|Optional Fields on WizardPage [message #1827440]
||Thu, 14 May 2020 14:27
| Marie-Saphira Flug
Registered: January 2019
I'm building a jface Wizard where some pages depend on the input given on previous pages.
But not only the data of fields depends on the input but also if some fields are created at all.
Example: I have three chekboxes i.e. Button(main, SWT.CHECK) and a Combo:
Only one of the checkboxes can be selected, so the others have to get deselected in each checkbox's selection listener.
Also the combo has to be disabled if check2 is selected.
The optionalCheck only appears if some value is set false on the previous page.
The fields above are all put in a Group. This group does not appear once on this page but a numberOfGroups times which given to the page's constructor.
Lets call this page MyPage.
I tried three ideas:
Create two pages of MyPage, one with the value set to false, and a second with true , let getNextPage() return the right page and skip the other one.
The optionalCheck is put into an extra Composite which gets a GridData with gridData.exlude set to true or false respectively.
But now the optionalCheckbox is not aligned with the other checkboxes, so I have to put each of the fields into its own Composite?
Have the gridData as field, let it get changed by getNextPage() and pack() the composite, but apparently I didn't get it right and if I went "Back",
changed the boolean and went to MyPage again it didn't work at all.
Also the Groups looked really ugly, since they only enclose the fields but I want them to fill all the (horizontal) space.
Override setVisible(boolean visible) on MyPage, create the fields if(visible) and pack() the main composite.
But the groups again look bad and are created again and again every time the page gets visited. So I prefer the first idea so far.
I will also put a ScrollingComposite around the Groups but that's a different kettle of fish.
So my question is:
Is there a better way to handle optional fields than creating different pages?
(The true/false setting is an example, it's actually an int taken from an enum, but at the moment there are only two possibilities so boolean works as well)
Powered by FUDForum
. Page generated in 0.01127 seconds