예제 #1
0
  protected void runSootDirectly(String mainClass) {

    int length = getSootCommandList().getList().size();
    String temp[] = new String[length];

    getSootCommandList().getList().toArray(temp);

    sendSootOutputEvent(mainClass);
    sendSootOutputEvent(" ");

    final String[] cmdAsArray = temp;

    for (int i = 0; i < temp.length; i++) {

      sendSootOutputEvent(temp[i]);
      sendSootOutputEvent(" ");
    }
    sendSootOutputEvent("\n");

    IRunnableWithProgress op;
    try {
      newProcessStarting();
      op = new SootRunner(temp, Display.getCurrent(), mainClass);
      ((SootRunner) op).setParent(this);
      ModalContext.run(op, true, new NullProgressMonitor(), Display.getCurrent());
    } catch (InvocationTargetException e1) {
      // handle exception
      System.out.println("InvocationTargetException: " + e1.getMessage());
      System.out.println("InvocationTargetException: " + e1.getTargetException());
      System.out.println(e1.getStackTrace());
    } catch (InterruptedException e2) {
      // handle cancelation
      System.out.println("InterruptedException: " + e2.getMessage());
    }
  }
  /* (non-Javadoc)
   * Method declared on IRunnableContext
   */
  public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
      throws InvocationTargetException, InterruptedException {
    if (fProgressMonitorPart == null) {
      ModalContext.run(runnable, false, new NullProgressMonitor(), getShell().getDisplay());
    } else {
      Object state = null;
      if (fActiveRunningOperations == 0) state = aboutToStart(fork && cancelable);

      fActiveRunningOperations++;
      try {
        ModalContext.run(runnable, fork, fProgressMonitorPart, getShell().getDisplay());
      } finally {
        fActiveRunningOperations--;
        // Stop if this is the last one
        if (state != null) stopped(state);
      }
    }
  }
예제 #3
0
 @Override
 public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
     throws InvocationTargetException, InterruptedException {
   ModalContext.run(runnable, fork, monitor, getDisplay());
 }
  private boolean login(boolean test) {
    final String username = usernameText.getText();
    final String password = passwordText.getText();
    if (StringUtil.isEmpty(username)) {
      if (test) {
        MessageDialog.openError(
            main.getShell(),
            Messages.JiraPreferencePageProvider_ERR_InvalidInput_Title,
            Messages.JiraPreferencePageProvider_ERR_EmptyUsername);
        return false;
      }
      return true;
    }
    if (StringUtil.isEmpty(password)) {
      if (test) {
        MessageDialog.openError(
            main.getShell(),
            Messages.JiraPreferencePageProvider_ERR_InvalidInput_Title,
            Messages.JiraPreferencePageProvider_ERR_EmptyPassword);
        return false;
      }
      return true;
    }

    setUILocked(true);
    firePreValidationStartEvent();
    try {
      ModalContext.run(
          new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor)
                throws InvocationTargetException, InterruptedException {
              monitor.beginTask(
                  Messages.JiraPreferencePageProvider_ValidateCredentials,
                  IProgressMonitor.UNKNOWN);
              try {
                IStatus status = getJiraManager().login(username, password);
                if (status.isOK()) {
                  // successful; now re-layout to show the logout components
                  UIUtils.getDisplay()
                      .asyncExec(
                          new Runnable() {

                            public void run() {
                              updateUserText();
                              layout();
                            }
                          });
                } else {
                  throw new InvocationTargetException(new CoreException(status));
                }
              } finally {
                if (!monitor.isCanceled()) {
                  monitor.done();
                }
              }
            }
          },
          true,
          getProgressMonitor(),
          UIUtils.getDisplay());
    } catch (InvocationTargetException e) {
      if (main != null && !main.isDisposed()) {
        MessageDialog.openError(
            main.getShell(),
            Messages.JiraPreferencePageProvider_ERR_LoginFailed_Title,
            e.getTargetException().getMessage());
      }
      return false;
    } catch (Exception e) {
      IdeLog.logError(JiraUIPlugin.getDefault(), e);
    } finally {
      setUILocked(false);
      firePostValidationEndEvent();
    }

    return true;
  }