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

History | View | Annotate | Download (14.1 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
   JButton btnSearch = new JButton();
52
   JButton btnClear = new JButton();
53
   JTable tblResults = new JTable();
54
   JLabel lblMsg = new JLabel();
55
   JPanel pnlActions = new JPanel();
56

    
57
   /**
58
    * Default constructor
59
    */
60
   public DefaultSearchPanelView()
61
   {
62
      initializePanel();
63
   }
64

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

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

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

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

    
105
   }
106

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

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

    
144
   public JPanel createPanel()
145
   {
146
      JPanel jpanel1 = new JPanel();
147
      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:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
148
      CellConstraints cc = new CellConstraints();
149
      jpanel1.setLayout(formlayout1);
150

    
151
      tabSearchMode.setName("tabSearchMode");
152
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
153
      tabSearchMode.setBorder(emptyborder1);
154
      tabSearchMode.setTabPlacement(JTabbedPane.BOTTOM);
155
      tabSearchMode.addTab("Simplificada",null,createPanel1());
156
      tabSearchMode.addTab("Avanzada",null,createPanel2());
157
      jpanel1.add(tabSearchMode,cc.xy(2,2));
158

    
159
      jpanel1.add(createPanel3(),cc.xy(2,3));
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,5));
166

    
167
      jpanel1.add(createPanel4(),cc.xy(2,7));
168
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8 });
169
      return jpanel1;
170
   }
171

    
172
   public JPanel createPanel1()
173
   {
174
      JPanel jpanel1 = new JPanel();
175
      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");
176
      CellConstraints cc = new CellConstraints();
177
      jpanel1.setLayout(formlayout1);
178

    
179
      cboValue1.setEditable(true);
180
      cboValue1.setName("cboValue1");
181
      cboValue1.setRequestFocusEnabled(false);
182
      jpanel1.add(cboValue1,cc.xywh(2,6,3,1));
183

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

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

    
194
      cboValue4.setEditable(true);
195
      cboValue4.setName("cboValue4");
196
      cboValue4.setRequestFocusEnabled(false);
197
      jpanel1.add(cboValue4,cc.xywh(20,6,2,1));
198

    
199
      lblRelationalOperator1.setName("lblRelationalOperator1");
200
      lblRelationalOperator1.setText("Igual");
201
      lblRelationalOperator1.setHorizontalAlignment(JLabel.CENTER);
202
      jpanel1.add(lblRelationalOperator1,cc.xy(2,4));
203

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

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

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

    
219
      lblLogicalOperators1.setName("lblLogicalOperators1");
220
      lblLogicalOperators1.setText("WWWWW");
221
      lblLogicalOperators1.setHorizontalAlignment(JLabel.CENTER);
222
      jpanel1.add(lblLogicalOperators1,cc.xy(6,2));
223

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

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

    
234
      lblField1.setName("lblField1");
235
      lblField1.setHorizontalAlignment(JLabel.CENTER);
236
      jpanel1.add(lblField1,cc.xy(2,2));
237

    
238
      lblField2.setName("lblField2");
239
      lblField2.setHorizontalAlignment(JLabel.CENTER);
240
      jpanel1.add(lblField2,cc.xy(8,2));
241

    
242
      lblField3.setName("lblField3");
243
      lblField3.setHorizontalAlignment(JLabel.CENTER);
244
      jpanel1.add(lblField3,cc.xy(14,2));
245

    
246
      lblField4.setName("lblField4");
247
      lblField4.setHorizontalAlignment(JLabel.CENTER);
248
      jpanel1.add(lblField4,cc.xy(20,2));
249

    
250
      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"));
251
      lblExtraFields1.setName("lblExtraFields1");
252
      jpanel1.add(lblExtraFields1,cc.xy(4,2));
253

    
254
      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"));
255
      lblExtraFields2.setName("lblExtraFields2");
256
      jpanel1.add(lblExtraFields2,cc.xy(10,2));
257

    
258
      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"));
259
      lblExtraFields3.setName("lblExtraFields3");
260
      jpanel1.add(lblExtraFields3,cc.xy(16,2));
261

    
262
      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"));
263
      lblExtraFields4.setName("lblExtraFields4");
264
      jpanel1.add(lblExtraFields4,cc.xy(21,2));
265

    
266
      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 });
