This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Patch: javax.swing.table.AbstractTableModel


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list,


I commited the attached patch to merge 
javax.swing.table.AbstractTableModel with classpath again.


Michael
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/e/IuWSOgCCdjSDsRAkRNAJ97B7kNxe9nY0Nt/1sZ7zp0rGoeTgCfXiuP
LM77GjDmACWVNVR90PCZZfY=
=beH+
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2205
diff -u -b -B -r1.2205 ChangeLog
--- ChangeLog	29 Sep 2003 21:13:52 -0000	1.2205
+++ ChangeLog	2 Oct 2003 09:33:39 -0000
@@ -1,3 +1,28 @@
+2003-10-02  Michael Koch  <konqueror@gmx.de>
+
+	* javax/swing/table/AbstractTableModel.java
+	(findColumnName): Prevent from NullPointerException if argument
+	columnName is null.
+
+2003-10-02  Michael Koch  <konqueror@gmx.de>
+
+	* javax/swing/table/AbstractTableModel.java:
+	This patch is based on a patch done by Arnaud Vandyck
+	<arnaud.vandyck@ulg.ac.be>.
+	(getColumnName): Fixed method documentation.
+	(findColumn): Likewise.
+	(getColumnClass): Likewise.
+	(isCellEditable): Likewise.
+	(setValueAt): Likewise.
+	(addTableModelListener): Likewise.
+	(removeTableModelListener): Likewise.
+	(getTableModelListeners): New method.
+
+2003-10-02  Michael Koch  <konqueror@gmx.de>
+
+	* javax/swing/table/AbstractTableModel.java:
+	Reformated.
+
 2003-09-29  Tom Tromey  <tromey@redhat.com>
 
 	PR libgcj/10596:
