Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.impl / src / main / java / org / gvsig / export / swing / impl / panels / SelectFilterPanelView.java @ 44168

History | View | Annotate | Download (8.38 KB)

1 43925 jjdelcerro
package org.gvsig.export.swing.impl.panels;
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.ButtonGroup;
12
import javax.swing.ImageIcon;
13
import javax.swing.JButton;
14
import javax.swing.JFrame;
15
import javax.swing.JLabel;
16
import javax.swing.JList;
17
import javax.swing.JPanel;
18
import javax.swing.JRadioButton;
19
import javax.swing.JScrollPane;
20
import javax.swing.JTextArea;
21
import javax.swing.JTextField;
22
23
24
public class SelectFilterPanelView extends JPanel
25
{
26
   JLabel lblHeader = new JLabel();
27
   JRadioButton rdbAllRows = new JRadioButton();
28
   ButtonGroup buttongroup1 = new ButtonGroup();
29
   JRadioButton rdbSelectedRows = new JRadioButton();
30
   JRadioButton rdbFilteredRows = new JRadioButton();
31
   JRadioButton rdoUseSavedExpresion = new JRadioButton();
32
   JRadioButton rdoUseNewExpresion = new JRadioButton();
33
   JLabel lblName = new JLabel();
34
   JTextField txtName = new JTextField();
35
   JLabel lblExpresion = new JLabel();
36
   JTextArea txtExpresion = new JTextArea();
37
   JButton butTest = new JButton();
38
   JButton butFilterDialog = new JButton();
39
   JList lstFilters = new JList();
40
41
   /**
42
    * Default constructor
43
    */
44
   public SelectFilterPanelView()
45
   {
46
      initializePanel();
47
   }
48
49
   /**
50
    * Adds fill components to empty cells in the first row and first column of the grid.
51
    * This ensures that the grid spacing will be the same as shown in the designer.
52
    * @param cols an array of column indices in the first row where fill components should be added.
53
    * @param rows an array of row indices in the first column where fill components should be added.
54
    */
55
   void addFillComponents( Container panel, int[] cols, int[] rows )
56
   {
57
      Dimension filler = new Dimension(10,10);
58
59
      boolean filled_cell_11 = false;
60
      CellConstraints cc = new CellConstraints();
61
      if ( cols.length > 0 && rows.length > 0 )
62
      {
63
         if ( cols[0] == 1 && rows[0] == 1 )
64
         {
65
            /** add a rigid area  */
66
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
67
            filled_cell_11 = true;
68
         }
69
      }
70
71
      for( int index = 0; index < cols.length; index++ )
72
      {
73
         if ( cols[index] == 1 && filled_cell_11 )
74
         {
75
            continue;
76
         }
77
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
78
      }
79
80
      for( int index = 0; index < rows.length; index++ )
81
      {
82
         if ( rows[index] == 1 && filled_cell_11 )
83
         {
84
            continue;
85
         }
86
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
87
      }
88
89
   }
90
91
   /**
92
    * Helper method to load an image file from the CLASSPATH
93
    * @param imageName the package and name of the file to load relative to the CLASSPATH
94
    * @return an ImageIcon instance with the specified image file
95
    * @throws IllegalArgumentException if the image resource cannot be loaded.
96
    */
97
   public ImageIcon loadImage( String imageName )
98
   {
99
      try
100
      {
101
         ClassLoader classloader = getClass().getClassLoader();
102
         java.net.URL url = classloader.getResource( imageName );
103
         if ( url != null )
104
         {
105
            ImageIcon icon = new ImageIcon( url );
106
            return icon;
107
         }
108
      }
109
      catch( Exception e )
110
      {
111
         e.printStackTrace();
112
      }
113
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
114
   }
115
116
   /**
117
    * Method for recalculating the component orientation for
118
    * right-to-left Locales.
119
    * @param orientation the component orientation to be applied
120
    */
121
   public void applyComponentOrientation( ComponentOrientation orientation )
122
   {
123
      // Not yet implemented...
124
      // I18NUtils.applyComponentOrientation(this, orientation);
125
      super.applyComponentOrientation(orientation);
126
   }
127
128
   public JPanel createPanel()
129
   {
130
      JPanel jpanel1 = new JPanel();
131
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:8DLU:NONE,FILL:8DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
132
      CellConstraints cc = new CellConstraints();
133
      jpanel1.setLayout(formlayout1);
134
135
      lblHeader.setName("lblHeader");
136
      lblHeader.setText("_Indique_que_registros_desea_exportar");
137
      jpanel1.add(lblHeader,cc.xywh(2,2,3,1));
138
139
      rdbAllRows.setActionCommand("_Todos_los_registros");
140
      rdbAllRows.setName("rdbAllRows");
141
      rdbAllRows.setText("_Todos_los_registros");
142
      buttongroup1.add(rdbAllRows);
143
      jpanel1.add(rdbAllRows,cc.xywh(2,4,3,1));
144
145
      rdbSelectedRows.setActionCommand("_Los_registros_seleccionados");
146
      rdbSelectedRows.setName("rdbSelectedRows");
147
      rdbSelectedRows.setText("_Los_registros_seleccionados");
148
      buttongroup1.add(rdbSelectedRows);
149
      jpanel1.add(rdbSelectedRows,cc.xywh(2,6,3,1));
150
151
      rdbFilteredRows.setActionCommand("_Los_registros_que_cumplan_el_critrio_seleccionado");
152
      rdbFilteredRows.setName("rdbFilteredRows");
153
      rdbFilteredRows.setText("_Los_registros_que_cumplan_el_critrio_seleccionado");
154
      buttongroup1.add(rdbFilteredRows);
155
      jpanel1.add(rdbFilteredRows,cc.xywh(2,8,3,1));
156
157
      rdoUseSavedExpresion.setActionCommand("_Usar_una_expresion_guardada");
158
      rdoUseSavedExpresion.setName("rdoUseSavedExpresion");
159
      rdoUseSavedExpresion.setText("_Usar_una_expresion_guardada");
160
      buttongroup1.add(rdoUseSavedExpresion);
161
      jpanel1.add(rdoUseSavedExpresion,cc.xywh(3,10,2,1));
162
163
      rdoUseNewExpresion.setActionCommand("_Nueva_expresion");
164
      rdoUseNewExpresion.setName("rdoUseNewExpresion");
165
      rdoUseNewExpresion.setText("_Nueva_expresion");
166
      buttongroup1.add(rdoUseNewExpresion);
167
      jpanel1.add(rdoUseNewExpresion,cc.xywh(3,14,2,1));
168
169
      lblName.setName("lblName");
170
      lblName.setText("_Nombre_de_la_expresion_opcinal");
171
      jpanel1.add(lblName,cc.xy(4,16));
172
173
      txtName.setName("txtName");
174
      jpanel1.add(txtName,cc.xy(4,18));
175
176
      lblExpresion.setName("lblExpresion");
177
      lblExpresion.setText("_Expresion");
178
      jpanel1.add(lblExpresion,cc.xy(4,20));
179
180
      txtExpresion.setName("txtExpresion");
181
      JScrollPane jscrollpane1 = new JScrollPane();
182
      jscrollpane1.setViewportView(txtExpresion);
183
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
184
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
185
      jpanel1.add(jscrollpane1,cc.xy(4,22));
186
187
      jpanel1.add(createPanel1(),cc.xy(4,24));
188
      lstFilters.setName("lstFilters");
189
      JScrollPane jscrollpane2 = new JScrollPane();
190
      jscrollpane2.setViewportView(lstFilters);
191
      jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
192
      jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
193
      jpanel1.add(jscrollpane2,cc.xy(4,12));
194
195
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25 });
196
      return jpanel1;
197
   }
198
199
   public JPanel createPanel1()
200
   {
201
      JPanel jpanel1 = new JPanel();
202
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
203
      CellConstraints cc = new CellConstraints();
204
      jpanel1.setLayout(formlayout1);
205
206
      butTest.setActionCommand("_Test");
207
      butTest.setName("butTest");
208
      butTest.setText("_Test");
209
      jpanel1.add(butTest,cc.xy(5,1));
210
211
      butFilterDialog.setActionCommand("_Filtro");
212
      butFilterDialog.setName("butFilterDialog");
213
      butFilterDialog.setText("_Filtro");
214
      jpanel1.add(butFilterDialog,cc.xy(3,1));
215
216
      addFillComponents(jpanel1,new int[]{ 1,2,4 },new int[]{ 1 });
217
      return jpanel1;
218
   }
219
220
   /**
221
    * Initializer
222
    */
223
   protected void initializePanel()
224
   {
225
      setLayout(new BorderLayout());
226
      add(createPanel(), BorderLayout.CENTER);
227
   }
228
229
230
}