From 08d438cdbc9bc89b4c1c4574156f2716e6f4e37f Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Mon, 7 Jan 2013 08:44:57 -0600 Subject: [PATCH] Issue #1431 - Fix Dual List filter problem. Former-commit-id: 71ce5aa24954dc3bdf65cee64b8c2f1df67146a7 [formerly ace6214c3fd2084d75ff09c0a5e158fa1bceeb8e] [formerly 71ce5aa24954dc3bdf65cee64b8c2f1df67146a7 [formerly ace6214c3fd2084d75ff09c0a5e158fa1bceeb8e] [formerly 7eb980fd8329573a7ea1ba2472c42ecbffe0ec08 [formerly 0fc212dac04a4693060ee0e321c532a3f5076e01]]] Former-commit-id: 7eb980fd8329573a7ea1ba2472c42ecbffe0ec08 Former-commit-id: 0014c1073a638ab1209e234e5c7a39fc792689fc [formerly 4757feb616c6d86789b94dc66db200693e4c89b0] Former-commit-id: d72d3db542e023bd25cab395b117cff0c7d73d6b --- .../viz/ui/widgets/duallist/DualList.java | 67 +++++++++------- .../ui/widgets/duallist/DualListConfig.java | 78 ++++++++++++++----- 2 files changed, 100 insertions(+), 45 deletions(-) diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/DualList.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/DualList.java index cda0de1e9b..ff98677754 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/DualList.java +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/DualList.java @@ -42,11 +42,11 @@ import com.raytheon.viz.ui.widgets.duallist.ButtonImages.ButtonImage; /** * SWT Dual List Widget. - * + * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * Feb 13, 2012            mpduff      Initial creation
@@ -54,9 +54,10 @@ import com.raytheon.viz.ui.widgets.duallist.ButtonImages.ButtonImage;
  * Aug 08, 2012    863     jpiatt      Added checks for selection changes.
  * Aug 10, 2012   1002     mpduff      Fixed sorting of numeric data on move left.
  * Sep 07, 2012    684     mpduff      Deselect selection prior to selecting new items.
- *
+ * Dec 17, 2012   1431     mpduff      Fix filter problem when deselecting items.
+ * 
  * 
