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