/** * Generated with Acceleo */ package net.certware.argument.gsn.components; // Start of user code for imports import net.certware.argument.arm.ArmPackage; import net.certware.argument.arm.TaggedValue; import net.certware.argument.gsn.Context; import net.certware.argument.gsn.Goal; import net.certware.argument.gsn.GsnPackage; import net.certware.argument.gsn.Justification; import net.certware.argument.gsn.Solution; import net.certware.argument.gsn.Strategy; import net.certware.argument.gsn.parts.GsnViewsRepository; import net.certware.argument.gsn.parts.StrategyPropertiesEditionPart; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.util.BasicDiagnostic; import org.eclipse.emf.common.util.Diagnostic; import org.eclipse.emf.common.util.WrappedException; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.util.Diagnostician; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.eef.runtime.api.notify.EStructuralFeatureNotificationFilter; import org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent; import org.eclipse.emf.eef.runtime.api.notify.NotificationFilter; import org.eclipse.emf.eef.runtime.context.PropertiesEditingContext; import org.eclipse.emf.eef.runtime.context.impl.EObjectPropertiesEditionContext; import org.eclipse.emf.eef.runtime.context.impl.EReferencePropertiesEditionContext; import org.eclipse.emf.eef.runtime.impl.components.SinglePartPropertiesEditingComponent; import org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent; import org.eclipse.emf.eef.runtime.impl.utils.EEFConverterUtil; import org.eclipse.emf.eef.runtime.policies.PropertiesEditingPolicy; import org.eclipse.emf.eef.runtime.policies.impl.CreateEditingPolicy; import org.eclipse.emf.eef.runtime.providers.PropertiesEditingProvider; import org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; // End of user code /** * * */ public class StrategyPropertiesEditionComponent extends SinglePartPropertiesEditingComponent { public static String BASE_PART = "Base"; //$NON-NLS-1$ /** * Settings for isTagged ReferencesTable */ protected ReferencesTableSettings isTaggedSettings; /** * Settings for goals ReferencesTable */ protected ReferencesTableSettings goalsSettings; /** * Settings for justifications ReferencesTable */ protected ReferencesTableSettings justificationsSettings; /** * Settings for strategyContexts ReferencesTable */ protected ReferencesTableSettings strategyContextsSettings; /** * Settings for strategySolutions ReferencesTable */ protected ReferencesTableSettings strategySolutionsSettings; /** * Default constructor * */ public StrategyPropertiesEditionComponent(PropertiesEditingContext editingContext, EObject strategy, String editing_mode) { super(editingContext, strategy, editing_mode); parts = new String[] { BASE_PART }; repositoryKey = GsnViewsRepository.class; partKey = GsnViewsRepository.Strategy.class; } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject, * org.eclipse.emf.ecore.resource.ResourceSet) * */ public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) { setInitializing(true); if (editingPart != null && key == partKey) { editingPart.setContext(elt, allResource); final Strategy strategy = (Strategy)elt; final StrategyPropertiesEditionPart basePart = (StrategyPropertiesEditionPart)editingPart; // init values if (isAccessible(GsnViewsRepository.Strategy.Properties.identifier)) basePart.setIdentifier(EEFConverterUtil.convertToString(ArmPackage.Literals.STRING, strategy.getIdentifier())); if (isAccessible(GsnViewsRepository.Strategy.Properties.description)) basePart.setDescription(EEFConverterUtil.convertToString(ArmPackage.Literals.STRING, strategy.getDescription())); if (isAccessible(GsnViewsRepository.Strategy.Properties.content)) basePart.setContent(EEFConverterUtil.convertToString(ArmPackage.Literals.STRING, strategy.getContent())); if (isAccessible(GsnViewsRepository.Strategy.Properties.isTagged)) { isTaggedSettings = new ReferencesTableSettings(strategy, ArmPackage.eINSTANCE.getModelElement_IsTagged()); basePart.initIsTagged(isTaggedSettings); } if (isAccessible(GsnViewsRepository.Strategy.Properties.goals)) { goalsSettings = new ReferencesTableSettings(strategy, GsnPackage.eINSTANCE.getStrategy_Goals()); basePart.initGoals(goalsSettings); } if (isAccessible(GsnViewsRepository.Strategy.Properties.justifications)) { justificationsSettings = new ReferencesTableSettings(strategy, GsnPackage.eINSTANCE.getStrategy_Justifications()); basePart.initJustifications(justificationsSettings); } if (isAccessible(GsnViewsRepository.Strategy.Properties.strategyContexts)) { strategyContextsSettings = new ReferencesTableSettings(strategy, GsnPackage.eINSTANCE.getStrategy_StrategyContexts()); basePart.initStrategyContexts(strategyContextsSettings); } if (isAccessible(GsnViewsRepository.Strategy.Properties.strategySolutions)) { strategySolutionsSettings = new ReferencesTableSettings(strategy, GsnPackage.eINSTANCE.getStrategy_StrategySolutions()); basePart.initStrategySolutions(strategySolutionsSettings); } // init filters if (isAccessible(GsnViewsRepository.Strategy.Properties.isTagged)) { basePart.addFilterToIsTagged(new ViewerFilter() { /** * {@inheritDoc} * * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ public boolean select(Viewer viewer, Object parentElement, Object element) { return (element instanceof String && element.equals("")) || (element instanceof TaggedValue); //$NON-NLS-1$ } }); // Start of user code for additional businessfilters for isTagged // End of user code } if (isAccessible(GsnViewsRepository.Strategy.Properties.goals)) { basePart.addFilterToGoals(new ViewerFilter() { /** * {@inheritDoc} * * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ public boolean select(Viewer viewer, Object parentElement, Object element) { return (element instanceof String && element.equals("")) || (element instanceof Goal); //$NON-NLS-1$ } }); // Start of user code for additional businessfilters for goals // End of user code } if (isAccessible(GsnViewsRepository.Strategy.Properties.justifications)) { basePart.addFilterToJustifications(new ViewerFilter() { /** * {@inheritDoc} * * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ public boolean select(Viewer viewer, Object parentElement, Object element) { return (element instanceof String && element.equals("")) || (element instanceof Justification); //$NON-NLS-1$ } }); // Start of user code for additional businessfilters for justifications // End of user code } if (isAccessible(GsnViewsRepository.Strategy.Properties.strategyContexts)) { basePart.addFilterToStrategyContexts(new ViewerFilter() { /** * {@inheritDoc} * * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ public boolean select(Viewer viewer, Object parentElement, Object element) { return (element instanceof String && element.equals("")) || (element instanceof Context); //$NON-NLS-1$ } }); // Start of user code for additional businessfilters for strategyContexts // End of user code } if (isAccessible(GsnViewsRepository.Strategy.Properties.strategySolutions)) { basePart.addFilterToStrategySolutions(new ViewerFilter() { /** * {@inheritDoc} * * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ public boolean select(Viewer viewer, Object parentElement, Object element) { return (element instanceof String && element.equals("")) || (element instanceof Solution); //$NON-NLS-1$ } }); // Start of user code for additional businessfilters for strategySolutions // End of user code } // init values for referenced views // init filters for referenced views } setInitializing(false); } /** * {@inheritDoc} * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#associatedFeature(java.lang.Object) */ public EStructuralFeature associatedFeature(Object editorKey) { if (editorKey == GsnViewsRepository.Strategy.Properties.identifier) { return ArmPackage.eINSTANCE.getModelElement_Identifier(); } if (editorKey == GsnViewsRepository.Strategy.Properties.description) { return ArmPackage.eINSTANCE.getModelElement_Description(); } if (editorKey == GsnViewsRepository.Strategy.Properties.content) { return ArmPackage.eINSTANCE.getModelElement_Content(); } if (editorKey == GsnViewsRepository.Strategy.Properties.isTagged) { return ArmPackage.eINSTANCE.getModelElement_IsTagged(); } if (editorKey == GsnViewsRepository.Strategy.Properties.goals) { return GsnPackage.eINSTANCE.getStrategy_Goals(); } if (editorKey == GsnViewsRepository.Strategy.Properties.justifications) { return GsnPackage.eINSTANCE.getStrategy_Justifications(); } if (editorKey == GsnViewsRepository.Strategy.Properties.strategyContexts) { return GsnPackage.eINSTANCE.getStrategy_StrategyContexts(); } if (editorKey == GsnViewsRepository.Strategy.Properties.strategySolutions) { return GsnPackage.eINSTANCE.getStrategy_StrategySolutions(); } return super.associatedFeature(editorKey); } /** * {@inheritDoc} * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updateSemanticModel(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) * */ public void updateSemanticModel(final IPropertiesEditionEvent event) { Strategy strategy = (Strategy)semanticObject; if (GsnViewsRepository.Strategy.Properties.identifier == event.getAffectedEditor()) { strategy.setIdentifier((java.lang.String)EEFConverterUtil.createFromString(ArmPackage.Literals.STRING, (String)event.getNewValue())); } if (GsnViewsRepository.Strategy.Properties.description == event.getAffectedEditor()) { strategy.setDescription((java.lang.String)EEFConverterUtil.createFromString(ArmPackage.Literals.STRING, (String)event.getNewValue())); } if (GsnViewsRepository.Strategy.Properties.content == event.getAffectedEditor()) { strategy.setContent((java.lang.String)EEFConverterUtil.createFromString(ArmPackage.Literals.STRING, (String)event.getNewValue())); } if (GsnViewsRepository.Strategy.Properties.isTagged == event.getAffectedEditor()) { if (event.getKind() == PropertiesEditionEvent.ADD) { EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, isTaggedSettings, editingContext.getAdapterFactory()); 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) { isTaggedSettings.removeFromReference((EObject) event.getNewValue()); } else if (event.getKind() == PropertiesEditionEvent.MOVE) { isTaggedSettings.move(event.getNewIndex(), (TaggedValue) event.getNewValue()); } } if (GsnViewsRepository.Strategy.Properties.goals == event.getAffectedEditor()) { if (event.getKind() == PropertiesEditionEvent.ADD) { EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, goalsSettings, editingContext.getAdapterFactory()); 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) { goalsSettings.removeFromReference((EObject) event.getNewValue()); } else if (event.getKind() == PropertiesEditionEvent.MOVE) { goalsSettings.move(event.getNewIndex(), (Goal) event.getNewValue()); } } if (GsnViewsRepository.Strategy.Properties.justifications == event.getAffectedEditor()) { if (event.getKind() == PropertiesEditionEvent.ADD) { EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, justificationsSettings, editingContext.getAdapterFactory()); 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) { justificationsSettings.removeFromReference((EObject) event.getNewValue()); } else if (event.getKind() == PropertiesEditionEvent.MOVE) { justificationsSettings.move(event.getNewIndex(), (Justification) event.getNewValue()); } } if (GsnViewsRepository.Strategy.Properties.strategyContexts == event.getAffectedEditor()) { if (event.getKind() == PropertiesEditionEvent.ADD) { EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, strategyContextsSettings, editingContext.getAdapterFactory()); 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) { strategyContextsSettings.removeFromReference((EObject) event.getNewValue()); } else if (event.getKind() == PropertiesEditionEvent.MOVE) { strategyContextsSettings.move(event.getNewIndex(), (Context) event.getNewValue()); } } if (GsnViewsRepository.Strategy.Properties.strategySolutions == event.getAffectedEditor()) { if (event.getKind() == PropertiesEditionEvent.ADD) { EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, strategySolutionsSettings, editingContext.getAdapterFactory()); 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) { strategySolutionsSettings.removeFromReference((EObject) event.getNewValue()); } else if (event.getKind() == PropertiesEditionEvent.MOVE) { strategySolutionsSettings.move(event.getNewIndex(), (Solution) event.getNewValue()); } } } /** * {@inheritDoc} * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updatePart(org.eclipse.emf.common.notify.Notification) */ public void updatePart(Notification msg) { super.updatePart(msg); if (editingPart.isVisible()) { StrategyPropertiesEditionPart basePart = (StrategyPropertiesEditionPart)editingPart; if (ArmPackage.eINSTANCE.getModelElement_Identifier().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(GsnViewsRepository.Strategy.Properties.identifier)) { if (msg.getNewValue() != null) { basePart.setIdentifier(EcoreUtil.convertToString(ArmPackage.Literals.STRING, msg.getNewValue())); } else { basePart.setIdentifier(""); } } if (ArmPackage.eINSTANCE.getModelElement_Description().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(GsnViewsRepository.Strategy.Properties.description)) { if (msg.getNewValue() != null) { basePart.setDescription(EcoreUtil.convertToString(ArmPackage.Literals.STRING, msg.getNewValue())); } else { basePart.setDescription(""); } } if (ArmPackage.eINSTANCE.getModelElement_Content().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(GsnViewsRepository.Strategy.Properties.content)) { if (msg.getNewValue() != null) { basePart.setContent(EcoreUtil.convertToString(ArmPackage.Literals.STRING, msg.getNewValue())); } else { basePart.setContent(""); } } if (ArmPackage.eINSTANCE.getModelElement_IsTagged().equals(msg.getFeature()) && isAccessible(GsnViewsRepository.Strategy.Properties.isTagged)) basePart.updateIsTagged(); if (GsnPackage.eINSTANCE.getStrategy_Goals().equals(msg.getFeature()) && isAccessible(GsnViewsRepository.Strategy.Properties.goals)) basePart.updateGoals(); if (GsnPackage.eINSTANCE.getStrategy_Justifications().equals(msg.getFeature()) && isAccessible(GsnViewsRepository.Strategy.Properties.justifications)) basePart.updateJustifications(); if (GsnPackage.eINSTANCE.getStrategy_StrategyContexts().equals(msg.getFeature()) && isAccessible(GsnViewsRepository.Strategy.Properties.strategyContexts)) basePart.updateStrategyContexts(); if (GsnPackage.eINSTANCE.getStrategy_StrategySolutions().equals(msg.getFeature()) && isAccessible(GsnViewsRepository.Strategy.Properties.strategySolutions)) basePart.updateStrategySolutions(); } } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#getNotificationFilters() */ @Override protected NotificationFilter[] getNotificationFilters() { NotificationFilter filter = new EStructuralFeatureNotificationFilter( ArmPackage.eINSTANCE.getModelElement_Identifier(), ArmPackage.eINSTANCE.getModelElement_Description(), ArmPackage.eINSTANCE.getModelElement_Content(), ArmPackage.eINSTANCE.getModelElement_IsTagged(), GsnPackage.eINSTANCE.getStrategy_Goals(), GsnPackage.eINSTANCE.getStrategy_Justifications(), GsnPackage.eINSTANCE.getStrategy_StrategyContexts(), GsnPackage.eINSTANCE.getStrategy_StrategySolutions() ); return new NotificationFilter[] {filter,}; } /** * {@inheritDoc} * * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) * */ public Diagnostic validateValue(IPropertiesEditionEvent event) { Diagnostic ret = Diagnostic.OK_INSTANCE; if (event.getNewValue() != null) { try { if (GsnViewsRepository.Strategy.Properties.identifier == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(ArmPackage.eINSTANCE.getModelElement_Identifier().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(ArmPackage.eINSTANCE.getModelElement_Identifier().getEAttributeType(), newValue); } if (GsnViewsRepository.Strategy.Properties.description == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(ArmPackage.eINSTANCE.getModelElement_Description().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(ArmPackage.eINSTANCE.getModelElement_Description().getEAttributeType(), newValue); } if (GsnViewsRepository.Strategy.Properties.content == event.getAffectedEditor()) { Object newValue = event.getNewValue(); if (newValue instanceof String) { newValue = EEFConverterUtil.createFromString(ArmPackage.eINSTANCE.getModelElement_Content().getEAttributeType(), (String)newValue); } ret = Diagnostician.INSTANCE.validate(ArmPackage.eINSTANCE.getModelElement_Content().getEAttributeType(), newValue); } } catch (IllegalArgumentException iae) { ret = BasicDiagnostic.toDiagnostic(iae); } catch (WrappedException we) { ret = BasicDiagnostic.toDiagnostic(we); } } return ret; } }