Index: trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/filter/FilterDialog.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/filter/FilterDialog.java	(revision 43168)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/filter/FilterDialog.java	(revision 43169)
@@ -32,21 +32,26 @@
 import java.util.Comparator;
 import java.util.Date;
 import java.util.Iterator;
+import java.util.List;
 import java.util.TreeSet;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import javax.swing.JOptionPane;
 
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.gvsig.andami.PluginServices;
-import org.gvsig.andami.messages.NotificationManager;
 import org.gvsig.andami.ui.mdiManager.IWindow;
 import org.gvsig.andami.ui.mdiManager.IWindowListener;
 import org.gvsig.andami.ui.mdiManager.WindowInfo;
+import org.gvsig.app.ApplicationLocator;
+import org.gvsig.app.ApplicationManager;
 import org.gvsig.fmap.dal.exception.DataException;
 import org.gvsig.fmap.dal.feature.Feature;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
@@ -54,8 +59,10 @@
 import org.gvsig.fmap.dal.feature.FeatureSet;
 import org.gvsig.fmap.dal.feature.FeatureStore;
 import org.gvsig.gui.beans.filterPanel.tableFilterQueryPanel.TableFilterQueryJPanel;
+import org.gvsig.tools.ToolsLocator;
 import org.gvsig.tools.dispose.DisposableIterator;
 import org.gvsig.tools.dispose.DisposeUtils;
+import org.gvsig.tools.i18n.I18nManager;
 import org.gvsig.utils.DefaultCharSet;
 import org.gvsig.utils.StringUtilities;
 import org.gvsig.utils.exceptionHandling.ExceptionHandlingSupport;
@@ -76,13 +83,13 @@
      * 
      */
     private static final long serialVersionUID = -149317534873551735L;
-    private static final Logger logger =
-        LoggerFactory.getLogger(FilterDialog.class);
+    private static final Logger logger = LoggerFactory.getLogger(FilterDialog.class);
+
     private FeatureStore model = null;
-    private ArrayList expressionListeners = new ArrayList();
-    private ExceptionHandlingSupport exceptionHandlingSupport =
-        new ExceptionHandlingSupport();
-    private NumberFormat nf = NumberFormat.getNumberInstance();
+    
+    private final List<ExpressionListener> expressionListeners = new ArrayList<>();
+    private final ExceptionHandlingSupport exceptionHandlingSupport = new ExceptionHandlingSupport();
+    private final NumberFormat nf = NumberFormat.getNumberInstance();
 
     private String title;
 
