Skip to main content



      Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » EMF Forms: How to disable the add button for references field
EMF Forms: How to disable the add button for references field [message #1755477] Fri, 03 March 2017 10:32 Go to next message
Eclipse UserFriend
Hi,

If someone has a guideline to do that in EMF Forms:
disable the add button for references field

I am very interested for that.

Rgds
Jim
Re: EMF Forms: How to disable the add button for references field [message #1755602 is a reply to message #1755477] Mon, 06 March 2017 04:38 Go to previous messageGo to next message
Eclipse UserFriend
Hi Jim,
you have to provide a custom renderer for this.
So you have to subclass org.eclipse.emf.ecp.view.internal.control.multireference.MultiReferenceSWTRenderer.MultiReferenceSWTRenderer(VControl, ViewModelContext, ReportService, EMFFormsDatabinding, EMFFormsLabelProvider, VTViewTemplateProvider, ImageRegistryService) and here you can overwrite eg org.eclipse.emf.ecp.view.internal.control.multireference.MultiReferenceSWTRenderer.showAddNewButton() .
You will also need the service which registers the control, check this blog post for this:http://eclipsesource.com/blogs/tutorials/how-to-customize-emf-forms/#customizecontrols

Cheers,
Eugen
Re: EMF Forms: How to disable the add button for references field [message #1755637 is a reply to message #1755602] Mon, 06 March 2017 08:04 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Thx but to fight against such documentation is not easy.
I am not sure that a normal developer as I am can manage easily the task.

Especially to inject the ImageRegistryService?
I don't see any doc...

I am even not sure that it will work in my Eclipse 3 application? as if I remember I tested such @inject annotations, and it works only in Eclipse 4 application?

Can you help me pls?



Re: EMF Forms: How to disable the add button for references field [message #1755639 is a reply to message #1755637] Mon, 06 March 2017 08:22 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I finally managed to add the Image Registry.

So I added my plugin to my final product but it seems that the registration of the service is not done.
the isApplicable Method is not called in my debug mode.

Here is the code:

package biz.astron.sales.quoting.ui.renderer.levelscontrol;

import org.eclipse.core.databinding.property.value.IValueProperty;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
import org.eclipse.emf.ecp.view.spi.model.VControl;
import org.eclipse.emf.ecp.view.spi.model.VElement;
import org.eclipse.emfforms.spi.common.report.ReportService;
import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException;
import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedReport;
import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
import org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer;
import org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererService;

import biz.astron.sales.quoting.QuotingPackage;

public class LevelsControlSWTRendererService 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;
}

/**
* {@inheritDoc}
*
* @see org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererService#isApplicable(VElement,ViewModelContext)
*/
@Override
public double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
if (!VControl.class.isInstance(vElement)) {
return NOT_APPLICABLE;
}
final VControl control = (VControl) vElement;
if (control.getDomainModelReference() == null) {
return NOT_APPLICABLE;
}
@SuppressWarnings("rawtypes")
IValueProperty valueProperty;
try {
valueProperty = databindingService.getValueProperty(control.getDomainModelReference(),
viewModelContext.getDomainModel());
} catch (final DatabindingFailedException ex) {
reportService.report(new DatabindingFailedReport(ex));
return NOT_APPLICABLE;
}
final EStructuralFeature eStructuralFeature = EStructuralFeature.class.cast(valueProperty.getValueType());
if (QuotingPackage.eINSTANCE.getEngineeringPart_Levels().equals(eStructuralFeature)) {
return 10;
}
return NOT_APPLICABLE;
}

/**
* {@inheritDoc}
*
* @see org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererService#getRendererClass()
*/
@Override
public Class<? extends AbstractSWTRenderer<VControl>> getRendererClass() {
return LevelsControlRenderer.class;
}

}
Re: EMF Forms: How to disable the add button for references field [message #1755642 is a reply to message #1755639] Mon, 06 March 2017 08:43 Go to previous message
Eclipse UserFriend

It works finally.

Thx Eugen

Previous Topic:Extending ECPReferenceService
Next Topic:EMF Forms: Customize derived field - Modification is ignored
Goto Forum:
  


Current Time: Thu Jun 19 19:06:08 EDT 2025

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

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

Back to the top