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.codegen.builder;
20:
21: import java.awt.Color;
22: import java.awt.Font;
23: import java.util.HashMap;
24:
25: import com.jeta.forms.store.properties.BorderProperty;
26: import com.jeta.forms.store.properties.ButtonGroupProperty;
27: import com.jeta.forms.store.properties.CompoundBorderProperty;
28: import com.jeta.forms.store.properties.IconProperty;
29: import com.jeta.forms.store.properties.ItemsProperty;
30: import com.jeta.forms.store.properties.ScrollBarsProperty;
31: import com.jeta.forms.store.properties.TabbedPaneProperties;
32: import com.jeta.forms.store.properties.TransformOptionsProperty;
33: import com.jeta.swingbuilder.codegen.builder.properties.BooleanPropertyWriter;
34: import com.jeta.swingbuilder.codegen.builder.properties.BorderPropertyBuilder;
35: import com.jeta.swingbuilder.codegen.builder.properties.ButtonGroupWriter;
36: import com.jeta.swingbuilder.codegen.builder.properties.ColorPropertyWriter;
37: import com.jeta.swingbuilder.codegen.builder.properties.FloatPropertyWriter;
38: import com.jeta.swingbuilder.codegen.builder.properties.FontPropertyWriter;
39: import com.jeta.swingbuilder.codegen.builder.properties.IconPropertyWriter;
40: import com.jeta.swingbuilder.codegen.builder.properties.IntegerPropertyWriter;
41: import com.jeta.swingbuilder.codegen.builder.properties.ItemsPropertyWriter;
42: import com.jeta.swingbuilder.codegen.builder.properties.ScrollPaneWriter;
43: import com.jeta.swingbuilder.codegen.builder.properties.StringPropertyBuilder;
44: import com.jeta.swingbuilder.codegen.builder.properties.TabbedPanePropertyWriter;
45: import com.jeta.swingbuilder.codegen.builder.properties.TransformPropertyWriter;
46:
47: public class PropertyWriterFactory {
48: public static final String COMPONENT_ID = "property.writer.factory";
49:
50: private HashMap m_writers = new HashMap();
51:
52: public PropertyWriterFactory() {
53: m_writers.put(String.class, new StringPropertyBuilder());
54: m_writers.put(java.awt.Color.class, new ColorPropertyWriter());
55: m_writers.put(ScrollBarsProperty.class, new ScrollPaneWriter());
56: m_writers.put(TabbedPaneProperties.class,
57: new TabbedPanePropertyWriter());
58: m_writers
59: .put(BorderProperty.class, new BorderPropertyBuilder());
60: m_writers.put(CompoundBorderProperty.class,
61: new BorderPropertyBuilder());
62: m_writers.put(ItemsProperty.class, new ItemsPropertyWriter());
63: m_writers.put(ButtonGroupProperty.class,
64: new ButtonGroupWriter());
65:
66: m_writers.put(int.class, new IntegerPropertyWriter());
67: m_writers.put(Integer.class, new IntegerPropertyWriter());
68: m_writers.put(short.class, new IntegerPropertyWriter());
69: m_writers.put(Short.class, new IntegerPropertyWriter());
70: m_writers.put(byte.class, new IntegerPropertyWriter());
71: m_writers.put(Byte.class, new IntegerPropertyWriter());
72: m_writers.put(long.class, new IntegerPropertyWriter());
73: m_writers.put(Long.class, new IntegerPropertyWriter());
74:
75: m_writers.put(float.class, new FloatPropertyWriter());
76: m_writers.put(Float.class, new FloatPropertyWriter());
77: m_writers.put(double.class, new FloatPropertyWriter());
78: m_writers.put(Double.class, new FloatPropertyWriter());
79:
80: m_writers.put(Font.class, new FontPropertyWriter());
81: m_writers.put(Color.class, new ColorPropertyWriter());
82: m_writers.put(boolean.class, new BooleanPropertyWriter());
83: m_writers.put(Boolean.class, new BooleanPropertyWriter());
84: m_writers.put(javax.swing.Icon.class, new IconPropertyWriter());
85: m_writers.put(javax.swing.ImageIcon.class,
86: new IconPropertyWriter());
87: m_writers.put(IconProperty.class, new IconPropertyWriter());
88: m_writers.put(TransformOptionsProperty.class,
89: new TransformPropertyWriter());
90: }
91:
92: public PropertyWriter createWriter(Class type) {
93: PropertyWriter writer = (PropertyWriter) m_writers.get(type);
94: return writer;
95: }
96: }
|