/**
  * Constructs a PlatformWindowContextImpl. It starts out by showing a progress window. Later a new
  * browser window is obtained given the windowId, or created.
  *
  * @param openerFrame the opener frame
  * @param windowId the window id
  * @param properties the properties
  */
 public NavigatorWindowImpl(NavigatorFrame openerFrame, String windowId, Properties properties) {
   this.requestedProperties = properties;
   this.windowId = windowId;
   WindowFactory wf = windowFactory;
   if (wf == null) {
     throw new IllegalStateException("Global WindowFactory is null.");
   }
   AbstractBrowserWindow window = wf.getExistingWindow(windowId);
   FramePanel framePanel = null;
   if (window != null) {
     framePanel = window.getTopFramePanel();
     if (framePanel == null) {
       throw new IllegalStateException(
           "Window with ID " + windowId + " exists but its top frame is null.");
     }
   } else {
     framePanel =
         FramePanelFactorySource.getInstance().getActiveFactory().createFramePanel(windowId);
     framePanel.setOpenerFrame(openerFrame);
   }
   this.framePanel = framePanel;
   // Starts out as progress window.
   // We allow documents to override window properties, but
   // it can also be the case that such methods as alert() are
   // invoked while the document loads.
   if (window != null) {
     this.browserWindow = window;
     this.progressWindow = null;
     this.launched = true;
   } else {
     AbstractBrowserWindow newWindow = wf.createWindow(this.windowId, properties, this);
     this.browserWindow = newWindow;
     JFrame progressWindow = new ProgressWindow();
     this.progressWindow = progressWindow;
     // Pack to use preferred sizes
     progressWindow.pack();
     // Then resize
     progressWindow.setSize(new Dimension(400, progressWindow.getHeight()));
     progressWindow.setLocationByPlatform(true);
     progressWindow.setVisible(true);
     progressWindow.addWindowListener(
         new WindowAdapter() {
           @Override
           public void windowClosed(WindowEvent e) {
             if (!launched) {
               if (logger.isLoggable(Level.INFO)) {
                 logger.info(
                     "NavigatorWindowImpl(): Disposing browserWindow due to progress window getting closed.");
               }
               browserWindow.dispose();
             }
           }
         });
   }
 }
Ejemplo n.º 2
0
  /**
   * Constructs a <code>BrowserPanel</code> with optional menu bar, toolbars, an address bar and a
   * status bar.
   *
   * @param menuBar A <code>JMenuBar</code> instance presumably set on a JFrame.
   * @param hasAddressBar Whether the panel has an address bar.
   * @param hasToolBar Whether the panel has toolbars.
   * @param hasStatusBar Whether the panel has a status bar.
   */
  public BrowserPanel(
      final JMenuBar menuBar,
      final boolean hasAddressBar,
      final boolean hasToolBar,
      final boolean hasStatusBar) {
    this.hasToolBar = hasToolBar;
    // this.hasAddressBar = hasAddressBar;
    // this.hasStatusBar = hasStatusBar;
    this.menuBar = menuBar;

    final String windowId = "BrowserPanel." + System.identityHashCode(this);
    final FramePanel framePanel =
        FramePanelFactorySource.getInstance().getActiveFactory().createFramePanel(windowId);
    this.framePanel = framePanel;

    final Container contentPane = this;
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    if (hasAddressBar) {
      final AddressBarPanel abp = new AddressBarPanel();
      this.addressBarPanel = abp;
      contentPane.add(abp);
    } else {
      this.addressBarPanel = null;
    }
    if (hasToolBar) {
      final SharedToolBarPanel stbp = new SharedToolBarPanel();
      this.sharedToolBarPanel = stbp;
      contentPane.add(stbp);
    } else {
      this.sharedToolBarPanel = null;
    }
    contentPane.add(new FillerComponent(framePanel, false));
    if (hasStatusBar) {
      final StatusBarPanel statusBar = new StatusBarPanel();
      this.statusBarPanel = statusBar;
      contentPane.add(statusBar);
    } else {
      this.statusBarPanel = null;
    }
    ExtensionManager.getInstance().initExtensionsWindow(this);
  }