[hg] main-silver: Issue #224240 - [73cat] Find issues is broken ...

  • From: Tomas Stupka < >
  • To:
  • Subject: [hg] main-silver: Issue #224240 - [73cat] Find issues is broken ...
  • Date: Mon, 07 Jan 2013 12:13:20 -0800

changeset 301717973fe2 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/301717973fe2
description:
        Issue #224240 - [73cat] Find issues is broken when searching for more 
than one word

diffstat:

 bugzilla/src/org/netbeans/modules/bugzilla/query/QueryController.java        
      |   7 +-
 bugzilla/src/org/netbeans/modules/bugzilla/query/QueryParameter.java         
      |  22 +++++-
 
bugzilla/test/unit/src/org/netbeans/modules/bugzilla/query/QueryParameterTest.java
 |  37 +++++++++-
 3 files changed, 60 insertions(+), 6 deletions(-)

diffs (135 lines):

diff --git 
a/bugzilla/src/org/netbeans/modules/bugzilla/query/QueryController.java 
b/bugzilla/src/org/netbeans/modules/bugzilla/query/QueryController.java
--- a/bugzilla/src/org/netbeans/modules/bugzilla/query/QueryController.java
+++ b/bugzilla/src/org/netbeans/modules/bugzilla/query/QueryController.java
@@ -87,6 +87,7 @@
 import org.netbeans.modules.bugzilla.repository.BugzillaRepository;
 import org.netbeans.modules.bugzilla.issue.BugzillaIssue;
 import org.netbeans.modules.bugzilla.kenai.KenaiRepository;
+import 
org.netbeans.modules.bugzilla.query.QueryParameter.AllWordsTextFieldParameter;
 import org.netbeans.modules.bugzilla.util.BugzillaUtil;
 import org.netbeans.modules.bugzilla.query.QueryParameter.CheckBoxParameter;
 import org.netbeans.modules.bugzilla.query.QueryParameter.ComboParameter;
@@ -226,9 +227,9 @@
             tmParameter = null;
         }
 
-        createQueryParameter(TextFieldParameter.class, 
panel.summaryTextField, "short_desc");                       // NOI18N
-        createQueryParameter(TextFieldParameter.class, 
panel.commentTextField, "long_desc");                        // NOI18N
-        createQueryParameter(TextFieldParameter.class, 
panel.whiteboardTextField, "status_whiteboard");             // NOI18N
+        createQueryParameter(AllWordsTextFieldParameter.class, 
panel.summaryTextField, "short_desc");               // NOI18N
+        createQueryParameter(AllWordsTextFieldParameter.class, 
panel.commentTextField, "long_desc");                // NOI18N
+        createQueryParameter(AllWordsTextFieldParameter.class, 
panel.whiteboardTextField, "status_whiteboard");     // NOI18N
         createQueryParameter(TextFieldParameter.class, 
panel.keywordsTextField, "keywords");                        // NOI18N
         createQueryParameter(TextFieldParameter.class, 
panel.peopleTextField, "email1");                            // NOI18N
         createQueryParameter(CheckBoxParameter.class, 
panel.bugAssigneeCheckBox, "emailassigned_to1");              // NOI18N
diff --git 
a/bugzilla/src/org/netbeans/modules/bugzilla/query/QueryParameter.java 
b/bugzilla/src/org/netbeans/modules/bugzilla/query/QueryParameter.java
--- a/bugzilla/src/org/netbeans/modules/bugzilla/query/QueryParameter.java
+++ b/bugzilla/src/org/netbeans/modules/bugzilla/query/QueryParameter.java
@@ -315,10 +315,16 @@
 
     static class TextFieldParameter extends QueryParameter {
         private final JTextField txt;
+        private final boolean allWords;
         public TextFieldParameter(JTextField txt, String parameter, String 
encoding) {
+            this(txt, parameter, encoding, false);
+        }
+        public TextFieldParameter(JTextField txt, String parameter, String 
encoding, boolean allWords) {
             super(parameter, encoding);
             this.txt = txt;
+            this.allWords = allWords;
         }
+        
         @Override
         public ParameterValue[] getValues() {
             String value = txt.getText();
@@ -330,7 +336,9 @@
             for (int i = 0; i < split.length; i++) {
                 String s = split[i];
                 sb.append(s);
-                if(i < split.length - 1) sb.append("+"); // NOI18N
+                if(i < split.length - 1) {
+                    sb.append(allWords ? " " : "+"); // NOI18N
+                } 
             }
             String v = sb.toString();
             return new ParameterValue[] { new ParameterValue(v, v) };
@@ -341,7 +349,11 @@
             if(pvs.length == 0 || pvs[0] == null) {
                 return;
             }
-            txt.setText(pvs[0].getValue().replace("+", " ")); // NOI18N
+            String value = pvs[0].getValue();
+            if(!allWords) {
+                value = value.replace("+", " "); // NOI18N
+            } 
+            txt.setText(value); 
         }
         @Override
         void setEnabled(boolean  b) {
@@ -349,6 +361,12 @@
         }
     }
 
