Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-09-05 19:02:30 +0000
committerCamille Letavernier2014-09-08 12:18:49 +0000
commit826fe6e5382002fbfee854b4d015012090d4e97b (patch)
tree880411748f2c369fc9e0141a7616af2a9f12a835 /plugins/views/properties
parentc53e3dfd6cc0e8a03c5e435dad88bcc1fba58f2c (diff)
downloadorg.eclipse.papyrus-826fe6e5382002fbfee854b4d015012090d4e97b.tar.gz
org.eclipse.papyrus-826fe6e5382002fbfee854b4d015012090d4e97b.tar.xz
org.eclipse.papyrus-826fe6e5382002fbfee854b4d015012090d4e97b.zip
443417: [Properties view] Gradient editor not refreshed when switching selection
https://bugs.eclipse.org/bugs/show_bug.cgi?id=443417 The ViewEditor class in the properties-view framework implements what amounts to a nested property sheet. Accordingly, when its containing property editors are reused for a new selection, it also needs to reuse its contents for the new selection. This requires keeping the same DisplayEngine to be reused and reusing the nested XWTSections that it manages.
Diffstat (limited to 'plugins/views/properties')
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/AbstractPropertyEditor.java13
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/ViewEditor.java85
2 files changed, 83 insertions, 15 deletions
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/AbstractPropertyEditor.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/AbstractPropertyEditor.java
index cb86e40f0c2..5c006213a09 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/AbstractPropertyEditor.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/AbstractPropertyEditor.java
@@ -10,6 +10,7 @@
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Thibault Le Ouay t.leouay@sherpa-eng.com - Add binding implementation
* Christian W. Damus (CEA) - bug 417409
+ * Christian W. Damus (CEA) - bug 443417
*
*****************************************************************************/
package org.eclipse.papyrus.views.properties.widgets;
@@ -309,13 +310,13 @@ public abstract class AbstractPropertyEditor implements IChangeListener, Customi
final DataSource oldInput = this.input;
if (input != oldInput) {
if (oldInput != null) {
- oldInput.removeDataSourceListener(getDataSourceListener());
+ unhookDataSourceListener(oldInput);
}
this.input = input;
if (input != null) {
- input.addDataSourceListener(getDataSourceListener());
+ hookDataSourceListener(input);
}
// Only do this after attaching our listener so that it will be ahead of
@@ -324,6 +325,14 @@ public abstract class AbstractPropertyEditor implements IChangeListener, Customi
}
}
+ protected void unhookDataSourceListener(DataSource oldInput) {
+ oldInput.removeDataSourceListener(getDataSourceListener());
+ }
+
+ protected void hookDataSourceListener(DataSource newInput) {
+ newInput.addDataSourceListener(getDataSourceListener());
+ }
+
/**
* @return the input DataSource for this Property editor
*/
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/ViewEditor.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/ViewEditor.java
index f7b12dcca3b..624d35d67ae 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/ViewEditor.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/ViewEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,13 +8,15 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 443417
+ *
*****************************************************************************/
package org.eclipse.papyrus.views.properties.widgets;
-import java.util.Collection;
import java.util.Collections;
-import java.util.LinkedList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.list.IObservableList;
@@ -27,12 +29,17 @@ import org.eclipse.papyrus.views.properties.Activator;
import org.eclipse.papyrus.views.properties.contexts.Context;
import org.eclipse.papyrus.views.properties.contexts.Section;
import org.eclipse.papyrus.views.properties.contexts.View;
+import org.eclipse.papyrus.views.properties.modelelement.DataSource;
+import org.eclipse.papyrus.views.properties.modelelement.DataSourceChangedEvent;
+import org.eclipse.papyrus.views.properties.modelelement.IDataSourceListener;
import org.eclipse.papyrus.views.properties.runtime.ConfigurationManager;
import org.eclipse.papyrus.views.properties.runtime.DefaultDisplayEngine;
import org.eclipse.papyrus.views.properties.runtime.DisplayEngine;
import org.eclipse.papyrus.views.properties.widgets.layout.PropertiesLayout;
import org.eclipse.papyrus.views.properties.xwt.XWTSection;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -49,7 +56,11 @@ public class ViewEditor extends AbstractPropertyEditor {
private Composite self;
- private Collection<XWTSection> sections;
+ private Map<Section, XWTSection> sections = new HashMap<Section, XWTSection>();
+
+ private DisplayEngine displayEngine;
+
+ private IDataSourceListener dataSourceListener;
/**
* Constructor.
@@ -65,6 +76,25 @@ public class ViewEditor extends AbstractPropertyEditor {
layout.horizontalSpacing = 0;
layout.marginWidth = 0;
self.setLayout(layout);
+
+ addDisposeListener(self);
+ }
+
+ private void addDisposeListener(Control control) {
+ control.addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ disposeDisplayEngine();
+ }
+ });
+ }
+
+ private void disposeDisplayEngine() {
+ if (displayEngine != null) {
+ displayEngine.dispose();
+ displayEngine = null;
+ sections.clear();
+ }
}
@Override
@@ -74,6 +104,32 @@ public class ViewEditor extends AbstractPropertyEditor {
}
}
+ @Override
+ protected void unhookDataSourceListener(DataSource oldInput) {
+ oldInput.removeDataSourceListener(getDataSourceListener());
+ super.unhookDataSourceListener(oldInput);
+ }
+
+ @Override
+ protected void hookDataSourceListener(DataSource newInput) {
+ super.hookDataSourceListener(newInput);
+ newInput.addDataSourceListener(getDataSourceListener());
+ }
+
+ private IDataSourceListener getDataSourceListener() {
+ if (dataSourceListener == null) {
+ dataSourceListener = new IDataSourceListener() {
+
+ public void dataSourceChanged(DataSourceChangedEvent event) {
+ // The data source's selection changed. Re-display our nested sections, if appropriate
+ checkInput();
+ }
+ };
+ }
+
+ return dataSourceListener;
+ }
+
/**
* Sets the number of columns for this editor. If the property is a list,
* there will be one view per element in the list : these views will be
@@ -138,23 +194,23 @@ public class ViewEditor extends AbstractPropertyEditor {
return;
}
- DisplayEngine display = new DefaultDisplayEngine(true);
-
- sections = new LinkedList<XWTSection>();
+ if (displayEngine == null) {
+ displayEngine = new DefaultDisplayEngine(false);
+ }
if (observable instanceof IObservableValue) {
IObservableValue observableValue = (IObservableValue) observable;
if (observableValue instanceof MultipleObservableValue) {
MultipleObservableValue multipleObservable = (MultipleObservableValue) observableValue;
- display(display, multipleObservable.getObservedValues(), view);
+ display(displayEngine, multipleObservable.getObservedValues(), view);
} else {
Object value = observableValue.getValue();
- display(display, value, view);
+ display(displayEngine, value, view);
}
} else if (observable instanceof IObservableList) {
IObservableList observableList = (IObservableList) observable;
for (Object value : observableList) {
- display(display, value, view);
+ display(displayEngine, value, view);
}
}
@@ -191,12 +247,15 @@ public class ViewEditor extends AbstractPropertyEditor {
*/
protected void display(DisplayEngine display, List<Object> selectedElements, View view) {
for (Section section : view.getSections()) {
- XWTSection xwtSection = new XWTSection(section, view, display);
- sections.add(xwtSection);
+ XWTSection xwtSection = sections.get(section);
+ if (xwtSection == null) {
+ xwtSection = new XWTSection(section, view, display);
+ sections.put(section, xwtSection);
+ xwtSection.createControls(new Composite(self, SWT.NONE), null);
+ }
ISelection selection = new StructuredSelection(selectedElements);
- xwtSection.createControls(new Composite(self, SWT.NONE), null);
xwtSection.setInput(null, selection);
xwtSection.refresh();
}

Back to the top