diff options
| author | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
| commit | e1e781bb2135ef78592226f1a3eaba4925702f1f (patch) | |
| tree | 8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/console/URLLine.java | |
| download | worlds.jar-main.tar.xz worlds.jar-main.zip | |
Diffstat (limited to 'NET/worlds/console/URLLine.java')
| -rw-r--r-- | NET/worlds/console/URLLine.java | 311 |
1 files changed, 311 insertions, 0 deletions
diff --git a/NET/worlds/console/URLLine.java b/NET/worlds/console/URLLine.java new file mode 100644 index 0000000..f2c354d --- /dev/null +++ b/NET/worlds/console/URLLine.java @@ -0,0 +1,311 @@ +/* */ package NET.worlds.console; +/* */ +/* */ import NET.worlds.scape.FrameEvent; +/* */ import NET.worlds.scape.Pilot; +/* */ import NET.worlds.scape.TeleportAction; +/* */ import NET.worlds.scape.TeleportStatus; +/* */ import java.awt.Container; +/* */ import java.awt.Event; +/* */ import java.awt.Label; +/* */ import java.awt.Menu; +/* */ import java.awt.MenuBar; +/* */ import java.awt.TextField; +/* */ import java.util.Vector; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class URLLine +/* */ extends TextField +/* */ implements FramePart, TeleportStatus, DialogDisabled +/* */ { +/* */ private static final long serialVersionUID = -4154943921462354673L; +/* 46 */ protected static String nonloadSign = "URL: "; +/* 47 */ public Label label = new Label(nonloadSign); +/* */ +/* */ +/* */ +/* */ +/* */ public Menu historyMenu; +/* */ +/* */ +/* */ +/* */ +/* 57 */ public boolean beingEdited = false; +/* 58 */ public String lastTextSet = ""; +/* */ +/* */ +/* */ +/* */ +/* 63 */ private String currentText = ""; +/* */ +/* */ private boolean okToCallGetText; +/* */ +/* */ private boolean isDialogDisabled; +/* */ +/* */ protected boolean teleporting; +/* */ protected int lastURLUpdate; +/* */ +/* */ public synchronized String getText() +/* */ { +/* 74 */ if (this.okToCallGetText) { +/* 75 */ return super.getText(); +/* */ } +/* 77 */ return this.currentText; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ private synchronized void syncCurrentText() +/* */ { +/* 86 */ this.okToCallGetText = true; +/* 87 */ this.currentText = getText(); +/* 88 */ this.okToCallGetText = false; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public synchronized void setText(String s) +/* */ { +/* 97 */ if (!this.beingEdited) +/* */ { +/* 99 */ if (!this.currentText.equals(this.lastTextSet)) { +/* 100 */ this.beingEdited = true; +/* */ } else { +/* 102 */ this.lastTextSet = s; +/* */ +/* 104 */ if (!this.currentText.equals(s)) { +/* 105 */ int p = getSelectionStart(); +/* 106 */ super.setText(this.currentText = s); +/* 107 */ select(p, p); +/* */ } +/* */ } +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ public void cancelEdit() +/* */ { +/* 117 */ this.beingEdited = false; +/* 118 */ this.lastTextSet = getText(); +/* */ +/* */ +/* 121 */ select(1000, 1000); +/* */ +/* */ +/* 124 */ this.lastURLUpdate = 0; +/* */ } +/* */ +/* */ @Deprecated +/* */ public boolean keyDown(Event event, int key) { +/* 129 */ if (key != 27) { +/* 130 */ return super.keyDown(event, key); +/* */ } +/* */ +/* 133 */ cancelEdit(); +/* 134 */ return true; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public void activate(Console c, Container f, Console prev) +/* */ { +/* 142 */ this.historyMenu = new Menu("History"); +/* 143 */ copyBackupToHistoryMenu(); +/* */ +/* */ +/* */ +/* */ +/* 148 */ Console.getMenuBar().add(this.historyMenu); +/* */ } +/* */ +/* */ +/* */ +/* */ public void deactivate() {} +/* */ +/* */ +/* */ +/* */ public void dialogDisable(boolean disable) +/* */ { +/* 159 */ this.isDialogDisabled = disable; +/* */ } +/* */ +/* */ @Deprecated +/* */ public boolean handleEvent(Event event) { +/* 164 */ if (this.isDialogDisabled) { +/* 165 */ return false; +/* */ } +/* 167 */ boolean ret = super.handleEvent(event); +/* */ +/* */ +/* */ +/* */ +/* 172 */ if (event.target == this) +/* 173 */ syncCurrentText(); +/* 174 */ return ret; +/* */ } +/* */ +/* */ @Deprecated +/* */ public boolean action(Event event, Object what) { +/* 179 */ if (event.target == this) { +/* 180 */ what = getText(); +/* */ +/* */ +/* */ +/* */ } +/* */ else +/* */ { +/* */ +/* */ +/* */ +/* 190 */ return true; +/* */ } +/* */ +/* 193 */ if (((String)what).length() != 0) { +/* 194 */ TeleportAction.teleport((String)what, null); +/* 195 */ cancelEdit(); +/* */ } +/* 197 */ return true; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void teleportStatus(String err, String url) +/* */ { +/* 206 */ this.teleporting = ((err != null) && (err.length() == 0)); +/* */ +/* */ +/* */ +/* */ +/* */ +/* 212 */ if (err == null) { +/* 213 */ addHistoryItem(getCurrentPositionURL()); +/* 214 */ setText(url); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public boolean handle(FrameEvent f) +/* */ { +/* 230 */ if (f.time < this.lastURLUpdate + 500) { +/* 231 */ return true; +/* */ } +/* 233 */ this.lastURLUpdate = f.time; +/* */ +/* 235 */ setText(getCurrentPositionURL()); +/* */ +/* 237 */ if (this.teleporting) +/* */ { +/* 239 */ if (this.label.getText().equals("LOAD ")) { +/* 240 */ this.label.setText("_____ "); +/* */ } else { +/* 242 */ this.label.setText("LOAD "); +/* */ } +/* 244 */ } else if (!this.label.getText().equals(nonloadSign)) { +/* 245 */ this.label.setText(nonloadSign); +/* */ } +/* 247 */ return true; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public static String getCurrentPositionURL() +/* */ { +/* 256 */ Pilot pilot = Pilot.getActive(); +/* 257 */ if (pilot == null) { +/* 258 */ return ""; +/* */ } +/* 260 */ String newURL = pilot.getURL(); +/* 261 */ if (newURL == null) { +/* 262 */ return ""; +/* */ } +/* 264 */ return newURL; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* 271 */ public static Vector<String> historyItems = new Vector(); +/* */ +/* */ +/* */ +/* */ +/* */ private void addHistoryItem(String url) +/* */ { +/* 278 */ if (url.length() == 0) { +/* 279 */ return; +/* */ } +/* 281 */ historyItems.insertElementAt(url, 0); +/* 282 */ int cnt = historyItems.size(); +/* 283 */ while (cnt > 10) { +/* 284 */ historyItems.removeElementAt(--cnt); +/* */ } +/* 286 */ copyBackupToHistoryMenu(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ private void copyBackupToHistoryMenu() +/* */ { +/* 294 */ while (this.historyMenu.getItemCount() > 0) { +/* 295 */ this.historyMenu.remove(0); +/* */ } +/* 297 */ int cnt = historyItems.size(); +/* 298 */ if (cnt == 0) { +/* 299 */ this.historyMenu.add(""); +/* */ } +/* 301 */ for (int i = 0; i < cnt; i++) { +/* 302 */ this.historyMenu.add((String)historyItems.elementAt(i)); +/* */ } +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\URLLine.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |