Revision 47264

View differences:

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/SearchConditionPanelSimplified.java
1 1
package org.gvsig.fmap.dal.swing.impl.searchpanel;
2 2

  
3
import java.awt.GridBagConstraints;
4
import java.awt.GridBagLayout;
5
import java.awt.Insets;
3 6
import java.awt.event.ActionEvent;
4 7
import java.util.ArrayList;
5 8
import java.util.List;
......
8 11
import javax.json.JsonObject;
9 12
import javax.json.JsonObjectBuilder;
10 13
import javax.swing.JButton;
11
import javax.swing.JComboBox;
12 14
import javax.swing.JComponent;
13
import javax.swing.JLabel;
15
import javax.swing.JPanel;
14 16
import javax.swing.event.ChangeListener;
15 17
import org.apache.commons.lang3.StringUtils;
16 18
import org.gvsig.expressionevaluator.Code;
......
113 115
    public SearchConditionPanelSimplified(
114 116
            SearchParameters parameters,
115 117
            FeatureStore store,
118
            JPanel panel,
116 119
            JButton btnAddToAccumulatedFilter,
117 120
            JButton btnRemoveAccumulatedFilter,
118
            JButton btnViewAccumulatedFilter,
119
            JLabel lblField1,
120
            JLabel lblExtraFields1,
121
            JLabel lblRelationalOperator1,
122
            JComboBox cboValue1,
123
            JLabel lblNull1,
124
            JLabel lblLogicalOperators1,
125
            JLabel lblField2,
126
            JLabel lblExtraFields2,
127
            JLabel lblRelationalOperator2,
128
            JComboBox cboValue2,
129
            JLabel lblNull2,
130
            JLabel lblLogicalOperators2,
131
            JLabel lblField3,
132
            JLabel lblExtraFields3,
133
            JLabel lblRelationalOperator3,
134
            JComboBox cboValue3,
135
            JLabel lblNull3,
136
            JLabel lblLogicalOperators3,
137
            JLabel lblField4,
138
            JLabel lblExtraFields4,
139
            JLabel lblRelationalOperator4,
140
            JComboBox cboValue4,
141
            JLabel lblNull4,
142
            JLabel lblLogicalOperators4
121
            JButton btnViewAccumulatedFilter
143 122
    ) {
144 123
        this.changeListenerHelper = ToolsSwingLocator.getToolsSwingManager().createChangeListenerHelper();
145 124
        this.store = store;
125
        
146 126
        this.searchFieldsControllers = new ArrayList<>();
147
        SearchConditionFieldController controller = new SearchConditionFieldController(
148
                parameters,
149
                store,
150
                lblField1,
151
                lblExtraFields1,
152
                lblRelationalOperator1,
153
                cboValue1,
154
                lblNull1,
155
                lblLogicalOperators1
156
        );
157
        this.searchFieldsControllers.add(controller);
158
        controller = new SearchConditionFieldController(
159
                parameters,
160
                store,
161
                lblField2,
162
                lblExtraFields2,
163
                lblRelationalOperator2,
164
                cboValue2,
165
                lblNull2,
166
                lblLogicalOperators2
167
        );
168
        this.searchFieldsControllers.add(controller);
169
        controller = new SearchConditionFieldController(
170
                parameters,
171
                store,
172
                lblField3,
173
                lblExtraFields3,
174
                lblRelationalOperator3,
175
                cboValue3,
176
                lblNull3,
177
                lblLogicalOperators3
178
        );
179
        this.searchFieldsControllers.add(controller);
180
        controller = new SearchConditionFieldController(
181
                parameters,
182
                store,
183
                lblField4,
184
                lblExtraFields4,
185
                lblRelationalOperator4,
186
                cboValue4,
187
                lblNull4,
188
                null
189
        );
190
        this.searchFieldsControllers.add(controller);
127
        int numfields = 4;
128
        GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 2), 0, 0);
129
        c.weightx = 1.0/numfields;
130
        panel.setLayout(new GridBagLayout());
131
        for (int i = 0; i < numfields; i++) {
132
            c.gridx = i;
133
            c.weightx = 1.0;
134
            SearchConditionFieldView view = new SearchConditionFieldView();
135
            panel.add(view,c);
136
            SearchConditionFieldController controller = new SearchConditionFieldController(
137
                    parameters,
138
                    store,
139
                    view
140
            );
141
            this.searchFieldsControllers.add(controller);
142
            if( i==numfields-1 ) {
143
                view.lblLogicalOperators.setVisible(false);
144
            }
145
        }        
191 146
        this.accumulatedFilter = null;
192 147
        this.btnAddAccumulatedFilter = btnAddToAccumulatedFilter;
