[EMF Forms] Setting the size of controls programmatically [message #1740998] |
Mon, 22 August 2016 09:38 |
Andre Doerscheln Messages: 7 Registered: June 2015 |
Junior Member |
|
|
Hi everybody!
I would like to set the size (primarily the height) of a TextControl.
I tried to override the render(SWTGriCell, Composite)-method of the TextControlSWTRenderer and set the preferred size of the cell there, but that resulted in an invalid layout of the complete form, also i just changed it for one specific field.
Using a static Template is no option, because our software is highly customizable.
Am i doing something wrong or is this a known issue?
Kind regards,
André
[Updated on: Mon, 22 August 2016 09:43] Report message to a moderator
|
|
|
|
Re: [EMF Forms] Setting the size of controls programmatically [message #1741179 is a reply to message #1741175] |
Tue, 23 August 2016 14:21 |
Andre Doerscheln Messages: 7 Registered: June 2015 |
Junior Member |
|
|
Hi Eugene,
thank you for your reply!
The code you posted didn't work as expected, because the layoutData of the control that is being returned by createSWTControl, is overridden later by ContainerSWTRenderer#setLayoutDataForControl.
Anyway: you led me the way to the solution. Because i already had overridden the createSWTControl-method, i instanciated an anonymous class of Text, in which i overrode the setLayoutData-method as following:
text = new Text(parent, getTextWidgetStyle()) {
private static final long serialVersionUID = -3354554595303103830L;
@Override
public void setLayoutData(Object layoutData) {
if (layoutData instanceof GridData) {
GridData gridData = (GridData) layoutData;
gridData.heightHint = dimensionOption.getHeight();
gridData.widthHint = dimensionOption.getWidth();
}
super.setLayoutData(layoutData);
}
};
I know this is not an ideal solution, because it presumes that the LayoutData is GridData, but we haven't had any case, where it's not like this - till now.
Thank you and have a nice day everybody!
|
|
|
Powered by
FUDForum. Page generated in 0.02675 seconds