Fixed semantics.

This commit is contained in:
Oliver Spohngellert 2016-05-26 16:06:20 -04:00
parent 305c7a332b
commit 126c12d2d1
8 changed files with 23 additions and 35 deletions

View File

@ -205,19 +205,9 @@ class DateSearchFilter extends AbstractFileSearchFilter<DateSearchPanel> {
getComponent().addActionListener(l);
}
@Override
public void addPropertyChangeListener(PropertyChangeListener listener) {
getComponent().addPropertyChangeListener(listener);
}
@Override
public boolean isValid() {
if (!isEnabled()) {
return true;
}
else {
return this.getComponent().isSearchable();
}
return this.getComponent().isValidSearch();
}
/**

View File

@ -430,7 +430,7 @@ class DateSearchPanel extends javax.swing.JPanel {
dateToButtonCalendar.setTargetDate(date);
}
boolean isSearchable() {
boolean isValidSearch() {
return this.accessedCheckBox.isSelected() ||
this.changedCheckBox.isSelected() ||
this.createdCheckBox.isSelected() ||

View File

@ -25,7 +25,7 @@ import javax.swing.JComponent;
/**
* Provides a filter and the panel to display it to the FileSearchTopComponent
*/
interface FileSearchFilter {
interface FileSearchFilter {
/**
* Gets the panel to put in the File Search pane.
@ -40,7 +40,12 @@ import javax.swing.JComponent;
* @return true if it should be included in the search
*/
boolean isEnabled();
/**
* Checks if the panel has valid input for search.
*
* @return Whether the panel has valid input for search.
*/
boolean isValid();
/**
@ -58,7 +63,12 @@ import javax.swing.JComponent;
* Add an action listener to the fields of this panel
*/
void addActionListener(ActionListener l);
/**
* Adds the property change listener to the panel
*
* @param listener the listener to add.
*/
void addPropertyChangeListener(PropertyChangeListener listener);
/**

View File

@ -105,7 +105,7 @@ class FileSearchPanel extends javax.swing.JPanel {
filter.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
searchButton.setEnabled(isSearchable());
searchButton.setEnabled(isValidSearch());
}
});
}
@ -116,13 +116,13 @@ class FileSearchPanel extends javax.swing.JPanel {
search();
}
});
searchButton.setEnabled(isSearchable());
searchButton.setEnabled(isValidSearch());
}
/**
* @return true if any of the filters in the panel are enabled (checked)
*/
private boolean isSearchable() {
private boolean isValidSearch() {
boolean enabled = false;
for (FileSearchFilter filter : this.getFilters()) {
if (filter.isEnabled()) {
@ -144,7 +144,7 @@ class FileSearchPanel extends javax.swing.JPanel {
// change the cursor to "waiting cursor" for this operation
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
if (this.isSearchable()) {
if (this.isValidSearch()) {
String title = NbBundle.getMessage(this.getClass(), "FileSearchPanel.search.results.title", ++resultWindowCount);
String pathText = NbBundle.getMessage(this.getClass(), "FileSearchPanel.search.results.pathText");

View File

@ -86,10 +86,6 @@ class KnownStatusSearchFilter extends AbstractFileSearchFilter<KnownStatusSearch
@Override
public boolean isValid() {
if (!isEnabled()) {
return true;
} else {
return this.getComponent().isSearchable();
}
return this.getComponent().isValidSearch();
}
}

View File

@ -77,7 +77,7 @@ class KnownStatusSearchPanel extends javax.swing.JPanel {
pcs.removePropertyChangeListener(pcl);
}
boolean isSearchable() {
boolean isValidSearch() {
return this.unknownOptionCheckBox.isSelected() || this.knownBadOptionCheckBox.isSelected() || this.knownOptionCheckBox.isSelected();
}

View File

@ -43,10 +43,6 @@ class MimeTypeFilter extends AbstractFileSearchFilter<MimeTypePanel> {
@Override
public boolean isValid() {
if (!isEnabled()) {
return true;
} else {
return !this.getComponent().getMimeTypesSelected().isEmpty();
}
return !this.getComponent().getMimeTypesSelected().isEmpty();
}
}

View File

@ -65,10 +65,6 @@ class NameSearchFilter extends AbstractFileSearchFilter<NameSearchPanel> {
@Override
public boolean isValid() {
if (!isEnabled()) {
return true;
} else {
return !this.getComponent().getSearchTextField().getText().isEmpty();
}
return !this.getComponent().getSearchTextField().getText().isEmpty();
}
}