コード例 #1
0
  @Override
  public List<Object> computeContext(
      IInteractionContext context, IAdaptable input, IProgressMonitor monitor) {
    if (delegates == null || delegates.isEmpty()) {
      return Collections.emptyList();
    }
    List<Object> objects = new ArrayList<Object>();

    SubMonitor progress = SubMonitor.convert(monitor);
    int workPerDelegate = 1000;
    progress.beginTask(
        Messages.CompoundContextComputationStrategy_Computing_Context_Task_Label,
        delegates.size() * workPerDelegate);
    try {
      for (ContextComputationStrategy delegate : delegates) {
        if (progress.isCanceled()) {
          break;
        }
        objects.addAll(delegate.computeContext(context, input, progress.newChild(workPerDelegate)));
      }
    } finally {
      progress.done();
    }

    return objects;
  }
コード例 #2
0
  private IStatus rebuildIndexCompletely(SubMonitor monitor)
      throws CorruptIndexException, LockObtainFailedException, IOException, CoreException {

    MultiStatus multiStatus = new MultiStatus(TasksIndexCore.ID_PLUGIN, 0, null, null);

    // get indexable tasks from the task list
    final TaskListState taskListState = new TaskListState();
    taskList.run(taskListState, monitor.newChild(0));

    monitor.beginTask(
        Messages.TaskListIndex_task_rebuilding_index, taskListState.indexableTasks.size());
    try {
      IndexWriter writer;
      try {
        writer = createIndexWriter(true);
      } catch (CorruptIndexException e) {
        if (directory instanceof FSDirectory) {
          cleanDirectory(((FSDirectory) directory).getFile());
          writer = createIndexWriter(true);
        } else {
          throw e;
        }
      }
      try {

        for (ITask task : taskListState.indexableTasks) {
          if (taskIsIndexable(task, null)) {
            try {
              TaskData taskData = dataManager.getTaskData(task);
              add(writer, task, taskData);
            } catch (CoreException e) {
              // an individual task data error should not prevent the index from updating
              multiStatus.add(e.getStatus());
            }
          }
          monitor.worked(1);
        }
        synchronized (this) {
          rebuildIndex = false;
        }
      } finally {
        writer.close();
      }
    } finally {
      monitor.done();
    }
    return multiStatus;
  }
コード例 #3
0
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.core.resources.IWorkspaceRunnable#run(org.eclipse.core.runtime.IProgressMonitor)
   */
  public void run(IProgressMonitor monitor) throws CoreException {
    SubMonitor subMonitor = SubMonitor.convert(monitor, 1000);
    subMonitor.beginTask("Generating MyBatis/iBATIS Artifacts:", 1000);

    setClassLoader();

    try {
      subMonitor.subTask("Parsing Configuration");

      ConfigurationParser cp = new ConfigurationParser(warnings);
      Configuration config = cp.parseConfiguration(inputFile.getLocation().toFile());

      subMonitor.worked(50);

      MyBatisGenerator mybatisGenerator =
          new MyBatisGenerator(config, new EclipseShellCallback(), warnings);
      monitor.subTask("Generating Files from Database Tables");
      SubMonitor spm = subMonitor.newChild(950);
      mybatisGenerator.generate(new EclipseProgressCallback(spm));

    } catch (InterruptedException e) {
      throw new OperationCanceledException();
    } catch (SQLException e) {
      Status status =
          new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
      Activator.getDefault().getLog().log(status);
      throw new CoreException(status);
    } catch (IOException e) {
      Status status =
          new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
      Activator.getDefault().getLog().log(status);
      throw new CoreException(status);
    } catch (XMLParserException e) {
      List<String> errors = e.getErrors();
      MultiStatus multiStatus =
          new MultiStatus(
              Activator.PLUGIN_ID,
              IStatus.ERROR,
              "XML Parser Errors\n  See Details for more Information",
              null);

      Iterator<String> iter = errors.iterator();
      while (iter.hasNext()) {
        Status message =
            new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, iter.next(), null);

        multiStatus.add(message);
      }
      throw new CoreException(multiStatus);
    } catch (InvalidConfigurationException e) {
      List<String> errors = e.getErrors();

      MultiStatus multiStatus =
          new MultiStatus(
              Activator.PLUGIN_ID,
              IStatus.ERROR,
              "Invalid Configuration\n  See Details for more Information",
              null);

      Iterator<String> iter = errors.iterator();
      while (iter.hasNext()) {
        Status message =
            new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, iter.next(), null);

        multiStatus.add(message);
      }
      throw new CoreException(multiStatus);
    } finally {
      monitor.done();
      restoreClassLoader();
    }
  }
