01: /*
02: ItsNat Java Web Application Framework
03: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
04: Author: Jose Maria Arranz Santamaria
05:
06: This program is free software: you can redistribute it and/or modify
07: it under the terms of the GNU Affero General Public License as published by
08: the Free Software Foundation, either version 3 of the License, or
09: (at your option) any later version. See the GNU Affero General Public
10: License for more details. See the copy of the GNU Affero General Public License
11: included in this program. If not, see <http://www.gnu.org/licenses/>.
12: */
13:
14: package org.itsnat.comp;
15:
16: import org.itsnat.comp.ui.ItsNatButtonUI;
17: import javax.swing.ButtonModel;
18:
19: /**
20: * Is the base interface of button components.
21: *
22: * <p>A button component manages a <code>javax.swing.ButtonModel</code>,
23: * user actions updates this model accordingly. Default button model
24: * depends on the concrete button type (normal, toggle etc). Button model listeners
25: * may be used to keep track of the button state changes.</p>
26: *
27: * <p>In spite of ItsNat specifies interfaces bound to the typical form based buttons,
28: * any (X)HTML element can be an ItsNat button (free buttons), however ItsNat does not define
29: * a default decoration, button model listeners may be used to decorate
30: * any button state.</p>
31: *
32: * @author Jose Maria Arranz Santamaria
33: */
34: public interface ItsNatButton extends ItsNatElementComponent {
35: /**
36: * Returns the current data model of this component.
37: *
38: * @return the current data model
39: * @see #setButtonModel(javax.swing.ButtonModel)
40: */
41: public ButtonModel getButtonModel();
42:
43: /**
44: * Changes the data model of this component.
45: *
46: * <p>Current data model is disconnected from this component, and the new
47: * data model is bound to this component, every change is tracked and
48: * updates the user interfaces accordingly.</p>
49: *
50: * <p>If the specified data model is the same instance as the current data model,
51: * then is reset, component listener is removed and added again. Use this technique if
52: * you want to add a data model listener to be executed <i>before</i> the default component listener.
53: *
54: * @param dataModel the new data model.
55: * @see #getButtonModel()
56: */
57: public void setButtonModel(ButtonModel dataModel);
58:
59: /**
60: * Creates a data model instance appropriated to this component. This instance
61: * is not bound to the component.
62: *
63: * @return a new data model instance.
64: */
65: public ButtonModel createDefaultButtonModel();
66:
67: /**
68: * Returns the user interface manager of this component.
69: *
70: * @return the user interface manager.
71: */
72: public ItsNatButtonUI getItsNatButtonUI();
73:
74: /**
75: * Informs whether this button receives UI events.
76: *
77: * <p>Current implementation calls <code>ButtonModel.isEnabled()</code>.</p>
78: *
79: * @return true if UI button is enabled.
80: * @see org.itsnat.comp.ui.ItsNatComponentUI#isEnabled()
81: */
82: public boolean isEnabled();
83:
84: /**
85: * Sets whether this button can receive UI events.
86: *
87: * <p>Current implementation calls <code>ButtonModel.setEnabled(boolean)</code>,
88: * a built-in listener then calls {@link org.itsnat.comp.ui.ItsNatComponentUI#setEnabled(boolean)}.</p>
89: *
90: * @param b true to enable the UI.
91: * @see org.itsnat.comp.ui.ItsNatComponentUI#setEnabled(boolean)
92: */
93: public void setEnabled(boolean b);
94: }
|