GlazedLists update

6 views
Skip to first unread message

Jacek Furmankiewicz

unread,
Jul 29, 2009, 9:14:34 AM7/29/09
to JavaBuilders
Just wanted to let everyone know that the reason for (apparent) lack
of progress on the GlazedLists integration is that it is actually
quite complex to make it right. But, from what I've seen I think it
will be a killer feature of Swing JB 1.0, on par with the introduction
of the MigLayout DSL in 0.1.

It's just a lot of investigation and coding to integrate GL into
SwingJB keeping our motto in mind : maximum productivity with minimum
code. GL is a complex thing, with a lot of powerful features and I
want to support them all in the easiest way possible.

Hopefully, I shall have something ready in the next 2 weeks with
proper unit tests, sample apps, etc.

Stay tuned, this is going to be a great new feature.

Jacek Furmankiewicz

unread,
Jul 30, 2009, 9:12:32 AM7/30/09
to JavaBuilders
First support in the latest build, it's as simple as:

JTable(name=defectsTable):
- EventTableModel
(name=defectsModel,source=defects,sort=multi,columns=[id,reporter])

In Java

private EventList<Defect> defects = GlazedLists.threadSafeList(new
BasicEventList<Defect>());

That's all. Ability to define default sort column and filtering on
column values is coming up next.
This is very alpha preview code, so pls bang away at it as much as you
can.

To avoid the runtime overhead of reflection when dealing with
potentially hundreds of thousands of rows in a table, most of the
dynamic portions of the code
now are compiled in-memory at run-time using the Janino embedded
compiler (which is a work of pure genius).

This will be especially important when adding filtering support, which
needs to evaluate the values of a column for each row...doing this via
reflection (like we do most of the time)
would be prohibitively slow.

Alexandre Navarro

unread,
Jul 30, 2009, 2:29:54 PM7/30/09
to javabu...@googlegroups.com
Is it possible now to do with this version
JTable(name=defectsTable):
- MyTableModel
if I define a my custom MyTableModel?

Alexandre

Jacek Furmankiewicz

unread,
Jul 30, 2009, 2:31:09 PM7/30/09
to JavaBuilders
Yes, it's been possible to do this for a few versions now, actually.

Jason S

unread,
Jul 30, 2009, 4:23:28 PM7/30/09
to JavaBuilders
On Jul 30, 9:12 am, Jacek Furmankiewicz <jace...@gmail.com> wrote:
> First support in the latest build, it's as simple as:
>
>         JTable(name=defectsTable):
>              - EventTableModel
> (name=defectsModel,source=defects,sort=multi,columns=[id,reporter])
>
> In Java
>
>         private EventList<Defect> defects = GlazedLists.threadSafeList(new
> BasicEventList<Defect>());
>

hey, that's neat! I'm not sure I will have much chance to try/test it
out soon (murphy's law says that a programming skill/library I use
once will not be used again until I have half-forgotten how to use it)
but it sounds like a good approach.

Alexandre Navarro

unread,
Jul 30, 2009, 8:09:50 PM7/30/09
to javabu...@googlegroups.com
Hi,

I tried your new version with a specific TableModel (BeanTableModel not
EventTableModel).

First question, why you chose the syntax
JTable(name=defectsTable):
- EventTableModel

instead of

JTable(name=defectsTable):
EventTableModel

You should have only one TableModel (as you did JScrollPane).

Second, I tried somethink like

JFrame(title=Bean Table Model Frame, size=640x480) :
- JPanel(name=mainPanel) :
- JScrollPane(name=pane) :
JTable(name=mainTable) :
- BeanTableModel(name=tableModel)
- JButton(name=addButton, label=Add a row, onAction=addARow)
- MigLayout : |
[]
pane
addButton []


But I have an error

org.javabuilders.BuildException: Unable to call JTable.setModel with
type BeanTableModel. Error: null

It is quite weird because
BeanTableModel extends AbstractTableModel and the constructor
BeanTableModel is called.

Can you tell me if I did a mistake or if it is a bug.

Thanks in advance

Alexandre

Jacek Furmankiewicz

unread,
Jul 30, 2009, 10:21:22 PM7/30/09
to JavaBuilders
The syntax was chosen because you can also have TableColumn entries,
e.g.

JTable(name=defectsTable):
- EventTableModel
(name=defectsModel,source=defects,sort=multi,columns=[id,reporter])
- TableColumn(name=reporter,headerValue=Some custom header for the
Reporter column):
- JComboBox(name=reporterCellEditor)

