01: /*
02: * Copyright (C) 2004 TiongHiang Lee
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: * Email: thlee@onemindsoft.org
19: */
20:
21: package org.onemind.swingweb.templaterender.peerdelegate.javax.swing;
22:
23: import javax.swing.*;
24: import org.onemind.awtbridge.peer.BridgeButtonGroupPeer;
25: import org.onemind.awtbridge.peer.BridgePeer;
26: import org.onemind.swingweb.templaterender.peerdelegate.TemplateRenderDelegate;
27:
28: /**
29: * The AbstractButton render delegate
30: * @author TiongHiang Lee (thlee@onemindsoft.org)
31: *
32: */
33: public class AbstractButtonRenderDelegate extends
34: JComponentRenderDelegate {
35: /** the instance **/
36: public static TemplateRenderDelegate INSTANCE = new AbstractButtonRenderDelegate();
37:
38: /**
39: * Get the group id for the abstract button render delegate
40: * @param peer the peer
41: * @return the group id
42: */
43: public String getGroupId(BridgePeer peer) {
44: AbstractButton cb = (AbstractButton) peer.getComponentObject();
45: ButtonGroup grp = ((DefaultButtonModel) cb.getModel())
46: .getGroup();
47: if (grp != null) {
48: BridgeButtonGroupPeer grpPeer = (BridgeButtonGroupPeer) peer
49: .getContext().getPeer(grp);
50: if (grpPeer == null) {
51: grpPeer = (BridgeButtonGroupPeer) peer
52: .getBridgeToolkit().createButtonGroupPeer(grp);
53: }
54: return grpPeer.getId();
55: } else {
56: return "";
57: }
58: }
59: }
|