コード例 #4
0
ファイル: Phase.java プロジェクト: hmalphettes/rt.equinox.p2
  private void mainPerform(
      MultiStatus status, EngineSession session, Operand[] operands, SubMonitor subMonitor) {
    IProfile profile = session.getProfile();
    subMonitor.beginTask(null, operands.length);
    for (int i = 0; i < operands.length; i++) {
      subMonitor.setWorkRemaining(operands.length - i);
      if (subMonitor.isCanceled()) throw new OperationCanceledException();
      Operand operand = operands[i];
      if (!isApplicable(operand)) continue;

      session.recordOperandStart(operand);
      List<ProvisioningAction> actions = getActions(operand);
      operandParameters = new HashMap<String, Object>(phaseParameters);
      operandParameters.put(PARM_OPERAND, operand);
      mergeStatus(status, initializeOperand(profile, operand, operandParameters, subMonitor));
      if (status.matches(IStatus.ERROR | IStatus.CANCEL)) {
        operandParameters = null;
        return;
      }

      Touchpoint operandTouchpoint = (Touchpoint) operandParameters.get(PARM_TOUCHPOINT);
      if (operandTouchpoint != null) {
        mergeStatus(
            status,
            initializeTouchpointParameters(profile, operand, operandTouchpoint, subMonitor));
        if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return;

        operandParameters = touchpointToTouchpointOperandParameters.get(operandTouchpoint);
      }

      operandParameters = Collections.unmodifiableMap(operandParameters);
      if (actions != null) {
        for (int j = 0; j < actions.size(); j++) {
          ProvisioningAction action = actions.get(j);
          Map<String, Object> parameters = operandParameters;
          Touchpoint touchpoint = action.getTouchpoint();
          if (touchpoint != null) {
            mergeStatus(
                status, initializeTouchpointParameters(profile, operand, touchpoint, subMonitor));
            if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return;

            parameters = touchpointToTouchpointOperandParameters.get(touchpoint);
          }
          IStatus actionStatus = null;
          try {
            session.recordActionExecute(action, parameters);
            actionStatus = action.execute(parameters);
          } catch (RuntimeException e) {
            if (!forced) throw e;
            // "action.execute" calls user code and might throw an unchecked exception
            // we catch the error here to gather information on where the problem occurred.
            actionStatus =
                new Status(
                    IStatus.ERROR,
                    EngineActivator.ID,
                    NLS.bind(Messages.forced_action_execute_error, action.getClass().getName()),
                    e);
          } catch (LinkageError e) {
            if (!forced) throw e;
            // Catch linkage errors as these are generally recoverable but let other Errors
            // propagate (see bug 222001)
            actionStatus =
                new Status(
                    IStatus.ERROR,
                    EngineActivator.ID,
                    NLS.bind(Messages.forced_action_execute_error, action.getClass().getName()),
                    e);
          }
          if (forced && actionStatus != null && actionStatus.matches(IStatus.ERROR)) {
            MultiStatus result =
                new MultiStatus(EngineActivator.ID, IStatus.ERROR, getProblemMessage(), null);
            result.add(
                new Status(
                    IStatus.ERROR,
                    EngineActivator.ID,
                    session.getContextString(this, operand, action),
                    null));
            LogHelper.log(result);
            actionStatus = Status.OK_STATUS;
          }
          mergeStatus(status, actionStatus);
          if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return;
        }
      }
      mergeStatus(
          status, touchpointCompleteOperand(profile, operand, operandParameters, subMonitor));
      mergeStatus(status, completeOperand(profile, operand, operandParameters, subMonitor));
      if (status.matches(IStatus.ERROR | IStatus.CANCEL)) return;
      operandParameters = null;
      session.recordOperandEnd(operand);
      subMonitor.worked(1);
    }
  }
