KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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 /**
14  * Classes that implement this interface can be added to the managed form and
15  * take part in the form life cycle. The part is initialized with the form and
16  * will be asked to accept focus. The part can receive form input and can elect
17  * to do something according to it (for example, select an object that matches
18  * the input).
19  * <p>
20  * The form part has two 'out of sync' states in respect to the model(s) that
21  * feed the form: <b>dirty</b> and <b>stale</b>. When a part is dirty, it
22  * means that the user interacted with it and now its widgets contain state that
23  * is newer than the model. In order to sync up with the model, 'commit' needs
24  * to be called. In contrast, the model can change 'under' the form (as a result
25  * of some actions outside the form), resulting in data in the model being
26  * 'newer' than the content presented in the form. A 'stale' form part is
27  * brought in sync with the model by calling 'refresh'. The part is responsible
28  * for notifying the form when one of these states change in the part. The form
29  * reserves the right to handle this notification in the most appropriate way
30  * for the situation (for example, if the form is in a page of the multi-page
31  * editor, it may do nothing for stale parts if the page is currently not
32  * showing).
33  * <p>
34  * When the form is disposed, each registered part is disposed as well. Parts
35  * are responsible for releasing any system resources they created and for
36  * removing themselves as listeners from all event providers.
37  *
38  * @see IManagedForm
39  * @since 3.0
40  *
41  */

42 public interface IFormPart {
43     /**
44      * Initializes the part.
45      *
46      * @param form
47      * the managed form that manages the part
48      */

49     void initialize(IManagedForm form);
50
51     /**
52      * Disposes the part allowing it to release allocated resources.
53      */

54     void dispose();
55
56     /**
57      * Returns true if the part has been modified with respect to the data
58      * loaded from the model.
59      *
60      * @return true if the part has been modified with respect to the data
61      * loaded from the model
62      */

63     boolean isDirty();
64
65     /**
66      * If part is displaying information loaded from a model, this method
67      * instructs it to commit the new (modified) data back into the model.
68      *
69      * @param onSave
70      * indicates if commit is called during 'save' operation or for
71      * some other reason (for example, if form is contained in a
72      * wizard or a multi-page editor and the user is about to leave
73      * the page).
74      */

75     void commit(boolean onSave);
76
77     /**
78      * Notifies the part that an object has been set as overall form's input.
79      * The part can elect to react by revealing or selecting the object, or do
80      * nothing if not applicable.
81      *
82      * @return <code>true</code> if the part has selected and revealed the
83      * input object, <code>false</code> otherwise.
84      */

85     boolean setFormInput(Object JavaDoc input);
86
87     /**
88      * Instructs form part to transfer focus to the widget that should has focus
89      * in that part. The method can do nothing (if it has no widgets capable of
90      * accepting focus).
91      */

92     void setFocus();
93
94     /**
95      * Tests whether the form part is stale and needs refreshing. Parts can
96      * receive notification from models that will make their content stale, but
97      * may need to delay refreshing to improve performance (for example, there
98      * is no need to immediately refresh a part on a form that is current on a
99      * hidden page).
100      * <p>
101      * It is important to differentiate 'stale' and 'dirty' states. Part is
102      * 'dirty' if user interacted with its editable widgets and changed the
103      * values. In contrast, part is 'stale' when the data it presents in the
104      * widgets has been changed in the model without direct user interaction.
105      *
106      * @return <code>true</code> if the part needs refreshing,
107      * <code>false</code> otherwise.
108      */

109     boolean isStale();
110
111     /**
112      * Refreshes the part completely from the information freshly obtained from
113      * the model. The method will not be called if the part is not stale.
114      * Otherwise, the part is responsible for clearing the 'stale' flag after
115      * refreshing itself.
116      */

117     void refresh();
118 }
119
Popular Tags