Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 578871 - use ISchedulableOperation #18

Merged
merged 1 commit into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.ISchedulableOperation;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.LegacyActionTools;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IPartListener;
Expand Down Expand Up @@ -298,7 +303,32 @@ public final void run() {
if (getOperation() instanceof IAdvancedUndoableOperation2) {
runInBackground = ((IAdvancedUndoableOperation2) getOperation()).runInBackground();
}
progressDialog.run(runInBackground, true, runnable);
if (runInBackground) {
progressDialog.run(runInBackground, true, runnable);
} else {
final IJobManager manager = Job.getJobManager();
final ISchedulingRule rule = (getOperation() instanceof ISchedulableOperation)
jukzi marked this conversation as resolved.
Show resolved Hide resolved
? ((ISchedulableOperation) getOperation()).getSchedulingRule()
: null;
if (rule == null) {
progressDialog.run(runInBackground, true, runnable);
} else {
// prevent UI freeze during AutoBuild as in
// org.eclipse.jdt.internal.ui.refactoring.RefactoringExecutionHelper#perform
try {
try {
// interrupt autobuild or show Wait/Cancel Dialog:
Runnable r = () -> manager.beginRule(rule, null);
BusyIndicator.showWhile(parent.getDisplay(), r);
laeubi marked this conversation as resolved.
Show resolved Hide resolved
} catch (OperationCanceledException e) {
throw new InterruptedException(e.getMessage());
}
progressDialog.run(runInBackground, true, runnable); // <-- actual work
laeubi marked this conversation as resolved.
Show resolved Hide resolved
} finally {
manager.endRule(rule);
}
}
}
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
if (t == null) {
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.ui.workbench/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Export-Package: org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;x-interna
org.eclipse.ui.themes,
org.eclipse.ui.views,
org.eclipse.ui.wizards
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.19.0,4.0.0)",
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.25.0,4.0.0)",
org.eclipse.help;bundle-version="[3.2.0,4.0.0)",
org.eclipse.jface;bundle-version="[3.18.0,4.0.0)",
org.eclipse.swt;bundle-version="[3.107.0,4.0.0)",
Expand Down