[Layer] Add a new delete Properties menu
- The last commit did not survive the rebase and lost its most important files
Change-Id: I17faa5ca372b9439fcaf223a8dc54da329d753ad
Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.model/src-gen/org/eclipse/papyrus/internal/infra/gmfdiag/layers/model/layers/impl/AbstractLayerImpl.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.model/src-gen/org/eclipse/papyrus/internal/infra/gmfdiag/layers/model/layers/impl/AbstractLayerImpl.java
index 5127612..07fce66 100755
--- a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.model/src-gen/org/eclipse/papyrus/internal/infra/gmfdiag/layers/model/layers/impl/AbstractLayerImpl.java
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.model/src-gen/org/eclipse/papyrus/internal/infra/gmfdiag/layers/model/layers/impl/AbstractLayerImpl.java
@@ -55,11 +55,11 @@
* The following features are implemented:
* </p>
* <ul>
- * <li>{@link org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl.AbstractLayerImpl#getPropertyValues <em>Property Values</em>}</li>
- * <li>{@link org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl.AbstractLayerImpl#getPropertyValueMap <em>Property Value Map</em>}</li>
- * <li>{@link org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl.AbstractLayerImpl#getLayerDescriptor <em>Layer Descriptor</em>}</li>
- * <li>{@link org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl.AbstractLayerImpl#getViews <em>Views</em>}</li>
- * <li>{@link org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl.AbstractLayerImpl#getAttachedProperties <em>Attached Properties</em>}</li>
+ * <li>{@link org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl.AbstractLayerImpl#getPropertyValues <em>Property Values</em>}</li>
+ * <li>{@link org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl.AbstractLayerImpl#getPropertyValueMap <em>Property Value Map</em>}</li>
+ * <li>{@link org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl.AbstractLayerImpl#getLayerDescriptor <em>Layer Descriptor</em>}</li>
+ * <li>{@link org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl.AbstractLayerImpl#getViews <em>Views</em>}</li>
+ * <li>{@link org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.impl.AbstractLayerImpl#getAttachedProperties <em>Attached Properties</em>}</li>
* </ul>
*
* @generated
@@ -69,6 +69,7 @@
* The cached value of the '{@link #getPropertyValues() <em>Property Values</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @see #getPropertyValues()
* @generated
* @ordered
@@ -79,6 +80,7 @@
* The cached value of the '{@link #getPropertyValueMap() <em>Property Value Map</em>}' map.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @see #getPropertyValueMap()
* @generated
* @ordered
@@ -89,6 +91,7 @@
* The cached value of the '{@link #getLayerDescriptor() <em>Layer Descriptor</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @see #getLayerDescriptor()
* @generated
* @ordered
@@ -99,6 +102,7 @@
* The cached value of the '{@link #getViews() <em>Views</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @see #getViews()
* @generated
* @ordered
@@ -133,6 +137,7 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
@@ -165,12 +170,13 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public EMap<String, TypeInstance> getPropertyValueMap() {
if (propertyValueMap == null) {
- propertyValueMap = new EcoreEMap<String,TypeInstance>(LayersPackage.Literals.STRING_TO_TYPE_INSTANCE_MAP, StringToTypeInstanceMapImpl.class, this, LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUE_MAP);
+ propertyValueMap = new EcoreEMap<String, TypeInstance>(LayersPackage.Literals.STRING_TO_TYPE_INSTANCE_MAP, StringToTypeInstanceMapImpl.class, this, LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUE_MAP);
}
return propertyValueMap;
}
@@ -178,13 +184,14 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public LayerDescriptor getLayerDescriptor() {
if (layerDescriptor != null && layerDescriptor.eIsProxy()) {
- InternalEObject oldLayerDescriptor = (InternalEObject)layerDescriptor;
- layerDescriptor = (LayerDescriptor)eResolveProxy(oldLayerDescriptor);
+ InternalEObject oldLayerDescriptor = (InternalEObject) layerDescriptor;
+ layerDescriptor = (LayerDescriptor) eResolveProxy(oldLayerDescriptor);
if (layerDescriptor != oldLayerDescriptor) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, LayersPackage.ABSTRACT_LAYER__LAYER_DESCRIPTOR, oldLayerDescriptor, layerDescriptor));
@@ -196,6 +203,7 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
public LayerDescriptor basicGetLayerDescriptor() {
@@ -205,6 +213,7 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
@@ -218,6 +227,7 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
@@ -328,13 +338,14 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
- case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUE_MAP:
- return ((InternalEList<?>)getPropertyValueMap()).basicRemove(otherEnd, msgs);
+ case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUE_MAP:
+ return ((InternalEList<?>) getPropertyValueMap()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
@@ -342,23 +353,27 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
- case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUES:
- return getPropertyValues();
- case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUE_MAP:
- if (coreType) return getPropertyValueMap();
- else return getPropertyValueMap().map();
- case LayersPackage.ABSTRACT_LAYER__LAYER_DESCRIPTOR:
- if (resolve) return getLayerDescriptor();
- return basicGetLayerDescriptor();
- case LayersPackage.ABSTRACT_LAYER__VIEWS:
- return getViews();
- case LayersPackage.ABSTRACT_LAYER__ATTACHED_PROPERTIES:
- return getAttachedProperties();
+ case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUES:
+ return getPropertyValues();
+ case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUE_MAP:
+ if (coreType)
+ return getPropertyValueMap();
+ else
+ return getPropertyValueMap().map();
+ case LayersPackage.ABSTRACT_LAYER__LAYER_DESCRIPTOR:
+ if (resolve)
+ return getLayerDescriptor();
+ return basicGetLayerDescriptor();
+ case LayersPackage.ABSTRACT_LAYER__VIEWS:
+ return getViews();
+ case LayersPackage.ABSTRACT_LAYER__ATTACHED_PROPERTIES:
+ return getAttachedProperties();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -366,30 +381,31 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
- case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUES:
- getPropertyValues().clear();
- getPropertyValues().addAll((Collection<? extends TypeInstance>)newValue);
- return;
- case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUE_MAP:
- ((EStructuralFeature.Setting)getPropertyValueMap()).set(newValue);
- return;
- case LayersPackage.ABSTRACT_LAYER__LAYER_DESCRIPTOR:
- setLayerDescriptor((LayerDescriptor)newValue);
- return;
- case LayersPackage.ABSTRACT_LAYER__VIEWS:
- getViews().clear();
- getViews().addAll((Collection<? extends View>)newValue);
- return;
- case LayersPackage.ABSTRACT_LAYER__ATTACHED_PROPERTIES:
- getAttachedProperties().clear();
- getAttachedProperties().addAll((Collection<? extends Property>)newValue);
- return;
+ case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUES:
+ getPropertyValues().clear();
+ getPropertyValues().addAll((Collection<? extends TypeInstance>) newValue);
+ return;
+ case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUE_MAP:
+ ((EStructuralFeature.Setting) getPropertyValueMap()).set(newValue);
+ return;
+ case LayersPackage.ABSTRACT_LAYER__LAYER_DESCRIPTOR:
+ setLayerDescriptor((LayerDescriptor) newValue);
+ return;
+ case LayersPackage.ABSTRACT_LAYER__VIEWS:
+ getViews().clear();
+ getViews().addAll((Collection<? extends View>) newValue);
+ return;
+ case LayersPackage.ABSTRACT_LAYER__ATTACHED_PROPERTIES:
+ getAttachedProperties().clear();
+ getAttachedProperties().addAll((Collection<? extends Property>) newValue);
+ return;
}
super.eSet(featureID, newValue);
}
@@ -397,26 +413,27 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
- case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUES:
- getPropertyValues().clear();
- return;
- case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUE_MAP:
- getPropertyValueMap().clear();
- return;
- case LayersPackage.ABSTRACT_LAYER__LAYER_DESCRIPTOR:
- setLayerDescriptor((LayerDescriptor)null);
- return;
- case LayersPackage.ABSTRACT_LAYER__VIEWS:
- getViews().clear();
- return;
- case LayersPackage.ABSTRACT_LAYER__ATTACHED_PROPERTIES:
- getAttachedProperties().clear();
- return;
+ case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUES:
+ getPropertyValues().clear();
+ return;
+ case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUE_MAP:
+ getPropertyValueMap().clear();
+ return;
+ case LayersPackage.ABSTRACT_LAYER__LAYER_DESCRIPTOR:
+ setLayerDescriptor((LayerDescriptor) null);
+ return;
+ case LayersPackage.ABSTRACT_LAYER__VIEWS:
+ getViews().clear();
+ return;
+ case LayersPackage.ABSTRACT_LAYER__ATTACHED_PROPERTIES:
+ getAttachedProperties().clear();
+ return;
}
super.eUnset(featureID);
}
@@ -424,21 +441,22 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
- case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUES:
- return propertyValues != null && !propertyValues.isEmpty();
- case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUE_MAP:
- return propertyValueMap != null && !propertyValueMap.isEmpty();
- case LayersPackage.ABSTRACT_LAYER__LAYER_DESCRIPTOR:
- return layerDescriptor != null;
- case LayersPackage.ABSTRACT_LAYER__VIEWS:
- return views != null && !views.isEmpty();
- case LayersPackage.ABSTRACT_LAYER__ATTACHED_PROPERTIES:
- return !getAttachedProperties().isEmpty();
+ case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUES:
+ return propertyValues != null && !propertyValues.isEmpty();
+ case LayersPackage.ABSTRACT_LAYER__PROPERTY_VALUE_MAP:
+ return propertyValueMap != null && !propertyValueMap.isEmpty();
+ case LayersPackage.ABSTRACT_LAYER__LAYER_DESCRIPTOR:
+ return layerDescriptor != null;
+ case LayersPackage.ABSTRACT_LAYER__VIEWS:
+ return views != null && !views.isEmpty();
+ case LayersPackage.ABSTRACT_LAYER__ATTACHED_PROPERTIES:
+ return !getAttachedProperties().isEmpty();
}
return super.eIsSet(featureID);
}
@@ -446,35 +464,33 @@
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ *
* @generated
*/
@Override
public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException {
switch (operationID) {
- case LayersPackage.ABSTRACT_LAYER___ADD_PROPERTY_INSTANCE__PROPERTY:
- try {
- return addPropertyInstance((Property)arguments.get(0));
- }
- catch (Throwable throwable) {
- throw new InvocationTargetException(throwable);
- }
- case LayersPackage.ABSTRACT_LAYER___REMOVE_PROPERTY_INSTANCE__PROPERTY:
- removePropertyInstance((Property)arguments.get(0));
- return null;
- case LayersPackage.ABSTRACT_LAYER___GET_PROPERTY_INSTANCE__PROPERTY:
- try {
- return getPropertyInstance((Property)arguments.get(0));
- }
- catch (Throwable throwable) {
- throw new InvocationTargetException(throwable);
- }
- case LayersPackage.ABSTRACT_LAYER___GET_PROPERTY_INSTANCE__STRING:
- try {
- return getPropertyInstance((String)arguments.get(0));
- }
- catch (Throwable throwable) {
- throw new InvocationTargetException(throwable);
- }
+ case LayersPackage.ABSTRACT_LAYER___ADD_PROPERTY_INSTANCE__PROPERTY:
+ try {
+ return addPropertyInstance((Property) arguments.get(0));
+ } catch (Throwable throwable) {
+ throw new InvocationTargetException(throwable);
+ }
+ case LayersPackage.ABSTRACT_LAYER___REMOVE_PROPERTY_INSTANCE__PROPERTY:
+ removePropertyInstance((Property) arguments.get(0));
+ return null;
+ case LayersPackage.ABSTRACT_LAYER___GET_PROPERTY_INSTANCE__PROPERTY:
+ try {
+ return getPropertyInstance((Property) arguments.get(0));
+ } catch (Throwable throwable) {
+ throw new InvocationTargetException(throwable);
+ }
+ case LayersPackage.ABSTRACT_LAYER___GET_PROPERTY_INSTANCE__STRING:
+ try {
+ return getPropertyInstance((String) arguments.get(0));
+ } catch (Throwable throwable) {
+ throw new InvocationTargetException(throwable);
+ }
}
return super.eInvoke(operationID, arguments);
}
@@ -540,7 +556,9 @@
try {
int propertyIndex = application.getPropertyRegistry().getPropertyIndex(propertyName);
- getPropertyValues().set(propertyIndex, value);
+ if (value != null) {
+ getPropertyValues().set(propertyIndex, value);
+ }
} catch (NullPointerException e) {
throw new BadStateException("application should be set first.");
}
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/commands/DeletePropertyCommand.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/commands/DeletePropertyCommand.java
new file mode 100755
index 0000000..3b76623
--- /dev/null
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/commands/DeletePropertyCommand.java
@@ -0,0 +1,121 @@
+/*****************************************************************************
+ * Copyright (c) 2017 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.internal.infra.gmfdiag.layers.ui.commands;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.ui.util.ServiceUtilsForIEvaluationContext;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.LayersException;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.NotFoundException;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.AbstractLayer;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.LayerExpression;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.LayersStack;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.LayersStackApplication;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.Property;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.TopLayerOperator;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.TypeInstance;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.runtime.model.LayersModelResource;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.Activator;
+
+/**
+ * @author Quentin Le Menez
+ *
+ */
+public class DeletePropertyCommand extends RecordingCommand implements Command {
+
+ private Collection<TypeInstance> typeInstances;
+
+ private IEvaluationContext context;
+
+ /**
+ * Constructor.
+ *
+ * @param namedStyle
+ * @param newValue
+ */
+ public DeletePropertyCommand(TransactionalEditingDomain domain, IEvaluationContext context, TypeInstance typeInstance) {
+ this(domain, context, Collections.singleton(typeInstance));
+ }
+
+ public DeletePropertyCommand(TransactionalEditingDomain domain, IEvaluationContext context, Collection<TypeInstance> typeInstances) {
+ super(domain);
+ this.typeInstances = typeInstances;
+ this.context = context;
+ }
+
+ /**
+ * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
+ *
+ */
+ @Override
+ protected void doExecute() {
+ CompoundCommand cc = new CompoundCommand("DeleteLayersCommand");
+
+ try {
+ LayersStackApplication layerStackApplication = lookupLayersStackApplicationChecked(context);
+ List<LayersStack> layerStacks = layerStackApplication.getLayersStacks();
+ LayerExpression topLayerExpression = (layerStacks.get(0).getLayers());
+ TopLayerOperator topLayerOperator = topLayerExpression instanceof TopLayerOperator ? (TopLayerOperator) topLayerExpression : null;
+ if (null == topLayerOperator) {
+ return;
+ }
+
+ for (LayerExpression layerExpression : topLayerOperator.getLayers()) {
+ AbstractLayer layer = layerExpression instanceof AbstractLayer ? (AbstractLayer) layerExpression : null;
+
+ if (null == layer) {
+ return;
+ }
+
+ List<Property> propertiesToRemove = new ArrayList<Property>();
+ for (Property property : layer.getAttachedProperties()) {
+ if (typeInstances.contains(layer.getPropertyInstance(property))) {
+ propertiesToRemove.add(property);
+ }
+ }
+
+ for (Property property : propertiesToRemove) {
+ layer.removePropertyInstance(property);
+ }
+ }
+ } catch (org.eclipse.papyrus.infra.core.resource.NotFoundException e) {
+ Activator.log.error("DeletePropertyCommand The LayerStackApplication could not be resolved from the context", e); //$NON-NLS-1$
+ } catch (ServiceException e) {
+ Activator.log.error("DeletePropertyCommand The LayerStackApplication could not be resolved from the context", e); //$NON-NLS-1$
+ } catch (LayersException e) {
+ Activator.log.error("DeletePropertyCommand The layer property could not be resolved", e); //$NON-NLS-1$
+ }
+
+ cc.execute();
+ }
+
+ protected LayersStackApplication lookupLayersStackApplicationChecked(IEvaluationContext context) throws NotFoundException, ServiceException, org.eclipse.papyrus.infra.core.resource.NotFoundException {
+
+ ModelSet modelSet = ServiceUtilsForIEvaluationContext.getInstance().getModelSet(context);
+ LayersModelResource model = (LayersModelResource) modelSet.getModelChecked(LayersModelResource.MODEL_ID);
+
+ return model.lookupLayerStackApplication();
+ }
+
+}
diff --git a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/handlers/DeleteItemHandler.java b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/handlers/DeleteItemHandler.java
index b33ca4c..29ade81 100755
--- a/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/handlers/DeleteItemHandler.java
+++ b/layers/plugins/org.eclipse.papyrus.infra.gmfdiag.layers.ui/src/org/eclipse/papyrus/internal/infra/gmfdiag/layers/ui/handlers/DeleteItemHandler.java
@@ -24,14 +24,13 @@
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.gmfdiag.css.properties.databinding.RemoveCssClassStyleCommand;
-import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.CSSInstance;
import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.Layer;
import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.LayerExpression;
import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.LayersStack;
import org.eclipse.papyrus.internal.infra.gmfdiag.layers.model.layers.TypeInstance;
import org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.commands.AbstractLayersCommand;
import org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.commands.DeleteLayersCommand;
+import org.eclipse.papyrus.internal.infra.gmfdiag.layers.ui.commands.DeletePropertyCommand;
/**
@@ -96,13 +95,16 @@
return;
}
- final CompoundCommand compoundCmd = new CompoundCommand("DeleteSelectedLayersCommand");
+ final CompoundCommand compoundCmd = new CompoundCommand("DeleteSelectedItemCommand");
// TODO support multiple deletion
Object selection = selections.get(0);
// for (Object selection : selections) {
if (selection instanceof Layer) {
compoundCmd.append(new DeleteLayersCommand(domain, (Layer) selection));
}
+ if (selection instanceof TypeInstance) {
+ compoundCmd.append(new DeletePropertyCommand(domain, context, (TypeInstance) selection));
+ }
// }
Command removeCmd = RemoveCommand.create(domain, selection);
@@ -129,7 +131,8 @@
return false;
}
Object first = selections.get(0);
- boolean res = (first instanceof LayerExpression && !(((EObject) first).eContainer() instanceof LayersStack));
+ boolean res = ((first instanceof LayerExpression && !(((EObject) first).eContainer() instanceof LayersStack))
+ || first instanceof TypeInstance);
return res;
}
@@ -141,7 +144,7 @@
*/
@Override
public String getCommandName() {
- return "Create Layer Operator";
+ return "DeleteItemHandler";
}
}