Bug 516997 - [SysML 1.4][Table] The non-atomic FlowPort direction cannot
be editable https://bugs.eclipse.org/bugs/show_bug.cgi?id=516997
- Manage FlowPort direction column do be not editable and displays 'N/A'
when the flowport is non-atomic
- refactor/move Constant in profile plugin as SysMLQualifiedName
Change-Id: I8ec729ab2b9f5a4b15f99fc533ad3fd27b97d20b
Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
diff --git a/table/org.eclipse.papyrus.sysml14.nattable.common/src/org/eclipse/papyrus/sysml14/nattable/common/utils/Constants.java b/core/org.eclipse.papyrus.sysml14/src/org/eclipse/papyrus/sysml14/util/SysMLQualifiedName.java
similarity index 67%
rename from table/org.eclipse.papyrus.sysml14.nattable.common/src/org/eclipse/papyrus/sysml14/nattable/common/utils/Constants.java
rename to core/org.eclipse.papyrus.sysml14/src/org/eclipse/papyrus/sysml14/util/SysMLQualifiedName.java
index e66635c..7a36d26 100644
--- a/table/org.eclipse.papyrus.sysml14.nattable.common/src/org/eclipse/papyrus/sysml14/nattable/common/utils/Constants.java
+++ b/core/org.eclipse.papyrus.sysml14/src/org/eclipse/papyrus/sysml14/util/SysMLQualifiedName.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2017 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -8,23 +8,22 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
*
*****************************************************************************/
-package org.eclipse.papyrus.sysml14.nattable.common.utils;
+package org.eclipse.papyrus.sysml14.util;
-public final class Constants {
+public final class SysMLQualifiedName {
- private Constants() {
+ private SysMLQualifiedName() {
// to prevent instantiation
}
-
/**
* The qualified name of the property direction
* @deprecated
*/
@Deprecated
- public static final String STEREOTYPE_FLOWPORT_DIRECTION = "SysML::PortsAndFlows::FlowPort::direction"; //$NON-NLS-1$
+ public static final String STEREOTYPE_FLOWPORT_DIRECTION = "SysML::DeprecatedElements::FlowPort::direction"; //$NON-NLS-1$
}
diff --git a/table/org.eclipse.papyrus.sysml14.nattable.common/META-INF/MANIFEST.MF b/table/org.eclipse.papyrus.sysml14.nattable.common/META-INF/MANIFEST.MF
index bfa975b..a1989f0 100644
--- a/table/org.eclipse.papyrus.sysml14.nattable.common/META-INF/MANIFEST.MF
+++ b/table/org.eclipse.papyrus.sysml14.nattable.common/META-INF/MANIFEST.MF
@@ -2,8 +2,7 @@
Export-Package: org.eclipse.papyrus.sysml14.nattable.common,
org.eclipse.papyrus.sysml14.nattable.common.manager.axis,
org.eclipse.papyrus.sysml14.nattable.common.manager.cell,
- org.eclipse.papyrus.sysml14.nattable.common.provider,
- org.eclipse.papyrus.sysml14.nattable.common.utils
+ org.eclipse.papyrus.sysml14.nattable.common.provider
Require-Bundle: org.eclipse.ui;bundle-version="[3.107.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.11.1,4.0.0)",
org.eclipse.uml2.uml;bundle-version="[5.1.0,6.0.0)",
diff --git a/table/org.eclipse.papyrus.sysml14.nattable.common/src/org/eclipse/papyrus/sysml14/nattable/common/manager/cell/SysMLStereotypePropertyCellManager.java b/table/org.eclipse.papyrus.sysml14.nattable.common/src/org/eclipse/papyrus/sysml14/nattable/common/manager/cell/SysMLStereotypePropertyCellManager.java
index 98c7690..526cb80 100644
--- a/table/org.eclipse.papyrus.sysml14.nattable.common/src/org/eclipse/papyrus/sysml14/nattable/common/manager/cell/SysMLStereotypePropertyCellManager.java
+++ b/table/org.eclipse.papyrus.sysml14.nattable.common/src/org/eclipse/papyrus/sysml14/nattable/common/manager/cell/SysMLStereotypePropertyCellManager.java
@@ -9,78 +9,84 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 516997
*
*****************************************************************************/
package org.eclipse.papyrus.sysml14.nattable.common.manager.cell;
+import java.util.AbstractMap;
import java.util.List;
-
+import java.util.Map.Entry;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.sysml14.service.types.matcher.FlowPortNAMatcher;
+import org.eclipse.papyrus.sysml14.util.SysMLQualifiedName;
import org.eclipse.papyrus.uml.nattable.manager.cell.StereotypePropertyCellManager;
import org.eclipse.papyrus.uml.nattable.utils.Constants;
import org.eclipse.uml2.uml.Port;
/**
- *
* This cell manager manages the cell displaying the direction of the FlowPort.
* If the flowport is not atomic, the cell is not editable and the direction is N/A.
- *
*/
public class SysMLStereotypePropertyCellManager extends StereotypePropertyCellManager {
/**
* the FlowPort isAtomicMatcher
*/
- private static FlowPortNAMatcher matcher = new FlowPortNAMatcher();
+ private static final FlowPortNAMatcher matcher = new FlowPortNAMatcher();
-// FIXME
-
-// /**
-// *
-// * @see org.eclipse.papyrus.uml.nattable.manager.cell.manager.StereotypePropertyCellManager#handles(java.lang.Object, java.lang.Object)
-// *
-// * @param columnElement
-// * @param rowElement
-// * @return
-// */
-// @Override
-// public boolean handles(final Object columnElement, final Object rowElement) {
-// if (super.handles(columnElement, rowElement)) {
-// final List<Object> objects = organizeAndResolvedObjects(columnElement, rowElement, null);
-// if (objects.size() == 2) {
-// final EObject object = (EObject) objects.get(0);
-// if (object instanceof Port) {
-// String propertyQualifiedName = (String) objects.get(1);
-// propertyQualifiedName = propertyQualifiedName.substring(Constants.PROPERTY_OF_STEREOTYPE_PREFIX.length(), propertyQualifiedName.length());
-// return propertyQualifiedName.equals(org.eclipse.papyrus.sysml14.nattable.common.utils.Constants.STEREOTYPE_FLOWPORT_DIRECTION);
-// }
-// }
-// }
-// return false;
-// }
-//
-//
-// /**
-// *
-// * @see org.eclipse.papyrus.uml.nattable.manager.cell.manager.StereotypePropertyCellManager#isCellEditable(java.lang.Object, java.lang.Object)
-// *
-// * @param columnElement
-// * @param rowElement
-// * @return
-// */
-// @Override
-// public boolean isCellEditable(final Object columnElement, final Object rowElement) {
-// boolean value = super.isCellEditable(columnElement, rowElement);
-// if (value) {
-// final List<Object> objects = organizeAndResolvedObjects(columnElement, rowElement, null);
-// if (objects.size() == 2) {
-// final EObject object = (EObject) objects.get(0);
-// if (matcher.matches(object)) {
-// value = false;
-// }
-// }
-// }
-// return value;
-// }
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.nattable.manager.cell.manager.StereotypePropertyCellManager#handles(java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public boolean handles(final Object columnElement, final Object rowElement, final INattableModelManager tableManager) {
+ boolean isHandled = super.handles(columnElement, rowElement, tableManager);
+ if (isHandled) {
+ Entry<EObject, String> cellDefinition = getCellDefinition(columnElement, rowElement);
+ if (cellDefinition.getKey() instanceof Port) {
+ final String propertyQualifiedNameString = cellDefinition.getValue().substring(Constants.PROPERTY_OF_STEREOTYPE_PREFIX.length(), cellDefinition.getValue().length());
+ // We have to use the full name for Constants because of the previous one
+ isHandled = SysMLQualifiedName.STEREOTYPE_FLOWPORT_DIRECTION.equals(propertyQualifiedNameString);
+ }
+ }
+ return isHandled;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.nattable.manager.cell.manager.StereotypePropertyCellManager#isCellEditable(java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public boolean isCellEditable(final Object columnElement, final Object rowElement, final INattableModelManager tableManager) {
+ boolean isEditable = super.isCellEditable(columnElement, rowElement, tableManager);
+ if (isEditable) {
+ Entry<EObject, String> cellDefinition = getCellDefinition(columnElement, rowElement);
+ if (cellDefinition != null) {
+ isEditable = !matcher.matches(cellDefinition.getKey());
+ }
+ }
+ return isEditable;
+ }
+
+ /**
+ * @param columnElement
+ * @param rowElement
+ * @return Entry<EObject,propertyQualifiedName>
+ */
+ //FIXME this method should be provided by the core API
+ private Entry<EObject, String> getCellDefinition(final Object columnElement, final Object rowElement) {
+ final List<Object> objects = organizeAndResolvedObjects(columnElement, rowElement, null);
+ // The list must have 2 elements (row and column elements)
+ if (objects != null && 2 == objects.size()) {
+ if (objects.get(0) instanceof EObject && objects.get(1) instanceof String) {
+ return new AbstractMap.SimpleEntry<EObject, String>((EObject) objects.get(0), (String) objects.get(1));
+ }
+ }
+ return null;
+ }
+
}
diff --git a/table/org.eclipse.papyrus.sysml14.nattable.common/src/org/eclipse/papyrus/sysml14/nattable/common/provider/SysMLFlowPortDirectionLabelProvider.java b/table/org.eclipse.papyrus.sysml14.nattable.common/src/org/eclipse/papyrus/sysml14/nattable/common/provider/SysMLFlowPortDirectionLabelProvider.java
index f754e8e..62f665f 100644
--- a/table/org.eclipse.papyrus.sysml14.nattable.common/src/org/eclipse/papyrus/sysml14/nattable/common/provider/SysMLFlowPortDirectionLabelProvider.java
+++ b/table/org.eclipse.papyrus.sysml14.nattable.common/src/org/eclipse/papyrus/sysml14/nattable/common/provider/SysMLFlowPortDirectionLabelProvider.java
@@ -9,6 +9,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 516997
*
*****************************************************************************/
package org.eclipse.papyrus.sysml14.nattable.common.provider;
@@ -19,6 +20,7 @@
import org.eclipse.papyrus.infra.nattable.utils.Constants;
import org.eclipse.papyrus.infra.nattable.utils.LabelProviderCellContextElementWrapper;
import org.eclipse.papyrus.sysml14.service.types.matcher.FlowPortNAMatcher;
+import org.eclipse.papyrus.sysml14.util.SysMLQualifiedName;
import org.eclipse.papyrus.uml.nattable.provider.AbstractUMLNattableCellLabelProvider;
import org.eclipse.uml2.uml.Port;
@@ -36,15 +38,13 @@
private static final FlowPortNAMatcher matcher = new FlowPortNAMatcher();
/**
- *
+ * {@inheritDoc}
+ *
* @see org.eclipse.papyrus.infra.nattable.provider.GenericCellLabelProvider#accept(java.lang.Object)
- *
- * @param element
- * @return
*/
@Override
public boolean accept(final Object element) {
- if (element instanceof LabelProviderCellContextElementWrapper) {
+ if (element instanceof LabelProviderCellContextElementWrapper) {
final ILayerCell cell = ((LabelProviderCellContextElementWrapper) element);
final IConfigRegistry registry = ((LabelProviderCellContextElementWrapper) element).getConfigRegistry();
final Object columnObject = getColumnObject(cell, registry);
@@ -54,18 +54,23 @@
str = AxisUtils.getPropertyId(rowObject);
}
if (str != null) {
- return str.endsWith(org.eclipse.papyrus.sysml14.nattable.common.utils.Constants.STEREOTYPE_FLOWPORT_DIRECTION);
+ return str.endsWith(SysMLQualifiedName.STEREOTYPE_FLOWPORT_DIRECTION);
}
}
return false;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.nattable.provider.GenericCellLabelProvider#getText(java.lang.Object)
+ */
@Override
public String getText(Object element) {
final ILayerCell cell = (LabelProviderCellContextElementWrapper) element;
final IConfigRegistry configRegistry = ((LabelProviderCellContextElementWrapper) element).getConfigRegistry();
- final Object rowObject = getRowObject(cell, configRegistry);
- final Object columObject = getColumnObject(cell, configRegistry);
+ final Object rowObject = AxisUtils.getRepresentedElement(getRowObject(cell, configRegistry));
+ final Object columObject = AxisUtils.getRepresentedElement(getColumnObject(cell, configRegistry));
Port port = null;
if (rowObject instanceof Port) {
port = (Port) rowObject;