Revision 44719 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/featurequery/DefaultFeatureQueryGroupByPanel.java

View differences:

DefaultFeatureQueryGroupByPanel.java
5 5
import java.awt.Dimension;
6 6
import java.net.URL;
7 7
import javax.swing.DefaultComboBoxModel;
8
import javax.swing.DefaultListModel;
9 8
import javax.swing.ImageIcon;
10 9
import javax.swing.JComponent;
11 10
import javax.swing.JLabel;
......
32 31
import org.gvsig.tools.swing.api.ToolsSwingManager;
33 32
import org.gvsig.tools.swing.icontheme.IconTheme;
34 33
import org.gvsig.fmap.dal.swing.featurequery.FeatureQueryGroupByPanel;
34
import org.gvsig.tools.swing.api.FilteredListModel;
35 35

  
36 36
/**
37 37
 *
......
94 94
      this.featureType = store.getDefaultFeatureType();
95 95
      this.store = store;
96 96
      this.query = store.createFeatureQuery();
97
      this.groupByPanel.setFeatureType(featureType);
98
      this.groupByPanel.setSelectedNames(query.getGroupByColumns());
97 99
      this.updateControls();
98 100
    } catch (DataException ex) {
99 101
      throw new RuntimeException("Can't assign store", ex);
......
157 159
  }
158 160

  
159 161
  private void updateControls() {
162
    int indexAttributes = this.lstAttributes.getSelectedIndex();
160 163
    if( this.cboAggretateFunctions.getModel().getSize() < 1 ) {
161 164
      DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>();
162 165
      model.addElement("<NULL>");
......
177 180
      this.cboAggretateFunctions.setSelectedIndex(0);
178 181
      this.txtCurrentAttributeName.setText("");
179 182
    }
180
    this.groupByPanel.setFeatureType(featureType);
181
    this.groupByPanel.setSelectedNames(query.getGroupByColumns());
182
    DefaultListModel<FeatureAttributeDescriptor> model = new DefaultListModel<>();
183
    ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager();
184
    FilteredListModel model = toolsSwingManager.createFilteredListModel();
183 185
    for (FeatureAttributeDescriptor attr : featureType) {
184 186
      model.addElement(attr);
185 187
    }
188
    model.setFilter(this.txtAttributesFilter.getText());
189
    model.sort(true);
186 190
    this.lstAttributes.setModel(model);
191
    this.lstAttributes.setSelectedIndex(indexAttributes);
187 192
    this.txtCurrentAttributeName.setText("");
188 193
    this.cboAggretateFunctions.setSelectedIndex(0);
189 194
  }
......
194 199
      return this.query.getCopy();
195 200
    }
196 201
    query.getGroupByColumns().clear();
197
    query.getGroupByColumns().addAll(this.query.getGroupByColumns());
202
    query.getGroupByColumns().addAll(this.groupByPanel.getSelectedNames());
198 203
    query.getAggregateFunctions().clear();
199 204
    query.getAggregateFunctions().putAll(this.query.getAggregateFunctions());
200 205
    return query;

Also available in: Unified diff