setFilter() and getFilter() methods made public

This commit is contained in:
fros4943 2010-01-15 10:54:05 +00:00
parent 34844188dd
commit a2b6c39ac2

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: LogListener.java,v 1.23 2010/01/13 15:04:47 nifi Exp $ * $Id: LogListener.java,v 1.24 2010/01/15 10:54:05 fros4943 Exp $
*/ */
package se.sics.cooja.plugins; package se.sics.cooja.plugins;
@ -110,7 +110,6 @@ public class LogListener extends VisPlugin {
private Simulation simulation; private Simulation simulation;
private String filterText = "";
private JTextField filterTextField = null; private JTextField filterTextField = null;
private Color filterTextFieldBackground; private Color filterTextFieldBackground;
@ -280,8 +279,8 @@ public class LogListener extends VisPlugin {
filterPanel.add(filterTextField); filterPanel.add(filterTextField);
filterTextField.addActionListener(new ActionListener() { filterTextField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
filterText = filterTextField.getText(); String str = filterTextField.getText();
setFilter(filterText); setFilter(str);
/* Autoscroll */ /* Autoscroll */
logTable.scrollRectToVisible(new Rectangle(0, logTable.getHeight() - 2, 1, logTable.getHeight())); logTable.scrollRectToVisible(new Rectangle(0, logTable.getHeight() - 2, 1, logTable.getHeight()));
} }
@ -319,7 +318,7 @@ public class LogListener extends VisPlugin {
Element element; Element element;
element = new Element("filter"); element = new Element("filter");
element.setText(filterText); element.setText(filterTextField.getText());
config.add(element); config.add(element);
return config; return config;
@ -329,11 +328,10 @@ public class LogListener extends VisPlugin {
for (Element element : configXML) { for (Element element : configXML) {
String name = element.getName(); String name = element.getName();
if ("filter".equals(name)) { if ("filter".equals(name)) {
filterText = element.getText(); final String str = element.getText();
EventQueue.invokeLater(new Runnable() { EventQueue.invokeLater(new Runnable() {
public void run() { public void run() {
filterTextField.setText(filterText); setFilter(str);
setFilter(filterText);
} }
}); });
} }
@ -342,10 +340,16 @@ public class LogListener extends VisPlugin {
return true; return true;
} }
private void setFilter(String text) { public String getFilter() {
return filterTextField.getText();
}
public void setFilter(String str) {
filterTextField.setText(str);
try { try {
if (text != null && text.length() > 0) { if (str != null && str.length() > 0) {
logFilter.setRowFilter(RowFilter.regexFilter(text, COLUMN_FROM, COLUMN_DATA, COLUMN_CONCAT)); logFilter.setRowFilter(RowFilter.regexFilter(str, COLUMN_FROM, COLUMN_DATA, COLUMN_CONCAT));
} else { } else {
logFilter.setRowFilter(null); logFilter.setRowFilter(null);
} }