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