| /******************************************************************************* |
| * Copyright (c) 2016 Fundación Tecnalia Research & Innovation. |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Huascar Espinoza - initial API and implementation |
| * Alejandra Ruíz - initial API and implementation |
| * Idoya Del Río - initial API and implementation |
| * Mari Carmen Palacios - initial API and implementation |
| * Angel López - initial API and implementation |
| *******************************************************************************/ |
| /** |
| * Generated with Acceleo |
| */ |
| package org.eclipse.opencert.sam.arg.arg.components; |
| |
| // Start of user code for imports |
| 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.EcorePackage;
|
|
|
| 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.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.impl.utils.EEFUtils;
|
|
|
| import org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings;
|
|
|
| import org.eclipse.opencert.sam.arg.arg.ArgPackage;
|
| import org.eclipse.opencert.sam.arg.arg.ArgumentationElement;
|
| import org.eclipse.opencert.sam.arg.arg.AssertedByMultiplicityExtension;
|
| import org.eclipse.opencert.sam.arg.arg.AssertedContext;
|
|
|
| import org.eclipse.opencert.sam.arg.arg.parts.ArgViewsRepository;
|
| import org.eclipse.opencert.sam.arg.arg.parts.AssertedContextPropertiesEditionPart; |
| |
| |
| // End of user code |
| |
| /** |
| * |
| * |
| */ |
| public class AssertedContextPropertiesEditionComponent extends SinglePartPropertiesEditingComponent { |
| |
| |
| public static String BASE_PART = "Base"; //$NON-NLS-1$ |
| |
| |
| /** |
| * Settings for source ReferencesTable |
| */ |
| private ReferencesTableSettings sourceSettings; |
| |
| /** |
| * Settings for target ReferencesTable |
| */ |
| private ReferencesTableSettings targetSettings; |
| |
| |
| /** |
| * Default constructor |
| * |
| */ |
| public AssertedContextPropertiesEditionComponent(PropertiesEditingContext editingContext, EObject assertedContext, String editing_mode) { |
| super(editingContext, assertedContext, editing_mode); |
| parts = new String[] { BASE_PART }; |
| repositoryKey = ArgViewsRepository.class; |
| partKey = ArgViewsRepository.AssertedContext.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 AssertedContext assertedContext = (AssertedContext)elt; |
| final AssertedContextPropertiesEditionPart basePart = (AssertedContextPropertiesEditionPart)editingPart; |
| // init values |
| if (isAccessible(ArgViewsRepository.AssertedContext.Properties.id)) |
| basePart.setId(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, assertedContext.getId())); |
| |
| if (isAccessible(ArgViewsRepository.AssertedContext.Properties.name)) |
| basePart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, assertedContext.getName())); |
| |
| if (isAccessible(ArgViewsRepository.AssertedContext.Properties.description)) |
| basePart.setDescription(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, assertedContext.getDescription())); |
| |
| if (isAccessible(ArgViewsRepository.AssertedContext.Properties.content)) |
| basePart.setContent(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, assertedContext.getContent())); |
| |
| if (isAccessible(ArgViewsRepository.AssertedContext.Properties.multiextension)) { |
| basePart.initMultiextension(EEFUtils.choiceOfValues(assertedContext, ArgPackage.eINSTANCE.getAssertedContext_Multiextension()), assertedContext.getMultiextension()); |
| } |
| if (isAccessible(ArgViewsRepository.AssertedContext.Properties.cardinality)) |
| basePart.setCardinality(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, assertedContext.getCardinality())); |
| |
| if (isAccessible(ArgViewsRepository.AssertedContext.Properties.source)) { |
| sourceSettings = new ReferencesTableSettings(assertedContext, ArgPackage.eINSTANCE.getAssertedContext_Source()); |
| basePart.initSource(sourceSettings); |
| } |
| if (isAccessible(ArgViewsRepository.AssertedContext.Properties.target)) { |
| targetSettings = new ReferencesTableSettings(assertedContext, ArgPackage.eINSTANCE.getAssertedContext_Target()); |
| basePart.initTarget(targetSettings); |
| } |
| // init filters |
| |
| |
| |
| |
| |
| |
| if (isAccessible(ArgViewsRepository.AssertedContext.Properties.source)) { |
| basePart.addFilterToSource(new EObjectFilter(ArgPackage.Literals.ARGUMENTATION_ELEMENT)); |
| // Start of user code for additional businessfilters for source |
| // End of user code |
| } |
| if (isAccessible(ArgViewsRepository.AssertedContext.Properties.target)) { |
| basePart.addFilterToTarget(new EObjectFilter(ArgPackage.Literals.ARGUMENTATION_ELEMENT)); |
| // Start of user code for additional businessfilters for target |
| // 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 == ArgViewsRepository.AssertedContext.Properties.id) { |
| return ArgPackage.eINSTANCE.getModelElement_Id(); |
| } |
| if (editorKey == ArgViewsRepository.AssertedContext.Properties.name) { |
| return ArgPackage.eINSTANCE.getModelElement_Name(); |
| } |
| if (editorKey == ArgViewsRepository.AssertedContext.Properties.description) { |
| return ArgPackage.eINSTANCE.getArgumentationElement_Description(); |
| } |
| if (editorKey == ArgViewsRepository.AssertedContext.Properties.content) { |
| return ArgPackage.eINSTANCE.getArgumentationElement_Content(); |
| } |
| if (editorKey == ArgViewsRepository.AssertedContext.Properties.multiextension) { |
| return ArgPackage.eINSTANCE.getAssertedContext_Multiextension(); |
| } |
| if (editorKey == ArgViewsRepository.AssertedContext.Properties.cardinality) { |
| return ArgPackage.eINSTANCE.getAssertedContext_Cardinality(); |
| } |
| if (editorKey == ArgViewsRepository.AssertedContext.Properties.source) { |
| return ArgPackage.eINSTANCE.getAssertedContext_Source(); |
| } |
| if (editorKey == ArgViewsRepository.AssertedContext.Properties.target) { |
| return ArgPackage.eINSTANCE.getAssertedContext_Target(); |
| } |
| 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) { |
| AssertedContext assertedContext = (AssertedContext)semanticObject; |
| if (ArgViewsRepository.AssertedContext.Properties.id == event.getAffectedEditor()) { |
| assertedContext.setId((java.lang.String)EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String)event.getNewValue())); |
| } |
| if (ArgViewsRepository.AssertedContext.Properties.name == event.getAffectedEditor()) { |
| assertedContext.setName((java.lang.String)EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String)event.getNewValue())); |
| } |
| if (ArgViewsRepository.AssertedContext.Properties.description == event.getAffectedEditor()) { |
| assertedContext.setDescription((java.lang.String)EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String)event.getNewValue())); |
| } |
| if (ArgViewsRepository.AssertedContext.Properties.content == event.getAffectedEditor()) { |
| assertedContext.setContent((java.lang.String)EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String)event.getNewValue())); |
| } |
| if (ArgViewsRepository.AssertedContext.Properties.multiextension == event.getAffectedEditor()) { |
| assertedContext.setMultiextension((AssertedByMultiplicityExtension)event.getNewValue()); |
| } |
| if (ArgViewsRepository.AssertedContext.Properties.cardinality == event.getAffectedEditor()) { |
| assertedContext.setCardinality((java.lang.String)EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String)event.getNewValue())); |
| } |
| if (ArgViewsRepository.AssertedContext.Properties.source == event.getAffectedEditor()) { |
| if (event.getKind() == PropertiesEditionEvent.ADD) { |
| if (event.getNewValue() instanceof ArgumentationElement) { |
| 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(), (ArgumentationElement) event.getNewValue()); |
| } |
| } |
| if (ArgViewsRepository.AssertedContext.Properties.target == event.getAffectedEditor()) { |
| if (event.getKind() == PropertiesEditionEvent.ADD) { |
| if (event.getNewValue() instanceof ArgumentationElement) { |
| 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(), (ArgumentationElement) 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()) { |
| AssertedContextPropertiesEditionPart basePart = (AssertedContextPropertiesEditionPart)editingPart; |
| if (ArgPackage.eINSTANCE.getModelElement_Id().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(ArgViewsRepository.AssertedContext.Properties.id)) { |
| if (msg.getNewValue() != null) { |
| basePart.setId(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue())); |
| } else { |
| basePart.setId(""); |
| } |
| } |
| if (ArgPackage.eINSTANCE.getModelElement_Name().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(ArgViewsRepository.AssertedContext.Properties.name)) { |
| if (msg.getNewValue() != null) { |
| basePart.setName(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue())); |
| } else { |
| basePart.setName(""); |
| } |
| } |
| if (ArgPackage.eINSTANCE.getArgumentationElement_Description().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(ArgViewsRepository.AssertedContext.Properties.description)) { |
| if (msg.getNewValue() != null) { |
| basePart.setDescription(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue())); |
| } else { |
| basePart.setDescription(""); |
| } |
| } |
| if (ArgPackage.eINSTANCE.getArgumentationElement_Content().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(ArgViewsRepository.AssertedContext.Properties.content)) { |
| if (msg.getNewValue() != null) { |
| basePart.setContent(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue())); |
| } else { |
| basePart.setContent(""); |
| } |
| } |
| if (ArgPackage.eINSTANCE.getAssertedContext_Multiextension().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && isAccessible(ArgViewsRepository.AssertedContext.Properties.multiextension)) |
| basePart.setMultiextension((AssertedByMultiplicityExtension)msg.getNewValue()); |
| |
| if (ArgPackage.eINSTANCE.getAssertedContext_Cardinality().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(ArgViewsRepository.AssertedContext.Properties.cardinality)) { |
| if (msg.getNewValue() != null) { |
| basePart.setCardinality(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue())); |
| } else { |
| basePart.setCardinality(""); |
| } |
| } |
| if (ArgPackage.eINSTANCE.getAssertedContext_Source().equals(msg.getFeature()) && isAccessible(ArgViewsRepository.AssertedContext.Properties.source)) |
| basePart.updateSource(); |
| if (ArgPackage.eINSTANCE.getAssertedContext_Target().equals(msg.getFeature()) && isAccessible(ArgViewsRepository.AssertedContext.Properties.target)) |
| basePart.updateTarget(); |
| |
| } |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#getNotificationFilters() |
| */ |
| @Override |
| protected NotificationFilter[] getNotificationFilters() { |
| NotificationFilter filter = new EStructuralFeatureNotificationFilter( |
| ArgPackage.eINSTANCE.getModelElement_Id(), |
| ArgPackage.eINSTANCE.getModelElement_Name(), |
| ArgPackage.eINSTANCE.getArgumentationElement_Description(), |
| ArgPackage.eINSTANCE.getArgumentationElement_Content(), |
| ArgPackage.eINSTANCE.getAssertedContext_Multiextension(), |
| ArgPackage.eINSTANCE.getAssertedContext_Cardinality(), |
| ArgPackage.eINSTANCE.getAssertedContext_Source(), |
| ArgPackage.eINSTANCE.getAssertedContext_Target() ); |
| 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 (ArgViewsRepository.AssertedContext.Properties.id == event.getAffectedEditor()) { |
| Object newValue = event.getNewValue(); |
| if (newValue instanceof String) { |
| newValue = EEFConverterUtil.createFromString(ArgPackage.eINSTANCE.getModelElement_Id().getEAttributeType(), (String)newValue); |
| } |
| ret = Diagnostician.INSTANCE.validate(ArgPackage.eINSTANCE.getModelElement_Id().getEAttributeType(), newValue); |
| } |
| if (ArgViewsRepository.AssertedContext.Properties.name == event.getAffectedEditor()) { |
| Object newValue = event.getNewValue(); |
| if (newValue instanceof String) { |
| newValue = EEFConverterUtil.createFromString(ArgPackage.eINSTANCE.getModelElement_Name().getEAttributeType(), (String)newValue); |
| } |
| ret = Diagnostician.INSTANCE.validate(ArgPackage.eINSTANCE.getModelElement_Name().getEAttributeType(), newValue); |
| } |
| if (ArgViewsRepository.AssertedContext.Properties.description == event.getAffectedEditor()) { |
| Object newValue = event.getNewValue(); |
| if (newValue instanceof String) { |
| newValue = EEFConverterUtil.createFromString(ArgPackage.eINSTANCE.getArgumentationElement_Description().getEAttributeType(), (String)newValue); |
| } |
| ret = Diagnostician.INSTANCE.validate(ArgPackage.eINSTANCE.getArgumentationElement_Description().getEAttributeType(), newValue); |
| } |
| if (ArgViewsRepository.AssertedContext.Properties.content == event.getAffectedEditor()) { |
| Object newValue = event.getNewValue(); |
| if (newValue instanceof String) { |
| newValue = EEFConverterUtil.createFromString(ArgPackage.eINSTANCE.getArgumentationElement_Content().getEAttributeType(), (String)newValue); |
| } |
| ret = Diagnostician.INSTANCE.validate(ArgPackage.eINSTANCE.getArgumentationElement_Content().getEAttributeType(), newValue); |
| } |
| if (ArgViewsRepository.AssertedContext.Properties.multiextension == event.getAffectedEditor()) { |
| Object newValue = event.getNewValue(); |
| if (newValue instanceof String) { |
| newValue = EEFConverterUtil.createFromString(ArgPackage.eINSTANCE.getAssertedContext_Multiextension().getEAttributeType(), (String)newValue); |
| } |
| ret = Diagnostician.INSTANCE.validate(ArgPackage.eINSTANCE.getAssertedContext_Multiextension().getEAttributeType(), newValue); |
| } |
| if (ArgViewsRepository.AssertedContext.Properties.cardinality == event.getAffectedEditor()) { |
| Object newValue = event.getNewValue(); |
| if (newValue instanceof String) { |
| newValue = EEFConverterUtil.createFromString(ArgPackage.eINSTANCE.getAssertedContext_Cardinality().getEAttributeType(), (String)newValue); |
| } |
| ret = Diagnostician.INSTANCE.validate(ArgPackage.eINSTANCE.getAssertedContext_Cardinality().getEAttributeType(), newValue); |
| } |
| } catch (IllegalArgumentException iae) { |
| ret = BasicDiagnostic.toDiagnostic(iae); |
| } catch (WrappedException we) { |
| ret = BasicDiagnostic.toDiagnostic(we); |
| } |
| } |
| return ret; |
| } |
| |
| |
| |
| |
| } |