Statistics
| Revision:

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 @ 44707

History | View | Annotate | Download (16.9 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.JTextArea;
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
   JButton btnRemoveAccumulatedFilter = new JButton();
47
   JButton btnAddAccumulatedFilter = new JButton();
48
   JButton btnViewAccumulatedFilter = new JButton();
49
   JLabel lblExpressionDeBusqueda = new JLabel();
50
   JButton btnAdvancedExpression = new JButton();
51
   JButton btnAdvancedExpressionHistory = new JButton();
52
   JButton btnAdvancedExpressionBookmarks = new JButton();
53
   JTextArea txtAdvancedExpression = new JTextArea();
54
   JTable tblResults = new JTable();
55
   JButton btnSearch = new JButton();
56
   JButton btnClear = new JButton();
57
   JLabel lblMsg = new JLabel();
58
   JPanel pnlActions = new JPanel();
59
   JPanel pnlCfgActions = new JPanel();
60

    
61
   /**
62
    * Default constructor
63
    */
64
   public DefaultSearchPanelView()
65
   {
66
      initializePanel();
67
   }
68

    
69
   /**
70
    * Adds fill components to empty cells in the first row and first column of the grid.
71
    * This ensures that the grid spacing will be the same as shown in the designer.
72
    * @param cols an array of column indices in the first row where fill components should be added.
73
    * @param rows an array of row indices in the first column where fill components should be added.
74
    */
75
   void addFillComponents( Container panel, int[] cols, int[] rows )
76
   {
77
      Dimension filler = new Dimension(10,10);
78

    
79
      boolean filled_cell_11 = false;
80
      CellConstraints cc = new CellConstraints();
81
      if ( cols.length > 0 && rows.length > 0 )
82
      {
83
         if ( cols[0] == 1 && rows[0] == 1 )
84
         {
85
            /** add a rigid area  */
86
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
87
            filled_cell_11 = true;
88
         }
89
      }
90

    
91
      for( int index = 0; index < cols.length; index++ )
92
      {
93
         if ( cols[index] == 1 && filled_cell_11 )
94
         {
95
            continue;
96
         }
97
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
98
      }
99

    
100
      for( int index = 0; index < rows.length; index++ )
101
      {
102
         if ( rows[index] == 1 && filled_cell_11 )
103
         {
104
            continue;
105
         }
106
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
107
      }
108

    
109
   }
110

    
111
   /**
112
    * Helper method to load an image file from the CLASSPATH
113
    * @param imageName the package and name of the file to load relative to the CLASSPATH
114
    * @return an ImageIcon instance with the specified image file
115
    * @throws IllegalArgumentException if the image resource cannot be loaded.
116
    */
117
   public ImageIcon loadImage( String imageName )
118
   {
119
      try
120
      {
121
         ClassLoader classloader = getClass().getClassLoader();
122
         java.net.URL url = classloader.getResource( imageName );
123
         if ( url != null )
124
         {
125
            ImageIcon icon = new ImageIcon( url );
126
            return icon;
127
         }
128
      }
129
      catch( Exception e )
130
      {
131
         e.printStackTrace();
132
      }
133
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
134
   }
135

    
136
   /**
137
    * Method for recalculating the component orientation for 
138
    * right-to-left Locales.
139
    * @param orientation the component orientation to be applied
140
    */
141
   public void applyComponentOrientation( ComponentOrientation orientation )
142
   {
143
      // Not yet implemented...
144
      // I18NUtils.applyComponentOrientation(this, orientation);
145
      super.applyComponentOrientation(orientation);
146
   }
147

    
148
   public JPanel createPanel()
149
   {
150
      JPanel jpanel1 = new JPanel();
151
      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");
152
      CellConstraints cc = new CellConstraints();
153
      jpanel1.setLayout(formlayout1);
154

    
155
      tabSearchMode.setName("tabSearchMode");
156
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
157
      tabSearchMode.setBorder(emptyborder1);
158
      tabSearchMode.setTabPlacement(JTabbedPane.BOTTOM);
159
      tabSearchMode.addTab("_Simplified",null,createPanel1());
160
      tabSearchMode.addTab("_Advanced",null,createPanel3());
161
      jpanel1.add(tabSearchMode,cc.xy(2,3));
162

    
163
      tblResults.setName("tblResults");
164
      JScrollPane jscrollpane1 = new JScrollPane();
165
      jscrollpane1.setViewportView(tblResults);
166
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
167
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
168
      jpanel1.add(jscrollpane1,cc.xy(2,6));
169

    
170
      jpanel1.add(createPanel4(),cc.xy(2,4));
171
      jpanel1.add(createPanel5(),cc.xy(2,8));
172
      jpanel1.add(createPanel6(),cc.xy(2,2));
173
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8,9 });
174
      return jpanel1;
