Search in sources :

Example 1 with IJobManager

use of org.eclipse.core.runtime.jobs.IJobManager in project che by eclipse.

the class RefactoringExecutionHelper method perform.

/**
	 * Must be called in the UI thread.<br>
	 * <strong>Use {@link #perform(boolean, boolean)} unless you know exactly what you are doing!</strong>
	 *
	 * @param fork if set, the operation will be forked
	 * @param forkChangeExecution if the change should not be executed in the UI thread: This may not work in any case
	 * @param cancelable  if set, the operation will be cancelable
	 * @throws InterruptedException thrown when the operation is cancelled
	 * @throws InvocationTargetException thrown when the operation failed to execute
	 */
public RefactoringStatus perform(boolean fork, boolean forkChangeExecution, boolean cancelable) throws InterruptedException, InvocationTargetException, CoreException {
    //		Assert.isTrue(Display.getCurrent() != null);
    final IJobManager manager = Job.getJobManager();
    final ISchedulingRule rule;
    if (fRefactoring instanceof IScheduledRefactoring) {
        rule = ((IScheduledRefactoring) fRefactoring).getSchedulingRule();
    } else {
        rule = ResourcesPlugin.getWorkspace().getRoot();
    }
    Operation op = null;
    try {
        try {
            op = new Operation(fork, forkChangeExecution);
            op.run(new NullProgressMonitor());
            fPerformChangeOperation = op.fPerformChangeOperation;
            //			fRefactoring.setValidationContext(fParent);
            if (op.fPerformChangeOperation != null) {
                ResourcesPlugin.getWorkspace().run(op.fPerformChangeOperation, new NullProgressMonitor());
            }
            if (op.fPerformChangeOperation != null) {
                RefactoringStatus validationStatus = op.fPerformChangeOperation.getValidationStatus();
                if (validationStatus != null) /*&& validationStatus.hasFatalError()*/
                {
                    //						throw new InterruptedException();
                    return validationStatus;
                }
            }
        } catch (OperationCanceledException e) {
            if (op != null) {
                if (op.allConditions != null) {
                    return op.allConditions;
                }
            }
            throw new InterruptedException(e.getMessage());
        } finally {
        //				saveHelper.triggerIncrementalBuild();
        }
    } finally {
        //			manager.endRule(rule);
        fRefactoring.setValidationContext(null);
    }
    return new RefactoringStatus();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IJobManager(org.eclipse.core.runtime.jobs.IJobManager) PerformChangeOperation(org.eclipse.ltk.core.refactoring.PerformChangeOperation) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule)

Aggregations

NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 IJobManager (org.eclipse.core.runtime.jobs.IJobManager)1 ISchedulingRule (org.eclipse.core.runtime.jobs.ISchedulingRule)1 PerformChangeOperation (org.eclipse.ltk.core.refactoring.PerformChangeOperation)1 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)1