+    static class AllWordsTextFieldParameter extends TextFieldParameter {
+        public AllWordsTextFieldParameter(JTextField txt, String parameter, 
String encoding) {
+            super(txt, parameter, encoding, true);
+        }
+    }
+        
     static class CheckBoxParameter extends QueryParameter {
         private ParameterValue[] selected = new ParameterValue[] {new 
ParameterValue("1")}; // NOI18N
         private final JCheckBox chk;
diff --git 
a/bugzilla/test/unit/src/org/netbeans/modules/bugzilla/query/QueryParameterTest.java
 
b/bugzilla/test/unit/src/org/netbeans/modules/bugzilla/query/QueryParameterTest.java
--- 
a/bugzilla/test/unit/src/org/netbeans/modules/bugzilla/query/QueryParameterTest.java
+++ 
b/bugzilla/test/unit/src/org/netbeans/modules/bugzilla/query/QueryParameterTest.java
@@ -53,7 +53,7 @@
 import javax.swing.JList;
 import javax.swing.JTextField;
 import org.netbeans.junit.NbTestCase;
-import org.netbeans.modules.bugtracking.util.TextUtils;
+import 
org.netbeans.modules.bugzilla.query.QueryParameter.AllWordsTextFieldParameter;
 import org.netbeans.modules.bugzilla.query.QueryParameter.CheckBoxParameter;
 import org.netbeans.modules.bugzilla.query.QueryParameter.ComboParameter;
 import org.netbeans.modules.bugzilla.query.QueryParameter.ListParameter;
@@ -182,6 +182,41 @@
 
     }
 
+    public void testAllWordsTextFieldParameter() throws 
UnsupportedEncodingException {
+        JTextField text = new JTextField();
+        TextFieldParameter tp = new AllWordsTextFieldParameter(text, 
PARAMETER, "UTF-8");
+        assertEquals(PARAMETER, tp.getParameter());
+        assertEquals("", text.getText());
+        assertEquals(tp.get(false).toString(), "&" + PARAMETER + "=");
+
+        tp.setValues(new ParameterValue[] {PV2});
+        assertEquals(PV2.getValue(), text.getText());
+        assertEquals(1, tp.getValues().length);
+        assertEquals(PV2, tp.getValues()[0]);
+        assertEquals(tp.get(false).toString(), "&" + PARAMETER + "=" + 
PV2.getValue());
+
+        String parameterValue = "New+Value";
+        tp.setValues(new ParameterValue[] {new 
ParameterValue(parameterValue)});
+        assertEquals("New+Value", text.getText());
+        assertEquals(1, tp.getValues().length);
+        assertEquals(new ParameterValue(parameterValue), tp.getValues()[0]);
+        assertEquals(tp.get(true).toString(), "&" + PARAMETER + "=" + 
URLEncoder.encode(parameterValue, "UTF-8"));
+
+        parameterValue = "NewValue";
+        text.setText(parameterValue);
+        assertEquals(1, tp.getValues().length);
+        assertEquals(new ParameterValue(parameterValue), tp.getValues()[0]);
+        assertEquals(tp.get(true).toString(), "&" + PARAMETER + "=" + 
URLEncoder.encode(parameterValue, "UTF-8"));
+        assertEquals("NewValue", text.getText());
+
+        text.setText("New Value1");
+        assertEquals(1, tp.getValues().length);
+        parameterValue = "New Value1";
+        assertEquals(new ParameterValue(parameterValue), tp.getValues()[0]);
+        assertEquals(tp.get(true).toString(), "&" + PARAMETER + "=" + 
URLEncoder.encode(parameterValue, "UTF-8"));
+
+    }
+
     public void testCheckBoxParameter() {
         JCheckBox checkbox = new JCheckBox();
         CheckBoxParameter cp = new CheckBoxParameter(checkbox, PARAMETER, 
"UTF-8");

[hg] main-silver: Issue #224240 - [73cat] Find issues is broken ...

Tomas Stupka 01/07/2013

Project Features

About this Project

ConnectedDeveloper was started in November 2009, is owned by tpavek, and has 65 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close