[kaffe] CVS kaffe (robilad): Resynced with GNU Classpath: JTable fixes

Kaffe CVS cvs-commits at kaffe.org
Wed Dec 22 18:57:54 PST 2004


PatchSet 5717 
Date: 2004/12/23 02:53:48
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Classpath: JTable fixes

Members: 
	ChangeLog:1.3262->1.3263 
	libraries/javalib/javax/swing/JTable.java:1.11->1.12 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3262 kaffe/ChangeLog:1.3263
--- kaffe/ChangeLog:1.3262	Thu Dec 23 02:43:07 2004
+++ kaffe/ChangeLog	Thu Dec 23 02:53:48 2004
@@ -1,5 +1,44 @@
 2004-12-22  Dalibor Topic  <robilad at kaffe.org>
 
+	* libraries/javalib/javax/swing/JTable.java:
+	Resynced with GNU Classpath.
+	
+	2004-12-22  Michael Koch  <konqueror at gmx.de>
+	    Olga Rodimina  <rodimina at redhat.com>
+
+	* javax/swing/JTable.java
+	(editorComp): New field.
+	(JTable): Initialize local variables and call updateUI
+	(selectionBackground): Make protected.
+	(selectionForeground): Likewise.
+	(initializeLocalVars): Create default editors and renderers,
+	initialize editingColumn, editingRow variables.
+	(createDefaultEditors): New Method.
+	(createDefaultRenderers): Likewise.
+	(createDefaultListSelectionModel): Removed
+	(createDefaultSelectionModel): New Method.
+	(createDefaultTableHeader): Likewise
+	(removeColumn): Likewise.
+	(getEditingColumn): Likewise.
+	(setEditingColumn): Likewise.
+	(getEditingRow): Likewise.
+	(setEditingRow): Likewise.
+	(getEditorComponent): Likewise.
+	(isEditing): Likewise.
+	(setDefaultEditor): Likewise.
+	(addColumnSelectionInterval): Likewise.
+	(addRowSelectionInterval): Likewise.
+	(setColumnSelectionInterval): Likewise.
+	(setRowSelectionInterval): Likewise.
+	(removeColumnSelectionInterval): Likewise.
+	(removeRowSelectionInterval): Likewise.
+	(isColumnSelected): Likewise.
+	(isRowSelected): Likewise.
+	(isCellSelected): Likewise.
+	(selectAll): Likewise.
+
+2004-12-22  Dalibor Topic  <robilad at kaffe.org>
+
 	* libraries/javalib/javax/swing/plaf/metal/MetalTheme.java
 	libraries/javalib/javax/swing/plaf/metal/DefaultMetalTheme.java,
 	libraries/javalib/javax/swing/plaf/metal/MetalLookAndFeel.java:
Index: kaffe/libraries/javalib/javax/swing/JTable.java
diff -u kaffe/libraries/javalib/javax/swing/JTable.java:1.11 kaffe/libraries/javalib/javax/swing/JTable.java:1.12
--- kaffe/libraries/javalib/javax/swing/JTable.java:1.11	Fri Dec 17 08:48:15 2004
+++ kaffe/libraries/javalib/javax/swing/JTable.java	Thu Dec 23 02:53:50 2004
@@ -42,6 +42,7 @@
 import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.Rectangle;
+import java.util.Date;
 import java.util.Hashtable;
 import java.util.Vector;
 
@@ -113,14 +114,35 @@
   /**
    * A table mapping {@link java.lang.Class} objects to 
    * {@link TableCellEditor} objects. This table is consulted by the 
-   * 
+   * FIXME
    */
   protected Hashtable defaultEditorsByColumnClass;
+
+  /**
+   * A table mapping {@link java.lang.Class} objects to 
+   * {@link TableCellEditor} objects. This table is consulted by the 
+   * FIXME
+   */
   protected Hashtable defaultRenderersByColumnClass;
+
+  /**
+   * The column that is edited, -1 if the table is not edited currently.
+   */
   protected int editingColumn;
