1 package org.simantics.ui.workbench.action;
3 import org.eclipse.swt.widgets.Control;
4 import org.eclipse.swt.widgets.Shell;
5 import org.eclipse.ui.IWorkbenchWindow;
6 import org.eclipse.ui.PlatformUI;
7 import org.simantics.db.Session;
8 import org.simantics.utils.ui.SWTUtils;
9 import org.simantics.utils.ui.workbench.WorkbenchUtils;
12 * @author Tuukka Lehtonen
14 public final class DefaultActions {
17 * Perform a default workbench action on the specified input object using
18 * {@link ChooseActionRequest} from any thread asynchronously.
22 * @param rememberAction
24 * @param neverPromptForAction true to never prompt/run an action if the
25 * action selection is ambiguous
27 public static void asyncPerformDefaultAction(
28 final Session session,
30 final boolean rememberAction,
31 final boolean alwaysAsk,
32 final boolean neverPromptForAction)
34 SWTUtils.asyncExec(PlatformUI.getWorkbench().getDisplay(), new Runnable() {
37 performDefaultAction(session, input, rememberAction, alwaysAsk, neverPromptForAction);
43 * Perform a default workbench action on the specified input object using
44 * {@link ChooseActionRequest} from the current thread. The current thread
45 * must be the SWT UI thread.
49 * @param rememberAction
51 * @param neverPromptForAction true to never prompt/run an action if the
52 * action selection is ambiguous
54 public static void performDefaultAction(
55 final Session session,
57 boolean rememberAction,
59 boolean neverPromptForAction)
61 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
62 Shell shell = window != null ? window.getShell() : null;
63 session.asyncRequest(new ChooseActionRequest(shell, null, input, WorkbenchUtils.getCurrentPerspectiveId(), rememberAction, alwaysAsk, neverPromptForAction));
67 * Perform a default workbench action on the specified input object using
68 * {@link ChooseActionRequest} from the current thread. The current thread
69 * must be the SWT UI thread.
71 * @param control the control contained
73 public static void performDefaultAction(Control control, Object input) {
74 new PerformDefaultAction("Perform Default Action", control, input).run();