Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2013-12-11 16:28:28 +0000
committerVincent Lorenzo2013-12-11 16:28:28 +0000
commit59ce8f4db28685083549d1ea989f08b939f6af43 (patch)
treebcbfa061f4901a326b42d9ce7a78b3decf450ce9 /plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties
parent4805b01c69b5ca19eeae72dcb353539f40053dbc (diff)
downloadorg.eclipse.papyrus-59ce8f4db28685083549d1ea989f08b939f6af43.tar.gz
org.eclipse.papyrus-59ce8f4db28685083549d1ea989f08b939f6af43.tar.xz
org.eclipse.papyrus-59ce8f4db28685083549d1ea989f08b939f6af43.zip
422553: [Diagram] Status (checked/uncheked) of the grid actions are not
updated when we change a new diagram take the focus https://bugs.eclipse.org/bugs/show_bug.cgi?id=422553 422406: Snap to grid disabled still makes snap to grid https://bugs.eclipse.org/bugs/show_bug.cgi?id=422406 423799: [Diagram]Rulers and Grid preferences are not customizable for each diagrams https://bugs.eclipse.org/bugs/show_bug.cgi?id=423799 423805: [Preferences] Key used for Preferences is the string "null" for all inherited diagrams (SysML Diagram + Uml Package +...) https://bugs.eclipse.org/bugs/show_bug.cgi?id=423805
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi51
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/notation.ctx27
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleLocation.xwt5
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleRulersAndGrid.xwt2
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/constraint/IsSingleDiagramEditorConstraint.java42
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/AbstractDiagramPreferencesObservableValue.java103
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/BooleanDiagramViewObservableValue.java79
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/DoubleDiagramViewObservaleValue.java83
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/IntegerDiagramViewObservableValue.java79
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/RulersUnitObservableValue.java65
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/Messages.java2
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/messages.properties1
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/RulerAndGridModelElement.java191
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/RulersAndGridModelElementFactory.java61
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/util/NotationUtil.java13
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/util/RulersAndGridPropertyConstants.java47
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/widget/DiagramPreferencesDefaultButton.java159
17 files changed, 997 insertions, 13 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi
index 7c44093d06f..2f94e101562 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi
@@ -1,12 +1,43 @@
<?xml version="1.0" encoding="ASCII"?>
-<environment:Environment xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:environment="http://www.eclipse.org/papyrus/properties/environment/0.9">
- <constraintTypes label="GMF Appearance Constraint" constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.AppearanceConstraint"/>
- <constraintTypes label="HasEditPolicy" constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.HasEditPolicy"/>
- <constraintTypes label="isGMFEditPart" constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.IsEditPartConstraint"/>
- <constraintTypes label="GMF Notation Constraint" constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.GMFNotationConstraint"/>
- <constraintTypes label="isDecorableElementConstraint" constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.IsDecorableElementConstraint"/>
- <modelElementFactories name="GMF Appearance Factory" factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.AppearanceModelElementFactory"/>
- <modelElementFactories name="GMF Custom Style" factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.CustomStyleModelElementFactory"/>
- <modelElementFactories name="GMF Notation Factory" factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.NotationModelElementFactory"/>
- <modelElementFactories name="Decorated Element Factory" factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.DecoratedModelElementFactory"/>
+<environment:Environment
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:environment="http://www.eclipse.org/papyrus/properties/environment/0.9">
+ <constraintTypes
+ label="GMF Appearance Constraint"
+ constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.AppearanceConstraint"/>
+ <constraintTypes
+ label="HasEditPolicy"
+ constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.HasEditPolicy"/>
+ <constraintTypes
+ label="isGMFEditPart"
+ constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.IsEditPartConstraint"/>
+ <constraintTypes
+ label="GMF Notation Constraint"
+ constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.GMFNotationConstraint"/>
+ <constraintTypes
+ label="isDecorableElementConstraint"
+ constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.IsDecorableElementConstraint"/>
+ <modelElementFactories
+ name="GMF Appearance Factory"
+ factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.AppearanceModelElementFactory"/>
+ <modelElementFactories
+ name="GMF Custom Style"
+ factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.CustomStyleModelElementFactory"/>
+ <modelElementFactories
+ name="GMF Notation Factory"
+ factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.NotationModelElementFactory"/>
+ <modelElementFactories
+ name="Decorated Element Factory"
+ factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.DecoratedModelElementFactory"/>
+ <modelElementFactories
+ name="Rulers And Grid Element Factory"
+ factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.RulersAndGridModelElementFactory"/>
+ <widgetTypes
+ label="DiagramPreferencesDefaultButton"
+ widgetClass="DiagramPreferencesDefaultButton"
+ namespace="//@namespaces.0"/>
+ <namespaces
+ name="ppeg"
+ value="org.eclipse.papyrus.infra.gmfdiag.properties.widget"/>
</environment:Environment>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/notation.ctx b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/notation.ctx
index 244e96c83c8..ba0a3c0b90d 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/notation.ctx
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/notation.ctx
@@ -179,6 +179,11 @@
<widget href="ui/SingleDecorableElement.xwt#/"/>
</sections>
</tabs>
+ <tabs label="Rulers And Grid" id="rulersAndGrid" category="org.eclipse.papyrus" afterTab="//@tabs.0" priority="75">
+ <sections name="Single RulersAndGrid" sectionFile="ui/SingleRulersAndGrid.xwt">
+ <widget href="ui/SingleRulersAndGrid.xwt#/"/>
+ </sections>
+ </tabs>
<views name="Single Diagram" sections="//@tabs.0/@sections.12" automaticContext="true" datacontexts="//@dataContexts.0/@elements.12">
<constraints xsi:type="constraints:SimpleConstraint" name="isSingleDiagram">
<constraintType href="ppe:/environment/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi#//@constraintTypes.3"/>
@@ -387,6 +392,12 @@
<properties xsi:type="constraints:ValueProperty" name="nsUri" value="http://www.eclipse.org/gmf/runtime/1.0.2/notation"/>
</constraints>
</views>
+ <views name="Single RulersAndGrid" sections="//@tabs.1/@sections.0" datacontexts="//@dataContexts.2">
+ <constraints xsi:type="constraints:SimpleConstraint" name="isSingleDiagramEditorConstraint" overrideable="false">
+ <constraintType href="ppe:/environment/org.eclipse.papyrus.views.properties/model/Environment.xmi#//@constraintTypes.4"/>
+ <properties xsi:type="constraints:ValueProperty" name="className" value="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.IsSingleDiagramEditorConstraint"/>
+ </constraints>
+ </views>
<views elementMultiplicity="-1" name="Multiple Edge" sections="//@tabs.0/@sections.29" automaticContext="true" datacontexts="//@dataContexts.0/@elements.0">
<constraints xsi:type="constraints:SimpleConstraint" name="isMultipleEdge">
<constraintType href="ppe:/environment/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi#//@constraintTypes.3"/>
@@ -679,4 +690,20 @@
</elements>
<modelElementFactory href="ppe:/environment/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi#//@modelElementFactories.3"/>
</dataContexts>
+ <dataContexts name="rulersAndGrid" label="rulersAndGrid">
+ <elements name="grid">
+ <properties name="grid.isDisplayingGrid" label="Show Grid" type="Boolean" description=""/>
+ <properties name="grid.isInFront" label="Grid In Front" type="Boolean" description=""/>
+ <properties name="grid.color" label="Color"/>
+ <properties name="grid.style" label="Style" type="Enumeration"/>
+ <properties name="grid.spacing" label="Grid Spacing"/>
+ <properties name="grid.isSnapToGrid" label="Snap To Grid"/>
+ <properties name="grid.isSnapToShapes" label="Snap To Shapes"/>
+ </elements>
+ <elements name="rulers">
+ <properties name="rulers.isDisplayingRulers" label="Show Ruler" type="Boolean"/>
+ <properties name="rulers.units" label="Ruler Units"/>
+ </elements>
+ <modelElementFactory href="ppe:/environment/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi#//@modelElementFactories.4"/>
+ </dataContexts>
</contexts:Context>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleLocation.xwt b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleLocation.xwt
index 89517d2ad16..d69369c20ec 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleLocation.xwt
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleLocation.xwt
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<Composite
+<Composite xmlns="http://www.eclipse.org/xwt/presentation"
xmlns:ppel="clr-namespace:org.eclipse.papyrus.views.properties.widgets.layout"
- xmlns:j="clr-namespace:java.lang" xmlns:x="http://www.eclipse.org/xwt"
- xmlns="http://www.eclipse.org/xwt/presentation">
+ xmlns:j="clr-namespace:java.lang" xmlns:x="http://www.eclipse.org/xwt">
<Composite.layout>
<ppel:PropertiesLayout></ppel:PropertiesLayout>
</Composite.layout>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleRulersAndGrid.xwt b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleRulersAndGrid.xwt
new file mode 100644
index 00000000000..1f133dd89e9
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleRulersAndGrid.xwt
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Composite xmlns:ppeg="clr-namespace:org.eclipse.papyrus.infra.gmfdiag.properties.widget" xmlns:ppe="clr-namespace:org.eclipse.papyrus.views.properties.widgets" xmlns:x="http://www.eclipse.org/xwt" xmlns:j="clr-namespace:java.lang" xmlns:ppel="clr-namespace:org.eclipse.papyrus.views.properties.widgets.layout" xmlns:gmf="clr-namespace:org.eclipse.papyrus.infra.gmfdiag.widgets.editors" xmlns="http://www.eclipse.org/xwt/presentation"><Composite.layout><GridLayout numColumns="1" makeColumnsEqualWidth="true"></GridLayout></Composite.layout><Composite><Composite.layout><FillLayout></FillLayout></Composite.layout><Group text="Display"><Group.layout><GridLayout makeColumnsEqualWidth="false" numColumns="2"></GridLayout></Group.layout><ppe:BooleanCheckbox input="{Binding}" property="rulersAndGrid:grid:grid.isDisplayingGrid"></ppe:BooleanCheckbox><ppe:BooleanCheckbox input="{Binding}" property="rulersAndGrid:rulers:rulers.isDisplayingRulers"></ppe:BooleanCheckbox><ppe:BooleanCheckbox input="{Binding}" property="rulersAndGrid:grid:grid.isInFront"></ppe:BooleanCheckbox></Group><Group text="Snap"><Group.layout><GridLayout numColumns="1"></GridLayout></Group.layout><ppe:BooleanCheckbox input="{Binding}" property="rulersAndGrid:grid:grid.isSnapToGrid"></ppe:BooleanCheckbox><ppe:BooleanCheckbox input="{Binding}" property="rulersAndGrid:grid:grid.isSnapToShapes"></ppe:BooleanCheckbox></Group><Group text="Measurement"><Group.layout><ppel:PropertiesLayout numColumns="1"></ppel:PropertiesLayout></Group.layout><ppe:EnumCombo input="{Binding}" property="rulersAndGrid:rulers:rulers.units"></ppe:EnumCombo><ppe:FloatEditor input="{Binding}" property="rulersAndGrid:grid:grid.spacing"></ppe:FloatEditor></Group></Composite><Group text="Grid Line"><Group.layout><GridLayout makeColumnsEqualWidth="true" numColumns="1"></GridLayout></Group.layout><gmf:XWTAwareColorPicker input="{Binding}" property="rulersAndGrid:grid:grid.color"></gmf:XWTAwareColorPicker><ppe:EnumCombo input="{Binding}" property="rulersAndGrid:grid:grid.style"></ppe:EnumCombo></Group><ppeg:DiagramPreferencesDefaultButton input="{Binding}"></ppeg:DiagramPreferencesDefaultButton></Composite> \ No newline at end of file
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/constraint/IsSingleDiagramEditorConstraint.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/constraint/IsSingleDiagramEditorConstraint.java
new file mode 100644
index 00000000000..a68337a0f75
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/constraint/IsSingleDiagramEditorConstraint.java
@@ -0,0 +1,42 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.constraint;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.papyrus.infra.constraints.constraints.JavaQuery;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil;
+
+/**
+ *
+ * A constraint to know if we are able to get a diagram editor from the selection
+ *
+ */
+public class IsSingleDiagramEditorConstraint implements JavaQuery {
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.constraints.constraints.JavaQuery#match(java.lang.Object)
+ *
+ * @param selection
+ * @return
+ */
+ public boolean match(Object selection) {
+ if(selection instanceof EditPart) {
+ return DiagramEditPartsUtil.getDiagramWorkspacePreferenceStore((EditPart)selection) != null;
+ }
+ return false;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/AbstractDiagramPreferencesObservableValue.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/AbstractDiagramPreferencesObservableValue.java
new file mode 100644
index 00000000000..95ce8f2d3e8
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/AbstractDiagramPreferencesObservableValue.java
@@ -0,0 +1,103 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding;
+
+import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
+import org.eclipse.core.databinding.observable.value.ValueDiff;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+/**
+ *
+ * This observable value listen the preference store to send event and refresh itself when a preferences has changed
+ *
+ */
+public abstract class AbstractDiagramPreferencesObservableValue extends AbstractObservableValue {
+
+ /**
+ * the name of the edited preference
+ */
+ private String preferenceName;
+
+ /**
+ * the edited preference store
+ */
+ private IPreferenceStore editedPreferenceStore;
+
+ /**
+ * the listener on the preference store used to force refresh
+ */
+ private IPropertyChangeListener listener;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param diagram
+ * the diagram for which we re editing a preference
+ * @param preferenceName
+ * the name of edited the preference
+ */
+ public AbstractDiagramPreferencesObservableValue(final Diagram diagram, final String preferenceName, final IPreferenceStore editedPreferenceStore) {
+ this.preferenceName = preferenceName;
+ this.editedPreferenceStore = editedPreferenceStore;
+ this.editedPreferenceStore.addPropertyChangeListener(this.listener = new IPropertyChangeListener() {
+
+ public void propertyChange(final PropertyChangeEvent event) {
+ if(getEditedPreference().equals(event.getProperty())) {
+ ValueDiff diff = new ValueDiff() {
+
+ @Override
+ public Object getOldValue() {
+ return event.getOldValue();
+ }
+
+ @Override
+ public Object getNewValue() {
+ return event.getNewValue();
+ }
+ };
+ fireValueChange(diff);
+ }
+ }
+ });
+ }
+
+
+ @Override
+ public synchronized void dispose() {
+ super.dispose();
+ this.editedPreferenceStore.removePropertyChangeListener(this.listener);
+ }
+
+ /**
+ *
+ * @return
+ * the edited preferences
+ */
+ public final String getEditedPreference() {
+ return this.preferenceName;
+ }
+
+ /**
+ *
+ * @return
+ * the edited preference store
+ */
+ public final IPreferenceStore getEditedPreferenceStore() {
+ return this.editedPreferenceStore;
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/BooleanDiagramViewObservableValue.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/BooleanDiagramViewObservableValue.java
new file mode 100644
index 00000000000..fb94fe629e4
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/BooleanDiagramViewObservableValue.java
@@ -0,0 +1,79 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding;
+
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+/**
+ *
+ * Class used to edit boolean preference
+ *
+ */
+public class BooleanDiagramViewObservableValue extends AbstractDiagramPreferencesObservableValue {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param diagram
+ * the edited diagram
+ * @param preferenceName
+ * the edited preference
+ * @param preferenceStore
+ * the edited preference store
+ */
+ public BooleanDiagramViewObservableValue(final Diagram diagram, final String preferenceName, IPreferenceStore preferenceStore) {
+ super(diagram, preferenceName, preferenceStore);
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.databinding.observable.value.IObservableValue#getValueType()
+ *
+ * @return
+ */
+ public final Object getValueType() {
+ return EcorePackage.eINSTANCE.getEBoolean();
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doGetValue()
+ *
+ * @return
+ */
+ @Override
+ protected final Object doGetValue() {
+ final IPreferenceStore wsPreferenceStore = getEditedPreferenceStore();
+ return wsPreferenceStore.getBoolean(getEditedPreference());
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doSetValue(java.lang.Object)
+ *
+ * @param value
+ */
+ @Override
+ protected void doSetValue(Object value) {
+ if(value instanceof Boolean) {
+ final IPreferenceStore wsPreferenceStore = getEditedPreferenceStore();
+ wsPreferenceStore.setValue(getEditedPreference(), ((Boolean)value).booleanValue());
+ }
+ }
+
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/DoubleDiagramViewObservaleValue.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/DoubleDiagramViewObservaleValue.java
new file mode 100644
index 00000000000..2702a1cda47
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/DoubleDiagramViewObservaleValue.java
@@ -0,0 +1,83 @@
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding;
+
+import org.eclipse.core.databinding.observable.value.ValueDiff;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+/**
+ *
+ * Class used to edit double preferences
+ *
+ */
+public class DoubleDiagramViewObservaleValue extends AbstractDiagramPreferencesObservableValue {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param diagram
+ * the edited diagram
+ * @param preferenceName
+ * the edited preference
+ * @param store
+ * the edited preference store
+ */
+ public DoubleDiagramViewObservaleValue(final Diagram diagram, final String preferenceName, final IPreferenceStore store) {
+ super(diagram, preferenceName, store);
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.databinding.observable.value.IObservableValue#getValueType()
+ *
+ * @return
+ */
+ public final Object getValueType() {
+ return EcorePackage.eINSTANCE.getEFloat();
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doGetValue()
+ *
+ * @return
+ */
+ @Override
+ protected Object doGetValue() {
+ final IPreferenceStore wsPreferenceStore = getEditedPreferenceStore();
+ return wsPreferenceStore.getDouble(getEditedPreference());
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doSetValue(java.lang.Object)
+ *
+ * @param value
+ */
+ @Override
+ protected void doSetValue(final Object value) {
+ if(value instanceof Float) {
+ final IPreferenceStore wsPreferenceStore = getEditedPreferenceStore();
+ final double oldValue = (Double)doGetValue();
+ wsPreferenceStore.setValue(getEditedPreference(), ((Float)value).doubleValue());
+ final ValueDiff diff = new ValueDiff() {
+
+ @Override
+ public Object getOldValue() {
+ return oldValue;
+ }
+
+ @Override
+ public Object getNewValue() {
+ return ((Float)value).doubleValue();
+ }
+ };
+ fireValueChange(diff);
+ }
+ }
+
+
+
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/IntegerDiagramViewObservableValue.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/IntegerDiagramViewObservableValue.java
new file mode 100644
index 00000000000..f89b117504a
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/IntegerDiagramViewObservableValue.java
@@ -0,0 +1,79 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding;
+
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+/**
+ *
+ * Class used to edit integer preferences
+ *
+ */
+public class IntegerDiagramViewObservableValue extends AbstractDiagramPreferencesObservableValue {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param diagram
+ * the edited diagram
+ * @param preferenceName
+ * the name of the edited preference
+ * @param store
+ * the edited preference store
+ */
+ public IntegerDiagramViewObservableValue(final Diagram diagram, final String preferenceName, final IPreferenceStore store) {
+ super(diagram, preferenceName, store);
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.databinding.observable.value.IObservableValue#getValueType()
+ *
+ * @return
+ */
+ public final Object getValueType() {
+ return EcorePackage.eINSTANCE.getEInt();
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doGetValue()
+ *
+ * @return
+ */
+ @Override
+ protected final Object doGetValue() {
+ final IPreferenceStore wsPreferenceStore = getEditedPreferenceStore();
+ return wsPreferenceStore.getInt(getEditedPreference());
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doSetValue(java.lang.Object)
+ *
+ * @param value
+ */
+ @Override
+ protected void doSetValue(Object value) {
+ if(value instanceof Integer) {
+ final IPreferenceStore wsPreferenceStore = getEditedPreferenceStore();
+ wsPreferenceStore.setValue(getEditedPreference(), ((Integer)value).intValue());
+ }
+ }
+
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/RulersUnitObservableValue.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/RulersUnitObservableValue.java
new file mode 100644
index 00000000000..7702194e980
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/RulersUnitObservableValue.java
@@ -0,0 +1,65 @@
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding;
+
+import java.text.NumberFormat;
+import java.text.ParseException;
+
+import org.eclipse.gmf.runtime.diagram.ui.internal.properties.WorkspaceViewerProperties;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.UnitsConverterUtils;
+
+
+
+@SuppressWarnings("restriction")
+//suppress warning for WorkspaceViewerProperties
+public class RulersUnitObservableValue extends IntegerDiagramViewObservableValue {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param view
+ * the view
+ * @param store
+ * the edited preference store
+ */
+ public RulersUnitObservableValue(final Diagram view, final IPreferenceStore store) {
+ super(view, WorkspaceViewerProperties.RULERUNIT, store);
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.properties.databinding.IntegerDiagramViewObservableValue#doSetValue(java.lang.Object)
+ *
+ * @param value
+ */
+ @Override
+ protected void doSetValue(final Object value) {
+ if(value instanceof Integer) {
+ final Integer oldValue = (Integer)doGetValue();
+ final IPreferenceStore wsPreferenceStore = getEditedPreferenceStore();
+ final Double oldGridSpacing = wsPreferenceStore.getDouble(WorkspaceViewerProperties.GRIDSPACING);
+
+
+ final String newValue = UnitsConverterUtils.convertUnits((Integer)oldValue, (Integer)value, NumberFormat.getInstance().format(oldGridSpacing));
+
+ Number number = null;
+ try {
+ number = NumberFormat.getInstance().parse(newValue);
+ } catch (ParseException e) {
+ //nothing to do
+ number = null;
+ return;
+ }
+
+ //we set the new unit value
+ super.doSetValue(value);
+
+ //we set the new spacing value
+ final double newGridSpacing = number.doubleValue();
+ wsPreferenceStore.setValue(WorkspaceViewerProperties.GRIDSPACING, newGridSpacing);
+ }
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/Messages.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/Messages.java
index 6efd7d9683c..88269b2493c 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/Messages.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/Messages.java
@@ -35,6 +35,8 @@ public class Messages extends NLS {
public static String DecoratedModelElement_WEST;
+ public static String DiagramPreferencesDefaultButton_ResetDefault;
+
public static String GradientDataModelElement_Horizontal;
public static String GradientDataModelElement_Vertical;
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/messages.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/messages.properties
index 2c1a13cf3d3..7da85c2df8a 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/messages.properties
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/messages.properties
@@ -7,5 +7,6 @@ DecoratedModelElement_SOUTH=Bottom
DecoratedModelElement_SOUTH_EAST=Bottom Right
DecoratedModelElement_SOUTH_WEST=Bottom Left
DecoratedModelElement_WEST=Left
+DiagramPreferencesDefaultButton_ResetDefault=Reset Default
GradientDataModelElement_Horizontal=Horizontal
GradientDataModelElement_Vertical=Vertical
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/RulerAndGridModelElement.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/RulerAndGridModelElement.java
new file mode 100644
index 00000000000..87f0f8cfd2b
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/RulerAndGridModelElement.java
@@ -0,0 +1,191 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement;
+
+import org.eclipse.core.databinding.observable.IObservable;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gef.rulers.RulerProvider;
+import org.eclipse.gmf.runtime.diagram.ui.internal.properties.WorkspaceViewerProperties;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.papyrus.infra.gmfdiag.common.providers.LineStyleLabelProvider;
+import org.eclipse.papyrus.infra.gmfdiag.common.providers.UnitsLabelProvider;
+import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.BooleanDiagramViewObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.DoubleDiagramViewObservaleValue;
+import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.IntegerDiagramViewObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.RulersUnitObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.properties.util.RulersAndGridPropertyConstants;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.StaticContentProvider;
+import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
+import org.eclipse.papyrus.views.properties.modelelement.AbstractModelElement;
+
+/**
+ *
+ * @author vl222926
+ * This class provides the ModelElement for the property view
+ */
+@SuppressWarnings("restriction")
+//suppress the warning for WorkspaceViewerProperties
+public class RulerAndGridModelElement extends AbstractModelElement {
+
+
+
+ /**
+ * the diagram for which we are editing preferences
+ */
+ private Diagram diagram;
+
+ /**
+ * the edited preference store
+ */
+ private IPreferenceStore store;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param view
+ * the diagram for which we are editing preferences
+ * @param domain
+ * the editing domain
+ * @param context
+ * the data context
+ * @param preferenceStore
+ * the edited preference store
+ */
+ public RulerAndGridModelElement(final Diagram view, final EditingDomain domain, final DataContextElement context, final IPreferenceStore preferenceStore) {
+ this.diagram = view;
+ this.store = preferenceStore;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.views.properties.modelelement.AbstractModelElement#dispose()
+ *
+ */
+ @Override
+ public void dispose() {
+ super.dispose();
+ this.diagram = null;
+ this.store = null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.views.properties.modelelement.AbstractModelElement#doGetObservable(java.lang.String)
+ *
+ * @param propertyPath
+ * @return
+ */
+ @Override
+ protected IObservable doGetObservable(final String propertyPath) {
+ IObservable observable = null;
+ if(RulersAndGridPropertyConstants.GRID_IS_DISPLAYING_GRID.equals(propertyPath)) {
+ observable = new BooleanDiagramViewObservableValue(this.diagram, WorkspaceViewerProperties.VIEWGRID, this.store);
+ }
+ if(RulersAndGridPropertyConstants.RULERS_IS_DISPLAYING_RULER.equals(propertyPath)) {
+ observable = new BooleanDiagramViewObservableValue(this.diagram, WorkspaceViewerProperties.VIEWRULERS, this.store);
+ }
+ if(RulersAndGridPropertyConstants.GRID_IS_IN_FRONT.equals(propertyPath)) {
+ observable = new BooleanDiagramViewObservableValue(diagram, WorkspaceViewerProperties.GRIDORDER, this.store);
+ }
+ if(RulersAndGridPropertyConstants.GRID_COLOR.equals(propertyPath)) {
+ observable = new IntegerDiagramViewObservableValue(diagram, WorkspaceViewerProperties.GRIDLINECOLOR, this.store);
+ }
+ if(RulersAndGridPropertyConstants.GRID_STYLE.equals(propertyPath)) {
+ observable = new IntegerDiagramViewObservableValue(diagram, WorkspaceViewerProperties.GRIDLINESTYLE, this.store);
+ }
+ if(RulersAndGridPropertyConstants.GRID_SPACING.equals(propertyPath)) {
+ observable = new DoubleDiagramViewObservaleValue(diagram, WorkspaceViewerProperties.GRIDSPACING, this.store);
+ }
+ if(RulersAndGridPropertyConstants.GRID_IS_SNAP_TO_GRID.equals(propertyPath)) {
+ observable = new BooleanDiagramViewObservableValue(this.diagram, WorkspaceViewerProperties.SNAPTOGRID, this.store);
+ }
+ if(RulersAndGridPropertyConstants.GRID_IS_SNAP_TO_SHAPE.equals(propertyPath)) {
+ observable = new BooleanDiagramViewObservableValue(this.diagram, WorkspaceViewerProperties.SNAPTOGEOMETRY, this.store);
+ }
+ if(RulersAndGridPropertyConstants.RULERS_UNITS.equals(propertyPath)) {
+ observable = new RulersUnitObservableValue(diagram, this.store);
+ }
+ return observable;
+ }
+
+
+
+ /**
+ *
+ * @see org.eclipse.papyrus.views.properties.modelelement.AbstractModelElement#getContentProvider(java.lang.String)
+ *
+ * @param propertyPath
+ * @return
+ */
+ @Override
+ public IStaticContentProvider getContentProvider(String propertyPath) {
+ if(RulersAndGridPropertyConstants.GRID_STYLE.equals(propertyPath)) {
+ return new StaticContentProvider(new Object[]{ Graphics.LINE_DASH, Graphics.LINE_DASHDOT, Graphics.LINE_DASHDOTDOT, Graphics.LINE_DOT, Graphics.LINE_SOLID, Graphics.LINE_CUSTOM });
+ }
+ if(RulersAndGridPropertyConstants.RULERS_UNITS.equals(propertyPath)) {
+ return new StaticContentProvider(new Object[]{ RulerProvider.UNIT_INCHES, RulerProvider.UNIT_CENTIMETERS, RulerProvider.UNIT_PIXELS });
+ }
+ return super.getContentProvider(propertyPath);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.views.properties.modelelement.AbstractModelElement#getLabelProvider(java.lang.String)
+ *
+ * @param propertyPath
+ * @return
+ */
+ @Override
+ public ILabelProvider getLabelProvider(final String propertyPath) {
+ if(RulersAndGridPropertyConstants.GRID_STYLE.equals(propertyPath)) {
+ return new LineStyleLabelProvider();
+ }
+ if(RulersAndGridPropertyConstants.RULERS_UNITS.equals(propertyPath)) {
+ return new UnitsLabelProvider();
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.views.properties.modelelement.AbstractModelElement#isMandatory(java.lang.String)
+ *
+ * @param propertyPath
+ * @return
+ */
+ @Override
+ public boolean isMandatory(final String propertyPath) {
+ if(RulersAndGridPropertyConstants.GRID_STYLE.equals(propertyPath) || RulersAndGridPropertyConstants.RULERS_UNITS.equals(propertyPath)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.views.properties.modelelement.AbstractModelElement#forceRefresh(java.lang.String)
+ *
+ * @param propertyPath
+ * @return
+ */
+ @Override
+ public boolean forceRefresh(final String propertyPath) {
+ return true;
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/RulersAndGridModelElementFactory.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/RulersAndGridModelElementFactory.java
new file mode 100644
index 00000000000..0709999a89e
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/RulersAndGridModelElementFactory.java
@@ -0,0 +1,61 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement;
+
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil;
+import org.eclipse.papyrus.infra.gmfdiag.properties.Activator;
+import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
+import org.eclipse.papyrus.views.properties.modelelement.ModelElement;
+import org.eclipse.papyrus.views.properties.modelelement.ModelElementFactory;
+
+/**
+ *
+ * @author vl222926
+ * The factory used to edit Rulers and Grid properties
+ */
+public class RulersAndGridModelElementFactory implements ModelElementFactory {
+
+ /**
+ *
+ * @see org.eclipse.papyrus.views.properties.modelelement.ModelElementFactory#createFromSource(java.lang.Object,
+ * org.eclipse.papyrus.views.properties.contexts.DataContextElement)
+ *
+ * @param sourceElement
+ * @param context
+ * @return
+ */
+ public ModelElement createFromSource(Object sourceElement, DataContextElement context) {
+ if(sourceElement instanceof EditPart) {
+ final IPreferenceStore preferenceStore = DiagramEditPartsUtil.getDiagramWorkspacePreferenceStore((EditPart)sourceElement);
+ View view = NotationHelper.findView(DiagramEditPartsUtil.getDiagramEditPart((EditPart)sourceElement));
+ if(preferenceStore != null && view instanceof Diagram) {
+ EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(view);
+ return new RulerAndGridModelElement((Diagram)view, domain, context, preferenceStore);
+ }
+ }
+
+ Activator.log.warn("The selected element cannot be resolved to a Diagram View"); //$NON-NLS-1$
+ return null;
+ }
+
+
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/util/NotationUtil.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/util/NotationUtil.java
index 18ca429fd7e..1fbdd42e1ac 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/util/NotationUtil.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/util/NotationUtil.java
@@ -1,3 +1,16 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.properties.util;
import org.eclipse.core.runtime.IAdaptable;
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/util/RulersAndGridPropertyConstants.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/util/RulersAndGridPropertyConstants.java
new file mode 100644
index 00000000000..03ae14a07fe
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/util/RulersAndGridPropertyConstants.java
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.util;
+
+/**
+ *
+ *
+ * This class provides the constants used in the declaration of the property view for Rulers and Grid
+ */
+public class RulersAndGridPropertyConstants {
+
+ private RulersAndGridPropertyConstants() {
+ // to prevent instanciation
+ }
+
+ /**
+ * the edited data
+ */
+ public static final String GRID_IS_DISPLAYING_GRID = "grid.isDisplayingGrid";
+
+ public static final String RULERS_IS_DISPLAYING_RULER = "rulers.isDisplayingRulers";
+
+ public static final String GRID_IS_IN_FRONT = "grid.isInFront";
+
+ public static final String GRID_COLOR = "grid.color";
+
+ public static final String GRID_STYLE = "grid.style";
+
+ public static final String GRID_SPACING = "grid.spacing";
+
+ public static final String GRID_IS_SNAP_TO_GRID = "grid.isSnapToGrid";
+
+ public static final String GRID_IS_SNAP_TO_SHAPE = "grid.isSnapToShapes";
+
+ public static final String RULERS_UNITS = "rulers.units";
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/widget/DiagramPreferencesDefaultButton.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/widget/DiagramPreferencesDefaultButton.java
new file mode 100644
index 00000000000..c565cd235a5
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/widget/DiagramPreferencesDefaultButton.java
@@ -0,0 +1,159 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.widget;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil;
+import org.eclipse.papyrus.infra.gmfdiag.properties.messages.Messages;
+import org.eclipse.papyrus.views.properties.modelelement.DataSource;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ *
+ * The button used to reset the preference of the diagram to the defaut values
+ *
+ */
+public class DiagramPreferencesDefaultButton extends Composite {
+
+ private Button button;
+
+ private SelectionListener listener;
+
+ protected DataSource input;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parent
+ * @param style
+ */
+ public DiagramPreferencesDefaultButton(Composite parent, int style) {
+ super(parent, style);
+ GridLayout layout = new GridLayout(1, false);
+ setLayout(layout);
+ createButton();
+ }
+
+ /**
+ * create the reset button
+ */
+ protected void createButton() {
+ button = new Button(this, SWT.NONE);
+ button.setText(Messages.DiagramPreferencesDefaultButton_ResetDefault);
+ this.listener = createListener();
+ button.addSelectionListener(this.listener);
+ }
+
+ /**
+ * Sets the input DataSource for this Property editor.
+ *
+ * @param input
+ */
+ public void setInput(DataSource input) {
+ this.input = input;
+ }
+
+ /**
+ * @return the input DataSource for this Property editor
+ */
+ public DataSource getInput() {
+ return input;
+ }
+
+
+ /**
+ *
+ * @return
+ * the listener to use for the button
+ */
+ private SelectionListener createListener() {
+ final SelectionListener listener = new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ resetProperties();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ //nothing to do
+ }
+ };
+ return listener;
+ }
+
+ /**
+ *
+ * @see org.eclipse.swt.widgets.Widget#dispose()
+ *
+ */
+ @Override
+ public void dispose() {
+ super.dispose();
+ this.button.removeSelectionListener(this.listener);
+ this.input = null;
+ }
+
+ /**
+ * Reset the properties to their default values
+ */
+ protected void resetProperties() {
+ final IPreferenceStore store = getPreferencesStore();
+ if(store != null) {
+ store.setValue(PreferencesConstantsHelper.VIEW_GRID_CONSTANT, store.getDefaultBoolean(PreferencesConstantsHelper.VIEW_GRID_CONSTANT));
+ store.setValue(PreferencesConstantsHelper.VIEW_RULERS_CONSTANT, store.getDefaultBoolean(PreferencesConstantsHelper.VIEW_RULERS_CONSTANT));
+ store.setValue(PreferencesConstantsHelper.GRID_ORDER_CONSTANT, store.getDefaultBoolean(PreferencesConstantsHelper.GRID_ORDER_CONSTANT));
+ store.setValue(PreferencesConstantsHelper.GRID_LINE_COLOR_CONSTANT, store.getDefaultInt(PreferencesConstantsHelper.GRID_LINE_COLOR_CONSTANT));
+ store.setValue(PreferencesConstantsHelper.GRID_LINE_STYLE_CONSTANT, store.getDefaultBoolean(PreferencesConstantsHelper.GRID_LINE_STYLE_CONSTANT));
+ store.setValue(PreferencesConstantsHelper.GRID_SPACING_CONSTANT, store.getDefaultDouble(PreferencesConstantsHelper.GRID_SPACING_CONSTANT));
+ store.setValue(PreferencesConstantsHelper.SNAP_TO_GRID_CONSTANT, store.getDefaultBoolean(PreferencesConstantsHelper.SNAP_TO_GRID_CONSTANT));
+ store.setValue(PreferencesConstantsHelper.SNAP_TO_GEOMETRY_CONSTANT, store.getDefaultBoolean(PreferencesConstantsHelper.SNAP_TO_GEOMETRY_CONSTANT));
+ store.setValue(PreferencesConstantsHelper.RULER_UNITS_CONSTANT, store.getDefaultInt(PreferencesConstantsHelper.RULER_UNITS_CONSTANT));
+
+ //doesn't work (ClassCastException due to GMF)
+ // store.setToDefault(PreferencesConstantsHelper.SHOW_GRID_CONSTANT);
+ // store.setToDefault(PreferencesConstantsHelper.SHOW_RULER_CONSTANT);
+ // store.setToDefault(PreferencesConstantsHelper.GRID_ORDER_CONSTANT);
+ // store.setToDefault(PreferencesConstantsHelper.GRID_COLOR_CONSTANT);
+ // store.setToDefault(PreferencesConstantsHelper.GRID_STYLE_CONSTANT);
+ // store.setToDefault(PreferencesConstantsHelper.GRID_SPACING_CONSTANT);
+ // store.setToDefault(PreferencesConstantsHelper.SNAP_TO_GRID_CONSTANT);
+ // store.setToDefault(PreferencesConstantsHelper.SNAP_TO_SHAPE_CONSTANT);
+ // store.setToDefault(PreferencesConstantsHelper.RULER_UNITS_CONSTANT);
+ }
+ }
+
+
+ /**
+ *
+ * @return
+ * the preference store
+ */
+ protected IPreferenceStore getPreferencesStore() {
+ final IStructuredSelection selection = this.input.getSelection();
+ final Object firstElement = selection.getFirstElement();
+ if(firstElement instanceof EditPart) {
+ return DiagramEditPartsUtil.getDiagramWorkspacePreferenceStore((EditPart)firstElement);
+ }
+ return null;
+ }
+
+}

Back to the top