175
   }
176

    
177
   public JPanel createPanel1()
178
   {
179
      JPanel jpanel1 = new JPanel();
180
      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,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
181
      CellConstraints cc = new CellConstraints();
182
      jpanel1.setLayout(formlayout1);
183

    
184
      cboValue1.setEditable(true);
185
      cboValue1.setName("cboValue1");
186
      cboValue1.setRequestFocusEnabled(false);
187
      jpanel1.add(cboValue1,cc.xywh(2,6,3,1));
188

    
189
      cboValue2.setEditable(true);
190
      cboValue2.setName("cboValue2");
191
      cboValue2.setRequestFocusEnabled(false);
192
      jpanel1.add(cboValue2,cc.xywh(8,6,3,1));
193

    
194
      cboValue3.setEditable(true);
195
      cboValue3.setName("cboValue3");
196
      cboValue3.setRequestFocusEnabled(false);
197
      jpanel1.add(cboValue3,cc.xywh(14,6,3,1));
198

    
199
      cboValue4.setEditable(true);
200
      cboValue4.setName("cboValue4");
201
      cboValue4.setRequestFocusEnabled(false);
202
      jpanel1.add(cboValue4,cc.xywh(20,6,2,1));
203

    
204
      lblRelationalOperator1.setName("lblRelationalOperator1");
205
      lblRelationalOperator1.setText("Igual");
206
      lblRelationalOperator1.setHorizontalAlignment(JLabel.CENTER);
207
      jpanel1.add(lblRelationalOperator1,cc.xy(2,4));
208

    
209
      lblRelationalOperator2.setName("lblRelationalOperator2");
210
      lblRelationalOperator2.setText("Igual");
211
      lblRelationalOperator2.setHorizontalAlignment(JLabel.CENTER);
212
      jpanel1.add(lblRelationalOperator2,cc.xy(8,4));
213

    
214
      lblRelationalOperator3.setName("lblRelationalOperator3");
215
      lblRelationalOperator3.setText("Igual");
216
      lblRelationalOperator3.setHorizontalAlignment(JLabel.CENTER);
217
      jpanel1.add(lblRelationalOperator3,cc.xy(14,4));
218

    
219
      lblRelationalOperator4.setName("lblRelationalOperator4");
220
      lblRelationalOperator4.setText("Igual");
221
      lblRelationalOperator4.setHorizontalAlignment(JLabel.CENTER);
222
      jpanel1.add(lblRelationalOperator4,cc.xy(20,4));
223

    
224
      lblLogicalOperators1.setName("lblLogicalOperators1");
225
      lblLogicalOperators1.setText("WWWWW");
226
      lblLogicalOperators1.setHorizontalAlignment(JLabel.CENTER);
227
      jpanel1.add(lblLogicalOperators1,cc.xy(6,2));
228

    
229
      lblLogicalOperators2.setName("lblLogicalOperators2");
230
      lblLogicalOperators2.setText("WWWWW");
231
      lblLogicalOperators2.setHorizontalAlignment(JLabel.CENTER);
232
      jpanel1.add(lblLogicalOperators2,cc.xy(12,2));
233

    
234
      lblLogicalOperators3.setName("lblLogicalOperators3");
235
      lblLogicalOperators3.setText("WWWWW");
236
      lblLogicalOperators3.setHorizontalAlignment(JLabel.CENTER);
237
      jpanel1.add(lblLogicalOperators3,cc.xy(18,2));
238

    
239
      lblField1.setName("lblField1");
240
      lblField1.setHorizontalAlignment(JLabel.CENTER);
241
      jpanel1.add(lblField1,cc.xy(2,2));
242

    
243
      lblField2.setName("lblField2");
244
      lblField2.setHorizontalAlignment(JLabel.CENTER);
245
      jpanel1.add(lblField2,cc.xy(8,2));
246

    
247
      lblField3.setName("lblField3");
248
      lblField3.setHorizontalAlignment(JLabel.CENTER);
249
      jpanel1.add(lblField3,cc.xy(14,2));
250

    
251
      lblField4.setName("lblField4");
252
      lblField4.setHorizontalAlignment(JLabel.CENTER);
253
      jpanel1.add(lblField4,cc.xy(20,2));
254

    
255
      lblExtraFields1.setIcon(loadImage("src/main/resources/org/gvsig/fmap/dal/swing/impl/searchpanel/featurestore-column.png"));
256
      lblExtraFields1.setName("lblExtraFields1");
257
      jpanel1.add(lblExtraFields1,cc.xy(4,2));
258

    
259
      lblExtraFields2.setIcon(loadImage("src/main/resources/org/gvsig/fmap/dal/swing/impl/searchpanel/featurestore-column.png"));
260
      lblExtraFields2.setName("lblExtraFields2");
261
      jpanel1.add(lblExtraFields2,cc.xy(10,2));
262

    
263
      lblExtraFields3.setIcon(loadImage("src/main/resources/org/gvsig/fmap/dal/swing/impl/searchpanel/featurestore-column.png"));
264
      lblExtraFields3.setName("lblExtraFields3");
265
      jpanel1.add(lblExtraFields3,cc.xy(16,2));
266

    
267
      lblExtraFields4.setIcon(loadImage("src/main/resources/org/gvsig/fmap/dal/swing/impl/searchpanel/featurestore-column.png"));
268
      lblExtraFields4.setName("lblExtraFields4");
269
      jpanel1.add(lblExtraFields4,cc.xy(21,2));
270

    
271
      jpanel1.add(createPanel2(),cc.xywh(2,8,20,1));
272
      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,8,9 });
