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