Revision 45155

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/DefaultFeatureProvider.java
22 22
 */
23 23
package org.gvsig.fmap.dal.feature.spi;
24 24

  
25
import org.apache.commons.lang3.ArrayUtils;
25 26
import org.apache.commons.lang3.StringUtils;
26 27
import org.gvsig.fmap.dal.DataTypes;
27 28
import org.gvsig.fmap.dal.feature.EditableFeatureType;
......
195 196
        data.defaultGeometry = this.defaultGeometry;
196 197
        data.envelope = this.envelope;
197 198
        data.isNew = this.isNew;
199
        if (this.extraValues!=null) {
200
            data.extraValues = new Object[this.extraValues.length];
201
            System.arraycopy(this.extraValues, 0, data.extraValues, 0, this.extraValues.length);
202
        } else {
203
            data.extraValues = null;
204
        }
205
        if (this.extraValuesNames!=null) {
206
            data.extraValuesNames = new String[this.extraValuesNames.length];
207
            System.arraycopy(this.extraValuesNames, 0, data.extraValuesNames, 0, this.extraValuesNames.length);
208
        } else {
209
            data.extraValuesNames = null;
210
        }
198 211
        return data;
199 212
    }
200 213

  
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/SQLBuilderBase.java
392 392

  
393 393
        @Override
