Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Forms] New custom controls
[EMF Forms] New custom controls [message #1799590] Mon, 10 December 2018 17:07 Go to next message
sri pamarti is currently offline sri pamartiFriend
Messages: 15
Registered: August 2015
Junior Member
Hi,
I'm trying to create a new custom control for child objects. I could only find two examples PGroupRenderer and Custom Emailfield renderer.

Which baseclass should I extend if I want to render my own control?

I've used the following in the view model definition for "Custom Control"

Domain Model Reference -> Linked Domain model EFeature for the children

Bundle Name -> bundle name where the RendererService resides
Class Name -> FQN Renderer service class

I tried to emulate the PGroupControl. However I'm getting the following exception
I'm using the latest version 1.18 with eclipse Photon

Custom Control class
public class RolePermissionsControl extends ContainerSWTRenderer<VControl> {

	// private ReportService reportService;

	@Inject
	public RolePermissionsControl(VControl vElement, ViewModelContext viewContext, ReportService reportService,
			EMFFormsRendererFactory factory, EMFFormsDatabinding emfFormsDatabinding) {
		super(vElement, viewContext, reportService, factory, emfFormsDatabinding);
	}

	private SWTGridDescription rendererGridDescription;
	private CheckboxTreeViewer treeViewer = null;


	@Override
	public SWTGridDescription getGridDescription(SWTGridDescription gridDescription) {
		if (rendererGridDescription == null) {
			rendererGridDescription = GridDescriptionFactory.INSTANCE.createSimpleGrid(1, 1, this);
			final SWTGridCell swtGridCell = rendererGridDescription.getGrid().get(0);
			swtGridCell.setVerticalFill(false);
			swtGridCell.setVerticalGrab(false);
		}
		return rendererGridDescription;
	}

	@Override
	public Control renderControl(SWTGridCell cell, Composite composite)
			throws NoRendererFoundException, NoPropertyDescriptorFoundExeption {
		Composite parent = new Composite(composite, SWT.NONE);
		parent.setLayout(new FillLayout(SWT.VERTICAL));[/size]



Renderer Service
public class RolePermissionsRendererService implements EMFFormsDIRendererService<VControl> {

	private EMFFormsDatabinding databindingService;
	private ReportService reportService;

	/**
	 * Called by the initializer to set the EMFFormsDatabinding.
	 *
	 * @param databindingService The EMFFormsDatabinding
	 */
	protected void setEMFFormsDatabinding(EMFFormsDatabinding databindingService) {
		this.databindingService = databindingService;
	}

	/**
	 * Called by the initializer to set the ReportService.
	 *
	 * @param reportService The ReportService
	 */
	protected void setReportService(ReportService reportService) {
		this.reportService = reportService;
	}

	@Override
	public double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
		if (!VCustomControl.class.isInstance(vElement)) {
			return NOT_APPLICABLE;
		}
		return 10;
	}

	@Override
	public Class<? extends AbstractSWTRenderer<VControl>> getRendererClass() {
		// TODO Auto-generated method stub
		return RolePermissionsControl.class;
	}


org.eclipse.e4.core.di.InjectionException: Could not find satisfiable constructor in mypackage.ui.controls.rolepermissions.RolePermissionsControl
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:421)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:331)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:190)
	at org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererFactory.getRendererInstance(EMFFormsDIRendererFactory.java:162)
	at org.eclipse.emfforms.internal.swt.core.EMFFormsRendererFactoryImpl.getRendererInstance(EMFFormsRendererFactoryImpl.java:102)
	at org.eclipse.emf.ecp.view.spi.core.swt.ContainerSWTRenderer.renderControl(ContainerSWTRenderer.java:133)
	at org.eclipse.emf.ecp.view.internal.core.swt.renderer.ViewSWTRenderer.renderControl(ViewSWTRenderer.java:100)
	at org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer.render(AbstractSWTRenderer.java:205)
	at org.eclipse.emf.ecp.view.internal.swt.ECPSWTViewRendererImpl.render(ECPSWTViewRendererImpl.java:120)
	at org.eclipse.emf.ecp.ui.e4.editor.ECPE4Editor.setInput(ECPE4Editor.java:110)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)

[Updated on: Tue, 11 December 2018 04:34]

Report message to a moderator

Re: [EMF Forms] New custom controls [message #1799616 is a reply to message #1799590] Tue, 11 December 2018 08:41 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 94
Registered: September 2016
Member
Hi,

custom controls are deprecated, please just implement a custom renderer following the examples (Mail and PGroup). No need to add a custom control in the view model, in the view model, it is just a regular control.
Does this help?

Best regards,
Jonas


--
Jonas Helming
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] New custom controls [message #1799630 is a reply to message #1799616] Tue, 11 December 2018 15:25 Go to previous message
sri pamarti is currently offline sri pamartiFriend
Messages: 15
Registered: August 2015
Junior Member
Thanks Jonas! It worked like a charm. Appreciate your help.

[Updated on: Tue, 11 December 2018 15:26]

Report message to a moderator

Previous Topic:[EMF Forms] Enum Dropdown: Value not set on keyboard input if Enter is not pressed
Next Topic:[EMF FORMS] TableControl WithDialog
Goto Forum:
  


Current Time: Sun Sep 15 07:29:19 GMT 2019

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

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

Back to the top