193 148
        this.btnRemoveAccumulatedFilter = btnRemoveAccumulatedFilter;
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/SelectGeometryPanelView.java
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.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.JPanel;
17
import javax.swing.JRadioButton;
18
import javax.swing.JScrollPane;
19
import javax.swing.JTextArea;
20
import javax.swing.JTextField;
21
import javax.swing.JTree;
22
import javax.swing.border.EmptyBorder;
23

  
24

  
25
public class SelectGeometryPanelView extends JPanel
26
{
27
   JRadioButton rdbUseGeomsFromClipbard = new JRadioButton();
28
   ButtonGroup buttongroup1 = new ButtonGroup();
29
   JRadioButton rdbUseGeomsFromLayerSelection = new JRadioButton();
30
   JRadioButton rdbConstantGeometry = new JRadioButton();
31
   JTree treeStores = new JTree();
32
   JTextArea txtGeometry = new JTextArea();
33
   JTextField txtProjection = new JTextField();
34
   JButton btnProjection = new JButton();
35
   JLabel lblProjection = new JLabel();
36

  
37
   /**
38
    * Default constructor
39
    */
40
   public SelectGeometryPanelView()
41
   {
42
      initializePanel();
43
   }
44

  
45
   /**
46
    * Adds fill components to empty cells in the first row and first column of the grid.
47
    * This ensures that the grid spacing will be the same as shown in the designer.
48
    * @param cols an array of column indices in the first row where fill components should be added.
49
    * @param rows an array of row indices in the first column where fill components should be added.
50
    */
51
   void addFillComponents( Container panel, int[] cols, int[] rows )
52
   {
53
      Dimension filler = new Dimension(10,10);
54

  
55
      boolean filled_cell_11 = false;
56
      CellConstraints cc = new CellConstraints();
57
      if ( cols.length > 0 && rows.length > 0 )
58
      {
59
         if ( cols[0] == 1 && rows[0] == 1 )
60
         {
61
            /** add a rigid area  */
62
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
63
            filled_cell_11 = true;
64
         }
65
      }
66

  
67
      for( int index = 0; index < cols.length; index++ )
68
      {
69
         if ( cols[index] == 1 && filled_cell_11 )
70
         {
71
            continue;
72
         }
73
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
74
      }
75

  
76
      for( int index = 0; index < rows.length; index++ )
77
      {
78
         if ( rows[index] == 1 && filled_cell_11 )
79
         {
80
            continue;
81
         }
82
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
83
      }
84

  
85
   }
86

  
87
   /**
88
    * Helper method to load an image file from the CLASSPATH
89
    * @param imageName the package and name of the file to load relative to the CLASSPATH
90
    * @return an ImageIcon instance with the specified image file
91
    * @throws IllegalArgumentException if the image resource cannot be loaded.
92
    */
93
   public ImageIcon loadImage( String imageName )
94
   {
95
      try
96
      {
97
         ClassLoader classloader = getClass().getClassLoader();
98
         java.net.URL url = classloader.getResource( imageName );
99
         if ( url != null )
100
         {
101
            ImageIcon icon = new ImageIcon( url );
102
            return icon;
103
         }
104
      }
105
      catch( Exception e )
106
      {
107
         e.printStackTrace();
108
      }
109
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
110
   }
111

  
112
   /**
113
    * Method for recalculating the component orientation for 
114
    * right-to-left Locales.
115
    * @param orientation the component orientation to be applied
116
    */
117
   public void applyComponentOrientation( ComponentOrientation orientation )
118
   {
119
      // Not yet implemented...
120
      // I18NUtils.applyComponentOrientation(this, orientation);
121
      super.applyComponentOrientation(orientation);
122
   }
123

  
124
   public JPanel createPanel()
125
   {
126
      JPanel jpanel1 = new JPanel();
127
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:8DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(0.9),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(0.1),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
128
      CellConstraints cc = new CellConstraints();
129
      jpanel1.setLayout(formlayout1);
130

  
131
      rdbUseGeomsFromClipbard.setActionCommand("_Use_geometries_from_clipboard");
132
      rdbUseGeomsFromClipbard.setName("rdbUseGeomsFromClipbard");
133
      rdbUseGeomsFromClipbard.setText("_Use_geometries_from_clipboard");
134
      buttongroup1.add(rdbUseGeomsFromClipbard);
135
      jpanel1.add(rdbUseGeomsFromClipbard,cc.xywh(2,2,2,1));
136

  
137
      rdbUseGeomsFromLayerSelection.setActionCommand("_Use_geometries_from_layer_selection");
138
      rdbUseGeomsFromLayerSelection.setName("rdbUseGeomsFromLayerSelection");
139
      rdbUseGeomsFromLayerSelection.setText("_Use_geometries_from_layer_selection");
140
      buttongroup1.add(rdbUseGeomsFromLayerSelection);
141
      jpanel1.add(rdbUseGeomsFromLayerSelection,cc.xywh(2,4,2,1));
142

  
143
      rdbConstantGeometry.setActionCommand("_Use_next_geometry");
144
      rdbConstantGeometry.setName("rdbConstantGeometry");
145
      rdbConstantGeometry.setText("_Use_the_following_geometry");
146
      buttongroup1.add(rdbConstantGeometry);
147
      jpanel1.add(rdbConstantGeometry,cc.xywh(2,8,2,1));
148

  
149
      treeStores.setName("treeStores");
150
      JScrollPane jscrollpane1 = new JScrollPane();
151
      jscrollpane1.setViewportView(treeStores);
152
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
153
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
154
      jpanel1.add(jscrollpane1,cc.xy(3,6));
155

  
156
      txtGeometry.setName("txtGeometry");
157
      JScrollPane jscrollpane2 = new JScrollPane();
158
      jscrollpane2.setViewportView(txtGeometry);
159
      jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
160
      jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
161
      jpanel1.add(jscrollpane2,cc.xy(3,10));
162

  
163
      jpanel1.add(createPanel1(),cc.xy(3,12));
164
      addFillComponents(jpanel1,new int[]{ 1,2,3,4 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13 });
165
      return jpanel1;
166
   }
167

  
168
   public JPanel createPanel1()
169
   {
170
      JPanel jpanel1 = new JPanel();
171
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
172
      CellConstraints cc = new CellConstraints();
173
      jpanel1.setLayout(formlayout1);
174

  
175
      txtProjection.setName("txtProjection");
176
      jpanel1.add(txtProjection,cc.xy(3,1));
177

  
178
      btnProjection.setActionCommand("...");
179
      btnProjection.setName("btnProjection");
180
      btnProjection.setText("...");
181
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
182
      btnProjection.setBorder(emptyborder1);
183
      jpanel1.add(btnProjection,cc.xy(5,1));
184

  
185
      lblProjection.setName("lblProjection");
186
      lblProjection.setText("_Projection");
187
      jpanel1.add(lblProjection,cc.xy(1,1));
188

  
189
      addFillComponents(jpanel1,new int[]{ 2,4 },new int[0]);
190
      return jpanel1;
191
   }
192

  
193
   /**
194
    * Initializer
195
    */
196
   protected void initializePanel()
197
   {
198
      setLayout(new BorderLayout());
199
      add(createPanel(), BorderLayout.CENTER);
200
   }
201

  
202

  
203
}
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/DefaultSearchPanelView2.java
11 11
import javax.swing.ImageIcon;
12 12
import javax.swing.JButton;
13 13
import javax.swing.JCheckBox;
14
import javax.swing.JComboBox;
15 14
import javax.swing.JFrame;
16 15
import javax.swing.JLabel;
17 16
import javax.swing.JPanel;
......
26 25
public class DefaultSearchPanelView2 extends JPanel
27 26
{
28 27
   JTabbedPane tabSearchMode = new JTabbedPane();
29
   JComboBox cboValue1 = new JComboBox();
30
   JComboBox cboValue2 = new JComboBox();
31
   JComboBox cboValue3 = new JComboBox();
32
   JComboBox cboValue4 = new JComboBox();
33
   JLabel lblRelationalOperator1 = new JLabel();
34
   JLabel lblRelationalOperator2 = new JLabel();
35
   JLabel lblRelationalOperator3 = new JLabel();
36
   JLabel lblRelationalOperator4 = new JLabel();
37
   JLabel lblLogicalOperators1 = new JLabel();
38
   JLabel lblLogicalOperators2 = new JLabel();
39
   JLabel lblLogicalOperators3 = new JLabel();
40
   JLabel lblField1 = new JLabel();
41
   JLabel lblField2 = new JLabel();
42
   JLabel lblField3 = new JLabel();
43
   JLabel lblField4 = new JLabel();
44
   JLabel lblExtraFields1 = new JLabel();
45
   JLabel lblExtraFields2 = new JLabel();
46
   JLabel lblExtraFields3 = new JLabel();
47
   JLabel lblExtraFields4 = new JLabel();
48
   JLabel lblNull1 = new JLabel();
49
   JLabel lblNull2 = new JLabel();
50
   JLabel lblNull3 = new JLabel();
51
   JLabel lblNull4 = new JLabel();
52 28
   JButton btnRemoveAccumulatedFilter = new JButton();
53 29
   JButton btnAddAccumulatedFilter = new JButton();
54 30
   JButton btnViewAccumulatedFilter = new JButton();
31
   JPanel pnlConditionField = new JPanel();
55 32
   JLabel lblExpressionDeBusqueda = new JLabel();
56 33
   JButton btnAdvancedExpression = new JButton();
57 34
   JButton btnAdvancedExpressionHistory = new JButton();
......
189 166
   public JPanel createPanel1()
190 167
   {
191 168
      JPanel jpanel1 = new JPanel();
192
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:MAX(120PX;DEFAULT):NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:MAX(120PX;DEFAULT):NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:MAX(120PX;DEFAULT):NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:MAX(120PX;DEFAULT):NONE,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");
169
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.2),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.2),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(0.2),FILL:DEFAULT:NONE,FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE");
193 170
      CellConstraints cc = new CellConstraints();
194 171
      jpanel1.setLayout(formlayout1);
195 172

  
196
      cboValue1.setEditable(true);
197
      cboValue1.setName("cboValue1");
198
      cboValue1.setRequestFocusEnabled(false);
199
      jpanel1.add(cboValue1,cc.xywh(2,6,3,1));
173
      jpanel1.add(createPanel2(),new CellConstraints(2,4,20,1,CellConstraints.RIGHT,CellConstraints.DEFAULT));
174
      pnlConditionField.setName("pnlConditionField");
175
      jpanel1.add(pnlConditionField,cc.xywh(2,2,20,1));
200 176

  
201
      cboValue2.setEditable(true);
202
      cboValue2.setName("cboValue2");
203
      cboValue2.setRequestFocusEnabled(false);
204
      jpanel1.add(cboValue2,new CellConstraints(8,6,3,1,CellConstraints.FILL,CellConstraints.DEFAULT));
205

  
206
      cboValue3.setEditable(true);
207
      cboValue3.setName("cboValue3");
208
      cboValue3.setRequestFocusEnabled(false);
209
      jpanel1.add(cboValue3,cc.xywh(14,6,3,1));
210

  
211
      cboValue4.setEditable(true);
212
      cboValue4.setName("cboValue4");
213
      cboValue4.setRequestFocusEnabled(false);
214
      jpanel1.add(cboValue4,cc.xywh(20,6,2,1));
215

  
216
      lblRelationalOperator1.setName("lblRelationalOperator1");
217
      lblRelationalOperator1.setText("Igual");
218
      lblRelationalOperator1.setHorizontalAlignment(JLabel.CENTER);
219
      jpanel1.add(lblRelationalOperator1,cc.xy(2,4));
220

  
221
      lblRelationalOperator2.setName("lblRelationalOperator2");
222
      lblRelationalOperator2.setText("Igual");
223
      lblRelationalOperator2.setHorizontalAlignment(JLabel.CENTER);
224
      jpanel1.add(lblRelationalOperator2,cc.xy(8,4));
225

  
226
      lblRelationalOperator3.setName("lblRelationalOperator3");
227
      lblRelationalOperator3.setText("Igual");
228
      lblRelationalOperator3.setHorizontalAlignment(JLabel.CENTER);
229
      jpanel1.add(lblRelationalOperator3,cc.xy(14,4));
230

  
231
      lblRelationalOperator4.setName("lblRelationalOperator4");
232
      lblRelationalOperator4.setText("Igual");
233
      lblRelationalOperator4.setHorizontalAlignment(JLabel.CENTER);
234
      jpanel1.add(lblRelationalOperator4,cc.xy(20,4));
235

  
236
      lblLogicalOperators1.setName("lblLogicalOperators1");
237
      lblLogicalOperators1.setText("WWWWW");
238
      lblLogicalOperators1.setHorizontalAlignment(JLabel.CENTER);
239
      jpanel1.add(lblLogicalOperators1,cc.xy(6,2));
240

  
241
      lblLogicalOperators2.setName("lblLogicalOperators2");
242
      lblLogicalOperators2.setText("WWWWW");
243
      lblLogicalOperators2.setHorizontalAlignment(JLabel.CENTER);
244
      jpanel1.add(lblLogicalOperators2,cc.xy(12,2));
245

  
246
      lblLogicalOperators3.setName("lblLogicalOperators3");
247
      lblLogicalOperators3.setText("WWWWW");
248
      lblLogicalOperators3.setHorizontalAlignment(JLabel.CENTER);
249
      jpanel1.add(lblLogicalOperators3,cc.xy(18,2));
250

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

  
255
      lblField2.setName("lblField2");
256
      lblField2.setHorizontalAlignment(JLabel.CENTER);
257
      jpanel1.add(lblField2,cc.xy(8,2));
258

  
259
      lblField3.setName("lblField3");
260
      lblField3.setHorizontalAlignment(JLabel.CENTER);
261
      jpanel1.add(lblField3,cc.xy(14,2));
262

  
263
      lblField4.setName("lblField4");
264
      lblField4.setHorizontalAlignment(JLabel.CENTER);
265
      jpanel1.add(lblField4,cc.xy(20,2));
266

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

  
271
      lblExtraFields2.setIcon(loadImage("src/main/resources/org/gvsig/fmap/dal/swing/impl/searchpanel/featurestore-column.png"));
272
      lblExtraFields2.setName("lblExtraFields2");
273
      jpanel1.add(lblExtraFields2,cc.xy(10,2));
274

  
275
      lblExtraFields3.setIcon(loadImage("src/main/resources/org/gvsig/fmap/dal/swing/impl/searchpanel/featurestore-column.png"));
276
      lblExtraFields3.setName("lblExtraFields3");
277
      jpanel1.add(lblExtraFields3,cc.xy(16,2));
278

  
279
      lblExtraFields4.setIcon(loadImage("src/main/resources/org/gvsig/fmap/dal/swing/impl/searchpanel/featurestore-column.png"));
280
      lblExtraFields4.setName("lblExtraFields4");
281
      jpanel1.add(lblExtraFields4,cc.xy(21,2));
282

  
283
      lblNull1.setName("lblNull1");
284
      lblNull1.setHorizontalAlignment(JLabel.CENTER);
285
      jpanel1.add(lblNull1,cc.xy(4,4));
286

  
287
      lblNull2.setName("lblNull2");
288
      lblNull2.setHorizontalAlignment(JLabel.CENTER);
289
      jpanel1.add(lblNull2,cc.xy(10,4));
290

  
291
      lblNull3.setName("lblNull3");
292
      lblNull3.setHorizontalAlignment(JLabel.CENTER);
293
      jpanel1.add(lblNull3,cc.xy(16,4));
294

  
295
      lblNull4.setName("lblNull4");
296
      lblNull4.setHorizontalAlignment(JLabel.CENTER);
297
      jpanel1.add(lblNull4,cc.xy(21,4));
298

  
299
      jpanel1.add(createPanel2(),new CellConstraints(2,8,20,1,CellConstraints.RIGHT,CellConstraints.DEFAULT));
300
      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 });
177
      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 });
301 178
      return jpanel1;
302 179
   }
303 180

  
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/SearchConditionFieldView.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.fmap.dal.swing.impl.searchpanel;
7

  
8
import java.awt.Color;
9
import java.awt.GridBagConstraints;
10
import java.awt.GridBagLayout;
11
import java.awt.Insets;
12
import javax.swing.JButton;
13
import javax.swing.JComboBox;
14
import javax.swing.JLabel;
15
import javax.swing.JPanel;
16
import javax.swing.JTextField;
17
import javax.swing.SwingConstants;
18
import org.gvsig.tools.swing.api.ToolsSwingUtils;
19

  
20
/**
21
 *
22
 * @author jjdelcerro
23
 */