273
      return jpanel1;
274
   }
275

    
276
   public JPanel createPanel2()
277
   {
278
      JPanel jpanel1 = new JPanel();
279
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
280
      CellConstraints cc = new CellConstraints();
281
      jpanel1.setLayout(formlayout1);
282

    
283
      btnRemoveAccumulatedFilter.setActionCommand("...");
284
      btnRemoveAccumulatedFilter.setIcon(loadImage("src/main/resources/org/gvsig/fmap/dal/swing/impl/searchpanel/search-simplifiedcondition-clear-accumulate.png"));
285
      btnRemoveAccumulatedFilter.setName("btnRemoveAccumulatedFilter");
286
      btnRemoveAccumulatedFilter.setToolTipText("_Remove_accumulated_filter");
287
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
288
      btnRemoveAccumulatedFilter.setBorder(emptyborder1);
289
      jpanel1.add(btnRemoveAccumulatedFilter,cc.xy(3,1));
290

    
291
      btnAddAccumulatedFilter.setActionCommand("...");
292
      btnAddAccumulatedFilter.setIcon(loadImage("src/main/resources/org/gvsig/fmap/dal/swing/impl/searchpanel/search-simplifiedcondition-add-accumulate.png"));
293
      btnAddAccumulatedFilter.setName("btnAddAccumulatedFilter");
294
      btnAddAccumulatedFilter.setToolTipText("_Accumulate_filter");
295
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
296
      btnAddAccumulatedFilter.setBorder(emptyborder2);
297
      jpanel1.add(btnAddAccumulatedFilter,cc.xy(7,1));
298

    
299
      btnViewAccumulatedFilter.setActionCommand("...");
300
      btnViewAccumulatedFilter.setIcon(loadImage("src/main/resources/org/gvsig/fmap/dal/swing/impl/searchpanel/search-simplifiedcondition-edit-accumulate.png"));
301
      btnViewAccumulatedFilter.setName("btnViewAccumulatedFilter");
302
      btnViewAccumulatedFilter.setToolTipText("_View_accumulated_filter");
303
      EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2);
304
      btnViewAccumulatedFilter.setBorder(emptyborder3);
305
      jpanel1.add(btnViewAccumulatedFilter,cc.xy(5,1));
306

    
307
      addFillComponents(jpanel1,new int[]{ 1,2,4,6 },new int[]{ 1 });
308
      return jpanel1;
309
   }
310

    
311
   public JPanel createPanel3()
312
   {
313
      JPanel jpanel1 = new JPanel();
314
      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,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE");
315
      CellConstraints cc = new CellConstraints();
316
      jpanel1.setLayout(formlayout1);
317

    
318
      lblExpressionDeBusqueda.setName("lblExpressionDeBusqueda");
319
      lblExpressionDeBusqueda.setText("_Insert_a_search_expression");
320
      jpanel1.add(lblExpressionDeBusqueda,cc.xy(2,2));
321

    
322
      btnAdvancedExpression.setActionCommand("...");
323
      btnAdvancedExpression.setName("btnAdvancedExpression");
324
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
325
      btnAdvancedExpression.setBorder(emptyborder1);
326
      jpanel1.add(btnAdvancedExpression,new CellConstraints(4,4,1,1,CellConstraints.DEFAULT,CellConstraints.TOP));
327

    
328
      btnAdvancedExpressionHistory.setActionCommand("...");
329
      btnAdvancedExpressionHistory.setName("btnAdvancedExpressionHistory");
330
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
331
      btnAdvancedExpressionHistory.setBorder(emptyborder2);
332
      jpanel1.add(btnAdvancedExpressionHistory,new CellConstraints(6,4,1,1,CellConstraints.DEFAULT,CellConstraints.TOP));
333

    
334
      btnAdvancedExpressionBookmarks.setActionCommand("...");
335
      btnAdvancedExpressionBookmarks.setName("btnAdvancedExpressionBookmarks");
336
      EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2);
337
      btnAdvancedExpressionBookmarks.setBorder(emptyborder3);
338
      jpanel1.add(btnAdvancedExpressionBookmarks,new CellConstraints(8,4,1,1,CellConstraints.DEFAULT,CellConstraints.TOP));
339

    
340
      txtAdvancedExpression.setName("txtAdvancedExpression");
341
      JScrollPane jscrollpane1 = new JScrollPane();
342
      jscrollpane1.setViewportView(txtAdvancedExpression);
343
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
344
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
345
      jpanel1.add(jscrollpane1,cc.xy(2,4));
346

    
347
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8,9 },new int[]{ 1,2,3,4,5 });
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:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
355
      CellConstraints cc = new CellConstraints();
356
      jpanel1.setLayout(formlayout1);
357

    
358
      btnSearch.setActionCommand("Buscar");
359
      btnSearch.setName("btnSearch");
360
      btnSearch.setText("_Search");
361
      jpanel1.add(btnSearch,cc.xy(4,1));
362

    
363
      btnClear.setActionCommand("Limpiar");
364
      btnClear.setName("btnClear");
365
      btnClear.setText("_Clear");
366
      jpanel1.add(btnClear,cc.xy(2,1));
367

    
368
      addFillComponents(jpanel1,new int[]{ 1,3 },new int[]{ 1 });
369
      return jpanel1;
370
   }
371

    
372
   public JPanel createPanel5()
373
   {
374
      JPanel jpanel1 = new JPanel();
375
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
376
      CellConstraints cc = new CellConstraints();
377
      jpanel1.setLayout(formlayout1);
378

    
379
      lblMsg.setName("lblMsg");
380
      jpanel1.add(lblMsg,cc.xy(1,1));
381

    
382
      pnlActions.setName("pnlActions");
383
      jpanel1.add(pnlActions,cc.xy(3,1));
384

    
385
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
386
      return jpanel1;
387
   }
388

    
389
   public JPanel createPanel6()
390
   {
391
      JPanel jpanel1 = new JPanel();
392
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
393
      CellConstraints cc = new CellConstraints();
394
      jpanel1.setLayout(formlayout1);
395

    
396
      pnlCfgActions.setName("pnlCfgActions");
397
      pnlCfgActions.setOpaque(false);
398
      jpanel1.add(pnlCfgActions,cc.xy(2,1));
399

    
400
      addFillComponents(jpanel1,new int[]{ 1 },new int[]{ 1 });
401
      return jpanel1;
402
   }
403

    
404
   /**
405
    * Initializer
406
    */
407
   protected void initializePanel()
408
   {
409
      setLayout(new BorderLayout());
410
      add(createPanel(), BorderLayout.CENTER);
411
   }
412

    
413

    
414
}