001: /*
002: ItsNat Java Web Application Framework
003: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
004: Author: Jose Maria Arranz Santamaria
005:
006: This program is free software: you can redistribute it and/or modify
007: it under the terms of the GNU Affero General Public License as published by
008: the Free Software Foundation, either version 3 of the License, or
009: (at your option) any later version. See the GNU Affero General Public
010: License for more details. See the copy of the GNU Affero General Public License
011: included in this program. If not, see <http://www.gnu.org/licenses/>.
012: */
013:
014: package org.itsnat.impl.comp.free;
015:
016: import org.itsnat.comp.ItsNatButtonGroup;
017: import org.itsnat.comp.free.ItsNatFreeRadioButton;
018: import org.itsnat.comp.ui.ItsNatButtonRadioUI;
019: import org.itsnat.comp.ui.ItsNatComponentUI;
020: import org.itsnat.impl.comp.*;
021: import org.itsnat.impl.comp.ui.free.ItsNatFreeRadioButtonUIImpl;
022: import javax.swing.ButtonGroup;
023: import javax.swing.ButtonModel;
024: import javax.swing.JToggleButton.ToggleButtonModel;
025: import org.itsnat.core.NameValue;
026: import org.w3c.dom.Element;
027:
028: /**
029: *
030: * @author jmarranz
031: */
032: public abstract class ItsNatFreeRadioButtonImpl extends
033: ItsNatFreeButtonToggleImpl implements ItsNatFreeRadioButton,
034: ItsNatButtonRadioInternal {
035: protected ItsNatButtonGroupImpl itsNatButtonGroup;
036:
037: /**
038: * Creates a new instance of ItsNatFreeRadioButtonImpl
039: */
040: public ItsNatFreeRadioButtonImpl(Element element,
041: NameValue[] artifacts,
042: ItsNatComponentManagerImpl componentMgr) {
043: super (element, artifacts, componentMgr);
044: }
045:
046: public ItsNatButtonRadioUI createDefaultItsNatFreeRadioButtonUI() {
047: return new ItsNatFreeRadioButtonUIImpl(this );
048: }
049:
050: public ItsNatComponentUI createDefaultItsNatComponentUI() {
051: return createDefaultItsNatFreeRadioButtonUI();
052: }
053:
054: public ItsNatButtonRadioUI getItsNatButtonRadioUI() {
055: return (ItsNatButtonRadioUI) compUI;
056: }
057:
058: public void syncWithDataModel() {
059: super .syncWithDataModel();
060:
061: ItsNatButtonRadioBasedSharedImpl.syncWithDataModel(this );
062: }
063:
064: public ToggleButtonModel getToggleButtonModelNoUpdateButtonGroup() {
065: return super .getToggleButtonModel();
066: }
067:
068: public ButtonModel getButtonModel() {
069: return getToggleButtonModel();
070: }
071:
072: public void setButtonModel(ButtonModel dataModel) {
073: super .setButtonModel(dataModel);
074:
075: getToggleButtonModel(); // Para que se actualice el group del nuevo data model
076: }
077:
078: public ToggleButtonModel getToggleButtonModel() {
079: // Como el cambio de ButtonGroup en el data model no genera eventos hemos de sincronizar en cuanto se pueda
080: ToggleButtonModel model = super .getToggleButtonModel();
081: setButtonGroup(model.getGroup()); // Si no hay cambio no hace nada
082: return model;
083: }
084:
085: public void setToggleButtonModel(ToggleButtonModel dataModel) {
086: super .setToggleButtonModel(dataModel);
087:
088: getToggleButtonModel(); // Para que se actualice el group del nuevo data model
089: }
090:
091: public ItsNatButtonGroup getItsNatButtonGroup() {
092: // Como el cambio de ButtonGroup en el data model no genera eventos hemos de sincronizar en cuanto se pueda
093: getToggleButtonModel(); // Actualiza el ButtonGroup si ha cambiado
094:
095: return itsNatButtonGroup;
096: }
097:
098: public ItsNatButtonGroup setButtonGroup(ButtonGroup group) {
099: return ItsNatButtonRadioBasedSharedImpl.setButtonGroup(this ,
100: this .itsNatButtonGroup, group);
101: }
102:
103: public void setItsNatButtonGroup(ItsNatButtonGroup buttonGroup) {
104: setItsNatButtonGroup(buttonGroup, true);
105: }
106:
107: public void setItsNatButtonGroup(ItsNatButtonGroup buttonGroup,
108: boolean addToGroup) {
109: setItsNatButtonGroup(buttonGroup, addToGroup, true);
110: }
111:
112: public void setItsNatButtonGroup(ItsNatButtonGroup buttonGroup,
113: boolean addToGroup, boolean updateUI) {
114: this .itsNatButtonGroup = (ItsNatButtonGroupImpl) buttonGroup;
115:
116: ItsNatButtonRadioBasedSharedImpl.setItsNatButtonGroup(this,
117: this.itsNatButtonGroup, addToGroup, updateUI);
118: }
119:
120: }
|