24
public class SearchConditionFieldView extends JPanel {
25
    
26
    public final JLabel lblFields;
27
    public final JLabel lblExtraFields;
28
    public final JLabel lblLogicalOperators;
29
    public final JLabel lblRelationalOperators;
30
    public final JComboBox cboValue;
31
    public final JTextField txtValue;
32
    public final JButton btnValue;
33
    public final JLabel lblNull;
34
    
35
    @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"})
36
    public SearchConditionFieldView() {
37
        this.lblFields = new JLabel();
38
        this.lblExtraFields = new JLabel(ToolsSwingUtils.loadImage(this, "featurestore-column"));
39
        this.lblRelationalOperators = new JLabel("WWWW");
40
        this.cboValue = new JComboBox();
41
        this.txtValue = new JTextField();
42
        this.btnValue = new JButton();
43
        this.lblNull = new JLabel();
44
        this.lblLogicalOperators = new JLabel();
45
        
46
        this.lblFields.setHorizontalAlignment(SwingConstants.CENTER);
47
        this.lblRelationalOperators.setHorizontalAlignment(SwingConstants.CENTER);
48
        this.cboValue.setEditable(true);
49
        this.txtValue.setEditable(true);
50
        ToolsSwingUtils.configurePickersButton(
51
                btnValue, 
52
                null, 
53
                "search-geometry-select", 
54
                null, 
55
                null
56
        );
57
        
58
//        this.setBackground(Color.BLUE.brighter());
59
        GridBagConstraints c = new GridBagConstraints();
60
        this.setLayout(new GridBagLayout());
61
        
62
        c.gridy = 0;
63
        c.gridx = 0;
64
        c.weightx = 1.0;
65
        c.fill = GridBagConstraints.HORIZONTAL;
66
        c.gridwidth = 2;
67
        c.insets = new Insets(2,2,2,2);
68
        c.anchor = GridBagConstraints.CENTER;
69
        this.add(this.lblFields, c);
70

  
71
        c.gridy = 0;
72
        c.gridx = 2;
73
        c.weightx = 0;
74
        c.fill = GridBagConstraints.NONE;
75
        c.gridwidth = 1;
76
        c.insets = new Insets(2,2,2,2);
77
        c.anchor = GridBagConstraints.LINE_START;
78
        this.add(this.lblExtraFields, c);
79
        
80
        c.gridx = 3;
81
        c.gridy = 0;
82
        c.weightx = 0;
83
        c.fill = GridBagConstraints.NONE;
84
        c.gridwidth = 1;
85
        c.insets = new Insets(2,2,2,2);
86
        c.anchor = GridBagConstraints.LINE_START;
87
        this.add(this.lblLogicalOperators, c);
88
        
89
        c.gridy = 1;
90
        c.gridx = 0;
91
        c.weightx = 1.0;
92
        c.fill = GridBagConstraints.HORIZONTAL;
93
        c.gridwidth = 2;
94
        c.insets = new Insets(2,2,2,2);
95
        c.anchor = GridBagConstraints.CENTER;
96
        this.add(this.lblRelationalOperators, c);
97
        
98
        c.gridy = 2;
99
        c.gridx = 0;
100
        c.weightx = 1.0;
101
        c.fill = GridBagConstraints.HORIZONTAL;
102
        c.gridwidth = 2;
103
        c.insets = new Insets(2,2,0,2);
104
        c.anchor = GridBagConstraints.CENTER;
105
        this.add(this.cboValue, c);
106
        
107
        c.gridy = 3;
108
        c.gridx = 0;
109
        c.weightx = 1.0;
110
        c.fill = GridBagConstraints.HORIZONTAL;
111
        c.gridwidth = 1;
112
        c.insets = new Insets(0,2,2,2);
113
        c.anchor = GridBagConstraints.CENTER;
114
        this.add(this.txtValue, c);
115
        
116
        c.gridy = 3;
117
        c.gridx = 1;
118
        c.weightx = 0;
119
        c.fill = GridBagConstraints.NONE;
120
        c.gridwidth = 1;
121
        c.insets = new Insets(0,2,2,2);
122
        c.anchor = GridBagConstraints.LINE_START;
123
        this.add(this.btnValue, c);
124
        
125
    }
126
}
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/SelectGeometryPanel.java
1
package org.gvsig.fmap.dal.swing.impl.searchpanel;
2

  
3
import javax.swing.JComponent;
4
import javax.swing.event.ChangeEvent;
5
import org.apache.commons.lang3.StringUtils;
6
import org.cresques.cts.IProjection;
7
import org.gvsig.fmap.dal.feature.FeatureStore;
8
import org.gvsig.fmap.dal.swing.DALSwingLocator;
9
import org.gvsig.fmap.dal.swing.DataSwingManager;
10
import org.gvsig.fmap.dal.swing.ProjectionPickerController;
11
import static org.gvsig.fmap.dal.swing.impl.searchpanel.SearchConditionFieldController.GEOM_OPERAND_MODE_CLIPBOARD;
12
import static org.gvsig.fmap.dal.swing.impl.searchpanel.SearchConditionFieldController.GEOM_OPERAND_MODE_CONSTANT;
13
import static org.gvsig.fmap.dal.swing.impl.searchpanel.SearchConditionFieldController.GEOM_OPERAND_MODE_LAYER_SELECTION;
14
import org.gvsig.fmap.dal.swing.storesrepository.StoresRepositoryController;
15
import org.gvsig.fmap.geom.Geometry;
16
import org.gvsig.fmap.geom.GeometryUtils;
17
import org.gvsig.tools.dispose.DisposeUtils;
18
import org.gvsig.tools.swing.api.Component;
19
import org.gvsig.tools.swing.api.ToolsSwingLocator;
20
import org.gvsig.tools.swing.api.ToolsSwingManager;
21
import org.gvsig.tools.swing.api.ToolsSwingUtils;
22

  
23
/**
24
 *
25
 * @author jjdelcerro
26
 */
27
public class SelectGeometryPanel 
28
        extends SelectGeometryPanelView 
29
        implements Component
30
    {
31

  
32
    private ProjectionPickerController pickerProjection;
33
    private StoresRepositoryController storesRepositoryController;
34

  
35
    public SelectGeometryPanel() {
36
        this.createComponents();
37
    }
38
    
39
    private void createComponents() {
40
        this.initComponents();        
41
    }
42
    
43
    private void initComponents() {
44
        this.translate();
45
        
46
        DataSwingManager dataSwingMamager = DALSwingLocator.getDataSwingManager();
47
        
48
        this.pickerProjection = dataSwingMamager.createProjectionPickerController(
49
                txtProjection, 
50
                btnProjection
51
        );
52
        this.storesRepositoryController = dataSwingMamager.createStoresRepositoryController(treeStores);
53
        
54
        this.rdbConstantGeometry.addChangeListener((ChangeEvent e) -> {
55
            doUpdateEnableComponents();
56
        });
57
        this.rdbUseGeomsFromClipbard.addChangeListener((ChangeEvent e) -> {
58
            doUpdateEnableComponents();
59
        });
60
        this.rdbUseGeomsFromLayerSelection.addChangeListener((ChangeEvent e) -> {
61
            doUpdateEnableComponents();
62
        });
63
        this.rdbUseGeomsFromClipbard.setSelected(true);
64
        doUpdateEnableComponents();
65

  
66
        ToolsSwingUtils.ensureRowsCols(this, 24, 80, 50, 100);
67
    }
68

  
69
    private void translate() {
70
        ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager();
71
        
72
        toolsSwingManager.translate(this.rdbConstantGeometry);
73
        toolsSwingManager.translate(this.rdbUseGeomsFromClipbard);
74
        toolsSwingManager.translate(this.rdbUseGeomsFromLayerSelection);
75
        toolsSwingManager.translate(this.lblProjection);
76
    }
77
    
78
    @Override
79
    public JComponent asJComponent() {
80
        return this;
81
    }
82

  
83
    public int getMode() {
84
        if( this.rdbUseGeomsFromClipbard.isSelected() ) {
85
            return GEOM_OPERAND_MODE_CLIPBOARD;
86
        } else if( this.rdbUseGeomsFromLayerSelection.isSelected() ) {
87
            return GEOM_OPERAND_MODE_LAYER_SELECTION;
88
        } else if( this.rdbConstantGeometry.isSelected() ) {
89
            return GEOM_OPERAND_MODE_CONSTANT;
90
        }
91
        return GEOM_OPERAND_MODE_CLIPBOARD;
92
    }
93

  
94
    public Geometry getGeometry() {
95
        String s = this.txtGeometry.getText();
96
        if( StringUtils.isBlank(s) ) {
97
            return null;
98
        }
99
        return GeometryUtils.createFrom(s, this.getProjection());
100
    }
101
    
102
    public IProjection getProjection() {
103
        return this.pickerProjection.get();
104
    }
105

  
106
    public String getStoreName() {
107
        FeatureStore store = null;
108
        try {
109
            store = this.storesRepositoryController.getSelectedFeatureStore();
110
            if( store == null ) {
111
                return null;
112
            }
113
            return store.getName();
114
        } finally {
115
            DisposeUtils.disposeQuietly(store);                    
116
        }
117
    }
118

  
119
    private void doUpdateEnableComponents() {
120
        if( this.rdbUseGeomsFromClipbard.isSelected() ) {
121
            this.treeStores.setEnabled(false);
122
            this.pickerProjection.setEnabled(false);
123
            this.txtGeometry.setEnabled(false);
124
        } else if( this.rdbUseGeomsFromLayerSelection.isSelected() ) {
125
            this.treeStores.setEnabled(true);
126
            this.pickerProjection.setEnabled(false);
127
            this.txtGeometry.setEnabled(false);
128
        } else if( this.rdbConstantGeometry.isSelected() ) {
129
            this.treeStores.setEnabled(false);
130
            this.pickerProjection.setEnabled(true);
131
            this.txtGeometry.setEnabled(true);
132
        }
133
    }
134
}
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/SearchConditionFieldController.java
1 1
package org.gvsig.fmap.dal.swing.impl.searchpanel;
2 2

  
3 3
import java.awt.Cursor;
4
import java.awt.Dimension;
4 5
import java.awt.event.ActionEvent;
5 6
import java.awt.event.ItemEvent;
6 7
import java.awt.event.ItemListener;
......
9 10
import java.text.DateFormat;
10 11
import java.util.ArrayList;
11 12
import java.util.Arrays;
13
import java.util.Collections;
12 14
import java.util.Comparator;
13 15
import java.util.Date;
14 16
import java.util.HashMap;
17
import java.util.Iterator;
15 18
import java.util.List;
16 19
import java.util.Locale;
17 20
import java.util.Map;
18 21
import java.util.Objects;
19
import javax.json.Json;
20 22
import javax.json.JsonArray;
21
import javax.json.JsonArrayBuilder;
22 23
import javax.json.JsonObject;
23
import javax.json.JsonObjectBuilder;
24 24
import javax.swing.ComboBoxModel;
25 25
import javax.swing.DefaultComboBoxModel;
26 26
import javax.swing.ImageIcon;
27
import javax.swing.JButton;
27 28
import javax.swing.JComboBox;
28 29
import javax.swing.JLabel;
29 30
import javax.swing.JOptionPane;
31
import javax.swing.JTextField;
30 32
import javax.swing.SwingUtilities;
31 33
import javax.swing.text.JTextComponent;
32 34
import org.apache.commons.lang3.StringUtils;
33 35
import org.apache.commons.lang3.mutable.MutableBoolean;
36
import org.cresques.cts.IProjection;
34 37
import org.gvsig.expressionevaluator.ExpressionBuilder;
38
import org.gvsig.expressionevaluator.GeometryExpressionBuilder;
35 39
import org.gvsig.fmap.dal.DALLocator;
36 40
import org.gvsig.fmap.dal.DataManager;
37 41
import org.gvsig.fmap.dal.DataStore;
42
import org.gvsig.fmap.dal.DataTypes;
38 43
import org.gvsig.fmap.dal.SQLBuilder;
44
import org.gvsig.fmap.dal.StoresRepository;
39 45
import org.gvsig.fmap.dal.complements.Search;
40 46
import org.gvsig.fmap.dal.exception.DataException;
41 47
import org.gvsig.fmap.dal.expressionevaluator.DALExpressionBuilder;
42 48
import org.gvsig.fmap.dal.feature.Feature;
43 49
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
44 50
import org.gvsig.fmap.dal.feature.FeatureQuery;
51
import org.gvsig.fmap.dal.feature.FeatureReference;
45 52
import org.gvsig.fmap.dal.feature.FeatureSet;
46 53
import org.gvsig.fmap.dal.feature.FeatureStore;
47 54
import org.gvsig.fmap.dal.feature.FeatureType;
......
53 60
import static org.gvsig.fmap.dal.swing.searchpanel.FeatureStoreSearchPanel.NULL_AS_FALSE;
54 61
import static org.gvsig.fmap.dal.swing.searchpanel.FeatureStoreSearchPanel.NULL_AS_TRUE;
55 62
import org.gvsig.fmap.dal.swing.searchpanel.SearchParameters;
63
import org.gvsig.fmap.geom.Geometry;
64
import org.gvsig.fmap.geom.GeometryUtils;
65
import org.gvsig.json.Json;
66
import org.gvsig.json.JsonArrayBuilder;
67
import org.gvsig.json.JsonObjectBuilder;
56 68
import org.gvsig.tools.ToolsLocator;
57 69
import org.gvsig.tools.dataTypes.Coercion;
58 70
import org.gvsig.tools.dataTypes.CoercionException;
59 71
import org.gvsig.tools.dataTypes.DataTypeUtils;
60
import org.gvsig.tools.dataTypes.DataTypes;
61 72
import org.gvsig.tools.dispose.DisposeUtils;
62 73
import org.gvsig.tools.dynobject.DynField;
63 74
import org.gvsig.tools.i18n.I18nManager;
......
90 101

  
91 102
    private static final int MAXLEN_IN_COMBOS = 70;
