Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2011-10-06 15:46:02 +0000
committervlorenzo2011-10-06 15:46:02 +0000
commitac5c94e387642d0e195f75008c326b53bfe22518 (patch)
tree9622efddd8e099850a9cd2a56fb1b5e8367a1e00 /incoming
parentfbaa5e499f9bf19b2b03e810a178dbb00660d6e5 (diff)
downloadorg.eclipse.papyrus-ac5c94e387642d0e195f75008c326b53bfe22518.tar.gz
org.eclipse.papyrus-ac5c94e387642d0e195f75008c326b53bfe22518.tar.xz
org.eclipse.papyrus-ac5c94e387642d0e195f75008c326b53bfe22518.zip
NEW - bug 360116: [Model Explorer] Papyrus ModelExplorer should be covered with JUnit Test
https://bugs.eclipse.org/bugs/show_bug.cgi?id=360116
Diffstat (limited to 'incoming')
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/.classpath7
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/.project28
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/META-INF/MANIFEST.MF26
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/about.html28
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/build.properties10
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/pdocumentation.pdoc4
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/plugin.properties3
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/resources/model.di47
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/resources/model.notation92
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/resources/model.uml14
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/Activator.java63
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/AbstractHandlerTest.java380
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/AllTests.java30
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/DeleteHandlerTest.java246
-rw-r--r--incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/RenameHandlerTest.java162
16 files changed, 1148 insertions, 0 deletions
diff --git a/incoming/org.eclipse.papyrus.modelexplorer.test/.classpath b/incoming/org.eclipse.papyrus.modelexplorer.test/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/.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/incoming/org.eclipse.papyrus.modelexplorer.test/.project b/incoming/org.eclipse.papyrus.modelexplorer.test/.project
new file mode 100644
index 00000000000..42d4d95a1cd
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.modelexplorer.test</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/incoming/org.eclipse.papyrus.modelexplorer.test/.settings/org.eclipse.jdt.core.prefs b/incoming/org.eclipse.papyrus.modelexplorer.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..30fcf77eee4
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Mon Sep 26 16:57:00 CEST 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/incoming/org.eclipse.papyrus.modelexplorer.test/META-INF/MANIFEST.MF b/incoming/org.eclipse.papyrus.modelexplorer.test/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..b3b1bfa2eb7
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/META-INF/MANIFEST.MF
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.modelexplorer.test
+Bundle-Version: 0.8.2.qualifier
+Bundle-Activator: org.eclipse.papyrus.modelexplorer.test.Activator
+Bundle-Vendor: %providerName
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.junit,
+ org.eclipse.core.resources,
+ org.eclipse.emf.facet.util.core,
+ org.eclipse.ui.ide,
+ org.eclipse.papyrus.modelexplorer,
+ org.eclipse.ui.navigator,
+ org.eclipse.uml2.uml,
+ org.eclipse.papyrus.table.instance;bundle-version="0.8.1",
+ org.eclipse.papyrus.umlutils,
+ org.eclipse.papyrus.table.modelexplorer;bundle-version="0.8.1",
+ org.eclipse.papyrus.uml.menu;bundle-version="0.8.1",
+ org.eclipse.emf.facet.infra.browser.uicore,
+ org.eclipse.emf.facet.infra.browser.custom
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Import-Package: org.eclipse.emf.facet.infra.facet
+Bundle-Localization: plugin
diff --git a/incoming/org.eclipse.papyrus.modelexplorer.test/about.html b/incoming/org.eclipse.papyrus.modelexplorer.test/about.html
new file mode 100644
index 00000000000..dd02e0be168
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/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>December 2, 2009</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> \ No newline at end of file
diff --git a/incoming/org.eclipse.papyrus.modelexplorer.test/build.properties b/incoming/org.eclipse.papyrus.modelexplorer.test/build.properties
new file mode 100644
index 00000000000..2287226d88d
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/build.properties
@@ -0,0 +1,10 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties,\
+ resources/,\
+ pdocumentation.pdoc
+src.includes = resources/,\
+ pdocumentation.pdoc,\
+ src/
diff --git a/incoming/org.eclipse.papyrus.modelexplorer.test/pdocumentation.pdoc b/incoming/org.eclipse.papyrus.modelexplorer.test/pdocumentation.pdoc
new file mode 100644
index 00000000000..71510298545
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/pdocumentation.pdoc
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<doc:Documentation xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:doc="http://www.eclipse.org/papyrus/documentation/plugin/documentation" description="This plugin was created to provide JUnits test for the action on the modelexplorer (Delete, Rename, ...)">
+ <referent firstName="Vincent" lastName="Lorenzo" eMail="vincent.lorenzo@cea.fr" currentCompany="CEA-LIST"/>
+</doc:Documentation>
diff --git a/incoming/org.eclipse.papyrus.modelexplorer.test/plugin.properties b/incoming/org.eclipse.papyrus.modelexplorer.test/plugin.properties
new file mode 100644
index 00000000000..e7ae290a90b
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/plugin.properties
@@ -0,0 +1,3 @@
+#Properties file for org.eclipse.papyrus.modelexplorer.test
+providerName = Eclipse Modeling Project
+pluginName = Tests for ModelExplorer \ No newline at end of file
diff --git a/incoming/org.eclipse.papyrus.modelexplorer.test/resources/model.di b/incoming/org.eclipse.papyrus.modelexplorer.test/resources/model.di
new file mode 100644
index 00000000000..ae65af6a3e9
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/resources/model.di
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="ASCII"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi" xmlns:org.eclipse.papyrus.table.instance.papyrustableinstance="http://www.eclipse.org/Papyrus/Table/0.8.0/papyrustableinstance" xmlns:tableinstance="http://www.eclipse.org/EMF_Facet/ModelCellEditor/0.1.0/tableinstance" xmlns:tableinstance2="http://www.eclipse.org/EMF_Facet/Table/0.1.0/tableinstance2">
+ <di:SashWindowsMngr>
+ <pageList>
+ <availablePage>
+ <emfPageIdentifier href="model.notation#_pEZ7EOjXEeCR1ocpRNl5DQ"/>
+ </availablePage>
+ <availablePage>
+ <emfPageIdentifier href="model.notation#_xIzPUOjXEeCR1ocpRNl5DQ"/>
+ </availablePage>
+ <availablePage emfPageIdentifier="/1"/>
+ <availablePage emfPageIdentifier="/3"/>
+ </pageList>
+ <sashModel currentSelection="/0/@sashModel/@windows.0/@children.0">
+ <windows>
+ <children xsi:type="di:TabFolder">
+ <children>
+ <emfPageIdentifier href="model.notation#_pEZ7EOjXEeCR1ocpRNl5DQ"/>
+ </children>
+ <children>
+ <emfPageIdentifier href="model.notation#_xIzPUOjXEeCR1ocpRNl5DQ"/>
+ </children>
+ <children emfPageIdentifier="/1"/>
+ <children emfPageIdentifier="/3"/>
+ </children>
+ </windows>
+ </sashModel>
+ </di:SashWindowsMngr>
+ <org.eclipse.papyrus.table.instance.papyrustableinstance:PapyrusTableInstance name="DefaultTable" table="/2"/>
+ <tableinstance2:TableInstance2 description="Table Description">
+ <tableConfiguration href="../../../plugin/org.eclipse.papyrus.table.default/resources/default.tableconfiguration2#/"/>
+ <customizations href="emffacet:/customization/UMLPapyrusDefaultBrowserCustomization#/"/>
+ <context href="model.uml#_pCw8UOjXEeCR1ocpRNl5DQ"/>
+ <columns xsi:type="tableinstance:DefaultLabelColumn"/>
+ <columns xsi:type="tableinstance:MetaClassColumn"/>
+ <columns xsi:type="tableinstance:EContainerColumn"/>
+ </tableinstance2:TableInstance2>
+ <org.eclipse.papyrus.table.instance.papyrustableinstance:PapyrusTableInstance name="DefaultTable" table="/4"/>
+ <tableinstance2:TableInstance2 description="Table Description">
+ <tableConfiguration href="../../../plugin/org.eclipse.papyrus.table.default/resources/default.tableconfiguration2#/"/>
+ <customizations href="emffacet:/customization/UMLPapyrusDefaultBrowserCustomization#/"/>
+ <context href="model.uml#_7yIzYOnFEeCWs89WZtbW4A"/>
+ <columns xsi:type="tableinstance:DefaultLabelColumn"/>
+ <columns xsi:type="tableinstance:MetaClassColumn"/>
+ <columns xsi:type="tableinstance:EContainerColumn"/>
+ </tableinstance2:TableInstance2>
+</xmi:XMI>
diff --git a/incoming/org.eclipse.papyrus.modelexplorer.test/resources/model.notation b/incoming/org.eclipse.papyrus.modelexplorer.test/resources/model.notation
new file mode 100644
index 00000000000..a42568dfccf
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/resources/model.notation
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML">
+ <notation:Diagram xmi:id="_pEZ7EOjXEeCR1ocpRNl5DQ" type="PapyrusUMLClassDiagram" name="NewDiagram" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="_uRV6AOjXEeCR1ocpRNl5DQ" type="2008" fontHeight="8" lineColor="0">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_uRfrAOjXEeCR1ocpRNl5DQ" source="ShadowFigure">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_uRfrAejXEeCR1ocpRNl5DQ" key="ShadowFigure_Value" value="false"/>
+ </eAnnotations>
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_uRfrAujXEeCR1ocpRNl5DQ" source="displayNameLabelIcon">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_uRfrA-jXEeCR1ocpRNl5DQ" key="displayNameLabelIcon_value" value="false"/>
+ </eAnnotations>
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_uRfrBOjXEeCR1ocpRNl5DQ" source="QualifiedName">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_uRfrBejXEeCR1ocpRNl5DQ" key="QualifiedNameDepth" value="1000"/>
+ </eAnnotations>
+ <children xmi:type="notation:DecorationNode" xmi:id="_uRfrBujXEeCR1ocpRNl5DQ" type="5029"/>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_uRfrB-jXEeCR1ocpRNl5DQ" type="7017">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_uRfrCOjXEeCR1ocpRNl5DQ"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_uRfrCejXEeCR1ocpRNl5DQ"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_uRfrCujXEeCR1ocpRNl5DQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_uRfrC-jXEeCR1ocpRNl5DQ"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_uRfrDOjXEeCR1ocpRNl5DQ" type="7018">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_uRfrDejXEeCR1ocpRNl5DQ"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_uRfrDujXEeCR1ocpRNl5DQ"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_uRfrD-jXEeCR1ocpRNl5DQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_uRfrEOjXEeCR1ocpRNl5DQ"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_uRfrEejXEeCR1ocpRNl5DQ" type="7019">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_uRfrEujXEeCR1ocpRNl5DQ"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_uRfrE-jXEeCR1ocpRNl5DQ"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_uRfrFOjXEeCR1ocpRNl5DQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_uRfrFejXEeCR1ocpRNl5DQ"/>
+ </children>
+ <element xmi:type="uml:Class" href="model.uml#_uQciIOjXEeCR1ocpRNl5DQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_uRV6AejXEeCR1ocpRNl5DQ" x="305" y="285" width="246" height="146"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="_vG1-oOjXEeCR1ocpRNl5DQ" type="2012" fontHeight="8" lineColor="0">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_vG1-oujXEeCR1ocpRNl5DQ" source="ShadowFigure">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_vG1-o-jXEeCR1ocpRNl5DQ" key="ShadowFigure_Value" value="false"/>
+ </eAnnotations>
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_vG1-pOjXEeCR1ocpRNl5DQ" source="displayNameLabelIcon">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_vG1-pejXEeCR1ocpRNl5DQ" key="displayNameLabelIcon_value" value="false"/>
+ </eAnnotations>
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_vG1-pujXEeCR1ocpRNl5DQ" source="QualifiedName">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_vG1-p-jXEeCR1ocpRNl5DQ" key="QualifiedNameDepth" value="1000"/>
+ </eAnnotations>
+ <children xmi:type="notation:DecorationNode" xmi:id="_vG1-qOjXEeCR1ocpRNl5DQ" type="5038"/>
+ <element xmi:type="uml:Comment" href="model.uml#_vFM_4OjXEeCR1ocpRNl5DQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_vG1-oejXEeCR1ocpRNl5DQ" x="313" y="613"/>
+ </children>
+ <children xmi:type="notation:Shape" xmi:id="_wJw0MejXEeCR1ocpRNl5DQ" type="2007" fontHeight="8" lineColor="0">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_wJw0M-jXEeCR1ocpRNl5DQ" source="ShadowFigure">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_wJw0NOjXEeCR1ocpRNl5DQ" key="ShadowFigure_Value" value="false"/>
+ </eAnnotations>
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_wJw0NejXEeCR1ocpRNl5DQ" source="displayNameLabelIcon">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_wJw0NujXEeCR1ocpRNl5DQ" key="displayNameLabelIcon_value" value="false"/>
+ </eAnnotations>
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_wJw0N-jXEeCR1ocpRNl5DQ" source="QualifiedName">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_wJw0OOjXEeCR1ocpRNl5DQ" key="QualifiedNameDepth" value="1000"/>
+ </eAnnotations>
+ <children xmi:type="notation:DecorationNode" xmi:id="_wJw0OejXEeCR1ocpRNl5DQ" type="5026"/>
+ <children xmi:type="notation:DecorationNode" xmi:id="_wJw0OujXEeCR1ocpRNl5DQ" type="7016">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_wJw0O-jXEeCR1ocpRNl5DQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_wJw0POjXEeCR1ocpRNl5DQ"/>
+ </children>
+ <element xmi:type="uml:Package" href="model.uml#_wJw0MOjXEeCR1ocpRNl5DQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_wJw0MujXEeCR1ocpRNl5DQ" x="615" y="400" width="336" height="351"/>
+ </children>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_pEZ7EejXEeCR1ocpRNl5DQ"/>
+ <element xmi:type="uml:Model" href="model.uml#_pCw8UOjXEeCR1ocpRNl5DQ"/>
+ </notation:Diagram>
+ <notation:Diagram xmi:id="_xIzPUOjXEeCR1ocpRNl5DQ" type="PapyrusUMLCommunicationDiagram" name="ComDiagram" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="_xIzPUejXEeCR1ocpRNl5DQ" type="8002" fontHeight="8" lineColor="0">
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_xIzPUujXEeCR1ocpRNl5DQ" source="ShadowFigure">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_xIzPU-jXEeCR1ocpRNl5DQ" key="ShadowFigure_Value" value="false"/>
+ </eAnnotations>
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_xIzPVOjXEeCR1ocpRNl5DQ" source="displayNameLabelIcon">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_xIzPVejXEeCR1ocpRNl5DQ" key="displayNameLabelIcon_value" value="false"/>
+ </eAnnotations>
+ <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_xIzPVujXEeCR1ocpRNl5DQ" source="QualifiedName">
+ <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_xIzPV-jXEeCR1ocpRNl5DQ" key="QualifiedNameDepth" value="1000"/>
+ </eAnnotations>
+ <children xmi:type="notation:DecorationNode" xmi:id="_xIzPWOjXEeCR1ocpRNl5DQ" type="5001"/>
+ <children xmi:type="notation:DecorationNode" xmi:id="_xIzPWejXEeCR1ocpRNl5DQ" type="7001">
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_xIzPWujXEeCR1ocpRNl5DQ"/>
+ </children>
+ <element xmi:type="uml:Interaction" href="model.uml#_w-OXAOjXEeCR1ocpRNl5DQ"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_xIzPW-jXEeCR1ocpRNl5DQ"/>
+ </children>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_xIzPXOjXEeCR1ocpRNl5DQ"/>
+ <element xmi:type="uml:Interaction" href="model.uml#_w-OXAOjXEeCR1ocpRNl5DQ"/>
+ </notation:Diagram>
+</xmi:XMI>
diff --git a/incoming/org.eclipse.papyrus.modelexplorer.test/resources/model.uml b/incoming/org.eclipse.papyrus.modelexplorer.test/resources/model.uml
new file mode 100644
index 00000000000..b892c739a81
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/resources/model.uml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xmi:id="_pCw8UOjXEeCR1ocpRNl5DQ" name="Model">
+ <ownedComment xmi:id="_vFM_4OjXEeCR1ocpRNl5DQ">
+ <body> </body>
+ </ownedComment>
+ <packageImport xmi:id="_pCw8UejXEeCR1ocpRNl5DQ">
+ <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
+ </packageImport>
+ <packagedElement xmi:type="uml:Class" xmi:id="_uQciIOjXEeCR1ocpRNl5DQ" name="Class0"/>
+ <packagedElement xmi:type="uml:Package" xmi:id="_wJw0MOjXEeCR1ocpRNl5DQ" name="Package0">
+ <packagedElement xmi:type="uml:Interaction" xmi:id="_w-OXAOjXEeCR1ocpRNl5DQ" name="Interaction0"/>
+ </packagedElement>
+ <packagedElement xmi:type="uml:Package" xmi:id="_7yIzYOnFEeCWs89WZtbW4A" name="Package1"/>
+</uml:Model>
diff --git a/incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/Activator.java b/incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/Activator.java
new file mode 100644
index 00000000000..e2bd1d875b3
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/Activator.java
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * 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.modelexplorer.test;
+
+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.modelexplorer.test"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(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/incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/AbstractHandlerTest.java b/incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/AbstractHandlerTest.java
new file mode 100644
index 00000000000..0ff645587ac
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/AbstractHandlerTest.java
@@ -0,0 +1,380 @@
+/*****************************************************************************
+ * 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.modelexplorer.test.tests;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ITreeElement;
+import org.eclipse.emf.facet.util.core.internal.FileUtils;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.core.editor.CoreMultiDiagramEditor;
+import org.eclipse.papyrus.modelexplorer.ModelExplorerPage;
+import org.eclipse.papyrus.modelexplorer.ModelExplorerPageBookView;
+import org.eclipse.papyrus.modelexplorer.ModelExplorerView;
+import org.eclipse.papyrus.modelexplorer.test.Activator;
+import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.table.instance.papyrustableinstance.PapyrusTableInstance;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.internal.handlers.HandlerProxy;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.part.IPage;
+import org.eclipse.uml2.uml.Package;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+
+public abstract class AbstractHandlerTest {
+
+ /** the di extension */
+ protected static final String EXTENSION_DI = ".di"; //$NON-NLS-1$
+
+ /** the notation extension */
+ protected static final String EXTENSION_NOTATION = ".notation"; //$NON-NLS-1$
+
+ /** the uml extension */
+ protected static final String EXTENSION_UML = ".uml"; //$NON-NLS-1$
+
+ /** the name of the file to open */
+ protected static final String FILE_NAME = "model"; //$NON-NLS-1$
+
+ /** the name of the project used to test the handler */
+ private static final String PROJECT_NAME = "Project Handler Test"; //$NON-NLS-1$
+
+ /** all the papyrus tables of the model */
+ protected List<PapyrusTableInstance> papyrusTable = new ArrayList<PapyrusTableInstance>();
+
+ /** all the papyrus diagrams of the model */
+ protected List<Diagram> diagrams = new ArrayList<Diagram>();
+
+ /** the id of the model explorer */
+ protected static final String viewId = "org.eclipse.papyrus.modelexplorer.modelexplorer"; //$NON-NLS-1$
+
+ /** the root of the model */
+ protected Package rootOfTheModel;
+
+ /** the model explorer view */
+ protected ModelExplorerView modelExplorerView;
+
+ /** the tested command */
+ protected Command testedCommand;
+
+ /** the common viewer */
+ protected CommonViewer commonViewer;
+
+ /** the selection servive */
+ protected ISelectionService selectionService;
+
+ /** the id of the command to test */
+ private String commandId;
+
+ /** the IPageMngr */
+ private IPageMngr pageManager;
+
+ /**
+ * useful messages for the tests
+ */
+ public static final String INITIALIZATION_ERROR = "Initialization error"; //$NON-NLS-1$
+
+ public static final String IT_IS_NOT_THE_REQUIRED_BEHAVIOR = "It is not the required behavior"; //$NON-NLS-1$
+
+ public static final String THE_HANDLER = "The handler"; //$NON-NLS-1$
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param commandId
+ * the id of the command to test
+ */
+ public AbstractHandlerTest(String commandId) {
+ this.commandId = commandId;
+ }
+
+ /**
+ *
+ * @param file
+ * the file to open
+ * @return
+ * the opened editor
+ * @throws PartInitException
+ */
+ protected IEditorPart openEditor(final IFile file) throws PartInitException {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IEditorPart editor = IDE.openEditor(activePage, file);
+ return editor;
+ }
+
+ /**
+ * This method tests if the active part is the model explorer
+ */
+ protected void testIsModelExplorerActivePart() {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPart activePart = activePage.getActivePart();
+ Assert.isTrue(activePart instanceof ModelExplorerPageBookView, "The active part is not the ModelExplorer"); //$NON-NLS-1$
+ }
+
+ /**
+ * This method selects an element in the modelexplorer and test that the new selection is the wanted selection using assertion
+ *
+ * @param elementToSelect
+ * the element to select
+ */
+ protected void selectElementInTheModelexplorer(final EObject elementToSelect) {
+ List<EObject> selectedElement = new ArrayList<EObject>();
+ selectedElement.add(elementToSelect);
+ modelExplorerView.revealSemanticElement(selectedElement);
+ IStructuredSelection currentSelection = (IStructuredSelection)selectionService.getSelection();
+ Assert.isTrue(!((IStructuredSelection)currentSelection).isEmpty(), "The current selection is empty!"); //$NON-NLS-1$
+ Assert.isTrue(((IStructuredSelection)currentSelection).size() == 1, "Only one element should be selected"); //$NON-NLS-1$
+ Object obj = currentSelection.getFirstElement();
+ if(obj instanceof IAdaptable) {
+ obj = ((IAdaptable)obj).getAdapter(EObject.class);
+ }
+ Assert.isTrue(obj == elementToSelect, "the current selected element is not the wanted element"); //$NON-NLS-1$
+ }
+
+ /**
+ * This method selects an element in the modelexplorer and test that the new selection is the wanted selection using assertion
+ *
+ * @param elementToSelect
+ * the element to select
+ */
+ protected void selectElementInTheModelexplorer(final ITreeElement elementToSelect) {
+ commonViewer.setSelection(new StructuredSelection(elementToSelect));
+ IStructuredSelection currentSelection = (IStructuredSelection)selectionService.getSelection();
+ Assert.isTrue(((IStructuredSelection)currentSelection).size() == 1, "Only one element should be selected"); //$NON-NLS-1$
+ Object obj = currentSelection.getFirstElement();
+ Assert.isTrue(obj == elementToSelect, "the current selected element is not the wanted element"); //$NON-NLS-1$
+ }
+
+ /**
+ *
+ * @return
+ * the current handler for the command
+ */
+ protected IHandler getActiveHandler() {
+ IHandler currentHandler = testedCommand.getHandler();
+ if(currentHandler instanceof HandlerProxy) {
+ currentHandler = ((HandlerProxy)currentHandler).getHandler();
+ }
+ return currentHandler;
+ }
+
+ /**
+ * This method cleans the workspace, creates a new project with the model and initialize the fields of the class
+ *
+ * @throws CoreException
+ * @throws IOException
+ */
+ @Before
+ public void initTests() throws CoreException, IOException {
+ //we clean the workspace and create a new project to test the handlers
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ for(IProject project : workspace.getRoot().getProjects()) {
+ project.delete(true, new NullProgressMonitor());
+ }
+ IProject testProject = workspace.getRoot().getProject(AbstractHandlerTest.PROJECT_NAME);
+ testProject.create(new NullProgressMonitor());
+ testProject.open(new NullProgressMonitor());
+
+ //we copy the file of the tested model in the new project
+ Bundle bundle = Activator.getDefault().getBundle();
+ FileUtils.copyFileFromBundle("/resources/" + FILE_NAME + EXTENSION_UML, //$NON-NLS-1$
+ testProject, '/' + FILE_NAME + EXTENSION_UML, bundle);
+ FileUtils.copyFileFromBundle("/resources/" + FILE_NAME + EXTENSION_NOTATION, //$NON-NLS-1$
+ testProject, '/' + FILE_NAME + EXTENSION_NOTATION, bundle);
+ FileUtils.copyFileFromBundle("/resources/" + FILE_NAME + EXTENSION_DI, //$NON-NLS-1$
+ testProject, '/' + FILE_NAME + EXTENSION_DI, bundle);
+ IFile file = testProject.getFile(FILE_NAME + EXTENSION_DI);
+
+ //we open the editor
+ CoreMultiDiagramEditor editor = (CoreMultiDiagramEditor)openEditor(file);
+
+ //we store all the diagrams and tables of the model
+ IEditorPart activeEditor = editor.getActiveEditor();
+ pageManager = (IPageMngr)editor.getAdapter(IPageMngr.class);
+
+ diagrams = getDiagrams();
+ papyrusTable = getTables();
+
+ IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+
+ //we look for the modelexplorer
+ IViewPart modelexplorer = activeWorkbenchWindow.getActivePage().showView(viewId);
+ ModelExplorerPageBookView view = (ModelExplorerPageBookView)modelexplorer;
+ IPage currentPage = view.getCurrentPage();
+ ModelExplorerPage page = (ModelExplorerPage)currentPage;
+ IViewPart viewer = page.getViewer();
+ modelExplorerView = (ModelExplorerView)viewer;
+ modelExplorerView.setFocus();
+
+ //we look for the common viewer
+ commonViewer = modelExplorerView.getCommonViewer();
+
+ //we look for the selection service
+ selectionService = activeWorkbenchWindow.getSelectionService();
+
+ //we look for the testedCommand
+ ICommandService commandService = (ICommandService)activeWorkbenchWindow.getService(ICommandService.class);
+ testedCommand = commandService.getCommand(commandId);
+
+ commonViewer.expandToLevel(2);
+ Object[] visibleElement = commonViewer.getVisibleExpandedElements();
+ EObject el = null;
+ if(visibleElement[0] instanceof IAdaptable) {
+ el = (EObject)((IAdaptable)visibleElement[0]).getAdapter(EObject.class);
+ }
+ if(el instanceof org.eclipse.uml2.uml.Element) {
+ rootOfTheModel = (Package)org.eclipse.papyrus.umlutils.PackageUtil.getRootPackage((org.eclipse.uml2.uml.Element)el);
+ }
+ Assert.isTrue(rootOfTheModel != null, INITIALIZATION_ERROR + " I can't find the root of the model"); //$NON-NLS-1$
+ Assert.isTrue(commandId != null, INITIALIZATION_ERROR + " Initialization error : the commandid can't be null"); //$NON-NLS-1$
+ Assert.isTrue(commonViewer != null, INITIALIZATION_ERROR + " I can' find the CommonViewer"); //$NON-NLS-1$
+ Assert.isTrue(selectionService != null, INITIALIZATION_ERROR + " I can't find the SelectionService"); //$NON-NLS-1$
+ Assert.isTrue(pageManager != null, INITIALIZATION_ERROR + " I can't find the IPageMngr"); //$NON-NLS-1$
+ Assert.isTrue(diagrams.size() != 0, INITIALIZATION_ERROR + " I can't find diagrams in this model"); //$NON-NLS-1$
+ Assert.isTrue(papyrusTable.size() != 0, INITIALIZATION_ERROR + " I can't find tables in this model"); //$NON-NLS-1$
+ }
+
+ /**
+ *
+ * @return
+ * the tables owned by the IPageMngr
+ */
+ protected List<PapyrusTableInstance> getTables() {
+ List<Object> pages = pageManager.allPages();
+ List<PapyrusTableInstance> tables = new ArrayList<PapyrusTableInstance>();
+ for(Object current : pages) {
+ if(current instanceof PapyrusTableInstance) {
+ tables.add((PapyrusTableInstance)current);
+ }
+ }
+ return tables;
+ }
+
+ /**
+ *
+ * @return
+ * the diagrams owned by the IPageMngr
+ */
+ protected List<Diagram> getDiagrams() {
+ List<Object> pages = pageManager.allPages();
+ List<Diagram> diagrams = new ArrayList<Diagram>();
+ for(Object current : pages) {
+ if(current instanceof Diagram) {
+ diagrams.add((Diagram)current);
+ }
+ }
+ return diagrams;
+ }
+
+ /**
+ * do an undo of the last executed command
+ */
+ private void doUndo() {
+ Assert.isTrue(getCommandStack().canUndo(), "I can't undo the last executed command"); //$NON-NLS-1$
+ getCommandStack().undo();
+ }
+
+ /**
+ * do a redo on the last executed command
+ */
+ private void doRedo() {
+ Assert.isTrue(getCommandStack().canRedo(), "I can't redo the last executed command"); //$NON-NLS-1$
+ getCommandStack().redo();
+ }
+
+ /**
+ * Execute the current command
+ * @throws NotDefinedException
+ * @throws NotEnabledException
+ * @throws NotHandledException
+ * @throws ExecutionException
+ */
+ protected void executeActiveCommand() throws NotDefinedException, NotEnabledException, NotHandledException, ExecutionException {
+ testedCommand.executeWithChecks(new ExecutionEvent(testedCommand, Collections.emptyMap(), null, null));
+ }
+
+ /**
+ *
+ * @return
+ * the command stack
+ */
+ private CommandStack getCommandStack() {
+ EditingDomain domain = modelExplorerView.getEditingDomain();
+ Assert.isNotNull(domain, "I can't find the EditingDomain"); //$NON-NLS-1$
+ CommandStack commandStack = domain.getCommandStack();
+ Assert.isNotNull(commandStack, "I can't find the CommandStack"); //$NON-NLS-1$
+ return commandStack;
+ }
+
+ /**
+ *
+ * @param time
+ * the number of time we want to do Undo/Redo
+ */
+ protected void doUndoRedo(int time) {
+ Assert.isTrue(time >= 1);//to be sure that the calling method is correctly written
+ for(int i = 0; i < time; i++) {
+ doUndo();
+ doRedo();
+ }
+ }
+
+
+ /**
+ * We close the editors
+ */
+ @After
+ public void endOfTests() {
+ // So that the Workbench can be closed.
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
+ }
+}
diff --git a/incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/AllTests.java b/incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/AllTests.java
new file mode 100644
index 00000000000..c845442070d
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/AllTests.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 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 Guyomar (Mia-Software) - Bug 340681 - Facet column implementation
+ * Nicolas Guyomar (Mia-Software) - Bug 344413 - Facet Columns are never created when we begin with an empty table
+ * Nicolas Guyomar (Mia-Software) - Bug 344921 - Undo/Redo just after the creation of the table
+ * Nicolas Guyomar (Mia-Software) - Bug 346465 - [EMF Facet Table] Remove line does not remove obsolete column
+ * Gregoire Dupe (Mia-Software) - Bug 350700 - TableWidget: Wrong cell label in multi-valued facet reference columns
+ * Gregoire Dupe (Mia-Software) - Bug 345730 - Deleting an element in the model breaks the table
+ *******************************************************************************/
+package org.eclipse.papyrus.modelexplorer.test.tests;
+
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({
+ DeleteHandlerTest.class, RenameHandlerTest.class
+
+})
+public class AllTests {
+ // JUnit 4 test suite
+}
diff --git a/incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/DeleteHandlerTest.java b/incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/DeleteHandlerTest.java
new file mode 100644
index 00000000000..5b96594d0ff
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/DeleteHandlerTest.java
@@ -0,0 +1,246 @@
+/*****************************************************************************
+ * 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.modelexplorer.test.tests;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.swing.text.Element;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.CommandManager;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.commands.NotHandledException;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.facet.infra.browser.uicore.CustomizationManager;
+import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ITreeElement;
+import org.eclipse.emf.facet.infra.browser.uicore.internal.model.LinkItem;
+import org.eclipse.emf.facet.util.core.internal.FileUtils;
+import org.eclipse.gmf.runtime.emf.core.util.PackageUtil;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.core.editor.CoreMultiDiagramEditor;
+import org.eclipse.papyrus.core.utils.PapyrusTrace;
+import org.eclipse.papyrus.modelexplorer.Activator;
+import org.eclipse.papyrus.modelexplorer.ModelExplorerPage;
+import org.eclipse.papyrus.modelexplorer.ModelExplorerPageBookView;
+import org.eclipse.papyrus.modelexplorer.ModelExplorerView;
+import org.eclipse.papyrus.modelexplorer.handler.DeleteCommandHandler;
+import org.eclipse.papyrus.modelexplorer.handler.DeleteDiagramHandler;
+import org.eclipse.papyrus.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.table.instance.papyrustableinstance.PapyrusTableInstance;
+import org.eclipse.papyrus.table.modelexplorer.handlers.DeleteTableHandler;
+import org.eclipse.papyrus.table.modelexplorer.handlers.RenameTableHandler;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.internal.handlers.HandlerProxy;
+import org.eclipse.ui.part.IPage;
+import org.eclipse.ui.services.IServiceLocator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.DataType;
+import org.eclipse.uml2.uml.Model;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PackageImport;
+import org.eclipse.uml2.uml.PackageableElement;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.internal.impl.AssociationImpl;
+import org.eclipse.emf.facet.infra.facet.FacetFactory;
+import org.eclipse.emf.facet.infra.facet.FacetSet;
+import org.eclipse.emf.facet.infra.facet.impl.*;
+import org.eclipse.emf.facet.infra.browser.custom.MetamodelView ;
+/**
+ *
+ * @author VL222926
+ *
+ * This plugin tests the activation of the correct handler for differents selection in the ModelExplorer
+ */
+//FIXME : remove the dependency with EMF-Facet
+public class DeleteHandlerTest extends AbstractHandlerTest {
+
+ /**
+ * the id of the delete command
+ */
+ private static final String DELETE_COMMAND_ID = "org.eclipse.ui.edit.delete"; //$NON-NLS-1$
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public DeleteHandlerTest() {
+ super(DELETE_COMMAND_ID);
+ }
+
+ /**
+ * We test if we can delete the root of the Model or not
+ */
+ @Test
+ public void deleteRootOfTheModelTest() {
+ selectElementInTheModelexplorer(rootOfTheModel);
+ IHandler handler = getActiveHandler();
+ if(handler == null) {
+ //not a problem in this case
+ } else {
+ Assert.isTrue(handler.isEnabled() == false, NLS.bind("The handler {0} is enabled on the root of the model", handler) + " " + IT_IS_NOT_THE_REQUIRED_BEHAVIOR); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * We test if we can delete other uml elements
+ * @throws ExecutionException
+ * @throws NotHandledException
+ * @throws NotEnabledException
+ * @throws NotDefinedException
+ */
+ @Test
+ public void deleteUMLElementsTest() throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException {
+ List<PackageableElement> packagedElements = rootOfTheModel.getPackagedElements();
+ int nbInitialElement = packagedElements.size();
+ int j=1;
+ while(packagedElements.size()!=0){
+ selectElementInTheModelexplorer(packagedElements.get(0));
+ IHandler handler = getActiveHandler();
+ Assert.isTrue(handler instanceof DeleteCommandHandler, NLS.bind("The handler {0} is actived on {1} instead of org.eclipse.papyrus.modelexplorer.handler.DeleteCommandHandler", new Object[]{handler, packagedElements.get(0)})); //$NON-NLS-1$
+ Assert.isTrue(handler.isEnabled(), NLS.bind("The handler {0} is disabled on {1}.",new Object[]{handler,packagedElements.get(0)})+ " " + IT_IS_NOT_THE_REQUIRED_BEHAVIOR); //$NON-NLS-1$ //$NON-NLS-2$
+ executeActiveCommand();
+ int nbElement = packagedElements.size();
+ Assert.isTrue((nbElement+j) == nbInitialElement);
+ j++;
+ doUndoRedo(10);
+ }
+ }
+
+
+
+ /**
+ * We test the delete on the diagrams
+ * @throws ExecutionException
+ * @throws NotHandledException
+ * @throws NotEnabledException
+ * @throws NotDefinedException
+ */
+ @Test
+ public void deleteDiagramTest() throws NotDefinedException, NotEnabledException, NotHandledException, ExecutionException {
+ for(int i = 0; i < diagrams.size(); i++) {
+ selectElementInTheModelexplorer(diagrams.get(i));
+ IHandler handler = getActiveHandler();
+ Assert.isTrue(handler instanceof DeleteDiagramHandler, NLS.bind("The handler {0} is actived on {1} instead of instead of org.eclipse.papyrus.modelexplorer.handler.DeleteCommandHandler",handler)); //$NON-NLS-1$
+ Assert.isTrue(handler.isEnabled(), NLS.bind("The handler {0} is disabled on {1}.",new Object[]{handler,diagrams.get(i)})+ " " + IT_IS_NOT_THE_REQUIRED_BEHAVIOR); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * We test the delete on the table instance
+ */
+ @Test
+ public void deletePapyrusTableInstanceTest() {
+ for(int i = 0; i < papyrusTable.size(); i++) {
+ selectElementInTheModelexplorer(papyrusTable.get(i));
+ IHandler handler = getActiveHandler();
+ Assert.isTrue(handler instanceof DeleteTableHandler,NLS.bind("The handler {0} is actived on {1} instead of org.eclipse.papyrus.table.modelexplorer.handlers.DeleteTableHandler", new Object[]{handler, papyrusTable.get(i)})); //$NON-NLS-1$
+ Assert.isTrue(handler.isEnabled(), "We can't delete the following element" + papyrusTable.get(i)); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * We test the delete on the ReadOnly element
+ */
+ @Test
+ public void deleteReadOnlyElementsTest() {
+
+ List<PackageImport> packageImports = rootOfTheModel.getPackageImports();
+ commonViewer.expandToLevel(4);
+
+ //the method revealSemanticelement doesn't work for imported element (bug 360092), so we use a workaround to write this JUnit test
+ Object[] elements = commonViewer.getVisibleExpandedElements();
+ List<Object> readOnlyElement = new ArrayList<Object>();
+ for(int i=0;i<elements.length;i++){
+ Object current = elements[i];
+ if(current instanceof LinkItem){
+ if(((LinkItem)current).getReference().getName().equals("importedPackage")){ //$NON-NLS-1$
+ readOnlyElement.addAll(((LinkItem)current).getChildren());
+ break;
+ }
+
+ }
+ }
+
+ for(int j=0;j<readOnlyElement.size();j++){
+ selectElementInTheModelexplorer((ITreeElement)readOnlyElement.get(j));
+ IHandler handler = getActiveHandler();
+ if(handler==null){
+ //not a problem here
+ }else{
+ Assert.isTrue(!handler.isEnabled(),NLS.bind("The handler {0} is enabled on read-only element",handler) + IT_IS_NOT_THE_REQUIRED_BEHAVIOR); //$NON-NLS-1$
+ }
+ return;
+ }
+ }
+
+ /**
+ * we test the delete on the link item
+ */
+ @Test
+ public void deleteLinkItemTest() {
+ commonViewer.expandToLevel(3);
+ Object[] expandedElement = commonViewer.getExpandedElements();
+ for(Object object : expandedElement) {
+ if(object instanceof org.eclipse.emf.facet.infra.browser.uicore.internal.model.LinkItem) {
+ selectElementInTheModelexplorer((ITreeElement)object);
+ IHandler handler = getActiveHandler();
+ if(handler != null) {
+ Assert.isTrue(!handler.isEnabled(), NLS.bind("The handler {0} is enabled on LinkItem",handler) + IT_IS_NOT_THE_REQUIRED_BEHAVIOR); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+}
diff --git a/incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/RenameHandlerTest.java b/incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/RenameHandlerTest.java
new file mode 100644
index 00000000000..d7dcad4aae4
--- /dev/null
+++ b/incoming/org.eclipse.papyrus.modelexplorer.test/src/org/eclipse/papyrus/modelexplorer/test/tests/RenameHandlerTest.java
@@ -0,0 +1,162 @@
+/*****************************************************************************
+ * 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.modelexplorer.test.tests;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ITreeElement;
+import org.eclipse.emf.facet.infra.browser.uicore.internal.model.LinkItem;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.modelexplorer.handler.RenameDiagramHandler;
+import org.eclipse.papyrus.table.modelexplorer.handlers.RenameTableHandler;
+import org.eclipse.ui.internal.handlers.HandlerProxy;
+import org.eclipse.uml2.uml.Comment;
+import org.eclipse.uml2.uml.PackageImport;
+import org.junit.Test;
+
+/**
+ *
+ * This command test the activation of the command org.eclipse.ui.edit.rename
+ *
+ */
+public class RenameHandlerTest extends AbstractHandlerTest {
+
+ /**
+ * the id of the command to rename the element
+ */
+ private static final String commandId = "org.eclipse.ui.edit.rename"; //$NON-NLS-1$
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public RenameHandlerTest() {
+ super(commandId);
+ }
+
+ /**
+ * We try to rename an UnnamedElement
+ */
+ @Test
+ public void renameUMLUnnamedElementTest() {
+ List<Comment> comments = rootOfTheModel.getOwnedComments();
+ Assert.isTrue(comments.size() != 0);
+ for(int i = 0; i < rootOfTheModel.getOwnedComments().size(); i++) {
+ selectElementInTheModelexplorer(rootOfTheModel.getOwnedComments().get(i));
+ IHandler handler = getActiveHandler();
+ if(handler != null) {
+ Assert.isTrue(handler.isEnabled() == false, NLS.bind("The handler {0} is active on UMLUnnamedElement.", handler) + " " + IT_IS_NOT_THE_REQUIRED_BEHAVIOR); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+
+ /**
+ * We try to rename a NamedElement
+ */
+ @Test
+ public void renameUMLNamedElementTest() {
+ selectElementInTheModelexplorer(rootOfTheModel);
+ IHandler handler = getActiveHandler();
+ //TODO import the handler
+ Assert.isTrue(handler.getClass().getName().equals("org.eclipse.papyrus.uml.menu.handler.RenameNamedElementHandler"), NLS.bind("The handler {0} is actived on UML NamedElement, instead of org.eclipse.papyrus.uml.menu.handler.RenameNamedElementHandler",handler )); //$NON-NLS-1$ //$NON-NLS-2$
+ Assert.isTrue(handler.isEnabled(), NLS.bind("The handler {0} is disabled on {1}.",new Object[]{handler,rootOfTheModel})+ " " + IT_IS_NOT_THE_REQUIRED_BEHAVIOR); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
+ /**
+ * We try to rename a Diagram
+ */
+ @Test
+ public void renameDiagramTest() {
+ for(int i = 0; i < diagrams.size(); i++) {
+ selectElementInTheModelexplorer(diagrams.get(i));
+ IHandler handler = getActiveHandler();
+ Assert.isTrue(handler instanceof RenameDiagramHandler, NLS.bind("The handler {0} is actived on Diagram, instead of RenameDiagramHandler",handler )); //$NON-NLS-1$
+ Assert.isTrue(handler.isEnabled(),NLS.bind("The handler {0} is disabled on {1}.",new Object[]{handler,diagrams.get(i)})+ " " + IT_IS_NOT_THE_REQUIRED_BEHAVIOR); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * We try to rename a Table
+ */
+ @Test
+ public void renameTableTest() {
+ for(int i = 0; i < papyrusTable.size(); i++) {
+ selectElementInTheModelexplorer(papyrusTable.get(i));
+ IHandler handler = getActiveHandler();
+ Assert.isTrue(handler instanceof RenameTableHandler, NLS.bind("The handler {0} is actived on Table, instead of RenameTableHandler ",handler )); //$NON-NLS-1$
+ Assert.isTrue(handler.isEnabled(),NLS.bind("The handler {0} is disabled on {1}.",new Object[]{handler,papyrusTable.get(i)})+ " " + IT_IS_NOT_THE_REQUIRED_BEHAVIOR); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * We try to rename a readonly element
+ */
+ @Test
+ public void renameReadOnlyElementsTest() {
+ List<PackageImport> packageImports = rootOfTheModel.getPackageImports();
+ commonViewer.expandToLevel(4);
+
+ //the method revealSemanticelement doesn't work for imported element (bug 360092), so we use a workaround to write this JUnit test
+ Object[] elements = commonViewer.getVisibleExpandedElements();
+ List<Object> readOnlyElement = new ArrayList<Object>();
+ for(int i = 0; i < elements.length; i++) {
+ Object current = elements[i];
+ if(current instanceof LinkItem) {
+ if(((LinkItem)current).getReference().getName().equals("importedPackage")) { //$NON-NLS-1$
+ readOnlyElement.addAll(((LinkItem)current).getChildren());
+ break;
+ }
+
+ }
+ }
+
+ for(int j = 0; j < readOnlyElement.size(); j++) {
+ selectElementInTheModelexplorer((ITreeElement)readOnlyElement.get(j));
+ IHandler handler = getActiveHandler();
+ if(handler == null) {
+ //not a problem here
+ } else {
+ Assert.isTrue(handler.isEnabled()==false, NLS.bind("The handler {0} is enabled on {1}.",new Object[]{handler,readOnlyElement.get(j)})+ " " + IT_IS_NOT_THE_REQUIRED_BEHAVIOR); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return;
+ }
+ }
+
+ /**
+ * We try to rename a LinkItem
+ */
+ @Test
+ public void renameLinkItemTest() {
+ commonViewer.expandToLevel(3);
+ Object[] expandedElement = commonViewer.getExpandedElements();
+ for(Object object : expandedElement) {
+ if(object instanceof org.eclipse.emf.facet.infra.browser.uicore.internal.model.LinkItem) {
+ selectElementInTheModelexplorer((ITreeElement)object);
+ IHandler handler = getActiveHandler();
+ if(handler != null) {
+ Assert.isTrue(handler.isEnabled() == false, NLS.bind("The handler {0} is enabled on {1}.",new Object[]{handler,object})+ " " + IT_IS_NOT_THE_REQUIRED_BEHAVIOR); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+ }
+}

Back to the top