1
2
3
4
5
6
7
8
9
10
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 }