Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2011-10-25 12:15:24 +0000
committercletavernie2011-10-25 12:15:24 +0000
commitefaa35d99af2f347ef8a940bf1af3d09bbd362d9 (patch)
tree02759794764cc7bccd22f14e9f7a04c2546bae59 /plugins/views/properties
parent7803af6503cc8502ffd1d9a5ad20424d166b1a27 (diff)
downloadorg.eclipse.papyrus-efaa35d99af2f347ef8a940bf1af3d09bbd362d9.tar.gz
org.eclipse.papyrus-efaa35d99af2f347ef8a940bf1af3d09bbd362d9.tar.xz
org.eclipse.papyrus-efaa35d99af2f347ef8a940bf1af3d09bbd362d9.zip
359057: [Architecture - SVN - Build] The Papyrus architecture should be refactored
https://bugs.eclipse.org/bugs/show_bug.cgi?id=359057
Diffstat (limited to 'plugins/views/properties')
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.classpath7
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.project28
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/META-INF/MANIFEST.MF34
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/about.html28
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/build.properties7
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Add_12x12.gifbin0 -> 345 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/BrokenLink.gifbin0 -> 579 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Constraint.gifbin0 -> 101 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Constraints.gifbin0 -> 101 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Content.gifbin0 -> 324 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Delete_12x12.gifbin0 -> 367 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Down_12x12.gifbin0 -> 308 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Duplicate.gifbin0 -> 350 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewContainer.gifbin0 -> 109 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewExpandableContainer.gifbin0 -> 139 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewFragment.gifbin0 -> 158 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewGridLayout.gifbin0 -> 920 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewGroupContainer.gifbin0 -> 99 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewPredefinedController.gifbin0 -> 123 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewReplacedSection.gifbin0 -> 150 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewSection.gifbin0 -> 351 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewSectionSet.gifbin0 -> 351 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewSimpleContainer.gifbin0 -> 109 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Provider.gifbin0 -> 307 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Refresh.gifbin0 -> 327 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Save.gifbin0 -> 639 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Up_12x12.gifbin0 -> 338 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Validate.gifbin0 -> 998 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/delete.gifbin0 -> 351 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/local_desc.gifbin0 -> 313 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/newEMFTController.gifbin0 -> 123 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/plugin_desc.gifbin0 -> 328 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/type.gifbin0 -> 324 bytes
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/plugin.properties12
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/plugin.xml97
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/resources/configuration_predefined_fragments.xml219
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/resources/configuration_wizards_dialogs.xml238
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/Activator.java120
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/Messages.java137
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/AbstractValidationProblem.java58
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ConfigurationContentProvider.java212
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ConfigurationLabelProvider.java57
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ConfigurationValidator.java517
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ContentHolder.java89
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/CustomizeContentWizardPage.java1344
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/CustomizePropertyViewWizard.java57
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/MetamodelContentProvider.java223
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/MetamodelLabelProvider.java67
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/SelectConfigurationFileWizardPage.java1346
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/AbstractMenuCreator.java92
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ContainerMenuCreator.java235
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ContentHolderMenuCreator.java286
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ControllerMenuCreator.java146
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/EClassifierMenuCreator.java210
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/FragmentMenuCreator.java215
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/PredefinedFragmentMenuCreator.java146
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ReplacedSectionMenuCreator.java114
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/SectionMenuCreator.java285
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/SectionSetMenuCreator.java101
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/StereotypeMenuCreator.java193
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/handler/CustomizePropertyViewCommandHandler.java73
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/messages.properties53
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/BooleanStateBeanPropertyEditorController.java70
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/ConstraintStateUtils.java168
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/IntegerStateBeanPropertyEditorController.java35
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/ReferenceStateBeanPropertyEditorController.java285
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/StateBeanPropertyEditorController.java208
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/StatePropertyTabViewProviderParser.java103
70 files changed, 7926 insertions, 0 deletions
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.classpath b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.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/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.project b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.project
new file mode 100644
index 00000000000..7c1c7b176cc
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.properties.tabbed.customization</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/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.settings/org.eclipse.core.resources.prefs b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000000..03e406e417d
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+#Tue May 11 17:06:31 CEST 2010
+eclipse.preferences.version=1
+encoding//src/org/eclipse/papyrus/properties/tabbed/customization/messages.properties=ISO-8859-1
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.settings/org.eclipse.jdt.core.prefs b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..4e7827f3562
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Tue May 11 10:51:57 CEST 2010
+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/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/META-INF/MANIFEST.MF b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..f3630f3bd15
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/META-INF/MANIFEST.MF
@@ -0,0 +1,34 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-Localization: plugin
+Bundle-SymbolicName: org.eclipse.papyrus.properties.tabbed.customization;singleton:=true
+Bundle-Version: 0.9.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.properties.tabbed.customization.Activator
+Bundle-Vendor: %providerName
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.ui.views;bundle-version="3.5.0",
+ org.eclipse.papyrus.properties.tabbed.core;bundle-version="0.8.0",
+ org.eclipse.papyrus.log;bundle-version="0.8.0",
+ org.eclipse.papyrus.properties.runtime;bundle-version="0.8.0",
+ org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.0",
+ org.eclipse.gmf.runtime.common.ui.services;bundle-version="1.3.0",
+ org.eclipse.emf.ecore;bundle-version="2.6.0",
+ org.eclipse.emf.ecore.edit;bundle-version="2.6.0",
+ org.eclipse.papyrus.core;bundle-version="0.8.0",
+ org.eclipse.uml2.uml;bundle-version="3.1.0",
+ org.eclipse.papyrus.umlutils;bundle-version="0.8.0",
+ org.apache.xml.serializer;bundle-version="2.7.1",
+ org.apache.batik.xml;bundle-version="1.6.0",
+ org.apache.xml.resolver;bundle-version="1.2.0",
+ org.eclipse.emf.facet.infra.browser.custom;bundle-version="0.1.0",
+ org.eclipse.emf.facet.infra.browser.custom.core;bundle-version="0.1.0",
+ org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.1.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.papyrus.properties.tabbed.customization,
+ org.eclipse.papyrus.properties.tabbed.customization.dialog,
+ org.eclipse.papyrus.properties.tabbed.customization.dialog.actions,
+ org.eclipse.papyrus.properties.tabbed.customization.handler,
+ org.eclipse.papyrus.properties.tabbed.customization.state
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/about.html b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/about.html
new file mode 100644
index 00000000000..209103075a7
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/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>November 14, 2008</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/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/build.properties b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/build.properties
new file mode 100644
index 00000000000..424a6089dd8
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/build.properties
@@ -0,0 +1,7 @@
+#
+#Mon Sep 12 09:30:07 CEST 2011
+bin.includes=META-INF/,.,icons/,plugin.properties,plugin.xml,resources/,about.html
+output..=bin/
+src.includes=META-INF/,.,icons/,plugin.properties,plugin.xml,resources/,about.html
+source..=src/
+bin..=bin/
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Add_12x12.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Add_12x12.gif
new file mode 100644
index 00000000000..189b46e5a5b
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Add_12x12.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/BrokenLink.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/BrokenLink.gif
new file mode 100644
index 00000000000..99c69bde431
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/BrokenLink.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Constraint.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Constraint.gif
new file mode 100644
index 00000000000..eed6acec1ee
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Constraint.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Constraints.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Constraints.gif
new file mode 100644
index 00000000000..eed6acec1ee
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Constraints.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Content.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Content.gif
new file mode 100644
index 00000000000..7ef81e587bd
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Content.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Delete_12x12.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Delete_12x12.gif
new file mode 100644
index 00000000000..bd924a5e0fa
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Delete_12x12.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Down_12x12.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Down_12x12.gif
new file mode 100644
index 00000000000..c0672e72a2b
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Down_12x12.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Duplicate.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Duplicate.gif
new file mode 100644
index 00000000000..e7dc14e5934
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Duplicate.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewContainer.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewContainer.gif
new file mode 100644
index 00000000000..7bb44f59cc8
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewContainer.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewExpandableContainer.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewExpandableContainer.gif
new file mode 100644
index 00000000000..3eb5e02a4d5
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewExpandableContainer.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewFragment.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewFragment.gif
new file mode 100644
index 00000000000..d6f284d26df
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewFragment.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewGridLayout.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewGridLayout.gif
new file mode 100644
index 00000000000..f25be4f997e
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewGridLayout.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewGroupContainer.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewGroupContainer.gif
new file mode 100644
index 00000000000..d85b06b9d3f
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewGroupContainer.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewPredefinedController.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewPredefinedController.gif
new file mode 100644
index 00000000000..bc9944a7d53
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewPredefinedController.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewReplacedSection.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewReplacedSection.gif
new file mode 100644
index 00000000000..c01c38436f0
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewReplacedSection.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewSection.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewSection.gif
new file mode 100644
index 00000000000..645141285f7
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewSection.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewSectionSet.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewSectionSet.gif
new file mode 100644
index 00000000000..645141285f7
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewSectionSet.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewSimpleContainer.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewSimpleContainer.gif
new file mode 100644
index 00000000000..7bb44f59cc8
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/NewSimpleContainer.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Provider.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Provider.gif
new file mode 100644
index 00000000000..560efc034e9
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Provider.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Refresh.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Refresh.gif
new file mode 100644
index 00000000000..3ca04d06ff9
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Refresh.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Save.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Save.gif
new file mode 100644
index 00000000000..499dd0ca602
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Save.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Up_12x12.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Up_12x12.gif
new file mode 100644
index 00000000000..9620d683cbd
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Up_12x12.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Validate.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Validate.gif
new file mode 100644
index 00000000000..5a1008341f9
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/Validate.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/delete.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/delete.gif
new file mode 100644
index 00000000000..b6922ac11cf
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/delete.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/local_desc.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/local_desc.gif
new file mode 100644
index 00000000000..d55b09f2e4b
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/local_desc.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/newEMFTController.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/newEMFTController.gif
new file mode 100644
index 00000000000..bc9944a7d53
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/newEMFTController.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/plugin_desc.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/plugin_desc.gif
new file mode 100644
index 00000000000..8493df40dfe
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/plugin_desc.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/type.gif b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/type.gif
new file mode 100644
index 00000000000..7ef81e587bd
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/icons/type.gif
Binary files differ
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/plugin.properties b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/plugin.properties
new file mode 100644
index 00000000000..c58a5855214
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/plugin.properties
@@ -0,0 +1,12 @@
+#################################################################################
+# Copyright (c) 2010 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
+##################################################################################
+pluginName=Papyrus Tabbed Properties Customization Tool (Incubation)
+providerName=Eclipse Modeling Project
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/plugin.xml b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/plugin.xml
new file mode 100644
index 00000000000..ef24c5b4e85
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/plugin.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ categoryId="org.eclipse.papyrus.editor.category"
+ defaultHandler="org.eclipse.papyrus.properties.tabbed.customization.handler.CustomizePropertyViewCommandHandler"
+ description="This command allows customization of the content of the properties view"
+ id="org.eclipse.papyrus.properties.tabbed.customize"
+ name="Customize properties view">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="menu:org.eclipse.ui.views.PropertySheet">
+ <command
+ commandId="org.eclipse.papyrus.properties.tabbed.customize"
+ icon="icons/type.gif"
+ id="org.eclipse.papyrus.properties.tabbed.customizehandler"
+ label="Customize Property view"
+ mnemonic="C"
+ mode="FORCE_TEXT"
+ style="push"
+ tooltip="Customize the content of the Property View">
+ <visibleWhen
+ checkEnabled="true">
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.properties.runtime.propertyViewProvider">
+ <propertyViewProvider
+ class="org.eclipse.papyrus.properties.runtime.view.XMLPropertyViewProvider">
+ <Priority
+ name="Lowest">
+ </Priority>
+ <PropertyViewContribution
+ name="Property Editor configuration dialogs"
+ id="propertyview.customization.dialogs"
+ icon="/icons/Provider.gif"
+ path="resources/configuration_wizards_dialogs.xml">
+ </PropertyViewContribution>
+ </propertyViewProvider>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.properties.runtime.propertyEditorControllerProvider">
+ <propertyEditorControllerProvider
+ class="org.eclipse.papyrus.properties.runtime.controller.PropertyEditorControllerProvider"
+ description="Property editor controller provider for states "
+ id="customizationPropertyEditorControllerProvider">
+ <Priority
+ name="Lowest">
+ </Priority>
+ <PropertyEditorController
+ class="org.eclipse.papyrus.properties.tabbed.customization.state.StateBeanPropertyEditorController"
+ description="controller for states in the customization wizard"
+ factory="org.eclipse.papyrus.properties.runtime.controller.descriptor.BeanPropertyEditorControllerDescriptorFactory"
+ id="stateBeanPropertyEditorController">
+ </PropertyEditorController>
+ <PropertyEditorController
+ class="org.eclipse.papyrus.properties.tabbed.customization.state.BooleanStateBeanPropertyEditorController"
+ factory="org.eclipse.papyrus.properties.runtime.controller.descriptor.BeanPropertyEditorControllerDescriptorFactory"
+ id="booleanStateBeanPropertyEditorController">
+ </PropertyEditorController>
+ <PropertyEditorController
+ class="org.eclipse.papyrus.properties.tabbed.customization.state.IntegerStateBeanPropertyEditorController"
+ factory="org.eclipse.papyrus.properties.runtime.controller.descriptor.BeanPropertyEditorControllerDescriptorFactory"
+ id="integerStateBeanPropertyEditorController">
+ </PropertyEditorController>
+ <PropertyEditorController
+ class="org.eclipse.papyrus.properties.tabbed.customization.state.ReferenceStateBeanPropertyEditorController"
+ factory="org.eclipse.papyrus.properties.runtime.controller.descriptor.BeanPropertyEditorControllerDescriptorFactory"
+ id="referenceStateBeanPropertyEditorController">
+ </PropertyEditorController>
+ </propertyEditorControllerProvider>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.properties.runtime.propertyViewProvider">
+ <propertyViewProvider
+ class="org.eclipse.papyrus.properties.runtime.view.XMLPropertyViewProvider">
+ <Priority
+ name="Lowest">
+ </Priority>
+ <PropertyViewContribution
+ description="Predefined fragments for Configuraiton of property view"
+ id="propertyview.customization.fragments"
+ icon="icons/Provider.gif"
+ name="Predefined Fragments For Configuration"
+ path="resources/configuration_predefined_fragments.xml">
+ </PropertyViewContribution>
+ </propertyViewProvider>
+ </extension>
+</plugin>
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/resources/configuration_predefined_fragments.xml b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/resources/configuration_predefined_fragments.xml
new file mode 100644
index 00000000000..029b80b2346
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/resources/configuration_predefined_fragments.xml
@@ -0,0 +1,219 @@
+<!--UML Basic fragment-->
+<fragments pluginId="org.eclipse.papyrus.properties.tabbed.customization">
+ <fragment id="fragment_single_ExpandableContainerDescriptorState">
+ <context enablesFor="1">
+ <elementClass name="org.eclipse.papyrus.properties.runtime.view.content.ExpandableContainerDescriptor$ExpandableContainerDescriptorState"/>
+ </context>
+ <content>
+ <container>
+ <layout kind="Grid" numColumns="1" sameWidth="false"/>
+ <controller id="stateBeanPropertyEditorController">
+ <property name="name"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="Label:" labelPosition="16384"/>
+ </controller>
+ </container>
+ </content>
+ </fragment>
+ <fragment id="fragment_single_GroupContainerDescriptorState">
+ <context enablesFor="1">
+ <elementClass name="org.eclipse.papyrus.properties.runtime.view.content.GroupContainerDescriptor$GroupContainerDescriptorState"/>
+ </context>
+ <content>
+ <container >
+ <layout kind="Grid" numColumns="1" sameWidth="false"/>
+ <controller id="stateBeanPropertyEditorController">
+ <property name="name"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="Label:" labelPosition="16384"/>
+ </controller>
+ </container>
+ </content>
+ </fragment>
+ <fragment id="fragment_single_FragmentDescriptorState">
+ <context enablesFor="1">
+ <elementClass name="org.eclipse.papyrus.properties.runtime.view.FragmentDescriptorState"/>
+ </context>
+ <content>
+ <container>
+ <layout kind="Grid" numColumns="1" sameWidth="false"/>
+ <controller id="stateBeanPropertyEditorController">
+ <property name="id"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="Identifier:" labelPosition="16384"/>
+ </controller>
+ <controller id="integerStateBeanPropertyEditorController">
+ <property name="selectionSize"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="Selection Size:" labelPosition="16384"/>
+ </controller>
+ </container>
+ </content>
+ </fragment>
+ <fragment id="fragment_single_SectionDescriptorState"> <!-- fragment for controller descriptor state -->
+ <context enablesFor="1">
+ <elementClass name="org.eclipse.papyrus.properties.tabbed.core.view.SectionDescriptorState"/>
+ </context>
+ <content>
+ <container>
+ <layout kind="Grid" numColumns="1" sameWidth="false"/>
+ <controller id="stateBeanPropertyEditorController">
+ <property name="id"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="Identifier:" labelPosition="16384"/>
+ </controller>
+ <controller id="referenceStateBeanPropertyEditorController">
+ <property name="targetTab"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.simpleReferencePropertyEditor" label="Tab Identifier:" labelPosition="16384"/>
+ </controller>
+ <controller id="referenceStateBeanPropertyEditorController">
+ <property name="afterSection"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.simpleReferencePropertyEditor" label="After Section:" labelPosition="16384"/>
+ </controller>
+ </container>
+ </content>
+ </fragment>
+ <fragment id="fragment_single_SectionSetDescriptorState"> <!-- fragment for controller descriptor state -->
+ <context enablesFor="1">
+ <elementClass name="org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState"/>
+ </context>
+ <content>
+ <container>
+ <layout kind="Grid" numColumns="1" sameWidth="false"/>
+ <controller id="stateBeanPropertyEditorController">
+ <property name="name"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="Name:" labelPosition="16384"/>
+ </controller>
+ <controller id="integerStateBeanPropertyEditorController">
+ <property name="selectionSize"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="Selection Size:" labelPosition="16384"/>
+ </controller>
+ </container>
+ </content>
+ </fragment>
+ <fragment id="fragment_single_ControllerDescriptorState">
+ <context enablesFor="1">
+ <elementClass name="org.eclipse.papyrus.properties.runtime.controller.descriptor.ControllerDescriptorState"></elementClass>
+ </context>
+ <content>
+ <container>
+ <layout kind="Grid" numColumns="1" sameWidth="false"/>
+ <controller id="stateBeanPropertyEditorController">
+ <property name="id"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="Identifier:" labelPosition="16384"/>
+ </controller>
+ <controller id="stateBeanPropertyEditorController">
+ <property name="id"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="Identifier:" labelPosition="16384"/>
+ </controller>
+ </container>
+ </content>
+ </fragment>
+ <fragment id="fragment_single_GridLayoutDescriptorState">
+ <context enablesFor="1">
+ <elementClass name="org.eclipse.papyrus.properties.runtime.view.content.GridLayoutDescriptor"/>
+ </context>
+ <content>
+ <container>
+ <layout kind="Grid" numColumns="1" sameWidth="false"/>
+ <controller id="integerStateBeanPropertyEditorController">
+ <property name="numColumns"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="Number of Columns:" labelPosition="16384"/>
+ </controller>
+ <controller id="booleanStateBeanPropertyEditorController">
+ <property name="sameWidth"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.radioBoxPropertyEditor" label="Columns equal width:" labelPosition="16384"/>
+ </controller>
+ </container>
+ </content>
+ </fragment>
+
+ <!-- Sub feature section and cie -->
+ <fragment id="fragment_single_SubFeatureSectionDescriptorState">
+ <context enablesFor="1">
+ <elementClass name="org.eclipse.papyrus.properties.tabbed.core.view.subfeatures.DynamicSubFeatureSectionDescriptor$SubFeatureSectionDescriptorState"/>
+ </context>
+ <content>
+ <container>
+ <layout kind="Grid" numColumns="1" sameWidth="false"/>
+ <controller id="integerStateBeanPropertyEditorController">
+ <property name="maxColumn"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="Maximum number of Columns:" labelPosition="16384"/>
+ </controller>
+ </container>
+ </content>
+ </fragment>
+ <fragment id="fragment_single_GroupContainerSubFeatureSectionDescriptorState">
+ <context enablesFor="1">
+ <elementClass name="org.eclipse.papyrus.properties.tabbed.core.view.subfeatures.GroupContainerDescriptor$GroupContainerDescriptorState"/>
+ </context>
+ <content>
+ <container>
+ <layout kind="Grid" numColumns="1" sameWidth="false"/>
+ <controller id="stateBeanPropertyEditorController">
+ <property name="label"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="CLabel:" labelPosition="16384"/>
+ </controller>
+ </container>
+ </content>
+ </fragment>
+ <fragment id="fragment_single_ExpandableContainerSubFeatureSectionDescriptorState">
+ <context enablesFor="1">
+ <elementClass name="org.eclipse.papyrus.properties.tabbed.core.view.subfeatures.ExpandableContainerDescriptor$ExpandableContainerDescriptorState"/>
+ </context>
+ <content>
+ <container>
+ <layout kind="Grid" numColumns="1" sameWidth="false"/>
+ <controller id="stateBeanPropertyEditorController">
+ <property name="label"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="CLabel:" labelPosition="16384"/>
+ </controller>
+ </container>
+ </content>
+ </fragment>
+ <fragment id="fragment_single_EMFSimpleSubFeatureDescriptorState">
+ <context enablesFor="1">
+ <elementClass name="org.eclipse.papyrus.properties.tabbed.core.view.subfeatures.EMFSimpleSubFeatureDescriptor$EMFSimpleSubFeatureDescriptorState"/>
+ </context>
+ <content>
+ <container>
+ <layout kind="Grid" numColumns="1" sameWidth="false"/>
+ <controller id="stateBeanPropertyEditorController">
+ <property name="featureNameState"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="Feature Name:" labelPosition="16384"/>
+ </controller>
+ </container>
+ </content>
+ </fragment>
+ <fragment id="fragment_single_ReplacedSectionState">
+ <context enablesFor="1">
+ <elementClass name="org.eclipse.papyrus.properties.tabbed.core.view.SectionDescriptorState$ReplacedSectionState"/>
+ </context>
+ <content>
+ <container>
+ <layout kind="Grid" numColumns="1" sameWidth="false"/>
+ <controller id="referenceStateBeanPropertyEditorController">
+ <property name="id"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.simpleReferencePropertyEditor" label="Identifier:" labelPosition="16384"/>
+ </controller>
+ </container>
+ </content>
+ </fragment>
+ <fragment id="fragment_TabDescriptorState">
+ <context enablesFor="1">
+ <elementClass name="org.eclipse.papyrus.properties.tabbed.core.view.TabDescriptorState"/>
+ </context>
+ <content>
+ <container>
+ <layout kind="Grid" numColumns="1" sameWidth="false"/>
+ <controller id="stateBeanPropertyEditorController">
+ <property name="category" />
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="Category:" labelPosition="16384" />
+ </controller>
+ <controller id="stateBeanPropertyEditorController">
+ <property name="id"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="Identifier:" labelPosition="16384"/>
+ </controller>
+ <controller id="stateBeanPropertyEditorController">
+ <property name="label"/>
+ <editor id="org.eclipse.papyrus.properties.runtime.textPropertyEditor" label="Label:" labelPosition="16384"/>
+ </controller>
+ </container>
+ </content>
+ </fragment>
+</fragments> \ No newline at end of file
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/resources/configuration_wizards_dialogs.xml b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/resources/configuration_wizards_dialogs.xml
new file mode 100644
index 00000000000..294c4c4873a
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/resources/configuration_wizards_dialogs.xml
@@ -0,0 +1,238 @@
+<!-- Generic dialogs for UML elements -->
+<dialogs pluginId="org.eclipse.papyrus.properties.tabbed.customization">
+ <dialog id="ControllerDescriptorEditorDialog"><!-- Dialog for single controller descriptor state -->
+ <context enablesFor="1">
+ <elementClass
+ name="org.eclipse.papyrus.properties.runtime.controller.descriptor.ControllerDescriptorState">
+ </elementClass>
+ </context>
+ <title>
+ <string value="Edit Controller Descriptor"/>
+ </title>
+ <message>
+ <string value="Edit Controller Descriptor Message"/>
+ </message>
+ <content>
+ <fragment predefinedId="fragment_single_ControllerDescriptorState"/> <!-- fragment for controller descriptor state -->
+ </content>
+ </dialog>
+ <dialog id="SectionDescriptorStateDialog"><!-- Dialog for single section descriptor state -->
+ <context enablesFor="1">
+ <elementClass
+ name="org.eclipse.papyrus.properties.tabbed.core.view.SectionDescriptorState">
+ </elementClass>
+ </context>
+ <title>
+ <string value="Edit Section Descriptor"/>
+ </title>
+ <message>
+ <string value="Edit Section Descriptor Message"/>
+ </message>
+ <content>
+ <fragment predefinedId="fragment_single_SectionDescriptorState"/> <!-- fragment for controller descriptor state -->
+ </content>
+ </dialog>
+ <dialog id="SectionSetDescriptorStateDialog"><!-- Dialog for single section set descriptor state -->
+ <context enablesFor="1">
+ <elementClass
+ name="org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState">
+ </elementClass>
+ </context>
+ <title>
+ <string value="Edit Section Set Descriptor"/>
+ </title>
+ <message>
+ <string value="Edit Section Set Descriptor Message"/>
+ </message>
+ <content>
+ <fragment predefinedId="fragment_single_SectionSetDescriptorState"/> <!-- fragment for section set descriptor state -->
+ </content>
+ </dialog>
+ <dialog id="FragmentDescriptorStateDialog"><!-- Dialog for single fragment descriptor state -->
+ <context enablesFor="1">
+ <elementClass
+ name="org.eclipse.papyrus.properties.runtime.view.FragmentDescriptorState">
+ </elementClass>
+ </context>
+ <title>
+ <string value="Edit Fragment Descriptor"/>
+ </title>
+ <message>
+ <string value="Edit Fragment Descriptor Message"/>
+ </message>
+ <content>
+ <fragment predefinedId="fragment_single_FragmentDescriptorState"/>
+ </content>
+ </dialog>
+ <dialog id="ContainerDescriptorStateDialog"><!-- Dialog for single container descriptor state -->
+ <context enablesFor="1">
+ <elementClass
+ name="org.eclipse.papyrus.properties.runtime.view.content.ContainerDescriptorState">
+ </elementClass>
+ </context>
+ <title>
+ <string value="Edit Container Descriptor"/>
+ </title>
+ <message>
+ <string value="Edit Container Descriptor Message"/>
+ </message>
+ <content>
+ <fragment predefinedId="fragment_single_ContainerDescriptorState"/>
+ </content>
+ </dialog>
+ <dialog id="GroupContainerDescriptorStateDialog">
+ <context enablesFor="1">
+ <elementClass
+ name="org.eclipse.papyrus.properties.runtime.view.content.GroupContainerDescriptor$GroupContainerDescriptorState">
+ </elementClass>
+ <replacedDialogs>
+ <replacedDialog id="ContainerDescriptorStateDialog"/>
+ </replacedDialogs>
+ </context>
+ <title>
+ <string value="Edit Group Container Descriptor"/>
+ </title>
+ <message>
+ <string value="Edit Group Container Descriptor Message"/>
+ </message>
+ <content>
+ <fragment predefinedId="fragment_single_ContainerDescriptorState"/>
+ <fragment predefinedId="fragment_single_GroupContainerDescriptorState"/>
+ </content>
+ </dialog>
+ <dialog id="ExpandableContainerDescriptorStateDialog"><!-- Dialog for single section descriptor state -->
+ <context enablesFor="1">
+ <elementClass
+ name="org.eclipse.papyrus.properties.runtime.view.content.ExpandableContainerDescriptor$ExpandableContainerDescriptorState">
+ </elementClass>
+ <replacedDialogs>
+ <replacedDialog id="ContainerDescriptorStateDialog"/>
+ </replacedDialogs>
+ </context>
+ <title>
+ <string value="Edit Expandable Container Descriptor"/>
+ </title>
+ <message>
+ <string value="Edit Expandable Container Descriptor Message"/>
+ </message>
+ <content>
+ <fragment predefinedId="fragment_single_ContainerDescriptorState"/>
+ <fragment predefinedId="fragment_single_ExpandableContainerDescriptorState"/>
+ </content>
+ </dialog>
+ <dialog id="GridLayoutDescriptorStateDialog"><!-- Dialog for single section descriptor state -->
+ <context enablesFor="1">
+ <elementClass
+ name="org.eclipse.papyrus.properties.runtime.view.content.GridLayoutDescriptor">
+ </elementClass>
+ </context>
+ <title>
+ <string value="Edit Grid Layout Descriptor"/>
+ </title>
+ <message>
+ <string value="Edit Grid Layout Message"/>
+ </message>
+ <content>
+ <fragment predefinedId="fragment_single_GridLayoutDescriptorState"/>
+ </content>
+ </dialog>
+
+ <!-- Sub Feature Section -->
+ <dialog id="SubFeatureSectionDescriptorStateDialog"><!-- Dialog for single sub feature descriptor state -->
+ <context enablesFor="1">
+ <elementClass
+ name="org.eclipse.papyrus.properties.tabbed.core.view.subfeatures.DynamicSubFeatureSectionDescriptor$SubFeatureSectionDescriptorState">
+ </elementClass>
+ </context>
+ <title>
+ <string value="Edit Subfeature section Descriptor"/>
+ </title>
+ <message>
+ <string value="Edit Subfeature section Descriptor Message"/>
+ </message>
+ <content>
+ <fragment predefinedId="fragment_single_SectionDescriptorState"/>
+ <fragment predefinedId="fragment_single_SubFeatureSectionDescriptorState"/>
+ </content>
+ </dialog>
+ <dialog id="SubFeatureGroupContainerDescriptorStateDialog"><!-- Dialog for single group container descriptor state -->
+ <context enablesFor="1">
+ <elementClass
+ name="org.eclipse.papyrus.properties.tabbed.core.view.subfeatures.GroupContainerDescriptor$GroupContainerDescriptorState">
+ </elementClass>
+ </context>
+ <title>
+ <string value="Edit Group container subFeature section Descriptor"/>
+ </title>
+ <message>
+ <string value="Edit Group container subFeature section Descriptor Message"/>
+ </message>
+ <content>
+ <fragment predefinedId="fragment_single_GroupContainerSubFeatureSectionDescriptorState"/>
+ </content>
+ </dialog>
+ <dialog id="SubFeatureExpandableContainerDescriptorStateDialog"><!-- Dialog for single expandable container descriptor state -->
+ <context enablesFor="1">
+ <elementClass
+ name="org.eclipse.papyrus.properties.tabbed.core.view.subfeatures.ExpandableContainerDescriptor$ExpandableContainerDescriptorState">
+ </elementClass>
+ </context>
+ <title>
+ <string value="Edit Expandable container subFeature section Descriptor"/>
+ </title>
+ <message>
+ <string value="Edit Expandable container subFeature section Descriptor Message"/>
+ </message>
+ <content>
+ <fragment predefinedId="fragment_single_ExpandableContainerSubFeatureSectionDescriptorState"/>
+ </content>
+ </dialog>
+ <dialog id="EMFSimpleSubFeatureDescriptorStateDialog"><!-- Dialog for single emf feature descriptor state -->
+ <context enablesFor="1">
+ <elementClass
+ name="org.eclipse.papyrus.properties.tabbed.core.view.subfeatures.EMFSimpleSubFeatureDescriptor$EMFSimpleSubFeatureDescriptorState">
+ </elementClass>
+ </context>
+ <title>
+ <string value="Edit EMF Feature Descriptor"/>
+ </title>
+ <message>
+ <string value="Edit EMF Feature Descriptor Message"/>
+ </message>
+ <content>
+ <fragment predefinedId="fragment_single_EMFSimpleSubFeatureDescriptorState"/>
+ </content>
+ </dialog>
+ <dialog id="ReplacedSectionStateDialog"><!-- Dialog for single emf feature descriptor state -->
+ <context enablesFor="1">
+ <elementClass
+ name="org.eclipse.papyrus.properties.tabbed.core.view.SectionDescriptorState$ReplacedSectionState">
+ </elementClass>
+ </context>
+ <title>
+ <string value="Edit Replaced Section"/>
+ </title>
+ <message>
+ <string value="Edit Replaced Section Message"/>
+ </message>
+ <content>
+ <fragment predefinedId="fragment_single_ReplacedSectionState"/>
+ </content>
+ </dialog>
+ <dialog id="TabDescriptorStateDialog"><!-- Dialog for tab descriptor state -->
+ <context enablesFor="1">
+ <elementClass
+ name="org.eclipse.papyrus.properties.tabbed.core.view.TabDescriptorState">
+ </elementClass>
+ </context>
+ <title>
+ <string value="Edit tab"/>
+ </title>
+ <message>
+ <string value="Edit tab Message"/>
+ </message>
+ <content>
+ <fragment predefinedId="fragment_TabDescriptorState"/>
+ </content>
+ </dialog>
+</dialogs> \ No newline at end of file
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/Activator.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/Activator.java
new file mode 100644
index 00000000000..2ebaf1ac740
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/Activator.java
@@ -0,0 +1,120 @@
+package org.eclipse.papyrus.properties.tabbed.customization;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.facet.infra.browser.custom.MetamodelView;
+import org.eclipse.emf.facet.infra.browser.custom.core.CustomizationsCatalog;
+import org.eclipse.emf.facet.infra.browser.uicore.CustomizationManager;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.papyrus.log.LogHelper;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+@SuppressWarnings("restriction")
+public class Activator extends AbstractUIPlugin {
+
+ /** plugin ID */
+ public static final String ID = "org.eclipse.papyrus.properties.tabbed.customization"; //$NON-NLS-1$
+
+ /** singleton instance */
+ private static Activator plugin;
+
+ /** Logging helper */
+ public static LogHelper log;
+
+ /** customization manager for modisco label and content provider */
+ private CustomizationManager fCustomizationManager;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(plugin);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ log = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ *
+ * @return the customization manager in charge to adapt element in modisco
+ */
+ public CustomizationManager getCustomizationManager() {
+ if(this.fCustomizationManager == null) {
+ this.fCustomizationManager = new CustomizationManager();
+ init(this.fCustomizationManager);
+ }
+ return this.fCustomizationManager;
+ }
+
+ /**
+ * Initializes the customization manager for this plugin.
+ *
+ * @param customizationManager
+ * the customization manager to initialize
+ */
+ private void init(final CustomizationManager customizationManager) {
+ // the appearance can be customized here:
+ try {
+ // load customizations defined as default through the customization
+ // extension
+ List<MetamodelView> registryDefaultCustomizations = CustomizationsCatalog.getInstance().getRegistryDefaultCustomizations();
+ for(MetamodelView metamodelView : registryDefaultCustomizations) {
+ customizationManager.registerCustomization(metamodelView);
+ }
+ customizationManager.loadCustomizations();
+ } catch (Throwable e) {
+ Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.ID, "Error initializing customizations", e)); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Returns the image from the given image descriptor
+ *
+ * @param descriptor
+ * the descriptor of the image to be displayed
+ * @return the image found
+ */
+ public static Image getImage(String path) {
+ final ImageRegistry registry = getDefault().getImageRegistry();
+ Image image = registry.get(path);
+ if(image == null) {
+ registry.put(path, Activator.imageDescriptorFromPlugin(ID, path));
+ image = registry.get(path);
+ }
+ return image;
+
+ }
+
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/Messages.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/Messages.java
new file mode 100644
index 00000000000..893fec16921
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/Messages.java
@@ -0,0 +1,137 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Messages internationalization.
+ */
+public class Messages extends NLS {
+
+ /** name of the bundle */
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.properties.tabbed.customization.messages"; //$NON-NLS-1$
+
+ public static String CustomizeContentWizardPage_ConfigurationArea_Label;
+
+ public static String CustomizeContentWizardPage_ContentArea_Label;
+
+ public static String CustomizeContentWizardPage_Error_NoActiveDiagram;
+
+ public static String CustomizeContentWizardPage_Error_NoEditorForElement;
+
+ public static String CustomizeContentWizardPage_Error_NoRootNode;
+
+ public static String CustomizeContentWizardPage_Error_NoSelectionForMenuCreation;
+
+ public static String CustomizeContentWizardPage_Error_NoSelectionFound;
+
+ public static String CustomizeContentWizardPage_Error_OutOfBoundExceptionIndex;
+
+ public static String CustomizeContentWizardPage_Error_SelectionStereotypeOrClassifier;
+
+ public static String CustomizeContentWizardPage_Job_SavingConfiguration;
+
+ public static String CustomizeContentWizardPage_Message;
+
+ public static String CustomizeContentWizardPage_PreviewArea_Label;
+
+ public static String CustomizeContentWizardPage_PreviewArea_RefreshButtonTooltip;
+
+ public static String CustomizeContentWizardPage_PreviewArea_SaveButtonTooltip;
+
+ public static String CustomizeContentWizardPage_PreviewArea_SelectionSizeLabel;
+
+ public static String CustomizeContentWizardPage_Title;
+
+ public static String CustomizeContentWizardPage_Warning_NoStereotypeNeitherMetaclass;
+
+ public static String CustomizePropertyViewDialog_Title;
+
+ public static String SelectConfigurationFileWizardPage_ErrorMessage_NoValidTextArea;
+
+ public static String SelectConfigurationFileWizardPage_ErrorMessage_notValidName;
+
+ public static String SelectConfigurationFileWizardPage_CreateAnEmptyConfig_Label;
+
+ public static String SelectConfigurationFileWizardPage_CreateAnEmptyConfigName_DefaultValue;
+
+ public static String SelectConfigurationFileWizardPage_CreateAnEmptyConfigName_Label;
+
+ public static String SelectConfigurationFileWizardPage_CreateAnEmptyConfigName_Tooltip;
+
+ public static String SelectConfigurationFileWizardPage_CreateAnEmptyConfigPluginId_DefaultValue;
+
+ public static String SelectConfigurationFileWizardPage_CreateAnEmptyConfigPluginId_Label;
+
+ public static String SelectConfigurationFileWizardPage_CreateAnEmptyConfigPluginId_Tooltip;
+
+ public static String SelectConfigurationFileWizardPage_CreateFromExistingConfigFile_Dialog_Message;
+
+ public static String SelectConfigurationFileWizardPage_CreateFromExistingConfigFile_Dialog_Title;
+
+ public static String SelectConfigurationFileWizardPage_CreateFromExistingConfigFile_Label;
+
+ public static String SelectConfigurationFileWizardPage_CreateFromExistingConfigName_DefaultValue;
+
+ public static String SelectConfigurationFileWizardPage_CreateFromExistingConfigName_Label;
+
+ public static String SelectConfigurationFileWizardPage_CreateFromExistingConfigName_Tooltip;
+
+ public static String SelectConfigurationFileWizardPage_CreateFromExistingConfiguration_Label;
+
+ public static String SelectConfigurationFileWizardPage_CreateFromExistingConfigurationSelectionButton_Label;
+
+ public static String SelectConfigurationFileWizardPage_CreateFromScratch_Label;
+
+ public static String SelectConfigurationFileWizardPage_DefaultConfigurationName;
+
+ public static String SelectConfigurationFileWizardPage_EmptyDocument_InitialComment;
+
+ public static String SelectConfigurationFileWizardPage_Error_NoAreaForWidget;
+
+ public static String SelectConfigurationFileWizardPage_ErrorMessage_NoValidExistingConfiguration;
+
+ public static String SelectConfigurationFileWizardPage_ErrorMessage_NoValidPluginIdentifier;
+
+ public static String SelectConfigurationFileWizardPage_ModifyExistingConfig_Dialog_Message;
+
+ public static String SelectConfigurationFileWizardPage_ModifyExistingConfig_Dialog_Title;
+
+ public static String SelectConfigurationFileWizardPage_ModifyExistingConfiguration_Label;
+
+ public static String SelectConfigurationFileWizardPage_ModifyExistingConfigurationSelectionButton_Label;
+
+ public static String SelectConfigurationFileWizardPage_PageName;
+
+ public static String SelectConfigurationFileWizardPage_UserGroup_Label;
+
+ public static String SelectConfigurationFileWizardPage_SourceGroup_Label;
+
+ public static String SelectConfigurationFileWizardPage_Title;
+
+ public static String CustomizeContentWizardPage_PreviewArea_AddTabButtonTooltip;
+
+ public static String CustomizeContentWizardPage_PreviewArea_DeleteTabButtonTooltip;
+
+ public static String CustomizeContentWizardPage_PreviewArea_MoveUpTabButtonTooltip;
+
+ public static String CustomizeContentWizardPage_PreviewArea_MoveDownTabButtonTooltip;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/AbstractValidationProblem.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/AbstractValidationProblem.java
new file mode 100644
index 00000000000..d752382114e
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/AbstractValidationProblem.java
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Florian Noyrit (CEA LIST) florian.noyrit@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.properties.tabbed.customization.dialog;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Abstract class used to be specialized for the various errors and warnings found by the validator in a configuration
+ */
+public abstract class AbstractValidationProblem {
+
+ /** The message to display as introduction of the problem */
+ protected String message;
+
+ /**
+ * Returns the full text description of the problem
+ *
+ * @return the text description of the problem
+ */
+ public abstract String getText();
+
+ /**
+ * Returns the image of the problem
+ *
+ * @return the image of the problem
+ */
+ public abstract Image getImage();
+
+ /**
+ * Getter for the message
+ *
+ * @return
+ * the message displayed as introduction of the problem
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Setter for the message
+ *
+ * @param message
+ * the message to display as introduction of the problem
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ConfigurationContentProvider.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ConfigurationContentProvider.java
new file mode 100644
index 00000000000..3e4948361a5
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ConfigurationContentProvider.java
@@ -0,0 +1,212 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.properties.runtime.state.AbstractState;
+import org.eclipse.papyrus.properties.runtime.state.ITraversableModelElement;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.swt.graphics.Image;
+
+
+/**
+ * Content provider for the configuration area of the content wizard page
+ */
+public class ConfigurationContentProvider implements ITreeContentProvider, PropertyChangeListener {
+
+ /** current selected sectionsetdescriptorState */
+ private SectionSetDescriptorState sectionSetDescriptorState;
+
+ /** current viewer */
+ private TreeViewer fViewer;
+
+ /**
+ * Creates a new ConfigurationContentProvider.
+ */
+ public ConfigurationContentProvider() {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object[] getElements(Object inputElement) {
+ if(inputElement instanceof SectionSetDescriptorState) {
+ return new Object[]{ new ConstraintHolder(sectionSetDescriptorState), new ContentHolder(sectionSetDescriptorState) };
+ }
+ return new Object[0];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ // nothing here
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ fViewer = (TreeViewer)viewer;
+ if(newInput instanceof SectionSetDescriptorState) {
+ // remove old listeners
+ if(sectionSetDescriptorState != null) {
+ traverseModel(sectionSetDescriptorState, false);
+ }
+ // set the new input
+ sectionSetDescriptorState = (SectionSetDescriptorState)newInput;
+
+ // add new listeners
+ traverseModel(sectionSetDescriptorState, true);
+ } else {
+ // should remove all listeners
+ if(sectionSetDescriptorState != null) {
+ traverseModel(sectionSetDescriptorState, false);
+ }
+ sectionSetDescriptorState = null;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object[] getChildren(Object parentElement) {
+ // assert section set descriptor set is not null
+ if(sectionSetDescriptorState == null) {
+ return new Object[0];
+ }
+ if(parentElement instanceof ConstraintHolder) {
+ return sectionSetDescriptorState.getConstraintDescriptorStates().toArray();
+ } else if(parentElement instanceof ITraversableModelElement) {
+ return ((ITraversableModelElement)parentElement).getChildren().toArray();
+ }
+ return new Object[0];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasChildren(Object element) {
+ return getChildren(element).length > 0;
+ }
+
+ /**
+ * traverse the model to add or remove listeners, given the value of the hook parameter
+ */
+ protected void traverseModel(ITraversableModelElement objectToTraverse, boolean isHook) {
+ if(objectToTraverse != null) {
+ if(isHook) {
+ objectToTraverse.removePropertyChangeListener(this);
+ objectToTraverse.addPropertyChangeListener(this);
+ } else {
+ objectToTraverse.removePropertyChangeListener(this);
+ }
+ }
+
+ if(objectToTraverse.getChildren() != null && !objectToTraverse.getChildren().isEmpty()) {
+ for(ITraversableModelElement child : objectToTraverse.getChildren()) {
+ traverseModel(child, isHook);
+ }
+ }
+ }
+
+ /**
+ * Object containing the constraints of the section set descriptor
+ */
+ protected class ConstraintHolder extends LabelProvider implements ITraversableModelElement {
+
+ /** current section set state descriptor edited */
+ private final SectionSetDescriptorState sectionSetDescriptorState;
+
+ /**
+ * Creates a new ConstraintHolder.
+ *
+ * @param sectionSetDescriptorState
+ */
+ public ConstraintHolder(SectionSetDescriptorState sectionSetDescriptorState) {
+ this.sectionSetDescriptorState = sectionSetDescriptorState;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Image getImage(Object element) {
+ return Activator.getImage("/icons/Constraints.gif");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getText(Object element) {
+ return "Constraints";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<? extends ITraversableModelElement> getChildren() {
+ return sectionSetDescriptorState.getConstraintDescriptorStates();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ sectionSetDescriptorState.addPropertyChangeListener(listener);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ sectionSetDescriptorState.removePropertyChangeListener(listener);
+ }
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ if(AbstractState.PROPERTY_ADD_CHILD.equals(evt.getPropertyName())) {
+ ((TreeViewer)fViewer).refresh(evt.getSource(), true);
+ traverseModel((ITraversableModelElement)evt.getSource(), true);
+ // try to keep a valid expand level
+ ((TreeViewer)fViewer).expandToLevel(evt.getSource(), 2);
+ } else if(AbstractState.PROPERTY_REMOVE_CHILD.equals(evt.getPropertyName())) {
+ ((TreeViewer)fViewer).refresh(evt.getSource(), true);
+ traverseModel((ITraversableModelElement)evt.getSource(), true);
+ ((TreeViewer)fViewer).expandAll();
+ } else {
+ ((TreeViewer)fViewer).refresh(evt.getSource(), true);
+ }
+
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ConfigurationLabelProvider.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ConfigurationLabelProvider.java
new file mode 100644
index 00000000000..7ed49fef780
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ConfigurationLabelProvider.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.papyrus.properties.runtime.state.IState;
+import org.eclipse.swt.graphics.Image;
+
+
+/**
+ * Label provider for the configuration area of the content wizard page
+ */
+public class ConfigurationLabelProvider extends LabelProvider {
+
+ /**
+ * Creates a new ConfigurationLabelProvider.
+ */
+ public ConfigurationLabelProvider() {
+ super();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getText(Object object) {
+ if(object instanceof IState) {
+ return ((IState)object).getText();
+ } else if(object instanceof LabelProvider) {
+ return ((LabelProvider)object).getText(object);
+ }
+ return super.getText(object);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Image getImage(Object object) {
+ if(object instanceof IState) {
+ return ((IState)object).getImage();
+ } else if(object instanceof LabelProvider) {
+ return ((LabelProvider)object).getImage(object);
+ }
+ return super.getImage(object);
+ }
+
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ConfigurationValidator.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ConfigurationValidator.java
new file mode 100644
index 00000000000..eb77e00f263
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ConfigurationValidator.java
@@ -0,0 +1,517 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Florian Noyrit (CEA LIST) florian.noyrit@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.properties.tabbed.customization.dialog;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.properties.runtime.state.IState;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionDescriptorState.ReplacedSectionState;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.core.view.StatesStore;
+import org.eclipse.papyrus.properties.tabbed.core.view.TabDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+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.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor;
+
+
+
+/**
+ * Validator for configuration that output report for errors and warnings.
+ */
+public class ConfigurationValidator {
+
+ protected Shell shell;
+
+ /** problem found during validation */
+ protected ArrayList<AbstractValidationProblem> errorsFound = new ArrayList<AbstractValidationProblem>();
+
+ /** problem found during validation */
+ protected ArrayList<AbstractValidationProblem> warningsFound = new ArrayList<AbstractValidationProblem>();
+
+ TableViewer errorsTableViewer;
+
+ TableViewer warningsTableViewer;
+
+ /**
+ * A specific validation problem for duplicates
+ */
+ protected class Duplicate extends AbstractValidationProblem {
+
+ protected IState stateA;
+
+ protected IState stateB;
+
+ /**
+ * Getter for the first state concerned by this problem
+ *
+ * @return
+ * the state concerned by this problem
+ */
+ public IState getStateA() {
+ return stateA;
+ }
+
+ /**
+ * Setter for the first state concerned by this problem
+ *
+ * @param state
+ * the state concerned by this problem
+ */
+ public void setStateA(IState state) {
+ this.stateA = state;
+ }
+
+ /**
+ * Getter for the second state concerned by this problem
+ *
+ * @return
+ * the state concerned by this problem
+ */
+ public IState getStateB() {
+ return stateB;
+ }
+
+ /**
+ * Setter for the second state concerned by this problem
+ *
+ * @param state
+ * the state concerned by this problem
+ */
+ public void setStateB(IState state) {
+ this.stateB = state;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param stateA
+ * the first state concerned by this problem
+ * @param stateB
+ * the second state concerned by this problem
+ */
+ public Duplicate(IState stateA, IState stateB) {
+ setMessage("Duplicate : ");
+ this.stateA = stateA;
+ this.stateB = stateB;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if(obj instanceof Duplicate) {
+ if(((Duplicate)obj).getStateA() == stateA || ((Duplicate)obj).getStateB() == stateA) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ return super.equals(obj);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getText() {
+ return message + stateA.getText() + " <-> " + stateB.getText();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Image getImage() {
+ return Activator.getImage("/icons/Duplicate.gif");
+ }
+ }
+
+ /**
+ * A specific validation problem for broken link (broken references among elements)
+ */
+ protected class BrokenLink extends AbstractValidationProblem {
+
+ protected IState state;
+
+ /**
+ * Getter for the state concerned by this problem
+ *
+ * @return
+ * the state concerned by this problem
+ */
+ public IState getState() {
+ return state;
+ }
+
+ /**
+ * Setter for the state concerned by this problem
+ *
+ * @param state
+ * the state concerned by this problem
+ */
+ public void setStateA(IState state) {
+ this.state = state;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param state
+ * the state concerned by this problem
+ */
+ public BrokenLink(IState state) {
+ setMessage("BrokenLink : ");
+ this.state = state;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getText() {
+ return message + state.getText();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Image getImage() {
+ return Activator.getImage("/icons/BrokenLink.gif");
+ }
+ }
+
+ public ConfigurationValidator(Shell shell) {
+ this.shell = shell;
+ }
+
+ /**
+ * Validates the configuration
+ *
+ * @param forSave
+ * if set to true, the report dialog will be adapted for saving purpose
+ * @param verbose
+ * if set to true, report is given even when configuration is valid
+ * @return true if the configuration is valid, false otherwise
+ */
+ public boolean validateConfig(boolean forSave, boolean verbose) {
+
+ errorsFound.clear();
+ warningsFound.clear();
+ //Find duplicates
+
+ //For tabs
+ for(TabDescriptorState tabDescriptorState : StatesStore.getTabDescriptorStates()) {
+ for(TabDescriptorState tabDescriptorState2 : StatesStore.getTabDescriptorStates()) {
+ if(tabDescriptorState != tabDescriptorState2) {
+ if(tabDescriptorState.getId().equals(tabDescriptorState2.getId())) {
+ if(!errorsFound.contains(new Duplicate(tabDescriptorState, tabDescriptorState2))) {
+ Duplicate duplicate = new Duplicate(tabDescriptorState, tabDescriptorState2);
+ duplicate.setMessage("Duplicated tabID: ");
+ errorsFound.add(duplicate);
+ }
+ }
+ }
+ }
+ }
+
+ //For sections
+ List<SectionDescriptorState> sectionDescriptorStates = new ArrayList<SectionDescriptorState>();
+ for(SectionSetDescriptorState sectionSetDescriptorState : StatesStore.getSectionSetDescriptorStates()) {
+ sectionDescriptorStates.addAll(sectionSetDescriptorState.getSectionDescriptorStates());
+ }
+ for(SectionDescriptorState sectionDescriptorState : sectionDescriptorStates) {
+ for(SectionDescriptorState sectionDescriptorState2 : sectionDescriptorStates) {
+ if(sectionDescriptorState != sectionDescriptorState2) {
+ if(sectionDescriptorState.getId().equals(sectionDescriptorState2.getId())) {
+ if(!errorsFound.contains(new Duplicate(sectionDescriptorState, sectionDescriptorState2))) {
+ Duplicate duplicate = new Duplicate(sectionDescriptorState, sectionDescriptorState2);
+ duplicate.setMessage("Duplicated sectionID: ");
+ errorsFound.add(duplicate);
+ }
+ }
+ }
+ }
+ }
+
+ //For fragments
+ // List<IFragmentDescriptorState> fragmentDescriptorStates = new ArrayList<IFragmentDescriptorState>();
+ // for(SectionDescriptorState sectionDescriptorState : sectionDescriptorStates) {
+ // fragmentDescriptorStates.addAll(sectionDescriptorState.getFragmentDescriptorStates());
+ // }
+ // for(IFragmentDescriptorState fragmentDescriptorState : fragmentDescriptorStates) {
+ // for(IFragmentDescriptorState fragmentDescriptorState2 : fragmentDescriptorStates) {
+ // if(fragmentDescriptorState != fragmentDescriptorState2) {
+ // if(fragmentDescriptorState.getId().equals(fragmentDescriptorState2.getId())) {
+ // if(!IDduplicates.containsValue(fragmentDescriptorState) && !IDduplicates.containsKey(fragmentDescriptorState)) {
+ // IDduplicates.put(fragmentDescriptorState, fragmentDescriptorState2);
+ // }
+ // }
+ // }
+ // }
+ // }
+
+ //Check tabs label
+ for(TabDescriptorState tabDescriptorState : StatesStore.getTabDescriptorStates()) {
+ for(TabDescriptorState tabDescriptorState2 : StatesStore.getTabDescriptorStates()) {
+ if(tabDescriptorState != tabDescriptorState2) {
+ if(tabDescriptorState.getLabel().equals(tabDescriptorState2.getLabel())) {
+ if(!warningsFound.contains(new Duplicate(tabDescriptorState, tabDescriptorState2))) {
+ Duplicate duplicate = new Duplicate(tabDescriptorState, tabDescriptorState2);
+ duplicate.setMessage("Confusing tab label: ");
+ warningsFound.add(duplicate);
+ }
+ }
+ }
+ }
+ }
+
+
+
+
+ //Check references
+ boolean found;
+ //TabIdentifier in sections
+ for(SectionDescriptorState sectionDescriptorState : sectionDescriptorStates) {
+ found = false;
+ for(TabDescriptorState tabDescriptorState : StatesStore.getTabDescriptorStates()) {
+ if(sectionDescriptorState.getTargetTab().equals(tabDescriptorState.getId())) {
+ found = true;
+ }
+ }
+ if(!found) {
+ BrokenLink brokenLink = new BrokenLink(sectionDescriptorState);
+ brokenLink.setMessage("Broken link for TargetTab in : ");
+ errorsFound.add(brokenLink);
+ }
+ }
+
+ //AfterSection in sections
+ for(SectionDescriptorState sectionDescriptorState : sectionDescriptorStates) {
+ found = false;
+ if(!sectionDescriptorState.getAfterSection().equals(ISectionDescriptor.TOP)) {
+ for(SectionDescriptorState sectionDescriptorState2 : sectionDescriptorStates) {
+ if(sectionDescriptorState.getAfterSection().equals(sectionDescriptorState2.getId())) {
+ found = true;
+ }
+ }
+ if(!found) {
+ BrokenLink brokenLink = new BrokenLink(sectionDescriptorState);
+ brokenLink.setMessage("Broken link for AfterSection in : ");
+ warningsFound.add(brokenLink);
+ }
+ }
+ }
+
+ //Identifier in ReplacedSection
+ List<ReplacedSectionState> replacedSectionStates = new ArrayList<ReplacedSectionState>();
+ for(SectionDescriptorState sectionDescriptorState : sectionDescriptorStates) {
+ replacedSectionStates.addAll(sectionDescriptorState.getReplacedSectionStates());
+ }
+ for(ReplacedSectionState replacedSectionState : replacedSectionStates) {
+ found = false;
+ for(SectionDescriptorState sectionDescriptorState : sectionDescriptorStates) {
+ if(replacedSectionState.getId().equals(sectionDescriptorState.getId())) {
+ found = true;
+ }
+ }
+ if(!found) {
+ BrokenLink brokenLink = new BrokenLink(replacedSectionState);
+ brokenLink.setMessage("Broken link for Identifier in : ");
+ warningsFound.add(brokenLink);
+ }
+ }
+
+ if(errorsFound.isEmpty() && warningsFound.isEmpty()) {
+ if(verbose) {
+ MessageDialog.openInformation(shell, "Validation report", "No error and no warning found");
+ }
+ return true;
+ } else {
+ ReportDialog dialog = new ReportDialog(shell, forSave);
+ dialog.open();
+ //If forSave and save anyway
+ if(forSave && dialog.getReturnCode() == IDialogConstants.OK_ID) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * The report dialog opened to display the errors and warnings found in the configuration
+ */
+ protected class ReportDialog extends TitleAreaDialog {
+
+ private boolean forSave;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parentShell
+ * the shell to use
+ * @param forSave
+ * if set to true, the report dialog will be adapted for saving purpose
+ */
+ public ReportDialog(Shell parentShell, boolean forSave) {
+ super(parentShell);
+ this.setShellStyle(getShellStyle() | SWT.RESIZE);
+ this.forSave = forSave;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Control createContents(Composite parent) {
+ Control contents = super.createContents(parent);
+
+ // Set the title
+ setTitle("Validation report");
+
+ // Set the message
+ setMessage("Please reconsider the following issues.", IMessageProvider.NONE);
+
+ return contents;
+ }
+
+ protected Control createProblemReportArea(Composite conposite) {
+ Composite contents = new Composite(conposite, SWT.BORDER);
+ contents.setLayout(new GridLayout(1, true));
+ contents.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ ILabelProvider labelProvider = new LabelProvider() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public Image getImage(Object element) {
+ if(element instanceof AbstractValidationProblem) {
+ return ((AbstractValidationProblem)element).getImage();
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getText(Object element) {
+ if(element instanceof AbstractValidationProblem) {
+ return ((AbstractValidationProblem)element).getText();
+ }
+ return element.toString();
+ }
+ };
+
+ IContentProvider contentProvider = new IStructuredContentProvider() {
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return ((ArrayList<Object>)inputElement).toArray();
+ }
+ };
+
+ // Create Label
+ Label labelErrors = new Label(contents, SWT.NONE);
+ labelErrors.setText("Error(s) found: ");
+
+
+ int flags = SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL;
+ errorsTableViewer = new TableViewer(contents, flags);
+ GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gridData.widthHint = convertWidthInCharsToPixels(80);
+ gridData.heightHint = convertHeightInCharsToPixels(18);
+ errorsTableViewer.getControl().setLayoutData(gridData);
+ errorsTableViewer.setLabelProvider(labelProvider);
+ errorsTableViewer.setContentProvider(contentProvider);
+
+
+ Label labelWarnings = new Label(contents, SWT.NONE);
+ labelWarnings.setText("Warning(s) found: ");
+
+ warningsTableViewer = new TableViewer(contents, flags);
+ GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gridData2.widthHint = convertWidthInCharsToPixels(80);
+ gridData2.heightHint = convertHeightInCharsToPixels(18);
+ warningsTableViewer.getControl().setLayoutData(gridData2);
+ warningsTableViewer.setLabelProvider(labelProvider);
+ warningsTableViewer.setContentProvider(contentProvider);
+
+
+ return contents;
+
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Control createDialogArea(Composite parent) {
+
+ Composite parentComposite = (Composite)super.createDialogArea(parent);
+
+ initializeDialogUnits(parentComposite);
+
+ createProblemReportArea(parentComposite);
+
+ errorsTableViewer.setInput(errorsFound);
+ warningsTableViewer.setInput(warningsFound);
+
+ return parentComposite;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void createButtonsForButtonBar(Composite parent) {
+ if(forSave) {
+ createButton(parent, IDialogConstants.CANCEL_ID, "Don't save", true);
+ createButton(parent, IDialogConstants.OK_ID, "Save anyway", false);
+ } else {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ }
+ }
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ContentHolder.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ContentHolder.java
new file mode 100644
index 00000000000..532c92d0908
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/ContentHolder.java
@@ -0,0 +1,89 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog;
+
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.papyrus.properties.runtime.state.ITraversableModelElement;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.swt.graphics.Image;
+
+
+/**
+ * Object containing the content of the section set descriptor
+ */
+public class ContentHolder extends LabelProvider implements ITraversableModelElement {
+
+ /** section set state for which this content holder describes content */
+ private final SectionSetDescriptorState sectionSetDescriptorState;
+
+ /**
+ * Creates a new ContentHolder.
+ *
+ * @param sectionSetDescriptorState
+ * the state of the {@link SectionSetDescriptor} displayed in the configuration area
+ */
+ public ContentHolder(SectionSetDescriptorState sectionSetDescriptorState) {
+ this.sectionSetDescriptorState = sectionSetDescriptorState;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Image getImage(Object element) {
+ return Activator.getImage("/icons/Content.gif");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getText(Object element) {
+ return "Content";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<? extends ITraversableModelElement> getChildren() {
+ return sectionSetDescriptorState.getSectionDescriptorStates();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ sectionSetDescriptorState.addPropertyChangeListener(listener);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ sectionSetDescriptorState.removePropertyChangeListener(listener);
+ }
+
+
+ /**
+ * Returns the sectionSetDescriptorState
+ *
+ * @return the sectionSetDescriptorState
+ */
+ public SectionSetDescriptorState getSectionSetDescriptorState() {
+ return sectionSetDescriptorState;
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/CustomizeContentWizardPage.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/CustomizeContentWizardPage.java
new file mode 100644
index 00000000000..5cb997e5644
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/CustomizeContentWizardPage.java
@@ -0,0 +1,1344 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ModelElementItem;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.papyrus.core.editor.CoreMultiDiagramEditor;
+import org.eclipse.papyrus.properties.runtime.controller.descriptor.ControllerDescriptorState;
+import org.eclipse.papyrus.properties.runtime.dialogs.PropertyDialog;
+import org.eclipse.papyrus.properties.runtime.state.IFragmentDescriptorState;
+import org.eclipse.papyrus.properties.runtime.state.IState;
+import org.eclipse.papyrus.properties.runtime.view.DialogDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.FragmentDescriptorState;
+import org.eclipse.papyrus.properties.runtime.view.PredefinedFragmentDescriptorState;
+import org.eclipse.papyrus.properties.runtime.view.PropertyViewService;
+import org.eclipse.papyrus.properties.runtime.view.XMLParseException;
+import org.eclipse.papyrus.properties.runtime.view.constraints.AppliedStereotypeConstraintDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.constraints.ConstraintDescriptorState;
+import org.eclipse.papyrus.properties.runtime.view.constraints.ObjectTypeConstraintDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.content.ContainerDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.core.view.DynamicSectionDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.DynamicTabDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionDescriptorState.ReplacedSectionState;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.core.view.StatesStore;
+import org.eclipse.papyrus.properties.tabbed.core.view.TabDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.papyrus.properties.tabbed.customization.Messages;
+import org.eclipse.papyrus.properties.tabbed.customization.dialog.actions.ContainerMenuCreator;
+import org.eclipse.papyrus.properties.tabbed.customization.dialog.actions.ContentHolderMenuCreator;
+import org.eclipse.papyrus.properties.tabbed.customization.dialog.actions.ControllerMenuCreator;
+import org.eclipse.papyrus.properties.tabbed.customization.dialog.actions.EClassifierMenuCreator;
+import org.eclipse.papyrus.properties.tabbed.customization.dialog.actions.FragmentMenuCreator;
+import org.eclipse.papyrus.properties.tabbed.customization.dialog.actions.PredefinedFragmentMenuCreator;
+import org.eclipse.papyrus.properties.tabbed.customization.dialog.actions.ReplacedSectionMenuCreator;
+import org.eclipse.papyrus.properties.tabbed.customization.dialog.actions.SectionMenuCreator;
+import org.eclipse.papyrus.properties.tabbed.customization.dialog.actions.SectionSetMenuCreator;
+import org.eclipse.papyrus.properties.tabbed.customization.dialog.actions.StereotypeMenuCreator;
+import org.eclipse.papyrus.properties.tabbed.customization.state.StatePropertyTabViewProviderParser;
+import org.eclipse.papyrus.umlutils.PackageUtil;
+import org.eclipse.papyrus.umlutils.StereotypeUtil;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.MenuDetectEvent;
+import org.eclipse.swt.events.MenuDetectListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.FilteredTree;
+import org.eclipse.ui.dialogs.PatternFilter;
+import org.eclipse.ui.views.properties.tabbed.ITabDescriptor;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.Stereotype;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Wizard page where user can customize the content of the property view
+ */
+@SuppressWarnings("restriction")
+public class CustomizeContentWizardPage extends WizardPage {
+
+ /** initial content */
+ protected Document document;
+
+ /** UML metamodel label for the metamodel selection combo */
+ protected static final String UML_METAMODEL = "UML"; //$NON-NLS-1$
+
+ /** Tree viewer on the metamodel and the set of available section sets descriptors */
+ protected FilteredTree metamodelViewer;
+
+ /** current selection of section set */
+ protected SectionSetDescriptorState currentSectionSetDescriptorState;
+
+ /** current selection of metaclass */
+ protected EClassifier currentMetaClass;
+
+ /** tree viewer for the configuration area */
+ protected TreeViewer configurationViewer;
+
+ /** viewer for tabs */
+ protected TableViewer tabViewer;
+
+ /** current tab selection */
+ protected TabDescriptorState selectedTab;
+
+ /** preview area */
+ protected ScrolledComposite previewArea;
+
+ /** widget factory for preview area */
+ protected TabbedPropertySheetWidgetFactory factory = new TabbedPropertySheetWidgetFactory();
+
+ /** current selection size for the preview */
+ protected int currentSelectionsize = 1;
+
+ /** area displaying the current selection size */
+ protected Combo sizeArea;
+
+ /** values in the selection size combo */
+ protected final static List<String> sizeValues = Arrays.asList("1", "-1"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ /** file where to save the content of the configuration */
+ protected File file;
+
+ /** list of available metamodels or profile */
+ protected List<EObject> metamodels = new ArrayList<EObject>();
+
+ /** combo to select metamodel being edited */
+ protected CCombo metamodelSelectionCombo;
+
+ /** current selected stereotype */
+ protected Stereotype currentStereoype;
+
+ /**
+ * Creates a new CustomizeContentWizardPage.
+ */
+ public CustomizeContentWizardPage() {
+ super(Messages.CustomizeContentWizardPage_Title, Messages.CustomizeContentWizardPage_Message, null);
+ }
+
+ /** filters for the metamodel tree viewer */
+ private List<ViewerFilter> metamodelViewerFilters;
+
+ /**
+ * {@inheritDoc}
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ SashForm sashForm = new SashForm(composite, SWT.HORIZONTAL);
+ sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ createContentExplorer(sashForm);
+ createConfigurationArea(sashForm);
+
+ sashForm.setWeights(new int[]{ 40, 60 });
+
+ setControl(composite);
+ }
+
+ /**
+ * Sets the initial content for this page
+ *
+ * @param initialContent
+ * the initial content for this page, i.e. the document
+ */
+ public void setInitialContent(Document document) {
+ this.document = document;
+
+ // parses the content of the document to create the
+ // SectionSetDescriptors states
+ List<ITabDescriptor> tabDescriptors = new ArrayList<ITabDescriptor>();
+
+ StatePropertyTabViewProviderParser parser = new StatePropertyTabViewProviderParser(tabDescriptors);
+ try {
+ parser.parseXMLfile(document, PropertyViewService.getInstance().getAllFragmentDescriptors(), new HashMap<String, DialogDescriptor>());
+ StatesStore.setSectionSetDescriptorStates(parser.getSectionSetDescriptorStates());
+ StatesStore.setTabDescriptorStates(parser.getTabDescriptorStates());
+ metamodelViewer.getViewer().setContentProvider(new MetamodelContentProvider(StatesStore.getSectionSetDescriptorStates()));
+ metamodelViewer.getViewer().setLabelProvider(new MetamodelLabelProvider());
+
+ // load by default the metamodel
+ metamodelViewer.getViewer().setInput(UMLPackage.eINSTANCE);
+ metamodelSelectionCombo.select(0);
+ tabViewer.setInput(StatesStore.getTabDescriptorStates());
+ } catch (XMLParseException e) {
+ Activator.log.error(e);
+ }
+ }
+
+ /**
+ * Returns the final content for this page
+ *
+ * @return the final content for this page
+ */
+ public Document getFinalContent() {
+ return createFinalDocument();
+ }
+
+ /**
+ * Creates the final document, serializing the existing section set
+ * descriptor states
+ *
+ * @return the final document created
+ */
+ protected Document createFinalDocument() {
+ // remove existing elements on the current document
+ Node topNode = retrieveTopNode(document);
+
+ if(topNode == null) {
+ return document;
+ }
+
+ removeAllExistingSectionSetDescriptors(topNode);
+
+ removeAllExistingTabDescriptors(topNode);
+
+ // add all new tab descriptors using states
+ for(TabDescriptorState state : StatesStore.getTabDescriptorStates()) {
+ topNode.appendChild(state.generateNode(document));
+ }
+
+ // add all new section set descriptors using states
+ for(SectionSetDescriptorState state : StatesStore.getSectionSetDescriptorStates()) {
+ topNode.appendChild(state.generateNode(document));
+ }
+
+ return document;
+ }
+
+
+
+ /**
+ * Retrieves the top node for this document
+ *
+ * @param document
+ * the document to look in
+ */
+ protected Node retrieveTopNode(Document document) {
+ NodeList childNodes = document.getChildNodes();
+ for(int i = 0; i < childNodes.getLength(); i++) {
+ Node childNode = childNodes.item(i);
+ // be sure child node is the propertyTabView node
+ if("propertyTabView".equals(childNode.getNodeName())) {
+ return childNode;
+ }
+ }
+ Activator.log.error(Messages.CustomizeContentWizardPage_Error_NoRootNode, null);
+ return null;
+ }
+
+ /**
+ * Removes all section set descriptors child of the specified node
+ *
+ * @param topNode
+ * the node that contains the element to remove
+ */
+ protected void removeAllExistingSectionSetDescriptors(Node topNode) {
+ NodeList children = topNode.getChildNodes();
+ for(int i = children.getLength() - 1; i >= 0; i--) {
+ Node child = children.item(i);
+ if("sectionSet".equals(child.getNodeName())) {
+ topNode.removeChild(child);
+ child = null;
+ }
+ }
+ }
+
+ /**
+ * Removes all tab descriptors child of the specified node
+ *
+ * @param topNode
+ * the node that contains the element to remove
+ */
+ protected void removeAllExistingTabDescriptors(Node topNode) {
+ NodeList children = topNode.getChildNodes();
+ for(int i = children.getLength() - 1; i >= 0; i--) {
+ Node child = children.item(i);
+ if("tab".equals(child.getNodeName())) {
+ topNode.removeChild(child);
+ child = null;
+ }
+ }
+ }
+
+ /**
+ * Creates the configuration area, where the configuration for one model
+ * element is displayed. This is the part on the right.
+ *
+ * @param composite
+ * the parent composite for the controls created in this area
+ */
+ protected void createConfigurationArea(Composite composite) {
+ SashForm configurationAreaSashForm = new SashForm(composite, SWT.VERTICAL);
+ configurationAreaSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ createConfigurationEditor(configurationAreaSashForm);
+ createPreviewArea(configurationAreaSashForm);
+
+ configurationAreaSashForm.setWeights(new int[]{ 50, 50 });
+ }
+
+ /**
+ * Creates the configuration editor, where the configuration for one model
+ * element can be edited
+ *
+ * @param composite
+ * the parent composite for the controls created in this area
+ */
+ protected void createConfigurationEditor(Composite composite) {
+ Composite configurationAreaComposite = new Composite(composite, SWT.NONE);
+ configurationAreaComposite.setLayout(new GridLayout(1, false));
+
+ // title of this area
+ Label titleLabel = new Label(configurationAreaComposite, SWT.NONE);
+ titleLabel.setText(Messages.CustomizeContentWizardPage_ConfigurationArea_Label);
+
+ // content tree and viewer on this tree
+ Tree configurationTree = new Tree(configurationAreaComposite, SWT.BORDER);
+ configurationTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ configurationViewer = new TreeViewer(configurationTree);
+ configurationViewer.setContentProvider(new ConfigurationContentProvider());
+ configurationViewer.setLabelProvider(new ConfigurationLabelProvider());
+ configurationViewer.addDoubleClickListener(new IDoubleClickListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void doubleClick(DoubleClickEvent event) {
+ // edit element on which double click occurs => open edit dialog
+ ITreeSelection selection = (ITreeSelection)event.getSelection();
+ Object selectedElement = selection.getFirstElement();
+
+ // if element is a state, opens the dialog on this state
+ if(selectedElement instanceof IState) {
+ openEditionDialog(((IState)selectedElement));
+ }
+ }
+ });
+ configurationViewer.getTree().addMenuDetectListener(new MenuDetectListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void menuDetected(MenuDetectEvent e) {
+ // retrieve current selection, this should be a state or
+ // a contentHolder/constraintholder
+ ITreeSelection selection = (ITreeSelection)configurationViewer.getSelection();
+ if(selection == null || selection.size() < 1) {
+ Activator.log.warn(Messages.CustomizeContentWizardPage_Error_NoSelectionFound);
+ return;
+ }
+
+ Object selectedObject = selection.getFirstElement();
+ Menu menu = null;
+ // awful code, should delegate to each state which menu
+ // should be created
+ if(selectedObject instanceof SectionDescriptorState) {
+ menu = new SectionMenuCreator(((SectionDescriptorState)selectedObject), getCurrentSectionSetDescriptorState(), getCurrentMetaClass(), getCurrentStereoype()).getMenu(configurationViewer.getTree());
+ } else if(selectedObject instanceof FragmentDescriptorState) {
+ menu = new FragmentMenuCreator(((FragmentDescriptorState)selectedObject), getCurrentSectionSetDescriptorState(), getCurrentMetaClass(), getCurrentStereoype()).getMenu(configurationViewer.getTree());
+ } else if(selectedObject instanceof PredefinedFragmentDescriptorState) {
+ menu = new PredefinedFragmentMenuCreator(((PredefinedFragmentDescriptorState)selectedObject), getCurrentSectionSetDescriptorState(), getCurrentMetaClass(), getCurrentStereoype()).getMenu(configurationViewer.getTree());
+ } else if(selectedObject instanceof ContainerDescriptorState) {
+ menu = new ContainerMenuCreator(((ContainerDescriptorState)selectedObject), getCurrentSectionSetDescriptorState(), getCurrentMetaClass(), getCurrentStereoype()).getMenu(configurationViewer.getTree());
+ } else if(selectedObject instanceof ControllerDescriptorState) {
+ menu = new ControllerMenuCreator(((ControllerDescriptorState)selectedObject), getCurrentSectionSetDescriptorState(), getCurrentMetaClass(), getCurrentStereoype()).getMenu(configurationViewer.getTree());
+ } else if(selectedObject instanceof ContentHolder) {
+ menu = new ContentHolderMenuCreator(((ContentHolder)selectedObject), getCurrentSectionSetDescriptorState(), getCurrentMetaClass(), getCurrentStereoype()).getMenu(configurationViewer.getTree());
+ } else if(selectedObject instanceof ReplacedSectionState) {
+ menu = new ReplacedSectionMenuCreator(((ReplacedSectionState)selectedObject), getCurrentSectionSetDescriptorState(), getCurrentMetaClass(), getCurrentStereoype()).getMenu(configurationViewer.getTree());
+ }
+
+ if(menu != null) {
+ // creates the menu, depending on the selection
+ menu.setVisible(true);
+ }
+ }
+ });
+ }
+
+ /**
+ * Opens an edition dialog on the given state
+ *
+ * @param iState
+ * the state to edit
+ */
+ protected void openEditionDialog(IState iState) {
+ // find editor descriptor...
+ DialogDescriptor descriptor = PropertyViewService.getInstance().getDialogDescriptor(iState.getEditionDialogId());
+ List<Object> objectsToEdit = new ArrayList<Object>();
+ objectsToEdit.add(iState);
+
+ if(descriptor != null) {
+ Shell parentShell = getShell();
+ PropertyDialog dialog = new PropertyDialog(parentShell, descriptor, objectsToEdit, new TabbedPropertySheetWidgetFactory());
+ dialog.open();
+ } else {
+ Activator.log.warn(Messages.CustomizeContentWizardPage_Error_NoEditorForElement + iState);
+ }
+ }
+
+ /**
+ * Creates the area where the preview of the property view is displayed.
+ * This is the part in the lower right.
+ *
+ * @param composite
+ * the parent composite for the controls created in this area
+ */
+ protected void createPreviewArea(Composite composite) {
+ Composite previewAreaComposite = new Composite(composite, SWT.NONE);
+ previewAreaComposite.setLayout(new GridLayout(2, false));
+ // previewAreaComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
+ // true, false));
+
+ Composite titleArea = new Composite(previewAreaComposite, SWT.NONE);
+ GridLayout layout = new GridLayout(5, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ titleArea.setLayout(layout);
+ titleArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+
+ // title of this area
+ Label titleLabel = new Label(titleArea, SWT.NONE);
+ titleLabel.setText(Messages.CustomizeContentWizardPage_PreviewArea_Label);
+ titleLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ Composite selectionSize = new Composite(titleArea, SWT.NONE);
+ layout = new GridLayout(2, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ selectionSize.setLayout(layout);
+ GridData data = new GridData(SWT.FILL, SWT.CENTER, false, false);
+ selectionSize.setLayoutData(data);
+
+ Label sizeLabel = new Label(selectionSize, SWT.NONE);
+ sizeLabel.setText(Messages.CustomizeContentWizardPage_PreviewArea_SelectionSizeLabel);
+
+ sizeArea = new Combo(selectionSize, SWT.BORDER | SWT.READ_ONLY);
+ sizeArea.setItems(sizeValues.toArray(new String[0]));
+ sizeArea.addSelectionListener(new SelectionListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetSelected(SelectionEvent e) {
+ int index = sizeArea.getSelectionIndex();
+ if(index >= 0) {
+ setCurrentSelectionsize(Integer.parseInt(sizeValues.get(index)));
+ } else {
+ Activator.log.error(Messages.CustomizeContentWizardPage_Error_OutOfBoundExceptionIndex, null);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // nothing to do here
+ }
+ });
+ updateSizeArea();
+
+ Button button = new Button(titleArea, SWT.NONE);
+ button.setImage(Activator.getImage("/icons/Refresh.gif")); //$NON-NLS-1$
+ button.setToolTipText(Messages.CustomizeContentWizardPage_PreviewArea_RefreshButtonTooltip);
+ button.addSelectionListener(new SelectionListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetSelected(SelectionEvent e) {
+ updatePreview();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // nothing to do here
+ }
+ });
+
+ Button validateButton = new Button(titleArea, SWT.NONE);
+ validateButton.setImage(Activator.getImage("/icons/Validate.gif")); //$NON-NLS-1$
+ validateButton.setToolTipText("Validate configuration");
+ validateButton.addSelectionListener(new SelectionListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetSelected(SelectionEvent e) {
+ ConfigurationValidator validator = new ConfigurationValidator(getShell());
+ validator.validateConfig(false, true);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // nothing to do here
+ }
+ });
+
+ Button saveButton = new Button(titleArea, SWT.NONE);
+ saveButton.setImage(Activator.getImage("/icons/Save.gif")); //$NON-NLS-1$
+ saveButton.setToolTipText(Messages.CustomizeContentWizardPage_PreviewArea_SaveButtonTooltip);
+ saveButton.addSelectionListener(new SelectionListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetSelected(SelectionEvent e) {
+ serializeContent();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // nothing to do here
+ }
+ });
+
+ Composite tabArea = new Composite(previewAreaComposite, SWT.NONE);
+ data = new GridData(SWT.FILL, SWT.FILL, false, true);
+ data.widthHint = 150;
+ data.minimumWidth = 150;
+ tabArea.setLayoutData(data);
+ layout = new GridLayout(4, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ tabArea.setLayout(layout);
+
+ Button addTabButton = new Button(tabArea, SWT.NONE);
+ addTabButton.setImage(Activator.getImage("/icons/Add_12x12.gif")); //$NON-NLS-1$
+ addTabButton.setToolTipText(Messages.CustomizeContentWizardPage_PreviewArea_AddTabButtonTooltip);
+ addTabButton.addSelectionListener(new SelectionListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetSelected(SelectionEvent e) {
+ InputDialog dialog = new InputDialog(getShell(), "Tab label", "Please enter the tab label", "", new IInputValidator() {
+
+ public String isValid(String newText) {
+ // FIXME Should check if already present
+ return null;
+ }
+ });
+ dialog.open();
+ if(dialog.getValue() != null) {
+ DynamicTabDescriptor tabDescriptor = new DynamicTabDescriptor("", "tab_" + dialog.getValue(), dialog.getValue());
+ StatesStore.getTabDescriptorStates().add(new TabDescriptorState(tabDescriptor, false));
+ tabViewer.refresh();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // nothing to do here
+ }
+ });
+
+ Button deleteTabButton = new Button(tabArea, SWT.NONE);
+ deleteTabButton.setImage(Activator.getImage("/icons/Delete_12x12.gif")); //$NON-NLS-1$
+ deleteTabButton.setToolTipText(Messages.CustomizeContentWizardPage_PreviewArea_DeleteTabButtonTooltip);
+ deleteTabButton.addSelectionListener(new SelectionListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetSelected(SelectionEvent e) {
+ ISelection selection = tabViewer.getSelection();
+ if(selection instanceof IStructuredSelection) {
+ StatesStore.getTabDescriptorStates().remove((TabDescriptorState)((IStructuredSelection)selection).getFirstElement());
+ tabViewer.refresh();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // nothing to do here
+ }
+ });
+
+ Button moveUpTabButton = new Button(tabArea, SWT.NONE);
+ moveUpTabButton.setImage(Activator.getImage("/icons/Up_12x12.gif")); //$NON-NLS-1$
+ moveUpTabButton.setToolTipText(Messages.CustomizeContentWizardPage_PreviewArea_MoveUpTabButtonTooltip);
+ moveUpTabButton.addSelectionListener(new SelectionListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetSelected(SelectionEvent e) {
+ ISelection selection = tabViewer.getSelection();
+ if(selection instanceof IStructuredSelection) {
+ int index = StatesStore.getTabDescriptorStates().indexOf(((IStructuredSelection)selection).getFirstElement());
+ if(index != 0) {
+ TabDescriptorState tab = StatesStore.getTabDescriptorStates().remove(index);
+ StatesStore.getTabDescriptorStates().add(index - 1, tab);
+ tabViewer.refresh();
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // nothing to do here
+ }
+ });
+
+ Button moveDownTabButton = new Button(tabArea, SWT.NONE);
+ moveDownTabButton.setImage(Activator.getImage("/icons/Down_12x12.gif")); //$NON-NLS-1$
+ moveDownTabButton.setToolTipText(Messages.CustomizeContentWizardPage_PreviewArea_MoveDownTabButtonTooltip);
+ moveDownTabButton.addSelectionListener(new SelectionListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetSelected(SelectionEvent e) {
+ ISelection selection = tabViewer.getSelection();
+ if(selection instanceof IStructuredSelection) {
+ int index = StatesStore.getTabDescriptorStates().indexOf(((IStructuredSelection)selection).getFirstElement());
+ if(index != StatesStore.getTabDescriptorStates().size() - 1) {
+ TabDescriptorState tab = StatesStore.getTabDescriptorStates().remove(index);
+ StatesStore.getTabDescriptorStates().add(index + 1, tab);
+ tabViewer.refresh();
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // nothing to do here
+ }
+ });
+
+ Table table = new Table(tabArea, SWT.BORDER);
+ GridData data2 = new GridData(SWT.FILL, SWT.FILL, false, true);
+ data2.widthHint = 150;
+ data2.minimumWidth = 150;
+ data2.horizontalSpan = 4;
+ table.setLayoutData(data2);
+ tabViewer = new TableViewer(table);
+ tabViewer.setLabelProvider(new LabelProvider() {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getText(Object element) {
+
+ if(element instanceof TabDescriptorState) {
+ return ((TabDescriptorState)element).getText();
+ }
+ return super.getText(element);
+ }
+
+ });
+ tabViewer.setContentProvider(new IStructuredContentProvider() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object[] getElements(Object inputElement) {
+ List<Object> results = new ArrayList<Object>();
+ if(inputElement instanceof List<?>) {
+ List<?> elements = (List<?>)inputElement;
+ for(Object o : elements) {
+ if(o instanceof TabDescriptorState) {
+ results.add((TabDescriptorState)o);
+ }
+ }
+ return results.toArray();
+ }
+ return new Object[0];
+ }
+ });
+
+ tabViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ selectedTab = (TabDescriptorState)((IStructuredSelection)event.getSelection()).getFirstElement();
+ updatePreview();
+ }
+ });
+
+ tabViewer.addDoubleClickListener(new IDoubleClickListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void doubleClick(DoubleClickEvent event) {
+ // edit element on which double click occurs => open edit dialog
+ IStructuredSelection selection = (IStructuredSelection)event.getSelection();
+
+ Object selectedElement = selection.getFirstElement();
+
+ // if element is a state, opens the dialog on this state
+ if(selectedElement instanceof IState) {
+ openEditionDialog(((IState)selectedElement));
+ }
+ tabViewer.refresh();
+ }
+ });
+
+ // real preview area
+ previewArea = factory.createScrolledComposite(previewAreaComposite, SWT.BORDER);
+ previewArea.setAlwaysShowScrollBars(false);
+ previewArea.setLayout(new GridLayout(1, true));
+ previewArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ Composite content = factory.createComposite(previewArea);
+ content.setLayout(new GridLayout(1, true));
+ content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ previewArea.setContent(content);
+ previewArea.setExpandVertical(true);
+ previewArea.setExpandHorizontal(true);
+ }
+
+ /**
+ * updates the content of the size area
+ */
+ protected void updateSizeArea() {
+ if(sizeArea != null && !sizeArea.isDisposed()) {
+ sizeArea.select(sizeValues.indexOf("" + currentSelectionsize)); //$NON-NLS-1$
+ }
+ updatePreview();
+
+ }
+
+ protected boolean isSectionSetDescriptorStateValid(SectionSetDescriptorState state) {
+ // check size
+ if(state.getSelectionSize() > getCurrentSelectionsize()) {
+ return false;
+ }
+ List<ConstraintDescriptorState> constraintDescriptorStates = state.getConstraintDescriptorStates();
+ for(ConstraintDescriptorState constraintDescriptorState : constraintDescriptorStates) {
+ // check the object type constraint if the current selected element
+ // is a metaclass
+ if(getCurrentMetaClass() != null) {
+ if(constraintDescriptorState instanceof ObjectTypeConstraintDescriptor.ObjectTypeConstraintDescriptorState) {
+ Class<?> elementClass = ((ObjectTypeConstraintDescriptor.ObjectTypeConstraintDescriptorState)constraintDescriptorState).getElementClassState();
+ if(elementClass.isAssignableFrom(getCurrentMetaClass().getInstanceClass())) {
+ return true;
+ }
+ }
+ } else if(getCurrentStereoype() != null) {
+ if(constraintDescriptorState instanceof AppliedStereotypeConstraintDescriptor.AppliedStereotypeConstraintDescriptorState) {
+ List<String> stereotypesToApply = ((AppliedStereotypeConstraintDescriptor.AppliedStereotypeConstraintDescriptorState)constraintDescriptorState).getStereotypesToApply();
+ if(stereotypesToApply.size() > 0) {
+ String stereotypeName = stereotypesToApply.get(0);
+ // we have the stereotype qualified name. Now, should
+ // check if it fits to the current stereotype or one of
+ // its parent
+ if(stereotypeName.equals(getCurrentStereoype().getQualifiedName())) {
+ return true;
+ }
+ // check in the general stereotypes list
+ List<Stereotype> generalStereotypes = StereotypeUtil.getAllSuperStereotypes(getCurrentStereoype());
+ for(Stereotype stereotype : generalStereotypes) {
+ if(stereotypeName.equals(stereotype.getQualifiedName())) {
+ return true;
+ }
+ }
+ }
+ }
+ } else {
+ Activator.log.warn(Messages.CustomizeContentWizardPage_Warning_NoStereotypeNeitherMetaclass);
+ }
+
+ }
+ return false;
+ }
+
+ /**
+ * update the preview area
+ */
+ protected void updatePreview() {
+ if(selectedTab != null && !(getCurrentMetaClass() == null && getCurrentStereoype() == null) && previewArea != null && !previewArea.isDisposed()) {
+ List<SectionDescriptorState> displayedSections = new ArrayList<SectionDescriptorState>();
+ String selectedTabName = selectedTab.getId();
+ Composite parent = previewArea.getParent();
+ previewArea.dispose();
+ previewArea = null;
+ previewArea = factory.createScrolledComposite(parent, SWT.VERTICAL | SWT.HORIZONTAL | SWT.BORDER);
+ previewArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ Composite content = factory.createComposite(previewArea);
+ content.setLayout(new GridLayout(1, true));
+ // content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
+ // true));
+ previewArea.setExpandVertical(true);
+ previewArea.setExpandHorizontal(true);
+ previewArea.getHorizontalBar().setIncrement(20);
+ previewArea.getVerticalBar().setIncrement(20);
+
+ for(SectionSetDescriptorState sectionSetDescriptorState : StatesStore.getSectionSetDescriptorStates()) {
+ if(isSectionSetDescriptorStateValid(sectionSetDescriptorState)) {
+ // check the content of this section set: sections give the
+ // constraints
+ for(SectionDescriptorState state : sectionSetDescriptorState.getSectionDescriptorStates()) {
+ if(selectedTabName.equals(state.getTargetTab())) {
+ displayedSections.add(state);
+ }
+ }
+ }
+ }
+
+ List<SectionDescriptorState> filteredSectionstates = new ArrayList<SectionDescriptorState>();
+ for(SectionDescriptorState sectionDescriptorState : displayedSections) {
+ boolean isRemoved = false;
+ String currentId = sectionDescriptorState.getId();
+ // is this descriptor removed by another one ?
+ for(SectionDescriptorState state : displayedSections) {
+ for(ReplacedSectionState replacedSectionState : state.getReplacedSectionStates()) {
+ if(replacedSectionState.getId().equals(currentId)) {
+ isRemoved = true;
+ }
+ }
+ }
+
+ if(!isRemoved) {
+ filteredSectionstates.add(sectionDescriptorState);
+ }
+ }
+
+ for(SectionDescriptorState state : filteredSectionstates) {
+ for(IFragmentDescriptorState fragmentDescriptorState : state.getFragmentDescriptorStates()) {
+ for(ContainerDescriptorState containerDescriptorState : fragmentDescriptorState.getContainerDescriptorStates()) {
+ containerDescriptorState.createPreview(content);
+ }
+ }
+ }
+
+ previewArea.setContent(content);
+ previewArea.getParent().layout(true);
+ }
+ }
+
+ /**
+ * Specialization that filters metamodel information
+ */
+ private class TreeSelectionPatternFilter extends PatternFilter {
+
+ @Override
+ protected boolean isParentMatch(Viewer viewer, Object element) {
+ if(element instanceof DynamicSectionDescriptor) {
+ String labelText = ((DynamicSectionDescriptor)element).getId();
+ if(labelText != null) {
+ return wordMatches(labelText);
+ }
+ } else if(element instanceof SectionSetDescriptorState) {
+ return true;
+ } else if(element instanceof NamedElement) {
+ String labelText = ((NamedElement)element).getQualifiedName();
+ if(labelText != null) {
+ return wordMatches(labelText);
+ }
+ } else if(element instanceof ModelElementItem) {
+ String labelText;
+ EObject eObject = ((ModelElementItem)element).getEObject();
+ if(eObject instanceof ENamedElement) {
+ labelText = ((ENamedElement)((ModelElementItem)element).getEObject()).getName();
+ } else {
+ labelText = ((ModelElementItem)element).getText();
+ }
+
+ if(labelText != null) {
+ return wordMatches(labelText);
+ }
+
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean isElementVisible(Viewer viewer, Object element) {
+ return isParentMatch(viewer, element);
+ }
+ }
+
+
+ /**
+ * Creates the area where the metamodel elements, the available views and
+ * controllers are displayed. This is the part on the upper left.
+ *
+ * @param composite
+ * the parent composite for the controls created in this area
+ */
+ protected void createContentExplorer(Composite composite) {
+ Composite mainContentAreaComposite = new Composite(composite, SWT.NONE);
+ mainContentAreaComposite.setLayout(new GridLayout(1, false));
+
+ // title of this area
+ Label contentLabel = new Label(mainContentAreaComposite, SWT.NONE);
+ contentLabel.setText(Messages.CustomizeContentWizardPage_ContentArea_Label);
+
+ metamodelSelectionCombo = new CCombo(mainContentAreaComposite, SWT.BORDER | SWT.READ_ONLY);
+ metamodelSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ metamodels = retrieveAvailableMetamodels();
+ String[] metamodelNames = retrieveMetamodelNames();
+ metamodelSelectionCombo.setItems(metamodelNames);
+ metamodelSelectionCombo.addSelectionListener(new SelectionListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetSelected(SelectionEvent e) {
+ // update the input of the content view
+ metamodelViewer.getViewer().setInput(metamodels.get(metamodelSelectionCombo.getSelectionIndex()));
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // nothing here
+ }
+ });
+
+ // treeviewer for the metamodel
+ int flags = SWT.BORDER | SWT.SINGLE;
+
+ TreeSelectionPatternFilter patternfilter = new TreeSelectionPatternFilter();
+ patternfilter.setIncludeLeadingWildcard(true);
+ metamodelViewer = new FilteredTree(mainContentAreaComposite, flags, patternfilter, true);
+ metamodelViewer.getViewer().getControl().addMenuDetectListener(new MenuDetectListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void menuDetected(MenuDetectEvent e) {
+ // retrieve current selection, this should be an EObject or a
+ // SectionSetDescriptorState
+ ITreeSelection selection = (ITreeSelection)metamodelViewer.getViewer().getSelection();
+ if(selection == null || selection.size() < 1) {
+ Activator.log.warn(Messages.CustomizeContentWizardPage_Error_NoSelectionForMenuCreation);
+ return;
+ }
+
+ Object selectedObject = selection.getFirstElement();
+ Menu menu = null;
+ // awful code, should delegate to each state which menu should
+ // be created
+ if(selectedObject instanceof SectionSetDescriptorState) {
+ menu = new SectionSetMenuCreator(StatesStore.getSectionSetDescriptorStates(), metamodelViewer.getViewer(), (SectionSetDescriptorState)selectedObject, getCurrentMetaClass(), getCurrentStereoype()).getMenu(metamodelViewer.getViewer().getTree());
+ } else if(selectedObject instanceof ModelElementItem) {
+ ModelElementItem item = (ModelElementItem)selectedObject;
+ EObject selectedEObject = item.getEObject();
+ if(selectedEObject instanceof EClassifier) {
+ menu = new EClassifierMenuCreator((ModelElementItem)selectedObject, StatesStore.getSectionSetDescriptorStates(), metamodelViewer.getViewer(), getCurrentSectionSetDescriptorState(), getCurrentMetaClass(), getCurrentStereoype()).getMenu(metamodelViewer.getViewer().getTree());
+ } else if(selectedEObject instanceof Stereotype) {
+ menu = new StereotypeMenuCreator((ModelElementItem)selectedObject, StatesStore.getSectionSetDescriptorStates(), metamodelViewer.getViewer(), getCurrentSectionSetDescriptorState(), getCurrentMetaClass(), getCurrentStereoype()).getMenu(metamodelViewer.getViewer().getTree());
+ }
+ }
+
+ if(menu != null) {
+ // creates the menu, depending on the selection
+ menu.setVisible(true);
+ }
+ }
+ });
+
+
+ metamodelViewer.getViewer().addPostSelectionChangedListener(new ISelectionChangedListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ // update the current section set selection
+ TreeSelection selection = ((TreeSelection)event.getSelection());
+ Object selectedElement = selection.getFirstElement();
+ // this can be a metaclass or a section set descriptor.
+ if(selectedElement instanceof ModelElementItem) {
+ setCurrentSectionSetDescriptorState(null);
+ EObject selectedEObject = ((ModelElementItem)selectedElement).getEObject();
+ if(selectedEObject instanceof EClassifier) {
+ setCurrentMetaClass((EClassifier)selectedEObject);
+ setCurrentStereotype(null);
+ } else if(selectedEObject instanceof Stereotype) {
+ setCurrentMetaClass(null);
+ setCurrentStereotype((Stereotype)selectedEObject);
+ } else {
+ Activator.log.error(Messages.CustomizeContentWizardPage_Error_SelectionStereotypeOrClassifier + selectedEObject, null);
+ }
+ } else if(selectedElement instanceof SectionSetDescriptorState) {
+ // retrieve the metaclass using the TreePath of the
+ // selection
+ TreePath[] paths = selection.getPathsFor(selectedElement);
+ // metaclass should be the first element in the
+ // table
+ if(paths.length > 0) {
+ TreePath treePath = paths[0];
+ Object firstSegment = treePath.getSegment(0);
+ if(firstSegment instanceof ModelElementItem) {
+ EObject selectedEObject = ((ModelElementItem)firstSegment).getEObject();
+ if(selectedEObject instanceof EClassifier) {
+ setCurrentMetaClass((EClassifier)selectedEObject);
+ setCurrentStereotype(null);
+ } else if(selectedEObject instanceof Stereotype) {
+ setCurrentMetaClass(null);
+ setCurrentStereotype((Stereotype)selectedEObject);
+ } else {
+ Activator.log.error(Messages.CustomizeContentWizardPage_Error_SelectionStereotypeOrClassifier + selectedEObject, null);
+ }
+ }
+ }
+ currentSectionSetDescriptorState = (SectionSetDescriptorState)selectedElement;
+ }
+ updatePreview();
+ updateConfigurationArea();
+ }
+ });
+ metamodelViewer.getViewer().addDoubleClickListener(new IDoubleClickListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void doubleClick(DoubleClickEvent event) {
+ // edit element on which double click occurs => open edit dialog
+ ITreeSelection selection = (ITreeSelection)event.getSelection();
+ Object selectedElement = selection.getFirstElement();
+
+ // if element is a state, opens the dialog on this state
+ if(selectedElement instanceof IState) {
+ openEditionDialog(((IState)selectedElement));
+ }
+ }
+ });
+
+ }
+
+ /**
+ * Returns the list of metamodels names for the list of available metamodels
+ *
+ * @return the list of metamodels names for the list of available metamodels
+ */
+ protected String[] retrieveMetamodelNames() {
+ List<String> names = new ArrayList<String>();
+ for(EObject object : metamodels) {
+ if(object instanceof EPackage) {
+ names.add(((EPackage)object).getName());
+ } else if(object instanceof Profile) {
+ names.add(((Profile)object).getName());
+ } else {
+ // should not happen
+ names.add(object.toString());
+ }
+ }
+
+ return names.toArray(new String[0]);
+ }
+
+ /**
+ * Updates the configuration area
+ */
+ protected void updateConfigurationArea() {
+ configurationViewer.setInput(currentSectionSetDescriptorState);
+ configurationViewer.expandAll();
+ }
+
+ /**
+ * Returns the list of metamodels for which a configuration of property view
+ * could be done.
+ *
+ * @return the list of metamodels, never <code>null</code>.
+ */
+ protected List<EObject> retrieveAvailableMetamodels() {
+ List<EObject> metamodels = new ArrayList<EObject>();
+ DiagramEditor editor = null;
+ // retrieve current editor, and current resources
+ IEditorPart mainEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if(mainEditor instanceof org.eclipse.papyrus.core.editor.CoreMultiDiagramEditor) {
+ editor = (DiagramEditor)((CoreMultiDiagramEditor)mainEditor).getActiveEditor();
+ }
+ if(editor == null) {
+ Activator.log.warn(Messages.CustomizeContentWizardPage_Error_NoActiveDiagram);
+ return Collections.emptyList();
+ }
+ EObject eObject = editor.getDiagram().getElement();
+ if(eObject == null) {
+ Activator.log.warn(Messages.CustomizeContentWizardPage_Error_NoActiveDiagram);
+ return Collections.emptyList();
+ }
+
+ if(eObject instanceof Element) {
+ // retrieve the top package, and the applied profiles
+ metamodels.add(UMLPackage.eINSTANCE);
+
+ org.eclipse.uml2.uml.Package rootPackage = PackageUtil.getRootPackage(((Element)eObject));
+ List<Profile> profilesApplied = rootPackage.getAllAppliedProfiles();
+ for(Profile profile : profilesApplied) {
+ metamodels.add(profile);
+ }
+ }
+ return metamodels;
+ }
+
+ /**
+ * Returns a human readable name for the given profile. This name will also
+ * be used to identify which currently selection has been done
+ *
+ * @param profile
+ * the profile to display
+ * @return the name of the profile
+ */
+ protected String getProfileDisplayName(Profile profile) {
+ return profile.getQualifiedName();
+ }
+
+ /**
+ * Returns the currentSectionSetDescriptorState
+ *
+ * @return the currentSectionSetDescriptorState
+ */
+ public SectionSetDescriptorState getCurrentSectionSetDescriptorState() {
+ return currentSectionSetDescriptorState;
+ }
+
+ /**
+ * Sets the currentSectionSetDescriptorState
+ *
+ * @param currentSectionSetDescriptorState
+ * the currentSectionSetDescriptorState to set
+ */
+ public void setCurrentSectionSetDescriptorState(SectionSetDescriptorState currentSectionSetDescriptorState) {
+ this.currentSectionSetDescriptorState = currentSectionSetDescriptorState;
+ }
+
+ /**
+ * Returns the current selected MetaClass
+ *
+ * @return the current selected MetaClass
+ */
+ public EClassifier getCurrentMetaClass() {
+ return currentMetaClass;
+ }
+
+ /**
+ * Sets the current selected MetaClass
+ *
+ * @param currentMetaClass
+ * the current MetaClass to set
+ */
+ public void setCurrentMetaClass(EClassifier currentMetaClass) {
+ this.currentMetaClass = currentMetaClass;
+ }
+
+ /**
+ * Sets the current selected Stereotype
+ *
+ * @param currentStereoype
+ * the current Stereotype to set
+ */
+ public void setCurrentStereotype(Stereotype currentStereoype) {
+ this.currentStereoype = currentStereoype;
+ }
+
+ /**
+ * Returns the currentStereoype
+ *
+ * @return the currentStereoype
+ */
+ public Stereotype getCurrentStereoype() {
+ return currentStereoype;
+ }
+
+ /**
+ * Sets the currentSelectionsize and updates the size area
+ *
+ * @param currentSelectionsize
+ * the currentSelectionsize to set
+ */
+ protected void setCurrentSelectionsize(int currentSelectionsize) {
+ this.currentSelectionsize = currentSelectionsize;
+ if(sizeArea != null && !sizeArea.isDisposed()) {
+ sizeArea.select(sizeValues.indexOf(currentSelectionsize));
+ }
+ updateSizeArea();
+ }
+
+ /**
+ * Returns the currentSelectionsize
+ *
+ * @return the currentSelectionsize
+ */
+ public int getCurrentSelectionsize() {
+ return currentSelectionsize;
+ }
+
+ /**
+ * Sets the file where the content will be serialized
+ *
+ * @param file
+ * the file in which the content will be serialized
+ */
+ public void setNewFile(File file) {
+ this.file = file;
+ }
+
+ /**
+ * Returns the file in which the content will be serialized
+ *
+ * @return the file in which the content will be serialized
+ */
+ public File getFile() {
+ return file;
+ }
+
+ /**
+ * Serializes the content of the configuration
+ *
+ * @return <code>true</code> if serialization finished well
+ */
+ public boolean serializeContent() {
+
+ ConfigurationValidator configurationValidator = new ConfigurationValidator(getShell());
+ if(configurationValidator.validateConfig(true, false)) {
+ Job job = new Job(Messages.CustomizeContentWizardPage_Job_SavingConfiguration) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+
+ try {
+ final Document document = getFinalContent();
+ final File file = getFile();
+ // final File file =
+ // ResourcesPlugin.getWorkspace().getRoot().getRawLocation().append("test/test.xml").toFile();
+ file.delete();
+
+ if(!file.exists()) {
+ file.createNewFile();
+ }
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = factory.newTransformer();
+
+ Source source = new DOMSource(document);
+ Result result = new StreamResult(file);
+
+ transformer.transform(source, result);
+ return Status.OK_STATUS;
+ } catch (TransformerException e) {
+ Activator.log.error(e);
+ return new Status(Status.ERROR, Activator.ID, e.getLocalizedMessage());
+ } catch (IOException e) {
+ Activator.log.error(e);
+ return new Status(Status.ERROR, Activator.ID, e.getLocalizedMessage());
+ }
+ }
+ };
+ job.schedule();
+ // there, the xml file should be serialized
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/CustomizePropertyViewWizard.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/CustomizePropertyViewWizard.java
new file mode 100644
index 00000000000..d552baa3452
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/CustomizePropertyViewWizard.java
@@ -0,0 +1,57 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+
+
+/**
+ * Wizard for Property View Customization
+ */
+public class CustomizePropertyViewWizard extends Wizard {
+
+ /** page to select the xml file to edit */
+ protected SelectConfigurationFileWizardPage selectXmlFilePage = new SelectConfigurationFileWizardPage();
+
+ /** Customize the content of the page */
+ protected CustomizeContentWizardPage customizeContentPage = new CustomizeContentWizardPage();
+
+ /**
+ * Creates a new CustomizePropertyViewWizard.
+ *
+ */
+ public CustomizePropertyViewWizard() {
+ setDialogSettings(Activator.getDefault().getDialogSettings());
+ setNeedsProgressMonitor(true);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addPages() {
+ addPage(selectXmlFilePage);
+ addPage(customizeContentPage);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean performFinish() {
+ boolean returnCode = customizeContentPage.serializeContent();
+ selectXmlFilePage.performPostSerializationAction();
+ return returnCode;
+ }
+
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/MetamodelContentProvider.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/MetamodelContentProvider.java
new file mode 100644
index 00000000000..89dd6a427ca
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/MetamodelContentProvider.java
@@ -0,0 +1,223 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.facet.infra.browser.uicore.CustomizableModelContentProvider;
+import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ModelElementItem;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.core.utils.FilteredCollectionView;
+import org.eclipse.papyrus.core.utils.IFilter;
+import org.eclipse.papyrus.properties.runtime.view.constraints.AppliedStereotypeConstraintDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.constraints.IConstraintDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.constraints.ObjectTypeConstraintDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.papyrus.umlutils.StereotypeUtil;
+import org.eclipse.uml2.uml.Profile;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+/**
+ * Content Provider for the metamodel viewer. It will display the metaclass elements, and the section sets that are available for these elements
+ */
+@SuppressWarnings("restriction")
+public class MetamodelContentProvider extends CustomizableModelContentProvider implements PropertyChangeListener {
+
+ /** list of available section sets */
+ protected final List<SectionSetDescriptorState> availableSectionSets;
+
+ /** metamodel tree viewer */
+ private TreeViewer fViewer;
+
+ /**
+ * Creates a new MetamodelContentProvider.
+ */
+ public MetamodelContentProvider(List<SectionSetDescriptorState> availableSectionSets) {
+ super(Activator.getDefault().getCustomizationManager());
+ this.availableSectionSets = availableSectionSets;
+ for(SectionSetDescriptorState state : availableSectionSets) {
+ state.addPropertyChangeListener(this);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ super.inputChanged(viewer, oldInput, newInput);
+ fViewer = (TreeViewer)viewer;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public EObject[] getRootElements(Object inputElement) {
+ if(inputElement instanceof EPackage) {
+ return ((EPackage)inputElement).getEClassifiers().toArray(new EClassifier[]{});
+ } else if(inputElement instanceof Profile) {
+ return ((Profile)inputElement).getOwnedStereotypes().toArray(new EObject[]{});
+ } else if(inputElement instanceof EObject) {
+ return ((EObject)inputElement).eContents().toArray(new EObject[]{});
+ } else if(inputElement instanceof List<?>) {
+ List<EClassifier> objects = new ArrayList<EClassifier>();
+ objects.addAll((List<EClassifier>)inputElement);
+ //order the list by name, if required ?
+ Collections.sort(objects, new Comparator<EClassifier>() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public int compare(EClassifier o1, EClassifier o2) {
+ if(o1.getName() == null) {
+ return 0;
+ }
+ return o1.getName().compareTo(o2.getName());
+ }
+
+ });
+ return objects.toArray(new EObject[]{});
+ }
+ return new EObject[0];
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object[] getChildren(Object parentElement) {
+ if(parentElement instanceof ModelElementItem) {
+ if(((ModelElementItem)(parentElement)).getEObject() instanceof EClassifier) {
+ EClassifier parentClassifier = (EClassifier)((ModelElementItem)(parentElement)).getEObject();
+ // List<SectionSetDescriptorState> sectionSetDescriptorStates = new ArrayList<SectionSetDescriptorState>();
+ String qualifiedInstanceClassName = parentClassifier.getInstanceClassName();
+ try {
+ final Class<?> metamodelClass = Class.forName(qualifiedInstanceClassName);
+
+ // populate the section sets
+ FilteredCollectionView<SectionSetDescriptorState> filteredList = new FilteredCollectionView<SectionSetDescriptorState>(availableSectionSets, new IFilter() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isAllowed(Object object) {
+ if(object instanceof SectionSetDescriptorState) {
+ List<IConstraintDescriptor> constraintDescriptors = ((SectionSetDescriptorState)object).getDescriptor().getConstraintDescriptors();
+ for(IConstraintDescriptor constraintDescriptor : constraintDescriptors) {
+ if(constraintDescriptor instanceof ObjectTypeConstraintDescriptor) {
+ Class<?> elementClass = ((ObjectTypeConstraintDescriptor)constraintDescriptor).getElementClass();
+ if(elementClass.isAssignableFrom(metamodelClass)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ });
+ return filteredList.toArray();
+
+ } catch (ClassNotFoundException e) {
+ // Activator.log.error(e);
+ return new Object[0];
+ }
+
+ } else if(((ModelElementItem)(parentElement)).getEObject() instanceof Stereotype) {
+ final Stereotype parentStereotype = (Stereotype)((ModelElementItem)(parentElement)).getEObject();
+ // List<SectionSetDescriptorState> sectionSetDescriptorStates = new ArrayList<SectionSetDescriptorState>();
+ // populate the section sets
+ FilteredCollectionView<SectionSetDescriptorState> filteredList = new FilteredCollectionView<SectionSetDescriptorState>(availableSectionSets, new IFilter() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isAllowed(Object object) {
+ if(object instanceof SectionSetDescriptorState) {
+ List<IConstraintDescriptor> constraintDescriptors = ((SectionSetDescriptorState)object).getDescriptor().getConstraintDescriptors();
+ for(IConstraintDescriptor constraintDescriptor : constraintDescriptors) {
+ if(constraintDescriptor instanceof AppliedStereotypeConstraintDescriptor) {
+ List<String> stereotypeNames = ((AppliedStereotypeConstraintDescriptor)constraintDescriptor).getStereotypeQualifiedNames();
+ // look only for the first one, this could lead to bugs...
+ if(stereotypeNames.size() > 0) {
+ String stereotypeName = stereotypeNames.get(0);
+ // we have the stereotype qualified name. Now, should check if it fits to the current stereotype or one of its parent
+ if(stereotypeName.equals(parentStereotype.getQualifiedName())) {
+ return true;
+ }
+ // check in the general stereotypes list
+ List<Stereotype> generalStereotypes = StereotypeUtil.getAllSuperStereotypes(parentStereotype);
+ for(Stereotype stereotype : generalStereotypes) {
+ if(stereotypeName.equals(stereotype.getQualifiedName())) {
+ return true;
+ }
+ }
+ }
+
+ }
+ }
+ }
+ return false;
+ }
+
+ });
+ return filteredList.toArray();
+ }
+ }
+
+ return new Object[0];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasChildren(Object element) {
+ // force computation, instead of returning true as treeElement.hasChildren() does.
+ Object[] children = getChildren(element);
+ return children != null && children.length > 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ if(evt.getSource() instanceof SectionSetDescriptorState) {
+ ((TreeViewer)fViewer).refresh(true);
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void dispose() {
+ for(SectionSetDescriptorState state : availableSectionSets) {
+ state.removePropertyChangeListener(this);
+ }
+ super.dispose();
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/MetamodelLabelProvider.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/MetamodelLabelProvider.java
new file mode 100644
index 00000000000..1c141244ae7
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/MetamodelLabelProvider.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog;
+
+import org.eclipse.emf.facet.infra.browser.uicore.CustomizableModelLabelProvider;
+import org.eclipse.papyrus.properties.tabbed.core.view.DynamicSectionDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.uml2.uml.NamedElement;
+
+
+/**
+ * Label provider for the metamodel tree viewer in the customize property view dialog
+ */
+public class MetamodelLabelProvider extends CustomizableModelLabelProvider {
+
+ /** image key for the section set state */
+ public static final String SECTION_SET_IMG = "sectionSetImg";
+
+ /**
+ * Creates a new MetamodelLabelProvider.
+ *
+ * @param adapterFactory
+ * the adapter factory from which elements can be adapt to find their own label provider
+ */
+ public MetamodelLabelProvider() {
+ super(Activator.getDefault().getCustomizationManager());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getText(Object object) {
+ if(object instanceof DynamicSectionDescriptor) {
+ return ((DynamicSectionDescriptor)object).getId();
+ } else if(object instanceof SectionSetDescriptorState) {
+ SectionSetDescriptorState state = (SectionSetDescriptorState)object;
+ return state.getLabel();
+ } else if(object instanceof NamedElement) {
+ return ((NamedElement)object).getQualifiedName();
+ } else {
+ return super.getText(object);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Image getImage(Object element) {
+ if(element instanceof SectionSetDescriptorState) {
+ return Activator.getImage("/icons/type.gif");
+ }
+ return super.getImage(element);
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/SelectConfigurationFileWizardPage.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/SelectConfigurationFileWizardPage.java
new file mode 100644
index 00000000000..e52fafc74d2
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/SelectConfigurationFileWizardPage.java
@@ -0,0 +1,1346 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
+import org.eclipse.gmf.runtime.common.core.service.IProvider;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.papyrus.properties.runtime.view.PropertyViewService;
+import org.eclipse.papyrus.properties.runtime.view.PropertyViewService.ProviderDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.XMLPropertyTabViewProvider;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.papyrus.properties.tabbed.customization.Messages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+
+/**
+ * Creates the page for the selection of the xml file to be edited.
+ * <p>
+ * This page should display three choices:
+ * <ul>
+ * <li>Create a new one from scratch</li>
+ * <li>Create a new one, based on a exiting one</li>
+ * <li>Modify an existing one</li>
+ * </ul>
+ * </p>
+ */
+public class SelectConfigurationFileWizardPage extends WizardPage {
+
+ /** selection listener for the radio buttons */
+ protected SelectionListener selectionListener = new RadioSelectionListener();
+
+ /** map of buttons to know which area should be selected or not */
+ protected Map<Button, IConfigurationArea> radioButtonsMapping = new HashMap<Button, IConfigurationArea>();
+
+ /** filter for file selection dialogs */
+ protected ViewerFilter fileViewerFilter = new XMLFileViewerFilter();
+
+ /** content area for the create from scratch */
+ protected CreateFromScratchArea createFromScratchArea = new CreateFromScratchArea();
+
+ /** content area for the create from exiting configuration */
+ protected CreateFromExistingConfigurationArea createFromExistingConfigurationArea = new CreateFromExistingConfigurationArea();
+
+ /** content area for the modify exiting configuration */
+ protected ModifyExistingConfigurationArea modifyExistingConfigurationArea = new ModifyExistingConfigurationArea();
+
+ /** content area for the modify plugin contribution */
+ protected ModifyPluginConfigurationArea modifyPluginConfigurationArea = new ModifyPluginConfigurationArea();
+
+ /** file where to serialize configuration */
+ protected File file;
+
+ /** empty string */
+ protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+ /** next page to be displayed */
+ protected IWizardPage nextPage;
+
+ /**
+ * Creates a new SelectConfigurationFileWizardPage.
+ */
+ protected SelectConfigurationFileWizardPage() {
+ super(Messages.SelectConfigurationFileWizardPage_PageName, Messages.SelectConfigurationFileWizardPage_Title, null);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridData data = new GridData(SWT.FILL, SWT.TOP, true, true);
+ composite.setLayoutData(data);
+ GridLayout layout = new GridLayout(2, false);
+ // layout.verticalSpacing = 0;
+ layout.marginHeight = 0;
+ composite.setLayout(layout);
+ // sets the new control
+ setControl(composite);
+
+ // creates the content
+ createContentArea(composite);
+ }
+
+ /**
+ * creates the content area for this wizard page
+ *
+ * @param composite
+ * the parent composite for the created composites in the content area
+ */
+ protected void createContentArea(Composite composite) {
+
+ Group userGroup = new Group(composite, SWT.NONE);
+ userGroup.setText(Messages.SelectConfigurationFileWizardPage_UserGroup_Label);
+ userGroup.setLayout(new GridLayout(1, false));
+ userGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+ modifyPluginConfigurationArea = new ModifyPluginConfigurationArea();
+ modifyPluginConfigurationArea.createContent(userGroup);
+
+ Group devGroup = new Group(composite, SWT.NONE);
+ devGroup.setText(Messages.SelectConfigurationFileWizardPage_SourceGroup_Label);
+ GridLayout layout = new GridLayout(1, false);
+ devGroup.setLayout(layout);
+ GridData groupData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
+ devGroup.setLayoutData(groupData);
+
+ // create content for the group
+ createFromScratchArea = new CreateFromScratchArea();
+ createFromScratchArea.createContent(devGroup);
+
+ createFromExistingConfigurationArea = new CreateFromExistingConfigurationArea();
+ createFromExistingConfigurationArea.createContent(devGroup);
+
+ modifyExistingConfigurationArea = new ModifyExistingConfigurationArea();
+ modifyExistingConfigurationArea.createContent(devGroup);
+
+ // create a new one by default
+ enableConfigurationArea(modifyPluginConfigurationArea);
+ }
+
+ /**
+ * Notifies that one of the radio button has been selected
+ *
+ * @param e
+ * selection event that triggers this method
+ */
+ protected void notifyButtonChanged(SelectionEvent e) {
+ // enable the right one
+ if(e.widget != null) {
+ IConfigurationArea enabledConfigurationArea = radioButtonsMapping.get(e.widget);
+ if(enabledConfigurationArea != null) {
+ enableConfigurationArea(enabledConfigurationArea);
+ } else {
+ Activator.log.warn(Messages.SelectConfigurationFileWizardPage_Error_NoAreaForWidget + e);
+ }
+ }
+ }
+
+ /**
+ * Enables the specified area
+ *
+ * @param areaToEnable
+ * the area to enable
+ */
+ protected void enableConfigurationArea(IConfigurationArea areaToEnable) {
+ // disable all area, then enables only the right one
+ for(IConfigurationArea area : radioButtonsMapping.values()) {
+ area.setEnable(false);
+ }
+ areaToEnable.setEnable(true);
+ areaToEnable.validatePage();
+ }
+
+ /**
+ * Returns the current selected configuration area
+ *
+ * @return the current selected configuration area
+ */
+ protected IConfigurationArea getEnableConfigurationArea() {
+ for(Button button : radioButtonsMapping.keySet()) {
+ if(button.getSelection()) {
+ return radioButtonsMapping.get(button);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Checks if the specified control is valid.
+ *
+ * @param control
+ * the control to check
+ * @return <code>true</code> if the control is valid, i.e. not <code>null</code> and not disposed.
+ */
+ protected boolean isValid(Control control) {
+ return (control != null && !control.isDisposed());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IWizardPage getNextPage() {
+ if(getWizard() instanceof CustomizePropertyViewWizard) {
+
+ BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
+
+ public void run() {
+ CustomizeContentWizardPage newPage = ((CustomizePropertyViewWizard)getWizard()).customizeContentPage;
+ // newPage.setInitialContent();
+ Document initialDocument = getEnableConfigurationArea().generateInitialContent();
+ newPage.setInitialContent(initialDocument);
+ file = getEnableConfigurationArea().getNewFile();
+ newPage.setNewFile(file);
+ setNextPage(newPage);
+ }
+ });
+ return nextPage;
+ }
+ return null;
+ }
+
+ /**
+ * Sets the next page
+ *
+ * @param page
+ * the next page to set
+ */
+ protected void setNextPage(IWizardPage page) {
+ this.nextPage = page;
+ }
+
+ /**
+ * Listener added to the radio buttons.
+ */
+ protected class RadioSelectionListener implements SelectionListener {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetSelected(SelectionEvent e) {
+ // action taken as soon as a button as been pressed
+ notifyButtonChanged(e);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // nothing to do here
+ }
+ }
+
+ /**
+ * Viewer filter for selection dialog, displaying only xml files
+ */
+ protected class XMLFileViewerFilter extends ViewerFilter {
+
+ /** XML file extension */
+ protected static final String XML_FILE_EXTENSION = "xml"; //$NON-NLS-1$
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if(element instanceof IFile) {
+ IFile file = (IFile)element;
+ return XML_FILE_EXTENSION.equals(file.getFileExtension());
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Interface for all configuration areas
+ */
+ protected interface IConfigurationArea {
+
+ /**
+ * Enables the elements on the area, given the specified enablement state
+ *
+ * @param enable
+ * the enablement state for the elements in the composite
+ */
+ public void setEnable(boolean enable);
+
+ /**
+ * Indicates if the page is complete and the user can go to the next page
+ */
+ public void validatePage();
+
+ /**
+ * Generates the initial content from the given configuration
+ *
+ * @return the initial content passed to the second page
+ */
+ public Document generateInitialContent();
+
+ /**
+ * Creates the content of the area
+ *
+ * @param parent
+ * the parent composite where content must be added
+ * @return the composite created
+ */
+ public Composite createContent(Composite parent);
+
+ /**
+ * Returns the new file where the content will be serialized
+ *
+ * @return the new file where the content will be serialized
+ */
+ public File getNewFile();
+
+ /**
+ *
+ */
+ public void performPostSerializationAction();
+ }
+
+ /**
+ * Interface for a configuration area that allows to enter a new name
+ */
+ protected interface INameConfigurationArea extends IConfigurationArea {
+
+ /**
+ * Returns the new name for the configuration
+ *
+ * @return the new name for the configuration
+ */
+ public String getNewName();
+ }
+
+ /**
+ * abstract implementation for the name configuration area interface
+ */
+ protected abstract class AbstractNameConfigurationArea implements INameConfigurationArea {
+
+ /** text area to enter the name of the new configuration */
+ protected Text nameText;
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getNewName() {
+ if(isValid(nameText)) {
+ return nameText.getText();
+ }
+ String generatedName = Messages.bind(Messages.SelectConfigurationFileWizardPage_DefaultConfigurationName, System.currentTimeMillis());
+ // generate a default name
+ Activator.log.warn(Messages.bind(Messages.SelectConfigurationFileWizardPage_ErrorMessage_NoValidTextArea, generatedName));
+ return generatedName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void validatePage() {
+ if(nameText.getText() == null || nameText.getText().equals(EMPTY_STRING)) {
+ setPageComplete(false);
+ setMessage(Messages.SelectConfigurationFileWizardPage_ErrorMessage_notValidName, ERROR);
+ } else {
+ setPageComplete(true);
+ setMessage(EMPTY_STRING, NONE);
+ }
+
+ }
+ }
+
+ /**
+ * Area for the "create a new empty configuration" in the dialog
+ */
+ protected class CreateFromScratchArea extends AbstractNameConfigurationArea {
+
+ /** Button used to create an empty configuration */
+ protected Button createFromScratchButton;
+
+ /** text used to enter the plugin id required to load classes on runtime */
+ protected Text pluginIdText;
+
+ /** text that contais the location of the new file, workspace root-relative */
+ protected Text folderText;
+
+ /** button that open a workspce folder selection dialog */
+ protected Button folderButton;
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setEnable(boolean enable) {
+ if(isValid(createFromScratchButton)) {
+ createFromScratchButton.setSelection(enable);
+ nameText.setEnabled(enable);
+ pluginIdText.setEnabled(enable);
+ folderButton.setEnabled(enable);
+ if(enable) {
+ nameText.selectAll();
+ nameText.setFocus();
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Composite createContent(Composite parent) {
+ // main container with a border
+ Composite createFromScratchComposite = new Composite(parent, SWT.BORDER);
+ createFromScratchComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ createFromScratchComposite.setLayout(new GridLayout(4, false));
+
+ // first line: selection line (radio button + label)
+ createFromScratchButton = new Button(createFromScratchComposite, SWT.RADIO);
+ createFromScratchButton.addSelectionListener(selectionListener);
+ radioButtonsMapping.put(createFromScratchButton, this);
+ Label createFromScratchLabel = new Label(createFromScratchComposite, SWT.NONE);
+ createFromScratchLabel.setText(Messages.SelectConfigurationFileWizardPage_CreateAnEmptyConfig_Label);
+ GridData labelData = new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1);
+ createFromScratchLabel.setLayoutData(labelData);
+
+ // second line: name of the new configuration
+ Label nameLabel = new Label(createFromScratchComposite, SWT.NONE);
+ nameLabel.setText(Messages.SelectConfigurationFileWizardPage_CreateAnEmptyConfigName_Label);
+ nameLabel.setToolTipText(Messages.SelectConfigurationFileWizardPage_CreateAnEmptyConfigName_Tooltip);
+ labelData = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
+ nameLabel.setLayoutData(labelData);
+
+ nameText = new Text(createFromScratchComposite, SWT.BORDER);
+ nameText.setText(Messages.SelectConfigurationFileWizardPage_CreateAnEmptyConfigName_DefaultValue);
+ GridData textData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
+ nameText.setLayoutData(textData);
+ nameText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ validatePage();
+ }
+ });
+
+ // third line: plugin required to load classes
+ Label pluginIdLabel = new Label(createFromScratchComposite, SWT.NONE);
+ pluginIdLabel.setText(Messages.SelectConfigurationFileWizardPage_CreateAnEmptyConfigPluginId_Label);
+ pluginIdLabel.setToolTipText(Messages.SelectConfigurationFileWizardPage_CreateAnEmptyConfigPluginId_Tooltip);
+ labelData = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
+ pluginIdLabel.setLayoutData(labelData);
+
+ pluginIdText = new Text(createFromScratchComposite, SWT.BORDER);
+ pluginIdText.setText(Messages.SelectConfigurationFileWizardPage_CreateAnEmptyConfigPluginId_DefaultValue);
+ pluginIdText.setLayoutData(textData);
+ pluginIdText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ validatePage();
+ }
+ });
+
+ // 4th line: folder where to create the new file
+ Label folderLabel = new Label(createFromScratchComposite, SWT.NONE);
+ folderLabel.setText("Folder:");
+ folderLabel.setToolTipText("Select the folder where you want to create the new file");
+ labelData = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
+ folderLabel.setLayoutData(labelData);
+
+ folderText = new Text(createFromScratchComposite, SWT.BORDER);
+ folderText.setText("");
+ folderText.setEditable(false);
+ textData = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
+ folderText.setLayoutData(textData);
+
+ folderButton = new Button(createFromScratchComposite, SWT.NONE);
+ folderButton.setText("Select...");
+ folderButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ ContainerSelectionDialog selectionDialog = new ContainerSelectionDialog(getShell(), null, true, "Select the container where the file will be created");
+ if(Dialog.OK == selectionDialog.open()) {
+ Object[] result = selectionDialog.getResult();
+ if(result.length < 1) {
+ Activator.log.error("no container was selected in the dialog", null);
+ return;
+ }
+
+ Object container = result[0];
+ if(container instanceof Path) {
+ Path path = (Path)container;
+ folderText.setText(path.toString());
+ }
+
+
+ validatePage();
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+
+ return createFromScratchComposite;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getPluginId() {
+ if(isValid(pluginIdText)) {
+ return pluginIdText.getText();
+ }
+ Activator.log.error("impossible to read plugin Id from the text area", null);
+ return "";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public File getNewFile() {
+ // retrieve the folder where to create the file
+ IPath path = new Path(folderText.getText());
+ IContainer iContainer = (IContainer)ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if(iContainer.exists()) {
+ IPath location = iContainer.getLocation();
+ File file = location.append(Character.toString(IPath.SEPARATOR)).append(nameText.getText()).addFileExtension("xml").toFile();
+ return file;
+ }
+ Activator.log.warn("should never enter here");
+ File file = ResourcesPlugin.getWorkspace().getRoot().getRawLocation().append(folderText.getText()).append(Character.toString(IPath.SEPARATOR)).append(nameText.getText()).addFileExtension("xml").toFile();
+ return file;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Document generateInitialContent() {
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ DocumentBuilder documentBuilder;
+ try {
+ documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ Document document = documentBuilder.newDocument();
+ Comment comment = document.createComment(Messages.bind(Messages.SelectConfigurationFileWizardPage_EmptyDocument_InitialComment, Calendar.getInstance().getTime()));
+ document.appendChild(comment);
+ // FIXME change with an interface constant
+ Element rootNode = document.createElement("propertyTabView");// $NON-NLS-1$
+ rootNode.setAttribute("pluginId", pluginIdText.getText()); // $NON-NLS-1$
+ document.appendChild(rootNode);
+ document.normalizeDocument();
+ return document;
+ } catch (ParserConfigurationException e) {
+ Activator.log.error(e);
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void validatePage() {
+ if(isValid(nameText)) {
+ if(pluginIdText.getText() == null || pluginIdText.getText().equals(EMPTY_STRING)) {
+ setPageComplete(false);
+ setMessage(Messages.SelectConfigurationFileWizardPage_ErrorMessage_NoValidPluginIdentifier, ERROR);
+ } else if(folderText.getText() == null || folderText.getText().equals(EMPTY_STRING)) {
+ setPageComplete(false);
+ setMessage("Please select a valid folder", ERROR);
+ } else {
+ super.validatePage();
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void performPostSerializationAction() {
+ // nothing here
+ }
+ }
+
+ /**
+ * Area for the "create from existing configuration" in the dialog
+ */
+ protected class CreateFromExistingConfigurationArea extends AbstractNameConfigurationArea {
+
+ /** Button used to initialize the xml file from an existing one */
+ protected Button createFromExistingConfigurationButton;
+
+ /** button that opens dialog to select configuration to copy and modify */
+ protected Button createFromExistingConfigurationSelectionButton;
+
+ /** text area that display the name of the configuration file to copy and modify */
+ protected Text createFromExistingConfigurationText;
+
+ /** text that contais the location of the new file, workspace root-relative */
+ protected Text folderText;
+
+ /** button that open a workspce folder selection dialog */
+ protected Button folderButton;
+
+ /**
+ * {@inheritDoc}
+ */
+ public Composite createContent(Composite parent) {
+ // create from an existing configuration composite
+ Composite mainComposite = new Composite(parent, SWT.BORDER);
+ mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+ mainComposite.setLayout(new GridLayout(4, false));
+
+ // first line: radio button + label
+ createFromExistingConfigurationButton = new Button(mainComposite, SWT.RADIO);
+ createFromExistingConfigurationButton.addSelectionListener(selectionListener);
+ radioButtonsMapping.put(createFromExistingConfigurationButton, this);
+ Label createFromExistingConfigurationLabel = new Label(mainComposite, SWT.NONE);
+ createFromExistingConfigurationLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));
+ createFromExistingConfigurationLabel.setText(Messages.SelectConfigurationFileWizardPage_CreateFromExistingConfiguration_Label);
+
+ // second line: browser to select existing configuration
+ Label createFromExistingConfigurationExistingLabel = new Label(mainComposite, SWT.NONE);
+ createFromExistingConfigurationExistingLabel.setText(Messages.SelectConfigurationFileWizardPage_CreateFromExistingConfigFile_Label);
+ createFromExistingConfigurationExistingLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
+ createFromExistingConfigurationText = new Text(mainComposite, SWT.BORDER | SWT.READ_ONLY);
+ createFromExistingConfigurationText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ createFromExistingConfigurationSelectionButton = new Button(mainComposite, SWT.NONE);
+ createFromExistingConfigurationSelectionButton.addSelectionListener(new SelectionListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetSelected(SelectionEvent e) {
+ // open a workspace dialog to choose the exiting configuration to update
+ IFile[] selectedFiles = WorkspaceResourceDialog.openFileSelection(getShell(), Messages.SelectConfigurationFileWizardPage_CreateFromExistingConfigFile_Dialog_Title, Messages.SelectConfigurationFileWizardPage_CreateFromExistingConfigFile_Dialog_Message, false, new Object[0], Collections.singletonList(fileViewerFilter));
+ if(selectedFiles != null && selectedFiles.length == 1) {
+ IFile selectedFile = selectedFiles[0];
+ createFromExistingConfigurationText.setText(selectedFile.getFullPath().toString());
+ validatePage();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // nothing to do here
+ }
+ });
+ createFromExistingConfigurationSelectionButton.setText(Messages.SelectConfigurationFileWizardPage_CreateFromExistingConfigurationSelectionButton_Label);
+
+ // third line: name of the new configuration
+ Label nameLabel = new Label(mainComposite, SWT.NONE);
+ nameLabel.setText(Messages.SelectConfigurationFileWizardPage_CreateFromExistingConfigName_Label);
+ nameLabel.setToolTipText(Messages.SelectConfigurationFileWizardPage_CreateFromExistingConfigName_Tooltip);
+ GridData labelData = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
+ nameLabel.setLayoutData(labelData);
+
+ nameText = new Text(mainComposite, SWT.BORDER);
+ nameText.setText(Messages.SelectConfigurationFileWizardPage_CreateFromExistingConfigName_DefaultValue);
+ GridData textData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
+ nameText.setLayoutData(textData);
+ nameText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ validatePage();
+ }
+ });
+
+ // 4th line: folder where to create the new file
+ Label folderLabel = new Label(mainComposite, SWT.NONE);
+ folderLabel.setText("Folder:");
+ folderLabel.setToolTipText("Select the folder where you want to create the new file");
+ labelData = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
+ folderLabel.setLayoutData(labelData);
+
+ folderText = new Text(mainComposite, SWT.BORDER);
+ folderText.setText("");
+ folderText.setEditable(false);
+ textData = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
+ folderText.setLayoutData(textData);
+
+ folderButton = new Button(mainComposite, SWT.NONE);
+ folderButton.setText("Select...");
+ folderButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ ContainerSelectionDialog selectionDialog = new ContainerSelectionDialog(getShell(), null, true, "Select the container where the file will be created");
+ if(Dialog.OK == selectionDialog.open()) {
+ Object[] result = selectionDialog.getResult();
+ if(result.length < 1) {
+ Activator.log.error("no container was selected in the dialog", null);
+ return;
+ }
+
+ Object container = result[0];
+ if(container instanceof Path) {
+ Path path = (Path)container;
+ folderText.setText(path.toString());
+ }
+ validatePage();
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+
+ return mainComposite;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setEnable(boolean enable) {
+ if(isValid(createFromExistingConfigurationButton)) {
+ createFromExistingConfigurationButton.setSelection(enable);
+ createFromExistingConfigurationSelectionButton.setEnabled(enable);
+ createFromExistingConfigurationText.setEnabled(enable);
+ folderButton.setEnabled(enable);
+ nameText.setEnabled(enable);
+ if(enable) {
+ nameText.setFocus();
+ nameText.selectAll();
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void validatePage() {
+ if(isValid(nameText)) {
+ if(createFromExistingConfigurationText.getText() == null || createFromExistingConfigurationText.getText().equals(EMPTY_STRING)) {
+ setPageComplete(false);
+ setMessage(Messages.SelectConfigurationFileWizardPage_ErrorMessage_NoValidExistingConfiguration, ERROR);
+ } else if(folderText.getText() == null || folderText.getText().equals(EMPTY_STRING)) {
+ setPageComplete(false);
+ setMessage("Please select a valid folder", ERROR);
+ } else {
+ super.validatePage();
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Document generateInitialContent() {
+ // should read the document from the existing file. The result will be put somewhere else.
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ DocumentBuilder documentBuilder;
+ try {
+ documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(createFromExistingConfigurationText.getText()));
+ if(iFile.exists()) {
+ IPath location = iFile.getLocation();
+ if(location != null) {
+ final File file = location.toFile();
+ Document document = documentBuilder.parse(file);
+ return document;
+ }
+ }
+ } catch (ParserConfigurationException e) {
+ Activator.log.error(e);
+ } catch (SAXException e) {
+ Activator.log.error(e);
+ } catch (IOException e) {
+ Activator.log.error(e);
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public File getNewFile() {
+ // retrieve the folder where to create the file
+ IPath path = new Path(folderText.getText());
+ IContainer iContainer = (IContainer)ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if(iContainer.exists()) {
+ IPath location = iContainer.getLocation();
+ File file = location.append(Character.toString(IPath.SEPARATOR)).append(nameText.getText()).addFileExtension("xml").toFile();
+ return file;
+ }
+ Activator.log.warn("should never enter here");
+ File file = ResourcesPlugin.getWorkspace().getRoot().getRawLocation().append(folderText.getText()).append(Character.toString(IPath.SEPARATOR)).append(nameText.getText()).addFileExtension("xml").toFile();
+ return file;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void performPostSerializationAction() {
+ // nothing here
+ }
+ }
+
+ /**
+ * Area for the "modify an existing configuration" in the dialog
+ */
+ public class ModifyExistingConfigurationArea implements IConfigurationArea {
+
+ /** text area that display the name of the configuration file to modify */
+ protected Text modifyExistingConfigurationText;
+
+ /** button that opens dialog to select configuration to modify */
+ protected Button modifyExistingConfigurationSelectionButton;
+
+ /** Button used to modify an existing configuration */
+ protected Button modifyExistingConfigurationButton;
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setEnable(boolean enable) {
+ if(isValid(modifyExistingConfigurationButton)) {
+ modifyExistingConfigurationButton.setSelection(enable);
+ modifyExistingConfigurationText.setEnabled(enable);
+ modifyExistingConfigurationSelectionButton.setEnabled(enable);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void validatePage() {
+ if(isValid(modifyExistingConfigurationText)) {
+ if(modifyExistingConfigurationText.getText() == null || modifyExistingConfigurationText.getText().equals(EMPTY_STRING)) {
+ setPageComplete(false);
+ setMessage(Messages.SelectConfigurationFileWizardPage_ErrorMessage_NoValidExistingConfiguration, ERROR);
+ } else {
+ setMessage(EMPTY_STRING, NONE);
+ setPageComplete(true);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Composite createContent(Composite parent) {
+ // modify an existing configuration composite
+ Composite modifyExistingConfigurationComposite = new Composite(parent, SWT.BORDER);
+ modifyExistingConfigurationComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+ modifyExistingConfigurationComposite.setLayout(new GridLayout(3, false));
+ modifyExistingConfigurationButton = new Button(modifyExistingConfigurationComposite, SWT.RADIO);
+ modifyExistingConfigurationButton.addSelectionListener(selectionListener);
+ radioButtonsMapping.put(modifyExistingConfigurationButton, this);
+ Label modifyExistingConfigurationLabel = new Label(modifyExistingConfigurationComposite, SWT.NONE);
+ modifyExistingConfigurationLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+ modifyExistingConfigurationLabel.setText(Messages.SelectConfigurationFileWizardPage_ModifyExistingConfiguration_Label);
+ modifyExistingConfigurationText = new Text(modifyExistingConfigurationComposite, SWT.BORDER | SWT.READ_ONLY);
+ modifyExistingConfigurationText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+ modifyExistingConfigurationSelectionButton = new Button(modifyExistingConfigurationComposite, SWT.NONE);
+ modifyExistingConfigurationSelectionButton.setText(Messages.SelectConfigurationFileWizardPage_ModifyExistingConfigurationSelectionButton_Label);
+ modifyExistingConfigurationSelectionButton.addSelectionListener(new SelectionListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetSelected(SelectionEvent e) {
+ // open a workspace dialog to choose the exiting configuration to update
+ IFile[] selectedFiles = WorkspaceResourceDialog.openFileSelection(getShell(), Messages.SelectConfigurationFileWizardPage_ModifyExistingConfig_Dialog_Title, Messages.SelectConfigurationFileWizardPage_ModifyExistingConfig_Dialog_Message, false, new Object[0], Collections.singletonList(fileViewerFilter));
+ if(selectedFiles != null && selectedFiles.length == 1) {
+ IFile selectedFile = selectedFiles[0];
+ modifyExistingConfigurationText.setText(selectedFile.getFullPath().toString());
+ validatePage();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // nothing to do here
+ }
+ });
+ return modifyExistingConfigurationComposite;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Document generateInitialContent() {
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ DocumentBuilder documentBuilder;
+ try {
+ documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(modifyExistingConfigurationText.getText()));
+ if(iFile.exists()) {
+ IPath location = iFile.getLocation();
+ if(location != null) {
+ final File file = location.toFile();
+ Document document = documentBuilder.parse(file);
+ return document;
+ }
+ }
+ } catch (ParserConfigurationException e) {
+ Activator.log.error(e);
+ } catch (SAXException e) {
+ Activator.log.error(e);
+ } catch (IOException e) {
+ Activator.log.error(e);
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public File getNewFile() {
+ // returns the file itself
+ IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(modifyExistingConfigurationText.getText()));
+ if(iFile.exists()) {
+ IPath location = iFile.getLocation();
+ if(location != null) {
+ return location.toFile();
+ }
+ }
+ // should never be used
+ Activator.log.warn("should not get the file using this method");
+ return ResourcesPlugin.getWorkspace().getRoot().getRawLocation().append(modifyExistingConfigurationText.getText()).toFile();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void performPostSerializationAction() {
+ // nothing here
+ }
+ }
+
+ /**
+ * Area for the "modify a plugin contribution" in the dialog
+ */
+ public class ModifyPluginConfigurationArea implements IConfigurationArea {
+
+ /** text area that display the id of the provider to modify */
+ protected Text modifyPluginConfigurationText;
+
+ /** button that opens dialog to select configuration to modify */
+ protected Button modifyPluginConfigurationSelectionButton;
+
+ /** Button used to modify an existing configuration */
+ protected Button modifyPluginConfigurationButton;
+
+ private File file;
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setEnable(boolean enable) {
+ if(isValid(modifyPluginConfigurationButton)) {
+ modifyPluginConfigurationButton.setSelection(enable);
+ modifyPluginConfigurationText.setEnabled(enable);
+ modifyPluginConfigurationSelectionButton.setEnabled(enable);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void validatePage() {
+ if(isValid(modifyPluginConfigurationText)) {
+ if(modifyPluginConfigurationText.getText() == null || modifyPluginConfigurationText.getText().equals(EMPTY_STRING)) {
+ setPageComplete(false);
+ setMessage(Messages.SelectConfigurationFileWizardPage_ErrorMessage_NoValidExistingConfiguration, ERROR);
+ } else {
+ setMessage(EMPTY_STRING, NONE);
+ setPageComplete(true);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Composite createContent(Composite parent) {
+ // modify an existing configuration composite
+ Composite modifyExistingConfigurationComposite = new Composite(parent, SWT.BORDER);
+ modifyExistingConfigurationComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+ modifyExistingConfigurationComposite.setLayout(new GridLayout(3, false));
+ modifyPluginConfigurationButton = new Button(modifyExistingConfigurationComposite, SWT.RADIO);
+ modifyPluginConfigurationButton.addSelectionListener(selectionListener);
+ radioButtonsMapping.put(modifyPluginConfigurationButton, this);
+ Label modifyExistingConfigurationLabel = new Label(modifyExistingConfigurationComposite, SWT.NONE);
+ modifyExistingConfigurationLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+ modifyExistingConfigurationLabel.setText("Modify plugin contribution");
+ modifyPluginConfigurationText = new Text(modifyExistingConfigurationComposite, SWT.BORDER | SWT.READ_ONLY);
+ modifyPluginConfigurationText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+ modifyPluginConfigurationSelectionButton = new Button(modifyExistingConfigurationComposite, SWT.NONE);
+ modifyPluginConfigurationSelectionButton.setText(Messages.SelectConfigurationFileWizardPage_ModifyExistingConfigurationSelectionButton_Label);
+ modifyPluginConfigurationSelectionButton.addSelectionListener(new SelectionListener() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetSelected(SelectionEvent e) {
+ // open a dialog which allows to select a contribution among all available contributions
+ List<XMLPropertyTabViewProvider> tabViewProviders = new ArrayList<XMLPropertyTabViewProvider>();
+ for(Object provider : PropertyViewService.getInstance().getPropertyViewProviders()) {
+ PropertyViewService.ProviderDescriptor descriptor = (PropertyViewService.ProviderDescriptor)provider;
+ if(descriptor.getProvider() instanceof XMLPropertyTabViewProvider) {
+ tabViewProviders.add((XMLPropertyTabViewProvider)descriptor.getProvider());
+ }
+ }
+
+ // open a dialog to choose among the provider
+ ProviderSelectionDialog dialog = new ProviderSelectionDialog(getShell(), tabViewProviders);
+ if(Dialog.OK == dialog.open()) {
+ // get the selection of the dialog
+ if(dialog.getFirstResult() != null) {
+ modifyPluginConfigurationText.setText(((XMLPropertyTabViewProvider)dialog.getFirstResult()).getId());
+ }
+
+ }
+
+ validatePage();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // nothing to do here
+ }
+ });
+ return modifyExistingConfigurationComposite;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Document generateInitialContent() {
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ DocumentBuilder documentBuilder;
+ try {
+ documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ // try to find the file for the given provider...
+ XMLPropertyTabViewProvider provider = retrieveProvider();
+ if(provider != null) {
+ Document document = documentBuilder.parse(provider.getConfigurationContent());
+ return document;
+ } else {
+ Activator.log.error("provider niot found. Impossible to edit", null);
+ }
+ } catch (ParserConfigurationException e) {
+ Activator.log.error(e);
+ } catch (SAXException e) {
+ Activator.log.error(e);
+ } catch (IOException e) {
+ Activator.log.error(e);
+ }
+ return null;
+ }
+
+ /**
+ * @return
+ */
+ protected XMLPropertyTabViewProvider retrieveProvider() {
+ for(ProviderDescriptor descriptor : PropertyViewService.getInstance().getPropertyViewProviders()) {
+ IProvider provider = descriptor.getProvider();
+ if(provider instanceof XMLPropertyTabViewProvider) {
+ // check this is the one we are looking for.
+ String id = ((XMLPropertyTabViewProvider)provider).getId();
+ if(id.equals(modifyPluginConfigurationText.getText())) {
+ return ((XMLPropertyTabViewProvider)provider);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Retrieves the descriptor of the provider to remove
+ *
+ * @return the descriptor of the provider to remove
+ */
+ protected ProviderDescriptor retrieveProviderDescriptor() {
+ for(ProviderDescriptor descriptor : PropertyViewService.getInstance().getPropertyViewProviders()) {
+ IProvider provider = descriptor.getProvider();
+ if(provider instanceof XMLPropertyTabViewProvider) {
+ // check this is the one we are looking for.
+ String id = ((XMLPropertyTabViewProvider)provider).getId();
+ if(id.equals(modifyPluginConfigurationText.getText())) {
+ return descriptor;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public File getNewFile() {
+ // retrieves the file in the metadata place
+ XMLPropertyTabViewProvider provider = retrieveProvider();
+ if(provider == null) {
+ return null;
+ }
+ // look if the file was already compute. If not, compute it now
+ if(file == null) {
+ file = provider.getLocalXmlfile(provider.getId() + "_" + System.currentTimeMillis() + ".xml");
+ }
+ return file;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void performPostSerializationAction() {
+ // retrieve provider and updates the preferences to point to the new place
+ XMLPropertyTabViewProvider provider = retrieveProvider();
+ if(provider == null) {
+ Activator.log.error("Impossible to find the provider to customize...", null);
+ return;
+ }
+
+ // updates the provider
+ provider.setConfigurationFile(getNewFile());
+
+ // no need to force update, the properties provider listens for preferences changes
+ // PropertyViewService.getInstance().resetTabViewProvider(retrieveProviderDescriptor());
+ }
+ }
+
+ /**
+ * Returns the new file, where the content of the configuration will be serialized
+ *
+ * @return the new file, where the content of the configuration will be serialized
+ */
+ public File getNewFile() {
+ return file;
+ }
+
+ /**
+ * selection dialog for tab view provider
+ */
+ public class ProviderSelectionDialog extends FilteredItemsSelectionDialog {
+
+ /** list of providers in which the edited provider will be selected */
+ private final List<XMLPropertyTabViewProvider> providers;
+
+ /** label provider for the list viewer */
+ private ProviderLabelProvider providerLabelProvider;
+
+ /** label provider for the details area */
+ private ProviderDetailsLabelProvider providerDetailsLabelProvider;
+
+ /**
+ * Creates a new ProviderSelectionDialog.
+ *
+ * @param shell
+ * the shell where to create the dialog
+ */
+ public ProviderSelectionDialog(Shell shell, List<XMLPropertyTabViewProvider> providers) {
+ super(shell, false);
+ this.providers = providers;
+ providerLabelProvider = new ProviderLabelProvider();
+ providerDetailsLabelProvider = new ProviderDetailsLabelProvider();
+ setListLabelProvider(providerLabelProvider);
+ setDetailsLabelProvider(providerDetailsLabelProvider);
+ setInitialPattern("**");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected IStatus validateItem(Object item) {
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Comparator<XMLPropertyTabViewProvider> getItemsComparator() {
+ return new Comparator<XMLPropertyTabViewProvider>() {
+
+ public int compare(XMLPropertyTabViewProvider o1, XMLPropertyTabViewProvider o2) {
+ return o1.getContributionName().compareTo(o2.getContributionName());
+ }
+
+ };
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getElementName(Object item) {
+ return providerLabelProvider.getText(item);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected IDialogSettings getDialogSettings() {
+ return Activator.getDefault().getDialogSettings();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void fillContentProvider(AbstractContentProvider contentProvider, ItemsFilter itemsFilter, IProgressMonitor progressMonitor) throws CoreException {
+ if(progressMonitor != null) {
+ progressMonitor.beginTask("Displaying Providers elements", providers.size());
+ }
+ for(XMLPropertyTabViewProvider provider : providers) {
+ contentProvider.add(provider, itemsFilter);
+ progressMonitor.worked(1);
+ }
+ if(progressMonitor != null)
+ progressMonitor.done();
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ItemsFilter createFilter() {
+ return new ItemsFilter() {
+
+ @Override
+ public boolean matchItem(Object item) {
+ if(!(item instanceof XMLPropertyTabViewProvider)) {
+ return false;
+ }
+ return matches(providerLabelProvider.getText((XMLPropertyTabViewProvider)item));
+ }
+
+ @Override
+ public boolean isConsistentItem(Object item) {
+ if(item instanceof XMLPropertyTabViewProvider) {
+ return true;
+ }
+ return false;
+ }
+
+ };
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Control createExtendedContentArea(Composite parent) {
+ return null;
+ }
+
+ /**
+ * label provider for the list viewer
+ */
+ protected class ProviderLabelProvider extends LabelProvider {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getText(Object element) {
+ if(element instanceof XMLPropertyTabViewProvider) {
+ return ((XMLPropertyTabViewProvider)element).getContributionName();
+ }
+ return super.getText(element);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Image getImage(Object element) {
+ if(element instanceof XMLPropertyTabViewProvider) {
+ return Activator.getImage("/icons/plugin_desc.gif");
+ }
+ return super.getImage(element);
+ }
+ }
+
+ /**
+ * label provider for the list viewer
+ */
+ protected class ProviderDetailsLabelProvider extends ProviderLabelProvider {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getText(Object element) {
+ if(element instanceof XMLPropertyTabViewProvider) {
+ return ((XMLPropertyTabViewProvider)element).getContributionName() + " - " + ((XMLPropertyTabViewProvider)element).getId();
+ }
+ return super.getText(element);
+ }
+ }
+ }
+
+ /**
+ * Perform actions after file serialization. Hook added to be able to modify preferences when modifying an in-place file
+ */
+ public void performPostSerializationAction() {
+ getEnableConfigurationArea().performPostSerializationAction();
+
+ };
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/AbstractMenuCreator.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/AbstractMenuCreator.java
new file mode 100644
index 00000000000..9c4da439eb7
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/AbstractMenuCreator.java
@@ -0,0 +1,92 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog.actions;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+/**
+ * Abstract class for all menu creators for customization dialog
+ */
+public abstract class AbstractMenuCreator implements IMenuCreator {
+
+ /** identifier for the add group in the menu */
+ public static final String ADD_GROUP = "addGroup";
+
+ /** current selected section set descriptor state */
+ private final SectionSetDescriptorState sectionSetDescriptorState;
+
+
+ /**
+ * Returns the sectionSetDescriptorState
+ *
+ * @return the sectionSetDescriptorState
+ */
+ public SectionSetDescriptorState getSectionSetDescriptorState() {
+ return sectionSetDescriptorState;
+ }
+
+ /**
+ * Returns the currentMetaclass
+ *
+ * @return the currentMetaclass
+ */
+ public EClassifier getCurrentMetaclass() {
+ return currentMetaclass;
+ }
+
+ /**
+ * Returns the currentStereotype
+ *
+ * @return the currentStereotype
+ */
+ public Stereotype getCurrentStereotype() {
+ return currentStereotype;
+ }
+
+ /** current selected metaclass */
+ private final EClassifier currentMetaclass;
+
+ /** current selected stereotype */
+ private final Stereotype currentStereotype;
+
+
+ /**
+ * Creates a new AbstractMenuCreator.
+ * Note: Either {@link #currentMetaclass} either {@link #currentStereotype} should not be null
+ *
+ * @param sectionSetDescriptorState
+ * the current selected section set descriptor state
+ * @param currentMetaclass
+ * the current selected metaclass. Can be <code>null</code>
+ * @param currentStereotype
+ * the current selected Stereotype. Can be <code>null</code>
+ *
+ */
+ public AbstractMenuCreator(SectionSetDescriptorState sectionSetDescriptorState, EClassifier currentMetaclass, Stereotype currentStereotype) {
+ this.sectionSetDescriptorState = sectionSetDescriptorState;
+ this.currentMetaclass = currentMetaclass;
+ this.currentStereotype = currentStereotype;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Menu getMenu(Menu parent) {
+ return null;
+ }
+
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ContainerMenuCreator.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ContainerMenuCreator.java
new file mode 100644
index 00000000000..c55abaacf8f
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ContainerMenuCreator.java
@@ -0,0 +1,235 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog.actions;
+
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.papyrus.properties.runtime.controller.PropertyEditorControllerService;
+import org.eclipse.papyrus.properties.runtime.controller.descriptor.ControllerDescriptorState;
+import org.eclipse.papyrus.properties.runtime.controller.predefined.PredefinedControllerDescriptor;
+import org.eclipse.papyrus.properties.runtime.controller.predefined.PredefinedControllerState;
+import org.eclipse.papyrus.properties.runtime.view.FragmentDescriptorState;
+import org.eclipse.papyrus.properties.runtime.view.constraints.AppliedStereotypeConstraintDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.constraints.ConstraintDescriptorState;
+import org.eclipse.papyrus.properties.runtime.view.constraints.IConstraintDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.constraints.ObjectTypeConstraintDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.content.ContainerDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.papyrus.properties.tabbed.customization.dialog.ContentHolder;
+import org.eclipse.papyrus.properties.tabbed.customization.state.ConstraintStateUtils;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+/**
+ * Menu creator for {@link ContainerDescriptorState}
+ */
+public class ContainerMenuCreator extends AbstractMenuCreator {
+
+ /** element on which the menu should be created */
+ private final ContainerDescriptorState containerDescriptorState;
+
+ /** menu manager used to create elements */
+ private MenuManager manager;
+
+ /**
+ * Creates a new ContainerMenuCreator.
+ *
+ * @param containerDescriptorState
+ * the state on which this menu is created
+ */
+ public ContainerMenuCreator(ContainerDescriptorState containerDescriptorState, SectionSetDescriptorState sectionSetDescriptorState, EClassifier currentMetaclass, Stereotype currentStereotype) {
+ super(sectionSetDescriptorState, currentMetaclass, currentStereotype);
+ this.containerDescriptorState = containerDescriptorState;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Menu getMenu(final Control parent) {
+ if(manager == null) {
+ manager = new MenuManager();
+ }
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ manager.removeAll();
+ menu = manager.createContextMenu(parent);
+ IAction removeAction = new Action("Remove Container", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/delete.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // remove this section descriptor state from its parent
+ if(parent instanceof Tree) {
+ TreeItem[] selectedItems = ((Tree)parent).getSelection();
+ if(selectedItems.length < 1) {
+ Activator.log.warn("Impossible to find the current selection in the tree");
+ return;
+ }
+ TreeItem selectedItem = selectedItems[0];
+ TreeItem parentItem = selectedItem.getParentItem();
+ // parent item should be the section descriptor set
+ if(parentItem == null) {
+ Activator.log.warn("Impossible to find the parent for current selection in the tree ");
+ return;
+ }
+ Object parent = parentItem.getData();
+ // test the parent is a FragmentDescriptorState
+ if((parent instanceof FragmentDescriptorState)) {
+ ((FragmentDescriptorState)parent).removeContainerDescriptorState(containerDescriptorState);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isEnabled() {
+ ContainerDescriptorState state = getSelectedContainerDescriptorState(parent);
+ if(state == null || state.isReadOnly()) {
+ setEnabled(false);
+ }
+ return super.isEnabled();
+ }
+
+ };
+ manager.add(removeAction);
+ manager.add(new Separator(ADD_GROUP));
+
+ ContainerDescriptorState state = getSelectedContainerDescriptorState(parent);
+ if(state == null || state.isReadOnly()) {
+ return menu;
+ }
+
+ Class<?> selectionClass = null;
+ List<String> appliedStereotypes = null;
+ if(parent instanceof Tree) {
+ Tree tree = (Tree)parent;
+ TreeItem[] items = tree.getSelection();
+ if(items.length < 1) {
+ Activator.log.warn("impossible to find an element in the selection");
+ return menu;
+ }
+ TreeItem root = retrieveRoot(items[0]);
+ if(root != null) {
+ Object rootElement = root.getData();
+ if(rootElement instanceof ContentHolder) {
+ List<ConstraintDescriptorState> constraintDescriptorStates = ((ContentHolder)rootElement).getSectionSetDescriptorState().getConstraintDescriptorStates();
+ for(ConstraintDescriptorState constraintDescriptorState : constraintDescriptorStates) {
+ IConstraintDescriptor descriptor = constraintDescriptorState.getDescriptor();
+ if(descriptor instanceof ObjectTypeConstraintDescriptor) { // check class compatibility. Should also check the other constraints...
+ selectionClass = ((ObjectTypeConstraintDescriptor)descriptor).getElementClass();
+ } else if(descriptor instanceof AppliedStereotypeConstraintDescriptor) {
+ appliedStereotypes = ((AppliedStereotypeConstraintDescriptor)descriptor).getStereotypeQualifiedNames();
+ }
+ }
+ }
+ }
+ }
+
+ // action to add a predefined controller => must retrieve the list of predefined controllers for this element
+ // => find the correct predefined controllers ? They should meet the constraints
+ Map<String, PredefinedControllerDescriptor> predefinedDescriptors = PropertyEditorControllerService.getInstance().getAllPredefinedControllers();
+
+ for(final String predefinedId : predefinedDescriptors.keySet()) {
+ final PredefinedControllerDescriptor propertyEditorControllerDescriptor = predefinedDescriptors.get(predefinedId);
+ List<IConstraintDescriptor> constraints = propertyEditorControllerDescriptor.getConstraintDescriptors();
+
+ boolean isValid = ConstraintStateUtils.areCompatible(constraints, getSectionSetDescriptorState().getConstraintDescriptorStates());
+
+ if(isValid) {
+ // build the action to add the controller
+ IAction action = new Action("Add " + propertyEditorControllerDescriptor.getText() + " (" + propertyEditorControllerDescriptor.getPredefinedId() + ")", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/NewPredefinedController.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // add this section descriptor state from its parent
+ if(parent instanceof Tree) {
+ TreeItem[] selectedItems = ((Tree)parent).getSelection();
+ if(selectedItems.length < 1) {
+ Activator.log.warn("Impossible to find the current selection in the tree");
+ return;
+ }
+ ControllerDescriptorState state = new PredefinedControllerState(propertyEditorControllerDescriptor, false);
+ containerDescriptorState.addPropertyEditorControllerState(state);
+ }
+ }
+
+ };
+ manager.appendToGroup(ADD_GROUP, action);
+ }
+ }
+
+ return menu;
+ }
+
+ protected TreeItem retrieveRoot(TreeItem item) {
+ if(item.getParentItem() == null) {
+ return item;
+ }
+ return retrieveRoot(item.getParentItem());
+ }
+
+ /**
+ * Returns the current selected container
+ *
+ * @return the current selected container or null
+ */
+ protected ContainerDescriptorState getSelectedContainerDescriptorState(Object parent) {
+ if(parent instanceof Tree) {
+ TreeItem[] selectedItems = ((Tree)parent).getSelection();
+ if(selectedItems.length < 1) {
+ Activator.log.warn("Impossible to find the current selection in the tree");
+ return null;
+ }
+ TreeItem selectedItem = selectedItems[0];
+ Object data = selectedItem.getData();
+ if(data instanceof ContainerDescriptorState) {
+ return ((ContainerDescriptorState)data);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ if(manager != null) {
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ }
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ContentHolderMenuCreator.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ContentHolderMenuCreator.java
new file mode 100644
index 00000000000..d2bd69939c4
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ContentHolderMenuCreator.java
@@ -0,0 +1,286 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog.actions;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.papyrus.properties.runtime.dialogs.PropertyDialog;
+import org.eclipse.papyrus.properties.runtime.state.IState;
+import org.eclipse.papyrus.properties.runtime.view.DialogDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.IFragmentDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.PropertyViewService;
+import org.eclipse.papyrus.properties.runtime.view.constraints.ConstraintDescriptorState;
+import org.eclipse.papyrus.properties.runtime.view.constraints.IConstraintDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.DynamicSectionDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.PropertyServiceUtil;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.papyrus.properties.tabbed.customization.dialog.ContentHolder;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.views.properties.tabbed.ITabDescriptor;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+/**
+ * Menu Creator for {@link ContentHolder}
+ */
+public class ContentHolderMenuCreator extends AbstractMenuCreator {
+
+ /** element on which the menu should be created */
+ private final ContentHolder contentHolder;
+
+ /** menu manager used to create elements */
+ private MenuManager manager;
+
+ /**
+ * Creates a new ContentHolderMenuCreator.
+ *
+ * @param contentHolder
+ * the content Holder on which this menu is created
+ */
+ public ContentHolderMenuCreator(ContentHolder contentHolder, SectionSetDescriptorState sectionSetDescriptorState, EClassifier currentMetaclass, Stereotype currentStereotype) {
+ super(sectionSetDescriptorState, currentMetaclass, currentStereotype);
+ this.contentHolder = contentHolder;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Menu getMenu(Control parent) {
+ if(manager == null) {
+ manager = new MenuManager();
+ }
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ manager.removeAll();
+ menu = manager.createContextMenu(parent);
+
+ // Class<?> selectionClass = get;
+ // final List<ConstraintDescriptorState> constraintDescriptorStates = getConstraintDescriptorStates(parent);
+ // if(constraintDescriptorStates != null) {
+ // for(ConstraintDescriptorState constraintDescriptorState : constraintDescriptorStates) {
+ // IConstraintDescriptor descriptor = constraintDescriptorState.getDescriptor();
+ // if(descriptor instanceof ObjectTypeConstraintDescriptor) { // check only class compatibility. Should also check the other constraints...
+ // selectionClass = ((ObjectTypeConstraintDescriptor)descriptor).getElementClass();
+ // }
+ // }
+ // }
+ // final Class<?> finalSelectionClass = selectionClass;
+ // SectionSetDescriptorState currentSectionSetDescriptorState = getCurrentSectionSetDescriptorState(parent);
+ // if(currentSectionSetDescriptorState == null) {
+ // return menu;
+ // }
+
+ SectionSetDescriptorState currentSectionSetDescriptorState = getSectionSetDescriptorState();
+ if(currentSectionSetDescriptorState == null) {
+ return menu;
+ }
+
+ final int selectionSize = currentSectionSetDescriptorState.getSelectionSize();
+
+
+ IAction action = new Action("Add Section", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/NewSection.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // should add a section here, using a new Section and pop-up the dialog on the section to create
+ DynamicSectionDescriptor descriptor = new DynamicSectionDescriptor(getNewSectionId(getCurrentMetaclass(), getCurrentStereotype(), selectionSize), getDefaultTabId(), new ArrayList<IConstraintDescriptor>(), 1, DynamicSectionDescriptor.SEMANTIC_RESOLVER, new ArrayList<String>(), null, new ArrayList<IFragmentDescriptor>());
+ SectionDescriptorState sectionDescriptorState = new SectionDescriptorState(descriptor, false);
+ contentHolder.getSectionSetDescriptorState().addSectionDescriptorState(sectionDescriptorState);
+ }
+
+ };
+
+ manager.add(action);
+ return menu;
+ }
+
+ protected void openSectionConfigurationDialog(IState iState) {
+ // find editor descriptor...
+ DialogDescriptor descriptor = PropertyViewService.getInstance().getDialogDescriptor(iState.getEditionDialogId());
+ List<Object> objectsToEdit = new ArrayList<Object>();
+ objectsToEdit.add(iState);
+
+ if(descriptor != null) {
+ Shell parentShell = Display.getCurrent().getActiveShell();
+ PropertyDialog dialog = new PropertyDialog(parentShell, descriptor, objectsToEdit, new TabbedPropertySheetWidgetFactory());
+ dialog.open();
+ } else {
+ Activator.log.warn("impossible to find an editor for element: " + iState);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Menu getMenu(Menu parent) {
+ return null;
+ }
+
+ /**
+ * Returns the new Id for the section
+ *
+ * @param selectionSize
+ * size of the selection
+ * @param metaclass
+ * metaclass for the section
+ *
+ * @return the new Id for the section
+ */
+ protected String getNewSectionId(EClassifier classifier, Stereotype stereotype, int selectionSize) {
+ for(int i = 0; i < 1000; i++) { // no need to go to more than 1000, because 1000 is already a very big number of sections
+ boolean found = false; // indicates if the id has been found in already sections or not
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("section_");
+ if(selectionSize == 1) {
+ buffer.append("single");
+ } else if(selectionSize < 0) {
+ buffer.append("multi");
+ } else {
+ buffer.append(selectionSize);
+ }
+ buffer.append("_");
+
+ if(classifier != null && classifier.getInstanceClass().getSimpleName() != null) {
+ buffer.append(classifier.getInstanceClass().getSimpleName());
+ } else if(stereotype != null && stereotype.getQualifiedName() != null) {
+ buffer.append(stereotype.getQualifiedName());
+ } else {
+ buffer.append("NoName");
+ }
+ if(i > 0) {
+ buffer.append(i);
+ }
+ String name = buffer.toString();
+
+ Iterator<SectionDescriptorState> it = contentHolder.getSectionSetDescriptorState().getSectionDescriptorStates().iterator();
+ while(it.hasNext()) {
+ SectionDescriptorState sectionDescriptorState = it.next();
+ String id = sectionDescriptorState.getDescriptor().getId();
+ if(name.equalsIgnoreCase(id)) {
+ found = true;
+ }
+ }
+
+ if(!found) {
+ return name;
+ }
+ }
+ return "";
+ }
+
+ /**
+ * Returns the value of the default tab selected.
+ *
+ * @return the value of the default tab selected.
+ */
+ protected String getDefaultTabId() {
+ Iterator<List<ITabDescriptor>> list = PropertyServiceUtil.getTabDescriptors().iterator();
+ while(list.hasNext()) {
+ List<ITabDescriptor> descriptors = list.next();
+ Iterator<ITabDescriptor> it = descriptors.iterator();
+ while(it.hasNext()) {
+ return it.next().getId();
+ }
+ }
+ return "";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ if(manager != null) {
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ }
+ }
+
+ /**
+ * returns the current {@link SectionSetDescriptorState}
+ *
+ * @param parent
+ * the tree element
+ * @return the current section set descriptor state edited or <code>null</code>.
+ */
+ protected SectionSetDescriptorState getCurrentSectionSetDescriptorState(Object parent) {
+ if(parent instanceof Tree) {
+ Tree tree = (Tree)parent;
+ TreeItem[] items = tree.getSelection();
+ if(items.length < 1) {
+ Activator.log.warn("impossible to find an element in the selection");
+ return null;
+ }
+ TreeItem root = retrieveRoot(items[0]);
+ if(root != null) {
+ Object rootElement = root.getData();
+ if(rootElement instanceof ContentHolder) {
+ return ((ContentHolder)rootElement).getSectionSetDescriptorState();
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Retrieves the root item in the tree
+ *
+ * @param item
+ * the current item
+ * @return the root item in the tree
+ */
+ protected TreeItem retrieveRoot(TreeItem item) {
+ if(item.getParentItem() == null) {
+ return item;
+ }
+ return retrieveRoot(item.getParentItem());
+ }
+
+ /**
+ * Returns the list of constraint descriptor states for the current selected section set descriptor state
+ *
+ * @return the list of constraint descriptor states for the current selected section set descriptor state or an empty list
+ */
+ protected List<ConstraintDescriptorState> getConstraintDescriptorStates(Object parent) {
+ SectionSetDescriptorState state = getCurrentSectionSetDescriptorState(parent);
+
+ if(state != null) {
+ return state.getConstraintDescriptorStates();
+ }
+ return Collections.emptyList();
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ControllerMenuCreator.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ControllerMenuCreator.java
new file mode 100644
index 00000000000..3c3ceac2345
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ControllerMenuCreator.java
@@ -0,0 +1,146 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog.actions;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.papyrus.properties.runtime.controller.descriptor.ControllerDescriptorState;
+import org.eclipse.papyrus.properties.runtime.view.content.ContainerDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+/**
+ * Menu creator for {@link ControllerDescriptorState}
+ */
+public class ControllerMenuCreator extends AbstractMenuCreator {
+
+ /** element on which the menu should be created */
+ private final ControllerDescriptorState controllerDescriptorState;
+
+ /** menu manager used to create elements */
+ private MenuManager manager;
+
+ /**
+ * Creates a new ControllerMenuCreator.
+ *
+ * @param controllerDescriptorState
+ * the state on which this menu is created
+ */
+ public ControllerMenuCreator(ControllerDescriptorState controllerDescriptorState, SectionSetDescriptorState sectionSetDescriptorState, EClassifier currentMetaclass, Stereotype currentStereotype) {
+ super(sectionSetDescriptorState, currentMetaclass, currentStereotype);
+ this.controllerDescriptorState = controllerDescriptorState;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Menu getMenu(final Control parent) {
+ if(manager == null) {
+ manager = new MenuManager();
+ }
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ manager.removeAll();
+ menu = manager.createContextMenu(parent);
+ IAction removeAction = new Action("Remove Controller", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/delete.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // remove this section descriptor state from its parent
+ if(parent instanceof Tree) {
+ TreeItem[] selectedItems = ((Tree)parent).getSelection();
+ if(selectedItems.length < 1) {
+ Activator.log.warn("Impossible to find the current selection in the tree");
+ return;
+ }
+ TreeItem selectedItem = selectedItems[0];
+ TreeItem parentItem = selectedItem.getParentItem();
+ // parent item should be the section descriptor set
+ if(parentItem == null) {
+ Activator.log.warn("Impossible to find the parent for current selection in the tree ");
+ return;
+ }
+ Object parent = parentItem.getData();
+ // test the parent is a FragmentDescriptorState
+ if((parent instanceof ContainerDescriptorState)) {
+ ((ContainerDescriptorState)parent).removePropertyEditorControllerState(controllerDescriptorState);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isEnabled() {
+ if(getSelectedControllerState() == null || getSelectedControllerState().isReadOnly()) {
+ setEnabled(false);
+ }
+ return super.isEnabled();
+ }
+
+ /**
+ * Returns the selected controller state
+ *
+ * @return the selected controller state
+ */
+ protected ControllerDescriptorState getSelectedControllerState() {
+ if(parent instanceof Tree) {
+ TreeItem[] selectedItems = ((Tree)parent).getSelection();
+ if(selectedItems.length < 1) {
+ Activator.log.warn("Impossible to find the current selection in the tree");
+ return null;
+ }
+ TreeItem selectedItem = selectedItems[0];
+ Object data = selectedItem.getData();
+ if(data instanceof ControllerDescriptorState) {
+ return ((ControllerDescriptorState)data);
+ }
+ }
+ return null;
+ }
+ };
+ manager.add(removeAction);
+ manager.add(new Separator(ADD_GROUP));
+
+ return menu;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ if(manager != null) {
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ }
+ }
+
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/EClassifierMenuCreator.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/EClassifierMenuCreator.java
new file mode 100644
index 00000000000..5c72bff7215
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/EClassifierMenuCreator.java
@@ -0,0 +1,210 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ModelElementItem;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.papyrus.properties.runtime.view.constraints.IConstraintDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.constraints.ObjectTypeConstraintDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.DynamicSectionDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+/**
+ * Menu creator for section sets
+ */
+@SuppressWarnings("restriction")
+public class EClassifierMenuCreator extends AbstractMenuCreator {
+
+ /** element on which the menu should be created */
+ private final ModelElementItem item;
+
+ /** menu manager used to create elements */
+ private MenuManager manager;
+
+ /** list of available section set descriptors */
+ private final List<SectionSetDescriptorState> sectionSetDescriptorStates;
+
+ /** tree viewer that displays the element */
+ private TreeViewer treeViewer;
+
+ /**
+ * Creates a new EClassifierMenuCreator.
+ *
+ * @param object
+ * object on which the menu is created
+ */
+ public EClassifierMenuCreator(ModelElementItem item, List<SectionSetDescriptorState> sectionSetDescriptorStates, TreeViewer treeViewer, SectionSetDescriptorState sectionSetDescriptorState, EClassifier currentMetaclass, Stereotype currentStereotype) {
+ super(sectionSetDescriptorState, currentMetaclass, currentStereotype);
+ this.item = item;
+ this.sectionSetDescriptorStates = sectionSetDescriptorStates;
+ this.treeViewer = treeViewer;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ if(manager != null) {
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Menu getMenu(final Control parent) {
+ if(manager == null) {
+ manager = new MenuManager();
+ }
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ manager.removeAll();
+
+ // create a new SectionSetDescriptor state
+ menu = manager.createContextMenu(parent);
+
+ IAction createAction = new Action("Create Section Set for single selection", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/NewSectionSet.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // remove this section descriptor set state from its parent
+ // create the constraint for the kind of object
+ List<IConstraintDescriptor> constraints = new ArrayList<IConstraintDescriptor>();
+
+ EClassifier classifier = ((EClassifier)item.getEObject());
+ String qualifiedInstanceClassName = classifier.getInstanceClassName();
+ Class<?> metamodelClass;
+ try {
+ metamodelClass = Class.forName(qualifiedInstanceClassName);
+ ObjectTypeConstraintDescriptor constraintDescriptor = new ObjectTypeConstraintDescriptor(metamodelClass);
+ constraints.add(constraintDescriptor);
+ SectionSetDescriptor descriptor = new SectionSetDescriptor(getNewSectionSetName(1), new ArrayList<DynamicSectionDescriptor>(), constraints, 1);
+ SectionSetDescriptorState state = descriptor.createState(false);
+ sectionSetDescriptorStates.add(state);
+ treeViewer.refresh();
+ // try to select the new element
+ treeViewer.setSelection(new TreeSelection(new TreePath(new Object[]{ item, state })));
+ } catch (ClassNotFoundException e) {
+ Activator.log.error(e);
+ }
+
+ }
+ };
+ manager.add(new Separator(ADD_GROUP));
+ manager.appendToGroup(ADD_GROUP, createAction);
+
+ IAction createMultipleElementAction = new Action("Create Section Set for multiple selection", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/NewSectionSet.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // remove this section descriptor set state from its parent
+ // create the constraint for the kind of object
+ List<IConstraintDescriptor> constraints = new ArrayList<IConstraintDescriptor>();
+
+ EClassifier classifier = ((EClassifier)item.getEObject());
+ String qualifiedInstanceClassName = classifier.getInstanceClassName();
+ Class<?> metamodelClass;
+ try {
+ metamodelClass = Class.forName(qualifiedInstanceClassName);
+ ObjectTypeConstraintDescriptor constraintDescriptor = new ObjectTypeConstraintDescriptor(metamodelClass);
+ constraints.add(constraintDescriptor);
+ SectionSetDescriptor descriptor = new SectionSetDescriptor(getNewSectionSetName(-1), new ArrayList<DynamicSectionDescriptor>(), constraints, -1);
+ SectionSetDescriptorState state = descriptor.createState(false);
+ sectionSetDescriptorStates.add(state);
+ treeViewer.refresh();
+ // try to select the new element
+ treeViewer.setSelection(new TreeSelection(new TreePath(new Object[]{ item, state })));
+ } catch (ClassNotFoundException e) {
+ Activator.log.error(e);
+ }
+
+ }
+ };
+ manager.appendToGroup(ADD_GROUP, createMultipleElementAction);
+
+ return menu;
+ }
+
+ protected String getNewSectionSetName(int selectionSize) {
+ for(int i = 0; i < 100; i++) { // no need to go to more than 100, because 100 is already a very big number of fragments
+ boolean found = false; // indicates if the id has been found in already fragments or not
+
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("sectionSet_");
+ if(selectionSize == 1) {
+ buffer.append("single");
+ } else if(selectionSize < 0) {
+ buffer.append("multi");
+ } else {
+ buffer.append(selectionSize);
+ }
+ buffer.append("_");
+
+ Class<?> selectionClass = (item.getEObject() instanceof EClassifier) ? ((EClassifier)item.getEObject()).getInstanceClass() : null;
+
+ if(selectionClass != null && selectionClass.getSimpleName() != null) {
+ buffer.append(selectionClass.getSimpleName());
+ } else {
+ buffer.append("NoName");
+ }
+ if(i > 0) {
+ buffer.append(i);
+ }
+ String name = buffer.toString();
+
+ Iterator<SectionSetDescriptorState> it = sectionSetDescriptorStates.iterator();
+ while(it.hasNext()) {
+ SectionSetDescriptorState sectionSetDescriptorState = it.next();
+ String id = sectionSetDescriptorState.getDescriptor().getName();
+ if(name.equalsIgnoreCase(id)) {
+ found = true;
+ }
+ }
+
+ if(!found) {
+ return name;
+ }
+ }
+ return "";
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/FragmentMenuCreator.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/FragmentMenuCreator.java
new file mode 100644
index 00000000000..80f676ba1cc
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/FragmentMenuCreator.java
@@ -0,0 +1,215 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog.actions;
+
+import java.util.ArrayList;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.papyrus.properties.runtime.controller.descriptor.IPropertyEditorControllerDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.FragmentDescriptorState;
+import org.eclipse.papyrus.properties.runtime.view.content.ContainerDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.content.ContainerDescriptorState;
+import org.eclipse.papyrus.properties.runtime.view.content.ExpandableContainerDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.content.GridLayoutDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.content.GroupContainerDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+/**
+ * Menu creator for {@link FragmentDescriptorState}
+ */
+public class FragmentMenuCreator extends AbstractMenuCreator {
+
+ /** element on which the menu should be created */
+ private final FragmentDescriptorState fragmentDescriptorState;
+
+ /** menu manager used to create elements */
+ private MenuManager manager;
+
+ /**
+ * Creates a new FragmentMenuCreator.
+ *
+ * @param fragmentDescriptorState
+ * the state on which this menu is created
+ */
+ public FragmentMenuCreator(FragmentDescriptorState fragmentDescriptorState, SectionSetDescriptorState sectionSetDescriptorState, EClassifier currentMetaclass, Stereotype currentStereotype) {
+ super(sectionSetDescriptorState, currentMetaclass, currentStereotype);
+ this.fragmentDescriptorState = fragmentDescriptorState;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Menu getMenu(final Control parent) {
+ if(manager == null) {
+ manager = new MenuManager();
+ }
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ manager.removeAll();
+ menu = manager.createContextMenu(parent);
+ IAction removeAction = new Action("Remove Fragment", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/delete.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // remove this section descriptor state from its parent
+ if(parent instanceof Tree) {
+ TreeItem[] selectedItems = ((Tree)parent).getSelection();
+ if(selectedItems.length < 1) {
+ Activator.log.warn("Impossible to find the current selection in the tree");
+ return;
+ }
+ TreeItem selectedItem = selectedItems[0];
+ TreeItem parentItem = selectedItem.getParentItem();
+ // parent item should be the section descriptor set
+ if(parentItem == null) {
+ Activator.log.warn("Impossible to find the parent for current selection in the tree ");
+ return;
+ }
+
+ Object parent = parentItem.getData();
+ // test the parent is a SectionDescriptorState
+ if((parent instanceof SectionDescriptorState)) {
+ ((SectionDescriptorState)parent).removeFragmentDescriptorState(fragmentDescriptorState);
+ }
+ }
+ }
+
+ };
+ manager.add(removeAction);
+ manager.add(new Separator(ADD_GROUP));
+
+ IAction addSimpleContainerAction = new Action("Add Simple Container", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/NewSimpleContainer.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // adds a simple container to the current element
+ ContainerDescriptor containerDescriptor = new ContainerDescriptor(new GridLayoutDescriptor(), new ArrayList<IPropertyEditorControllerDescriptor>());
+ ContainerDescriptorState containerDescriptorState = containerDescriptor.createState(false);
+ fragmentDescriptorState.addContainerDescriptorState(containerDescriptorState);
+ // try to retrieve the selection
+ if(parent instanceof Tree) {
+ TreeItem[] parentItems = ((Tree)parent).getSelection();
+ if(parentItems.length < 1) {
+ return;
+ }
+ parentItems[0].setExpanded(true);
+ for(TreeItem child : parentItems[0].getItems()) {
+ if(containerDescriptorState.equals(child.getData())) {
+ ((Tree)parent).select(child);
+ return;
+ }
+ }
+ }
+ }
+
+ };
+ manager.appendToGroup(ADD_GROUP, addSimpleContainerAction);
+
+ IAction addExpandableContainerAction = new Action("Add Expandable Container", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/NewExpandableContainer.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // adds an expandable container to the current element
+ ExpandableContainerDescriptor containerDescriptor = new ExpandableContainerDescriptor(new GridLayoutDescriptor(), "Label", new ArrayList<IPropertyEditorControllerDescriptor>());
+ ContainerDescriptorState containerDescriptorState = containerDescriptor.createState(false);
+ fragmentDescriptorState.addContainerDescriptorState(containerDescriptorState);
+ // try to retrieve the selection
+ if(parent instanceof Tree) {
+ TreeItem[] parentItems = ((Tree)parent).getSelection();
+ if(parentItems.length < 1) {
+ return;
+ }
+
+ parentItems[0].setExpanded(true);
+ for(TreeItem child : parentItems[0].getItems()) {
+ if(containerDescriptorState.equals(child.getData())) {
+ ((Tree)parent).select(child);
+ return;
+ }
+ }
+ }
+ }
+
+ };
+ manager.appendToGroup(ADD_GROUP, addExpandableContainerAction);
+
+ IAction addGroupContainerAction = new Action("Add Group Container", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/NewGroupContainer.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // adds an expandable container to the current element
+ GroupContainerDescriptor containerDescriptor = new GroupContainerDescriptor(new GridLayoutDescriptor(), "Label", new ArrayList<IPropertyEditorControllerDescriptor>());
+ ContainerDescriptorState containerDescriptorState = containerDescriptor.createState(false);
+ fragmentDescriptorState.addContainerDescriptorState(containerDescriptorState);
+
+ // try to retrieve the selection
+ if(parent instanceof Tree) {
+ TreeItem[] parentItems = ((Tree)parent).getSelection();
+ if(parentItems.length < 1) {
+ return;
+ }
+ parentItems[0].setExpanded(true);
+ for(TreeItem child : parentItems[0].getItems()) {
+ if(containerDescriptorState.equals(child.getData())) {
+ ((Tree)parent).select(child);
+ return;
+ }
+ }
+ }
+ }
+ };
+ manager.appendToGroup(ADD_GROUP, addGroupContainerAction);
+
+
+ return menu;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ if(manager != null) {
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ }
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/PredefinedFragmentMenuCreator.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/PredefinedFragmentMenuCreator.java
new file mode 100644
index 00000000000..785a3ccb3f3
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/PredefinedFragmentMenuCreator.java
@@ -0,0 +1,146 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog.actions;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.papyrus.properties.runtime.view.PredefinedFragmentDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+/**
+ * Menu creator for {@link PredefinedFragmentDescriptorState}
+ */
+public class PredefinedFragmentMenuCreator extends AbstractMenuCreator {
+
+ /** element on which the menu should be created */
+ private final PredefinedFragmentDescriptorState predefinedFragmentDescriptorState;
+
+ /** menu manager used to create elements */
+ private MenuManager manager;
+
+ /**
+ * Creates a new ContainerMenuCreator.
+ *
+ * @param containerDescriptorState
+ * the state on which this menu is created
+ */
+ public PredefinedFragmentMenuCreator(PredefinedFragmentDescriptorState predefinedFragmentDescriptorState, SectionSetDescriptorState sectionSetDescriptorState, EClassifier currentMetaclass, Stereotype currentStereotype) {
+ super(sectionSetDescriptorState, currentMetaclass, currentStereotype);
+ this.predefinedFragmentDescriptorState = predefinedFragmentDescriptorState;
+ }
+
+ /**
+ * Returns the current selected container
+ *
+ * @return the current selected container or null
+ */
+ protected PredefinedFragmentDescriptorState getSelectedPredefinedFragmentDescriptorState(Object parent) {
+ if(parent instanceof Tree) {
+ TreeItem[] selectedItems = ((Tree)parent).getSelection();
+ if(selectedItems.length < 1) {
+ Activator.log.warn("Impossible to find the current selection in the tree");
+ return null;
+ }
+ TreeItem selectedItem = selectedItems[0];
+ Object data = selectedItem.getData();
+ if(data instanceof PredefinedFragmentDescriptorState) {
+ return ((PredefinedFragmentDescriptorState)data);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ if(manager != null) {
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Menu getMenu(final Control parent) {
+ if(manager == null) {
+ manager = new MenuManager();
+ }
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ manager.removeAll();
+ menu = manager.createContextMenu(parent);
+ IAction removeAction = new Action("Remove Fragment", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/delete.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // remove this section descriptor state from its parent
+ if(parent instanceof Tree) {
+ TreeItem[] selectedItems = ((Tree)parent).getSelection();
+ if(selectedItems.length < 1) {
+ Activator.log.warn("Impossible to find the current selection in the tree");
+ return;
+ }
+ TreeItem selectedItem = selectedItems[0];
+ TreeItem parentItem = selectedItem.getParentItem();
+ // parent item should be the section descriptor set
+ if(parentItem == null) {
+ Activator.log.warn("Impossible to find the parent for current selection in the tree ");
+ return;
+ }
+ Object parent = parentItem.getData();
+ // test the parent is a FragmentDescriptorState
+ if((parent instanceof SectionDescriptorState)) {
+ ((SectionDescriptorState)parent).removeFragmentDescriptorState(predefinedFragmentDescriptorState);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isEnabled() {
+ PredefinedFragmentDescriptorState state = getSelectedPredefinedFragmentDescriptorState(parent);
+ if(state == null || state.isReadOnly()) {
+ setEnabled(false);
+ }
+ return super.isEnabled();
+ }
+
+ };
+ manager.add(removeAction);
+
+ return menu;
+ }
+
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ReplacedSectionMenuCreator.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ReplacedSectionMenuCreator.java
new file mode 100644
index 00000000000..24985b50de0
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/ReplacedSectionMenuCreator.java
@@ -0,0 +1,114 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog.actions;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionDescriptorState.ReplacedSectionState;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+/**
+ * menu creator for {@link ReplacedSectionState}
+ */
+public class ReplacedSectionMenuCreator extends AbstractMenuCreator {
+
+ /** element on which the menu should be created */
+ private final ReplacedSectionState replacedSectionState;
+
+ /** menu manager used to create elements */
+ private MenuManager manager;
+
+ /**
+ * Creates a new ReplacedSectionMenuCreator.
+ *
+ * @param ReplacedSectionState
+ * the state on which this menu is created
+ */
+ public ReplacedSectionMenuCreator(ReplacedSectionState replacedSectionState, SectionSetDescriptorState sectionSetDescriptorState, EClassifier currentMetaclass, Stereotype currentStereotype) {
+ super(sectionSetDescriptorState, currentMetaclass, currentStereotype);
+ this.replacedSectionState = replacedSectionState;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Menu getMenu(final Control parent) {
+ if(manager == null) {
+ manager = new MenuManager();
+ }
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ manager.removeAll();
+ menu = manager.createContextMenu(parent);
+ IAction removeAction = new Action("Remove Replaced Section", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/delete.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // remove this section descriptor state from its parent
+ if(parent instanceof Tree) {
+ TreeItem[] selectedItems = ((Tree)parent).getSelection();
+ if(selectedItems.length < 1) {
+ Activator.log.warn("Impossible to find the current selection in the tree");
+ return;
+ }
+ TreeItem selectedItem = selectedItems[0];
+ TreeItem parentItem = selectedItem.getParentItem();
+ // parent item should be the section descriptor set
+ if(parentItem == null) {
+ Activator.log.warn("Impossible to find the parent for current selection in the tree ");
+ return;
+ }
+
+ Object parent = parentItem.getData();
+ // test the parent is a SectionDescriptorState
+ if((parent instanceof SectionDescriptorState)) {
+ ((SectionDescriptorState)parent).removeReplacedSectionState(replacedSectionState);
+ }
+ }
+ }
+
+ };
+ manager.add(removeAction);
+
+
+ return menu;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ if(manager != null) {
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ }
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/SectionMenuCreator.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/SectionMenuCreator.java
new file mode 100644
index 00000000000..3b24d98c833
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/SectionMenuCreator.java
@@ -0,0 +1,285 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.papyrus.properties.runtime.state.IFragmentDescriptorState;
+import org.eclipse.papyrus.properties.runtime.view.FragmentDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.FragmentDescriptorState;
+import org.eclipse.papyrus.properties.runtime.view.PredefinedFragmentDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.PredefinedFragmentDescriptorState;
+import org.eclipse.papyrus.properties.runtime.view.PropertyViewService;
+import org.eclipse.papyrus.properties.runtime.view.constraints.ConstraintDescriptorState;
+import org.eclipse.papyrus.properties.runtime.view.constraints.IConstraintDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.constraints.ObjectTypeConstraintDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.content.ContainerDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.papyrus.properties.tabbed.customization.dialog.ContentHolder;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+/**
+ * Menu creator for {@link SectionDescriptorState}
+ */
+public class SectionMenuCreator extends AbstractMenuCreator {
+
+ /** element on which the menu should be created */
+ private final SectionDescriptorState sectionDescriptorState;
+
+ /** menu manager used to create elements */
+ private MenuManager manager;
+
+ /**
+ * Creates a new SectionMenuCreator.
+ *
+ * @param sectionDescriptorState
+ * the state on which this menu is created
+ */
+ public SectionMenuCreator(SectionDescriptorState sectionDescriptorState, SectionSetDescriptorState sectionSetDescriptorState, EClassifier currentMetaclass, Stereotype currentStereotype) {
+ super(sectionSetDescriptorState, currentMetaclass, currentStereotype);
+ this.sectionDescriptorState = sectionDescriptorState;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ if(manager != null) {
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Menu getMenu(final Control parent) {
+ if(manager == null) {
+ manager = new MenuManager();
+ }
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ manager.removeAll();
+ menu = manager.createContextMenu(parent);
+ IAction removeAction = new Action("Remove Section", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/delete.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // remove this section descriptor state from its parent
+ if(parent instanceof Tree) {
+ TreeItem[] selectedItems = ((Tree)parent).getSelection();
+ if(selectedItems.length < 1) {
+ Activator.log.warn("Impossible to find the curret selection in the tree");
+ return;
+ }
+ TreeItem selectedItem = selectedItems[0];
+ TreeItem parentItem = selectedItem.getParentItem();
+ // parent item should be the sectionsetdescriptor set (content holder exactly)
+ if(parentItem == null) {
+ Activator.log.warn("Impossible to find the parent for current selection in the tree ");
+ return;
+ }
+
+ Object parent = parentItem.getData();
+ // test the parent is a content holder
+ if((parent instanceof ContentHolder)) {
+ SectionSetDescriptorState sectionSetDescriptorState = ((ContentHolder)parent).getSectionSetDescriptorState();
+ sectionSetDescriptorState.removeSectionDescriptorState(sectionDescriptorState);
+ }
+ }
+ }
+
+ };
+ manager.add(removeAction);
+ manager.add(new Separator(ADD_GROUP));
+
+ Class<?> selectionClass = null;
+ if(getCurrentMetaclass() != null) {
+ selectionClass = getCurrentMetaclass().getInstanceClass();
+ }
+ final Class<?> finalSelectionClass = selectionClass;
+ SectionSetDescriptorState currentSectionSetDescriptorState = getSectionSetDescriptorState();
+ if(currentSectionSetDescriptorState == null) {
+ return menu;
+ }
+ final List<ConstraintDescriptorState> constraintDescriptorStates = getSectionSetDescriptorState().getConstraintDescriptorStates();
+
+ final int selectionSize = currentSectionSetDescriptorState.getSelectionSize();
+
+ IAction addFragmentAction = new Action("Add New Fragment", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/NewFragment.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // adds a fragment to the current element
+ FragmentDescriptor fragmentDescriptor = new FragmentDescriptor(getNewFragmentId(getCurrentMetaclass(), getCurrentStereotype(), selectionSize), new ArrayList<IConstraintDescriptor>(), new ArrayList<ContainerDescriptor>(), getSectionSetDescriptorState().getSelectionSize());
+ FragmentDescriptorState fragmentDescriptorState = new FragmentDescriptorState(fragmentDescriptor, false);
+
+ // retrieve constraints from current section set
+ for(ConstraintDescriptorState state : constraintDescriptorStates) {
+ fragmentDescriptorState.addConstraintDescriptorState(state);
+ }
+ sectionDescriptorState.addFragmentDescriptorState(fragmentDescriptorState);
+ }
+
+ };
+ manager.appendToGroup(ADD_GROUP, addFragmentAction);
+ // adds a fragment to the current element
+
+ IAction addReplacedSectionAction = new Action("Add New replaced section", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/NewReplacedSection.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // adds a fragment to the current element
+ sectionDescriptorState.addReplacedSectionState(sectionDescriptorState.new ReplacedSectionState(""));
+ }
+
+ };
+ manager.appendToGroup(ADD_GROUP, addReplacedSectionAction);
+
+
+ Map<String, FragmentDescriptor> availableFragmentDescriptors = PropertyViewService.getInstance().getAllFragmentDescriptors();
+
+ for(final FragmentDescriptor descriptor : availableFragmentDescriptors.values()) {
+ // check constraints
+ for(IConstraintDescriptor constraintDescriptor : descriptor.getConstraintDescriptors()) {
+ if(constraintDescriptor instanceof ObjectTypeConstraintDescriptor) {
+ Class<?> elementClass = ((ObjectTypeConstraintDescriptor)constraintDescriptor).getElementClass();
+ // check element class is compatible
+ if(selectionClass != null && elementClass.isAssignableFrom(selectionClass)) {
+
+ IAction addPredefinedFragmentAction = new Action("Add Predefined " + descriptor.getText(), Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/NewFragment.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // add this fragment descriptor state from its parent
+ if(parent instanceof Tree) {
+ TreeItem[] selectedItems = ((Tree)parent).getSelection();
+ if(selectedItems.length < 1) {
+ Activator.log.warn("Impossible to find the current selection in the tree");
+ return;
+ }
+ PredefinedFragmentDescriptor predefinedFragmentDescriptor = new PredefinedFragmentDescriptor(descriptor.getId());
+ PredefinedFragmentDescriptorState state = new PredefinedFragmentDescriptorState(predefinedFragmentDescriptor, false);
+ sectionDescriptorState.addFragmentDescriptorState(state);
+ }
+ }
+
+ };
+ manager.appendToGroup(ADD_GROUP, addPredefinedFragmentAction);
+ }
+ }
+ }
+ }
+
+ return menu;
+ }
+
+ /**
+ * Retrieves the root item in the tree
+ *
+ * @param item
+ * the current item
+ * @return the root item in the tree
+ */
+ protected TreeItem retrieveRoot(TreeItem item) {
+ if(item.getParentItem() == null) {
+ return item;
+ }
+ return retrieveRoot(item.getParentItem());
+ }
+
+ /**
+ * Returns the new Id for the section
+ *
+ * @param selectionClass
+ * the selected class
+ * @param selectionSize
+ * size of the selection
+ *
+ * @return the new Id for the section
+ */
+ protected String getNewFragmentId(EClassifier selectionClass, Stereotype stereotype, int selectionSize) {
+ for(int i = 0; i < 100; i++) { // no need to go to more than 100, because 100 is already a very big number of fragments
+ boolean found = false; // indicates if the id has been found in already fragments or not
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("fragment_");
+ if(selectionSize == 1) {
+ buffer.append("single");
+ } else if(selectionSize < 0) {
+ buffer.append("multi");
+ } else {
+ buffer.append(selectionSize);
+ }
+ buffer.append("_");
+
+ if(selectionClass != null && selectionClass.getInstanceClass() != null) {
+ buffer.append(selectionClass.getInstanceClass().getSimpleName());
+ } else if(stereotype != null && stereotype.getName() != null) {
+ buffer.append(stereotype.getName());
+ } else {
+ buffer.append("NoName");
+ }
+ if(i > 0) {
+ buffer.append(i);
+ }
+ String name = buffer.toString();
+
+ Iterator<IFragmentDescriptorState> it = sectionDescriptorState.getFragmentDescriptorStates().iterator();
+ while(it.hasNext()) {
+ IFragmentDescriptorState fragmentDescriptorState = it.next();
+ String id = fragmentDescriptorState.getDescriptor().getId();
+ if(name.equalsIgnoreCase(id)) {
+ found = true;
+ }
+ }
+
+ if(!found) {
+ return name;
+ }
+ }
+ return "";
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/SectionSetMenuCreator.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/SectionSetMenuCreator.java
new file mode 100644
index 00000000000..f3b5e4d0679
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/SectionSetMenuCreator.java
@@ -0,0 +1,101 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog.actions;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+/**
+ * Menu creator for section sets
+ */
+public class SectionSetMenuCreator extends AbstractMenuCreator {
+
+ /** list of states */
+ private final List<SectionSetDescriptorState> sectionSetDescriptorStates;
+
+ /** menu manager used to create elements */
+ private MenuManager manager;
+
+ /** tree viewer displaying elements */
+ private TreeViewer metamodelViewer;
+
+ /**
+ * Creates a new SectionSetMenuCreator.
+ *
+ * @param sectionSetDescriptorState
+ * state on which the menu is created
+ */
+ public SectionSetMenuCreator(List<SectionSetDescriptorState> sectionSetDescriptorStates, TreeViewer metamodelViewer, SectionSetDescriptorState sectionSetDescriptorState, EClassifier currentMetaclass, Stereotype currentStereotype) {
+ super(sectionSetDescriptorState, currentMetaclass, currentStereotype);
+ this.sectionSetDescriptorStates = sectionSetDescriptorStates;
+ this.metamodelViewer = metamodelViewer;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ if(manager != null) {
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Menu getMenu(final Control parent) {
+ if(manager == null) {
+ manager = new MenuManager();
+ }
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ manager.removeAll();
+ menu = manager.createContextMenu(parent);
+ IAction removeAction = new Action("Remove Section Set", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/delete.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // remove this section descriptor set state from its parent
+ sectionSetDescriptorStates.remove(getSectionSetDescriptorState());
+ metamodelViewer.refresh();
+ }
+
+ };
+ manager.add(removeAction);
+ manager.add(new Separator(ADD_GROUP));
+
+ return menu;
+ }
+
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/StereotypeMenuCreator.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/StereotypeMenuCreator.java
new file mode 100644
index 00000000000..60d4fa22cd5
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/dialog/actions/StereotypeMenuCreator.java
@@ -0,0 +1,193 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.dialog.actions;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ModelElementItem;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.papyrus.properties.runtime.view.constraints.AppliedStereotypeConstraintDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.constraints.IConstraintDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.DynamicSectionDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+/**
+ * Menu creator for section sets
+ */
+@SuppressWarnings("restriction")
+public class StereotypeMenuCreator extends AbstractMenuCreator {
+
+ /** element on which the menu should be created */
+ private final ModelElementItem item;
+
+ /** menu manager used to create elements */
+ private MenuManager manager;
+
+ /** list of available section set descriptors */
+ private final List<SectionSetDescriptorState> sectionSetDescriptorStates;
+
+ /** tree viewer that displays the element */
+ private TreeViewer treeViewer;
+
+ /**
+ * Creates a new EClassifierMenuCreator.
+ *
+ * @param object
+ * object on which the menu is created
+ */
+ public StereotypeMenuCreator(ModelElementItem item, List<SectionSetDescriptorState> sectionSetDescriptorStates, TreeViewer treeViewer, SectionSetDescriptorState sectionSetDescriptorState, EClassifier currentMetaclass, Stereotype currentStereotype) {
+ super(sectionSetDescriptorState, currentMetaclass, currentStereotype);
+ this.item = item;
+ this.sectionSetDescriptorStates = sectionSetDescriptorStates;
+ this.treeViewer = treeViewer;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ if(manager != null) {
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Menu getMenu(final Control parent) {
+ if(manager == null) {
+ manager = new MenuManager();
+ }
+ Menu menu = manager.getMenu();
+ if(menu != null) {
+ menu.dispose();
+ menu = null;
+ }
+ manager.removeAll();
+
+ // create a new SectionSetDescriptor state
+ menu = manager.createContextMenu(parent);
+
+ IAction createAction = new Action("Create Section Set for single selection", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/NewSectionSet.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // remove this section descriptor set state from its parent
+ // create the constraint for the kind of object
+ List<IConstraintDescriptor> constraints = new ArrayList<IConstraintDescriptor>();
+
+ AppliedStereotypeConstraintDescriptor constraintDescriptor = new AppliedStereotypeConstraintDescriptor(Arrays.asList(getCurrentStereotype().getQualifiedName()));
+ constraints.add(constraintDescriptor);
+ SectionSetDescriptor descriptor = new SectionSetDescriptor(getNewSectionSetName(1), new ArrayList<DynamicSectionDescriptor>(), constraints, 1);
+ SectionSetDescriptorState state = descriptor.createState(false);
+ sectionSetDescriptorStates.add(state);
+ treeViewer.refresh();
+ // try to select the new element
+ treeViewer.setSelection(new TreeSelection(new TreePath(new Object[]{ item, state })));
+
+ }
+ };
+ manager.add(new Separator(ADD_GROUP));
+ manager.appendToGroup(ADD_GROUP, createAction);
+
+ IAction createMultipleElementAction = new Action("Create Section Set for multiple selection", Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/NewSectionSet.gif")) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ // remove this section descriptor set state from its parent
+ // create the constraint for the kind of object
+ List<IConstraintDescriptor> constraints = new ArrayList<IConstraintDescriptor>();
+
+ AppliedStereotypeConstraintDescriptor constraintDescriptor = new AppliedStereotypeConstraintDescriptor(Arrays.asList(getCurrentStereotype().getQualifiedName()));
+ constraints.add(constraintDescriptor);
+ SectionSetDescriptor descriptor = new SectionSetDescriptor(getNewSectionSetName(-1), new ArrayList<DynamicSectionDescriptor>(), constraints, -1);
+ SectionSetDescriptorState state = descriptor.createState(false);
+ sectionSetDescriptorStates.add(state);
+ treeViewer.refresh();
+ // try to select the new element
+ treeViewer.setSelection(new TreeSelection(new TreePath(new Object[]{ item, state })));
+
+ }
+ };
+ manager.appendToGroup(ADD_GROUP, createMultipleElementAction);
+
+ return menu;
+ }
+
+ protected String getNewSectionSetName(int selectionSize) {
+ for(int i = 0; i < 100; i++) { // no need to go to more than 100, because 100 is already a very big number of fragments
+ boolean found = false; // indicates if the id has been found in already fragments or not
+
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("sectionSet_");
+ if(selectionSize == 1) {
+ buffer.append("single");
+ } else if(selectionSize < 0) {
+ buffer.append("multi");
+ } else {
+ buffer.append(selectionSize);
+ }
+ buffer.append("_");
+
+ if(getCurrentStereotype() != null && getCurrentStereotype().getQualifiedName() != null) {
+ buffer.append(getCurrentStereotype().getQualifiedName());
+ } else {
+ buffer.append("NoName");
+ }
+ if(i > 0) {
+ buffer.append(i);
+ }
+ String name = buffer.toString();
+
+ Iterator<SectionSetDescriptorState> it = sectionSetDescriptorStates.iterator();
+ while(it.hasNext()) {
+ SectionSetDescriptorState sectionSetDescriptorState = it.next();
+ String id = sectionSetDescriptorState.getDescriptor().getName();
+ if(name.equalsIgnoreCase(id)) {
+ found = true;
+ }
+ }
+
+ if(!found) {
+ return name;
+ }
+ }
+ return "";
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/handler/CustomizePropertyViewCommandHandler.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/handler/CustomizePropertyViewCommandHandler.java
new file mode 100644
index 00000000000..ad69619b59a
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/handler/CustomizePropertyViewCommandHandler.java
@@ -0,0 +1,73 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.papyrus.core.utils.EditorUtils;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.papyrus.properties.tabbed.customization.dialog.CustomizePropertyViewWizard;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * Handler for the command of customization of the content of the properties view
+ */
+public class CustomizePropertyViewCommandHandler extends AbstractHandler {
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ Display current = Display.getCurrent();
+ if(current == null) {
+ current = Display.getDefault();
+ }
+ Shell shell = current.getActiveShell();
+ if(shell != null) {
+
+ CustomizePropertyViewWizard wizard = new CustomizePropertyViewWizard();
+ WizardDialog wd = new WizardDialog(shell, wizard) {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText("Customize Property View");
+ }
+ };
+ wd.create();
+ // wd.getShell().setSize(640, 600);
+ wd.open();
+ } else {
+ Activator.log.error("impossible to find a shell to open the message dialog", null);
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isEnabled() {
+ if(EditorUtils.getMultiDiagramEditor() == null) {
+ return false;
+ }
+ return super.isEnabled();
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/messages.properties b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/messages.properties
new file mode 100644
index 00000000000..2131bfaf188
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/messages.properties
@@ -0,0 +1,53 @@
+CustomizeContentWizardPage_ConfigurationArea_Label=Configuration:
+CustomizeContentWizardPage_ContentArea_Label=Content:
+CustomizeContentWizardPage_Error_NoActiveDiagram=Impossible to find the active diagram editor
+CustomizeContentWizardPage_Error_NoEditorForElement=impossible to find an editor for element:
+CustomizeContentWizardPage_Error_NoRootNode=no propertyTabView node was found for this document
+CustomizeContentWizardPage_Error_NoSelectionForMenuCreation=Impossible to find the selection to create the menu
+CustomizeContentWizardPage_Error_NoSelectionFound=Impossible to find the selection to create the menu
+CustomizeContentWizardPage_Error_OutOfBoundExceptionIndex=Wrong index for selection size
+CustomizeContentWizardPage_Error_SelectionStereotypeOrClassifier=selection should be either stereotype or EClassifier, not
+CustomizeContentWizardPage_Job_SavingConfiguration=Saving configuration file
+CustomizeContentWizardPage_Message=Customize property view Wizard
+CustomizeContentWizardPage_PreviewArea_Label=Preview:
+CustomizeContentWizardPage_PreviewArea_RefreshButtonTooltip=Refresh the content of the preview area
+CustomizeContentWizardPage_PreviewArea_SaveButtonTooltip=Saves the current configuration
+CustomizeContentWizardPage_PreviewArea_SelectionSizeLabel=Size:
+CustomizeContentWizardPage_Title=Customize Property View
+CustomizeContentWizardPage_Warning_NoStereotypeNeitherMetaclass=either selected metaclass or selected stereotype should not be null
+CustomizePropertyViewDialog_Title=Property views content customization
+CustomizeContentWizardPage_PreviewArea_AddTabButtonTooltip=Add a tab
+CustomizeContentWizardPage_PreviewArea_DeleteTabButtonTooltip=Remove selected tab(s)
+CustomizeContentWizardPage_PreviewArea_MoveUpTabButtonTooltip=Move the tab(s) up
+CustomizeContentWizardPage_PreviewArea_MoveDownTabButtonTooltip=Move the tab(s) down
+SelectConfigurationFileWizardPage_ErrorMessage_NoValidTextArea=the text area for the new name was disposed or null. A default name has been generated: {0}
+SelectConfigurationFileWizardPage_ErrorMessage_notValidName=Please enter a valid name for the configuration
+SelectConfigurationFileWizardPage_CreateAnEmptyConfig_Label=Create an empty configuration
+SelectConfigurationFileWizardPage_CreateAnEmptyConfigName_DefaultValue=newConfiguration
+SelectConfigurationFileWizardPage_CreateAnEmptyConfigName_Label=Name:
+SelectConfigurationFileWizardPage_CreateAnEmptyConfigName_Tooltip=Enter here the name of the new configuration
+SelectConfigurationFileWizardPage_CreateAnEmptyConfigPluginId_DefaultValue=org.eclipse.uml2.uml
+SelectConfigurationFileWizardPage_CreateAnEmptyConfigPluginId_Label=Plugin Id:
+SelectConfigurationFileWizardPage_CreateAnEmptyConfigPluginId_Tooltip=Enter here the plugin identifier required to load classes at runtime, for example: org.eclipse.uml2.uml
+SelectConfigurationFileWizardPage_CreateFromExistingConfigFile_Dialog_Message=Please select an existing property view configuration.
+SelectConfigurationFileWizardPage_CreateFromExistingConfigFile_Dialog_Title=Select the current configuration
+SelectConfigurationFileWizardPage_CreateFromExistingConfigFile_Label=File:
+SelectConfigurationFileWizardPage_CreateFromExistingConfigName_DefaultValue=newName
+SelectConfigurationFileWizardPage_CreateFromExistingConfigName_Label=Name:
+SelectConfigurationFileWizardPage_CreateFromExistingConfigName_Tooltip=Enter here the name of the new configuration
+SelectConfigurationFileWizardPage_CreateFromExistingConfiguration_Label=Create from an existing configuration
+SelectConfigurationFileWizardPage_CreateFromExistingConfigurationSelectionButton_Label=Select...
+SelectConfigurationFileWizardPage_CreateFromScratch_Label=Create from scratch
+SelectConfigurationFileWizardPage_DefaultConfigurationName=Config_{0}
+SelectConfigurationFileWizardPage_EmptyDocument_InitialComment=Defined using Papyrus Property View customization. Date: {0}
+SelectConfigurationFileWizardPage_Error_NoAreaForWidget=impossible to find the area for the widget
+SelectConfigurationFileWizardPage_ErrorMessage_NoValidExistingConfiguration=Please select an existing configuration
+SelectConfigurationFileWizardPage_ErrorMessage_NoValidPluginIdentifier=Please enter a valid plugin identifier for the configuration
+SelectConfigurationFileWizardPage_ModifyExistingConfig_Dialog_Message=Please select an existing property view configuration.
+SelectConfigurationFileWizardPage_ModifyExistingConfig_Dialog_Title=Select the current configuration
+SelectConfigurationFileWizardPage_ModifyExistingConfiguration_Label=Modify an existing configuration
+SelectConfigurationFileWizardPage_ModifyExistingConfigurationSelectionButton_Label=Select...
+SelectConfigurationFileWizardPage_PageName=Name of the page
+SelectConfigurationFileWizardPage_UserGroup_Label=User
+SelectConfigurationFileWizardPage_SourceGroup_Label=Developer
+SelectConfigurationFileWizardPage_Title=Select the configuration file to edit
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/BooleanStateBeanPropertyEditorController.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/BooleanStateBeanPropertyEditorController.java
new file mode 100644
index 00000000000..ae1dcd99302
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/BooleanStateBeanPropertyEditorController.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.state;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.papyrus.properties.runtime.Activator;
+import org.eclipse.papyrus.properties.runtime.propertyeditor.descriptor.IBoundedValuesPropertyEditorDescriptor;
+import org.eclipse.papyrus.properties.runtime.propertyeditor.descriptor.IPropertyEditorDescriptor;
+
+
+/**
+ * Controller for states for customization wizard with boolean values
+ */
+public class BooleanStateBeanPropertyEditorController extends StateBeanPropertyEditorController {
+
+ /** identifier for this controller */
+ public final static String ID = "booleanStateBeanPropertyEditorController";
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void setValueInModel(Object value) {
+ if(value instanceof String) {
+ super.setValueInModel(Boolean.parseBoolean((String)value));
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getValueToEdit() {
+ Object value = super.getValueToEdit();
+ if(value instanceof Boolean) {
+ return Boolean.toString((Boolean)value);
+ }
+ return value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected IStatus initPropertyEditor(IPropertyEditorDescriptor descriptor) {
+ List<String> values = new ArrayList<String>();
+ values.add("true");
+ values.add("false");
+ if(descriptor instanceof IBoundedValuesPropertyEditorDescriptor) {
+ ((IBoundedValuesPropertyEditorDescriptor)descriptor).setAvailableValues(values);
+ } else {
+ Activator.log.warn(descriptor + "could not be completed.");
+ }
+
+ return super.initPropertyEditor(descriptor);
+ }
+
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/ConstraintStateUtils.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/ConstraintStateUtils.java
new file mode 100644
index 00000000000..5a6177a56ae
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/ConstraintStateUtils.java
@@ -0,0 +1,168 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.state;
+
+import java.util.List;
+
+import org.eclipse.papyrus.properties.runtime.view.constraints.AppliedStereotypeConstraintDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.constraints.AppliedStereotypeConstraintDescriptor.AppliedStereotypeConstraintDescriptorState;
+import org.eclipse.papyrus.properties.runtime.view.constraints.ConstraintDescriptorState;
+import org.eclipse.papyrus.properties.runtime.view.constraints.IConstraintDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.constraints.ObjectTypeConstraintDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.constraints.ObjectTypeConstraintDescriptor.ObjectTypeConstraintDescriptorState;
+
+/**
+ * Utility class for constraint states
+ */
+public class ConstraintStateUtils {
+
+ /**
+ * checks if the 2 sets of constraints are compatible. constraints of specific categories are compared one to each other
+ *
+ * @param constraintsToTest
+ * set of constraints to test
+ * @param referenceConstraints
+ * the second set of constraints, against which constraints are tested
+ * @return <code>true</code> if the 2 sets of constraints
+ */
+ public static boolean areCompatible(List<IConstraintDescriptor> constraintsToTest, List<ConstraintDescriptorState> referenceConstraints) {
+
+ // check for each category of constraints
+ // 1. Object type constraints
+ // 2. stereotype constraints
+
+ boolean classCompatible = areClassCompatibles(retrieveObjectTypeConstraint(constraintsToTest), retrieveObjectTypeConstraintState(referenceConstraints));
+
+
+ boolean stereotypesCompatible = areStereotypesCompatibles(retrieveStereotypeConstraint(constraintsToTest), retrieveStereotypeConstraintState(referenceConstraints));
+
+ return classCompatible && stereotypesCompatible;
+ }
+
+ /**
+ * @param retrieveStereotypeConstraint
+ * @param retrieveStereotypeConstraintState
+ * @return
+ */
+ private static boolean areStereotypesCompatibles(AppliedStereotypeConstraintDescriptor retrieveStereotypeConstraint, AppliedStereotypeConstraintDescriptorState retrieveStereotypeConstraintState) {
+ if(retrieveStereotypeConstraint == null && retrieveStereotypeConstraintState == null) {
+ return true;
+ } else if(retrieveStereotypeConstraint == null) {
+ return true;
+ } else if(retrieveStereotypeConstraintState == null) {
+ return false;
+ }
+
+ String stereotypeName = (retrieveStereotypeConstraint.getStereotypeQualifiedNames().size() > 0) ? retrieveStereotypeConstraint.getStereotypeQualifiedNames().get(0) : null;
+ if(stereotypeName == null) {
+ return false;
+ }
+
+ String referenceStereotypeName = (retrieveStereotypeConstraintState.getStereotypesToApply().size() > 0) ? retrieveStereotypeConstraintState.getStereotypesToApply().get(0) : null;
+ if(referenceStereotypeName == null) {
+ return false;
+ }
+
+ return referenceStereotypeName.equalsIgnoreCase(stereotypeName);
+ }
+
+ /**
+ * @param referenceConstraints
+ * @return
+ */
+ private static AppliedStereotypeConstraintDescriptorState retrieveStereotypeConstraintState(List<ConstraintDescriptorState> referenceConstraints) {
+ for(ConstraintDescriptorState descriptor : referenceConstraints) {
+ if(descriptor instanceof AppliedStereotypeConstraintDescriptorState) {
+ return (AppliedStereotypeConstraintDescriptorState)descriptor;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Retrieves the first stereotype constraint in the
+ *
+ * @param constraintsToTest
+ * the list of constraints
+ * @return the found AppliedStereotypeConstraintDescriptor or <code>null</code>
+ */
+ private static AppliedStereotypeConstraintDescriptor retrieveStereotypeConstraint(List<IConstraintDescriptor> constraintsToTest) {
+ for(IConstraintDescriptor descriptor : constraintsToTest) {
+ if(descriptor instanceof AppliedStereotypeConstraintDescriptor) {
+ return (AppliedStereotypeConstraintDescriptor)descriptor;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Check if the constraint to test is compatible with the reference constraint
+ *
+ * @param constraintToTest
+ * the constraint to test
+ * @param referenceConstraint
+ * the constraint against which the first one is tested
+ * @return <code>true</code> if both constraints are valid.
+ */
+ private static boolean areClassCompatibles(Class<?> constraintClass, Class<?> referenceClass) {
+ if(constraintClass == null) {
+ return true;
+ }
+ if(referenceClass == null) {
+ return false; // should never happen, but it can be hard to determine the reference class constraint from the stereotypes application (missing information at this level)
+ }
+ return constraintClass.isAssignableFrom(referenceClass);
+ }
+
+ /**
+ * Returns the first Object Type constraints in the list of given constraints
+ *
+ * @param constraintsToTest
+ * the list of constraints
+ * @return the first Object Type constraints in the list of given constraints or null
+ */
+ private static Class<?> retrieveObjectTypeConstraintState(List<ConstraintDescriptorState> constraintsToTest) {
+ for(ConstraintDescriptorState state : constraintsToTest) {
+ if(state instanceof ObjectTypeConstraintDescriptorState) {
+ return ((ObjectTypeConstraintDescriptorState)state).getElementClassState();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the first Object Type constraints in the list of given constraints
+ *
+ * @param constraintsToTest
+ * the list of constraints
+ * @return the first Object Type constraints in the list of given constraints or null
+ */
+ private static Class<?> retrieveObjectTypeConstraint(List<IConstraintDescriptor> constraintsToTest) {
+ for(IConstraintDescriptor state : constraintsToTest) {
+ if(state instanceof ObjectTypeConstraintDescriptor) {
+ return ((ObjectTypeConstraintDescriptor)state).getElementClass();
+ }
+ }
+
+ // // no object constraint. retrieve class constraint working with applied stereotypes
+ // for(IConstraintDescriptor state : constraintsToTest) {
+ // if(state instanceof AppliedStereotypeConstraintDescriptor) {
+ // List<String> stereotypes = ((AppliedStereotypeConstraintDescriptor)state).getStereotypeQualifiedNames();
+ // // retrieve the stereotypes using their qualified name... should have access to applied profiles
+ //
+ // }
+ // }
+
+ return null;
+ }
+
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/IntegerStateBeanPropertyEditorController.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/IntegerStateBeanPropertyEditorController.java
new file mode 100644
index 00000000000..ee17f127893
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/IntegerStateBeanPropertyEditorController.java
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.state;
+
+
+
+/**
+ * Controller for states for customization wizard with boolean values
+ */
+public class IntegerStateBeanPropertyEditorController extends StateBeanPropertyEditorController {
+
+ /** identifier for this controller */
+ public final static String ID = "integerStateBeanPropertyEditorController";
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void setValueInModel(Object value) {
+ if(value instanceof String) {
+ super.setValueInModel(Integer.parseInt((String)value));
+ }
+ }
+
+
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/ReferenceStateBeanPropertyEditorController.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/ReferenceStateBeanPropertyEditorController.java
new file mode 100644
index 00000000000..83cb41632ac
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/ReferenceStateBeanPropertyEditorController.java
@@ -0,0 +1,285 @@
+package org.eclipse.papyrus.properties.tabbed.customization.state;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.papyrus.properties.runtime.controller.IBoundedValuesController;
+import org.eclipse.papyrus.properties.runtime.state.IState;
+import org.eclipse.papyrus.properties.tabbed.core.view.StatesStore;
+
+/**
+ * Controller for references between states
+ */
+public class ReferenceStateBeanPropertyEditorController extends StateBeanPropertyEditorController implements IBoundedValuesController {
+
+ /** identifier for this controller */
+ public final static String ID = "referenceStateBeanPropertyEditorController";
+
+ /** label provider for references */
+ protected ILabelProvider labelProvider = initLabelProvider();
+
+ /**
+ * Creates and return the label provider for this controller
+ * Retrieves appropriate text and image thanks to #{@link org.eclipse.papyrus.properties.tabbed.core.view.StatesStore}.
+ *
+ * #FIXME This part of the code is really ugly both for the getText and getImage. We should rework on references between States.
+ *
+ * @return the label provider for this controller
+ */
+ protected ILabelProvider initLabelProvider() {
+ final ILabelProvider provider = new LabelProvider() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getText(Object input) {
+ if(input instanceof String) {
+ String propertyName = getDescriptor().getPropertyName();
+ String stateName = ((IState)objectToEdit.get(0)).getClass().getSimpleName();
+
+ try {
+ Method[] methods = StatesStore.class.getDeclaredMethods();
+ String searchMethodName = "getText" + stateName + propertyName;
+ for(Method method : methods) {
+ if(searchMethodName.equalsIgnoreCase(method.getName())) {
+ method.setAccessible(true);
+ Object arguments[] = { (String)input };
+ String text = (String)method.invoke(null, arguments);
+ if(text != null) {
+ return text;
+ }
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return "";
+ } else {
+ return input.toString();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public org.eclipse.swt.graphics.Image getImage(Object input) {
+ if(input instanceof String) {
+ String propertyName = getDescriptor().getPropertyName();
+ String stateName = ((IState)objectToEdit.get(0)).getClass().getSimpleName();
+
+ try {
+ Method[] methods = StatesStore.class.getDeclaredMethods();
+ String searchMethodName = "getImage" + stateName + propertyName;
+ for(Method method : methods) {
+ if(searchMethodName.equalsIgnoreCase(method.getName())) {
+ method.setAccessible(true);
+ org.eclipse.swt.graphics.Image image = (org.eclipse.swt.graphics.Image)method.invoke(null);
+ if(image != null) {
+ return image;
+ }
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return null;
+ } else {
+ return null;
+ }
+ }
+
+ };
+ return provider;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ILabelProvider getEditorLabelProvider() {
+ return labelProvider;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getAvailableValues() {
+ List<String> values = new ArrayList<String>();
+ for(Object object : objectToEdit) {
+ if(object instanceof IState) {
+ IState state = (IState)object;
+ String propertyName = getDescriptor().getPropertyName();
+ try {
+ Method[] methods = state.getClass().getDeclaredMethods();
+ String searchMethodName = "getAvailable" + propertyName;
+ for(Method method : methods) {
+ if(searchMethodName.equalsIgnoreCase(method.getName())) {
+ method.setAccessible(true);
+ values.addAll((List<String>)method.invoke(state));
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return values;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object[] getCurrentValues() {
+ List<String> values = new ArrayList<String>();
+ for(Object object : objectToEdit) {
+ if(object instanceof IState) {
+ IState state = (IState)object;
+ String propertyName = getDescriptor().getPropertyName();
+ try {
+ Method[] methods = state.getClass().getDeclaredMethods();
+ String searchMethodName = "get" + propertyName;
+ for(Method method : methods) {
+ if(searchMethodName.equalsIgnoreCase(method.getName())) {
+ method.setAccessible(true);
+ values.add((String)method.invoke(state));
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return values.toArray();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<ViewerFilter> getViewerFilters() {
+ List<ViewerFilter> filters = new ArrayList<ViewerFilter>();
+ ViewerFilter typeFilter = new ViewerFilter() {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ // return containsValidElements(element,
+ // getFeatureToEdit().getEType().getInstanceClass());
+ return true;
+ }
+ };
+ filters.add(typeFilter);
+ return filters;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public IStructuredContentProvider getContentProvider() {
+
+ ITreeContentProvider contentProvider = new ITreeContentProvider() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void dispose() {
+ // Nothing todo
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object[] getElements(Object inputElement) {
+ if(inputElement instanceof List<?>) {
+ return ((List)inputElement).toArray();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object[] getChildren(Object parentElement) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getParent(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasChildren(Object element) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ };
+ return contentProvider;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ILabelProvider getBrowserLabelProvider() {
+ return labelProvider;
+ }
+
+
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/StateBeanPropertyEditorController.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/StateBeanPropertyEditorController.java
new file mode 100644
index 00000000000..0973a5264c4
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/StateBeanPropertyEditorController.java
@@ -0,0 +1,208 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.state;
+
+import java.beans.PropertyChangeEvent;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.papyrus.properties.runtime.controller.BeanPropertyEditorController;
+import org.eclipse.papyrus.properties.runtime.state.IState;
+import org.eclipse.papyrus.properties.tabbed.customization.Activator;
+import org.eclipse.swt.widgets.Composite;
+
+
+/**
+ * Controller for states for customization wizard
+ */
+public class StateBeanPropertyEditorController extends BeanPropertyEditorController {
+
+ /** identifier for this controller */
+ public final static String ID = "stateBeanPropertyEditorController";
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<? extends IState> getObjectsToEdit() {
+ return (List<? extends IState>)super.getObjectsToEdit();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getDefaultLabel() {
+ return getDescriptor().getPropertyName();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void setValueInModel(Object value) {
+ IState state = getObjectsToEdit().get(0);
+ String propertyName = getDescriptor().getPropertyName();
+ try {
+ Method[] methods = state.getClass().getDeclaredMethods();
+ String searchMethodName = "set" + propertyName;
+ for(Method method : methods) {
+ if(searchMethodName.equalsIgnoreCase(method.getName())) {
+ method.setAccessible(true);
+ method.invoke(state, value);
+ return;
+ }
+ }
+
+ Class<?> currentClass = state.getClass();
+ // retrieve method in super classes...
+ while(retrieveSuperClass(currentClass) != null) {
+ currentClass = retrieveSuperClass(currentClass);
+ methods = state.getClass().getDeclaredMethods();
+ searchMethodName = "set" + propertyName;
+ for(Method method : methods) {
+ if(searchMethodName.equalsIgnoreCase(method.getName())) {
+ method.setAccessible(true);
+ method.invoke(state, value);
+ return;
+ }
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ Activator.log.error(e);
+ } catch (SecurityException e) {
+ Activator.log.error(e);
+ } catch (IllegalAccessException e) {
+ Activator.log.error(e);
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Object getValueToEdit() {
+ IState state = getObjectsToEdit().get(0);
+ String propertyName = getDescriptor().getPropertyName();
+ try {
+ Method[] methods = state.getClass().getDeclaredMethods();
+ String searchMethodName = "get" + propertyName;
+ for(Method method : methods) {
+ if(searchMethodName.equalsIgnoreCase(method.getName())) {
+ method.setAccessible(true);
+ return method.invoke(state);
+ }
+ }
+ Class<?> currentClass = state.getClass();
+ // retrieve method in super classes...
+ while(retrieveSuperClass(currentClass) != null) {
+ currentClass = retrieveSuperClass(currentClass);
+ methods = currentClass.getDeclaredMethods();
+ searchMethodName = "get" + propertyName;
+ for(Method method : methods) {
+ if(searchMethodName.equalsIgnoreCase(method.getName())) {
+ method.setAccessible(true);
+ return method.invoke(state);
+ }
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ Activator.log.error(e);
+ } catch (SecurityException e) {
+ Activator.log.error(e);
+ } catch (IllegalAccessException e) {
+ Activator.log.error(e);
+ } catch (InvocationTargetException e) {
+ Activator.log.error(e);
+ }
+ return null;
+ }
+
+ protected Class<?> retrieveSuperClass(Class<?> class_) {
+ return class_.getSuperclass();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addListenersToModel() {
+ for(IState state : getObjectsToEdit()) {
+ state.addPropertyChangeListener(this);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void removeListenersFromModel() {
+ for(IState state : getObjectsToEdit()) {
+ state.removePropertyChangeListener(this);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ if(evt.getPropertyName().equals(getDescriptor().getPropertyName())) {
+ refreshDisplay();
+ }
+ }
+
+ public IUndoableOperation getMoveCurrentValuesOperation(List<Integer> indexes, int move) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean canMoveValues(List<Integer> indexes, int move) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public List<IUndoableOperation> getCreateValueOperations() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean canCreateValueOperations() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public IUndoableOperation getDeleteValueOperation(List<Integer> indexes) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean canDeleteValueOperation() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public IUndoableOperation getEditValueOperation(int index, Composite parent, Object value) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean canCreateEditOperation(int index, Composite parent, Object value) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/StatePropertyTabViewProviderParser.java b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/StatePropertyTabViewProviderParser.java
new file mode 100644
index 00000000000..ff65de98af6
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.properties.tabbed.customization/src/org/eclipse/papyrus/properties/tabbed/customization/state/StatePropertyTabViewProviderParser.java
@@ -0,0 +1,103 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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.properties.tabbed.customization.state;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeSet;
+
+import org.eclipse.papyrus.properties.runtime.view.DialogDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.FragmentDescriptor;
+import org.eclipse.papyrus.properties.runtime.view.XMLParseException;
+import org.eclipse.papyrus.properties.tabbed.core.view.PropertyTabViewProviderParser;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptor;
+import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
+import org.eclipse.papyrus.properties.tabbed.core.view.TabDescriptorState;
+import org.eclipse.ui.views.properties.tabbed.ITabDescriptor;
+import org.w3c.dom.Document;
+
+
+/**
+ * Parser that stores a list of state on configuration elements instead of contributing to property view
+ */
+public class StatePropertyTabViewProviderParser extends PropertyTabViewProviderParser {
+
+ /** states of section set descriptors in the xml file */
+ protected List<SectionSetDescriptorState> sectionSetDescriptorStates = new ArrayList<SectionSetDescriptorState>();
+
+ /** states of tab descriptors in the xml file */
+ protected TreeSet<TabDescriptorState> tabDescriptorStates = new TreeSet<TabDescriptorState>(new Comparator<TabDescriptorState>() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public int compare(TabDescriptorState o1, TabDescriptorState o2) {
+ if(o1.getAfterTab().compareTo((o2.getId())) == 0) {
+ return -1;
+ } else if(o1.getId().compareTo((o2.getId())) == 0) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+ });
+
+ /**
+ * Creates a new StatePropertyTabViewProviderParser.
+ *
+ * @param tabDescriptors
+ * list of already available tab descriptors
+ */
+ public StatePropertyTabViewProviderParser(List<ITabDescriptor> tabDescriptors) {
+ super(tabDescriptors);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void parseXMLfile(Document document, Map<String, FragmentDescriptor> predefinedFragments, Map<String, DialogDescriptor> predefinedDialogs) throws XMLParseException {
+ super.parseXMLfile(document, predefinedFragments, predefinedDialogs);
+
+ // from the list of created tab descriptors and section sets descriptors, creates the state
+ for(SectionSetDescriptor sectionSetDescriptor : getProvidedSectionSets()) {
+ SectionSetDescriptorState descriptorState = new SectionSetDescriptorState(sectionSetDescriptor, false);
+ sectionSetDescriptorStates.add(descriptorState);
+ }
+
+ for(ITabDescriptor tabDescriptor : getProvidedTabDescriptors()) {
+ TabDescriptorState descriptorState = new TabDescriptorState(tabDescriptor, false);
+ tabDescriptorStates.add(descriptorState);
+ }
+
+ }
+
+ /**
+ * Returns the sectionSetDescriptorStates
+ *
+ * @return the sectionSetDescriptorStates
+ */
+ public List<SectionSetDescriptorState> getSectionSetDescriptorStates() {
+ return sectionSetDescriptorStates;
+ }
+
+ /**
+ * Returns the sectionSetDescriptorStates
+ *
+ * @return the sectionSetDescriptorStates
+ */
+ public List<TabDescriptorState> getTabDescriptorStates() {
+ return new ArrayList<TabDescriptorState>(tabDescriptorStates);
+ }
+}

Back to the top