Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2014-01-21 16:23:14 +0000
committerptessier2014-01-21 16:23:14 +0000
commit4af4e531738ee2f8d495f8bef5f1fe4fdddb8619 (patch)
treedfab2ea273dfb4ff5e5018a65573c016d12c4c2f /deprecated
parent45a9998523fdf94c8196b9261167a5062917e25e (diff)
downloadorg.eclipse.papyrus-4af4e531738ee2f8d495f8bef5f1fe4fdddb8619.tar.gz
org.eclipse.papyrus-4af4e531738ee2f8d495f8bef5f1fe4fdddb8619.tar.xz
org.eclipse.papyrus-4af4e531738ee2f8d495f8bef5f1fe4fdddb8619.zip
386118: [EMF Facet] Papyrus should progressively support EMF Facet 0.2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=386118
Diffstat (limited to 'deprecated')
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/.classpath7
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/.project28
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/META-INF/MANIFEST.MF54
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/about.html28
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/build.properties7
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/icons/select_columns_to_show.pngbin0 -> 433 bytes
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/icons/table.gifbin0 -> 965 bytes
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/icons/table.pngbin0 -> 1347 bytes
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/icons/table_green.gifbin0 -> 994 bytes
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/icons/table_green.pngbin0 -> 1390 bytes
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/plugin.properties3
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/plugin.xml142
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/resources/table_Ecore_hideEAnnotationFeature.uiCustom10
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/Activator.java71
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/adapters/TableAdapterFactory.java44
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/adapters/TableOpenable.java44
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/advice/DeletePapyrusTableInstanceAdvice.java90
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/advice/TableDuplicateEditHelperAdvice.java404
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/dialog/TwoInputDialog.java134
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/editor/AbstractNattableEditor.java382
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/exceptions/ErrorInPastePreparationException.java34
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/factory/AbstractNattableEditorFactory.java207
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/factory/PapyrusCommandFactory.java312
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/handlers/AbstractCreateNattableEditorCommand.java516
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/IPapyrusNatTableWidget.java52
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/NatTableEditor.java460
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/PapyrusNatTableWidget.java263
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/TableEditorInput.java77
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/listener/AbstractSynchronizedTableTriggerListener.java431
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/listener/ModelTriggerListener.java90
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/listener/TableTriggerListener.java88
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/messages/Messages.java42
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/messages/messages.properties7
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/modelresource/EMFFacetNattableModel.java117
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/modelresource/PapyrusNattableModel.java118
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/providers/FilteredTableLabelProvider.java37
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/providers/TableLabelProvider.java85
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/util/FillingQueriesUtil.java30
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/util/QueryRepresentation.java69
41 files changed, 4494 insertions, 0 deletions
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/.classpath b/deprecated/org.eclipse.papyrus.infra.table.common/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/.project b/deprecated/org.eclipse.papyrus.infra.table.common/.project
new file mode 100644
index 00000000000..7605b36adae
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.infra.table.common</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/.settings/org.eclipse.core.resources.prefs b/deprecated/org.eclipse.papyrus.infra.table.common/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000000..e2ae99e6efc
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+#Fri Nov 04 17:01:15 CET 2011
+eclipse.preferences.version=1
+encoding//src/org/eclipse/papyrus/infra/table/common/messages/messages.properties=ISO-8859-1
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/.settings/org.eclipse.jdt.core.prefs b/deprecated/org.eclipse.papyrus.infra.table.common/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..498b15f69f9
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Mon Feb 21 13:41:19 CET 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/META-INF/MANIFEST.MF b/deprecated/org.eclipse.papyrus.infra.table.common/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..5a88a76b83b
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/META-INF/MANIFEST.MF
@@ -0,0 +1,54 @@
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.emf.facet.widgets.nattable.instance,
+ org.eclipse.emf.facet.widgets.nattable,
+ org.eclipse.papyrus.infra.widgets;bundle-version="1.0.0",
+ org.eclipse.papyrus.views.properties;bundle-version="1.0.0",
+ org.eclipse.emf.databinding;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.table.instance;bundle-version="1.0.0",
+ org.eclipse.emf.facet.infra.query.core;bundle-version="0.1.0",
+ org.eclipse.emf.facet.infra.query.editor;bundle-version="0.1.0",
+ org.eclipse.emf.facet.query.java;bundle-version="0.1.0",
+ org.eclipse.emf.facet.infra.common.core;bundle-version="0.1.0",
+ org.eclipse.papyrus.infra.services.edit;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.0",
+ net.sourceforge.nattable.core;bundle-version="2.1.0",
+ org.eclipse.emf.facet.infra.facet.core,
+ org.eclipse.papyrus.infra.emf;bundle-version="1.0.0",
+ org.eclipse.papyrus.uml.tools;bundle-version="1.0.0",
+ org.eclipse.core.runtime;bundle-version="3.8.0",
+ org.eclipse.emf.transaction;bundle-version="1.4.0",
+ org.eclipse.gmf.runtime.common.core;bundle-version="1.4.1",
+ org.eclipse.gmf.runtime.emf.type.core;bundle-version="1.4.0",
+ org.eclipse.uml2.uml;bundle-version="4.0.0",
+ org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
+ org.eclipse.emf.facet.util.emf.core;bundle-version="0.2.0",
+ org.eclipse.papyrus.infra.core.sasheditor;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.core.log;bundle-version="1.0.0",
+ org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.2.0",
+ org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.table.papyrustableconfiguration.metamodel;bundle-version="1.0.0",
+ com.google.guava;bundle-version="11.0.0"
+Export-Package: org.eclipse.papyrus.infra.table.common,
+ org.eclipse.papyrus.infra.table.common.advice,
+ org.eclipse.papyrus.infra.table.common.dialog,
+ org.eclipse.papyrus.infra.table.common.editor,
+ org.eclipse.papyrus.infra.table.common.exceptions,
+ org.eclipse.papyrus.infra.table.common.factory,
+ org.eclipse.papyrus.infra.table.common.handlers,
+ org.eclipse.papyrus.infra.table.common.internal,
+ org.eclipse.papyrus.infra.table.common.listener,
+ org.eclipse.papyrus.infra.table.common.messages,
+ org.eclipse.papyrus.infra.table.common.modelresource,
+ org.eclipse.papyrus.infra.table.common.util
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 1.0.0.qualifier
+Bundle-Name: %pluginName
+Bundle-Localization: plugin
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.infra.table.common.Activator
+Bundle-SymbolicName: org.eclipse.papyrus.infra.table.common;singleton:
+ =true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/about.html b/deprecated/org.eclipse.papyrus.infra.table.common/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/build.properties b/deprecated/org.eclipse.papyrus.infra.table.common/build.properties
new file mode 100644
index 00000000000..0845977ec69
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/build.properties
@@ -0,0 +1,7 @@
+#
+#Mon Sep 12 09:30:18 CEST 2011
+bin.includes=META-INF/,.,plugin.xml,plugin.properties,resources/,icons/,about.html
+output..=bin/
+src.includes = about.html
+source..=src/
+bin..=bin/
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/icons/select_columns_to_show.png b/deprecated/org.eclipse.papyrus.infra.table.common/icons/select_columns_to_show.png
new file mode 100644
index 00000000000..5a2446c88ef
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/icons/select_columns_to_show.png
Binary files differ
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/icons/table.gif b/deprecated/org.eclipse.papyrus.infra.table.common/icons/table.gif
new file mode 100644
index 00000000000..4c9048708b0
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/icons/table.gif
Binary files differ
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/icons/table.png b/deprecated/org.eclipse.papyrus.infra.table.common/icons/table.png
new file mode 100644
index 00000000000..2a979527f4a
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/icons/table.png
Binary files differ
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/icons/table_green.gif b/deprecated/org.eclipse.papyrus.infra.table.common/icons/table_green.gif
new file mode 100644
index 00000000000..b75d2dc269d
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/icons/table_green.gif
Binary files differ
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/icons/table_green.png b/deprecated/org.eclipse.papyrus.infra.table.common/icons/table_green.png
new file mode 100644
index 00000000000..16dcb3e4716
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/icons/table_green.png
Binary files differ
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/plugin.properties b/deprecated/org.eclipse.papyrus.infra.table.common/plugin.properties
new file mode 100644
index 00000000000..236e6df956a
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/plugin.properties
@@ -0,0 +1,3 @@
+#Properties file for org.eclipse.papyrus.infra.table.common
+providerName = Eclipse Modeling Project
+pluginName = Common Plugin for Papyrus Table Editor (Incubation) \ No newline at end of file
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/plugin.xml b/deprecated/org.eclipse.papyrus.infra.table.common/plugin.xml
new file mode 100644
index 00000000000..bd0eb3fc2b3
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/plugin.xml
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse version="3.4"?>
+
+<plugin>
+
+<!--We declare the model used for the Papyrus Table Editor -->
+ <extension point="org.eclipse.papyrus.infra.core.model">
+ <model classname="org.eclipse.papyrus.infra.table.common.modelresource.EMFFacetNattableModel" description="Model for Papyrus Table editors">
+ </model>
+ <model classname="org.eclipse.papyrus.infra.table.common.modelresource.PapyrusNattableModel" description="Model for Papyrus Table editors">
+ </model>
+ </extension>
+ <!--extension id="papyrus.table.menuspapyrus.table.menu" name="Papyrus Table Menus" point="org.eclipse.ui.menus">
+ <menuContribution allPopups="false" locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup?after=org.eclipse.papyrus.views.modelexplorer.popupmenu.creatediagram">
+ <menu icon="icons/table.gif" id="org.eclipse.papyrus.views.modelexplorer.popupmenu.createtable" label="New Table" mnemonic="&amp;T" tooltip="The table menu">
+ </menu>
+ </menuContribution>
+ <menuContribution allPopups="false" locationURI="menu:org.eclipse.papyrus.ui.menu?after=org.eclipse.papyrus.uml.diagram.ui.menu.diagrams">
+ <menu icon="icons/table.gif" id="org.eclipse.papyrus.table.ui.menu.tables" label="Tables" mnemonic="&amp;T" tooltip="The table menu">
+ </menu>
+ </menuContribution>
+ <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?endof=org.eclipse.papyrus.uml.diagram.ui.toolbar">
+ <toolbar id="org.eclipse.papyrus.table.ui.toolbar" label="Papyrus Table Toolbar">
+ </toolbar>
+ </menuContribution>
+ </extension-->
+ <extension point="org.eclipse.emf.facet.infra.browser.custom.core.registration">
+ <browserCustomization file="resources/table_Ecore_hideEAnnotationFeature.uiCustom"/>
+ </extension>
+ <extension
+ point="org.eclipse.emf.facet.widgets.celleditors.commandFactories">
+ <commandFactory
+ class="org.eclipse.papyrus.infra.table.common.factory.PapyrusCommandFactory">
+ </commandFactory>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.views.properties.labelprovider">
+ <labelProvider
+ labelProvider="org.eclipse.papyrus.infra.table.common.providers.FilteredTableLabelProvider"
+ priority="45">
+ </labelProvider>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.services.labelprovider.labelProvider">
+ <labelProvider
+ priority="45"
+ provider="org.eclipse.papyrus.infra.table.common.providers.FilteredTableLabelProvider">
+ </labelProvider>
+ </extension>
+ <!--extension
+ point="org.eclipse.ui.commands">
+ <command
+ categoryId="org.eclipse.papyrus.editor.category"
+ description="Open a dialog to select the columns to display"
+ id="org.eclipse.papyrus.infra.table.common.selectvisiblecolumns"
+ name="Select the columns to Show">
+ </command>
+ </extension-->
+ <!--extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.ui.popup.any">
+ <command
+ commandId="org.eclipse.papyrus.infra.table.common.selectvisiblecolumns"
+ icon="icons/select_columns_to_show.png"
+ label="Select the columns to show"
+ style="push"
+ tooltip="Open a dialog to choose the visible columns">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.ui.edit.paste"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension-->
+ <extension
+ point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
+ <metamodel
+ nsURI="http://www.eclipse.org/Papyrus/Table/0.8.0/papyrustableinstance">
+ <adviceBinding
+ class="org.eclipse.papyrus.infra.table.common.advice.DeletePapyrusTableInstanceAdvice"
+ id="org.eclipse.papyrus.infra.table.common.advice.DeletePapyrusTableInstanceAdvice"
+ inheritance="all"
+ typeId="*">
+ </adviceBinding>
+ </metamodel>
+ </extension>
+ <extension
+ point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
+ <binding
+ context="org.eclipse.papyrus.infra.services.edit.TypeContext">
+ <elementType
+ ref="org.eclipse.papyrus.infra.table.common.advice.DeletePapyrusTableInstanceAdvice">
+ </elementType>
+ </binding>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.papyrus.table.instance.papyrustableinstance.PapyrusTableInstance"
+ class="org.eclipse.papyrus.infra.table.common.adapters.TableAdapterFactory">
+ <adapter
+ type="org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenable">
+ </adapter>
+ </factory>
+ <factory
+ adaptableType="org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.TableInstance2"
+ class="org.eclipse.papyrus.infra.table.common.adapters.TableAdapterFactory">
+ <adapter
+ type="org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenable">
+ </adapter>
+ </factory>
+ </extension>
+ <!-- ElementType bindings for diagram duplication with paste command -->
+ <extension
+ point="org.eclipse.gmf.runtime.emf.type.core.elementTypes">
+ <metamodel
+ nsURI="http://www.eclipse.org/emf/2002/Ecore">
+ <adviceBinding
+ class="org.eclipse.papyrus.infra.table.common.advice.TableDuplicateEditHelperAdvice"
+ id="org.eclipse.papyrus.infra.table.common.advice.TableDuplicateEditHelperAdvice"
+ inheritance="none"
+ typeId="*">
+ </adviceBinding>
+ </metamodel>
+ </extension>
+
+<extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings">
+
+ <!-- Bindings declaration -->
+ <binding context="org.eclipse.papyrus.infra.services.edit.TypeContext">
+ <advice ref="org.eclipse.papyrus.infra.table.common.advice.TableDuplicateEditHelperAdvice" />
+ </binding>
+</extension>
+</plugin>
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/resources/table_Ecore_hideEAnnotationFeature.uiCustom b/deprecated/org.eclipse.papyrus.infra.table.common/resources/table_Ecore_hideEAnnotationFeature.uiCustom
new file mode 100644
index 00000000000..79a0cc69a63
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/resources/table_Ecore_hideEAnnotationFeature.uiCustom
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="ASCII"?>
+<uicustom:MetamodelView xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:uicustom="http://www.eclipse.org/EmfFacet/infra/browser/custom/0.8" metamodelURI="http://www.eclipse.org/emf/2002/Ecore">
+ <types metaclassName="ecore.EModelElement">
+ <references referenceName="eAnnotations">
+ <customizedFeatures>
+ <defaultValue xsi:type="uicustom:StaticFeatureValue" value="false"/>
+ </customizedFeatures>
+ </references>
+ </types>
+</uicustom:MetamodelView>
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/Activator.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/Activator.java
new file mode 100644
index 00000000000..d9496b16e90
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/Activator.java
@@ -0,0 +1,71 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common;
+
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.table.common"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ public static LogHelper log;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(final BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(final BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/adapters/TableAdapterFactory.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/adapters/TableAdapterFactory.java
new file mode 100644
index 00000000000..69190f2f14d
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/adapters/TableAdapterFactory.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (c) 2011 Atos
+ *
+ *
+ * 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:
+ * Tristan FAURE - tristan.faure@atos.net - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.adapters;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.TableInstance2;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenable;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenableWithContainer;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+
+@SuppressWarnings("rawtypes")
+public class TableAdapterFactory implements IAdapterFactory {
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if(adapterType == IOpenable.class) {
+ if (adaptableObject instanceof TableInstance2) {
+ return new TableOpenable((TableInstance2)adaptableObject);
+ }
+ if (adaptableObject instanceof PapyrusTableInstance) {
+ PapyrusTableInstance papyrusTableInstance = (PapyrusTableInstance)adaptableObject;
+ if (papyrusTableInstance.getTable() != null) {
+ return new IOpenableWithContainer.Openable(papyrusTableInstance, papyrusTableInstance.getTable().getContext());
+ }
+ }
+ }
+ return null;
+ }
+
+ public Class[] getAdapterList() {
+ return new Class[]{IOpenable.class};
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/adapters/TableOpenable.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/adapters/TableOpenable.java
new file mode 100644
index 00000000000..0bfbd265913
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/adapters/TableOpenable.java
@@ -0,0 +1,44 @@
+package org.eclipse.papyrus.infra.table.common.adapters;
+
+import java.util.Collection;
+import java.util.NoSuchElementException;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.TableInstance2;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenableWithContainer;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+
+public class TableOpenable implements IOpenableWithContainer {
+
+ protected TableInstance2 tableInstance;
+
+ public TableOpenable(TableInstance2 tableInstance) {
+ this.tableInstance = tableInstance;
+ }
+
+ public Object getPageIdentifier() {
+ Collection<Setting> usages = EMFHelper.getUsages(tableInstance);
+ Predicate<Setting> p = new Predicate<EStructuralFeature.Setting>() {
+
+ public boolean apply(EStructuralFeature.Setting setting) {
+ return setting.getEObject() instanceof PapyrusTableInstance;
+ }
+ };
+ try {
+ return Iterables.filter(usages, p).iterator().next();
+ } catch (NoSuchElementException e) {
+ return null;
+ }
+ }
+
+ public Object getContainer() {
+ return tableInstance.getContext();
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/advice/DeletePapyrusTableInstanceAdvice.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/advice/DeletePapyrusTableInstanceAdvice.java
new file mode 100644
index 00000000000..cdabb59384a
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/advice/DeletePapyrusTableInstanceAdvice.java
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.advice;
+
+import java.util.Collection;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableinstancePackage;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.TableInstance2;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrustableinstancePackage;
+
+/**
+ * Destroy the referenced TableInstance2
+ *
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class DeletePapyrusTableInstanceAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ *
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeDestroyDependentsCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ protected ICommand getBeforeDestroyDependentsCommand(DestroyDependentsRequest request) {
+ final EObject objectToDestroy = request.getElementToDestroy();
+ if(objectToDestroy == null) {
+ return null;
+ }
+ //the destroyed element is a PapyrusTableInstace
+ if(objectToDestroy instanceof PapyrusTableInstance) {
+ final TableInstance2 instance = ((PapyrusTableInstance)objectToDestroy).getTable();
+ final DestroyElementRequest request2 = new DestroyElementRequest(instance, false);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(instance);
+ return provider.getEditCommand(request2);
+ } else if(objectToDestroy instanceof EObject) {//the destroyed element could be a table container
+ final ECrossReferenceAdapter crossReferencerAdapter = CrossReferenceAdapter.getCrossReferenceAdapter(objectToDestroy);
+ final Collection<Setting> settings = crossReferencerAdapter.getNonNavigableInverseReferences(objectToDestroy);
+ //the destroyed context can references several table!
+ final CompositeCommand cmd = new CompositeCommand("Destroy Table Instance2 Command"); //$NON-NLS-1$
+ for(Setting currentSetting : settings) {
+ final EObject currentEObject = currentSetting.getEObject();
+ final EStructuralFeature currentfeature = currentSetting.getEStructuralFeature();
+ if(currentEObject instanceof TableInstance2 && currentfeature == TableinstancePackage.eINSTANCE.getTableInstance_Context()) {
+ final Collection<Setting> tableInstanceSettings = crossReferencerAdapter.getNonNavigableInverseReferences(currentEObject);
+ for(Setting setting : tableInstanceSettings) {
+ final EObject eobject = setting.getEObject();
+ final EStructuralFeature currentFeature = setting.getEStructuralFeature();
+ if(eobject instanceof PapyrusTableInstance && currentFeature == PapyrustableinstancePackage.eINSTANCE.getPapyrusTableInstance_Table()) {//the destroyed element is a table container
+ final DestroyElementRequest request2 = new DestroyElementRequest(eobject, false);
+ final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(eobject);
+ final ICommand tmp = provider.getEditCommand(request2);
+ cmd.add(tmp);
+ }
+ }
+ }
+ }
+ if(!cmd.isEmpty()) {
+ return cmd;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/advice/TableDuplicateEditHelperAdvice.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/advice/TableDuplicateEditHelperAdvice.java
new file mode 100644
index 00000000000..b1ffe031e2a
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/advice/TableDuplicateEditHelperAdvice.java
@@ -0,0 +1,404 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.advice;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableInstance;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableinstancePackage;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.TableInstance2;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.commands.core.commands.DuplicateEObjectsCommand;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.commands.IPapyrusDuplicateCommandConstants;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel;
+import org.eclipse.papyrus.infra.table.common.Activator;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrustableinstancePackage;
+
+
+/**
+ * Edit Helper advice to add Table duplication when duplicating
+ */
+public class TableDuplicateEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ICommand getBeforeDuplicateCommand(DuplicateElementsRequest request) {
+ Object additional = request.getParameter(IPapyrusDuplicateCommandConstants.ADDITIONAL_DUPLICATED_ELEMENTS); // Taken from uml.pastemanager
+
+ // additional element should be a set of elements that will be duplicated. If this is null, the request will be ignored.
+ if(!(additional instanceof Set<?>)) {
+ return super.getBeforeDuplicateCommand(request);
+ }
+
+ Set<Object> duplicatedObjects = ((Set<Object>)additional);
+ EObject object = getDuplicatedEObject(request);
+ if(object == null || object.eResource()==null) {
+ return super.getBeforeDuplicateCommand(request);
+ }
+
+ // retrieve the tables linked to the object
+ List<PapyrusTableInstance> tablesToDuplicate = getRelatedTables(object, true);
+
+ if(!tablesToDuplicate.isEmpty()) {
+ CompositeCommand command = null;
+ // create the command for all the tables that have no command ready
+ for(PapyrusTableInstance tableToDuplicate : tablesToDuplicate) {
+ if(!duplicatedObjects.contains(tableToDuplicate)) {
+ if(command == null) {
+ command = new CompositeCommand("", Arrays.asList(new DuplicatePapyrusTableCommand(request.getEditingDomain(), "Duplicate Table", tableToDuplicate, request.getAllDuplicatedElementsMap())));
+ } else {
+ command.add(new DuplicatePapyrusTableCommand(request.getEditingDomain(), "Duplicate Table", tableToDuplicate, request.getAllDuplicatedElementsMap()));
+ }
+ duplicatedObjects.add(tableToDuplicate);
+ }
+ }
+
+ if(command != null) {
+ if(super.getBeforeDuplicateCommand(request) != null) {
+ command.add(super.getBeforeDuplicateCommand(request));
+ return command.reduce();
+ } else {
+ return command.reduce();
+
+ }
+ }
+ }
+
+ return super.getBeforeDuplicateCommand(request);
+ }
+
+ /**
+ * Returns the EObject to be duplicated
+ *
+ * @return the EObject to be duplicated
+ */
+ protected EObject getDuplicatedEObject(DuplicateElementsRequest request) {
+ List<Object> elementsToBeDuplicated = request.getElementsToBeDuplicated();
+ if(elementsToBeDuplicated == null || elementsToBeDuplicated.isEmpty()) {
+ return null;
+ }
+ Object elementToBeDuplicated = elementsToBeDuplicated.get(0);
+ if(elementToBeDuplicated instanceof EObject) {
+ return ((EObject)elementToBeDuplicated);
+ }
+ return null;
+ }
+
+ /**
+ * Returns the list of "Owned" tables for a given object
+ *
+ * @param object
+ * the object for which tables are searched
+ * @param lookInChildren
+ * <code>true</code> if the search shall be done for contained EObject.
+ * @return the list of tables found or an empty list
+ */
+ protected List<PapyrusTableInstance> getRelatedTables(EObject object, boolean lookInChildren) {
+ List<PapyrusTableInstance> tables = new ArrayList<PapyrusTableInstance>();
+ if(object.eResource()==null) {
+ return tables;
+ }
+ ResourceSet resourceSet = object.eResource().getResourceSet();
+ ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(resourceSet);
+ if(adapter == null) {
+ adapter = new ECrossReferenceAdapter();
+ resourceSet.eAdapters().add(adapter);
+ }
+
+ // check for the element itself
+ Collection<Setting> settings = adapter.getInverseReferences(object, false);
+ for(Setting setting : settings) {
+ EObject value = setting.getEObject();
+ if(value instanceof TableInstance && TableinstancePackage.Literals.TABLE_INSTANCE__CONTEXT == setting.getEStructuralFeature()) {
+ // get the papyrus table instance to be duplicated
+ Collection<Setting> tableSettings = adapter.getInverseReferences((TableInstance)value, false);
+ for(Setting tableSetting : tableSettings) {
+ EObject tableValue = tableSetting.getEObject();
+ if(tableValue instanceof PapyrusTableInstance && PapyrustableinstancePackage.Literals.PAPYRUS_TABLE_INSTANCE__TABLE == tableSetting.getEStructuralFeature()) {
+ // get the papyrus table instance to be duplicated
+ tables.add((PapyrusTableInstance)tableValue);
+ }
+ }
+ }
+ }
+
+ if(lookInChildren) {
+ for(EObject child : object.eContents()) {
+ tables.addAll(getRelatedTables(child, lookInChildren));
+ }
+ }
+ return tables;
+ }
+
+ /**
+ * Command to duplicate tables. This adds the table to the resource containing the source table.
+ */
+ public class DuplicatePapyrusTableCommand extends DuplicateEObjectsCommand {
+
+ /** table to be duplicated */
+ private final PapyrusTableInstance papyrusTableInstanceToDuplicate;
+
+ /**
+ * Constructs a new duplicate EObjects command with the specified label and
+ * list of EObjects.
+ *
+ * @param editingDomain
+ * the editing domain through which model changes are made
+ * @param label
+ * The label for the new command.
+ * @param table
+ * <code>PapyrusTableInstance</code> to be duplicated.
+ */
+ public DuplicatePapyrusTableCommand(TransactionalEditingDomain editingDomain, String label, PapyrusTableInstance table) {
+ super(editingDomain, label, Collections.singletonList(table));
+ this.papyrusTableInstanceToDuplicate = table;
+ }
+
+ /**
+ * Constructs a new duplicate Table command with the specified label and
+ * list of EObjects.
+ *
+ * @param editingDomain
+ * the editing domain through which model changes are made
+ * @param label
+ * The label for the new command.
+ * @param table
+ * <code>PapyrusTableInstance</code> to be duplicated.
+ * @param allDuplicatedObjectsMap
+ * An empty map to be populated with the duplicated objects.
+ */
+ public DuplicatePapyrusTableCommand(TransactionalEditingDomain editingDomain, String label, PapyrusTableInstance table, Map allDuplicatedObjectsMap) {
+ super(editingDomain, label, Collections.singletonList(table), allDuplicatedObjectsMap);
+ this.papyrusTableInstanceToDuplicate = table;
+ }
+
+ /**
+ * Constructs a new duplicate EObjects command with the specified label and
+ * list of EObjects. Also sets the list of affected files to be the files,
+ * where the targetContainer is stored. Target container specifies the
+ * eObject into which the duplicated eObjects will be added.
+ *
+ * @param editingDomain
+ * the editing domain through which model changes are made
+ * @param label
+ * The label for the new command.
+ * @param table
+ * <code>PapyrusTableInstance</code> to be duplicated.
+ * @param allDuplicatedObjectsMap
+ * An empty map to be populated with the duplicated objects.
+ */
+ public DuplicatePapyrusTableCommand(TransactionalEditingDomain editingDomain, String label, PapyrusTableInstance table, Map allDuplicatedObjectsMap, EObject targetContainer) {
+ super(editingDomain, label, Collections.singletonList(table), allDuplicatedObjectsMap, targetContainer);
+ this.papyrusTableInstanceToDuplicate = table;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ // Remove elements whose container is getting copied.
+ // ClipboardSupportUtil.getCopyElements(getObjectsToBeDuplicated());
+
+ // Perform the copy and update the references.
+ EcoreUtil.Copier copier = new TableCopier(getAllDuplicatedObjectsMap());
+ TableInstance tableInstanceToDuplicate = papyrusTableInstanceToDuplicate.getTable();
+ copier.copy(tableInstanceToDuplicate);
+ copier.copy(papyrusTableInstanceToDuplicate);
+ copier.copyReferences();
+
+ // Add the duplicates to the original's container.
+ EObject duplicatePapyrusTableInstance = (EObject)copier.get(papyrusTableInstanceToDuplicate);
+ EObject duplicateTableInstance = (EObject)copier.get(tableInstanceToDuplicate);
+
+ Resource targetResource = getDiResourceForTable(duplicateTableInstance, getEditingDomain());
+ // Resource containerResource = papyrusTableInstanceToDuplicate.eResource();
+ if(targetResource != null) {
+ targetResource.getContents().add(duplicateTableInstance);
+ targetResource.getContents().add(duplicatePapyrusTableInstance);
+ } else { // no resource found, try to add in resource of the original table
+ targetResource = papyrusTableInstanceToDuplicate.eResource();
+ if(targetResource != null) {
+ Activator.log.warn("It was not possible to find the Resource with the target EObject");
+ targetResource.getContents().add(duplicateTableInstance);
+ targetResource.getContents().add(duplicatePapyrusTableInstance);
+ }
+ return CommandResult.newErrorCommandResult("Impossible to find a resource for the new table");
+ }
+
+ // modify also the di, in order to be able to open the table
+ Resource diResource = getDiResourceForTable(duplicateTableInstance, getEditingDomain());
+ if(diResource !=null) {
+ try {
+ IPageManager iPageManager = ServiceUtilsForResource.getInstance().getIPageManager(diResource);
+ iPageManager.addPage(duplicatePapyrusTableInstance);
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ return CommandResult.newErrorCommandResult("Impossible to find a di resource to add the new available page");
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("Impossible to find a di resource to add the new available page");
+ }
+ // copy also uml profile facet set in case of UML profiles appplied
+ return CommandResult.newOKCommandResult(getAllDuplicatedObjectsMap());
+ }
+
+ @Override
+ public boolean canExecute() {
+ // should add some tests here? no need to test containement feature like previous, Table has no owner...
+ return true;
+ }
+ }
+
+ /**
+ * Copier for tables, where only views and internal references are duplicated, not the semantic elements themselves.
+ */
+ protected class TableCopier extends EcoreUtil.Copier {
+
+ /** Serial UUID */
+ private static final long serialVersionUID = 8544123249170461708L;
+
+ /** semantic objects referenced by the views in the diagram */
+ private Map<EObject, EObject> semanticObjects;
+
+ /**
+ * Creates a new {@link TableCopier}
+ *
+ * @param semanticObjects
+ * list of semantic objects already copied, to which new views should be related.
+ */
+ public TableCopier(Map<EObject, EObject> semanticObjects) {
+ this.semanticObjects = semanticObjects;
+ }
+
+ /**
+ * Overrides the get to look in the map of duplicated semantic objects in case the element was not found in this map
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public EObject get(Object arg0) {
+ EObject object = super.get(arg0);
+ if(object == null) {
+ object = semanticObjects.get(arg0);
+ }
+ return object;
+ }
+ }
+
+ /**
+ * Returns the notation resource where to add the new diagram
+ *
+ * @param eObject
+ * the semantic object linked to the diagram or the diagram itself.
+ * @param domain
+ * the editing domain
+ * @return the resource where the diagram should be added or <code>null</code> if no resource was found
+ * TODO this method should be handled by the resource plugin.
+ */
+ public Resource getNotationResourceForTable(EObject eObject, TransactionalEditingDomain domain) {
+ EObject semanticObject = eObject;
+ if(eObject instanceof PapyrusTableInstance) {
+ TableInstance2 tableInstance = ((PapyrusTableInstance)eObject).getTable();
+ if(tableInstance != null) {
+ semanticObject = tableInstance.getContext();
+ }
+ } else if(eObject instanceof TableInstance2) {
+ semanticObject = ((TableInstance2)eObject).getContext();
+ }
+ if(semanticObject == null) {
+ return null;
+ }
+
+ Resource containerResource = semanticObject.eResource();
+ if(containerResource == null) {
+ return null;
+ }
+ // retrieve the model set from the container resource
+ ResourceSet resourceSet = containerResource.getResourceSet();
+
+ if(resourceSet instanceof ModelSet) {
+ ModelSet modelSet = (ModelSet)resourceSet;
+ Resource destinationResource = modelSet.getAssociatedResource(semanticObject, NotationModel.NOTATION_FILE_EXTENSION, true);
+ return destinationResource;
+ } else throw new RuntimeException("Resource Set is not a ModelSet or is null");
+ }
+
+
+ /**
+ * Returns the di resource where to add the new diagram
+ *
+ * @param eObject
+ * the semantic object linked to the diagram or the diagram itself.
+ * @param domain
+ * the editing domain
+ * @return the resource where the diagram should be added or <code>null</code> if no resource was found
+ */
+ public Resource getDiResourceForTable(EObject eObject, TransactionalEditingDomain domain) {
+ EObject semanticObject = eObject;
+ if(eObject instanceof PapyrusTableInstance) {
+ TableInstance2 tableInstance = ((PapyrusTableInstance)eObject).getTable();
+ if(tableInstance != null) {
+ semanticObject = tableInstance.getContext();
+ }
+ } else if(eObject instanceof TableInstance2) {
+ semanticObject = ((TableInstance2)eObject).getContext();
+ }
+ if(semanticObject == null) {
+ return null;
+ }
+
+ Resource containerResource = semanticObject.eResource();
+ if(containerResource == null) {
+ return null;
+ }
+ // retrieve the model set from the container resource
+ ResourceSet resourceSet = containerResource.getResourceSet();
+
+ if(resourceSet instanceof ModelSet) {
+ ModelSet modelSet = (ModelSet)resourceSet;
+ Resource destinationResource = modelSet.getAssociatedResource(semanticObject, DiModel.DI_FILE_EXTENSION, true);
+ return destinationResource;
+ } else throw new RuntimeException("Resource Set is not a ModelSet or is null");
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/dialog/TwoInputDialog.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/dialog/TwoInputDialog.java
new file mode 100644
index 00000000000..2c2f14a47d2
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/dialog/TwoInputDialog.java
@@ -0,0 +1,134 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.dialog;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * This Dialog provides 2 texts field. It was created to be used during the table creation.
+ * It doesn't provide validator for the second field.
+ *
+ *
+ */
+public class TwoInputDialog extends InputDialog {
+
+ /** widget for the second value */
+ private Text text_2;
+
+ /** the second values */
+ private String value_2;
+
+ /** the message for the second Text */
+ protected String message_2;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parentShell
+ * the parent shell
+ * @param dialogTitle
+ * the dialog title
+ * @param message1
+ * the first message for the dialog
+ * @param message2
+ * the second message for the dialog
+ * @param initialValue1
+ * the first initial value
+ * @param initialValue2
+ * the second initial value
+ * @param validator
+ * the validator
+ */
+ public TwoInputDialog(Shell parentShell, String dialogTitle, String message1, String message2, String initialValue1, String initialValue2, IInputValidator validator) {
+ super(parentShell, dialogTitle, message1, initialValue1, validator);
+ this.message_2 = message2;
+ this.value_2 = initialValue2;
+ }
+
+ /**
+ * Create the second Text Area
+ *
+ * @see org.eclipse.jface.dialogs.InputDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ * @return
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite)super.createDialogArea(parent);
+ if(message_2 != null) {
+ Label label = new Label(composite, SWT.WRAP);
+ label.setText(message_2);
+ GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
+ data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
+ label.setLayoutData(data);
+ label.setFont(parent.getFont());
+ }
+ text_2 = new Text(composite, getInputTextStyle());
+ text_2.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+ applyDialogFont(composite);
+ return composite;
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.dialogs.InputDialog#buttonPressed(int)
+ *
+ * @param buttonId
+ */
+ @Override
+ protected void buttonPressed(int buttonId) {
+ if(buttonId == IDialogConstants.OK_ID) {
+ this.value_2 = this.text_2.getText();
+ } else {
+ this.value_2 = null;
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.dialogs.InputDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ super.createButtonsForButtonBar(parent);
+ if(value_2 != null) {
+ text_2.setText(value_2);
+ }
+ }
+
+ /**
+ * Getter for {@link #value_2}
+ *
+ * @return
+ * the description for the table
+ */
+ public String getValue_2() {
+ return this.value_2;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/editor/AbstractNattableEditor.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/editor/AbstractNattableEditor.java
new file mode 100644
index 00000000000..a785c0bb4d6
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/editor/AbstractNattableEditor.java
@@ -0,0 +1,382 @@
+/*****************************************************************************
+ * Copyright (c) 2009 CEA LIST & LIFL
+ *
+ *
+ * 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:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ * Vincent Lorenzo (CEA-LIST) vincent.lorenzo@cea.fr
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.editor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.commands.State;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.infra.query.ModelQuery;
+import org.eclipse.emf.facet.infra.query.core.AbstractModelQuery;
+import org.eclipse.emf.facet.infra.query.core.ModelQuerySetCatalog;
+import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryException;
+import org.eclipse.emf.facet.infra.query.runtime.ModelQueryResult;
+import org.eclipse.emf.facet.widgets.nattable.INatTableWidgetProvider;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.Column;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.DefaultLabelColumn;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.EContainerColumn;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.MetaClassColumn;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableInstance;
+import org.eclipse.emf.facet.widgets.nattable.internal.NatTableWidgetInternalUtils;
+import org.eclipse.emf.transaction.ResourceSetChangeEvent;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.TriggerListener;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.table.common.Activator;
+import org.eclipse.papyrus.infra.table.common.internal.IPapyrusNatTableWidget;
+import org.eclipse.papyrus.infra.table.common.internal.TableEditorInput;
+import org.eclipse.papyrus.infra.table.common.listener.ModelTriggerListener;
+import org.eclipse.papyrus.infra.table.common.listener.TableTriggerListener;
+import org.eclipse.papyrus.infra.table.common.util.FillingQueriesUtil;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrustableinstancePackage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.commands.ICommandService;
+
+/**
+ * Abstract class for TableEditor
+ *
+ *
+ *
+ */
+public abstract class AbstractNattableEditor extends org.eclipse.papyrus.infra.table.common.internal.NatTableEditor {
+
+ /** the service registry */
+ protected ServicesRegistry servicesRegistry;
+
+ /** the table instance */
+ protected PapyrusTableInstance rawModel;
+
+ /** listener on the model for synchronized table */
+ protected TriggerListener modelTriggerListener;
+
+ /** listener on the table for synchronized table : listen the properties "isSynchronized" and "fillingQueries" */
+ protected TriggerListener tableTriggerListener;
+
+ /**
+ * the part name synchronizer
+ */
+ private final PartNameSynchronizer synchronizer;
+
+ /**
+ * @param servicesRegistry
+ * @param rawModel
+ *
+ */
+ public AbstractNattableEditor(final ServicesRegistry servicesRegistry, final PapyrusTableInstance rawModel) {
+ this.servicesRegistry = servicesRegistry;
+ this.rawModel = rawModel;
+ this.synchronizer = new PartNameSynchronizer(rawModel);
+
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.facet.widgets.nattable.workbench.editor.NatTableEditor#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
+ *
+ * @param site
+ * @param input
+ * @throws PartInitException
+ */
+ @Override
+ public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {
+ TableEditorInput tableEditorInput = new TableEditorInput(this.rawModel, getEditingDomain());
+ initHiddenColumn(this.rawModel);
+ setSite(site);
+ setInput(tableEditorInput);
+ setPartName(this.rawModel.getName());
+ addListeners();
+ super.init(site, tableEditorInput);
+ }
+
+ /**
+ * add listeners on the context of the table and on the table itself
+ */
+ protected void addListeners() {
+ EditingDomain editingDomain = getEditingDomain();
+ Assert.isTrue(editingDomain instanceof TransactionalEditingDomain);
+ this.modelTriggerListener = new ModelTriggerListener(this.rawModel, (INatTableWidgetProvider)getAdapter(INatTableWidgetProvider.class));
+ ((TransactionalEditingDomain)editingDomain).addResourceSetListener(this.modelTriggerListener);
+ this.tableTriggerListener = new TableTriggerListener(this.rawModel, (INatTableWidgetProvider)getAdapter(INatTableWidgetProvider.class));
+ ((TransactionalEditingDomain)editingDomain).addResourceSetListener(this.tableTriggerListener);
+ }
+
+ /**
+ * {@inheritDoc} + update the content of the table if the table is synchronized
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ super.createPartControl(parent);
+ // we update the table
+ if(rawModel.isIsSynchronized()) {
+ Notification impl = new ENotificationImpl((InternalEObject)rawModel, FillingQueriesUtil.OPEN_TABLE, null, null, null);
+ List<Notification> notifications = Collections.singletonList(impl);
+ ResourceSetChangeEvent event = new ResourceSetChangeEvent((TransactionalEditingDomain)getEditingDomain(), null, notifications);
+ Command cmd = null;
+ try {
+ cmd = this.modelTriggerListener.transactionAboutToCommit(event);
+ if(cmd != null && cmd.canExecute()) {
+ cmd.execute();
+ }
+ } catch (Exception e) {
+ Activator.log.error("I can't update the opened table", e); //$NON-NLS-1$
+ }
+ }
+ }
+
+ @Override
+ public Object getAdapter(Class adapter) {
+ return super.getAdapter(adapter);
+ };
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.table.common.internal.NatTableEditor#dispose()
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public void dispose() {
+ if(this.modelTriggerListener != null) {
+ ((TransactionalEditingDomain)getEditingDomain()).removeResourceSetListener(this.modelTriggerListener);
+ }
+ if(this.tableTriggerListener != null) {
+ ((TransactionalEditingDomain)getEditingDomain()).removeResourceSetListener(this.tableTriggerListener);
+ }
+ synchronizer.dispose();
+ super.dispose();
+ }
+
+ /**
+ *
+ * @param rawModel2
+ */
+ private void initHiddenColumn(final PapyrusTableInstance rawModel2) {
+ for(Column current : rawModel2.getTable().getColumns()) {
+ if(current instanceof DefaultLabelColumn || current instanceof MetaClassColumn || current instanceof EContainerColumn) {
+ String name = NatTableWidgetInternalUtils.getColumnName(current);
+ if(getInitialHiddenColumns().contains(name)) {
+ current.setIsHidden(true);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @return
+ * a list of the names of the columns to hide by default
+ */
+ protected List<String> getInitialHiddenColumns() {
+ return Collections.emptyList();
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.facet.widgets.nattable.workbench.editor.NatTableEditor#getEditingDomain()
+ *
+ * @return
+ */
+ @Override
+ public EditingDomain getEditingDomain() {
+ try {
+ return ServiceUtils.getInstance().getTransactionalEditingDomain(this.servicesRegistry);
+ } catch (ServiceException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+
+ /**
+ * This method execute the filling queries
+ */
+ @Deprecated
+ protected void executeQueries() {
+ if(this.rawModel.isIsSynchronized()) {
+ TableInstance table = this.rawModel.getTable();
+ EObject context = table.getContext();
+ List<EObject> elementsToAdd = new ArrayList<EObject>();
+ for(ModelQuery query : this.rawModel.getFillingQueries()) {
+ ModelQuerySetCatalog catalog = ModelQuerySetCatalog.getSingleton();
+ AbstractModelQuery impl = null;
+ try {
+ impl = catalog.getModelQueryImpl(query);
+ } catch (ModelQueryException e) {
+ e.printStackTrace();
+ }
+ if(impl != null) {
+ ModelQueryResult result = impl.evaluate(context);
+ Object value = result.getValue();
+ if(value instanceof Collection<?>) {
+ for(Object currentObject : (Collection<?>)value) {
+ if(currentObject instanceof EObject && !table.getElements().contains(currentObject)) {
+ elementsToAdd.add((EObject)currentObject);
+ }
+ }
+
+ } else {
+ //nothing to do for the moment
+ }
+ }
+ }
+ if(!elementsToAdd.isEmpty()) {
+ // this.natTableWidget.addRows(elementsToAdd);
+ if(this.natTableWidget instanceof IPapyrusNatTableWidget) {
+ ((IPapyrusNatTableWidget)this.natTableWidget).addRowsOutOfCommandStack(elementsToAdd);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * A class taking in charge the synchronization of the partName and the diagram name.
+ * When diagram name change, the other is automatically updated.
+ *
+ * @author vincent lorenzo
+ * adapted class from UmlGmfDiagramEditor
+ */
+ public class PartNameSynchronizer {
+
+ /** the papyrus table */
+ private PapyrusTableInstance papyrusTable;
+
+ /**
+ * Listener on diagram name change.
+ */
+ private final Adapter tableNameListener = new Adapter() {
+
+ /**
+ *
+ * @see org.eclipse.emf.common.notify.Adapter#notifyChanged(org.eclipse.emf.common.notify.Notification)
+ *
+ * @param notification
+ */
+ public void notifyChanged(final Notification notification) {
+ if(notification.getFeatureID(PapyrusTableInstance.class) == PapyrustableinstancePackage.PAPYRUS_TABLE_INSTANCE__NAME && notification.getNotifier() == PartNameSynchronizer.this.papyrusTable) {
+ setPartName(PartNameSynchronizer.this.papyrusTable.getName());
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.common.notify.Adapter#getTarget()
+ *
+ * @return
+ */
+ public Notifier getTarget() {
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.common.notify.Adapter#setTarget(org.eclipse.emf.common.notify.Notifier)
+ *
+ * @param newTarget
+ */
+ public void setTarget(final Notifier newTarget) {
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.common.notify.Adapter#isAdapterForType(java.lang.Object)
+ *
+ * @param type
+ * @return
+ */
+ public boolean isAdapterForType(final Object type) {
+ return false;
+ }
+
+ };
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param diagram
+ */
+ public PartNameSynchronizer(final PapyrusTableInstance papyrusTable) {
+ setTable(papyrusTable);
+ }
+
+ public void dispose() {
+ this.papyrusTable.eAdapters().remove(tableNameListener);
+ }
+
+ /**
+ * Change the associated diagram.
+ *
+ * @param papyrusTable
+ */
+ public void setTable(final PapyrusTableInstance papyrusTable) {
+ // Remove from old diagram, if any
+ if(this.papyrusTable != null) {
+ papyrusTable.eAdapters().remove(this.tableNameListener);
+ }
+ // Set new table
+ this.papyrusTable = papyrusTable;
+ // Set editor name
+ setPartName(papyrusTable.getName());
+ // Listen to name change
+ papyrusTable.eAdapters().add(this.tableNameListener);
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.table.common.internal.NatTableEditor#setFocus()
+ *
+ */
+ @Override
+ public void setFocus() {
+ super.setFocus();
+
+ //we update the status of the toggle action on the Table (these actions are declared into oep.infra.table.menu)
+ final ICommandService commandService = (ICommandService)this.getEditorSite().getService(ICommandService.class);
+ if(commandService != null) {
+ org.eclipse.core.commands.Command command = commandService.getCommand("org.eclipse.emf.facet.widget.nattable.common.columns.command"); //$NON-NLS-1$
+ if(command != null) {
+ final State state = command.getState("org.eclipse.ui.commands.toggleState"); //$NON-NLS-1$
+ if(state != null) {
+ state.setValue(this.rawModel.getTable().isOnlyShowCommonColumns());
+ }
+ }
+ command = commandService.getCommand("org.eclipse.emf.facet.widget.nattable.empty.columns.command"); //$NON-NLS-1$
+ if(command != null) {
+ final State state = command.getState("org.eclipse.ui.commands.toggleState"); //$NON-NLS-1$
+ if(state != null) {
+ state.setValue(this.rawModel.getTable().isHideEmptyColumns());
+ }
+ }
+ }
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/exceptions/ErrorInPastePreparationException.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/exceptions/ErrorInPastePreparationException.java
new file mode 100644
index 00000000000..1020724ed1b
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/exceptions/ErrorInPastePreparationException.java
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.exceptions;
+
+
+public class ErrorInPastePreparationException extends Exception {
+
+
+ /**
+ * the serial version UID
+ */
+ private static final long serialVersionUID = -2707065012620342372L;
+
+
+ public ErrorInPastePreparationException(final String message) {
+ super(message);
+ }
+
+
+ public ErrorInPastePreparationException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/factory/AbstractNattableEditorFactory.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/factory/AbstractNattableEditorFactory.java
new file mode 100644
index 00000000000..469081b7a74
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/factory/AbstractNattableEditorFactory.java
@@ -0,0 +1,207 @@
+/*****************************************************************************
+ * Copyright (c) 2011 LIFL & CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation
+ * Vincent Lorenzo (CEA-LIST) vincent.lorenzo@cea.fr
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.factory;
+
+import java.lang.reflect.Constructor;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.infra.core.editor.BackboneException;
+import org.eclipse.papyrus.infra.core.extension.diagrameditor.AbstractEditorFactory;
+import org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor.ActionBarContributorRegistry;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.table.common.Activator;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.EditorActionBarContributor;
+
+/**
+ * Abstract factory for the NattableEditor
+ *
+ *
+ *
+ */
+public abstract class AbstractNattableEditorFactory extends AbstractEditorFactory {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param editorClass
+ * the editor class
+ * @param editorType
+ * the type of editor
+ */
+ public AbstractNattableEditorFactory(Class<?> editorClass, String editorType) {
+ super(editorClass, editorType);
+ }
+
+ /**
+ * Create the IPageModel that is used by the SashWindows to manage the editor.
+ *
+ * @see org.eclipse.papyrus.infra.core.editorsfactory.IEditorFactory#createIPageModel(java.lang.Object)
+ *
+ * @param pageIdentifier
+ * The model pushed in the sashmodel by the creation command
+ * @return A model implementing the IPageModel
+ */
+ public IPageModel createIPageModel(Object pageIdentifier) {
+ return new NattableEditorModel(pageIdentifier, getServiceRegistry());
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.core.editorsfactory.IEditorFactory#isPageModelFactoryFor(java.lang.Object)
+ *
+ * @param pageIdentifier
+ * @return
+ */
+ public boolean isPageModelFactoryFor(Object pageIdentifier) {
+ if(pageIdentifier instanceof PapyrusTableInstance) {
+ return getExpectedType().equals(((PapyrusTableInstance)pageIdentifier).getType());
+ }
+ return false;
+ }
+
+ /**
+ * IEditorModel used internally by the SashContainer. This model know how to handle IEditor creation.
+ *
+ * @author cedric dumoulin
+ *
+ */
+ class NattableEditorModel implements IEditorModel {
+
+
+ /**
+ * The servicesRegistry provided at creation.
+ */
+ private ServicesRegistry servicesRegistry;
+
+ /**
+ * The raw model stored in the SashProvider.
+ */
+ private PapyrusTableInstance rawModel;
+
+ /**
+ *
+ * Constructor.
+ */
+ public NattableEditorModel(Object pageIdentifier, ServicesRegistry servicesRegistry) {
+ rawModel = (PapyrusTableInstance)pageIdentifier;
+ this.servicesRegistry = servicesRegistry;
+ }
+
+ /**
+ * Create the IEditor for the diagram.
+ *
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel#createIEditorPart()
+ * @return
+ * @throws PartInitException
+ *
+ */
+ public IEditorPart createIEditorPart() throws PartInitException {
+ try {
+
+ Constructor<?> c = getDiagramClass().getConstructor(ServicesRegistry.class, PapyrusTableInstance.class);
+ IEditorPart newEditor = (IEditorPart)c.newInstance(servicesRegistry, rawModel);
+ // IEditorPart newEditor = new DefaultNattableEditor(getServiceRegistry(), rawModel);
+ return newEditor;
+ } catch (Exception e) {
+ // Lets propagate. This is an implementation problem that should be solved by
+ // programmer.
+ throw new PartInitException("Can't create TextEditor", e); //$NON-NLS-1$
+ }
+
+ }
+
+ /**
+ * Get the action bar requested by the Editor.
+ *
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel#getActionBarContributor()
+ * @return
+ *
+ */
+ public EditorActionBarContributor getActionBarContributor() {
+
+ String actionBarId = editorDescriptor.getActionBarContributorId();
+
+ // Do nothing if no EditorActionBarContributor is specify.
+ if(actionBarId == null || actionBarId.length() == 0) {
+ return null;
+ }
+
+ // Try to get it.
+
+ // Get ServiceRegistry
+ // ServicesRegistry serviceRegistry = getServicesRegistry();
+ ActionBarContributorRegistry registry;
+ try {
+ registry = servicesRegistry.getService(ActionBarContributorRegistry.class);
+ } catch (ServiceException e) {
+ // Service not found
+ Activator.log.error(e);
+ return null;
+ }
+
+ try {
+ return registry.getActionBarContributor(actionBarId);
+ } catch (BackboneException e) {
+ // TODO Log the error and throw an exception instead
+ Activator.log.error(e);
+ return null;
+ }
+ }
+
+ /**
+ * Get the underlying RawModel. Return the Diagram.
+ *
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getRawModel()
+ * @return
+ *
+ */
+ public Object getRawModel() {
+ return rawModel;
+ }
+
+ /**
+ * Get the icon to be shown by Tabs
+ *
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getTabIcon()
+ * @return
+ *
+ */
+ public Image getTabIcon() {
+ ImageDescriptor imageDescriptor = getEditorDescriptor().getIcon();
+ if(imageDescriptor == null) {
+ return null;
+ }
+
+ return imageDescriptor.createImage();
+ }
+
+ /**
+ * Get the title of the Diagram.
+ *
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getTabTitle()
+ * @return
+ *
+ */
+ public String getTabTitle() {
+ return rawModel.getName();
+ }
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/factory/PapyrusCommandFactory.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/factory/PapyrusCommandFactory.java
new file mode 100644
index 00000000000..27f1c609f39
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/factory/PapyrusCommandFactory.java
@@ -0,0 +1,312 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.factory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.IdentityCommand;
+import org.eclipse.emf.common.command.UnexecutableCommand;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.infra.browser.custom.AttributeView;
+import org.eclipse.emf.facet.infra.browser.custom.CustomViewFeature;
+import org.eclipse.emf.facet.infra.browser.custom.MetamodelView;
+import org.eclipse.emf.facet.infra.browser.custom.ReferenceView;
+import org.eclipse.emf.facet.infra.browser.custom.StaticFeatureValue;
+import org.eclipse.emf.facet.infra.browser.custom.TypeView;
+import org.eclipse.emf.facet.infra.facet.Facet;
+import org.eclipse.emf.facet.widgets.celleditors.internal.DefaultCommandFactory;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.Column;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.Row;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableInstance;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableinstancePackage;
+import org.eclipse.emf.facet.widgets.nattable.internal.painter.Customization;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+
+/**
+ *
+ * This factory is used by the Papyrus Table when the editing domain is an instanceof TransactionalEditingDomain
+ *
+ */
+public class PapyrusCommandFactory extends DefaultCommandFactory {
+
+ /**
+ *
+ * @see org.eclipse.emf.facet.widgets.celleditors.internal.DefaultCommandFactory#handles(org.eclipse.emf.edit.domain.EditingDomain)
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean handles(final EditingDomain editingDomain) {
+ return editingDomain instanceof TransactionalEditingDomain;
+ }
+
+ /**
+ *
+ * @param owner
+ * the owner object
+ * @param feature
+ * the feature to edit
+ * @return <code>true</code> if object is an {@link EObject} and feature a {@link EStructuralFeature}
+ */
+ protected boolean testArgs(final Object owner, final Object feature) {
+ if(feature != null) {
+ if(feature instanceof EStructuralFeature) {
+ /*
+ * The ElementEditService can be used for UML Element and for view and for... others things,
+ * but it doesn't work correctly with the nattable widget elements
+ */
+ if(isEMFFacetElement(owner)) {
+ return false;
+ } else if(owner instanceof EObject) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * The ElementEditService can be used for UML Element and for view and for... others things, but it doesn't work correctly with the nattable
+ * widget
+ * elements
+ *
+ * @param owner
+ * an object
+ * @return
+ * <code>true</code> if the object is an EMF-Facet object
+ */
+ private boolean isEMFFacetElement(final Object owner) {
+ if(owner instanceof TableInstance) {
+ return true;
+ } else if(owner instanceof MetamodelView) {
+ return true;
+ } else if(owner instanceof Row) {
+ return true;
+ } else if(owner instanceof Column) {
+ return true;
+ } else if(owner instanceof Facet) {
+ return true;
+ } else if(owner instanceof Customization) {
+ return true;
+ } else if(owner instanceof TypeView) {
+ return true;
+ } else if(owner instanceof ReferenceView) {
+ return true;
+ } else if(owner instanceof AttributeView) {
+ return true;
+ } else if(owner instanceof CustomViewFeature) {
+ return true;
+ } else if(owner instanceof StaticFeatureValue) {
+ return true;
+ }
+ //we add this test,because, it is possible that we forget some emf-facet elements
+ final String className = owner.getClass().getCanonicalName();
+ if(className.contains("org.eclipse.emf.facet")) { //$NON-NLS-1$
+ //TODO : write a factory for the new metamodel
+ // String message = "the type " + className + " should be included in the test"; //$NON-NLS-1$ //$NON-NLS-2$
+ // Activator.getDefault().log.info(message);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.facet.widgets.celleditors.internal.DefaultCommandFactory#createAddCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.lang.Object, java.lang.Object, java.lang.Object)
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public Command createAddCommand(final EditingDomain editingDomain, final Object owner, final Object feature, final Object value) {
+ //the ElementEditService doesn't work correctly with nattable elements, so we test the edited element
+ if(isEMFFacetElement(owner)) {
+ return super.createAddCommand(editingDomain, owner, feature, value);
+ }
+ final IElementEditService elementEditService = ElementEditServiceUtils.getCommandProvider(owner);
+ if(testArgs(owner, feature) && (elementEditService != null)) {
+ final EObject current = (EObject)owner;
+ final Object values = current.eGet((EStructuralFeature)feature);
+ if(values instanceof List<?>) {
+ final ArrayList<Object> newList = new ArrayList<Object>();
+ newList.addAll((List<?>)values);
+ newList.add(value);
+ final SetRequest request = new SetRequest((TransactionalEditingDomain)editingDomain, current, (EStructuralFeature)feature, newList);
+ final ICommand command = elementEditService.getEditCommand(request);
+ if(command.canExecute()) {
+ return new GMFtoEMFCommandWrapper(command);
+ }
+ }
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.facet.widgets.celleditors.internal.DefaultCommandFactory#createDeleteCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.lang.Object)
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public Command createDeleteCommand(final EditingDomain editingDomain, final Object elementToDestroy) {
+ //the ElementEditService doesn't work correctly with nattable elements, so we test the edited element
+ if(isEMFFacetElement(elementToDestroy)) {
+ return super.createDeleteCommand(editingDomain, elementToDestroy);
+ }
+ final IElementEditService elementEditService = ElementEditServiceUtils.getCommandProvider(elementToDestroy);
+ if(testArgs(elementToDestroy, null) && (elementEditService != null)) {
+ final DestroyElementRequest request = new DestroyElementRequest((TransactionalEditingDomain)editingDomain, (EObject)elementToDestroy, false);
+ final ICommand command = elementEditService.getEditCommand(request);
+ if(command.canExecute()) {
+ return new GMFtoEMFCommandWrapper(command);
+ }
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.facet.widgets.celleditors.internal.DefaultCommandFactory#createMoveCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.lang.Object, java.lang.Object, java.lang.Object, int)
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public Command createMoveCommand(final EditingDomain editingDomain, final Object owner, final Object feature, final Object value, final int index) {
+ //the ElementEditService doesn't work correctly with nattable elements, so we test the edited element
+ if(isEMFFacetElement(owner)) {
+ return super.createMoveCommand(editingDomain, owner, feature, value, index);
+ }
+
+ final IElementEditService elementEditService = ElementEditServiceUtils.getCommandProvider(owner);
+ if(testArgs(owner, feature) && (elementEditService != null)) {
+ final EObject current = (EObject)owner;
+ final Object values = current.eGet((EStructuralFeature)feature);
+ if(values instanceof List<?>) {
+ final ArrayList<Object> newList = new ArrayList<Object>();
+ newList.addAll((List<?>)values);
+ final int currentIndex = ((List<?>)values).indexOf(value);
+ newList.remove(currentIndex);
+ newList.add(index, value);
+ final SetRequest request = new SetRequest((TransactionalEditingDomain)editingDomain, (EObject)owner, (EStructuralFeature)feature, newList);
+ final ICommand command = elementEditService.getEditCommand(request);
+ if(command.canExecute()) {
+ return new GMFtoEMFCommandWrapper(command);
+ }
+ }
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.facet.widgets.celleditors.internal.DefaultCommandFactory#createRemoveCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.lang.Object, java.lang.Object, java.lang.Object)
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public Command createRemoveCommand(final EditingDomain editingDomain, final Object owner, final Object feature, final Object value) {
+ //the ElementEditService doesn't work correctly with nattable elements, so we test the edited element
+
+ //cf bug 396621: [Table] The default columns are not visible just after the creation of the table (when the created table is empty)
+ if(owner instanceof TableInstance && feature==TableinstancePackage.eINSTANCE.getTableInstance_Columns()){
+ if(((TableInstance)owner).getRows().size()==0){
+ return IdentityCommand.INSTANCE;//we can' return a null command!
+ }
+ }
+
+
+ if(isEMFFacetElement(owner)) {
+ return super.createRemoveCommand(editingDomain, owner, feature, value);
+ }
+ final IElementEditService elementEditService = ElementEditServiceUtils.getCommandProvider(owner);
+ if(testArgs(owner, feature) && (elementEditService != null)) {
+ final DestroyReferenceRequest request = new DestroyReferenceRequest((TransactionalEditingDomain)editingDomain, (EObject)owner, (EReference)feature, (EObject)value, false);
+ final ICommand command = elementEditService.getEditCommand(request);
+ if(command.canExecute()) {
+ return new GMFtoEMFCommandWrapper(command);
+ }
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.facet.widgets.celleditors.internal.DefaultCommandFactory#createSetCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.lang.Object, java.lang.Object, java.lang.Object)
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public Command createSetCommand(final EditingDomain editingDomain, final Object owner, final Object feature, final Object value) {
+ //the ElementEditService doesn't work correctly with nattable elements, so we test the edited element
+ if(isEMFFacetElement(owner)) {
+ return super.createSetCommand(editingDomain, owner, feature, value);
+ }
+ final IElementEditService elementEditService = ElementEditServiceUtils.getCommandProvider(owner);
+ if(testArgs(owner, feature) && (elementEditService != null)) {
+ final SetRequest request = new SetRequest((TransactionalEditingDomain)editingDomain, (EObject)owner, (EStructuralFeature)feature, value);
+ final ICommand command = elementEditService.getEditCommand(request);
+ if(command.canExecute()) {
+ return new GMFtoEMFCommandWrapper(command);
+ }
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.facet.widgets.celleditors.internal.DefaultCommandFactory#createSetCommand(org.eclipse.emf.edit.domain.EditingDomain,
+ * java.lang.Object, java.lang.Object, java.lang.Object, int)
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public Command createSetCommand(final EditingDomain editingDomain, final Object owner, final Object feature, final Object value, final int index) {
+ //the ElementEditService doesn't work correctly with nattable elements, so we test the edited element
+ if(isEMFFacetElement(owner)) {
+ return super.createSetCommand(null, owner, feature, value, index);
+ }
+ final IElementEditService elementEditService = ElementEditServiceUtils.getCommandProvider(owner);
+ if(testArgs(owner, feature) && (elementEditService != null)) {
+ final EObject current = (EObject)owner;
+ final Object values = current.eGet((EStructuralFeature)feature);
+ if(values instanceof List<?>) {
+ final ArrayList<Object> newList = new ArrayList<Object>();
+ newList.addAll((List<?>)values);
+ newList.set(index, value);
+ final SetRequest request = new SetRequest((TransactionalEditingDomain)editingDomain, (EObject)owner, (EStructuralFeature)feature, newList);
+ final ICommand command = elementEditService.getEditCommand(request);
+ if(command.canExecute()) {
+ return new GMFtoEMFCommandWrapper(command);
+ }
+ }
+ }
+ return UnexecutableCommand.INSTANCE;
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/handlers/AbstractCreateNattableEditorCommand.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/handlers/AbstractCreateNattableEditorCommand.java
new file mode 100644
index 00000000000..33c7822d58c
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/handlers/AbstractCreateNattableEditorCommand.java
@@ -0,0 +1,516 @@
+/*****************************************************************************
+ * Copyright (c) 2011 LIFL & CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation
+ * Vincent Lorenzo (CEA-LIST) vincent.lorenzo@cea.fr
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.table.common.handlers;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.facet.infra.facet.Facet;
+import org.eclipse.emf.facet.infra.facet.FacetAttribute;
+import org.eclipse.emf.facet.infra.facet.FacetReference;
+import org.eclipse.emf.facet.infra.query.ModelQuery;
+import org.eclipse.emf.facet.infra.query.ModelQuerySet;
+import org.eclipse.emf.facet.infra.query.core.AbstractModelQuery;
+import org.eclipse.emf.facet.infra.query.core.ModelQuerySetCatalog;
+import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryException;
+import org.eclipse.emf.facet.infra.query.runtime.ModelQueryResult;
+import org.eclipse.emf.facet.widgets.nattable.NatTableWidgetUtils;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.AttributeColumn;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.Column;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.FacetAttributeColumn;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.FacetReferenceColumn;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.FeatureColumn;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.ReferenceColumn;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableinstanceFactory;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.TableInstance2;
+import org.eclipse.emf.facet.widgets.nattable.internal.NatTableWidgetInternalUtils;
+import org.eclipse.emf.facet.widgets.nattable.tableconfiguration.TableConfiguration;
+import org.eclipse.emf.facet.widgets.nattable.tableconfiguration2.TableConfiguration2;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.AbstractEMFOperation;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.commands.CheckedOperationHistory;
+import org.eclipse.papyrus.infra.core.resource.AbstractBaseModel;
+import org.eclipse.papyrus.infra.core.resource.IModel;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.resource.NotFoundException;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForHandlers;
+import org.eclipse.papyrus.infra.table.common.Activator;
+import org.eclipse.papyrus.infra.table.common.dialog.TwoInputDialog;
+import org.eclipse.papyrus.infra.table.common.messages.Messages;
+import org.eclipse.papyrus.infra.table.common.modelresource.EMFFacetNattableModel;
+import org.eclipse.papyrus.infra.table.common.modelresource.PapyrusNattableModel;
+import org.eclipse.papyrus.infra.table.common.util.QueryRepresentation;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrustableinstanceFactory;
+import org.eclipse.papyrus.infra.table.papyrustableconfiguration.metamodel.PapyrusTableConfiguration.PapyrusTableConfiguration;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.Element;
+
+
+/**
+ * @author dumoulin
+ *
+ */
+public abstract class AbstractCreateNattableEditorCommand extends AbstractHandler {
+
+
+ /** the default name for the table */
+ private final String defaultName;
+
+ /** the default description for the table */
+ private final String defaultDescription = "Table Description"; //$NON-NLS-1$
+
+ /** the editor type */
+ private final String editorType;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param editorType
+ * the type of the editor
+ * @param defaultName
+ * the default name for this editor
+ */
+ public AbstractCreateNattableEditorCommand(final String editorType, final String defaultName) {
+ Assert.isNotNull(editorType != null);
+ this.editorType = editorType;
+ this.defaultName = defaultName;
+ }
+
+ /**
+ * Should be overridden in order to restrict creation
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ *
+ * @return
+ */
+ @Override
+ public boolean isEnabled() {
+ EObject context = getTableContext();
+ return context instanceof Element;
+ }
+
+ /**
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ try {
+
+ runAsTransaction(event);
+ } catch (ServiceException e) {
+ throw new ExecutionException("Can't create TableEditor", e); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ /**
+ * Run the command as a transaction.
+ * Create a Transaction and delegate the command to {@link #doExecute(ServicesRegistry)}.
+ *
+ * @throws ServiceException
+ *
+ */
+ public void runAsTransaction(ExecutionEvent event) throws ServiceException {
+ //default Value
+ final String name;
+ final String description;
+ TwoInputDialog dialog = new TwoInputDialog(Display.getCurrent().getActiveShell(), Messages.AbstractCreateNattableEditorCommand_CreateNewTableDialogTitle, Messages.AbstractCreateNattableEditorCommand_CreateNewTableDialog_TableNameMessage, Messages.AbstractCreateNattableEditorCommand_CreateNewTableDialog_TableDescriptionMessage, defaultName, defaultDescription, null);
+ if(dialog.open() == Dialog.OK) {
+ //get the name and the description for the table
+ name = dialog.getValue();
+ description = dialog.getValue_2();
+
+ final ServicesRegistry serviceRegistry = ServiceUtilsForHandlers.getInstance().getServiceRegistry(event);
+ TransactionalEditingDomain domain = ServiceUtils.getInstance().getTransactionalEditingDomain(serviceRegistry);
+
+ //Create the transactional command
+ AbstractEMFOperation command = new AbstractEMFOperation(domain, "Create Table Editor") { //$NON-NLS-1$
+
+ @Override
+ protected IStatus doExecute(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ try {
+ AbstractCreateNattableEditorCommand.this.doExecute(serviceRegistry, name, description);
+ } catch (ServiceException e) {
+ e.printStackTrace();
+ return Status.CANCEL_STATUS;
+ } catch (NotFoundException e) {
+ e.printStackTrace();
+ return Status.CANCEL_STATUS;
+ }
+ return Status.OK_STATUS;
+ }
+ };
+
+ // Execute the command
+ try {
+ CheckedOperationHistory.getInstance().execute(command, new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ Activator.log.error("Can't create Table Editor", e); //$NON-NLS-1$
+ }
+
+ }
+ }
+
+ /**
+ * Do the execution of the command.
+ *
+ * @param serviceRegistry
+ * @throws ServiceException
+ * @throws NotFoundException
+ */
+ public void doExecute(final ServicesRegistry serviceRegistry, String name, String description) throws ServiceException, NotFoundException {
+
+ Object editorModel = createEditorModel(serviceRegistry, name, description);
+ // Get the mngr allowing to add/open new editor.
+ IPageManager pageMngr = ServiceUtils.getInstance().getIPageManager(serviceRegistry);
+ // add the new editor model to the sash.
+ pageMngr.openPage(editorModel);
+
+ }
+
+ /**
+ * Create a model identifying the editor. This model will be saved with the sash
+ *
+ * @return
+ * @throws ServiceException
+ * @throws NotFoundException
+ * The model where to save the TableInstance is not found.
+ */
+ protected Object createEditorModel(final ServicesRegistry serviceRegistry, String name, String description) throws ServiceException, NotFoundException {
+ PapyrusTableInstance papyrusTable = PapyrustableinstanceFactory.eINSTANCE.createPapyrusTableInstance();
+ papyrusTable.setName(name);
+ papyrusTable.setType(editorType);
+ PapyrusNattableModel papyrusModel = (PapyrusNattableModel)ServiceUtils.getInstance().getModelSet(serviceRegistry).getModelChecked(PapyrusNattableModel.MODEL_ID);
+ papyrusModel.addPapyrusTableInstance(papyrusTable);
+
+ setFillingQueries(papyrusTable); //should be done before the TableInstance creation
+ setSynchronization(papyrusTable); //should be done before the TableInstance creation
+ EObject context = getTableContext();
+ Assert.isNotNull(context);
+ List<EObject> elements = getInitialElement(papyrusTable, context);
+
+ TableInstance2 tableInstance = NatTableWidgetUtils.createTableInstance(elements, defaultDescription, getTableConfiguration2(), getTableContext(), null);
+ tableInstance.setDescription(description);
+
+ final PapyrusTableConfiguration papyrusConfiguration = getPapyrusTableConfiguration();
+ if(papyrusConfiguration != null) {
+ papyrusTable.setPastedElementContainmentFeature(papyrusConfiguration.getPastedElementContainmentFeature());
+ papyrusTable.setPastedElementId(papyrusConfiguration.getPastedElementId());
+
+ // Add default column not already added.
+ List<EStructuralFeature> defaultFeatures = papyrusConfiguration.getDefaultColumns();
+ for(Column column : tableInstance.getColumns()) {
+ if(column instanceof FeatureColumn) {
+ defaultFeatures.remove(((FeatureColumn)column).getFeature());
+ }
+ }
+ for(final EStructuralFeature feature : defaultFeatures) {
+ if(feature instanceof FacetAttribute) {
+ FacetAttributeColumn col = TableinstanceFactory.eINSTANCE.createFacetAttributeColumn();
+ col.setAttribute((FacetAttribute)feature);
+ tableInstance.getColumns().add(col);
+ tableInstance.getFacets2().add((Facet)feature.eContainer());
+ } else if(feature instanceof FacetReference) {
+ FacetReferenceColumn col = TableinstanceFactory.eINSTANCE.createFacetReferenceColumn();
+ col.setReference((FacetReference)feature);
+ tableInstance.getColumns().add(col);
+ tableInstance.getFacets2().add((Facet)feature.eContainer());
+ } else if(feature instanceof EAttribute) {
+ AttributeColumn col = TableinstanceFactory.eINSTANCE.createAttributeColumn();
+ col.setAttribute((EAttribute)feature);
+ tableInstance.getColumns().add(col);
+ } else if(feature instanceof EReference) {
+ ReferenceColumn col = TableinstanceFactory.eINSTANCE.createReferenceColumn();
+ col.setReference((EReference)feature);
+ tableInstance.getColumns().add(col);
+ }
+
+ }
+ }
+
+ // Save the model in the associated resource
+ EMFFacetNattableModel model = (EMFFacetNattableModel)ServiceUtils.getInstance().getModelSet(serviceRegistry).getModelChecked(EMFFacetNattableModel.MODEL_ID);
+ model.addTableInstance(tableInstance);
+ papyrusTable.setTable(tableInstance);
+
+ tableInstance.setContext(context);
+
+ setHiddenColumns(papyrusTable);
+ return papyrusTable;
+ }
+
+ /**
+ *
+ * @param papyrusTable
+ * the papyrus table
+ * @param context
+ * @return the list of the initial element for the table
+ */
+ private List<EObject> getInitialElement(PapyrusTableInstance papyrusTable, EObject context) {
+ if(papyrusTable.isIsSynchronized() && !papyrusTable.getFillingQueries().isEmpty()) {
+ List<EObject> elements = new ArrayList<EObject>();
+
+ for(ModelQuery query : papyrusTable.getFillingQueries()) {
+ ModelQuerySetCatalog catalog = ModelQuerySetCatalog.getSingleton();
+ AbstractModelQuery impl = null;
+ try {
+ impl = catalog.getModelQueryImpl(query);
+ } catch (ModelQueryException e) {
+ Activator.getDefault().log.error(e);
+ }
+ if(impl != null) {
+ ModelQueryResult result = impl.evaluate(context);
+ Object value = result.getValue();
+ if(value instanceof Collection<?>) {
+ // the build the list of the elements to add in the
+ // table
+ for(Object currentObject : (Collection<?>)value) {
+ if(currentObject instanceof EObject) {
+ elements.add((EObject)currentObject);
+ }
+ }
+
+ }
+ }
+ }
+ return elements;
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * Allows to hide the columns created by default
+ *
+ * @param papyrusTable
+ */
+ private void setHiddenColumns(final PapyrusTableInstance papyrusTable) {
+ List<String> hiddenColumnsName = getHiddenColumnName();
+ if(!hiddenColumnsName.isEmpty()) {
+ for(Column column : papyrusTable.getTable().getColumns()) {
+ String name = NatTableWidgetInternalUtils.getColumnName(column);
+ if(hiddenColumnsName.contains(name)) {
+ column.setIsHidden(true);
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the list of the columns to hide. Currently, the name can be :
+ * <ul>
+ * <li>[Label]</li>
+ * <li>[Metaclass]</li>
+ * <li>/eContainer</li>
+ * </ul>
+ *
+ * @return
+ * the list of the columns to hide
+ */
+ protected List<String> getHiddenColumnName() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Returns the table configuration for the table
+ *
+ * {@link Deprecated} // use getTableConfiguration2
+ *
+ * @return
+ * the table configuration of the table
+ * FIXME should be removed in Papyrus 0.9.0
+ *
+ */
+ @Deprecated
+ protected TableConfiguration getTableConfiguration() {
+ return getTableConfiguration2();
+ }
+
+ /**
+ * Returns the table configuration for the table
+ *
+ * @return
+ * the table configuration of the table
+ *
+ */
+ protected TableConfiguration2 getTableConfiguration2() {
+ final PapyrusTableConfiguration papyrusConfig = getPapyrusTableConfiguration();
+ if(papyrusConfig != null) {
+ return papyrusConfig.getTableConfiguration();
+ }
+ return null;
+ }
+
+ protected PapyrusTableConfiguration getPapyrusTableConfiguration() {
+ return null;
+ }
+
+ /**
+ * Set the table synchronization to <code>true</code> if there is filling queries, to <code>false</code> if not
+ *
+ * @param papyrusTable
+ * the papyrusTable
+ */
+ protected void setSynchronization(final PapyrusTableInstance papyrusTable) {
+ papyrusTable.setIsSynchronized(papyrusTable.getFillingQueries().size() != 0);
+ }
+
+ /**
+ * Set the queries used to fill Papyrus
+ *
+ * @param papyrusTable
+ * the {@link PapyrusTableInstance} to fill with queries
+ */
+ protected void setFillingQueries(final PapyrusTableInstance papyrusTable) {
+ ModelQuerySetCatalog catalog = ModelQuerySetCatalog.getSingleton();
+ for(QueryRepresentation rep : getQueryRepresentations()) {
+ ModelQuerySet querySet = catalog.getModelQuerySet(rep.getQuerySetName());
+ if(querySet != null) {
+ ModelQuery query = querySet.getQuery(rep.getQueryName());
+ if(query != null) {
+ papyrusTable.getFillingQueries().add(query);
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the context used to create the table
+ *
+ * @return
+ * the context used to create the table or <code>null</code> if not found
+ * @throws ServiceException
+ */
+ //FIXME: This method introduces a dependency to UML. Use the semantic service instead.
+ protected EObject getTableContext() {
+ List<EObject> selection = getSelection();
+
+ if(!selection.isEmpty()) {
+ return selection.get(0);
+ }
+
+ //we shouldn't try to find a valid context when the selection is not valid!
+ ModelSet modelSet = null;
+ ServicesRegistry serviceRegistry;
+ try {
+ serviceRegistry = ServiceUtilsForActionHandlers.getInstance().getServiceRegistry();
+ modelSet = ServiceUtils.getInstance().getModelSet(serviceRegistry);
+ } catch (NullPointerException npe) {
+ //
+ } catch (ServiceException exception) {
+
+ }
+
+
+ if(modelSet != null) {
+ IModel model = modelSet.getModel(org.eclipse.papyrus.uml.tools.model.UmlModel.MODEL_ID);
+
+ if(model instanceof AbstractBaseModel) {
+ return getRootElement(((AbstractBaseModel)model).getResource());
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @return
+ */
+ protected List<EObject> getSelection() {
+ List<EObject> selectedElements = new ArrayList<EObject>();
+ final IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if(ww != null) {
+ ISelection selection = ww.getSelectionService().getSelection();
+ if(selection instanceof IStructuredSelection) {
+
+ IStructuredSelection structuredSelection = (IStructuredSelection)selection;
+
+ Iterator<?> it = structuredSelection.iterator();
+ while(it.hasNext()) {
+ Object object = it.next();
+ if(object instanceof IAdaptable) {
+ EObject currentEObject = (EObject)((IAdaptable)object).getAdapter(EObject.class);
+
+ if(currentEObject != null) {
+ selectedElements.add(currentEObject);
+ }
+ }
+
+ }
+ }
+ }
+ return selectedElements;
+ }
+
+ /**
+ * Get the root element associated with canvas.
+ */
+ protected EObject getRootElement(final Resource modelResource) {
+ EObject rootElement = null;
+ if(modelResource != null && modelResource.getContents() != null && modelResource.getContents().size() > 0) {
+ Object root = modelResource.getContents().get(0);
+ if(root instanceof EObject) {
+ rootElement = (EObject)root;
+ }
+ }
+ return rootElement;
+ }
+
+ /**
+ * This method should be overridden by the user, if he wants provide filling queries
+ * The list of the queries used to fill the table, identified by their querySet name and query name.
+ *
+ *
+ * @return
+ * The list of the queries used to fill the table, identified by their querySet name and query name.
+ *
+ */
+ protected List<QueryRepresentation> getQueryRepresentations() {
+ List<QueryRepresentation> list = new ArrayList<QueryRepresentation>();
+ return list;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/IPapyrusNatTableWidget.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/IPapyrusNatTableWidget.java
new file mode 100644
index 00000000000..1edf41bb452
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/IPapyrusNatTableWidget.java
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.internal;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.widgets.nattable.INatTableWidget;
+import org.eclipse.ui.services.IDisposable;
+
+/**
+ *
+ * This interface is used to add some useful method to INatTableWidget
+ *
+ *
+ */
+@Deprecated
+/**
+ * I think this interface is deprecated, because the 2 methods provided by this interfaces are obsolete.
+ * Now we use TriggerListener in the table, so the command for the synchronization are executed in a best way
+ * @author VL222926
+ *
+ */
+public interface IPapyrusNatTableWidget extends INatTableWidget , IDisposable{
+
+ /**
+ * This method allow to add elements in the table without execute the command in the command stack
+ * @param elementsToAdd
+ * the list of the elements to add
+ */
+ @Deprecated
+ public void addRowsOutOfCommandStack(List<EObject> elementsToAdd);
+
+ /**
+ * This method allow to remove elements from the table without execute the command in the command stack
+ * @param elementsToDelete
+ * the list of the element to delete
+ */
+ @Deprecated
+ public void removeRowsOutOfCommandStack(List<EObject> elementsToDelete);
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/NatTableEditor.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/NatTableEditor.java
new file mode 100644
index 00000000000..ec2093aa269
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/NatTableEditor.java
@@ -0,0 +1,460 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Mia-Software.
+ * 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:
+ * Nicolas Bros (Mia-Software) - Bug 331203 - table model editor - initial API and implementation
+ * Nicolas Guyomar (Mia-Software) - Bug 331442 - To be able to add and remove lines (model elements) from the table
+ * Nicolas Bros (Mia-Software) - Bug 332226 - To be able to create or delete model element from the table
+ * Nicolas Guyomar (Mia-Software) - Bug 332226 - To be able to create or delete model element from the table
+ * Nicolas Bros (Mia-Software) - Bug 331900 - customizable NatTable
+ * Nicolas Guyomar (Mia-Software) - Bug 332924 - To be able to save the table
+ * Nicolas Guyomar (Mia-Software) - Bug 332998 - To be able to add a column and fill it with the result of a query
+ * Gregoire Dupe (Mia-Software) - Bug 332998 - To be able to add a column and fill it with the result of a query
+ * Nicolas Guyomar (Mia-Software) - Bug 333015 - To be able to hide columns
+ * Nicolas Guyomar (Mia-Software) - Bug 333029 - To be able to save the size of the lines and the columns
+ * Nicolas Guyomar (Mia-Software) - Bug 335154 - Sort Column By Type : Cannot modify resource set without a write transaction
+ * Nicolas Guyomar (Mia-Software) - Bug 335020 - Nattable widget should use the Eclipse framework
+ *******************************************************************************/
+package org.eclipse.papyrus.infra.table.common.internal;
+
+import java.util.EventObject;
+import java.util.HashMap;
+
+import org.eclipse.core.databinding.conversion.IConverter;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.BasicCommandStack;
+import org.eclipse.emf.common.command.CommandStackListener;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.databinding.EObjectObservableValue;
+import org.eclipse.emf.ecore.EClass;
+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.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.facet.widgets.nattable.INatTableWidget;
+import org.eclipse.emf.facet.widgets.nattable.INatTableWidgetProvider;
+import org.eclipse.emf.facet.widgets.nattable.IWorkbenchPartProvider;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableInstance;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableinstancePackage;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.TableInstance2;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.infra.emf.databinding.EMFObservableValue;
+import org.eclipse.papyrus.infra.table.common.messages.Messages;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrustableinstancePackage;
+import org.eclipse.papyrus.infra.widgets.editors.BooleanRadio;
+import org.eclipse.papyrus.infra.widgets.editors.StringEditor;
+import org.eclipse.papyrus.infra.widgets.editors.StringLabel;
+import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.EditorPart;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+/**
+ * Comes from org.eclipse.emf.facet.widget.nattable.workbench.
+ *
+ * This class should not be used by others plugins
+ * TODO Should be deleted or merge with an other classe
+ */
+public class NatTableEditor extends EditorPart implements ISelectionProvider, IEditingDomainProvider, IWorkbenchPartProvider {
+
+ public static final String ID = "org.eclipse.emf.facet.widgets.nattable.workbench.editor.NatTableEditor"; //$NON-NLS-1$
+
+ private TableEditorInput tableEditorInput;
+
+ protected INatTableWidget natTableWidget;
+
+ private EditingDomain editingDomain;
+
+ private MenuManager menuMgr;
+
+ private StringLabel contextLabel;
+
+ private final CommandStackListener commandListener = new CommandStackListener() {
+
+ public void commandStackChanged(final EventObject event) {
+ Display.getCurrent().asyncExec(new Runnable() {
+
+ public void run() {
+ firePropertyChange(PROP_DIRTY);
+ }
+ });
+ }
+ };
+
+ /**
+ * we listen the context to refresh it in the table if the context change
+ */
+ private final Adapter contextListener = new AdapterImpl() {
+
+ /**
+ *
+ * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
+ *
+ * @param notification
+ */
+ @Override
+ public void notifyChanged(final Notification notification) {
+ NatTableEditor.this.contextLabel.refreshValue();
+ super.notifyChanged(notification);
+ }
+ };
+
+ @SuppressWarnings("rawtypes")
+ // We cannot change the method signature because of the override
+ @Override
+ public Object getAdapter(final Class adapter) {
+ if(adapter == INatTableWidgetProvider.class) {
+ return new INatTableWidgetProvider() {
+
+ public INatTableWidget getNatTableWidget() {
+ return NatTableEditor.this.natTableWidget;
+ }
+ };
+ }
+ if(adapter == PapyrusTableInstance.class) {
+ return this.tableEditorInput.getPapyrusTableInstance();
+ }
+ return null;
+ }
+
+ @Override
+ public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {
+ if(input instanceof TableEditorInput) {
+ this.tableEditorInput = (TableEditorInput)input;
+ this.editingDomain = this.tableEditorInput.getEditingDomain();
+ initializeEditingDomain();
+ setSite(site);
+ setInput(this.tableEditorInput);
+ setPartName(this.tableEditorInput.getName());
+ } else if(input instanceof FileEditorInput) {
+ initializeEditingDomain();
+ FileEditorInput fileEditorInput = (FileEditorInput)input;
+ URI uri = URI.createPlatformResourceURI(fileEditorInput.getFile().getFullPath().toString(), false);
+ if(uri != null) {
+ Resource resource = null;
+ if(getEditingDomain() != null) {
+ resource = getEditingDomain().loadResource(uri.toString());
+ } else {
+ ResourceSet rSet = new ResourceSetImpl();
+ resource = rSet.createResource(uri);
+ }
+ PapyrusTableInstance tableInstance = null;
+ for(EObject eObject : resource.getContents()) {
+ if(eObject instanceof PapyrusTableInstance) {
+ tableInstance = (PapyrusTableInstance)eObject;
+ // One instance of tableInstance per .table file
+ break;
+ }
+ }
+ this.tableEditorInput = new TableEditorInput(tableInstance, getEditingDomain());
+ setSite(site);
+ setInput(this.tableEditorInput);
+ setPartName(fileEditorInput.getName());
+ }
+
+ } else {
+ throw new PartInitException("Input should be of type TableEditorInput or a .table file"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ */
+ @Override
+ public void createPartControl(final Composite parent) {
+ this.menuMgr = new MenuManager("#PopUp", NatTableEditor.ID); //$NON-NLS-1$
+ this.menuMgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+ this.menuMgr.setRemoveAllWhenShown(true);
+
+ final Composite editorComposite = createCompositeCompositeWthTableBorder(parent);
+ // createFirstLine(editorComposite);
+ // createDescription(editorComposite);
+
+ // the composite owning the table
+ final Composite tableComposite = new Composite(editorComposite, SWT.NONE);
+ GridLayout tableCompositeGridLayout = new GridLayout(1, true);
+ tableComposite.setLayout(tableCompositeGridLayout);
+
+ final GridData compositeTableGridLayout = new GridData();
+ compositeTableGridLayout.grabExcessHorizontalSpace = true;
+ compositeTableGridLayout.grabExcessVerticalSpace = true;
+ compositeTableGridLayout.horizontalAlignment = SWT.FILL;
+ compositeTableGridLayout.verticalAlignment = SWT.FILL;
+ tableComposite.setLayoutData(compositeTableGridLayout);
+
+ this.natTableWidget = createNattableWidget(tableComposite, this, this.tableEditorInput.getPapyrusTableInstance().getTable(), this.menuMgr);
+
+ getSite().setSelectionProvider(this);
+ getSite().registerContextMenu(this.menuMgr, this.natTableWidget);
+ }
+
+
+ private INatTableWidget createNattableWidget(final Composite tableComposite, final NatTableEditor natTableEditor, final TableInstance2 table, final MenuManager menuMgr2) {
+ // the nattable widget itself
+ //old instanciation
+ // this.natTableWidget = INatTableWidgetFactory.INSTANCE.createNatTableWidget(tableComposite, this, this.tableEditorInput.getPapyrusTableInstance().getTable(), this.menuMgr);
+ this.natTableWidget = new PapyrusNatTableWidget(tableComposite, natTableEditor, table, this.menuMgr);
+ final GridData tableGridData = new GridData();
+ tableGridData.grabExcessHorizontalSpace = true;
+ tableGridData.grabExcessVerticalSpace = true;
+ tableGridData.horizontalAlignment = SWT.FILL;
+ tableGridData.verticalAlignment = SWT.FILL;
+ this.natTableWidget.getComposite().setLayoutData(tableGridData);
+
+ return this.natTableWidget;
+ }
+
+ private Composite createCompositeCompositeWthTableBorder(final Composite parent) {
+ Composite editorComposite = new Composite(parent, SWT.BORDER);
+ final GridLayout editorGridLayout = new GridLayout(1, true);
+ editorGridLayout.marginHeight = 0;
+ editorGridLayout.marginWidth = 0;
+
+ GridData data = new GridData();
+ data.grabExcessHorizontalSpace = true;
+ data.horizontalAlignment = SWT.FILL;
+ editorComposite.setLayoutData(data);
+ editorComposite.setLayout(editorGridLayout);
+ return editorComposite;
+ }
+
+ /**
+ *
+ * @param parent
+ * the parent composite
+ */
+ protected void createFirstLine(final Composite parent) {
+
+ final TableInstance table = this.tableEditorInput.getPapyrusTableInstance().getTable();
+ Composite firstLineComposite = new Composite(parent, SWT.NONE);
+ final GridLayout smallGridLayout = new GridLayout(2, true);
+ smallGridLayout.marginHeight = 0;
+ smallGridLayout.marginWidth = 0;
+ smallGridLayout.marginLeft = 0;
+ smallGridLayout.marginRight = 0;
+
+ firstLineComposite.setLayout(smallGridLayout);
+ GridData lineData = new GridData();
+ lineData.horizontalSpan = 1;
+ lineData.horizontalAlignment = SWT.FILL;
+ firstLineComposite.setLayoutData(lineData);
+
+ //we display the context of the table
+ this.contextLabel = new StringLabel(firstLineComposite, SWT.LEFT);
+ this.contextLabel.setLabel(Messages.NatTableEditor_TableContextLabel);
+ this.contextLabel.setToolTipText(Messages.NatTableEditor_TableContextTollTip);
+
+ //we observe the feature context of the table (and not the name of the context, because the context is not a NamedElement, but an EObject
+ final IObservableValue contextObservable = new EObjectObservableValue(table, TableinstancePackage.eINSTANCE.getTableInstance_Context());
+ table.getContext().eAdapters().add(this.contextListener);
+ /*
+ * we should set the converted before the observable!
+ */
+ this.contextLabel.setConverters(null, new ContextLabelConverter());
+ this.contextLabel.setLabelProvider(new UMLLabelProvider());
+ this.contextLabel.setModelObservable(contextObservable);
+
+ //set the layout for contextLabel
+ GridData contextGridData = new GridData();
+ contextGridData.grabExcessHorizontalSpace = true;
+ contextGridData.horizontalAlignment = SWT.FILL;
+ contextGridData.horizontalSpan = 1;
+ this.contextLabel.setLayoutData(contextGridData);
+
+ BooleanRadio checkbox = new BooleanRadio(firstLineComposite, SWT.NONE, "IsSynchronized :");
+ checkbox.setToolTipText("Indicates if the table is synchronized with queries");
+ final IObservableValue isSynchronizedObservable = new EMFObservableValue(this.tableEditorInput.getPapyrusTableInstance(), PapyrustableinstancePackage.eINSTANCE.getPapyrusTableInstance_IsSynchronized(), getEditingDomain());
+ checkbox.setModelObservable(isSynchronizedObservable);
+
+ GridData checkboxGridData = new GridData();
+ checkboxGridData.grabExcessHorizontalSpace = true;
+ checkboxGridData.horizontalAlignment = SWT.FILL;
+ checkbox.setLayoutData(checkboxGridData);
+
+ }
+
+ protected void createDescription(final Composite parent) {
+ final TableInstance table = this.tableEditorInput.getPapyrusTableInstance().getTable();
+ EClass tableEClass = table.eClass();
+
+ //we display the description of the table
+ final StringEditor descriptionEditor = new StringEditor(parent, SWT.MULTI);
+ descriptionEditor.setLabel(Messages.NatTableEditor_TaleDescriptionLabel);
+ descriptionEditor.setToolTipText(Messages.NatTableEditor_TableDescriptionToolTip);
+
+
+ EStructuralFeature myFeature = tableEClass.getEStructuralFeature(TableinstancePackage.TABLE_INSTANCE__DESCRIPTION);
+ EMFObservableValue observable = new EMFObservableValue(table, myFeature, getEditingDomain());
+ descriptionEditor.setModelObservable(observable);
+
+ //set the layout for the description editor
+ GridData descriptionGridData = new GridData();
+ descriptionGridData.grabExcessHorizontalSpace = true;
+ descriptionGridData.horizontalAlignment = SWT.FILL;
+ descriptionEditor.setLayoutData(descriptionGridData);
+ }
+
+ @Override
+ public void dispose() {
+ if(this.natTableWidget.getTableInstance().getContext() != null) {//can be null when we are destroying the context (and the table!)
+ this.natTableWidget.getTableInstance().getContext().eAdapters().remove(this.contextListener);
+ }
+ editingDomain.getCommandStack().removeCommandStackListener(commandListener);
+ super.dispose();
+ for(final ISelectionChangedListener listener : this.natTableWidget.getSelectionChangedListeners()) {
+ this.natTableWidget.removeSelectionChangedListener(listener);
+ }
+ ((IPapyrusNatTableWidget)this.natTableWidget).dispose();
+ this.natTableWidget = null;
+ }
+
+ @Override
+ public void setFocus() {
+ this.natTableWidget.getComposite().setFocus();
+ }
+
+ @Override
+ public boolean isDirty() {
+ return ((BasicCommandStack)this.editingDomain.getCommandStack()).isSaveNeeded();
+ }
+
+ @Override
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+
+ @Override
+ public void doSave(final IProgressMonitor monitor) {
+ this.natTableWidget.save();
+ firePropertyChange(PROP_DIRTY);
+ }
+
+ @Override
+ public void doSaveAs() {
+ this.natTableWidget.saveAs();
+ firePropertyChange(PROP_DIRTY);
+ }
+
+ public void addSelectionChangedListener(final ISelectionChangedListener listener) {
+ this.natTableWidget.addSelectionChangedListener(listener);
+ }
+
+ public ISelection getSelection() {
+ /*
+ * if nattable has the focus : we retun the nattable selection
+ * if not, we return the papyrus table instance
+ */
+ Control[] children = ((Composite)this.natTableWidget).getChildren();
+ if(children.length != 0) {
+ boolean focus = children[0].isFocusControl();
+ if(focus) {
+ return this.natTableWidget.getSelection();
+ }
+ }
+ return new StructuredSelection(this.tableEditorInput.getPapyrusTableInstance());
+ }
+
+ public EditingDomain getEditingDomain() {
+ return this.editingDomain;
+ }
+
+ public void removeSelectionChangedListener(final ISelectionChangedListener listener) {
+ if(this.natTableWidget != null) {
+ this.natTableWidget.removeSelectionChangedListener(listener);
+ }
+ }
+
+ public void setSelection(final ISelection selection) {
+ this.natTableWidget.setSelection(selection);
+ }
+
+ /**
+ * This sets up the editing domain for the model editor
+ */
+ protected void initializeEditingDomain() {
+ if(this.editingDomain == null) {
+ ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+ BasicCommandStack commandStack = new BasicCommandStack();
+ this.editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
+ }
+ this.editingDomain.getCommandStack().removeCommandStackListener(this.commandListener);
+ this.editingDomain.getCommandStack().addCommandStackListener(this.commandListener);
+ }
+
+ public IWorkbenchPart getPart() {
+ return this;
+ }
+
+ /**
+ * This ocnverter is used by the LabelEditor (used to display the context)
+ */
+ private static class ContextLabelConverter implements IConverter {
+
+ /**
+ *
+ * @see org.eclipse.core.databinding.conversion.IConverter#getToType()
+ *
+ * @return
+ */
+ public Object getToType() {
+ return String.class;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.databinding.conversion.IConverter#getFromType()
+ *
+ * @return
+ */
+ public Object getFromType() {
+ return Object.class;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.databinding.conversion.IConverter#convert(java.lang.Object)
+ *
+ * @param fromObject
+ * @return
+ */
+ public Object convert(final Object fromObject) {
+ if(fromObject instanceof EObject) {
+ return UMLUtil.getQualifiedText((EObject)fromObject);
+ }
+ return ""; //$NON-NLS-1$
+ }
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/PapyrusNatTableWidget.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/PapyrusNatTableWidget.java
new file mode 100644
index 00000000000..eaf569aa2d4
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/PapyrusNatTableWidget.java
@@ -0,0 +1,263 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.internal;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.domain.IEditingDomainProvider;
+import org.eclipse.emf.facet.infra.browser.custom.MetamodelView;
+import org.eclipse.emf.facet.infra.browser.custom.emf.UicustomFactory;
+import org.eclipse.emf.facet.infra.browser.custom.emf.UicustomPackage;
+import org.eclipse.emf.facet.infra.browser.custom.util.UicustomUtil;
+import org.eclipse.emf.facet.widgets.celleditors.ICommandFactoriesRegistry;
+import org.eclipse.emf.facet.widgets.celleditors.ICommandFactory;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.AttributeColumn;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.ReferenceColumn;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.Row;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableInstance;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableinstanceFactory;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableinstancePackage;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.TableInstance2;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.Tableinstance2Package;
+import org.eclipse.emf.facet.widgets.nattable.internal.NatTableWidget;
+import org.eclipse.emf.facet.widgets.nattable.internal.TableInstanceCommandFactory;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ *
+ * The Papyrus Nattable Widget. This widget provides 2 interesting methods for the synchronized table :
+ * <ul>
+ * <li>a method to add rows without execute the command in the command stack</li>
+ * <li>a method to remove rows without execute the command in the command stack</li>
+ * </ul>
+ *
+ * The synchronization of the table is done using listener on the context.
+ * We can't use the commadStack to add/remove element in the table, because in this case we add a command in the CommandStack :
+ * -> 2 Commands for the Undo
+ * -> moreover we add a new command executing the undo (thanks to the listener...)
+ *
+ * Another idea : maybe, we should use something like the ServiceEdit, which provides commands for each action,
+ * to chain the commands to execute.
+ *
+ * -> the new solution : TriggerListener of the ResourceSet!!!
+ *
+ */
+@Deprecated
+/**
+ *
+ * This class is now deprecated thanks to the TriggerListener. Nevertheless, I'm not sure it is useful to delete it for the moment,
+ * but the interface can be deleted!
+ *
+ */
+public class PapyrusNatTableWidget extends NatTableWidget implements IPapyrusNatTableWidget {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parent
+ * @param editingDomainProvider
+ * @param tableInstanceParam
+ * @param menuMgr
+ */
+ public PapyrusNatTableWidget(final Composite parent, final IEditingDomainProvider editingDomainProvider, final TableInstance tableInstanceParam, final MenuManager menuMgr) {
+ super(parent, editingDomainProvider, tableInstanceParam, menuMgr);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.table.common.internal.IPapyrusNatTableWidget#addRowsOutOfCommandStack(java.util.List)
+ *
+ * {@inheritDoc}
+ */
+ @Deprecated
+ public void addRowsOutOfCommandStack(final List<EObject> newElements) {
+ ICommandFactory commandFactory = ICommandFactoriesRegistry.INSTANCE.getCommandFactoryFor(getEditingDomain());
+ CompoundCommand cmCommand = new CompoundCommand();
+ // the EPackage for which the MetamodelView has already been created
+ Set<EPackage> alreadyDone = new HashSet<EPackage>();
+ for(EObject eObject : newElements) {
+ if(!getTableInstance().getElements().contains(eObject)) {
+ Row row = TableinstanceFactory.eINSTANCE.createRow();
+ Command cmd2 = commandFactory.createSetCommand(getEditingDomain(), row, TableinstancePackage.eINSTANCE.getRow_Element(), eObject);
+ cmCommand.append(cmd2);
+ Command cmd1 = commandFactory.createAddCommand(getEditingDomain(), getTableInstance(), TableinstancePackage.eINSTANCE.getTableInstance_Rows(), row);
+ cmCommand.append(cmd1);
+ for(EStructuralFeature eStructuralFeature : eObject.eClass().getEAllStructuralFeatures()) {
+ if(!isColumnAlreadyDeclared(eStructuralFeature)) {
+ if(eStructuralFeature instanceof EReference) {
+ ReferenceColumn referenceColumn = TableinstanceFactory.eINSTANCE.createReferenceColumn();
+ referenceColumn.setReference((EReference)eStructuralFeature);
+ Command cmd = commandFactory.createAddCommand(getEditingDomain(), getTableInstance(), TableinstancePackage.eINSTANCE.getTableInstance_Columns(), referenceColumn);
+ cmCommand.append(cmd);
+
+ } else if(eStructuralFeature instanceof EAttribute) {
+ AttributeColumn attributeColumn = TableinstanceFactory.eINSTANCE.createAttributeColumn();
+ attributeColumn.setAttribute((EAttribute)eStructuralFeature);
+ Command cmd = commandFactory.createAddCommand(getEditingDomain(), getTableInstance(), TableinstancePackage.eINSTANCE.getTableInstance_Columns(), attributeColumn);
+ cmCommand.append(cmd);
+ }
+
+ // we add the local customization file
+ if(getTableInstance() instanceof TableInstance2) {
+ List<MetamodelView> localCustoms = getLocalCustomizations();
+ EObject container = eStructuralFeature.eContainer();
+ if(container != null) {
+ container = container.eContainer();
+ if(container instanceof EPackage) {
+ if(!alreadyDone.contains(container)) {
+ if(UicustomUtil.getMetamodelViewByEPackage(localCustoms, (EPackage)container) == null) {
+ Command cmd = createMetamodelViewCommand(((EPackage)container).getNsURI(), this);
+ if(cmd.canExecute()) {
+ cmCommand.append(cmd);
+ }
+ alreadyDone.add((EPackage)container);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ // getEditingDomain().getCommandStack().execute(cmCommand);
+ cmCommand.execute();
+ if(getTableInstance() instanceof TableInstance2) {
+ TableInstance2 tableInstance2 = (TableInstance2)getTableInstance();
+ try {
+ setFacets(tableInstance2.getFacets2());
+ } catch (CoreException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ loadCustomizations(getTableInstance().getCustomizations());
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.table.common.internal.IPapyrusNatTableWidget#removeRowsOutOfCommandStack(java.util.List)
+ *
+ * {@inheritDoc}
+ */
+ @Deprecated
+ public void removeRowsOutOfCommandStack(final List<EObject> elementsToDelete) {
+ // this.natTable.setRedraw(false);
+ try {
+ ICommandFactory commandFactory = ICommandFactoriesRegistry.INSTANCE.getCommandFactoryFor(getEditingDomain());
+ CompoundCommand compoundCommand = new CompoundCommand();
+ for(int i = 0; i < getTableInstance().getRows().size(); i++) {
+ if(elementsToDelete.contains(getTableInstance().getRows().get(i).getElement())) {
+ Command removeRowCommand = commandFactory.createRemoveCommand(getEditingDomain(), getTableInstance(), TableinstancePackage.eINSTANCE.getTableInstance_Rows(), getTableInstance().getRows().get(i));
+ compoundCommand.append(removeRowCommand);
+ }
+ }
+
+ if(!compoundCommand.isEmpty() && compoundCommand.canExecute()) {
+ // getEditingDomain().getCommandStack().execute(compoundCommand);
+ compoundCommand.execute();
+ }
+ } finally {
+ // this.natTable.setRedraw(true);
+ }
+ }
+
+ private static Command createMetamodelViewCommand(final String nsURI, final PapyrusNatTableWidget natTableWidget) {
+ CompoundCommand compoundCommand = new CompoundCommand();
+ TableInstance tableInstance = natTableWidget.getTableInstance();
+ EditingDomain editingDomain = natTableWidget.getEditingDomain();
+ ICommandFactory commandFactory = natTableWidget.getCommandFactory();
+ MetamodelView newMetamodelView = UicustomFactory.eINSTANCE.createMetamodelView();
+ Command createMetamodelView = commandFactory.createSetCommand(editingDomain, newMetamodelView, UicustomPackage.eINSTANCE.getMetamodelView_MetamodelURI(), nsURI);
+ compoundCommand.append(createMetamodelView);
+
+ if(tableInstance instanceof TableInstance2) {
+ Command setMetamodelViewLocalCmd = commandFactory.createAddCommand(editingDomain, tableInstance, Tableinstance2Package.eINSTANCE.getTableInstance2_LocalCustomizations(), newMetamodelView);
+ compoundCommand.append(setMetamodelViewLocalCmd);
+
+ List<MetamodelView> views = new ArrayList<MetamodelView>();
+ views.addAll(tableInstance.getCustomizations());
+ // we look for the index of the local new custom
+ List<MetamodelView> localCustom = natTableWidget.getLocalCustomizations();
+ int i = 0;
+ for(; i < views.size(); i++) {
+ if(localCustom.contains(views.get(i))) {
+ break;
+ }
+ }
+ views.add(i, newMetamodelView);
+ Command setMetamodelViewCmd = commandFactory.createSetCommand(editingDomain, tableInstance, TableinstancePackage.eINSTANCE.getTableInstance_Customizations(), views);
+ compoundCommand.append(setMetamodelViewCmd);
+
+ } else {
+ // TODO should be removed when all tables will be TableInstance2
+ Command setMetamodelView = commandFactory.createSetCommand(editingDomain, tableInstance, TableinstancePackage.eINSTANCE.getTableInstance_LocalCustomization(), newMetamodelView);
+ compoundCommand.append(setMetamodelView);
+ }
+ return compoundCommand;
+ }
+
+ /**
+ * This method takes a list of {@link EObject} and add it to the widget list
+ * if their are not already in it.
+ *
+ * @param newElements
+ * The list of EObject elements to be added to the table
+ */
+ public void addRows(final List<EObject> newElements) {
+ CompoundCommand addRowCommand = TableInstanceCommandFactory.createAddRowsCommand(newElements, this);
+ //see bug 397849: 397849: [Table]Hidden Facets Columns become visible after drop, creation of paste into the table
+ //we want to avoid that not wanted FacetElement column appears after a drop
+
+// if getTableInstance() instanceof TableInstance2) {
+// TableInstance2 tableInstance2 = (TableInstance2) getTableInstance() ;
+// try {
+// this.facetContext.clear();
+// this.facetContext.addFacets(tableInstance2.getFacets2());
+// Command setFacetsCommand = TableInstanceCommandFactory.createSetFacetsCommand(
+// tableInstance2.getFacets2(), newElements, this);
+// if (setFacetsCommand != null && setFacetsCommand.canExecute()) {
+//// addRowCommand.append(setFacetsCommand);
+// }
+// } catch (CoreException e) {
+// throw new RuntimeException(e);
+// }
+// }
+ Command loadCustomizationCommand = TableInstanceCommandFactory
+ .createLoadCustomizationsCommand(getTableInstance().getCustomizations(), this);
+ if (loadCustomizationCommand != null && loadCustomizationCommand.canExecute()) {
+ addRowCommand.append(loadCustomizationCommand);
+ }
+ getEditingDomain().getCommandStack().execute(addRowCommand);
+ }
+
+ @Override
+ public void dispose() {
+ getCustomizationEngine().clear();
+ }
+}
+
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/TableEditorInput.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/TableEditorInput.java
new file mode 100644
index 00000000000..621e09c3891
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/internal/TableEditorInput.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Mia-Software.
+ * 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:
+ * Nicolas Bros (Mia-Software) - Bug 331203 - table model editor - initial API and implementation
+ * Nicolas Guyomar (Mia-Software) - Bug 332924 - To be able to save the table
+ * Nicolas Guyomar (Mia-Software) - Bug 333029 - To be able to save the size of the lines and the columns
+ *******************************************************************************/
+package org.eclipse.papyrus.infra.table.common.internal;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+/**
+ * Comes from org.eclipse.emf.facet.widget.nattable.workbench.
+ *
+ * This class should not be used by others plugins
+ */
+public class TableEditorInput implements IEditorInput {
+
+ /** The input for the Table widget */
+ private final PapyrusTableInstance tableInstance;
+
+ /** A textual description of what is shown in the editor */
+ private final String description;
+
+ private final EditingDomain editingDomain;
+
+ public TableEditorInput(final PapyrusTableInstance papyrusTable, final EditingDomain editingDomain) {
+ this.tableInstance = papyrusTable;
+ this.description = papyrusTable.getTable().getDescription();
+ this.editingDomain = editingDomain;
+ }
+
+ public PapyrusTableInstance getPapyrusTableInstance() {
+ return this.tableInstance;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public boolean exists() {
+ return false;
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return null;
+ }
+
+ public String getName() {
+ return "Model Table"; //$NON-NLS-1$
+ }
+
+ public IPersistableElement getPersistable() {
+ return null;
+ }
+
+ public String getToolTipText() {
+ return "Model Table"; //$NON-NLS-1$
+ }
+
+ public Object getAdapter(@SuppressWarnings("rawtypes") final Class adapter) {
+ return null;
+ }
+
+ protected EditingDomain getEditingDomain() {
+ return this.editingDomain;
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/listener/AbstractSynchronizedTableTriggerListener.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/listener/AbstractSynchronizedTableTriggerListener.java
new file mode 100644
index 00000000000..e3190ce7795
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/listener/AbstractSynchronizedTableTriggerListener.java
@@ -0,0 +1,431 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.listener;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.infra.query.ModelQuery;
+import org.eclipse.emf.facet.infra.query.core.AbstractModelQuery;
+import org.eclipse.emf.facet.infra.query.core.ModelQuerySetCatalog;
+import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryException;
+import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList;
+import org.eclipse.emf.facet.infra.query.runtime.ModelQueryResult;
+import org.eclipse.emf.facet.widgets.celleditors.ICommandFactoriesRegistry;
+import org.eclipse.emf.facet.widgets.celleditors.ICommandFactory;
+import org.eclipse.emf.facet.widgets.nattable.INatTableWidget;
+import org.eclipse.emf.facet.widgets.nattable.INatTableWidgetProvider;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.Row;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableInstance;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableinstancePackage;
+import org.eclipse.emf.facet.widgets.nattable.internal.NatTableWidget;
+import org.eclipse.emf.facet.widgets.nattable.internal.TableInstanceCommandFactory;
+import org.eclipse.emf.facet.widgets.nattable.tableconfiguration.TableConfiguration;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.TriggerListener;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.table.common.Activator;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+
+/**
+ *
+ * This abstract class provides useful method for the TriggerListener used for the table synchronization
+ *
+ */
+public abstract class AbstractSynchronizedTableTriggerListener extends TriggerListener {
+
+ /**
+ * The Papyrus table
+ */
+ final protected PapyrusTableInstance table;
+
+ /**
+ * the nattable widget provider
+ */
+ private INatTableWidgetProvider provider;
+
+ /**
+ * the ModelQuery Catalog
+ */
+ private final ModelQuerySetCatalog catalog = ModelQuerySetCatalog.getSingleton();
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param table
+ * the table
+ * @param provider
+ * the nattable widget provider
+ */
+ public AbstractSynchronizedTableTriggerListener(final PapyrusTableInstance table, final INatTableWidgetProvider provider) {
+ this.table = table;
+ this.provider = provider;
+ }
+
+ /**
+ *
+ * @param domain
+ * the editing domain
+ * @return
+ * the command to do the synchronization
+ */
+ protected CompoundCommand getSynchronizationCommand(final TransactionalEditingDomain domain) {
+ if(!this.table.getFillingQueries().isEmpty()) {
+ CompoundCommand command = new CompoundCommand("Command to synchronize table with its context"); //$NON-NLS-1$
+
+ // // the list of the elements to add in the table
+ // final List<EObject> elementsToAdd = new ArrayList<EObject>();
+ //
+ // // the list of the element to remove in the table
+ // final List<EObject> elementToRemove = new ArrayList<EObject>();
+
+ // all the elements in the table
+ final Collection<EObject> allElements = getAllElementsUsingFillingqueries();
+
+ final List<EObject> currentElements = this.table.getTable().getElements();
+
+ // //a new element has been added to the model
+ // for(ModelQuery query : this.table.getFillingQueries()) {
+ // ModelQuerySetCatalog catalog = ModelQuerySetCatalog.getSingleton();
+ // AbstractModelQuery impl = null;
+ // try {
+ // impl = catalog.getModelQueryImpl(query);
+ // } catch (ModelQueryException e) {
+ // Activator.getDefault().log.error(e);
+ // }
+ // if(impl != null) {
+ // ModelQueryResult result = impl.evaluate(this.table.getTable().getContext());
+ // Object value = result.getValue();
+ // if(value instanceof Collection<?>) {
+ // //the build the list of the elements to add in the table
+ // for(Object currentObject : (Collection<?>)value) {
+ // if(currentObject instanceof EObject && !this.table.getTable().getElements().contains(currentObject)) {
+ // elementsToAdd.add((EObject)currentObject);
+ // }
+ // }
+ //
+ // /*
+ // * we build the list of the elements to remove from the table
+ // */
+ // for(EObject currentObject : this.table.getTable().getElements()) {
+ // if(!((Collection<?>)value).contains(currentObject)) {
+ // elementToRemove.add(currentObject);
+ // }
+ // }
+ // } else {
+ // //nothing to do for the moment
+ // }
+ // }
+ // }
+ // we build the list of the elements to add in the table
+ List<EObject> elementsToAdd = new ArrayList<EObject>(allElements);
+ elementsToAdd.removeAll(currentElements);
+
+ /*
+ * we build the list of the elements to remove from the
+ * table
+ */
+ List<EObject> elementsToRemove = new ArrayList<EObject>(currentElements);
+ elementsToRemove.removeAll(allElements);
+
+ if(!elementsToAdd.isEmpty()) {
+ final List<EObject> forbiddenElements = getForbiddenElement(elementsToAdd);
+ /*
+ * The following line is commented because it doesn't work correctly : The same new object is added many times!
+ */
+ //command.append(TableInstanceCommandFactory.createAddRowsCommand(elementsToAdd, (NatTableWidget)this.provider.getNatTableWidget()));
+ elementsToAdd.removeAll(forbiddenElements);
+ command.append(getAddElementCommand(domain, elementsToAdd, this.provider.getNatTableWidget()));
+
+ //we don't display a message because we will get it each time the synchronized table is refreshed
+ //we display a message
+ // if(!forbiddenElements.isEmpty()) {
+ // command.append(new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, "Display Notification", null) {
+ //
+ // @Override
+ // protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ // String list = "";
+ // //TODO, maybe the label provider can manage a list?
+ // ILabelProvider labelProvider = new UMLLabelProvider();
+ // Iterator<EObject> iter = forbiddenElements.iterator();
+ // while(iter.hasNext()) {
+ // list += labelProvider.getText(iter.next());
+ // if(iter.hasNext()) {
+ // list += ", ";
+ // }
+ // }
+ // //new NotificationBuilder().setBuilderClass(CombinedPopupAndViewBuilder.class).setType(Type.WARNING).setTitle("Synchronized Table Message").setMessage("The following elements should be put in the table by the <<FillingQueries>>, but the query <<CanBePresentedInTheTable>> refuses them. " + "\n" + list).run();
+ // return CommandResult.newOKCommandResult();
+ // }
+ // }));
+ // }
+ }
+
+ if(!elementsToRemove.isEmpty()) {
+ command.append(getRemoveElementCommand(domain, elementsToRemove, this.provider.getNatTableWidget()));
+ }
+
+ if(!allElements.isEmpty()) {
+ // respect the order of the lines!
+ command.append(new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, null, null) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ TableInstance table = provider.getNatTableWidget().getTableInstance();
+ List<Row> newOrder = new ArrayList<Row>();
+ List<Row> rows = table.getRows();
+
+ //Assert.isTrue(rows.size() == allElements.size());//not the case when we are deleting elements of the table
+ for(EObject current : allElements) {
+ for(Row currentRow : rows) {
+ if(currentRow.getElement() == current) {
+ newOrder.add(currentRow);
+ break;
+ }
+ }
+ }
+ ICommandFactory commandFactory = ICommandFactoriesRegistry.INSTANCE.getCommandFactoryFor(domain);
+ Command command = commandFactory.createSetCommand(domain, table, TableinstancePackage.eINSTANCE.getTableInstance_Rows(), newOrder);
+ command.execute();
+ return null;
+ }
+ }));
+ }
+ if(!command.isEmpty()) {
+ return command;
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @return
+ * a collection with the elements returned by the filling queries
+ */
+ private Collection<EObject> getAllElementsUsingFillingqueries() {
+ final List<ModelQuery> queries = this.table.getFillingQueries();
+ if(queries.size() == 1) {
+ AbstractModelQuery impl = null;
+ try {
+ impl = catalog.getModelQueryImpl(queries.get(0));
+ } catch (ModelQueryException e) {
+ Activator.log.error(e);
+ }
+ Assert.isNotNull(impl != null);
+ ModelQueryResult result = impl.evaluate(this.table.getTable().getContext());
+ Object value = result.getValue();
+ Assert.isTrue(value instanceof Collection<?>);
+ return Collections.checkedCollection((Collection<EObject>)value, EObject.class);
+ } else {
+ final Collection<EObject> allElements = new LinkedHashSet<EObject>();
+ for(ModelQuery query : this.table.getFillingQueries()) {
+ AbstractModelQuery impl = null;
+ try {
+ impl = catalog.getModelQueryImpl(query);
+ } catch (ModelQueryException e) {
+ Activator.log.error(e);
+ }
+
+ if(impl != null) {
+ ModelQueryResult result = impl.evaluate(this.table.getTable().getContext());
+ Object value = result.getValue();
+ if(value instanceof Collection<?>) {
+ // we build the list of all the element which should be in
+ // the table
+ for(Object currentObject : (Collection<?>)value) {
+ if(currentObject instanceof EObject) {
+ allElements.add((EObject)currentObject);
+ }
+ }
+ }
+ }
+ }
+ return allElements;
+ }
+
+
+ }
+
+
+ /**
+ *
+ * @param domain
+ * the domain to do the command
+ * @param elementsToAdd
+ * the elements to add in the table
+ * @param widget
+ * the widget
+ * @return
+ * the command to add the elements in the table
+ */
+ protected Command getAddElementCommand(final TransactionalEditingDomain domain, final List<EObject> elementsToAdd, final INatTableWidget widget) {
+ return new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, null, null) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ widget.addRows(elementsToAdd);
+ for(EObject current : elementsToAdd) {
+ if(!widget.getTableInstance().getElements().contains(current)) {//we re-test during the execution, to avoid the same element will be added many times
+ widget.addRows(Collections.singletonList(current));
+ }
+ }
+ // List<EObject> toAdd = new ArrayList<EObject>();
+ // toAdd.add(current);
+ // Command command = TableInstanceCommandFactory.createAddRowsCommand(toAdd, (NatTableWidget)widget);
+ // if(command != null) {
+ // command.execute();
+ // }
+ // }
+ // }
+ //I change the implementation of this command, because, when we create a new element in the model explorer, the facet column are not created
+ // for(EObject current : elementsToAdd) {
+ // if(!widget.getTableInstance().getElements().contains(current)) {//we re-test during the execution, to avoid the same element will be added many times
+ //
+ // List<EObject> toAdd = new ArrayList<EObject>();
+ // toAdd.add(current);
+ // Command command = TableInstanceCommandFactory.createAddRowsCommand(toAdd, (NatTableWidget)widget);
+ // if(command != null) {
+ // command.execute();
+ // }
+ // }
+ // }
+ return null;
+ }
+ });
+ }
+
+ /**
+ *
+ * @param domain
+ * the domain for the command
+ * @param elementsToRemove
+ * the element to remove
+ * @param widget
+ * the widget
+ * @return
+ */
+ protected Command getRemoveElementCommand(final TransactionalEditingDomain domain, final List<EObject> elementsToRemove, final INatTableWidget widget) {
+ return new GMFtoEMFCommandWrapper(new AbstractTransactionalCommand(domain, null, null) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ for(EObject current : elementsToRemove) {
+ if(widget.getTableInstance().getElements().contains(current)) {//we re-test to avoid to remove the same element many times
+ List<EObject> toRemove = new ArrayList<EObject>();
+ toRemove.add(current);
+ Command command = createRemoveRowsCommand(domain, toRemove, widget);
+ if(command != null) {
+ command.execute();
+ }
+ }
+
+ }
+ return null;
+ }
+ });
+ }
+
+
+
+ /**
+ * TODO : this method should be provided by the TableInstanceCommandFactory
+ *
+ * @param domain
+ * the domain
+ * @param toRemove
+ * the list of the elements to remove
+ * @param widget
+ * the widget
+ * @return
+ * the command to remove the elements
+ */
+ private Command createRemoveRowsCommand(final TransactionalEditingDomain domain, final List<EObject> toRemove, final INatTableWidget widget) {
+ ICommandFactory commandFactory = ICommandFactoriesRegistry.INSTANCE.getCommandFactoryFor(domain);
+ CompoundCommand compoundCommand = new CompoundCommand();
+ for(int i = 0; i < widget.getTableInstance().getRows().size(); i++) {
+ if(toRemove.contains(widget.getTableInstance().getRows().get(i).getElement())) {
+ Command removeRowCommand = commandFactory.createRemoveCommand(domain, widget.getTableInstance(), TableinstancePackage.eINSTANCE.getTableInstance_Rows(), widget.getTableInstance().getRows().get(i));
+ compoundCommand.append(removeRowCommand);
+ }
+ }
+ if(!compoundCommand.isEmpty()) {
+ return compoundCommand;
+ }
+ return null;
+ }
+
+ /**
+ * This method allows to filter the elements to add which are forbidden in the table, using the query canBePresentedInTheTable
+ *
+ * @param elementsToAdd
+ * the list of the elements to add in the table
+ * @return
+ * the list of the elements to add which are forbidden in the table
+ */
+ private List<EObject> getForbiddenElement(final List<EObject> elementsToAdd) {
+ List<EObject> forbiddenElements = new ArrayList<EObject>();
+
+ //we need to test that each element to add can be put in the table. So we use the query CanBePresentedInTheTable
+ TableConfiguration tableConfiguration = this.table.getTable().getTableConfiguration();
+ if(tableConfiguration != null) {
+ ModelQuery query = tableConfiguration.getCanBePresentedInTheTable();
+ if(query != null) {
+ AbstractModelQuery queryImpl = null;
+ try {
+ queryImpl = ModelQuerySetCatalog.getSingleton().getModelQueryImpl(query);
+ } catch (ModelQueryException e) {
+ Activator.getDefault().log.error(e);
+ }
+
+ for(EObject current : elementsToAdd) {
+ boolean matched = (query.getScope().size() == 0);
+ Iterator<EClass> queryScopes = query.getScope().iterator();
+ while(queryScopes.hasNext() && !matched) {
+ EClass eClass = queryScopes.next();
+ if(eClass.isInstance(current)) {
+ matched = true;
+ }
+ }
+
+ if(!matched) {
+ forbiddenElements.add(current);
+ } else {
+ ModelQueryResult result = queryImpl.evaluate(current, new ParameterValueList());
+
+ if(!result.getValue().equals(Boolean.TRUE)) {
+ forbiddenElements.add(current);
+ }
+ }
+ }
+ }
+ }
+ return forbiddenElements;
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/listener/ModelTriggerListener.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/listener/ModelTriggerListener.java
new file mode 100644
index 00000000000..78a985ca387
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/listener/ModelTriggerListener.java
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.listener;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.emf.facet.widgets.nattable.INatTableWidgetProvider;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.table.common.util.FillingQueriesUtil;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+
+/**
+ *
+ * This listener allows to synchronized the table with its context, listening the changes on the model (listen the change in the uml file.
+ *
+ */
+public class ModelTriggerListener extends AbstractSynchronizedTableTriggerListener {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param table
+ * the table
+ * @param provider
+ * the nattable widget provider
+ */
+ public ModelTriggerListener(final PapyrusTableInstance table, final INatTableWidgetProvider provider) {
+ super(table, provider);
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.transaction.TriggerListener#trigger(org.eclipse.emf.transaction.TransactionalEditingDomain,
+ * org.eclipse.emf.common.notify.Notification)
+ *
+ * @param domain
+ * @param notification
+ * @return
+ * the command to add and remove elements from the table when the table is synchronized
+ */
+ @Override
+ protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
+ if(this.table.isIsSynchronized()) {
+ Object notifier = notification.getNotifier();
+ int eventType = notification.getEventType();
+ if(notifier instanceof PapyrusTableInstance) {
+ if(this.table.isIsSynchronized()) {
+ switch(eventType) {
+ case FillingQueriesUtil.OPEN_TABLE:
+ return getSynchronizationCommand(domain);
+ default:
+ break;
+ }
+ }
+ } else if(notifier instanceof org.eclipse.uml2.uml.Element) { //we only listen the modification on the UML model
+ //we can't do a test on the element which provide the notification, because each action on the model can change the result of the query
+ switch(eventType) {
+ //I think that only Set and Unset are required to get all changes in the model
+ case Notification.SET:
+ case Notification.UNSET:
+ case Notification.ADD:
+ case Notification.REMOVE:
+ case Notification.ADD_MANY:
+ case Notification.REMOVE_MANY:
+ return getSynchronizationCommand(domain);
+ default:
+ break;
+ //nothing to do
+ }
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/listener/TableTriggerListener.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/listener/TableTriggerListener.java
new file mode 100644
index 00000000000..423fffede80
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/listener/TableTriggerListener.java
@@ -0,0 +1,88 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.listener;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.facet.widgets.nattable.INatTableWidgetProvider;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrustableinstancePackage;
+
+/**
+ *
+ * This trigger returns a command when the following table features are modified :
+ * <ul>
+ * <li>PapyrustableinstancePackage.PAPYRUS_TABLE_INSTANCE__IS_SYNCHRONIZED</li>
+ * <li>PapyrustableinstancePackage.PAPYRUS_TABLE_INSTANCE__FILLING_QUERIES</li>
+ * <li></li>
+ * </ul>
+ *
+ */
+public class TableTriggerListener extends AbstractSynchronizedTableTriggerListener {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param table
+ * the table
+ * @param provider
+ * the nattable widget provider
+ */
+ public TableTriggerListener(PapyrusTableInstance table, INatTableWidgetProvider provider) {
+ super(table, provider);
+ }
+
+ /**
+ *
+ * @see org.eclipse.emf.transaction.TriggerListener#trigger(org.eclipse.emf.transaction.TransactionalEditingDomain,
+ * org.eclipse.emf.common.notify.Notification)
+ *
+ * @param domain
+ * @param notification
+ * @return
+ */
+ @Override
+ protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
+ Object notifier = notification.getNotifier();
+ if(notifier instanceof PapyrusTableInstance) {
+ Object feature = notification.getFeature();
+ if(feature instanceof EStructuralFeature) {
+ int featureID = ((EStructuralFeature)feature).getFeatureID();
+ switch(featureID) {
+ case PapyrustableinstancePackage.PAPYRUS_TABLE_INSTANCE__IS_SYNCHRONIZED:
+ if(notification.getNewBooleanValue()) {
+ return getSynchronizationCommand(domain);
+ }
+ break;
+ case PapyrustableinstancePackage.PAPYRUS_TABLE_INSTANCE__FILLING_QUERIES:
+ if(this.table.isIsSynchronized()) {
+ switch(notification.getEventType()) {
+ case Notification.ADD_MANY:
+ case Notification.ADD:
+ case Notification.REMOVE: //we remove the elements that the removed query brought
+ return getSynchronizationCommand(domain);
+ default:
+ //nothing to do
+ break;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/messages/Messages.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/messages/Messages.java
new file mode 100644
index 00000000000..ea598f974a1
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/messages/Messages.java
@@ -0,0 +1,42 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.table.common.messages.messages"; //$NON-NLS-1$
+
+ public static String AbstractCreateNattableEditorCommand_CreateNewTableDialog_TableDescriptionMessage;
+
+ public static String AbstractCreateNattableEditorCommand_CreateNewTableDialog_TableNameMessage;
+
+ public static String AbstractCreateNattableEditorCommand_CreateNewTableDialogTitle;
+
+ public static String NatTableEditor_TableContextLabel;
+
+ public static String NatTableEditor_TableContextTollTip;
+
+ public static String NatTableEditor_TableDescriptionToolTip;
+
+ public static String NatTableEditor_TaleDescriptionLabel;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/messages/messages.properties b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/messages/messages.properties
new file mode 100644
index 00000000000..4a229edb74b
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/messages/messages.properties
@@ -0,0 +1,7 @@
+AbstractCreateNattableEditorCommand_CreateNewTableDialog_TableDescriptionMessage=The new table description:
+AbstractCreateNattableEditorCommand_CreateNewTableDialog_TableNameMessage=The new table name:
+AbstractCreateNattableEditorCommand_CreateNewTableDialogTitle=Enter a new Table Name and a new Table Description
+NatTableEditor_TableContextLabel=Table Context :
+NatTableEditor_TableContextTollTip=This context will be the parent of the created elements. This field can not be modify.
+NatTableEditor_TableDescriptionToolTip=The table description
+NatTableEditor_TaleDescriptionLabel=Table Description :
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/modelresource/EMFFacetNattableModel.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/modelresource/EMFFacetNattableModel.java
new file mode 100644
index 00000000000..df44916fee1
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/modelresource/EMFFacetNattableModel.java
@@ -0,0 +1,117 @@
+/*****************************************************************************
+ * Copyright (c) 2011 LIFL & CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.table.common.modelresource;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableInstance;
+import org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource;
+import org.eclipse.papyrus.infra.core.resource.IModel;
+
+
+
+/**
+ * A model used to save data from the {@link DefaultNattableEditor}
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class EMFFacetNattableModel extends /* AbstractBaseModel */AbstractModelWithSharedResource<TableInstance> implements IModel {
+
+ /*
+ * To save in a new file :
+ * the class should extends AbstractBaseModel and NOTATION_FILE_EXTENSION = "nattable" for example
+ */
+
+
+ /**
+ * File extension used for notation.
+ */
+ // public static final String NOTATION_FILE_EXTENSION = "nattable"; //$NON-NLS-1$
+
+ public static final String NOTATION_FILE_EXTENSION = "di"; //$NON-NLS-1$
+
+ /**
+ * Model ID.
+ */
+ public static final String MODEL_ID = "org.eclipse.papyrus.emf.facet.nattable.resource.NattableModel"; //$NON-NLS-1$
+
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public EMFFacetNattableModel() {
+
+ }
+
+ /**
+ * Get the file extension used for this model.
+ *
+ * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getModelFileExtension()
+ *
+ * @return
+ */
+ @Override
+ protected String getModelFileExtension() {
+ return NOTATION_FILE_EXTENSION;
+ }
+
+ /**
+ * Get the identifier used to register this model.
+ *
+ * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getIdentifier()
+ *
+ * @return
+ */
+ @Override
+ public String getIdentifier() {
+ return MODEL_ID;
+ }
+
+
+ /**
+ * Add a new initialized {@link Diagram} to the model.
+ *
+ * @param newDiagram
+ * The diagram to add.
+ */
+ public void addTableInstance(TableInstance tableInstance) {
+ getResource().getContents().add(tableInstance);
+ }
+
+ /**
+ * Add a new initialized {@link Diagram} to the model.
+ *
+ * @param newDiagram
+ * The diagram to add.
+ */
+ public void removeTableInstance(TableInstance tableInstance) {
+ getResource().getContents().remove(tableInstance);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource#isModelRoot(org.eclipse.emf.ecore.EObject)
+ *
+ * @param object
+ * @return
+ */
+ @Override
+ protected boolean isModelRoot(EObject object) {
+ return false;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/modelresource/PapyrusNattableModel.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/modelresource/PapyrusNattableModel.java
new file mode 100644
index 00000000000..aed70db5dd5
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/modelresource/PapyrusNattableModel.java
@@ -0,0 +1,118 @@
+/*****************************************************************************
+ * Copyright (c) 2011 LIFL & CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.table.common.modelresource;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableInstance;
+import org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource;
+import org.eclipse.papyrus.infra.core.resource.IModel;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+
+
+
+/**
+ * A model used to save data from the {@link DefaultNattableEditor}
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class PapyrusNattableModel extends AbstractModelWithSharedResource<TableInstance> implements IModel {
+
+ /*
+ * To save in a new file :
+ * the class should extends AbstractBaseModel and NOTATION_FILE_EXTENSION = "nattable" for example
+ */
+
+
+ /**
+ * File extension used for notation.
+ */
+ // public static final String NOTATION_FILE_EXTENSION = "nattable"; //$NON-NLS-1$
+
+ public static final String NOTATION_FILE_EXTENSION = "di"; //$NON-NLS-1$
+
+ /**
+ * Model ID.
+ */
+ public static final String MODEL_ID = "org.eclipse.papyrus.nattable.resource.NattableModel"; //$NON-NLS-1$
+
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public PapyrusNattableModel() {
+
+ }
+
+ /**
+ * Get the file extension used for this model.
+ *
+ * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getModelFileExtension()
+ *
+ * @return
+ */
+ @Override
+ protected String getModelFileExtension() {
+ return NOTATION_FILE_EXTENSION;
+ }
+
+ /**
+ * Get the identifier used to register this model.
+ *
+ * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getIdentifier()
+ *
+ * @return
+ */
+ @Override
+ public String getIdentifier() {
+ return MODEL_ID;
+ }
+
+
+ /**
+ * Add a new initialized {@link PapyrusTableInstance} to the model.
+ *
+ * @param tableInstance
+ * The tableInstance to add.
+ */
+ public void addPapyrusTableInstance(PapyrusTableInstance tableInstance) {
+ getResource().getContents().add(tableInstance);
+ }
+
+ /**
+ * Add a new initialized {@link PapyrusTableInstance} to the model.
+ *
+ * @param tableInstance
+ * The tableInstance to add.
+ */
+ public void removeTableInstance(PapyrusTableInstance tableInstance) {
+ getResource().getContents().remove(tableInstance);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.core.resource.AbstractModelWithSharedResource#isModelRoot(org.eclipse.emf.ecore.EObject)
+ *
+ * @param object
+ * @return
+ */
+ @Override
+ protected boolean isModelRoot(EObject object) {
+ return false;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/providers/FilteredTableLabelProvider.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/providers/FilteredTableLabelProvider.java
new file mode 100644
index 00000000000..8f474a2549a
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/providers/FilteredTableLabelProvider.java
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.providers;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+
+/**
+ * A Filter Label Provider for {@link PapyrusTableInstance}
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class FilteredTableLabelProvider extends TableLabelProvider implements IFilteredLabelProvider {
+
+ /**
+ * Accepts {@link PapyrusTableInstance}
+ */
+ public boolean accept(Object element) {
+ //The element is a PapyrusTableInstance or can be adapted to an PapyrusTableInstance
+ EObject eObject = EMFHelper.getEObject(element);
+
+ return eObject instanceof PapyrusTableInstance;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/providers/TableLabelProvider.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/providers/TableLabelProvider.java
new file mode 100644
index 00000000000..5ae80d192db
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/providers/TableLabelProvider.java
@@ -0,0 +1,85 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.providers;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
+import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistryExtended;
+import org.eclipse.papyrus.infra.core.editorsfactory.PageIconsRegistry;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * A Label Provider for {@link PapyrusTableInstance}
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class TableLabelProvider extends LabelProvider {
+
+ /**
+ * Return the EditorRegistry for nested editor descriptors. Subclass should
+ * implements this method in order to return the registry associated to the
+ * extension point namespace.
+ *
+ * @return the EditorRegistry for nested editor descriptors
+ * FIXME : use a deprecated method
+ */
+ protected IPageIconsRegistry createEditorRegistry(EObject from) {
+ try {
+ return ServiceUtilsForEObject.getInstance().getService(IPageIconsRegistry.class, from);
+ } catch (ServiceException e) {
+ // Not found, return an empty one which return null for each
+ // request.
+ return new PageIconsRegistry();
+ }
+ }
+
+ /**
+ * the icon registry
+ */
+ private IPageIconsRegistry editorRegistry;
+
+
+ protected IPageIconsRegistryExtended getEditorRegistry(EObject from) {
+ if(editorRegistry == null) {
+ editorRegistry = createEditorRegistry(from);
+ }
+ if(!(editorRegistry instanceof IPageIconsRegistryExtended)) {
+ throw new RuntimeException("The editor registry do not implement IPageIconsRegistryExtended");////$NON-NLS-1$
+ }
+ return (IPageIconsRegistryExtended)editorRegistry;
+ }
+
+ @Override
+ public String getText(Object element) {
+ EObject eObject = EMFHelper.getEObject(element);
+ if(eObject instanceof PapyrusTableInstance) {
+ return ((PapyrusTableInstance)eObject).getName();
+ }
+ return super.getText(element);
+ }
+
+
+ @Override
+ public Image getImage(Object element) {
+ EObject eObject = EMFHelper.getEObject(element);
+ if(eObject instanceof PapyrusTableInstance) {
+ return getEditorRegistry(eObject).getEditorIcon(eObject);
+ }
+ return super.getImage(element);
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/util/FillingQueriesUtil.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/util/FillingQueriesUtil.java
new file mode 100644
index 00000000000..5b9ef95c86d
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/util/FillingQueriesUtil.java
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.util;
+
+import org.eclipse.emf.common.notify.Notification;
+
+public class FillingQueriesUtil {
+
+ /**
+ * The constructor for this class
+ */
+ private FillingQueriesUtil() {
+ //nothing to do
+ }
+
+ /** the value for the event which opens the table */
+ public static final int OPEN_TABLE = Notification.EVENT_TYPE_COUNT + 1;
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/util/QueryRepresentation.java b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/util/QueryRepresentation.java
new file mode 100644
index 00000000000..24ccc28fba2
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/util/QueryRepresentation.java
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.common.util;
+
+
+/**
+ * This class is used to represent the queries used to fill the table.
+ *
+ *
+ *
+ */
+public class QueryRepresentation {
+
+ /**
+ * the query set name
+ */
+ private String querySetName;
+
+ /**
+ * the query name
+ */
+ private String queryName;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param querySetName
+ * the querySet name
+ * @param queryName
+ * the query name
+ */
+ public QueryRepresentation(String querySetName, String queryName) {
+ this.querySetName = querySetName;
+ this.queryName = queryName;
+ }
+
+ /**
+ * Getter for {@link #querySetName}
+ *
+ * @return
+ * this{@link #querySetName}
+ */
+ public String getQuerySetName() {
+ return querySetName;
+ }
+
+ /**
+ * Getter for {@link #queryName}
+ *
+ * @return
+ * this {@link #queryName}
+ */
+ public String getQueryName() {
+ return queryName;
+ }
+
+}

Back to the top