View Javadoc

1   /*
2    * Created on Mar 8, 2005. Copyright 1999-2006 Faculty of Mathematics, Physics
3    * and Informatics, Comenius University, Bratislava. This file is protected by
4    * the Mozilla Public License version 1.1 (the "License"); you may not use this
5    * file except in compliance with the License. You may obtain a copy of the
6    * License at http://euromath2.sourceforge.net/license.html Unless required by
7    * applicable law or agreed to in writing, software distributed under the
8    * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9    * OF ANY KIND, either express or implied. See the License for the specific
10   * language governing permissions and limitations under the License.
11   */
12  package sk.uniba.euromath.editor.widgets;
13  import org.eclipse.swt.widgets.Composite;
14  /***
15   * Says that implementing object contains a composite and some controls.
16   * @author Martin Vysny
17   */
18  public interface IUserInputWidget {
19  	/***
20  	 * Returns composite that is encapsulated in this object.
21  	 * @return composite where all controls are placed.
22  	 */
23  	public Composite getComposite();
24  	/***
25  	 * Registers given modify listener.
26  	 * @param listener listener to register.
27  	 */
28  	public void addModifyListener(IModifyListener listener);
29  	/***
30  	 * Unregisters given modify listener.
31  	 * @param listener listener to unregister.
32  	 */
33  	public void removeModifyListener(IModifyListener listener);
34  	/***
35  	 * Registers given error listener.
36  	 * @param listener the error listener called when last error changes.
37  	 */
38  	public void addMessageListener(IMessagesChangeListener listener);
39  	/***
40  	 * Unregisters given error listener.
41  	 * @param listener the error listener called when last error changes.
42  	 */
43  	public void removeMessageListener(IMessagesChangeListener listener);
44  	/***
45  	 * Checks if data contained in the widget are correct. Contains
46  	 * error/info/warning messages that occured during last data change.
47  	 * @return <code>null</code> if data is correct, or instance of
48  	 * <code>ValidityMessages</code> if there is error, warning or info
49  	 * message.
50  	 */
51  	public ValidityMessages getMessages();
52  	/***
53  	 * Returns the state of this widget. The state must be in sync with the
54  	 * controls placed on the widget.
55  	 * @return the model.
56  	 */
57  	Object getState();
58  	/***
59  	 * Sets new state for the widget. The widget must re-read all relevant
60  	 * properties from the state and set its controls with new values.
61  	 * @param state the model to set. You may use the construct
62  	 * <code>setModel(getModel())</code> to reflect changes made in the model.
63  	 * Please note that nearly all widgets rejects <code>null</code> value.
64  	 * @throws ClassCastException if given model is not castable to the
65  	 * {@link #getStateClass() supported model class}.
66  	 * @throws UnsupportedOperationException if state change is not supported.
67  	 * @throws IllegalArgumentException if new state is invalid.
68  	 */
69  	void setState(Object state);
70  	/***
71  	 * Returns the class of the state that the widget accepts.
72  	 * @return model class, never <code>null</code>.
73  	 */
74  	Class< ? > getStateClass();
75  }