01: /* SwingML
02: * Copyright (C) 2002 Bram Stieperaere.
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 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
16: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17: * Boston, MA 02111-1307, USA.
18: *
19: * Authors:
20: * Bram Stieperaere <bramez@users.sourceforge.net>
21: *
22: */
23:
24: package org.swingml.xml.mapper;
25:
26: import java.awt.*;
27:
28: import org.swingml.*;
29: import org.swingml.model.*;
30: import org.swingml.xml.*;
31: import org.w3c.dom.*;
32:
33: public class JRadioButtonMapper extends MapperUtil implements Mapper {
34:
35: public Object getModelToMap(final Node n, final Object o,
36: final Container aContainer) {
37: JRadioButtonModel jrbm = new JRadioButtonModel();
38: SwingMLModel smlm = (SwingMLModel) o;
39: smlm.addChild(jrbm);
40: jrbm.setParent(smlm);
41:
42: return jrbm;
43: }
44:
45: public void mapModel(final Node n, final Object o,
46: Container aContainer) {
47: JRadioButtonModel jrbm = (JRadioButtonModel) getModelToMap(n,
48: o, aContainer);
49: mapModelAttributes(n, jrbm, o);
50: super .iterate(n, jrbm, aContainer);
51: }
52:
53: public void mapModelAttributes(final Node n, final Object m,
54: final Object p) {
55: JRadioButtonModel model = (JRadioButtonModel) m;
56: super .mapCommonAttributes(model, n);
57:
58: Node node = getAttribute(n, Constants.CHECKED);
59: if (node != null) {
60: model.setChecked(node.getNodeValue().equalsIgnoreCase(
61: Constants.TRUE));
62: }
63:
64: node = getAttribute(n, Constants.ALIGN);
65: if (node != null) {
66: model.setAlign(node.getNodeValue());
67: }
68:
69: node = getAttribute(n, Constants.ENABLED);
70: if (node != null) {
71: model.setEnabled(node.getNodeValue().equalsIgnoreCase(
72: Constants.TRUE));
73: }
74:
75: node = super.getAttribute(n, Constants.FONT);
76: if (node != null) {
77: model.setFontName(node.getNodeValue());
78: }
79:
80: node = super.getAttribute(n, Constants.FONT_SIZE);
81: if (node != null) {
82: model.setFontSize(node.getNodeValue());
83: }
84: }
85: }
|