/* */ package NET.worlds.console; /* */ /* */ import NET.worlds.core.IniFile; /* */ import java.awt.Dimension; /* */ import java.awt.Point; /* */ import java.awt.Rectangle; /* */ import java.io.IOException; /* */ import java.util.Enumeration; /* */ import java.util.Stack; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class WebBrowser /* */ { /* 80 */ private static Stack browsers = new Stack(); /* */ /* */ /* 83 */ private static boolean disabled = IniFile.gamma().getIniInt("DISABLEIE", 0) != 0; /* */ /* */ /* */ /* */ /* */ private static boolean everWorked; /* */ /* */ /* */ /* */ /* */ private int nativeBrowserPointer; /* */ /* */ /* */ /* */ /* */ private InternetExplorer _activeX; /* */ /* */ /* */ /* */ /* */ /* */ public static WebBrowser reuseOrMake(String url, String postData) /* */ throws IOException /* */ { /* 107 */ return reuseOrMake(url, postData, defaultPlacement()); /* */ } /* */ /* */ /* */ /* */ /* 113 */ private static boolean toolbarON = true; /* */ /* */ public static void useToolbar() { /* 116 */ toolbarON = true; /* */ } /* */ /* */ public static void dontUseToolbar() { /* 120 */ toolbarON = false; /* */ } /* */ /* */ /* */ /* */ /* */ /* 127 */ private static boolean windowFrameON = true; /* */ /* */ public static void useWindowFrame() { /* 130 */ windowFrameON = true; /* */ } /* */ /* */ public static void dontUseWindowFrame() { /* 134 */ windowFrameON = false; /* */ } /* */ /* */ /* */ /* */ /* 140 */ private static boolean _stayMinimized = false; /* */ /* */ public static void forceMinimized(boolean force) { /* 143 */ _stayMinimized = force; /* */ } /* */ /* */ /* */ /* */ public static WebBrowser findTag(String tag) /* */ { /* 150 */ for (Enumeration e = browsers.elements(); e.hasMoreElements();) { /* 151 */ WebBrowser browser = (WebBrowser)e.nextElement(); /* 152 */ if (tag != null) { /* 153 */ if (tag.equals(browser.getTag())) { /* 154 */ return browser; /* */ } /* */ } /* 157 */ else if (browser.getTag() == null) { /* 158 */ return browser; /* */ } /* */ } /* 161 */ return null; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static WebBrowser reuseOrMake(String url, String postData, Rectangle placement) /* */ throws IOException /* */ { /* 173 */ for (Enumeration e = browsers.elements(); e.hasMoreElements();) { /* 174 */ WebBrowser browser = (WebBrowser)e.nextElement(); /* */ /* 176 */ if (browser.getTag() == null) { /* */ try { /* 178 */ browser.browse(url, postData, null); /* 179 */ return browser; /* */ } /* */ catch (IOException localIOException) {} /* */ } /* */ } /* */ /* */ /* */ /* 187 */ return new WebBrowser(url, postData, placement); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 196 */ private String browserTag = null; /* */ /* */ private String getTag() { /* 199 */ return this.browserTag; /* */ } /* */ /* */ /* */ /* */ /* */ public static WebBrowser reuseOrMake(String url, String postData, Rectangle placement, String tag) /* */ throws IOException /* */ { /* 208 */ for (Enumeration e = browsers.elements(); e.hasMoreElements();) { /* 209 */ WebBrowser browser = (WebBrowser)e.nextElement(); /* */ /* 211 */ if (tag.equals(browser.getTag())) { /* */ try { /* 213 */ browser.browse(url, postData, null); /* 214 */ return browser; /* */ } /* */ catch (IOException localIOException) {} /* */ } /* */ } /* */ /* */ /* */ /* */ /* 223 */ return new WebBrowser(url, postData, placement, tag); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public static Rectangle defaultPlacement() /* */ { /* 232 */ Console c = Console.getActive(); /* 233 */ if ((c instanceof DefaultConsole)) /* 234 */ return ((DefaultConsole)c).getBrowserPlacement(); /* 235 */ return new Rectangle(0, 0, 200, 200); /* */ } /* */ /* */ public static boolean isDisabled() /* */ { /* 240 */ return disabled; /* */ } /* */ /* */ public static void setDisabled(boolean be) /* */ { /* 245 */ IniFile.gamma().setIniInt("DISABLEIE", be ? 1 : 0); /* 246 */ disabled = be; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public WebBrowser(String url, String postData) /* */ throws IOException /* */ { /* 256 */ this(url, postData, defaultPlacement()); /* */ } /* */ /* */ public WebBrowser(String url, String postData, Rectangle placement) throws IOException /* */ { /* 261 */ this(url, postData, placement, null); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public WebBrowser(String url, String postData, Rectangle placement, String tag) /* */ throws IOException /* */ { /* 271 */ if (!disabled) /* */ { /* */ /* 274 */ this._activeX = new InternetExplorer(this); /* */ try { /* 276 */ this.nativeBrowserPointer = openBrowser(); /* */ } /* */ catch (IOException ioe) /* */ { /* */ try { /* 281 */ this._activeX.Release(); /* */ } catch (OLEInvalidObjectException e) { /* 283 */ if (!$assertionsDisabled) throw new AssertionError(); /* */ } /* 285 */ this._activeX = null; /* */ /* */ /* */ /* */ /* 290 */ disabled = true; /* 291 */ throw ioe; /* */ } /* */ /* */ /* */ /* 296 */ browsers.push(this); /* */ /* */ /* */ /* 300 */ if (tag != null) { /* 301 */ this.browserTag = tag; /* */ } /* */ /* */ try /* */ { /* 306 */ browse(url, postData, placement); /* */ /* */ /* 309 */ everWorked = true; /* */ /* */ } /* */ catch (IOException ioe) /* */ { /* */ /* 315 */ if (!everWorked) /* 316 */ disabled = true; /* 317 */ throw ioe; /* */ } /* */ } else { /* 320 */ throw new IOException(); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void browse(String url, String postData, Rectangle placement) /* */ throws IOException /* */ { /* 334 */ if (this.nativeBrowserPointer != 0) { /* 335 */ int x = -1; /* 336 */ int y = -1; /* 337 */ int w = -1; /* 338 */ int h = -1; /* 339 */ if (placement != null) { /* 340 */ x = placement.x; /* 341 */ y = placement.y; /* 342 */ w = placement.width; /* 343 */ h = placement.height; /* */ } /* */ try { /* 346 */ browse(url, postData, x, y, w, h, this.nativeBrowserPointer); /* */ } catch (IOException ioe) { /* 348 */ close(); /* 349 */ throw ioe; /* */ } /* */ } else { /* 352 */ throw new IOException(); /* */ } /* */ } /* */ /* */ /* */ /* */ public void close() /* */ { /* 360 */ if (this.nativeBrowserPointer != 0) { /* 361 */ closeBrowser(this.nativeBrowserPointer); /* 362 */ this.nativeBrowserPointer = 0; /* */ try { /* 364 */ this._activeX.Release(); /* */ } catch (OLEInvalidObjectException e) { /* 366 */ if (!$assertionsDisabled) throw new AssertionError(); /* */ } /* 368 */ this._activeX = null; /* 369 */ browsers.removeElement(this); /* */ } /* */ } /* */ /* */ /* */ /* */ private static native void browse(String paramString1, String paramString2, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5) /* */ throws IOException; /* */ /* */ /* */ private static native int openBrowser() /* */ throws IOException; /* */ /* */ /* */ private static native void closeBrowser(int paramInt); /* */ /* */ /* */ public static Rectangle getMapPartPlacement() /* */ { /* 388 */ Rectangle placement = null; /* */ /* 390 */ Console c = Console.getActive(); /* 391 */ if (c != null) { /* 392 */ MapPart ap = null; /* 393 */ for (Enumeration e = c.getParts(); e.hasMoreElements();) { /* 394 */ Object o = e.nextElement(); /* 395 */ if ((o instanceof MapPart)) { /* 396 */ ap = (MapPart)o; /* 397 */ break; /* */ } /* */ } /* 400 */ if (ap != null) { /* 401 */ placement = new Rectangle(ap.getLocationOnScreen(), /* 402 */ ap.getSize()); /* 403 */ placement.grow(0, 10); /* 404 */ placement.translate(0, -9); /* */ } /* */ } /* 407 */ return placement; /* */ } /* */ /* */ /* */ /* */ /* */ public static Rectangle getAdPartPlacement() /* */ { /* 415 */ Rectangle placement = null; /* */ /* 417 */ Console c = Console.getActive(); /* 418 */ if (c != null) { /* 419 */ AdPart ap = null; /* 420 */ for (Enumeration e = c.getParts(); e.hasMoreElements();) { /* 421 */ Object o = e.nextElement(); /* 422 */ if ((o instanceof AdPart)) { /* 423 */ ap = (AdPart)o; /* 424 */ break; /* */ } /* */ } /* 427 */ if (ap != null) { /* 428 */ placement = new Rectangle(ap.getLocationOnScreen(), /* 429 */ ap.getSize()); /* 430 */ placement.grow(0, 10); /* 431 */ placement.translate(0, -9); /* */ } /* */ } /* 434 */ return placement; /* */ } /* */ /* */ /* */ /* */ /* */ public static Rectangle getRenderPartPlacement() /* */ { /* 442 */ Rectangle placement = null; /* */ /* 444 */ Console c = Console.getActive(); /* 445 */ if (c != null) { /* 446 */ RenderCanvas ap = null; /* 447 */ for (Enumeration e = c.getParts(); e.hasMoreElements();) { /* 448 */ Object o = e.nextElement(); /* 449 */ if ((o instanceof RenderCanvas)) { /* 450 */ ap = (RenderCanvas)o; /* 451 */ break; /* */ } /* */ } /* 454 */ if (ap != null) { /* 455 */ placement = new Rectangle(ap.getLocationOnScreen(), /* 456 */ ap.getSize()); /* 457 */ placement.grow(2, 10); /* 458 */ placement.translate(-1, 7); /* */ } /* */ } /* 461 */ return placement; /* */ } /* */ /* */ /* */ /* */ /* */ public static Rectangle getLeftRenderPartPlacement() /* */ { /* 469 */ Rectangle placement = null; /* */ /* 471 */ Console c = Console.getActive(); /* 472 */ if (c != null) { /* 473 */ RenderCanvas ap = null; /* 474 */ for (Enumeration e = c.getParts(); e.hasMoreElements();) { /* 475 */ Object o = e.nextElement(); /* 476 */ if ((o instanceof RenderCanvas)) { /* 477 */ ap = (RenderCanvas)o; /* 478 */ break; /* */ } /* */ } /* 481 */ if (ap != null) { /* 482 */ placement = new Rectangle(ap.getLocationOnScreen(), /* 483 */ ap.getSize()); /* */ /* 485 */ placement.grow(2, 10); /* 486 */ placement.translate(-1, 7); /* 487 */ Dimension d = placement.getSize(); /* 488 */ placement.setSize(d.width / 2, d.height); /* */ } /* */ } /* 491 */ return placement; /* */ } /* */ /* */ /* */ /* */ public static Rectangle getOutsidePlacement() /* */ { /* 498 */ Rectangle placement = null; /* */ /* 500 */ Console c = Console.getActive(); /* 501 */ if (c != null) { /* 502 */ RenderCanvas ap = null; /* 503 */ for (Enumeration e = c.getParts(); e.hasMoreElements();) { /* 504 */ Object o = e.nextElement(); /* 505 */ if ((o instanceof RenderCanvas)) { /* 506 */ ap = (RenderCanvas)o; /* 507 */ break; /* */ } /* */ } /* 510 */ if (ap != null) { /* 511 */ Point ploc = ap.getLocationOnScreen(); /* 512 */ Dimension d = new Dimension(250, 500); /* 513 */ Point bloc = new Point(0, ploc.y); /* */ /* 515 */ if (ploc.x > 254) { /* 516 */ ploc.x -= 254; /* */ } else { /* 518 */ bloc.x = 0; /* */ } /* */ /* 521 */ placement = new Rectangle(bloc, d); /* */ } /* */ } /* 524 */ return placement; /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\WebBrowser.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */