Index: DefaultSearchPanel.java
===================================================================
--- DefaultSearchPanel.java	(revision 44262)
+++ DefaultSearchPanel.java	(revision 44263)
@@ -1,12 +1,19 @@
 package org.gvsig.fmap.dal.swing.impl.searchpanel;
 
+import java.awt.Cursor;
 import java.awt.Dimension;
+import java.awt.FlowLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
+import javax.swing.Action;
 import javax.swing.ImageIcon;
+import javax.swing.JButton;
 import javax.swing.JComponent;
 import javax.swing.SwingUtilities;
 import javax.swing.event.ListSelectionEvent;
@@ -14,7 +21,6 @@
 import javax.swing.table.AbstractTableModel;
 import javax.swing.table.TableModel;
 import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.lang.mutable.MutableLong;
 import org.apache.commons.lang.mutable.MutableObject;
 import org.gvsig.expressionevaluator.Expression;
 import org.gvsig.expressionevaluator.ExpressionBuilder;
@@ -24,21 +30,21 @@
 import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator;
 import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager;
 import org.gvsig.expressionevaluator.swing.ExpressionPickerController;
-import org.gvsig.featureform.swing.JFeaturesForm;
 import org.gvsig.fmap.dal.complements.Search;
 import org.gvsig.fmap.dal.exception.DataException;
 import org.gvsig.fmap.dal.feature.Feature;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
-import org.gvsig.fmap.dal.feature.FeatureQuery;
 import org.gvsig.fmap.dal.feature.FeatureStore;
 import org.gvsig.fmap.dal.feature.FeatureType;
 import org.gvsig.fmap.dal.swing.DALSwingLocator;
-import org.gvsig.fmap.dal.swing.DataSwingManager;
+import org.gvsig.fmap.dal.swing.impl.searchpanel.actions.SelectionAddAction;
+import org.gvsig.fmap.dal.swing.impl.searchpanel.actions.SelectionFilterAction;
+import org.gvsig.fmap.dal.swing.impl.searchpanel.actions.SelectionSetAction;
+import org.gvsig.fmap.dal.swing.impl.searchpanel.actions.ShowFormAction;
 import org.gvsig.fmap.dal.swing.searchpanel.FeatureStoreSearchPanel;
 import org.gvsig.tools.ToolsLocator;
 import org.gvsig.tools.swing.api.ActionListenerSupport;
 import org.gvsig.tools.swing.api.ToolsSwingLocator;
-import org.gvsig.tools.swing.api.windowmanager.WindowManager;
 import org.gvsig.tools.swing.icontheme.IconTheme;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -53,7 +59,6 @@
         implements FeatureStoreSearchPanel {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(DefaultSearchPanel.class);
-    private boolean showFormSingleElement;
     private Expression currentSearch;
 
     private class FeaturesTableModel extends AbstractTableModel {
@@ -155,11 +160,13 @@
     private final ActionListenerSupport acctionListeners;
     private final List<SearchFieldController> searchFields;
     private ExpressionPickerController advancedExpression;
+    private List<Action> actions;
 
     public DefaultSearchPanel(FeatureStore store) {
         this.store = store;
         this.acctionListeners = ToolsSwingLocator.getToolsSwingManager().createActionListenerSupport();
         this.searchFields = new ArrayList<>();
+        this.actions = new ArrayList<>();
         this.initComponents();
     }
 
@@ -168,6 +175,25 @@
         return this;
     }
 
+    private void addActions() {
+        this.pnlActions.removeAll();
+        this.pnlActions.setLayout(new FlowLayout(FlowLayout.TRAILING, 2, 2));
+        Collection<ActionFactory> factories = DALSwingLocator.getSwingManager().getFeatureStoreSearchActions();
+        for (ActionFactory factory : factories) {
+            Action action = factory.createAction(this);
+            this.actions.add(action);
+            JButton button = new JButton(action);
+//            button.setBorder(BorderFactory.createEmptyBorder());
+            button.setBorderPainted(false);
+            button.setFocusPainted(false);
+            button.setContentAreaFilled(false);
+            button.setCursor(new Cursor(Cursor.HAND_CURSOR));
+            this.pnlActions.add(button);
+        }
+        this.pnlActions.revalidate();
+        this.pnlActions.repaint();
+    }
+
     @Override
     public void addActionListener(ActionListener listener) {
         this.acctionListeners.addActionListener(listener);
@@ -262,33 +288,14 @@
             }
         });
 
