}
private void executeSearch() {
String cmd = this.typeGroup.getSelection().getActionCommand();
this.model.clear();
DefaultMatcher matcher = null;
final String searchString = this.freeTextField.getText();
if (cmd.equals("cs")) {
matcher = new DefaultMatcher() {
@Override
public boolean matches(String match) {
return match.indexOf(searchString) != -1;
}
@Override
public void addLink(final Link link) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
SearchTab.this.model.addElement(link);
}
});
}
};
} else if (cmd.equals("ci")) {
matcher = new DefaultMatcher() {
@Override
public boolean matches(String match) {
return match.toLowerCase().indexOf(
searchString.toLowerCase()) != -1;
}
@Override
public void addLink(final Link link) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
SearchTab.this.model.addElement(link);
}
});
}
};
} else if (cmd.equals("re")) {
final Pattern pattern = Pattern.compile(searchString);
matcher = new DefaultMatcher() {
@Override
public boolean matches(String match) {
java.util.regex.Matcher matcher = pattern.matcher(match);
return matcher.find();
}
@Override
public void addLink(final Link link) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
SearchTab.this.model.addElement(link);
}
});
}
};
} else {
throw new AssertionError("Invalid search type option.");
}
matcher.setProgressMonitor(SystemFacade.getInstance()
.getProgressMonitor());
SystemFacade.getInstance().search(matcher);
}