In the example above, the EventTableModel creates the "id" and
"reporter" columns, then the "reporter"
is further customized via the TableColumn instance and on top of that
we add a JComboBox cell editor for that column.

As for your error, unfortunately I shamefully admit it's a bug :-(
I will look at it ASAP for the next build. I had to mess around a lot
with the table logic to get GlazedLists to work....

Jacek Furmankiewicz

unread,
Jul 30, 2009, 10:52:01 PM7/30/09
to JavaBuilders
Actually, I have a unit test for this (i.e. a custom table model) and
for me it passes, weird.

Could you send me the sample code for a BeanTableModel so I can try to
reproduce it?

thx

Jacek Furmankiewicz

unread,
Jul 30, 2009, 11:04:15 PM7/30/09
to JavaBuilders
Do you have your own custom handler for BeanTableModel?

If yes, do you do Node.setMainObject(your model) on it in the
useExistingInstance() method?

Alexandre Navarro

unread,
Jul 31, 2009, 3:34:40 AM7/31/09
to javabu...@googlegroups.com
Ok but something like

JTable(name=defectsTable):
EventTableModel
(name=defectsModel,source=defects,sort=multi,columns=[id,reporter]) :
- TableColumn(name=reporter,headerValue=Some custom header for the
Reporter column):
JComboBox(name=reporterCellEditor)

is more natural, isn't? (it is what I plan to do with BeanTableModel),
maybe there is an technical reason for this choice?

Alexandre

Alexandre Navarro

unread,
Jul 31, 2009, 3:34:44 AM7/31/09
to javabu...@googlegroups.com
I will send you my complete code this evening (on Paris time).

Alexandre

Alexandre Navarro

unread,
Jul 31, 2009, 3:34:55 AM7/31/09
to javabu...@googlegroups.com
Not yet but I will.

I just add my TableModel as
SwingJavaBuilder.getConfig().addType(BeanTableModel.class);
I must add some configuration for TableModel?

Alexandre

Jacek Furmankiewicz

unread,
Jul 31, 2009, 8:13:35 AM7/31/09
to JavaBuilders
Not really. I prefer to always avoid additional levels of indentation
and keep it as flat as possible.
The TableColumn object belongs really to JTable, not the model...the
model creates it, but it then falls under JTable as its child.
Also, don't forget we support just specifying TableColumn directly
under JTable already, without any models. So it would be too confusing
to allow TableColumn in different places.

On Jul 31, 3:34 am, Alexandre Navarro <alexandre.j.nava...@gmail.com>
wrote:

Jacek Furmankiewicz

unread,
Jul 31, 2009, 8:14:28 AM7/31/09
to JavaBuilders
No, that should work. That's pretty much exactly what I have in my
unit test, so that's why I am surprised.
I'll wait for your code listing to try to fully replicate it.
Pls create it as a new issue and attach the code to it.

Cheers, Jacek

On Jul 31, 3:34 am, Alexandre Navarro <alexandre.j.nava...@gmail.com>
wrote:

Jacek Furmankiewicz

unread,
Aug 12, 2009, 7:41:13 AM8/12/09
to JavaBuilders
New dev build has ability to specify default sort when binding to a
JTable (sortBy):

JTable(name=defectsTable):
- EventTableModel(name=defectsModel,source=defects,sort=multi,sortBy=
[reporter,state,id])

More docs in PDF

Sebastien Gollion

unread,
Oct 5, 2009, 11:18:53 AM10/5/09
to JavaBuilders
When you bind with GlazedList a JTable, the column classes are not
set.

Is it possible to inform colum class from binding ?

Thx, Seb.

Jacek Furmankiewicz

unread,
Oct 5, 2009, 12:21:50 PM10/5/09
to JavaBuilders
Is your model defined with generics? I pick up the class definition
from the faint traces of generic types that javac still leaves lyring
around...

EventTableModel<Person> personModel;

Sebastien Gollion

unread,
Oct 5, 2009, 3:17:37 PM10/5/09
to JavaBuilders
That's the right example: EventTableModel<Person> personModel

When cell renderer is called, the Object class is returned for each
field of Person.
I was expecting firstName=>String, lastName=>String and
birthDate=>Calendar.
If the right class is set, then the rigth cell renderer is used.
Reply all
Reply to author
Forward
0 new messages