コード例 #1
0
 @Override
 public void open() {
   try {
     DartUI.openInEditor(element);
   } catch (Throwable e) {
     DartToolsPlugin.log(e);
   }
 }
コード例 #2
0
 private void gotoSelectedElement() {
   Object selectedElement = getSelectedElement();
   if (selectedElement instanceof com.google.dart.engine.element.Element) {
     try {
       DartUI.openInEditor((com.google.dart.engine.element.Element) selectedElement);
     } catch (CoreException ex) {
       DartToolsPlugin.log(ex);
     }
     dispose();
   }
   if (selectedElement instanceof com.google.dart.server.generated.types.Element) {
     try {
       DartUI.openInEditor((com.google.dart.server.generated.types.Element) selectedElement, true);
     } catch (Exception ex) {
       DartToolsPlugin.log(ex);
     }
     dispose();
   }
 }
コード例 #3
0
 @Override
 public void run(IMarker marker) {
   try {
     IEditorPart part = EditorUtility.isOpenInEditor(unit);
     if (part == null) {
       part = DartUI.openInEditor(unit, true, false);
       if (part instanceof ITextEditor) {
         ((ITextEditor) part).selectAndReveal(offset, length);
       }
     }
     if (part != null) {
       IEditorInput input = part.getEditorInput();
       IDocument doc = getDocumentProvider().getDocument(input);
       proposal.apply(doc);
     }
   } catch (CoreException e) {
     DartToolsPlugin.log(e);
   }
 }
コード例 #4
0
  /**
   * Opens a type selection dialog. If the user selects a type (and does not cancel), an editor is
   * opened on the selected type.
   *
   * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event)
   */
  @Override
  public void runWithEvent(Event e) {
    Shell parent = DartToolsPlugin.getActiveWorkbenchShell();
    if (!doCreateProjectFirstOnEmptyWorkspace(parent)) {
      return;
    }

    SelectionDialog dialog =
        new OpenTypeSelectionDialog(
            parent,
            true,
            PlatformUI.getWorkbench().getProgressService(),
            null,
            SEARCH_ELEMENT_KINDS);
    dialog.setTitle(DartUIMessages.OpenTypeAction_dialogTitle);
    dialog.setMessage(DartUIMessages.OpenTypeAction_dialogMessage);

    int result = dialog.open();
    if (result != IDialogConstants.OK_ID) {
      return;
    }

    Object[] types = dialog.getResult();
    if (types == null || types.length == 0) {
      return;
    }

    if (types.length == 1) {
      try {
        DartUI.openInEditor((Element) types[0], true, true);
      } catch (CoreException x) {
        ExceptionHandler.handle(
            x,
            DartUIMessages.OpenTypeAction_errorTitle,
            DartUIMessages.OpenTypeAction_errorMessage);
      }
      return;
    }

    final IWorkbenchPage workbenchPage = DartToolsPlugin.getActivePage();
    if (workbenchPage == null) {
      IStatus status =
          new Status(
              IStatus.ERROR,
              DartToolsPlugin.getPluginId(),
              DartUIMessages.OpenTypeAction_no_active_WorkbenchPage);
      ExceptionHandler.handle(
          status,
          DartUIMessages.OpenTypeAction_errorTitle,
          DartUIMessages.OpenTypeAction_errorMessage);
      return;
    }

    MultiStatus multiStatus =
        new MultiStatus(
            DartToolsPlugin.getPluginId(),
            DartStatusConstants.INTERNAL_ERROR,
            DartUIMessages.OpenTypeAction_multiStatusMessage,
            null);

    for (int i = 0; i < types.length; i++) {
      Type type = (Type) types[i];
      try {
        DartUI.openInEditor(type, true, true);
      } catch (CoreException x) {
        multiStatus.merge(x.getStatus());
      }
    }

    if (!multiStatus.isOK()) {
      ExceptionHandler.handle(
          multiStatus,
          DartUIMessages.OpenTypeAction_errorTitle,
          DartUIMessages.OpenTypeAction_errorMessage);
    }
  }