/* */ 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 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 */