92 103
    
104
    /*friend*/ static final int GEOM_OPERAND_MODE_CLIPBOARD = 0;
105
    /*friend*/ static final int GEOM_OPERAND_MODE_LAYER_SELECTION = 1;
106
    /*friend*/ static final int GEOM_OPERAND_MODE_CONSTANT = 2;
107
    
93 108
    private static final String OPERATOR_CONTAINS = "CONTAINS";
94
    private UpdateValueList updateValueListTask;
95
    
109

  
96 110
    private class UpdateValueList implements Runnable, CancellableTask {
97 111

  
98 112
        private final Field field;
......
223 237
                        return;
224 238
                    }
225 239
                    setEnabled(false);
240
                    Dimension sz = cboValue.getPreferredSize();
226 241
                    cboValue.setModel(model);
242
                    cboValue.setPreferredSize(sz);
227 243
                    if (valueAssigned != null) {
228 244
                        cboValue.setSelectedItem(valueAssigned);
229 245
                        valueAssigned = null;
......
320 336
    private final JLabel lblLogicalOperators;
321 337
    private final JLabel lblRelationalOperators;
322 338
    private final JComboBox cboValue;
339
    private final JTextField txtValue;
340
    private final JButton btnValue;
323 341
    private final JLabel lblNull;
324 342
    private Object valueAssigned = null;
325 343

  
......
339 357
    private int updateValuesTimeLimit;
340 358
    private int updateValuesFeaturesLimit;
341 359

  
360
    private UpdateValueList updateValueListTask;
361
    private LabeledValue[] geometryRelationalOperators;
362
    private DefaultComboBoxModel modelRelationalOperators;
363
    private DefaultComboBoxModel modelGeometryRelationalOperators;
364
    
365
    private int geometryOperandMode;
366
    private String geometryOperandStoreName;
367
    private Geometry geometryOperandConstant;
368
    
342 369
    public SearchConditionFieldController(
343 370
            SearchParameters parameters,
344 371
            FeatureStore store,
345
            JLabel lblFields,
346
            JLabel lblExtraFields,
347
            JLabel lblRelationalOperators,
348
            JComboBox cboValue,
349
            JLabel lblNull,
350
            JLabel lblLogicalOperators
372
            SearchConditionFieldView view           
351 373
    ) {
352 374
        this.parameters = parameters;
353 375
        this.store = store;
354
        this.lblFields = lblFields;
355
        this.lblExtraFields = lblExtraFields;
356
        this.lblRelationalOperators = lblRelationalOperators;
357
        this.cboValue = cboValue;
358
        this.lblNull = lblNull;
359
        this.lblLogicalOperators = lblLogicalOperators;
376
        this.lblFields = view.lblFields;
377
        this.lblExtraFields = view.lblExtraFields;
378
        this.lblRelationalOperators = view.lblRelationalOperators;
379
        this.cboValue = view.cboValue;
380
        this.txtValue = view.txtValue;
381
        this.btnValue = view.btnValue;
382
        this.lblNull = view.lblNull;
383
        this.lblLogicalOperators = view.lblLogicalOperators;
360 384
        this.updateValuesTimeLimit = 60;
361 385
        this.updateValuesFeaturesLimit = 1000;
362 386
        this.initComponents();
......
371 395
        return false;
372 396
    }
373 397

  
398
    @SuppressWarnings("Convert2Lambda")
374 399
    private void initComponents() {
375 400
        try {
376 401
            I18nManager i18n = ToolsLocator.getI18nManager();
......
389 414
                new LabeledValueImpl(i18n.getTranslation("_Is_not_null"), ExpressionBuilder.OPERATOR_IS_NOT_NULL)
390 415
            };
391 416

  
417
            this.geometryRelationalOperators = new LabeledValue[]{
418
                new LabeledValueImpl(i18n.getTranslation("_Is_covered_by"), GeometryExpressionBuilder.FUNCTION_ST_COVEREDBY),
419
                new LabeledValueImpl(i18n.getTranslation("_Covers_to"), GeometryExpressionBuilder.FUNCTION_ST_COVERS),
420
                new LabeledValueImpl(i18n.getTranslation("_Contains_to"), GeometryExpressionBuilder.FUNCTION_ST_CONTAINS),
421
                new LabeledValueImpl(i18n.getTranslation("_Crosses_to"), GeometryExpressionBuilder.FUNCTION_ST_CROSSES),
422
                new LabeledValueImpl(i18n.getTranslation("_Is_disjoint_with"), GeometryExpressionBuilder.FUNCTION_ST_DISJOINT),
423
                new LabeledValueImpl(i18n.getTranslation("_Intersects_with"), GeometryExpressionBuilder.FUNCTION_ST_INTERSECTS),
424
                new LabeledValueImpl(i18n.getTranslation("_Is_closed"), GeometryExpressionBuilder.FUNCTION_ST_ISCLOSED),
425
                new LabeledValueImpl(i18n.getTranslation("_Overlaps_with"), GeometryExpressionBuilder.FUNCTION_ST_OVERLAPS),
426
                new LabeledValueImpl(i18n.getTranslation("_Touches_with"), GeometryExpressionBuilder.FUNCTION_ST_TOUCHES),
427
                new LabeledValueImpl(i18n.getTranslation("_Is_within_of"), GeometryExpressionBuilder.FUNCTION_ST_WITHIN),
428
                new LabeledValueImpl(i18n.getTranslation("_Is_equals_to"), GeometryExpressionBuilder.FUNCTION_ST_EQUALS),
429
                new LabeledValueImpl(i18n.getTranslation("_Is_null"), ExpressionBuilder.OPERATOR_IS_NULL),
430
                new LabeledValueImpl(i18n.getTranslation("_Is_not_null"), ExpressionBuilder.OPERATOR_IS_NOT_NULL)
431
            };
432

  
392 433
            logicalOperators = new LabeledValue[]{
393 434
                new LabeledValueImpl(i18n.getTranslation("_Or"), ExpressionBuilder.OPERATOR_OR),
394 435
                new LabeledValueImpl(i18n.getTranslation("_And"), ExpressionBuilder.OPERATOR_AND)
......
416 457
                this.ddnLogicalOperators.setVisibleDropdownArrow(false);
417 458
            }
418 459

  
419
            DefaultComboBoxModel modelRelationalOperators = new DefaultComboBoxModel();
460
            this.modelRelationalOperators = new DefaultComboBoxModel();
420 461
            for (LabeledValue op : relationalOperators) {
421 462
                modelRelationalOperators.addElement(op);
422 463
            }
464
            this.modelGeometryRelationalOperators = new DefaultComboBoxModel();
465
            for (LabeledValue op : geometryRelationalOperators) {
466
                modelGeometryRelationalOperators.addElement(op);
467
            }
423 468
            this.ddnRelationalOperators.setModel(modelRelationalOperators);
424 469
            this.ddnRelationalOperators.addItemListener(new ItemListener() {
425 470
                @Override
......
437 482
                this.ddnLogicalOperators.setSelectedIndex(1);
438 483
            }
439 484

  
440
//            this.ddnNullOperators = new DropDownLabelIcon(lblNull);
441 485
            this.ddnNullBehavior = toolsSwingManager.createDropDownIcon(lblNull);
442 486
            this.ddnNullBehavior.setVisibleDropdownArrow(false);
443 487
            DefaultComboBoxModel modelNullOperators = new DefaultComboBoxModel();
......
452 496
                    Search.COMPLEMENT_MANE, featureType
453 497
            );
454 498
            List<Search.OrderedAttribute> orderedAttributes = search.getOrderedAttributes(
455
                    Search.BASIC_TYPES_FILTER,
499
                    Search.ALL_FILTER, //BASIC_TYPES_FILTER,
456 500
                    Search.STR_INT_LONG_LABEL_ORDER,
457 501
                    SIZE_ORDERED_ATTRIBUTES
458 502
            );
......
508 552
                    doSelectMoreFields();
509 553
                }
510 554
            });
