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

History | View | Annotate | Download (13.6 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 btnSearch = new JButton();
50
   JButton btnClear = new JButton();
51
   JTable tblResults = new JTable();
52
   JButton btnShowForm = new JButton();
53
   JLabel lblMsg = new JLabel();
54

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

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

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

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

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

    
103
   }
104

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

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

    
142
   public JPanel createPanel()
143
   {
144
      JPanel jpanel1 = new JPanel();
145
      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");
146
      CellConstraints cc = new CellConstraints();
147
      jpanel1.setLayout(formlayout1);
148

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

    
157
      jpanel1.add(createPanel3(),cc.xy(2,3));
158
      tblResults.setName("tblResults");
159
      JScrollPane jscrollpane1 = new JScrollPane();
160
      jscrollpane1.setViewportView(tblResults);
161
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
162
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
163
      jpanel1.add(jscrollpane1,cc.xy(2,5));
164

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

    
170
   public JPanel createPanel1()
171
   {
172
      JPanel jpanel1 = new JPanel();
173
      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:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,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: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");
174
      CellConstraints cc = new CellConstraints();
175
      jpanel1.setLayout(formlayout1);
176

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
248
      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-search-attribute-selector.png"));
249
      lblExtraFields1.setName("lblExtraFields1");
250
      jpanel1.add(lblExtraFields1,cc.xy(4,2));
251

    
252
      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-search-attribute-selector.png"));
253
      lblExtraFields2.setName("lblExtraFields2");
254
      jpanel1.add(lblExtraFields2,cc.xy(10,2));
255

    
256
      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-search-attribute-selector.png"));
257
      lblExtraFields3.setName("lblExtraFields3");
258
      jpanel1.add(lblExtraFields3,cc.xy(16,2));
259

    
260
      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-search-attribute-selector.png"));
261
      lblExtraFields4.setName("lblExtraFields4");
262
      jpanel1.add(lblExtraFields4,cc.xy(21,2));
263

    
264
      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 });
265
      return jpanel1;
266
   }
267

    
268
   public JPanel createPanel2()
269
   {
270
      JPanel jpanel1 = new JPanel();
271
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
272
      CellConstraints cc = new CellConstraints();
273
      jpanel1.setLayout(formlayout1);
274

    
275
      txtAdvancedExpression.setName("txtAdvancedExpression");
276
      jpanel1.add(txtAdvancedExpression,cc.xy(2,4));
277

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

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

    
288
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5 });
289
      return jpanel1;
290
   }
291

    
292
   public JPanel createPanel3()
293
   {
294
      JPanel jpanel1 = new JPanel();
295
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
296
      CellConstraints cc = new CellConstraints();
297
      jpanel1.setLayout(formlayout1);
298

    
299
      btnSearch.setActionCommand("Buscar");
300
      btnSearch.setName("btnSearch");
301
      btnSearch.setText("Buscar");
302
      jpanel1.add(btnSearch,cc.xy(4,1));
303

    
304
      btnClear.setActionCommand("Limpiar");
305
      btnClear.setName("btnClear");
306
      btnClear.setText("Limpiar");
307
      jpanel1.add(btnClear,cc.xy(2,1));
308

    
309
      addFillComponents(jpanel1,new int[]{ 1,3 },new int[]{ 1 });
310
      return jpanel1;
311
   }
312

    
313
   public JPanel createPanel4()
314
   {
315
      JPanel jpanel1 = new JPanel();
316
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
317
      CellConstraints cc = new CellConstraints();
318
      jpanel1.setLayout(formlayout1);
319

    
320
      btnShowForm.setActionCommand("Ver");
321
      btnShowForm.setName("btnShowForm");
322
      btnShowForm.setText("Mostrar formulario");
323
      jpanel1.add(btnShowForm,cc.xy(6,1));
324

    
325
      lblMsg.setName("lblMsg");
326
      jpanel1.add(lblMsg,cc.xy(1,1));
327

    
328
      addFillComponents(jpanel1,new int[]{ 2,3,4,5 },new int[0]);
329
      return jpanel1;
330
   }
331

    
332
   /**
333
    * Initializer
334
    */
335
   protected void initializePanel()
336
   {
337
      setLayout(new BorderLayout());
338
      add(createPanel(), BorderLayout.CENTER);
339
   }
340

    
341

    
342
}