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