コード例 #1
0
  public static void main(String[] args) {
    Assert.setEnabled(true);

    Log.setApplicationName("WindowControlImpl");
    Log.setApplicationVersion("0.0");
    Log.setApplicationVersionDate(
        "$Id: WindowControlImpl.java,v 1.1 2001/07/27 21:01:12 ashuk%eng.sun.com Exp $");

    try {
      org.mozilla.webclient.BrowserControlFactory.setAppData("nonnative", args[0]);
      org.mozilla.webclient.BrowserControl control =
          org.mozilla.webclient.BrowserControlFactory.newBrowserControl();
      Assert.assert_it(control != null);

      WindowControl wc =
          (WindowControl)
              control.queryInterface(org.mozilla.webclient.BrowserControl.WINDOW_CONTROL_NAME);
      Assert.assert_it(wc != null);
    } catch (Exception e) {
      System.out.println("got exception: " + e.getMessage());
    }
  }
コード例 #2
0
/** @author edburns */
abstract class NativeBrowserControlCanvas extends BrowserControlCanvas {

  public static final String LOG =
      "org.mozilla.webclient.impl.wrapper_native.NativeBrowserControlCanvas";

  public static final Logger LOGGER = Log.getLogger(LOG);

  protected int nativeWindow = 0;

  /** Creates a new instance of NativeBrowserControlCanvas */
  public NativeBrowserControlCanvas() {}

  public void addNotify() {
    super.addNotify();

    if (0 == nativeWindow) {
      synchronized (getTreeLock()) {
        // Create the Native window and it's container and
        // get a handle to this widget
        nativeWindow = getWindow();
      }
    } else {
      return;
    }

    try {
      synchronized (getTreeLock()) {
        createNativeBrowser();
        initializeOK = true;
      }
    } catch (IllegalStateException ise) {
      if (LOGGER.isLoggable(Level.SEVERE)) {
        LOGGER.log(Level.SEVERE, "Exception while creating native browser", ise);
      }
      throw ise;
    }
  }

  /** Create the Native window and get it's handle */
  protected abstract int getWindow();

  /** Allow platform specific handling of new window creation. */
  abstract void performPlatformAppropriateNewWindowRealization(NewWindowEvent event);

  private void createNativeBrowser() throws IllegalStateException {
    try {
      Rectangle r = new Rectangle(getBoundsRelativeToWindow());
      Assert.assert_it(null != webShell);

      WindowControl wc =
          (WindowControl) webShell.queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
      // This createWindow call sets in motion the creation of the
      // nativeInitContext and the creation of the Mozilla embedded
      // webBrowser
      wc.createWindow(nativeWindow, r);
    } catch (IllegalStateException ise) {
      if (LOGGER.isLoggable(Level.SEVERE)) {
        LOGGER.log(Level.SEVERE, "Exception while creating native browser", ise);
      }
      throw ise;
    } catch (Exception e) {
      if (LOGGER.isLoggable(Level.SEVERE)) {
        LOGGER.log(Level.SEVERE, "Exception while creating native browser", e);
      }
      throw new IllegalStateException(null != e.getCause() ? e.getCause() : e);
    }
    return;
  }
}