Home » Eclipse Projects » Eclipse Scout » RadioButtonGroup not disabling its children
|
Re: RadioButtonGroup not disabling its children [message #964328 is a reply to message #957746] |
Tue, 30 October 2012 12:42 |
Ken Lee Messages: 97 Registered: March 2012 |
Member |
|
|
Hi Patrick,
Quote:
- When I configure a radio button group to be disabled (getConfiguredEnabled: false), only the label of the group is decorated as disabled. The buttons themselves remain enabled. This happens if I use static buttons, but also with CodeTypes (getConfiguredCodeType) and LookupCalls (tested with a LocalLookupCall).
I expect the buttons to be also disabled when the radio button is disabled (a behaviour that is implemented in the setEnabled Method in the AbstractRadioButtonGroup...
If the radio button group box and its fields are created, the model is traversed in a outer-to-inner classes manner, i.e. the group box is created before the buttons (since the buttons are children of the group box and hence have to know their parent).
All the getConfigured methods are executed as part of the field creation. When the method getConfiguredEnabled is executed, its result is passed to the method setEnabled which calls the same method on all of its children.
However, since children i.e. the radio buttons haven't been created during initialization of the group box, the recursive call on setEnabled has no impact.
Quote:
I can do a workaround using the following, but that should not be necessary IMHO:
@Override
protected void execInitField() throws ProcessingException {
setEnabled(false);
}
The difference here is that execInitField is executed at a later stage, i.e. after all fields on the form have been created, the execInitField method is executed on all instantiated fields. Since the radio buttons are available, the setEnabled method is called recursively on all radio buttons.
Quote:
Would you agree that this is a bug, or do I aim totally in the wrong direction with my coding?
If you have a look at the Javadoc of the getConfiguredEnabled method, it says
affects only the field itself. in case of a composite field initially the property does not get broadcasted.
It sounds that only the group box is affected but not its children (radio buttons).
However, it would make sense in my opinion, if getConfiguredEnabled property were also applied to the child fields.
Feel free to open an enhancement ticket to change this behaviour.
Cheers,
Ken
[Updated on: Tue, 30 October 2012 12:42] Report message to a moderator
|
|
| | | |
Re: RadioButtonGroup not disabling its children [message #1006672 is a reply to message #957746] |
Fri, 01 February 2013 11:32 |
Ken Lee Messages: 97 Registered: March 2012 |
Member |
|
|
I had a deeper look into the discussed solution and came to the conclusion that this cannot be applied directly.
What we would like to do is to broadcast the getConfiguredEnabled() property on the RadioButtonGroupBox to its child fields (radio buttons, smartfields, etc.).
In case, a subclass of AbstractRadioButtonGroupBox overrides the getConfiguredEnabled() method and returns false, we discussed last time that all child fields should be notified and get disabled too.
In contrary, if a subclass overrides getConfiguredEnabled() to return true, we could argue that all child fields have to be enabled as well.
The problem that I found now is the fact that AbstractRadioButtonGroupBox inherits the getConfiguredEnabled() method from AbstractFormField which returns true by default.
Imagine now that someone subclasses the RadioButtonGroupBox without overriding getConfiguredEnabled(). Further, some radio buttons (child fields) are disabled initially. According the our proposed solution, the RadioButtonGroupBox would broadcast its enabled state to all its children and will finally enable all child fields, even those which are intended to be disabled.
I can think of 2 solutions for this problem:
- During runtime we have to check if the subclass of AbstractRadioButtonGroupBox overrides the getConfiguredEnabled() method. If this is the case, this state will be broadcasted to its child fields. Otherwise, only the groupbox and its label are affected.
- We need another property something like getConfiguredBroadcastEnabled() which returns false by default. If set to true, the child fields will always inherit the property of the groupbox.
If prefer solution 2 because we could avoid reflective code during runtime and it is clearer to the programmer since the broadcast has to be set explicitly.
What are your opinions?
|
|
| | | | | | |
Re: RadioButtonGroup not disabling its children [message #1007495 is a reply to message #1007133] |
Wed, 06 February 2013 08:14 |
|
Hi there
In my opinion, introducing a new property doesn't make it any better. The user still has to know, that setting getConfiguredEnabled to false does not disable the whole group. So he still need to do something more, either call setEnabled(false) or set the new property, so where's the benefit?
Either let it as it is, or maybe, only broadcast the disabled state. This would be more what the user expects, even though getConfiguredEnabled and setEnabled still wouldn't exactly behave the same, but this shouldn't be any problem.
And yes, if you change it, please change it for the AbstractCompositeField as well.
|
|
| |
Goto Forum:
Current Time: Thu Apr 18 08:38:57 GMT 2024
Powered by FUDForum. Page generated in 0.02725 seconds
|