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