1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
package NET.worlds.scape;
import java.io.IOException;
public class WebWallControlAction extends Action {
private final int reload = 1;
private final int setURL = 2;
private final int refresh = 3;
private final int back = 4;
private final int forward = 5;
private final int stop = 6;
private final int home = 7;
private int mode = 1;
private String url;
private String postData;
private WebPageWall webWall = null;
private static Object classCookie = new Object();
WebWallControlAction() {
this.postData = null;
this.url = "http://www.worlds.com/";
}
@Override
public Persister trigger(Event e, Persister seqID) {
if (!this.getWebWall()) {
System.out.println("ERROR! Tried to attach WebWallControlAction to something other than a WebWall object.");
return null;
} else {
switch (this.mode) {
case 1:
this.webWall.rebuild();
break;
case 2:
this.webWall.getWebControlImp().setURL(this.url, this.postData);
break;
case 3:
this.webWall.getWebControlImp().refresh();
break;
case 4:
this.webWall.getWebControlImp().goBack();
break;
case 5:
this.webWall.getWebControlImp().goForward();
break;
case 6:
this.webWall.getWebControlImp().stop();
break;
case 7:
this.webWall.getWebControlImp().home();
}
return null;
}
}
private boolean getWebWall() {
if (this.webWall != null) {
return true;
} else {
Object owner = this.getOwner();
if (owner != null && owner instanceof WebPageWall) {
this.webWall = (WebPageWall)owner;
return this.webWall == null ? false : this.webWall.getWebControlImp() != null;
} else {
return false;
}
}
}
@Override
public void saveState(Saver s) throws IOException {
s.saveVersion(0, classCookie);
super.saveState(s);
s.saveInt(this.mode);
s.saveString(this.url);
s.saveString(this.postData);
}
@Override
public void restoreState(Restorer r) throws IOException, TooNewException {
switch (r.restoreVersion(classCookie)) {
case 0:
super.restoreState(r);
this.mode = r.restoreInt();
this.url = r.restoreString();
this.postData = r.restoreString();
}
}
@Override
public Object properties(int index, int offset, int pmode, Object value) throws NoSuchPropertyException {
Object ret = null;
switch (index - offset) {
case 0:
if (pmode == 0) {
ret = IntegerPropertyEditor.make(new Property(this, index, "1=Reload, 2=SetURL, 3=Refresh, 4=Back, 5=Fwd, 6=Stop, 7=Home"));
} else if (pmode == 1) {
ret = new Integer(this.mode);
} else if (pmode == 2) {
this.mode = (Integer)value;
}
break;
case 1:
if (pmode == 0) {
ret = StringPropertyEditor.make(new Property(this, index, "URL for mode 2"));
} else if (pmode == 1) {
ret = this.url;
} else if (pmode == 2) {
this.url = ((String)value).trim();
}
break;
case 2:
if (pmode == 0) {
ret = StringPropertyEditor.make(new Property(this, index, "POST data for mode 2"));
} else if (pmode == 1) {
ret = this.postData;
} else if (pmode == 2) {
this.postData = ((String)value).trim();
}
break;
default:
ret = super.properties(index, offset + 3, pmode, value);
}
return ret;
}
}
|