Issue #1733 - Fix issue with moving items between selected and available in dual list, moved some test code to test project
Change-Id: Ic46ce9adabf8a922066c2a2d58596504e244332c Former-commit-id: 8a14be26db146b44fd364b26a694c2531ec843a4
This commit is contained in:
parent
158b0f8564
commit
a7b6f116bd
12 changed files with 114 additions and 99 deletions
|
@ -41,6 +41,7 @@ import com.raytheon.uf.viz.datadelivery.filter.IFilterUpdate;
|
|||
import com.raytheon.viz.ui.widgets.duallist.DualList;
|
||||
import com.raytheon.viz.ui.widgets.duallist.DualListConfig;
|
||||
import com.raytheon.viz.ui.widgets.duallist.IUpdate;
|
||||
import com.raytheon.viz.ui.widgets.duallist.SearchUtils;
|
||||
|
||||
/**
|
||||
* Standard Filter Composite
|
||||
|
@ -55,6 +56,7 @@ import com.raytheon.viz.ui.widgets.duallist.IUpdate;
|
|||
* Aug 08, 2012 863 jpiatt Added new interface method.
|
||||
* Jan 07, 2013 1432 mpduff Fix case sensitive and exclude checkboxes.
|
||||
* Feb 25, 2013 1588 mpduff Fix match any/all.
|
||||
* Aug 20, 2013 1733 mpduff Match any/all now executes the search on selection.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -223,9 +225,10 @@ public class FilterComp extends AbstractFilterComp implements IUpdate {
|
|||
matchAnyBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if (matchAnyBtn.getSelection() == true) {
|
||||
if (matchAnyBtn.getSelection()) {
|
||||
matchAnyFlag = true;
|
||||
}
|
||||
handleSearch();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -235,9 +238,10 @@ public class FilterComp extends AbstractFilterComp implements IUpdate {
|
|||
matchAllBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if (matchAllBtn.getSelection() == true) {
|
||||
if (matchAllBtn.getSelection()) {
|
||||
matchAnyFlag = false;
|
||||
}
|
||||
handleSearch();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -284,26 +288,36 @@ public class FilterComp extends AbstractFilterComp implements IUpdate {
|
|||
boolean excludeSearch = exclusionBtn.getSelection();
|
||||
|
||||
String search = regExTxt.getText();
|
||||
dualConfig.setSearchField(search);
|
||||
dualConfig.setMatchAny(matchAnyFlag);
|
||||
List<String> fullList = dualConfig.getFullList();
|
||||
|
||||
if (search != null && search.length() > 0) {
|
||||
|
||||
dualConfig.setSearchField(search);
|
||||
|
||||
String[] filteredList = dualConfig.getFullList().toArray(
|
||||
new String[dualConfig.getFullList().size()]);
|
||||
|
||||
List<String> tmpFilterList = DataBrowserUtils.search(search,
|
||||
List<String> tmpFilterList = SearchUtils.search(search,
|
||||
filteredList, matchAnyFlag, caseBtn.getSelection(),
|
||||
excludeSearch);
|
||||
|
||||
// Clear the list and add the newly filtered items
|
||||
dualList.clearAvailableList(false);
|
||||
for (String s : dualList.getSelectedListItems()) {
|
||||
tmpFilterList.remove(s);
|
||||
}
|
||||
dualList.setAvailableItems(tmpFilterList);
|
||||
return;
|
||||
} else {
|
||||
|
||||
// Clear the list and repopulate with the full list
|
||||
dualList.clearAvailableList(false);
|
||||
for (String s : dualList.getSelectedListItems()) {
|
||||
fullList.remove(s);
|
||||
}
|
||||
dualList.setAvailableItems(fullList);
|
||||
}
|
||||
|
||||
// Clear the list and repopulate with the full list
|
||||
dualList.clearAvailableList(false);
|
||||
dualList.setAvailableItems(dualConfig.getFullList());
|
||||
dualList.enableDisableLeftRightButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="tests"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -56,6 +56,7 @@ import com.raytheon.viz.ui.widgets.duallist.ButtonImages.ButtonImage;
|
|||
* Sep 07, 2012 684 mpduff Deselect selection prior to selecting new items.
|
||||
* Dec 17, 2012 1431 mpduff Fix filter problem when deselecting items.
|
||||
* Jan 07, 2013 1456 bgonzale Added setSelectedList(ArrayList<String>).
|
||||
* Aug 20, 2013 1733 mpduff Search now uses SearchUtils.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -258,11 +259,7 @@ public class DualList extends Composite {
|
|||
availableList.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if (availableList.getSelectionCount() > 0) {
|
||||
moveRightBtn.setEnabled(true);
|
||||
} else {
|
||||
moveRightBtn.setEnabled(false);
|
||||
}
|
||||
enableDisableLeftRightButtons();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -375,12 +372,7 @@ public class DualList extends Composite {
|
|||
selectedList.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if (selectedList.getSelectionCount() > 0) {
|
||||
moveLeftBtn.setEnabled(true);
|
||||
} else {
|
||||
moveLeftBtn.setEnabled(false);
|
||||
}
|
||||
|
||||
enableDisableLeftRightButtons();
|
||||
enableDisableUpDownButtons();
|
||||
}
|
||||
});
|
||||
|
@ -487,13 +479,7 @@ public class DualList extends Composite {
|
|||
}
|
||||
}
|
||||
|
||||
if (availableList.getItemCount() > 0) {
|
||||
moveAllRightBtn.setEnabled(true);
|
||||
}
|
||||
|
||||
if (selectedList.getItemCount() > 0) {
|
||||
moveAllLeftBtn.setEnabled(true);
|
||||
}
|
||||
enableDisableLeftRightButtons();
|
||||
|
||||
entriesUpdated();
|
||||
}
|
||||
|
@ -551,14 +537,11 @@ public class DualList extends Composite {
|
|||
} else {
|
||||
selectedList.setSelection(selectedList.getItemCount() - 1);
|
||||
}
|
||||
} else {
|
||||
moveLeftBtn.setEnabled(false);
|
||||
}
|
||||
|
||||
moveAllRightBtn.setEnabled(true);
|
||||
|
||||
entriesUpdated();
|
||||
enableDisableUpDownButtons();
|
||||
enableDisableLeftRightButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -570,23 +553,19 @@ public class DualList extends Composite {
|
|||
moveAllLeft = true;
|
||||
|
||||
for (String sl : selectedList.getItems()) {
|
||||
|
||||
if (!list.contains(sl)) {
|
||||
selectedList.remove(sl);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
reloadAvailableList();
|
||||
moveLeftBtn.setEnabled(false);
|
||||
moveAllLeftBtn.setEnabled(false);
|
||||
moveAllRightBtn.setEnabled(true);
|
||||
|
||||
if (callEntriesUpdated == true) {
|
||||
entriesUpdated();
|
||||
}
|
||||
|
||||
enableDisableUpDownButtons();
|
||||
enableDisableLeftRightButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -621,12 +600,10 @@ public class DualList extends Composite {
|
|||
}
|
||||
|
||||
availableList.removeAll();
|
||||
moveRightBtn.setEnabled(false);
|
||||
moveAllRightBtn.setEnabled(false);
|
||||
moveAllLeftBtn.setEnabled(true);
|
||||
|
||||
entriesUpdated();
|
||||
enableDisableUpDownButtons();
|
||||
enableDisableLeftRightButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -647,9 +624,7 @@ public class DualList extends Composite {
|
|||
|
||||
availableList.remove(availableList.getSelectionIndices());
|
||||
|
||||
if (availableList.getItemCount() == 0) {
|
||||
moveRightBtn.setEnabled(false);
|
||||
} else {
|
||||
if (availableList.getItemCount() > 0) {
|
||||
if (firstIdxSelected > availableList.getItemCount() - 1) {
|
||||
availableList.select(availableList.getItemCount() - 1);
|
||||
} else {
|
||||
|
@ -657,10 +632,9 @@ public class DualList extends Composite {
|
|||
}
|
||||
}
|
||||
|
||||
moveAllLeftBtn.setEnabled(true);
|
||||
|
||||
entriesUpdated();
|
||||
enableDisableUpDownButtons();
|
||||
enableDisableLeftRightButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -702,7 +676,6 @@ public class DualList extends Composite {
|
|||
|
||||
String[] selectedStrings = availableList.getSelection();
|
||||
ArrayList<String> availableListNew = new ArrayList<String>();
|
||||
String search = config.getSearchField();
|
||||
|
||||
String[] selectedItemArray = selectedList.getItems();
|
||||
ArrayList<String> selectedItemList = new ArrayList<String>();
|
||||
|
@ -745,29 +718,15 @@ public class DualList extends Composite {
|
|||
if (moveAllLeft) {
|
||||
availableList.removeAll();
|
||||
|
||||
// Add all matching search field text to available list
|
||||
for (String s : config.getFullList()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
String[] fullList = config.getFullList().toArray(
|
||||
new String[config.getFullList().size()]);
|
||||
java.util.List<String> filteredList = SearchUtils.search(
|
||||
config.getSearchField(), fullList,
|
||||
config.getMatchAny(), config.isCaseFlag(),
|
||||
config.isExcludeFlag());
|
||||
|
||||
for (String s : filteredList) {
|
||||
availableList.add(s);
|
||||
}
|
||||
} else if (moveLeft) {
|
||||
// Add selected item matching search field text to available
|
||||
|
@ -969,4 +928,14 @@ public class DualList extends Composite {
|
|||
public void setConfig(DualListConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/disable left/right movement buttons
|
||||
*/
|
||||
public void enableDisableLeftRightButtons() {
|
||||
moveAllRightBtn.setEnabled(availableList.getItemCount() > 0);
|
||||
moveAllLeftBtn.setEnabled(selectedList.getItemCount() > 0);
|
||||
moveRightBtn.setEnabled(availableList.getSelectionCount() > 0);
|
||||
moveLeftBtn.setEnabled(selectedList.getSelectionCount() > 0);
|
||||
}
|
||||
}
|
|
@ -35,6 +35,7 @@ import java.util.List;
|
|||
* 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.
|
||||
* Aug 20, 2013 1733 mpduff Add match flag.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -104,6 +105,12 @@ public class DualListConfig {
|
|||
/** Flag for numeric data */
|
||||
private boolean numericData = false;
|
||||
|
||||
/**
|
||||
* Match any/all flag. True is match any, false is match all. Only used when
|
||||
* searchField != null;
|
||||
*/
|
||||
private boolean matchAny = true;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
|
@ -250,7 +257,7 @@ public class DualListConfig {
|
|||
* @return The array of all available items.
|
||||
*/
|
||||
public List<String> getFullList() {
|
||||
return fullList;
|
||||
return new ArrayList<String>(fullList);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -334,4 +341,23 @@ public class DualListConfig {
|
|||
public void setExcludeFlag(boolean excludeFlag) {
|
||||
this.excludeFlag = excludeFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* true is match any, false is match all
|
||||
*
|
||||
* @return the matchAny
|
||||
*/
|
||||
public boolean getMatchAny() {
|
||||
return matchAny;
|
||||
}
|
||||
|
||||
/**
|
||||
* true is match any, false is match all
|
||||
*
|
||||
* @param matchAny
|
||||
* the matchAny to set
|
||||
*/
|
||||
public void setMatchAny(boolean matchAny) {
|
||||
this.matchAny = matchAny;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.datadelivery.browser;
|
||||
package com.raytheon.viz.ui.widgets.duallist;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -33,6 +33,7 @@ import java.util.regex.Pattern;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 25, 2013 1588 mpduff Initial creation.
|
||||
* Aug 20, 2013 1733 mpduff Moved and renamed.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -40,7 +41,7 @@ import java.util.regex.Pattern;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DataBrowserUtils {
|
||||
public class SearchUtils {
|
||||
|
||||
private static final Pattern WILDCARD_PATTERN = Pattern.compile("\\*");
|
||||
|
||||
|
@ -120,7 +121,9 @@ public class DataBrowserUtils {
|
|||
} else {
|
||||
if (testCaseItem.contains(term) != excludeSearchFlag) {
|
||||
if (matchAnyFlag) {
|
||||
results.add(item);
|
||||
if (!results.contains(item)) {
|
||||
results.add(item);
|
||||
}
|
||||
} else {
|
||||
holder.add(term);
|
||||
}
|
|
@ -160,5 +160,6 @@
|
|||
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="/awips2/edex/lib/dependencies/meteolib.jni.linux32"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="/opt/uframe-eclipse/plugins/org.eclipse.jface_3.6.1.M20100825-0800.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.datadelivery.browser;
|
||||
package com.raytheon.viz.ui.widgets.duallist;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
|
@ -27,6 +27,8 @@ import java.util.List;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.viz.ui.widgets.duallist.SearchUtils;
|
||||
|
||||
/**
|
||||
* Test the filter functionality of the Dataset Discovery Brower's FilterComps.
|
||||
*
|
||||
|
@ -37,6 +39,7 @@ import org.junit.Test;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 25, 2013 1588 mpduff Initial creation.
|
||||
* Aug 20, 2013 1733 mpduff Moved and renamed.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -44,7 +47,7 @@ import org.junit.Test;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DataBrowserRegexTest {
|
||||
public class SearchUtilsTest {
|
||||
|
||||
private static final List<String> itemList = Arrays.asList("temp",
|
||||
"surface", "temp2", "temp3", "temp4", "wndSpd", "wndDir", "pres",
|
||||
|
@ -66,8 +69,8 @@ public class DataBrowserRegexTest {
|
|||
String searchTerm = "Emp";
|
||||
String[] fullList = itemList.toArray(new String[itemList.size()]);
|
||||
|
||||
List<String> results = DataBrowserUtils.search(searchTerm, fullList,
|
||||
true, false, false);
|
||||
List<String> results = SearchUtils.search(searchTerm, fullList, true,
|
||||
false, false);
|
||||
|
||||
String msg = checkResults(expected, results);
|
||||
assertNull(msg);
|
||||
|
@ -87,8 +90,8 @@ public class DataBrowserRegexTest {
|
|||
String searchTerm = "emp";
|
||||
String[] fullList = itemList.toArray(new String[itemList.size()]);
|
||||
|
||||
List<String> results = DataBrowserUtils.search(searchTerm, fullList,
|
||||
true, true, false);
|
||||
List<String> results = SearchUtils.search(searchTerm, fullList, true,
|
||||
true, false);
|
||||
|
||||
String msg = checkResults(expected, results);
|
||||
assertNull(msg);
|
||||
|
@ -110,8 +113,8 @@ public class DataBrowserRegexTest {
|
|||
String searchTerm = "emp";
|
||||
String[] fullList = itemList.toArray(new String[itemList.size()]);
|
||||
|
||||
List<String> results = DataBrowserUtils.search(searchTerm, fullList,
|
||||
true, false, true);
|
||||
List<String> results = SearchUtils.search(searchTerm, fullList, true,
|
||||
false, true);
|
||||
|
||||
String msg = checkResults(expected, results);
|
||||
assertNull(msg);
|
||||
|
@ -133,8 +136,8 @@ public class DataBrowserRegexTest {
|
|||
String searchTerm = "emp";
|
||||
String[] fullList = itemList.toArray(new String[itemList.size()]);
|
||||
|
||||
List<String> results = DataBrowserUtils.search(searchTerm, fullList,
|
||||
true, true, true);
|
||||
List<String> results = SearchUtils.search(searchTerm, fullList, true,
|
||||
true, true);
|
||||
|
||||
String msg = checkResults(expected, results);
|
||||
assertNull(msg);
|
||||
|
@ -154,8 +157,8 @@ public class DataBrowserRegexTest {
|
|||
String searchTerm = "Te 3";
|
||||
String[] fullList = itemList.toArray(new String[itemList.size()]);
|
||||
|
||||
List<String> results = DataBrowserUtils.search(searchTerm, fullList,
|
||||
true, false, false);
|
||||
List<String> results = SearchUtils.search(searchTerm, fullList, true,
|
||||
false, false);
|
||||
|
||||
String msg = checkResults(expected, results);
|
||||
assertNull(msg);
|
||||
|
@ -172,8 +175,8 @@ public class DataBrowserRegexTest {
|
|||
String searchTerm = "Te 3";
|
||||
String[] fullList = itemList.toArray(new String[itemList.size()]);
|
||||
|
||||
List<String> results = DataBrowserUtils.search(searchTerm, fullList,
|
||||
false, false, false);
|
||||
List<String> results = SearchUtils.search(searchTerm, fullList, false,
|
||||
false, false);
|
||||
|
||||
String msg = checkResults(expected, results);
|
||||
assertNull(msg);
|
||||
|
@ -190,8 +193,8 @@ public class DataBrowserRegexTest {
|
|||
String searchTerm = "te 3";
|
||||
String[] fullList = itemList.toArray(new String[itemList.size()]);
|
||||
|
||||
List<String> results = DataBrowserUtils.search(searchTerm, fullList,
|
||||
false, true, false);
|
||||
List<String> results = SearchUtils.search(searchTerm, fullList, false,
|
||||
true, false);
|
||||
|
||||
String msg = checkResults(expected, results);
|
||||
assertNull(msg);
|
||||
|
@ -208,8 +211,8 @@ public class DataBrowserRegexTest {
|
|||
String searchTerm = "T*3";
|
||||
String[] fullList = itemList.toArray(new String[itemList.size()]);
|
||||
|
||||
List<String> results = DataBrowserUtils.search(searchTerm, fullList,
|
||||
true, false, false);
|
||||
List<String> results = SearchUtils.search(searchTerm, fullList, true,
|
||||
false, false);
|
||||
|
||||
String msg = checkResults(expected, results);
|
||||
assertNull(msg);
|
||||
|
@ -226,8 +229,8 @@ public class DataBrowserRegexTest {
|
|||
String searchTerm = "t*3";
|
||||
String[] fullList = itemList.toArray(new String[itemList.size()]);
|
||||
|
||||
List<String> results = DataBrowserUtils.search(searchTerm, fullList,
|
||||
true, true, false);
|
||||
List<String> results = SearchUtils.search(searchTerm, fullList, true,
|
||||
true, false);
|
||||
|
||||
String msg = checkResults(expected, results);
|
||||
assertNull(msg);
|
||||
|
@ -249,8 +252,8 @@ public class DataBrowserRegexTest {
|
|||
String searchTerm = "te*3";
|
||||
String[] fullList = itemList.toArray(new String[itemList.size()]);
|
||||
|
||||
List<String> results = DataBrowserUtils.search(searchTerm, fullList,
|
||||
true, false, true);
|
||||
List<String> results = SearchUtils.search(searchTerm, fullList, true,
|
||||
false, true);
|
||||
String msg = checkResults(expected, results);
|
||||
assertNull(msg);
|
||||
}
|
||||
|
@ -268,8 +271,8 @@ public class DataBrowserRegexTest {
|
|||
String searchTerm = "t*3 wnd";
|
||||
String[] fullList = itemList.toArray(new String[itemList.size()]);
|
||||
|
||||
List<String> results = DataBrowserUtils.search(searchTerm, fullList,
|
||||
true, false, false);
|
||||
List<String> results = SearchUtils.search(searchTerm, fullList, true,
|
||||
false, false);
|
||||
|
||||
String msg = checkResults(expected, results);
|
||||
assertNull(msg);
|
||||
|
@ -286,8 +289,8 @@ public class DataBrowserRegexTest {
|
|||
String searchTerm = "t*3 mp";
|
||||
String[] fullList = itemList.toArray(new String[itemList.size()]);
|
||||
|
||||
List<String> results = DataBrowserUtils.search(searchTerm, fullList,
|
||||
false, false, false);
|
||||
List<String> results = SearchUtils.search(searchTerm, fullList, false,
|
||||
false, false);
|
||||
|
||||
String msg = checkResults(expected, results);
|
||||
assertNull(msg);
|
Loading…
Add table
Reference in a new issue