diff options
Diffstat (limited to 'sandbox')
24 files changed, 919 insertions, 32 deletions
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectAxisManager.java index dfb68a46eaf..7369266c984 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectAxisManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EObjectAxisManager.java @@ -20,12 +20,18 @@ import org.eclipse.emf.common.command.CompoundCommand; import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager;
import org.eclipse.papyrus.infra.nattable.messages.Messages;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EObjectAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.NattableaxisFactory;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.NattableaxisproviderPackage;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
/**
*
@@ -147,4 +153,52 @@ public class EObjectAxisManager extends AbstractAxisManager { throw new UnsupportedOperationException();
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canDestroyAxisElement(org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis)
+ *
+ * @param axis
+ * @return
+ */
+ public boolean canDestroyAxisElement(final IAxis axis) {
+ final EObject object = (EObject)axis.getElement();
+ return !EMFHelper.isReadOnly(object);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canDestroyAxisElement(java.lang.Integer)
+ *
+ * @param axisPosition
+ * @return
+ */
+ public boolean canDestroyAxisElement(Integer axisPosition) {
+ final Object current = getElements().get(axisPosition);
+ if(current instanceof EObjectAxis) {
+ return !EMFHelper.isReadOnly(((EObjectAxis)current).getElement());
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getDestroyAxisElementCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.lang.Integer)
+ *
+ * @param domain
+ * @param axisPosition
+ * @return
+ */
+ public Command getDestroyAxisElementCommand(EditingDomain domain, Integer axisPosition) {
+ final Object current = getElements().get(axisPosition);
+ if(current instanceof EObjectAxis) {
+ final EObject element = ((EObjectAxis)current).getElement();
+ final DestroyElementRequest request = new DestroyElementRequest((TransactionalEditingDomain)getContextEditingDomain(), element, false);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(element);
+ return new GMFtoEMFCommandWrapper(provider.getEditCommand(request));
+ }
+ return null;
+ }
+
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EStructuralFeatureAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EStructuralFeatureAxisManager.java index 1449c5cdbfc..284edfa0adf 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EStructuralFeatureAxisManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.emf.nattable/src/org/eclipse/papyrus/infra/emf/nattable/manager/axis/EStructuralFeatureAxisManager.java @@ -19,6 +19,7 @@ import java.util.HashSet; import java.util.Set;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
@@ -29,6 +30,7 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EStructuralFeatureAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
@@ -230,4 +232,23 @@ public class EStructuralFeatureAxisManager extends AbstractAxisManager { return null;
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canDestroyAxisElement(org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis)
+ *
+ * @param axis
+ * @return
+ */
+ public boolean canDestroyAxisElement(final IAxis axis) {
+ final EObject object = (EObject)axis.getElement();
+ return !EMFHelper.isReadOnly(object);
+ }
+
+ public boolean canDestroyAxisElement(Integer axisPosition) {
+ return false;
+ }
+
+ public Command getDestroyAxisElementCommand(EditingDomain domain, Integer axisPosition) {
+ return UnexecutableCommand.INSTANCE;
+ }
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorContextSynchronizerAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorContextSynchronizerAxisManager.java index c93eeae04e0..aeb9e26a886 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorContextSynchronizerAxisManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorContextSynchronizerAxisManager.java @@ -17,9 +17,12 @@ import java.util.ArrayList; import java.util.Collection;
import java.util.List;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.papyrus.infra.core.sashwindows.di.DiPackage;
import org.eclipse.papyrus.infra.core.sashwindows.di.PageList;
import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
@@ -161,4 +164,14 @@ public class EditorContextSynchronizerAxisManager extends AbstractSynchronizedOn return false;
}
+ @Override
+ public boolean canDestroyAxisElement(Integer axisPosition) {
+ return false;
+ }
+
+ @Override
+ public Command getDestroyAxisElementCommand(EditingDomain domain, Integer axisPosition) {
+ return UnexecutableCommand.INSTANCE;
+ }
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorFeatureAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorFeatureAxisManager.java index 4a5a386e7a9..56cb61ce6e4 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorFeatureAxisManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable.views.config/src/org/eclipse/papyrus/infra/nattable/views/config/manager/axis/EditorFeatureAxisManager.java @@ -13,6 +13,9 @@ *****************************************************************************/
package org.eclipse.papyrus.infra.nattable.views.config.manager.axis;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager;
/**
@@ -53,4 +56,30 @@ public class EditorFeatureAxisManager extends AbstractAxisManager { public boolean canEditAxisHeader() {
return true;
}
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canDestroyAxisElement(java.lang.Integer)
+ *
+ * @param axisPosition
+ * @return
+ */
+ @Override
+ public boolean canDestroyAxisElement(Integer axisPosition) {
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getDestroyAxisElementCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.lang.Integer)
+ *
+ * @param domain
+ * @param axisPosition
+ * @return
+ */
+ @Override
+ public Command getDestroyAxisElementCommand(EditingDomain domain, Integer axisPosition) {
+ return UnexecutableCommand.INSTANCE;
+ }
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/delete_obj.gif b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/delete_obj.gif Binary files differnew file mode 100644 index 00000000000..b6922ac11cf --- /dev/null +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/delete_obj.gif diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/remove_column.gif b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/remove_column.gif Binary files differnew file mode 100644 index 00000000000..f8afafa242c --- /dev/null +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/remove_column.gif diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/remove_row.gif b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/remove_row.gif Binary files differnew file mode 100644 index 00000000000..23a70e32522 --- /dev/null +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/icons/remove_row.gif diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml index a1c8a5cae59..fb4b375b930 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/plugin.xml @@ -900,6 +900,30 @@ id="org.eclipse.papyrus.infra.nattable.edit.row.header"
name="Rename Header">
</command>
+ <command
+ categoryId="org.eclipse.papyrus.infra.nattable.rows.command.category"
+ defaultHandler="org.eclipse.papyrus.infra.nattable.handler.RowDestroyAxisHandler"
+ id="org.eclipse.papyrus.infra.nattable.destroy.row"
+ name="Destroy Row">
+ </command>
+ <command
+ categoryId="org.eclipse.papyrus.infra.nattable.rows.command.category"
+ defaultHandler="org.eclipse.papyrus.infra.nattable.handler.RowDestroyAxisElementHandler"
+ id="org.eclipse.papyrus.infra.nattable.destroy.row.element"
+ name="Destroy Row Element">
+ </command>
+ <command
+ categoryId="org.eclipse.papyrus.infra.nattable.columns.command.category"
+ defaultHandler="org.eclipse.papyrus.infra.nattable.handler.ColumnDestroyAxisHandler"
+ id="org.eclipse.papyrus.infra.nattable.destroy.column"
+ name="Destroy Column">
+ </command>
+ <command
+ categoryId="org.eclipse.papyrus.infra.nattable.columns.command.category"
+ defaultHandler="org.eclipse.papyrus.infra.nattable.handler.ColumnDestroyAxisElementHandler"
+ id="org.eclipse.papyrus.infra.nattable.destroy.column.element"
+ name="Destroy Column Element">
+ </command>
</extension>
<extension
point="org.eclipse.ui.commandImages">
@@ -911,6 +935,22 @@ commandId="org.eclipse.papyrus.infra.nattable.edit.row.header"
icon="icons/rename.gif">
</image>
+ <image
+ commandId="org.eclipse.papyrus.infra.nattable.destroy.column.element"
+ icon="icons/delete_obj.gif">
+ </image>
+ <image
+ commandId="org.eclipse.papyrus.infra.nattable.destroy.row.element"
+ icon="icons/delete_obj.gif">
+ </image>
+ <image
+ commandId="org.eclipse.papyrus.infra.nattable.destroy.row"
+ icon="icons/remove_row.gif">
+ </image>
+ <image
+ commandId="org.eclipse.papyrus.infra.nattable.destroy.column"
+ icon="icons/remove_column.gif">
+ </image>
</extension> </plugin>
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java index 56b5c80ab5c..ceb98614208 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java @@ -13,15 +13,21 @@ *****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.messages.Messages;
import org.eclipse.swt.events.MouseEvent;
@@ -44,6 +50,14 @@ public abstract class AbstractTableHandler extends AbstractHandler { public static final String NAT_EVENT_DATA_PARAMETER_ID = "natEventParameterId";
/**
+ * the event which have declenched the call to setEnable(Object evaluationContext. This event contains the location of the mouse pointer when
+ * the popup menu for this handler have been created
+ */
+ //FIXME : should maybe be remove with the future usage of e4 and the Eclispe Context
+ protected NatEventData eventData;
+
+
+ /**
*
* @return
* the current active part
@@ -108,6 +122,9 @@ public abstract class AbstractTableHandler extends AbstractHandler { * the NatEventData from this evaluation context
*/
protected NatEventData getNatEventData(final Object evaluationContext) {
+ if(evaluationContext instanceof NatEventData) {
+ return (NatEventData)evaluationContext;
+ }
NatEventData eventData = null;
if(evaluationContext instanceof IEvaluationContext) {
Object value = ((IEvaluationContext)evaluationContext).getVariable(NAT_EVENT_DATA_PARAMETER_ID);
@@ -134,4 +151,75 @@ public abstract class AbstractTableHandler extends AbstractHandler { return eventData;
}
+ /**
+ *
+ * @param evaluationContext
+ * @return
+ * the index of the rows which are fully selected
+ */
+ protected List<Integer> getFullSelectedRows(Object evaluationContext) {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ if(manager != null) {
+ final NatEventData data = getNatEventData(evaluationContext);
+ if(data != null) {
+ final SelectionLayer layer = manager.getBodyLayerStack().getSelectionLayer();
+ int[] fullSelectedColumnsPosition = layer.getFullySelectedRowPositions();
+ List<Integer> positions = new ArrayList<Integer>();
+ for(int i : fullSelectedColumnsPosition) {
+ positions.add(layer.getRowIndexByPosition(i));
+ }
+ return positions;
+ }
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ *
+ * @param evaluationContext
+ * @return
+ * the index of the columns which are fully selected
+ */
+ protected List<Integer> getFullSelectedColumns(Object evaluationContext) {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ if(manager != null) {
+ final NatEventData data = getNatEventData(evaluationContext);
+ if(data != null) {
+ final SelectionLayer layer = manager.getBodyLayerStack().getSelectionLayer();
+ int[] fullSelectedColumnsPosition = layer.getFullySelectedColumnPositions();
+ List<Integer> positions = new ArrayList<Integer>();
+ for(int i : fullSelectedColumnsPosition) {
+ positions.add(layer.getColumnIndexByPosition(i));
+ }
+ return positions;
+ }
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ *
+ * @return
+ * the row axis manager
+ */
+ protected IAxisManager getRowAxisManager() {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ if(manager != null) {
+ return manager.getRowAxisManager();
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @return
+ * the column axis manager
+ */
+ protected IAxisManager getColumnAxisManager() {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ if(manager != null) {
+ return manager.getColumnAxisManager();
+ }
+ return null;
+ }
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisElementHandler.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisElementHandler.java new file mode 100644 index 00000000000..1adc97fd8c8 --- /dev/null +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisElementHandler.java @@ -0,0 +1,64 @@ +/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
+
+/**
+ * The handler used to destroy the elements represented by the selected columns
+ *
+ * @author VL222926
+ *
+ */
+public class ColumnDestroyAxisElementHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final IAxisManager axisManager = getColumnAxisManager();
+ if(axisManager != null) {
+ axisManager.destroyAxisElement(getFullSelectedColumns(this.eventData));
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ final IAxisManager axisManager = getColumnAxisManager();
+ if(axisManager != null) {
+ this.eventData = getNatEventData(evaluationContext);
+ final List<Integer> col = getFullSelectedColumns(this.eventData);
+ setBaseEnabled(axisManager.canDestroyAxisElement(col));
+ } else {
+ setBaseEnabled(false);
+ }
+ }
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisHandler.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisHandler.java new file mode 100644 index 00000000000..6dfacbb508e --- /dev/null +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisHandler.java @@ -0,0 +1,63 @@ +/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
+
+/**
+ * The handler used to destroy the selected columns
+ *
+ * @author VL222926
+ *
+ */
+public class ColumnDestroyAxisHandler extends AbstractTableHandler {
+
+ /**
+ * @Override
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final IAxisManager axisManager = getColumnAxisManager();
+ if(axisManager != null) {
+ axisManager.destroyAxis(getFullSelectedColumns(this.eventData));
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ final IAxisManager axisManager = getColumnAxisManager();
+ if(axisManager != null) {
+ this.eventData = getNatEventData(evaluationContext);
+ final List<Integer> col = getFullSelectedColumns(this.eventData);
+ setBaseEnabled(axisManager.canDestroyAxis(col));
+ } else {
+ setBaseEnabled(false);
+ }
+ }
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InvertAxisHandler.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InvertAxisHandler.java index 74b716112a2..279ebbed901 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InvertAxisHandler.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InvertAxisHandler.java @@ -1,3 +1,16 @@ +/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
import org.eclipse.core.commands.ExecutionEvent;
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java new file mode 100644 index 00000000000..13115404da7 --- /dev/null +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java @@ -0,0 +1,64 @@ +/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
+
+/**
+ * The handler used to destroy the element represented by the selected rows
+ *
+ * @author VL222926
+ *
+ */
+public class RowDestroyAxisElementHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final IAxisManager axisManager = getRowAxisManager();
+ if(axisManager != null) {
+ axisManager.destroyAxisElement(getFullSelectedRows(this.eventData));
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ final IAxisManager axisManager = getRowAxisManager();
+ if(axisManager != null) {
+ this.eventData = getNatEventData(evaluationContext);
+ final List<Integer> col = getFullSelectedRows(this.eventData);
+ setBaseEnabled(axisManager.canDestroyAxisElement(col));
+ } else {
+ setBaseEnabled(false);
+ }
+ }
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java new file mode 100644 index 00000000000..26c1f859eea --- /dev/null +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java @@ -0,0 +1,63 @@ +/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.nattable.handler;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
+
+/**
+ * The handler used to destroy the element represented by the selected rows
+ *
+ * @author VL222926
+ *
+ */
+public class RowDestroyAxisHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final IAxisManager axisManager = getRowAxisManager();
+ if(axisManager != null) {
+ axisManager.destroyAxis(getFullSelectedRows(this.eventData));
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ final IAxisManager axisManager = getRowAxisManager();
+ if(axisManager != null) {
+ this.eventData = getNatEventData(evaluationContext);
+ final List<Integer> rows = getFullSelectedRows(this.eventData);
+ setBaseEnabled(axisManager.canDestroyAxis(rows));
+ }
+ super.setBaseEnabled(false);
+ }
+}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java index 9e1c3b95458..e1fd1dc7924 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/AbstractAxisManager.java @@ -15,9 +15,11 @@ package org.eclipse.papyrus.infra.nattable.manager.axis; import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
@@ -411,4 +413,101 @@ public abstract class AbstractAxisManager implements IAxisManager { return this.representedAxisManager;
}
+ /**
+ *
+ * @param axisPositions
+ * @return
+ */
+ @Override
+ public boolean canDestroyAxis(final List<Integer> axisPositions) {
+ if(axisPositions.isEmpty()) {
+ return false;
+ }
+ for(final Integer integer : axisPositions) {
+ if(!canDestroyAxis(integer)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean canDestroyAxisElement(List<Integer> axisPositions) {
+ if(axisPositions.isEmpty()) {
+ return false;
+ }
+ for(final Integer integer : axisPositions) {
+ if(!canDestroyAxisElement(integer)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ *
+ * @param axisPositions
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#destroyAxis(java.util.List)
+ */
+ @Override
+ public void destroyAxis(final List<Integer> axisPositions) {
+ final List<Object> toDestroy = getElements(axisPositions);
+ EditingDomain domain = getTableEditingDomain();
+ final Command cmd = getDestroyAxisCommand(domain, toDestroy);
+ domain.getCommandStack().execute(cmd);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canDestroyAxis(java.lang.Integer)
+ *
+ * @param axisPosition
+ * @return
+ */
+ public boolean canDestroyAxis(final Integer axisPosition) {
+ return !isDynamic();
+ }
+
+
+ /**
+ *
+ * @param axisPositions
+ * axis positions
+ * @return
+ * the elements located at these axis position
+ */
+ protected List<Object> getElements(final List<Integer> axisPositions) {
+ final List<Object> elements = getElements();
+ for(final Integer position : axisPositions) {
+ final Object element = elements.get(position);
+ elements.add(element);
+ }
+ return elements;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#destroyAxisElement(java.util.List)
+ *
+ * @param axisPosition
+ */
+ @Override
+ public void destroyAxisElement(final List<Integer> axisPosition) {
+ final CompoundCommand cmd = new CompoundCommand("Destroy Axis Element Command");
+ EditingDomain domain = getContextEditingDomain();
+ for(Integer integer : axisPosition) {
+ cmd.append(getDestroyAxisElementCommand(domain, integer));
+ }
+
+ domain.getCommandStack().execute(cmd);
+ }
+
+ /**
+ *
+ * @return
+ * the list owning the elements displayed on the managed axis
+ */
+ protected List<Object> getElements() {
+ return this.tableManager.getElementsList(getRepresentedContentProvider());
+ }
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java index 2ec193e262e..afe68fc069f 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/CompositeAxisManager.java @@ -23,6 +23,7 @@ import java.util.Set; import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.edit.command.MoveCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
@@ -414,4 +415,88 @@ public class CompositeAxisManager extends AbstractAxisManager implements ICompos throw new UnsupportedOperationException();
}
}
+
+ /**
+ *
+ * @param axis
+ * an axis
+ * @return
+ * the axis manager managing this axis
+ */
+ protected IAxisManager getAxisManager(final IAxis axis) {
+ final AxisManagerRepresentation rep = axis.getManager();
+ for(final IAxisManager man : this.subManagers) {
+ if(man.getAxisManagerRepresentation() == rep) {
+ return man;
+ }
+ }
+ return null;//must be impossible
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.AbstractAxisManager#canDestroyAxis(java.lang.Integer)
+ *
+ * @param axisPosition
+ * @return
+ */
+ @Override
+ public boolean canDestroyAxis(final Integer axisPosition) {
+ final List<Object> elements = tableManager.getElementsList(getRepresentedContentProvider());//FIXME create a util method for that
+ final Object element = elements.get(axisPosition);
+ if(element instanceof IAxis) {
+ return getAxisManager((IAxis)element).canDestroyAxis(axisPosition);
+ }
+ //not yet managed
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canDestroyAxisElement(java.lang.Integer)
+ *
+ * @param axisPosition
+ * @return
+ */
+ @Override
+ public boolean canDestroyAxisElement(Integer axisPosition) {
+ final List<Object> elements = tableManager.getElementsList(getRepresentedContentProvider());//FIXME create a util method for that
+ final Object element = elements.get(axisPosition);
+ if(element instanceof IAxis) {
+ return getAxisManager((IAxis)element).canDestroyAxisElement(axisPosition);
+ } else if(subManagers.size() == 1) {
+ return subManagers.get(0).canDestroyAxisElement(axisPosition);
+ }
+ //not yet managed
+ return false;
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getDestroyAxisElementCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.lang.Integer)
+ *
+ * @param domain
+ * @param axisPosition
+ * @return
+ */
+ @Override
+ public Command getDestroyAxisElementCommand(EditingDomain domain, Integer axisPosition) {
+ final List<Object> elements = tableManager.getElementsList(getRepresentedContentProvider());//FIXME create a util method for that
+ final Object element = elements.get(axisPosition);
+ if(element instanceof IAxis) {
+ return getAxisManager((IAxis)element).getDestroyAxisElementCommand(domain, axisPosition);
+ } else if(subManagers.size() == 1) {
+ return subManagers.get(0).getDestroyAxisElementCommand(domain, axisPosition);
+ }
+ //not yet managed
+ return UnexecutableCommand.INSTANCE;
+ }
+
+
+
+
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java index 071f220432e..1643eb0e3ff 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/axis/IAxisManager.java @@ -14,6 +14,7 @@ package org.eclipse.papyrus.infra.nattable.manager.axis;
import java.util.Collection;
+import java.util.List;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.edit.domain.EditingDomain;
@@ -204,5 +205,65 @@ public interface IAxisManager extends IDisposable { * @return
* the name used for this axis
*/
- public String getElementAxisName(final IAxis axis);//FIXME pb if the axisManager returns Object and not IAxis...
+ public String getElementAxisName(final IAxis axis);//FIXME pb if the axisManager returns Object and not IAxis... -> use the index!
+
+ /**
+ *
+ * @param axisIndex
+ * axis index
+ * @return
+ * <code>true</code> if ALL axis identified by the axisIndex can be destroyed
+ */
+ public boolean canDestroyAxis(final List<Integer> axisIndex);
+
+ /**
+ *
+ * @param axisIndex
+ * @return
+ * <code>true</code> if the axis identified by the axisIndex can be destroyed
+ */
+ public boolean canDestroyAxis(final Integer axisIndex);
+
+ /**
+ * Destroy all axis represented by their index
+ *
+ * @param axisIndex
+ * a list of axis index
+ */
+ public void destroyAxis(final List<Integer> axisIndex);
+
+ /**
+ *
+ * @param axisIndex
+ * a list of axis index
+ * @return
+ * <code>true</code> if ALL elements represented by the axis located to these index can be destroyed
+ */
+ public boolean canDestroyAxisElement(final List<Integer> axisIndex);
+
+ /**
+ *
+ * @param axisIndex
+ * the index of an element
+ * @return
+ * <code>true</code> if we can destroy the element represented by the axis located to this index
+ */
+ public boolean canDestroyAxisElement(final Integer axisIndex);
+
+ /**
+ *
+ * @param axisIndex
+ * the list of the index of the elements to destroy
+ */
+ public void destroyAxisElement(final List<Integer> axisIndex);
+
+ /**
+ *
+ * @param domain
+ * @param axisPosition
+ * @return
+ */
+ public Command getDestroyAxisElementCommand(final EditingDomain domain, final Integer axisPosition);
+
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java index 64da2e92045..78a2d5f8d25 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java @@ -190,6 +190,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan //for the edition
// configureEdition(this.natTable, this.bodyLayerStack);
this.natTable.addConfiguration(new PapyrusHeaderMenuConfiguration());
+ // this.natTable.addConfiguration(new HeaderMenuConfiguration(this.natTable));
this.natTable.addConfiguration(new IConfiguration() {
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java index f933142ba46..956c0aa9732 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/INattableModelManager.java @@ -56,10 +56,6 @@ public interface INattableModelManager extends ILimitedNattableModelManager, ITa public IDataProvider getBodyDataProvider();
- public IAxisManager getColumnDataProvider();
-
- public IAxisManager getLineDataProvider();
-
public boolean canMoveColumns();
public boolean canMoveRows();
@@ -168,4 +164,18 @@ public interface INattableModelManager extends ILimitedNattableModelManager, ITa public boolean canEditColumnHeader(final NatEventData eventData);
public boolean canEditRowHeader(final NatEventData eventData);
+
+ /**
+ *
+ * @return
+ * the column axis manager, managing the axis inversion
+ */
+ public IAxisManager getColumnAxisManager();
+
+ /**
+ *
+ * @return
+ * the row axis manager, managing the axis inversion
+ */
+ public IAxisManager getRowAxisManager();
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java index af23616733a..5954ffdd303 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java @@ -524,30 +524,6 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen }
/**
- * this method returns the column data provider and is able to manage
- * inversion in the axis
- *
- * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#getColumnDataProvider()
- *
- * @return the column data provider
- */
- public IAxisManager getColumnDataProvider() {
- return this.columnManager;
- }
-
- /**
- * this method returns the row data provider and is able to manage inversion
- * in the axis
- *
- * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#getLineDataProvider()
- *
- * @return the row data provider
- */
- public IAxisManager getLineDataProvider() {
- return this.rowManager;
- }
-
- /**
* refresh NatTable (asyncExec)
*/
public void refreshNatTable() {
@@ -1029,4 +1005,27 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen this.columnManager.openEditAxisAliasDialog(event, event.getNatTable().getColumnIndexByPosition(event.getColumnPosition()));
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#getColumnAxisManager()
+ *
+ * @return
+ */
+ @Override
+ public IAxisManager getColumnAxisManager() {
+ return this.columnManager;
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager#getRowAxisManager()
+ *
+ * @return
+ */
+ @Override
+ public IAxisManager getRowAxisManager() {
+ return this.rowManager;
+ }
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/META-INF/MANIFEST.MF b/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/META-INF/MANIFEST.MF index b20c0eee3ae..8ce9352f681 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/META-INF/MANIFEST.MF +++ b/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/META-INF/MANIFEST.MF @@ -18,7 +18,10 @@ Require-Bundle: org.eclipse.ui, org.eclipse.emf.edit;bundle-version="2.9.0", org.eclipse.papyrus.infra.nattable.model, org.eclipse.papyrus.infra.widgets;bundle-version="0.10.0", - org.eclipse.gmf.runtime.emf.type.core + org.eclipse.gmf.runtime.emf.type.core, + org.eclipse.papyrus.infra.services.edit, + org.eclipse.papyrus.infra.gmfdiag.commands, + org.eclipse.papyrus.infra.emf Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.papyrus.sysml.nattable.manager.axis diff --git a/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/src/org/eclipse/papyrus/sysml/nattable/manager/axis/AllocateAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/src/org/eclipse/papyrus/sysml/nattable/manager/axis/AllocateAxisManager.java index ba2d132db0b..ad5060bca05 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/src/org/eclipse/papyrus/sysml/nattable/manager/axis/AllocateAxisManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/src/org/eclipse/papyrus/sysml/nattable/manager/axis/AllocateAxisManager.java @@ -16,16 +16,25 @@ package org.eclipse.papyrus.sysml.nattable.manager.axis; import java.util.ArrayList;
import java.util.List;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.nattable.manager.axis.AbstractSynchronizedOnFeatureAxisManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EObjectAxis;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
import org.eclipse.papyrus.sysml.service.types.matcher.AllocateMatcher;
import org.eclipse.uml2.uml.UMLPackage;
-public class AllocateAxisManager extends AbstractSynchronizedOnFeatureAxisManager {
+public class AllocateAxisManager extends AbstractSynchronizedOnFeatureAxisManager {//FIXME must inherits from EObjectAxisManager when the listen feature is typed by an EObejct...
/**
*
@@ -85,4 +94,47 @@ public class AllocateAxisManager extends AbstractSynchronizedOnFeatureAxisManage return interestingObjects;
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canDestroyAxisElement(java.lang.Integer)
+ *
+ * @param axisPosition
+ * @return
+ */
+ public boolean canDestroyAxisElement(Integer axisPosition) {
+ final Object current = getElements().get(axisPosition);
+ if(current instanceof EObjectAxis) {
+ return !EMFHelper.isReadOnly(((EObjectAxis)current).getElement());
+ } else if(current instanceof EObject) {
+ return !EMFHelper.isReadOnly((EObject)current);
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getDestroyAxisElementCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.lang.Integer)
+ *
+ * @param domain
+ * @param axisPosition
+ * @return
+ */
+ public Command getDestroyAxisElementCommand(EditingDomain domain, Integer axisPosition) {
+ final Object current = getElements().get(axisPosition);
+ EObject elementToDestroy = null;
+ if(current instanceof EObjectAxis) {
+ elementToDestroy = ((EObjectAxis)current).getElement();
+ } else if(current instanceof EObject) {
+ elementToDestroy = (EObject)current;
+ }
+ if(elementToDestroy != null) {
+ final DestroyElementRequest request = new DestroyElementRequest((TransactionalEditingDomain)getContextEditingDomain(), elementToDestroy, false);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(elementToDestroy);
+ return new GMFtoEMFCommandWrapper(provider.getEditCommand(request));
+ }
+ return null;
+ }
+
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/src/org/eclipse/papyrus/sysml/nattable/manager/axis/RequirementAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/src/org/eclipse/papyrus/sysml/nattable/manager/axis/RequirementAxisManager.java index 7ef3848c192..4c844c3a353 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/src/org/eclipse/papyrus/sysml/nattable/manager/axis/RequirementAxisManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/src/org/eclipse/papyrus/sysml/nattable/manager/axis/RequirementAxisManager.java @@ -16,11 +16,20 @@ package org.eclipse.papyrus.sysml.nattable.manager.axis; import java.util.ArrayList;
import java.util.List;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.nattable.manager.axis.AbstractSynchronizedOnFeatureAxisManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EObjectAxis;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
import org.eclipse.papyrus.sysml.service.types.element.SysMLElementTypes;
import org.eclipse.papyrus.sysml.service.types.matcher.RequirementMatcher;
import org.eclipse.uml2.uml.UMLPackage;
@@ -32,7 +41,7 @@ import org.eclipse.uml2.uml.UMLPackage; * @author Vincent Lorenzo
*
*/
-public class RequirementAxisManager extends AbstractSynchronizedOnFeatureAxisManager {
+public class RequirementAxisManager extends AbstractSynchronizedOnFeatureAxisManager {//FIXME must inherits from EObjectAxisManager when the listen feature is typed by an EObejct...
/**
*
@@ -91,4 +100,40 @@ public class RequirementAxisManager extends AbstractSynchronizedOnFeatureAxisMan return interestingObjects;
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canDestroyAxisElement(java.lang.Integer)
+ *
+ * @param axisPosition
+ * @return
+ */
+ public boolean canDestroyAxisElement(Integer axisPosition) {
+ final Object current = getElements().get(axisPosition);
+ if(current instanceof EObjectAxis) {
+ return !EMFHelper.isReadOnly(((EObjectAxis)current).getElement());
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#getDestroyAxisElementCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.lang.Integer)
+ *
+ * @param domain
+ * @param axisPosition
+ * @return
+ */
+ public Command getDestroyAxisElementCommand(EditingDomain domain, Integer axisPosition) {
+ final Object current = getElements().get(axisPosition);
+ if(current instanceof EObjectAxis) {
+ final EObject element = ((EObjectAxis)current).getElement();
+ final DestroyElementRequest request = new DestroyElementRequest((TransactionalEditingDomain)getContextEditingDomain(), element, false);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(element);
+ return new GMFtoEMFCommandWrapper(provider.getEditCommand(request));
+ }
+ return null;
+ }
+
+
}
diff --git a/sandbox/TableV3/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java index 1756c8b4a29..d404cedefcb 100644 --- a/sandbox/TableV3/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java +++ b/sandbox/TableV3/org.eclipse.papyrus.uml.nattable/src/org/eclipse/papyrus/uml/nattable/manager/axis/UMLStereotypePropertyAxisManager.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.Set;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
@@ -294,4 +295,23 @@ public class UMLStereotypePropertyAxisManager extends AbstractAxisManager { public boolean canEditAxisHeader() {
return true;
}
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager#canDestroyAxisElement(org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis)
+ *
+ * @param axis
+ * @return
+ */
+ public boolean canDestroyAxisElement(IAxis axis) {
+ return false;
+ }
+
+ public boolean canDestroyAxisElement(Integer axisPosition) {
+ return false;
+ }
+
+ public Command getDestroyAxisElementCommand(EditingDomain domain, Integer axisPosition) {
+ return UnexecutableCommand.INSTANCE;
+ }
}
|