Revision 44744

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/featuretype/DefaultFeatureAttributePanel.java
820 820
                    if (!emulator.isValid()) {
821 821
                        ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager();
822 822
                        dialogs.messageDialog(
823
                                i18n.getTranslation("_The_expression_of_virtual_field_is_not_valid")
823
                                i18n.getTranslation("_The_expression_of_virtual_field_is_not_valid")+"\n"
824 824
                                + "\n"
825 825
                                + emulator.getErrorMessage(),
826 826
                                i18n.getTranslation("_Warning"),
......
841 841
                            return null;
842 842
                        }
843 843
                    }
844
                    List<String> undefinedSymbols = emulator.getUndefinedSymbols();
845
                    if( undefinedSymbols!=null && !undefinedSymbols.isEmpty() ) {
846
                        ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager();
847
                        dialogs.messageDialog(
848
                                i18n.getTranslation("_The_expression_has_undefined_symbols_at_this_moment")+"\n"
849
                                + i18n.getTranslation("_This_may_not_be_a_mistake")+"\n"
850
                                + "\n"
851
                                + "("+StringUtils.join(undefinedSymbols,",")+")",
852
                                i18n.getTranslation("_Warning"),
853
                                JOptionPane.WARNING_MESSAGE
854
                        );
855
                    }
844 856
                    descriptor.setFeatureAttributeEmulator(emulator);
845 857
                    //
846 858
                    // No se porque esto de abajo no funciona.
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/DefaultFeatureAttributeSelectionPanel.java
3 3
import org.gvsig.fmap.dal.swing.featuretype.FeatureAttributeSelectionPanel;
4 4
import java.awt.Dimension;
5 5
import java.net.URL;
6
import java.util.function.Predicate;
6 7
import javax.swing.ImageIcon;
7 8
import javax.swing.JComponent;
8 9
import javax.swing.tree.TreePath;
......
11 12
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
12 13
import org.gvsig.fmap.dal.feature.FeatureStore;
13 14
import org.gvsig.fmap.dal.swing.impl.featuretype.FeatureAttributeTreeModel.Node;
15
import org.gvsig.timesupport.DataTypes;
14 16
import org.gvsig.tools.swing.api.FilteredTreeController;
15 17
import org.gvsig.tools.swing.api.ToolsSwingLocator;
16 18
import org.gvsig.tools.swing.icontheme.IconTheme;
......
35 37
    FeatureAttributeTreeModel treeModel = new FeatureAttributeTreeModel(
36 38
            this.store,
37 39
            true,
38
            Search.BASIC_TYPES_FILTER
40
            Search.BASIC_TYPES_FILTER.or((FeatureAttributeDescriptor t) -> t.getType()==DataTypes.LIST)
39 41
    );
40 42
    this.treeFields.setCellRenderer(new FeatureAttributeTreeCellRenderer());
41 43
    this.treeFields.setModel(treeModel);
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/FeatureAttributeTreeModel.java
126 126
      if (showRelations && this.childs == null) {
127 127
        FeatureAttributeDescriptor descriptor = this.getValue();
128 128
        try {
129
          this.childs = Collections.EMPTY_LIST;
129 130
          switch (descriptor.getRelationType()) {
130 131
            case DynField.RELATION_TYPE_IDENTITY:
131 132
            case DynField.RELATION_TYPE_COLLABORATION:
......
158 159
                    stores.add(fullName);
159 160
                  }
160 161
                }
161
              } else {
162
                this.childs = Collections.EMPTY_LIST;
163 162
              }
164 163
              break;
165 164

  
......
170 169
                FeatureAttributeEmulatorExpression emulatorExp = (FeatureAttributeEmulatorExpression) emulator;
171 170
                Code code = emulatorExp.getExpression().getCode();
172 171
                if( code.code()==Code.CALLER ) {
173
                  Function function = ((Code.Caller)code).function();
174
                  if( function != null && StringUtils.equalsIgnoreCase(function.name(), "SELECT") ) {
172
//                  Function function = ((Code.Caller)code).function();
173
                  if( StringUtils.equalsIgnoreCase(((Code.Caller)code).name(), "SELECT") ) {
175 174
                    Codes parameters = ((Code.Caller)code).parameters();
176 175
                    String tableName = (String) ((Code.Constant)(parameters.get("TABLE"))).value();
177 176
                    DataManager dataManager = DALLocator.getDataManager();
......
203 202
                  }
204 203
                }
205 204
              }