@@ -96,6 +103,7 @@
 
     /**
      * This is the default constructor
+     * @param _title
      */
     public FilterDialog(String _title) {
         super();
@@ -134,63 +142,51 @@
         // Listener for "btnAdd"
         // Adds more elements to the current set
         getBtnAddToCurrentSet().addActionListener(
-            new java.awt.event.ActionListener() {
+                new java.awt.event.ActionListener() {
 
-                /*
-                 * (non-Javadoc)
-                 * 
-                 * @see
-                 * java.awt.event.ActionListener#actionPerformed(java.awt.event
-                 * .ActionEvent)
-                 */
-                public void actionPerformed(java.awt.event.ActionEvent e) {
-                    // final String expr = "select * from '" +
-                    // model.getName() + "' where " +
-                    // getTxtExpression().getText() + ";";
-                    final String expr = getTxtExpression().getText();
-                    logger.debug(expr);
+                    @Override
+                    public void actionPerformed(java.awt.event.ActionEvent e) {
+                        final String expr = getTxtExpression().getText();
+                        if (!validateQuotes(expr) || !validateLike(expr)) {
+                            return;
+                        }
 
-                    PluginServices.backgroundExecution(new Runnable() {
+                        PluginServices.backgroundExecution(new Runnable() {
 
-                        public void run() {
-                            for (int i = 0; i < expressionListeners.size(); i++) {
-                                ExpressionListener l =
-                                    (ExpressionListener) expressionListeners
-                                        .get(i);
-                                try {
-                                    l.addToSet(expr);
-                                } catch (DataException e) {
-                                    e.printStackTrace();
+                            @Override
+                            public void run() {
+                                for (ExpressionListener l : expressionListeners) {
+                                    try {
+                                        l.addToSet(expr);
+                                    } catch (DataException e) {
+                                        logger.warn("Can't add expression '"+expr+"' to set.", e);
+                                    }
                                 }
                             }
-                        }
-                    });
-                }
-            });
+                        });
+                    }
+                });
 
         // Listener for "btnNuevo"
         // Adds a new set
         getBtnNewSet().addActionListener(new java.awt.event.ActionListener() {
 
+            @Override
             public void actionPerformed(java.awt.event.ActionEvent e) {
-                // final String expr = "select * from '" +
-                // model.getName() + "' where " +
-                // getTxtExpression().getText() + ";";
                 final String expr = getTxtExpression().getText();
+                if (!validateQuotes(expr) || !validateLike(expr)) {
+                    return;
+                }
 
-                logger.debug(expr);
-
                 PluginServices.backgroundExecution(new Runnable() {
 
+                    @Override
                     public void run() {
-                        for (int i = 0; i < expressionListeners.size(); i++) {
-                            ExpressionListener l =
-                                (ExpressionListener) expressionListeners.get(i);
+                        for (ExpressionListener l : expressionListeners) {
                             try {
                                 l.newSet(expr);
                             } catch (DataException e) {
-                                // TODO Auto-generated catch block
-                                NotificationManager.addError(e);
+                                logger.warn("Can't create set with expression '"+expr+"'.", e);
                             }
                         }
                     }
@@ -202,23 +198,22 @@
         // Selects elements from the current filtered selection
         getBtnFromSet().addActionListener(new java.awt.event.ActionListener() {
 
+            @Override
             public void actionPerformed(java.awt.event.ActionEvent e) {
-                // final String expr = "select * from '" +
-                // model.getName() + "' where " +
-                // getTxtExpression().getText() + ";";
                 final String expr = getTxtExpression().getText();
-                logger.debug(expr);
+                if (!validateQuotes(expr) || !validateLike(expr) ) {
+                    return;
+                }
 
                 PluginServices.backgroundExecution(new Runnable() {
 
+                    @Override
                     public void run() {
-                        for (int i = 0; i < expressionListeners.size(); i++) {
-                            ExpressionListener l =
-                                (ExpressionListener) expressionListeners.get(i);
+                        for (ExpressionListener l : expressionListeners) {
                             try {
                                 l.fromSet(expr);
                             } catch (DataException e) {
-                                NotificationManager.addError(e);
+                                logger.warn("Can't create expression '"+expr+"' from set.", e);
                             }
                         }
                     }
@@ -229,25 +224,17 @@
         // Listener for "fieldsJTree"
         getFieldsJTree().addMouseListener(new MouseAdapter() {
 
-            /*
-             * (non-Javadoc)
-             * 
-             * @see
-             * java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent
-             * )
-             */
             @Override
             public void mouseClicked(MouseEvent e) {
                 int row = fieldsJTree.getRowForLocation(e.getX(), e.getY());
-
                 if (row > -1) {
                     switch (e.getClickCount()) {
-                    case 1:
-                        fillValues(row);
-                        break;
-                    case 2:
-                        putSymbol(jtreeRoot.getChildAt(row).toString());
-                        break;
+                        case 1:
+                            fillValues(row);
+                            break;
+                        case 2:
+                            putSymbol(jtreeRoot.getChildAt(row).toString());
+                            break;
                     }
                 }
             }
@@ -256,36 +243,70 @@
         // Listener for "valuesJList"
         getValuesJList().addMouseListener(new MouseAdapter() {
 
-            /*
-             * (non-Javadoc)
-             * 
-             * @see
-             * java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent
-             * )
-             */
             @Override
             public void mouseClicked(MouseEvent e) {
                 if (e.getClickCount() == 2) {
-                    Object valor =
-                        valuesListModel.getElementAt(getValuesJList()
+                    Object valor = valuesListModel.getElementAt(getValuesJList()
                             .getSelectedIndex());
-
-                    if (valor instanceof Date) {
+                    if (valor == null) {
+                        putSymbol("null");
+                    } else if (valor instanceof Date) {
                         putSymbol("date('" + valor + "')");
-                    } else
-                        if (valor instanceof Boolean) {
-                          putSymbol(valor.toString());
-                        } else
-                            if (valor instanceof String) {
-                                putSymbol("'" + valor + "'");
-                            } else {
-                                putSymbol(valor.toString());
-                            }
+                    } else if (valor instanceof Boolean) {
+                        putSymbol(valor.toString());
+                    } else if (valor instanceof String) {
+                        // putSymbol("'" + StringEscapeUtils.escapeSql((String) valor) + "'");
+                        putSymbol("'" + ((String)valor).replace('\'', '?') + "'");
+                    } else {
+                        putSymbol(StringEscapeUtils.escapeSql(valor.toString()));
+                    }
                 }
             }
         });
     }
 
+    private boolean validateQuotes(String expr) {
+        if ((StringUtils.countMatches(expr, "'") % 2) != 0) {
+            ApplicationManager application = ApplicationLocator.getManager();
+            I18nManager i18n = ToolsLocator.getI18nManager();
+            String msg = i18n.getTranslation("_The_number_of_quotes_is_doubtful_It_could_be_that_some_of_them_should_escape_Do_you_want_to_continue_the_operation_anyway");
+            int resp = application.confirmDialog(
+                    msg,
+                    i18n.getTranslation("_Caution"),
+                    JOptionPane.YES_NO_OPTION,
+                    JOptionPane.QUESTION_MESSAGE,
+                    "Doubtless number of quotes in the filter dialog"
+            );
+            if (resp == JOptionPane.NO_OPTION) {
+                return false;
+            }
+        }
+        return true;
+
+    }
+
+    private boolean validateLike(String expr) {
+        if( (expr.toLowerCase().contains("?") || 
+                expr.toLowerCase().contains("%")) && 
+                !expr.toLowerCase().contains("like") ) 
+            {
+            ApplicationManager application = ApplicationLocator.getManager();
+            I18nManager i18n = ToolsLocator.getI18nManager();
+            String msg = i18n.getTranslation("_It_looks_like_youre_using_percent_o_question_and_the_like_operator_is_not_being_used_I_should_probably_keep_the_equal_operator_by_like_Do_you_want_to_continue_anyway");
+            int resp = application.confirmDialog(
+                    msg,
+                    i18n.getTranslation("_Caution"),
+                    JOptionPane.YES_NO_OPTION,
+                    JOptionPane.QUESTION_MESSAGE,
+                    "You may need the like operator in the filter dialog"
+            );
+            if (resp == JOptionPane.NO_OPTION) {
+                return false;
+            }
+        }
+        return true;
+
+    }
     /**
      * Rellena la lista con los valores del campo seleccionado
      */
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties	(revision 43168)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties	(revision 43169)
@@ -1190,4 +1190,5 @@
 _lower_right_corner=Lower right corner
 _lower_left_corner=Lower left corner
 _Remembered_dialogs=Remembered dialogs
-_Remember_responses_from_selected_dialogs=Remember responses from selected dialogs
\ No newline at end of file
+_Remember_responses_from_selected_dialogs=Remember responses from selected dialogs
+_It_looks_like_youre_using_percent_o_question_and_the_like_operator_is_not_being_used_I_should_probably_keep_the_equal_operator_by_like_Do_you_want_to_continue_anyway=It looks like you're using '%' o '?' and the 'like' operator is not being used. I should probably keep the '=' operator by 'like'. Do you want to continue anyway?
\ No newline at end of file
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/i18n/text.properties
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/i18n/text.properties	(revision 43168)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/i18n/text.properties	(revision 43169)
@@ -1272,3 +1272,4 @@
 _lower_left_corner=Esquina inferior izquierda
 _Remembered_dialogs=Dialogos recordados
 _Remember_responses_from_selected_dialogs=Respuestas recordadas para los siguientes dialogos
+_It_looks_like_youre_using_percent_o_question_and_the_like_operator_is_not_being_used_I_should_probably_keep_the_equal_operator_by_like_Do_you_want_to_continue_anyway=Parece que se esta usando '%' o '?' y no se esta usando el operador like. Problablemente deberia sustiuir el operador '=' por 'like'. \u00bf Desea continuar de todas formas ?
\ No newline at end of file
