]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
ab79d1f8ce29eaff9337a6a0fce426cef8b6087c
[simantics/sysdyn.git] /
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
3  * 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.sysdyn.ui.handlers.newComponents;\r
13 \r
14 import org.eclipse.core.commands.ExecutionEvent;\r
15 import org.eclipse.core.commands.ExecutionException;\r
16 import org.eclipse.jface.viewers.ISelection;\r
17 import org.eclipse.ui.handlers.HandlerUtil;\r
18 import org.simantics.browsing.ui.common.node.AbstractNode;\r
19 import org.simantics.db.Resource;\r
20 import org.simantics.utils.ui.AdaptionUtils;\r
21 \r
22 /**\r
23  * Creates a new shared function library.\r
24  * \r
25  * @author Teemu Lempinen\r
26  *\r
27  */\r
28 public class NewSharedFunctionLibraryHandler extends NewFunctionLibraryHandler {\r
29 \r
30         @Override\r
31         public Object execute(ExecutionEvent event) throws ExecutionException {\r
32 \r
33         ISelection sel = HandlerUtil.getCurrentSelection(event);\r
34         \r
35         @SuppressWarnings("unchecked")\r
36                 AbstractNode<Resource> node = AdaptionUtils.adaptToSingle(sel, AbstractNode.class);\r
37         if (node == null)\r
38             return null;\r
39 \r
40         createLibrary(node.data, true);\r
41         return null;\r
42         }\r
43 }\r