1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 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.message.ui.scheme;
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;
24 * @author Tuukka Lehtonen
26 public class ResourceSchemeHandler extends AbstractMessageSchemeHandler<Resource> {
28 public ResourceSchemeHandler() {
29 super("resource", Resource.class); //$NON-NLS-1$
33 public void doPerform(Resource r) {
34 Session session = Simantics.peekSession();
35 if (session == null) {
37 System.out.println("ResourceSchemeHandler: no session"); //$NON-NLS-1$
41 // Try the doubleClick-extensions
42 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
46 final String perspectiveId = WorkbenchUtils.getCurrentPerspectiveId();
48 session.asyncRequest(new ChooseActionRequest(window.getShell(), r, perspectiveId, false, true));