1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.cosylab.gui.components;
21
22 import java.awt.Component;
23 import java.beans.IntrospectionException;
24 import java.beans.PropertyEditorSupport;
25
26 import com.cosylab.util.BeanInfoSupport;
27
28
29
30
31
32
33 public class AbstractDisplayerPanelBeanInfo extends BeanInfoSupport {
34
35 public class OrientationPropertyEditor extends PropertyEditorSupport {
36 private static final String DYNAMIC_LAYOUT = "Automatic Layout";
37 private static final String VERTICAL_LAYOUT = "Vertical Layout";
38 private static final String HORIZONTAL_LAYOUT = "Horizontal Layout";
39
40 private int value=0;
41
42 public boolean isPaintable() {
43 return false;
44 }
45
46 public boolean supportsCustomEditor() {
47 return false;
48 }
49
50 public Component getCustomEditor() {
51 return null;
52 }
53
54 public Object getValue() {
55 return new Integer(value);
56 }
57
58 public void setValue(Object value) {
59 this.value = ((Number)value).intValue();
60 firePropertyChange();
61 }
62
63 public String getAsText() {
64 if (value==AbstractDisplayerPanel.DYNAMIC_LAYOUT) return DYNAMIC_LAYOUT;
65 if (value==AbstractDisplayerPanel.HORIZONTAL_LAYOUT) return HORIZONTAL_LAYOUT;
66 if (value==AbstractDisplayerPanel.VERTICAL_LAYOUT) return VERTICAL_LAYOUT;
67 return null;
68 }
69
70 public String getJavaInitializationString() {
71 return Integer.toString(value);
72 }
73
74 public String[] getTags() {
75 return new String[]{HORIZONTAL_LAYOUT,VERTICAL_LAYOUT,DYNAMIC_LAYOUT};
76 }
77
78 public void setAsText(String text) throws IllegalArgumentException {
79 if (text.equals(DYNAMIC_LAYOUT)) value = AbstractDisplayerPanel.DYNAMIC_LAYOUT;
80 if (text.equals(HORIZONTAL_LAYOUT)) value = AbstractDisplayerPanel.HORIZONTAL_LAYOUT;
81 if (text.equals(VERTICAL_LAYOUT)) value = AbstractDisplayerPanel.VERTICAL_LAYOUT;
82 firePropertyChange();
83 }
84
85 }
86
87
88
89
90
91
92 public AbstractDisplayerPanelBeanInfo() throws IntrospectionException {
93 setBeanDescriptor(AbstractDisplayerPanelCustomizer.class);
94 loadDefaultPropertyDescriptors();
95 setPropertyEditor("layoutOrientation",OrientationPropertyEditor.class);
96 removePropertyDescriptor("state");
97 }
98
99 }