keyword list adjustments:

- do not save list if no keywords
- run search with all keywords on list, not only selected
This commit is contained in:
adam-m 2012-01-18 19:58:17 -05:00
parent e12ed4f5e4
commit 620da797cc

View File

@ -91,8 +91,8 @@ public final class KeywordSearchListTopComponent extends TopComponent implements
importButton.setToolTipText("Import list(s) of keywords from an external file."); importButton.setToolTipText("Import list(s) of keywords from an external file.");
saveListButton.setToolTipText("Save the current keyword list to a file"); saveListButton.setToolTipText("Save the current keyword list to a file");
searchButton.setToolTipText("Execute the keyword list search using the current list"); searchButton.setToolTipText("Execute the keyword list search using the current list");
deleteWordButton.setToolTipText("Delete selected keyword(s) from the list"); deleteWordButton.setToolTipText("Remove selected keyword(s) from the list");
deleteAllWordsButton.setToolTipText("Delete all keywords from the list (clear it)"); deleteAllWordsButton.setToolTipText("Remove all keywords from the list (clear it)");
keywordTable.setAutoscrolls(true); keywordTable.setAutoscrolls(true);
keywordTable.setTableHeader(null); keywordTable.setTableHeader(null);
@ -417,6 +417,12 @@ public final class KeywordSearchListTopComponent extends TopComponent implements
final String FEATURE_NAME = "Save Keyword List"; final String FEATURE_NAME = "Save Keyword List";
KeywordSearchListsXML writer = KeywordSearchListsXML.getCurrent(); KeywordSearchListsXML writer = KeywordSearchListsXML.getCurrent();
List<String> keywords = tableModel.getAllKeywords();
if (keywords.isEmpty()) {
KeywordSearchUtil.displayDialog(FEATURE_NAME, "Keyword List is empty and cannot be saved", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
return;
}
String listName = (String) JOptionPane.showInputDialog( String listName = (String) JOptionPane.showInputDialog(
null, null,
"New keyword list name:", "New keyword list name:",
@ -425,11 +431,10 @@ public final class KeywordSearchListTopComponent extends TopComponent implements
null, null,
null, null,
currentKeywordList != null ? currentKeywordList : ""); currentKeywordList != null ? currentKeywordList : "");
if (listName == null || listName.equals("")) { if (listName == null || listName.trim().equals("")) {
return; return;
} }
List<String> keywords = tableModel.getAllKeywords();
boolean shouldAdd = false; boolean shouldAdd = false;
if (writer.listExists(listName)) { if (writer.listExists(listName)) {
boolean replace = KeywordSearchUtil.displayConfirmDialog(FEATURE_NAME, "Keyword List <" + listName + "> already exists, do you want to replace it?", boolean replace = KeywordSearchUtil.displayConfirmDialog(FEATURE_NAME, "Keyword List <" + listName + "> already exists, do you want to replace it?",
@ -669,7 +674,7 @@ public final class KeywordSearchListTopComponent extends TopComponent implements
@Override @Override
public Map<String, Boolean> getQueryList() { public Map<String, Boolean> getQueryList() {
List<String> selected = getSelectedKeywords(); List<String> selected = getAllKeywords();
//filter out blank just in case //filter out blank just in case
Map<String, Boolean> ret = new LinkedHashMap<String, Boolean>(); Map<String, Boolean> ret = new LinkedHashMap<String, Boolean>();
for (String s : selected) { for (String s : selected) {