1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package org.mlc.swing.layout;
31
32 import com.jgoodies.forms.factories.DefaultComponentFactory;
33 import java.util.ArrayList;
34 import java.util.List;
35 import java.util.Map;
36
37 /***
38 * This is the component builder for the JGoodies Separator.
39 *
40 * @author Michael Connor
41 */
42 public class SeparatorComponentBuilder implements ComponentBuilder
43 {
44 List<BeanProperty> properties = new ArrayList<BeanProperty>();
45
46 private static final String TEXT = "text";
47
48 /*** Creates a new instance of SeparatorComponentBuilder */
49 public SeparatorComponentBuilder()
50 {
51 properties.add(new BeanProperty(TEXT, String.class));
52 }
53
54 public String getDeclaration(String name,
55 java.util.Map<String, Object> beanProperties)
56 {
57 String text = (String) beanProperties.get(TEXT);
58 if (text == null)
59 text = "";
60 return "java.awt.Component "
61 + name
62 + " = com.jgoodies.forms.factories.DefaultComponentFactory.getInstance().createSeparator(\""
63 + text + "\");\n";
64 }
65
66 public java.awt.Component getInstance(
67 java.util.Map<String, Object> beanProperties) throws Exception
68 {
69 String text = (String) beanProperties.get(TEXT);
70 if (text == null)
71 text = "";
72 return DefaultComponentFactory.getInstance().createSeparator(text);
73 }
74
75 public java.util.List<BeanProperty> getProperties()
76 {
77 return properties;
78 }
79
80 public boolean isComponentALayoutContainer()
81 {
82 return false;
83 }
84
85 public String toString()
86 {
87 return "JGoodies separator";
88 }
89 public ComponentDef getComponentDef(String name, Map<String, Object> beanProperties)
90 {
91 String imp = "";
92 String decl = getDeclaration(name, beanProperties);
93 String add = "${container}.add(${name}, \"${name}\");";
94 ComponentDef cd = new ComponentDef(name,imp,decl,add);
95 return cd;
96 }
97
98 }