コード例 #1
0
  private void openedByBrowser(Item item, URL url) {
    if (url == null || item == null) {
      return;
    }

    WebBrowserEditorInput input = new WebBrowserEditorInput(url);
    // add for bug TDI-21189 at 2012-6-8,that a document exist is only opened one time in studio
    try {
      IWorkbenchPage page = getActivePage();
      IEditorReference[] iEditorReference = page.getEditorReferences();
      for (IEditorReference editors : iEditorReference) {
        if (WebBrowserEditor.WEB_BROWSER_EDITOR_ID.equals(editors.getId())) {
          IEditorPart iEditorPart = editors.getEditor(true);
          if (iEditorPart != null && iEditorPart instanceof WebBrowserEditor) {
            WebBrowserEditorInput webBrowserEditorInput =
                (WebBrowserEditorInput) iEditorPart.getEditorInput();
            if (webBrowserEditorInput != null && url.equals(webBrowserEditorInput.getURL())) {
              // page.activate(iEditorPart);
              iEditorPart.init(iEditorPart.getEditorSite(), webBrowserEditorInput);
              DocumentationUtil.setPartItemId(
                  (WebBrowserEditor) iEditorPart,
                  item.getProperty().getId(),
                  ERepositoryObjectType.getItemType(item));
              return;
            }
          }
        }
      }
      input.setName(item.getProperty().getLabel());
      input.setToolTipText(
          item.getProperty().getLabel() + " " + item.getProperty().getVersion()); // $NON-NLS-1$
      IEditorPart editorPart = page.openEditor(input, WebBrowserEditor.WEB_BROWSER_EDITOR_ID);
      if (editorPart != null && editorPart instanceof WebBrowserEditor) {
        DocumentationUtil.setPartItemId(
            (WebBrowserEditor) editorPart,
            item.getProperty().getId(),
            ERepositoryObjectType.getItemType(item));
      }
    } catch (PartInitException e) {
      MessageBoxExceptionHandler.process(e);
    }
  }