Skip to main content

#181-swing - convenience table.getColumnByModelIndex(column)?

1 reply [Last post]
Anonymous

Noel,

I'm moving this here because I want to get more opinions (maybe you can
convince me by drumming up support ) The issue is

https://swingx.dev.java.net/issues/show_bug.cgi?id=181

Though I have stumbled into wanting such a method myself
(TableComponentAdapter has it :-) I'm reluctant in introducing it into
the public api of JXTable because it breaks the overall and simple
convention that every coordinate in a public method is in view coordinates.

The convention has a principal problem with hidden columns: they don't
have view coordinates and consequently are not directly accessible by
the JXTable api. But they are indirectly accessible by
table.getColumns(includeHidden) and looping through the columns returned.

Additionally, I favour going into the direction of identifiers vs.
coordinates: I always see an index as a "weak" hook into the actual
object (here that's the column) because it can easily get invalid due to
removing/adding items (in the model). Accessing columns (hidden as well
as visible) by identifier is supported in JXTable.

As to the use-case example in the bug report - that looks like a initial
configuration issue, which might be abstracted a bit more and maybe
solved by a custom ColumnFactory: the binding project f.i. has a
metadata-aware ColumnFactoryExt which configures the columns accordingly.

Opinions?

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Noel Grandin

Hi

I think that this issue is going come up more and more as people need to
manipulate active JXTable widgets i.e. where the configuration of the
table changes dynamically.
You need to be able access parts of the model easily to modify them, and
you don't want to care about whether the user has made columns invisible
or not.

>
> Additionally, I favour going into the direction of identifiers vs.
> coordinates: I always see an index as a "weak" hook into the actual
> object (here that's the column) because it can easily get invalid due
> to removing/adding items (in the model). Accessing columns (hidden as
> well as visible) by identifier is supported in JXTable.
>
Personally, I don't see that identifiers are any stronger or weaker than
indices - you have simply created a new namespace for the columns.

Regards,
Noel

NOTICE: Please note that this email, and the contents thereof,
are subject to the standard Peralex email disclaimer, which may
be found at: http://www.peralex.com/disclaimer.html

If you cannot access the disclaimer through the URL attached
and you wish to receive a copy thereof please send
an email to email@peralex.com

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net