Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2011-11-02 09:40:00 +0000
committercletavernie2011-11-02 09:40:00 +0000
commit0ca380ef7ab0df5a1ee804158540e675d50482c5 (patch)
tree2e2ab22da0090cdcc4e8fe773b83a68df7ff3109 /plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences
parentb30ccd9faa91fb46165234860034f153122ea263 (diff)
downloadorg.eclipse.papyrus-0ca380ef7ab0df5a1ee804158540e675d50482c5.tar.gz
org.eclipse.papyrus-0ca380ef7ab0df5a1ee804158540e675d50482c5.tar.xz
org.eclipse.papyrus-0ca380ef7ab0df5a1ee804158540e675d50482c5.zip
362162: [Architecture - Refactoring] The plug-ins should be renamed to match their layer's qualified name
https://bugs.eclipse.org/bugs/show_bug.cgi?id=362162
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/.classpath7
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/.project28
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/META-INF/MANIFEST.MF23
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/about.html28
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/build.properties7
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/diag.gifbin0 -> 962 bytes
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/fill_color.gifbin0 -> 217 bytes
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/font_color.gifbin0 -> 143 bytes
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/line_color.gifbin0 -> 194 bytes
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/pref.gifbin0 -> 369 bytes
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/plugin.properties14
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/plugin.xml100
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/Activator.java107
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/Messages.java98
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/PapyrusPreferenceInitializer.java48
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/PapyrusPreferenceStore.java251
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/PapyrusScopedPreferenceStore.java859
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/initializer/AbstractViewInitializer.java136
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/initializer/LinkViewInitializer.java162
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/initializer/NodeViewInitializer.java65
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/ColorFieldEditor.java197
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/FontFieldEditor.java204
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/GradientFieldEditor.java283
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/dialogs/GradientTransparencySelectionDialog.java128
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/messages.properties35
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/messages/Messages.java17
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/messages/messages.properties1
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusElementPreferencePage.java78
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusLinkPreferencePage.java64
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusNodePreferencePage.java101
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusPreferencePage.java242
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/DiagramPreferencePage.java179
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/PapyrusAllDiagramsPreferencePage.java126
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusPathmapsPreferencePage.java73
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusPrintingPreferencePage.java73
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusRulersAndGridPreferencePage.java72
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusUML2PreferencePage.java53
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/VisiblePageSingleton.java75
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/AbstractGroup.java173
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/BackgroundColor.java105
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/ConnectionGroup.java178
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/DecorationGroup.java87
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/DimensionGroup.java79
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/FontGroup.java66
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/LabelGroup.java90
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/LinkColorGroup.java90
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/NodeColorGroup.java68
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/NodeCompartmentGroup.java136
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/OrderedCompartmentGroup.java135
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/OrderedLabelGroup.java110
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramBackgroundColor.java43
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramConnectionGroup.java44
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramDecorationGroup.java49
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramDimensionGroup.java48
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramFontGroup.java48
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramLinkColorGroup.java48
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramNodeColorGroup.java48
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/dialog/AbstractPreferenceKeyDialog.java220
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/dialog/ApplyValueOnPreferenceKeyDialog.java75
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/CLabelBooleanFieldEditor.java234
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorBackgroundColor.java48
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorConnectionGroup.java48
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorDecorationGroup.java48
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorDimensionGroup.java48
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorFontGroup.java48
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorLinkColorGroup.java48
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorNodeColorGroup.java48
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/utils/FontHelper.java92
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/utils/GradientPreferenceConverter.java207
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/utils/PreferenceConstantHelper.java387
71 files changed, 7137 insertions, 0 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/.classpath b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/.classpath
new file mode 100644
index 00000000000..2d1a4302f04
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/.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/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/.project b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/.project
new file mode 100644
index 00000000000..deb7f5cdffd
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.preferences</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/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..1dfafddf005
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Thu Sep 11 16:39:45 CEST 2008
+eclipse.preferences.version=1
+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/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..37a81ecc553
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.gmf.runtime.diagram.ui.properties,
+ org.eclipse.papyrus.log;bundle-version="0.9.0"
+Export-Package: org.eclipse.papyrus.preferences,
+ org.eclipse.papyrus.preferences.initializer,
+ org.eclipse.papyrus.preferences.jface.preference;x-internal:=true,
+ org.eclipse.papyrus.preferences.jface.preference.dialogs,
+ org.eclipse.papyrus.preferences.pages,
+ org.eclipse.papyrus.preferences.pages.internal;x-internal:=true,
+ org.eclipse.papyrus.preferences.ui,
+ org.eclipse.papyrus.preferences.ui.diagram,
+ org.eclipse.papyrus.preferences.ui.editor,
+ org.eclipse.papyrus.preferences.utils
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 0.9.0.qualifier
+Bundle-Name: %pluginName
+Bundle-Localization: plugin
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.preferences.Activator
+Bundle-SymbolicName: org.eclipse.papyrus.preferences;singleton:=true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/about.html b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/about.html
new file mode 100644
index 00000000000..209103075a7
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/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/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/build.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/build.properties
new file mode 100644
index 00000000000..56a49c81d0d
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/build.properties
@@ -0,0 +1,7 @@
+#
+#Mon Sep 12 09:30:03 CEST 2011
+bin.includes=META-INF/,.,plugin.properties,plugin.xml,about.html,icons/
+output..=bin/
+src.includes=META-INF/,.,plugin.properties,plugin.xml,about.html,icons/
+source..=src/
+bin..=bin/
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/diag.gif b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/diag.gif
new file mode 100644
index 00000000000..30ba00d73da
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/diag.gif
Binary files differ
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/fill_color.gif b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/fill_color.gif
new file mode 100644
index 00000000000..93d2da13552
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/fill_color.gif
Binary files differ
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/font_color.gif b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/font_color.gif
new file mode 100644
index 00000000000..291a7e32500
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/font_color.gif
Binary files differ
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/line_color.gif b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/line_color.gif
new file mode 100644
index 00000000000..9dfa28cb9e3
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/line_color.gif
Binary files differ
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/pref.gif b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/pref.gif
new file mode 100644
index 00000000000..906c0f5870a
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/icons/pref.gif
Binary files differ
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/plugin.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/plugin.properties
new file mode 100644
index 00000000000..b1e3391bd11
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/plugin.properties
@@ -0,0 +1,14 @@
+#############################################################################
+# Copyright (c) 2008 Atos Origin.
+#
+# 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:
+# Atos Origin - Initial API and implementation
+#
+#############################################################################/
+pluginName=Papyrus Preferences (Incubation)
+providerName=Eclipse Modeling Project \ No newline at end of file
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/plugin.xml
new file mode 100644
index 00000000000..e96c195d7da
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/plugin.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ class="org.eclipse.papyrus.preferences.pages.internal.PapyrusUML2PreferencePage"
+ id="org.eclipse.papyrus.preferences.generalcategory"
+ name="Papyrus">
+ </page>
+ <page
+ category="org.eclipse.papyrus.preferences.generalcategory"
+ class="org.eclipse.papyrus.preferences.pages.PapyrusAllDiagramsPreferencePage"
+ id="org.eclipse.papyrus.preferences.diagrams"
+ name="Diagrams">
+ </page>
+ <page
+ category="org.eclipse.papyrus.preferences.generalcategory"
+ class="org.eclipse.papyrus.preferences.pages.internal.PapyrusRulersAndGridPreferencePage"
+ id="org.eclipse.papyrus.preferences.rulersandgrid"
+ name="Rulers And Grid">
+ </page>
+ <page
+ category="org.eclipse.papyrus.preferences.generalcategory"
+ class="org.eclipse.papyrus.preferences.pages.internal.PapyrusPrintingPreferencePage"
+ id="org.eclipse.papyrus.preferences.printing"
+ name="Printing">
+ </page>
+ <page
+ category="org.eclipse.papyrus.preferences.generalcategory"
+ class="org.eclipse.papyrus.preferences.pages.internal.PapyrusPathmapsPreferencePage"
+ id="org.eclipse.papyrus.preferences.pathmaps"
+ name="Pathmaps">
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+ class="org.eclipse.papyrus.preferences.pages.internal.PapyrusUML2PreferencePage"
+ id="org.eclipse.papyrus.preferences.properties.generalcategory"
+ name="Papyrus">
+ <enabledWhen>
+ <adapt
+ type="org.eclipse.core.resources.IProject">
+ </adapt>
+ </enabledWhen>
+ </page>
+ <page
+ category="org.eclipse.papyrus.preferences.properties.generalcategory"
+ class="org.eclipse.papyrus.preferences.pages.internal.PapyrusDiagramsPreferencePage"
+ id="org.eclipse.papyrus.preferences.pages.internal.PapyrusAllDiagramsPreferencePage"
+ name="Diagrams">
+ <enabledWhen>
+ <adapt
+ type="org.eclipse.core.resources.IProject">
+ </adapt>
+ </enabledWhen>
+ </page>
+ <page
+ category="org.eclipse.papyrus.preferences.properties.generalcategory"
+ class="org.eclipse.papyrus.preferences.pages.internal.PapyrusRulersAndGridPreferencePage"
+ id="org.eclipse.papyrus.preferences.properties.rulersandgrid"
+ name="Rulers And Grid">
+ <enabledWhen>
+ <adapt
+ type="org.eclipse.core.resources.IProject">
+ </adapt>
+ </enabledWhen>
+ </page>
+ <page
+ category="org.eclipse.papyrus.preferences.properties.generalcategory"
+ class="org.eclipse.papyrus.preferences.pages.internal.PapyrusPrintingPreferencePage"
+ id="org.eclipse.papyrus.preferences.properties.printing"
+ name="Printing">
+ <enabledWhen>
+ <adapt
+ type="org.eclipse.core.resources.IProject">
+ </adapt>
+ </enabledWhen>
+ </page>
+ <page
+ category="org.eclipse.papyrus.preferences.properties.generalcategory"
+ class="org.eclipse.papyrus.preferences.pages.internal.PapyrusPathmapsPreferencePage"
+ id="org.eclipse.papyrus.preferences.properties.pathmaps"
+ name="Pathmaps">
+ <enabledWhen>
+ <adapt
+ type="org.eclipse.core.resources.IProject">
+ </adapt>
+ </enabledWhen>
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.papyrus.preferences.PapyrusPreferenceInitializer">
+ </initializer>
+ </extension>
+
+</plugin>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/Activator.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/Activator.java
new file mode 100644
index 00000000000..e12333d90cf
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/Activator.java
@@ -0,0 +1,107 @@
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences;
+
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+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
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.preferences"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /** Logging helper */
+ public static LogHelper log;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /**
+ * Storage for preferences.
+ */
+ protected IPreferenceStore papyrusPreferenceStore;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ // register the login helper
+ log = new LogHelper(plugin);
+ }
+
+ public IPreferenceStore getPreferenceStore() {
+ // Create the preference store lazily.
+ if(papyrusPreferenceStore == null) {
+ papyrusPreferenceStore = new PapyrusPreferenceStore(new InstanceScope(), getBundle().getSymbolicName());
+
+ }
+ return papyrusPreferenceStore;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ 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;
+ }
+
+ public static Image getPluginIconImage(String pluginId, String iconPath) {
+ String key = pluginId + iconPath;
+ ImageRegistry registry = getDefault().getImageRegistry();
+ Image image = registry.get(key);
+
+ if(image == null) {
+
+ ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, iconPath);
+
+ registry.put(key, desc);
+ image = registry.get(key);
+
+ }
+
+
+ return image;
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/Messages.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/Messages.java
new file mode 100644
index 00000000000..50699a0678a
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/Messages.java
@@ -0,0 +1,98 @@
+/****************************************************************************
+ * Copyright (c) 2009 Atos Origin.
+ *
+ * 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
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.preferences.messages"; //$NON-NLS-1$
+
+
+
+ public static String AbstractPapyrusElementPreferencePage_Colors;
+
+ public static String AbstractPapyrusElementPreferencePage_Font;
+
+ public static String AbstractPapyrusLinkPreferencePage_Above;
+
+ public static String AbstractPapyrusLinkPreferencePage_All;
+
+ public static String AbstractPapyrusLinkPreferencePage_AvoidObstructions;
+
+ public static String AbstractPapyrusLinkPreferencePage_Below;
+
+ public static String AbstractPapyrusLinkPreferencePage_Chamfered;
+
+ public static String AbstractPapyrusLinkPreferencePage_ClosestDistance;
+
+ public static String AbstractPapyrusLinkPreferencePage_Connection;
+
+ public static String AbstractPapyrusLinkPreferencePage_JUMPLINKS;
+
+ public static String AbstractPapyrusLinkPreferencePage_Less;
+
+ public static String AbstractPapyrusLinkPreferencePage_More;
+
+ public static String AbstractPapyrusLinkPreferencePage_None;
+
+ public static String AbstractPapyrusLinkPreferencePage_Normal;
+
+ public static String AbstractPapyrusLinkPreferencePage_Oblique;
+
+ public static String AbstractPapyrusLinkPreferencePage_Rectilinear;
+
+ public static String AbstractPapyrusLinkPreferencePage_ReverseJumpLinks;
+
+ public static String AbstractPapyrusLinkPreferencePage_Routing;
+
+ public static String AbstractPapyrusLinkPreferencePage_SemiCircle;
+
+ public static String AbstractPapyrusLinkPreferencePage_Smoothness;
+
+ public static String AbstractPapyrusLinkPreferencePage_Square;
+
+ public static String AbstractPapyrusLinkPreferencePage_Status;
+
+ public static String AbstractPapyrusLinkPreferencePage_Styles;
+
+ public static String AbstractPapyrusLinkPreferencePage_Tree;
+
+ public static String AbstractPapyrusLinkPreferencePage_Type;
+
+ public static String AbstractPapyrusNodePreferencePage_Activate;
+
+ public static String AbstractPapyrusNodePreferencePage_Gradient;
+
+ public static String GradientFieldEditor_Color;
+
+ public static String GradientFieldEditor_Horizontal;
+
+ public static String GradientFieldEditor_Style;
+
+ public static String GradientFieldEditor_Transparency;
+
+ public static String GradientFieldEditor_Vertical;
+
+ public static String DecorationGroup_Name;
+
+ public static String DimensionGroupName;
+
+
+
+ public static String NodeCompartmentGroup_Compartiments;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/PapyrusPreferenceInitializer.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/PapyrusPreferenceInitializer.java
new file mode 100644
index 00000000000..f8321f53f9b
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/PapyrusPreferenceInitializer.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.preferences.pages.PapyrusAllDiagramsPreferencePage;
+import org.eclipse.papyrus.preferences.pages.internal.PapyrusPrintingPreferencePage;
+import org.eclipse.papyrus.preferences.pages.internal.PapyrusRulersAndGridPreferencePage;
+import org.eclipse.papyrus.preferences.pages.internal.PapyrusUML2PreferencePage;
+
+/**
+ * This class is use to initialize the preference at the level Papyrus editor
+ *
+ */
+public class PapyrusPreferenceInitializer extends AbstractPreferenceInitializer {
+
+ private IPreferenceStore store;
+
+ /**
+ * constructor of this class
+ */
+ public PapyrusPreferenceInitializer() {
+ store = Activator.getDefault().getPreferenceStore();
+ }
+
+
+ @Override
+ public void initializeDefaultPreferences() {
+ PapyrusAllDiagramsPreferencePage.initDefaults(store);
+ PapyrusRulersAndGridPreferencePage.initDefaults(store);
+ PapyrusPrintingPreferencePage.initDefaults(store);
+ PapyrusUML2PreferencePage.initDefaults(store);
+
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/PapyrusPreferenceStore.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/PapyrusPreferenceStore.java
new file mode 100644
index 00000000000..c603ddc367f
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/PapyrusPreferenceStore.java
@@ -0,0 +1,251 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.papyrus.preferences.ui.dialog.ApplyValueOnPreferenceKeyDialog;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+
+/**
+ * this class is a specific store that is used to look for value of element
+ * by taking account the structure of preferences : papyrus editor-> Diagram -> Elements of Diagram
+ *
+ */
+public class PapyrusPreferenceStore extends PapyrusScopedPreferenceStore {
+
+ /**
+ * this method is used to overload all value under a level of preferences.
+ * In order to overload a pop-up is opened, and the user can choose value to overload
+ *
+ * @param level
+ * of preference: Editor or diagram
+ */
+
+ public void deleteAllSubPreference(String level) {
+ //remove all sub value diagram+ element
+ ArrayList<String> keytoRemove = new ArrayList<String>();
+ //key to collect
+ ArrayList<String> elementKey = new ArrayList<String>();
+ try {
+ for(int i = 0; i < getStorePreferences().keys().length; i++) {
+ //level diagram collect only element
+ if(level.startsWith(PreferenceConstantHelper.DIAGRAM_PREFERENCE_PREFIX)) {
+ if(getStorePreferences().keys()[i].startsWith(PreferenceConstantHelper.DIAGRAM_ELEMENT)) {
+ elementKey.add(getStorePreferences().keys()[i]);
+ }
+ }
+ //editor level, collect all element+diagram
+ else if(level.startsWith(PreferenceConstantHelper.PAPYRUS_EDITOR_PREFERENCE_PREFIX)) {
+ if((getStorePreferences().keys()[i].startsWith(PreferenceConstantHelper.DIAGRAM_ELEMENT)) || (getStorePreferences().keys()[i].startsWith(PreferenceConstantHelper.DIAGRAM_PREFERENCE_PREFIX))) {
+ elementKey.add(getStorePreferences().keys()[i]);
+ }
+ }
+
+ }
+
+ } catch (Exception e) {
+ Activator.log.error(e);
+ }
+ if(elementKey.size() > 0) {
+ String[] keyRoconsult = new String[elementKey.size()];
+ ApplyValueOnPreferenceKeyDialog dialog = new ApplyValueOnPreferenceKeyDialog(elementKey.toArray(keyRoconsult));
+ dialog.open();
+ keytoRemove = dialog.getKeyToRemove();
+
+ //remove key
+ Iterator<String> iterator = keytoRemove.iterator();
+ while(iterator.hasNext()) {
+ String key = (String)iterator.next();
+ getStorePreferences().remove(key);
+ }
+ }
+ }
+
+
+ /**
+ * constructor
+ *
+ * @param context
+ * the scope to store to
+ * @param qualifier
+ * the qualifier used to look up the preference node
+ */
+ public PapyrusPreferenceStore(IScopeContext context, String qualifier) {
+ super(context, qualifier);
+ }
+
+ /**
+ * constructor
+ *
+ * @param context
+ * the scope to store to
+ * @param qualifier
+ * the qualifier used to look up the preference node
+ * @param defaultQualifierPath
+ * the qualifier used when looking up the defaults
+ */
+ public PapyrusPreferenceStore(IScopeContext context, String qualifier, String defaultQualifierPath) {
+ super(context, qualifier, defaultQualifierPath);
+ }
+
+ // each get value will be overloaded
+ //if not value is found for an element, a value is look for in DIAGRAM
+ // if a the value is not find for Diagram a value is find for Papyrus editor
+
+
+ /**
+ * this method is used to find a key that a got a value:
+ * if the key is an element. The method look for if this key exist. If no value exists, it look for the key for diagram
+ * if the key for diagram do not exist it look for key for papyrus Editor
+ * the structure of Key is:
+ * element : ELEMENT_DiagramKind_ElementKind.preferenceKind
+ * Diagram : DIAGRAM_DiagramKind.preferenceKind
+ * Editor: PAPYRUS_EDITOR.preferenceKind
+ *
+ */
+ protected String findKeyWithAValue(String initialKey) {
+ String foundedKey = null;
+ //first look for in value stack
+ foundedKey = findKeyAStoreValue(initialKey);
+ //then look for in default stack
+ if(foundedKey == null) {
+ foundedKey = findKeyWithADefaultValue(initialKey);
+ }
+ if(foundedKey == null) {
+ foundedKey = initialKey;
+ }
+ return foundedKey;
+
+ }
+
+ /**
+ * look for a key with a value in the store stack
+ *
+ * @param initialKey
+ * element : ELEMENT_DiagramKind_ElementKind.preferenceKind
+ * Diagram : DIAGRAM_DiagramKind.preferenceKind
+ * Editor: PAPYRUS_EDITOR.preferenceKind
+ * @return the key that returns a value or null if there is no value
+ */
+ protected String findKeyAStoreValue(String initialKey) {
+ String foundedKey = null;
+ if(getStorePreferences().get(initialKey, null) != null) {
+ foundedKey = initialKey;
+ }
+
+ if(foundedKey == null && hasPrefix(initialKey)) {
+ foundedKey = findKeyAStoreValue(getUpperKey(initialKey));
+ }
+ return foundedKey;
+ }
+
+ /**
+ * this method is used to find a key that a got a value:
+ * if the key is an element. The method look for if this key exist. If no value exists, it look for the key for diagram
+ * if the key for diagram do not exist it look for key for papyrus Editor
+ * the structure of Key is:
+ * element : ELEMENT_DiagramKind_ElementKind.preferenceKind
+ * Diagram : DIAGRAM_DiagramKind.preferenceKind
+ * Editor: PAPYRUS_EDITOR.preferenceKind
+ *
+ */
+ protected String findKeyWithADefaultValue(String initialKey) {
+ String foundedKey = null;
+
+ if(getDefaultPreferences().get(initialKey, null) != null) {
+ foundedKey = initialKey;
+ }
+
+ if(foundedKey == null && hasPrefix(initialKey)) {
+ return findKeyWithADefaultValue(getUpperKey(initialKey));
+ } else {
+ foundedKey = initialKey;
+ }
+ return foundedKey;
+
+ }
+
+ /**
+ * get the upper Key from the initial Key
+ * * the structure of Key is:
+ * element : ELEMENT_DiagramKind_ElementKind.preferenceKind
+ * Diagram : DIAGRAM_DiagramKind.preferenceKind
+ * Editor: PAPYRUS_EDITOR.preferenceKind
+ *
+ * @param initialKey
+ * @return the upperKey
+ *
+ */
+ protected String getUpperKey(String initialKey) {
+
+ String out = initialKey.toString();
+ if(initialKey.startsWith(PreferenceConstantHelper.DIAGRAM_ELEMENT)) {
+ out = initialKey.toString().replaceAll(PreferenceConstantHelper.DIAGRAM_ELEMENT, PreferenceConstantHelper.DIAGRAM_PREFERENCE_PREFIX);
+ out = out.substring(0, out.lastIndexOf("_")) + out.substring(out.indexOf("."), out.length());
+ }
+ if(initialKey.startsWith(PreferenceConstantHelper.DIAGRAM_PREFERENCE_PREFIX)) {
+ // out=initialKey.toString().replaceAll(PreferenceConstantHelper.DIAGRAM_PREFERENCE_PREFIX, PreferenceConstantHelper.PAPYRUS_EDITOR_PREFERENCE_PREFIX);
+ out = PreferenceConstantHelper.PAPYRUS_EDITOR_PREFERENCE_PREFIX + out.substring(out.indexOf("."), out.length());
+ }
+ return out;
+ }
+
+ protected boolean hasPrefix(String key) {
+ if(key.startsWith(PreferenceConstantHelper.DIAGRAM_ELEMENT) || key.startsWith(PreferenceConstantHelper.DIAGRAM_PREFERENCE_PREFIX)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * get the value from a key
+ *
+ * @param key
+ * @return the value
+ */
+ protected String internalGet(String key) {
+ String newKey = findKeyWithAValue(key);
+ //System.err.println("-->Initial Key "+key+"--> "+ newKey);
+ return Platform.getPreferencesService().get(newKey, null, getPreferenceNodes(true));
+ }
+
+ public boolean getDefaultBoolean(String name) {
+
+ return super.getDefaultBoolean(findKeyWithADefaultValue(name));
+ }
+
+ public double getDefaultDouble(String name) {
+ return super.getDefaultDouble(findKeyWithADefaultValue(name));
+ }
+
+ public float getDefaultFloat(String name) {
+ return super.getDefaultFloat(findKeyWithADefaultValue(name));
+ };
+
+ public int getDefaultInt(String name) {
+ return super.getDefaultInt(findKeyWithADefaultValue(name));
+ }
+
+ public long getDefaultLong(String name) {
+ return super.getDefaultLong(findKeyWithADefaultValue(name));
+ }
+
+ public String getDefaultString(String name) {
+ return super.getDefaultString(findKeyWithADefaultValue(name));
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/PapyrusScopedPreferenceStore.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/PapyrusScopedPreferenceStore.java
new file mode 100644
index 00000000000..d77132dabe4
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/PapyrusScopedPreferenceStore.java
@@ -0,0 +1,859 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences;
+
+/***************************************************************************
+ 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:
+ * the code is copy from ScopedPreferenceStore but I have open some methods in order to be
+ * available for the overload
+ *
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *
+ *******************************************************************************/
+
+import java.io.IOException;
+
+import org.eclipse.core.commands.common.EventManager;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.jface.preference.IPersistentPreferenceStore;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.util.SafeRunnable;
+import org.eclipse.ui.internal.WorkbenchMessages;
+import org.osgi.service.prefs.BackingStoreException;
+
+/**
+ * The ScopedPreferenceStore is an IPreferenceStore that uses the scopes
+ * provided in org.eclipse.core.runtime.preferences.
+ * <p>
+ * A ScopedPreferenceStore does the lookup of a preference based on it's search scopes and sets the value of the preference based on its store scope.
+ * </p>
+ * <p>
+ * The default scope is always included in the search scopes when searching for preference values.
+ * </p>
+ *
+ * @see org.eclipse.core.runtime.preferences
+ * @since 3.1
+ */
+public class PapyrusScopedPreferenceStore extends EventManager implements IPreferenceStore, IPersistentPreferenceStore {
+
+ /**
+ * The storeContext is the context where values will stored with the
+ * setValue methods. If there are no searchContexts this will be the search
+ * context. (along with the "default" context)
+ */
+ protected IScopeContext storeContext;
+
+ /**
+ * The searchContext is the array of contexts that will be used by the get
+ * methods for searching for values.
+ */
+ protected IScopeContext[] searchContexts;
+
+ /**
+ * A boolean to indicate the property changes should not be propagated.
+ */
+ protected boolean silentRunning = false;
+
+ /**
+ * The listener on the IEclipsePreferences. This is used to forward updates
+ * to the property change listeners on the preference store.
+ */
+ protected IEclipsePreferences.IPreferenceChangeListener preferencesListener;
+
+ /**
+ * The default context is the context where getDefault and setDefault
+ * methods will search. This context is also used in the search.
+ */
+ protected IScopeContext defaultContext = new DefaultScope();
+
+ /**
+ * The nodeQualifer is the string used to look up the node in the contexts.
+ */
+ protected String nodeQualifier;
+
+ /**
+ * The defaultQualifier is the string used to look up the default node.
+ */
+ protected String defaultQualifier;
+
+ /**
+ * Boolean value indicating whether or not this store has changes to be
+ * saved.
+ */
+ private boolean dirty;
+
+ /**
+ * Create a new instance of the receiver. Store the values in context in the
+ * node looked up by qualifier. <strong>NOTE:</strong> Any instance of
+ * ScopedPreferenceStore should call
+ *
+ * @param context
+ * the scope to store to
+ * @param qualifier
+ * the qualifier used to look up the preference node
+ * @param defaultQualifierPath
+ * the qualifier used when looking up the defaults
+ */
+ public PapyrusScopedPreferenceStore(IScopeContext context, String qualifier, String defaultQualifierPath) {
+ this(context, qualifier);
+ this.defaultQualifier = defaultQualifierPath;
+ }
+
+ /**
+ * Create a new instance of the receiver. Store the values in context in the
+ * node looked up by qualifier.
+ *
+ * @param context
+ * the scope to store to
+ * @param qualifier
+ * the qualifer used to look up the preference node
+ */
+ public PapyrusScopedPreferenceStore(IScopeContext context, String qualifier) {
+ storeContext = context;
+ this.nodeQualifier = qualifier;
+ this.defaultQualifier = qualifier;
+
+ ((IEclipsePreferences)getStorePreferences().parent()).addNodeChangeListener(getNodeChangeListener());
+ }
+
+ /**
+ * Return a node change listener that adds a removes the receiver when nodes
+ * change.
+ *
+ * @return INodeChangeListener
+ */
+ private INodeChangeListener getNodeChangeListener() {
+ return new IEclipsePreferences.INodeChangeListener() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#added(org.eclipse.core.runtime.preferences.IEclipsePreferences
+ * .NodeChangeEvent)
+ */
+ public void added(NodeChangeEvent event) {
+ if(nodeQualifier.equals(event.getChild().name()) && isListenerAttached()) {
+ getStorePreferences().addPreferenceChangeListener(preferencesListener);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#removed(org.eclipse.core.runtime.preferences.
+ * IEclipsePreferences.NodeChangeEvent)
+ */
+ public void removed(NodeChangeEvent event) {
+ // Do nothing as there are no events from removed node
+ }
+ };
+ }
+
+ /**
+ * Initialize the preferences listener.
+ */
+ private void initializePreferencesListener() {
+ if(preferencesListener == null) {
+ preferencesListener = new IEclipsePreferences.IPreferenceChangeListener() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.
+ * preferences.IEclipsePreferences.PreferenceChangeEvent)
+ */
+ public void preferenceChange(PreferenceChangeEvent event) {
+
+ if(silentRunning) {
+ return;
+ }
+
+ Object oldValue = event.getOldValue();
+ Object newValue = event.getNewValue();
+ String key = event.getKey();
+ if(newValue == null) {
+ newValue = getDefault(key, oldValue);
+ } else if(oldValue == null) {
+ oldValue = getDefault(key, newValue);
+ }
+ firePropertyChangeEvent(event.getKey(), oldValue, newValue);
+ }
+ };
+ getStorePreferences().addPreferenceChangeListener(preferencesListener);
+ }
+
+ }
+
+ /**
+ * Does its best at determining the default value for the given key. Checks
+ * the given object's type and then looks in the list of defaults to see if
+ * a value exists. If not or if there is a problem converting the value, the
+ * default default value for that type is returned.
+ *
+ * @param key
+ * the key to search
+ * @param obj
+ * the object who default we are looking for
+ * @return Object or <code>null</code>
+ */
+ protected Object getDefault(String key, Object obj) {
+ IEclipsePreferences defaults = getDefaultPreferences();
+ if(obj instanceof String) {
+ return defaults.get(key, STRING_DEFAULT_DEFAULT);
+ } else if(obj instanceof Integer) {
+ return new Integer(defaults.getInt(key, INT_DEFAULT_DEFAULT));
+ } else if(obj instanceof Double) {
+ return new Double(defaults.getDouble(key, DOUBLE_DEFAULT_DEFAULT));
+ } else if(obj instanceof Float) {
+ return new Float(defaults.getFloat(key, FLOAT_DEFAULT_DEFAULT));
+ } else if(obj instanceof Long) {
+ return new Long(defaults.getLong(key, LONG_DEFAULT_DEFAULT));
+ } else if(obj instanceof Boolean) {
+ return defaults.getBoolean(key, BOOLEAN_DEFAULT_DEFAULT) ? Boolean.TRUE : Boolean.FALSE;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Return the IEclipsePreferences node associated with this store.
+ *
+ * @return the preference node for this store
+ */
+ protected IEclipsePreferences getStorePreferences() {
+ return storeContext.getNode(nodeQualifier);
+ }
+
+ /**
+ * Return the default IEclipsePreferences for this store.
+ *
+ * @return this store's default preference node
+ */
+ protected IEclipsePreferences getDefaultPreferences() {
+ return defaultContext.getNode(defaultQualifier);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
+ */
+ public void addPropertyChangeListener(IPropertyChangeListener listener) {
+ initializePreferencesListener();// Create the preferences listener if it
+ // does not exist
+ addListenerObject(listener);
+ }
+
+ /**
+ * Return the preference path to search preferences on. This is the list of
+ * preference nodes based on the scope contexts for this store. If there are
+ * no search contexts set, then return this store's context.
+ * <p>
+ * Whether or not the default context should be included in the resulting list is specified by the <code>includeDefault</code> parameter.
+ * </p>
+ *
+ * @param includeDefault
+ * <code>true</code> if the default context should be included
+ * and <code>false</code> otherwise
+ * @return IEclipsePreferences[]
+ * @since 3.4 public, was added in 3.1 as private method
+ */
+ public IEclipsePreferences[] getPreferenceNodes(boolean includeDefault) {
+ // if the user didn't specify a search order, then return the scope that
+ // this store was created on. (and optionally the default)
+ if(searchContexts == null) {
+ if(includeDefault) {
+ return new IEclipsePreferences[]{ getStorePreferences(), getDefaultPreferences() };
+ }
+ return new IEclipsePreferences[]{ getStorePreferences() };
+ }
+ // otherwise the user specified a search order so return the appropriate
+ // nodes based on it
+ int length = searchContexts.length;
+ if(includeDefault) {
+ length++;
+ }
+ IEclipsePreferences[] preferences = new IEclipsePreferences[length];
+ for(int i = 0; i < searchContexts.length; i++) {
+ preferences[i] = searchContexts[i].getNode(nodeQualifier);
+ }
+ if(includeDefault) {
+ preferences[length - 1] = getDefaultPreferences();
+ }
+ return preferences;
+ }
+
+ /**
+ * Set the search contexts to scopes. When searching for a value the seach
+ * will be done in the order of scope contexts and will not search the
+ * storeContext unless it is in this list.
+ * <p>
+ * If the given list is <code>null</code>, then clear this store's search contexts. This means that only this store's scope context and default
+ * scope will be used during preference value searching.
+ * </p>
+ * <p>
+ * The defaultContext will be added to the end of this list automatically and <em>MUST NOT</em> be included by the user.
+ * </p>
+ *
+ * @param scopes
+ * a list of scope contexts to use when searching, or <code>null</code>
+ */
+ public void setSearchContexts(IScopeContext[] scopes) {
+ this.searchContexts = scopes;
+ if(scopes == null) {
+ return;
+ }
+
+ // Assert that the default was not included (we automatically add it to
+ // the end)
+ for(int i = 0; i < scopes.length; i++) {
+ if(scopes[i].equals(defaultContext)) {
+ Assert.isTrue(false, WorkbenchMessages.ScopedPreferenceStore_DefaultAddedError);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#contains(java.lang.String)
+ */
+ public boolean contains(String name) {
+ if(name == null) {
+ return false;
+ }
+ return (Platform.getPreferencesService().get(name, null, getPreferenceNodes(true))) != null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#firePropertyChangeEvent(java.lang.String,
+ * java.lang.Object, java.lang.Object)
+ */
+ public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
+ // important: create intermediate array to protect against listeners
+ // being added/removed during the notification
+ final Object[] list = getListeners();
+ if(list.length == 0) {
+ return;
+ }
+ final PropertyChangeEvent event = new PropertyChangeEvent(this, name, oldValue, newValue);
+ for(int i = 0; i < list.length; i++) {
+ final IPropertyChangeListener listener = (IPropertyChangeListener)list[i];
+ SafeRunner.run(new SafeRunnable(JFaceResources.getString("PreferenceStore.changeError")) { //$NON-NLS-1$
+
+ public void run() {
+ listener.propertyChange(event);
+ }
+ });
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getBoolean(java.lang.String)
+ */
+ public boolean getBoolean(String name) {
+ String value = internalGet(name);
+ return value == null ? BOOLEAN_DEFAULT_DEFAULT : Boolean.valueOf(value).booleanValue();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultBoolean(java.lang.String)
+ */
+ public boolean getDefaultBoolean(String name) {
+ return getDefaultPreferences().getBoolean(name, BOOLEAN_DEFAULT_DEFAULT);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultDouble(java.lang.String)
+ */
+ public double getDefaultDouble(String name) {
+ return getDefaultPreferences().getDouble(name, DOUBLE_DEFAULT_DEFAULT);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultFloat(java.lang.String)
+ */
+ public float getDefaultFloat(String name) {
+ return getDefaultPreferences().getFloat(name, FLOAT_DEFAULT_DEFAULT);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultInt(java.lang.String)
+ */
+ public int getDefaultInt(String name) {
+ return getDefaultPreferences().getInt(name, INT_DEFAULT_DEFAULT);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultLong(java.lang.String)
+ */
+ public long getDefaultLong(String name) {
+ return getDefaultPreferences().getLong(name, LONG_DEFAULT_DEFAULT);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultString(java.lang.String)
+ */
+ public String getDefaultString(String name) {
+ return getDefaultPreferences().get(name, STRING_DEFAULT_DEFAULT);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getDouble(java.lang.String)
+ */
+ public double getDouble(String name) {
+ String value = internalGet(name);
+ if(value == null) {
+ return DOUBLE_DEFAULT_DEFAULT;
+ }
+ try {
+ return Double.parseDouble(value);
+ } catch (NumberFormatException e) {
+ return DOUBLE_DEFAULT_DEFAULT;
+ }
+ }
+
+ /**
+ * Return the string value for the specified key. Look in the nodes which
+ * are specified by this object's list of search scopes. If the value does
+ * not exist then return <code>null</code>.
+ *
+ * @param key
+ * the key to search with
+ * @return String or <code>null</code> if the value does not exist.
+ */
+ protected String internalGet(String key) {
+ return Platform.getPreferencesService().get(key, null, getPreferenceNodes(true));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getFloat(java.lang.String)
+ */
+ public float getFloat(String name) {
+ String value = internalGet(name);
+ if(value == null) {
+ return FLOAT_DEFAULT_DEFAULT;
+ }
+ try {
+ return Float.parseFloat(value);
+ } catch (NumberFormatException e) {
+ return FLOAT_DEFAULT_DEFAULT;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getInt(java.lang.String)
+ */
+ public int getInt(String name) {
+ String value = internalGet(name);
+ if(value == null) {
+ return INT_DEFAULT_DEFAULT;
+ }
+ try {
+ return Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ return INT_DEFAULT_DEFAULT;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getLong(java.lang.String)
+ */
+ public long getLong(String name) {
+ String value = internalGet(name);
+ if(value == null) {
+ return LONG_DEFAULT_DEFAULT;
+ }
+ try {
+ return Long.parseLong(value);
+ } catch (NumberFormatException e) {
+ return LONG_DEFAULT_DEFAULT;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#getString(java.lang.String)
+ */
+ public String getString(String name) {
+ String value = internalGet(name);
+ return value == null ? STRING_DEFAULT_DEFAULT : value;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#isDefault(java.lang.String)
+ */
+ public boolean isDefault(String name) {
+ if(name == null) {
+ return false;
+ }
+ return (Platform.getPreferencesService().get(name, null, getPreferenceNodes(false))) == null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#needsSaving()
+ */
+ public boolean needsSaving() {
+ return dirty;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#putValue(java.lang.String,
+ * java.lang.String)
+ */
+ public void putValue(String name, String value) {
+ try {
+ // Do not notify listeners
+ silentRunning = true;
+ getStorePreferences().put(name, value);
+ } finally {
+ // Be sure that an exception does not stop property updates
+ silentRunning = false;
+ dirty = true;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
+ */
+ public void removePropertyChangeListener(IPropertyChangeListener listener) {
+ removeListenerObject(listener);
+ if(!isListenerAttached()) {
+ disposePreferenceStoreListener();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String,
+ * double)
+ */
+ public void setDefault(String name, double value) {
+ getDefaultPreferences().putDouble(name, value);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String,
+ * float)
+ */
+ public void setDefault(String name, float value) {
+ getDefaultPreferences().putFloat(name, value);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String,
+ * int)
+ */
+ public void setDefault(String name, int value) {
+ getDefaultPreferences().putInt(name, value);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String,
+ * long)
+ */
+ public void setDefault(String name, long value) {
+ getDefaultPreferences().putLong(name, value);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String,
+ * java.lang.String)
+ */
+ public void setDefault(String name, String defaultObject) {
+ getDefaultPreferences().put(name, defaultObject);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String,
+ * boolean)
+ */
+ public void setDefault(String name, boolean value) {
+ getDefaultPreferences().putBoolean(name, value);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setToDefault(java.lang.String)
+ */
+ public void setToDefault(String name) {
+
+ String oldValue = getString(name);
+ String defaultValue = getDefaultString(name);
+ try {
+ silentRunning = true;// Turn off updates from the store
+ // removing a non-existing preference is a no-op so call the Core
+ // API directly
+ getStorePreferences().remove(name);
+ if(oldValue != defaultValue) {
+ dirty = true;
+ firePropertyChangeEvent(name, oldValue, defaultValue);
+ }
+
+ } finally {
+ silentRunning = false;// Restart listening to preferences
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String,
+ * double)
+ */
+ public void setValue(String name, double value) {
+ double oldValue = getDouble(name);
+ if(oldValue == value) {
+ return;
+ }
+ try {
+ silentRunning = true;// Turn off updates from the store
+ if(getDefaultDouble(name) == value) {
+ getStorePreferences().remove(name);
+ } else {
+ getStorePreferences().putDouble(name, value);
+ }
+ dirty = true;
+ firePropertyChangeEvent(name, new Double(oldValue), new Double(value));
+ } finally {
+ silentRunning = false;// Restart listening to preferences
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String,
+ * float)
+ */
+ public void setValue(String name, float value) {
+ float oldValue = getFloat(name);
+ if(oldValue == value) {
+ return;
+ }
+ try {
+ silentRunning = true;// Turn off updates from the store
+ if(getDefaultFloat(name) == value) {
+ getStorePreferences().remove(name);
+ } else {
+ getStorePreferences().putFloat(name, value);
+ }
+ dirty = true;
+ firePropertyChangeEvent(name, new Float(oldValue), new Float(value));
+ } finally {
+ silentRunning = false;// Restart listening to preferences
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String,
+ * int)
+ */
+ public void setValue(String name, int value) {
+ int oldValue = getInt(name);
+ if(oldValue == value) {
+ return;
+ }
+ try {
+ silentRunning = true;// Turn off updates from the store
+ if(getDefaultInt(name) == value) {
+ getStorePreferences().remove(name);
+ } else {
+ getStorePreferences().putInt(name, value);
+ }
+ dirty = true;
+ firePropertyChangeEvent(name, new Integer(oldValue), new Integer(value));
+ } finally {
+ silentRunning = false;// Restart listening to preferences
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String,
+ * long)
+ */
+ public void setValue(String name, long value) {
+ long oldValue = getLong(name);
+ if(oldValue == value) {
+ return;
+ }
+ try {
+ silentRunning = true;// Turn off updates from the store
+ if(getDefaultLong(name) == value) {
+ getStorePreferences().remove(name);
+ } else {
+ getStorePreferences().putLong(name, value);
+ }
+ dirty = true;
+ firePropertyChangeEvent(name, new Long(oldValue), new Long(value));
+ } finally {
+ silentRunning = false;// Restart listening to preferences
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String,
+ * java.lang.String)
+ */
+ public void setValue(String name, String value) {
+ // Do not turn on silent running here as Strings are propagated
+ if(getDefaultString(name).equals(value)) {
+ getStorePreferences().remove(name);
+ } else {
+ getStorePreferences().put(name, value);
+ }
+ dirty = true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String,
+ * boolean)
+ */
+ public void setValue(String name, boolean value) {
+ boolean oldValue = getBoolean(name);
+ if(oldValue == value) {
+ return;
+ }
+ try {
+ silentRunning = true;// Turn off updates from the store
+ if(getDefaultBoolean(name) == value) {
+ getStorePreferences().remove(name);
+ } else {
+ getStorePreferences().putBoolean(name, value);
+ }
+ dirty = true;
+ firePropertyChangeEvent(name, oldValue ? Boolean.TRUE : Boolean.FALSE, value ? Boolean.TRUE : Boolean.FALSE);
+ } finally {
+ silentRunning = false;// Restart listening to preferences
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.IPersistentPreferenceStore#save()
+ */
+ public void save() throws IOException {
+ try {
+ getStorePreferences().flush();
+ dirty = false;
+ } catch (BackingStoreException e) {
+ throw new IOException(e.getMessage());
+ }
+
+ }
+
+ /**
+ * Dispose the receiver.
+ */
+ private void disposePreferenceStoreListener() {
+
+ IEclipsePreferences root = (IEclipsePreferences)Platform.getPreferencesService().getRootNode().node(Plugin.PLUGIN_PREFERENCE_SCOPE);
+ try {
+ if(!(root.nodeExists(nodeQualifier))) {
+ return;
+ }
+ } catch (BackingStoreException e) {
+ return;// No need to report here as the node won't have the
+ // listener
+ }
+
+ IEclipsePreferences preferences = getStorePreferences();
+ if(preferences == null) {
+ return;
+ }
+ if(preferencesListener != null) {
+ preferences.removePreferenceChangeListener(preferencesListener);
+ preferencesListener = null;
+ }
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/initializer/AbstractViewInitializer.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/initializer/AbstractViewInitializer.java
new file mode 100644
index 00000000000..c9e00ebafb9
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/initializer/AbstractViewInitializer.java
@@ -0,0 +1,136 @@
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.initializer;
+
+import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.LineStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ * Initialize a view with the properties contained in a preference store
+ *
+ * <p>
+ * The following properties can be initialized :
+ * <ul>
+ * <li>{@link org.eclipse.gmf.runtime.notation.FontStyle#getFontName() <em>Font </em>}</li>
+ * <li>{@link org.eclipse.gmf.runtime.notation.FontStyle#getFontColor() <em>Font Color</em>}</li>
+ * <li>{@link org.eclipse.gmf.runtime.notation.LineStyle#getLineColor() <em>Line Color</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @author tlandre
+ */
+public abstract class AbstractViewInitializer {
+
+ /** The view to initialize */
+ private final View view;
+
+ /** The preference store to use */
+ private final IPreferenceStore store;
+
+ /**
+ * Constructor
+ *
+ * @param view
+ * the view to initialize
+ * @param store
+ * the preference store where the properties are.
+ */
+ public AbstractViewInitializer(View view, IPreferenceStore store) {
+ this.view = view;
+ this.store = store;
+ }
+
+ /**
+ * Initialize the font.
+ *
+ * @param preferenceFontName
+ * the name of the preference where is stored the value of the font.
+ */
+ // @unused
+ public void initFont(String preferenceFontName) {
+ FontStyle fontStyle = (FontStyle)view.getStyle(NotationPackage.Literals.FONT_STYLE);
+
+ if(fontStyle != null) {
+ // default font
+ FontData fontData = PreferenceConverter.getFontData(store, preferenceFontName);
+ fontStyle.setFontName(fontData.getName());
+ fontStyle.setFontHeight(fontData.getHeight());
+ fontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
+ fontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
+ // font color
+ RGB fontRGB = PreferenceConverter.getColor(store, preferenceFontName);
+ fontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
+ }
+ }
+
+ /**
+ * Initialize the font color.
+ *
+ * @param preferenceFontColorName
+ * the name of the preference where is stored the value of the color.
+ */
+ // @unused
+ public void initFontColor(String preferenceFontColorName) {
+ FontStyle fontStyle = (FontStyle)view.getStyle(NotationPackage.Literals.FONT_STYLE);
+
+ if(fontStyle != null) {
+ // font color
+ RGB fontRGB = PreferenceConverter.getColor(store, preferenceFontColorName);
+ fontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
+ }
+ }
+
+ /**
+ * Initialize the line color.
+ *
+ * @param preferenceLineColorName
+ * the name of the preference where is stored the value of the color.
+ */
+ // @unused
+ public void initLineColor(String preferenceLineColorName) {
+ LineStyle lineStyle = (LineStyle)view.getStyle(NotationPackage.Literals.LINE_STYLE);
+ if(lineStyle != null) {
+ // line color
+ RGB lineRGB = PreferenceConverter.getColor(store, preferenceLineColorName);
+
+ lineStyle.setLineColor(FigureUtilities.RGBToInteger(lineRGB).intValue());
+ }
+ }
+
+ /**
+ * Get the preference store used for this view
+ *
+ * @return the preference store used
+ */
+ public IPreferenceStore getStore() {
+ return store;
+ }
+
+ /**
+ * Get the view for this initializer
+ *
+ * @return the view used
+ */
+ public View getView() {
+ return view;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/initializer/LinkViewInitializer.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/initializer/LinkViewInitializer.java
new file mode 100644
index 00000000000..36a0adae2cf
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/initializer/LinkViewInitializer.java
@@ -0,0 +1,162 @@
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.initializer;
+
+import org.eclipse.gmf.runtime.notation.JumpLinkStatus;
+import org.eclipse.gmf.runtime.notation.JumpLinkType;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.Routing;
+import org.eclipse.gmf.runtime.notation.RoutingStyle;
+import org.eclipse.gmf.runtime.notation.Smoothness;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+/**
+ * Initialize the {@link org.eclipse.gmf.runtime.notation.RoutingStyle <em>Routing Style</em>} of a
+ * connection view with the properties contained in a preference store
+ *
+ * <p>
+ * The following properties can be initialized :
+ * <ul>
+ * <li>{@link org.eclipse.gmf.runtime.notation.RoutingStyle#getRouting <em> Routing</em>}</li>
+ * <li>{@link org.eclipse.gmf.runtime.notation.RoutingStyle#getSmoothness <em> Smoothness</em>}</li>
+ * <li>{@link org.eclipse.gmf.runtime.notation.RoutingStyle#isAvoidObstructions <em>Avoid Obstructions</em>}</li>
+ * <li>{@link org.eclipse.gmf.runtime.notation.RoutingStyle#isClosestDistance <em>Closest Distance </em>}</li>
+ * <li>{@link org.eclipse.gmf.runtime.notation.RoutingStyle#getJumpLinkStatus <em>Jump Link Status </em>}</li>
+ * <li>{@link org.eclipse.gmf.runtime.notation.RoutingStyle#getJumpLinkType <em> Jump Link Type </em>}</li>
+ * <li>{@link org.eclipse.gmf.runtime.notation.RoutingStyle#isJumpLinksReverse <em>Jump Links Reverse</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @author tlandre
+ */
+public class LinkViewInitializer extends AbstractViewInitializer {
+
+ /**
+ * The routing style
+ */
+ RoutingStyle routingStyle;
+
+ /**
+ * Constructor
+ *
+ * @param view
+ * the view to initialize
+ * @param store
+ * the preference store where the properties are.
+ */
+ // @unused
+ public LinkViewInitializer(View view, IPreferenceStore store) {
+ super(view, store);
+ routingStyle = (RoutingStyle)view.getStyle(NotationPackage.Literals.ROUTING_STYLE);
+ }
+
+ /**
+ * Initialize the {@link org.eclipse.gmf.runtime.notation.RoutingStyle#getRouting
+ * <em>Routing</em>}
+ *
+ * @param preferenceRoutingName
+ * the name of the preference where is stored the value of the Routing
+ */
+ // @unused
+ public void initRouting(String preferenceRoutingName) {
+ if(routingStyle != null) {
+ Routing routing = Routing.get(getStore().getInt(preferenceRoutingName));
+ if(routing != null) {
+ routingStyle.setRouting(routing);
+ }
+ }
+ }
+
+ /**
+ * Initialize the {@link org.eclipse.gmf.runtime.notation.RoutingStyle#isAvoidObstructions
+ * <em>Avoid Obstructions</em>}
+ *
+ * @param preferenceRoutingJumpName
+ * the name of the preference where is stored the value.
+ */
+ // @unused
+ public void initAvoidObstructions(String preferenceRoutingJumpName) {
+ routingStyle.setAvoidObstructions(getStore().getBoolean(preferenceRoutingJumpName));
+ }
+
+ /**
+ * Initialize {@link org.eclipse.gmf.runtime.notation.RoutingStyle#isClosestDistance
+ * <em>Closest Distance</em>}
+ *
+ * @param preferenceClosestDistanceName
+ * the name of the preference where is stored the value of the closest distance
+ */
+ // @unused
+ public void initClosestDistance(String preferenceClosestDistanceName) {
+ routingStyle.setClosestDistance(getStore().getBoolean(preferenceClosestDistanceName));
+ }
+
+ /**
+ * Initialize the {@link org.eclipse.gmf.runtime.notation.RoutingStyle#isJumpLinksReverse
+ * <em>Jump Links Reverse</em>}
+ *
+ * @param preferenceJumpLinkReverseName
+ * the name of the preference where is stored the value of the jumplink reverse
+ */
+ // @unused
+ public void initJumpLinkReverse(String preferenceJumpLinkReverseName) {
+ routingStyle.setJumpLinksReverse(getStore().getBoolean(preferenceJumpLinkReverseName));
+ }
+
+ /**
+ * Initialize the {@link org.eclipse.gmf.runtime.notation.RoutingStyle#getJumpLinkStatus
+ * <em>Jump Link Status</em>}
+ *
+ * @param preferenceJumpLinkStatusName
+ * the name of the preference where is stored the value of the jumplink status
+ */
+ // @unused
+ public void initJumpLinkStatus(String preferenceJumpLinkStatusName) {
+ JumpLinkStatus jumpLinkStatus = JumpLinkStatus.get(getStore().getInt(preferenceJumpLinkStatusName));
+ if(jumpLinkStatus != null) {
+ routingStyle.setJumpLinkStatus(jumpLinkStatus);
+ }
+ }
+
+ /**
+ * Initialize the {@link org.eclipse.gmf.runtime.notation.RoutingStyle#getJumpLinkType
+ * <em>Jump Link Type</em>}
+ *
+ * @param preferenceJumpLinkTypeName
+ * the name of the preference where is stored the value of the jumplink type
+ */
+ // @unused
+ public void initJumpLinkType(String preferenceJumpLinkTypeName) {
+ JumpLinkType jumpLinkType = JumpLinkType.get(getStore().getInt(preferenceJumpLinkTypeName));
+ if(jumpLinkType != null) {
+ routingStyle.setJumpLinkType(jumpLinkType);
+ }
+ }
+
+ /**
+ * Initialize the {@link org.eclipse.gmf.runtime.notation.RoutingStyle#getSmoothness
+ * <em>Smoothness</em>}
+ *
+ * @param preferenceSmoothnessName
+ * the name of the preference where is stored the value of the Smoothness
+ */
+ // @unused
+ public void initSmoothness(String preferenceSmoothnessName) {
+ Smoothness smoothness = Smoothness.get(getStore().getInt(preferenceSmoothnessName));
+ if(smoothness != null) {
+ routingStyle.setSmoothness(smoothness);
+ }
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/initializer/NodeViewInitializer.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/initializer/NodeViewInitializer.java
new file mode 100644
index 00000000000..402140e298b
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/initializer/NodeViewInitializer.java
@@ -0,0 +1,65 @@
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.initializer;
+
+import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
+import org.eclipse.gmf.runtime.notation.FillStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ * Initialize a node view with the properties contained in a preference store
+ * <p>
+ * The following properties can be initialized :
+ * <ul>
+ * <li>{@link org.eclipse.gmf.runtime.notation.FillStyle#getFillColor() <em> FillColor</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @author tlandre
+ */
+// @unused
+public class NodeViewInitializer extends AbstractViewInitializer {
+
+ /**
+ * Default Constructor
+ *
+ * @param view
+ * the node view to initialize
+ * @param store
+ * the preference store to use
+ */
+ // @unused
+ public NodeViewInitializer(View view, IPreferenceStore store) {
+ super(view, store);
+ }
+
+ /**
+ * Initialize the fill color.
+ *
+ * @param preferenceFillColorName
+ * the name of the preference where is stored the value of the color.
+ */
+ // @unused
+ public void initFillColor(String preferenceFillColorName) {
+ FillStyle fillStyle = (FillStyle)getView().getStyle(NotationPackage.Literals.FILL_STYLE);
+ if(fillStyle != null) {
+ // fill color
+ RGB fillRGB = PreferenceConverter.getColor(getStore(), preferenceFillColorName);
+ fillStyle.setFillColor(FigureUtilities.RGBToInteger(fillRGB).intValue());
+ }
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/ColorFieldEditor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/ColorFieldEditor.java
new file mode 100644
index 00000000000..d7497590835
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/ColorFieldEditor.java
@@ -0,0 +1,197 @@
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.jface.preference;
+
+import org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ColorPalettePopup;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.CompositeImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.PaletteData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * A field editor that display a button and a small rectangle under it to show the color selected.
+ *
+ * This field editor is inspired by the class {@link org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ColorsAndFontsPropertySection
+ * <em>ColorsAndFontsPropertySection</em>}
+ *
+ * @author tlandre
+ */
+
+public class ColorFieldEditor extends FieldEditor {
+
+ private Image buttonImage;
+
+ private Image backgroundImage;
+
+ private ColorPalettePopup colorSelector;
+
+ private Button colorButton;
+
+ /**
+ * Default constructor
+ *
+ * @param name
+ * the preference name to use
+ * @param image
+ * the image to display
+ * @param parent
+ * the parent composite
+ */
+ public ColorFieldEditor(String name, Image image, Composite parent) {
+ super(name, "", parent); // $NON-NLS-1$
+ backgroundImage = image;
+ }
+
+ @Override
+ public void load() {
+ super.load();
+
+ buttonImage = new ColorOverlayImageDescriptor(backgroundImage.getImageData(), PreferenceConverter.getColor(getPreferenceStore(), getPreferenceName())).createImage();
+ colorButton.setImage(buttonImage);
+ }
+
+ @Override
+ protected void adjustForNumColumns(int numColumns) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void doFillIntoGrid(Composite parent, int numColumns) {
+ colorButton = new Button(parent, SWT.PUSH);
+ colorButton.setLayoutData(new GridData());
+ colorButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent event) {
+ changeColors(colorButton);
+ }
+ });
+
+ }
+
+ @Override
+ protected void doLoad() {
+ doLoadColor(PreferenceConverter.getColor(getPreferenceStore(), getPreferenceName()));
+ }
+
+ @Override
+ protected void doLoadDefault() {
+ doLoadColor(PreferenceConverter.getDefaultColor(getPreferenceStore(), getPreferenceName()));
+
+ }
+
+ private void doLoadColor(RGB rgb) {
+ updateButtonImage(rgb);
+ if(colorSelector != null) {
+ colorSelector.setPreviousColor(FigureUtilities.RGBToInteger(rgb));
+ }
+
+ }
+
+ @Override
+ protected void doStore() {
+ if(colorSelector != null) {
+ PreferenceConverter.setValue(getPreferenceStore(), getPreferenceName(), colorSelector.getSelectedColor());
+ }
+ }
+
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+
+ private void changeColors(Button button) {
+
+ colorSelector = new ColorPalettePopup(colorButton.getParent().getShell(), IDialogConstants.BUTTON_BAR_HEIGHT);
+
+ Rectangle r = button.getBounds();
+ Point location = button.getParent().toDisplay(r.x, r.y);
+ colorSelector.open(location);
+
+ if(colorSelector.getSelectedColor() == null && !colorSelector.useDefaultColor()) {
+ return;
+ }
+ updateButtonImage(colorSelector.getSelectedColor());
+
+ }
+
+ private void updateButtonImage(RGB rgb) {
+ if(!colorButton.isDisposed() && colorButton.getImage() != null && !colorButton.getImage().isDisposed()) {
+ colorButton.getImage().dispose();
+ Image overlyedImage = new ColorOverlayImageDescriptor(backgroundImage.getImageData(), rgb).createImage();
+ colorButton.setImage(overlyedImage);
+ }
+ }
+
+ protected static class ColorOverlayImageDescriptor extends CompositeImageDescriptor {
+
+ /** default color icon width */
+ private static final Point ICON_SIZE = new Point(16, 16);
+
+ /** the basic icon */
+ private ImageData basicImgData;
+
+ /** the color of the thin color bar */
+ private RGB rgb;
+
+ /**
+ * Creates a new color menu image descriptor
+ *
+ * @param basicImgData
+ * The basic Image data
+ * @param rgb
+ * The color bar RGB value
+ */
+ public ColorOverlayImageDescriptor(ImageData basicImgData, RGB rgb) {
+ this.basicImgData = basicImgData;
+ this.rgb = rgb;
+ }
+
+ /**
+ * @see org.eclipse.jface.resource.CompositeImageDescriptor#drawCompositeImage(int, int)
+ */
+ protected void drawCompositeImage(int width, int height) {
+
+ // draw the thin color bar underneath
+ if(rgb != null) {
+ ImageData colorBar = new ImageData(width, height / 5, 1,
+
+ new PaletteData(new RGB[]{ rgb }));
+ drawImage(colorBar, 0, height - height / 5);
+
+ }
+ // draw the base image
+ drawImage(basicImgData, 0, 0);
+ }
+
+ /**
+ * @see org.eclipse.jface.resource.CompositeImageDescriptor#getSize()
+ */
+ protected Point getSize() {
+ return ICON_SIZE;
+ }
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/FontFieldEditor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/FontFieldEditor.java
new file mode 100644
index 00000000000..d3042e0a222
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/FontFieldEditor.java
@@ -0,0 +1,204 @@
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.preferences.jface.preference;
+
+import org.eclipse.gmf.runtime.common.core.util.StringStatics;
+import org.eclipse.gmf.runtime.diagram.ui.properties.internal.l10n.DiagramUIPropertiesImages;
+import org.eclipse.gmf.runtime.diagram.ui.properties.internal.l10n.DiagramUIPropertiesMessages;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.papyrus.preferences.utils.FontHelper;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontData;
+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;
+
+/**
+ * A field editor for GMF Font preferences. This field editor handles :
+ * <ul>
+ * <li>Font Style</li>
+ * <li>Font Size</li>
+ * <li>Bold</li>
+ * <li>Italic</li>
+ * </ul>
+ * This field editor is inspired by the class {@link org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ColorsAndFontsPropertySection
+ * <em>ColorsAndFontsPropertySection</em>}
+ *
+ * @author tlandre
+ */
+public class FontFieldEditor extends FieldEditor {
+
+ private Button fontBoldButton;
+
+ private Button fontItalicButton;
+
+ private Combo fontNameCombo;
+
+ private Combo fontSizeCombo;
+
+ /** value changed string */
+ // @unused
+ static protected String VALUE_CHANGED_STRING = DiagramUIPropertiesMessages.AbstractPropertySection_UndoIntervalPropertyString;
+
+ /** properties */
+ // @unused
+ protected static final String FONT_COMMAND_NAME = DiagramUIPropertiesMessages.Font_commandText + StringStatics.SPACE + VALUE_CHANGED_STRING;
+
+ // @unused
+ protected static final String FONTS_AND_COLORS_LABEL = DiagramUIPropertiesMessages.FontAndColor_nameLabel;
+
+ private FontData fontData;
+
+ /**
+ * Constructor
+ *
+ * @param preferenceName
+ * the preference used for the Font
+ * @param parent
+ * the parent composite in which this field editor will be placed.
+ */
+ public FontFieldEditor(String preferenceName, Composite parent) {
+ super(preferenceName, "", parent); //$NON-NLS-1$
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.FieldEditor#adjustForNumColumns(int)
+ */
+ @Override
+ protected void adjustForNumColumns(int numColumns) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.FieldEditor#doFillIntoGrid(org.eclipse.swt.widgets.Composite, int)
+ */
+ @Override
+ protected void doFillIntoGrid(Composite parent, int numColumns) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.FieldEditor#doLoad()
+ */
+ @Override
+ protected void doLoad() {
+ fontData = PreferenceConverter.getFontData(getPreferenceStore(), getPreferenceName());
+ initFontData();
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.FieldEditor#doLoadDefault()
+ */
+ @Override
+ protected void doLoadDefault() {
+ fontData = PreferenceConverter.getDefaultFontData(getPreferenceStore(), getPreferenceName());
+ initFontData();
+ }
+
+ private void initFontData() {
+
+ // Name Combo
+ fontNameCombo.setText(fontData.getName());
+ // Size combo
+ fontSizeCombo.setText("" + fontData.getHeight()); //$NON-NLS-1$
+
+ int style = fontData.getStyle();
+ // Bold Button
+ if((style & SWT.BOLD) == SWT.BOLD) {
+ fontBoldButton.setSelection(true);
+ } else {
+ fontBoldButton.setSelection(false);
+ }
+ // Italic Button
+ if((style & SWT.ITALIC) == SWT.ITALIC) {
+ fontItalicButton.setSelection(true);
+ } else {
+ fontItalicButton.setSelection(false);
+ }
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.FieldEditor#doStore()
+ */
+ @Override
+ protected void doStore() {
+ fontData = new FontData();
+ fontData.setName(fontNameCombo.getText());
+ fontData.setHeight(Integer.parseInt(fontSizeCombo.getText()));
+ fontData.setStyle(getStyle());
+ PreferenceConverter.setValue(getPreferenceStore(), getPreferenceName(), fontData);
+
+ }
+
+ private int getStyle() {
+ int style = SWT.NORMAL;
+ if(fontBoldButton.getSelection()) {
+ style |= SWT.BOLD;
+ }
+ if(fontItalicButton.getSelection()) {
+ style |= SWT.ITALIC;
+ }
+ return style;
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ fontBoldButton.dispose();
+ fontItalicButton.dispose();
+ fontNameCombo.dispose();
+ fontSizeCombo.dispose();
+ }
+
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+
+ @Override
+ protected void createControl(Composite parent) {
+ Composite compo = new Composite(parent, SWT.NONE);
+ GridLayout gl = new GridLayout(3, false);
+ gl.marginWidth = 0;
+ gl.marginHeight = 0;
+ compo.setLayout(gl);
+
+ fontNameCombo = new Combo(compo, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
+ fontNameCombo.setItems(FontHelper.getFontNames());
+
+ GridData gridData = new GridData(SWT.BEGINNING, SWT.CENTER, true, false);
+ gridData.horizontalSpan = 3;
+
+ fontNameCombo.setLayoutData(gridData);
+
+ fontBoldButton = new Button(compo, SWT.TOGGLE);
+ fontBoldButton.setImage(DiagramUIPropertiesImages.get(DiagramUIPropertiesImages.IMG_BOLD));
+
+ fontItalicButton = new Button(compo, SWT.TOGGLE);
+ fontItalicButton.setImage(DiagramUIPropertiesImages.get(DiagramUIPropertiesImages.IMG_ITALIC));
+
+ fontSizeCombo = new Combo(compo, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
+ fontSizeCombo.setItems(FontHelper.getFontSizes());
+
+ gridData = new GridData(SWT.END, SWT.CENTER, true, false);
+ fontSizeCombo.setLayoutData(gridData);
+
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/GradientFieldEditor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/GradientFieldEditor.java
new file mode 100644
index 00000000000..bfbc315f3e2
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/GradientFieldEditor.java
@@ -0,0 +1,283 @@
+/****************************************************************************
+ * Copyright (c) 2009 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ * Patrick Tessier (CEA LIST) modification
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.jface.preference;
+
+import org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ColorPalettePopup;
+import org.eclipse.gmf.runtime.notation.GradientStyle;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.papyrus.preferences.Messages;
+import org.eclipse.papyrus.preferences.utils.GradientPreferenceConverter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Spinner;
+
+/**
+ * A field editor for gradient Preferences. This field editor handles :
+ * <ul>
+ * <li>Gradient color1</li>
+ * <li>Gradient transparency. The value must be contained in [0,100]</li>
+ * <li>Gradient style. The value is GradientStyle.HORIZONTAL or GradientStyle.VERTICAL</li>
+ * </ul>
+ * The second color of the gradient is set by default at RGB{255,255,255}
+ *
+ * @author tlandre
+ */
+public class GradientFieldEditor extends FieldEditor {
+
+ private Button colorButton;
+
+ private Button verticalStyleButton;
+
+ private Button horizontalStyleButton;
+
+ private Spinner transparencyValueSpinner;
+
+ private RGB color1 = new RGB(0, 0, 0);
+
+ private RGB color2 = new RGB(255, 255, 255);
+
+ private int transparency = 0;
+
+ private int style = GradientStyle.HORIZONTAL;
+
+ /**
+ * create a field to display gradient preference
+ *
+ * @param gradientPreferenceName
+ * the name of the gradient field
+ * @param parent
+ * the parent composite
+ */
+ public GradientFieldEditor(String gradientPreferenceName, Composite parent) {
+ super(gradientPreferenceName, "", parent); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void adjustForNumColumns(int arg0) {
+
+ }
+
+ @Override
+ public void load() {
+ super.load();
+ setButtonImage(color1);
+ transparencyValueSpinner.setSelection(transparency);
+ if(style == GradientStyle.HORIZONTAL) {
+ horizontalStyleButton.setSelection(true);
+ } else if(style == GradientStyle.VERTICAL) {
+ verticalStyleButton.setSelection(true);
+ }
+ }
+
+ @Override
+ protected void doFillIntoGrid(Composite parent, int numColumns) {
+
+ Composite gradientComposite = new Composite(parent, SWT.NULL);
+ gradientComposite.setLayout(new GridLayout(2, false));
+ Label colorLabel = new Label(gradientComposite, SWT.NULL);
+ colorLabel.setText(Messages.GradientFieldEditor_Color);
+
+ colorButton = new Button(gradientComposite, SWT.PUSH);
+ colorButton.addListener(SWT.Selection, new Listener() {
+
+ public void handleEvent(Event event) {
+ color1 = changeColor();
+ }
+ });
+
+ Label styleLabel = new Label(gradientComposite, SWT.NULL);
+ styleLabel.setText(Messages.GradientFieldEditor_Style);
+
+ Composite styleComposite = new Composite(gradientComposite, SWT.NULL);
+ GridLayout gl = new GridLayout(1, false);
+ gl.marginWidth = 0;
+ styleComposite.setLayout(gl);
+ verticalStyleButton = new Button(styleComposite, SWT.RADIO);
+ verticalStyleButton.setText(Messages.GradientFieldEditor_Vertical);
+ horizontalStyleButton = new Button(styleComposite, SWT.RADIO);
+ horizontalStyleButton.setText(Messages.GradientFieldEditor_Horizontal);
+
+ SelectionListener selectionListener = new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if(!((Button)e.widget).getSelection()) {
+ // don't react on de-selection
+ return;
+ }
+ if(verticalStyleButton.getSelection()) {
+ style = GradientStyle.VERTICAL;
+ } else {
+ style = GradientStyle.HORIZONTAL;
+ }
+
+ }
+ };
+ horizontalStyleButton.addSelectionListener(selectionListener);
+ verticalStyleButton.addSelectionListener(selectionListener);
+
+ Label transparencyLabel = new Label(gradientComposite, SWT.NULL);
+ transparencyLabel.setText(Messages.GradientFieldEditor_Transparency);
+
+ // Create the Spinner
+ transparencyValueSpinner = new Spinner(gradientComposite, SWT.BORDER);
+ transparencyValueSpinner.setMinimum(0);
+ transparencyValueSpinner.setMaximum(100);
+ transparencyValueSpinner.setIncrement(1);
+
+ transparencyValueSpinner.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent arg0) {
+ transparency = transparencyValueSpinner.getSelection();
+ }
+ });
+ }
+
+ @Override
+ protected void doLoad() {
+ String preferenceValue = getPreferenceStore().getString(getPreferenceName());
+ loadGradientValues(preferenceValue);
+
+ }
+
+ private void loadGradientValues(String preferenceValue) {
+ GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(preferenceValue);
+ color1 = gradientPreferenceConverter.getColor1();
+ style = gradientPreferenceConverter.getStyle();
+ transparency = gradientPreferenceConverter.getTransparency();
+ }
+
+ @Override
+ protected void doLoadDefault() {
+ String preferenceValue = getPreferenceStore().getDefaultString(getPreferenceName());
+ loadGradientValues(preferenceValue);
+ }
+
+ @Override
+ protected void doStore() {
+ GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(color1, color2, style, transparency);
+ getPreferenceStore().setValue(getPreferenceName(), gradientPreferenceConverter.getPreferenceValue());
+ }
+
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.gmf.runtime.diagram.ui.properties.sections.AbstractModelerPropertySection#dispose
+ * ()
+ */
+ @Override
+ public void dispose() {
+ disposeButtonImage();
+ super.dispose();
+ }
+
+ /**
+ * Dispose the image associated with the given button
+ *
+ * @param btn
+ * the button that contains the image
+ */
+ protected void disposeButtonImage() {
+ if(colorButton != null && !colorButton.isDisposed()) {
+ Image imageColor1 = colorButton.getImage();
+ if(imageColor1 != null && !imageColor1.isDisposed()) {
+ imageColor1.dispose();
+ }
+ }
+ }
+
+ /**
+ * Sets the image for a color button (square filled with the color that button represents)
+ */
+ protected void setButtonImage(RGB rgb) {
+ // First, dispose the current image, if any
+ Image image = colorButton.getImage();
+ if(image != null) {
+ image.dispose();
+ }
+
+ Display display = colorButton.getParent().getShell().getDisplay();
+ // Now set the new image based on rgbColor
+ Color color = new Color(display, rgb);
+ image = new Image(display, 16, 16);
+ GC gc = new GC(image);
+ gc.setBackground(color);
+ Rectangle rect = image.getBounds();
+ gc.fillRectangle(rect);
+ gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
+ gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height - 1);
+ gc.dispose();
+ color.dispose();
+ colorButton.setImage(image);
+ }
+
+ /**
+ * Allow user to change the color of the given button.
+ *
+ * @param button
+ * the button
+ * @return the selected color or null
+ * @see org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ColorPalettePopup
+ */
+ private RGB changeColor() {
+ ColorPalettePopup popup = new ColorPalettePopup(colorButton.getParent().getShell(), IDialogConstants.BUTTON_BAR_HEIGHT);
+ Rectangle r = colorButton.getBounds();
+ Point location = colorButton.getParent().toDisplay(r.x, r.y);
+ popup.open(new Point(location.x, location.y + r.height));
+ if(popup.getSelectedColor() == null && !popup.useDefaultColor()) {
+ return null;
+ }
+ RGB rgb = popup.getSelectedColor();
+ setButtonImage(rgb);
+ return rgb;
+ }
+
+ /**
+ * used to set disable this field editor
+ *
+ * @param enabled
+ * a boolean, ture to edit the field
+ */
+ public void setEnabled(boolean enabled) {
+ colorButton.setEnabled(enabled);
+ horizontalStyleButton.setEnabled(enabled);
+ transparencyValueSpinner.setEnabled(enabled);
+ verticalStyleButton.setEnabled(enabled);
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/dialogs/GradientTransparencySelectionDialog.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/dialogs/GradientTransparencySelectionDialog.java
new file mode 100644
index 00000000000..e89e9dfd0c7
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/jface/preference/dialogs/GradientTransparencySelectionDialog.java
@@ -0,0 +1,128 @@
+/****************************************************************************
+ * Copyright (c) 2009 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.jface.preference.dialogs;
+
+import org.eclipse.gmf.runtime.common.ui.dialogs.GradientSelectionDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Spinner;
+
+/**
+ * Add a transparency group to the {@link GradientSelectionDialog} allow users to set the
+ * transparency too.
+ *
+ * @author tlandre
+ */
+// @unused
+public class GradientTransparencySelectionDialog extends GradientSelectionDialog {
+
+ /**
+ * The spinner used to set the transparencyValue
+ */
+ Spinner transparencyValueSpinner;
+
+ /**
+ * Default Constructor
+ *
+ * @param parent
+ * the shell used
+ * @param style
+ * the style of the shell.
+ * @param initColor1
+ * the first color used for the gradient
+ * @param initColor2
+ * the seconde color used for the gradient
+ * @param defaultGradientStyle
+ * initial Gradient style. The allowed values are GradientStyle.HORIZONTAL or
+ * GradientStyle.VERTICAL
+ * @param transparency
+ * the transparency of the gradient. It is ignored if not within [0, 100] range
+ */
+ // @unused
+ public GradientTransparencySelectionDialog(Shell parent, int style, RGB initColor1, RGB initColor2, int defaultGradientStyle, int transparency) {
+ super(parent, style, initColor1, initColor2, defaultGradientStyle, transparency);
+ }
+
+ @Override
+ protected void createClearButton(Composite okCancelComp, Shell parent) {
+ // Remove Clear Button
+ }
+
+ /**
+ * Creates the controls of the dialog.
+ *
+ * @param parent
+ * Parent shell
+ */
+ @Override
+ protected void createDialogControls(Shell parent) {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 4;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ Composite topComposite = new Composite(parent, SWT.NONE);
+ topComposite.setLayout(layout);
+
+ createColorGroup(parent, topComposite);
+ createStyleGroup(topComposite);
+ createTransparencyGroup(parent, topComposite);
+ createSample(parent, topComposite);
+
+ createOkCancelClearButtons(parent, topComposite);
+
+ }
+
+ /**
+ * Create the transparency group
+ *
+ * @param parent
+ * the shell used
+ * @param topComposite
+ * the parent composite
+ */
+ protected void createTransparencyGroup(Shell parent, Composite topComposite) {
+ Group transparencyGroup = new Group(topComposite, SWT.NONE);
+ transparencyGroup.setText("Transparency");
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ GridData gridData = new GridData();
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.verticalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ transparencyGroup.setLayout(layout);
+ transparencyGroup.setLayoutData(gridData);
+
+ transparencyValueSpinner = new Spinner(transparencyGroup, SWT.BORDER);
+ transparencyValueSpinner.setSelection(getTransparency());
+ transparencyValueSpinner.setMinimum(0);
+ transparencyValueSpinner.setMaximum(100);
+ transparencyValueSpinner.setIncrement(1);
+
+ transparencyValueSpinner.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent arg0) {
+ setTransparency(transparencyValueSpinner.getSelection());
+ getSampleCanvas().redraw();
+ }
+ });
+
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/messages.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/messages.properties
new file mode 100644
index 00000000000..5372bd6a1de
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/messages.properties
@@ -0,0 +1,35 @@
+AbstractPapyrusElementPreferencePage_Colors=Colors
+AbstractPapyrusElementPreferencePage_Font=Font
+AbstractPapyrusLinkPreferencePage_Above=Above
+AbstractPapyrusLinkPreferencePage_All=All
+AbstractPapyrusLinkPreferencePage_AvoidObstructions=Avoid Obstructions
+AbstractPapyrusLinkPreferencePage_Below=Below
+AbstractPapyrusLinkPreferencePage_Chamfered=Chamfered
+AbstractPapyrusLinkPreferencePage_ClosestDistance=Closest Distance
+AbstractPapyrusLinkPreferencePage_Connection=Connection
+AbstractPapyrusLinkPreferencePage_JUMPLINKS=Jump Links
+AbstractPapyrusLinkPreferencePage_Less=Less
+AbstractPapyrusLinkPreferencePage_More=More
+AbstractPapyrusLinkPreferencePage_None=None
+AbstractPapyrusLinkPreferencePage_Normal=Normal
+AbstractPapyrusLinkPreferencePage_Oblique=Oblique
+AbstractPapyrusLinkPreferencePage_Rectilinear=Rectilinear
+AbstractPapyrusLinkPreferencePage_ReverseJumpLinks=Reverse jump links
+AbstractPapyrusLinkPreferencePage_Routing=Routing
+AbstractPapyrusLinkPreferencePage_SemiCircle=Semi-Circle
+AbstractPapyrusLinkPreferencePage_Smoothness=Smoothness
+AbstractPapyrusLinkPreferencePage_Square=Square
+AbstractPapyrusLinkPreferencePage_Status=Status
+AbstractPapyrusLinkPreferencePage_Styles=Styles
+AbstractPapyrusLinkPreferencePage_Tree=Tree
+AbstractPapyrusLinkPreferencePage_Type=Type
+AbstractPapyrusNodePreferencePage_Activate=Activate
+AbstractPapyrusNodePreferencePage_Gradient=Gradient :
+GradientFieldEditor_Color=Color
+GradientFieldEditor_Horizontal=Horizontal
+GradientFieldEditor_Style=Style
+GradientFieldEditor_Transparency=Transparency
+GradientFieldEditor_Vertical=Vertical
+DecorationGroup_Name=Decoration
+DimensionGroupName=Dimension
+NodeCompartmentGroup_Compartiments=Show/hide compartments
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/messages/Messages.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/messages/Messages.java
new file mode 100644
index 00000000000..6b162684e84
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/messages/Messages.java
@@ -0,0 +1,17 @@
+package org.eclipse.papyrus.preferences.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.preferences.messages.messages"; //$NON-NLS-1$
+
+ public static String LabelGroup_Labels_To_Display;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/messages/messages.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/messages/messages.properties
new file mode 100644
index 00000000000..bb2c968ed60
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/messages/messages.properties
@@ -0,0 +1 @@
+LabelGroup_Labels_To_Display=Labels to display
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusElementPreferencePage.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusElementPreferencePage.java
new file mode 100644
index 00000000000..51c1278ef77
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusElementPreferencePage.java
@@ -0,0 +1,78 @@
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.pages;
+
+import org.eclipse.papyrus.preferences.ui.FontGroup;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Layout;
+
+/**
+ * An abstract implementation of a Papyrus Preference Page.
+ * <p>
+ * This class create the default editorFields used in a Papyrus preference page.
+ * </p>
+ * <ul>
+ * The following editor fields are initialized :
+ * <li>{@link org.eclipse.papyrus.preferences.jface.preference.ColorFieldEditor} <em>ColorFieldEditor</em></li>
+ * <li>{@link org.eclipse.papyrus.preferences.jface.preference.FontFieldEditor} <em>FontFieldEditor</em></li>
+ * </ul>
+ *
+ * @author tlandre
+ */
+public abstract class AbstractPapyrusElementPreferencePage extends AbstractPapyrusPreferencePage {
+
+ private Group toolbar;
+
+ protected Layout getToolbarLayout() {
+ return new GridLayout(2, false);
+ }
+
+ /**
+ * create a local composite
+ *
+ * @param parent
+ * @return
+ */
+ protected Composite getEncapsulatedCompo(Composite parent) {
+ Composite compo = new Composite(parent, SWT.NONE);
+ compo.setLayout(new GridLayout());
+ return compo;
+ }
+
+ @Override
+ protected void createPageContents(Composite parent) {
+ FontGroup fontGroupComposite = new FontGroup(parent, getPreferenceKey(), this);
+ addAbstractGroup(fontGroupComposite);
+
+ }
+
+ protected Group getToolbar() {
+ return toolbar;
+ }
+
+ /**
+ * Get the specified preference type associated with this preference page.
+ *
+ * @param preferenceType
+ * an int representing the preference type to retrieve. It must be a value defined in {@link PreferenceConstantHelper}
+ * @return the preference constant used to store the given prefence type.
+ */
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getElementConstant(getTitle(), preferenceType);
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusLinkPreferencePage.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusLinkPreferencePage.java
new file mode 100644
index 00000000000..8fb5c8b00f3
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusLinkPreferencePage.java
@@ -0,0 +1,64 @@
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ * Vincent Lorenzo (CEA-LIst) - bug 335989: [Preferences] [Enhancement] Add a group for labels in each Connection Preference Page
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.pages;
+
+import java.util.TreeMap;
+
+import org.eclipse.papyrus.preferences.ui.ConnectionGroup;
+import org.eclipse.papyrus.preferences.ui.LabelGroup;
+import org.eclipse.papyrus.preferences.ui.LinkColorGroup;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * An abstract implementation of a basic link preference page.
+ *
+ * <p>
+ * This Preference page adds the preference for
+ * <ul>
+ * <li>{@link org.eclipse.gmf.runtime.notation.RoutingStyle#getRouting <em>Routing</em>}</li>
+ * <li>{@link org.eclipse.gmf.runtime.notation.RoutingStyle#getSmoothness <em>Smoothness</em>}</li>
+ * <li>{@link org.eclipse.gmf.runtime.notation.RoutingStyle#isAvoidObstructions <em>Avoid Obstructions</em>}</li>
+ * <li>{@link org.eclipse.gmf.runtime.notation.RoutingStyle#isClosestDistance <em>Closest Distance </em>}</li>
+ * <li>{@link org.eclipse.gmf.runtime.notation.RoutingStyle#getJumpLinkStatus <em>Jump Link Status </em>}</li>
+ * <li>{@link org.eclipse.gmf.runtime.notation.RoutingStyle#getJumpLinkType <em>Jump Link Type</em>}</li>
+ * <li>{@link org.eclipse.gmf.runtime.notation.RoutingStyle#isJumpLinksReverse <em>Jump Links Reverse</em>}</li>
+ * </ul>
+ *
+ * @author tlandre
+ */
+public abstract class AbstractPapyrusLinkPreferencePage extends AbstractPapyrusElementPreferencePage {
+
+
+ @Override
+ protected void createPageContents(Composite parent) {
+ super.createPageContents(parent);
+ // color pref for links
+ LinkColorGroup colorGroupComposite = new LinkColorGroup(parent, getPreferenceKey(), this);
+ addAbstractGroup(colorGroupComposite);
+
+ // router for links
+ ConnectionGroup connectionGroupComposite = new ConnectionGroup(parent, getPreferenceKey(), this);
+ addAbstractGroup(connectionGroupComposite);
+
+ //Label role group
+ if(!getLabelRole().isEmpty()) {
+ LabelGroup compartmentGroup = new LabelGroup(parent, getPreferenceKey(), this, getLabelRole());
+ addAbstractGroup(compartmentGroup);
+ }
+
+ }
+
+ protected TreeMap<String, String> getLabelRole() {
+ return new TreeMap<String, String>();
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusNodePreferencePage.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusNodePreferencePage.java
new file mode 100644
index 00000000000..b5d41a491a1
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusNodePreferencePage.java
@@ -0,0 +1,101 @@
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ * Vincent Lorenzo (CEA LIST) - Add a list for the compartment names
+ * Vincent Lorenzo (CEA-LIst) - bug 335989: [Preferences] [Enhancement] Add a group for labels in each Connection Preference Page
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.pages;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.TreeMap;
+
+import org.eclipse.papyrus.preferences.ui.BackgroundColor;
+import org.eclipse.papyrus.preferences.ui.DecorationGroup;
+import org.eclipse.papyrus.preferences.ui.LabelGroup;
+import org.eclipse.papyrus.preferences.ui.NodeColorGroup;
+import org.eclipse.papyrus.preferences.ui.NodeCompartmentGroup;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * An abstract implementation of a basic node preference page.
+ * <p>
+ * This Preference page adds the preference for {@link org.eclipse.gmf.runtime.notation.FillStyle#getFillColor() <em>FillColor</em>}
+ * </p>
+ *
+ * @author tlandre
+ */
+public abstract class AbstractPapyrusNodePreferencePage extends AbstractPapyrusElementPreferencePage {
+
+ /** the list owning the compartment names for the Node */
+ protected List<String> compartmentsList;
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public AbstractPapyrusNodePreferencePage() {
+ compartmentsList = new ArrayList<String>();
+ initializeCompartmentsList();
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.preferences.pages.AbstractPapyrusElementPreferencePage#createPageContents(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ */
+ @Override
+ protected void createPageContents(Composite parent) {
+ super.createPageContents(parent);
+ NodeColorGroup colorGroupForNodeComposite = new NodeColorGroup(parent, getPreferenceKey(), this);
+ addAbstractGroup(colorGroupForNodeComposite);
+ BackgroundColor backgroundColorGroup = new BackgroundColor(parent, getPreferenceKey(), this);
+ addAbstractGroup(backgroundColorGroup);
+ DecorationGroup decorationGroup = new DecorationGroup(parent, getPreferenceKey(), this);
+ addAbstractGroup(decorationGroup);
+ if(!compartmentsList.isEmpty()) {
+ NodeCompartmentGroup compartmentGroup = new NodeCompartmentGroup(parent, getPreferenceKey(), this, compartmentsList, getCompartmentTitleVisibilityPreferences().keySet(), getPreferenceStore());
+ addAbstractGroup(compartmentGroup);
+ }
+
+ //Label role group
+ if(!getLabelRole().isEmpty()) {
+ LabelGroup compartmentGroup = new LabelGroup(parent, getPreferenceKey(), this, getLabelRole());
+ addAbstractGroup(compartmentGroup);
+ }
+ }
+
+ /**
+ * Initialize {@link #compartmentsList} with the name of the compartment owned by the node
+ */
+ protected void initializeCompartmentsList() {
+ // TODO Auto-generated method stub
+ }
+
+ /**
+ *
+ * @return
+ * the label roles
+ */
+ protected TreeMap<String, String> getLabelRole() {
+ return new TreeMap<String, String>();
+ }
+
+ /**
+ *
+ * @return
+ * the compartment title visibility
+ */
+ protected TreeMap<String, Boolean> getCompartmentTitleVisibilityPreferences() {
+ return new TreeMap<String, Boolean>();
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusPreferencePage.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusPreferencePage.java
new file mode 100644
index 00000000000..6f2805acce7
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/AbstractPapyrusPreferencePage.java
@@ -0,0 +1,242 @@
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.pages;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.papyrus.preferences.Activator;
+import org.eclipse.papyrus.preferences.pages.internal.VisiblePageSingleton;
+import org.eclipse.papyrus.preferences.ui.AbstractGroup;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+
+/**
+ * An abstract implementation of a Preference page.
+ *
+ * This preference page allows clients to define preference page in the preference of Eclipse, and
+ * in the properties of a project in the workspace.
+ * <p>
+ * Clients must implement :
+ * <ul>
+ * <li><code>getBundleId()</code> method in order to define the preference scope (Project or Instance) of the preference page.</li>
+ * <li><code>createPageContents()</code> method to populate the preference page with the different {@link AbstractGroup}. </br>Each group added has to
+ * be declared through the <code>addAbstractGroup(AbstractGroup fe)</code> method</li>
+ * </ul>
+ * </p>
+ */
+public abstract class AbstractPapyrusPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IWorkbenchPropertyPage {
+
+ private IProject project;
+
+ private Set<AbstractGroup> groupSet;
+
+ private String key;
+
+ /**
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
+ */
+ public IAdaptable getElement() {
+ return project;
+ }
+
+ protected void setPreferenceKey(String aKey) {
+ this.key = aKey;
+ }
+
+ protected String getPreferenceKey() {
+ return this.key;
+ }
+
+ public IPreferenceStore getPreferenceStore() {
+ return Activator.getDefault().getPreferenceStore();
+ }
+
+ /**
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
+ */
+ public void setElement(IAdaptable element) {
+ project = (IProject)element.getAdapter(IResource.class);
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
+ */
+ protected IPreferenceStore doGetPreferenceStore() {
+ IPreferenceStore store;
+ if(project != null) {
+ store = new ScopedPreferenceStore(new ProjectScope(project), getBundleId());
+ } else {
+ store = new ScopedPreferenceStore(new InstanceScope(), getBundleId());
+ }
+ return store;
+ }
+
+ /**
+ * Initializes this preference page for the given workbench.
+ *
+ * @param workbench
+ * the workbench
+ *
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ *
+ */
+ public void init(IWorkbench workbench) {
+ // Do nothing
+ }
+
+ /**
+ * Create the Papyrus preference page and inits the different fields editor contained in the
+ * page.
+ * <p>
+ * This method shouldn't be overriden by sub-classes
+ * </p>
+ * {@inheritDoc}
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ // Create the container composite
+ Composite container = new Composite(parent, SWT.NONE);
+ GridLayout containerLayout = new GridLayout();
+ container.setLayout(containerLayout);
+
+ createPageContents(container);
+
+ initGroup();
+
+ return container;
+ }
+
+ /**
+ * Populate the preference page with the different field editor.
+ * <p>
+ * Each field added has to be declared through the <code>addEditorFields(FieldEditor fe)</code> method
+ * </p>
+ *
+ * @param parent
+ * the parent composite
+ */
+ protected abstract void createPageContents(Composite parent);
+
+ /**
+ * Add the given field editor to the page.
+ */
+ protected void addAbstractGroup(AbstractGroup fe) {
+ if(groupSet == null) {
+ groupSet = new HashSet<AbstractGroup>();
+ }
+ groupSet.add(fe);
+ }
+
+ public boolean performOk() {
+ VisiblePageSingleton.getInstance().store();
+ return super.performOk();
+ }
+
+ /**
+ * Stores the values of the fields contained in this page into the preference store.
+ */
+ protected void storePreferences() {
+ if(groupSet != null) {
+ for(AbstractGroup gs : groupSet) {
+ gs.storePreferences();
+ }
+ }
+ }
+
+ /**
+ * Store all preferences
+ */
+ public void storeAllPreferences() {
+ storePreferences();
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+ protected void performDefaults() {
+ loadDefaultPreferences();
+ super.performDefaults();
+ }
+
+ /**
+ * Load the default preferences of the fields contained in this page
+ */
+ private void loadDefaultPreferences() {
+ if(groupSet != null) {
+ for(AbstractGroup gs : groupSet) {
+ gs.loadDefault();
+ }
+ }
+
+ }
+
+ /**
+ * Init groups contained in this page.
+ */
+ private void initGroup() {
+ if(groupSet != null) {
+ for(AbstractGroup gs : groupSet) {
+ gs.setPreferenceStore(getPreferenceStore());
+ gs.load();
+ }
+ }
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ if(groupSet != null) {
+ for(AbstractGroup gs : groupSet) {
+ gs.dispose();
+ }
+ }
+
+
+ }
+
+ @Override
+ public void setVisible(boolean visible) {
+ // TODO Auto-generated method stub
+ if(visible == true) {
+ VisiblePageSingleton.getInstance().setVisiblePage(this);
+ initGroup();
+ }
+ super.setVisible(visible);
+
+ }
+
+ /**
+ * The bundle ID used to defined the preference store
+ *
+ * @return String
+ */
+ protected abstract String getBundleId();
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/DiagramPreferencePage.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/DiagramPreferencePage.java
new file mode 100644
index 00000000000..edd35f217b2
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/DiagramPreferencePage.java
@@ -0,0 +1,179 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.pages;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.gmf.runtime.diagram.ui.preferences.DiagramsPreferencePage;
+import org.eclipse.papyrus.preferences.PapyrusPreferenceStore;
+import org.eclipse.papyrus.preferences.pages.internal.VisiblePageSingleton;
+import org.eclipse.papyrus.preferences.ui.AbstractGroup;
+import org.eclipse.papyrus.preferences.ui.BackgroundColor;
+import org.eclipse.papyrus.preferences.ui.ConnectionGroup;
+import org.eclipse.papyrus.preferences.ui.DecorationGroup;
+import org.eclipse.papyrus.preferences.ui.FontGroup;
+import org.eclipse.papyrus.preferences.ui.NodeColorGroup;
+import org.eclipse.papyrus.preferences.ui.diagram.DiagramBackgroundColor;
+import org.eclipse.papyrus.preferences.ui.diagram.DiagramConnectionGroup;
+import org.eclipse.papyrus.preferences.ui.diagram.DiagramDecorationGroup;
+import org.eclipse.papyrus.preferences.ui.diagram.DiagramFontGroup;
+import org.eclipse.papyrus.preferences.ui.diagram.DiagramNodeColorGroup;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ */
+public class DiagramPreferencePage extends DiagramsPreferencePage {
+
+
+ private Set<AbstractGroup> groupSet;
+
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ initGroup();
+ }
+
+ private String key = null;
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Group contentGroup = new Group(parent, 2);
+ contentGroup.setLayout(new GridLayout(4, false));
+
+ //FontGroup
+ FontGroup fontGroupComposite = new DiagramFontGroup(contentGroup, getPreferenceKey(), this);
+ addAbstractGroup(fontGroupComposite);
+ //color
+ NodeColorGroup colorGroupForNodeComposite = new DiagramNodeColorGroup(contentGroup, getPreferenceKey(), this);
+ addAbstractGroup(colorGroupForNodeComposite);
+
+
+ // router for links
+ ConnectionGroup connectionGroupComposite = new DiagramConnectionGroup(contentGroup, getPreferenceKey(), this);
+ addAbstractGroup(connectionGroupComposite);
+
+ //background
+ BackgroundColor backgroundColorGroup = new DiagramBackgroundColor(contentGroup, getPreferenceKey(), this);
+ addAbstractGroup(backgroundColorGroup);
+
+ DecorationGroup decorationGroupComposite = new DiagramDecorationGroup(contentGroup, getPreferenceKey(), this);
+ addAbstractGroup(decorationGroupComposite);
+ return super.createContents(parent);
+ }
+
+ protected String getPreferenceKey() {
+ return this.key;
+ }
+
+ /**
+ * Init groups contained in this page.
+ */
+ private void initGroup() {
+ if(groupSet != null) {
+ for(AbstractGroup gs : groupSet) {
+ gs.setPreferenceStore(getPreferenceStore());
+ gs.load();
+ }
+ }
+ }
+
+ public boolean performOk() {
+ VisiblePageSingleton.getInstance().store();
+ return super.performOk();
+ }
+
+ /**
+ * Stores the values of the fields contained in this page into the preference store.
+ */
+ public void storePreferences() {
+ if(groupSet != null) {
+ for(AbstractGroup gs : groupSet) {
+ gs.storePreferences();
+ }
+ }
+
+ }
+
+ /**
+ * store all preferences
+ */
+ public void storeAllPreferences() {
+ storePreferences();
+ ((PapyrusPreferenceStore)getPreferenceStore()).deleteAllSubPreference(PreferenceConstantHelper.DIAGRAM_PREFERENCE_PREFIX);
+
+ }
+
+ protected void setPreferenceKey(String aKey) {
+ this.key = aKey;
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ if(groupSet != null) {
+ for(AbstractGroup gs : groupSet) {
+ gs.dispose();
+ }
+ }
+
+
+ }
+
+ /**
+ * Add the given field editor to the page.
+ */
+ protected void addAbstractGroup(AbstractGroup fe) {
+ if(groupSet == null) {
+ groupSet = new HashSet<AbstractGroup>();
+ }
+ groupSet.add(fe);
+ }
+
+ /**
+ * Load the default preferences of the fields contained in this page
+ */
+ private void loadDefaultPreferences() {
+ if(groupSet != null) {
+ for(AbstractGroup gs : groupSet) {
+ gs.loadDefault();
+ }
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+ protected void performDefaults() {
+ loadDefaultPreferences();
+ super.performDefaults();
+ }
+
+ @Override
+ public void setVisible(boolean visible) {
+ // TODO Auto-generated method stub
+ if(visible == true) {
+ VisiblePageSingleton.getInstance().setVisiblePage(this);
+ initGroup();
+ }
+ super.setVisible(visible);
+
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/PapyrusAllDiagramsPreferencePage.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/PapyrusAllDiagramsPreferencePage.java
new file mode 100644
index 00000000000..ff74cdc6928
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/PapyrusAllDiagramsPreferencePage.java
@@ -0,0 +1,126 @@
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ * Patrick Tessier (CEA LIST)- modifications
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.pages;
+
+import org.eclipse.gmf.runtime.notation.JumpLinkStatus;
+import org.eclipse.gmf.runtime.notation.Routing;
+import org.eclipse.gmf.runtime.notation.Smoothness;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.papyrus.preferences.Activator;
+import org.eclipse.papyrus.preferences.PapyrusPreferenceStore;
+import org.eclipse.papyrus.preferences.ui.BackgroundColor;
+import org.eclipse.papyrus.preferences.ui.ConnectionGroup;
+import org.eclipse.papyrus.preferences.ui.DecorationGroup;
+import org.eclipse.papyrus.preferences.ui.DimensionGroup;
+import org.eclipse.papyrus.preferences.ui.FontGroup;
+import org.eclipse.papyrus.preferences.ui.NodeColorGroup;
+import org.eclipse.papyrus.preferences.ui.editor.EditorBackgroundColor;
+import org.eclipse.papyrus.preferences.ui.editor.EditorConnectionGroup;
+import org.eclipse.papyrus.preferences.ui.editor.EditorDecorationGroup;
+import org.eclipse.papyrus.preferences.ui.editor.EditorDimensionGroup;
+import org.eclipse.papyrus.preferences.ui.editor.EditorFontGroup;
+import org.eclipse.papyrus.preferences.ui.editor.EditorNodeColorGroup;
+import org.eclipse.papyrus.preferences.utils.GradientPreferenceConverter;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * The default preference page all element of diagrams
+ *
+ */
+public class PapyrusAllDiagramsPreferencePage extends AbstractPapyrusPreferencePage {
+
+ @Override
+ protected void createPageContents(Composite parent) {
+ Group contentGroup = new Group(parent, 2);
+ contentGroup.setLayout(new GridLayout(4, false));
+
+ //FontGroup
+ FontGroup fontGroupComposite = new EditorFontGroup(contentGroup, getTitle(), this);
+ addAbstractGroup(fontGroupComposite);
+ //color
+ NodeColorGroup colorGroupForNodeComposite = new EditorNodeColorGroup(contentGroup, getTitle(), this);
+ addAbstractGroup(colorGroupForNodeComposite);
+
+
+ // router for links
+ ConnectionGroup connectionGroupComposite = new EditorConnectionGroup(contentGroup, getTitle(), this);
+ addAbstractGroup(connectionGroupComposite);
+
+ //background
+ BackgroundColor backgroundColorGroup = new EditorBackgroundColor(contentGroup, getTitle(), this);
+ addAbstractGroup(backgroundColorGroup);
+
+ DecorationGroup decorationGroupComposite = new EditorDecorationGroup(contentGroup, getTitle(), this);
+ addAbstractGroup(decorationGroupComposite);
+
+ DimensionGroup dimensionGroup = new EditorDimensionGroup(contentGroup, getTitle(), this);
+ addAbstractGroup(dimensionGroup);
+ }
+
+
+ @Override
+ protected String getBundleId() {
+ return Activator.PLUGIN_ID;
+ }
+
+ /**
+ * use to init default preferences at the papyrus level
+ *
+ * @param store
+ * the preference store
+ */
+ public static void initDefaults(IPreferenceStore store) {
+
+ //Nodes
+ PreferenceConverter.setDefault(store, PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.COLOR_FILL), new org.eclipse.swt.graphics.RGB(255, 255, 255));
+ PreferenceConverter.setDefault(store, PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.COLOR_LINE), new org.eclipse.swt.graphics.RGB(0, 0, 0));
+
+ // Set the default for the gradient
+ store.setDefault(PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.GRADIENT_POLICY), false);
+ GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(new org.eclipse.swt.graphics.RGB(255, 255, 255), new org.eclipse.swt.graphics.RGB(0, 0, 0), 0, 0);
+ store.setDefault(PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.COLOR_GRADIENT), gradientPreferenceConverter.getPreferenceValue());
+
+ // Links
+ store.setDefault(PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.SMOOTHNESS), Smoothness.NONE);
+ store.setDefault(PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.JUMPLINK_STATUS), JumpLinkStatus.NONE);
+ store.setDefault(PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.JUMPLINK_TYPE), JumpLinkStatus.NONE);
+ store.setDefault(PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.JUMPLINK_REVERSE), false);
+
+ store.setDefault(PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.ROUTING_STYLE), Routing.MANUAL);
+ store.setDefault(PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.ROUTING_POLICY_OBSTRUCTION), false);
+ store.setDefault(PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.ROUTING_POLICY_DISTANCE), false);
+
+ //decoration
+ store.setDefault(PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.SHADOW), false);
+ store.setDefault(PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.ELEMENTICON), false);
+ store.setDefault(PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.QUALIFIEDNAME), false);
+ //dimension
+ store.setDefault(PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.WIDTH), 100);
+ store.setDefault(PreferenceConstantHelper.getPapyrusEditorConstant(PreferenceConstantHelper.HEIGHT), 100);
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void storeAllPreferences() {
+ super.storeAllPreferences();
+ ((PapyrusPreferenceStore)getPreferenceStore()).deleteAllSubPreference(PreferenceConstantHelper.PAPYRUS_EDITOR_PREFERENCE_PREFIX);
+
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusPathmapsPreferencePage.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusPathmapsPreferencePage.java
new file mode 100644
index 00000000000..65d6fd4649e
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusPathmapsPreferencePage.java
@@ -0,0 +1,73 @@
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.pages.internal;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.gmf.runtime.emf.ui.preferences.PathmapsPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.preferences.Activator;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+
+/**
+ * The Papyrus Pathmaps preference page
+ *
+ * @author tlandre
+ */
+public class PapyrusPathmapsPreferencePage extends PathmapsPreferencePage implements IWorkbenchPropertyPage {
+
+ private IProject project;
+
+ /**
+ * Default constructor
+ */
+ public PapyrusPathmapsPreferencePage() {
+ setPreferenceStore(null);
+ }
+
+ /**
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
+ */
+ public IAdaptable getElement() {
+ return project;
+ }
+
+ /**
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
+ */
+ public void setElement(IAdaptable element) {
+ project = (IProject)element.getAdapter(IResource.class);
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
+ */
+ protected IPreferenceStore doGetPreferenceStore() {
+ IPreferenceStore store;
+ if(project != null) {
+ store = new ScopedPreferenceStore(new ProjectScope(project), getBundleId());
+ } else {
+ store = new ScopedPreferenceStore(new InstanceScope(), getBundleId());
+ }
+ return store;
+ }
+
+ private String getBundleId() {
+ return Activator.PLUGIN_ID;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusPrintingPreferencePage.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusPrintingPreferencePage.java
new file mode 100644
index 00000000000..788295b4c35
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusPrintingPreferencePage.java
@@ -0,0 +1,73 @@
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.pages.internal;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.gmf.runtime.diagram.ui.preferences.PrintingPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.preferences.Activator;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+
+/**
+ * The Papyrus printing preference page
+ *
+ * @author tlandre
+ */
+public class PapyrusPrintingPreferencePage extends PrintingPreferencePage implements IWorkbenchPropertyPage {
+
+ private IProject project;
+
+ /**
+ * Default Constructor
+ */
+ public PapyrusPrintingPreferencePage() {
+ setPreferenceStore(null);
+ }
+
+ /**
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
+ */
+ public IAdaptable getElement() {
+ return project;
+ }
+
+ /**
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
+ */
+ public void setElement(IAdaptable element) {
+ project = (IProject)element.getAdapter(IResource.class);
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
+ */
+ protected IPreferenceStore doGetPreferenceStore() {
+ IPreferenceStore store;
+ if(project != null) {
+ store = new ScopedPreferenceStore(new ProjectScope(project), getBundleId());
+ } else {
+ store = new ScopedPreferenceStore(new InstanceScope(), getBundleId());
+ }
+ return store;
+ }
+
+ private String getBundleId() {
+ return Activator.PLUGIN_ID;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusRulersAndGridPreferencePage.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusRulersAndGridPreferencePage.java
new file mode 100644
index 00000000000..e006c1a1f17
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusRulersAndGridPreferencePage.java
@@ -0,0 +1,72 @@
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.pages.internal;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.gmf.runtime.diagram.ui.preferences.RulerGridPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.preferences.Activator;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+
+/**
+ * The preference page for the rulers and grid
+ *
+ * @author tlandre
+ */
+public class PapyrusRulersAndGridPreferencePage extends RulerGridPreferencePage implements IWorkbenchPropertyPage {
+
+ private IProject project;
+
+ public PapyrusRulersAndGridPreferencePage() {
+ setPreferenceStore(null);
+ }
+
+ /**
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
+ */
+ public IAdaptable getElement() {
+ return project;
+ }
+
+ /**
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
+ */
+ public void setElement(IAdaptable element) {
+ project = (IProject)element.getAdapter(IResource.class);
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
+ */
+ protected IPreferenceStore doGetPreferenceStore() {
+ IPreferenceStore store;
+ if(project != null) {
+ store = new ScopedPreferenceStore(new ProjectScope(project), getBundleId());
+ } else {
+ store = new ScopedPreferenceStore(new InstanceScope(), getBundleId());
+ }
+ return store;
+ }
+
+ /**
+ * @return this bundle ID.
+ */
+ private String getBundleId() {
+ return Activator.PLUGIN_ID;
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusUML2PreferencePage.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusUML2PreferencePage.java
new file mode 100644
index 00000000000..decb64e76d1
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/PapyrusUML2PreferencePage.java
@@ -0,0 +1,53 @@
+/****************************************************************************
+ * Copyright (c) 2008 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.pages.internal;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.preferences.Activator;
+import org.eclipse.papyrus.preferences.pages.AbstractPapyrusPreferencePage;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Represent the main preference page of the Papyrus UML2 editor
+ *
+ * <p>
+ * This class shouldn't be overriden.
+ * </p>
+ *
+ * @author tlandre
+ */
+public class PapyrusUML2PreferencePage extends AbstractPapyrusPreferencePage {
+
+ @Override
+ protected void createPageContents(Composite parent) {
+ // Do nothing
+
+ }
+
+ @Override
+ protected String getBundleId() {
+ return Activator.PLUGIN_ID;
+ }
+
+ /**
+ * Initialize the fields editor of this preference page. This method is call during the
+ * initialization of the preference page.
+ *
+ * @param store
+ * the preference store used
+ */
+ public static void initDefaults(IPreferenceStore store) {
+ // TODO Auto-generated method stub
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/VisiblePageSingleton.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/VisiblePageSingleton.java
new file mode 100644
index 00000000000..5253a2fbe55
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/pages/internal/VisiblePageSingleton.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.pages.internal;
+
+import org.eclipse.jface.preference.IPreferencePage;
+import org.eclipse.papyrus.preferences.pages.AbstractPapyrusPreferencePage;
+import org.eclipse.papyrus.preferences.pages.DiagramPreferencePage;
+
+/**
+ * This singleton has bee created to manage the button ok and apply of preference page.
+ * In the case of button ok pressed, the behavior of eclipse try of apply in the first preference page found.
+ * Here each page has a specific behavior. So to store the preference, the active page is called
+ *
+ */
+public class VisiblePageSingleton {
+
+ private static VisiblePageSingleton instance;
+
+ private IPreferencePage page;
+
+ /**
+ *
+ * @return the instance of the {@link VisiblePageSingleton}
+ */
+ public static VisiblePageSingleton getInstance() {
+ if(instance == null) {
+ instance = new VisiblePageSingleton();
+ }
+ return instance;
+ }
+
+ /**
+ * set the visible page
+ *
+ * @param page
+ * a {@link IPreferencePage} --> {@link DiagramPreferencePage} or {@link AbstractPapyrusPreferencePage}
+ */
+ public void setVisiblePage(IPreferencePage page) {
+ this.page = page;
+ }
+
+ /**
+ *
+ * @return the Visible Page
+ */
+ public IPreferencePage getVisiblePage() {
+ return this.page;
+ }
+
+ /**
+ * call the visisble page in order to store preferences
+ */
+ public void store() {
+ if(this.page != null) {
+ if(this.page instanceof DiagramPreferencePage) {
+ ((DiagramPreferencePage)(this.page)).storeAllPreferences();
+ }
+ if(this.page instanceof AbstractPapyrusPreferencePage) {
+ ((AbstractPapyrusPreferencePage)(this.page)).storeAllPreferences();
+ }
+
+ }
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/AbstractGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/AbstractGroup.java
new file mode 100644
index 00000000000..e2f50523842
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/AbstractGroup.java
@@ -0,0 +1,173 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr
+ * Thibault Landre (Atos Origin)
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * The Class AbstractGroupComposite.
+ */
+public abstract class AbstractGroup extends Composite {
+
+ /** The key to find preference */
+ private String key;
+
+ /**
+ * The fieldsEditor : a set that will contain all editor in the composite. It is in charge of
+ * loading / storing / setting the preference store / loading default of all its contained field
+ * editor
+ */
+ private Set<FieldEditor> fieldsEditor;
+
+ /**
+ * Gets the dialog page.
+ *
+ * @return the dialogPage
+ */
+ protected DialogPage getDialogPage() {
+ return dialogPage;
+ }
+
+ /** The dialog page. */
+ protected DialogPage dialogPage;
+
+ /**
+ * Gets the title.
+ *
+ * @return the title
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * Sets the title.
+ *
+ * @param title
+ * the title to set
+ */
+ protected void setKey(String title) {
+ this.key = title;
+ }
+
+ /**
+ * Instantiates a new abstract group.
+ *
+ * @param parent
+ * the parent of the composite
+ * @param String
+ * the title of the page
+ * @param dialogPage
+ * to set the page in field editor
+ */
+ public AbstractGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, SWT.None);
+ this.key = key;
+ this.dialogPage = dialogPage;
+ this.setLayout(new GridLayout());
+ fieldsEditor = new HashSet<FieldEditor>();
+ }
+
+ /**
+ * Get the specified preference type associated with this preference page.
+ *
+ * @param preferenceType
+ * an int representing the preference type to retrieve. It must be a value defined in {@link PreferenceConstantHelper}
+ *
+ * @return the preference constant used to store the given preference type.
+ */
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getElementConstant(key, preferenceType);
+ }
+
+ /**
+ * Gets an encapsulated compo. This composite is used to contain a FieldEditor and to allow
+ * developers to work with a FieldEditor like Composite element.
+ *
+ * @param parent
+ * the parent
+ *
+ * @return the encapsulated compo
+ */
+ protected final Composite getEncapsulatedCompo(Composite parent) {
+ Composite compo = new Composite(parent, SWT.NONE);
+ compo.setLayout(new GridLayout());
+ return compo;
+ }
+
+ /**
+ * Register field editor. It will add the fieldEditor to a map that will be used to
+ * store/load/loadDefault/set the PreferenceStore of contained fieldEditor
+ *
+ * @param fieldEditor
+ * the fieldEditor to add.
+ */
+ protected void addFieldEditor(FieldEditor fieldEditor) {
+ fieldsEditor.add(fieldEditor);
+ }
+
+ /**
+ * Load preferences of all registered fieldEditors.
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#addFieldEditor(FieldEditor)
+ */
+ public void load() {
+ for(FieldEditor fe : fieldsEditor) {
+ fe.load();
+ }
+ }
+
+ /**
+ * Set the preference store of all registered fieldEditors.
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#addFieldEditor(FieldEditor)
+ */
+ public final void setPreferenceStore(IPreferenceStore store) {
+ for(FieldEditor fe : fieldsEditor) {
+ fe.setPreferenceStore(store);
+ }
+ }
+
+ /**
+ * Load default preferences of all registered fieldEditors.
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#addFieldEditor(FieldEditor)
+ */
+ public final void loadDefault() {
+ for(FieldEditor fe : fieldsEditor) {
+ fe.loadDefault();
+ }
+ }
+
+ /**
+ * Store preferences of the registered fieldEditors.
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#addFieldEditor(FieldEditor)
+ */
+ public final void storePreferences() {
+ for(FieldEditor fe : fieldsEditor) {
+ fe.store();
+ }
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/BackgroundColor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/BackgroundColor.java
new file mode 100644
index 00000000000..d55cf58de67
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/BackgroundColor.java
@@ -0,0 +1,105 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr
+ * Thibault Landre (Atos Origin)
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.papyrus.preferences.Messages;
+import org.eclipse.papyrus.preferences.jface.preference.GradientFieldEditor;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * The Class BackgroundColorGroup is group that contains all editor to manage the gradient and associated color background
+ */
+public class BackgroundColor extends AbstractGroup {
+
+ /**
+ * Instantiates a new background color group.
+ *
+ * @param parent
+ * the parent of the composite
+ * @param key
+ * the key of the preference
+ * @param dialogPage
+ * to set the page in field editor
+ **/
+ public BackgroundColor(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ createContent(parent);
+ }
+
+ /** The use gradient fill editor. */
+ private BooleanFieldEditor useGradientFillEditor;
+
+ /** The gradient fill editor. */
+ private GradientFieldEditor gradientFillEditor;
+
+ /** The title. */
+
+ /**
+ * Creates the content.
+ *
+ * @param parent
+ * the parent
+ */
+ public void createContent(Composite parent) {
+
+ Group fillColorGroup = new Group(parent, SWT.SHADOW_NONE);
+ fillColorGroup.setLayout(new GridLayout(1, false));
+ fillColorGroup.setText(Messages.AbstractPapyrusNodePreferencePage_Gradient);
+
+ Composite useGradientCompo = new Composite(fillColorGroup, SWT.NULL);
+ GridLayout gl = new GridLayout(2, false);
+ gl.marginHeight = 0;
+ useGradientCompo.setLayout(gl);
+
+ Label useGradientLabel = new Label(useGradientCompo, SWT.NULL);
+ useGradientLabel.setText(Messages.AbstractPapyrusNodePreferencePage_Activate);
+ Composite useGradientFillEditorCompo = getEncapsulatedCompo(useGradientCompo);
+ useGradientFillEditor = new BooleanFieldEditor(getPreferenceConstant(PreferenceConstantHelper.GRADIENT_POLICY), "", useGradientFillEditorCompo); //$NON-NLS-1$
+ useGradientFillEditor.setPage(dialogPage);
+
+ addFieldEditor(useGradientFillEditor);
+
+ Composite gradientFillEditorCompo = getEncapsulatedCompo(fillColorGroup);
+ gradientFillEditor = new GradientFieldEditor(getPreferenceConstant(PreferenceConstantHelper.COLOR_GRADIENT), gradientFillEditorCompo);
+ gradientFillEditor.setPage(dialogPage);
+ gradientFillEditor.setEnabled(useGradientFillEditor.getBooleanValue());
+
+ addFieldEditor(gradientFillEditor);
+ useGradientFillEditor.setPropertyChangeListener(new IPropertyChangeListener() {
+
+ public void propertyChange(PropertyChangeEvent event) {
+
+ gradientFillEditor.setEnabled(useGradientFillEditor.getBooleanValue());
+
+
+ }
+ });
+ }
+
+ @Override
+ public void load() {
+ super.load();
+ gradientFillEditor.setEnabled(useGradientFillEditor.getBooleanValue());
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/ConnectionGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/ConnectionGroup.java
new file mode 100644
index 00000000000..d710f9baa7f
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/ConnectionGroup.java
@@ -0,0 +1,178 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr
+ * Thibault Landre (Atos Origin)
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui;
+
+import org.eclipse.gmf.runtime.notation.JumpLinkStatus;
+import org.eclipse.gmf.runtime.notation.JumpLinkType;
+import org.eclipse.gmf.runtime.notation.Routing;
+import org.eclipse.gmf.runtime.notation.Smoothness;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.ComboFieldEditor;
+import org.eclipse.papyrus.preferences.Messages;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * The Class ConnectionGroupComposite constains all field to manage the router of a link
+ */
+public class ConnectionGroup extends AbstractGroup {
+
+ /**
+ * Instantiates a new connection group composite.
+ *
+ * @param parent
+ * the parent of the composite
+ * @param String
+ * the title of the page
+ * @param dialogPage
+ * to set the page in field editor
+ **/
+
+ public ConnectionGroup(Composite parent, String title, DialogPage dialogPage) {
+ super(parent, title, dialogPage);
+ createContent(parent);
+ }
+
+ /** The Constant JUMPLINK_STATUS_COMBOFIELDEDITOR_LABEL. */
+ private static final String JUMPLINK_STATUS_COMBOFIELDEDITOR_LABEL = Messages.AbstractPapyrusLinkPreferencePage_Status;
+
+ /** The Constant JUMPLINK_TYPE_COMBOFIELDEDITOR_LABEL. */
+ private static final String JUMPLINK_TYPE_COMBOFIELDEDITOR_LABEL = Messages.AbstractPapyrusLinkPreferencePage_Type;
+
+ /** The Constant JUMPLINK_REVERSE_BOOLEANFIELDEDITOR_LABEL. */
+ private static final String JUMPLINK_REVERSE_BOOLEANFIELDEDITOR_LABEL = Messages.AbstractPapyrusLinkPreferencePage_ReverseJumpLinks;
+
+ /** The Constant ROUTING_STYLES_COMBOFIELDEDITOR_LABEL. */
+ private static final String ROUTING_STYLES_COMBOFIELDEDITOR_LABEL = Messages.AbstractPapyrusLinkPreferencePage_Styles;
+
+ /** The Constant ROUTING_OBSTRUCTION_POLICY_BOOLEANFIELDEDITOR_LABEL. */
+ private static final String ROUTING_OBSTRUCTION_POLICY_BOOLEANFIELDEDITOR_LABEL = Messages.AbstractPapyrusLinkPreferencePage_AvoidObstructions;
+
+ /** The Constant ROUTING_DISTANCE_POLICY_BOOLEANFIELDEDITOR_LABEL. */
+ private static final String ROUTING_DISTANCE_POLICY_BOOLEANFIELDEDITOR_LABEL = Messages.AbstractPapyrusLinkPreferencePage_ClosestDistance;
+
+ /** The Constant SMOOTHNESS_COMBOFIELDEDITOR_NAMES_AND_VALUES. */
+ private static final String[][] SMOOTHNESS_COMBOFIELDEDITOR_NAMES_AND_VALUES = { { Messages.AbstractPapyrusLinkPreferencePage_None, "" + Smoothness.NONE }, //$NON-NLS-2$
+ { Messages.AbstractPapyrusLinkPreferencePage_Less, "" + Smoothness.LESS }, { Messages.AbstractPapyrusLinkPreferencePage_Normal, "" + Smoothness.NORMAL }, { Messages.AbstractPapyrusLinkPreferencePage_More, "" + Smoothness.MORE } }; //$NON-NLS-2$ //$NON-NLS-4$ //$NON-NLS-6$
+
+ /** The Constant JUMPLINK_STATUS_COMBOFIELDEDITOR_NAMES_AND_VALUES. */
+ private static final String[][] JUMPLINK_STATUS_COMBOFIELDEDITOR_NAMES_AND_VALUES = { { Messages.AbstractPapyrusLinkPreferencePage_None, "" + JumpLinkStatus.NONE }, { Messages.AbstractPapyrusLinkPreferencePage_Below, "" + JumpLinkStatus.BELOW }, //$NON-NLS-2$ //$NON-NLS-4$
+ { Messages.AbstractPapyrusLinkPreferencePage_All, "" + JumpLinkStatus.ALL }, { Messages.AbstractPapyrusLinkPreferencePage_Above, "" + JumpLinkStatus.ABOVE } }; //$NON-NLS-2$ //$NON-NLS-4$
+
+ /** The Constant JUMPLINK_TYPE_COMBOFIELDEDITOR_NAMES_AND_VALUES. */
+ private static final String[][] JUMPLINK_TYPE_COMBOFIELDEDITOR_NAMES_AND_VALUES = { { Messages.AbstractPapyrusLinkPreferencePage_SemiCircle, "" + JumpLinkType.SEMICIRCLE }, { Messages.AbstractPapyrusLinkPreferencePage_Square, "" + JumpLinkType.SQUARE }, //$NON-NLS-2$ //$NON-NLS-4$
+ { Messages.AbstractPapyrusLinkPreferencePage_Chamfered, "" + JumpLinkType.CHAMFERED } }; //$NON-NLS-2$
+
+ // TODO : check if Tree is always a valid possibility
+ /** The Constant ROUTING_STYLES_COMBOFIELDEDITOR_NAMES_AND_VALUES. */
+ private static final String[][] ROUTING_STYLES_COMBOFIELDEDITOR_NAMES_AND_VALUES = { { Messages.AbstractPapyrusLinkPreferencePage_Oblique, "" + Routing.MANUAL }, { Messages.AbstractPapyrusLinkPreferencePage_Rectilinear, "" + Routing.RECTILINEAR }, //$NON-NLS-2$ //$NON-NLS-4$
+ { Messages.AbstractPapyrusLinkPreferencePage_Tree, "" + Routing.TREE } }; //$NON-NLS-2$
+
+ /** The routing styles combo field editor. */
+ private ComboFieldEditor routingStylesComboFieldEditor;
+
+ /** The routing obstruction policy boolean field editor. */
+ private BooleanFieldEditor routingObstructionPolicyBooleanFieldEditor;
+
+ /** The routing distance policy boolean field editor. */
+ private BooleanFieldEditor routingDistancePolicyBooleanFieldEditor;
+
+ /** The jump link reverse boolean field editor. */
+ private BooleanFieldEditor jumpLinkReverseBooleanFieldEditor;
+
+ /** The jump link type combo field editor. */
+ private ComboFieldEditor jumpLinkTypeComboFieldEditor;
+
+ /** The jump link status combo field editor. */
+ private ComboFieldEditor jumpLinkStatusComboFieldEditor;
+
+ /**
+ * Creates the content.
+ *
+ * @param parent
+ * the parent
+ */
+ public void createContent(Composite parent) {
+ Group connectionGroup = new Group(parent, 2);
+ connectionGroup.setLayout(new GridLayout());
+ connectionGroup.setText(Messages.AbstractPapyrusLinkPreferencePage_Connection);
+
+ ComboFieldEditor smoothnessComboFieldEditor = new ComboFieldEditor(getPreferenceConstant(PreferenceConstantHelper.SMOOTHNESS), Messages.AbstractPapyrusLinkPreferencePage_Smoothness, SMOOTHNESS_COMBOFIELDEDITOR_NAMES_AND_VALUES, connectionGroup);
+
+ addFieldEditor(smoothnessComboFieldEditor);
+
+ createRoutingGroup(connectionGroup);
+ createJumpLinkGroup(connectionGroup);
+ }
+
+ /**
+ * Creates the jump link group.
+ *
+ * @param connectionGroup
+ * the connection group
+ */
+
+ private void createJumpLinkGroup(Group connectionGroup) {
+ Group jumpLinkGroup = new Group(connectionGroup, 2);
+ jumpLinkGroup.setLayout(new GridLayout());
+ jumpLinkGroup.setText(Messages.AbstractPapyrusLinkPreferencePage_JUMPLINKS);
+
+ jumpLinkStatusComboFieldEditor = new ComboFieldEditor(getPreferenceConstant(PreferenceConstantHelper.JUMPLINK_STATUS), JUMPLINK_STATUS_COMBOFIELDEDITOR_LABEL, JUMPLINK_STATUS_COMBOFIELDEDITOR_NAMES_AND_VALUES, jumpLinkGroup);
+ jumpLinkStatusComboFieldEditor.setPage(dialogPage);
+
+ addFieldEditor(jumpLinkStatusComboFieldEditor);
+
+ jumpLinkTypeComboFieldEditor = new ComboFieldEditor(getPreferenceConstant(PreferenceConstantHelper.JUMPLINK_TYPE), JUMPLINK_TYPE_COMBOFIELDEDITOR_LABEL, JUMPLINK_TYPE_COMBOFIELDEDITOR_NAMES_AND_VALUES, jumpLinkGroup);
+ jumpLinkTypeComboFieldEditor.setPage(dialogPage);
+
+ addFieldEditor(jumpLinkTypeComboFieldEditor);
+
+ jumpLinkReverseBooleanFieldEditor = new BooleanFieldEditor(getPreferenceConstant(PreferenceConstantHelper.JUMPLINK_REVERSE), JUMPLINK_REVERSE_BOOLEANFIELDEDITOR_LABEL, jumpLinkGroup);
+ jumpLinkReverseBooleanFieldEditor.setPage(dialogPage);
+
+ addFieldEditor(jumpLinkReverseBooleanFieldEditor);
+ }
+
+ /**
+ * Creates the routing group.
+ *
+ * @param connectionGroup
+ * the connection group
+ */
+ private void createRoutingGroup(Group connectionGroup) {
+ Group routingGroup = new Group(connectionGroup, 2);
+ routingGroup.setLayout(new GridLayout());
+ routingGroup.setText(Messages.AbstractPapyrusLinkPreferencePage_Routing);
+
+ routingStylesComboFieldEditor = new ComboFieldEditor(getPreferenceConstant(PreferenceConstantHelper.ROUTING_STYLE), ROUTING_STYLES_COMBOFIELDEDITOR_LABEL, ROUTING_STYLES_COMBOFIELDEDITOR_NAMES_AND_VALUES, routingGroup);
+ routingStylesComboFieldEditor.setPage(dialogPage);
+
+ addFieldEditor(routingStylesComboFieldEditor);
+
+ routingObstructionPolicyBooleanFieldEditor = new BooleanFieldEditor(getPreferenceConstant(PreferenceConstantHelper.ROUTING_POLICY_OBSTRUCTION), ROUTING_OBSTRUCTION_POLICY_BOOLEANFIELDEDITOR_LABEL, routingGroup);
+ routingObstructionPolicyBooleanFieldEditor.setPage(dialogPage);
+
+ addFieldEditor(routingObstructionPolicyBooleanFieldEditor);
+
+ routingDistancePolicyBooleanFieldEditor = new BooleanFieldEditor(getPreferenceConstant(PreferenceConstantHelper.ROUTING_POLICY_DISTANCE), ROUTING_DISTANCE_POLICY_BOOLEANFIELDEDITOR_LABEL, routingGroup);
+ routingDistancePolicyBooleanFieldEditor.setPage(dialogPage);
+
+ addFieldEditor(routingDistancePolicyBooleanFieldEditor);
+
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/DecorationGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/DecorationGroup.java
new file mode 100644
index 00000000000..84cad3c553a
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/DecorationGroup.java
@@ -0,0 +1,87 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.papyrus.preferences.Messages;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * The Class DecorationGroup that display field for shadow, element icon, and qualified name
+ */
+public class DecorationGroup extends AbstractGroup {
+
+ /** The Constant SHADOW_BOOLEANFIELDEDITOR_LABEL. */
+ protected static final String SHADOW_BOOLEANFIELDEDITOR_LABEL = "Shadow";
+
+ /** The Constant ELEMENTICON_BOOLEANFIELDEDITOR_LABEL. */
+ private static final String ELEMENTICON_BOOLEANFIELDEDITOR_LABEL = "Element icon";
+
+ /** The Constant QUALIFIEDNAME_BOOLEANFIELDEDITOR_LABEL. */
+ private static final String QUALIFIEDNAME_BOOLEANFIELDEDITOR_LABEL = "Qualified name";
+
+ /** The shadow fied editor. */
+ protected BooleanFieldEditor shadowFiedEditor;
+
+ /** The element icon. */
+ protected BooleanFieldEditor elementIcon;
+
+ /** The qualifiedname. */
+ protected BooleanFieldEditor qualifiedname;
+
+ /**
+ * Instantiates a new decoration group.
+ *
+ * @param parent
+ * the parent
+ * @param key
+ * the key
+ * @param dialogPage
+ * the dialog page
+ */
+ public DecorationGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ createContent(parent);
+ }
+
+ /**
+ * Creates the content.
+ *
+ * @param parent
+ * the parent
+ */
+ public void createContent(Composite parent) {
+ Group decorationGroup = new Group(parent, 2);
+ decorationGroup.setLayout(new GridLayout());
+ decorationGroup.setText(Messages.DecorationGroup_Name);
+
+ shadowFiedEditor = new BooleanFieldEditor(getPreferenceConstant(PreferenceConstantHelper.SHADOW), SHADOW_BOOLEANFIELDEDITOR_LABEL, decorationGroup);
+ shadowFiedEditor.setPage(dialogPage);
+
+ addFieldEditor(shadowFiedEditor);
+
+ elementIcon = new BooleanFieldEditor(getPreferenceConstant(PreferenceConstantHelper.ELEMENTICON), ELEMENTICON_BOOLEANFIELDEDITOR_LABEL, decorationGroup);
+ elementIcon.setPage(dialogPage);
+ addFieldEditor(elementIcon);
+
+ qualifiedname = new BooleanFieldEditor(getPreferenceConstant(PreferenceConstantHelper.QUALIFIEDNAME), QUALIFIEDNAME_BOOLEANFIELDEDITOR_LABEL, decorationGroup);
+ qualifiedname.setPage(dialogPage);
+ addFieldEditor(qualifiedname);
+
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/DimensionGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/DimensionGroup.java
new file mode 100644
index 00000000000..16a04770231
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/DimensionGroup.java
@@ -0,0 +1,79 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.papyrus.preferences.Messages;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class DimensionGroup that display fields for the the dimension of a node (width, height)
+ */
+public class DimensionGroup extends AbstractGroup {
+
+ /** The Constant HEIGHT_INTFIELDEDITOR_LABEL. */
+ private static final String HEIGHT_INTFIELDEDITOR_LABEL = "height";
+
+ /** The Constant WIDTH_INTFIELDEDITOR_LABEL. */
+ private static final String WIDTH_INTFIELDEDITOR_LABEL = "width";
+
+ /** The width fied editor. */
+ protected IntegerFieldEditor widthFiedEditor;
+
+ /** The height fied editor. */
+ protected IntegerFieldEditor heightFiedEditor;
+
+ /**
+ * Instantiates a new dimension group.
+ *
+ * @param parent
+ * the parent
+ * @param key
+ * the key
+ * @param dialogPage
+ * the dialog page
+ */
+ public DimensionGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ createContent(parent);
+ }
+
+ /**
+ * Creates the content.
+ *
+ * @param parent
+ * the parent
+ */
+ public void createContent(Composite parent) {
+ Group decorationGroup = new Group(parent, 4);
+ decorationGroup.setLayout(new GridLayout());
+ decorationGroup.setText(Messages.DimensionGroupName);
+
+ widthFiedEditor = new IntegerFieldEditor(getPreferenceConstant(PreferenceConstantHelper.WIDTH), WIDTH_INTFIELDEDITOR_LABEL, decorationGroup);
+ widthFiedEditor.setPage(dialogPage);
+
+ addFieldEditor(widthFiedEditor);
+
+ heightFiedEditor = new IntegerFieldEditor(getPreferenceConstant(PreferenceConstantHelper.HEIGHT), HEIGHT_INTFIELDEDITOR_LABEL, decorationGroup);
+ heightFiedEditor.setPage(dialogPage);
+
+ addFieldEditor(heightFiedEditor);
+
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/FontGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/FontGroup.java
new file mode 100644
index 00000000000..d7eddb40306
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/FontGroup.java
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr
+ * Thibault Landre (Atos Origin)
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.Messages;
+import org.eclipse.papyrus.preferences.jface.preference.FontFieldEditor;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * The Class FontGroupComposite contains a field to manage preference to display a text in a label
+ */
+public class FontGroup extends AbstractGroup {
+
+ /** The FONT Group label **/
+ private static final String FONT_GROUPBOX_LABEL = Messages.AbstractPapyrusElementPreferencePage_Font;
+
+ /** The font field editor. */
+ protected FontFieldEditor fontFieldEditor;
+
+ /**
+ * Instantiates a new font group composite.
+ *
+ * @param parent
+ * the parent of the composite
+ * @param key
+ * the key of the preference
+ * @param dialogPage
+ * to set the page in field editor
+ **/
+ public FontGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ createContent(parent);
+ }
+
+ /**
+ * Creates the content.
+ *
+ * @param parent
+ * the parent
+ */
+ protected void createContent(Composite parent) {
+ Group fontGroup = new Group(parent, SWT.SHADOW_NONE);
+ fontGroup.setLayout(new GridLayout(1, true));
+ fontGroup.setText(FONT_GROUPBOX_LABEL);
+ fontFieldEditor = new FontFieldEditor(getPreferenceConstant(PreferenceConstantHelper.FONT), fontGroup);
+
+ addFieldEditor(fontFieldEditor);
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/LabelGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/LabelGroup.java
new file mode 100644
index 00000000000..b15ac2a91a0
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/LabelGroup.java
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.TreeMap;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.preferences.Activator;
+import org.eclipse.papyrus.preferences.messages.Messages;
+import org.eclipse.papyrus.preferences.ui.editor.CLabelBooleanFieldEditor;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * The class LabelGroup to manage the property of the label
+ *
+ *
+ *
+ */
+public class LabelGroup extends AbstractGroup {
+
+ /**
+ * the map owning the roles and their icons
+ */
+ private TreeMap<String, String> myRoles;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parent
+ * the parent composite
+ * @param preferenceKey
+ * the preference key
+ * @param dialogPage
+ * the dialog page
+ * @param roles
+ * the roles for the labels
+ */
+ public LabelGroup(Composite parent, String preferenceKey, DialogPage dialogPage, TreeMap<String, String> roles) {
+ super(parent, preferenceKey, dialogPage);
+ this.myRoles = roles;
+ createContent(parent);
+ }
+
+ /**
+ * create the content.
+ *
+ * @param parent
+ * : the parent composite
+ */
+ protected void createContent(Composite parent) {
+ Group group = new Group(parent, SWT.NONE);
+ group.setLayout(new GridLayout());
+ group.setText(Messages.LabelGroup_Labels_To_Display);
+ for(String role : myRoles.keySet()) {
+ String key = PreferenceConstantHelper.getLabelElementConstant(getKey(), role, PreferenceConstantHelper.LABEL_VISIBILITY);
+ Image im = null;
+ String iconPath = myRoles.get(role);
+ if(iconPath != null && iconPath != "") { //$NON-NLS-1$
+ try {
+ im = ImageDescriptor.createFromURL(new URL(iconPath)).createImage();
+ } catch (MalformedURLException e) {
+ Activator.log.error("I can't find the following image " + myRoles.get(role), e); //$NON-NLS-1$
+ }
+ }
+ CLabelBooleanFieldEditor editor = new CLabelBooleanFieldEditor(key, role, im, group);
+ editor.setPage(dialogPage);
+ addFieldEditor(editor);
+ }
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/LinkColorGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/LinkColorGroup.java
new file mode 100644
index 00000000000..e4ff387a1ca
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/LinkColorGroup.java
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr
+ * Thibault Landre (Atos Origin)
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui;
+
+import org.eclipse.gmf.runtime.diagram.ui.properties.internal.l10n.DiagramUIPropertiesImages;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.Messages;
+import org.eclipse.papyrus.preferences.jface.preference.ColorFieldEditor;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * The Class LinkColorGroup contains editor to edit preference of link color
+ */
+public class LinkColorGroup extends AbstractGroup {
+
+ /** The font color editor. */
+ protected ColorFieldEditor fontColorEditor;
+
+ /** The line color editor. */
+ protected ColorFieldEditor lineColorEditor;
+
+ /** The toolbar. */
+ protected Group toolbar;
+
+ /**
+ * creation of a colorGroup Composite.
+ *
+ * @param parent
+ * the parent of the composite
+ * @param dialogPage
+ * to set the page in field editor
+ * @param title
+ * the title
+ */
+
+ public LinkColorGroup(Composite parent, String title, DialogPage dialogPage) {
+ super(parent, title, dialogPage);
+ createContent(parent);
+ }
+
+ /**
+ * Gets the toolbar.
+ *
+ * @return the group that contains editors
+ */
+ protected Group getToolbar() {
+ return toolbar;
+ }
+
+ /**
+ * Creates the content.
+ *
+ * @param parent
+ * the parent
+ */
+ protected void createContent(Composite parent) {
+ toolbar = new Group(parent, SWT.SHADOW_NONE);
+ toolbar.setText(Messages.AbstractPapyrusElementPreferencePage_Colors);
+ toolbar.setLayout(new GridLayout(3, false));
+
+ Composite fontColorEditorCompo = getEncapsulatedCompo(toolbar);
+ fontColorEditor = new ColorFieldEditor(getPreferenceConstant(PreferenceConstantHelper.COLOR_FONT), DiagramUIPropertiesImages.get(DiagramUIPropertiesImages.IMG_FONT_COLOR), fontColorEditorCompo);
+ fontColorEditor.setPage(dialogPage);
+
+ addFieldEditor(fontColorEditor);
+
+ Composite lineColorEditorCompo = getEncapsulatedCompo(toolbar);
+ lineColorEditor = new ColorFieldEditor(getPreferenceConstant(PreferenceConstantHelper.COLOR_LINE), DiagramUIPropertiesImages.get(DiagramUIPropertiesImages.IMG_LINE_COLOR), lineColorEditorCompo);
+
+ lineColorEditor.setPage(dialogPage);
+
+ addFieldEditor(lineColorEditor);
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/NodeColorGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/NodeColorGroup.java
new file mode 100644
index 00000000000..aa4f25a0d1e
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/NodeColorGroup.java
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * Copyright (c) 2009 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr
+ * Thibault Landre (Atos Origin)
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui;
+
+import org.eclipse.gmf.runtime.diagram.ui.properties.internal.l10n.DiagramUIPropertiesImages;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.jface.preference.ColorFieldEditor;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * The Class NodeColorGroup contains field editor to manage color of a node
+ */
+public class NodeColorGroup extends LinkColorGroup {
+
+ /** The font color editor. */
+ protected ColorFieldEditor fontColorEditor;
+
+ /** The line color editor. */
+ protected ColorFieldEditor lineColorEditor;
+
+ /** The fill color editor. */
+ protected ColorFieldEditor fillColorEditor;
+
+ /**
+ * create a composite to display the group color for a node.
+ *
+ * @param parent
+ * the parent of the composite
+ * @param dialogPage
+ * to set the page in field editor
+ * @param title
+ * the title
+ */
+
+
+ public NodeColorGroup(Composite parent, String title, DialogPage dialogPage) {
+ super(parent, title, dialogPage);
+ }
+
+ /**
+ * create the content.
+ *
+ * @param parent
+ * : the parent composite
+ */
+ protected void createContent(Composite parent) {
+ super.createContent(parent);
+
+ Composite fillColorEditorCompo = getEncapsulatedCompo(getToolbar());
+ fillColorEditor = new ColorFieldEditor(getPreferenceConstant(PreferenceConstantHelper.COLOR_FILL), DiagramUIPropertiesImages.get(DiagramUIPropertiesImages.IMG_FILL_COLOR), fillColorEditorCompo);
+ fillColorEditor.setPage(dialogPage);
+
+ addFieldEditor(fillColorEditor);
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/NodeCompartmentGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/NodeCompartmentGroup.java
new file mode 100644
index 00000000000..34aac7c61d1
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/NodeCompartmentGroup.java
@@ -0,0 +1,136 @@
+/*****************************************************************************
+ * Copyright (c) 2009-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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Tatiana Fesenko (CEA LIST) - Bug 330772 - [Usability] Allow to configure visibility of name of compartments in the preferences pages
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.preferences.ui;
+
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.gmf.runtime.common.ui.preferences.CheckBoxFieldEditor;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.SWT;
+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.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * The Class NodeCompartmentGroup contains field editor to manage the display of the compartment
+ */
+public class NodeCompartmentGroup extends AbstractGroup {
+
+ /** the list owning the compartment names for the UML element */
+ private final List<String> myCompartments;
+
+ private final IPreferenceStore myPreferenceStore;
+
+ private final Set<String> compartmentsWithTitle;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parent
+ * @param title
+ * @param dialogPage
+ * @param compartmentsName
+ */
+ public NodeCompartmentGroup(Composite parent, String title, DialogPage dialogPage, List<String> compartmentsName, Set<String> compartmentsWithTitle, IPreferenceStore store) {
+ super(parent, title, dialogPage);
+ this.myCompartments = compartmentsName;
+ this.compartmentsWithTitle = compartmentsWithTitle;
+ myPreferenceStore = store;
+ createContent(parent);
+ }
+
+ /**
+ * create the content.
+ *
+ * @param parent
+ * : the parent composite
+ */
+ protected void createContent(Composite parent) {
+ for(String compartment : myCompartments) {
+ addCompartmentVisibilityGroup(parent, compartment);
+ }
+ }
+
+ private void addCompartmentVisibilityGroup(Composite parent, String compartment) {
+ // show Compartment Visibility and CompartmentName Visibility items in the same row
+ Group group = new Group(parent, SWT.NONE);
+ group.setLayout(new GridLayout(2, true));
+ group.setText(compartment);
+
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 2;
+ group.setLayoutData(gridData);
+
+ String compartmentVisibilityPreference = PreferenceConstantHelper.getCompartmentElementConstant(getKey(), compartment, PreferenceConstantHelper.COMPARTMENT_VISIBILITY);
+ String compartmentVisibilityLabel = "Show compartment";
+ Button showCompartmentButton = addCheckboxField(group, compartmentVisibilityPreference, compartmentVisibilityLabel);
+
+ if(this.compartmentsWithTitle.contains(compartment)) {
+ String compartmentNameVisibilityPreference = PreferenceConstantHelper.getCompartmentElementConstant(getKey(), compartment, PreferenceConstantHelper.COMPARTMENT_NAME_VISIBILITY);
+ String compartmentNameVisibilityLabel = "Show title";
+ Button showNameButton = addCheckboxField(group, compartmentNameVisibilityPreference, compartmentNameVisibilityLabel);
+
+ boolean showCompartmentIsNotChecked = !myPreferenceStore.getBoolean(compartmentVisibilityPreference);
+ if(showCompartmentIsNotChecked) {
+ showNameButton.setEnabled(false);
+ }
+ createDependency(showCompartmentButton, new Control[]{ showNameButton });
+ }
+ }
+
+
+ private Button addCheckboxField(Composite parent, String preferenceKey, String label) {
+ // show Compartment Visibility and CompartmentName Visibility items in the same row
+ // as CheckBoxFieldEditor resets layout data to fit the grid we create this stub plate
+ // @see #doFillIntoGrid
+ Composite plate = new Composite(parent, SWT.NONE);
+ plate.setLayoutData(new GridData());
+
+ CheckBoxFieldEditor compartmentVisibilityBooleanFieldEditor = new CheckBoxFieldEditor(preferenceKey, label, plate);
+ Button checkbox = compartmentVisibilityBooleanFieldEditor.getCheckbox();
+ compartmentVisibilityBooleanFieldEditor.setPage(getDialogPage());
+ addFieldEditor(compartmentVisibilityBooleanFieldEditor);
+ return checkbox;
+ }
+
+ private void createDependency(final Button master, final Control[] slaves) {
+ SelectionListener dependencyListener = new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ boolean state = master.getSelection();
+ for(int i = 0; i < slaves.length; i++) {
+ slaves[i].setEnabled(state);
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ };
+ master.addSelectionListener(dependencyListener);
+ }
+
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/OrderedCompartmentGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/OrderedCompartmentGroup.java
new file mode 100644
index 00000000000..b79a977036e
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/OrderedCompartmentGroup.java
@@ -0,0 +1,135 @@
+/*****************************************************************************
+ * Copyright (c) 2009-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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Tatiana Fesenko (CEA LIST) - Bug 330772 - [Usability] Allow to configure visibility of name of compartments in the preferences pages
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.preferences.ui;
+
+import java.util.List;
+
+import org.eclipse.gmf.runtime.common.ui.preferences.CheckBoxFieldEditor;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.SWT;
+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.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * The Class NodeCompartmentGroup contains field editor to manage the display of the compartment
+ */
+public class OrderedCompartmentGroup extends AbstractGroup {
+
+ /** the list owning the compartment names for the UML element */
+ private final List<String> compartmentsName;
+
+ private final IPreferenceStore store;
+
+ private final List<String> compartmentsWithTitle;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parent
+ * @param title
+ * @param dialogPage
+ * @param compartmentsName
+ */
+ public OrderedCompartmentGroup(Composite parent, String title, DialogPage dialogPage, List<String> compartmentsName, List<String> compartmentsWithTitle, IPreferenceStore store) {
+ super(parent, title, dialogPage);
+ this.compartmentsName = compartmentsName;
+ this.compartmentsWithTitle = compartmentsWithTitle;
+ this.store = store;
+ createContent(parent);
+ }
+
+ /**
+ * create the content.
+ *
+ * @param parent
+ * : the parent composite
+ */
+ protected void createContent(Composite parent) {
+ for(String name : compartmentsName) {
+ addCompartmentVisibilityGroup(parent, name);
+ }
+ }
+
+ private void addCompartmentVisibilityGroup(Composite parent, String compartmentName) {
+ // show Compartment Visibility and CompartmentName Visibility items in the same row
+ Group group = new Group(parent, SWT.NONE);
+ group.setLayout(new GridLayout(2, true));
+ group.setText(compartmentName);
+
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalSpan = 2;
+ group.setLayoutData(gridData);
+
+ String compartmentVisibilityPreference = PreferenceConstantHelper.getCompartmentElementConstant(getKey(), compartmentName, PreferenceConstantHelper.COMPARTMENT_VISIBILITY);
+ String compartmentVisibilityLabel = "Show compartment";
+ Button showCompartmentButton = addCheckboxField(group, compartmentVisibilityPreference, compartmentVisibilityLabel);
+
+ if(this.compartmentsWithTitle.contains(compartmentName)) {
+ String compartmentNameVisibilityPreference = PreferenceConstantHelper.getCompartmentElementConstant(getKey(), compartmentName, PreferenceConstantHelper.COMPARTMENT_NAME_VISIBILITY);
+ String compartmentNameVisibilityLabel = "Show title";
+ Button showNameButton = addCheckboxField(group, compartmentNameVisibilityPreference, compartmentNameVisibilityLabel);
+
+ boolean showCompartmentIsNotChecked = !store.getBoolean(compartmentVisibilityPreference);
+ if(showCompartmentIsNotChecked) {
+ showNameButton.setEnabled(false);
+ }
+ createDependency(showCompartmentButton, new Control[]{ showNameButton });
+ }
+ }
+
+
+ private Button addCheckboxField(Composite parent, String preferenceKey, String label) {
+ // show Compartment Visibility and CompartmentName Visibility items in the same row
+ // as CheckBoxFieldEditor resets layout data to fit the grid we create this stub plate
+ // @see #doFillIntoGrid
+ Composite plate = new Composite(parent, SWT.NONE);
+ plate.setLayoutData(new GridData());
+
+ CheckBoxFieldEditor compartmentVisibilityBooleanFieldEditor = new CheckBoxFieldEditor(preferenceKey, label, plate);
+ Button checkbox = compartmentVisibilityBooleanFieldEditor.getCheckbox();
+ compartmentVisibilityBooleanFieldEditor.setPage(getDialogPage());
+ addFieldEditor(compartmentVisibilityBooleanFieldEditor);
+ return checkbox;
+ }
+
+ private void createDependency(final Button master, final Control[] slaves) {
+ SelectionListener dependencyListener = new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ boolean state = master.getSelection();
+ for(int i = 0; i < slaves.length; i++) {
+ slaves[i].setEnabled(state);
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ };
+ master.addSelectionListener(dependencyListener);
+ }
+
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/OrderedLabelGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/OrderedLabelGroup.java
new file mode 100644
index 00000000000..7037b306ff1
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/OrderedLabelGroup.java
@@ -0,0 +1,110 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.papyrus.preferences.Activator;
+import org.eclipse.papyrus.preferences.messages.Messages;
+import org.eclipse.papyrus.preferences.ui.editor.CLabelBooleanFieldEditor;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+/**
+ * The class LabelGroup to manage the property of the label
+ */
+public class OrderedLabelGroup extends AbstractGroup {
+
+ /**
+ * the map owning the roles and their icons
+ */
+ private Map<String, String> myRoles = new LinkedHashMap<String, String>();
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parent
+ * the parent composite
+ * @param preferenceKey
+ * the preference key
+ * @param dialogPage
+ * the dialog page
+ * @param roles
+ * the roles for the labels
+ */
+ public OrderedLabelGroup(Composite parent, String preferenceKey, DialogPage dialogPage, Map<String, String> roles) {
+ super(parent, preferenceKey, dialogPage);
+ this.myRoles = roles;
+ createContent(parent);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parent
+ * the parent composite
+ * @param preferenceKey
+ * the preference key
+ * @param dialogPage
+ * the dialog page
+ * @param roles
+ * the roles for the labels
+ */
+ public OrderedLabelGroup(Composite parent, String preferenceKey, DialogPage dialogPage, List<String> roles) {
+ super(parent, preferenceKey, dialogPage);
+ for(String role : roles) {
+ myRoles.put(role, ""); //$NON-NLS-1$
+ }
+ createContent(parent);
+ }
+
+ /**
+ * create the content.
+ *
+ * @param parent
+ * : the parent composite
+ */
+ protected void createContent(Composite parent) {
+ Group group = new Group(parent, SWT.NONE);
+ group.setLayout(new GridLayout());
+ group.setText(Messages.LabelGroup_Labels_To_Display);
+ for(String role : myRoles.keySet()) {
+ String key = PreferenceConstantHelper.getLabelElementConstant(getKey(), role, PreferenceConstantHelper.LABEL_VISIBILITY);
+ Image im = null;
+ String iconPath = myRoles.get(role);
+ if(iconPath != null && iconPath != "") { //$NON-NLS-1$
+ try {
+ im = ImageDescriptor.createFromURL(new URL(iconPath)).createImage();
+ } catch (MalformedURLException e) {
+ Activator.log.error("I can't find the following image " + myRoles.get(role), e); //$NON-NLS-1$
+ }
+ }
+ CLabelBooleanFieldEditor editor = new CLabelBooleanFieldEditor(key, role, im, group);
+ editor.setPage(dialogPage);
+ addFieldEditor(editor);
+ }
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramBackgroundColor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramBackgroundColor.java
new file mode 100644
index 00000000000..fbb6f89249b
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramBackgroundColor.java
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.diagram;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.ui.BackgroundColor;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * this class is a background group specialized for the level diagram
+ *
+ */
+public class DiagramBackgroundColor extends BackgroundColor {
+
+ /**
+ * constructor
+ *
+ * @param parent
+ * the composite patent
+ * @param key
+ * the preference key the kind of diagram
+ * @param dialogPage
+ */
+ public DiagramBackgroundColor(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ }
+
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getDiagramConstant(getKey(), preferenceType);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramConnectionGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramConnectionGroup.java
new file mode 100644
index 00000000000..092e0ccf813
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramConnectionGroup.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.diagram;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.ui.ConnectionGroup;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * this clas is a specialiezation of the connection for the diagram level
+ *
+ */
+public class DiagramConnectionGroup extends ConnectionGroup {
+
+ /**
+ * constructor
+ *
+ * @param parent
+ * the composite parent
+ * @param key
+ * the preference key the kind of diagram
+ * @param dialogPage
+ */
+ public DiagramConnectionGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ // TODO Auto-generated constructor stub
+ }
+
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getDiagramConstant(getKey(), preferenceType);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramDecorationGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramDecorationGroup.java
new file mode 100644
index 00000000000..bb9ae473b81
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramDecorationGroup.java
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.diagram;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.ui.DecorationGroup;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.widgets.Composite;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class DiagramDecorationGroupthat specialize Decoration group for the diagram level
+ */
+public class DiagramDecorationGroup extends DecorationGroup {
+
+ /**
+ * Instantiates a new diagram decoration group.
+ *
+ * @param parent
+ * the parent
+ * @param key
+ * the prefix preference key the kind of diagram
+ * @param dialogPage
+ * the dialog page
+ */
+ public DiagramDecorationGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#getPreferenceConstant(int)
+ */
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getDiagramConstant(getKey(), preferenceType);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramDimensionGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramDimensionGroup.java
new file mode 100644
index 00000000000..a1f9886ae1b
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramDimensionGroup.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.diagram;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.ui.DimensionGroup;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * The Class DiagramDimensionGroup specialized at the level diagra
+ */
+public class DiagramDimensionGroup extends DimensionGroup {
+
+ /**
+ * Instantiates a new diagram dimension group.
+ *
+ * @param parent
+ * the composite parent
+ * @param key
+ * the key the kind of the diagram
+ * @param dialogPage
+ * the dialog page
+ */
+ public DiagramDimensionGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#getPreferenceConstant(int)
+ */
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getDiagramConstant(getKey(), preferenceType);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramFontGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramFontGroup.java
new file mode 100644
index 00000000000..5fb1fa0998c
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramFontGroup.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.diagram;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.ui.FontGroup;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * The Class DiagramFontGroup specialized at the level diagram
+ */
+public class DiagramFontGroup extends FontGroup {
+
+ /**
+ * Instantiates a new diagram font group.
+ *
+ * @param parent
+ * the parent composite
+ * @param key
+ * the kind of the diagram
+ * @param dialogPage
+ * the dialog page
+ */
+ public DiagramFontGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#getPreferenceConstant(int)
+ */
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getDiagramConstant(getKey(), preferenceType);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramLinkColorGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramLinkColorGroup.java
new file mode 100644
index 00000000000..2de215efe4c
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramLinkColorGroup.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.diagram;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.ui.LinkColorGroup;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * The Class DiagramLinkColorGroup specialized at the diagram level
+ */
+public class DiagramLinkColorGroup extends LinkColorGroup {
+
+ /**
+ * Instantiates a new diagram link color group.
+ *
+ * @param parent
+ * the parent composite
+ * @param key
+ * the tkind of the diagram
+ * @param dialogPage
+ * the dialog page
+ */
+ public DiagramLinkColorGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#getPreferenceConstant(int)
+ */
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getDiagramConstant(getKey(), preferenceType);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramNodeColorGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramNodeColorGroup.java
new file mode 100644
index 00000000000..b7a95dad6df
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/diagram/DiagramNodeColorGroup.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.diagram;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.ui.NodeColorGroup;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * The Class DiagramNodeColorGroup specilized at the diagram level
+ */
+public class DiagramNodeColorGroup extends NodeColorGroup {
+
+ /**
+ * Instantiates a new diagram node color group.
+ *
+ * @param parent
+ * the parent composite
+ * @param key
+ * the kind of the diagram
+ * @param dialogPage
+ * the dialog page
+ */
+ public DiagramNodeColorGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#getPreferenceConstant(int)
+ */
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getDiagramConstant(getKey(), preferenceType);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/dialog/AbstractPreferenceKeyDialog.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/dialog/AbstractPreferenceKeyDialog.java
new file mode 100644
index 00000000000..fd6e49837c2
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/dialog/AbstractPreferenceKeyDialog.java
@@ -0,0 +1,220 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.dialog;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableColorProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.preferences.Activator;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+/**
+ * The Class AbstractPreferenceKeyDialog display all preference key that are given in parameters
+ */
+public class AbstractPreferenceKeyDialog extends org.eclipse.jface.dialogs.StatusDialog {
+
+ /** The key table. */
+ protected Table keyTable;
+
+ /** The table viewer. */
+ protected TableViewer tableViewer;
+
+ /** The keys. */
+ protected String[] keys;
+
+ /**
+ * Instantiates a new abstract preference key dialog.
+ *
+ * @param keys
+ * the array of preference jy to display
+ */
+ public AbstractPreferenceKeyDialog(String[] keys) {
+ super(new Shell());
+ this.keys = keys;
+ setStatusLineAboveButtons(true);
+ updateStatus(new Status(IStatus.INFO, Activator.PLUGIN_ID, "Would you like to overload those preferences?"));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite)super.createDialogArea(parent);
+ keyTable = new Table(composite, SWT.CHECK | SWT.BORDER);
+ tableViewer = new TableViewer(keyTable);
+ tableViewer.setLabelProvider(new KeyLabelProvider());
+ tableViewer.setContentProvider(new KeyContentProvider());
+
+ TableColumn column = new TableColumn(keyTable, SWT.NONE);
+ column.setWidth(150);
+ column.setText("Pref. kind ");
+
+ column = new TableColumn(keyTable, SWT.NONE);
+ column.setWidth(90);
+ column.setText("Level");
+
+ column = new TableColumn(keyTable, SWT.NONE);
+ column.setWidth(200);
+ column.setText("Localization");
+ tableViewer.setInput(keys);
+ keyTable.setHeaderVisible(true);
+
+
+ return composite;
+
+ }
+
+ /**
+ * The Class KeyLabelProvider.
+ */
+ protected class KeyLabelProvider extends LabelProvider implements ITableLabelProvider, ITableColorProvider {
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITableColorProvider#getForeground(java.lang.Object, int)
+ */
+ public Color getForeground(Object element, int columnIndex) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITableColorProvider#getBackground(java.lang.Object, int)
+ */
+ public Color getBackground(Object element, int columnIndex) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ */
+ public Image getColumnImage(Object element, int columnIndex) {
+ if(columnIndex == 0) {
+ if(element.toString().startsWith(PreferenceConstantHelper.DIAGRAM_ELEMENT)) {
+ return Activator.getPluginIconImage(Activator.PLUGIN_ID, "/icons/pref.gif");
+ }
+ if(element.toString().startsWith(PreferenceConstantHelper.DIAGRAM_PREFERENCE_PREFIX)) {
+ return Activator.getPluginIconImage(Activator.PLUGIN_ID, "/icons/diag.gif");
+ }
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ public String getColumnText(Object element, int columnIndex) {
+ String initialKey = element.toString();
+ String out = initialKey.toString();
+ if(columnIndex == 0) {
+ out = out.substring(out.indexOf(".") + 1, out.length()).toUpperCase();
+ }
+ if(columnIndex == 1) {
+ if(element.toString().startsWith(PreferenceConstantHelper.DIAGRAM_ELEMENT)) {
+ return "ELEMENT";
+ }
+ if(element.toString().startsWith(PreferenceConstantHelper.DIAGRAM_PREFERENCE_PREFIX)) {
+ return "DIAGRAM";
+ }
+ }
+ if(columnIndex == 2) {
+ if(initialKey.startsWith(PreferenceConstantHelper.DIAGRAM_ELEMENT)) {
+ out = initialKey.toString().replaceAll(PreferenceConstantHelper.DIAGRAM_ELEMENT, "");
+ // Reorganize display
+ if(out.indexOf(".") > 0) {
+ String beforePoint = out.substring(0, out.indexOf("."));
+ if(beforePoint.lastIndexOf("_") > 0) {
+ out = out.substring(beforePoint.lastIndexOf("_") + 1, out.indexOf(".")) + " (" + beforePoint.substring(0, beforePoint.lastIndexOf("_")) + ")";
+ }
+ }
+ }
+ if(initialKey.startsWith(PreferenceConstantHelper.DIAGRAM_PREFERENCE_PREFIX)) {
+ out = initialKey.toString().replaceAll(PreferenceConstantHelper.DIAGRAM_PREFERENCE_PREFIX, "");
+ out = out.substring(0, out.indexOf("."));
+ }
+ }
+ return out;
+ }
+ }
+
+
+ /**
+ * The Class KeyContentProvider.
+ */
+ protected class KeyContentProvider implements IStructuredContentProvider {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ ArrayList<String> result = new ArrayList<String>();
+ for(int i = 0; i < keys.length; i++) {
+ if(keys[i].startsWith(PreferenceConstantHelper.DIAGRAM_PREFERENCE_PREFIX)) {
+ result.add(keys[i]);
+ }
+ if(keys[i].startsWith(PreferenceConstantHelper.DIAGRAM_ELEMENT)) {
+ result.add(keys[i]);
+ }
+ }
+ return result.toArray();
+ }
+
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/dialog/ApplyValueOnPreferenceKeyDialog.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/dialog/ApplyValueOnPreferenceKeyDialog.java
new file mode 100644
index 00000000000..54a2a350a58
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/dialog/ApplyValueOnPreferenceKeyDialog.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.dialog;
+
+import java.util.ArrayList;
+
+/**
+ * The Class ApplyValueOnPreferenceKeyDialog display all the preference key and give all selected keys
+ */
+public class ApplyValueOnPreferenceKeyDialog extends AbstractPreferenceKeyDialog {
+
+ /** The checked key. */
+ protected ArrayList<String> checkedKey;
+
+ /**
+ * Instantiates a new apply value on preference key dialog.
+ *
+ * @param keys
+ * the keys
+ */
+ public ApplyValueOnPreferenceKeyDialog(String[] keys) {
+ super(keys);
+ checkedKey = new ArrayList<String>();
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * Gets the key to remove.
+ *
+ * @return the key to remove
+ */
+ public ArrayList<String> getKeyToRemove() {
+ return checkedKey;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+
+
+
+ for(int i = 0; i < keyTable.getItems().length; i++) {
+ if(keyTable.getItems()[i].getChecked()) {
+ checkedKey.add((String)keyTable.getItems()[i].getData());
+ }
+ }
+ super.okPressed();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#cancelPressed()
+ */
+ @Override
+ protected void cancelPressed() {
+ super.cancelPressed();
+ checkedKey = new ArrayList<String>();
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/CLabelBooleanFieldEditor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/CLabelBooleanFieldEditor.java
new file mode 100644
index 00000000000..d0fd112c5fd
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/CLabelBooleanFieldEditor.java
@@ -0,0 +1,234 @@
+/*****************************************************************************
+ * Copyright (c) 2011 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.editor;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+
+
+/**
+ * A field editor for a boolean type preference.
+ * This field accepts 2 styles :
+ * <ul>
+ * <li>SWT.LEFT : the CLabel will be on the left</li>
+ * <li>SWT.RIGHT : the CLabel will be on the right</li>
+ * </ul>
+ */
+public class CLabelBooleanFieldEditor extends BooleanFieldEditor {
+
+ /**
+ * A CLabel
+ */
+ private CLabel cLabel = null;
+
+ /**
+ * the checkbox
+ */
+ private Button checkBox = null;
+
+ /**
+ * Style bits. Either <code>SWT.LEFT</code> or <code>SWT.RIGHT</code>.
+ */
+ private int style = SWT.LEFT;
+
+ /**
+ * the image to display
+ */
+ private Image image = null;
+
+ /**
+ * Creates a boolean field editor in the given style.
+ *
+ * @param preferenceKey
+ * the name of the preference this field editor works on
+ * @param labelText
+ * the label text of the field editor
+ * @param style
+ * the style, either <code>SWT.LEFT</code> or <code>SWT.RIGHT</code>. If style value is different, we use <code>SWT.RIGHT</code> The style
+ * allows to define if the label is on the left side or in the right side
+ * @param parent
+ * the parent of the field editor's control
+ */
+ public CLabelBooleanFieldEditor(String preferenceKey, String labelText, int style, Image im, Composite parent) {
+ this.image = im;
+ this.style = (SWT.LEFT == style ? SWT.LEFT : SWT.RIGHT);
+ init(preferenceKey, labelText);
+ createControl(parent);
+
+ }
+
+ /**
+ *
+ * Constructor. This constructor build a CLabelFieldEditor with the label in the right of the checkbox.
+ *
+ * @param preferenceKey
+ * the key for the preference
+ * @param labelText
+ * the label text
+ * @param im
+ * an image to illustrate the preference
+ * @param parent
+ * the composite parent
+ */
+ public CLabelBooleanFieldEditor(String preferenceKey, String labelText, Image im, Composite parent) {
+ this(preferenceKey, labelText, SWT.RIGHT, im, parent);
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.preference.BooleanFieldEditor#doFillIntoGrid(org.eclipse.swt.widgets.Composite, int)
+ *
+ * @param parent
+ * @param numColumns
+ */
+ @Override
+ protected void doFillIntoGrid(Composite parent, int numColumns) {
+ GridData gd = new GridData();
+ switch(this.style) {
+ case SWT.LEFT:
+ getCLabelControl(parent);
+ checkBox = getChangeControl(parent);
+ checkBox.setLayoutData(gd);
+ case SWT.RIGHT:
+ checkBox = getChangeControl(parent);
+ checkBox.setLayoutData(gd);
+ getCLabelControl(parent);
+ }
+ }
+
+ /**
+ * Returns the label control.
+ *
+ * @return the label control, or <code>null</code> if no label control has been created
+ */
+ protected CLabel getCLabelControl() {
+ return cLabel;
+ }
+
+ /**
+ * Returns this field editor's label component.
+ * <p>
+ * The label is created if it does not already exist
+ * </p>
+ *
+ * @param parent
+ * the parent
+ * @return the label control
+ */
+ public CLabel getCLabelControl(Composite parent) {
+ if(cLabel == null) {
+ cLabel = new CLabel(parent, SWT.LEFT);
+ cLabel.setFont(parent.getFont());
+
+ if(image != null) {
+ cLabel.setImage(image);
+ }
+ String text = getLabelText();
+ if(text != null) {
+ cLabel.setText(text);
+ }
+ cLabel.addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent event) {
+ cLabel = null;
+ }
+ });
+ } else {
+ checkParent(cLabel, parent);
+ }
+ return cLabel;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on FieldEditor.
+ */
+ public void setCLabelText(String text) {
+ super.setLabelText(text);
+ Assert.isNotNull(text);
+ cLabel = getCLabelControl();
+ if(cLabel == null && checkBox != null) {
+ checkBox.setText(text);
+ }
+ }
+
+ /*
+ *
+ * The following methods are duplicated from BooleanFieldEditor, because, we need the style value before the end of the constructor execution!
+ */
+
+ /**
+ *
+ * @see org.eclipse.jface.preference.BooleanFieldEditor#adjustForNumColumns(int)
+ *
+ * @param numColumns
+ */
+ @Override
+ protected void adjustForNumColumns(int numColumns) {
+ // if(style == SEPARATE_LABEL) {
+ // numColumns--;
+ // }
+ // ((GridData)checkBox.getLayoutData()).horizontalSpan = numColumns;
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.preference.BooleanFieldEditor#getDescriptionControl(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ * @return
+ */
+ @Override
+ public Control getDescriptionControl(Composite parent) {
+ if(style == SEPARATE_LABEL) {
+ return getLabelControl(parent);
+ }
+ return getChangeControl(parent);
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.preference.BooleanFieldEditor#getNumberOfControls()
+ *
+ * @return
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 2;
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.preference.BooleanFieldEditor#setEnabled(boolean, org.eclipse.swt.widgets.Composite)
+ *
+ * @param enabled
+ * @param parent
+ */
+ @Override
+ public void setEnabled(boolean enabled, Composite parent) {
+ getCLabelControl(parent).setEnabled(enabled);
+ getChangeControl(parent).setEnabled(enabled);
+ }
+
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorBackgroundColor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorBackgroundColor.java
new file mode 100644
index 00000000000..7904688260a
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorBackgroundColor.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.editor;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.ui.BackgroundColor;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * The Class EditorBackgroundColor is the back ground group specailized at the papyrus editor level.
+ */
+public class EditorBackgroundColor extends BackgroundColor {
+
+ /**
+ * Instantiates a new editor background color.
+ *
+ * @param parent
+ * the parent composite
+ * @param key
+ * the key of the preference
+ * @param dialogPage
+ * the dialog page
+ */
+ public EditorBackgroundColor(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#getPreferenceConstant(int)
+ */
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getPapyrusEditorConstant(preferenceType);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorConnectionGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorConnectionGroup.java
new file mode 100644
index 00000000000..ca0ebc1d30a
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorConnectionGroup.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.editor;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.ui.ConnectionGroup;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * The Class EditorConnectionGroup : ac onnection group specialized for the editor level
+ */
+public class EditorConnectionGroup extends ConnectionGroup {
+
+ /**
+ * Instantiates a new editor connection group.
+ *
+ * @param parent
+ * the parent composite
+ * @param key
+ * the title
+ * @param dialogPage
+ * the dialog page
+ */
+ public EditorConnectionGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#getPreferenceConstant(int)
+ */
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getPapyrusEditorConstant(preferenceType);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorDecorationGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorDecorationGroup.java
new file mode 100644
index 00000000000..b8ea5aeafc0
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorDecorationGroup.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.editor;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.ui.DecorationGroup;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * The Class EditorDecorationGroup specialized for the Diagram level
+ */
+public class EditorDecorationGroup extends DecorationGroup {
+
+ /**
+ * Instantiates a new editor decoration group.
+ *
+ * @param parent
+ * the parent composite
+ * @param key
+ * the key
+ * @param dialogPage
+ * the dialog page
+ */
+ public EditorDecorationGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#getPreferenceConstant(int)
+ */
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getPapyrusEditorConstant(preferenceType);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorDimensionGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorDimensionGroup.java
new file mode 100644
index 00000000000..955c233276f
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorDimensionGroup.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.editor;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.ui.DimensionGroup;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * The Class EditorDimensionGroup specialized for the editor level
+ */
+public class EditorDimensionGroup extends DimensionGroup {
+
+ /**
+ * Instantiates a new editor dimension group.
+ *
+ * @param parent
+ * the parent composite
+ * @param key
+ * the key
+ * @param dialogPage
+ * the dialog page
+ */
+ public EditorDimensionGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#getPreferenceConstant(int)
+ */
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getPapyrusEditorConstant(preferenceType);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorFontGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorFontGroup.java
new file mode 100644
index 00000000000..5ef7ff20f73
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorFontGroup.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.editor;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.ui.FontGroup;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * The Class EditorFontGroup specialized for the editor level.
+ */
+public class EditorFontGroup extends FontGroup {
+
+ /**
+ * Instantiates a new editor font group.
+ *
+ * @param parent
+ * the parent composite
+ * @param key
+ * the key
+ * @param dialogPage
+ * the dialog page
+ */
+ public EditorFontGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#getPreferenceConstant(int)
+ */
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getPapyrusEditorConstant(preferenceType);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorLinkColorGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorLinkColorGroup.java
new file mode 100644
index 00000000000..5988e5aea24
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorLinkColorGroup.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.editor;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.ui.LinkColorGroup;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * The Class EditorLinkColorGroup specialized for the editor level
+ */
+public class EditorLinkColorGroup extends LinkColorGroup {
+
+ /**
+ * Instantiates a new editor link color group.
+ *
+ * @param parent
+ * the parent composite
+ * @param key
+ * the title
+ * @param dialogPage
+ * the dialog page
+ */
+ public EditorLinkColorGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#getPreferenceConstant(int)
+ */
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getPapyrusEditorConstant(preferenceType);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorNodeColorGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorNodeColorGroup.java
new file mode 100644
index 00000000000..3250b3cbda8
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/ui/editor/EditorNodeColorGroup.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.ui.editor;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.preferences.ui.NodeColorGroup;
+import org.eclipse.papyrus.preferences.utils.PreferenceConstantHelper;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * The Class EditorNodeColorGroup specialized for the editor level
+ */
+public class EditorNodeColorGroup extends NodeColorGroup {
+
+ /**
+ * Instantiates a new editor node color group.
+ *
+ * @param parent
+ * the parent composite
+ * @param key
+ * the key
+ * @param dialogPage
+ * the dialog page
+ */
+ public EditorNodeColorGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.papyrus.preferences.ui.AbstractGroup#getPreferenceConstant(int)
+ */
+ protected String getPreferenceConstant(int preferenceType) {
+ return PreferenceConstantHelper.getPapyrusEditorConstant(preferenceType);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/utils/FontHelper.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/utils/FontHelper.java
new file mode 100644
index 00000000000..ae93efd44e2
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/utils/FontHelper.java
@@ -0,0 +1,92 @@
+/******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ****************************************************************************/
+
+package org.eclipse.papyrus.preferences.utils;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Helper for fonts.
+ *
+ * For now, it contains a method to get the font names.
+ *
+ * @author wdiu, Wayne Diu
+ * @canBeSeenBy %level1
+ */
+public class FontHelper {
+
+ private static String[] FONT_NAMES;
+
+ /**
+ * array of font sizes
+ */
+ protected static final String[] FONT_SIZES = { "8", //$NON-NLS-1$
+ "9", //$NON-NLS-1$
+ "10", //$NON-NLS-1$
+ "11", //$NON-NLS-1$
+ "12", //$NON-NLS-1$
+ "14", //$NON-NLS-1$
+ "16", //$NON-NLS-1$
+ "18", //$NON-NLS-1$
+ "20", //$NON-NLS-1$
+ "22", //$NON-NLS-1$
+ "24", //$NON-NLS-1$
+ "26", //$NON-NLS-1$
+ "28", //$NON-NLS-1$
+ "36", //$NON-NLS-1$
+ "48", //$NON-NLS-1$
+ "72" }; //$NON-NLS-1$
+
+ /**
+ * Return the font names for the default display.
+ *
+ * @return String array of font names as String objects for the default display.
+ */
+ static public String[] getFontNames() {
+ if(FONT_NAMES != null)
+ return FONT_NAMES;
+
+ // add the names into a set to get a set of unique names
+ Set<String> stringItems = new HashSet<String>();
+ FontData[] fontDatas = Display.getDefault().getFontList(null, true);
+ for(int i = 0; i < fontDatas.length; i++) {
+ if(fontDatas[i].getName() != null) {
+ stringItems.add(fontDatas[i].getName());
+ }
+ }
+
+ // add strings into the array
+ String strings[] = new String[stringItems.size()];
+ int i = 0;
+ for(Iterator<String> it = stringItems.iterator(); it.hasNext();) {
+ strings[i++] = it.next();
+ }
+
+ // sort the array
+ Arrays.sort(strings);
+
+ return FONT_NAMES = strings;
+ }
+
+ /**
+ * @return - array of font sizes
+ */
+ public static final String[] getFontSizes() {
+ return FONT_SIZES;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/utils/GradientPreferenceConverter.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/utils/GradientPreferenceConverter.java
new file mode 100644
index 00000000000..b8d42ec1d7e
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/utils/GradientPreferenceConverter.java
@@ -0,0 +1,207 @@
+/****************************************************************************
+ * Copyright (c) 2009 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.utils;
+
+import java.util.StringTokenizer;
+
+import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
+import org.eclipse.gmf.runtime.notation.GradientStyle;
+import org.eclipse.gmf.runtime.notation.datatype.GradientData;
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ * An utility class to ease the use of gradient preference within Papyrus. It converts the
+ * preference into gradientData, RGB color and int (transparency and style) and vice versa
+ *
+ * @author tlandre
+ *
+ */
+public class GradientPreferenceConverter {
+
+ private static final int GRADIENT_COLOR1 = 0;
+
+ private static final int GRADIENT_COLOR2 = 1;
+
+ private static final int GRADIENT_STYLE = 2;
+
+ private static final int GRADIENT_TRANSPARENCY = 3;
+
+ private int fStyle = GradientStyle.HORIZONTAL;
+
+ private int fTransparency = 0;
+
+ private RGB fColor1;
+
+ private RGB fColor2;
+
+ /**
+ * Constructor
+ *
+ * @param pPreference
+ * the preference. It must be formated like this : <br>
+ * <code>RGB {x, x, x};RGB {x, x,
+ * x};style;transparency</code> <br>
+ * where style and transparency are <code>int</code>
+ */
+ public GradientPreferenceConverter(String pPreference) {
+ initFieldFromPreference(pPreference);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param pColor1
+ * the first color used
+ * @param pColor2
+ * the second color used
+ * @param pStyle
+ * the style of the gradient. It can be GradientStyle.VERTICAL or
+ * GradientStyle.HORIZONTAL
+ * @param pTransparency
+ * the transparency. It must be contained in [0,100]
+ */
+ public GradientPreferenceConverter(RGB pColor1, RGB pColor2, int pStyle, int pTransparency) {
+ fColor1 = pColor1;
+ fColor2 = pColor2;
+ fStyle = pStyle;
+ fTransparency = pTransparency;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param pColor1
+ * the first color used
+ * @param pColor2
+ * the second color used
+ * @param pStyle
+ * the style of the gradient. It can be GradientStyle.VERTICAL or
+ * GradientStyle.HORIZONTAL
+ * @param pTransparency
+ * the transparency. It must be contained in [0,100]
+ */
+ // @unused
+ public GradientPreferenceConverter(int pColor1, int pColor2, int pStyle, int pTransparency) {
+ fColor1 = FigureUtilities.integerToRGB(pColor1);
+ fColor2 = FigureUtilities.integerToRGB(pColor2);
+ fStyle = pStyle;
+ fTransparency = pTransparency;
+ }
+
+ private void initFieldFromPreference(String pPreference) {
+ String[] values = pPreference.split(";"); //$NON-NLS-1$
+ if(values.length == 4) {
+ fColor1 = getRGBColor(values[GRADIENT_COLOR1]);
+ fColor2 = getRGBColor(values[GRADIENT_COLOR2]);
+ fStyle = Integer.parseInt(values[GRADIENT_STYLE]);
+ fTransparency = Integer.parseInt(values[GRADIENT_TRANSPARENCY]);
+ }
+ }
+
+ /**
+ * Get the transparency of the gradient
+ *
+ * @return the transparency
+ */
+ public int getTransparency() {
+ return fTransparency;
+ }
+
+ /**
+ * Get the gradientData of the gradient
+ *
+ * @return the gradientData
+ */
+ public GradientData getGradientData() {
+ GradientData gd = GradientData.getDefaultGradientData();
+ if(fColor1 != null && fColor2 != null) {
+ gd = new GradientData(FigureUtilities.RGBToInteger(fColor1), FigureUtilities.RGBToInteger(fColor2), fStyle);
+ }
+ return gd;
+ }
+
+ /**
+ * Get the first color used for the gradient.
+ *
+ * @return the RGB
+ */
+ public RGB getColor1() {
+ RGB color;
+ if(fColor1 != null) {
+ color = fColor1;
+ } else {
+ color = FigureUtilities.integerToRGB(GradientData.getDefaultGradientData().getGradientColor1());
+ }
+ return color;
+ }
+
+ /**
+ * Get the second color used for the gradient.
+ *
+ * @return the RGB
+ */
+ // @unused
+ public RGB getColor2() {
+ RGB color;
+ if(fColor1 != null) {
+ color = fColor2;
+ } else {
+ color = FigureUtilities.integerToRGB(GradientData.getDefaultGradientData().getGradientColor2());
+ }
+ return color;
+ }
+
+ /**
+ * Get the style of the gradient
+ *
+ * @return GradientStyle.HORIZONTAL or GradientStyle.VERTICAL
+ */
+ public int getStyle() {
+ return fStyle;
+ }
+
+ /**
+ * Extract the values of the RGB color contained in the string "RGB {x, x, x}"
+ *
+ * @param string
+ * a string of format "RGB {x, x, x}"
+ * @return the corresponding color
+ */
+ private static RGB getRGBColor(String string) {
+ StringTokenizer st = new StringTokenizer(string, "RGB ,{}"); //$NON-NLS-1$
+ int red = Integer.parseInt(st.nextToken());
+ int green = Integer.parseInt(st.nextToken());
+ int blue = Integer.parseInt(st.nextToken());
+
+ return new RGB(red, green, blue);
+ }
+
+ /**
+ * Get a string that can be store The value is in the following format : <br>
+ * <b>RGB {x, x, x};RGB {x, x, x};style;transparency</b> <br>
+ * where style and transparency are <b>int</b>
+ *
+ * @return the string
+ */
+ public String getPreferenceValue() {
+ StringBuffer sb = new StringBuffer(30);
+ sb.append(fColor1.toString());
+ sb.append(";"); //$NON-NLS-1$
+ sb.append(fColor2.toString());
+ sb.append(";"); //$NON-NLS-1$
+ sb.append(fStyle);
+ sb.append(";"); //$NON-NLS-1$
+ sb.append(fTransparency);
+ return sb.toString().trim();
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/utils/PreferenceConstantHelper.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/utils/PreferenceConstantHelper.java
new file mode 100644
index 00000000000..c026abb5c74
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/preferences/utils/PreferenceConstantHelper.java
@@ -0,0 +1,387 @@
+/****************************************************************************
+ * Copyright (c) 2009 Atos Origin.
+ *
+ * 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:
+ * Thibault Landre (Atos Origin) - Initial API and implementation
+ * Lorenzo Vincent (CEA LIST) - Add Compartment Visibility
+ * Vincent Lorenzo (CEA-LIst) - bug 335989: [Preferences] [Enhancement] Add a group for labels in each Connection Preference Page
+ *****************************************************************************/
+package org.eclipse.papyrus.preferences.utils;
+
+/**
+ * <p>
+ * A class that defines the available preference type available through Papyrus.
+ * </p>
+ * <p>
+ * It defines the following type:
+ * </p>
+ * <ul>
+ * <li>COLOR_FILL</li>
+ * <li>FONT</li>
+ * <li>COLOR_FONT</li>
+ * <li>COLOR_LINE</li>
+ * <li>COLOR_GRADIENT</li>
+ * <li>GRADIENT_POLICY</li>
+ * <li>JUMPLINK_STATUS</li>
+ * <li>JUMPLINK_REVERSE</li>
+ * <li>JUMPLINK_TYPE</li>
+ * <li>ROUTING_POLICY_DISTANCE</li>
+ * <li>ROUTING_POLICY_OBSTRUCTION</li>
+ * <li>ROUTING_STYLE</li>
+ * <li>SMOOTHNESS</li>
+ * </ul>
+ * <p>
+ * It also helps to retrieve the string used to store the preference type for a given element.
+ * </p>
+ *
+ */
+public class PreferenceConstantHelper {
+
+ /**
+ * Prefix for preference for Papyrus Level editor
+ */
+ public static String PAPYRUS_EDITOR_PREFERENCE_PREFIX = "PAPYRUS_EDITOR"; //$NON-NLS-1$
+
+ /**
+ * Prefix for preference for Diagram Level
+ */
+ public static String DIAGRAM_PREFERENCE_PREFIX = "DIAGRAM_"; //$NON-NLS-1$
+
+ /**
+ * Prefix for preference for element Level
+ */
+ public static String DIAGRAM_ELEMENT = "ELEMENT_"; //$NON-NLS-1$
+
+ private final static String COLOR = "color."; //$NON-NLS-1$
+
+ private final static String GRADIENT = "gradient"; //$NON-NLS-1$
+
+ private final static String POLICY = ".policy"; //$NON-NLS-1$
+
+ private final static String JUMPLINK = "jumplink."; //$NON-NLS-1$
+
+ private final static String ROUTING = "routing"; //$NON-NLS-1$
+
+ private final static String ROUTING_POLICY = ROUTING + POLICY;
+
+ private final static String COLOR_FILL_CONSTANT = COLOR + "fill"; //$NON-NLS-1$
+
+ private final static String FONT_CONSTANT = "font"; //$NON-NLS-1$
+
+ private final static String COLOR_FONT_CONSTANT = COLOR + FONT_CONSTANT;
+
+ private final static String COLOR_LINE_CONSTANT = COLOR + "line"; //$NON-NLS-1$
+
+ private final static String COLOR_GRADIENT_CONSTANT = COLOR + GRADIENT;
+
+ private final static String GRADIENT_POLICY_CONSTANT = GRADIENT + POLICY;
+
+ private final static String JUMPLINK_STATUS_CONSTANT = JUMPLINK + "status"; //$NON-NLS-1$
+
+ private final static String JUMPLINK_REVERSE_CONSTANT = JUMPLINK + "reverse"; //$NON-NLS-1$
+
+ private final static String JUMPLINK_TYPE_CONSTANT = JUMPLINK + "type"; //$NON-NLS-1$
+
+ private final static String ROUTING_POLICY_DISTANCE_CONSTANT = ROUTING_POLICY + ".distance"; //$NON-NLS-1$
+
+ private final static String ROUTING_POLICY_OBSTRUCTION_CONSTANT = ROUTING_POLICY + ".obstruction"; //$NON-NLS-1$
+
+ private final static String ROUTING_STYLE_CONSTANT = ROUTING + ".style"; //$NON-NLS-1$
+
+ private final static String SMOOTHNESS_CONSTANT = "smoothness"; //$NON-NLS-1$
+
+ private final static String SHADOW_CONSTANT = "shadow"; //$NON-NLS-1$
+
+ private final static String ELEMENTICON_CONSTANT = "elementicon"; //$NON-NLS-1$
+
+ private final static String QUALIFIEDNAME_CONSTANT = "qualifiedname"; //$NON-NLS-1$
+
+ private final static String HEIGHT_CONSTANT = "height";//$NON-NLS-1$
+
+ private final static String WIDTH_CONSTANT = "width"; //$NON-NLS-1$
+
+ private final static String COMPARTMENT_VISIBILITY_CONSTANT = "compartment.visibility"; //$NON-NLS-1$
+
+ private final static String COMPARTMENT_NAME_VISIBILITY_CONSTANT = "compartment_name.visibility"; //$NON-NLS-1$
+
+ private final static String LABEL_VISIBILITY_CONSTANT = "label.visibility"; //$NON-NLS-1$
+
+ private final static String LOCATION_X_CONSTANT = "location_x";//$NON-NLS-1$
+
+ private final static String LOCATION_Y_CONSTANT = "location_y"; //$NON-NLS-1$
+
+ /**
+ * A preference of type COLOR FILL
+ */
+ public final static int COLOR_FILL = 0;
+
+ /**
+ * A preference of type FONT
+ */
+ public final static int FONT = COLOR_FILL + 1;
+
+ /**
+ * A preference of type COLOR FONT
+ */
+ public final static int COLOR_FONT = FONT + 1;
+
+ /**
+ * A preference of type COLOR LINE
+ */
+ public final static int COLOR_LINE = COLOR_FONT + 1;
+
+ /**
+ * A preference of type COLOR GRADIENT
+ */
+ public final static int COLOR_GRADIENT = COLOR_LINE + 1;
+
+ /**
+ * A preference of type GRADIENT POLICY
+ */
+ public final static int GRADIENT_POLICY = COLOR_GRADIENT + 1;
+
+ /**
+ * A preference of type JUMPLINK STATUS
+ */
+ public final static int JUMPLINK_STATUS = GRADIENT_POLICY + 1;
+
+ /**
+ * A preference of type JUMPLINK REVERSE
+ */
+ public final static int JUMPLINK_REVERSE = JUMPLINK_STATUS + 1;
+
+ /**
+ * A preference of type JUMPLINK TYPE
+ */
+ public final static int JUMPLINK_TYPE = JUMPLINK_REVERSE + 1;
+
+ /**
+ * A preference of type ROUTING POLICY DISTANCE
+ */
+ public final static int ROUTING_POLICY_DISTANCE = JUMPLINK_TYPE + 1;
+
+ /**
+ * A preference of type ROUTING POLICY OBSTRUCTION
+ */
+ public final static int ROUTING_POLICY_OBSTRUCTION = ROUTING_POLICY_DISTANCE + 1;
+
+ /**
+ * A preference of type ROUTING STYLE
+ */
+ public final static int ROUTING_STYLE = ROUTING_POLICY_OBSTRUCTION + 1;
+
+ /**
+ * A preference of type SMOOTHNESS
+ */
+ public final static int SMOOTHNESS = ROUTING_STYLE + 1;
+
+ /**
+ * A preference of type Shadow
+ */
+ public final static int SHADOW = SMOOTHNESS + 1;
+
+ /**
+ * A preference of type elementIcon
+ */
+ public final static int ELEMENTICON = SHADOW + 1;
+
+ /**
+ * A preference of type QualifiedName
+ */
+ public final static int QUALIFIEDNAME = ELEMENTICON + 1;
+
+ /**
+ * A preference of type height
+ */
+ public static final int HEIGHT = QUALIFIEDNAME + 1;
+
+ /**
+ * A preference of type width
+ */
+ public static final int WIDTH = HEIGHT + 1;
+
+ /**
+ * A preference of type compartment visibility
+ */
+ public static final int COMPARTMENT_VISIBILITY = WIDTH + 1;
+
+ /**
+ * A preference of type compartment visibility
+ */
+ public static final int COMPARTMENT_NAME_VISIBILITY = COMPARTMENT_VISIBILITY + 1;
+
+ /**
+ * A preference of type label visibility
+ */
+ public static final int LABEL_VISIBILITY = COMPARTMENT_NAME_VISIBILITY + 1;
+
+ /**
+ * A preference for label default location
+ */
+ public static final int LOCATION_X = LABEL_VISIBILITY + 1;
+
+ /**
+ * A preference for label default location
+ */
+ public static final int LOCATION_Y = LOCATION_X + 1;
+
+
+ /**
+ * Get the preference constant used to store the preference of an element.
+ *
+ * @param elementName
+ * the name of the element
+ * @param preferenceType
+ * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
+ * @return the constant used.
+ */
+ public static String getConstant(String elementName, int preferenceType) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(elementName);
+ sb.append("."); //$NON-NLS-1$
+
+ switch(preferenceType) {
+ case COLOR_FILL:
+ sb.append(COLOR_FILL_CONSTANT);
+ break;
+ case FONT:
+ sb.append(FONT_CONSTANT);
+ break;
+ case COLOR_FONT:
+ sb.append(COLOR_FONT_CONSTANT);
+ break;
+ case COLOR_LINE:
+ sb.append(COLOR_LINE_CONSTANT);
+ break;
+ case COLOR_GRADIENT:
+ sb.append(COLOR_GRADIENT_CONSTANT);
+ break;
+ case GRADIENT_POLICY:
+ sb.append(GRADIENT_POLICY_CONSTANT);
+ break;
+ case JUMPLINK_STATUS:
+ sb.append(JUMPLINK_STATUS_CONSTANT);
+ break;
+ case JUMPLINK_REVERSE:
+ sb.append(JUMPLINK_REVERSE_CONSTANT);
+ break;
+ case JUMPLINK_TYPE:
+ sb.append(JUMPLINK_TYPE_CONSTANT);
+ break;
+ case ROUTING_POLICY_DISTANCE:
+ sb.append(ROUTING_POLICY_DISTANCE_CONSTANT);
+ break;
+ case ROUTING_POLICY_OBSTRUCTION:
+ sb.append(ROUTING_POLICY_OBSTRUCTION_CONSTANT);
+ break;
+ case ROUTING_STYLE:
+ sb.append(ROUTING_STYLE_CONSTANT);
+ break;
+ case SMOOTHNESS:
+ sb.append(SMOOTHNESS_CONSTANT);
+ break;
+ case SHADOW:
+ sb.append(SHADOW_CONSTANT);
+ break;
+ case ELEMENTICON:
+ sb.append(ELEMENTICON_CONSTANT);
+ break;
+ case QUALIFIEDNAME:
+ sb.append(QUALIFIEDNAME_CONSTANT);
+ break;
+ case HEIGHT:
+ sb.append(HEIGHT_CONSTANT);
+ break;
+ case WIDTH:
+ sb.append(WIDTH_CONSTANT);
+ break;
+ case COMPARTMENT_VISIBILITY:
+ sb.append(COMPARTMENT_VISIBILITY_CONSTANT);
+ break;
+ case COMPARTMENT_NAME_VISIBILITY:
+ sb.append(COMPARTMENT_NAME_VISIBILITY_CONSTANT);
+ break;
+ case LABEL_VISIBILITY:
+ sb.append(LABEL_VISIBILITY_CONSTANT);
+ case LOCATION_X:
+ sb.append(LOCATION_X_CONSTANT);
+ case LOCATION_Y:
+ sb.append(LOCATION_Y_CONSTANT);
+ default:
+ break;
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ *
+ * @param elementName
+ * diagramKind+'_'+element
+ * @param preferenceType
+ * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
+ * @return the key for the element of a diagram
+ */
+ public static String getElementConstant(String elementName, int preferenceType) {
+ return DIAGRAM_ELEMENT + getConstant(elementName, preferenceType);
+ }
+
+ /**
+ *
+ * @param elementName
+ * diagramKind+'_'+element
+ * @param compartmentName
+ * the compartment name
+ * @param preferenceType
+ * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
+ * @return the key for the element of a diagram
+ */
+ public static String getCompartmentElementConstant(String elementName, String compartmentName, int preferenceType) {
+ String tmp = getElementConstant(elementName, preferenceType);
+ return tmp.replaceFirst("\\.", "_" + compartmentName + "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ /**
+ *
+ *
+ * @param elementName
+ * diagramKind+'_'+element
+ * @param labelRole
+ * he role of the label
+ * @param preferenceType
+ * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
+ * @return the key for the element of a diagram
+ */
+ public static String getLabelElementConstant(String elementName, String labelRole, int preferenceType) {
+ String tmp = getElementConstant(elementName, preferenceType);
+ return tmp.replaceFirst("\\.", "_" + labelRole + "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ /**
+ *
+ * @param preferenceType
+ * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
+ * @return get the preference key at the papyrus editor level
+ */
+ public static String getPapyrusEditorConstant(int preferenceType) {
+ return getConstant(PAPYRUS_EDITOR_PREFERENCE_PREFIX, preferenceType);
+ }
+
+ /**
+ *
+ * @param diagramKind
+ * the kind of diagram.
+ * @param preferenceType
+ * the type of preference to store. It must be a value defined in {@link PreferenceConstantHelper}
+ * @return the preference key at the diagram level
+ */
+ public static String getDiagramConstant(String diagramKind, int preferenceType) {
+ return DIAGRAM_PREFERENCE_PREFIX + getConstant(diagramKind, preferenceType);
+ }
+
+}

Back to the top