Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMFForms] Custom Group Control has wrong numColumns(following contol lable is in same row)
[EMFForms] Custom Group Control has wrong numColumns [message #1422099] Fri, 12 September 2014 10:11 Go to next message
Phil Wim is currently offline Phil WimFriend
Messages: 89
Registered: October 2013
Member
Hi,

for a custom group in emfforms i decided to use sections from forms toolkit. When i'm implementing the following group, it appears as a section but the lable of the following control is placed behind the section.

The section seams to be added to a gridlayout.numColumns = 2. (see Screenshot)

Any ideas?

public class PGroupRenderer extends ContainerSWTRenderer<VGroup> {

	@Override
	protected Collection<VContainedElement> getChildren() {
		return getVElement().getChildren();
	}

	@Override
	protected String getCustomVariant() {
		return "PGroup"; //$NON-NLS-1$
	}

	@Override
	protected Composite getComposite(Composite parent) {
		

		final Composite main = new Composite(parent, SWT.FILL);

//main.setBackground(parent.getDisplay().getSystemColor(0 + (int) (Math.random() * 10)));
		main.setBackgroundMode(SWT.INHERIT_FORCE);

		final GridData gridData = new GridData();
		gridData.horizontalAlignment = GridData.FILL;
		gridData.grabExcessHorizontalSpace = true;
		final GridLayout layout = new GridLayout();
		layout.numColumns = 1;

		main.setLayoutData(gridData);
		main.setLayout(layout);
		final FormToolkit toolkit = new FormToolkit(main.getDisplay());

		Section section = toolkit.createSection(main, ExpandableComposite.TITLE_BAR);
		section.setLayoutData(gridData);
		section.setText(getVElement().getName());


		final Composite client = toolkit.createComposite(section, SWT.FILL);
		client.setLayoutData(gridData);
		section.setClient(client);

		return client;
	}
}

  • Attachment: emfforms.png
    (Size: 6.81KB, Downloaded 119 times)
Re: [EMFForms] Custom Group Control has wrong numColumns [message #1422877 is a reply to message #1422099] Sat, 13 September 2014 14:48 Go to previous messageGo to next message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 63
Registered: March 2012
Member
Hi,
this is because the container renderer sets the layout by itself.
This is what will work:
public class PGroupRenderer extends ContainerSWTRenderer<VGroup> {

	private Section section;

	@Override
	protected Collection<VContainedElement> getChildren() {
		return getVElement().getChildren();
	}

	@Override
	protected String getCustomVariant() {
		return "PGroup"; //$NON-NLS-1$
	}

	@Override
	protected Composite getComposite(Composite parent) {
		final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
		section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
		section.setText(getVElement().getName());

		final GridLayout layout = new GridLayout(1, true);
		section.setLayout(layout);

		final Composite client = toolkit.createComposite(section, SWT.FILL);
		final GridData gridData = new GridData();
		gridData.horizontalAlignment = GridData.FILL;
		gridData.grabExcessHorizontalSpace = true;
		client.setLayoutData(gridData);

		section.setClient(client);
		return client;
	}

	@Override
	protected Control renderControl(SWTGridCell gridCell, Composite parent) throws NoRendererFoundException,NoPropertyDescriptorFoundExeption {
		super.renderControl(gridCell, parent);
		return section;
	}

}


Cheers,
Eugen
Re: [EMFForms] Custom Group Control has wrong numColumns [message #1425637 is a reply to message #1422877] Wed, 17 September 2014 15:54 Go to previous message
Phil Wim is currently offline Phil WimFriend
Messages: 89
Registered: October 2013
Member
Thanks for instructions Eugen. It works!
Previous Topic:[EMF Forms] How to add actions to a form
Next Topic:[EEF] Is EEF still alive?
Goto Forum:
  


Current Time: Tue Mar 19 08:48:29 GMT 2024

Powered by FUDForum. Page generated in 0.03698 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top