Index: javax/swing/table/AbstractTableModel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/table/AbstractTableModel.java,v
retrieving revision 1.3
diff -u -b -B -r1.3 AbstractTableModel.java
--- javax/swing/table/AbstractTableModel.java	11 Jun 2003 13:20:41 -0000	1.3
+++ javax/swing/table/AbstractTableModel.java	2 Oct 2003 09:33:39 -0000
@@ -46,53 +46,37 @@
 
 /**
  * AbstractTableModel
+ * 
  * @author Andrew Selkirk
  */
 public abstract class AbstractTableModel implements TableModel, Serializable
 {
   static final long serialVersionUID = -5798593159423650347L;
 
-	//-------------------------------------------------------------
-	// Variables --------------------------------------------------
-	//-------------------------------------------------------------
-
 	/**
 	 * listenerList
 	 */
 	protected EventListenerList listenerList = new EventListenerList();
 
-
-	//-------------------------------------------------------------
-	// Initialization ---------------------------------------------
-	//-------------------------------------------------------------
-
 	/**
 	 * Constructor AbstractTableModel
 	 */
-	public AbstractTableModel() {
+  public AbstractTableModel()
+  {
 		// TODO
-	} // AbstractTableModel()
-
-
-	//-------------------------------------------------------------
-	// Methods ----------------------------------------------------
-	//-------------------------------------------------------------
+  }
 
 	/**
-	 * getColumnName
-	 * @param value0 TODO
-	 * @returns String
+   * Get the name of the column for this index. If you do not override
+   * this methode, you'll get something like: 0, A; 1, B; ...; AA; AB;
+   * ...
+   *
+   * @param columnIndex The index of the column.
+   *
+   * @return The name of the column.
 	 */
-	public String getColumnName(int columnIndex) {
-
-		// Variables
-		int		index;
-		int		left;
-		int		base;
-		int		multiplier;
-		StringBuffer	buffer;
-		boolean		foundFirst;
-
+  public String getColumnName (int columnIndex)
+  {
 		// Ok, this is not the best solution in the world
 		// and it does produce wrong answers starting 1378
 		// but it's a start.  I sure hope there is a more
@@ -105,211 +89,247 @@
 		// much simplier and works for all values...I'll
 		// be adding it soon...
 
-		// Process Exponent levels
-		buffer = new StringBuffer();
-		left = columnIndex;
-		foundFirst = false;
-		for (index = 6; index >= 0; index--) {
-			base = (int) (Math.pow(26, index));
-			if (index > 1) {
-				base = base + (int) (Math.pow(26, index - 1));
-			}
-			if (base <= left) {
-				multiplier = left / base;
-				if (foundFirst == false && index > 0) {
-					buffer.append((char) (multiplier + 64)); 
-				} else {
-					buffer.append((char) (multiplier + 65));
+    StringBuffer buffer = new StringBuffer();
+    int left = columnIndex;
+    boolean foundFirst = false;
+    
+    // Process Exponent levels.
+    for (int index = 6; index >= 0; index--)
+      {
+        int base = (int) (Math.pow (26, index));
+        
+        if (index > 1)
+          {
+            base = base + (int) (Math.pow (26, index - 1));
+          }
+        
+        if (base <= left)
+          {
+            int multiplier = left / base;
+            
+            if (foundFirst == false
+                && index > 0)
+              {
+                buffer.append ((char) (multiplier + 64));
 				}
+            else
+              {
+                buffer.append ((char) (multiplier + 65));
+              }
+            
 				left = left - (base * multiplier);
 				foundFirst = true;
-			} else if (foundFirst == true || index == 0) {
+          }
+        else if (foundFirst == true
+                 || index == 0)
+          {
 				buffer.append('A');
 			}
-		} // for
+    }
 
-		// Return Column Name
+    // Return column name.
 		return buffer.toString();
-
-	} // getColumnName()
+  }
 
 	/**
-	 * findColumn
-	 * @param value0 TODO
-	 * @returns int
-	 */
-	public int findColumn(String columnName) {
-
-		// Variables
-		int		index;
-		String		name;
-		int		count;
+   * Return the index of the given name.
+   *
+   * @param columnName The name of the column.
+   *
+   * @return The index of the column, -1 if not found.
+   */
+  public int findColumn (String columnName)
+  {
+    int count = getColumnCount();
+    
+    for (int index = 0; index < count; index++)
+      {
+        String name = getColumnName (index);
 
-		// Process Columns
-		count = getColumnCount();
-		for (index = 0; index < count; index++) {
-			name = getColumnName(index);
-			if (columnName.equals(name) == true) {
+        if (name.equals (columnName))
 				return index;
-			} // if
-		} // for
+    }
 
-		// Unable to Locate
+    // Unable to locate.
 		return -1;
-
-	} // findColumn()
+  }
 
 	/**
-	 * getColumnClass
-	 * @param value0 TODO
-	 * @returns Class
+   * Returns the class of a comlumn.
+   *
+   * @param columnIndex The index of the column.
+   *
+   * @return The class type of the column.
 	 */
-	public Class getColumnClass(int columnIndex) {
+  public Class getColumnClass (int columnIndex)
+  {
 		return Object.class;
-	} // getColumnClass()
+  }
 
 	/**
-	 * isCellEditable
-	 * @param value0 TODO
-	 * @param value1 TODO
-	 * @returns boolean
+   * Tells whether a cell is editable.
+   *
+   * @param rowIndex The row of the cell.
+   * @param columnIndex The index of the cell.
+   *
+   * @return True if cell is editable.
 	 */
-	public boolean isCellEditable(int rowIndex, int columnIndex) {
+  public boolean isCellEditable (int rowIndex, int columnIndex)
+  {
 		return false;
-	} // isCellEditable()
+  }
 
 	/**
-	 * setValueAt
-	 * @param value0 TODO
-	 * @param value1 TODO
-	 * @param value2 TODO
+   * Sets a cell to a value.
+   *
+   * @param value New value of cell.
+   * @param rowIndex The row of the cell.
+   * @param columnIndex The column of the cell.
 	 */
-	public void setValueAt(Object value, int rowIndex, int columnIndex) {
+  public void setValueAt (Object value, int rowIndex, int columnIndex)
+  {
 		// Do nothing...
-	} // setValueAt()
+  }
 
 	/**
-	 * addTableModelListener
-	 * @param value0 TODO
-	 */
-	public void addTableModelListener(TableModelListener listener) {
-		listenerList.add(TableModelListener.class, listener);
-	} // addTableModelListener()
+   * Add a TableModelListener.
+   *
+   * @param listener The listener to add.
+   */
+  public void addTableModelListener (TableModelListener listener)
+  {
+    listenerList.add (TableModelListener.class, listener);
+  }
 
 	/**
-	 * removeTableModelListener
-	 * @param value0 TODO
-	 */
-	public void removeTableModelListener(TableModelListener listener) {
-		listenerList.remove(TableModelListener.class, listener);
-	} // removeTableModelListener()
+   * Removes a TableModelListener.
+   *
+   * @param listener The listener to remove.
+   */
+  public void removeTableModelListener (TableModelListener listener)
+  {
+    listenerList.remove (TableModelListener.class, listener);
+  }
+
+  /**
+   * Return all registered TableModelListener objects.
+   *
+   * @return Array of TableModelListener objects.
+   *
+   * @since 1.4
+   */
+  public TableModelListener[] getTableModelListeners()
+  {
+    return (TableModelListener[])
+      listenerList.getListeners (TableModelListener.class);
+  }
 
 	/**
 	 * fireTableDataChanged
 	 */
-	public void fireTableDataChanged() {
-		fireTableChanged(new TableModelEvent(this));
-	} // fireTableDataChanged()
+  public void fireTableDataChanged()
+  {
+    fireTableChanged (new TableModelEvent (this));
+  }
 
 	/**
 	 * fireTableStructureChanged
 	 */
-	public void fireTableStructureChanged() {
-		fireTableChanged(new TableModelEvent(this,
-			TableModelEvent.HEADER_ROW));
-	} // fireTableStructureChanged()
+  public void fireTableStructureChanged()
+  {
+    fireTableChanged (new TableModelEvent (this, TableModelEvent.HEADER_ROW));
+  }
 
 	/**
 	 * fireTableRowsInserted
 	 * @param value0 TODO
 	 * @param value1 TODO
 	 */
-	public void fireTableRowsInserted(int firstRow, int lastRow) {
-		fireTableChanged(new TableModelEvent(this, firstRow, lastRow,
-			TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT));
-	} // fireTableRowsInserted()
+  public void fireTableRowsInserted (int firstRow, int lastRow)
+  {
+    fireTableChanged (new TableModelEvent (this, firstRow, lastRow,
+                                           TableModelEvent.ALL_COLUMNS,
+                                           TableModelEvent.INSERT));
+  }
 
 	/**
 	 * fireTableRowsUpdated
 	 * @param value0 TODO
 	 * @param value1 TODO
 	 */
-	public void fireTableRowsUpdated(int firstRow, int lastRow) {
-		fireTableChanged(new TableModelEvent(this, firstRow, lastRow,
-			TableModelEvent.ALL_COLUMNS, TableModelEvent.UPDATE));
-	} // fireTableRowsUpdated()
+  public void fireTableRowsUpdated (int firstRow, int lastRow)
+  {
+    fireTableChanged (new TableModelEvent (this, firstRow, lastRow,
+                                           TableModelEvent.ALL_COLUMNS,
+                                           TableModelEvent.UPDATE));
+  }
 
 	/**
 	 * fireTableRowsDeleted
 	 * @param value0 TODO
 	 * @param value1 TODO
 	 */
-	public void fireTableRowsDeleted(int firstRow, int lastRow) {
-		fireTableChanged(new TableModelEvent(this, firstRow, lastRow,
-			TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE));
-	} // fireTableRowsDeleted()
+  public void fireTableRowsDeleted(int firstRow, int lastRow)
+  {
+    fireTableChanged (new TableModelEvent (this, firstRow, lastRow,
+                                           TableModelEvent.ALL_COLUMNS,
+                                           TableModelEvent.DELETE));
+  }
 
 	/**
 	 * fireTableCellUpdated
 	 * @param value0 TODO
 	 * @param value1 TODO
 	 */
-	public void fireTableCellUpdated(int row, int column) {
-		fireTableChanged(new TableModelEvent(this, row, row, column));
-	} // fireTableCellUpdated()
+  public void fireTableCellUpdated (int row, int column)
+  {
+    fireTableChanged (new TableModelEvent (this, row, row, column));
+  }
 
 	/**
 	 * fireTableChanged
 	 * @param value0 TODO
 	 */
-	public void fireTableChanged(TableModelEvent event) {
-
-		// Variables
-		Object[]		list;
+  public void fireTableChanged (TableModelEvent event)
+  {
 		int			index;
 		TableModelListener	listener;
+    Object[] list = listenerList.getListenerList();
  
-		// Get Listener List
-		list = listenerList.getListenerList();
- 
-		for (index = 0; index < list.length; index += 2) {
- 
-			// Get Listener
-			listener = (TableModelListener) list[index + 1];
- 
-			// Notify Listener
-			listener.tableChanged(event);
- 
-		} // for: index                                                 
-
-	} // fireTableChanged()
+    for (index = 0; index < list.length; index += 2)
+      {
+        listener = (TableModelListener) list [index + 1];
+        listener.tableChanged (event);
+      }
+  }
 
 	/**
 	 * getListeners
 	 * @param value0 TODO
-	 * @returns EventListener[]
+   * @return EventListener[]
 	 */
-	public EventListener[] getListeners(Class listenerType) {
-		return listenerList.getListeners(listenerType);
-	} // getListeners()
+  public EventListener[] getListeners (Class listenerType)
+  {
+    return listenerList.getListeners (listenerType);
+  }
 
 	/**
 	 * getValueAt
 	 * @param value0 TODO
 	 * @param value1 TODO
-	 * @returns Object
+   * @return Object
 	 */
-	public abstract Object getValueAt(int row, int column);
+  public abstract Object getValueAt (int row, int column);
 
 	/**
 	 * getColumnCount
-	 * @returns int
+   * @return int
 	 */
 	public abstract int getColumnCount();
 
 	/**
 	 * getRowCount
-	 * @returns int
+   * @return int
 	 */
 	public abstract int getRowCount();
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]