swing/src/net/sf/xframe/swing JXTable.java,1.8,1.9

Kurt Riede <[email protected]> Sat, 02 Apr 2005 21:06:47 +0000
Newsgroups gmane.text.xml.xframe.xsddoc.devel
Message-ID <[email protected]>
Update of /cvsroot/xframe/swing/src/net/sf/xframe/swing
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16384/src/net/sf/xframe/swing

Modified Files:
	JXTable.java 
Log Message:
fix for bug [1169153] JXTable.setModel doesn't work.

Index: JXTable.java
===================================================================
RCS file: /cvsroot/xframe/swing/src/net/sf/xframe/swing/JXTable.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** JXTable.java	23 Mar 2005 15:29:50 -0000	1.8
--- JXTable.java	2 Apr 2005 21:06:45 -0000	1.9
***************
*** 329,350 ****
  
      /**
-      * Creates a default column model for a given table model.
-      *
-      * @param m the table model
-      * @return a default column model
-      */
-     private TableColumnModel createDefaultColumnModelFromModel(final TableModel m) {
-         if (m != null) {
-             TableColumnModel cm = createDefaultColumnModel();
-             for (int i = 0; i < m.getColumnCount(); i++) {
-                 TableColumn newColumn = new TableColumn(i);
-                 cm.addColumn(newColumn);
-             }
-             return cm;
-         }
-         return null;
-     }
- 
-     /**
       * Adjusts the action maps of the two tables to allow proper navigation
       * between the two tables.
--- 329,332 ----
***************
*** 1824,1853 ****
       */
      public void setModel(final TableModel dataModel) {
          lockedTable.setModel(dataModel);
          scrollTable.setModel(dataModel);
          // Check if new model has enough columns for current number of frozen columns
          if (frozenColumns > dataModel.getColumnCount()) {
!             frozenColumns = 0;
          }
!         // Remove the locked columns from the main table
!         final TableColumnModel scrollColumnModel = scrollTable.getColumnModel();
          for (int i = 0; i < frozenColumns; i++) {
              scrollColumnModel.removeColumn(scrollColumnModel.getColumn(0));
          }
!         // Remove the scrollable columns from the fixed table
!         final TableColumnModel lockedColumnModel = lockedTable.getColumnModel();
          while (lockedTable.getColumnCount() > frozenColumns) {
              lockedColumnModel.removeColumn(lockedColumnModel.getColumn(frozenColumns));
          }
-         // Add new columns to the locked table
-         for (int i = 0; i < frozenColumns; i++) {
-             lockedColumnModel.addColumn(new TableColumn(i));
-         }
-         // Add new columns to the scrollable table
-         for (int i = frozenColumns; i < dataModel.getColumnCount(); i++) {
-             scrollColumnModel.addColumn(new TableColumn(i));
-         }
-         // Add the fixed table to the scroll pane
-         lockedTable.setPreferredScrollableViewportSize(lockedTable.getPreferredSize());
      }
  
--- 1806,1836 ----
       */
      public void setModel(final TableModel dataModel) {
+         // Remove all columns from the scrollable table
+         final TableColumnModel scrollColumnModel = scrollTable.getColumnModel();
+         while (scrollColumnModel.getColumnCount() > 0) {
+             scrollColumnModel.removeColumn(scrollColumnModel.getColumn(0));
+         }
+         // Remove all columns from the locked table
+         final TableColumnModel lockedColumnModel = lockedTable.getColumnModel();
+         while (lockedTable.getColumnCount() > 0) {
+             lockedColumnModel.removeColumn(lockedColumnModel.getColumn(frozenColumns));
+         }
          lockedTable.setModel(dataModel);
          scrollTable.setModel(dataModel);
+         // Create new columns from the new data model
+         lockedTable.createDefaultColumnsFromModel();
+         scrollTable.createDefaultColumnsFromModel();
          // Check if new model has enough columns for current number of frozen columns
          if (frozenColumns > dataModel.getColumnCount()) {
!             frozenColumns = dataModel.getColumnCount();
          }
!         // Remove the locked columns from the scrollable table
          for (int i = 0; i < frozenColumns; i++) {
              scrollColumnModel.removeColumn(scrollColumnModel.getColumn(0));
          }
!         // Remove the scrollable columns from the locked table
          while (lockedTable.getColumnCount() > frozenColumns) {
              lockedColumnModel.removeColumn(lockedColumnModel.getColumn(frozenColumns));
          }
      }
  
***************
*** 2706,2708 ****
--- 2689,2699 ----
          frozenColumns++;
      }
+ 
+     /**
+      * Returns the scroll pane adjuster.
+      * @return the scroll pane adjuster
+      */
+     protected JScrollPaneAdjuster getAdjuster() {
+         return adjuster;
+     }
  }



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click