555
            this.txtValue.setVisible(false);
556
            this.btnValue.setVisible(false);
557
            this.geometryOperandMode = GEOM_OPERAND_MODE_CLIPBOARD;
558
            this.geometryOperandStoreName = null;
559
            this.geometryOperandConstant = null;
560
            this.btnValue.addActionListener((ActionEvent e) -> {doSelectGeometryOperand(); });
561

  
511 562
            doUpdateControllerByRelationalOperator();
512 563
//      clear();
513 564
        } catch (Exception ex) {
......
525 576
            lblNull.setEnabled(true);
526 577
            cboValue.setEnabled(true);
527 578
        }
579
        doUpdateCurrentValue();
580
    }
528 581

  
582
    private void doUpdateCurrentValue() {
583
        Field field = this.getCurrentField();
584
        if( field!=null ) {
585
            FeatureAttributeDescriptor desc = field.getDescriptor();
586
            int type = desc==null? DataTypes.INT:desc.getType();
587
            switch(type) {
588
                case DataTypes.GEOMETRY:
589
                    this.cboValue.setVisible(false);
590
                    this.txtValue.setVisible(true);
591
                    this.btnValue.setVisible(true);
592
                    switch(this.geometryOperandMode) {
593
                        case GEOM_OPERAND_MODE_CONSTANT:
594
                            if( this.geometryOperandConstant == null ) {
595
                                this.txtValue.setText("");
596
                            } else {
597
                                this.txtValue.setText(Objects.toString(GeometryUtils.toWKT(this.geometryOperandConstant), ""));
598
                            }
599
                            break;
600
                        case GEOM_OPERAND_MODE_LAYER_SELECTION:
601
                            if( this.geometryOperandStoreName!=null ) {
602
                                StoresRepository repo = DALLocator.getDataManager().getStoresRepository();
603
                                this.txtValue.setText(repo.getLabelOrName(this.geometryOperandStoreName));
604
                                break;
605
                            }
606
                            this.geometryOperandMode = GEOM_OPERAND_MODE_CLIPBOARD;
607
                        case GEOM_OPERAND_MODE_CLIPBOARD:
608
                            this.txtValue.setText("Contenido del portapapeles"); // i18n.getTranslation("_Clipboard_content"));
609
                            break;
610
                    }
611
                    break;
612
                default:
613
                    if( this.txtValue.isVisible() ) {
614
                        this.ddnRelationalOperators.setSelectedIndex(1);
615
                    }
616
                    this.cboValue.setVisible(true);
617
                    this.txtValue.setVisible(false);
618
                    this.btnValue.setVisible(false);
619
            }
620
        }
529 621
    }
530 622

  
531 623
    private FeatureType getFeatureType() {
......
639 731
        }
640 732
        this.cboValue.setSelectedIndex(-1);
641 733
        this.ddnNullBehavior.setSelectedIndex(0);
734
        this.geometryOperandStoreName = null;
735
        this.geometryOperandMode = GEOM_OPERAND_MODE_CLIPBOARD;
642 736
        doUpdateControllerByRelationalOperator();
643 737
    }
644 738

  
......
662 756
        lastUpdateValuesFeaturesLimit = updateValuesFeaturesLimit;
663 757
        lastUpdateValuesTimeLimit = updateValuesTimeLimit;
664 758
        
665
        if (descriptor.getType() == DataTypes.DATE) {
666
            if (this.dateController == null) {
667
                this.dateController = ToolsSwingLocator.getToolsSwingManager().createDatePickerController(
668
                        (JTextComponent) this.cboValue.getEditor().getEditorComponent(),
669
                        null
670
                );
671
            }
672
        } else {
673
            if (this.dateController != null) {
674
                this.dateController.uninstall();
675
                this.dateController = null;
676
            }
677
        }
678

  
679 759
        if(this.updateValueListTask != null){
680 760
            this.updateValueListTask.cancelRequest();
681 761
        }
682
        this.updateValueListTask = new UpdateValueList(field);
683
        Thread th = new Thread(updateValueListTask);
684
        th.start();
762
        Thread updateTask;