-        this.btnShowForm.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                doShowForm();
-            }
-        });
-        try {
-            this.showFormSingleElement = true;
-            FeatureAttributeDescriptor[] pks = this.store.getDefaultFeatureType().getPrimaryKey();
-            if (pks == null || pks.length < 1) {
-                this.showFormSingleElement = false;
-            }
-        } catch (Exception ex) {
-        }
-        this.btnShowForm.setEnabled(true);
-
         this.tblResults.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
             @Override
             public void valueChanged(ListSelectionEvent e) {
-                if (e.getValueIsAdjusting()) {
-                    return;
+                for (Action action : actions) {
+                    if( action instanceof ListSelectionListener) {
+                        ((ListSelectionListener) action).valueChanged(e);
+                    }
                 }
-                if (tblResults.getSelectedRowCount() == 0) {
-                    btnShowForm.setEnabled(true);
-                    return;
-                }
-                btnShowForm.setEnabled(showFormSingleElement);
             }
         });
         this.btnClear.addActionListener(new ActionListener() {
@@ -297,6 +304,7 @@
                 clear();
             }
         });
+        addActions();
         this.setPreferredSize(new Dimension(700, 450));
 
         doSearch(null);
@@ -309,8 +317,10 @@
         }
         this.btnClear.setEnabled(enabled);
         this.btnSearch.setEnabled(enabled);
-        this.btnShowForm.setEnabled(enabled);
         this.advancedExpression.setEnabled(enabled);
+        for (Action action : actions) {
+            action.setEnabled(enabled);
+        }
     }
 
     public void clear() {
@@ -398,45 +408,43 @@
         th.start();
     }
 
-    private void doShowForm() {
+    @Override
+    public Expression getCurrentSearch() {
+        return this.currentSearch;
+    }
+
+    @Override
+    public Expression getSearchForSelectedFeature() {
+        int selectedRow = this.tblResults.getSelectedRow();
+        if (selectedRow < 0) {
+            return null;
+        }
         try {
-            this.btnShowForm.setEnabled(false);
-            DataSwingManager dataSwingManager = DALSwingLocator.getSwingManager();
-
-            Expression filter;
-            int selectedRow = this.tblResults.getSelectedRow();
-            if (selectedRow < 0) {
-                filter = this.currentSearch;
-            } else {
-                List<Feature> features = ((FeaturesTableModel) this.tblResults.getModel()).getFeatures();
-                Feature feature = features.get(selectedRow);
-
-                ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder();
-                FeatureType ftype = this.store.getDefaultFeatureType();
-                for (FeatureAttributeDescriptor attrdesc : ftype.getPrimaryKey()) {
-                    builder.and(
-                            builder.eq(
-                                    builder.column(attrdesc.getName()),
-                                    builder.constant(feature.get(attrdesc.getName()))
-                            )
-                    );
-                }
-                filter = ExpressionUtils.createExpression(builder.toString());
+            List<Feature> features = ((FeaturesTableModel) this.tblResults.getModel()).getFeatures();
+            Feature feature = features.get(selectedRow);
+            
+            ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder();
+            FeatureType ftype = this.store.getDefaultFeatureType();
+            for (FeatureAttributeDescriptor attrdesc : ftype.getPrimaryKey()) {
+                builder.and(
+                        builder.eq(
+                                builder.column(attrdesc.getName()),
+                                builder.constant(feature.get(attrdesc.getName()))
+                        )
+                );
             }
-            FeatureQuery query = store.createFeatureQuery();
-            query.setFilter(filter);
-            query.retrievesAllAttributes();
-            JFeaturesForm form = dataSwingManager.createJFeaturesForm(store);
-            form.setQuery(query);
-            form.showForm(WindowManager.MODE.WINDOW);
-
+            Expression filter = ExpressionUtils.createExpression(builder.toString());
+            return filter;
         } catch (Exception ex) {
-            LOGGER.warn("Can't show form", ex);
-        } finally {
-            this.btnShowForm.setEnabled(true);
+            LOGGER.warn("Can't build search for the selected feature.", ex);
+            return null;
         }
     }
 
+    public FeatureStore getStore() {
+        return store;
+    }
+    
     @Override
     public ImageIcon loadImage(String imageName) {
         String name = FilenameUtils.getBaseName(imageName);
@@ -455,7 +463,11 @@
         String[][] iconNames = new String[][]{
             new String[]{"dalswing", "featurestore-column"},
             new String[]{"dalswing", "featurestore-foreing-key"},
-            new String[]{"dalswing", "featurestore-table"}
+            new String[]{"dalswing", "featurestore-table"},
+            new String[]{"dalswing", "search-action-showform"},
+            new String[]{"dalswing", "search-action-select"},
+            new String[]{"dalswing", "search-action-select-add"},
+            new String[]{"dalswing", "search-action-select-filter"}
         };
         IconTheme theme = ToolsSwingLocator.getIconThemeManager().getCurrent();
         for (String[] icon : iconNames) {
@@ -464,4 +476,10 @@
         }
 
     }
-};
+
+    @Override
+    public int getSelectedFeatureCount() {
+        return this.tblResults.getSelectedRowCount();
+    }
+    
+}
