KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > forms > AbstractFormPart


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.forms;
12 /**
13  * AbstractFormPart implements IFormPart interface and can be used as a
14  * convenient base class for concrete form parts. If a method contains
15  * code that must be called, look for instructions to call 'super'
16  * when overriding.
17  *
18  * @see org.eclipse.ui.forms.widgets.Section
19  * @since 3.0
20  */

21 public abstract class AbstractFormPart implements IFormPart {
22     private IManagedForm managedForm;
23     private boolean dirty = false;
24     private boolean stale = true;
25     /**
26      * @see org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm)
27      */

28     public void initialize(IManagedForm form) {
29         this.managedForm = form;
30     }
31     /**
32      * Returns the form that manages this part.
33      *
34      * @return the managed form
35      */

36     public IManagedForm getManagedForm() {
37         return managedForm;
38     }
39     /**
40      * Disposes the part. Subclasses should override to release any system
41      * resources.
42      */

43     public void dispose() {
44     }
45     /**
46      * Commits the part. Subclasses should call 'super' when overriding.
47      *
48      * @param onSave
49      * <code>true</code> if the request to commit has arrived as a
50      * result of the 'save' action.
51      */

52     public void commit(boolean onSave) {
53         dirty = false;
54     }
55     /**
56      * Sets the overall form input. Subclases may elect to override the method
57      * and adjust according to the form input.
58      *
59      * @param input
60      * the form input object
61      * @return <code>false</code>
62      */

63     public boolean setFormInput(Object JavaDoc input) {
64         return false;
65     }
66     /**
67      * Instructs the part to grab keyboard focus.
68      */

69     public void setFocus() {
70     }
71     /**
72      * Refreshes the section after becoming stale (falling behind data in the
73      * model). Subclasses must call 'super' when overriding this method.
74      */

75     public void refresh() {
76         stale = false;
77         // since we have refreshed, any changes we had in the
78
// part are gone and we are not dirty
79
dirty = false;
80     }
81     /**
82      * Marks the part dirty. Subclasses should call this method as a result of
83      * user interaction with the widgets in the section.
84      */

85     public void markDirty() {
86         dirty = true;
87         managedForm.dirtyStateChanged();
88     }
89     /**
90      * Tests whether the part is dirty i.e. its widgets have state that is
91      * newer than the data in the model.
92      *
93      * @return <code>true</code> if the part is dirty, <code>false</code>
94      * otherwise.
95      */

96     public boolean isDirty() {
97         return dirty;
98     }
99     /**
100      * Tests whether the part is stale i.e. its widgets have state that is
101      * older than the data in the model.
102      *
103      * @return <code>true</code> if the part is stale, <code>false</code>
104      * otherwise.
105      */

106     public boolean isStale() {
107         return stale;
108     }
109     /**
110      * Marks the part stale. Subclasses should call this method as a result of
111      * model notification that indicates that the content of the section is no
112      * longer in sync with the model.
113      */

114     public void markStale() {
115         stale = true;
116         managedForm.staleStateChanged();
117     }
118 }
119
Popular Tags