Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFanch BONNABESSE2017-02-01 13:39:16 +0000
committerGerrit Code Review @ Eclipse.org2017-02-09 10:07:56 +0000
commitf1f1dc7f8592e9825c485f0b53aaf1c8e7c4ab10 (patch)
tree83b33d7ddb05d39bab85345ea1b8306c97556ffb /plugins/infra/ui
parente036cad510358b6cb804466842722cebc2425aca (diff)
downloadorg.eclipse.papyrus-f1f1dc7f8592e9825c485f0b53aaf1c8e7c4ab10.tar.gz
org.eclipse.papyrus-f1f1dc7f8592e9825c485f0b53aaf1c8e7c4ab10.tar.xz
org.eclipse.papyrus-f1f1dc7f8592e9825c485f0b53aaf1c8e7c4ab10.zip
Bug 511468: [Property View][DataType] TreeViewers are not refreshed on
the selection change of stereotyped elements https://bugs.eclipse.org/bugs/show_bug.cgi?id=511468 Add refresh when the selection change. Add MultipleObservableValue instead of a List of IObservableValue. Change-Id: If07c0c95493f861190e4a90a2b8668414483cb86 Signed-off-by: Fanch BONNABESSE <fanch.bonnabesse@all4tec.net>
Diffstat (limited to 'plugins/infra/ui')
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeReferenceValueEditor.java54
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/messages/Messages.java4
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/messages/messages.properties2
3 files changed, 35 insertions, 25 deletions
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeReferenceValueEditor.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeReferenceValueEditor.java
index 999c2b8c85a..a3325e479af 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeReferenceValueEditor.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/TreeReferenceValueEditor.java
@@ -16,12 +16,10 @@ package org.eclipse.papyrus.infra.widgets.editors;
import java.util.Collection;
import java.util.Collections;
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.layout.TreeColumnLayout;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.EditingSupport;
@@ -92,15 +90,22 @@ public abstract class TreeReferenceValueEditor extends AbstractValueEditor imple
protected Composite compositeTree;
/**
- * The adapter used to refresh the TreeViewer.
+ * Listener to modify IObservableValue when modelProperty changed.
*/
- protected Adapter adapterNotifyChanged = new AdapterImpl() {
+ private IChangeListener changeListener = new IChangeListener() {
+
@Override
- public void notifyChanged(Notification msg) {
+ public void handleChange(ChangeEvent event) {
+ setWidgetObservable(createWidgetObservable(modelProperty));
+ checkCreateInstanceButton();
+ setValueRootContentProvider();
if (null != treeViewer) {
treeViewer.refresh();
+ if (null != tree && null != tree.getTopItem()) {
+ treeViewer.expandToLevel(tree.getTopItem().getData(), 10);
+ }
}
- };
+ }
};
/**
@@ -137,11 +142,11 @@ public abstract class TreeReferenceValueEditor extends AbstractValueEditor imple
final TreeViewerColumn columnProperty = new TreeViewerColumn(treeViewer, SWT.LEFT);
columnProperty.getColumn().setAlignment(SWT.LEFT);
- columnProperty.getColumn().setText("Property"); //$NON-NLS-1$
+ columnProperty.getColumn().setText(Messages.TreeReferenceValueEditor_NameColumnProperty);
treeColumnLayout.setColumnData(columnProperty.getColumn(), new ColumnWeightData(100));
final TreeViewerColumn columnValue = new TreeViewerColumn(treeViewer, SWT.RIGHT);
columnValue.getColumn().setAlignment(SWT.LEFT);
- columnValue.getColumn().setText("Value"); //$NON-NLS-1$
+ columnValue.getColumn().setText(Messages.TreeReferenceValueEditor_NameColumnValue);
treeColumnLayout.setColumnData(columnValue.getColumn(), new ColumnWeightData(200));
columnValue.setEditingSupport(createEditingSupport());
@@ -262,8 +267,8 @@ public abstract class TreeReferenceValueEditor extends AbstractValueEditor imple
this.value = modelProperty.getValue();
}
super.setModelObservable(modelProperty);
- addEAdapters();
setWidgetObservable(createWidgetObservable(modelProperty));
+ addListeners();
checkCreateInstanceButton();
}
@@ -311,7 +316,6 @@ public abstract class TreeReferenceValueEditor extends AbstractValueEditor imple
// Do nothing
}
-
/**
* Set value of the modelProperty and create the widget observable.
*
@@ -320,12 +324,12 @@ public abstract class TreeReferenceValueEditor extends AbstractValueEditor imple
*/
@SuppressWarnings("unchecked")
public void setValue(final Object value) {
- removeEAdapters();
+ removeListeners();
this.value = value;
if (null != modelProperty) {
modelProperty.setValue(value);
setWidgetObservable(createWidgetObservable(modelProperty));
- addEAdapters();
+ addListeners();
}
if (null != treeViewer) {
@@ -366,27 +370,27 @@ public abstract class TreeReferenceValueEditor extends AbstractValueEditor imple
*/
@Override
public void dispose() {
- removeEAdapters();
+ removeListeners();
super.dispose();
}
/**
- * Add the eAdapters to the current value.
+ * Add all the listeners.
*/
- private void addEAdapters() {
- if (value instanceof EObject) {
- ((EObject) value).eAdapters().add(adapterNotifyChanged);
+ protected void addListeners() {
+ if (modelProperty != null) {
+ modelProperty.addChangeListener(changeListener);
}
- }
+ };
/**
- * Remove the eAdapters to the current value.
+ * Remove all the listeners.
*/
- private void removeEAdapters() {
- if (value instanceof EObject) {
- ((EObject) value).eAdapters().remove(adapterNotifyChanged);
+ protected void removeListeners() {
+ if (modelProperty != null) {
+ modelProperty.removeChangeListener(changeListener);
}
- }
+ };
/**
* Set the value root to the content provider of the tree viewer.
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/messages/Messages.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/messages/Messages.java
index 67d768312ee..6458857aaca 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/messages/Messages.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/messages/Messages.java
@@ -191,6 +191,10 @@ public class Messages extends NLS {
public static String BundleExplorerDialog_PlugInSelectionTitle;
+ public static String TreeReferenceValueEditor_NameColumnProperty;
+
+ public static String TreeReferenceValueEditor_NameColumnValue;
+
public static String TreeSelectorDialog_defaultTabLabel;
static {
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/messages/messages.properties b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/messages/messages.properties
index daa80251bfb..426ac6207b6 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/messages/messages.properties
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/messages/messages.properties
@@ -87,4 +87,6 @@ BundleExplorerDialog_DialogMessage=Select a Plug-in:
BundleExplorerDialog_PlugInSelectionTitle=Plug-in Selection
IconValueEditor_WaitingOneIconButFound=Waiting one icon path, but found
+TreeReferenceValueEditor_NameColumnProperty=Property
+TreeReferenceValueEditor_NameColumnValue=Value
TreeSelectorDialog_defaultTabLabel=Tree

Back to the top