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