0

I have a Wizard that contains multiple components. On the wizard I have drop-downs that can filter the results, which then hides various rows that are not required. However when these rows are hidden the components remain in the same location and do not re-size/move up. My problem I believe is similar to this issue (SWT components relayout after visibility set to false) however it uses RowLayout instead. I have also tried copying what was done but it did not change anything. How would I get the components to be placed togeather instead of leaving gaps?

I'v also read that .pack() and .revalidate() might be options, but I cannot seem how to make them work with the wizard classes. As best I can tell, it is using org.eclipse.jface.wizard for the base components. Any advice is highly appreciated for this, and I will update my question as requires if it needs to be clarified.

Edit Attempting to recreate the style outlined in the link above, I came up with this (please note the project abstracts a few things away, so I have to make some extra calls). However after implementing I see no notable difference in the program (e.g. everything is still in the exact same spots, no spacing differences).

RowData data = new RowData();
RowData data2 = new RowData();
guiPiece.getGUILayout().getPiece("label").setLayoutData(data);
guiPiece.getGUILayout().getPiece("field").setLayoutData(data2);

guiPiece.getGUILayout().getPiece("label").setVisible(newVisibility);
data = (RowData)guiPiece.getGUILayout().getPiece("label").getLayoutData();
data.exclude = !newVisibility;
guiPiece.getGUILayout().getPiece("field").setVisible(newVisibility);
data2 = (RowData)guiPiece.getGUILayout().getPiece("field").getLayoutData();
data2.exclude = !newVisibility;

guiPiece.getFieldParentingControl().layout(true);
Community
  • 1
  • 1
Sh4d0wsPlyr
  • 948
  • 12
  • 28
  • You would have to switch completely to GridLayout and GridData to make the linked answer work. – greg-449 Mar 02 '16 at 19:20
  • I expect this is also related - Another idea I might try if I can ever find the right components is to just disable them rather then hide them. http://stackoverflow.com/questions/7727728/invisible-components-still-take-up-space-jpanel – Sh4d0wsPlyr Mar 02 '16 at 19:55
  • That is Swing not SWT, a completely different GUI. – greg-449 Mar 02 '16 at 20:11

1 Answers1

0

You can use a similar method to the GridLayout link you provide but using RowLayout.

You need to set RowData layout data on each of your controls.

RowData data = new RowData();
control.setLayoutData(data);

RowData also has an exclude flag which you can set the include / exclude a control from the layout.

So to hide a control you would do:

control.setVisible(false);

RowData data = (RowData)control.getLayoutData();
data.exclude = true;

You then call layout(true) on the main Composite of the wizard page.

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • I'v tried implementing this - perhaps I missed something. I'll update my question with what I attempted and maybe you can see where I went wrong with this. – Sh4d0wsPlyr Mar 03 '16 at 15:08
  • You must use a separate instance of `RowData` for each control, **never** use layout data for more than one control. You haven't shown what the layout of the parent Composite is - this must be `RowLayout`. I have no idea what `guiPiece.getGUILayout().getPiece("field")` does so I can't say if that is correct or not. – greg-449 Mar 03 '16 at 15:39
  • The *.getPiece("fieldname")* returns the control. *getFieldParentingControl* returns the composite. – Sh4d0wsPlyr Mar 03 '16 at 15:56
  • We would need to see a [mcve] to get anywhere with this. – greg-449 Mar 03 '16 at 16:05