[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] Proposed patch: JTable and DefaultTableColumnModel
From: |
David Gilbert |
Subject: |
[cp-patches] Proposed patch: JTable and DefaultTableColumnModel |
Date: |
Fri, 01 Jul 2005 18:04:58 +0000 |
User-agent: |
Mozilla Thunderbird 1.0.2 (X11/20050426) |
This patch implements the isCellEditable() method in JTable and fixes a
problem I noticed in DefaultTableColumnModel's moveColumn() method while
I was writing the Mauve tests for the new method:
2005-07-01 David Gilbert <address@hidden>
* javax/swing/JTable.java
(convertColumnIndexToModel): remove check for > columnCount and let
exception happen,
(isCellEditable): implemented.
* javax/swing/table/DefaultTableColumnModel.java
(moveColumn): move the column, don't swap it. Also added argument
checks.
I've committed Mauve tests to back up these changes. OK to commit?
Regards,
Dave
Index: javax/swing/JTable.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JTable.java,v
retrieving revision 1.28
diff -u -r1.28 JTable.java
--- javax/swing/JTable.java 30 Jun 2005 20:35:00 -0000 1.28
+++ javax/swing/JTable.java 1 Jul 2005 16:52:33 -0000
@@ -1027,8 +1027,6 @@
{
if (vc < 0)
return vc;
- else if (vc > getColumnCount())
- return -1;
else
return columnModel.getColumn(vc).getModelIndex();
}
@@ -2074,6 +2072,20 @@
dataModel.setValueAt(value, row, convertColumnIndexToModel(column));
}
+ /**
+ * Returns <code>true</code> if the specified cell is editable, and
+ * <code>false</code> otherwise.
+ *
+ * @param row the row index.
+ * @param column the column index.
+ *
+ * @return A boolean.
+ */
+ public boolean isCellEditable(int row, int column)
+ {
+ return dataModel.isCellEditable(row, convertColumnIndexToModel(column));
+ }
+
public TableColumn getColumn(Object identifier)
{
return columnModel.getColumn(columnModel.getColumnIndex(identifier));
Index: javax/swing/table/DefaultTableColumnModel.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/javax/swing/table/DefaultTableColumnModel.java,v
retrieving revision 1.12
diff -u -r1.12 DefaultTableColumnModel.java
--- javax/swing/table/DefaultTableColumnModel.java 7 Jan 2005 18:32:49
-0000 1.12
+++ javax/swing/table/DefaultTableColumnModel.java 1 Jul 2005 16:52:35
-0000
@@ -147,10 +147,14 @@
*/
public void moveColumn(int i, int j)
{
- Object tmp = tableColumns.get(i);
- tableColumns.set(i, tableColumns.get(j));
- tableColumns.set(j, tmp);
- fireColumnAdded(new TableColumnModelEvent(this,i,j));
+ int columnCount = getColumnCount();
+ if (i < 0 || i >= columnCount)
+ throw new IllegalArgumentException("Index 'i' out of range.");
+ if (j < 0 || j >= columnCount)
+ throw new IllegalArgumentException("Index 'j' out of range.");
+ Object column = tableColumns.remove(i);
+ tableColumns.add(j, column);
+ fireColumnAdded(new TableColumnModelEvent(this, i, j));
}
/**
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] Proposed patch: JTable and DefaultTableColumnModel,
David Gilbert <=