]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.ui/src/org/simantics/ui/workbench/ResourceFormViewPart.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.ui / src / org / simantics / ui / workbench / ResourceFormViewPart.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in 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.ui.workbench;\r
13 \r
14 import org.eclipse.swt.widgets.Composite;\r
15 import org.eclipse.ui.forms.widgets.FormToolkit;\r
16 import org.eclipse.ui.forms.widgets.ScrolledForm;\r
17 \r
18 \r
19 /**\r
20  * This class acts as a base class for Eclipse forms-based form-editors in a\r
21  * using the ProCore semantic triple data model.\r
22  * \r
23  * Extend SinglePageTypeEditor or MultiPageFormView to create your own editor,\r
24  * not this one.\r
25  * \r
26  * @author Antti Villberg\r
27  * @author Tuukka Lehtonen\r
28  */\r
29 public abstract class ResourceFormViewPart extends ResourceInputViewPart {\r
30 \r
31     protected FormToolkit toolkit;\r
32 \r
33     //----------------------------------------------------------------------\r
34     // Getters\r
35     \r
36     public FormToolkit getToolkit() {\r
37         return toolkit;\r
38     }\r
39     \r
40     \r
41     //----------------------------------------------------------------------\r
42     // Event utilities\r
43 \r
44     public void reflow(boolean flushCache) {\r
45         //System.out.println("FormTypeEditorBase.reflow(" + flushCache + ")");\r
46         getActiveForm().reflow(flushCache);\r
47     }\r
48     \r
49     \r
50     //----------------------------------------------------------------------\r
51     // Event handlers & initialisation\r
52 \r
53     @Override\r
54     public void createPartControl(Composite parent) {\r
55         this.toolkit = new FormToolkit(parent.getDisplay());\r
56         super.createPartControl(parent);\r
57     }\r
58 \r
59     @Override\r
60     public void dispose() {\r
61         if (toolkit != null) {\r
62             toolkit.dispose();\r
63         }\r
64         super.dispose();\r
65     }\r
66     \r
67     @Override\r
68     public void setFocus() {\r
69         //System.out.println("FormTypeEditorBase.setFocus(): Input = " + getInput());\r
70         ScrolledForm form = getActiveForm();\r
71         if (form != null) {\r
72             form.setFocus();\r
73         }\r
74     }\r
75 \r
76     \r
77     //----------------------------------------------------------------------\r
78     // Implement these yourself:\r
79     \r
80     public abstract ScrolledForm getActiveForm();\r
81 \r
82     protected abstract String getFormText();\r
83     \r
84 }\r