コード例 #5
0
  private void indexQueuedTasks(SubMonitor monitor)
      throws CorruptIndexException, LockObtainFailedException, IOException, CoreException {

    synchronized (reindexQueue) {
      if (reindexQueue.isEmpty()) {
        return;
      }

      monitor.beginTask(Messages.TaskListIndex_task_rebuilding_index, reindexQueue.size());
    }

    try {
      IndexWriter writer = null;
      try {
        Map<ITask, TaskData> workingQueue = new HashMap<ITask, TaskData>();

        // reindex tasks that are in the reindexQueue, making multiple passes so that we catch
        // anything
        // added/changed while we were reindexing
        for (; ; ) {
          workingQueue.clear();

          synchronized (reindexQueue) {
            if (reindexQueue.isEmpty()) {
              break;
            }
            // move items from the reindexQueue to the temporary working queue
            workingQueue.putAll(reindexQueue);
            reindexQueue.keySet().removeAll(workingQueue.keySet());
          }

          if (writer == null) {
            try {
              writer = createIndexWriter(false);
            } catch (CorruptIndexException e) {
              rebuildIndex = true;
              synchronized (reindexQueue) {
                reindexQueue.clear();
              }
              rebuildIndexCompletely(monitor);
              return;
            }
          }

          monitor.setWorkRemaining(workingQueue.size());

          for (Entry<ITask, TaskData> entry : workingQueue.entrySet()) {
            ITask task = entry.getKey();
            TaskData taskData = entry.getValue();

            writer.deleteDocuments(
                new Term(FIELD_IDENTIFIER.getIndexKey(), task.getHandleIdentifier()));

            add(writer, task, taskData);

            monitor.worked(1);
          }
        }
      } finally {
        if (writer != null) {
          writer.close();
        }
      }
    } finally {
      monitor.done();
    }
  }
コード例 #6
0
  /**
   * Do the PYTHON installation.
   *
   * @param progressMonitor
   * @return A status indication of the process success or failure.
   */
  protected IStatus install(IProgressMonitor progressMonitor) {
    if (CollectionsUtil.isEmpty(downloadedPaths)) {
      String failureMessge = Messages.InstallProcessor_couldNotLocateInstaller;
      String err = NLS.bind(Messages.InstallProcessor_failedToInstall, PYTHON);
      displayMessageInUIThread(
          MessageDialog.ERROR,
          Messages.InstallProcessor_installationErrorTitle,
          err + ' ' + failureMessge);
      return new Status(IStatus.ERROR, PortalUIPlugin.PLUGIN_ID, err + ' ' + failureMessge);
    }
    SubMonitor subMonitor =
        SubMonitor.convert(
            progressMonitor,
            Messages.InstallProcessor_installerProgressInfo,
            IProgressMonitor.UNKNOWN);
    final Map<String, Object> installationAttributes = new HashMap<String, Object>();
    try {
      subMonitor.beginTask(
          NLS.bind(Messages.InstallProcessor_installingTaskName, PYTHON), IProgressMonitor.UNKNOWN);
      final String[] installDir = new String[1];
      Job installPythonDialog = new UIJob("Python installer options") // $NON-NLS-1$
          {
            @Override
            public IStatus runInUIThread(IProgressMonitor monitor) {
              PythonInstallerOptionsDialog dialog = new PythonInstallerOptionsDialog();
              if (dialog.open() == Window.OK) {
                installationAttributes.putAll(dialog.getAttributes());
                return Status.OK_STATUS;
              }
              return Status.CANCEL_STATUS;
            }
          };
      installPythonDialog.schedule();
      try {
        installPythonDialog.join();
      } catch (InterruptedException e) {
      }
      IStatus result = installPythonDialog.getResult();
      if (!result.isOK()) {
        return result;
      }

      IStatus status = installPYTHON(installationAttributes);
      if (!status.isOK()) {
        return status;
      }
      IdeLog.logInfo(
          PortalUIPlugin.getDefault(),
          MessageFormat.format(
              "Successfully installed PYTHON into {0}. PYTHON installation completed.",
              installDir[0])); // $NON-NLS-1$
      // note that we called the finalizeInstallation from the installPYTHON Job.
      return Status.OK_STATUS;
    } catch (Exception e) {
      IdeLog.logError(
          PortalUIPlugin.getDefault(), "Error while installing PYTHON", e); // $NON-NLS-1$
      return new Status(
          IStatus.ERROR,
          PortalUIPlugin.PLUGIN_ID,
          NLS.bind(Messages.InstallProcessor_errorWhileInstalling, PYTHON));
    } finally {
      subMonitor.done();
    }
  }