763
        switch(descriptor.getType()) {
764
            case DataTypes.GEOMETRY:
765
                this.ddnRelationalOperators.setModel(modelGeometryRelationalOperators);
766
                if( !this.txtValue.isVisible() ) {
767
                    this.ddnRelationalOperators.setSelectedIndex(0);
768
                }
769
                this.cboValue.setVisible(false);
770
                this.txtValue.setVisible(true);
771
                this.btnValue.setVisible(true);
772
                break;
773
            case DataTypes.DATE:
774
                if (this.dateController == null) {
775
                    this.dateController = ToolsSwingLocator.getToolsSwingManager().createDatePickerController(
776
                            (JTextComponent) this.cboValue.getEditor().getEditorComponent(),
777
                            null
778
                    );
779
                }
780
                this.ddnRelationalOperators.setModel(modelRelationalOperators);
781
                if( this.txtValue.isVisible() ) {
782
                    this.ddnRelationalOperators.setSelectedIndex(0);
783
                }
784
                this.cboValue.setVisible(true);
785
                this.txtValue.setVisible(false);
786
                this.btnValue.setVisible(false);
787
                this.updateValueListTask = new UpdateValueList(field);
788
                updateTask = new Thread(updateValueListTask);
789
                updateTask.start();
790
                break;
791
            default:
792
                this.ddnRelationalOperators.setModel(modelRelationalOperators);
793
                if( this.txtValue.isVisible() ) {
794
                    this.ddnRelationalOperators.setSelectedIndex(0);
795
                }
796
                this.cboValue.setVisible(true);
797
                this.txtValue.setVisible(false);
798
                this.btnValue.setVisible(false);
799
                if (this.dateController != null) {
800
                    this.dateController.uninstall();
801
                    this.dateController = null;
802
                }
803
                this.updateValueListTask = new UpdateValueList(field);
804
                updateTask = new Thread(updateValueListTask);
805
                updateTask.start();
806
        }
685 807
    }
686 808

  
687 809
    public void setEnabled(boolean enabled) {
......
798 920
                }
799 921
                // si no lo encuentra en el modelo lo a?ade
800 922
                final Field field = (Field) ddnFields.getSelectedItem();
801
                if (field == null) {
802
                    return;
803
                } else {
923
                if (field != null) {
804 924
                    LabeledValue[] availableValues = field.getDescriptor().getAvailableValues();
805 925
                    Map<String, String> availableValuesMap = new HashMap<>();
806 926
                    if (availableValues != null) {
......
1028 1148
    public ExpressionBuilder.Value getFilter() {
1029 1149
        ExpressionBuilder.Value filter = null;
1030 1150

  
1031
        Object value = this.getValue();
1032
        if (value == null
1033
                && this.getRelationalOperator() != ExpressionBuilder.OPERATOR_IS_NULL
1034
                && this.getRelationalOperator() != ExpressionBuilder.OPERATOR_IS_NOT_NULL) {
1035
            return null;
1036
        }
1037 1151
        Field field = this.getCurrentField();
1038 1152
        if (field == null) {
1039 1153
            return null;
......
1046 1160
        DALExpressionBuilder builder = dataManager.createDALExpressionBuilder();
1047 1161
        FeatureAttributeDescriptor parentDescriptor = field.getParentDescriptor();
1048 1162
        FeatureAttributeDescriptor descriptor = field.getDescriptor();
1049

  
1163
        
1164
        switch(descriptor.getType()) {
1165
            case DataTypes.GEOMETRY:
1166
                filter = this.createGeometryFilter(builder, parentDescriptor, descriptor, field);
1167
                if( filter == null ) {
1168
                    return null;
1169
                }
1170
                filter = builder.expression().group(filter);
1171
                return filter;
1172
            case DataTypes.DATE:
1173
            default:
1174
        }        
1175
        Object value = this.getValue();
1176
        if (value == null
1177
                && this.getRelationalOperator() != ExpressionBuilder.OPERATOR_IS_NULL
1178
                && this.getRelationalOperator() != ExpressionBuilder.OPERATOR_IS_NOT_NULL) {
1179
            return null;
1180
        }
1050 1181
        ExpressionBuilder.Constant value_constant = null;
1051 1182

  
1052 1183
        String operator = this.getRelationalOperator();
......
1063 1194
            case ExpressionBuilder.OPERATOR_GE:
1064 1195
            case ExpressionBuilder.OPERATOR_LT:
1065 1196
            case ExpressionBuilder.OPERATOR_LE:
1066
        try {
1067
                value_constant = builder.expression().constant(
1068
                        descriptor.getDataType().coerce(value)
1069
                );
1070
            } catch (CoercionException ex) {
1071
                return null;
1072
            }
1073
            break;
1197
                try {
1198
                    value_constant = builder.expression().constant(
1199
                            descriptor.getDataType().coerce(value)
1200
                    );
1201
                } catch (CoercionException ex) {
1202
                    return null;
1203
                }
1204
                break;
1074 1205

  
1075 1206
            case ExpressionBuilder.OPERATOR_ILIKE:                
1076 1207
                value_constant = builder.expression().constant(value);
......
1079 1210
            case OPERATOR_CONTAINS:
1080 1211
                value_constant = builder.expression().constant("%" + value + "%");
1081 1212
                operator = ExpressionBuilder.OPERATOR_ILIKE;
1082
                break;
1213
                break;                
1083 1214
        }
1084 1215

  
1085 1216
        ExpressionBuilder.Value fieldOp = null;
......
1205 1336
                String storeName = featureType.getStore().getName();
1206 1337
                pathArray.add(storeName);
1207 1338
            }
1208
            arrayBuilder.add(pathArray.build());
1339
            arrayBuilder.add(pathArray);
1209 1340
        }
1210 1341
        String relational = this.getRelationalOperator();
1211 1342
        Object value = this.getValue();
1212 1343
        String strValue = DataTypeUtils.toString(value);
1213 1344
        String logical = this.getLogicalOperator();
1214 1345

  
1215
        fieldBuilder.add("fieldPath", arrayBuilder.build());
1346
        fieldBuilder.add("fieldPath", arrayBuilder);
1216 1347
        fieldBuilder.add("relational", relational);
1217 1348
        if (!StringUtils.isEmpty(strValue)) {
1218 1349
            fieldBuilder.add("strValue", strValue);
......
1222 1353
        }
1223 1354
        int nullBehavior = this.getNullBehavior();
1224 1355
        fieldBuilder.add("nullBehavior", nullBehavior);
1356
        
1357
        fieldBuilder.add("geometryOperandMode", this.geometryOperandMode);
1358
        fieldBuilder.add("geometryOperandStoreName", this.geometryOperandStoreName);
1359
        fieldBuilder.add("geometryOperandConstant", this.geometryOperandConstant);
1225 1360
        return fieldBuilder.build();
1226 1361
    }
1227 1362
    
......
1277 1412
            this.setNullBehavior(nullBehavior);
1278 1413
        }
1279 1414

  
1415
        this.geometryOperandMode = jsonState.getInt("geometryOperandMode", GEOM_OPERAND_MODE_CLIPBOARD);
1416
        this.geometryOperandStoreName = jsonState.getString("geometryOperandStoreName", null);
1417
        this.geometryOperandConstant = (Geometry) Json.toObject(jsonState,"geometryOperandConstant");
1280 1418
    }
1281 1419

  
1282 1420
    public void setUpdateValuesLimits(int limit, int featuresLimit) {
......
1386 1524
        filter = builder.expression().group(filter);
1387 1525
        return filter;
1388 1526
    }
1527

  
1528
    private ExpressionBuilder.Value createGeometryFilter(DALExpressionBuilder builder, FeatureAttributeDescriptor parentDescriptor, FeatureAttributeDescriptor descriptor, Field field) {
1529
        ExpressionBuilder.Value filter = null;
1530

  
1531
        if( parentDescriptor!=null ) {
1532
            return null; //FIXME
1533
        }
1534
        Geometry geometry = this.getGeometryOperand(descriptor.getSRS());
1535
        if( geometry==null ) {
1536
            return null; // FIXME
1537
        }
1538
        String operator = this.getRelationalOperator();
1539
        switch (operator) {
1540
            case ExpressionBuilder.OPERATOR_IS_NULL:
1541
                filter = getFilterForOperatorNull(parentDescriptor, descriptor, builder, field);
1542
                return filter;
1543
            case ExpressionBuilder.OPERATOR_IS_NOT_NULL:
1544
                filter = getFilterForOperatorNotNull(parentDescriptor, descriptor, builder, field);
1545
                return filter;
1546
            case GeometryExpressionBuilder.FUNCTION_ST_CONTAINS:
1547
            case GeometryExpressionBuilder.FUNCTION_ST_COVERS:
1548
            case GeometryExpressionBuilder.FUNCTION_ST_COVEREDBY:
1549
            case GeometryExpressionBuilder.FUNCTION_ST_CROSSES:
1550
            case GeometryExpressionBuilder.FUNCTION_ST_DISJOINT:
1551
            case GeometryExpressionBuilder.FUNCTION_ST_EQUALS:
1552
            case GeometryExpressionBuilder.FUNCTION_ST_INTERSECTS:
1553
            case GeometryExpressionBuilder.FUNCTION_ST_OVERLAPS:
1554
                filter = builder.expression().function(
1555
                        operator,
1556
                        builder.expression().column(descriptor.getName()),
1557
                        builder.expression().geometry(geometry)
1558
                );
1559
                return filter;
1560
            case GeometryExpressionBuilder.FUNCTION_ST_ISCLOSED:
1561
                filter = builder.expression().function(
1562
                        operator,
1563
                        builder.expression().column(descriptor.getName())
1564
                );
1565
                return filter;                
1566
        }
1567
        return null;
1568
    }
