コード例 #1
0
  protected IWebBrowser doCreateBrowser(int style, String browserId, String name, String tooltip)
      throws PartInitException {

    // external browser is not required by called or user
    if (((style & AS_EXTERNAL) == 0)
        && (WebBrowserPreference.getBrowserChoice() == WebBrowserPreference.INTERNAL)) {
      return new InternalWebBrowser(this, browserId);
    }

    IWebBrowser webBrowser = null;

    // AS_EXTERNAL will force the external browser regardless of the user
    // preference
    // The help editor will open in an editor regardless of the user
    // preferences
    boolean isHelpEditor = ((style & AS_EDITOR) != 0) && HELP_BROWSER_ID.equals(browserId);
    if ((style & AS_EXTERNAL) != 0
        || (WebBrowserPreference.getBrowserChoice() != WebBrowserPreference.INTERNAL
            && !isHelpEditor)
        || !WebBrowserUtil.canUseInternalWebBrowser()) {
      IBrowserDescriptor ewb = BrowserManager.getInstance().getCurrentWebBrowser();
      if (ewb == null) throw new PartInitException("Error No Browser detected");

      if (ewb instanceof SystemBrowserDescriptor) webBrowser = new SystemBrowserInstance(browserId);
      else {
        IBrowserExt ext = null;
        if (ewb != null) ext = WebBrowserUIPlugin.findBrowsers(getLocation(ewb));
        if (ext != null)
          webBrowser = ext.createBrowser(browserId, getLocation(ewb), ewb.getParameters());
        if (webBrowser == null) webBrowser = new ExternalBrowserInstance(browserId, ewb);
      }
    } else {
      if ((style & IWorkbenchBrowserSupport.AS_VIEW) != 0)
        webBrowser = new InternalBrowserViewInstance(browserId, style, name, tooltip);
      else webBrowser = new InternalBrowserEditorInstance(browserId, style, name, tooltip);
    }

    return webBrowser;
  }
コード例 #2
0
 @SuppressWarnings("unchecked")
 private static List<IBrowserDescriptor> getBrowsers() {
   return BrowserManager.getInstance().getWebBrowsers();
 }