1 package org.simantics.ui.workbench.action;
3 import org.eclipse.swt.widgets.Shell;
4 import org.eclipse.ui.IWorkbenchWindow;
5 import org.eclipse.ui.PlatformUI;
6 import org.simantics.db.Session;
7 import org.simantics.utils.ui.SWTUtils;
8 import org.simantics.utils.ui.workbench.WorkbenchUtils;
11 * @author Tuukka Lehtonen
13 public final class DefaultActions {
16 * Perform a default workbench action on the specified input object using
17 * {@link ChooseActionRequest} from any thread asynchronously.
21 * @param rememberAction
23 * @param neverPromptForAction true to never prompt/run an action if the
24 * action selection is ambiguous
26 public static void asyncPerformDefaultAction(
27 final Session session,
29 final boolean rememberAction,
30 final boolean alwaysAsk,
31 final boolean neverPromptForAction)
33 SWTUtils.asyncExec(PlatformUI.getWorkbench().getDisplay(), new Runnable() {
36 performDefaultAction(session, input, rememberAction, alwaysAsk, neverPromptForAction);
42 * Perform a default workbench action on the specified input object using
43 * {@link ChooseActionRequest} from the current thread. The current thread
44 * must be the SWT UI thread.
48 * @param rememberAction
50 * @param neverPromptForAction true to never prompt/run an action if the
51 * action selection is ambiguous
53 public static void performDefaultAction(
54 final Session session,
56 boolean rememberAction,
58 boolean neverPromptForAction)
60 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
61 Shell shell = window != null ? window.getShell() : null;
62 session.asyncRequest(new ChooseActionRequest(shell, null, input, WorkbenchUtils.getCurrentPerspectiveId(), rememberAction, alwaysAsk, neverPromptForAction));