1 /*******************************************************************************
2 * Copyright (c) 2012 Association for Decentralized Information Management in
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.jface.action.Action;
15 import org.eclipse.swt.widgets.Control;
16 import org.eclipse.swt.widgets.Shell;
17 import org.eclipse.ui.IWorkbench;
18 import org.eclipse.ui.IWorkbenchWindow;
19 import org.eclipse.ui.PlatformUI;
20 import org.simantics.db.Resource;
21 import org.simantics.ui.SimanticsUI;
22 import org.simantics.utils.ui.workbench.WorkbenchUtils;
25 * @author Tuukka Lehtonen
27 public class PerformDefaultAction extends Action {
29 private Control control;
30 private Resource component;
32 public PerformDefaultAction(String name, Control control, Resource component) {
34 this.control = control;
35 this.component = component;
40 final String perspectiveId = WorkbenchUtils.getCurrentPerspectiveId();
42 if (control != null) {
43 shell = control.getShell();
45 IWorkbench wb = PlatformUI.getWorkbench();
46 IWorkbenchWindow window = wb.getActiveWorkbenchWindow();
48 shell = window.getShell();
50 SimanticsUI.getSession().asyncRequest(new ChooseActionRequest(shell, control, component, perspectiveId));