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