diff options
Diffstat (limited to 'NET/worlds/scape/WebWallControlAction.java')
| -rw-r--r-- | NET/worlds/scape/WebWallControlAction.java | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/NET/worlds/scape/WebWallControlAction.java b/NET/worlds/scape/WebWallControlAction.java new file mode 100644 index 0000000..7420f51 --- /dev/null +++ b/NET/worlds/scape/WebWallControlAction.java @@ -0,0 +1,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; + } +} |