[EMF Forms] multi-row controls [message #1715956] |
Sun, 29 November 2015 06:47  |
Eclipse User |
|
|
|
Hi
I try to render something called "text area" - in SWT it is called "multi-line text", however it does not work. I subclassed TextControlSWTRenderer like this:
public class DescriptionControlRenderer extends TextControlSWTRenderer {
private final static int ROWS = 10;
@Inject
public DescriptionControlRenderer(VControl vElement, ViewModelContext viewContext, ReportService reportService,
EMFFormsDatabinding emfFormsDatabinding, EMFFormsLabelProvider emfFormsLabelProvider,
VTViewTemplateProvider vtViewTemplateProvider, EMFFormsEditSupport emfFormsEditSupport) {
super(vElement, viewContext, reportService, emfFormsDatabinding, emfFormsLabelProvider, vtViewTemplateProvider,
emfFormsEditSupport);
}
@Override
protected Control createSWTControl(Composite parent) {
final Text text = new Text(parent, getTextWidgetStyle());
GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
gridData.minimumHeight = ROWS * text.getLineHeight();
gridData.heightHint = ROWS * text.getLineHeight();
text.setLayoutData(gridData);
return text;
}
@Override
public SWTGridDescription getGridDescription(SWTGridDescription gridDescription) {
int columns;
switch (getVElement().getLabelAlignment()) {
case DEFAULT:
case LEFT:
columns = 3;
break;
case NONE:
columns = 2;
break;
default:
getReportService().report(new AbstractReport(MessageFormat.format(
"Label alignment {0} is not supported by renderer {1}. Label alignment set to default.",
getVElement().getLabelAlignment().getLiteral(), getClass().getName()), IStatus.INFO));
getVElement().setLabelAlignment(LabelAlignment.DEFAULT);
columns = 3;
}
SWTGridDescription description = GridDescriptionFactory.INSTANCE.createSimpleGrid(ROWS, columns, this);
for (int i = 0; i < description.getGrid().size() - 1; i++) {
SWTGridCell swtGridCell = description.getGrid().get(i);
swtGridCell.setHorizontalGrab(false);
}
return description;
}
@Override
protected int getTextWidgetStyle() {
return SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | getAlignment();
}
private int getAlignment() {
if (getVTViewTemplateProvider() == null) {
return getDefaultAlignment();
}
final Set<VTStyleProperty> styleProperties = getVTViewTemplateProvider()
.getStyleProperties(getVElement(), getViewModelContext());
for (final VTStyleProperty styleProperty : styleProperties) {
if (VTAlignmentStyleProperty.class.isInstance(styleProperty)) {
if (VTAlignmentStyleProperty.class.cast(styleProperty).getType() == AlignmentType.LEFT) {
return SWT.LEFT;
} else if (VTAlignmentStyleProperty.class.cast(styleProperty).getType() == AlignmentType.RIGHT) {
return SWT.RIGHT;
}
}
}
return getDefaultAlignment();
}
}
That is I set the number of rows in getGridDescription(), as well the height of the multi-line control but nothing seem to work.
Is it a limitation of EMF Forms: always the one-row? Or can it be achieved with custom areas? Looking at the custom area example gives no clarity on this topic, because the example uses 2 1*1 grids instead of 1 2*1... how can we render text area in EMF Forms?
|
|
|
|
|
Re: [EMF Forms] multi-row controls [message #1716056 is a reply to message #1716001] |
Mon, 30 November 2015 16:48  |
Eclipse User |
|
|
|
Hi Klim,
good that you found the option.
Yeah the multi-line thing is strange.
On the one hand site the genmodel has this optional so it makes sense to reuse it. On the other hand one could make this explicit.
So could you please open a bug report for this. Maybe we will find some time to fix this.
Thanks and cheers,
Eugen
|
|
|
Powered by
FUDForum. Page generated in 0.06176 seconds