Index: FeatureAttributeElement.java
===================================================================
--- FeatureAttributeElement.java	(revision 44258)
+++ FeatureAttributeElement.java	(revision 44259)
@@ -1,16 +1,16 @@
 package org.gvsig.fmap.dal.swing.impl.expressionevaluator;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 import org.apache.commons.lang3.StringUtils;
 import org.gvsig.expressionevaluator.Function;
-import org.gvsig.expressionevaluator.SymbolTable;
 import org.gvsig.expressionevaluator.swing.Element;
 import org.gvsig.expressionevaluator.swing.Element.GroupElement;
 import org.gvsig.expressionevaluator.swing.Element.SimpleElement;
-import org.gvsig.expressionevaluator.swing.Element.VariableElement;
-import org.gvsig.expressionevaluator.swing.ExpressionBuilderConfig;
 import org.gvsig.expressionevaluator.swing.spi.AbstractElement;
 import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator;
 import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager;
@@ -18,9 +18,11 @@
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureSet;
 import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.swing.impl.searchpanel.SearchUtils;
 import org.gvsig.tools.ToolsLocator;
 import org.gvsig.tools.exception.BaseException;
 import org.gvsig.tools.i18n.I18nManager;
+import org.gvsig.tools.util.LabeledValue;
 import org.gvsig.tools.visitor.VisitCanceledException;
 import org.gvsig.tools.visitor.Visitor;
 
@@ -28,23 +30,20 @@
  *
  * @author jjdelcerro
  */
-public class FeatureAttributeElement        
+public class FeatureAttributeElement
         extends AbstractElement