+
+  /**
+   * The row that is edited, -1 if the table is not edited currently.
+   */
   protected int editingRow;
 
   /**
+   * The component that is used for editing.
+   * <code>null</code> if the table is not editing currently.
+   *
+   */
+  protected transient Component editorComp;
+
+  /**
    * Whether or not the table should automatically compute a matching
    * {@link TableColumnModel} and assign it to the {@link #columnModel}
    * property when the {@link #dataModel} property is changed. 
@@ -163,8 +185,8 @@
    * 
    * @see #setRowMargin()
    * @see #getRowHeight()
-   * @see #getInterCellSpacing()
-   * @see #setInterCellSpacing()
+   * @see #getIntercellSpacing()
+   * @see #setIntercellSpacing()
    * @see TableColumnModel#getColumnMargin()
    * @see TableColumnModel#setColumnMargin()
    */
@@ -285,7 +307,7 @@
    * @see #setSelectionBackground()
    * @see #getSelectionBackground()
    */
-  Color selectionBackground;
+  protected Color selectionBackground;
 
   /**
    * The name carried in property change events when the {@link
@@ -301,7 +323,7 @@
    * @see #setSelectionForeground()
    * @see #getSelectionForeground()
    */
-  Color selectionForeground;
+  protected Color selectionForeground;
 
   /**
    * The name carried in property change events when the
@@ -386,11 +408,17 @@
   public JTable (TableModel dm, TableColumnModel cm, ListSelectionModel sm)
   {
     this.dataModel = dm == null ? createDefaultDataModel() : dm;
-    setSelectionModel(sm == null ? createDefaultListSelectionModel() : sm);
+    setSelectionModel(sm == null ? createDefaultSelectionModel() : sm);
 
     this.columnModel = cm;
+    initializeLocalVars();
+    updateUI();
+  }    
+
+  protected void initializeLocalVars()
+  {
     this.autoCreateColumnsFromModel = false;
-    if (cm == null)
+    if (columnModel == null)
       {
         this.autoCreateColumnsFromModel = true;
         createColumnsFromModel();
@@ -398,7 +426,10 @@
     this.columnModel.addColumnModelListener(this);
     
     this.defaultRenderersByColumnClass = new Hashtable();
+    createDefaultRenderers();
+
     this.defaultEditorsByColumnClass = new Hashtable();
+    createDefaultEditors();
 
     this.autoResizeMode = AUTO_RESIZE_ALL_COLUMNS;
     this.rowHeight = 16;
@@ -410,9 +441,10 @@
     this.preferredScrollableViewportSize = new Dimension(450,400);
     this.showHorizontalLines = true;
     this.showVerticalLines = true;
+    this.editingColumn = -1;
+    this.editingRow = -1;
     setIntercellSpacing(new Dimension(1,1));
-    setTableHeader(new JTableHeader(columnModel));
-    updateUI();
+    setTableHeader(createDefaultTableHeader());
   }
 
   /**
@@ -436,6 +468,16 @@
     
     columnModel.addColumn(column);
   }
+
+  protected void createDefaultEditors()
+  {
+    //FIXME: Create the editor object.
+  }
+
+  protected void createDefaultRenderers()
+  {
+    //FIXME: Create the renderer object.
+  }
   
   /**
    * @deprecated 1.0.2, replaced by <code>new JScrollPane(JTable)</code>
@@ -444,7 +486,7 @@
   {
     return new JScrollPane(table);
   }
- 
+
   protected TableColumnModel createDefaultColumnModel()
   {
     return new DefaultTableColumnModel();
@@ -455,11 +497,16 @@
     return new DefaultTableModel();
   }
 
-  protected ListSelectionModel createDefaultListSelectionModel()
+  protected ListSelectionModel createDefaultSelectionModel()
   {
     return new DefaultListSelectionModel();
   }
 
+  protected JTableHeader createDefaultTableHeader()
+  {
+    return new JTableHeader(columnModel);
+  }
+ 
   private void createColumnsFromModel()
   {
     if (dataModel == null)
@@ -667,6 +714,7 @@
       return (TableCellEditor) defaultEditorsByColumnClass.get(columnClass);
     else
       {
+	// FIXME: We have at least an editor for Object.class in our defaults.
         TableCellEditor r = new DefaultCellEditor(new JTextField());
         defaultEditorsByColumnClass.put(columnClass, r);
         return r;
@@ -1083,6 +1131,12 @@
     return tableHeader;
   }
 
+  public void removeColumn(TableColumn column)
+  {
+    // FIXME: Implement me.
+    throw new Error("not implemented");
+  }
+
   /**
    * Set the value of the {@link #autoCreateColumnsFromModel} property.
    *
@@ -1612,5 +1666,118 @@
   public String getColumnName(int column)
   {
     return dataModel.getColumnName(column);
+  }
+
+  public int getEditingColumn()
+  {
+    return editingColumn;
+  }
+
+  public void setEditingColumn(int column)
+  {
+    editingColumn = column;
+  }
+  
+  public int getEditingRow()
+  {
+    return editingRow;
+  }
+
+  public void setEditingRow(int column)
+  {
+    editingRow = column;
+  }
+  
+  public Component getEditorComponent()
+  {
+    return editorComp;
+  }
+  
+  public boolean isEditing()
+  {
+    return editorComp != null;
+  }
+
+  public void setDefaultEditor(Class columnClass, TableCellEditor editor)
+  {
+    if (editor != null)
+      defaultEditorsByColumnClass.put(columnClass, editor);
+    else
+      defaultEditorsByColumnClass.remove(columnClass);
+  }
+
+  public void addColumnSelectionInterval(int index0, int index1)
+  {
+    if ((index0 < 0 || index0 > (getColumnCount()-1)
+         || index1 < 0 || index1 > (getColumnCount()-1)))
+      throw new IllegalArgumentException("Column index out of range.");
+    
+    getColumnModel().getSelectionModel().addSelectionInterval(index0, index1);
+  }
+  
+  public void addRowSelectionInterval(int index0, int index1)
+  {            
+    if ((index0 < 0 || index0 > (getRowCount()-1)
+         || index1 < 0 || index1 > (getRowCount()-1)))
+      throw new IllegalArgumentException("Row index out of range.");
+      	
+    getSelectionModel().addSelectionInterval(index0, index1);
+  }
+  
+  public void setColumnSelectionInterval(int index0, int index1)
+  {
+    if ((index0 < 0 || index0 > (getColumnCount()-1)
+         || index1 < 0 || index1 > (getColumnCount()-1)))
+      throw new IllegalArgumentException("Column index out of range.");
+
+    getColumnModel().getSelectionModel().setSelectionInterval(index0, index1);
+  }
+  
+  public void setRowSelectionInterval(int index0, int index1)
+  {    
+    if ((index0 < 0 || index0 > (getRowCount()-1)
+         || index1 < 0 || index1 > (getRowCount()-1)))
+      throw new IllegalArgumentException("Row index out of range.");
+
+    getSelectionModel().setSelectionInterval(index0, index1);
+  }
+  
+  public void removeColumnSelectionInterval(int index0, int index1)  
+  {
+    if ((index0 < 0 || index0 > (getColumnCount()-1)
+         || index1 < 0 || index1 > (getColumnCount()-1)))
+      throw new IllegalArgumentException("Column index out of range.");
+
+    getColumnModel().getSelectionModel().removeSelectionInterval(index0, index1);
+  }
+  
+  public void removeRowSelectionInterval(int index0, int index1)
+  {
+    if ((index0 < 0 || index0 > (getRowCount()-1)
+         || index1 < 0 || index1 > (getRowCount()-1)))
+      throw new IllegalArgumentException("Row index out of range.");
+
+    getSelectionModel().removeSelectionInterval(index0, index1);
+  }
+  
+  public boolean isColumnSelected(int column)
+  {
+    return getColumnModel().getSelectionModel().isSelectedIndex(column);
+  }
+
+  public boolean isRowSelected(int row)
+  {
+    return getSelectionModel().isSelectedIndex(row);
+  }
+
+  public boolean isCellSelected(int row, int column)
+  {
+    return isRowSelected(row) && isColumnSelected(column);
+  }
+  
+  public void selectAll()
+  {
+    setColumnSelectionInterval(0, getColumnCount() - 1);
+    setRowSelectionInterval(0, getRowCount() - 1);
   }
 }




More information about the kaffe mailing list