Community
Participate
Working Groups
With the fix for bug 261989 the behavior of IRidget.isVisible() changed: it no longer returns the ridgets own visible setting but whether the ridget is actually showing which implies the visibility of all ancestors. This new behavior of IRidget.isVisible() matches that of org.eclipse.swt.widgets.Control.isVisible(). There should be an additional getter in IRidget that is symmetric to the setter setVisible(boolean) i.e. that returns the ridgets own visible setting. In analogy to org.eclipse.swt.widgets.Control this getter should be called getVisible(). Personally I think this is pretty awful: having to getters (isVisible() and getVisible()) for one property ("visible") that will return different values for certain states of the object. But that's the way it is in SWT so I think Riena should go along with that.
The same pattern applies to 'enabled': Control.setEnabled(boolean): Enables the receiver if the argument is true, and disables it otherwise. Control.getEnabled(): Returns true if the receiver is enabled, and false otherwise. Control.isEnabled(): Returns true if the receiver is enabled and all ancestors up to and including the receiver's nearest ancestor shell are enabled. So we should change the behavior of the methods setEnabled(boolean)/isEnabled() in IRidget too and add getEnabled(), shouldn't we...?
I agree that it is confusing. Just curious: is there a use-case for getVisible() ? I we don't need it, we could leave it out. If we do need it, I don't see a better way of doing it.
A use-case? Hmm... Update all ridgets of a controller that are not explicitly hidden. Include those that are only currently not showing because an ancestor of the widget in the view is hidden. for (IRidget ridget : getRidgets()) { if (ridget.getVisible()) { ridget.updateFromModel(); } }
Thanks, makes sense :-)
I am not sure why the code that Carsten has posted is not better or also written as: for (IRidget ridget : getRidgets()) { if (ridget.isVisible()) { ridget.updateFromModel(); } }
When isVisible() is used as it is implemented now, Ridgets that are only currently not showing because an ancestor of the widget in the view is hidden would be ignored. My use-case included not to ignore those. Does this use-case make any sense...? Maybe there is some logic in the view so that the user can switch between two panels take are shown at the same location. If this only makes the layout clearer but has no business meaning it could make sense to do this in the view. Then some Ridgets would always be not showing. But from the business point of view of the controller it could still be necessary to update all Ridgets at the same time.