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