01: /*
02: * Copyright (C) 2005 Jeff Tassin
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:
19: package com.jeta.swingbuilder.gui.components.panel;
20:
21: import java.awt.Color;
22: import java.awt.Component;
23:
24: import com.jeta.forms.components.colors.ColorSelector;
25: import com.jeta.forms.components.colors.JETAColorWell;
26: import com.jeta.forms.components.panel.FormPanel;
27: import com.jeta.forms.store.properties.ColorProperty;
28:
29: /**
30: * An extension of FormPanel to provde some common features needed in the swing
31: * builder app.
32: *
33: * @author Jeff Tassin
34: */
35: public class SwingBuilderPanel extends FormPanel {
36: /**
37: * ctor
38: *
39: * @param formPath
40: * the path to the form file. This path can be absolute or
41: * relative to the classpath.
42: */
43: public SwingBuilderPanel(String formPath) {
44: super (formPath);
45: }
46:
47: /**
48: * @return the ColorProperty for the JETAColorWell with the given name. Null
49: * is returned if a JETAColorWell cannot be found.
50: */
51: public Color getColor(String compName) {
52: Component comp = getComponentByName(compName);
53: if (comp instanceof JETAColorWell) {
54: return ((JETAColorWell) comp).getColor();
55: } else
56: return null;
57: }
58:
59: /**
60: * @return the ColorProperty for the ColorSelector with the given name. Null
61: * is returned if a ColorSelector cannot be found.
62: */
63: public ColorProperty getColorProperty(String compName) {
64: Component comp = getComponentByName(compName);
65: if (comp instanceof ColorSelector) {
66: return ((ColorSelector) comp).getColorProperty();
67: } else
68: return null;
69: }
70:
71: /**
72: * Sets the Color for the JETAColorWell with the given name. The call is
73: * ignored if a JETAColorWell cannot be found.
74: */
75: public void setColorProperty(String compName, ColorProperty cprop) {
76: Component comp = getComponentByName(compName);
77: if (comp instanceof ColorSelector) {
78: ((ColorSelector) comp).setColorProperty(cprop);
79: }
80: }
81:
82: /**
83: * Sets the ColorProperty for the ColorSelector with the given name. The
84: * call is ignored if a ColorSelector cannot be found.
85: */
86: public void setColor(String compName, Color cprop) {
87: Component comp = getComponentByName(compName);
88: if (comp instanceof JETAColorWell) {
89: ((JETAColorWell) comp).setColor(cprop);
90: }
91: }
92:
93: }
|