Hi Daniel

Thanks for your reply!

I'm surprised that you think the table model would ever expect a view
index and not the model index. Why would that be the case? Take a look
at JTable#getColumnClass(int) and JTable#addColumn(TableColumn) from the
JDK:

    public void addColumn(TableColumn aColumn) {
        if (aColumn.getHeaderValue() == null) {
            int modelColumn = aColumn.getModelIndex();
            String columnName = getModel().getColumnName(modelColumn);
            aColumn.setHeaderValue(columnName);
        }
        getColumnModel().addColumn(aColumn);
    }

    public Class getColumnClass(int column) {
        return
getModel().getColumnClass(convertColumnIndexToModel(column));
    }

I think you mixed up JTable#getColumnClass(int) with
TableModel#getColumnClass(int)...

It's not about being right or wrong (even though I'm right in this
case;-)), but I think it is important for developers to know that
whenever a table model is accessed, TableColumn indices must first be
converted to TableModel indices!

Regards, Etienne



> -----Original Message-----
> From: Daniel Grob [mailto:[EMAIL PROTECTED]
> Sent: Saturday, August 05, 2006 1:32 PM
> To: Etienne Studer
> Cc: [EMAIL PROTECTED]
> Subject: Re: [ULC-developer] EagerLoadingHandler issues
> 
> Hi Etienne,
> 
> You are half right :-)
> - ULCTable.getColumnClass() expects the view index, not the model
index,
> i.e. my original code is correct
> - Columns are referenced by proxy id, not by view index, i.e. my
> original code is buggy
> 
> The correct code is now
>             ULCTableColumn column =
table.getColumnModel().getColumn(i);
>             if (column.getCellRenderer() != null
>                     ||
table.getDefaultRenderer(table.getColumnClass(i))
> != null) {
>                 tmpResult[tmpCount] = *column.getId()*;*  // used to
be
> 'i'*
>                 tmpCount++;
>             }
> 
> I will correct the contribution in the next days. Thanx for your
> detailed feedback!
> 
> Regards Dany
> 
> 
> Etienne Studer wrote:
> >
> > Hi ULC Team & Daniel (Grob)
> >
> >
> >
> > When running against ULC 6.0.4, the EagerLoadingHandler community
> > contribution has 2 bugs, triggering exceptions at startup time in
our
> > application.
> >
> >
> >
> > Correct would be:
> >
> >
> >
> > private static int[]
> > getRendererColumns()/getEditorColumns()/getHeaderColumns() {
> >
> >         int[] tmpResult = new int[table.getColumnCount()];
> >
> >         int tmpCount = 0;
> >
> >         for (int i = 0; i < table.getColumnCount(); i++) {
> >
> >             ULCTableColumn column =
table.getColumnModel().getColumn(i);
> >
> >             if (column.getCellEditor() != null ||
> >
> >
> >
> table.getDefaultEditor(table.getColumnClass(*column.getModelIndex()*))
> > != null) { *// used to be i*
> >
> > *                *tmpResult[tmpCount] =*
> > table.getColumnModel().getColumn(i).getId(); // used to be i;*
> >
> >                 tmpCount++;
> >
> >             }
> >
> >         }
> >
> >
> >
> >         int[] result = new int[tmpCount];
> >
> >         System.arraycopy(tmpResult, 0, result, 0, result.length);
> >
> >         return result;
> >
> >     }
> >
> >
> >
> > Just to let you (and other developers) know.
> >
> >
> >
> > Thanks for the contribution.
> >
> >
> >
> > Regards, Etienne
> >
> >
> >

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to