/**
* 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.ModelElement;
import net.certware.argument.arm.TaggedValue;
import net.certware.argument.gsn.Context;
import net.certware.argument.gsn.Evidence;
import net.certware.argument.gsn.GsnPackage;
import net.certware.argument.gsn.Solution;
import net.certware.argument.gsn.parts.GsnViewsRepository;
import net.certware.argument.gsn.parts.SolutionPropertiesEditionPart;
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.filters.EObjectFilter;
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 SolutionPropertiesEditionComponent extends SinglePartPropertiesEditingComponent {
public static String BASE_PART = "Base"; //$NON-NLS-1$
/**
* Settings for isTagged ReferencesTable
*/
protected ReferencesTableSettings isTaggedSettings;
/**
* Settings for target ReferencesTable
*/
private ReferencesTableSettings targetSettings;
/**
* Settings for source ReferencesTable
*/
private ReferencesTableSettings sourceSettings;
/**
* Settings for solutionEvidence ReferencesTable
*/
protected ReferencesTableSettings solutionEvidenceSettings;
/**
* Settings for solutionContexts ReferencesTable
*/
protected ReferencesTableSettings solutionContextsSettings;
/**
* Default constructor
*
*/
public SolutionPropertiesEditionComponent(PropertiesEditingContext editingContext, EObject solution, String editing_mode) {
super(editingContext, solution, editing_mode);
parts = new String[] { BASE_PART };
repositoryKey = GsnViewsRepository.class;
partKey = GsnViewsRepository.Solution.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 Solution solution = (Solution)elt;
final SolutionPropertiesEditionPart basePart = (SolutionPropertiesEditionPart)editingPart;
// init values
if (isAccessible(GsnViewsRepository.Solution.Properties.identifier))
basePart.setIdentifier(EEFConverterUtil.convertToString(ArmPackage.Literals.STRING, solution.getIdentifier()));
if (isAccessible(GsnViewsRepository.Solution.Properties.description))
basePart.setDescription(EEFConverterUtil.convertToString(ArmPackage.Literals.STRING, solution.getDescription()));
if (isAccessible(GsnViewsRepository.Solution.Properties.content))
basePart.setContent(EEFConverterUtil.convertToString(ArmPackage.Literals.STRING, solution.getContent()));
if (isAccessible(GsnViewsRepository.Solution.Properties.isTagged)) {
isTaggedSettings = new ReferencesTableSettings(solution, ArmPackage.eINSTANCE.getModelElement_IsTagged());
basePart.initIsTagged(isTaggedSettings);
}
if (isAccessible(GsnViewsRepository.Solution.Properties.target)) {
targetSettings = new ReferencesTableSettings(solution, ArmPackage.eINSTANCE.getArgumentLink_Target());
basePart.initTarget(targetSettings);
}
if (isAccessible(GsnViewsRepository.Solution.Properties.source)) {
sourceSettings = new ReferencesTableSettings(solution, ArmPackage.eINSTANCE.getArgumentLink_Source());
basePart.initSource(sourceSettings);
}
if (isAccessible(GsnViewsRepository.Solution.Properties.solutionEvidence)) {
solutionEvidenceSettings = new ReferencesTableSettings(solution, GsnPackage.eINSTANCE.getSolution_SolutionEvidence());
basePart.initSolutionEvidence(solutionEvidenceSettings);
}
if (isAccessible(GsnViewsRepository.Solution.Properties.solutionContexts)) {
solutionContextsSettings = new ReferencesTableSettings(solution, GsnPackage.eINSTANCE.getSolution_SolutionContexts());
basePart.initSolutionContexts(solutionContextsSettings);
}
// init filters
if (isAccessible(GsnViewsRepository.Solution.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.Solution.Properties.target)) {
basePart.addFilterToTarget(new EObjectFilter(ArmPackage.Literals.MODEL_ELEMENT));
// Start of user code for additional businessfilters for target
// End of user code
}
if (isAccessible(GsnViewsRepository.Solution.Properties.source)) {
basePart.addFilterToSource(new EObjectFilter(ArmPackage.Literals.MODEL_ELEMENT));
// Start of user code for additional businessfilters for source
// End of user code
}
if (isAccessible(GsnViewsRepository.Solution.Properties.solutionEvidence)) {
basePart.addFilterToSolutionEvidence(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 Evidence); //$NON-NLS-1$
}
});
// Start of user code for additional businessfilters for solutionEvidence
// End of user code
}
if (isAccessible(GsnViewsRepository.Solution.Properties.solutionContexts)) {
basePart.addFilterToSolutionContexts(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 solutionContexts
// 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.Solution.Properties.identifier) {
return ArmPackage.eINSTANCE.getModelElement_Identifier();
}
if (editorKey == GsnViewsRepository.Solution.Properties.description) {
return ArmPackage.eINSTANCE.getModelElement_Description();
}
if (editorKey == GsnViewsRepository.Solution.Properties.content) {
return ArmPackage.eINSTANCE.getModelElement_Content();
}
if (editorKey == GsnViewsRepository.Solution.Properties.isTagged) {
return ArmPackage.eINSTANCE.getModelElement_IsTagged();
}
if (editorKey == GsnViewsRepository.Solution.Properties.target) {
return ArmPackage.eINSTANCE.getArgumentLink_Target();
}
if (editorKey == GsnViewsRepository.Solution.Properties.source) {
return ArmPackage.eINSTANCE.getArgumentLink_Source();
}
if (editorKey == GsnViewsRepository.Solution.Properties.solutionEvidence) {
return GsnPackage.eINSTANCE.getSolution_SolutionEvidence();
}
if (editorKey == GsnViewsRepository.Solution.Properties.solutionContexts) {
return GsnPackage.eINSTANCE.getSolution_SolutionContexts();
}
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) {
Solution solution = (Solution)semanticObject;
if (GsnViewsRepository.Solution.Properties.identifier == event.getAffectedEditor()) {
solution.setIdentifier((java.lang.String)EEFConverterUtil.createFromString(ArmPackage.Literals.STRING, (String)event.getNewValue()));
}
if (GsnViewsRepository.Solution.Properties.description == event.getAffectedEditor()) {
solution.setDescription((java.lang.String)EEFConverterUtil.createFromString(ArmPackage.Literals.STRING, (String)event.getNewValue()));
}
if (GsnViewsRepository.Solution.Properties.content == event.getAffectedEditor()) {
solution.setContent((java.lang.String)EEFConverterUtil.createFromString(ArmPackage.Literals.STRING, (String)event.getNewValue()));
}
if (GsnViewsRepository.Solution.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.Solution.Properties.target == event.getAffectedEditor()) {
if (event.getKind() == PropertiesEditionEvent.ADD) {
if (event.getNewValue() instanceof ModelElement) {
targetSettings.addToReference((EObject) event.getNewValue());
}
} else if (event.getKind() == PropertiesEditionEvent.REMOVE) {
targetSettings.removeFromReference((EObject) event.getNewValue());
} else if (event.getKind() == PropertiesEditionEvent.MOVE) {
targetSettings.move(event.getNewIndex(), (ModelElement) event.getNewValue());
}
}
if (GsnViewsRepository.Solution.Properties.source == event.getAffectedEditor()) {
if (event.getKind() == PropertiesEditionEvent.ADD) {
if (event.getNewValue() instanceof ModelElement) {
sourceSettings.addToReference((EObject) event.getNewValue());
}
} else if (event.getKind() == PropertiesEditionEvent.REMOVE) {
sourceSettings.removeFromReference((EObject) event.getNewValue());
} else if (event.getKind() == PropertiesEditionEvent.MOVE) {
sourceSettings.move(event.getNewIndex(), (ModelElement) event.getNewValue());
}
}
if (GsnViewsRepository.Solution.Properties.solutionEvidence == event.getAffectedEditor()) {
if (event.getKind() == PropertiesEditionEvent.ADD) {
EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, solutionEvidenceSettings, 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) {
solutionEvidenceSettings.removeFromReference((EObject) event.getNewValue());
} else if (event.getKind() == PropertiesEditionEvent.MOVE) {
solutionEvidenceSettings.move(event.getNewIndex(), (Evidence) event.getNewValue());
}
}
if (GsnViewsRepository.Solution.Properties.solutionContexts == event.getAffectedEditor()) {
if (event.getKind() == PropertiesEditionEvent.ADD) {
EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, solutionContextsSettings, 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) {
solutionContextsSettings.removeFromReference((EObject) event.getNewValue());
} else if (event.getKind() == PropertiesEditionEvent.MOVE) {
solutionContextsSettings.move(event.getNewIndex(), (Context) 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()) {
SolutionPropertiesEditionPart basePart = (SolutionPropertiesEditionPart)editingPart;
if (ArmPackage.eINSTANCE.getModelElement_Identifier().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(GsnViewsRepository.Solution.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.Solution.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.Solution.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.Solution.Properties.isTagged))
basePart.updateIsTagged();
if (ArmPackage.eINSTANCE.getArgumentLink_Target().equals(msg.getFeature()) && isAccessible(GsnViewsRepository.Solution.Properties.target))
basePart.updateTarget();
if (ArmPackage.eINSTANCE.getArgumentLink_Source().equals(msg.getFeature()) && isAccessible(GsnViewsRepository.Solution.Properties.source))
basePart.updateSource();
if (GsnPackage.eINSTANCE.getSolution_SolutionEvidence().equals(msg.getFeature()) && isAccessible(GsnViewsRepository.Solution.Properties.solutionEvidence))
basePart.updateSolutionEvidence();
if (GsnPackage.eINSTANCE.getSolution_SolutionContexts().equals(msg.getFeature()) && isAccessible(GsnViewsRepository.Solution.Properties.solutionContexts))
basePart.updateSolutionContexts();
}
}
/**
* {@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(),
ArmPackage.eINSTANCE.getArgumentLink_Target(),
ArmPackage.eINSTANCE.getArgumentLink_Source(),
GsnPackage.eINSTANCE.getSolution_SolutionEvidence(),
GsnPackage.eINSTANCE.getSolution_SolutionContexts() );
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.Solution.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.Solution.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.Solution.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;
}
}