-        implements 
-            GroupElement,
-            SimpleElement,
-            VariableElement
-{
+        implements
+        GroupElement,
+        SimpleElement
+    {
 
     final FeatureStore store;
     final FeatureAttributeDescriptor attrdesc;
     List<Element> elements;
-    final ExpressionBuilderConfig config;
-    boolean hasMoreElements; 
-    
-    FeatureAttributeElement(ExpressionBuilderConfig configPanel, FeatureStore store, FeatureAttributeDescriptor attrdesc) {
-        super(attrdesc.getName(), "expressionbuilder-element-table-field");
-        this.config = configPanel;
+    boolean hasMoreElements;
+
+    FeatureAttributeElement(FeatureStore store, FeatureAttributeDescriptor attrdesc) {
+        super(attrdesc.getName(), attrdesc.getName(), "expressionbuilder-element-table-field");
         this.store = store;
         this.attrdesc = attrdesc;
         this.elements = null;
@@ -52,19 +51,14 @@
     }
 
     @Override
-    public String getTypeName() {
-        return this.attrdesc.getDataTypeName();
-    }
-
-    @Override
     public Element get(int index) {
         return this.getElements().get(index);
     }
-    
+
     @Override
     public boolean isEnabled() {
-        if( this.config.isSQLCompatible() ) {
-            if( this.attrdesc.isComputed() ) {
+        if (this.getConfig().getPreferences().isSQLCompatible()) {
+            if (this.attrdesc.isComputed()) {
                 return false;
             }
         }
@@ -93,41 +87,59 @@
 
     @Override
     public void reload() {
-        this.elements=null; 
+        this.elements = null;
         hasMoreElements = false;
     }
 
     @Override
     public List<Element> getElements() {
-        if( this.elements==null ) {
+        if (this.elements == null) {
             hasMoreElements = false;
             ExpressionEvaluatorSwingManager manager = ExpressionEvaluatorSwingLocator.getManager();
             final List<Object> values = new ArrayList<>();
-            final int limit = this.config==null? 60 : this.config.getSimpleElementsLimit();
-            final long timeLimit = System.currentTimeMillis() + limit*1000;
+            final int limit = this.getConfig() == null ? 60 : this.getConfig().getPreferences().getSimpleElementsLimit();
+            final long timeLimit = System.currentTimeMillis() + limit * 1000;
             try {
                 FeatureSet set = this.store.getFeatureSet();
                 set.accept(new Visitor() {
                     @Override
                     public void visit(Object o) throws VisitCanceledException, BaseException {
-                        Object value = ((Feature)o).get(attrdesc.getName());
-                        if( !values.contains(value ) ) {
+                        Object value = ((Feature) o).get(attrdesc.getName());
+                        if (!values.contains(value)) {
                             values.add(value);
                         }
-                        if( System.currentTimeMillis() > timeLimit ) {
+                        if (System.currentTimeMillis() > timeLimit) {
                             hasMoreElements = true;
                             throw new VisitCanceledException();
                         }
                     }
                 });
-            } catch(VisitCanceledException ex) {
-                
+            } catch (VisitCanceledException ex) {
+
             } catch (Exception ex) {
                 // FIXME
             }
             this.elements = new ArrayList<>();
-            for (Object value : values) {
-                this.elements.add(manager.createConstantElement(this.config, value));
+            if (!values.isEmpty()) {
+                LabeledValue[] availableValues = this.attrdesc.getAvailableValues();
+                Map<String, String> availableValuesMap = new HashMap<>();
+                if( availableValues!=null ) {
+                    for (LabeledValue availableValue : availableValues) {
+                        availableValuesMap.put(
+                                Objects.toString(availableValue.getValue()),
+                                availableValue.getLabel()
+                        );
+                    }
+                }
+                for (Object value : values) {
+                    String key = Objects.toString(value);
+                    String label = availableValuesMap.getOrDefault(key, null);
+                    this.elements.add(manager.createConstantElement(
+                            value,
+                            label
+                        )
+                    );
+                }
             }
         }
         return this.elements;
@@ -139,18 +151,28 @@
     }
 
     @Override
-    public String getSource() {
-        return this.store.getName();
+    public boolean hasMoreElements() {
+        return this.hasMoreElements;
     }
 
     @Override
+    public String getName() {
+        return attrdesc.getName();
+    }
+    
+    @Override
     public String getLabel() {
-        return "Field";
+        if (getConfig().getPreferences().getShowLabelsOfElements()) {
+            if (!StringUtils.equals(attrdesc.getName(), attrdesc.getLabel())) {
+                return "<html>" + attrdesc.getLabel() + "<br><font size=\"2\"><i>(" + attrdesc.getName() + ")</i></font></html>";
+            }
+        }
+        return "<html>" + attrdesc.getName() + "</html>";
     }
 
     @Override
-    public boolean hasMoreElements() {
-        return this.hasMoreElements;
+    public String getRenderedValue() {
+        return " "+attrdesc.getName()+" ";
     }
 
     @Override
@@ -161,17 +183,21 @@
         html.append("<html>\n");
 
         html.append("<b>").append(this.getLabel()).append("</b><br>\n<br>\n");
-        html.append("<b>").append(i18n.getTranslation("_Source")).append("</b> ").append(this.getSource()).append("<br>\n");
+        html.append("<b>").append(i18n.getTranslation("_Source")).append("</b> ").append(this.store.getName()).append("<br>\n");
         html.append("<b>").append(i18n.getTranslation("_Name")).append("</b> ").append(this.getName()).append("<br>\n");
-        html.append("<b>").append(i18n.getTranslation("_Type")).append("</b> ").append(this.getTypeName()).append("<br>\n");
-        if( !StringUtils.isBlank(this.attrdesc.getDescription()) &&
-                StringUtils.equalsAnyIgnoreCase(this.getName(), this.attrdesc.getDescription()) ) {
+        html.append("<b>").append(i18n.getTranslation("_Type")).append("</b> ").append(this.attrdesc.getDataTypeName()).append("<br>\n");
+        if (!StringUtils.isBlank(this.attrdesc.getDescription())
+                && StringUtils.equalsAnyIgnoreCase(this.getName(), this.attrdesc.getDescription())) {
             html.append("<b>").append(i18n.getTranslation("_Description")).append("</b><br>\n");
             html.append(this.attrdesc.getDescription().replace("\n", "<br>")).append("<br>\n");
         }
         html.append("</html>\n");
         return html.toString();
     }
-    
-    
+
+    @Override
+    @SuppressWarnings("empty-statement")
+    public void used() {
+        SearchUtils.getRecentUseds().add(attrdesc);
+    }
 }
