From 7e8c7e6056d6ab949b3a1531c859e0bddfdf91a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Kubitz?= <51790620+jukzi@users.noreply.github.com> Date: Wed, 27 Apr 2022 10:37:07 +0200 Subject: [PATCH] Bug 578871 - resolve ISchedulableOperation for TriggeredOperations (#18) (#37) TriggeredOperations hides ISchedulableOperation in triggeredOperation. see https://user-images.githubusercontent.com/964108/165256257-f796f30f-6d8f-4b1d-9611-863e323f8df6.png --- .../OperationHistoryActionHandler.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/operations/OperationHistoryActionHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/operations/OperationHistoryActionHandler.java index ac11215626a..8625ebe981d 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/operations/OperationHistoryActionHandler.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/operations/OperationHistoryActionHandler.java @@ -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; @@ -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 {