Revision 501
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.main/src/main/java/org/gvsig/tools/main/usability/UsabilityAction.java | ||
---|---|---|
32 | 32 |
import javax.swing.JButton; |
33 | 33 |
import javax.swing.JComponent; |
34 | 34 |
import javax.swing.JPanel; |
35 |
import javax.swing.JSpinner; |
|
35 | 36 |
import javax.swing.JTabbedPane; |
37 |
import javax.swing.JTextArea; |
|
36 | 38 |
|
39 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
37 | 40 |
import org.gvsig.tools.main.MainAction; |
38 | 41 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
39 | 42 |
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager; |
... | ... | |
64 | 67 |
tabbedPane.setTabPlacement(JTabbedPane.RIGHT); |
65 | 68 |
|
66 | 69 |
tabbedPane.addTab("JButton", createJButtonComponent()); |
67 |
|
|
70 |
tabbedPane.addTab("JTextArea", createJTextAreaComponent()); |
|
71 |
tabbedPane.addTab("JNullSpinner", createJNullSpinnerComponent()); |
|
68 | 72 |
return tabbedPane; |
69 | 73 |
} |
70 | 74 |
|
... | ... | |
79 | 83 |
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); |
80 | 84 |
// panel.setLayout(new GridLayout(18, 1)); |
81 | 85 |
// panel.setLayout(new ); |
82 |
|
|
86 |
JButton button = manager.createJButton("+"); |
|
87 |
panel.add(button); |
|
88 |
button = manager.createJButton("-"); |
|
89 |
panel.add(button); |
|
90 |
button = manager.createJToolButton("+"); |
|
91 |
panel.add(button); |
|
92 |
button = manager.createJToolButton("-"); |
|
93 |
panel.add(button); |
|
83 | 94 |
// Create buttons with different sizes |
84 | 95 |
StringBuffer text = new StringBuffer("012"); |
85 | 96 |
for (int i = 4; i < 22; i++) { |
86 | 97 |
text.append(String.valueOf(i % 10)); |
87 |
JButton button = manager.createJButton(text.toString());
|
|
98 |
button = manager.createJButton(text.toString()); |
|
88 | 99 |
panel.add(button); |
89 | 100 |
} |
90 | 101 |
|
91 | 102 |
return panel; |
92 | 103 |
} |
93 | 104 |
|
105 |
private Component createJTextAreaComponent() { |
|
106 |
// Create the container panel |
|
107 |
JPanel panel = new JPanel(); |
|
108 |
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); |
|
109 |
// panel.setLayout(new GridLayout(18, 1)); |
|
110 |
// panel.setLayout(new ); |
|
111 |
JTextArea ta = manager.createJTextArea(""); |
|
112 |
ta = manager.createJTextArea("test"); |
|
113 |
panel.add(ta); |
|
114 |
ta = manager.createJTextArea("test longer"); |
|
115 |
panel.add(ta); |
|
116 |
ta = manager.createJTextArea("test much longer"); |
|
117 |
panel.add(ta); |
|
118 |
ta = manager.createJTextArea("test"); |
|
119 |
panel.add(ta); |
|
120 |
ta = manager.createJTextArea("test size = 150", 150); |
|
121 |
panel.add(ta); |
|
122 |
ta = manager.createJTextArea("test too long", -1); |
|
123 |
panel.add(ta); |
|
124 |
// Create buttons with different sizes |
|
125 |
StringBuffer text = new StringBuffer("012"); |
|
126 |
for (int i = 4; i < 22; i++) { |
|
127 |
text.append(String.valueOf(i % 10)); |
|
128 |
ta = manager.createJTextArea(text.toString()); |
|
129 |
panel.add(ta); |
|
130 |
} |
|
131 |
|
|
132 |
|
|
133 |
return panel; |
|
134 |
} |
|
135 |
|
|
136 |
private Component createJNullSpinnerComponent() { |
|
137 |
// Create the container panel |
|
138 |
JPanel panel = new JPanel(); |
|
139 |
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); |
|
140 |
// panel.setLayout(new GridLayout(18, 1)); |
|
141 |
// panel.setLayout(new ); |
|
142 |
JSpinner spinner = manager.createJNullSpinner(DataTypes.FLOAT, "1.05", -1); |
|
143 |
panel.add(spinner); |
|
144 |
// Create buttons with different sizes |
|
145 |
StringBuffer text = new StringBuffer("01287."); |
|
146 |
for (int i = 4; i < 22; i++) { |
|
147 |
text.append(String.valueOf(i % 10)); |
|
148 |
spinner = manager.createJNullSpinner(DataTypes.FLOAT, text.toString(), -1); |
|
149 |
panel.add(spinner); |
|
150 |
} |
|
151 |
|
|
152 |
return panel; |
|
153 |
} |
|
154 |
|
|
94 | 155 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.main/src/main/java/org/gvsig/tools/main/dynobject/TestDynObject.java | ||
---|---|---|
55 | 55 |
*/ |
56 | 56 |
public class TestDynObject extends DefaultDynClass { |
57 | 57 |
|
58 |
public static final String TESTDYNOBJECT_NAME = "Test"; |
|
59 |
public static final String TESTDYNOBJECTREADONLY_NAME = "TestReadOnly"; |
|
60 |
|
|
58 | 61 |
private static DynObjectSwingManager swingManager = |
59 | 62 |
ToolsSwingLocator.getDynObjectSwingManager(); |
60 | 63 |
|
61 | 64 |
private static DynObjectManager dynManager = |
62 | 65 |
ToolsLocator.getDynObjectManager(); |
66 |
|
|
67 |
|
|
63 | 68 |
|
64 | 69 |
public static void registerDynObject() { |
65 |
dynManager.add(new TestDynObject("Test", "test dynclass")); |
|
70 |
dynManager.add(new TestDynObject(TESTDYNOBJECT_NAME, "Test dynclass", false)); |
|
71 |
dynManager.add(new TestDynObject(TESTDYNOBJECTREADONLY_NAME, "Test dynclass with readonly fields", true)); |
|
66 | 72 |
} |
67 | 73 |
|
68 |
// private DynClass createDynClass(DynClass dynClass) { |
|
69 |
// DynClass dynClass2 = createDynClass2(dynClass); |
|
70 |
// // dynClass2.addDynField("dynObject").setType(DataTypes.DYNOBJECT); |
|
71 |
// return dynClass2; |
|
72 |
// } |
|
73 | 74 |
|
74 |
// |
|
75 | 75 |
/** |
76 | 76 |
* @param manager |
77 | 77 |
* @param name |
78 | 78 |
* @param description |
79 | 79 |
*/ |
80 |
public TestDynObject(String name, String description) { |
|
80 |
public TestDynObject(String name, String description, boolean allReadOnly) {
|
|
81 | 81 |
super(dynManager, name, description); |
82 |
initDynClass(); |
|
82 |
if(!allReadOnly){ |
|
83 |
initDynClass(); |
|
84 |
}else{ |
|
85 |
initReadOnlyDynClass(); |
|
86 |
} |
|
83 | 87 |
} |
84 | 88 |
|
85 | 89 |
/** |
... | ... | |
104 | 108 |
DynObjectModel model = swingManager.createEmptyDynObjectModel(this); |
105 | 109 |
model.add("text"); |
106 | 110 |
model.add("label"); |
111 |
model.add("text-list"); |
|
112 |
model.add("label-list"); |
|
113 |
|
|
107 | 114 |
model.add("boolean"); |
108 | 115 |
model.add("boolean-list"); |
109 | 116 |
|
... | ... | |
145 | 152 |
List<Boolean> booleanList = new ArrayList<Boolean>(); |
146 | 153 |
dynObject.setDynValue("boolean-list", booleanList); |
147 | 154 |
|
148 |
// a?ado los valores del list
|
|
155 |
// adding list values
|
|
149 | 156 |
booleanList.add(true); |
150 | 157 |
booleanList.add(false); |
151 | 158 |
booleanList.add(null); |
152 | 159 |
|
160 |
// STRING LIST |
|
161 |
List<String> stringList = new ArrayList<String>(); |
|
162 |
dynObject.setDynValue("text-list", stringList); |
|
163 |
|
|
164 |
// adding list values |
|
165 |
stringList.add("string-1"); |
|
166 |
stringList.add("string-2"); |
|
167 |
stringList.add("string-3"); |
|
168 |
|
|
169 |
|
|
170 |
// LABEL LIST |
|
171 |
List<String> labelList = new ArrayList<String>(); |
|
172 |
dynObject.setDynValue("label-list", labelList); |
|
173 |
|
|
174 |
// adding list values |
|
175 |
labelList.add("label-1"); |
|
176 |
labelList.add("label-2"); |
|
177 |
labelList.add("label-3"); |
|
178 |
|
|
179 |
|
|
153 | 180 |
// INTEGER LIST |
154 | 181 |
List<Integer> integerList = new ArrayList<Integer>(); |
155 | 182 |
dynObject.setDynValue("integer-list", integerList); |
... | ... | |
205 | 232 |
return dynObject; |
206 | 233 |
} |
207 | 234 |
|
208 |
/** |
|
209 |
* @return |
|
210 |
*/ |
|
211 | 235 |
private void initDynClass() { |
212 | 236 |
|
213 | 237 |
this.addDynFieldList("Address-list").setMandatory(true) |
... | ... | |
219 | 243 |
|
220 | 244 |
this.addDynFieldInt("integer").setReadOnly(true).setMandatory(true); |
221 | 245 |
|
246 |
|
|
247 |
this.addDynFieldList("text-list").setMandatory(true) |
|
248 |
.setElementsType(DataTypes.STRING); |
|
249 |
|
|
250 |
this.addDynFieldList("label-list").setMandatory(true) |
|
251 |
.setElementsType(DataTypes.STRING).setReadOnly(true); |
|
252 |
|
|
222 | 253 |
this.addDynFieldList("boolean-list").setMandatory(true) |
223 | 254 |
.setElementsType(DataTypes.BOOLEAN); |
224 | 255 |
this.addDynFieldList("integer-list").setMandatory(true) |
... | ... | |
262 | 293 |
DataTypes.DATE); |
263 | 294 |
} |
264 | 295 |
|
296 |
private void initReadOnlyDynClass() { |
|
297 |
|
|
298 |
this.addDynFieldList("Address-list").setMandatory(true) |
|
299 |
.setElementsType(DataTypes.DYNOBJECT).setReadOnly(true); |
|
300 |
|
|
301 |
// TODO add all the available data types |
|
302 |
this.addDynFieldString("text").setReadOnly(true); |
|
303 |
this.addDynFieldString("label").setReadOnly(true); |
|
304 |
|
|
305 |
this.addDynFieldInt("integer").setReadOnly(true).setMandatory(true); |
|
306 |
|
|
307 |
|
|
308 |
this.addDynFieldList("text-list").setMandatory(true) |
|
309 |
.setElementsType(DataTypes.STRING).setReadOnly(true); |
|
310 |
|
|
311 |
this.addDynFieldList("label-list").setMandatory(true) |
|
312 |
.setElementsType(DataTypes.STRING).setReadOnly(true); |
|
313 |
|
|
314 |
this.addDynFieldList("boolean-list").setMandatory(true) |
|
315 |
.setElementsType(DataTypes.BOOLEAN).setReadOnly(true); |
|
316 |
this.addDynFieldList("integer-list").setMandatory(true) |
|
317 |
.setElementsType(DataTypes.INT).setReadOnly(true); |
|
318 |
this.addDynFieldFloat("float").setReadOnly(true); |
|
319 |
this.addDynFieldList("float-list").setMandatory(true).setElementsType( |
|
320 |
DataTypes.FLOAT).setReadOnly(true); |
|
321 |
//revisar esto |
|
322 |
this.addDynField("byte").setType(DataTypes.BYTE).setReadOnly(true); |
|
323 |
this.addDynFieldList("byte-list").setMandatory(true).setElementsType( |
|
324 |
DataTypes.BYTE).setReadOnly(true); |
|
325 |
|
|
326 |
DynObjectValueItem[] values = new DynObjectValueItem[3]; |
|
327 |
values[0] = new DynObjectValueItem(0, "monday"); |
|
328 |
values[1] = new DynObjectValueItem(1, "tuesday"); |
|
329 |
values[2] = new DynObjectValueItem(2, "wednesday"); |
|
330 |
this.addDynFieldInt("combo").setDefaultFieldValue(0) |
|
331 |
.setAvailableValues(values).setMandatory(true).setReadOnly(true); |
|
332 |
|
|
333 |
this.addDynFieldList("combo-list").setMandatory(true).setElementsType( |
|
334 |
DataTypes.INT).getElementsType().setAvailableValues(values).setReadOnly(true); |
|
335 |
|
|
336 |
this.addDynField("file").setMandatory(true).setType(DataTypes.FILE).setReadOnly(true); |
|
337 |
this.addDynField("folder").setMandatory(true).setType(DataTypes.FOLDER); |
|
338 |
this.addDynFieldList("folders").setElementsType(DataTypes.FOLDER); |
|
339 |
this.addDynFieldList("files").setElementsType(DataTypes.FILE).setReadOnly(true); |
|
340 |
|
|
341 |
this.addDynFieldDate("date").setMandatory(true).setSubtype(null).setReadOnly(true); |
|
342 |
this.addDynField("date-only").setMandatory(true) |
|
343 |
.setType(DataTypes.DATE).setSubtype(DataTypes.SUBTYPE_DATE).setReadOnly(true); |
|
344 |
this.addDynFieldDate("time-only").setMandatory(true).setType( |
|
345 |
DataTypes.TIME).setSubtype(null).setReadOnly(true); |
|
346 |
this.addDynField("timestamp").setMandatory(true).setType( |
|
347 |
DataTypes.TIMESTAMP).setReadOnly(true); |
|
348 |
|
|
349 |
this.addDynFieldBoolean("boolean").setReadOnly(true); |
|
350 |
|
|
351 |
this.addDynField("Address").setType(DataTypes.DYNOBJECT).setReadOnly(true); |
|
352 |
|
|
353 |
this.addDynFieldList("dates").setMandatory(true).setElementsType( |
|
354 |
DataTypes.DATE).setReadOnly(true); |
|
355 |
} |
|
356 |
|
|
357 |
|
|
265 | 358 |
// public DynObject createDynObject() { |
266 | 359 |
// DynObject dynObject = dynManager.createDynObject(this); |
267 | 360 |
// |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.main/src/main/java/org/gvsig/tools/main/dynobject/DynObjectComponentAction.java | ||
---|---|---|
45 | 45 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
46 | 46 |
import org.gvsig.tools.swing.api.dynobject.DynObjectSwingManager; |
47 | 47 |
import org.gvsig.tools.swing.api.dynobject.JDynObjectComponent; |
48 |
import org.gvsig.tools.swing.api.dynobject.dynfield.JDynComponent; |
|
48 | 49 |
|
49 | 50 |
/** |
50 | 51 |
* Action used to show the DynObject components panel |
... | ... | |
63 | 64 |
|
64 | 65 |
private JDynObjectComponent dynObjectView; |
65 | 66 |
|
67 |
private String dynObjectID; |
|
68 |
|
|
66 | 69 |
/** |
67 | 70 |
* @see MainAction#MainAction(JTabbedPane) |
68 | 71 |
*/ |
69 |
public DynObjectComponentAction(JTabbedPane tabbedPane) { |
|
70 |
super("DynObject", tabbedPane); |
|
72 |
public DynObjectComponentAction(JTabbedPane tabbedPane, String dynObjectID) { |
|
73 |
super(dynObjectID + "Action", tabbedPane); |
|
74 |
this.dynObjectID= dynObjectID; |
|
71 | 75 |
putValue(SHORT_DESCRIPTION, "DynObject viewer components"); |
72 |
registerDynObjects(); |
|
73 | 76 |
} |
74 | 77 |
|
75 | 78 |
@Override |
76 | 79 |
protected JComponent createComponent() { |
77 | 80 |
JPanel mainPane = new JPanel(new BorderLayout()); |
78 |
dynObjectView = getDynObjectView(); |
|
81 |
dynObjectView = getDynObjectView(dynObjectID);
|
|
79 | 82 |
if (dynObjectView == null) |
80 | 83 |
return mainPane; |
81 | 84 |
|
... | ... | |
102 | 105 |
/** |
103 | 106 |
* @return |
104 | 107 |
*/ |
105 |
private JDynObjectComponent getDynObjectView() { |
|
108 |
private JDynObjectComponent getDynObjectView(String dynObjectID) {
|
|
106 | 109 |
if (dynObjectView != null) |
107 | 110 |
return dynObjectView; |
108 | 111 |
try { |
109 | 112 |
TestDynObject testDynObject = |
110 |
(TestDynObject) dynManager.get("Test");
|
|
113 |
(TestDynObject) dynManager.get(dynObjectID);
|
|
111 | 114 |
this.dynObjectView = |
112 | 115 |
swingManager.createJDynObjectComponent(testDynObject |
113 | 116 |
.createDynObject(), testDynObject.createDynModel()); |
... | ... | |
135 | 138 |
frame.setVisible(true); |
136 | 139 |
} |
137 | 140 |
|
138 |
public void registerDynObjects() { |
|
141 |
private JDynObjectComponent getDynObjectView() { |
|
142 |
return this.getDynObjectView(dynObjectID); |
|
143 |
} |
|
144 |
|
|
145 |
public static void registerDynObjects() { |
|
139 | 146 |
TestDynObject.registerDynObject(); |
140 | 147 |
Address.registerDynObject(); |
141 | 148 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.main/src/main/java/org/gvsig/tools/main/Main.java | ||
---|---|---|
17 | 17 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
18 | 18 |
import org.gvsig.tools.main.dynobject.DynObjectComponentAction; |
19 | 19 |
import org.gvsig.tools.main.dynobject.DynObjectSetComponentAction; |
20 |
import org.gvsig.tools.main.dynobject.TestDynObject; |
|
20 | 21 |
import org.gvsig.tools.main.taskstatus.JTaskStatusAction; |
21 | 22 |
import org.gvsig.tools.main.usability.UsabilityAction; |
22 | 23 |
|
... | ... | |
31 | 32 |
|
32 | 33 |
public static void main(String args[]) { |
33 | 34 |
new DefaultLibrariesInitializer().fullInitialize(); |
35 |
DynObjectComponentAction.registerDynObjects(); |
|
34 | 36 |
Main main = new Main(); |
35 | 37 |
main.show(); |
36 | 38 |
} |
... | ... | |
91 | 93 |
|
92 | 94 |
private MainAction[] createActions() { |
93 | 95 |
return new MainAction[] { |
94 |
new DynObjectComponentAction(tabbedPane), |
|
96 |
new DynObjectComponentAction(tabbedPane, TestDynObject.TESTDYNOBJECT_NAME), |
|
97 |
new DynObjectComponentAction(tabbedPane, TestDynObject.TESTDYNOBJECTREADONLY_NAME), |
|
95 | 98 |
new DynObjectSetComponentAction(tabbedPane), |
96 | 99 |
new UsabilityAction(tabbedPane), |
97 | 100 |
new JTaskStatusAction(tabbedPane) |
Also available in: Unified diff