394 394
        public void accept(Visitor visitor, VisitorFilter filter) {
395
            if (filter.accept(this)) {
395
            if (filter==null || filter.accept(this)) {
396 396
                visitor.visit(this);
397 397
            }
398 398
        }
......
632 632

  
633 633
        @Override
634 634
        public void accept(Visitor visitor, VisitorFilter filter) {
635
            if (filter.accept(this)) {
635
            if (filter==null || filter.accept(this)) {
636 636
                visitor.visit(this);
637 637
            }
638 638
            if (this.tableName != null) {
......
694 694

  
695 695
        @Override
696 696
        public void accept(Visitor visitor, VisitorFilter filter) {
697
            if (filter.accept(this)) {
697
            if (filter==null || filter.accept(this)) {
698 698
                visitor.visit(this);
699 699
            }
700 700
            if (this.name != null) {
......
837 837

  
838 838
        @Override
839 839
        public void accept(Visitor visitor, VisitorFilter filter) {
840
            if (filter.accept(this)) {
840
            if (filter==null || filter.accept(this)) {
841 841
                visitor.visit(this);
842 842
            }
843 843
        }
......
903 903
        protected List<SelectColumnBuilder> columns;
904 904
        protected List<OrderByBuilder> order_by;
905 905
        protected boolean distinct;
906
        protected List<Variable> groupColumn;
906
        protected List<Value> groupColumn;
907 907
        protected boolean check_order_and_offset = true;
908 908

  
909 909
        public SelectBuilderBase() {
......
912 912
        }
913 913

  
914 914
        @Override
915
        public SelectBuilder group_by(Variable... columns) {
915
        public SelectBuilder group_by(Value... columns) {
916 916
            if( this.groupColumn==null ) {
917 917
                this.groupColumn = new ArrayList<>();
918 918
            }
919
            for (Variable column : columns) {
919
            for (Value column : columns) {
920 920
                this.groupColumn.add(column);
921 921
            }
922 922
            return this;
......
924 924

  
925 925
        @Override
926 926
        public void accept(Visitor visitor, VisitorFilter filter) {
927
            if (filter.accept(this)) {
927
            if (filter==null || filter.accept(this)) {
928 928
                visitor.visit(this);
929 929
            }
930 930
            for (SelectColumnBuilder column : columns) {
......
941 941
                    order.accept(visitor, filter);
942 942
                }
943 943
            }
944
            if (this.has_group_by()) {
945
                for (Value group : groupColumn) {
946
                    group.accept(visitor, filter);
947
                }
948
            }
944 949
        }
945 950

  
946 951
        @Override
......
981 986
                    }
982 987
                }
983 988
            }
989
            if (this.has_group_by()) {
990
                for (int i = 0; i < groupColumn.size(); i++) {
991
                    Value group = groupColumn.get(i);
992
                    if( group == target ) {
993
                        groupColumn.set(i, replacement);
994
                    } else {
995
                        group.replace(target, replacement);
996
                    }
997
                }
998
            }
984 999
        }
985 1000

  
986 1001
        @Override
......
1207 1222

  
1208 1223
        @Override
1209 1224
        public void accept(Visitor visitor, VisitorFilter filter) {
1210
            if (filter.accept(this)) {
1225
            if (filter==null || filter.accept(this)) {
1211 1226
                visitor.visit(this);
1212 1227
            }
1213 1228
            this.table.accept(visitor, filter);
......
1417 1432

  
1418 1433
        @Override
1419 1434
        public void accept(Visitor visitor, VisitorFilter filter) {
1420
            if (filter.accept(this)) {
1435
            if (filter==null || filter.accept(this)) {
1421 1436
                visitor.visit(this);
1422 1437
            }
1423 1438
            if (this.table != null) {
......
1510 1525

  
1511 1526
        @Override
1512 1527
        public void accept(Visitor visitor, VisitorFilter filter) {
1513
            if (filter.accept(this)) {
1528
            if (filter==null || filter.accept(this)) {
1514 1529
                visitor.visit(this);
1515 1530
            }
1516 1531
            if (this.table != null) {
......
1613 1628

  
1614 1629
        @Override
1615 1630
        public void accept(Visitor visitor, VisitorFilter filter) {
1616
            if (filter.accept(this)) {
1631
            if (filter==null || filter.accept(this)) {
1617 1632
                visitor.visit(this);
1618 1633
            }
1619 1634
            if (this.table != null) {
......
1731 1746

  
1732 1747
        @Override
1733 1748
        public void accept(Visitor visitor, VisitorFilter filter) {
1734
            if (filter.accept(this)) {
1749
            if (filter==null || filter.accept(this)) {
1735 1750
                visitor.visit(this);
1736 1751
            }
1737 1752
            if (this.table != null) {
......
1833 1848

  
1834 1849
        @Override
1835 1850
        public void accept(Visitor visitor, VisitorFilter filter) {
1836
            if (filter.accept(this)) {
1851
            if (filter==null || filter.accept(this)) {
1837 1852
                visitor.visit(this);
1838 1853
            }
1839 1854
            if (this.table != null) {
......
2074 2089

  
2075 2090
        @Override
2076 2091
        public void accept(Visitor visitor, VisitorFilter filter) {
2077
            if (filter.accept(this)) {
2092
            if (filter==null || filter.accept(this)) {
2078 2093
                visitor.visit(this);
2079 2094
            }
2080 2095
            if (this.table != null) {
......
2263 2278

  
2264 2279
        @Override
2265 2280
        public void accept(Visitor visitor, VisitorFilter filter) {
2266
            if (filter.accept(this)) {
2281
            if (filter==null || filter.accept(this)) {
2267 2282
                visitor.visit(this);
2268 2283
            }
2269 2284
            if (this.name != null) {
......
2323 2338

  
2324 2339
        @Override
2325 2340
        public void accept(Visitor visitor, VisitorFilter filter) {
2326
            if (filter.accept(this)) {
2341
            if (filter==null || filter.accept(this)) {
2327 2342
                visitor.visit(this);
2328 2343
            }
2329 2344
            if (this.table != null) {
......
2405 2420

  
2406 2421
        @Override
2407 2422
        public void accept(Visitor visitor, VisitorFilter filter) {
2408
            if (filter.accept(this)) {
2423
            if (filter==null || filter.accept(this)) {
2409 2424
                visitor.visit(this);
2410 2425
            }
2411 2426
            if (this.table != null) {
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.dbf/src/test/java/org/gvsig/fmap/dal/store/dbf/TestExtraColumn.java
107 107
        assertTrue(descriptor2.getFeatureType()==null);
108 108
        
109 109
        // El valor de la columna extra debe ser el que toca.
110
        Number value = (Number) f.getExtraValue("test1");
111
        assertEquals(Long.valueOf(300), value);        
110
        Number value = (Number) f.get("test1");
111
        assertEquals(Long.valueOf(300), value);   
112 112
    }
113 113
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeature.java
662 662
    public Object get(String name) {
663 663
        int index = this.data.getType().getIndex(name);
664 664
        if( index < 0 ) {
665
            // buscamos en los extra cols
666
            if(hasExtraColumnValue(name)) {
667
                return getExtraColumnValue(name);
668
            }
669
            if (hasExtraValue(name)) {
670
                return getExtraValue(name);
671
            }
672
            // y si esta ahi return
665 673
            throw new IllegalArgumentException("Attribute name '"+name+"' not found in the feature.");
666 674
        }
667 675
        return this.get(index);
......
1247 1255
      }
1248 1256
      this.extraValues.put(name, value);
1249 1257
    }
1250

  
1251
    @Override
1252
    public Object getExtraValue(String name) {
1258
    
1259
    public Object getExtraColumnValue(String name) {
1253 1260
        Object value;
1254 1261
        if( this.extraValues!=null ) {
1255 1262
          if( this.extraValues.containsKey(name) ) {
......
1274 1281
          }
1275 1282
          return value;
1276 1283
        }
1277
        value = this.data.getExtraValue(name);
1284
        throw new RuntimeException("Not extra column value found");
1285
    }
1286

  
1287
    @Override
1288
    public Object getExtraValue(String name) {
1289
        Object value = this.data.getExtraValue(name);
1278 1290
        return value;
1279 1291
    }
1280 1292

  
1281 1293
    @Override
1282 1294
    public boolean hasExtraValue(String name) {
1295
        return this.data.hasExtraValue(name);
1296
    }
1297
    
1298

  
1299
    private boolean hasExtraColumnValue(String name) {
1283 1300
        if( this.extraValues!=null ) {
1284 1301
          if( this.extraValues.containsKey(name) ) {
1285 1302
            return true;
......
1290 1307
        if( index >= 0 ) {
1291 1308
          return true;
1292 1309
        }
1293
        return this.data.hasExtraValue(name);
1310
        return false;
1294 1311
    }
1295 1312
    
1296 1313
    @Override
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureExtraColumns.java
172 172
                .setMandatory(false);
173 173

  
174 174
    }
175

  
176
    @Override
177
    public void remove(String attribute) {
178
        for (EditableFeatureAttributeDescriptor extraColumn : extraColumns) {
179
            if (extraColumn.getName().equalsIgnoreCase(attribute)) {
180
                this.extraColumns.remove(extraColumn);
181
                break;
182
            }
183
        }
184
    }
175 185
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCHelperBase.java
681 681
    try {
682 682
      // See test SQLBuilderTest->testForeingValue()
683 683
      final ExpressionBuilder where = sqlbuilder.select().where();
684
      if (where == null || where.isEmpty()) {
685
        return;
686
      }
684
//      if (where == null || where.isEmpty()) {
685
//        return;
686
//      }
687 687
      final SQLBuilder.TableNameBuilder table = sqlbuilder.select().from().table();
688 688
      final ExpressionBuilder expbuilder = sqlbuilder.expression();
689 689

  
......
698 698
      // Buscamos las llamadas a la funcion "foreing_value" y nos quedamos
699 699
      // el argumento de esta asi como por que tendriamos que sustituirla 
700 700
      // una vez hechos los left joins que toquen.
701
      where.accept(new ExpressionBuilder.Visitor() {
701
      sqlbuilder.select().accept(new ExpressionBuilder.Visitor() {
702 702
        @Override
703 703
        public void visit(ExpressionBuilder.Visitable value) {
704 704
          // Requiere que sea la funcion "FOREING_VALUE con un solo 
......
752 752
                    function_replacement
753 753
                  }
754 754
          );
755
          foreing_value_args.add(foreing_value_arg);
755
          if (!foreing_value_args.contains(foreing_value_arg)) {
756
            foreing_value_args.add(foreing_value_arg);
757
          }
756 758
        }
757 759
      }, null);
758

  
760
      
759 761
      // Si no habia ningun llamada a la funcion FOREING_VALUE, no hay que
760 762
      // hacer nada.
761 763
      if (foreing_value_args.isEmpty()) {
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/ResultSetForSetProviderOperation.java
28 28
import java.util.List;
29 29
import org.apache.commons.lang3.ArrayUtils;
30 30
import org.apache.commons.lang3.StringUtils;
31
import org.gvsig.expressionevaluator.Code;
31 32
import org.gvsig.expressionevaluator.ExpressionBuilder;
33
import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_LET;
32 34
import org.gvsig.expressionevaluator.ExpressionUtils;
33 35
import org.gvsig.fmap.dal.SQLBuilder.SelectBuilder;
34 36
import org.gvsig.fmap.dal.exception.DataException;
......
158 160
            }
159 161
            columns.add(attr);
160 162
        }
161
        if( query !=null && query.hasGroupByColumns() ) {
163
       
164
       if( query !=null && query.hasGroupByColumns() ) {
162 165
            for(String attrName : query.getGroupByColumns() ) {
163
                select.group_by(expbuilder.column(attrName));
164
            }
166
                if( setType.get(attrName)==null ) {
167
                    try {
168
                    Code code = ExpressionUtils.compile(attrName);
169
                    if( code.code()==Code.CALLABLE ) {
170
                        Code.Callable callable = (Code.Callable) code;
171
                        if( callable.name().equalsIgnoreCase(FUNCTION_LET) ) { 
172
                            code = callable.parameters().get(1);
173
                            Code name = callable.parameters().get(0);
174
                            select.column().value(callable.parameters().get(1).toValue())
175
                                    .as((String) ((Code.Constant)name).value());
176
                            extraColumnNames.add((String) ((Code.Constant)name).value());
177
                        }
178
                    }
179
                    select.group_by(code.toValue());
180
                    } catch (Exception ex) {
181
                        throw new RuntimeException("Not able to create column by expression in groupby query", ex);
182
                    }
183
                } else {
184
                    select.group_by(expbuilder.column(attrName));
185
                }
186
            }            
165 187
        } else {
166 188
            for(String attrName : forcedColumns ) {
167 189
                select.column().name(attrName);
168 190
                columns.add(setType.getAttributeDescriptor(attrName));
169 191
            }
170 192
        }
171
        
193
                                  
172 194
        select.from().table()
173 195
                .database(this.table.getDatabase())
174 196
                .schema(this.table.getSchema())
......
262 284
        );
263 285
        return resultSetEntry;
264 286
    }
265

  
287
 
266 288
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CountOperation.java
29 29
import java.sql.Statement;
30 30
import java.util.List;
31 31
import org.apache.commons.lang3.StringUtils;
32
import org.gvsig.expressionevaluator.Code;
32 33
import org.gvsig.expressionevaluator.ExpressionBuilder;
34
import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_LET;
35
import org.gvsig.expressionevaluator.ExpressionUtils;
33 36
import org.gvsig.fmap.dal.SQLBuilder.SelectBuilder;
34 37
import org.gvsig.fmap.dal.exception.DataException;
35 38
import org.gvsig.fmap.dal.feature.FeatureQuery;
......
80 83
        ExpressionBuilder expbuilder = sqlbuilder.expression();
81 84

  
82 85
        SelectBuilder select = sqlbuilder.select();
83
        
84
        if( this.query!=null && this.query.hasGroupByColumns() ) {
85
          JDBCSQLBuilderBase subsqlbuilder = this.createSQLBuilder();
86
          SelectBuilder subselect = subsqlbuilder.select();
87
          subselect.column().value(subsqlbuilder.count().all());
88
          subselect.from().table()
89
                  .database(this.table.getDatabase())
90
                  .schema(this.table.getSchema())
91
                  .name(this.table.getTable());
92
          subselect.from().subquery(this.table.getSubquery());
93
          Evaluator filter = query==null? null:query.getFilter();
94
          if( filter != null ) {
95
              String sqlfilter = filter.getSQL();
96
              if( ! StringUtils.isEmpty(sqlfilter) ) {
97
                  if( this.helper.supportFilter(this.featureType, filter) ) {
98
                      subselect.where().set(expbuilder.toValue(sqlfilter));
99
                  }
100
              }
101
          }
102
          if( ! StringUtils.isEmpty(baseFilter) ) {
103
              subselect.where().and(expbuilder.toValue(baseFilter));
104
          }
105 86

  
106
          FeatureQueryOrder order = query==null? null:query.getOrder();
107
          if( order != null ) {
108
              for( FeatureQueryOrder.FeatureQueryOrderMember member : order.members() ) {
109
                  if( member.hasEvaluator() ) {
110
                      String sqlorder = member.getEvaluator().getSQL();
111
                      if( ! StringUtils.isEmpty(sqlorder) ) {
112
                          subselect.order_by().custom(sqlorder);
113
                      }
114
                  } else {
115
                      subselect.order_by()
116
                              .column(member.getAttributeName())
117
                              .ascending(member.getAscending());
118
                  }
119
              }
120
          }
121
          
122
          List<String> groupbyColumns = query==null? null:query.getGroupByColumns();
123
          if( groupbyColumns!=null && !groupbyColumns.isEmpty() ) {
124
            for(String columnName : groupbyColumns ) {
125
                subselect.group_by(expbuilder.column(columnName));
87
        if (this.query != null && this.query.hasGroupByColumns()) {
88
            JDBCSQLBuilderBase subsqlbuilder = this.createSQLBuilder();
89
            SelectBuilder subselect = subsqlbuilder.select();
90
            subselect.column().value(subsqlbuilder.count().all());
91
            subselect.from().table()
92
                    .database(this.table.getDatabase())
93
                    .schema(this.table.getSchema())
94
                    .name(this.table.getTable());
95
            subselect.from().subquery(this.table.getSubquery());
96
            Evaluator filter = query == null ? null : query.getFilter();
97
            if (filter != null) {
98
                String sqlfilter = filter.getSQL();
99
                if (!StringUtils.isEmpty(sqlfilter)) {
100
                    if (this.helper.supportFilter(this.featureType, filter)) {
101
                        subselect.where().set(expbuilder.toValue(sqlfilter));
102
                    }
103
                }
126 104
            }
127
          }
128
          subsqlbuilder.setProperties(
129
                  ExpressionBuilder.Variable.class, 
130
                  PROP_TABLE, table
131
          );
132
          String subsql = subselect.toString();
133
          select.from().table()
134
                  .database(this.table.getDatabase())
135
                  .schema(this.table.getSchema())
136
                  .name(this.table.getTable());
137
          select.from().subquery(subsql);
138
          
139
          
105
            if (!StringUtils.isEmpty(baseFilter)) {
106
                subselect.where().and(expbuilder.toValue(baseFilter));
107
            }
108

  
109
            FeatureQueryOrder order = query == null ? null : query.getOrder();
110
            if (order != null) {
111
                for (FeatureQueryOrder.FeatureQueryOrderMember member : order.members()) {
112
                    if (member.hasEvaluator()) {
113
                        String sqlorder = member.getEvaluator().getSQL();
114
                        if (!StringUtils.isEmpty(sqlorder)) {
115
                            subselect.order_by().custom(sqlorder);
116
                        }
117
                    } else {
118
                        subselect.order_by()
119
                                .column(member.getAttributeName())
120
                                .ascending(member.getAscending());
121
                    }
122
                }
123
            }
124

  
125
            List<String> groupbyColumns = query == null ? null : query.getGroupByColumns();
126
            if (groupbyColumns != null && !groupbyColumns.isEmpty()) {
127
                for (String columnName : groupbyColumns) {
128
                    if (this.featureType.getAttributeDescriptor(columnName) != null) {
129
                        subselect.group_by(expbuilder.column(columnName));
130
                    } else {
131
                        try {
132
                            try {
133
                                Code groupByColumnCode = ExpressionUtils.compile(columnName);
134
                                if (groupByColumnCode.code() == Code.CALLABLE) {
135
                                    Code.Callable callable = (Code.Callable) groupByColumnCode;
136
                                    if (callable.name().equalsIgnoreCase(FUNCTION_LET)) {
137
                                        Code exp = callable.parameters().get(1);
138
                                        Code name = callable.parameters().get(0);
139
                                        subselect.column().value(exp.toValue())
140
                                                .as((String) ((Code.Constant) name).value());
141
                                        // nombre que se pone en la parte del groupby debe de ser el nombre de la var del set
142
                                        groupByColumnCode = exp; 
143
                                    }
144
                                }
145
                                subselect.group_by(groupByColumnCode.toValue());
146
                            } catch (Exception ex) {
147
                                throw new RuntimeException("Not able to create column by expression in groupby query", ex);
148
                            }
149
                        } catch (Exception ex) {
150
                            throw new RuntimeException("Not able to create column by expression in groupby query", ex);
151
                        }
152
                    }
153
                }
154
            }
155
            this.helper.processSpecialFunctions(subsqlbuilder, featureType, null);
156
            subsqlbuilder.setProperties(
157
                    ExpressionBuilder.Variable.class,
158
                    PROP_TABLE, table
159
            );
160
            String subsql = subselect.toString();
161
            select.from().table()
162
                    .database(this.table.getDatabase())
163
                    .schema(this.table.getSchema())
164
                    .name(this.table.getTable());
165
            select.from().subquery(subsql);
166

  
140 167
        } else {
141
          select.column().value(sqlbuilder.count().all());
142
          select.from().table()
143
                  .database(this.table.getDatabase())
144
                  .schema(this.table.getSchema())
145
                  .name(this.table.getTable());
146
          select.from().subquery(this.table.getSubquery());
147
          if (!StringUtils.isEmpty(baseFilter)) {
148
              sqlbuilder.select().where().set( expbuilder.custom(baseFilter) );
149
          }
150
          if( this.query!=null ) {
151
            if( this.query.getFilter()!=null && !StringUtils.isBlank(this.query.getFilter().getSQL()) ) {
152
              // El and() hace un set() si no hay un filtro previo
153
              select.where().and(expbuilder.toValue(this.query.getFilter().getSQL()));
168
            select.column().value(sqlbuilder.count().all());
169
            select.from().table()
170
                    .database(this.table.getDatabase())
171
                    .schema(this.table.getSchema())
172
                    .name(this.table.getTable());
173
            select.from().subquery(this.table.getSubquery());
174
            if (!StringUtils.isEmpty(baseFilter)) {
175
                sqlbuilder.select().where().set(expbuilder.custom(baseFilter));
154 176
            }
155
          }
177
            if (this.query != null) {
178
                if (this.query.getFilter() != null && !StringUtils.isBlank(this.query.getFilter().getSQL())) {
179
                    // El and() hace un set() si no hay un filtro previo
180
                    select.where().and(expbuilder.toValue(this.query.getFilter().getSQL()));
181
                }
182
            }
156 183
        }
157 184
        this.helper.processSpecialFunctions(sqlbuilder, featureType, null);
158
        
185

  
159 186
        select.remove_all_columns();
160 187
        select.column().value(sqlbuilder.count().all());
161
        
188

  
162 189
        sqlbuilder.setProperties(
163
                ExpressionBuilder.Variable.class, 
190
                ExpressionBuilder.Variable.class,
164 191
                PROP_TABLE, table
165 192
        );
166 193

  
167 194
        String sql = select.toString();
168 195
        return sql;
169 196
    }
170
    
197

  
171 198
    public long count(Connection conn) throws DataException {
172 199

  
173 200
        String sql = this.getSQL();
......
188 215
            JDBCUtils.closeQuietly(rs);
189 216
        }
190 217
    }
191

  
218
   
192 219
}
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
17 17
import javax.swing.event.ListSelectionEvent;
18 18
import org.apache.commons.io.FilenameUtils;
19 19
import org.apache.commons.lang3.StringUtils;
20
import org.gvsig.expressionevaluator.Code;
21
import org.gvsig.expressionevaluator.ExpressionBuilder;
22
import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_LET;
20 23
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
21 24
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager;
25
import org.gvsig.expressionevaluator.ExpressionUtils;
26
import org.gvsig.expressionevaluator.Formatter;
22 27
import org.gvsig.expressionevaluator.Function;
23 28
import org.gvsig.expressionevaluator.SymbolTable;
24 29
import org.gvsig.expressionevaluator.SymbolTableFactory;
30
import org.gvsig.fmap.dal.DALLocator;
25 31
import org.gvsig.fmap.dal.exception.DataException;
32
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
26 33
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
27 34
import org.gvsig.fmap.dal.feature.FeatureQuery;
28 35
import org.gvsig.fmap.dal.feature.FeatureStore;
......
36 43
import org.gvsig.tools.swing.api.ToolsSwingManager;
37 44
import org.gvsig.tools.swing.icontheme.IconTheme;
38 45
import org.gvsig.fmap.dal.swing.featurequery.FeatureQueryGroupByPanel;
46
import org.gvsig.tools.dataTypes.DataTypes;
39 47
import org.gvsig.tools.swing.api.FilteredListModel;
40 48

  
41 49
/**
......
114 122
    toolsSwingManager.translate(this.tabGroup);
115 123
    
116 124
    this.groupByPanel = new DefaultFeatureAttributesSelectionPanel();
125
    this.groupByPanel.allowCalculatedAttributes(true);
117 126

  
118 127
    this.pnlGroupByAttributes.setLayout(new BorderLayout());
119 128
    this.pnlGroupByAttributes.add(this.groupByPanel, BorderLayout.CENTER);
......
226 235
    query.getGroupByColumns().addAll(this.groupByPanel.getSelectedNames());
227 236
    query.getAggregateFunctions().clear();
228 237
    query.getAggregateFunctions().putAll(this.query.getAggregateFunctions());
238
    
239
    List<String> selectedNames = this.groupByPanel.getSelectedNames();
240
      for (String selectedName : selectedNames) {
241
          if (this.featureType.getAttributeDescriptor(selectedName) == null) {
242
              try {
243
                  Code selectedNameCode = ExpressionUtils.compile(selectedName);
244
                  if (selectedNameCode.code() == Code.CALLABLE) {
245
                      Code.Callable callable = (Code.Callable) selectedNameCode;
246
                      if (callable.name().equalsIgnoreCase(FUNCTION_LET)) {
247
                          String exp = callable.parameters().get(1).toString();
248
                          String attrNameInExpression = (String) ((ExpressionBuilder.Constant) callable.parameters().get(0).toValue()).value();
249
                          if (query.getExtraColumn().get(attrNameInExpression)!=null) {
250
                              query.getExtraColumn().remove(attrNameInExpression);
251
                          }
252
                          EditableFeatureAttributeDescriptor newExtraColumn = query.getExtraColumn().add(attrNameInExpression);
253
                          newExtraColumn.setDataType(DataTypes.STRING);
254
                          newExtraColumn.setSize(newExtraColumn.getDataType().getDefaultSize());
255
                          newExtraColumn.setFeatureAttributeEmulator(
256
                                  "current_row().getExtraValue('"+attrNameInExpression+"')");
257
                      }
258
                  }
259
              } catch (Exception ex) {
260
                  throw new RuntimeException("Not able to create column by expression in groupby query", ex);
261
              }
262
          }
263
      }
264
      
265
            
229 266
    return query;
230 267
  }
231 268

  
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/featuretable/SimpleFeaturesTableModel.java
107 107
                if (extraCol!=null) {
108 108
                    return extraCol.getLocalizedShortLabel();
109 109
                }
110
                return "C" + columnIndex;
110
                if (attrName==null) {
111
                    return "Column"+columnIndex;
112
                }
113
                return attrName;
111 114
            }
112 115
            return attrdesc.getLocalizedShortLabel();
113 116
        }
......
166 169
                    int extraIndex = featureType.getExtraColumns().getIndexOf(attrName);
167 170
                    if (extraIndex != -1) {
168 171
                        attrdesc = featureType.getExtraColumns().get(extraIndex);
169
                        value = feature.getExtraValue(attrName);
170 172
                    }
173
                    value = feature.getExtraValue(attrName);
171 174
                } else {
172 175
                    value = feature.get(attrName);
173 176
                }
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/featuretype/DefaultFeatureAttributesSelectionPanel.java
10 10
import javax.swing.DefaultListCellRenderer;
11 11
import javax.swing.ImageIcon;
12 12
import javax.swing.JComponent;
13
import javax.swing.event.DocumentEvent;
14
import javax.swing.event.DocumentListener;
13 15
import javax.swing.event.ListSelectionEvent;
14 16
import org.apache.commons.io.FilenameUtils;
17
import org.gvsig.expressionevaluator.Expression;
18
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
19
import org.gvsig.expressionevaluator.swing.ExpressionPickerController;
15 20
import org.gvsig.fmap.dal.exception.DataException;
16 21
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
17 22
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
18 23
import org.gvsig.fmap.dal.feature.FeatureStore;
19 24
import org.gvsig.fmap.dal.feature.FeatureType;
25
import org.gvsig.fmap.dal.swing.DALSwingLocator;
20 26
import org.gvsig.tools.swing.api.ActionListenerSupport;
21 27
import org.gvsig.tools.swing.api.FilteredListController;
22 28
import org.gvsig.tools.swing.api.FilteredListModel;
......
39 45
    private final ActionListenerSupport actionListenerSupport;
40 46
    private FilteredListController availableFieldsController;
41 47
    private final List<String> selecteds;
48
    private ExpressionPickerController expressionPicker = null;
49
    private boolean allowCalculatedAttributes;
42 50
    
43 51
    public DefaultFeatureAttributesSelectionPanel() {
44 52
        this.actionListenerSupport = ToolsSwingLocator.getToolsSwingManager().createActionListenerSupport();
......
65 73
          }
66 74
          doSelectColumn();
67 75
        });
76
        this.txtExpression.getDocument().addDocumentListener(new DocumentListener() {
77
            public void changedUpdate(DocumentEvent e) {
78
              doSelectAvailableColumn();
79
            }
80
            @Override
81
            public void insertUpdate(DocumentEvent de) {
82
                 doSelectAvailableColumn();
83
            }
84

  
85
            @Override
86
            public void removeUpdate(DocumentEvent de) {
87
                 doSelectAvailableColumn();
88
            }
89
        });
68 90
        this.btnColumnAdd.addActionListener((ActionEvent e) -> {
69 91
          doColumnAdd();
70 92
        });
......
81 103
                lstAvailableColumns, 
82 104
                txtColumnsFilter, 
83 105
                btnColumnsFilter
84
        );
106
        );     
85 107
        Dimension sz = this.getPreferredSize();
86 108
        if( sz.width<450 ) {
87 109
            sz.width = 450;
......
109 131
    }
110 132

  
111 133
    private void doSelectAvailableColumn() {
112
        if( this.lstAvailableColumns.getSelectedIndex()>=0 ) {
134
        if( this.lstAvailableColumns.getSelectedIndex()>=0 || !this.expressionPicker.isEmpty()) {
113 135
            this.btnColumnAdd.setEnabled(true);
114 136
            return;
115 137
        }
......
159 181
        this.lstSelectedColumns.setSelectedIndex(n+1);
160 182
        this.updateControls();
161 183
    }
184
    
185
    private boolean checkIfAttributeInFeatureType(String myAttr) {
186
        for (FeatureAttributeDescriptor attr : featureType) {
187
            if(attr.getName().equalsIgnoreCase(myAttr) ) {
188
               return true;
189
            }
190
        }
191
        List<EditableFeatureAttributeDescriptor> columns = featureType.getExtraColumns().getColumns();
192
        if (columns!=null && !columns.isEmpty()) {
193
            for (EditableFeatureAttributeDescriptor extraCol : columns) {
194
                if(extraCol.getName().equalsIgnoreCase(myAttr)) {
195
                    return true;
196
                }
197
            }
198
        }
199
        return false;
200
    }
162 201

  
163 202
    private void doColumnRemove() {
164 203
        LabeledValue attr = (LabeledValue) this.lstSelectedColumns.getSelectedValue();
165 204
        if( attr == null ) {
166 205
            return;
167 206
        }
168
        int n = this.selecteds.indexOf(attr.getLabel());
207
        String label = attr.getLabel();
208
        int n = this.selecteds.indexOf(label);
169 209
        if( n<0 ) {
170 210
          return;
171 211
        }
212
        
213
        if (!checkIfAttributeInFeatureType(label)) {
214
            Expression toExp = ExpressionEvaluatorLocator.getManager().createExpression();
215
            toExp.setPhrase(label);
216
            this.expressionPicker.set(toExp);
217
        } 
218
 
172 219
        this.selecteds.remove(n);
173 220
        this.updateControls();
174 221
    }
175 222

  
176 223
    private void doColumnAdd() {
177
        LabeledValue attr = (LabeledValue) this.lstAvailableColumns.getSelectedValue();
178
        if( attr == null ) {
179
            return;
224
        
225
        if (this.expressionPicker.isEmpty()) {
226
            LabeledValue attr = (LabeledValue) this.lstAvailableColumns.getSelectedValue();
227
            if( attr == null ) {
228
                return;
229
            }
230
            int n = this.selecteds.indexOf(attr);
231
            if( n>=0 ) {
232
              return;
233
            }
234
            this.selecteds.add(attr.getLabel());
235
        } else {
236
            if (this.expressionPicker.isValid()) {
237
                Expression exp = this.expressionPicker.get();
238
                String expressionField = exp.getPhrase();
239
                int n = this.selecteds.indexOf(expressionField);
240
                if (n >= 0) {
241
                    return;
242
                }
243
                this.selecteds.add(expressionField);
244
                this.expressionPicker.set(null);
245
            }
180 246
        }
181
        int n = this.selecteds.indexOf(attr);
182
        if( n>=0 ) {
183
          return;
184
        }
185
        this.selecteds.add(attr.getLabel());
186 247
        this.updateControls();
187 248
    }
188 249

  
......
245 306
    }
246 307
    
247 308
    private void updateControls() {
309
        
310
        if (this.expressionPicker == null) {
311
                this.expressionPicker = 
312
                DALSwingLocator.getDataSwingManager().createExpressionPickerController(
313
                        this.featureType.getStore(), 
314
                        txtExpression, 
315
                        btnExpression, 
316
                        btnBookmarks, 
317
                        btnHistory);
318
        }
248 319
        int indexAvailables = this.lstAvailableColumns.getSelectedIndex();
249 320
        int indexSelecteds = this.lstSelectedColumns.getSelectedIndex();
250 321
        FilteredListModel modelAvailables = ToolsSwingLocator.getToolsSwingManager().createFilteredListModel();
251 322
        FilteredListModel modelSelecteds = ToolsSwingLocator.getToolsSwingManager().createFilteredListModel();
252 323
        for (FeatureAttributeDescriptor attr : featureType) {
253 324
            if( !this.selecteds.contains(attr.getName()) ) {
254
                modelAvailables.addElement(attr.getName());
325
                modelAvailables.addElement(attr.getName()); //label?
255 326
            }
256 327
        }
257 328
        List<EditableFeatureAttributeDescriptor> columns = featureType.getExtraColumns().getColumns();
......
277 348
            this.lstAvailableColumns.setSelectedIndex(indexAvailables);
278 349
            this.btnColumnAdd.setEnabled(true);
279 350
        } else {
280
            this.btnColumnAdd.setEnabled(false);
351
            if(!this.expressionPicker.isEmpty()) {
352
                this.btnColumnAdd.setEnabled(true);  
353
            } else {
354
                this.btnColumnAdd.setEnabled(false);
355
            }
281 356
        }
282 357
        
283 358
        if( indexSelecteds >= 0 && modelSelecteds.getSize()>0 ) {
......
319 394
            theme.registerDefault("DALSwing", icon[0], icon[1], null, url);
320 395
        }
321 396
    }
397

  
398
    public void allowCalculatedAttributes(boolean b) {
399
        this.allowCalculatedAttributes = b;
400
    }
322 401
}
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/featuretype/DefaultFeatureAttributesSelectionPanelView.xml
24 24
    </at>
25 25
    <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
26 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/featuretype/DefaultFeatureAttributesSelectionPanelView.xml</at>
28
   <at name="path">src/main/java/org/gvsig/fmap/dal/swing/impl/featuretype/DefaultFeatureAttributesSelectionPanelView.xml</at>
27
   <at name="id">/home/omartinez/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/featuretype/DefaultFeatureAttributesSelectionPanelView.xml</at>
29 28
   <at name="rowspecs">CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE</at>
30 29
   <at name="colspecs">FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.5),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.4),FILL:4DLU:NONE</at>
31 30
   <at name="components">
......
39 38
           <at name="column">2</at>
40 39
           <at name="row">4</at>
41 40
           <at name="colspan">1</at>
42
           <at name="rowspan">3</at>
41
           <at name="rowspan">1</at>
43 42
           <at name="halign">default</at>
44 43
           <at name="valign">default</at>
45 44
           <at name="insets" object="insets">0,0,0,0</at>
......
77 76
            <at name="scrollableTracksViewportHeight">true</at>
78 77
            <at name="scrollableTracksViewportWidth">true</at>
79 78
            <at name="name">lstAvailableColumns</at>
80
            <at name="width">482</at>
79
            <at name="width">584</at>
81 80
            <at name="items">
82 81
             <object classname="com.jeta.forms.store.properties.ItemsProperty">
83 82
              <at name="name">items</at>
......
110 109
              </at>
111 110
             </object>
112 111
            </at>
113
            <at name="height">482</at>
112
            <at name="height">481</at>
114 113
           </object>
115 114
          </at>
116 115
         </object>
......
165 164
            <at name="scrollableTracksViewportHeight">true</at>
166 165
            <at name="scrollableTracksViewportWidth">true</at>
167 166
            <at name="name">lstSelectedColumns</at>
168
            <at name="width">449</at>
167
            <at name="width">215</at>
169 168
            <at name="items">
170 169
             <object classname="com.jeta.forms.store.properties.ItemsProperty">
171 170
              <at name="name">items</at>
......
198 197
              </at>
199 198
             </object>
200 199
            </at>
201
            <at name="height">428</at>
200
            <at name="height">481</at>
202 201
           </object>
203 202
          </at>
204 203
         </object>
......
223 222
         </at>
224 223
         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
225 224
        </super>
226
        <at name="id">embedded.83764835</at>
225
        <at name="id">embedded.867929971</at>
227 226
        <at name="rowspecs">CENTER:DEFAULT:NONE</at>
228 227
        <at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE</at>
229 228
        <at name="components">
......
381 380
              </at>
382 381
             </object>
383 382
            </at>
384
            <at name="name"/>
383
            <at name="name"></at>
385 384
            <at name="fill">
386 385
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
387 386
              <at name="name">fill</at>
......
463 462
         </at>
464 463
         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
465 464
        </super>
466
        <at name="id">embedded.1972576236</at>
465
        <at name="id">embedded.2099906498</at>
467 466
        <at name="rowspecs">CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE</at>
468 467
        <at name="colspecs">FILL:DEFAULT:NONE</at>
469 468
        <at name="components">
......
709 708
         </at>
710 709
         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
711 710
        </super>
712
        <at name="id">embedded.836726237</at>
711
        <at name="id">embedded.579122055</at>
713 712
        <at name="rowspecs">CENTER:DEFAULT:NONE</at>
714 713
        <at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE</at>
715 714
        <at name="components">
......
759 758
                  </object>
760 759
                 </at>
761 760
                 <at name="name">txtColumnsFilter</at>
762
                 <at name="width">448</at>
761
                 <at name="width">550</at>
763 762
                 <at name="height">20</at>
764 763
                </object>
765 764
               </at>
......
853 852
              </at>
854 853
             </object>
855 854
            </at>
856
            <at name="name"/>
855
            <at name="name"></at>
857 856
            <at name="fill">
858 857
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
859 858
              <at name="name">fill</at>
......
918 917
       </object>
919 918
      </at>
920 919
     </item>
920
     <item >
921
      <at name="value">
922
       <object classname="com.jeta.forms.store.memento.FormMemento">
923
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
924
         <at name="cellconstraints">
925
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
926
           <at name="column">2</at>
927
           <at name="row">6</at>
928
           <at name="colspan">1</at>
929
           <at name="rowspan">1</at>
930
           <at name="halign">default</at>
931
           <at name="valign">default</at>
932
           <at name="insets" object="insets">0,0,0,0</at>
933
          </object>
934
         </at>
935
         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
936
        </super>
937
        <at name="id">embedded.659516054</at>
938
        <at name="rowspecs">CENTER:DEFAULT:NONE</at>
939
        <at name="colspecs">FILL:390PX:GROW(1.0),FILL:4PX:NONE,FILL:DEFAULT:NONE,FILL:2DLU:NONE,FILL:DEFAULT:NONE,FILL:1DLU:NONE,FILL:DEFAULT:NONE</at>
940
        <at name="components">
941
         <object classname="java.util.LinkedList">
942
          <item >
943
           <at name="value">
944
            <object classname="com.jeta.forms.store.memento.BeanMemento">
945
             <super classname="com.jeta.forms.store.memento.ComponentMemento">
946
              <at name="cellconstraints">
947
               <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
948
                <at name="column">7</at>
949
                <at name="row">1</at>
950
                <at name="colspan">1</at>
951
                <at name="rowspan">1</at>
952
                <at name="halign">default</at>
953
                <at name="valign">default</at>
954
                <at name="insets" object="insets">0,0,0,0</at>
955
               </object>
956
              </at>
957
              <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
958
             </super>
959
             <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
960
             <at name="beanclass">javax.swing.JButton</at>
961
             <at name="beanproperties">
962
              <object classname="com.jeta.forms.store.memento.PropertiesMemento">
963
               <at name="classname">javax.swing.JButton</at>
964
               <at name="properties">
965
                <object classname="com.jeta.forms.store.support.PropertyMap">
966
                 <at name="border">
967
                  <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
968
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
969
                    <at name="name">border</at>
970
                   </super>
971
                   <at name="borders">
972
                    <object classname="java.util.LinkedList">
973
                     <item >
974
                      <at name="value">
975
                       <object classname="com.jeta.forms.store.properties.EmptyBorderProperty">
976
                        <super classname="com.jeta.forms.store.properties.BorderProperty">
977
                         <at name="name">border</at>
978
                        </super>
979
                        <at name="top">2</at>
980
                        <at name="left">2</at>
981
                        <at name="bottom">2</at>
982
                        <at name="right">2</at>
983
                       </object>
984
                      </at>
985
                     </item>
986
                    </object>
987
                   </at>
988
                  </object>
989
                 </at>
990
                 <at name="actionCommand">...</at>
991
                 <at name="icon">
992
                  <object classname="com.jeta.forms.store.properties.IconProperty">
993
                   <at name="embedded">false</at>
994
                   <at name="path">src/main/resources/org/gvsig/fmap/dal/swing/impl/featuretype/featuretype-column-down.png</at>
995
                   <at name="description">featuretype-column-down.png</at>
996
                   <at name="width">16</at>
997
                   <at name="height">16</at>
998
                  </object>
999
                 </at>
1000
                 <at name="name">btnHistory</at>
1001
                 <at name="width">20</at>
1002
                 <at name="height">20</at>
1003
                </object>
1004
               </at>
1005
              </object>
1006
             </at>
1007
            </object>
1008
           </at>
1009
          </item>
1010
          <item >
1011
           <at name="value">
1012
            <object classname="com.jeta.forms.store.memento.BeanMemento">
1013
             <super classname="com.jeta.forms.store.memento.ComponentMemento">
1014
              <at name="cellconstraints">
1015
               <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
1016
                <at name="column">5</at>
1017
                <at name="row">1</at>
1018
                <at name="colspan">1</at>
1019
                <at name="rowspan">1</at>
1020
                <at name="halign">default</at>
1021
                <at name="valign">default</at>
1022
                <at name="insets" object="insets">0,0,0,0</at>
1023
               </object>
1024
              </at>
1025
              <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
1026
             </super>
1027
             <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
1028
             <at name="beanclass">javax.swing.JButton</at>
1029
             <at name="beanproperties">
1030
              <object classname="com.jeta.forms.store.memento.PropertiesMemento">
1031
               <at name="classname">javax.swing.JButton</at>
1032
               <at name="properties">
1033
                <object classname="com.jeta.forms.store.support.PropertyMap">
1034
                 <at name="border">
1035
                  <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
1036
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
1037
                    <at name="name">border</at>
1038
                   </super>
1039
                   <at name="borders">
1040
                    <object classname="java.util.LinkedList">
1041
                     <item >
1042
                      <at name="value">
1043
                       <object classname="com.jeta.forms.store.properties.EmptyBorderProperty">
1044
                        <super classname="com.jeta.forms.store.properties.BorderProperty">
1045
                         <at name="name">border</at>
1046
                        </super>
1047
                        <at name="top">2</at>
1048
                        <at name="left">2</at>
1049
                        <at name="bottom">2</at>
1050
                        <at name="right">2</at>
1051
                       </object>
1052
                      </at>
1053
                     </item>
1054
                    </object>
1055
                   </at>
1056
                  </object>
1057
                 </at>
1058
                 <at name="actionCommand">...</at>
1059
                 <at name="icon">
1060
                  <object classname="com.jeta.forms.store.properties.IconProperty">
1061
                   <at name="embedded">false</at>
1062
                   <at name="path">src/main/resources/org/gvsig/fmap/dal/swing/impl/featuretype/featuretype-column-up.png</at>
1063
                   <at name="description">featuretype-column-up.png</at>
1064
                   <at name="width">16</at>
1065
                   <at name="height">16</at>
1066
                  </object>
1067
                 </at>
1068
                 <at name="name">btnBookmarks</at>
1069
                 <at name="width">20</at>
1070
                 <at name="height">20</at>
1071
                </object>
1072
               </at>
1073
              </object>
1074
             </at>
1075
            </object>
1076
           </at>
1077
          </item>
1078
          <item >
1079
           <at name="value">
1080
            <object classname="com.jeta.forms.store.memento.BeanMemento">
1081
             <super classname="com.jeta.forms.store.memento.ComponentMemento">
1082
              <at name="cellconstraints">
1083
               <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
1084
                <at name="column">3</at>
1085
                <at name="row">1</at>
1086
                <at name="colspan">1</at>
1087
                <at name="rowspan">1</at>
1088
                <at name="halign">default</at>
1089
                <at name="valign">default</at>
1090
                <at name="insets" object="insets">0,0,0,0</at>
1091
               </object>
1092
              </at>
1093
              <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
1094
             </super>
1095
             <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
1096
             <at name="beanclass">javax.swing.JButton</at>
1097
             <at name="beanproperties">
1098
              <object classname="com.jeta.forms.store.memento.PropertiesMemento">
1099
               <at name="classname">javax.swing.JButton</at>
1100
               <at name="properties">
1101
                <object classname="com.jeta.forms.store.support.PropertyMap">
1102
                 <at name="border">
1103
                  <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
1104
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
1105
                    <at name="name">border</at>
1106
                   </super>
1107
                   <at name="borders">
1108
                    <object classname="java.util.LinkedList">
1109
                     <item >
1110
                      <at name="value">
1111
                       <object classname="com.jeta.forms.store.properties.EmptyBorderProperty">
1112
                        <super classname="com.jeta.forms.store.properties.BorderProperty">
1113
                         <at name="name">border</at>
1114
                        </super>
1115
                        <at name="top">2</at>
1116
                        <at name="left">2</at>
1117
                        <at name="bottom">2</at>
1118
                        <at name="right">2</at>
1119
                       </object>
1120
                      </at>
1121
                     </item>
1122
                    </object>
1123
                   </at>
1124
                  </object>
1125
                 </at>
1126
                 <at name="actionCommand">...</at>
1127
                 <at name="icon">
1128
                  <object classname="com.jeta.forms.store.properties.IconProperty">
1129
                   <at name="embedded">false</at>
1130
                   <at name="path">src/main/resources/org/gvsig/fmap/dal/swing/impl/featuretype/featuretype-column-up.png</at>
1131
                   <at name="description">featuretype-column-up.png</at>
1132
                   <at name="width">16</at>
1133
                   <at name="height">16</at>
1134
                  </object>
1135
                 </at>
1136
                 <at name="name">btnExpression</at>
1137
                 <at name="width">20</at>
1138
                 <at name="height">20</at>
1139
                </object>
1140
               </at>
1141
              </object>
1142
             </at>
1143
            </object>
1144
           </at>
1145
          </item>
1146
          <item >
1147
           <at name="value">
1148
            <object classname="com.jeta.forms.store.memento.BeanMemento">
1149
             <super classname="com.jeta.forms.store.memento.ComponentMemento">
1150
              <at name="cellconstraints">
1151
               <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
1152
                <at name="column">1</at>
1153
                <at name="row">1</at>
1154
                <at name="colspan">1</at>
1155
                <at name="rowspan">1</at>
1156
                <at name="halign">default</at>
1157
                <at name="valign">default</at>
1158
                <at name="insets" object="insets">0,0,0,0</at>
1159
               </object>
1160
              </at>
1161
              <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
1162
             </super>
1163
             <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
1164
             <at name="beanclass">javax.swing.JTextField</at>
1165
             <at name="beanproperties">
1166
              <object classname="com.jeta.forms.store.memento.PropertiesMemento">
1167
               <at name="classname">javax.swing.JTextField</at>
1168
               <at name="properties">
1169
                <object classname="com.jeta.forms.store.support.PropertyMap">
1170
                 <at name="border">
1171
                  <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
1172
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
1173
                    <at name="name">border</at>
1174
                   </super>
1175
                   <at name="borders">
1176
                    <object classname="java.util.LinkedList">
1177
                     <item >
1178
                      <at name="value">
1179
                       <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
1180
                        <super classname="com.jeta.forms.store.properties.BorderProperty">
1181
                         <at name="name">border</at>
1182
                        </super>
1183
                       </object>
1184
                      </at>
1185
                     </item>
1186
                    </object>
1187
                   </at>
1188
                  </object>
1189
                 </at>
1190
                 <at name="name">txtExpression</at>
1191
                 <at name="width">499</at>
1192
                 <at name="height">20</at>
1193
                </object>
1194
               </at>
1195
              </object>
1196
             </at>
1197
            </object>
1198
           </at>
1199
          </item>
1200
         </object>
1201
        </at>
1202
        <at name="properties">
1203
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
1204
          <at name="classname">com.jeta.forms.gui.form.GridView</at>
1205
          <at name="properties">
1206
           <object classname="com.jeta.forms.store.support.PropertyMap">
1207
            <at name="border">
1208
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
1209
              <super classname="com.jeta.forms.store.properties.BorderProperty">
1210
               <at name="name">border</at>
1211
              </super>
1212
              <at name="borders">
1213
               <object classname="java.util.LinkedList"/>
1214
              </at>
1215
             </object>
1216
            </at>
1217
            <at name="name"></at>
1218
            <at name="fill">
1219
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
1220
              <at name="name">fill</at>
1221
             </object>
1222
            </at>
1223
            <at name="scollBars">
1224
             <object classname="com.jeta.forms.store.properties.ScrollBarsProperty">
1225
              <at name="name">scollBars</at>
1226
              <at name="verticalpolicy">21</at>
1227
              <at name="horizontalpolicy">31</at>
1228
              <at name="border">
1229
               <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
1230
                <super classname="com.jeta.forms.store.properties.BorderProperty">
1231
                 <at name="name">border</at>
1232
                </super>
1233
                <at name="borders">
1234
                 <object classname="java.util.LinkedList">
1235
                  <item >
1236
                   <at name="value">
1237
                    <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
1238
                     <super classname="com.jeta.forms.store.properties.BorderProperty">
1239
                      <at name="name">border</at>
1240
                     </super>
1241
                    </object>
1242
                   </at>
1243
                  </item>
1244
                 </object>
1245
                </at>
1246
               </object>
1247
              </at>
1248
             </object>
1249
            </at>
1250
           </object>
1251
          </at>
1252
         </object>
1253
        </at>
1254
        <at name="cellpainters">
1255
         <object classname="com.jeta.forms.store.support.Matrix">
1256
          <at name="rows">
1257
           <object classname="[Ljava.lang.Object;" size="1">
1258
            <at name="item" index="0">
1259
             <object classname="[Ljava.lang.Object;" size="7"/>
1260
            </at>
1261
           </object>
1262
          </at>
1263
         </object>
1264
        </at>
1265
        <at name="rowgroups">
1266
         <object classname="com.jeta.forms.store.memento.FormGroupSet">
1267
          <at name="groups">
1268
           <object classname="java.util.HashMap"/>
1269
          </at>
1270
         </object>
1271
        </at>
1272
        <at name="colgroups">
1273
         <object classname="com.jeta.forms.store.memento.FormGroupSet">
1274
          <at name="groups">
1275
           <object classname="java.util.HashMap"/>
1276
          </at>
1277
         </object>
1278
        </at>
1279
       </object>
1280
      </at>
1281
     </item>
921 1282
    </object>
922 1283
   </at>
923 1284
   <at name="properties">
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/featuretype/DefaultFeatureAttributesSelectionPanelView.java
1 1
package org.gvsig.fmap.dal.swing.impl.featuretype;
2

  
3 2
import com.jeta.open.i18n.I18NUtils;
4 3
import com.jgoodies.forms.layout.CellConstraints;
5 4
import com.jgoodies.forms.layout.FormLayout;
......
7 6
import java.awt.ComponentOrientation;
8 7
import java.awt.Container;
9 8
import java.awt.Dimension;
9
import java.awt.event.WindowAdapter;
10
import java.awt.event.WindowEvent;
10 11
import javax.swing.Box;
11 12
import javax.swing.ImageIcon;
12 13
import javax.swing.JButton;
......
28 29
   JButton btnColumnRemove = new JButton();
29 30
   JTextField txtColumnsFilter = new JTextField();
30 31
   JButton btnColumnsFilter = new JButton();
32
   JButton btnHistory = new JButton();
33
   JButton btnBookmarks = new JButton();
34
   JButton btnExpression = new JButton();
35
   JTextField txtExpression = new JTextField();
31 36

  
32 37
   /**
33 38
    * Default constructor
......
38 43
   }
39 44

  
40 45
   /**
46
    * Main method for panel
47
    */
48
   public static void main(String[] args)
49
   {
50
      JFrame frame = new JFrame();
51
      frame.setSize(600, 400);
52
      frame.setLocation(100, 100);
53
      frame.getContentPane().add(new DefaultFeatureAttributesSelectionPanelView());
54
      frame.setVisible(true);
55

  
56
      frame.addWindowListener( new WindowAdapter()
57
      {
58
         public void windowClosing( WindowEvent evt )
59
         {
60
            System.exit(0);
61
         }
62
      });
63
   }
64

  
65
   /**
41 66
    * Adds fill components to empty cells in the first row and first column of the grid.
42 67
    * This ensures that the grid spacing will be the same as shown in the designer.
43 68
    * @param cols an array of column indices in the first row where fill components should be added.
......
128 153
      jscrollpane1.setViewportView(lstAvailableColumns);
129 154
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
130 155
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
131
      jpanel1.add(jscrollpane1,cc.xywh(2,4,1,3));
156
      jpanel1.add(jscrollpane1,cc.xy(2,4));
132 157

  
133 158
      lstSelectedColumns.setName("lstSelectedColumns");
134 159
      JScrollPane jscrollpane2 = new JScrollPane();
......
140 165
      jpanel1.add(createPanel1(),cc.xy(6,6));
141 166
      jpanel1.add(createPanel2(),cc.xy(4,4));
142 167
      jpanel1.add(createPanel3(),cc.xy(2,2));
168
      jpanel1.add(createPanel4(),cc.xy(2,6));
143 169
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7 },new int[]{ 1,2,3,4,5,6,7 });
144 170
      return jpanel1;
145 171
   }
......
215 241
      return jpanel1;
216 242
   }
217 243

  
244
   public JPanel createPanel4()
245
   {
246
      JPanel jpanel1 = new JPanel();
247
      FormLayout formlayout1 = new FormLayout("FILL:390PX:GROW(1.0),FILL:4PX:NONE,FILL:DEFAULT:NONE,FILL:2DLU:NONE,FILL:DEFAULT:NONE,FILL:1DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
248
      CellConstraints cc = new CellConstraints();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff