diff options
Diffstat (limited to 'plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src')
25 files changed, 0 insertions, 2065 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/Activator.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/Activator.java deleted file mode 100644 index a6a13edb45d..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/Activator.java +++ /dev/null @@ -1,78 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.elementtypesconfigurations; - -import org.eclipse.papyrus.infra.core.log.LogHelper; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * This is the central singleton for the ApplyStereotypeAdviceConfiguration model plugin. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * - * @generated - */ -public final class Activator extends AbstractUIPlugin { - - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.papyrus.uml.elementtypesconfigurations"; //$NON-NLS-1$ - - // The shared instance - private static Activator INSTANCE; - - /** Logging helper */ - public static LogHelper log; - - /** - * The constructor - */ - public Activator() { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - INSTANCE = this; - log = new LogHelper(this); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - @Override - public void stop(BundleContext context) throws Exception { - log = null; - INSTANCE = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return INSTANCE; - } - - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/applystereotypeadviceconfiguration/ApplyStereotypeAdviceEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/applystereotypeadviceconfiguration/ApplyStereotypeAdviceEditHelperAdvice.java deleted file mode 100644 index 14da444df50..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/applystereotypeadviceconfiguration/ApplyStereotypeAdviceEditHelperAdvice.java +++ /dev/null @@ -1,216 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.elementtypesconfigurations.applystereotypeadviceconfiguration; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; -import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; -import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; -import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; -import org.eclipse.papyrus.uml.elementtypesconfigurations.Activator; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.ApplyStereotypeRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.SetStereotypeValueRequest; -import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.NamedElement; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.Profile; -import org.eclipse.uml2.uml.Stereotype; -import org.eclipse.uml2.uml.Type; -import org.eclipse.uml2.uml.TypedElement; -import org.eclipse.uml2.uml.UMLPackage; - -/** - * advice for the {@link ApplyStereotypeAdviceConfiguration} - */ -public class ApplyStereotypeAdviceEditHelperAdvice extends AbstractEditHelperAdvice { - - - protected ApplyStereotypeAdviceConfiguration configuration; - - - public ApplyStereotypeAdviceEditHelperAdvice(ApplyStereotypeAdviceConfiguration configuration) { - this.configuration = configuration; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean approveRequest(IEditCommandRequest request) { - if (request instanceof CreateElementRequest) { - if (configuration == null) { - return false; - } - if (!(((CreateElementRequest) request).getContainer() instanceof Element)) { - return false; - } - Element container = (Element) ((CreateElementRequest) request).getContainer(); - Package nearestPackage = container.getNearestPackage(); - if (nearestPackage == null) { - return false; - } - List<Profile> appliedProfiles = nearestPackage.getAllAppliedProfiles(); - if (appliedProfiles == null) { - // no profiles applied, no stereotype can be applied - return false; - } - List<String> appliedProfileNames = new ArrayList<String>(); - for (Profile profile : appliedProfiles) { - appliedProfileNames.add(profile.getQualifiedName()); - } - for (StereotypeToApply stereotypeToApply : configuration.getStereotypesToApply()) { - List<String> requiredProfiles = stereotypeToApply.getRequiredProfiles(); - if (requiredProfiles != null) { - for (String requiredProfile : requiredProfiles) { - if (!appliedProfileNames.contains(requiredProfile)) { - return false; - } - } - } - } - return true; - } - - return true; - } - - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getAfterConfigureCommand(ConfigureRequest request) { - if (configuration == null) { - return null; - } - ICommand resultCommand = null; - // retrieve eobject - EObject elementToConfigure = request.getElementToConfigure(); - if (!(elementToConfigure instanceof Element)) { - return null; - } - - TransactionalEditingDomain editingDomain = request.getEditingDomain(); - if (editingDomain == null) { - return null; - } - // retrieve edit service to get features from configure command - IElementEditService service = ElementEditServiceUtils.getCommandProvider(elementToConfigure); - if (service == null) { - Activator.log.error("Impossible to get edit service from element: " + elementToConfigure, null); - return null; - } - - // for each stereotype, apply stereotype and apply values - for (StereotypeToApply stereotypeToApply : configuration.getStereotypesToApply()) { - Stereotype stereotype = ((Element) elementToConfigure).getApplicableStereotype(stereotypeToApply.getStereotypeQualifiedName()); - - if (stereotype != null) { - - ICommand applyStereotypeCommand = service.getEditCommand(new ApplyStereotypeRequest((Element) elementToConfigure, stereotype, editingDomain)); - - if (resultCommand == null) { - resultCommand = applyStereotypeCommand; - } else { - resultCommand = resultCommand.compose(applyStereotypeCommand); - } - - if (stereotypeToApply.isUpdateName() && elementToConfigure instanceof NamedElement) { - if (((NamedElement) elementToConfigure).getNamespace() != null) { - String newName = NamedElementUtil.getDefaultNameWithIncrementFromBase(stereotype.getName(), ((NamedElement) elementToConfigure).getNamespace().getMembers()); - ICommand renameCommand = service.getEditCommand(new SetRequest(editingDomain, elementToConfigure, UMLPackage.eINSTANCE.getNamedElement_Name(), newName)); - - if (resultCommand == null) { - resultCommand = renameCommand; - } else { - resultCommand = resultCommand.compose(renameCommand); - } - } - } - - // Set values - for (FeatureToSet featureToSet : stereotypeToApply.getFeaturesToSet()) { - // retrieve feature value - ICommand command = getSetStereotypeFeatureValueCommand((Element) elementToConfigure, stereotype, featureToSet.getFeatureName(), featureToSet.getValue(), service, request); - if (command != null) { - if (resultCommand == null) { - resultCommand = command; - } else { - resultCommand = resultCommand.compose(command); - } - } - } - } - - } - - if (resultCommand != null) { - return resultCommand.reduce(); - } - return super.getAfterConfigureCommand(request); - } - - /** - * @param elementToConfigure - * the eobject to configure - * @param name - * the name of the feature to set - * @param value - * the new value of the feature - */ - protected ICommand getSetStereotypeFeatureValueCommand(Element elementToConfigure, Stereotype stereotype, String name, FeatureValue featureValue, IElementEditService service, ConfigureRequest configureRequest) { - if (name == null) { - Activator.log.debug("No feature name has been set."); - return null; - } - if (elementToConfigure.eClass() == null) { - Activator.log.error("Impossible to find EClass from EObject: " + elementToConfigure, null); - return null; - } - - if (configureRequest.getEditingDomain() == null) { - return null; - } - - // retrieve structural feature for the element to configure - TypedElement typedElement = (TypedElement) stereotype.getMember(name, true, UMLPackage.eINSTANCE.getTypedElement()); - if (typedElement == null) { - Activator.log.error("Impossible to find feature " + name + " for eobject " + elementToConfigure, null); - return null; - } - Object value = getStereotypeValue(elementToConfigure, stereotype, typedElement.getType(), featureValue); - - return service.getEditCommand(new SetStereotypeValueRequest(configureRequest.getEditingDomain(), stereotype, (Element) elementToConfigure, name, value)); - } - - - /** - * @param elementToConfigure - * @param stereotype - * @param feature - * @param featureValue - * @return - */ - protected Object getStereotypeValue(Element elementToConfigure, Stereotype stereotype, Type type, FeatureValue featureValue) { - return StereotypeFeatureValueUtils.getValue(elementToConfigure, stereotype, type, featureValue); - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/applystereotypeadviceconfiguration/ApplyStereotypeAdviceFactory.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/applystereotypeadviceconfiguration/ApplyStereotypeAdviceFactory.java deleted file mode 100644 index 6e3a7c3747a..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/applystereotypeadviceconfiguration/ApplyStereotypeAdviceFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.elementtypesconfigurations.applystereotypeadviceconfiguration; - -import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice; -import org.eclipse.papyrus.infra.elementtypesconfigurations.AbstractAdviceBindingConfiguration; -import org.eclipse.papyrus.infra.elementtypesconfigurations.factories.impl.AbstractAdviceBindingFactory; -import org.eclipse.papyrus.infra.elementtypesconfigurations.impl.NullEditHelperAdvice; - -public class ApplyStereotypeAdviceFactory extends AbstractAdviceBindingFactory<AbstractAdviceBindingConfiguration> { - - - @Override - protected IEditHelperAdvice getEditHelperAdvice(AbstractAdviceBindingConfiguration adviceConfiguration) { - if (adviceConfiguration instanceof ApplyStereotypeAdviceConfiguration) { - IEditHelperAdvice editHelperAdvice = new ApplyStereotypeAdviceEditHelperAdvice((ApplyStereotypeAdviceConfiguration) adviceConfiguration); - return editHelperAdvice; - } - return NullEditHelperAdvice.getInstance(); - } - - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/applystereotypeadviceconfiguration/StereotypeFeatureValueUtils.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/applystereotypeadviceconfiguration/StereotypeFeatureValueUtils.java deleted file mode 100644 index 76b5135707a..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/applystereotypeadviceconfiguration/StereotypeFeatureValueUtils.java +++ /dev/null @@ -1,130 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.elementtypesconfigurations.applystereotypeadviceconfiguration; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.papyrus.infra.elementtypesconfigurations.Activator; -import org.eclipse.papyrus.infra.elementtypesconfigurations.emf.converter.ConverterNotfoundException; -import org.eclipse.papyrus.infra.elementtypesconfigurations.emf.converter.ConverterRegistry; -import org.eclipse.papyrus.uml.elementtypesconfigurations.applystereotypeadviceconfiguration.util.ApplyStereotypeAdviceConfigurationSwitch; -import org.eclipse.papyrus.uml.tools.utils.PrimitivesTypesUtils; -import org.eclipse.uml2.uml.DataType; -import org.eclipse.uml2.uml.Enumeration; -import org.eclipse.uml2.uml.PrimitiveType; -import org.eclipse.uml2.uml.Stereotype; -import org.eclipse.uml2.uml.Type; -import org.eclipse.uml2.uml.ValueSpecification; - - -/** - * Utility class to get values from a {@link FeatureValue} - */ -public class StereotypeFeatureValueUtils { - - protected StereotypeFeatureValueUtils() { - // no instanciation, helper class - } - - /** - * Returns the value to set for a given feature of a given element - * - * @param elementToConfigure - * eobject for which feature is set. This must not be <code>null</code> - * @param feature - * {@link EStructuralFeature} to set. This must not be <code>null</code> - * @param valueModel - * configuration of the value, stored in the model - * @return the real value that will be set to the object or <code>null</code> if none could be computed - */ - public static Object getValue(final EObject elementToConfigure, final Stereotype stereotype, final Type type, final FeatureValue featureValue) { - - Object result = new ApplyStereotypeAdviceConfigurationSwitch<Object>() { - /** - * {@inheritDoc} - */ - @Override - public Object caseConstantValue(ConstantValue object) { - ValueSpecification valueSpecification = object.getValueInstance(); - - if (valueSpecification == null) { - return null; - } - - try { - if (type instanceof PrimitiveType) { - final PrimitiveType pType = (PrimitiveType) type; - final String name = pType.getName(); - if (PrimitivesTypesUtils.UML_BOOLEAN.equals(name)) { - return ConverterRegistry.getSingleton().convert(boolean.class, valueSpecification); - } else if (PrimitivesTypesUtils.UML_INTEGER.equals(name)) { - return ConverterRegistry.getSingleton().convert(int.class, valueSpecification); - } else if (PrimitivesTypesUtils.UML_REAL.equals(name)) { - return ConverterRegistry.getSingleton().convert(double.class, valueSpecification); - } else if (PrimitivesTypesUtils.UML_STRING.equals(name)) { - return ConverterRegistry.getSingleton().convert(String.class, valueSpecification); - } else if (PrimitivesTypesUtils.UML_UNLIMITED_NATURAL.equals(name)) { - return ConverterRegistry.getSingleton().convert(int.class, valueSpecification); - } else { // custom PrimitiveType - return ConverterRegistry.getSingleton().convert(String.class, valueSpecification); - } - } else if (type instanceof Enumeration) { - return ConverterRegistry.getSingleton().convert(Enumeration.class, valueSpecification); - } else if (type instanceof DataType) {// FIXME manage the data type - return ConverterRegistry.getSingleton().convert(String.class, valueSpecification); - } - } catch (ConverterNotfoundException e) { - Activator.log.error("Impossible to convert " + valueSpecification + " to fit feature type :" + type, e); - } - return super.caseConstantValue(object); - } - - /** - * {@inheritDoc} - */ - @Override - public Object caseQueryExecutionValue(QueryExecutionValue object) { - throw new UnsupportedOperationException("Query execution values resolution has not been implemented yet"); - }; - - /** - * {@inheritDoc} - */ - @Override - public Object caseDynamicValue(DynamicValue object) { - throw new UnsupportedOperationException("Dynamic values resolution has not been implemented yet"); - }; - - /** - * {@inheritDoc} - */ - @Override - public Object caseListValue(ListValue object) { - // resolve one by one all features in the values list of this listvalue - List<Object> results = new ArrayList<Object>(); - for (FeatureValue value : object.getValues()) { - Object singleResult = getValue(elementToConfigure, stereotype, type, value); - results.add(singleResult); - } - return results; - }; - - }.doSwitch(featureValue); - return result; - } - - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/AbstractProfilingCommand.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/AbstractProfilingCommand.java deleted file mode 100644 index b967dd1822b..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/AbstractProfilingCommand.java +++ /dev/null @@ -1,79 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.elementtypesconfigurations.commands; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; - -public abstract class AbstractProfilingCommand extends AbstractTransactionalCommand { - - /** - * Constructor. - * - * @param domain - * @param label - * @param affectedFiles - */ - public AbstractProfilingCommand(TransactionalEditingDomain domain, String label, List<Object> affectedFiles) { - super(domain, label, affectedFiles); - } - - protected static List<Object> getAffectedFiles(IEditCommandRequest request) { - List<Object> result = new ArrayList<Object>(); - List<?> elements = request.getElementsToEdit(); - int size; - if (elements != null && ((size = elements.size()) > 0)) { - if (size == 1) { - Resource resource = ((EObject) elements.get(0)).eResource(); - if (resource != null) { - IFile file = WorkspaceSynchronizer.getFile(resource); - if (file != null) { - result.add(file); - } - } - } else { - Map<Resource, Object> resourcesToFileMap = new HashMap<Resource, Object>(); - for (int i = 0; i < size; ++i) { - Resource resource = ((EObject) elements.get(i)).eResource(); - if (resource != null) { - Object file = resourcesToFileMap.get(resource); - // if it is in the Map, then it is in the List already as well - if (file == null) { - file = WorkspaceSynchronizer.getFile(resource); - if (file != null) { - resourcesToFileMap.put(resource, file); - result.add(file); - } - } - } - } - } - } - return result; - } - - - - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/ApplyProfileCommand.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/ApplyProfileCommand.java deleted file mode 100644 index 096a2cd00d0..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/ApplyProfileCommand.java +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.elementtypesconfigurations.commands; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.ApplyProfileRequest; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.Profile; - -public class ApplyProfileCommand extends AbstractProfilingCommand { - - private ApplyProfileRequest request; - - /** - * - * Constructor. - * - * @param request - * @param domain - * @param label - */ - public ApplyProfileCommand(ApplyProfileRequest request, TransactionalEditingDomain domain, String label) { - super(domain, label, getAffectedFiles(request)); - this.request = request; - } - - /** - * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - * - * @param monitor - * @param info - * @return - * @throws ExecutionException - */ - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - Package pkg = this.request.getUmlPackage(); - Profile profile = this.request.getProfile(); - try { - pkg.applyProfile(profile); - } catch (IllegalArgumentException e) { - return CommandResult.newErrorCommandResult(e); - } - - - return CommandResult.newOKCommandResult(); - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/ApplyStereotypeCommand.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/ApplyStereotypeCommand.java deleted file mode 100644 index 197f8068172..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/ApplyStereotypeCommand.java +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.elementtypesconfigurations.commands; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.ApplyStereotypeRequest; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Stereotype; - -public class ApplyStereotypeCommand extends AbstractProfilingCommand { - - private ApplyStereotypeRequest request; - - /** - * - * Constructor. - * - * @param request - * @param domain - * @param label - */ - public ApplyStereotypeCommand(ApplyStereotypeRequest request, TransactionalEditingDomain domain, String label) { - super(domain, label, getAffectedFiles(request)); - this.request = request; - } - - /** - * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - * - * @param monitor - * @param info - * @return - * @throws ExecutionException - */ - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - Element element = this.request.getUmlElement(); - Stereotype stereotype = this.request.getStereotype(); - try { - element.applyStereotype(stereotype); - } catch (IllegalArgumentException e) { - return CommandResult.newErrorCommandResult(e); - } - - - return CommandResult.newOKCommandResult(); - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/SetStereotypeValueCommand.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/SetStereotypeValueCommand.java deleted file mode 100644 index 2c24d34d04c..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/SetStereotypeValueCommand.java +++ /dev/null @@ -1,65 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.elementtypesconfigurations.commands; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.SetStereotypeValueRequest; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Stereotype; - -public class SetStereotypeValueCommand extends AbstractProfilingCommand { - - private SetStereotypeValueRequest request; - - /** - * - * Constructor. - * - * @param request - * @param domain - * @param label - */ - public SetStereotypeValueCommand(SetStereotypeValueRequest request, TransactionalEditingDomain domain, String label) { - super(domain, label, getAffectedFiles(request)); - this.request = request; - } - - /** - * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - * - * @param monitor - * @param info - * @return - * @throws ExecutionException - */ - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - Element element = this.request.getUmlElement(); - Stereotype stereotype = this.request.getStereotype(); - String propertyName = this.request.getPropertyName(); - Object value = this.request.getValue(); - try { - element.setValue(stereotype, propertyName, value); - } catch (IllegalArgumentException e) { - return CommandResult.newErrorCommandResult(e); - } - - - return CommandResult.newOKCommandResult(); - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/UnapplyProfileCommand.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/UnapplyProfileCommand.java deleted file mode 100644 index 4d1b2c79557..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/UnapplyProfileCommand.java +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.elementtypesconfigurations.commands; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.UnapplyProfileRequest; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.Profile; - -public class UnapplyProfileCommand extends AbstractProfilingCommand { - - private UnapplyProfileRequest request; - - /** - * - * Constructor. - * - * @param request - * @param domain - * @param label - */ - public UnapplyProfileCommand(UnapplyProfileRequest request, TransactionalEditingDomain domain, String label) { - super(domain, label, getAffectedFiles(request)); - this.request = request; - } - - /** - * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - * - * @param monitor - * @param info - * @return - * @throws ExecutionException - */ - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - Package pkg = this.request.getUmlPackage(); - Profile profile = this.request.getProfile(); - try { - pkg.unapplyProfile(profile); - } catch (IllegalArgumentException e) { - return CommandResult.newErrorCommandResult(e); - } - - - return CommandResult.newOKCommandResult(); - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/UnapplyStereotypeCommand.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/UnapplyStereotypeCommand.java deleted file mode 100644 index be159c453c4..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/commands/UnapplyStereotypeCommand.java +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.elementtypesconfigurations.commands; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.UnapplyStereotypeRequest; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Stereotype; - -public class UnapplyStereotypeCommand extends AbstractProfilingCommand { - - private UnapplyStereotypeRequest request; - - /** - * - * Constructor. - * - * @param request - * @param domain - * @param label - */ - public UnapplyStereotypeCommand(UnapplyStereotypeRequest request, TransactionalEditingDomain domain, String label) { - super(domain, label, getAffectedFiles(request)); - this.request = request; - } - - /** - * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - * - * @param monitor - * @param info - * @return - * @throws ExecutionException - */ - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - Element element = this.request.getUmlElement(); - Stereotype stereotype = this.request.getStereotype(); - try { - element.unapplyStereotype(stereotype); - } catch (IllegalArgumentException e) { - return CommandResult.newErrorCommandResult(e); - } - - - return CommandResult.newOKCommandResult(); - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/edithelper/DefaultUMLEditHelper.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/edithelper/DefaultUMLEditHelper.java deleted file mode 100644 index 931cbc9f6c0..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/edithelper/DefaultUMLEditHelper.java +++ /dev/null @@ -1,96 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.elementtypesconfigurations.edithelper; - -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; -import org.eclipse.papyrus.infra.gmfdiag.common.helper.DefaultEditHelper; -import org.eclipse.papyrus.uml.elementtypesconfigurations.commands.ApplyProfileCommand; -import org.eclipse.papyrus.uml.elementtypesconfigurations.commands.ApplyStereotypeCommand; -import org.eclipse.papyrus.uml.elementtypesconfigurations.commands.SetStereotypeValueCommand; -import org.eclipse.papyrus.uml.elementtypesconfigurations.commands.UnapplyProfileCommand; -import org.eclipse.papyrus.uml.elementtypesconfigurations.commands.UnapplyStereotypeCommand; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.ApplyProfileRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.ApplyStereotypeRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.SetStereotypeValueRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.UnapplyProfileRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.UnapplyStereotypeRequest; - -public class DefaultUMLEditHelper extends DefaultEditHelper { - - /** - * @see org.eclipse.papyrus.infra.gmfdiag.common.helper.DefaultEditHelper#getInsteadCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) - * - * @param req - * @return - */ - @Override - protected ICommand getInsteadCommand(IEditCommandRequest req) { - - if (req instanceof ApplyProfileRequest) { - return getApplyProfileCommand((ApplyProfileRequest) req); - } else if (req instanceof UnapplyProfileRequest) { - return getUnapplyProfileCommand((UnapplyProfileRequest) req); - } else if (req instanceof ApplyStereotypeRequest) { - return getApplyStereotypeCommand((ApplyStereotypeRequest) req); - } else if (req instanceof UnapplyStereotypeRequest) { - return getUnapplyStereotypeCommand((UnapplyStereotypeRequest) req); - } else if (req instanceof SetStereotypeValueRequest) { - return getSetStereotypeValueCommand((SetStereotypeValueRequest) req); - } - - return super.getInsteadCommand(req); - } - - /** - * @param req - * @return - */ - protected ICommand getUnapplyProfileCommand(UnapplyProfileRequest req) { - return new UnapplyProfileCommand(req, req.getEditingDomain(), req.getLabel()); - } - - /** - * @param req - * @return - */ - protected ICommand getApplyProfileCommand(ApplyProfileRequest req) { - return new ApplyProfileCommand(req, req.getEditingDomain(), req.getLabel()); - } - - /** - * @param req - * @return - */ - protected ICommand getUnapplyStereotypeCommand(UnapplyStereotypeRequest req) { - return new UnapplyStereotypeCommand(req, req.getEditingDomain(), req.getLabel()); - } - - /** - * @param req - * @return - */ - protected ICommand getApplyStereotypeCommand(ApplyStereotypeRequest req) { - return new ApplyStereotypeCommand(req, req.getEditingDomain(), req.getLabel()); - } - - /** - * @param req - * @return - */ - protected ICommand getSetStereotypeValueCommand(SetStereotypeValueRequest req) { - return new SetStereotypeValueCommand(req, req.getEditingDomain(), req.getLabel()); - } - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/edithelper/DefaultUMLEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/edithelper/DefaultUMLEditHelperAdvice.java deleted file mode 100644 index 4d3f1a18c0f..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/edithelper/DefaultUMLEditHelperAdvice.java +++ /dev/null @@ -1,152 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.elementtypesconfigurations.edithelper; - -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.ApplyProfileRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.ApplyStereotypeRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.SetStereotypeValueRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.UnapplyProfileRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.UnapplyStereotypeRequest; - -public class DefaultUMLEditHelperAdvice extends AbstractEditHelperAdvice { - - /** - * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeEditCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) - * - * @param request - * @return - */ - @Override - public ICommand getBeforeEditCommand(IEditCommandRequest req) { - if (req instanceof ApplyProfileRequest) { - return getBeforeApplyProfileCommand((ApplyProfileRequest) req); - } else if (req instanceof UnapplyStereotypeRequest) { - return getBeforeUnapplyProfileCommand((UnapplyStereotypeRequest) req); - } else if (req instanceof ApplyStereotypeRequest) { - return getBeforeApplyStereotypeCommand((ApplyStereotypeRequest) req); - } else if (req instanceof UnapplyProfileRequest) { - return getBeforeUnapplyStereotypeCommand((UnapplyProfileRequest) req); - } else if (req instanceof SetStereotypeValueRequest) { - return getBeforeSetValueCommand((SetStereotypeValueRequest) req); - } - - return super.getBeforeEditCommand(req); - } - - /** - * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterEditCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) - * - * @param request - * @return - */ - @Override - public ICommand getAfterEditCommand(IEditCommandRequest req) { - if (req instanceof ApplyProfileRequest) { - return getAfterApplyProfileCommand((ApplyProfileRequest) req); - } else if (req instanceof UnapplyStereotypeRequest) { - return getAfterUnapplyProfileCommand((UnapplyStereotypeRequest) req); - } else if (req instanceof ApplyStereotypeRequest) { - return getAfterApplyStereotypeCommand((ApplyStereotypeRequest) req); - } else if (req instanceof UnapplyProfileRequest) { - return getAfterUnapplyStereotypeCommand((UnapplyProfileRequest) req); - } else if (req instanceof SetStereotypeValueRequest) { - return getAfterSetValueCommand((SetStereotypeValueRequest) req); - } - - return super.getAfterEditCommand(req); - } - - /** - * @param req - * @return - */ - protected ICommand getBeforeUnapplyProfileCommand(UnapplyStereotypeRequest req) { - return null; - } - - /** - * @param req - * @return - */ - protected ICommand getBeforeApplyProfileCommand(ApplyProfileRequest req) { - return null; - } - - /** - * @param req - * @return - */ - protected ICommand getBeforeUnapplyStereotypeCommand(UnapplyProfileRequest req) { - return null; - } - - /** - * @param req - * @return - */ - protected ICommand getBeforeApplyStereotypeCommand(ApplyStereotypeRequest req) { - return null; - } - - /** - * @param req - * @return - */ - protected ICommand getAfterUnapplyProfileCommand(UnapplyStereotypeRequest req) { - return null; - } - - /** - * @param req - * @return - */ - protected ICommand getAfterApplyProfileCommand(ApplyProfileRequest req) { - return null; - } - - /** - * @param req - * @return - */ - protected ICommand getAfterUnapplyStereotypeCommand(UnapplyProfileRequest req) { - return null; - } - - /** - * @param req - * @return - */ - protected ICommand getAfterApplyStereotypeCommand(ApplyStereotypeRequest req) { - return null; - } - - /** - * @param req - * @return - */ - protected ICommand getBeforeSetValueCommand(SetStereotypeValueRequest req) { - return null; - } - - /** - * @param req - * @return - */ - protected ICommand getAfterSetValueCommand(SetStereotypeValueRequest req) { - return null; - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/invariantstereotyperuleconfiguration/InvariantStereotypeRule.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/invariantstereotyperuleconfiguration/InvariantStereotypeRule.java deleted file mode 100644 index 9509e98a5e1..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/invariantstereotyperuleconfiguration/InvariantStereotypeRule.java +++ /dev/null @@ -1,193 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.elementtypesconfigurations.invariantstereotyperuleconfiguration; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; -import org.eclipse.papyrus.infra.elementtypesconfigurations.impl.ConfiguredHintedSpecializationElementType; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.ApplyProfileRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.ApplyStereotypeRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.SetStereotypeValueRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.UnapplyProfileRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.UnapplyStereotypeRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.umlinvariantrule.AbstractUmlInvariantRule; -import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.Profile; -import org.eclipse.uml2.uml.Stereotype; - -public class InvariantStereotypeRule extends AbstractUmlInvariantRule<InvariantStereotypeRuleConfiguration> { - - /** - * @see org.eclipse.papyrus.infra.elementtypesconfigurations.invarianttypes.invarianttypeconfiguration.IInvariantRule#matches(org.eclipse.emf.ecore.EObject) - * - * @param eObject - * @return - */ - public boolean matches(EObject eObject) { - if (!(eObject instanceof Element)) { - return false; - } - - String stereotypeQualifiedName = invariantRuleConfiguration.getStereotypeQualifiedName(); - if (stereotypeQualifiedName == null) { // to avoid null pointers - return false; - } - Stereotype appliedStereotype = ((Element) eObject).getAppliedStereotype(stereotypeQualifiedName); - if (appliedStereotype != null) { // one has been found, no need to get further - return true; - } else if (!invariantRuleConfiguration.isStrict()) { // the stereotype does not match perfectly, but one of the applied stereotypes on the element could match if not strict - for (Stereotype stereotype : ((Element) eObject).getAppliedStereotypes()) { - for (Stereotype superStereotype : StereotypeUtil.getAllSuperStereotypes(stereotype)) { - if (stereotypeQualifiedName.equals(superStereotype.getQualifiedName())) { - return true; // there is a match in the super stereotypes. Finish here, element matches - } - } - } - } - return false; - } - - /** - * @see org.eclipse.papyrus.infra.elementtypesconfigurations.invarianttypes.invarianttypeconfiguration.AbstractInvariantRule#approveMoveRequest(org.eclipse.papyrus.infra.elementtypesconfigurations.impl.ConfiguredHintedSpecializationElementType, - * org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest) - * - * @param type - * @param request - * @return - */ - @Override - protected boolean approveMoveRequest(ConfiguredHintedSpecializationElementType type, MoveRequest request) { - return true; - } - - /** - * @see org.eclipse.papyrus.infra.elementtypesconfigurations.invarianttypes.invarianttypeconfiguration.AbstractInvariantRule#approveSetRequest(org.eclipse.papyrus.infra.elementtypesconfigurations.impl.ConfiguredHintedSpecializationElementType, - * org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest) - * - * @param type - * @param request - * @return - */ - @Override - protected boolean approveSetRequest(ConfiguredHintedSpecializationElementType type, SetRequest request) { - return true; - } - - /** - * @see org.eclipse.papyrus.infra.elementtypesconfigurations.invarianttypes.invarianttypeconfiguration.AbstractInvariantRule#approveCreationRequest(org.eclipse.papyrus.infra.elementtypesconfigurations.impl.ConfiguredHintedSpecializationElementType, - * org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) - * - * @param type - * @param request - * @return - */ - @Override - protected boolean approveCreationRequest(ConfiguredHintedSpecializationElementType type, CreateElementRequest request) { - // check that the required profile is present. - String requiredProfileName = invariantRuleConfiguration.getRequiredProfile(); - if (requiredProfileName != null) { - // check target - EObject container = request.getContainer(); - if (!(container instanceof Element)) { - return false; - } - Package nearestPackage = ((Element) container).getNearestPackage(); - if (nearestPackage == null) { - return false; - } - Profile appliedProfile = nearestPackage.getAppliedProfile(requiredProfileName, true); - return appliedProfile != null; - } - - return true; - } - - /** - * @see org.eclipse.papyrus.uml.elementtypesconfigurations.umlinvariantrule.AbstractUmlInvariantRule#approveApplyStereotypeRequest(org.eclipse.papyrus.infra.elementtypesconfigurations.impl.ConfiguredHintedSpecializationElementType, - * org.eclipse.papyrus.uml.elementtypesconfigurations.requests.ApplyStereotypeRequest) - * - * @param type - * @param request - * @return - */ - @Override - protected boolean approveApplyStereotypeRequest(ConfiguredHintedSpecializationElementType type, ApplyStereotypeRequest request) { - return true; - } - - /** - * @see org.eclipse.papyrus.uml.elementtypesconfigurations.umlinvariantrule.AbstractUmlInvariantRule#approveUnapplyStereotypeRequest(org.eclipse.papyrus.infra.elementtypesconfigurations.impl.ConfiguredHintedSpecializationElementType, - * org.eclipse.papyrus.uml.elementtypesconfigurations.requests.UnapplyStereotypeRequest) - * - * @param type - * @param request - * @return - */ - @Override - protected boolean approveUnapplyStereotypeRequest(ConfiguredHintedSpecializationElementType type, UnapplyStereotypeRequest request) { - - if (request.getStereotype().getQualifiedName().equals(this.invariantRuleConfiguration.getStereotypeQualifiedName())) { - return false; - } - return true; - } - - /** - * @see org.eclipse.papyrus.uml.elementtypesconfigurations.umlinvariantrule.AbstractUmlInvariantRule#approveApplyProfileRequest(org.eclipse.papyrus.infra.elementtypesconfigurations.impl.ConfiguredHintedSpecializationElementType, - * org.eclipse.papyrus.uml.elementtypesconfigurations.requests.ApplyProfileRequest) - * - * @param type - * @param request - * @return - */ - @Override - protected boolean approveApplyProfileRequest(ConfiguredHintedSpecializationElementType type, ApplyProfileRequest request) { - return true; - } - - /** - * @see org.eclipse.papyrus.uml.elementtypesconfigurations.umlinvariantrule.AbstractUmlInvariantRule#approveUnapplyProfileRequest(org.eclipse.papyrus.infra.elementtypesconfigurations.impl.ConfiguredHintedSpecializationElementType, - * org.eclipse.papyrus.uml.elementtypesconfigurations.requests.UnapplyProfileRequest) - * - * @param type - * @param request - * @return - */ - @Override - protected boolean approveUnapplyProfileRequest(ConfiguredHintedSpecializationElementType type, UnapplyProfileRequest request) { - String requiredProfileName = invariantRuleConfiguration.getRequiredProfile(); - - if (requiredProfileName.equals(request.getProfile().getQualifiedName())) { - return false; - } - return true; - } - - /** - * @see org.eclipse.papyrus.uml.elementtypesconfigurations.umlinvariantrule.AbstractUmlInvariantRule#approveSetStereotypeValueRequest(org.eclipse.papyrus.infra.elementtypesconfigurations.impl.ConfiguredHintedSpecializationElementType, - * org.eclipse.papyrus.uml.elementtypesconfigurations.requests.SetStereotypeValueRequest) - * - * @param type - * @param request - * @return - */ - @Override - protected boolean approveSetStereotypeValueRequest(ConfiguredHintedSpecializationElementType type, SetStereotypeValueRequest request) { - return true; - } - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/AbstractProfileRequest.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/AbstractProfileRequest.java deleted file mode 100644 index bcca470441d..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/AbstractProfileRequest.java +++ /dev/null @@ -1,90 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.elementtypesconfigurations.requests; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.emf.type.core.EditHelperContext; -import org.eclipse.gmf.runtime.emf.type.core.IClientContext; -import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.Profile; - -public abstract class AbstractProfileRequest extends AbstractEditCommandRequest { - - private org.eclipse.uml2.uml.Package umlPackage; - private Profile profile; - - - public AbstractProfileRequest(TransactionalEditingDomain editingDomain, org.eclipse.uml2.uml.Package umlPackage, Profile profile) { - super(editingDomain); - this.umlPackage = umlPackage; - this.profile = profile; - } - - /** - * @see org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest#getEditHelperContext() - * - * @return - */ - public Object getEditHelperContext() { - IClientContext context = getClientContext(); - - if (context == null) { - return umlPackage; - } else { - return new EditHelperContext(umlPackage, context); - } - } - - /** - * @return the umlPackage - */ - public org.eclipse.uml2.uml.Package getUmlPackage() { - return umlPackage; - } - - /** - * @param umlPackage - * the umlPackage to set - */ - public void setUmlPackage(org.eclipse.uml2.uml.Package umlPackage) { - this.umlPackage = umlPackage; - } - - /** - * @return the profile - */ - public Profile getProfile() { - return profile; - } - - /** - * @param profile - * the profile to set - */ - public void setProfile(Profile profile) { - this.profile = profile; - } - - public List<Package> getElementsToEdit() { - if (umlPackage != null) { - return Collections.singletonList(umlPackage); - } - - return Collections.emptyList(); - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/AbstractStereotypeRequest.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/AbstractStereotypeRequest.java deleted file mode 100644 index e07a1ac5f83..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/AbstractStereotypeRequest.java +++ /dev/null @@ -1,88 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.elementtypesconfigurations.requests; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.emf.type.core.EditHelperContext; -import org.eclipse.gmf.runtime.emf.type.core.IClientContext; -import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Stereotype; - -public abstract class AbstractStereotypeRequest extends AbstractEditCommandRequest { - private Element umlElement; - private Stereotype stereotype; - - public AbstractStereotypeRequest(TransactionalEditingDomain editingDomain, Element umlElement, Stereotype stereotype) { - super(editingDomain); - this.umlElement = umlElement; - this.stereotype = stereotype; - } - - /** - * @see org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest#getEditHelperContext() - * - * @return - */ - public Object getEditHelperContext() { - IClientContext context = getClientContext(); - - if (context == null) { - return umlElement; - } else { - return new EditHelperContext(umlElement, context); - } - } - - /** - * @return the umlElement - */ - public Element getUmlElement() { - return umlElement; - } - - /** - * @param umlElement - * the umlElement to set - */ - public void setUmlElement(Element umlElement) { - this.umlElement = umlElement; - } - - /** - * @return the stereotype - */ - public Stereotype getStereotype() { - return stereotype; - } - - /** - * @param stereotype - * the stereotype to set - */ - public void setStereotype(Stereotype stereotype) { - this.stereotype = stereotype; - } - - public List<Element> getElementsToEdit() { - if (umlElement != null) { - return Collections.singletonList(umlElement); - } - - return Collections.emptyList(); - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/ApplyProfileRequest.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/ApplyProfileRequest.java deleted file mode 100644 index 8786934fca6..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/ApplyProfileRequest.java +++ /dev/null @@ -1,34 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.elementtypesconfigurations.requests; - -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.Profile; - -public class ApplyProfileRequest extends AbstractProfileRequest { - - /** - * Constructor. - * - * @param umlPackage - * @param profile - * @param editingDomain - */ - public ApplyProfileRequest(TransactionalEditingDomain editingDomain, Package umlPackage, Profile profile) { - super(editingDomain, umlPackage, profile); - } - - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/ApplyStereotypeRequest.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/ApplyStereotypeRequest.java deleted file mode 100644 index 675d4fd5730..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/ApplyStereotypeRequest.java +++ /dev/null @@ -1,33 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.elementtypesconfigurations.requests; - -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Stereotype; - -public class ApplyStereotypeRequest extends AbstractStereotypeRequest { - - /** - * Constructor. - * - * @param umlElement - * @param stereotype - * @param editingDomain - */ - public ApplyStereotypeRequest(Element umlElement, Stereotype stereotype, TransactionalEditingDomain editingDomain) { - super(editingDomain, umlElement, stereotype); - } - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/SetStereotypeValueRequest.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/SetStereotypeValueRequest.java deleted file mode 100644 index 3f40328ba62..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/SetStereotypeValueRequest.java +++ /dev/null @@ -1,111 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.elementtypesconfigurations.requests; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.emf.type.core.EditHelperContext; -import org.eclipse.gmf.runtime.emf.type.core.IClientContext; -import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Stereotype; - -public class SetStereotypeValueRequest extends AbstractEditCommandRequest { - - - private String propertyName; - - private Element umlElement; - - private Stereotype stereotype; - - private Object value; - - - public SetStereotypeValueRequest(TransactionalEditingDomain editingDomain, Stereotype stereotype, Element elementToEdit, String propertyName, Object value) { - super(editingDomain); - this.umlElement = elementToEdit; - this.propertyName = propertyName; - this.value = value; - this.stereotype = stereotype; - } - - /** - * @return the stereotype - */ - public Stereotype getStereotype() { - return stereotype; - } - - /** - * @param stereotype - * the stereotype to set - */ - public void setStereotype(Stereotype stereotype) { - this.stereotype = stereotype; - } - - public Object getValue() { - return value; - } - - /** - * @param value - * the value to set - */ - public void setValue(Object value) { - this.value = value; - } - - public String getPropertyName() { - return propertyName; - } - - /** - * @param propertyName - * the propertyName to set - */ - public void setPropertyName(String propertyName) { - this.propertyName = propertyName; - } - - - public List<Element> getElementsToEdit() { - if (umlElement != null) { - return Collections.singletonList(umlElement); - } - - return Collections.emptyList(); - } - - - public Object getEditHelperContext() { - IClientContext context = getClientContext(); - - if (context == null) { - return umlElement; - } else { - return new EditHelperContext(umlElement, context); - } - } - - /** - * @return the umlElement - */ - public Element getUmlElement() { - return umlElement; - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/UnapplyProfileRequest.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/UnapplyProfileRequest.java deleted file mode 100644 index ddde7b8ca8e..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/UnapplyProfileRequest.java +++ /dev/null @@ -1,26 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.elementtypesconfigurations.requests; - -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.Profile; - -public class UnapplyProfileRequest extends AbstractProfileRequest { - - public UnapplyProfileRequest(Package umlPackage, Profile profile, TransactionalEditingDomain editingDomain) { - super(editingDomain, umlPackage, profile); - } - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/UnapplyStereotypeRequest.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/UnapplyStereotypeRequest.java deleted file mode 100644 index d2893c8cd1b..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/requests/UnapplyStereotypeRequest.java +++ /dev/null @@ -1,34 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.elementtypesconfigurations.requests; - -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Stereotype; - -public class UnapplyStereotypeRequest extends AbstractStereotypeRequest { - - /** - * Constructor. - * - * @param umlPackage - * @param profile - * @param editingDomain - */ - public UnapplyStereotypeRequest(Element umlElement, Stereotype stereotype, TransactionalEditingDomain editingDomain) { - super(editingDomain, umlElement, stereotype); - } - - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/settypeadviceconfiguration/SetTypeAdviceEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/settypeadviceconfiguration/SetTypeAdviceEditHelperAdvice.java deleted file mode 100644 index 1b0234dc73a..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/settypeadviceconfiguration/SetTypeAdviceEditHelperAdvice.java +++ /dev/null @@ -1,116 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.elementtypesconfigurations.settypeadviceconfiguration; - -import java.util.Arrays; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; -import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; -import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; -import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; -import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory; -import org.eclipse.papyrus.uml.elementtypesconfigurations.Activator; -import org.eclipse.papyrus.uml.elementtypesconfigurations.applystereotypeadviceconfiguration.ApplyStereotypeAdviceConfiguration; -import org.eclipse.papyrus.uml.properties.modelelement.UMLModelElement; -import org.eclipse.swt.widgets.Display; -import org.eclipse.uml2.uml.Element; - -/** - * advice for the {@link ApplyStereotypeAdviceConfiguration} - */ -public class SetTypeAdviceEditHelperAdvice extends AbstractEditHelperAdvice { - - protected SetTypeAdviceConfiguration configuration; - - public SetTypeAdviceEditHelperAdvice(SetTypeAdviceConfiguration configuration) { - this.configuration = configuration; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean approveRequest(IEditCommandRequest request) { - return super.approveRequest(request); - } - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getBeforeConfigureCommand(ConfigureRequest request) { - return super.getBeforeConfigureCommand(request); - } - - /** - * {@inheritDoc} - */ - @Override - protected ICommand getAfterConfigureCommand(ConfigureRequest request) { - if (configuration == null) { - return null; - } - ICommand resultCommand = null; - // retrieve eobject - final EObject elementToConfigure = request.getElementToConfigure(); - if (!(elementToConfigure instanceof Element)) { - return null; - } - - final TransactionalEditingDomain editingDomain = request.getEditingDomain(); - if (editingDomain == null) { - return null; - } - // retrieve edit service to get features from configure command - IElementEditService service = ElementEditServiceUtils.getCommandProvider(elementToConfigure); - if (service == null) { - Activator.log.error("Impossible to get edit service from element: " + elementToConfigure, null); - return null; - } - - resultCommand = new AbstractTransactionalCommand(editingDomain, "Editing type", Arrays.asList((WorkspaceSynchronizer.getFile(elementToConfigure.eResource())))) { - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - UMLModelElement umlModelElement = new UMLModelElement(elementToConfigure, editingDomain); - ReferenceValueFactory factory = umlModelElement.getValueFactory("type"); - Object elemObject = factory.edit(Display.getDefault().getFocusControl(), elementToConfigure); - return CommandResult.newOKCommandResult(elemObject); - } - }; - - return resultCommand; - } - - /** - * @return - */ - protected EObject getDefaultTypeContainer(ConfigureRequest request) { - if (request.getElementToConfigure() instanceof Element) { - return ((Element) request.getElementToConfigure()).getNearestPackage(); - } - return request.getElementToConfigure().eContainer(); - } - - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/settypeadviceconfiguration/SetTypeAdviceFactory.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/settypeadviceconfiguration/SetTypeAdviceFactory.java deleted file mode 100644 index 5dd70631439..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/settypeadviceconfiguration/SetTypeAdviceFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.elementtypesconfigurations.settypeadviceconfiguration; - -import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice; -import org.eclipse.papyrus.infra.elementtypesconfigurations.AbstractAdviceBindingConfiguration; -import org.eclipse.papyrus.infra.elementtypesconfigurations.factories.impl.AbstractAdviceBindingFactory; -import org.eclipse.papyrus.infra.elementtypesconfigurations.impl.NullEditHelperAdvice; - -public class SetTypeAdviceFactory extends AbstractAdviceBindingFactory<AbstractAdviceBindingConfiguration> { - - - @Override - protected IEditHelperAdvice getEditHelperAdvice(AbstractAdviceBindingConfiguration adviceConfiguration) { - if (adviceConfiguration instanceof SetTypeAdviceConfiguration) { - IEditHelperAdvice editHelperAdvice = new SetTypeAdviceEditHelperAdvice((SetTypeAdviceConfiguration) adviceConfiguration); - return editHelperAdvice; - } - return NullEditHelperAdvice.getInstance(); - } - - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/stereotypeapplicationmatcherconfiguration/StereotypeApplicationMatcher.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/stereotypeapplicationmatcherconfiguration/StereotypeApplicationMatcher.java deleted file mode 100644 index d7af16b11f8..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/stereotypeapplicationmatcherconfiguration/StereotypeApplicationMatcher.java +++ /dev/null @@ -1,83 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.elementtypesconfigurations.stereotypeapplicationmatcherconfiguration; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Model; -import org.eclipse.uml2.uml.Profile; - - -/** - * Matcher for UML elements that should be stereotyped - */ -public class StereotypeApplicationMatcher implements IElementMatcher { - - private List<String> stereotypesQualifiedNames; - private String profileUri; - - public StereotypeApplicationMatcher(StereotypeApplicationMatcherConfiguration configuration) { - this.profileUri = configuration.getProfileUri(); - this.stereotypesQualifiedNames = configuration.getStereotypesQualifiedNames(); - } - - - public boolean matches(EObject eObject) { - if (!(eObject instanceof Element)) { - return false; - } - - Element element = (Element) eObject; - if (element.getAppliedStereotypes().isEmpty()) { - return false; - } - - for (String stereotypeQualifiedName : stereotypesQualifiedNames) { - if (element.getAppliedStereotype(stereotypeQualifiedName) == null) { - return false; - } - } - - if (profileUri != null){ - Model model = element.getModel(); - if (model == null){ - return false; - } - - List<String> appliedProfileByUri = new ArrayList<String>(); - for (Profile appliedProfile : model.getAllAppliedProfiles()) { - appliedProfileByUri.add(appliedProfile.getURI()); - } - - if (!appliedProfileByUri.contains(profileUri)){ - return false; - } - - } - return true; - } - - public List<String> getStereotypesQualifiedNames() { - return stereotypesQualifiedNames; - } - - - public void setStereotypesQualifiedNames(List<String> stereotypeQualifiedName) { - this.stereotypesQualifiedNames = stereotypeQualifiedName; - } - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/stereotypeapplicationmatcherconfiguration/StereotypeApplicationMatcherFactory.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/stereotypeapplicationmatcherconfiguration/StereotypeApplicationMatcherFactory.java deleted file mode 100644 index 0bd33486693..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/stereotypeapplicationmatcherconfiguration/StereotypeApplicationMatcherFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.elementtypesconfigurations.stereotypeapplicationmatcherconfiguration; - -import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher; -import org.eclipse.papyrus.infra.elementtypesconfigurations.factories.IMatcherFactory; - - -/** - * Factory to create matcher based on stereotypes applied on the element - */ -public class StereotypeApplicationMatcherFactory implements IMatcherFactory<StereotypeApplicationMatcherConfiguration> { - - /** - * {@inheritDoc} - */ - public IElementMatcher createElementMatcher(StereotypeApplicationMatcherConfiguration configuration) { - return new StereotypeApplicationMatcher(configuration); - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/umlinvariantrule/AbstractUmlInvariantRule.java b/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/umlinvariantrule/AbstractUmlInvariantRule.java deleted file mode 100644 index 888f4e4cc75..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.elementtypesconfigurations/src/org/eclipse/papyrus/uml/elementtypesconfigurations/umlinvariantrule/AbstractUmlInvariantRule.java +++ /dev/null @@ -1,93 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.elementtypesconfigurations.umlinvariantrule; - -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; -import org.eclipse.papyrus.infra.elementtypesconfigurations.impl.ConfiguredHintedSpecializationElementType; -import org.eclipse.papyrus.infra.elementtypesconfigurations.invarianttypeconfiguration.InvariantRuleConfiguration; -import org.eclipse.papyrus.infra.elementtypesconfigurations.invarianttypes.invarianttypeconfiguration.AbstractInvariantRule; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.ApplyProfileRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.ApplyStereotypeRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.SetStereotypeValueRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.UnapplyProfileRequest; -import org.eclipse.papyrus.uml.elementtypesconfigurations.requests.UnapplyStereotypeRequest; - -public abstract class AbstractUmlInvariantRule<T extends InvariantRuleConfiguration> extends AbstractInvariantRule<T> { - protected T invariantRuleConfiguration; - - /** - * @see org.eclipse.papyrus.infra.elementtypesconfigurations.invarianttypes.invarianttypeconfiguration.AbstractInvariantRule#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) - * - * @param request - * @return - */ - @Override - public boolean approveRequest(IEditCommandRequest request) { - - List<?> elementsToEdit = request.getElementsToEdit(); - for (Object elementToEdit : elementsToEdit) { - if (elementToEdit instanceof EObject) { - IElementType[] types = ElementTypeRegistry.getInstance().getAllTypesMatching((EObject) elementToEdit, request.getClientContext()); - - for (IElementType type : types) { - if (type instanceof ConfiguredHintedSpecializationElementType) { - ConfiguredHintedSpecializationElementType configuredHintedSpecializationElementType = (ConfiguredHintedSpecializationElementType) type; - if (request instanceof ApplyStereotypeRequest) { - if (!approveApplyStereotypeRequest(configuredHintedSpecializationElementType, (ApplyStereotypeRequest) request)) { - return false; - } - } else if (request instanceof UnapplyStereotypeRequest) { - if (!approveUnapplyStereotypeRequest(configuredHintedSpecializationElementType, (UnapplyStereotypeRequest) request)) { - return false; - } - } else if (request instanceof ApplyProfileRequest) { - if (!approveApplyProfileRequest(configuredHintedSpecializationElementType, (ApplyProfileRequest) request)) { - return false; - } - } else if (request instanceof UnapplyProfileRequest) { - if (!approveUnapplyProfileRequest(configuredHintedSpecializationElementType, (UnapplyProfileRequest) request)) { - return false; - } - } else if (request instanceof SetStereotypeValueRequest) { - if (!approveSetStereotypeValueRequest(configuredHintedSpecializationElementType, (SetStereotypeValueRequest) request)) { - return false; - } - } - } - } - } - } - - return super.approveRequest(request); - } - - abstract protected boolean approveApplyStereotypeRequest(ConfiguredHintedSpecializationElementType type, ApplyStereotypeRequest request); - - abstract protected boolean approveUnapplyStereotypeRequest(ConfiguredHintedSpecializationElementType type, UnapplyStereotypeRequest request); - - abstract protected boolean approveApplyProfileRequest(ConfiguredHintedSpecializationElementType type, ApplyProfileRequest request); - - abstract protected boolean approveUnapplyProfileRequest(ConfiguredHintedSpecializationElementType type, UnapplyProfileRequest request); - - abstract protected boolean approveSetStereotypeValueRequest(ConfiguredHintedSpecializationElementType type, SetStereotypeValueRequest request); - - @Override - public void init(T invariantRuleConfiguration) { - this.invariantRuleConfiguration = invariantRuleConfiguration; - } -} |