- * + * * @author mpduff * @version 1.0 */ @@ -145,7 +146,7 @@ public class DualList extends Composite { /** * Constructor - * + * * @param parent * Parent container * @param style @@ -159,7 +160,7 @@ public class DualList extends Composite { /** * Constructor - * + * * @param parent * Parent container * @param style @@ -168,7 +169,7 @@ public class DualList extends Composite { * Data/Configuration object * @param cb * Update Callback - * + * */ public DualList(Composite parent, int style, DualListConfig config, IUpdate cb) { @@ -438,7 +439,7 @@ public class DualList extends Composite { /** * Set FullList. - * + * * @param fullList * all users listed in notification table */ @@ -685,7 +686,7 @@ public class DualList extends Composite { /** * Reload the availableList data preserving the original order of the list. */ - private void reloadAvailableList() { + public void reloadAvailableList() { String[] selectedStrings = availableList.getSelection(); ArrayList availableListNew = new ArrayList(); @@ -729,20 +730,34 @@ public class DualList extends Composite { } } else { - if (moveAllLeft) { - availableList.removeAll(); // Add all matching search field text to available list for (String s : config.getFullList()) { - if (s.contains(search)) { - availableList.add(s); + if (!config.isCaseFlag()) { + if (s.toLowerCase().contains(search.toLowerCase())) { + if (!config.isExcludeFlag()) { + availableList.add(s); + } + } else { + if (config.isExcludeFlag()) { + availableList.add(s); + } + } + } else { + if (s.contains(search)) { + if (!config.isExcludeFlag()) { + availableList.add(s); + } + } else { + if (config.isExcludeFlag()) { + availableList.add(s); + } + } } } - } else if (moveLeft) { - // Add selected item matching search field text to available // list for (String s : selectedList.getSelection()) { @@ -839,7 +854,7 @@ public class DualList extends Composite { /** * Clear Available Users list. - * + * * @param clearSelectionList */ public void clearAvailableList(boolean clearSelectionList) { @@ -852,7 +867,7 @@ public class DualList extends Composite { /** * Set the Available List items. - * + * * @param items * the list items. */ @@ -862,7 +877,7 @@ public class DualList extends Composite { /** * Get the number of items in the list. - * + * * @return the number of items. */ public int getItemCount() { @@ -871,7 +886,7 @@ public class DualList extends Composite { /** * Get the Selected List items. - * + * * @return the items in the selected list. */ public String[] getSelectedListItems() { @@ -880,7 +895,7 @@ public class DualList extends Composite { /** * Get the selection. - * + * * @return the selections. */ public String[] getSelectedSelection() { @@ -889,7 +904,7 @@ public class DualList extends Composite { /** * Get the configuration. - * + * * @return items in available list. */ public String[] getAvailableListItems() { @@ -898,7 +913,7 @@ public class DualList extends Composite { /** * Set the Selected List items. - * + * * @param items * the list items. */ @@ -909,7 +924,7 @@ public class DualList extends Composite { /** * Selected User items. - * + * * @param selection * selected user items */ @@ -926,7 +941,7 @@ public class DualList extends Composite { /** * Get the configuration. - * + * * @return the configuration. */ public DualListConfig getConfig() { @@ -935,7 +950,7 @@ public class DualList extends Composite { /** * Set the configuration. - * + * * @param config * the configuration. */ diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/DualListConfig.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/DualListConfig.java index 9f07b12469..5314d4c36f 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/DualListConfig.java +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/widgets/duallist/DualListConfig.java @@ -23,23 +23,23 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; - /** - * Config file for DualList class. Reused from Data Delivery. + * Config file for DualList class. Reused from Data Delivery. * *
- *
+ * 
  * SOFTWARE HISTORY
- *
+ * 
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * May 31, 2012            mpduff      Initial creation.
  * Aug 10, 2012  1002      mpduff      Added numeric flag for sorting.
- *
+ * Jan 07, 2013  1431      mpduff      Add case sensitive and exclude flags.
+ * 
  * 
- * + * * @author mpduff - * @version 1.0 + * @version 1.0 */ public class DualListConfig { @@ -78,19 +78,29 @@ public class DualListConfig { * Full list of available items. */ private List fullList = new ArrayList(); - + /** * The list to include. */ private HashSet includeList = new HashSet(); - + /** * The search field. */ private String searchField = null; - + + /** + * Case Sensitive search flag. + */ + private boolean caseFlag = false; + + /** + * Exclude search flag. + */ + private boolean excludeFlag = false; + private IMenuData menuData; - + /** Flag for numeric data */ private boolean numericData = false; @@ -100,7 +110,7 @@ public class DualListConfig { public DualListConfig() { } - + /** * Get the include list. * @@ -252,12 +262,11 @@ public class DualListConfig { public void setFullList(List fullList) { this.fullList = fullList; } - + /** * Get the search field text. * - * @return the String - * the search field text. + * @return the String the search field text. */ public String getSearchField() { return searchField; @@ -267,22 +276,23 @@ public class DualListConfig { * Set the search field text. * * @param searchField - * the search field text. + * the search field text. */ public void setSearchField(String searchField) { this.searchField = searchField; } - + public IMenuData getMenuData() { return menuData; } - + public void setMenuData(IMenuData menuData) { this.menuData = menuData; } /** - * @param numericData the numericData to set + * @param numericData + * the numericData to set */ public void setNumericData(boolean numericData) { this.numericData = numericData; @@ -294,4 +304,34 @@ public class DualListConfig { public boolean isNumericData() { return numericData; } + + /** + * @return the caseFlag + */ + public boolean isCaseFlag() { + return caseFlag; + } + + /** + * @return the excludeFlag + */ + public boolean isExcludeFlag() { + return excludeFlag; + } + + /** + * @param caseFlag + * the caseFlag to set + */ + public void setCaseFlag(boolean caseFlag) { + this.caseFlag = caseFlag; + } + + /** + * @param excludeFlag + * the excludeFlag to set + */ + public void setExcludeFlag(boolean excludeFlag) { + this.excludeFlag = excludeFlag; + } }