Search in sources :

Example 1 with TypedEReferencePropertiesEditingContext

use of org.eclipse.emf.eef.runtime.context.impl.TypedEReferencePropertiesEditingContext in project InformationSystem by ObeoNetwork.

the class MetadataCptPropertiesEditionComponent method updateSemanticModel.

/**
 * {@inheritDoc}
 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updateSemanticModel(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
 * @generated NOT
 */
public void updateSemanticModel(final IPropertiesEditionEvent event) {
    ObeoDSMObject obeoDSMObject = (ObeoDSMObject) semanticObject;
    if (EnvironmentViewsRepository.Metadatas.Properties.metadata == event.getAffectedEditor()) {
        if (event.getKind() == PropertiesEditionEvent.ADD) {
            EReferencePropertiesEditionContext context = new TypedEReferencePropertiesEditingContext(editingContext, this, metadataSettings, EnvironmentPackage.Literals.ANNOTATION, editingContext.getAdapterFactory());
            /*
				 * Generated code below, but it leads to NPE when clicking on the add button
				 * 
				EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, metadataSettings, editingContext.getAdapterFactory());
				context.addInstanciableTypeFilter(new InstanciableTypeFilter() {
					public boolean select(EClass instanciableType) {
						return EnvironmentPackage.Literals.ANNOTATION == instanciableType;
					}
				});
				*/
            PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt(semanticObject, PropertiesEditingProvider.class);
            if (provider != null) {
                PropertiesEditingPolicy policy = provider.getPolicy(context);
                if (policy instanceof CreateEditingPolicy) {
                    policy.execute();
                }
            }
        } else if (event.getKind() == PropertiesEditionEvent.EDIT) {
            EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(editingContext, this, (EObject) event.getNewValue(), editingContext.getAdapterFactory());
            PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt((EObject) event.getNewValue(), PropertiesEditingProvider.class);
            if (provider != null) {
                PropertiesEditingPolicy editionPolicy = provider.getPolicy(context);
                if (editionPolicy != null) {
                    editionPolicy.execute();
                }
            }
        } else if (event.getKind() == PropertiesEditionEvent.REMOVE) {
            metadataSettings.removeFromReference((EObject) event.getNewValue());
        } else if (event.getKind() == PropertiesEditionEvent.MOVE) {
            metadataSettings.move(event.getNewIndex(), (MetaData) event.getNewValue());
        }
    }
}
Also used : EObjectPropertiesEditionContext(org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext) PropertiesEditingProvider(org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider) MetaData(org.obeonetwork.dsl.environment.MetaData) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) TypedEReferencePropertiesEditingContext(org.eclipse.emf.eef.runtime.context.impl.TypedEReferencePropertiesEditingContext) EObject(org.eclipse.emf.ecore.EObject) PropertiesEditingPolicy(org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy) CreateEditingPolicy(org.eclipse.emf.eef.runtime.policies.impl.CreateEditingPolicy) EReferencePropertiesEditionContext(org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)1 EObjectPropertiesEditionContext (org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext)1 EReferencePropertiesEditionContext (org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext)1 TypedEReferencePropertiesEditingContext (org.eclipse.emf.eef.runtime.context.impl.TypedEReferencePropertiesEditingContext)1 PropertiesEditingPolicy (org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy)1 CreateEditingPolicy (org.eclipse.emf.eef.runtime.policies.impl.CreateEditingPolicy)1 PropertiesEditingProvider (org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider)1 MetaData (org.obeonetwork.dsl.environment.MetaData)1 ObeoDSMObject (org.obeonetwork.dsl.environment.ObeoDSMObject)1