Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2020-05-06 08:53:36 +0000
committerPatrick Tessier2020-05-11 08:54:07 +0000
commite6e797ea86f481b9d88a7d3d73642df093c69fa5 (patch)
tree63c5bd5c46ba7c546c083b8d3d98103d957d7597 /plugins
parent18768fb206d41d1f0d9c512f2c696e0ec18c1029 (diff)
downloadorg.eclipse.papyrus-e6e797ea86f481b9d88a7d3d73642df093c69fa5.tar.gz
org.eclipse.papyrus-e6e797ea86f481b9d88a7d3d73642df093c69fa5.tar.xz
org.eclipse.papyrus-e6e797ea86f481b9d88a7d3d73642df093c69fa5.zip
Bug 562864: [Table] StackOverflow generated by UnsetCellValueHandler
Change-Id: I25a5ffa829c7ba9084ec4c7ff4ed67d8edfc7232 Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractDisconnectSlaveHandler.java17
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java63
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTreeRowHideShowCategoryHandler.java19
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTreeTableHandler.java23
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ChangeHierarchicalTableStyle.java20
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/CollapseAndExpandTreeHandler.java38
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisElementHandler.java26
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisHandler.java32
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnEditAliasHeaderHandler.java30
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InsertInTableHandler.java45
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/LoadColumnAxisProvidersHandler.java25
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/LoadRowAxisProvidersHandler.java25
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RefreshNattableHandler.java8
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ResolvedProblemHandler.java82
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java30
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java31
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowEditAliasHeaderHandler.java29
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SaveCurrentColumnAxisProvidersHandler.java36
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SaveCurrentRowAxisProvidersHandler.java31
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectColumnsHandler.java20
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectRowsHandler.java20
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortColumnsHandler.java25
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortRowsHandler.java23
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowHideAllCategoriesCommandHandler.java33
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowHideAllCategoriesHandler.java22
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowShowAllCategoriesHandler.java19
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowShowHideCategoryCommandHandler.java13
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/UnsetCellValueHandler.java18
28 files changed, 411 insertions, 392 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractDisconnectSlaveHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractDisconnectSlaveHandler.java
index 0a38c07aba5..11d2efcf66c 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractDisconnectSlaveHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractDisconnectSlaveHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013, 2015 CEA LIST.
+ * Copyright (c) 2013, 2015, 2020 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,7 +11,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -67,13 +67,16 @@ public abstract class AbstractDisconnectSlaveHandler extends AbstractTableHandle
protected abstract AbstractAxisProvider getAxisProviderToEdit();
/**
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#computeEnable(Object)
*
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- setBaseEnabled(getAxisProviderToEdit() instanceof MasterObjectAxisProvider);
+ protected boolean computeEnable(final Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ calculatedValue = getAxisProviderToEdit() instanceof MasterObjectAxisProvider;
+ }
+ return calculatedValue;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
index 58782fa8db5..139197d89af 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
+ * Copyright (c) 2012, 2020 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,7 +11,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -57,7 +57,7 @@ public abstract class AbstractTableHandler extends AbstractHandler {
/**
* the id used to find the NatEvent in the EclipseContext
- *
+ *
* @deprecated since Papyrus 1.2 (Eclipse Neon)
*/
@Deprecated
@@ -66,7 +66,7 @@ public abstract class AbstractTableHandler extends AbstractHandler {
/**
* 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
- *
+ *
* we do a weak reference to fix the bug 469376: [Table] Memory Leak : (Tree)NattableWidgetManager, EObjectTreeItemAxis and others objects are not disposed when the table is closed
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=469376
*/
@@ -76,7 +76,7 @@ public abstract class AbstractTableHandler extends AbstractHandler {
/**
*
* @return
- * the current active part
+ * the current active part
* @deprecated since 2.0
*/
@Deprecated
@@ -85,9 +85,9 @@ public abstract class AbstractTableHandler extends AbstractHandler {
}
/**
- *
+ *
* @return
- * the TableSelectioWrapper used (according to the referenced NatEventData) or <code>null</code> if not found
+ * the TableSelectioWrapper used (according to the referenced NatEventData) or <code>null</code> if not found
* @since 2.0
*/
protected final TableSelectionWrapper getTableSelectionWrapper() {
@@ -117,7 +117,7 @@ public abstract class AbstractTableHandler extends AbstractHandler {
/**
* @return
- * the current NatTable or <code>null</code> if not found
+ * the current NatTable or <code>null</code> if not found
* @since 5.0
*/
protected NatTable getCurrentNatTable() {
@@ -149,9 +149,9 @@ public abstract class AbstractTableHandler extends AbstractHandler {
}
/**
- *
+ *
* @return
- * the last NatEventData received during the setEnable
+ * the last NatEventData received during the setEnable
*/
protected NatEventData getNatEventData() {
if (this.eventDataWeakReference != null) {
@@ -165,7 +165,7 @@ public abstract class AbstractTableHandler extends AbstractHandler {
* @param evaluationContext
* the evaluation context
* @return
- * the NatEventData from this evaluation context or <code>null</code> if not found
+ * the NatEventData from this evaluation context or <code>null</code> if not found
*/
protected NatEventData getNatEventData(final Object evaluationContext) {
if (evaluationContext instanceof NatEventData) {
@@ -183,23 +183,23 @@ public abstract class AbstractTableHandler extends AbstractHandler {
if (eventData == null) {
Point cursorLocation = Display.getDefault().getCursorLocation();
Control control = null;
-
+
// Try to get the nattable from the multi diagram
// We need to manage it from active editor for the sub menu items
final IEditorPart activeEditor = EditorHelper.getCurrentEditor();
if (null != activeEditor) {
INattableModelManager nattableModelManager = null;
- if(activeEditor instanceof IMultiPageEditorPart && null != ((IMultiPageEditorPart)activeEditor).getActiveEditor()){
- nattableModelManager = ((IMultiPageEditorPart)activeEditor).getActiveEditor().getAdapter(INattableModelManager.class);
- }else if(activeEditor instanceof IAdaptable){
- nattableModelManager = ((IAdaptable)activeEditor).getAdapter(INattableModelManager.class);
+ if (activeEditor instanceof IMultiPageEditorPart && null != ((IMultiPageEditorPart) activeEditor).getActiveEditor()) {
+ nattableModelManager = ((IMultiPageEditorPart) activeEditor).getActiveEditor().getAdapter(INattableModelManager.class);
+ } else if (activeEditor instanceof IAdaptable) {
+ nattableModelManager = ((IAdaptable) activeEditor).getAdapter(INattableModelManager.class);
}
-
- if(null != nattableModelManager){
+
+ if (null != nattableModelManager) {
control = nattableModelManager.getAdapter(NatTable.class);
}
}
-
+
if (control instanceof NatTable) {// : not nice, but required
cursorLocation = control.toControl(cursorLocation);
Event e = new Event();
@@ -227,7 +227,7 @@ public abstract class AbstractTableHandler extends AbstractHandler {
if (data != null) {
final SelectionLayer layer = manager.getBodyLayerStack().getSelectionLayer();
int[] fullSelectedColumnsPosition = layer.getFullySelectedRowPositions();
- List<Integer> positions = new ArrayList<Integer>();
+ List<Integer> positions = new ArrayList<>();
for (int i : fullSelectedColumnsPosition) {
positions.add(layer.getRowIndexByPosition(i));
}
@@ -250,7 +250,7 @@ public abstract class AbstractTableHandler extends AbstractHandler {
if (data != null) {
final SelectionLayer layer = manager.getBodyLayerStack().getSelectionLayer();
int[] fullSelectedColumnsPosition = layer.getFullySelectedColumnPositions();
- List<Integer> positions = new ArrayList<Integer>();
+ List<Integer> positions = new ArrayList<>();
for (int i : fullSelectedColumnsPosition) {
positions.add(layer.getColumnIndexByPosition(i));
}
@@ -288,16 +288,31 @@ public abstract class AbstractTableHandler extends AbstractHandler {
}
/**
+ * TODO : this method should be declared as final in Papyrus 5.0 (bug 562866)
*
* @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
*
+ * Please override {@link #computeEnable(Object)} instead of this method
* @param evaluationContext
+ *
*/
@Override
public void setEnabled(Object evaluationContext) {
- this.eventDataWeakReference = new WeakReference<NatEventData>(getNatEventData(evaluationContext));
- boolean enabled = getCurrentNattableModelManager() != null;
- setBaseEnabled(enabled);
+ this.eventDataWeakReference = new WeakReference<>(getNatEventData(evaluationContext));
+ setBaseEnabled(computeEnable(evaluationContext));
+ }
+
+ /**
+ * This method avoid to call setBaseEnable several time in the same handler
+ * to avoid a StackOverFlow is strange cases
+ *
+ * @param evaluationContext
+ * the evaluation context used to calculate the enablement
+ * @since 6.7
+ *
+ */
+ protected boolean computeEnable(final Object evaluationContext) {
+ return getCurrentNattableModelManager() != null;
}
/**
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTreeRowHideShowCategoryHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTreeRowHideShowCategoryHandler.java
index 5bf3284dd15..93ef172d0e2 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTreeRowHideShowCategoryHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTreeRowHideShowCategoryHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST and others.
+ * Copyright (c) 2014, 2020 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,7 +10,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -55,17 +55,16 @@ public abstract class AbstractTreeRowHideShowCategoryHandler extends AbstractTre
}
/**
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#computeEnable(Object)
*
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- if (isEnabled()) {
- if (FillingConfigurationUtils.getAllTreeFillingConfiguration(getTable()).size() == 0) {
- setBaseEnabled(false);
- }
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ calculatedValue = FillingConfigurationUtils.getAllTreeFillingConfiguration(getTable()).size() != 0;
}
+ return calculatedValue;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTreeTableHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTreeTableHandler.java
index 57a5fb14b1e..67a669d2821 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTreeTableHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTreeTableHandler.java
@@ -1,6 +1,6 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST and others.
- *
+ * Copyright (c) 2014, 2020 CEA LIST and others.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -25,22 +25,21 @@ import org.eclipse.papyrus.infra.nattable.utils.TableHelper;
public abstract class AbstractTreeTableHandler extends AbstractTableHandler {
/**
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#computeEnable(Object)
*
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- if (isEnabled()) {
- if ((!TableHelper.isTreeTable(getCurrentNattableModelManager())) || getTreeNattableModelManager() == null) {
- setBaseEnabled(false);
- }
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ calculatedValue = TableHelper.isTreeTable(getCurrentNattableModelManager()) && getTreeNattableModelManager() != null;
}
+ return calculatedValue;
}
/**
- *
+ *
* @return
* the current tree nattable model manager
*/
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ChangeHierarchicalTableStyle.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ChangeHierarchicalTableStyle.java
index 5bc49b1248e..a681675e1cb 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ChangeHierarchicalTableStyle.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ChangeHierarchicalTableStyle.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST and others.
+ * Copyright (c) 2014, 2020 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,7 +10,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -71,17 +71,19 @@ public class ChangeHierarchicalTableStyle extends AbstractTreeTableHandler {
}
/**
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#computeEnable(Object)
*
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- if (isEnabled()) {
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
final DisplayStyle style = TableHelper.getTableDisplayStyle(getCurrentNattableModelManager());
- setBaseEnabled(DisplayStyle.HIERARCHIC_MULTI_TREE_COLUMN.equals(style) || DisplayStyle.HIERARCHIC_SINGLE_TREE_COLUMN.equals(style));
+ calculatedValue = DisplayStyle.HIERARCHIC_MULTI_TREE_COLUMN.equals(style) || DisplayStyle.HIERARCHIC_SINGLE_TREE_COLUMN.equals(style);
}
-
+ return calculatedValue;
}
+
}
+
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/CollapseAndExpandTreeHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/CollapseAndExpandTreeHandler.java
index 2841b2bd925..0e3fad07d34 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/CollapseAndExpandTreeHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/CollapseAndExpandTreeHandler.java
@@ -1,6 +1,6 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST and others.
- *
+ * Copyright (c) 2014, 2020 CEA LIST and others.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -55,36 +55,18 @@ public class CollapseAndExpandTreeHandler extends AbstractParametricTreeTableHan
return null;
}
-
-
/**
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- if (isEnabled() && this.actionId == null) {
- setBaseEnabled(false);
- return;
- }
- if (isEnabled()) {
- switch (this.actionId) {
- case COLLAPSE_ALL_FROM_SELECTION:
- case COLLAPSE_ONE_LEVEL:
- case EXPAND_ALL_FROM_SELECTION:
- case EXPAND_ONE_LEVEL:
- if (getFullSelectedRowsIndex(evaluationContext).isEmpty()) {
- setBaseEnabled(false);
- }
- break;
-
- default:
- // nothing to do
- break;
- }
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ calculatedValue = this.actionId != null && !getFullSelectedRowsIndex(evaluationContext).isEmpty();
}
+ return calculatedValue;
}
/**
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisElementHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisElementHandler.java
index d23048bcc7b..64ac8b80f3f 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisElementHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisElementHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2020 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,7 +11,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -51,23 +51,23 @@ public class ColumnDestroyAxisElementHandler extends AbstractTableHandler {
}
/**
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- NatEventData eventData = getNatEventData();
- boolean enabled = false;
- if (isEnabled() && eventData != null) {
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ final NatEventData eventData = getNatEventData();
final IAxisManager axisManager = getColumnAxisManager();
- if (axisManager != null) {
+ if (eventData == null || axisManager == null) {
+ calculatedValue = false;
+ } else {
final List<Integer> col = getFullSelectedColumnsIndex(eventData);
- enabled = axisManager.canDestroyAxisElement(col);
+ calculatedValue = axisManager.canDestroyAxisElement(col);
}
}
- setBaseEnabled(enabled);
+ return calculatedValue;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisHandler.java
index ac8fe5ad62e..63b1f9ce1f7 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnDestroyAxisHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2020 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,7 +11,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -42,28 +42,30 @@ public class ColumnDestroyAxisHandler extends AbstractTableHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
final IAxisManager axisManager = getColumnAxisManager();
NatEventData eventData = getNatEventData();
- if (axisManager != null && eventData!=null) {
+ if (axisManager != null && eventData != null) {
axisManager.destroyAxis(getFullSelectedColumnsIndex(eventData));
}
return null;
}
/**
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- NatEventData eventData = getNatEventData();
- boolean enabled = false;
- final IAxisManager axisManager = getColumnAxisManager();
- if (isEnabled() && axisManager != null && eventData!=null) {
- final List<Integer> col = getFullSelectedColumnsIndex(eventData);
- enabled = axisManager.canDestroyAxis(col);
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ final NatEventData eventData = getNatEventData();
+ final IAxisManager axisManager = getColumnAxisManager();
+ if (eventData == null || axisManager == null) {
+ calculatedValue = false;
+ } else {
+ final List<Integer> col = getFullSelectedColumnsIndex(eventData);
+ calculatedValue = axisManager.canDestroyAxis(col);
+ }
}
- setBaseEnabled(enabled);
+ return calculatedValue;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnEditAliasHeaderHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnEditAliasHeaderHandler.java
index 49123f4afd7..94dd9d27217 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnEditAliasHeaderHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ColumnEditAliasHeaderHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2020 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,7 +11,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -26,7 +26,7 @@ import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
public class ColumnEditAliasHeaderHandler extends AbstractTableHandler {
/**
- *
+ *
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*
* @param event
@@ -44,20 +44,22 @@ public class ColumnEditAliasHeaderHandler extends AbstractTableHandler {
}
/**
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {// it must be the nattable selection event
- super.setEnabled(evaluationContext);
- final NatEventData eventData = getNatEventData();
- final NattableModelManager manager = (NattableModelManager) getCurrentNattableModelManager();
- if (isEnabled() && eventData != null && manager != null) {
- setBaseEnabled(manager.canEditColumnHeader(eventData));
- } else {
- setBaseEnabled(false);
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ final NatEventData eventData = getNatEventData();
+ final NattableModelManager manager = (NattableModelManager) getCurrentNattableModelManager();
+ if (eventData == null || manager == null) {
+ calculatedValue = false;
+ } else {
+ calculatedValue = manager.canEditColumnHeader(eventData);
+ }
}
+ return calculatedValue;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InsertInTableHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InsertInTableHandler.java
index 807a7ff3c3a..fc0c2402a97 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InsertInTableHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/InsertInTableHandler.java
@@ -1,6 +1,6 @@
/*****************************************************************************
- * Copyright (c) 2015 CEA LIST and others.
- *
+ * Copyright (c) 2015, 2020 CEA LIST and others.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,7 @@
*
* Contributors:
* Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -18,7 +18,6 @@ package org.eclipse.papyrus.infra.nattable.handler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
import org.eclipse.papyrus.infra.nattable.provider.TableStructuredSelection;
import org.eclipse.papyrus.infra.nattable.utils.AbstractPasteInsertInTableHandler;
@@ -33,7 +32,7 @@ public class InsertInTableHandler extends AbstractPasteInsertInTableHandler {
/**
* {@inheritDoc}
- *
+ *
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@SuppressWarnings("unchecked")
@@ -43,32 +42,32 @@ public class InsertInTableHandler extends AbstractPasteInsertInTableHandler {
}
/**
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(final Object evaluationContext) {
- super.setEnabled(evaluationContext);
- if (isEnabled()) {
- // Recalculate if the enable is allowed because the user can select cells and try to insert by click on rows for example.
- boolean canEnable = false;
- final INattableModelManager currentNattableModelManager = getCurrentNattableModelManager();
- if (null != currentNattableModelManager) {
- final ISelection currentSelection = ((NattableModelManager) currentNattableModelManager).getSelectionInTable();
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ final NattableModelManager manager = (NattableModelManager) getCurrentNattableModelManager();
+ if (manager == null) {
+ calculatedValue = false;
+ } else {
+ final ISelection currentSelection = manager.getSelectionInTable();
if (null == currentSelection) {
- canEnable = true;
+ calculatedValue = true;
} else if (currentSelection instanceof TableStructuredSelection) {
TableSelectionWrapper tableSelectionWrapper = (TableSelectionWrapper) ((TableStructuredSelection) currentSelection).getAdapter(TableSelectionWrapper.class);
- if (null != tableSelectionWrapper) {
- if (tableSelectionWrapper.getSelectedCells().isEmpty()
- || !tableSelectionWrapper.getFullySelectedRows().isEmpty() && tableSelectionWrapper.getFullySelectedColumns().isEmpty()) {
- canEnable = true;
- }
- }
+ calculatedValue = tableSelectionWrapper != null
+ && (tableSelectionWrapper.getSelectedCells().isEmpty()
+ || (!tableSelectionWrapper.getFullySelectedRows().isEmpty()
+ && tableSelectionWrapper.getFullySelectedColumns().isEmpty()));
+ } else {
+ calculatedValue = false;
}
}
- setBaseEnabled(canEnable);
}
+ return calculatedValue;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/LoadColumnAxisProvidersHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/LoadColumnAxisProvidersHandler.java
index f63b27c1c1f..db25c2b1037 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/LoadColumnAxisProvidersHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/LoadColumnAxisProvidersHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2020 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
*
* Contributors:
* Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -71,19 +72,21 @@ public class LoadColumnAxisProvidersHandler extends AbstractLoadAxisProvidersHan
}
/**
- * This handler is enabled only if the concerned axis manager allows to save a configuration.
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- if (getCurrentNattableModelManager() != null && getCurrentNattableModelManager().getColumnAxisManager() != null) {
- IAxisManager columnAxisManager = this.getCurrentNattableModelManager().getColumnAxisManager();
- setBaseEnabled(columnAxisManager.canBeSavedAsConfig());
- } else {
- setBaseEnabled(false);
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ if (getCurrentNattableModelManager() != null && getCurrentNattableModelManager().getColumnAxisManager() != null) {
+ final IAxisManager columnAxisManager = getCurrentNattableModelManager().getColumnAxisManager();
+ calculatedValue = columnAxisManager.canBeSavedAsConfig();
+ } else {
+ calculatedValue = false;
+ }
}
+ return calculatedValue;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/LoadRowAxisProvidersHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/LoadRowAxisProvidersHandler.java
index 011da2cf60a..896bf98a3dc 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/LoadRowAxisProvidersHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/LoadRowAxisProvidersHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2020 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
*
* Contributors:
* Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -26,20 +27,22 @@ import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.Ab
public class LoadRowAxisProvidersHandler extends AbstractLoadAxisProvidersHandler {
/**
- * This handler is enabled only if the concerned axis manager allows to save a configuration.
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- if (getCurrentNattableModelManager() != null && getCurrentNattableModelManager().getRowAxisManager() != null) {
- IAxisManager columnAxisManager = this.getCurrentNattableModelManager().getRowAxisManager();
- setBaseEnabled(columnAxisManager.canBeSavedAsConfig());
- } else {
- setBaseEnabled(false);
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ if (getCurrentNattableModelManager() != null && getCurrentNattableModelManager().getRowAxisManager() != null) {
+ final IAxisManager rowAxisManager = getCurrentNattableModelManager().getRowAxisManager();
+ calculatedValue = rowAxisManager.canBeSavedAsConfig();
+ } else {
+ calculatedValue = false;
+ }
}
+ return calculatedValue;
}
/**
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RefreshNattableHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RefreshNattableHandler.java
index 3e300bc42e8..2ebf1fa63a0 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RefreshNattableHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RefreshNattableHandler.java
@@ -17,18 +17,19 @@ package org.eclipse.papyrus.infra.nattable.handler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.papyrus.infra.nattable.Activator;
import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
import org.eclipse.swt.widgets.Display;
/**
- *
+ *
* This handler allows to force a nattable refresh
*
*/
public class RefreshNattableHandler extends AbstractTableHandler {
/**
- *
+ *
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*
* @param event
@@ -43,8 +44,7 @@ public class RefreshNattableHandler extends AbstractTableHandler {
try {
b = Display.getDefault().readAndDispatch();
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Activator.log.error(e);
}
if (!b) {
break;
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ResolvedProblemHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ResolvedProblemHandler.java
index f9cfb865c25..7cd26ec6b05 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ResolvedProblemHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ResolvedProblemHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2020 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,7 +11,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -60,7 +60,7 @@ public class ResolvedProblemHandler extends AbstractTableHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final TransactionalEditingDomain domain = getTableEditingDomain();
-
+
Problem problemToDestroy = getProblemToDestroy(event);
DestroyElementRequest request = new DestroyElementRequest(domain, problemToDestroy, false);
final Cell cell = (Cell) problemToDestroy.eContainer();
@@ -71,61 +71,61 @@ public class ResolvedProblemHandler extends AbstractTableHandler {
// TODO : improve me and move me into an edit helper when we will have customization for the cell
composite.add(new AbstractTransactionalCommand(domain, "Clean Table Model : remove empty Cell", null) { //$NON-NLS-1$
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- boolean isEmpty = true;
- if (cell.getProblems().size() == 0) {
- Collection<EStructuralFeature> featureToIgnore = new ArrayList<EStructuralFeature>();
- featureToIgnore.add(EcorePackage.eINSTANCE.getEModelElement_EAnnotations());
- featureToIgnore.add(NattablecellPackage.eINSTANCE.getCell_ColumnWrapper());
- featureToIgnore.add(NattablecellPackage.eINSTANCE.getCell_RowWrapper());
- Collection<EStructuralFeature> allFeatures = new ArrayList<EStructuralFeature>(cell.eClass().getEAllStructuralFeatures());
- allFeatures.removeAll(featureToIgnore);
- for (EStructuralFeature eStructuralFeature : allFeatures) {
- if (eStructuralFeature.isMany()) {
- if (!((Collection<?>) cell.eGet(eStructuralFeature)).isEmpty()) {
- isEmpty = false;
- }
- } else {
- if (cell.eGet(eStructuralFeature) != eStructuralFeature.getDefaultValue()) {
- isEmpty = false;
- }
- }
-
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ boolean isEmpty = true;
+ if (cell.getProblems().size() == 0) {
+ Collection<EStructuralFeature> featureToIgnore = new ArrayList<>();
+ featureToIgnore.add(EcorePackage.eINSTANCE.getEModelElement_EAnnotations());
+ featureToIgnore.add(NattablecellPackage.eINSTANCE.getCell_ColumnWrapper());
+ featureToIgnore.add(NattablecellPackage.eINSTANCE.getCell_RowWrapper());
+ Collection<EStructuralFeature> allFeatures = new ArrayList<>(cell.eClass().getEAllStructuralFeatures());
+ allFeatures.removeAll(featureToIgnore);
+ for (EStructuralFeature eStructuralFeature : allFeatures) {
+ if (eStructuralFeature.isMany()) {
+ if (!((Collection<?>) cell.eGet(eStructuralFeature)).isEmpty()) {
+ isEmpty = false;
+ }
+ } else {
+ if (cell.eGet(eStructuralFeature) != eStructuralFeature.getDefaultValue()) {
+ isEmpty = false;
}
}
- if (isEmpty) {
- DestroyElementRequest request = new DestroyElementRequest(domain, cell, false);
- // final Cell cell = (Cell)problemToDestroy.eContainer();
- IElementEditService provider = ElementEditServiceUtils.getCommandProvider(cell.eContainer());
- provider.getEditCommand(request).execute(null, null);
- }
- return null;
+
}
- });
+ }
+ if (isEmpty) {
+ DestroyElementRequest request = new DestroyElementRequest(domain, cell, false);
+ // final Cell cell = (Cell)problemToDestroy.eContainer();
+ IElementEditService provider = ElementEditServiceUtils.getCommandProvider(cell.eContainer());
+ provider.getEditCommand(request).execute(null, null);
+ }
+ return null;
+ }
+ });
Command cmd = new GMFtoEMFCommandWrapper(composite);
domain.getCommandStack().execute(cmd);
return null;
}
/**
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- if (isEnabled()) {
- setBaseEnabled(getProblemToDestroy(evaluationContext) != null);
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ calculatedValue = getProblemToDestroy(evaluationContext) != null;
}
+ return calculatedValue;
}
/**
- *
+ *
* @param evaluationContextOrExecutionEvent
- * an evaluation context (coming from setEnable(Object evaluationContext) or an ExecutionEvent (coming from execute(ExecutionEvent e)
+ * an evaluation context (coming from setEnable(Object evaluationContext) or an ExecutionEvent (coming from execute(ExecutionEvent e)
* @return
*/
private Problem getProblemToDestroy(Object evaluationContextOrExecutionEvent) {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java
index ddf637ea6da..740d50a1a0b 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisElementHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2020 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,7 +11,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -49,21 +49,23 @@ public class RowDestroyAxisElementHandler extends AbstractTableHandler {
}
/**
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- boolean enabled = false;
- NatEventData eventData = getNatEventData();
- final IAxisManager axisManager = getRowAxisManager();
- if (isEnabled() && axisManager != null && eventData != null) {
- final List<Integer> rows = getFullSelectedRowsIndex(eventData);
- enabled = axisManager.canDestroyAxisElement(rows);
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ final NatEventData eventData = getNatEventData();
+ final IAxisManager axisManager = getRowAxisManager();
+ calculatedValue = eventData != null && axisManager != null;
+ if (calculatedValue) {
+ final List<Integer> rows = getFullSelectedRowsIndex(eventData);
+ calculatedValue = axisManager.canDestroyAxisElement(rows);
+ }
}
- setBaseEnabled(enabled);
+ return calculatedValue;
}
+
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java
index 47680b92451..5d8d94b9bb7 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowDestroyAxisHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2020 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,7 +11,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -42,28 +42,29 @@ public class RowDestroyAxisHandler extends AbstractTableHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
final IAxisManager axisManager = getRowAxisManager();
NatEventData eventData = getNatEventData();
- if (axisManager != null && eventData!=null) {
+ if (axisManager != null && eventData != null) {
axisManager.destroyAxis(getFullSelectedRowsIndex(eventData));
}
return null;
}
/**
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- final IAxisManager axisManager = getRowAxisManager();
- boolean enabled = false;
- NatEventData eventData = getNatEventData();
- if (isEnabled() && axisManager != null && eventData!=null) {
- final List<Integer> rows = getFullSelectedRowsIndex(eventData);
- enabled = axisManager.canDestroyAxis(rows);
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ final NatEventData eventData = getNatEventData();
+ final IAxisManager axisManager = getRowAxisManager();
+ calculatedValue = eventData != null && axisManager != null;
+ if (calculatedValue) {
+ final List<Integer> rows = getFullSelectedRowsIndex(eventData);
+ calculatedValue = axisManager.canDestroyAxis(rows);
+ }
}
- setBaseEnabled(enabled);
+ return calculatedValue;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowEditAliasHeaderHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowEditAliasHeaderHandler.java
index 030c6ed72de..d2d61e523fb 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowEditAliasHeaderHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/RowEditAliasHeaderHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2020 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,7 +11,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -26,7 +26,7 @@ import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
public class RowEditAliasHeaderHandler extends AbstractTableHandler {
/**
- *
+ *
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*
* @param event
@@ -36,7 +36,7 @@ public class RowEditAliasHeaderHandler extends AbstractTableHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
NatEventData eventData = getNatEventData();
- if (eventData!=null) {
+ if (eventData != null) {
AbstractNattableWidgetManager manager = (AbstractNattableWidgetManager) getCurrentNattableModelManager();
manager.openEditRowAliasDialog(eventData);
}
@@ -44,22 +44,19 @@ public class RowEditAliasHeaderHandler extends AbstractTableHandler {
}
/**
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {// it must be the nattable selection event
- super.setEnabled(evaluationContext);
- final NatEventData eventData = getNatEventData();
- final NattableModelManager manager = (NattableModelManager) getCurrentNattableModelManager();
- if(isEnabled() && eventData!=null && manager!=null ){
- setBaseEnabled(manager.canEditRowHeader(eventData));
- } else {
- setBaseEnabled(false);
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ final NatEventData eventData = getNatEventData();
+ final NattableModelManager manager = (NattableModelManager) getCurrentNattableModelManager();
+ calculatedValue = eventData != null && manager != null && manager.canEditRowHeader(eventData);
}
+ return calculatedValue;
}
-
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SaveCurrentColumnAxisProvidersHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SaveCurrentColumnAxisProvidersHandler.java
index ddb52f20324..abfa29322c0 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SaveCurrentColumnAxisProvidersHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SaveCurrentColumnAxisProvidersHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2020 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,12 +10,12 @@
*
* Contributors:
* Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EReference;
-import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
@@ -26,22 +26,30 @@ import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.Ab
*/
public class SaveCurrentColumnAxisProvidersHandler extends AbstractSaveCurrentAxisProvidersHandler {
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
+ *
+ * @return
+ * @since 6.7
+ */
@Override
- public void setEnabled(Object evaluationContext) {
- INattableModelManager manager = this.getCurrentNattableModelManager();
- if (manager == null) {
- setBaseEnabled(false);
- return;
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ calculatedValue = manager != null
+ && manager.getColumnAxisManager() != null
+ && manager.getColumnAxisManager().canBeSavedAsConfig();
}
-
- IAxisManager columnAxisManager = manager.getColumnAxisManager();
- if (columnAxisManager == null) {
- setBaseEnabled(false);
- return;
- }
- setBaseEnabled(columnAxisManager.canBeSavedAsConfig());
+ return calculatedValue;
}
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractSaveCurrentAxisProvidersHandler#getAxisProvider()
+ *
+ * @return
+ */
@Override
public AbstractAxisProvider getAxisProvider() {
return this.getCurrentNattableModelManager().getVerticalAxisProvider();
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SaveCurrentRowAxisProvidersHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SaveCurrentRowAxisProvidersHandler.java
index 7e4d41fe35f..9170c5cab1b 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SaveCurrentRowAxisProvidersHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SaveCurrentRowAxisProvidersHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2020 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,12 +10,12 @@
*
* Contributors:
* Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EReference;
-import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
@@ -60,25 +60,20 @@ public class SaveCurrentRowAxisProvidersHandler extends AbstractSaveCurrentAxisP
}
/**
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
+ * @return
+ * @since 6.7
*/
@Override
- public void setEnabled(Object evaluationContext) {
- INattableModelManager manager = this.getCurrentNattableModelManager();
- if (manager == null) {
- setBaseEnabled(false);
- return;
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ calculatedValue = manager != null
+ && manager.getRowAxisManager() != null
+ && manager.getRowAxisManager().canBeSavedAsConfig();
}
-
- IAxisManager rowAxisManager = manager.getRowAxisManager();
- if (rowAxisManager == null) {
- setBaseEnabled(false);
- return;
- }
- setBaseEnabled(rowAxisManager.canBeSavedAsConfig());
+ return calculatedValue;
}
-
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectColumnsHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectColumnsHandler.java
index d2953f368f6..c7ea5526ef3 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectColumnsHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectColumnsHandler.java
@@ -44,19 +44,19 @@ public class SelectColumnsHandler extends AbstractTableHandler {
}
/**
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
+ * @return
+ * @since 6.7
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- final INattableModelManager currentNattableModelManager = getCurrentNattableModelManager();
- boolean enabled = false;
- if (currentNattableModelManager != null) {
- enabled = currentNattableModelManager.canCreateDestroyColumnsAxis();
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ calculatedValue = manager != null
+ && manager.canCreateDestroyColumnsAxis();
}
- setBaseEnabled(enabled);
+ return calculatedValue;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectRowsHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectRowsHandler.java
index 933ce1e80b2..198158ac996 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectRowsHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectRowsHandler.java
@@ -44,19 +44,19 @@ public class SelectRowsHandler extends AbstractTableHandler {
}
/**
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
+ * @return
+ * @since 6.7
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- final INattableModelManager currentNattableModelManager = getCurrentNattableModelManager();
- boolean enabled = false;
- if (currentNattableModelManager != null) {
- enabled = currentNattableModelManager.canCreateDestroyRowsAxis();
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ calculatedValue = manager != null
+ && manager.canCreateDestroyRowsAxis();
}
- setBaseEnabled(enabled);
+ return calculatedValue;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortColumnsHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortColumnsHandler.java
index caa306f44ba..644b66d6965 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortColumnsHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortColumnsHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2020 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,7 +11,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -40,26 +40,25 @@ public class SortColumnsHandler extends AbstractTableHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
final String directionParameter = event.getParameter(Constants.SORT_COMMAND_PARAMETER);
INattableModelManager manager = getCurrentNattableModelManager();
- boolean alphabeticOrder = "true".equals(directionParameter);
+ boolean alphabeticOrder = Boolean.TRUE.toString().equals(directionParameter);
manager.sortColumnsByName(alphabeticOrder);
return null;
}
/**
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- INattableModelManager manager = getCurrentNattableModelManager();
- boolean enabled = false;
- if (manager != null) {
- enabled = manager.canMoveColumns();
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ calculatedValue = manager != null
+ && manager.canMoveColumns();
}
- setBaseEnabled(enabled);
+ return calculatedValue;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortRowsHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortRowsHandler.java
index e627c9da29d..cbdccc46b04 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortRowsHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortRowsHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2020 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,7 +11,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -46,19 +46,18 @@ public class SortRowsHandler extends AbstractTableHandler {
}
/**
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- INattableModelManager manager = getCurrentNattableModelManager();
- boolean enabled = false;
- if (manager != null) {
- enabled = manager.canMoveColumns();
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ final INattableModelManager manager = getCurrentNattableModelManager();
+ calculatedValue = manager != null
+ && manager.canMoveRows();
}
- setBaseEnabled(enabled);
+ return calculatedValue;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowHideAllCategoriesCommandHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowHideAllCategoriesCommandHandler.java
index 3cd406d24ec..ef073fe3f03 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowHideAllCategoriesCommandHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowHideAllCategoriesCommandHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST and others.
+ * Copyright (c) 2014, 2020 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,7 +10,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -30,12 +30,18 @@ import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.Nattables
import org.eclipse.papyrus.infra.nattable.utils.FillingConfigurationUtils;
import org.eclipse.papyrus.infra.nattable.utils.NamedStyleConstants;
-
-
+/**
+ *
+ * @deprecated since Papyrus 4.8, use TreeRowHideAllCategoriesHandler
+ *
+ * this class is not used
+ * this class will be removed in Papyrus 5.0 (see bug Bug 562870)
+ */
+@Deprecated
public class TreeRowHideAllCategoriesCommandHandler extends AbstractTreeRowHideShowCategoryHandler {
/**
- *
+ *
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*
* @param event
@@ -54,7 +60,7 @@ public class TreeRowHideAllCategoriesCommandHandler extends AbstractTreeRowHideS
cc.append(AddCommand.create(getTableEditingDomain(), table, NattablestylePackage.eINSTANCE.getStyledElement_Styles(), Collections.singleton(values)));
cc.append(SetCommand.create(getTableEditingDomain(), values, NattablestylePackage.eINSTANCE.getNamedStyle_Name(), NamedStyleConstants.HIDDEN_CATEGORY_FOR_DEPTH));
}
- final List<Integer> toHide = new ArrayList<Integer>();
+ final List<Integer> toHide = new ArrayList<>();
int start = 0;
if (!FillingConfigurationUtils.hasTreeFillingConfigurationForDepth(getTable(), 0)) {
start = 1;
@@ -69,18 +75,17 @@ public class TreeRowHideAllCategoriesCommandHandler extends AbstractTreeRowHideS
}
/**
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- if (isEnabled()) {
- if (allCategoriesAreCurrentlyHidden()) {
- setBaseEnabled(false);
- }
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ calculatedValue = !allCategoriesAreCurrentlyHidden();
}
+ return calculatedValue;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowHideAllCategoriesHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowHideAllCategoriesHandler.java
index d9470654214..8a92ae10668 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowHideAllCategoriesHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowHideAllCategoriesHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST and others.
+ * Copyright (c) 2014, 2020 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,7 +10,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -52,7 +52,7 @@ public class TreeRowHideAllCategoriesHandler extends AbstractTreeRowHideShowCate
Table table = getTable();
// 1. obtain the list of feature to hide
- final List<Integer> toHide = new ArrayList<Integer>();
+ final List<Integer> toHide = new ArrayList<>();
int start = 0;
if (!FillingConfigurationUtils.hasTreeFillingConfigurationForDepth(getTable(), 0)) {
start = 1;
@@ -83,19 +83,19 @@ public class TreeRowHideAllCategoriesHandler extends AbstractTreeRowHideShowCate
return null;
}
+
/**
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- if (isEnabled()) {
- if (allCategoriesAreCurrentlyHidden()) {
- setBaseEnabled(false);
- }
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ calculatedValue = allCategoriesAreCurrentlyHidden();
}
+ return calculatedValue;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowShowAllCategoriesHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowShowAllCategoriesHandler.java
index dadb4b6e76f..d7e5a1e9c8f 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowShowAllCategoriesHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowShowAllCategoriesHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST and others.
+ * Copyright (c) 2014, 2020 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,7 +10,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -49,17 +49,16 @@ public class TreeRowShowAllCategoriesHandler extends AbstractTreeRowHideShowCate
}
/**
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTreeTableHandler#computeEnable(Object)
*
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- if (isEnabled()) {
- if (allCategoriesAreCurrentlyVisible()) {
- setBaseEnabled(false);
- }
+ protected boolean computeEnable(Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ calculatedValue = !allCategoriesAreCurrentlyVisible();
}
+ return calculatedValue;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowShowHideCategoryCommandHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowShowHideCategoryCommandHandler.java
index 460eab185a4..c784c46da4e 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowShowHideCategoryCommandHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowShowHideCategoryCommandHandler.java
@@ -1,6 +1,6 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST and others.
- *
+ * Copyright (c) 2014, 2020 CEA LIST and others.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -10,7 +10,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -19,9 +19,14 @@ import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
/**
- * @author Vincent Lorenzo
+ *
+ * @deprecated since Papyrus 4.8, use TreeRowHideAllCategoriesHandler
+ *
+ * this class is not used
+ * this class will be removed in Papyrus 5.0 (see bug Bug 562870)
*
*/
+@Deprecated
public class TreeRowShowHideCategoryCommandHandler extends AbstractTreeRowHideShowCategoryHandler {
/**
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/UnsetCellValueHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/UnsetCellValueHandler.java
index de0ba95dcf5..3f2b01e883d 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/UnsetCellValueHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/UnsetCellValueHandler.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - bug 559968
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - bug 559968, 562864
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.handler;
@@ -73,21 +73,21 @@ public class UnsetCellValueHandler extends AbstractTableHandler {
return null;
}
-
/**
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#computeEnable(Object)
*
- * @param evaluationContext
+ * @return
*/
@Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- if (isEnabled()) {
- boolean enabled = canUnsetCell(evaluationContext);
- setBaseEnabled(enabled);
+ protected boolean computeEnable(final Object evaluationContext) {
+ boolean calculatedValue = super.computeEnable(evaluationContext);
+ if (calculatedValue) {
+ calculatedValue = canUnsetCell(evaluationContext);
}
+ return calculatedValue;
}
+
/**
*
* @param evaluationContext

Back to the top