Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 314089

Summary: Cannot add implementation to component EClass
Product: z_Archived Reporter: Eneko Fernandez <eneko.fernandez>
Component: ScaAssignee: Project Inbox <stp.sca-inbox>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: Stephane.Drapeau
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Eneko Fernandez CLA 2010-05-24 06:02:07 EDT
sca.ecore sets component´s attribute implementation as not changeable. This makes impossible to deal with new components creation through dyanmic emf.

Error example:

	Component component = ScaFactory.eINSTANCE.createComponent();
		composite.getComponent().add(component);
		component.setName(componentName);
		// Create component´s implementation 
		JavaImplementation implementation = ScaFactory.eINSTANCE.createJavaImplementation();
		implementation.setClass(compositeName + "." + componentName);
		component.eSet(ScaPackage.Literals.COMPONENT__IMPLEMENTATION, implementation);

Returns: 

java.lang.IllegalArgumentException: The feature 'implementation' is not a valid changeable feature
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1093)

I guess that there is an error in ecor´s file and implementation EAttribute should be changeable = true
Comment 1 Stephane Drapeau CLA 2010-05-25 03:36:09 EDT
Hi Eneko,

It's not an error. To modify the implementation, you must use the feature "implementation group":

JavaImplementation newValue = ScaFactory.eINSTANCE.createJavaImplementation();

((FeatureMap.Internal) component.getImplementationGroup()).clear();

((FeatureMap.Internal) component.getImplementationGroup()).add( ScaPackage.Literals.COMPONENT__IMPLEMENTATION_GROUP,FeatureMapUtil.createEntry( ScaPackage.Literals.DOCUMENT_ROOT__IMPLEMENTATION_JAVA, newValue));

It's the same way of doing to add an interface or a binding.
Comment 2 Eneko Fernandez CLA 2010-05-31 02:52:54 EDT
Thanks for the answer. I could manage as you said.

Best