From 4f591cbe4568f54b0dbcef50e8fd018e9a11535e Mon Sep 17 00:00:00 2001 From: Vincent Lorenzo Date: Mon, 10 Feb 2020 13:31:59 +0100 Subject: Bug 559968: [Table] org.eclipse.papyrus.infra.nattable.handler.UnsetCellValueHandler must be modified Change-Id: I25e421666d4b11252122cd6dfd6f7a448d7e1446 Signed-off-by: Vincent Lorenzo --- .../META-INF/MANIFEST.MF | 2 +- .../org.eclipse.papyrus.infra.nattable/pom.xml | 2 +- .../nattable/handler/UnsetCellValueHandler.java | 34 +++++++++++++++------- .../papyrus/infra/widgets/util/EditorFactory.java | 12 ++++---- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF index 4fa46aa1aab..9575b94ffd7 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF @@ -76,7 +76,7 @@ Require-Bundle: org.eclipse.gmf.runtime.emf.type.core;bundle-version="[1.9.0,2.0 javax.inject;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %Bundle-Vendor Bundle-ActivationPolicy: lazy -Bundle-Version: 6.5.0.qualifier +Bundle-Version: 6.5.100.qualifier Bundle-Name: %Bundle-Name Bundle-Activator: org.eclipse.papyrus.infra.nattable.Activator Bundle-ManifestVersion: 2 diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/pom.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/pom.xml index 2dca78fa70c..760ad5fd80c 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/pom.xml +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/pom.xml @@ -9,6 +9,6 @@ 0.0.1-SNAPSHOT org.eclipse.papyrus.infra.nattable - 6.5.0-SNAPSHOT + 6.5.100-SNAPSHOT eclipse-plugin 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 2a449e03872..de0ba95dcf5 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 @@ -1,3 +1,18 @@ +/***************************************************************************** + * Copyright (c) 2015, 2016, 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 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - bug 559968 + *****************************************************************************/ + package org.eclipse.papyrus.infra.nattable.handler; import org.eclipse.core.commands.ExecutionEvent; @@ -11,18 +26,17 @@ import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer; import org.eclipse.nebula.widgets.nattable.ui.NatEventData; import org.eclipse.papyrus.infra.nattable.manager.cell.CellManagerFactory; import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; -import org.eclipse.papyrus.infra.nattable.utils.AxisUtils; import org.eclipse.papyrus.infra.nattable.utils.TableSelectionWrapper; /** - * + * * This handler is used to unset cell values, that is to say, than we reset the cell value to the default value * */ public class UnsetCellValueHandler extends AbstractTableHandler { /** - * + * * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) * * @param event @@ -44,8 +58,8 @@ public class UnsetCellValueHandler extends AbstractTableHandler { SelectionLayer layer = manager.getBodyLayerStack().getSelectionLayer(); int colIndex = layer.getColumnIndexByPosition(colPosition); int rowIndex = layer.getRowIndexByPosition(rowposition); - Object columnElement = AxisUtils.getRepresentedElement(manager.getColumnElement(colIndex)); - Object rowElement = AxisUtils.getRepresentedElement(manager.getRowElement(rowIndex)); + Object columnElement = manager.getColumnElement(colIndex); + Object rowElement = manager.getRowElement(rowIndex); Command command = CellManagerFactory.INSTANCE.getUnsetCellValueCommand(getContextEditingDomain(), columnElement, rowElement, manager); if (command != null && command.canExecute()) { @@ -75,21 +89,21 @@ public class UnsetCellValueHandler extends AbstractTableHandler { } /** - * + * * @param evaluationContext - * + * * @return * true if the mouse is in the Body of the table and if cells are selected */ protected boolean canUnsetCell(Object evaluationContext) { boolean enabled = false; TableSelectionWrapper wrapper = getTableSelectionWrapper(); - if (wrapper!=null && !wrapper.getSelectedCells().isEmpty()) { + if (wrapper != null && !wrapper.getSelectedCells().isEmpty()) { enabled = true; NatEventData data = getNatEventData(); - if (data != null) { //null with JUnit tests + if (data != null) { // null with JUnit tests LabelStack labels = data.getRegionLabels(); - if(labels!=null){ //seem null with JUnit tests + if (labels != null) { // seem null with JUnit tests enabled = labels.hasLabel(GridRegion.BODY) && labels.getLabels().size() == 1; } } diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/EditorFactory.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/EditorFactory.java index 967c32f863f..e25bfcb8e50 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/EditorFactory.java +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/EditorFactory.java @@ -1,14 +1,16 @@ /***************************************************************************** * Copyright (c) 2018 CEA LIST and others. - * + * * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation - * + * *****************************************************************************/ package org.eclipse.papyrus.infra.widgets.util; @@ -18,7 +20,7 @@ import org.eclipse.swt.widgets.Composite; /** * The editor factory to create value editor. - * + * * @since 3.3 */ @FunctionalInterface -- cgit v1.2.3