1 /*******************************************************************************
2 * Copyright (c) 2012, 2017 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.ui.workbench.action;
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.core.runtime.Status;
16 import org.eclipse.jface.action.Action;
17 import org.eclipse.swt.widgets.Control;
18 import org.eclipse.swt.widgets.Shell;
19 import org.eclipse.ui.IWorkbench;
20 import org.eclipse.ui.IWorkbenchWindow;
21 import org.eclipse.ui.PlatformUI;
22 import org.simantics.Simantics;
23 import org.simantics.db.common.procedure.adapter.ProcedureAdapter;
24 import org.simantics.ui.internal.Activator;
25 import org.simantics.utils.ui.workbench.WorkbenchUtils;
28 * @author Tuukka Lehtonen
30 public class PerformDefaultAction extends Action {
32 private Control control;
35 public PerformDefaultAction(String name, Control control, Object input) {
37 this.control = control;
43 final String perspectiveId = WorkbenchUtils.getCurrentPerspectiveId();
45 if (control != null) {
46 shell = control.getShell();
48 IWorkbench wb = PlatformUI.getWorkbench();
49 IWorkbenchWindow window = wb.getActiveWorkbenchWindow();
51 shell = window.getShell();
53 Simantics.getSession().asyncRequest(
54 new ChooseActionRequest(shell, control, input, perspectiveId),
55 new ProcedureAdapter<Object>() {
57 public void exception(Throwable t) {
58 Activator.getDefault().getLog().log(
59 new Status(IStatus.ERROR, Activator.PLUGIN_ID,
60 "Failed to choose action for input " + input + ", see exception for details.", t));