]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/ComponentTypeEditor.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / componentTypeEditor / ComponentTypeEditor.java
1 /*******************************************************************************\r
2  * Copyright (c) 2012 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.modeling.ui.componentTypeEditor;\r
13 \r
14 import org.eclipse.core.runtime.IConfigurationElement;\r
15 import org.eclipse.core.runtime.IExecutableExtension;\r
16 import org.eclipse.swt.widgets.Composite;\r
17 import org.simantics.ui.workbench.ResourceEditorPart;\r
18 \r
19 /**\r
20  * @author Hannu Niemistö\r
21  * @author Tuukka Lehtonen (IExecutableExtension)\r
22  */\r
23 public class ComponentTypeEditor extends ResourceEditorPart implements IExecutableExtension {\r
24 \r
25     protected ComponentTypeViewer viewer;\r
26     protected String formTitle = "User Component Interface";\r
27 \r
28     @Override\r
29     public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {\r
30         if (data instanceof String) {\r
31             String[] params = ((String) data).split(";");\r
32             for (String param : params) {\r
33                 String[] keyValue = param.split("=");\r
34                 if (keyValue.length == 2) {\r
35                     if ("formTitle".equals(keyValue[0])) {\r
36                         formTitle = keyValue[1];\r
37                     }\r
38                 }\r
39             }\r
40         }\r
41     }\r
42 \r
43     @Override\r
44     public void createPartControl(Composite parent) {\r
45         viewer = new ComponentTypeViewer(parent, getInputResource(), getEditorTitle());\r
46         activateValidation();\r
47     }\r
48 \r
49     protected String getEditorTitle() {\r
50         return formTitle;\r
51     }\r
52 \r
53     @Override\r
54     public void setFocus() {\r
55         viewer.setFocus();\r
56     }\r
57 \r
58 }\r