[Schmitzm-commits] r67 - in trunk/src/schmitzm: geotools/gui swing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Apr 20 11:55:19 CEST 2009


Author: mojays
Date: 2009-04-20 11:55:19 +0200 (Mon, 20 Apr 2009)
New Revision: 67

Added:
   trunk/src/schmitzm/swing/SortableJTable.java
Removed:
   trunk/src/schmitzm/swing/SortedJTable.java
Modified:
   trunk/src/schmitzm/geotools/gui/FeatureTablePane.java
Log:
SortedJTable renamed to SortableJTable

Modified: trunk/src/schmitzm/geotools/gui/FeatureTablePane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/FeatureTablePane.java	2009-04-19 20:38:56 UTC (rev 66)
+++ trunk/src/schmitzm/geotools/gui/FeatureTablePane.java	2009-04-20 09:55:19 UTC (rev 67)
@@ -45,7 +45,7 @@
 import schmitzm.geotools.feature.FeatureUtil;
 import schmitzm.swing.JPanel;
 import schmitzm.swing.MultiSplitPane;
-import schmitzm.swing.SortedJTable;
+import schmitzm.swing.SortableJTable;
 import schmitzm.swing.SwingUtil;
 import schmitzm.swing.table.SelectionTableModel;
 import skrueger.geotools.StyledFeatureCollectionTableModel;
@@ -64,7 +64,7 @@
  */
 public class FeatureTablePane extends JPanel {
   /** Tabelle in der die Features angezeigt werden. */
-  protected SortedJTable featuresTable = null;
+  protected SortableJTable featuresTable = null;
   /** Tabellen-Modell der Feature-Tabelle. */
   protected FeatureCollectionTableModel featuresTableModel = null;
   /** Preview-Bereich fuer die in der Tabelle selektierten Features. */
@@ -190,7 +190,7 @@
     // Tabelle fuer FeatureCollection
 //    featuresTable = new JTable();
 //    featuresTable.setAutoCreateRowSorter(true);
-    featuresTable = new SortedJTable();
+    featuresTable = new SortableJTable();
     featuresTable.setModel( new SelectionTableModel(featuresTableModel, featuresTable) );
     featuresTable.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
     featuresTable.setColumnSelectionAllowed(false);

Added: trunk/src/schmitzm/swing/SortableJTable.java
===================================================================
--- trunk/src/schmitzm/swing/SortableJTable.java	2009-04-19 20:38:56 UTC (rev 66)
+++ trunk/src/schmitzm/swing/SortableJTable.java	2009-04-20 09:55:19 UTC (rev 67)
@@ -0,0 +1,187 @@
+/** SCHMITZM - This file is part of the java library of Martin O.J. Schmitz (SCHMITZM)
+
+    This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
+    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+    You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
+
+    Diese Bibliothek ist freie Software; Sie dürfen sie unter den Bedingungen der GNU Lesser General Public License, wie von der Free Software Foundation veröffentlicht, weiterverteilen und/oder modifizieren; entweder gemäß Version 2.1 der Lizenz oder (nach Ihrer Option) jeder späteren Version.
+    Diese Bibliothek wird in der Hoffnung weiterverbreitet, daß sie nützlich sein wird, jedoch OHNE IRGENDEINE GARANTIE, auch ohne die implizierte Garantie der MARKTREIFE oder der VERWENDBARKEIT FÜR EINEN BESTIMMTEN ZWECK. Mehr Details finden Sie in der GNU Lesser General Public License.
+    Sie sollten eine Kopie der GNU Lesser General Public License zusammen mit dieser Bibliothek erhalten haben; falls nicht, schreiben Sie an die Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA.
+ **/
+package schmitzm.swing;
+
+import java.util.Vector;
+
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.table.TableColumnModel;
+import javax.swing.table.TableModel;
+
+/**
+ * Extends the {@link JTable} with automatic sort functionality.
+ * This class adds the following methods so that manually calling
+ * {@link JTable#convertRowIndexToModel(int)} and {@link JTable#convertRowIndexToView(int)}
+ * is not necessary:
+ * <ul>
+ *   <li>{@link #getEditingModelRow()}</li>
+ *   <li>{@link #getSelectedModelRow()}</li>
+ *   <li>{@link #getSelectedModelRows()}</li>
+ *   <li>{@link #addModelRowSelectionInterval(int, int)}</li>
+ *   <li>{@link #setModelRowSelectionInterval(int, int)}</li>
+ *   <li>{@link #removeRowSelectionInterval(int, int)}</li>
+ *   <li>{@link #changeModelSelection(int, int, boolean, boolean)}</li>
+ * </ul>   
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
+ */
+public class SortableJTable extends JTable {
+
+  /**
+   * Creates an empty table.
+   */
+  public SortableJTable() {
+    super();
+    initTable();
+  }
+
+  /**
+   * Creates an empty table.
+   */
+  public SortableJTable(int numRows, int numColumns) {
+    super(numRows, numColumns);
+    initTable();
+  }
+
+  /**
+   * Creates a new table.
+   */
+  public SortableJTable(Object[][] rowData, Object[] columnNames) {
+    super(rowData, columnNames);
+    initTable();
+  }
+
+  /**
+   * Creates a new table.
+   */
+  public SortableJTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm) {
+    super(dm, cm, sm);
+    initTable();
+  }
+
+  /**
+   * Creates a new table.
+   */
+  public SortableJTable(TableModel dm, TableColumnModel cm) {
+    super(dm, cm);
+    initTable();
+  }
+
+  /**
+   * Creates a new table.
+   */
+  public SortableJTable(TableModel dm) {
+    super(dm);
+    initTable();
+  }
+
+  /**
+   * Creates a new table.
+   */
+  public SortableJTable(Vector rowData, Vector columnNames) {
+    super(rowData, columnNames);
+    initTable();
+  }
+  
+  
+  /**
+   * Called by every constructor to initialize the extended
+   * functionalities.
+   */
+  protected void initTable() {
+    setAutoCreateRowSorter(true);
+  }
+  
+  /**
+   * Returns the index of the currently edited row according to
+   * the table model.
+   */
+  public int getEditingModelRow() {
+    return convertRowIndexToModel(getEditingRow());
+  }
+
+  /**
+   * Returns the index of the selected row according to
+   * the table model.
+   */
+  public int getSelectedModelRow() {
+    return convertRowIndexToModel(getSelectedRow());
+  }
+
+  /**
+   * Returns the indices of the selected rows according to
+   * the table model.
+   */
+  public int[] getSelectedModelRows() {
+    int[] rows = super.getSelectedRows();
+    for (int i=0; i<rows.length; i++)
+      rows[i] = convertRowIndexToModel(rows[i]);
+    return rows;
+  }
+  
+  /**
+   * Changes the selected cells.
+   * @param row row index
+   * @param col column index
+   * @param toggle see {@link #changeSelection(int, int, boolean, boolean)}
+   * @param extend see {@link #changeSelection(int, int, boolean, boolean)}
+   */
+  public void changeModelSelection(int row, int col, boolean toggle, boolean extend) {
+    row = convertRowIndexToView(row);
+    changeSelection(row, col, toggle, extend);
+  }
+  
+  /**
+   * Extends the current selection by the given index interval
+   * according to the table model.
+   * @param index0 start index
+   * @param index1 end index (inclusive)
+   */
+  public void addModelRowSelectionInterval(int index0, int index1) {
+    for (int i=index0; i<=index1; i++) {
+      int viewIdx = convertRowIndexToView(i);
+      addRowSelectionInterval(viewIdx, viewIdx);
+    }
+  }
+
+  /**
+   * Sets the current selection to the given index interval
+   * according to the table model.
+   * @param index0 start index
+   * @param index1 end index (inclusive)
+   */
+  public void setModelRowSelectionInterval(int index0, int index1) {
+    clearSelection();
+    for (int i=index0; i<=index1; i++) {
+      int viewIdx = convertRowIndexToView(i);
+      addRowSelectionInterval(viewIdx, viewIdx);
+    }
+  }
+  
+  /**
+   * Removes the given index interval of rows from the current selection
+   * according to the table model.
+   * @param index0 start index
+   * @param index1 end index (inclusive)
+   */
+  public void removeModelRowSelectionInterval(int index0, int index1) {
+    for (int i=index0; i<=index1; i++) {
+      int viewIdx = convertRowIndexToView(i);
+      removeRowSelectionInterval(viewIdx, viewIdx);
+    }
+  }
+  
+//  @Override
+//  public void clearSelection() {
+//    super.clearSelection();
+//  }
+
+}

