[Schmitzm-commits] r1414 - in trunk: . schmitzm-core/src/main/java/de/schmitzm/swing schmitzm-core/src/main/java/de/schmitzm/swing/event schmitzm-gt/src/main/java/de/schmitzm/geotools/gui
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Jan 27 11:51:04 CET 2011
Author: mojays
Date: 2011-01-27 11:51:02 +0100 (Thu, 27 Jan 2011)
New Revision: 1414
Added:
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/event/FilterTableKeyListener.java
Removed:
trunk/schmitzm-core/src/main/java/de/schmitzm/swing/FilterTableKeyListener.java
Modified:
trunk/release.txt
trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/SelectableFeatureTablePane.java
Log:
FilterTableKeyListener moved to schmitzm.swing.event
Modified: trunk/release.txt
===================================================================
--- trunk/release.txt 2011-01-27 09:16:10 UTC (rev 1413)
+++ trunk/release.txt 2011-01-27 10:51:02 UTC (rev 1414)
@@ -25,6 +25,9 @@
of the library. E.g. there is no need for the "big" geotools when only
using the core functionalities (schmitzm-core) or the base JFreeChart
extensions (schmitzm-jfree).
+Furthermore a union of Steve's and Martin's classes was performed. All
+classes previously located in package 'skrueger' were moved to package
+'schmitzm'.
SCHMITZM 2.4.x
Deleted: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/FilterTableKeyListener.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/FilterTableKeyListener.java 2011-01-27 09:16:10 UTC (rev 1413)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/FilterTableKeyListener.java 2011-01-27 10:51:02 UTC (rev 1414)
@@ -1,110 +0,0 @@
-package de.schmitzm.swing;
-
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.regex.Pattern;
-
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.RowFilter;
-import javax.swing.table.AbstractTableModel;
-import javax.swing.table.TableRowSorter;
-
-/**
- * Connects a {@link JTextField} with a {@link JTable} to filter the data. The
- * column it should filter are given as indices on construction.
- *
- */
-public class FilterTableKeyListener extends KeyAdapter {
-
- private final JTable table;
- private final int[] indices;
- private final JTextField jTextField;
- private Timer setRowFilterTimer;
-
- /**
- * Collects key events for 300ms, The constructor adds itself the the
- * {@link JTextField}!
- *
- * @param table
- * @param jTextField
- * @param indices
- */
- public FilterTableKeyListener(JTable table, JTextField jTextField,
- int... indices) {
- this(table, 300, jTextField, indices);
- }
-
- /**
- * The constructor adds itself the the {@link JTextField}!
- *
- * @param table
- * @param jTextField
- * @param waitToUpdateGuiMs
- * ms to wait until the table rowSorter is changed.
- * @param indices
- */
- public FilterTableKeyListener(JTable table, long waitToUpdateGuiMs,
- JTextField jTextField, int... indices) {
- this.table = table;
- this.jTextField = jTextField;
- this.indices = indices;
-
- jTextField.addKeyListener(this);
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
- String text = jTextField.getText();
- newFilterForTable(
- (TableRowSorter<AbstractTableModel>) table.getRowSorter(),
- text, indices);
- }
-
- /**
- * When a key is released, filter for the table is updated
- */
- private void newFilterForTable(
- final TableRowSorter<AbstractTableModel> sorter, String text,
- int... indices) {
- // System.out.println("\n" + text);
-
- String filter = "";
- String[] split = text.trim().split("\\s");
- for (String s : split) {
- if (s.trim().isEmpty())
- continue;
- s = Pattern.quote(s);
- s = s.substring(2, s.length() - 2);
- filter += "|.*" + s + ".*";
- }
- if (filter.length() > 0)
- filter = filter.substring(1);
-
- // If current expression doesn't parse, don't update.
- try {
- // System.out.println(filter);
- final RowFilter<AbstractTableModel, Object> rf = RowFilter
- .regexFilter("(?i)" + filter, indices);
- if (setRowFilterTimer != null)
- setRowFilterTimer.cancel();
- setRowFilterTimer = new Timer("Set rowFilter for JTable");
- setRowFilterTimer.schedule(new TimerTask() {
-
- @Override
- public void run() {
- sorter.setRowFilter(rf);
- }
- }, 300);
-
- return;
- } catch (java.util.regex.PatternSyntaxException e) {
- return;
- }
-
- // sorter.setRowFilter(null);
- }
-
-}
Added: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/event/FilterTableKeyListener.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/event/FilterTableKeyListener.java 2011-01-27 09:16:10 UTC (rev 1413)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/event/FilterTableKeyListener.java 2011-01-27 10:51:02 UTC (rev 1414)
@@ -0,0 +1,110 @@
+package de.schmitzm.swing.event;
+
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.regex.Pattern;
+
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.RowFilter;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.TableRowSorter;
+
+/**
+ * Connects a {@link JTextField} with a {@link JTable} to filter the data. The
+ * column it should filter are given as indices on construction.
+ *
+ */
+public class FilterTableKeyListener extends KeyAdapter {
+
+ private final JTable table;
+ private final int[] indices;
+ private final JTextField jTextField;
+ private Timer setRowFilterTimer;
+
+ /**
+ * Collects key events for 300ms, The constructor adds itself the the
+ * {@link JTextField}!
+ *
+ * @param table
+ * @param jTextField
+ * @param indices
+ */
+ public FilterTableKeyListener(JTable table, JTextField jTextField,
+ int... indices) {
+ this(table, 300, jTextField, indices);
+ }
+
+ /**
+ * The constructor adds itself the the {@link JTextField}!
+ *
+ * @param table
+ * @param jTextField
+ * @param waitToUpdateGuiMs
+ * ms to wait until the table rowSorter is changed.
+ * @param indices
+ */
+ public FilterTableKeyListener(JTable table, long waitToUpdateGuiMs,
+ JTextField jTextField, int... indices) {
+ this.table = table;
+ this.jTextField = jTextField;
+ this.indices = indices;
+
+ jTextField.addKeyListener(this);
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ String text = jTextField.getText();
+ newFilterForTable(
+ (TableRowSorter<AbstractTableModel>) table.getRowSorter(),
+ text, indices);
+ }
+
+ /**
+ * When a key is released, filter for the table is updated
+ */
+ private void newFilterForTable(
+ final TableRowSorter<AbstractTableModel> sorter, String text,
+ int... indices) {
+ // System.out.println("\n" + text);
+
+ String filter = "";
+ String[] split = text.trim().split("\\s");
+ for (String s : split) {
+ if (s.trim().isEmpty())
+ continue;
+ s = Pattern.quote(s);
+ s = s.substring(2, s.length() - 2);
+ filter += "|.*" + s + ".*";
+ }
+ if (filter.length() > 0)
+ filter = filter.substring(1);
+
+ // If current expression doesn't parse, don't update.
+ try {
+ // System.out.println(filter);
+ final RowFilter<AbstractTableModel, Object> rf = RowFilter
+ .regexFilter("(?i)" + filter, indices);
+ if (setRowFilterTimer != null)
+ setRowFilterTimer.cancel();
+ setRowFilterTimer = new Timer("Set rowFilter for JTable");
+ setRowFilterTimer.schedule(new TimerTask() {
+
+ @Override
+ public void run() {
+ sorter.setRowFilter(rf);
+ }
+ }, 300);
+
+ return;
+ } catch (java.util.regex.PatternSyntaxException e) {
+ return;
+ }
+
+ // sorter.setRowFilter(null);
+ }
+
+}
Modified: trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/SelectableFeatureTablePane.java
===================================================================
--- trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/SelectableFeatureTablePane.java 2011-01-27 09:16:10 UTC (rev 1413)
+++ trunk/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/SelectableFeatureTablePane.java 2011-01-27 10:51:02 UTC (rev 1414)
@@ -56,7 +56,7 @@
import org.geotools.feature.FeatureCollection;
import de.schmitzm.geotools.feature.FeatureUtil;
-import de.schmitzm.swing.FilterTableKeyListener;
+import de.schmitzm.swing.event.FilterTableKeyListener;
import de.schmitzm.swing.table.SelectionTableModel;
/**
More information about the Schmitzm-commits
mailing list