gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.swing / org.gvsig.tools.swing.impl / src / main / java / org / gvsig / tools / swing / impl / dynclass / DynClassView.java @ 1405
History | View | Annotate | Download (14.7 KB)
1 |
package org.gvsig.tools.swing.impl.dynclass; |
---|---|
2 |
|
3 |
import com.jeta.open.i18n.I18NUtils; |
4 |
import com.jgoodies.forms.layout.CellConstraints; |
5 |
import com.jgoodies.forms.layout.FormLayout; |
6 |
import java.awt.BorderLayout; |
7 |
import java.awt.ComponentOrientation; |
8 |
import java.awt.Container; |
9 |
import java.awt.Dimension; |
10 |
import javax.swing.Box; |
11 |
import javax.swing.ImageIcon; |
12 |
import javax.swing.JButton; |
13 |
import javax.swing.JComboBox; |
14 |
import javax.swing.JFrame; |
15 |
import javax.swing.JLabel; |
16 |
import javax.swing.JList; |
17 |
import javax.swing.JPanel; |
18 |
import javax.swing.JScrollPane; |
19 |
import javax.swing.JTabbedPane; |
20 |
import javax.swing.JTable; |
21 |
import javax.swing.JTextArea; |
22 |
import javax.swing.JTextField; |
23 |
|
24 |
|
25 |
public class DynClassView extends JPanel |
26 |
{ |
27 |
JTabbedPane jtabbedpane1 = new JTabbedPane(); |
28 |
JTextArea txtDescription = new JTextArea(); |
29 |
JTextField txtNamespace = new JTextField(); |
30 |
JTextField txtName = new JTextField(); |
31 |
JTextField txtLabel = new JTextField(); |
32 |
JTable tblFields = new JTable(); |
33 |
JButton btnModifyField = new JButton(); |
34 |
JButton btnAddField = new JButton(); |
35 |
JButton btnDeleteField = new JButton(); |
36 |
JTable tblTags = new JTable(); |
37 |
JButton btnModifyTag = new JButton(); |
38 |
JButton btnAddTag = new JButton(); |
39 |
JButton btnDeleteTag = new JButton(); |
40 |
JList lstExtends = new JList(); |
41 |
JButton btnModifySuperClass = new JButton(); |
42 |
JButton btnDeleteSuperClass = new JButton(); |
43 |
JButton btnAddSuperClass = new JButton(); |
44 |
JTable tblMethods = new JTable(); |
45 |
JComboBox cboScriptLanguage = new JComboBox(); |
46 |
JTextArea txtScriptCode = new JTextArea(); |
47 |
|
48 |
/**
|
49 |
* Default constructor
|
50 |
*/
|
51 |
public DynClassView()
|
52 |
{ |
53 |
initializePanel(); |
54 |
} |
55 |
|
56 |
/**
|
57 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
58 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
59 |
* @param cols an array of column indices in the first row where fill components should be added.
|
60 |
* @param rows an array of row indices in the first column where fill components should be added.
|
61 |
*/
|
62 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
63 |
{ |
64 |
Dimension filler = new Dimension(10,10); |
65 |
|
66 |
boolean filled_cell_11 = false; |
67 |
CellConstraints cc = new CellConstraints();
|
68 |
if ( cols.length > 0 && rows.length > 0 ) |
69 |
{ |
70 |
if ( cols[0] == 1 && rows[0] == 1 ) |
71 |
{ |
72 |
/** add a rigid area */
|
73 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
74 |
filled_cell_11 = true;
|
75 |
} |
76 |
} |
77 |
|
78 |
for( int index = 0; index < cols.length; index++ ) |
79 |
{ |
80 |
if ( cols[index] == 1 && filled_cell_11 ) |
81 |
{ |
82 |
continue;
|
83 |
} |
84 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
85 |
} |
86 |
|
87 |
for( int index = 0; index < rows.length; index++ ) |
88 |
{ |
89 |
if ( rows[index] == 1 && filled_cell_11 ) |
90 |
{ |
91 |
continue;
|
92 |
} |
93 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
94 |
} |
95 |
|
96 |
} |
97 |
|
98 |
/**
|
99 |
* Helper method to load an image file from the CLASSPATH
|
100 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
101 |
* @return an ImageIcon instance with the specified image file
|
102 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
103 |
*/
|
104 |
public ImageIcon loadImage( String imageName ) |
105 |
{ |
106 |
try
|
107 |
{ |
108 |
ClassLoader classloader = getClass().getClassLoader();
|
109 |
java.net.URL url = classloader.getResource( imageName ); |
110 |
if ( url != null ) |
111 |
{ |
112 |
ImageIcon icon = new ImageIcon( url ); |
113 |
return icon;
|
114 |
} |
115 |
} |
116 |
catch( Exception e ) |
117 |
{ |
118 |
e.printStackTrace(); |
119 |
} |
120 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
121 |
} |
122 |
|
123 |
/**
|
124 |
* Method for recalculating the component orientation for
|
125 |
* right-to-left Locales.
|
126 |
* @param orientation the component orientation to be applied
|
127 |
*/
|
128 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
129 |
{ |
130 |
// Not yet implemented...
|
131 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
132 |
super.applyComponentOrientation(orientation);
|
133 |
} |
134 |
|
135 |
public JPanel createPanel() |
136 |
{ |
137 |
JPanel jpanel1 = new JPanel(); |
138 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,LEFT:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,TOP:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE"); |
139 |
CellConstraints cc = new CellConstraints();
|
140 |
jpanel1.setLayout(formlayout1); |
141 |
|
142 |
jtabbedpane1.addTab("General",null,createPanel1()); |
143 |
jtabbedpane1.addTab("Fields",null,createPanel2()); |
144 |
jtabbedpane1.addTab("Tags",null,createPanel4()); |
145 |
jtabbedpane1.addTab("Extends",null,createPanel6()); |
146 |
jtabbedpane1.addTab("Methods",null,createPanel8()); |
147 |
jtabbedpane1.addTab("Script",null,createPanel9()); |
148 |
jpanel1.add(jtabbedpane1,new CellConstraints(2,2,1,1,CellConstraints.FILL,CellConstraints.FILL)); |
149 |
|
150 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3 }); |
151 |
return jpanel1;
|
152 |
} |
153 |
|
154 |
public JPanel createPanel1() |
155 |
{ |
156 |
JPanel jpanel1 = new JPanel(); |
157 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE"); |
158 |
CellConstraints cc = new CellConstraints();
|
159 |
jpanel1.setLayout(formlayout1); |
160 |
|
161 |
JLabel jlabel1 = new JLabel(); |
162 |
jlabel1.setText("Description");
|
163 |
jpanel1.add(jlabel1,cc.xy(2,8)); |
164 |
|
165 |
txtDescription.setName("txtDescription");
|
166 |
txtDescription.setRows(2);
|
167 |
JScrollPane jscrollpane1 = new JScrollPane(); |
168 |
jscrollpane1.setViewportView(txtDescription); |
169 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
170 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
171 |
jpanel1.add(jscrollpane1,cc.xywh(2,10,3,1)); |
172 |
|
173 |
txtNamespace.setName("txtNamespace");
|
174 |
jpanel1.add(txtNamespace,cc.xy(4,6)); |
175 |
|
176 |
JLabel jlabel2 = new JLabel(); |
177 |
jlabel2.setText("Name-space");
|
178 |
jpanel1.add(jlabel2,cc.xy(2,6)); |
179 |
|
180 |
txtName.setEnabled(false);
|
181 |
txtName.setName("txtName");
|
182 |
jpanel1.add(txtName,cc.xy(4,4)); |
183 |
|
184 |
JLabel jlabel3 = new JLabel(); |
185 |
jlabel3.setText("Name");
|
186 |
jpanel1.add(jlabel3,cc.xy(2,4)); |
187 |
|
188 |
JLabel jlabel4 = new JLabel(); |
189 |
jlabel4.setText("Label");
|
190 |
jpanel1.add(jlabel4,cc.xy(2,2)); |
191 |
|
192 |
txtLabel.setName("txtLabel");
|
193 |
jpanel1.add(txtLabel,cc.xy(4,2)); |
194 |
|
195 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11 }); |
196 |
return jpanel1;
|
197 |
} |
198 |
|
199 |
public JPanel createPanel2() |
200 |
{ |
201 |
JPanel jpanel1 = new JPanel(); |
202 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
203 |
CellConstraints cc = new CellConstraints();
|
204 |
jpanel1.setLayout(formlayout1); |
205 |
|
206 |
tblFields.setName("tblFields");
|
207 |
JScrollPane jscrollpane1 = new JScrollPane(); |
208 |
jscrollpane1.setViewportView(tblFields); |
209 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
210 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
211 |
jpanel1.add(jscrollpane1,cc.xy(2,2)); |
212 |
|
213 |
jpanel1.add(createPanel3(),new CellConstraints(2,4,1,1,CellConstraints.RIGHT,CellConstraints.FILL)); |
214 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5 }); |
215 |
return jpanel1;
|
216 |
} |
217 |
|
218 |
public JPanel createPanel3() |
219 |
{ |
220 |
JPanel jpanel1 = new JPanel(); |
221 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
222 |
CellConstraints cc = new CellConstraints();
|
223 |
jpanel1.setLayout(formlayout1); |
224 |
|
225 |
btnModifyField.setActionCommand("Show");
|
226 |
btnModifyField.setName("btnModifyField");
|
227 |
btnModifyField.setText("Modify");
|
228 |
jpanel1.add(btnModifyField,cc.xy(6,1)); |
229 |
|
230 |
btnAddField.setActionCommand("Add");
|
231 |
btnAddField.setName("btnAddField");
|
232 |
btnAddField.setText("Add");
|
233 |
jpanel1.add(btnAddField,cc.xy(4,1)); |
234 |
|
235 |
btnDeleteField.setActionCommand("Delete");
|
236 |
btnDeleteField.setName("btnDeleteField");
|
237 |
btnDeleteField.setText("Delete");
|
238 |
jpanel1.add(btnDeleteField,cc.xy(2,1)); |
239 |
|
240 |
addFillComponents(jpanel1,new int[]{ 1,3,5 },new int[]{ 1 }); |
241 |
return jpanel1;
|
242 |
} |
243 |
|
244 |
public JPanel createPanel4() |
245 |
{ |
246 |
JPanel jpanel1 = new JPanel(); |
247 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
248 |
CellConstraints cc = new CellConstraints();
|
249 |
jpanel1.setLayout(formlayout1); |
250 |
|
251 |
tblTags.setName("tblTags");
|
252 |
JScrollPane jscrollpane1 = new JScrollPane(); |
253 |
jscrollpane1.setViewportView(tblTags); |
254 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
255 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
256 |
jpanel1.add(jscrollpane1,cc.xy(2,2)); |
257 |
|
258 |
jpanel1.add(createPanel5(),new CellConstraints(2,4,1,1,CellConstraints.RIGHT,CellConstraints.FILL)); |
259 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5 }); |
260 |
return jpanel1;
|
261 |
} |
262 |
|
263 |
public JPanel createPanel5() |
264 |
{ |
265 |
JPanel jpanel1 = new JPanel(); |
266 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
267 |
CellConstraints cc = new CellConstraints();
|
268 |
jpanel1.setLayout(formlayout1); |
269 |
|
270 |
btnModifyTag.setActionCommand("Show");
|
271 |
btnModifyTag.setName("btnModifyTag");
|
272 |
btnModifyTag.setText("Modify");
|
273 |
jpanel1.add(btnModifyTag,cc.xy(6,1)); |
274 |
|
275 |
btnAddTag.setActionCommand("Add");
|
276 |
btnAddTag.setName("btnAddTag");
|
277 |
btnAddTag.setText("Add");
|
278 |
jpanel1.add(btnAddTag,cc.xy(4,1)); |
279 |
|
280 |
btnDeleteTag.setActionCommand("Delete");
|
281 |
btnDeleteTag.setName("btnDeleteTag");
|
282 |
btnDeleteTag.setText("Delete");
|
283 |
jpanel1.add(btnDeleteTag,cc.xy(2,1)); |
284 |
|
285 |
addFillComponents(jpanel1,new int[]{ 1,3,5 },new int[]{ 1 }); |
286 |
return jpanel1;
|
287 |
} |
288 |
|
289 |
public JPanel createPanel6() |
290 |
{ |
291 |
JPanel jpanel1 = new JPanel(); |
292 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
293 |
CellConstraints cc = new CellConstraints();
|
294 |
jpanel1.setLayout(formlayout1); |
295 |
|
296 |
lstExtends.setName("lstExtends");
|
297 |
JScrollPane jscrollpane1 = new JScrollPane(); |
298 |
jscrollpane1.setViewportView(lstExtends); |
299 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
300 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
301 |
jpanel1.add(jscrollpane1,cc.xy(2,2)); |
302 |
|
303 |
jpanel1.add(createPanel7(),new CellConstraints(2,4,1,1,CellConstraints.RIGHT,CellConstraints.FILL)); |
304 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5 }); |
305 |
return jpanel1;
|
306 |
} |
307 |
|
308 |
public JPanel createPanel7() |
309 |
{ |
310 |
JPanel jpanel1 = new JPanel(); |
311 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
312 |
CellConstraints cc = new CellConstraints();
|
313 |
jpanel1.setLayout(formlayout1); |
314 |
|
315 |
btnModifySuperClass.setActionCommand("Show");
|
316 |
btnModifySuperClass.setName("btnModifySuperClass");
|
317 |
btnModifySuperClass.setText("Modify");
|
318 |
jpanel1.add(btnModifySuperClass,cc.xy(5,1)); |
319 |
|
320 |
btnDeleteSuperClass.setActionCommand("Delete");
|
321 |
btnDeleteSuperClass.setName("btnDeleteSuperClass");
|
322 |
btnDeleteSuperClass.setText("Delete");
|
323 |
jpanel1.add(btnDeleteSuperClass,cc.xy(1,1)); |
324 |
|
325 |
btnAddSuperClass.setActionCommand("Add");
|
326 |
btnAddSuperClass.setName("btnAddSuperClass");
|
327 |
btnAddSuperClass.setText("Add");
|
328 |
jpanel1.add(btnAddSuperClass,cc.xy(3,1)); |
329 |
|
330 |
addFillComponents(jpanel1,new int[]{ 2,4 },new int[0]); |
331 |
return jpanel1;
|
332 |
} |
333 |
|
334 |
public JPanel createPanel8() |
335 |
{ |
336 |
JPanel jpanel1 = new JPanel(); |
337 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE"); |
338 |
CellConstraints cc = new CellConstraints();
|
339 |
jpanel1.setLayout(formlayout1); |
340 |
|
341 |
tblMethods.setName("tblMethods");
|
342 |
JScrollPane jscrollpane1 = new JScrollPane(); |
343 |
jscrollpane1.setViewportView(tblMethods); |
344 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
345 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
346 |
jpanel1.add(jscrollpane1,cc.xy(2,2)); |
347 |
|
348 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3 }); |
349 |
return jpanel1;
|
350 |
} |
351 |
|
352 |
public JPanel createPanel9() |
353 |
{ |
354 |
JPanel jpanel1 = new JPanel(); |
355 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE"); |
356 |
CellConstraints cc = new CellConstraints();
|
357 |
jpanel1.setLayout(formlayout1); |
358 |
|
359 |
JLabel jlabel1 = new JLabel(); |
360 |
jlabel1.setText("Language");
|
361 |
jpanel1.add(jlabel1,cc.xy(2,2)); |
362 |
|
363 |
JLabel jlabel2 = new JLabel(); |
364 |
jlabel2.setText("Code");
|
365 |
jpanel1.add(jlabel2,cc.xy(2,4)); |
366 |
|
367 |
cboScriptLanguage.setName("cboScriptLanguage");
|
368 |
cboScriptLanguage.addItem("python");
|
369 |
cboScriptLanguage.addItem("groovy");
|
370 |
jpanel1.add(cboScriptLanguage,cc.xy(4,2)); |
371 |
|
372 |
txtScriptCode.setName("txtScriptCode");
|
373 |
txtScriptCode.setRows(2);
|
374 |
JScrollPane jscrollpane1 = new JScrollPane(); |
375 |
jscrollpane1.setViewportView(txtScriptCode); |
376 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
377 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
378 |
jpanel1.add(jscrollpane1,cc.xywh(2,6,3,1)); |
379 |
|
380 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7 }); |
381 |
return jpanel1;
|
382 |
} |
383 |
|
384 |
/**
|
385 |
* Initializer
|
386 |
*/
|
387 |
protected void initializePanel() |
388 |
{ |
389 |
setLayout(new BorderLayout()); |
390 |
add(createPanel(), BorderLayout.CENTER);
|
391 |
} |
392 |
|
393 |
|
394 |
} |