Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-03-01 17:20:08 +0000
committercletavernie2012-03-01 17:20:08 +0000
commit14dd209f3e1276dcec9133ba094bf876d2be5a84 (patch)
tree8c16664f09744f9f91dc6f3a83be9163293e1aa8 /plugins/views
parent3f84d7084be994f53705ef85244c2e23309d964c (diff)
downloadorg.eclipse.papyrus-14dd209f3e1276dcec9133ba094bf876d2be5a84.tar.gz
org.eclipse.papyrus-14dd209f3e1276dcec9133ba094bf876d2be5a84.tar.xz
org.eclipse.papyrus-14dd209f3e1276dcec9133ba094bf876d2be5a84.zip
370797: [Theme] Papyrus should provide a support for CSS files on its diagrams
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370797
Diffstat (limited to 'plugins/views')
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/model/Environment.xmi7
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EditionDialog.java22
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/PropertyEditorFactory.java2
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/PreferencesModelElement.java37
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/PreferencesModelElementFactory.java23
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/observable/PreferencesObservableValue.java63
6 files changed, 148 insertions, 6 deletions
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/model/Environment.xmi b/plugins/views/properties/org.eclipse.papyrus.views.properties/model/Environment.xmi
index 51ad66f8680..4cc013351d6 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/model/Environment.xmi
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/model/Environment.xmi
@@ -2,9 +2,7 @@
<environment:Environment
xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:environment="http://www.eclipse.org/papyrus/properties/environment/0.9"
- xsi:schemaLocation="http://www.eclipse.org/papyrus/properties/environment/0.9 ../../../plugin/org.eclipse.papyrus.views.properties.model/Model/Properties.ecore#//environment">
+ xmlns:environment="http://www.eclipse.org/papyrus/properties/environment/0.9">
<constraintTypes
label="EMF Instance Of (Deprecated)"
constraintClass="org.eclipse.papyrus.infra.constraints.constraints.EMFInstanceOfConstraint"/>
@@ -26,6 +24,9 @@
<modelElementFactories
name="Annotation Factory"
factoryClass="org.eclipse.papyrus.views.properties.modelelement.AnnotationModelElementFactory"/>
+ <modelElementFactories
+ name="Basic preferences Factory"
+ factoryClass="org.eclipse.papyrus.views.properties.modelelement.PreferencesModelElementFactory"/>
<widgetTypes
label="Label"
widgetClass="Label"/>
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EditionDialog.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EditionDialog.java
index 4f604992350..c2bcf7efc2c 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EditionDialog.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/EditionDialog.java
@@ -61,15 +61,33 @@ public class EditionDialog extends SelectionDialog {
private Set<XWTSection> sections = new HashSet<XWTSection>();
+ private boolean cancelable = false;
+
/**
*
* Constructor.
*
* @param shell
* The shell in which the dialog will be opened
+ * @param cancelable
+ * Whether the cancel button is active or not. The values are data-binded, ie.
+ * edited in real time, before the ok button is pressed. If the cancel button
+ * is active, callers are responsible for undoing the changes.
*/
- protected EditionDialog(Shell shell) {
+ protected EditionDialog(Shell shell, boolean cancelable) {
super(shell);
+ this.cancelable = cancelable;
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param shell
+ * The shell in which the dialog will be opened
+ */
+ protected EditionDialog(Shell shell) {
+ this(shell, false);
}
@Override
@@ -90,7 +108,7 @@ public class EditionDialog extends SelectionDialog {
display();
//The values are data-binded, thus are edited in real time. It is not possible to cancel (However, Ctrl+Z should work)
- getButton(IDialogConstants.CANCEL_ID).setEnabled(false);
+ getButton(IDialogConstants.CANCEL_ID).setEnabled(cancelable);
}
@Override
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/PropertyEditorFactory.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/PropertyEditorFactory.java
index eec3f3598fe..8364885ebdb 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/PropertyEditorFactory.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/creation/PropertyEditorFactory.java
@@ -87,7 +87,7 @@ public class PropertyEditorFactory implements ReferenceValueFactory {
ViewConstraintEngine constraintEngine = ConfigurationManager.instance.constraintEngine;
Set<View> views = constraintEngine.getViews(selection);
if(!views.isEmpty()) {
- EditionDialog dialog = new EditionDialog(widget.getShell());
+ EditionDialog dialog = new EditionDialog(widget.getShell(), true);
dialog.setViews(views);
dialog.setInput(source);
dialog.setTitle(getCreationDialogTitle());
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/PreferencesModelElement.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/PreferencesModelElement.java
new file mode 100644
index 00000000000..e64f96dde16
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/PreferencesModelElement.java
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.properties.modelelement;
+
+import org.eclipse.core.databinding.observable.IObservable;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
+import org.eclipse.papyrus.views.properties.observable.PreferencesObservableValue;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+
+
+public class PreferencesModelElement extends AbstractModelElement {
+
+ protected DataContextElement context;
+
+ protected IPreferenceStore store;
+
+ public PreferencesModelElement(DataContextElement context) {
+ this.context = context;
+ store = new ScopedPreferenceStore(InstanceScope.INSTANCE, context.getName());
+ }
+
+ @Override
+ protected IObservable doGetObservable(String propertyPath) {
+ return new PreferencesObservableValue(propertyPath, store);
+ }
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/PreferencesModelElementFactory.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/PreferencesModelElementFactory.java
new file mode 100644
index 00000000000..0aa2db099db
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/PreferencesModelElementFactory.java
@@ -0,0 +1,23 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.properties.modelelement;
+
+import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
+
+
+public class PreferencesModelElementFactory implements ModelElementFactory {
+
+ public ModelElement createFromSource(Object sourceElement, DataContextElement context) {
+ return new PreferencesModelElement(context);
+ }
+
+}
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/observable/PreferencesObservableValue.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/observable/PreferencesObservableValue.java
new file mode 100644
index 00000000000..3ee1c2d0114
--- /dev/null
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/observable/PreferencesObservableValue.java
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.views.properties.observable;
+
+import org.eclipse.core.databinding.observable.Diffs;
+import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+
+public class PreferencesObservableValue extends AbstractObservableValue implements IPropertyChangeListener {
+
+ protected String key;
+
+ protected IPreferenceStore store;
+
+ public PreferencesObservableValue(String key, IPreferenceStore store) {
+ this.key = key;
+ this.store = store;
+ store.addPropertyChangeListener(this);
+ }
+
+ public Object getValueType() {
+ return String.class;
+ }
+
+ @Override
+ protected Object doGetValue() {
+ if(store.contains(key)) {
+ return store.getString(key);
+ }
+ return null;
+ }
+
+ @Override
+ protected void doSetValue(Object value) {
+ if(value instanceof String) {
+ store.setValue(key, (String)value);
+ }
+ }
+
+ public void propertyChange(PropertyChangeEvent event) {
+ if(event.getProperty().equals(key)) {
+ fireValueChange(Diffs.createValueDiff(event.getOldValue(), event.getNewValue()));
+ }
+ }
+
+ @Override
+ public void dispose() {
+ store.removePropertyChangeListener(this);
+ super.dispose();
+ }
+}

Back to the top