Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2016-02-16 10:33:54 +0000
committerGerrit Code Review @ Eclipse.org2016-02-23 14:23:01 +0000
commit03a9f2860c1f3730528447f513b6216d41b6dca3 (patch)
treec7258683e9ff6ff20d7515bcf11392acc9f0d929 /plugins
parent6c187df42d3c041fa2527fe32c5d219edbdd7ff6 (diff)
downloadorg.eclipse.papyrus-03a9f2860c1f3730528447f513b6216d41b6dca3.tar.gz
org.eclipse.papyrus-03a9f2860c1f3730528447f513b6216d41b6dca3.tar.xz
org.eclipse.papyrus-03a9f2860c1f3730528447f513b6216d41b6dca3.zip
Bug 487496: [Table] Cannot delete elements in a Generic Tree Table
https://bugs.eclipse.org/bugs/show_bug.cgi?id=487496 Allow the 'Delete Row Element' on tree table elements (not tree filling) and deny the 'Delete Row' on top tree filling. Another bug is related with this one: - Bug 487860 - [Table] The 'Delete Row' doesn't work for the top level (not tree filling) of a tree table Change-Id: Ibfe446618d033e4d8171101e9259fb610d63609e Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectTreeAxisManagerForEventList.java49
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractTreeAxisManagerForEventList.java33
2 files changed, 63 insertions, 19 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectTreeAxisManagerForEventList.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectTreeAxisManagerForEventList.java
index 4ec66ede8b2..50d4c426794 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectTreeAxisManagerForEventList.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectTreeAxisManagerForEventList.java
@@ -9,31 +9,38 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 487496
*
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.nattable.manager.axis;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
import org.eclipse.papyrus.infra.core.sashwindows.di.Window;
-import org.eclipse.papyrus.infra.nattable.dataprovider.HierarchicalRowLabelHeaderDataProvider;
+import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.nattable.manager.axis.AbstractTreeAxisManagerForEventList;
import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManagerForEventList;
import org.eclipse.papyrus.infra.nattable.manager.axis.ITreeItemAxisManagerForEventList;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EObjectAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EObjectTreeItemAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.ITreeItemAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.NattableaxisFactory;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TreeFillingConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.NattableaxisproviderPackage;
import org.eclipse.papyrus.infra.nattable.tree.ITreeItemAxisHelper;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
//import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
@@ -61,7 +68,7 @@ public class EObjectTreeAxisManagerForEventList extends AbstractTreeAxisManagerF
return null;
}
-
+
/**
* @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#getAddAxisCommand(org.eclipse.emf.transaction.TransactionalEditingDomain, java.util.Collection, int)
*
@@ -78,14 +85,15 @@ public class EObjectTreeAxisManagerForEventList extends AbstractTreeAxisManagerF
}
return null;
}
-
+
/**
* Get the axis to add from the objects to add.
*
- * @param objectToAdd The objects to add.
+ * @param objectToAdd
+ * The objects to add.
* @return The axis to add.
*/
- protected Collection<IAxis> getAxisToAdd(final Collection<Object> objectToAdd){
+ protected Collection<IAxis> getAxisToAdd(final Collection<Object> objectToAdd) {
final Collection<IAxis> toAdd = new ArrayList<IAxis>();
for (final Object object : objectToAdd) {
if (isAllowedContents(object, null, null, 0) && !isAlreadyManaged(object)) {
@@ -185,4 +193,35 @@ public class EObjectTreeAxisManagerForEventList extends AbstractTreeAxisManagerF
// return true;
return false;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractTreeAxisManagerForEventList#canDestroyAxisElement(java.lang.Integer)
+ */
+ @Override
+ public boolean canDestroyAxisElement(final Integer axisIndex) {
+ final Object current = getElements().get(axisIndex);
+ if (current instanceof EObjectTreeItemAxis && !(((EObjectTreeItemAxis) current).getElement() instanceof TreeFillingConfiguration)) {
+ return !EMFHelper.isReadOnly(((EObjectTreeItemAxis) current).getElement());
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractTreeAxisManagerForEventList#getDestroyAxisElementCommand(org.eclipse.emf.transaction.TransactionalEditingDomain, java.lang.Integer)
+ */
+ @Override
+ public Command getDestroyAxisElementCommand(final TransactionalEditingDomain domain, final Integer axisPosition) {
+ final Object current = getElements().get(axisPosition);
+ if (current instanceof EObjectTreeItemAxis) {
+ final EObject element = ((EObjectTreeItemAxis) current).getElement();
+ final DestroyElementRequest request = new DestroyElementRequest(getContextEditingDomain(), element, false);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(element);
+ return new RemoveCommandWrapper(new GMFtoEMFCommandWrapper(provider.getEditCommand(request)), Collections.singleton((Object) ((EObjectTreeItemAxis) current).getElement()));
+ }
+ return null;
+ }
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractTreeAxisManagerForEventList.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractTreeAxisManagerForEventList.java
index 8cb3575b947..f08fb40fd8f 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractTreeAxisManagerForEventList.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractTreeAxisManagerForEventList.java
@@ -206,7 +206,7 @@ public abstract class AbstractTreeAxisManagerForEventList extends AbstractAxisMa
@Override
public boolean canDestroyAxis(Integer axisPosition) {
IAxis axis = (IAxis) getTableManager().getRowElementsList().get(axisPosition.intValue());// we need to have the tree list here and not the basic event list!
- if (axis instanceof ITreeItemAxis) {
+ if (axis instanceof ITreeItemAxis && !(((ITreeItemAxis)axis).getElement() instanceof TreeFillingConfiguration)) {
return ((ITreeItemAxis) axis).getParent() == null;
}
return false;
@@ -515,7 +515,10 @@ public abstract class AbstractTreeAxisManagerForEventList extends AbstractAxisMa
EventListHelper.removeFromEventList(eventList, axis);
this.alreadyExpanded.remove(axis);
ITreeItemAxisHelper.unlinkITreeItemAxisToSemanticElement(this.managedElements, axis);
- ITreeItemAxisHelper.destroyITreeItemAxis(getTableEditingDomain(), axis);
+ final TransactionalEditingDomain tableEditingDomain = getTableEditingDomain();
+ if(null != tableEditingDomain){
+ ITreeItemAxisHelper.destroyITreeItemAxis(tableEditingDomain, axis);
+ }
if (parentAxis != null) {
final Object representedElement = parentAxis.getElement();
if (representedElement instanceof TreeFillingConfiguration && parentAxis.getChildren().size() == 0) {
@@ -859,18 +862,20 @@ public abstract class AbstractTreeAxisManagerForEventList extends AbstractAxisMa
Collection<ITreeItemAxis> itemAxisRepresentations = new ArrayList<ITreeItemAxis>(this.managedElements.get(object));
for (final ITreeItemAxis current : itemAxisRepresentations) {
ITreeItemAxis parent = current.getParent();
- // must always be a TreeFillingConfiguration
- TreeFillingConfiguration conf = (TreeFillingConfiguration) parent.getElement();
- Object context;
- ITreeItemAxis greatParent = parent.getParent();
- if (greatParent == null) {
- context = getTableContext();
- } else {
- context = greatParent.getElement();
- }
- Collection<?> values = getCellValueAsCollection(conf.getAxisUsedAsAxisProvider(), context);
- if (!values.contains(object)) {
- removeObject(current);
+ if(null != parent){
+ // must always be a TreeFillingConfiguration
+ TreeFillingConfiguration conf = (TreeFillingConfiguration) parent.getElement();
+ Object context;
+ ITreeItemAxis greatParent = parent.getParent();
+ if (greatParent == null) {
+ context = getTableContext();
+ } else {
+ context = greatParent.getElement();
+ }
+ Collection<?> values = getCellValueAsCollection(conf.getAxisUsedAsAxisProvider(), context);
+ if (!values.contains(object)) {
+ removeObject(current);
+ }
}
}
}

Back to the top