Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java2
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.welcome/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/.settings/.api_filters11
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/META-INF/MANIFEST.MF4
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/pom.xml2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/.settings/.api_filters11
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/META-INF/MANIFEST.MF4
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/pom.xml2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model/.settings/.api_filters45
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model/pom.xml2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/plugin.xml46
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/advice/DeleteNatTableContextAdvice.java26
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/FilterRowCustomConfiguration.java24
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java5
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java25
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TreeTablePopupMenuConfiguration.java29
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/converter/GenericDisplayConverter.java1
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java96
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/PasteInTableHandler.java10
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ResolvedProblemHandler.java2
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectColumnsHandler.java1
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SelectRowsHandler.java1
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortColumnsHandler.java1
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/SortRowsHandler.java1
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowShowAllCategoriesCommandHandler.java63
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowShowAllCategoriesHandler.java2
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/UnsetCellValueHandler.java22
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java81
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java24
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/TreeNattableModelManager.java41
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/AbstractPapyrusPopupMenuAction.java158
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/MenuConstants.java15
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/PapyrusBodyPopupMenuAction.java73
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/PapyrusHeaderPopupMenuAction.java88
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/ShowHideCategoriesContributionItem.java20
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/TreePapyrusBodyPopupMenuAction.java56
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/TreeRowPapyrusHeaderPopupMenuAction.java (renamed from plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/TreePapyrusHeaderPopupMenuAction.java)36
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CollapseExpandActionHelper.java3
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/META-INF/MANIFEST.MF2
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/pom.xml2
-rw-r--r--plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/src/org/eclipse/papyrus/uml/nattable/stereotype/display/manager/axis/NotationTreeTableAxisManager.java19
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/NattablePropertyEditor.java658
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeDisplayNattablePropertyEditor.java34
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/TreeNattablePropertyEditor.java98
48 files changed, 1296 insertions, 560 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java
index 13601f8708c..2c7a88fc161 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java
@@ -1034,7 +1034,7 @@ public class ServicesRegistry {
* @throws ServiceMultiException
*
* @throws ServiceException
- * If a service can't be started.
+ * If a service can't be disposed.
*/
private void disposeServices(Collection<ServiceStartupEntry> services, ServiceMultiException errors) {
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.welcome/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.welcome/META-INF/MANIFEST.MF
index eaf7258e82c..9d86b081795 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.welcome/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.welcome/META-INF/MANIFEST.MF
@@ -7,7 +7,7 @@ Require-Bundle: org.eclipse.papyrus.infra.editor.welcome;bundle-version="[1.2.0,
org.eclipse.papyrus.infra.services.navigation;bundle-version="[2.0.0,3.0.0)",
org.eclipse.jface.databinding;bundle-version="[1.8.0,2.0.0)",
org.eclipse.papyrus.infra.editor.welcome.nattable;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.papyrus.infra.nattable.model;bundle-version="[1.2.0,2.0.0)"
+ org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0,3.0.0)"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.2.0.qualifier
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF
index 0219f98b0a0..7d13976b58b 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/META-INF/MANIFEST.MF
@@ -9,7 +9,7 @@ Export-Package: org.eclipse.papyrus.infra.nattable.common,
org.eclipse.papyrus.infra.nattable.common.wizards,
org.eclipse.papyrus.infra.nattable.internal.common.commands;x-friends:="org.eclipse.papyrus.infra.nattable.gmfdiag"
Require-Bundle: org.eclipse.papyrus.infra.nattable;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.nattable.model;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/.settings/.api_filters b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/.settings/.api_filters
deleted file mode 100644
index be20b5eaff4..00000000000
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/.settings/.api_filters
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<component id="org.eclipse.papyrus.infra.nattable.model.edit" version="2">
- <resource path="META-INF/MANIFEST.MF">
- <filter comment="Dependencies had implicit upper bounds in Mars" id="927989779">
- <message_arguments>
- <message_argument value="1.2.0"/>
- <message_argument value="org.eclipse.emf.ecore.edit"/>
- </message_arguments>
- </filter>
- </resource>
-</component>
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/META-INF/MANIFEST.MF
index 084ac72666e..5d9ae837ce9 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)",
org.eclipse.emf.ecore.edit;bundle-version="[2.9.0,3.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.nattable.model;bundle-version="[1.2.0,2.0.0)";visibility:=reexport
+ org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0,3.0.0)";visibility:=reexport
Export-Package: org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.provider,
org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.provider,
org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.provider,
@@ -15,7 +15,7 @@ Export-Package: org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.p
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 2.0.0.qualifier
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-Activator: org.eclipse.papyrus.infra.nattable.model.nattable.provider.NattableEditPlugin$Implementation
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/pom.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/pom.xml
index f2198148dd3..82731898486 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/pom.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.edit/pom.xml
@@ -7,6 +7,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.infra.nattable.model.edit</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/.settings/.api_filters b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/.settings/.api_filters
deleted file mode 100644
index b400bc4be4d..00000000000
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/.settings/.api_filters
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<component id="org.eclipse.papyrus.infra.nattable.model.editor" version="2">
- <resource path="META-INF/MANIFEST.MF">
- <filter comment="Dependencies had implicit upper bounds in Mars" id="927989779">
- <message_arguments>
- <message_argument value="1.2.0"/>
- <message_argument value="org.eclipse.core.resources"/>
- </message_arguments>
- </filter>
- </resource>
-</component>
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/META-INF/MANIFEST.MF
index d8cecaa6e24..ffcfa1d1b99 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.11.0,4.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.nattable.model.edit;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.nattable.model.edit;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.emf.ecore.xmi;bundle-version="[2.12.0,3.0.0)";visibility:=reexport,
org.eclipse.emf.edit.ui;bundle-version="[2.12.0,3.0.0)";visibility:=reexport,
org.eclipse.ui.ide;bundle-version="[3.12.0,4.0.0)";visibility:=reexport,
@@ -20,7 +20,7 @@ Export-Package: org.eclipse.papyrus.infra.nattable.model.editor.customeditors,
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 2.0.0.qualifier
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-Activator: org.eclipse.papyrus.infra.nattable.model.nattable.presentation.NattableEditorPlugin$Implementation
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/pom.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/pom.xml
index bee3b610d9f..8e4d482e406 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/pom.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/pom.xml
@@ -7,6 +7,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.infra.nattable.model.editor</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model/.settings/.api_filters b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model/.settings/.api_filters
deleted file mode 100644
index a16d858b286..00000000000
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model/.settings/.api_filters
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<component id="org.eclipse.papyrus.infra.nattable.model" version="2">
- <resource path="src-gen/org/eclipse/papyrus/infra/nattable/model/nattable/nattableaxisconfiguration/NattableaxisconfigurationPackage.java" type="org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage">
- <filter comment="The feature count constants are notAPI" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage"/>
- <message_argument value="PASTE_EOBJECT_CONFIGURATION_FEATURE_COUNT"/>
- <message_argument value="6"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src-gen/org/eclipse/papyrus/infra/nattable/model/nattable/nattableaxisconfiguration/util/NattableaxisconfigurationValidator.java" type="org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.util.NattableaxisconfigurationValidator">
- <filter comment="The particular validation constraints are not API" id="338755678">
- <message_arguments>
- <message_argument value="org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.util.NattableaxisconfigurationValidator"/>
- <message_argument value="ABSTRACT_HEADER_AXIS_CONFIGURATION__ONE_FEATURE_LABEL_CONFIGURATION_TYPES__EEXPRESSION"/>
- </message_arguments>
- </filter>
- <filter comment="The particular validation constraints are not API" id="338755678">
- <message_arguments>
- <message_argument value="org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.util.NattableaxisconfigurationValidator"/>
- <message_argument value="ABSTRACT_HEADER_AXIS_CONFIGURATION__ONE_OBJECT_LABEL_CONFIGURATION_TYPES__EEXPRESSION"/>
- </message_arguments>
- </filter>
- <filter comment="The particular validation constraints are not API" id="338792546">
- <message_arguments>
- <message_argument value="org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.util.NattableaxisconfigurationValidator"/>
- <message_argument value="validateAbstractHeaderAxisConfiguration_oneFeatureLabelConfigurationTypes(AbstractHeaderAxisConfiguration, DiagnosticChain, Map&lt;Object,Object&gt;)"/>
- </message_arguments>
- </filter>
- <filter comment="The particular validation constraints are not API" id="338792546">
- <message_arguments>
- <message_argument value="org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.util.NattableaxisconfigurationValidator"/>
- <message_argument value="validateAbstractHeaderAxisConfiguration_oneObjectLabelConfigurationTypes(AbstractHeaderAxisConfiguration, DiagnosticChain, Map&lt;Object,Object&gt;)"/>
- </message_arguments>
- </filter>
- <filter comment="OCL constraint expressions are not API" id="388194388">
- <message_arguments>
- <message_argument value="org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.util.NattableaxisconfigurationValidator"/>
- <message_argument value="TABLE_HEADER_AXIS_CONFIGURATION__AXIS_MANAGERS_ID_UNIQUE__EEXPRESSION"/>
- <message_argument value="axisManagers-&gt;forAll(am1 : AxisManagerRepresentation, am2 : AxisManagerRepresentation | am1.axisManagerId &lt;&gt; am2.axisManagerId)"/>
- </message_arguments>
- </filter>
- </resource>
-</component>
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model/META-INF/MANIFEST.MF
index f154e000f4f..546feb04e7c 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model/META-INF/MANIFEST.MF
@@ -36,7 +36,7 @@ Export-Package: org.eclipse.papyrus.infra.nattable.model,
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 2.0.0.qualifier
Bundle-Localization: plugin
Bundle-Name: %pluginName
Bundle-Activator: org.eclipse.papyrus.infra.nattable.model.Activator
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model/pom.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model/pom.xml
index 8dd4e4fc37c..aac4e2c71c3 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model/pom.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model/pom.xml
@@ -7,6 +7,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.infra.nattable.model</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF
index 5c78a287fc2..8c6e273480e 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.modelexplorer/META-INF/MANIFEST.MF
@@ -8,7 +8,7 @@ Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Bundle-Name: %Bundle-Name
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Require-Bundle: org.eclipse.papyrus.infra.nattable.model;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
+Require-Bundle: org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.emf.facet.query.java.core;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
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 f35b9b726ec..adaf51605c4 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
@@ -48,7 +48,7 @@ Export-Package: org.eclipse.papyrus.infra.nattable,
Require-Bundle: org.eclipse.gmf.runtime.emf.type.core;bundle-version="[1.9.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)",
org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.papyrus.infra.nattable.model;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.nattable.model;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.services.labelprovider;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
org.eclipse.nebula.widgets.nattable.core;bundle-version="[1.4.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.services.edit;bundle-version="[2.0.0,3.0.0)",
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/plugin.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/plugin.xml
index 1c972229727..39fa7384f28 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/plugin.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/plugin.xml
@@ -93,15 +93,8 @@
locationURI="popup:org.eclipse.papyrus.infra.nattable.widget.menu?after=tree.separator">
<menu
label="Hierarchic Style">
- <visibleWhen>
- <with
- variable="selection">
- <test
- forcePluginActivation="false"
- property="org.eclipse.papyrus.infra.nattable.tester.isHierarchicTable"
- value="true">
- </test>
- </with>
+ <visibleWhen
+ checkEnabled="true">
</visibleWhen>
<command
commandId="org.eclipse.papyrus.infra.nattable.table.hierarchic.style"
@@ -126,14 +119,6 @@
commandId="org.eclipse.papyrus.infra.nattable.row.categories.command"
style="push">
<visibleWhen>
- <with
- variable="selection">
- <test
- forcePluginActivation="true"
- property="org.eclipse.papyrus.infra.nattable.tester.isHierarchicTable"
- value="true">
- </test>
- </with>
</visibleWhen>
</command>
</menuContribution>
@@ -195,7 +180,7 @@
value="true">
</parameter>
<visibleWhen
- checkEnabled="false">
+ checkEnabled="true">
</visibleWhen>
</command>
<command
@@ -214,14 +199,23 @@
<command
commandId="org.eclipse.papyrus.infra.nattable.column.display.index"
style="toggle">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
</command>
<command
commandId="org.eclipse.papyrus.infra.nattable.column.display.label"
style="toggle">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
</command>
<command
commandId="org.eclipse.papyrus.infra.nattable.column.display.filter"
style="toggle">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
</command>
<menu
icon="icons/columnIndex.png"
@@ -399,6 +393,9 @@
name="org.eclipse.ui.commands.radioStateParameter"
value="ALPHABETIC">
</parameter>
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
</command>
<command
commandId="org.eclipse.papyrus.infra.nattable.row.index.style"
@@ -408,6 +405,9 @@
name="org.eclipse.ui.commands.radioStateParameter"
value="NUMERIC">
</parameter>
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
</command>
</menu>
<menu
@@ -578,7 +578,7 @@
</visibleWhen>
</command>
<command
- commandId="org.eclipse.papyrus.infra.nattable.row.collapse.all.tree.command"
+ commandId="org.eclipse.papyrus.infra.nattable.row.collapse.all.on.selection.command"
style="push">
<visibleWhen
checkEnabled="true">
@@ -605,10 +605,10 @@
checkEnabled="true">
</visibleWhen>
</command>
- <separator
- name="category.separator"
- visible="true">
- </separator>
+ </menuContribution>
+ <menuContribution
+ allPopups="true"
+ locationURI="popup:org.eclipse.papyrus.infra.nattable.widget.header.rows.menu?after=category.separator">
<command
commandId="org.eclipse.papyrus.infra.nattable.row.categories.command"
style="push">
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/advice/DeleteNatTableContextAdvice.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/advice/DeleteNatTableContextAdvice.java
index ca0e7d30548..2ee302e19fb 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/advice/DeleteNatTableContextAdvice.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/advice/DeleteNatTableContextAdvice.java
@@ -52,19 +52,21 @@ public class DeleteNatTableContextAdvice extends AbstractEditHelperAdvice {
}
final ECrossReferenceAdapter crossReferencerAdapter = ECrossReferenceAdapter.getCrossReferenceAdapter(objectToDestroy);
- final Collection<Setting> settings = crossReferencerAdapter.getNonNavigableInverseReferences(objectToDestroy);
- CompositeCommand cmd = new CompositeCommand(Messages.DeleteNatTableContextAdvice_DestroyNattableCommand);
- for (Setting currentSetting : settings) {
- final EObject currentEObject = currentSetting.getEObject();
- final EStructuralFeature currentfeature = currentSetting.getEStructuralFeature();
- if (currentEObject instanceof Table && currentfeature == NattablePackage.eINSTANCE.getTable_Context()) {
- final DestroyElementRequest request2 = new DestroyElementRequest(currentEObject, false);
- final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(currentEObject);
- cmd.add(provider.getEditCommand(request2));
+ if (crossReferencerAdapter != null) {
+ final Collection<Setting> settings = crossReferencerAdapter.getNonNavigableInverseReferences(objectToDestroy);
+ CompositeCommand cmd = new CompositeCommand(Messages.DeleteNatTableContextAdvice_DestroyNattableCommand);
+ for (Setting currentSetting : settings) {
+ final EObject currentEObject = currentSetting.getEObject();
+ final EStructuralFeature currentfeature = currentSetting.getEStructuralFeature();
+ if (currentEObject instanceof Table && currentfeature == NattablePackage.eINSTANCE.getTable_Context()) {
+ final DestroyElementRequest request2 = new DestroyElementRequest(currentEObject, false);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(currentEObject);
+ cmd.add(provider.getEditCommand(request2));
+ }
+ }
+ if (!cmd.isEmpty()) {
+ return cmd;
}
- }
- if (!cmd.isEmpty()) {
- return cmd;
}
return null;
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/FilterRowCustomConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/FilterRowCustomConfiguration.java
index b15a8bbaaca..6a34a98f623 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/FilterRowCustomConfiguration.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/FilterRowCustomConfiguration.java
@@ -13,21 +13,10 @@
package org.eclipse.papyrus.infra.nattable.configuration;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.transaction.NotificationFilter;
-import org.eclipse.emf.transaction.ResourceSetChangeEvent;
-import org.eclipse.emf.transaction.ResourceSetListener;
-import org.eclipse.emf.transaction.RollbackException;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.filterrow.FilterIconPainter;
-import org.eclipse.nebula.widgets.nattable.filterrow.FilterRowDataLayer;
import org.eclipse.nebula.widgets.nattable.filterrow.FilterRowPainter;
import org.eclipse.nebula.widgets.nattable.filterrow.config.FilterRowConfigAttributes;
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
@@ -35,20 +24,7 @@ import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.nebula.widgets.nattable.style.Style;
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
-import org.eclipse.papyrus.infra.nattable.command.UpdateFilterMapCommand;
import org.eclipse.papyrus.infra.nattable.converter.GenericDisplayConverter;
-import org.eclipse.papyrus.infra.nattable.filter.configuration.FilterConfigurationRegistry;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
-import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
-import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
-import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.widgets.Display;
-
-import ca.odell.glazedlists.EventList;
-import ca.odell.glazedlists.event.ListEvent;
-import ca.odell.glazedlists.event.ListEventListener;
/**
* This class configure the filters for the table
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java
index 767234a2cd6..4bad7639b03 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/PapyrusPopupMenuAction.java
@@ -105,10 +105,6 @@ public class PapyrusPopupMenuAction extends PopupMenuAction {
private void buildMenu(final Menu popupMenu, final NatTable natTable) {
final Collection<Command> commands = EclipseCommandUtils.getAllExistingCommandsInCategory(category);
- // TODO : we should use the EclipseContext to transfert the eventData from here to the handler, but currently we can't have dependency on e4 plugins
- // final IEclipseContext eclipseContext = (IEclipseContext)PlatformUI.getWorkbench().getService(IEclipseContext.class);
- // eclipseContext.set(AbstractTableHandler.NAT_EVENT_DATA_PARAMETER_ID, eventData);
-
for (final Command command : commands) {
final IHandler handler = command.getHandler();
if (handler == null || !(handler instanceof AbstractHandler)) {
@@ -180,7 +176,6 @@ public class PapyrusPopupMenuAction extends PopupMenuAction {
* @param command
* @param natTable
*/
- // TODO we should refactor code to create a new class PapyrusTreePopupMenu
private void addShowHideCategoryCommandToMenu(final Menu menu, final Command command, final NatTable natTable) {
Table table = getTable(natTable);
int maxDepth = FillingConfigurationUtils.getMaxDepthForTree(table);
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java
index 32a52956901..606a1e7b62e 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TablePopupMenuConfiguration.java
@@ -13,21 +13,38 @@
package org.eclipse.papyrus.infra.nattable.configuration;
+import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
import org.eclipse.papyrus.infra.nattable.menu.MenuConstants;
+import org.eclipse.papyrus.infra.nattable.menu.PapyrusBodyPopupMenuAction;
import org.eclipse.papyrus.infra.nattable.menu.PapyrusHeaderPopupMenuAction;
import org.eclipse.swt.SWT;
/**
* @author VL222926
- * This configuration allows to register popup menu for row header, column header and body of the table
+ * This configuration allows to register popup menu for row header, column header and body of the table
+ * @since 2.0
*/
public class TablePopupMenuConfiguration extends AbstractUiBindingConfiguration {
/**
+ * the configured nattable widget
+ */
+ protected final NatTable natTable;
+
+ /**
+ * Constructor.
+ *
+ */
+ public TablePopupMenuConfiguration(final NatTable natTable) {
+ this.natTable = natTable;
+ }
+
+
+ /**
* @see org.eclipse.nebula.widgets.nattable.config.IConfiguration#configureUiBindings(org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry)
*
* @param uiBindingRegistry
@@ -46,7 +63,7 @@ public class TablePopupMenuConfiguration extends AbstractUiBindingConfiguration
*
*/
protected void registerBodyPopupMenu(final UiBindingRegistry uiBindingRegistry) {
- // nothing to do
+ uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.BODY, MouseEventMatcher.RIGHT_BUTTON), new PapyrusBodyPopupMenuAction(MenuConstants.BODY_POPUP_MENU_ID, this.natTable));
}
/**
@@ -56,7 +73,7 @@ public class TablePopupMenuConfiguration extends AbstractUiBindingConfiguration
*
*/
protected void registerRowHeaderPopupMenu(final UiBindingRegistry uiBindingRegistry) {
- uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, MouseEventMatcher.RIGHT_BUTTON), new PapyrusHeaderPopupMenuAction(MenuConstants.ROW_HEADER_POPUP_MENU_ID));
+ uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, MouseEventMatcher.RIGHT_BUTTON), new PapyrusHeaderPopupMenuAction(MenuConstants.ROW_HEADER_POPUP_MENU_ID, this.natTable));
}
/**
@@ -66,6 +83,6 @@ public class TablePopupMenuConfiguration extends AbstractUiBindingConfiguration
*
*/
protected void registerColumnHeaderPopupMenu(final UiBindingRegistry uiBindingRegistry) {
- uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, MouseEventMatcher.RIGHT_BUTTON), new PapyrusHeaderPopupMenuAction(MenuConstants.COLUMN_HEADER_POPUP_MENU_ID));
+ uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, MouseEventMatcher.RIGHT_BUTTON), new PapyrusHeaderPopupMenuAction(MenuConstants.COLUMN_HEADER_POPUP_MENU_ID, this.natTable));
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TreeTablePopupMenuConfiguration.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TreeTablePopupMenuConfiguration.java
index 56ff1334c64..2116c74ce55 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TreeTablePopupMenuConfiguration.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/configuration/TreeTablePopupMenuConfiguration.java
@@ -13,26 +13,49 @@
package org.eclipse.papyrus.infra.nattable.configuration;
+import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
import org.eclipse.papyrus.infra.nattable.menu.MenuConstants;
-import org.eclipse.papyrus.infra.nattable.menu.TreePapyrusHeaderPopupMenuAction;
+import org.eclipse.papyrus.infra.nattable.menu.TreePapyrusBodyPopupMenuAction;
+import org.eclipse.papyrus.infra.nattable.menu.TreeRowPapyrusHeaderPopupMenuAction;
import org.eclipse.swt.SWT;
/**
* @author VL222926
- * The configuration to use to popup menu in Tree Table
+ * The configuration to use to popup menu in Tree Table
*/
public class TreeTablePopupMenuConfiguration extends TablePopupMenuConfiguration {
/**
+ * Constructor.
+ *
+ * @param natTable
+ * @param site
+ * @param provider
+ */
+ public TreeTablePopupMenuConfiguration(final NatTable natTable) {
+ super(natTable);
+ }
+
+ /**
* @see org.eclipse.papyrus.infra.nattable.configuration.TablePopupMenuConfiguration#registerRowHeaderPopupMenu(org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry)
*
* @param uiBindingRegistry
*/
@Override
protected void registerRowHeaderPopupMenu(UiBindingRegistry uiBindingRegistry) {
- uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, MouseEventMatcher.RIGHT_BUTTON), new TreePapyrusHeaderPopupMenuAction(MenuConstants.ROW_HEADER_POPUP_MENU_ID));
+ uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.ROW_HEADER, MouseEventMatcher.RIGHT_BUTTON), new TreeRowPapyrusHeaderPopupMenuAction(MenuConstants.ROW_HEADER_POPUP_MENU_ID, this.natTable));
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.configuration.TablePopupMenuConfiguration#registerBodyPopupMenu(org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry)
+ *
+ * @param uiBindingRegistry
+ */
+ @Override
+ protected void registerBodyPopupMenu(UiBindingRegistry uiBindingRegistry) {
+ uiBindingRegistry.registerMouseDownBinding(new MouseEventMatcher(SWT.NONE, GridRegion.BODY, MouseEventMatcher.RIGHT_BUTTON), new TreePapyrusBodyPopupMenuAction(MenuConstants.BODY_POPUP_MENU_ID, this.natTable));
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/converter/GenericDisplayConverter.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/converter/GenericDisplayConverter.java
index 753a86f90b6..469f2ca8d3c 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/converter/GenericDisplayConverter.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/converter/GenericDisplayConverter.java
@@ -20,7 +20,6 @@ import org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter;
import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.papyrus.infra.nattable.utils.Constants;
-import org.eclipse.papyrus.infra.nattable.utils.ILabelProviderContextElementWrapper;
import org.eclipse.papyrus.infra.nattable.utils.LabelProviderCellContextElementWrapper;
import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
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 ee0254d451e..fb3158f0a9d 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
@@ -19,29 +19,22 @@ import java.util.Collections;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
+import org.eclipse.nebula.widgets.nattable.ui.menu.MenuItemProviders;
import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
-import org.eclipse.papyrus.infra.nattable.provider.TableStructuredSelection;
+import org.eclipse.papyrus.infra.nattable.utils.NattableConfigAttributes;
import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils;
import org.eclipse.papyrus.infra.nattable.utils.TableSelectionWrapper;
import org.eclipse.papyrus.infra.ui.util.WorkbenchPartHelper;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
/**
* The abstract handler to use for the table actions
@@ -51,7 +44,12 @@ import org.eclipse.ui.handlers.HandlerUtil;
*/
public abstract class AbstractTableHandler extends AbstractHandler {
- /** the id used to find the NatEvent in the EclipseContext */
+ /**
+ * the id used to find the NatEvent in the EclipseContext
+ *
+ * @deprecated since Papyrus 1.2 (Eclipse Neon)
+ */
+ @Deprecated
public static final String NAT_EVENT_DATA_PARAMETER_ID = "natEventParameterId"; //$NON-NLS-1$
/**
@@ -67,7 +65,9 @@ public abstract class AbstractTableHandler extends AbstractHandler {
/**
*
* @return
- * the current active part
+ * the current active part
+ *
+ * @deprecated since Papyrus 1.2 (Eclipse Neon)
*/
protected IWorkbenchPart getActivePart() {
return WorkbenchPartHelper.getCurrentActiveWorkbenchPart();
@@ -75,21 +75,14 @@ public abstract class AbstractTableHandler extends AbstractHandler {
/**
*
- * @param evaluationContextOrExecutionEvent
- *
+ * @return
+ * the TableSelectioWrapper used (according to the referenced NatEventData) or <code>null</code> if not found
+ * @since 2.0
*/
- protected final TableSelectionWrapper getTableSelectionWrapper(Object evaluationContextOrExecutionEvent) {
- if (evaluationContextOrExecutionEvent instanceof IEvaluationContext) {
- Object selection = HandlerUtil.getVariable(evaluationContextOrExecutionEvent, "selection"); //$NON-NLS-1$
- if (selection instanceof IAdaptable) {
- return (TableSelectionWrapper) ((IAdaptable) selection).getAdapter(TableSelectionWrapper.class);
- }
- } else if (evaluationContextOrExecutionEvent instanceof ExecutionEvent) {
- IWorkbenchPart p = HandlerUtil.getActivePart((ExecutionEvent) evaluationContextOrExecutionEvent);
- ISelection selection = (ISelection) p.getAdapter(ISelection.class);
- if (selection instanceof TableStructuredSelection) {
- return (TableSelectionWrapper) ((TableStructuredSelection) selection).getAdapter(TableSelectionWrapper.class);
- }
+ protected final TableSelectionWrapper getTableSelectionWrapper() {
+ final INattableModelManager tableManager = getCurrentNattableModelManager();
+ if (tableManager != null) {
+ return tableManager.getAdapter(TableSelectionWrapper.class);
}
return null;
}
@@ -100,10 +93,12 @@ public abstract class AbstractTableHandler extends AbstractHandler {
* the current table manager or <code>null</code> if not found
*/
protected INattableModelManager getCurrentNattableModelManager() {
- final IWorkbenchPart currentPart = getActivePart();
- if (currentPart != null) {
- final INattableModelManager manager = (INattableModelManager) currentPart.getAdapter(INattableModelManager.class);
- return manager;
+ final NatEventData data = getNatEventData();
+ if (data != null) {
+ final NatTable natTable = data.getNatTable();
+ if (natTable != null && natTable.getConfigRegistry() != null) {
+ return natTable.getConfigRegistry().getConfigAttribute(NattableConfigAttributes.NATTABLE_MODEL_MANAGER_CONFIG_ATTRIBUTE, DisplayMode.NORMAL, NattableConfigAttributes.NATTABLE_MODEL_MANAGER_ID);
+ }
}
return null;
}
@@ -127,6 +122,11 @@ public abstract class AbstractTableHandler extends AbstractHandler {
return TableEditingDomainUtils.getTableContextEditingDomain(getCurrentNattableModelManager().getTable());
}
+ /**
+ *
+ * @return
+ * the last NatEventData received during the setEnable
+ */
protected NatEventData getNatEventData() {
if (this.eventDataWeakReference != null) {
return this.eventDataWeakReference.get();
@@ -139,7 +139,7 @@ public abstract class AbstractTableHandler extends AbstractHandler {
* @param evaluationContext
* the evaluation context
* @return
- * the NatEventData from this evaluation context
+ * the NatEventData from this evaluation context or <code>null</code> if not found
*/
protected NatEventData getNatEventData(final Object evaluationContext) {
if (evaluationContext instanceof NatEventData) {
@@ -147,30 +147,30 @@ public abstract class AbstractTableHandler extends AbstractHandler {
}
NatEventData eventData = null;
if (evaluationContext instanceof IEvaluationContext) {
- Object value = ((IEvaluationContext) evaluationContext).getVariable(NAT_EVENT_DATA_PARAMETER_ID);
+ Object value = ((IEvaluationContext) evaluationContext).getVariable(MenuItemProviders.NAT_EVENT_DATA_KEY);
if (value instanceof NatEventData) {
eventData = (NatEventData) value;
}
}
- // TODO : currently we can't have dependency on org.eclipse.e4....
+
+ // Commented since Papyrus 1.2 (Neon Mars 2016)
// that's why we can't add the variable NAT_EVENT_DATA_PARAMETER_ID and we need to create a NatEventData instead of to get it in evaluationContext
- if (eventData == null) {
- Point cursorLocation = Display.getDefault().getCursorLocation();
- Control control = Display.getDefault().getCursorControl();// TODO doesn't work when we are selecting a command in a menu!
- if (control instanceof NatTable) {// TODO : not nice, but required
- cursorLocation = control.toControl(cursorLocation);
- Event e = new Event();
- e.x = cursorLocation.x;
- e.y = cursorLocation.y;
- e.display = Display.getDefault();
- e.widget = control;
- MouseEvent event = new MouseEvent(e);
- eventData = NatEventData.createInstanceFromEvent(event);
- }
- }
+ // if (eventData == null) {
+ // Point cursorLocation = Display.getDefault().getCursorLocation();
+ // Control control = Display.getDefault().getCursorControl();// doesn't work when we are selecting a command in a sub menu!
+ // if (control instanceof NatTable) {// : not nice, but required
+ // cursorLocation = control.toControl(cursorLocation);
+ // Event e = new Event();
+ // e.x = cursorLocation.x;
+ // e.y = cursorLocation.y;
+ // e.display = Display.getDefault();
+ // e.widget = control;
+ // MouseEvent event = new MouseEvent(e);
+ // eventData = NatEventData.createInstanceFromEvent(event);
+ // }
+ // }
return eventData;
}
-
/**
*
* @param evaluationContext
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/PasteInTableHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/PasteInTableHandler.java
index afff4539851..86e3bddaca8 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/PasteInTableHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/PasteInTableHandler.java
@@ -91,14 +91,4 @@ public class PasteInTableHandler extends AbstractPasteInsertInTableHandler {
return result;
}
- /**
- * @Override
- *
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
- */
- @Override
- public void setEnabled(final Object evaluationContext) {
- setBaseEnabled(getCurrentNattableModelManager() != null);
- }
-
}
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 c7d039473f1..b50926f1c18 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
@@ -127,7 +127,7 @@ public class ResolvedProblemHandler extends AbstractTableHandler {
* @return
*/
private Problem getProblemToDestroy(Object evaluationContextOrExecutionEvent) {
- TableSelectionWrapper wrapper = getTableSelectionWrapper(evaluationContextOrExecutionEvent);
+ TableSelectionWrapper wrapper = getTableSelectionWrapper();
if (isEnabled() && wrapper != null) {
Collection<PositionCoordinate> selectionCells = wrapper.getSelectedCells();
if (selectionCells.size() == 1) {
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 a330bbea3b0..f60084b62f9 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
@@ -49,6 +49,7 @@ public class SelectColumnsHandler extends AbstractTableHandler {
*/
@Override
public void setEnabled(Object evaluationContext) {
+ super.setEnabled(evaluationContext);
final INattableModelManager currentNattableModelManager = getCurrentNattableModelManager();
boolean enabled = false;
if (currentNattableModelManager != null) {
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 c0a58568df4..de63d6866ad 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
@@ -49,6 +49,7 @@ public class SelectRowsHandler extends AbstractTableHandler {
*/
@Override
public void setEnabled(Object evaluationContext) {
+ super.setEnabled(evaluationContext);
final INattableModelManager currentNattableModelManager = getCurrentNattableModelManager();
boolean enabled = false;
if (currentNattableModelManager != null) {
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 60a5e4c3374..33f567921ed 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
@@ -52,6 +52,7 @@ public class SortColumnsHandler extends AbstractTableHandler {
*/
@Override
public void setEnabled(Object evaluationContext) {
+ super.setEnabled(evaluationContext);
INattableModelManager manager = getCurrentNattableModelManager();
boolean enabled = false;
if (manager != null) {
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 b7ce382bc8c..836618768cd 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
@@ -51,6 +51,7 @@ public class SortRowsHandler extends AbstractTableHandler {
*/
@Override
public void setEnabled(Object evaluationContext) {
+ super.setEnabled(evaluationContext);
INattableModelManager manager = getCurrentNattableModelManager();
boolean enabled = false;
if (manager != null) {
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowShowAllCategoriesCommandHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowShowAllCategoriesCommandHandler.java
deleted file mode 100644
index ef4c66d1ca7..00000000000
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/TreeRowShowAllCategoriesCommandHandler.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2014 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.nattable.handler;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.edit.command.RemoveCommand;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.IntListValueStyle;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NattablestylePackage;
-import org.eclipse.papyrus.infra.nattable.utils.NamedStyleConstants;
-
-
-/**
- *
- * @author VL222926
- *
- */
-public class TreeRowShowAllCategoriesCommandHandler extends AbstractTreeRowHideShowCategoryHandler {
-
- /**
- *
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- *
- * @param event
- * @return
- * @throws ExecutionException
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IntListValueStyle values = (IntListValueStyle) getTable().getNamedStyle(NattablestylePackage.eINSTANCE.getIntListValueStyle(), NamedStyleConstants.HIDDEN_CATEGORY_FOR_DEPTH);
- if (values != null) {
- Command c = RemoveCommand.create(getTableEditingDomain(), values);
- getContextEditingDomain().getCommandStack().execute(c);
- }
- return null;
- }
-
- /**
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
- */
- @Override
- public void setEnabled(Object evaluationContext) {
- super.setEnabled(evaluationContext);
- if (isEnabled()) {
- if (allCategoriesAreCurrentlyVisible()) {
- setBaseEnabled(false);
- }
- }
- }
-}
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 ba67f1a2fbd..fa541245a24 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
@@ -41,7 +41,7 @@ public class TreeRowShowAllCategoriesHandler extends AbstractTreeRowHideShowCate
IntListValueStyle values = (IntListValueStyle) getTable().getNamedStyle(NattablestylePackage.eINSTANCE.getIntListValueStyle(), NamedStyleConstants.HIDDEN_CATEGORY_FOR_DEPTH);
if (values != null) {
Command c = RemoveCommand.create(getTableEditingDomain(), getTable(), NattablestylePackage.eINSTANCE.getStyledElement_Styles(), values);
- getContextEditingDomain().getCommandStack().execute(c);
+ getTableEditingDomain().getCommandStack().execute(c);
}
return null;
}
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 ba7135f426b..2a449e03872 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
@@ -5,7 +5,10 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate;
+import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
+import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
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;
@@ -31,7 +34,7 @@ public class UnsetCellValueHandler extends AbstractTableHandler {
if (!canUnsetCell(event)) {
return null;
}
- TableSelectionWrapper wrapper = getTableSelectionWrapper(event);
+ TableSelectionWrapper wrapper = getTableSelectionWrapper();
CompoundCommand cc = new CompoundCommand("Unset cell values"); //$NON-NLS-1$
for (PositionCoordinate current : wrapper.getSelectedCells()) {
int colPosition = current.getColumnPosition();
@@ -76,10 +79,21 @@ public class UnsetCellValueHandler extends AbstractTableHandler {
* @param evaluationContext
*
* @return
- * <code>true</code> if cells are selected (any selected region must be managed)
+ * <code>true</code> if the mouse is in the Body of the table and if cells are selected
*/
protected boolean canUnsetCell(Object evaluationContext) {
- final TableSelectionWrapper wrapper = getTableSelectionWrapper(evaluationContext);
- return null != wrapper ? !wrapper.getSelectedCells().isEmpty() : false;
+ boolean enabled = false;
+ TableSelectionWrapper wrapper = getTableSelectionWrapper();
+ if (wrapper!=null && !wrapper.getSelectedCells().isEmpty()) {
+ enabled = true;
+ NatEventData data = getNatEventData();
+ if (data != null) { //null with JUnit tests
+ LabelStack labels = data.getRegionLabels();
+ if(labels!=null){ //seem null with JUnit tests
+ enabled = labels.hasLabel(GridRegion.BODY) && labels.getLabels().size() == 1;
+ }
+ }
+ }
+ return enabled;
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
index c3a1f180e49..776de35c33e 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/AbstractNattableWidgetManager.java
@@ -38,8 +38,8 @@ import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
@@ -106,7 +106,6 @@ import org.eclipse.papyrus.infra.nattable.layerstack.ColumnHeaderLayerStack;
import org.eclipse.papyrus.infra.nattable.layerstack.RowHeaderHierarchicalLayerStack;
import org.eclipse.papyrus.infra.nattable.layerstack.RowHeaderLayerStack;
import org.eclipse.papyrus.infra.nattable.listener.NatTableDropListener;
-import org.eclipse.papyrus.infra.nattable.menu.MenuConstants;
import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.EObjectAxis;
@@ -152,7 +151,7 @@ import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.services.IDisposable;
@@ -248,6 +247,8 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
/**
* the composite layer providing the filter row in the column header
+ *
+ * @since 2.0
*/
protected FilterRowHeaderComposite<?> filterColumnHeaderComposite;
@@ -359,8 +360,6 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
this.natTable = new NatTable(parent, this.gridLayer, false);
// we register nattable configuration
- registerPopupMenuConfiguration(this.natTable);
-
addClickSortConfiguration(this.natTable);
this.natTable.addConfiguration(new FilterRowCustomConfiguration());
this.natTable.addConfiguration(new RowSortModelConfiguration(getRowSortModel()));
@@ -388,6 +387,13 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
this.natTable.setConfigRegistry(configRegistry);
this.natTable.setUiBindingRegistry(new UiBindingRegistry(this.natTable));
+ this.selectionProvider = new TableSelectionProvider(this, this.bodyLayerStack.getSelectionLayer());
+
+ if (site != null) {
+ // we are creating an editor
+ site.setSelectionProvider(this.selectionProvider);
+ }
+ registerPopupMenuConfiguration(this.natTable);
this.natTable.configure();
// we create editors and filter configuration, we can not add it to a layer, because the configuration must be updated after add/move axis and invert axis
@@ -411,10 +417,6 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
addRowHeaderResizeListener(getRowHeaderLayerStack());
addDragAndDropSupport(this.natTable);
- this.selectionProvider = new TableSelectionProvider(this, this.bodyLayerStack.getSelectionLayer());
- createAndRegisterMenuManagerAndSelectionProvider(this.natTable, site, this.selectionProvider);
-
-
new PapyrusNatTableToolTipProvider(this.natTable, GridRegion.BODY, GridRegion.COLUMN_HEADER, GridRegion.ROW_HEADER);
initResourceSetListener();
return this.natTable;
@@ -425,9 +427,10 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
*
* @param natTable
* the nattable to configure
+ * @since 2.0
*/
protected void registerPopupMenuConfiguration(final NatTable natTable) {
- natTable.addConfiguration(new TablePopupMenuConfiguration());
+ natTable.addConfiguration(new TablePopupMenuConfiguration(natTable));
}
/**
@@ -657,7 +660,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
* @param natTable
* @return
*
- * @deprecated since Papyrus 1.3 (Eclipse Neon)
+ * @deprecated since Papyrus 1.2 (Eclipse Neon), now the menu configuration is done using {@link TablePopupMenuConfiguration}
*/
@Deprecated
public MenuManager createMenuManager(final NatTable natTable) {
@@ -672,49 +675,12 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
*
* @return
* This method creates the MenuManager used for theBody of the table and register it, with the selection provider in the {@link IWorkbenchPartSite} of the editor when not <code>null</code>
+ * @since 2.0
*/
public MenuManager createAndRegisterMenuManagerAndSelectionProvider(final NatTable natTable, final IWorkbenchPartSite site, ISelectionProvider selectionProvider) {
- final MenuManager menuManager = new MenuManager(MenuConstants.POPUP, MenuConstants.TABLE_POPUP_MENU_ID);
- // menuManager.setRemoveAllWhenShown(true);
-
- final Menu menu = menuManager.createContextMenu(this.natTable);
-
- this.natTable.setMenu(menu);
- if (site != null) {
- site.registerContextMenu(menuManager.getId(), menuManager, selectionProvider);
- site.setSelectionProvider(this.selectionProvider);
- }
-
- // we create the separator here, and not in the plugin.xml file in order to get the wanted order (in plugin.xml it seems depends on the order of plugin activation
- Separator separator = new Separator(MenuConstants.GENERAL_SEPARATOR_ID);
- separator.setVisible(false);// the first one is not visible
- menuManager.add(separator);
-
- separator = new Separator(MenuConstants.EDIT_SEPARATOR_ID);
- separator.setVisible(true);
- menuManager.add(separator);
-
- separator = new Separator(MenuConstants.CELL_SEPARATOR_ID);
- separator.setVisible(true);
- menuManager.add(separator);
-
- separator = new Separator(MenuConstants.ROWS_AND_COLUMNS_SEPARATOR_ID);
- separator.setVisible(true);
- menuManager.add(separator);
-
- separator = new Separator(MenuConstants.CREATIONS_SEPARATOR_ID);
- separator.setVisible(true);
- menuManager.add(separator);
-
- separator = new Separator(MenuConstants.TOOLS_SEPARATOR_ID);
- separator.setVisible(true);
- menuManager.add(separator);
-
- // commented to avoid to pollute the table menu with global contribution
- // separator = new Separator(MenuConstants.ADDITIONS_SEPARATOR_ID);
- // separator.setVisible(true);
- // menuManager.add(separator);
-
+ final MenuManager menuManager = new MenuManager("#PopUp", "org.eclipse.papyrus.infra.nattable.widget.menu") ; //$NON-NLS-1$ //$NON-NLS-2$
+ menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+ menuManager.setRemoveAllWhenShown(true);
return menuManager;
}
@@ -1474,16 +1440,20 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
}
}
-
}
/**
* This allows to manage the fill columns size named style by managing the width of columns to fill all the parent space.
+ *
+ * @since 2.0
*/
protected void doFillColumnsSize() {
+ BooleanValueStyle fillColumnsSize = (BooleanValueStyle) getTable().getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.FILL_COLUMNS_SIZE);
+ if (fillColumnsSize == null) {
+ final TableConfiguration config = getTable().getTableConfiguration();
+ fillColumnsSize = (BooleanValueStyle) config.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.FILL_COLUMNS_SIZE);
+ }
- final TableConfiguration config = getTable().getTableConfiguration();
- final BooleanValueStyle fillColumnsSize = (BooleanValueStyle) config.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.FILL_COLUMNS_SIZE);
if (null != fillColumnsSize) {
if (fillColumnsSize.isBooleanValue()) {
final Composite parent = natTable.getParent();
@@ -1860,6 +1830,7 @@ public abstract class AbstractNattableWidgetManager implements INattableModelMan
*
* @return
* a {@link TableStructuredSelection} representing the current selection of the table or <code>null</code> when there is no selection
+ * @since 2.0
*/
public final TableStructuredSelection getSelectionInTable() {
ISelection selection = this.selectionProvider.getSelection();
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
index 9aa999b82e6..ea7d51ca73c 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/NattableModelManager.java
@@ -879,7 +879,7 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
*/
@Override
public void addRows(final Collection<Object> objectsToAdd) {
- final TransactionalEditingDomain domain = getContextEditingDomain();
+ final TransactionalEditingDomain domain = getTableEditingDomain();
final Command cmd = getAddRowElementCommand(objectsToAdd);
if (cmd != null && cmd.canExecute()) {
domain.getCommandStack().execute(cmd);
@@ -912,7 +912,7 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
*/
@Override
public void addColumns(final Collection<Object> objectsToAdd) {
- final TransactionalEditingDomain domain = getContextEditingDomain();
+ final TransactionalEditingDomain domain = getTableEditingDomain();
final Command cmd = getAddColumnElementCommand(objectsToAdd);
if (cmd != null && cmd.canExecute()) {
domain.getCommandStack().execute(cmd);
@@ -927,7 +927,7 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
*/
@Override
public void removeColumns(final Collection<Object> objetsToRemove) {
- final TransactionalEditingDomain domain = getContextEditingDomain();
+ final TransactionalEditingDomain domain = getTableEditingDomain();
final Command cmd = getDestroyColumnElementCommand(objetsToRemove);
if (cmd != null && cmd.canExecute()) {
domain.getCommandStack().execute(cmd);
@@ -942,7 +942,7 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
*/
@Override
public void removeRows(final Collection<Object> objectsToRemove) {
- final TransactionalEditingDomain domain = getContextEditingDomain();
+ final TransactionalEditingDomain domain = getTableEditingDomain();
final Command cmd = getDestroyRowElementCommand(objectsToRemove);
if (cmd != null && cmd.canExecute()) {
domain.getCommandStack().execute(cmd);
@@ -1140,8 +1140,8 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
public void updateAxisContents(final AbstractAxisProvider axis) {
try {
- if (null != getContextEditingDomain()) {
- getContextEditingDomain().runExclusive(new Runnable() {
+ if (null != getTableEditingDomain()) {
+ getTableEditingDomain().runExclusive(new Runnable() {
@Override
public void run() {
@@ -1318,7 +1318,7 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
@Override
public void invertAxis() {
final CompoundCommand cmd = new CompoundCommand(Messages.NattableModelManager_SwitchLinesAndColumns);
- final TransactionalEditingDomain domain = getContextEditingDomain();
+ final TransactionalEditingDomain domain = getTableEditingDomain();
final boolean oldValue = getTable().isInvertAxis();
if (canInvertAxis()) {
final Command tmp = new SetCommand(domain, getTable(), NattablePackage.eINSTANCE.getTable_InvertAxis(), !oldValue);
@@ -1349,7 +1349,7 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
@Override
public Command getAddRowElementCommand(final Collection<Object> objectsToAdd) {
- final TransactionalEditingDomain domain = getContextEditingDomain();
+ final TransactionalEditingDomain domain = getTableEditingDomain();
final CompoundCommand cmd = new CompoundCommand(Messages.NattableModelManager_AddRowCommand);
Command tmp = this.rowManager.getAddAxisCommand(domain, objectsToAdd);
if (tmp != null) {
@@ -1369,7 +1369,7 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
@Override
public Command getAddColumnElementCommand(final Collection<Object> objectsToAdd) {
- final TransactionalEditingDomain domain = getContextEditingDomain();
+ final TransactionalEditingDomain domain = getTableEditingDomain();
final CompoundCommand cmd = new CompoundCommand(Messages.NattableModelManager_AddColumnCommand);
Command tmp = this.columnManager.getAddAxisCommand(domain, objectsToAdd);
if (tmp != null) {
@@ -1394,7 +1394,7 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
*/
@Override
public Command getAddRowElementCommand(final Collection<Object> objectsToAdd, final int index) {
- final TransactionalEditingDomain domain = getContextEditingDomain();
+ final TransactionalEditingDomain domain = getTableEditingDomain();
final CompoundCommand cmd = new CompoundCommand(Messages.NattableModelManager_AddRowCommand);
Command tmp = this.rowManager.getAddAxisCommand(domain, objectsToAdd, index);
if (tmp != null) {
@@ -1419,7 +1419,7 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
*/
@Override
public Command getAddColumnElementCommand(final Collection<Object> objectsToAdd, final int index) {
- final TransactionalEditingDomain domain = getContextEditingDomain();
+ final TransactionalEditingDomain domain = getTableEditingDomain();
final CompoundCommand cmd = new CompoundCommand(Messages.NattableModelManager_AddColumnCommand);
Command tmp = this.columnManager.getAddAxisCommand(domain, objectsToAdd, index);
if (tmp != null) {
@@ -1596,7 +1596,7 @@ public class NattableModelManager extends AbstractNattableWidgetManager implemen
}
}
if (!compoundCommand.isEmpty()) {
- getContextEditingDomain().getCommandStack().execute(compoundCommand);
+ getTableEditingDomain().getCommandStack().execute(compoundCommand);
updateToggleActionState();
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/TreeNattableModelManager.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/TreeNattableModelManager.java
index 6daf13c0562..5bbb3629c83 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/TreeNattableModelManager.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/table/TreeNattableModelManager.java
@@ -30,9 +30,6 @@ import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer;
import org.eclipse.nebula.widgets.nattable.hideshow.command.MultiColumnHideCommand;
@@ -65,7 +62,6 @@ import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManagerForEventList;
import org.eclipse.papyrus.infra.nattable.manager.axis.ICompositeAxisManager;
import org.eclipse.papyrus.infra.nattable.manager.axis.ITreeItemAxisManagerForEventList;
-import org.eclipse.papyrus.infra.nattable.menu.MenuConstants;
import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
@@ -196,7 +192,7 @@ public class TreeNattableModelManager extends NattableModelManager implements IT
*/
@Override
protected void registerPopupMenuConfiguration(final NatTable natTable) {
- natTable.addConfiguration(new TreeTablePopupMenuConfiguration());
+ natTable.addConfiguration(new TreeTablePopupMenuConfiguration(natTable));
}
/**
@@ -226,24 +222,6 @@ public class TreeNattableModelManager extends NattableModelManager implements IT
return this.treeList;
}
- /**
- * @see org.eclipse.papyrus.infra.nattable.manager.table.AbstractNattableWidgetManager#createAndRegisterMenuManagerAndSelectionProvider(org.eclipse.nebula.widgets.nattable.NatTable, org.eclipse.ui.IWorkbenchPartSite,
- * org.eclipse.jface.viewers.ISelectionProvider)
- *
- * @param natTable
- * @param site
- * @param selectionProvider
- * @return
- */
- @Override
- public MenuManager createAndRegisterMenuManagerAndSelectionProvider(NatTable natTable, IWorkbenchPartSite site, ISelectionProvider selectionProvider) {
- final MenuManager menuManager = super.createAndRegisterMenuManagerAndSelectionProvider(natTable, site, selectionProvider);
- final Separator separator = new Separator(MenuConstants.TREE_SEPARATOR_ID);
- separator.setVisible(true);
- menuManager.insertAfter(MenuConstants.EDIT_SEPARATOR_ID, separator);
- return menuManager;
- }
-
/**
* @see org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager#createNattable(org.eclipse.swt.widgets.Composite, int, org.eclipse.ui.IWorkbenchPartSite)
@@ -332,9 +310,11 @@ public class TreeNattableModelManager extends NattableModelManager implements IT
doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
}
Table table = getTable();
- TableConfiguration config = table.getTableConfiguration();
-
- BooleanValueStyle expandAll = (BooleanValueStyle) config.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.EXPAND_ALL);
+ BooleanValueStyle expandAll = (BooleanValueStyle) table.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.EXPAND_ALL);
+ if (expandAll == null) {
+ TableConfiguration config = table.getTableConfiguration();
+ expandAll = (BooleanValueStyle) config.getNamedStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle(), NamedStyleConstants.EXPAND_ALL);
+ }
if (null != expandAll) {
if (expandAll.isBooleanValue()) {
doCollapseExpandAction(org.eclipse.papyrus.infra.nattable.tree.CollapseAndExpandActionsEnum.EXPAND_ALL, null);
@@ -347,6 +327,7 @@ public class TreeNattableModelManager extends NattableModelManager implements IT
* Get the width of the slider composite.
*
* @return The int value corresponding to the needed row header width.
+ * @since 2.0
*/
protected int getWidthSliderComposite() {
int result = 0;
@@ -365,6 +346,7 @@ public class TreeNattableModelManager extends NattableModelManager implements IT
* This allows to calculate the initial width of the row header.
*
* @return The int value corresponding to the needed row header width.
+ * @since 2.0
*/
protected int calculateBestWidthSliderComposite() {
@@ -471,12 +453,16 @@ public class TreeNattableModelManager extends NattableModelManager implements IT
*
* @param leftSliderComposite
* the slider composite.
+ * @since 2.0
*/
protected void addControlListener(final Composite leftSliderComposite) {
leftSliderComposite.addControlListener(new ControlAdapter() {
@Override
public void controlResized(final ControlEvent e) {
+ if (null == natTable || natTable.isDisposed()) {
+ return;
+ }
super.controlResized(e);
final CompositeCommand resizeRowHeaderCommand = new CompositeCommand("Resize Slider composite"); //$NON-NLS-1$
@@ -723,6 +709,9 @@ public class TreeNattableModelManager extends NattableModelManager implements IT
return new RowHeaderHierarchicalLayerStack(bodyLayerStack, this);
}
+ /**
+ * @since 2.0
+ */
public RowHeaderHierarchicalLayerStack getRowHeaderLayerStack() {
return (RowHeaderHierarchicalLayerStack) super.getRowHeaderLayerStack();
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/AbstractPapyrusPopupMenuAction.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/AbstractPapyrusPopupMenuAction.java
new file mode 100644
index 00000000000..248c725b6d7
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/AbstractPapyrusPopupMenuAction.java
@@ -0,0 +1,158 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.menu;
+
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
+import org.eclipse.nebula.widgets.nattable.ui.action.IMouseAction;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.menus.IMenuService;
+
+/**
+ * @author VL222926
+ * Abstract popup menu used in papyrus table
+ * @since 2.0
+ */
+public class AbstractPapyrusPopupMenuAction implements IMouseAction, IMenuListener {
+
+ /**
+ * the id of the menu to create, plugins can contribute to the menu using this id;
+ */
+ protected final String menuId;
+
+ /**
+ * the location used to fill the menu
+ */
+ protected final String menuLocation;
+
+ /**
+ * the menu manager used for the popup menu
+ */
+ protected final MenuManager menuManager;
+
+ /**
+ * the menu used as popup
+ */
+ protected final Menu menu;
+
+ /**
+ * the table
+ */
+ protected final NatTable natTable;
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param menuId
+ * the id to use to fill the popup menu
+ * @param natTable
+ * the nattable widget on which we declare the menu
+ */
+ public AbstractPapyrusPopupMenuAction(final String menuId, final NatTable natTable) {
+ this.menuId = menuId;
+ this.menuLocation = new StringBuilder(MenuConstants.POPUP).append(MenuConstants.DELIMITER).append(menuId).toString();
+ this.menuManager = new MenuManager(MenuConstants.POPUP, this.menuId);
+ this.natTable = natTable;
+ this.menu = menuManager.createContextMenu(this.natTable);
+ this.menuManager.setRemoveAllWhenShown(true);
+ addMenuListener(this.menuManager);
+ }
+
+ /**
+ *
+ * @param menuManager
+ * the menu manager of which we want add a listener
+ */
+ protected void addMenuListener(IMenuManager menuManager) {
+ menuManager.addMenuListener(this);
+ }
+
+ /**
+ * @see org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction#run(org.eclipse.nebula.widgets.nattable.NatTable, org.eclipse.swt.events.MouseEvent)
+ *
+ * @param natTable
+ * @param event
+ */
+ @Override
+ public void run(final NatTable natTable, final MouseEvent event) {
+ if (event == null) {
+ return;
+ }
+
+ Object data = event.data; // in which case could it be null ?
+ final NatEventData natEventData;
+ if (data instanceof NatEventData) {
+ natEventData = (NatEventData) data;
+ } else {
+ natEventData = null;
+ }
+
+ Assert.isNotNull(natEventData, "The natEventData is null"); //$NON-NLS-1$
+
+ // we register the nat event data to get it during the menu creation (method menuAboutToShow
+ this.menu.setData(MenuConstants.NAT_EVENT_DATA_KEY, natEventData);
+ menu.setVisible(true);
+ return;
+ }
+
+ /**
+ * This method registers the separator for the menu
+ *
+ * @param menuManager
+ * the menu manager
+ */
+ protected void addMenuSeparators(IMenuManager menuManager) {
+ // we create the separator here, and not in the plugin.xml file in order to get the wanted order (in plugin.xml it seems depends on the order of plugin activation
+ final Separator general = new Separator(MenuConstants.GENERAL_SEPARATOR_ID);
+ general.setVisible(false);
+ menuManager.add(general);
+
+ final Separator edit = new Separator(MenuConstants.EDIT_SEPARATOR_ID);
+ edit.setVisible(true);
+ menuManager.add(edit);
+ }
+
+ /**
+ * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
+ *
+ * @param manager
+ */
+ @Override
+ public final void menuAboutToShow(final IMenuManager menuManager) {
+ addMenuSeparators(menuManager);
+ final IMenuService menuService = PlatformUI.getWorkbench().getService(IMenuService.class);
+ final IEvaluationContext state = menuService.getCurrentState();
+
+ final NatEventData natEventData = (NatEventData) this.menuManager.getMenu().getData(MenuConstants.NAT_EVENT_DATA_KEY);
+ // we register the nattable event data here, in order to get i
+ state.addVariable(MenuConstants.NAT_EVENT_DATA_KEY, natEventData);
+ if (menuService != null && menuManager instanceof MenuManager) {
+ menuService.populateContributionManager((MenuManager) menuManager, this.menuLocation);
+ }
+ // we must not remove the value after the menu creation!!!
+ // state.removeVariable(MenuConstants.NAT_EVENT_DATA_KEY);
+
+ }
+
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/MenuConstants.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/MenuConstants.java
index 8df669290de..01e9d48b1c9 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/MenuConstants.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/MenuConstants.java
@@ -13,11 +13,12 @@
package org.eclipse.papyrus.infra.nattable.menu;
+import org.eclipse.nebula.widgets.nattable.ui.menu.MenuItemProviders;
import org.eclipse.ui.IWorkbenchActionConstants;
/**
* @author VL222926
- * This class grousp the constant used for table menu
+ * This class groups the constant used for table menu
*/
public class MenuConstants {
@@ -37,7 +38,7 @@ public class MenuConstants {
/**
* the table body popup menu id
*/
- public static final String TABLE_POPUP_MENU_ID = "org.eclipse.papyrus.infra.nattable.widget.menu"; //$NON-NLS-1$
+ public static final String BODY_POPUP_MENU_ID = "org.eclipse.papyrus.infra.nattable.widget.menu"; //$NON-NLS-1$
/**
* the table row header menu id
@@ -70,6 +71,11 @@ public class MenuConstants {
public static final String TREE_SEPARATOR_ID = "tree.separator"; //$NON-NLS-1$
/**
+ * this separator is used to group contribution for categories of tree table
+ */
+ public static final String CATEGORY_SEPARATOR_ID = "category.separator";//$NON-NLS-1$
+
+ /**
* this separator is used to group contribution for the cells
*/
public static final String CELL_SEPARATOR_ID = "cells.separator"; //$NON-NLS-1$
@@ -93,4 +99,9 @@ public class MenuConstants {
* this separator could be used to group contribution registered on additions, but we do not used it currently to avoid to be polluted by global menu contribution
*/
public static final String ADDITIONS_SEPARATOR_ID = IWorkbenchActionConstants.MB_ADDITIONS;
+
+ /**
+ * the key to get the nattable event data
+ */
+ public static final String NAT_EVENT_DATA_KEY = MenuItemProviders.NAT_EVENT_DATA_KEY;
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/PapyrusBodyPopupMenuAction.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/PapyrusBodyPopupMenuAction.java
new file mode 100644
index 00000000000..22cde00c459
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/PapyrusBodyPopupMenuAction.java
@@ -0,0 +1,73 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.menu;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+
+/**
+ * The Body popup menu for the table
+ *
+ */
+public class PapyrusBodyPopupMenuAction extends AbstractPapyrusPopupMenuAction {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param menuId
+ * the id of the body menu
+ * @param nattable
+ * the nattable for which we are creating the body menu
+ */
+ public PapyrusBodyPopupMenuAction(final String menuId, final NatTable nattable) {
+ super(menuId, nattable);
+ this.natTable.setMenu(menu);
+ }
+
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.menu.AbstractPapyrusPopupMenuAction#addMenuSeparators(org.eclipse.jface.action.MenuManager)
+ *
+ * @param menuManager
+ */
+ @Override
+ protected void addMenuSeparators(IMenuManager menuManager) {
+ super.addMenuSeparators(menuManager);
+
+
+ Separator separator = new Separator(MenuConstants.CELL_SEPARATOR_ID);
+ separator.setVisible(true);
+ menuManager.add(separator);
+
+ separator = new Separator(MenuConstants.ROWS_AND_COLUMNS_SEPARATOR_ID);
+ separator.setVisible(true);
+ menuManager.add(separator);
+
+ separator = new Separator(MenuConstants.CREATIONS_SEPARATOR_ID);
+ separator.setVisible(true);
+ menuManager.add(separator);
+
+ separator = new Separator(MenuConstants.TOOLS_SEPARATOR_ID);
+ separator.setVisible(true);
+ menuManager.add(separator);
+
+ // commented to avoid to pollute the table menu with global contribution
+ // separator = new Separator(MenuConstants.ADDITIONS_SEPARATOR_ID);
+ // separator.setVisible(true);
+ // menuManager.add(separator);
+ }
+
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/PapyrusHeaderPopupMenuAction.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/PapyrusHeaderPopupMenuAction.java
index 0310361d8fb..785799dd283 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/PapyrusHeaderPopupMenuAction.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/PapyrusHeaderPopupMenuAction.java
@@ -13,16 +13,9 @@
package org.eclipse.papyrus.infra.nattable.menu;
-import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.nebula.widgets.nattable.NatTable;
-import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.menus.IMenuService;
/**
* @author VL222926
@@ -30,91 +23,30 @@ import org.eclipse.ui.menus.IMenuService;
* This class allows to fill the popup menu of the table, according to the contribution described in the plugin.xml
*
*/
-public class PapyrusHeaderPopupMenuAction extends PopupMenuAction {
+public class PapyrusHeaderPopupMenuAction extends AbstractPapyrusPopupMenuAction {
- /**
- * the id of the menu to create, plugins can contribute to the menu using this id;
- */
- private final String menuId;
- /**
- * the location used to fill the menu
- */
- private final String menuLocation;
-
- /**
- * The menu manager for the menu creation.
- */
- private MenuManager menuManager = null;
-
- /**
- * The create menu.
- */
- private Menu menu = null;
/**
+ *
* Constructor.
*
- * @param menu
+ * @param menuId
+ * the id of the created menu
+ * @param natTable
+ * the nattable for which this menu is created
*/
- public PapyrusHeaderPopupMenuAction(final String menuId) {
- super(null);
- this.menuId = menuId;
- this.menuLocation = new StringBuilder(MenuConstants.POPUP).append(MenuConstants.DELIMITER).append(menuId).toString();
+ public PapyrusHeaderPopupMenuAction(final String menuId, final NatTable natTable) {
+ super(menuId, natTable);
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction#run(org.eclipse.nebula.widgets.nattable.NatTable, org.eclipse.swt.events.MouseEvent)
- */
- @Override
- public void run(final NatTable natTable, final MouseEvent event) {
- if (null != menu && null != menuManager) {
- menu.dispose();
- menuManager.dispose();
- }
-
- menuManager = new MenuManager(MenuConstants.POPUP, this.menuId);
- menu = menuManager.createContextMenu(natTable);
-
- addMenuSeparators(menuManager);
- /* This listener allows us to fill the popup menu using extension point contributing to the popup menu of the table */
- menuManager.addMenuListener(new IMenuListener() {
-
- /**
- *
- * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
- *
- * @param manager
- */
- @Override
- public void menuAboutToShow(IMenuManager manager) {
- IMenuService menuService = PlatformUI.getWorkbench().getService(IMenuService.class);
- if (menuService != null) {
- menuService.populateContributionManager(menuManager, PapyrusHeaderPopupMenuAction.this.menuLocation);
- }
- }
- });
-
- menu.setVisible(true);
- return;
- }
/**
*
* @param menuManager
* the menu manager
*/
- protected void addMenuSeparators(final MenuManager menuManager) {
- final Separator general = new Separator(MenuConstants.GENERAL_SEPARATOR_ID);
- general.setVisible(false);
- menuManager.add(general);
-
- final Separator edit = new Separator(MenuConstants.EDIT_SEPARATOR_ID);
- edit.setVisible(true);
- menuManager.add(edit);
+ protected void addMenuSeparators(final IMenuManager menuManager) {
+ super.addMenuSeparators(menuManager);
}
-
-
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/ShowHideCategoriesContributionItem.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/ShowHideCategoriesContributionItem.java
index 0e9fc489d3f..970c801dad2 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/ShowHideCategoriesContributionItem.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/ShowHideCategoriesContributionItem.java
@@ -49,6 +49,7 @@ import org.eclipse.ui.commands.ICommandService;
* @author VL222926
*
* This contribution creates a MenuItem for each depth of the tree table, in order to be able to show/hide it easily.
+ * @since 2.0
*/
public class ShowHideCategoriesContributionItem extends ContributionItem {
@@ -84,11 +85,14 @@ public class ShowHideCategoriesContributionItem extends ContributionItem {
final ICommandService serv = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
// 2. find the command associated to the handler
final Command command = serv.getCommand(TreeRowHideShowCategoryHandler.COMMAND_ID);
- // 3. try to find the current nattable
- Control control = Display.getDefault().getCursorControl();
- if (control instanceof NatTable) {
- // 4. contribute to the menu
- addShowHideCategoryCommandToMenu(menu, command, (NatTable) control);
+
+ if (command.isEnabled()) {// required to call setEnable and initialize the field with the table in the handler
+ // 3. try to find the current nattable
+ Control control = Display.getDefault().getCursorControl();
+ if (control instanceof NatTable) {
+ // 4. contribute to the menu
+ addShowHideCategoryCommandToMenu(menu, command, (NatTable) control);
+ }
}
}
@@ -118,7 +122,7 @@ public class ShowHideCategoriesContributionItem extends ContributionItem {
@Override
public void widgetSelected(SelectionEvent arg0) {
- //we must be able to give the SelectionEvent to the handler using EclispeContext
+ // we must be able to give the SelectionEvent to the handler using EclispeContext
Map<Object, Object> parameters = new HashMap<Object, Object>();
parameters.put(TreeRowHideShowCategoryHandler.DEPTH_PARAMETER_KEY, index);
parameters.put(TreeRowHideShowCategoryHandler.HIDE_CATEGORY_PARAMETER_KEY, Boolean.valueOf(!isHidden));
@@ -142,7 +146,7 @@ public class ShowHideCategoriesContributionItem extends ContributionItem {
* @param natTable
* the natTable widget
* @return
- * the table
+ * the table
*/
private Table getTable(final NatTable natTable) {
final IConfigRegistry configRegistry = natTable.getConfigRegistry();
@@ -157,7 +161,7 @@ public class ShowHideCategoriesContributionItem extends ContributionItem {
* @param depth
* a depth
* @return
- * <code>true</code> if the depth is hidden
+ * <code>true</code> if the depth is hidden
*/
private boolean isHidden(Table table, int depth) {
return StyleUtils.getHiddenDepths(table).contains(Integer.valueOf(depth));
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/TreePapyrusBodyPopupMenuAction.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/TreePapyrusBodyPopupMenuAction.java
new file mode 100644
index 00000000000..fc93e59521d
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/TreePapyrusBodyPopupMenuAction.java
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.menu;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+
+/**
+ * The body menu for the tree table
+ *
+ * @since 2.0
+ *
+ */
+public class TreePapyrusBodyPopupMenuAction extends PapyrusBodyPopupMenuAction {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param menuId
+ * the id of the body menu
+ * @param nattable
+ * the nattable for which we are creating the body menu
+ */
+ public TreePapyrusBodyPopupMenuAction(final String menuId, final NatTable nattable) {
+ super(menuId, nattable);
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.menu.PapyrusBodyPopupMenuAction#addMenuSeparators(org.eclipse.jface.action.MenuManager)
+ *
+ * @param menuManager
+ */
+ protected void addMenuSeparators(IMenuManager menuManager) {
+ super.addMenuSeparators(menuManager);
+ final Separator separator = new Separator(MenuConstants.TREE_SEPARATOR_ID);
+ separator.setVisible(true);
+ menuManager.insertAfter(MenuConstants.EDIT_SEPARATOR_ID, separator);
+ };
+
+
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/TreePapyrusHeaderPopupMenuAction.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/TreeRowPapyrusHeaderPopupMenuAction.java
index 94d986f3654..932dde8d513 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/TreePapyrusHeaderPopupMenuAction.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/menu/TreeRowPapyrusHeaderPopupMenuAction.java
@@ -13,38 +13,48 @@
package org.eclipse.papyrus.infra.nattable.menu;
-import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.nebula.widgets.nattable.NatTable;
/**
* @author VL222926
- *
+ * Header Popup Menu action for Tree Table
+ * @since 2.0
*/
-public class TreePapyrusHeaderPopupMenuAction extends PapyrusHeaderPopupMenuAction {
+public class TreeRowPapyrusHeaderPopupMenuAction extends PapyrusHeaderPopupMenuAction {
+
/**
+ *
* Constructor.
*
* @param menuId
+ * the id of the menu to contribute
+ * @param natTable
+ * the nattable for which we are creation a menu
*/
- public TreePapyrusHeaderPopupMenuAction(String menuId) {
- super(menuId);
+ public TreeRowPapyrusHeaderPopupMenuAction(final String menuId, final NatTable natTable) {
+ super(menuId, natTable);
}
-
+
/**
* @see org.eclipse.papyrus.infra.nattable.menu.PapyrusHeaderPopupMenuAction#addMenuSeparators(org.eclipse.jface.action.MenuManager)
*
* @param menuManager
*/
@Override
- protected void addMenuSeparators(final MenuManager menuManager) {
- //1. we add the common separators
+ protected void addMenuSeparators(final IMenuManager menuManager) {
+ // 1. we add the common separators
super.addMenuSeparators(menuManager);
- //2. we add a new separator for tree actions
- final Separator tree = new Separator(MenuConstants.TREE_SEPARATOR_ID);
- tree.setVisible(true);
- menuManager.add(tree);
-
+ // 2. we add separators for tree actions
+ Separator separator = new Separator(MenuConstants.TREE_SEPARATOR_ID);
+ separator.setVisible(true);
+ menuManager.add(separator);
+
+ separator = new Separator(MenuConstants.CATEGORY_SEPARATOR_ID);
+ separator.setVisible(true);
+ menuManager.add(separator);
}
}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CollapseExpandActionHelper.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CollapseExpandActionHelper.java
index b6975920da3..fc09a521a1a 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CollapseExpandActionHelper.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CollapseExpandActionHelper.java
@@ -19,8 +19,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import javax.swing.plaf.TableUI;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.nebula.widgets.nattable.NatTable;
@@ -33,7 +31,6 @@ import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.ITreeItemA
import org.eclipse.papyrus.infra.nattable.provider.TableStructuredSelection;
import org.eclipse.papyrus.infra.nattable.tree.CollapseAndExpandActionsEnum;
import org.eclipse.papyrus.infra.ui.util.SelectionHelper;
-import org.eclipse.swt.widgets.Control;
/**
* This class is not in API.
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/META-INF/MANIFEST.MF b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/META-INF/MANIFEST.MF
index e38ce3cf25d..00d503a2b55 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/META-INF/MANIFEST.MF
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/META-INF/MANIFEST.MF
@@ -6,7 +6,7 @@ Export-Package: org.eclipse.papyrus.uml.nattable.clazz.config,
org.eclipse.papyrus.uml.nattable.clazz.config.manager.axis
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 2.0.0.qualifier
Bundle-Localization: plugin
Bundle-Name: %Bundle-Name
Bundle-Activator: org.eclipse.papyrus.uml.nattable.clazz.config.Activator
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/pom.xml b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/pom.xml
index d29df297815..9ec082bd1ea 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/pom.xml
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.clazz.config/pom.xml
@@ -7,6 +7,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.uml.nattable.clazz.config</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/src/org/eclipse/papyrus/uml/nattable/stereotype/display/manager/axis/NotationTreeTableAxisManager.java b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/src/org/eclipse/papyrus/uml/nattable/stereotype/display/manager/axis/NotationTreeTableAxisManager.java
index 5312ff102ec..68a48d1bbee 100644
--- a/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/src/org/eclipse/papyrus/uml/nattable/stereotype/display/manager/axis/NotationTreeTableAxisManager.java
+++ b/plugins/uml/nattable/org.eclipse.papyrus.uml.nattable.stereotype.display/src/org/eclipse/papyrus/uml/nattable/stereotype/display/manager/axis/NotationTreeTableAxisManager.java
@@ -18,8 +18,8 @@ import org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer;
import org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand;
import org.eclipse.nebula.widgets.nattable.layer.ILayer;
import org.eclipse.nebula.widgets.nattable.tree.TreeLayer;
+import org.eclipse.papyrus.infra.emf.gmf.util.GMFUnsafe;
import org.eclipse.papyrus.infra.emf.nattable.manager.axis.EObjectTreeAxisManagerForEventList;
-import org.eclipse.papyrus.infra.gmfdiag.common.utils.GMFUnsafe;
import org.eclipse.papyrus.infra.nattable.layer.PapyrusGridLayer;
import org.eclipse.papyrus.infra.nattable.layerstack.RowHeaderHierarchicalLayerStack;
import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManagerForEventList;
@@ -113,13 +113,14 @@ public class NotationTreeTableAxisManager extends EObjectTreeAxisManagerForEvent
}
final Command cmd = getAddAxisCommand(getTableEditingDomain(), selectionList);
-
- try {
- GMFUnsafe.write(getTableEditingDomain(), cmd);
- } catch (InterruptedException e) {
- Activator.log.error(e);
- } catch (RollbackException e) {
- Activator.log.error(e);
+ if (cmd != null) {
+ try {
+ GMFUnsafe.write(getTableEditingDomain(), cmd);
+ } catch (InterruptedException e) {
+ Activator.log.error(e);
+ } catch (RollbackException e) {
+ Activator.log.error(e);
+ }
}
// because event will be propagated and children will be set!
return;
@@ -324,7 +325,7 @@ public class NotationTreeTableAxisManager extends EObjectTreeAxisManagerForEvent
return;
}
final TreeLayer treeLayer = getTreeLayer();
- if(null != treeLayer){
+ if (null != treeLayer) {
for (int cpt = selectionList.size() - 1; cpt >= 0; cpt--) {
// Expand the tree item
treeLayer.expandTreeRow(cpt);
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/NattablePropertyEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/NattablePropertyEditor.java
index 45cf7dd85a1..354a03849d3 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/NattablePropertyEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/NattablePropertyEditor.java
@@ -12,28 +12,52 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.properties.widgets;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.EditPart;
import org.eclipse.gef.editparts.AbstractEditPart;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.papyrus.infra.core.resource.EditingDomainServiceFactory;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.services.ServiceDescriptor;
+import org.eclipse.papyrus.infra.core.services.ServiceDescriptor.ServiceTypeKind;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServiceMultiException;
+import org.eclipse.papyrus.infra.core.services.ServiceStartKind;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.emf.nattable.selection.EObjectSelectionExtractor;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
import org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager;
import org.eclipse.papyrus.infra.nattable.model.nattable.NattableFactory;
+import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
@@ -42,11 +66,11 @@ import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfigurati
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TableHeaderAxisConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.NattableaxisproviderFactory;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.NattableaxisproviderPackage;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.TableConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.BooleanValueStyle;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NattablestylePackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.NattablestyleFactory;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.Style;
-import org.eclipse.papyrus.infra.nattable.tree.CollapseAndExpandActionsEnum;
import org.eclipse.papyrus.infra.nattable.tree.ITreeItemAxisHelper;
import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
import org.eclipse.papyrus.infra.nattable.utils.NamedStyleConstants;
@@ -63,15 +87,13 @@ import org.eclipse.papyrus.infra.properties.ui.widgets.AbstractPropertyEditor;
import org.eclipse.papyrus.uml.properties.Activator;
import org.eclipse.papyrus.uml.properties.modelelement.UMLNotationModelElement;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
import org.eclipse.uml2.uml.Element;
/**
@@ -80,6 +102,28 @@ import org.eclipse.uml2.uml.Element;
public class NattablePropertyEditor extends AbstractPropertyEditor {
/**
+ * the save option to uses
+ */
+ private static final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
+
+ static {
+ saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
+ saveOptions.put(Resource.OPTION_LINE_DELIMITER, Resource.OPTION_LINE_DELIMITER_UNSPECIFIED);
+ saveOptions.put(XMLResource.OPTION_SAVE_TYPE_INFORMATION, true);
+ }
+ /**
+ * the folders in which we wil save the table configured by the user.
+ */
+ private static final String TABLES_PREFERENCES_FOLDER_NAME = "tables";//$NON-NLS-1$
+
+ /**
+ * The file in which the table will be saved
+ *
+ * It doesn't work using .notation as extension file. In this case, the commands are not executed, because it is read-only, but why ?
+ */
+ private static final String FILE_EXTENSION = "table";//$NON-NLS-1$
+
+ /**
* The composite.
*/
protected Group self = null;;
@@ -110,6 +154,31 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
private IDataSourceListener dataSourceListener;
/**
+ * The service registry used to manipulate the table
+ */
+ private ServicesRegistry serviceRegistry = null;
+
+ /**
+ * the resource where the table will be saved
+ */
+ private Resource resource = null;
+
+ /**
+ * the edited Papyrus table
+ */
+ private Table table = null;
+
+ /**
+ * the table configuration
+ */
+ private TableConfiguration tableConfiguration = null;
+
+ /**
+ * if <code>true</code> we register table configuration by eClass and not only by table type
+ */
+ private boolean registerTableConfigurationByEClass = false;
+
+ /**
* Constructor.
*
* @param parent
@@ -126,12 +195,22 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
}
/**
+ *
+ * @param newValue
+ * if <code>true</code> we register the table configuration by type AND by the ECLass of the selected element
+ */
+ public final void setRegisterTableConfigurationByEClass(final boolean newValue) {
+ this.registerTableConfigurationByEClass = newValue;
+ }
+
+ /**
* Set the table URI.
*
* @param uri
* The URI of the table (as String).
+ * @since 2.0
*/
- public void setTableURI(final String uri) {
+ public void setTableConfigurationURI(final String uri) {
tableConfigURI = URI.createURI(uri);
checkInput();
}
@@ -140,11 +219,38 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
* Get the table configuration URI.
*
* @return The table configuration URI.
+ * @since 2.0
+ *
*/
- public String getTableURI() {
+ public String getTableConfigurationURI() {
return tableConfigURI == null ? null : tableConfigURI.toString();
}
+ /**
+ * Set the table URI.
+ *
+ * @param uri
+ * The URI of the table (as String).
+ *
+ * @deprecated since 2.0, use setTableConfigurationURI instead
+ */
+ @Deprecated
+ public void setTableURI(final String uri) {
+ setTableConfigurationURI(uri);
+ }
+
+ /**
+ * Get the table configuration URI.
+ *
+ * @return The table configuration URI.
+ * @deprecated since 2.0, use getTableConfigurationUri instead
+ */
+ public String getTableURI() {
+ return getTableConfigurationURI();
+ }
+
+
+
/**
* {@inheritDoc}
@@ -211,7 +317,7 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
}
/**
- * This allow to create the table widget.
+ * This allow to create the table widget or to reuse a table previously used in the property view
*
* @param sourceElement
* The source Element.
@@ -219,47 +325,190 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
* The parent structural feature.
* @param rows
* The rows of the table.
+ *
+ * @since 2.0
*/
protected void createTableWidget(final EObject sourceElement, final EStructuralFeature feature, final Collection<?> rows) {
+ // 1. we initialize a service registry
+ if (this.serviceRegistry == null) {
+ try {
+ this.serviceRegistry = createServiceRegistry(sourceElement);
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+
+ if (this.serviceRegistry == null) {
+ displayError("Cannot initialize the service registry"); //$NON-NLS-1$
+ return;
+ }
- // Create the table
- final Table table = createTable(sourceElement, feature, rows);
- if (table == null) {
+ // 2. get the editing domain
+ TransactionalEditingDomain domain = getTableEditingDomain();
+ if (domain == null) {
+ displayError("Cannot found the editing domain"); //$NON-NLS-1$
+ return;
+ }
+
+ // 3. Create the table or get an existing one
+ this.table = getOrCreateTable(sourceElement, feature, rows);
+
+ if (this.table == null) {
displayError("Cannot initialize the table"); //$NON-NLS-1$
return;
}
-
- manageTableNamedStyle(table);
-
- // Create the widget
- nattableManager = NattableModelManagerFactory.INSTANCE.createNatTableModelManager(table, new EObjectSelectionExtractor());
- natTableWidget = nattableManager.createNattable(self, SWT.NONE, null);
- if (nattableManager instanceof TreeNattableModelManager) {
- configureTreeTable((TreeNattableModelManager) nattableManager, sourceElement, feature, rows);
- ((TreeNattableModelManager) nattableManager).doCollapseExpandAction(CollapseAndExpandActionsEnum.EXPAND_ALL, null);
+ // 4. we configure the table
+ final CompoundCommand cc = new CompoundCommand("Configure table command");//$NON-NLS-1$
+
+ // 4.1 we register it into a resource if required
+ if (this.table.eResource() == null) {
+ cc.append(addTableToResource(domain, this.resource, this.table));
}
-
- self.addDisposeListener(getDisposeListener());
- natTableWidget.setBackground(self.getBackground());
+ // 4.2 we configure the table
+ configureTable(domain, this.table, sourceElement, feature, rows, cc);
+
+ if (!cc.canExecute()) {
+ displayError("The table can't be initialized");//$NON-NLS-1$
+ return;
+ }
+ domain.getCommandStack().execute(cc);
+ if (this.table.getContext() == null) {
+ displayError("The context of the table hasn't be set");//$NON-NLS-1$
+ return;
+ }
+ // 5. Create the widget
+ this.nattableManager = NattableModelManagerFactory.INSTANCE.createNatTableModelManager(this.table, new EObjectSelectionExtractor());
+ this.natTableWidget = createNatTableWidget(this.nattableManager, self, SWT.NONE, rows);
+
+ self.addDisposeListener(getDisposeListener());
// Configure the layout and the layout data
configureLayout();
-
- ((NattableModelManager)nattableManager).refreshNatTable();
+
+ ((NattableModelManager) nattableManager).refreshNatTable();
+ }
+
+ /**
+ *
+ * @param parent
+ * the composite parent
+ * @param style
+ * the style to use to create the nattable widget
+ * @param rows
+ * the initial rows
+ * @return
+ * the created nattable widget
+ * @since 2.0
+ */
+ protected NatTable createNatTableWidget(final INattableModelManager manager, final Composite parent, final int style, Collection<?> rows) {
+ NatTable natTable = manager.createNattable(self, style, null);
+ natTable.setBackground(self.getBackground());
+ return natTable;
+ }
+
+ /**
+ *
+ * @param sourceElement
+ * the source element used to initiatiaze the table
+ * @return
+ * the service registry to use for the table displayed in property view
+ * @throws Exception
+ *
+ * Duplicated code from org.eclipse.papyrus.junit.utils.rules.ModelSetFixture
+ * @since 2.0
+ */
+ protected ServicesRegistry createServiceRegistry(EObject sourceElement) throws Exception {
+ ServicesRegistry result = new ServicesRegistry();
+
+ result.add(ModelSet.class, 10, new ModelSet());
+
+ ServiceDescriptor desc = new ServiceDescriptor(TransactionalEditingDomain.class, EditingDomainServiceFactory.class.getName(), ServiceStartKind.STARTUP, 10);// , Collections.singletonList(ResourceSet.class.getName()));
+ desc.setServiceTypeKind(ServiceTypeKind.serviceFactory);
+ desc.setClassBundleID(Activator.PLUGIN_ID);
+ result.add(desc);
+
+ result.startRegistry();
+ return result;
+ }
+
+ /**
+ *
+ * @param domain
+ * the editing domain to use
+ * @param table
+ * the edited table
+ * @param sourceElement
+ * the source element (id the context of the table
+ * @param synchronizedFeature
+ * the feature on which the table is synchronized
+ * @param rows
+ * the initial rows for the table
+ * @param command
+ * the compound command used to do additional stuff
+ *
+ * @since 2.0
+ */
+ protected void configureTable(final TransactionalEditingDomain domain, final Table table, final EObject sourceElement, final EStructuralFeature synchronizedFeature, Collection<?> rows, CompoundCommand command) {
+ Assert.isNotNull(domain);
+ // 1. we register the context of the table
+ Command setContextCommand = SetCommand.create(domain, table, NattablePackage.eINSTANCE.getTable_Context(), sourceElement);
+ command.append(setContextCommand);
}
/**
+ * This method initialize the context of the table, the feature to listen and the intial rows list element
+ *
+ * @since 2.0
+ *
+ * @deprecated since 2.0, use {@link #configureTable(TransactionalEditingDomain, Table, EObject, EStructuralFeature, Collection, Command)} instead
+ */
+ @Deprecated
+ protected void configureTable(Table table, EObject sourceElement, EStructuralFeature synchronizedFeature, Collection<?> rows) {
+ final TransactionalEditingDomain domain = getTableEditingDomain();
+ if (null != domain) {
+ Command setContextCommand = SetCommand.create(domain, table, NattablePackage.eINSTANCE.getTable_Context(), sourceElement);
+ getTableEditingDomain().getCommandStack().execute(setContextCommand);
+ Assert.isNotNull(table.getContext());
+
+ if (TableHelper.isTreeTable(table) && null != rows && !rows.isEmpty()) {// add test on TreeTable to fix bug 476623
+ final AbstractAxisProvider axisProvider = table.getCurrentRowAxisProvider();
+ TableHeaderAxisConfiguration conf = (TableHeaderAxisConfiguration) HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisInTableConfiguration(table);
+ AxisManagerRepresentation rep = conf.getAxisManagers().get(0);
+ for (Object context : rows) {
+ addTreeItemAxis(axisProvider, rep, context);
+ }
+ }
+ }
+ }
+
+
+ /**
* This allows to add some named style to the table.
*
- * @param table The current table.
+ * @param table
+ * The current table.
+ * @since 2.0
+ *
+ * @deprecated since 2.0 done directly in the creation of the table
*/
- protected void manageTableNamedStyle(final Table table){
- final Style fillColumnsSizeStyle = table.getTableConfiguration().createStyle(NattablestylePackage.eINSTANCE.getBooleanValueStyle());
- ((BooleanValueStyle)fillColumnsSizeStyle).setName(NamedStyleConstants.FILL_COLUMNS_SIZE);
- ((BooleanValueStyle)fillColumnsSizeStyle).setBooleanValue(true);
+ @Deprecated
+ protected void manageTableNamedStyle(final Table table) {
+ final org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.BooleanValueStyle style = NattablestyleFactory.eINSTANCE.createBooleanValueStyle();
+ style.setName(NamedStyleConstants.FILL_COLUMNS_SIZE);
+ style.setBooleanValue(true);
+ final TransactionalEditingDomain domain = getTableEditingDomain();
+ RecordingCommand rc = new RecordingCommand(domain) {
+
+ @Override
+ protected void doExecute() {
+ table.getStyles().add(style);
+
+ }
+ };
+ domain.getCommandStack().execute(rc);
}
-
+
/**
* This allows to configure the tree table.
*
@@ -271,15 +520,17 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
* The feature.
* @param rows
* The rows of the table.
+ * @deprecated since 2.0, moved into {@link TreeNattablePropertyEditor}
*/
+ @Deprecated
protected void configureTreeTable(final TreeNattableModelManager nattableManager, final EObject sourceElement, final EStructuralFeature feature, final Collection<?> rows) {
- // Do nohting
+ // Do nothing
}
-
+
/**
* This allows to configure the layout and the layout data.
*/
- protected void configureLayout(){
+ protected void configureLayout() {
// Adapt the group to the table preferred size
final GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
@@ -325,15 +576,128 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
* This allow to display the error.
*
* @param message
- * The error mesage to display.
+ * The error message to display.
*/
protected void displayError(final String message) {
- final Label label = new Label(self, SWT.NONE);
+ final CLabel label = new CLabel(self, SWT.NONE);
label.setText(message);
label.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("icons/error.gif")); //$NON-NLS-1$
}
/**
+ *
+ * @param sourceElement
+ * the source Element
+ * @param synchronizedFeature
+ * the synchronized feature
+ * @param rows
+ * @return
+ * the existing table of the new created one
+ * @since 2.0
+ */
+ protected Table getOrCreateTable(final EObject sourceElement, final EStructuralFeature synchronizedFeature, final Collection<?> rows) {
+ Table returnedTable = null;
+ final TableConfiguration tableConfiguration = getTableConfiguration();
+ if (tableConfiguration == null) {
+ return null;
+ }
+
+ if (this.serviceRegistry != null) {
+ URI tableURI = createTableURI(sourceElement, tableConfiguration);
+ final ResourceSet resourceSet = getResourceSet();
+ ((ModelSet) resourceSet).createModels(tableURI);
+ boolean exists = resourceSet.getURIConverter().exists(tableURI, Collections.emptyMap());
+ if (exists) {
+ this.resource = resourceSet.getResource(tableURI, true);
+ } else {
+ this.resource = resourceSet.createResource(tableURI);
+ }
+
+ Iterator<EObject> iter = this.resource.getContents().iterator();
+ while (iter.hasNext() && returnedTable == null) {// the resource should contains only 1 table and this one will get the good type
+ EObject object = iter.next();
+ if (object instanceof Table) {
+ TableConfiguration configuration = ((Table) object).getTableConfiguration();
+ if (configuration != null && configuration.getType().equals(getTableConfiguration().getType())) {
+ returnedTable = (Table) object;
+ }
+ }
+ }
+
+ if (null == returnedTable) {
+ returnedTable = createTable(sourceElement, synchronizedFeature);
+ }
+
+ }
+
+ return returnedTable;
+ }
+
+ /**
+ *
+ * @return
+ * the resource set to use to load/store emf files
+ * @since 2.0
+ */
+ protected ResourceSet getResourceSet() {
+ ResourceSet set = null;
+ if (this.serviceRegistry != null) {
+ try {
+ set = this.serviceRegistry.getService(ModelSet.class);
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ }
+ }
+ return set;
+ }
+
+ /**
+ *
+ * @param sourceElement
+ * the source Element
+ * @param tableConfiguration
+ * the tableConfiguration
+ * @return
+ * the URI to use to save and load the table
+ * @since 2.0
+ */
+ protected URI createTableURI(final EObject sourceElement, final TableConfiguration tableConfiguration) {
+ IPath preferencePath = Activator.getDefault().getStateLocation();
+ // we create a folder to save the tables used by the property view and we start to create the name of the model owning the table
+ preferencePath = preferencePath.append(TABLES_PREFERENCES_FOLDER_NAME).append(tableConfiguration.getType());
+
+ // we continue to build the path, adding the good suffix to the name of the model
+ final StringBuilder b = new StringBuilder().append(preferencePath.toPortableString());
+ if (this.registerTableConfigurationByEClass) {
+ final ModelElement modelElement = input.getModelElement(propertyPath);
+ EClass eClass = null;
+ if (modelElement instanceof CompositeModelElement) {
+ CompositeModelElement compoModelElement = (CompositeModelElement) modelElement;
+ Iterator<ModelElement> iter = compoModelElement.getSubElements().iterator();
+ while (eClass == null && iter.hasNext()) {
+ ModelElement tmp = iter.next();
+ if (tmp instanceof UMLNotationModelElement) {
+ EditPart part = ((UMLNotationModelElement) tmp).getEditPart();
+ eClass = EMFHelper.getEObject(part).eClass();
+ } else if (tmp instanceof EMFModelElement) {
+ eClass = ((EMFModelElement) tmp).getSource().eClass();
+ }
+ }
+ }
+
+ if (modelElement instanceof UMLNotationModelElement) {
+ EditPart part = ((UMLNotationModelElement) modelElement).getEditPart();
+ eClass = EMFHelper.getEObject(part).eClass();
+ }
+ b.append("_"); //$NON-NLS-1$
+ b.append(eClass.getName());
+ }
+ URI newURI = URI.createFileURI(b.toString()).appendFileExtension(FILE_EXTENSION);
+ return newURI;
+ }
+
+
+ /**
* This allow to create the nattable.
*
* @param sourceElement
@@ -342,20 +706,18 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
* The synchronized feature.
* @param rows
* The rows of the table.
- * @return The created nattable.
+ * @return The created table.
+ *
+ * @since 2.0
*/
- protected Table createTable(final EObject sourceElement, final EStructuralFeature synchronizedFeature, final Collection<?> rows) {
-
+ protected Table createTable(final EObject sourceElement, final EStructuralFeature synchronizedFeature) {
final TableConfiguration tableConfiguration = getTableConfiguration();
if (tableConfiguration == null) {
return null;
}
-
- final Property property = getModelProperty();
final Table table = NattableFactory.eINSTANCE.createTable();
-
table.setTableConfiguration(tableConfiguration);
-
+ final Property property = getModelProperty();
if (property != null) {
String description = property.getDescription();
if (description != null) {
@@ -387,29 +749,94 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
}
}
}
-
+ table.getColumnAxisProvidersHistory().add(columnProvider);
table.setCurrentColumnAxisProvider(columnProvider);
+ table.getRowAxisProvidersHistory().add(rowProvider);
table.setCurrentRowAxisProvider(rowProvider);
-
- table.setContext(sourceElement);
-
for (final Style style : tableConfiguration.getStyles()) {
table.getStyles().add(EcoreUtil.copy(style));
}
- // Manage the construction of axis here because the table editing domain is null
- if (TableHelper.isTreeTable(table) && null != rows && !rows.isEmpty()) {// add test on TreeTable to fix bug 476623
- final AbstractAxisProvider axisProvider = table.getCurrentRowAxisProvider();
- TableHeaderAxisConfiguration conf = (TableHeaderAxisConfiguration) HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisInTableConfiguration(table);
- AxisManagerRepresentation rep = conf.getAxisManagers().get(0);
- for (Object context : rows) {
- addTreeItemAxis(axisProvider, rep, context);
+ // for the table displayed in property view, we want to use all the available place, so we add a specific named style each time
+ final BooleanValueStyle fillStyle = NattablestyleFactory.eINSTANCE.createBooleanValueStyle();
+ fillStyle.setName(NamedStyleConstants.FILL_COLUMNS_SIZE);
+ fillStyle.setBooleanValue(true);
+ table.getStyles().add(fillStyle);
+
+ // for the table displayed in property view, we expand all directly
+ final BooleanValueStyle expandStyle = NattablestyleFactory.eINSTANCE.createBooleanValueStyle();
+ expandStyle.setName(NamedStyleConstants.EXPAND_ALL);
+ expandStyle.setBooleanValue(true);
+ table.getStyles().add(expandStyle);
+
+ return table;
+ }
+
+ /**
+ * This allow to create the nattable.
+ *
+ * @param sourceElement
+ * The context element.
+ * @param synchronizedFeature
+ * The synchronized feature.
+ * @param rows
+ * The rows of the table.
+ * @return The created table.
+ *
+ * @deprecated since 2.0, use the same method without the collections of rows as arguments. Rows are set later in the new implementation
+ */
+ @Deprecated
+ protected Table createTable(final EObject sourceElement, final EStructuralFeature synchronizedFeature, final Collection<?> rows) {
+ final TableConfiguration tableConfiguration = getTableConfiguration();
+ if (tableConfiguration == null) {
+ return null;
+ }
+ final Table table = NattableFactory.eINSTANCE.createTable();
+ table.setTableConfiguration(tableConfiguration);
+ final Property property = getModelProperty();
+ if (property != null) {
+ String description = property.getDescription();
+ if (description != null) {
+ table.setDescription(description);
}
}
+ table.setName(getLabel());
+
+ AbstractAxisProvider rowProvider = tableConfiguration.getDefaultRowAxisProvider();
+ if (rowProvider == null) {
+ rowProvider = NattableaxisproviderFactory.eINSTANCE.createMasterObjectAxisProvider();
+ } else {
+ rowProvider = EcoreUtil.copy(rowProvider);
+ }
+
+ AbstractAxisProvider columnProvider = tableConfiguration.getDefaultColumnAxisProvider();
+ if (columnProvider == null) {
+ columnProvider = NattableaxisproviderFactory.eINSTANCE.createSlaveObjectAxisProvider();
+ } else {
+ columnProvider = EcoreUtil.copy(columnProvider);
+ }
+
+ if (null != synchronizedFeature) {
+ TableHeaderAxisConfiguration rowHeaderAxisconfig = tableConfiguration.getRowHeaderAxisConfiguration();
+ for (IAxisConfiguration axisConfig : rowHeaderAxisconfig.getOwnedAxisConfigurations()) {
+ if (axisConfig instanceof EStructuralFeatureValueFillingConfiguration) {
+ ((EStructuralFeatureValueFillingConfiguration) axisConfig).setListenFeature(synchronizedFeature);
+ }
+ }
+ }
+ table.getColumnAxisProvidersHistory().add(columnProvider);
+ table.setCurrentColumnAxisProvider(columnProvider);
+ table.getRowAxisProvidersHistory().add(rowProvider);
+ table.setCurrentRowAxisProvider(rowProvider);
+ for (final Style style : tableConfiguration.getStyles()) {
+ table.getStyles().add(EcoreUtil.copy(style));
+ }
+
return table;
}
+
/**
* This allow to add the tree item axis.
*
@@ -419,15 +846,36 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
* The axis manager representation.
* @param object
* The object to add.
+ *
+ * @deprecated since 2.0, moved into {@link TreeNattablePropertyEditor} with command
*/
+ @Deprecated
protected void addTreeItemAxis(final AbstractAxisProvider axisProvider, final AxisManagerRepresentation rep, final Object object) {
if (object instanceof View && isStereotypedElement((View) object)) {
+ TransactionalEditingDomain domain = getTableEditingDomain();
final IAxis axis = ITreeItemAxisHelper.createITreeItemAxis(null, null, object, rep);
- axisProvider.getAxis().add(axis);
+ Command addCommand = AddCommand.create(getTableEditingDomain(), axisProvider, NattableaxisproviderPackage.eINSTANCE.getAxisProvider_Axis(), Collections.singleton(axis));
+ domain.getCommandStack().execute(addCommand);
}
}
/**
+ *
+ * @return
+ * the editing domain to use
+ *
+ * @since 2.0
+ */
+ protected TransactionalEditingDomain getTableEditingDomain() {
+ try {
+ return this.serviceRegistry.getService(TransactionalEditingDomain.class);
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ }
+ return null;
+ }
+
+ /**
* Check is the element of the view is stereotyped.
*
* @param view
@@ -448,16 +896,17 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
* @return The table configuration.
*/
protected TableConfiguration getTableConfiguration() {
- ResourceSet resourceSet = new ResourceSetImpl();
- try {
- final TableConfiguration tableConfiguration = (TableConfiguration) EMFHelper.loadEMFModel(resourceSet,
- tableConfigURI);
- return tableConfiguration;
- } catch (Exception ex) {
- Activator.log.error("Invalid table configuration", ex); //$NON-NLS-1$
+ if (this.tableConfiguration == null) {
+ ResourceSet resourceSet = getResourceSet();
+ if (resourceSet != null) {
+ try {
+ this.tableConfiguration = (TableConfiguration) EMFHelper.loadEMFModel(resourceSet, this.tableConfigURI);
+ } catch (Exception ex) {
+ Activator.log.error("Invalid table configuration", ex); //$NON-NLS-1$
+ }
+ }
}
-
- return null;
+ return this.tableConfiguration;
}
/**
@@ -466,12 +915,36 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
* @return The dispose nattable manager listener.
*/
protected DisposeListener getDisposeListener() {
- if (null == nattableDisposeListener) {
- nattableDisposeListener = new DisposeListener() {
+ if (null == this.nattableDisposeListener) {
+ this.nattableDisposeListener = new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
- nattableManager.dispose();
- natTableWidget.dispose();
+
+ if (NattablePropertyEditor.this.serviceRegistry != null) {
+ // we dispose it to avoid unecessary refresh
+ NattablePropertyEditor.this.nattableManager.dispose();
+ NattablePropertyEditor.this.natTableWidget.dispose();
+
+ TransactionalEditingDomain domain = getTableEditingDomain();
+ Command cmd = getDisposeCommand(domain, table);
+ domain.getCommandStack().execute(cmd);
+
+ if (NattablePropertyEditor.this.resource != null) {
+ try {
+ NattablePropertyEditor.this.resource.save(saveOptions);
+ } catch (IOException e1) {
+ Activator.log.error(e1);
+ }
+ }
+ try {
+ NattablePropertyEditor.this.serviceRegistry.disposeRegistry();
+ } catch (ServiceMultiException e1) {
+ Activator.log.error(e1);
+ }
+ NattablePropertyEditor.this.serviceRegistry = null;
+ NattablePropertyEditor.this.table = null;
+
+ }
}
};
}
@@ -479,6 +952,26 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
}
/**
+ *
+ * @param domain
+ * the editing domain
+ * @param table
+ * the table to clean before dispose
+ * @return
+ * the command to use to clean the table before disposing it
+ * @since 2.0
+ */
+ protected CompoundCommand getDisposeCommand(final TransactionalEditingDomain domain, final Table table) {
+ CompoundCommand disposeCommand = new CompoundCommand("Command used to clean the table before disposing it"); //$NON-NLS-1$
+ disposeCommand.append(SetCommand.create(domain, table, NattablePackage.eINSTANCE.getTable_Context(), null));
+ disposeCommand.append(SetCommand.create(domain, table, NattablePackage.eINSTANCE.getTable_Owner(), null));
+ // assuming the table is synchronized and not inverted :
+ disposeCommand.append(SetCommand.create(domain, table.getCurrentRowAxisProvider(), NattableaxisproviderPackage.eINSTANCE.getAxisProvider_Axis(), Collections.emptyList()));
+
+ return disposeCommand;
+ }
+
+ /**
* {@inheritDoc}
*
* @see org.eclipse.papyrus.infra.properties.ui.widgets.AbstractPropertyEditor#unhookDataSourceListener(org.eclipse.papyrus.infra.properties.ui.modelelement.DataSource)
@@ -501,7 +994,7 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
/**
* This allow to create the data source listener.
*
- * @return The created data source listeer.
+ * @return The created data source listener.
*/
private IDataSourceListener getDataSourceListener() {
if (dataSourceListener == null) {
@@ -535,7 +1028,7 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
}
// Get the model element
- if(0 < contexts.size()){
+ if (0 < contexts.size()) {
final ModelElement modelElement = dataSource.getModelElement(propertyPath);
EObject sourceElement = EMFHelper.getEObject(contexts.get(0));
EStructuralFeature feature = null;
@@ -550,7 +1043,7 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
final EMFModelElement emfModelElement = (EMFModelElement) modelElement;
feature = emfModelElement.getFeature(getLocalPropertyPath());
}
-
+
// Recreate the table widget
createTableWidget(sourceElement, feature, contexts);
}
@@ -560,4 +1053,25 @@ public class NattablePropertyEditor extends AbstractPropertyEditor {
return dataSourceListener;
}
+
+ /**
+ *
+ * @param domain
+ * the editing domain to use
+ * @param resource
+ * the resource where the table must be saved
+ * @param table
+ * the table to add to the resource
+ * @return
+ * the command to add the table to the resource
+ */
+ private static final Command addTableToResource(final TransactionalEditingDomain domain, final Resource resource, final Table table) {
+ return new RecordingCommand(domain) {
+
+ @Override
+ protected void doExecute() {
+ resource.getContents().add(table);
+ }
+ };
+ }
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeDisplayNattablePropertyEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeDisplayNattablePropertyEditor.java
index 5d479a90033..c0d51e833a8 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeDisplayNattablePropertyEditor.java
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/StereotypeDisplayNattablePropertyEditor.java
@@ -16,15 +16,18 @@ import java.util.Collection;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer;
import org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager;
+import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
import org.eclipse.swt.widgets.Composite;
/**
* The property editor for the stereotype display nattable widget.
*/
-public class StereotypeDisplayNattablePropertyEditor extends NattablePropertyEditor {
+public class StereotypeDisplayNattablePropertyEditor extends TreeNattablePropertyEditor {
/**
* Constructor.
@@ -43,7 +46,10 @@ public class StereotypeDisplayNattablePropertyEditor extends NattablePropertyEdi
*
* @see org.eclipse.papyrus.uml.properties.widgets.NattablePropertyEditor#configureTreeTable(org.eclipse.papyrus.infra.nattable.manager.table.TreeNattableModelManager, org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EStructuralFeature,
* java.util.Collection)
+ *
+ * @deprecated since 2.0, done in the override of {@link #createNatTableWidget(INattableModelManager, Composite, int, Collection)}
*/
+ @Deprecated
@Override
protected void configureTreeTable(TreeNattableModelManager nattableManager, final EObject sourceElement, final EStructuralFeature feature, final Collection<?> rows) {
super.configureTreeTable(nattableManager, sourceElement, feature, rows);
@@ -56,4 +62,30 @@ public class StereotypeDisplayNattablePropertyEditor extends NattablePropertyEdi
}
}
}
+
+ /**
+ * @see org.eclipse.papyrus.uml.properties.widgets.NattablePropertyEditor#createNatTableWidget(org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager, org.eclipse.swt.widgets.Composite, int, Collection)
+ *
+ * @param manager
+ * @param parent
+ * @param style
+ * @return
+ */
+ @Override
+ protected NatTable createNatTableWidget(INattableModelManager manager, Composite parent, int style, Collection<?> rows) {
+ NatTable natTable = super.createNatTableWidget(manager, parent, style, rows);
+ // Bug 470252 : This allow to remove the 'view' rows
+ if (null != rows && !rows.isEmpty()) {
+ // the widget is already expanded
+ final RowHideShowLayer layer = nattableManager.getBodyLayerStack().getRowHideShowLayer();
+ for (Object current : manager.getRowElementsList()) {
+ if (rows.contains(AxisUtils.getRepresentedElement(current))) {
+ int index = manager.getRowElementsList().indexOf(current);
+ int realIndex = layer.underlyingToLocalRowPosition(natTable, index);
+ natTable.doCommand(new RowHideCommand(layer, realIndex));
+ }
+ }
+ }
+ return natTable;
+ }
}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/TreeNattablePropertyEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/TreeNattablePropertyEditor.java
new file mode 100644
index 00000000000..e6d5edea2a2
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/TreeNattablePropertyEditor.java
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * Copyright (c) 2016 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.properties.widgets;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxis.IAxis;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TableHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.NattableaxisproviderPackage;
+import org.eclipse.papyrus.infra.nattable.tree.ITreeItemAxisHelper;
+import org.eclipse.papyrus.infra.nattable.utils.HeaderAxisConfigurationManagementUtils;
+import org.eclipse.papyrus.infra.nattable.utils.TableHelper;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author VL222926
+ * @since 2.0
+ *
+ * Nattable Editor to use for tree table
+ *
+ */
+public class TreeNattablePropertyEditor extends NattablePropertyEditor {
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * @param style
+ */
+ public TreeNattablePropertyEditor(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.properties.widgets.NattablePropertyEditor#configureTable(org.eclipse.emf.transaction.TransactionalEditingDomain, org.eclipse.papyrus.infra.nattable.model.nattable.Table, org.eclipse.emf.ecore.EObject,
+ * org.eclipse.emf.ecore.EStructuralFeature, java.util.Collection, org.eclipse.emf.common.command.CompoundCommand)
+ *
+ * @param domain
+ * @param table
+ * @param sourceElement
+ * @param synchronizedFeature
+ * @param rows
+ * @param command
+ */
+ @Override
+ protected void configureTable(TransactionalEditingDomain domain, Table table, EObject sourceElement, EStructuralFeature synchronizedFeature, Collection<?> rows, CompoundCommand command) {
+ super.configureTable(domain, table, sourceElement, synchronizedFeature, rows, command);
+ if (TableHelper.isTreeTable(table) && null != rows && !rows.isEmpty()) {// add test on TreeTable to fix bug 476623
+ final AbstractAxisProvider axisProvider = table.getCurrentRowAxisProvider();
+ TableHeaderAxisConfiguration conf = (TableHeaderAxisConfiguration) HeaderAxisConfigurationManagementUtils.getRowAbstractHeaderAxisInTableConfiguration(table);
+ AxisManagerRepresentation rep = conf.getAxisManagers().get(0);
+ for (Object context : rows) {
+ addTreeItemAxis(domain, axisProvider, rep, context, command);
+ }
+ }
+ }
+
+ /**
+ * This allow to add the tree item axis.
+ *
+ * @param axisProvider
+ * The axis provider.
+ * @param rep
+ * The axis manager representation.
+ * @param object
+ * The object to add.
+ *
+ */
+ protected void addTreeItemAxis(final TransactionalEditingDomain domain, final AbstractAxisProvider axisProvider, final AxisManagerRepresentation rep, final Object object, final CompoundCommand command) {
+ if (object instanceof View && isStereotypedElement((View) object)) {
+ final IAxis axis = ITreeItemAxisHelper.createITreeItemAxis(null, null, object, rep);
+ Command addCommand = AddCommand.create(getTableEditingDomain(), axisProvider, NattableaxisproviderPackage.eINSTANCE.getAxisProvider_Axis(), Collections.singleton(axis));
+ command.append(addCommand);
+ }
+ }
+}

Back to the top