1 /*******************************************************************************
\r
2 * Copyright (c) 2012 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.ui.workbench.action;
\r
14 import org.eclipse.jface.action.Action;
\r
15 import org.eclipse.swt.widgets.Control;
\r
16 import org.eclipse.swt.widgets.Shell;
\r
17 import org.eclipse.ui.IWorkbench;
\r
18 import org.eclipse.ui.IWorkbenchWindow;
\r
19 import org.eclipse.ui.PlatformUI;
\r
20 import org.simantics.db.Resource;
\r
21 import org.simantics.ui.SimanticsUI;
\r
22 import org.simantics.utils.ui.workbench.WorkbenchUtils;
\r
25 * @author Tuukka Lehtonen
\r
27 public class PerformDefaultAction extends Action {
\r
29 private Control control;
\r
30 private Resource component;
\r
32 public PerformDefaultAction(String name, Control control, Resource component) {
\r
34 this.control = control;
\r
35 this.component = component;
\r
40 final String perspectiveId = WorkbenchUtils.getCurrentPerspectiveId();
\r
42 if (control != null) {
\r
43 shell = control.getShell();
\r
45 IWorkbench wb = PlatformUI.getWorkbench();
\r
46 IWorkbenchWindow window = wb.getActiveWorkbenchWindow();
\r
48 shell = window.getShell();
\r
50 SimanticsUI.getSession().asyncRequest(new ChooseActionRequest(shell, control, component, perspectiveId));
\r