Skip to content

Commit

Permalink
Bug 578871 - resolve ISchedulableOperation for TriggeredOperations (#18
Browse files Browse the repository at this point in the history
…) (#37)

TriggeredOperations hides ISchedulableOperation in triggeredOperation.
see https://user-images.githubusercontent.com/964108/165256257-f796f30f-6d8f-4b1d-9611-863e323f8df6.png
  • Loading branch information
jukzi authored Apr 27, 2022
1 parent 95c9174 commit 7e8c7e6
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.core.commands.operations.OperationHistoryEvent;
import org.eclipse.core.commands.operations.TriggeredOperations;
import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
Expand Down Expand Up @@ -300,19 +301,25 @@ public final void run() {
};
try {
boolean runInBackground = false;
if (getOperation() instanceof IAdvancedUndoableOperation2) {
runInBackground = ((IAdvancedUndoableOperation2) getOperation()).runInBackground();
IUndoableOperation operation = getOperation();
if (operation instanceof IAdvancedUndoableOperation2) {
runInBackground = ((IAdvancedUndoableOperation2) operation).runInBackground();
}
if (runInBackground) {
progressDialog.run(runInBackground, true, runnable);
} else {
final IJobManager manager = Job.getJobManager();
final ISchedulingRule rule = (getOperation() instanceof ISchedulableOperation)
? ((ISchedulableOperation) getOperation()).getSchedulingRule()
Object schedulableOperation = operation;
while (!(schedulableOperation instanceof ISchedulableOperation)
&& schedulableOperation instanceof TriggeredOperations) {
schedulableOperation = ((TriggeredOperations) schedulableOperation).getTriggeringOperation();
}
final ISchedulingRule rule = (schedulableOperation instanceof ISchedulableOperation)
? ((ISchedulableOperation) schedulableOperation).getSchedulingRule()
: null;
if (rule == null) {
progressDialog.run(runInBackground, true, runnable);
} else {
final IJobManager manager = Job.getJobManager();
// prevent UI freeze during AutoBuild as in
// org.eclipse.jdt.internal.ui.refactoring.RefactoringExecutionHelper#perform
try {
Expand Down

0 comments on commit 7e8c7e6

Please sign in to comment.