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.impl.comp.free;
15:
16: import org.itsnat.comp.free.ItsNatFreeButtonToggle;
17: import org.itsnat.comp.ui.ItsNatButtonToggleUI;
18: import javax.swing.ButtonModel;
19: import javax.swing.JToggleButton.ToggleButtonModel;
20: import org.itsnat.core.NameValue;
21: import org.itsnat.impl.comp.*;
22: import org.w3c.dom.Element;
23:
24: /**
25: *
26: * @author jmarranz
27: */
28: public abstract class ItsNatFreeButtonToggleImpl extends
29: ItsNatFreeButtonImpl implements ItsNatFreeButtonToggle,
30: ItsNatButtonToggleInternal {
31: /**
32: * Creates a new instance of ItsNatFreeButtonToggleImpl
33: */
34: public ItsNatFreeButtonToggleImpl(Element element,
35: NameValue[] artifacts,
36: ItsNatComponentManagerImpl componentMgr) {
37: super (element, artifacts, componentMgr);
38: }
39:
40: public boolean isSelected() {
41: return getButtonModel().isSelected();
42: }
43:
44: public void setSelected(boolean b) {
45: getButtonModel().setSelected(b);
46: }
47:
48: public Object createDefaultModelInternal() {
49: return createDefaultButtonModel();
50: }
51:
52: public ButtonModel createDefaultButtonModel() {
53: return new ToggleButtonModel();
54: }
55:
56: public void syncUIWithDataModel() {
57: super .syncUIWithDataModel();
58:
59: ItsNatButtonToggleBasedSharedImpl.syncUIWithDataModel(this );
60: }
61:
62: public ToggleButtonModel getToggleButtonModel() {
63: return (ToggleButtonModel) dataModel;
64: }
65:
66: public void setToggleButtonModel(ToggleButtonModel dataModel) {
67: setDataModel(dataModel);
68: }
69:
70: public ItsNatButtonToggleUI getItsNatButtonToggleUI() {
71: return (ItsNatButtonToggleUI) compUI;
72: }
73:
74: public void setUISelected(boolean selected) {
75: ItsNatButtonToggleUI compUI = getItsNatButtonToggleUI();
76: compUI.setSelected(selected);
77: }
78: }
|