Example #1
0
 /**
  * Show something in the status line; this is used when we don't have easy access to the view for
  * getting the StatusLineManager.
  *
  * @param message
  * @param debugMessage
  */
 private void showStatusMessage(String message, String debugMessage) {
   if (false) {
     message += " - "; // $NON-NLS-1$
     message += debugMessage;
   }
   IWorkbenchWindow ww = CommonPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
   IWorkbenchPage page = ww.getActivePage();
   IViewReference[] viewRefs = page.getViewReferences();
   for (int j = 0; j < viewRefs.length; j++) {
     IViewReference reference = viewRefs[j];
     IViewPart vp = reference.getView(false);
     if (vp != null) {
       vp.getViewSite().getActionBars().getStatusLineManager().setMessage(message);
     }
   }
 }
Example #2
0
 /** Read preferences */
 protected void readPreferences() {
   Preferences pref = CommonPlugin.getDefault().getPluginPreferences();
   forceEcho = pref.getBoolean(IDs.P_ECHO_FORCE);
 }
Example #3
0
  /**
   * Do the "Run Analysis" on a resource (project, folder, or file). Descends to all child nodes,
   * collecting artifacts on each.
   */
  public void run() {
    if (traceOn) {
      System.out.println("RunAnalyseHandlerBase.run()..."); // $NON-NLS-1$
    }

    cancelledByUser = false;
    err = false;
    cumulativeArtifacts = 0;
    readPreferences();

    final int indent = 0;

    if ((selection == null) || selection.isEmpty()) {
      MessageDialog.openWarning(
          null,
          Messages.RunAnalyseHandlerBase_no_files_selected,
          Messages.RunAnalyseHandlerBase_please_select);

      return;
    } else {
      // get preference for include paths
      final List<String> includes = getIncludePath();
      if (areIncludePathsNeeded() && includes.isEmpty()) {
        // System.out.println("RunAnalyseHandlerBase.run(), no include paths found.");
        MessageDialog.openWarning(
            shell,
            name + Messages.RunAnalyseHandlerBase_include_paths_not_found,
            Messages.RunAnalyseHandlerBase_please_first_specify
                + name
                + Messages.RunAnalyseHandlerBase_incl_paths_in_pref_page);

      } else {

        // batch ws modifications *and* report progress
        WorkspaceModifyOperation wmo =
            new WorkspaceModifyOperation() {
              @Override
              protected void execute(IProgressMonitor monitor)
                  throws CoreException, InvocationTargetException, InterruptedException {
                err = runResources(monitor, indent, includes);
              }
            };
        ProgressMonitorDialog pmdialog = new ProgressMonitorDialog(shell);
        try {
          pmdialog.run(true, true, wmo); // fork=true; if false, not
          // cancelable

        } catch (InvocationTargetException e) {
          err = true;
          Throwable cause = e.getCause();
          System.out.println(
              "Error running analysis: ITE: " //$NON-NLS-1$
                  + e.getMessage());
          System.out.println(
              "  cause: "
                  + cause
                  + " - " //$NON-NLS-1$ //$NON-NLS-2$
                  + cause.getMessage());

          cause.printStackTrace();
        } catch (InterruptedException e) {
          cancelledByUser = true;
        }
      } // end else
    }
    if (traceOn) {
      System.out.println(
          "RunAnalyseBase: retd from run iterator, err=" //$NON-NLS-1$
              + err);
    }
    String artsFound =
        "\nNumber of "
            + name
            + " Artifacts found: " //$NON-NLS-1$ //$NON-NLS-2$
            + cumulativeArtifacts;
    if (cancelledByUser) {
      MessageDialog.openInformation(
          null,
          Messages.RunAnalyseHandlerBase_partial_analysis_complete,
          Messages.RunAnalyseHandlerBase_15 + artsFound);
    } else {
      String msg = Messages.RunAnalyseHandlerBase_cancelled_by_user;
      if (!err) {
        String key = IDs.SHOW_ANALYSIS_CONFIRMATION;
        IPreferenceStore pf = CommonPlugin.getDefault().getPreferenceStore();
        boolean showDialog = pf.getBoolean(IDs.SHOW_ANALYSIS_CONFIRMATION);
        if (showDialog) {
          String title = Messages.RunAnalyseHandlerBase_analysis_complete;
          StringBuffer sMsg =
              new StringBuffer(
                  cumulativeArtifacts
                      + " "
                      + name //$NON-NLS-1$
                      + Messages.RunAnalyseHandlerBase_artifacts_found);
          // provide some explanation of why perhaps no artifacts were
          // found.
          // Note: should this perhaps be in a "Details" section of
          // the dialog?
          if (cumulativeArtifacts == 0) {
            // Unless "Recognize artifacts by prefix alone" is set in the preferences (this is the
            // default),
            // this could be a problem with the include file for this API.
            sMsg.append(Messages.RunAnalyseHandlerBase_notfound_0)
                .append(name)
                .append(Messages.RunAnalyseHandlerBase_notfound_1);
            sMsg.append(name).append(Messages.RunAnalyseHandlerBase_notfound_2);
            sMsg.append(Messages.RunAnalyseHandlerBase_notfound_3);
          }
          String togMsg = Messages.RunAnalyseHandlerBase_dont_show_this_again;
          MessageDialogWithToggle.openInformation(
              shell, title, sMsg.toString(), togMsg, false, pf, key);
          showStatusMessage(sMsg.toString(), "RunAnalyseBase.run()"); // $NON-NLS-1$
        }
        activateProblemsView();
        activateArtifactView();
      } else { // error occurred
        showStatusMessage(msg, "RunAnalyseBase.run() error"); // $NON-NLS-1$
        msg = Messages.RunAnalyseHandlerBase_27;
        MessageDialog.openError(null, Messages.RunAnalyseHandlerBase_28, msg + artsFound);
      }
    }
  }