Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[riena-dev] Thoughts on tweaking the LabelRidget

Hi riena-dev,

I was using the LabelRidget today and I was a bit frustrated because
it is hard to keep it in-sync with the model. Two ideas came to mind:

1. Would it make sense that the label ridget auto-updates from
model-to-ridget (maybe off by default, but easy to turn on:
labelRidget.setAutoUpdateFromModel(true); ).

Background: I wanted to use a LabelRidget to show the current value of
a bean property. As you know, all the ridgets update from model to
ridget "on demand" only (r.updateFromModel()). In the case of the
LabelRidget, this means that one has to add a property listener to the
model and invoke labelRidget.updateFromModel() by hand :-(.

// complicated:
fooBean.addPropertyChangeListener(new PCL() {
  public void propertyChange(...) { labelRidget.updateFromModel(); }
});

For all other ridgets, the auto-update is not that useful, since they
are typically edited (i.e. load data once, then user edits the data,
write data back to model). The LabelRidget however is read only. It is
never edited, only updated from the model. So I think an auto-update
flag makes a lot of sense.

(@Yang: I think you too were a bit surprised that we needed a listener
to update a label while working on the Snippets some time ago...)

2. Should we add special handling to convert null to "" in the LabelRidget ?

My second problem was: I noticed that in some cases the LabelRidget
was showing an "old" value. It turns out this happens when the
bean-value is null. By default a SWT Label cannot accept null, so
there was an internal exception thrown.

I think it would make sense to convert null to "" when showing it in a
LabelRidget.


Thoughts and comments?

Kind regards,
Elias.

-- 
Elias Volanakis | Technical Lead | http://eclipsesource.com
elias@xxxxxxxxxxxxxxxxx | +1 503 929 5537 | @evolanakis


Back to the top