Commit dee9ea93 authored by Ryan Graham's avatar Ryan Graham Committed by ryang

changed the ui to use a single text field with multiple checkboxes to specify...

changed the ui to use a single text field with multiple checkboxes to specify which fields are to be searched (thanks jfroehlich)


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1226 b35dd754-fafc-0310-a699-88a17e54d16e
parent c2e0bd2d
version 1.0.6
---------------
* changed the ui to use a single text field with multiple checkboxes to specify which fields are to be searched (thanks jfroehlich)
version 1.0.5 version 1.0.5
--------------- ---------------
* Added basic support for non-data form searches to support the Miranda (thanks Baron Ng) * Added basic support for non-data form searches to support the Miranda (thanks Baron Ng)
......
...@@ -109,7 +109,8 @@ public class SearchPlugin implements Component, Plugin { ...@@ -109,7 +109,8 @@ public class SearchPlugin implements Component, Plugin {
componentManager = ComponentManagerFactory.getComponentManager(); componentManager = ComponentManagerFactory.getComponentManager();
try { try {
componentManager.addComponent(SERVICE_NAME, this); componentManager.addComponent(SERVICE_NAME, this);
} catch (Exception e) { }
catch (Exception e) {
componentManager.getLog().error(e); componentManager.getLog().error(e);
} }
...@@ -122,6 +123,12 @@ public class SearchPlugin implements Component, Plugin { ...@@ -122,6 +123,12 @@ public class SearchPlugin implements Component, Plugin {
XDataFormImpl searchForm = new XDataFormImpl(DataForm.TYPE_FORM); XDataFormImpl searchForm = new XDataFormImpl(DataForm.TYPE_FORM);
searchForm.setTitle("User Search"); searchForm.setTitle("User Search");
searchForm.addInstruction(instructions); searchForm.addInstruction(instructions);
XFormFieldImpl field = new XFormFieldImpl("search");
field.setType(FormField.TYPE_TEXT_SINGLE);
field.setLabel("Search");
field.setRequired(false);
searchForm.addField(field);
Iterator iter = searchFields.iterator(); Iterator iter = searchFields.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
...@@ -130,8 +137,9 @@ public class SearchPlugin implements Component, Plugin { ...@@ -130,8 +137,9 @@ public class SearchPlugin implements Component, Plugin {
//non-data form //non-data form
probeResult.addElement(searchField.toLowerCase()); probeResult.addElement(searchField.toLowerCase());
XFormFieldImpl field = new XFormFieldImpl(searchField); field = new XFormFieldImpl(searchField);
field.setType(FormField.TYPE_TEXT_SINGLE); field.setType(FormField.TYPE_BOOLEAN);
field.addValue("1");
field.setLabel(searchField); field.setLabel(searchField);
field.setRequired(false); field.setRequired(false);
searchForm.addField(field); searchForm.addField(field);
...@@ -277,9 +285,7 @@ public class SearchPlugin implements Component, Plugin { ...@@ -277,9 +285,7 @@ public class SearchPlugin implements Component, Plugin {
/** /**
* nick, first, last, email fields have been hardcoded to support Miranda which does not * nick, first, last, email fields have been hardcoded to support Miranda which does not
* follow the JEP-0055 spec by requesting a list of searchable fields. If/when Miranda * make a query to discover which fields are available to be searched
* is updated to follow the spect the hardcoded field checks can be removed and replaced
* with the commented code below.
*/ */
private Hashtable<String, String> extractSearchQuery(Element incomingForm) { private Hashtable<String, String> extractSearchQuery(Element incomingForm) {
Hashtable<String, String> searchList = new Hashtable<String, String>(); Hashtable<String, String> searchList = new Hashtable<String, String>();
...@@ -309,32 +315,32 @@ public class SearchPlugin implements Component, Plugin { ...@@ -309,32 +315,32 @@ public class SearchPlugin implements Component, Plugin {
if (email != null) { if (email != null) {
searchList.put("Email", email.getTextTrim()); searchList.put("Email", email.getTextTrim());
} }
/*
Iterator iter = searchFields.iterator();
while (iter.hasNext()) {
String field = (String) iter.next();
Element e = incomingForm.element(field);
if (field != null) {
searchList.put(field, e.getTextTrim());
}
}
*/
} }
else { else {
List<String> searchFields = new ArrayList<String>();
String search = "";
Iterator fields = form.elementIterator("field"); Iterator fields = form.elementIterator("field");
while (fields.hasNext()) { while (fields.hasNext()) {
Element searchField = (Element) fields.next(); Element searchField = (Element) fields.next();
Iterator iter = searchField.elementIterator("value"); String field = searchField.attributeValue("var");
while (iter.hasNext()) { String value = searchField.element("value").getTextTrim();
Element queryField = (Element) iter.next(); if (field.equals("search")) {
String query = queryField.getTextTrim(); search = value;
searchList.put(searchField.attributeValue("var"), query); }
} else if (value.equals("1")) {
searchFields.add(field);
}
} }
Iterator iter = searchFields.iterator();
while (iter.hasNext()) {
String field = (String) iter.next();
searchList.put(field, search);
}
} }
return searchList; return searchList;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment