Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2013-12-18 09:37:23 +0000
committerVincent Lorenzo2013-12-18 09:37:23 +0000
commitf656a98b8b47da33f9b01450b95d7ddcec1a1981 (patch)
tree7bdaaec109de8fa4d767d6272bfeb97844749976 /plugins
parentc5a90f43ab938b8e2723ba7dd9e4b52d30827419 (diff)
downloadorg.eclipse.papyrus-f656a98b8b47da33f9b01450b95d7ddcec1a1981.tar.gz
org.eclipse.papyrus-f656a98b8b47da33f9b01450b95d7ddcec1a1981.tar.xz
org.eclipse.papyrus-f656a98b8b47da33f9b01450b95d7ddcec1a1981.zip
423799: [Diagram]Rulers and Grid preferences are not customizable for
each diagrams https://bugs.eclipse.org/bugs/show_bug.cgi?id=423799 Fix bad preferences initialization reopening diagrams (bad preference initialization)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java32
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/RulersAndGridGroup.java3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/widget/DiagramPreferencesDefaultButton.java69
4 files changed, 59 insertions, 48 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java
index 03d97ac1ca3..9f5c2f46113 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/SynchronizableGmfDiagramEditor.java
@@ -222,25 +222,19 @@ public class SynchronizableGmfDiagramEditor extends DiagramDocumentEditor implem
//set the preferences
final IPreferenceStore localStore = getWorkspaceViewerPreferenceStore();
- // localStore.setValue(PreferencesConstantsHelper.SHOW_GRID_CONSTANT, viewGrid);
- // localStore.setValue(PreferencesConstantsHelper.SHOW_RULER_CONSTANT, viewRuler);
- // localStore.setValue(PreferencesConstantsHelper.RULER_UNITS_CONSTANT, rulerUnit);
- // localStore.setValue(PreferencesConstantsHelper.SNAP_TO_GRID_CONSTANT, snapToGrid);
- // localStore.setValue(PreferencesConstantsHelper.SNAP_TO_SHAPE_CONSTANT, snapToGeometry);
- // localStore.setValue(PreferencesConstantsHelper.GRID_COLOR_CONSTANT, gridLineColor);
- // localStore.setValue(PreferencesConstantsHelper.GRID_SPACING_CONSTANT, gridSpacing);
- // localStore.setValue(PreferencesConstantsHelper.GRID_ORDER_CONSTANT, gridOrder);
- // localStore.setValue(PreferencesConstantsHelper.GRID_STYLE_CONSTANT, gridLineStyle);
-
- localStore.setDefault(PreferencesConstantsHelper.VIEW_GRID_CONSTANT, viewGrid);
- localStore.setDefault(PreferencesConstantsHelper.VIEW_RULERS_CONSTANT, viewRuler);
- localStore.setDefault(PreferencesConstantsHelper.RULER_UNITS_CONSTANT, rulerUnit);
- localStore.setDefault(PreferencesConstantsHelper.SNAP_TO_GRID_CONSTANT, snapToGrid);
- localStore.setDefault(PreferencesConstantsHelper.SNAP_TO_GEOMETRY_CONSTANT, snapToGeometry);
- localStore.setDefault(PreferencesConstantsHelper.GRID_LINE_COLOR_CONSTANT, gridLineColor);
- localStore.setDefault(PreferencesConstantsHelper.GRID_SPACING_CONSTANT, gridSpacing);
- localStore.setDefault(PreferencesConstantsHelper.GRID_ORDER_CONSTANT, gridOrder);
- localStore.setDefault(PreferencesConstantsHelper.GRID_LINE_STYLE_CONSTANT, gridLineStyle);
+ localStore.setValue(PreferencesConstantsHelper.VIEW_GRID_CONSTANT, viewGrid);
+ localStore.setValue(PreferencesConstantsHelper.VIEW_RULERS_CONSTANT, viewRuler);
+ localStore.setValue(PreferencesConstantsHelper.RULER_UNITS_CONSTANT, rulerUnit);
+ localStore.setValue(PreferencesConstantsHelper.SNAP_TO_GRID_CONSTANT, snapToGrid);
+ localStore.setValue(PreferencesConstantsHelper.SNAP_TO_GEOMETRY_CONSTANT, snapToGeometry);
+ localStore.setValue(PreferencesConstantsHelper.GRID_LINE_COLOR_CONSTANT, gridLineColor);
+ localStore.setValue(PreferencesConstantsHelper.GRID_SPACING_CONSTANT, gridSpacing);
+
+ //to force refresh
+ localStore.setValue(PreferencesConstantsHelper.GRID_ORDER_CONSTANT, !gridOrder);
+ localStore.setValue(PreferencesConstantsHelper.GRID_ORDER_CONSTANT, gridOrder);
+
+ localStore.setValue(PreferencesConstantsHelper.GRID_LINE_STYLE_CONSTANT, gridLineStyle);
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/RulersAndGridGroup.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/RulersAndGridGroup.java
index 1c7033d76ae..524d1516087 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/RulersAndGridGroup.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.preferences/src/org/eclipse/papyrus/infra/gmfdiag/preferences/ui/RulersAndGridGroup.java
@@ -127,8 +127,11 @@ public class RulersAndGridGroup extends AbstractGroup {
store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.SNAP_TO_GEOMETRY), false);
store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.GRID_LINE_STYLE), Graphics.LINE_CUSTOM);
store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.GRID_ORDER), false);
+ //to force the refresh of the value
+ PreferenceConverter.setDefault(store, PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.GRID_LINE_COLOR), new org.eclipse.swt.graphics.RGB(250, 0, 0));
final int rgbValue = 50;
PreferenceConverter.setDefault(store, PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.GRID_LINE_COLOR), new org.eclipse.swt.graphics.RGB(rgbValue, rgbValue, rgbValue));
+
store.setDefault(PreferencesConstantsHelper.getPapyrusEditorConstant(PreferencesConstantsHelper.GRID_SPACING), 20);
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF
index 8c556d1fc6f..80c9d55034a 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF
@@ -19,7 +19,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
org.eclipse.papyrus.uml.tools;bundle-version="1.0.0",
org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.2.0",
- org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.0"
+ org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="1.0.0"
Export-Package: org.eclipse.papyrus.infra.gmfdiag.properties.extension,
org.eclipse.papyrus.infra.gmfdiag.properties.modelelement
Bundle-Vendor: %Bundle-Vendor
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
index c565cd235a5..eda0cb82580 100644
--- 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
@@ -14,15 +14,22 @@
package org.eclipse.papyrus.infra.gmfdiag.properties.widget;
import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
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.preferences.Activator;
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.graphics.RGB;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
@@ -80,11 +87,9 @@ public class DiagramPreferencesDefaultButton extends Composite {
return input;
}
-
/**
*
- * @return
- * the listener to use for the button
+ * @return the listener to use for the button
*/
private SelectionListener createListener() {
final SelectionListener listener = new SelectionListener() {
@@ -94,7 +99,7 @@ public class DiagramPreferencesDefaultButton extends Composite {
}
public void widgetDefaultSelected(SelectionEvent e) {
- //nothing to do
+ // nothing to do
}
};
return listener;
@@ -116,36 +121,28 @@ public class DiagramPreferencesDefaultButton extends Composite {
* 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);
+ final IPreferenceStore globalPreferenceStore = Activator.getDefault().getPreferenceStore();
+ final String diagramType = getDiagramType();
+ if(store != null && diagramType != null && !diagramType.equals("")) { //$NON-NLS-1$
+ store.setValue(PreferencesConstantsHelper.VIEW_GRID_CONSTANT, globalPreferenceStore.getBoolean(PreferencesConstantsHelper.getDiagramConstant(diagramType, PreferencesConstantsHelper.VIEW_GRID)));
+ store.setValue(PreferencesConstantsHelper.VIEW_RULERS_CONSTANT, globalPreferenceStore.getBoolean(PreferencesConstantsHelper.getDiagramConstant(diagramType, PreferencesConstantsHelper.VIEW_RULER)));
+ store.setValue(PreferencesConstantsHelper.GRID_ORDER_CONSTANT, globalPreferenceStore.getBoolean(PreferencesConstantsHelper.getDiagramConstant(diagramType, PreferencesConstantsHelper.GRID_ORDER)));
+
+ final RGB gridColor = PreferenceConverter.getColor(globalPreferenceStore, PreferencesConstantsHelper.getDiagramConstant(diagramType, PreferencesConstantsHelper.GRID_LINE_COLOR));
+ store.setValue(PreferencesConstantsHelper.GRID_LINE_COLOR_CONSTANT, FigureUtilities.RGBToInteger(gridColor));
+ store.setValue(PreferencesConstantsHelper.GRID_LINE_STYLE_CONSTANT, globalPreferenceStore.getInt(PreferencesConstantsHelper.getDiagramConstant(diagramType, PreferencesConstantsHelper.GRID_LINE_STYLE)));
+ store.setValue(PreferencesConstantsHelper.GRID_SPACING_CONSTANT, globalPreferenceStore.getDouble(PreferencesConstantsHelper.getDiagramConstant(diagramType, PreferencesConstantsHelper.GRID_SPACING)));
+ store.setValue(PreferencesConstantsHelper.SNAP_TO_GRID_CONSTANT, globalPreferenceStore.getBoolean(PreferencesConstantsHelper.getDiagramConstant(diagramType, PreferencesConstantsHelper.SNAP_TO_GRID)));
+ store.setValue(PreferencesConstantsHelper.SNAP_TO_GEOMETRY_CONSTANT, globalPreferenceStore.getBoolean(PreferencesConstantsHelper.getDiagramConstant(diagramType, PreferencesConstantsHelper.SNAP_TO_GEOMETRY)));
+ store.setValue(PreferencesConstantsHelper.RULER_UNITS_CONSTANT, globalPreferenceStore.getInt(PreferencesConstantsHelper.getDiagramConstant(diagramType, PreferencesConstantsHelper.RULER_UNITS)));
}
}
-
/**
*
- * @return
- * the preference store
+ * @return the preference store
*/
protected IPreferenceStore getPreferencesStore() {
final IStructuredSelection selection = this.input.getSelection();
@@ -156,4 +153,20 @@ public class DiagramPreferencesDefaultButton extends Composite {
return null;
}
+ /**
+ *
+ * @return
+ * the type of the diagram
+ */
+ protected String getDiagramType() {
+ final IStructuredSelection selection = this.input.getSelection();
+ final Object firstElement = selection.getFirstElement();
+ if(firstElement instanceof EditPart) {
+ final DiagramEditPart diagramEditPart = DiagramEditPartsUtil.getDiagramEditPart((EditPart)firstElement);
+ final Diagram diagram = (Diagram)diagramEditPart.getAdapter(Diagram.class);
+ return diagram.getType();
+ }
+ return ""; //$NON-NLS-1$
+ }
+
}

Back to the top