Exemplo n.º 1
0
  @Override
  public void doRun(ISelection selection, Event event, UIInstrumentationBuilder instrumentation) {
    instrumentation.metric("command", command);

    if (!(selection instanceof ITextSelection)) {
      instrumentation.metric("Problem", "Selection was not a TextSelection");
    }

    IWorkbenchPage page = DartToolsPlugin.getActivePage();
    if (page == null) {
      instrumentation.metric("Problem", "Page was null");
      return;
    }

    IEditorPart part = page.getActiveEditor();
    if (part == null) {
      instrumentation.metric("Problem", "Part was null");
      return;
    }

    IEditorInput editorInput = part.getEditorInput();
    IProject project = EditorUtility.getProject(editorInput);
    instrumentation.data("Project", project.getName());
    savePubspecFile(project);
    runPubJob(project);
  }
Exemplo n.º 2
0
  @Override
  public void doRun(
      IStructuredSelection selection, Event event, UIInstrumentationBuilder instrumentation) {

    instrumentation.metric("command", command);

    if (!selection.isEmpty() && selection.getFirstElement() instanceof IResource) {
      Object object = selection.getFirstElement();
      if (object instanceof IFile) {
        object = ((IFile) object).getParent();
      }
      while (object != null
          && ((IContainer) object).findMember(DartCore.PUBSPEC_FILE_NAME) == null) {
        object = ((IContainer) object).getParent();
      }
      if (object instanceof IContainer) {
        IContainer container = (IContainer) object;
        instrumentation.data("name", container.getName());
        savePubspecFile(container);
        runPubJob(container);
        return;
      } else {
        instrumentation.metric("Problem", "Object was null").log();
      }
    }

    instrumentation.metric("Problem", "pubspec.yaml file not selected, showing dialog");

    MessageDialog.openError(
        getShell(), ActionMessages.RunPubAction_fail, ActionMessages.RunPubAction_fileNotFound);

    instrumentation.log();
  }