1569

  
1570
    private Geometry getGeometryOperand(IProjection proj) {
1571
        List<Geometry> geoms;
1572
        switch(this.geometryOperandMode) {
1573
            case GEOM_OPERAND_MODE_LAYER_SELECTION:
1574
                geoms = this.getGeometryOperandFromLayerSelection(this.geometryOperandStoreName);
1575
                break;
1576
            case GEOM_OPERAND_MODE_CONSTANT:
1577
                geoms = this.getGeometryOperandConstant(proj);
1578
                break;
1579
            case GEOM_OPERAND_MODE_CLIPBOARD:
1580
            default:
1581
                geoms = this.getGeometryOperandFromClipboard(proj);
1582
        }
1583
        if( geoms==null || geoms.isEmpty() ) {
1584
            return null;
1585
        }
1586
        if( geoms.size()==1 ) {
1587
            return geoms.get(0);
1588
        }
1589
        return GeometryUtils.toAggregate(geoms);
1590
    }
1591
    
1592
    private List<Geometry> getGeometryOperandConstant(IProjection proj) {
1593
        if( this.geometryOperandConstant==null ) {
1594
            return null;
1595
        }
1596
        if( this.geometryOperandConstant.getProjection()==null ) {
1597
            this.geometryOperandConstant.setProjection(proj);
1598
        }
1599
        return Collections.singletonList(this.geometryOperandConstant);
1600
    }
1601
    
1602
    private List<Geometry> getGeometryOperandFromClipboard(IProjection proj) {
1603
        try {
1604
            ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager();
1605

  
1606
            String s = toolsSwingManager.getFromClipboard();
1607
            if( StringUtils.isBlank(s) ) {
1608
                return null;
1609
            }
1610
            List<Geometry> geom = GeometryUtils.extractFrom(s, proj);
1611
            return geom;
1612
        } catch (Exception ex) {
1613
            LOGGER.warn("Can't get geometry value.", ex);
1614
            return null;
1615
        }
1616
    }
1617
    
1618
    private List<Geometry> getGeometryOperandFromLayerSelection(String storeName) {
1619
        if( StringUtils.isBlank(storeName) ) {
1620
            return null;
1621
        }        
1622
        StoresRepository repo = null;
1623
        FeatureStore theStore = null;
1624
        try {
1625
            repo = DALLocator.getDataManager().getStoresRepository();
1626
            theStore = (FeatureStore) repo.getStore(storeName);
1627
            if( theStore == null ) {
1628
                return null;
1629
            }
1630
            String geomAttrName = theStore.getDefaultFeatureTypeQuietly().getDefaultGeometryAttributeName();
1631
            if( StringUtils.isEmpty(geomAttrName) ) {
1632
                return null;
1633
            }
1634
            if( theStore.isFeatureSelectionEmpty() ) {
1635
                return null;
1636
            }
1637
            Iterator<FeatureReference> it = theStore.getFeatureSelectionQuietly().referenceIterator();
1638
            List<Geometry> geoms = new ArrayList<>();
1639
            for (Feature feature : theStore.getFeaturesIterable(it)) {
1640
                geoms.add(feature.getGeometry(geomAttrName));
1641
            }
1642
            return geoms;
1643
        } finally {
1644
            DisposeUtils.dispose(theStore);
1645
        }
1646
    }
1647
    
1648
    private void doSelectGeometryOperand() {
1649
        I18nManager i18n = ToolsLocator.getI18nManager();
1650
        WindowManager_v2 windowManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
1651
        SelectGeometryPanel panel = new SelectGeometryPanel();
1652
        Dialog dialog = windowManager.createDialog(
1653
                panel, 
1654
                i18n.getTranslation("_Indicate_where_to_obtain_the_geometries"), 
1655
                null, 
1656
                WindowManager_v2.BUTTONS_OK_CANCEL
1657
        );
1658
        dialog.addActionListener((ActionEvent e) -> {
1659
            if( dialog.getAction()==WindowManager_v2.BUTTON_OK ) {
1660
                this.geometryOperandMode = panel.getMode();
1661
                this.geometryOperandConstant = panel.getGeometry();
1662
                this.geometryOperandStoreName = panel.getStoreName();
1663
                doUpdateCurrentValue();
1664
            }
1665
        });
1666
        dialog.show(WindowManager.MODE.DIALOG);
1667
    }
1389 1668
}
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/SelectGeometryPanelView.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<object classname="com.jeta.forms.store.memento.FormPackage">
4
 <at name="fileversion">
5
  <object classname="com.jeta.forms.store.memento.FormsVersion2">
6
   <at name="major">2</at>
7
   <at name="minor">0</at>
8
   <at name="sub">0</at>
9
  </object>
10
 </at>
11
 <at name="form">
12
  <object classname="com.jeta.forms.store.memento.FormMemento">
13
   <super classname="com.jeta.forms.store.memento.ComponentMemento">
14
    <at name="cellconstraints">
15
     <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
16
      <at name="column">1</at>
17
      <at name="row">1</at>
18
      <at name="colspan">1</at>
19
      <at name="rowspan">1</at>
20
      <at name="halign">default</at>
21
      <at name="valign">default</at>
22
      <at name="insets" object="insets">0,0,0,0</at>
23
     </object>
24
    </at>
25
    <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
26
   </super>
27
   <at name="id">/home/jjdelcerro/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/java/org/gvsig/fmap/dal/swing/impl/searchpanel/SelectGeometryPanelView.xml</at>
28
   <at name="path">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/java/org/gvsig/fmap/dal/swing/impl/searchpanel/SelectGeometryPanelView.xml</at>
29
   <at name="rowspecs">CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(0.9),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(0.1),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE</at>
30
   <at name="colspecs">FILL:4DLU:NONE,FILL:8DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE</at>
31
   <at name="components">
32
    <object classname="java.util.LinkedList">
33
     <item >
34
      <at name="value">
35
       <object classname="com.jeta.forms.store.memento.BeanMemento">
36
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
37
         <at name="cellconstraints">
38
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
39
           <at name="column">2</at>
40
           <at name="row">2</at>
41
           <at name="colspan">2</at>
42
           <at name="rowspan">1</at>
43
           <at name="halign">default</at>
44
           <at name="valign">default</at>
45
           <at name="insets" object="insets">0,0,0,0</at>
46
          </object>
47
         </at>
48
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
49
        </super>
50
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
51
        <at name="beanclass">javax.swing.JRadioButton</at>
52
        <at name="beanproperties">
53
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
54
          <at name="classname">javax.swing.JRadioButton</at>
55
          <at name="properties">
56
           <object classname="com.jeta.forms.store.support.PropertyMap">
57
            <at name="border">
58
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
59
              <super classname="com.jeta.forms.store.properties.BorderProperty">
60
               <at name="name">border</at>
61
              </super>
62
              <at name="borders">
63
               <object classname="java.util.LinkedList">
64
                <item >
65
                 <at name="value">
66
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
67
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
68
                    <at name="name">border</at>
69
                   </super>
70
                  </object>
71
                 </at>
72
                </item>
73
               </object>
74
              </at>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff