]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.message.ui/src/org/simantics/message/ui/scheme/ResourceSchemeHandler.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.message.ui / src / org / simantics / message / ui / scheme / ResourceSchemeHandler.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.message.ui.scheme;\r
13 \r
14 import org.eclipse.ui.IWorkbenchWindow;\r
15 import org.eclipse.ui.PlatformUI;\r
16 import org.simantics.db.Resource;\r
17 import org.simantics.db.Session;\r
18 import org.simantics.message.AbstractMessageSchemeHandler;\r
19 import org.simantics.ui.SimanticsUI;\r
20 import org.simantics.ui.workbench.action.ChooseActionRequest;\r
21 import org.simantics.utils.ui.workbench.WorkbenchUtils;\r
22 \r
23 /**\r
24  * @author Tuukka Lehtonen\r
25  */\r
26 public class ResourceSchemeHandler extends AbstractMessageSchemeHandler<Resource> {\r
27 \r
28     public ResourceSchemeHandler() {\r
29         super("resource", Resource.class);\r
30     }\r
31 \r
32     @Override\r
33     public void doPerform(Resource r) {\r
34         Session session = SimanticsUI.peekSession();\r
35         if (session == null) {\r
36             // FIXME: not stdout.\r
37             System.out.println("ResourceSchemeHandler: no session");\r
38             return;\r
39         }\r
40 \r
41         // Try the doubleClick-extensions\r
42         IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();\r
43         if (window == null)\r
44             return;\r
45 \r
46         final String perspectiveId = WorkbenchUtils.getCurrentPerspectiveId();\r
47 \r
48         session.asyncRequest(new ChooseActionRequest(window.getShell(), r, perspectiveId, false, true));\r
49         \r
50     }\r
51 \r
52 }\r