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