206
              this.childs = Collections.EMPTY_LIST;
207 205
              break;
208 206

  
209 207
            case DynField.RELATION_TYPE_NONE: 
210 208
            default:
211
              this.childs = Collections.EMPTY_LIST;
212 209
              break;
213 210
          }
214 211
        } catch(Exception ex) {
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/expressionevaluator/FeatureAttributeEmulatorExpression.java
1 1
package org.gvsig.fmap.dal.expressionevaluator;
2 2

  
3
import java.util.List;
3 4
import org.gvsig.expressionevaluator.Expression;
4 5
import org.gvsig.expressionevaluator.SymbolTable;
5 6
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator;
......
17 18

  
18 19
    public String getErrorMessage();
19 20

  
21
    public List<String> getUndefinedSymbols();
22
    
20 23
    public boolean isValid();
21 24
    
22 25
    public void setEnableExceptions(boolean enableException);
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/DefaultEditableFeatureAttributeDescriptor.java
170 170
                this.getFeatureType(),
171 171
                expression
172 172
        );
173
        if( !emulator.isValid() ) {
174
            this.setFeatureAttributeEmulator(emulator);
175
            throw new IllegalArgumentException("Can't create calculated field '"+this.getName()+"', "+emulator.getErrorMessage());
176
        }
177 173
        return this.setFeatureAttributeEmulator(emulator);
178 174
    }
179 175

  
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/impl/expressionevaluator/DefaultFeatureAttributeEmulatorExpression.java
47 47
    private String errorMessage;
48 48
    
49 49
    private boolean enableExceptions;
50
    private List<String> undefinedSymbols;
50 51
    
51 52
    private FilteredLogger logger;
52 53
    
......
69 70
    private void checkVars(final FeatureType featureType) {
70 71
        this.valid = true;
71 72
        final List<String> theUsedFields = new ArrayList<>();
72
        final List<String> undefinedFields = new ArrayList<>();
73
        this.undefinedSymbols = new ArrayList<>();
73 74
        
74 75
        try {
75 76
            Code code = this.expression.getCode();
......
80 81
                    if (code instanceof Identifier) {
81 82
                        String name = ((Identifier) code).name();
82 83
                        if (featureType.get(name) == null) {
83
                            undefinedFields.add(name);
84
                            valid = false;
84
                            undefinedSymbols.add(name);
85 85
                        } else {
86 86
                            theUsedFields.add(name);
87 87
                        }
88 88
                    }
89 89
                }
90 90
            });
91
            if(!undefinedFields.isEmpty()){
92
                this.errorMessage = "undefined fields " + StringUtils.join(undefinedFields,", ");
93
            }
94 91
        } catch (Exception ex) {
95 92
            valid = false;
96 93
            this.errorMessage = ex.getMessage();
......
99 96
    }
100 97

  
101 98
    @Override
99
    public List<String> getUndefinedSymbols() {
100
      return undefinedSymbols;
101
    }
102

  
103
    @Override
102 104
    public boolean isEnableExceptions() {
103 105
        return enableExceptions;
104 106
    }
......
134 136

  
135 137
    @Override
136 138
    public Object get(Feature feature) {
137
        if (!this.valid) {
138
            return null;
139
        }
140 139
        this.getFeatureSymbolTable().setFeature(feature);
141 140
        try {
142 141
            Object result = this.expression.execute(this.getSymbolTable());
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties
1355 1355
_Relation_type=Relation type
1356 1356
_Data_type_selection=Data type selection
1357 1357
_Select_the_data_type=Select the data type
1358
_The_expression_has_undefined_symbols_at_this_moment=The expression has undefined symbols at this moment.
1359
_This_may_not_be_a_mistake=This may not be a mistake.
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/i18n/text.properties
1436 1436
_Relation_type=Tipo de relaci\u00f3n
1437 1437
_Data_type_selection=Selecci\u00f3n de tipo de datos
1438 1438
_Select_the_data_type=Seleccione el tipo de dato
1439
_The_expression_has_undefined_symbols_at_this_moment=La expresion tiene simbolos no definidos en este momento.
1440
_This_may_not_be_a_mistake=Esto puede no ser un error.

Also available in: Unified diff