267
      return jpanel1;
268
   }
269

    
270
   public JPanel createPanel2()
271
   {
272
      JPanel jpanel1 = new JPanel();
273
      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");
274
      CellConstraints cc = new CellConstraints();
275
      jpanel1.setLayout(formlayout1);
276

    
277
      txtAdvancedExpression.setName("txtAdvancedExpression");
278
      jpanel1.add(txtAdvancedExpression,cc.xy(2,4));
279

    
280
      lblExpressionDeBusqueda.setName("lblExpressionDeBusqueda");
281
      lblExpressionDeBusqueda.setText("Introduzca una expresion de busqueda");
282
      jpanel1.add(lblExpressionDeBusqueda,cc.xy(2,2));
283

    
284
      btnAdvancedExpression.setActionCommand("...");
285
      btnAdvancedExpression.setName("btnAdvancedExpression");
286
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
287
      btnAdvancedExpression.setBorder(emptyborder1);
288
      jpanel1.add(btnAdvancedExpression,cc.xy(4,4));
289

    
290
      btnAdvancedExpressionHistory.setActionCommand("...");
291
      btnAdvancedExpressionHistory.setName("btnAdvancedExpressionHistory");
292
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
293
      btnAdvancedExpressionHistory.setBorder(emptyborder2);
294
      jpanel1.add(btnAdvancedExpressionHistory,cc.xy(6,4));
295

    
296
      btnAdvancedExpressionBookmarks.setActionCommand("...");
297
      btnAdvancedExpressionBookmarks.setName("btnAdvancedExpressionBookmarks");
298
      EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2);
299
      btnAdvancedExpressionBookmarks.setBorder(emptyborder3);
300
      jpanel1.add(btnAdvancedExpressionBookmarks,cc.xy(8,4));
301

    
302
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8,9 },new int[]{ 1,2,3,4,5 });
303
      return jpanel1;
304
   }
305

    
306
   public JPanel createPanel3()
307
   {
308
      JPanel jpanel1 = new JPanel();
309
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
310
      CellConstraints cc = new CellConstraints();
311
      jpanel1.setLayout(formlayout1);
312

    
313
      btnSearch.setActionCommand("Buscar");
314
      btnSearch.setName("btnSearch");
315
      btnSearch.setText("Buscar");
316
      jpanel1.add(btnSearch,cc.xy(4,1));
317

    
318
      btnClear.setActionCommand("Limpiar");
319
      btnClear.setName("btnClear");
320
      btnClear.setText("Limpiar");
321
      jpanel1.add(btnClear,cc.xy(2,1));
322

    
323
      addFillComponents(jpanel1,new int[]{ 1,3 },new int[]{ 1 });
324
      return jpanel1;
325
   }
326

    
327
   public JPanel createPanel4()
328
   {
329
      JPanel jpanel1 = new JPanel();
330
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
331
      CellConstraints cc = new CellConstraints();
332
      jpanel1.setLayout(formlayout1);
333

    
334
      lblMsg.setName("lblMsg");
335
      jpanel1.add(lblMsg,cc.xy(1,1));
336

    
337
      pnlActions.setName("pnlActions");
338
      jpanel1.add(pnlActions,cc.xy(3,1));
339

    
340
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
341
      return jpanel1;
342
   }
343

    
344
   /**
345
    * Initializer
346
    */
347
   protected void initializePanel()
348
   {
349
      setLayout(new BorderLayout());
350
      add(createPanel(), BorderLayout.CENTER);
351
   }
352

    
353

    
354
}