Deleted: trunk/src/schmitzm/swing/SortedJTable.java
===================================================================
--- trunk/src/schmitzm/swing/SortedJTable.java	2009-04-19 20:38:56 UTC (rev 66)
+++ trunk/src/schmitzm/swing/SortedJTable.java	2009-04-20 09:55:19 UTC (rev 67)
@@ -1,187 +0,0 @@
-/** SCHMITZM - This file is part of the java library of Martin O.J. Schmitz (SCHMITZM)
-
-    This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
-    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-    You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
-
-    Diese Bibliothek ist freie Software; Sie dürfen sie unter den Bedingungen der GNU Lesser General Public License, wie von der Free Software Foundation veröffentlicht, weiterverteilen und/oder modifizieren; entweder gemäß Version 2.1 der Lizenz oder (nach Ihrer Option) jeder späteren Version.
-    Diese Bibliothek wird in der Hoffnung weiterverbreitet, daß sie nützlich sein wird, jedoch OHNE IRGENDEINE GARANTIE, auch ohne die implizierte Garantie der MARKTREIFE oder der VERWENDBARKEIT FÜR EINEN BESTIMMTEN ZWECK. Mehr Details finden Sie in der GNU Lesser General Public License.
-    Sie sollten eine Kopie der GNU Lesser General Public License zusammen mit dieser Bibliothek erhalten haben; falls nicht, schreiben Sie an die Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA.
- **/
-package schmitzm.swing;
-
-import java.util.Vector;
-
-import javax.swing.JTable;
-import javax.swing.ListSelectionModel;
-import javax.swing.table.TableColumnModel;
-import javax.swing.table.TableModel;
-
-/**
- * Extends the {@link JTable} with automatic sort functionality.
- * This class adds the following methods so that manually calling
- * {@link JTable#convertRowIndexToModel(int)} and {@link JTable#convertRowIndexToView(int)}
- * is not necessary:
- * <ul>
- *   <li>{@link #getEditingModelRow()}</li>
- *   <li>{@link #getSelectedModelRow()}</li>
- *   <li>{@link #getSelectedModelRows()}</li>
- *   <li>{@link #addModelRowSelectionInterval(int, int)}</li>
- *   <li>{@link #setModelRowSelectionInterval(int, int)}</li>
- *   <li>{@link #removeRowSelectionInterval(int, int)}</li>
- *   <li>{@link #changeModelSelection(int, int, boolean, boolean)}</li>
- * </ul>   
- * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
- */
-public class SortedJTable extends JTable {
-
-  /**
-   * Creates an empty table.
-   */
-  public SortedJTable() {
-    super();
-    initTable();
-  }
-
-  /**
-   * Creates an empty table.
-   */
-  public SortedJTable(int numRows, int numColumns) {
-    super(numRows, numColumns);
-    initTable();
-  }
-
-  /**
-   * Creates a new table.
-   */
-  public SortedJTable(Object[][] rowData, Object[] columnNames) {
-    super(rowData, columnNames);
-    initTable();
-  }
-
-  /**
-   * Creates a new table.
-   */
-  public SortedJTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm) {
-    super(dm, cm, sm);
-    initTable();
-  }
-
-  /**
-   * Creates a new table.
-   */
-  public SortedJTable(TableModel dm, TableColumnModel cm) {
-    super(dm, cm);
-    initTable();
-  }
-
-  /**
-   * Creates a new table.
-   */
-  public SortedJTable(TableModel dm) {
-    super(dm);
-    initTable();
-  }
-
-  /**
-   * Creates a new table.
-   */
-  public SortedJTable(Vector rowData, Vector columnNames) {
-    super(rowData, columnNames);
-    initTable();
-  }
-  
-  
-  /**
-   * Called by every constructor to initialize the extended
-   * functionalities.
-   */
-  protected void initTable() {
-    setAutoCreateRowSorter(true);
-  }
-  
-  /**
-   * Returns the index of the currently edited row according to
-   * the table model.
-   */
-  public int getEditingModelRow() {
-    return convertRowIndexToModel(getEditingRow());
-  }
-
-  /**
-   * Returns the index of the selected row according to
-   * the table model.
-   */
-  public int getSelectedModelRow() {
-    return convertRowIndexToModel(getSelectedRow());
-  }
-
-  /**
-   * Returns the indices of the selected rows according to
-   * the table model.
-   */
-  public int[] getSelectedModelRows() {
-    int[] rows = super.getSelectedRows();
-    for (int i=0; i<rows.length; i++)
-      rows[i] = convertRowIndexToModel(rows[i]);
-    return rows;
-  }
-  
-  /**
-   * Changes the selected cells.
-   * @param row row index
-   * @param col column index
-   * @param toggle see {@link #changeSelection(int, int, boolean, boolean)}
-   * @param extend see {@link #changeSelection(int, int, boolean, boolean)}
-   */
-  public void changeModelSelection(int row, int col, boolean toggle, boolean extend) {
-    row = convertRowIndexToView(row);
-    changeSelection(row, col, toggle, extend);
-  }
-  
-  /**
-   * Extends the current selection by the given index interval
-   * according to the table model.
-   * @param index0 start index
-   * @param index1 end index (inclusive)
-   */
-  public void addModelRowSelectionInterval(int index0, int index1) {
-    for (int i=index0; i<=index1; i++) {
-      int viewIdx = convertRowIndexToView(i);
-      addRowSelectionInterval(viewIdx, viewIdx);
-    }
-  }
-
-  /**
-   * Sets the current selection to the given index interval
-   * according to the table model.
-   * @param index0 start index
-   * @param index1 end index (inclusive)
-   */
-  public void setModelRowSelectionInterval(int index0, int index1) {
-    clearSelection();
-    for (int i=index0; i<=index1; i++) {
-      int viewIdx = convertRowIndexToView(i);
-      addRowSelectionInterval(viewIdx, viewIdx);
-    }
-  }
-  
-  /**
-   * Removes the given index interval of rows from the current selection
-   * according to the table model.
-   * @param index0 start index
-   * @param index1 end index (inclusive)
-   */
-  public void removeModelRowSelectionInterval(int index0, int index1) {
-    for (int i=index0; i<=index1; i++) {
-      int viewIdx = convertRowIndexToView(i);
-      removeRowSelectionInterval(viewIdx, viewIdx);
-    }
-  }
-  
-//  @Override
-//  public void clearSelection() {
-//    super.clearSelection();
-//  }
-
-}



More information about the Schmitzm-commits mailing list