summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Merks2013-01-15 08:48:39 (EST)
committerEd Merks2013-01-15 08:48:39 (EST)
commit884d645931f6f0caacaf092c166ce19942f37176 (patch)
tree812197d3c575da63d1c0518acb03cd53fa955caf
parent576d3781ea37a6d4e55fa5b13ba6f51632949846 (diff)
downloadorg.eclipse.emf-884d645931f6f0caacaf092c166ce19942f37176.zip
org.eclipse.emf-884d645931f6f0caacaf092c166ce19942f37176.tar.gz
org.eclipse.emf-884d645931f6f0caacaf092c166ce19942f37176.tar.bz2
[243694] Preserve expansion state.
-rw-r--r--plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/provider/AdapterFactoryContentProvider.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/provider/AdapterFactoryContentProvider.java b/plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/provider/AdapterFactoryContentProvider.java
index 604cf45..d5631ca 100644
--- a/plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/provider/AdapterFactoryContentProvider.java
+++ b/plugins/org.eclipse.emf.edit.ui/src/org/eclipse/emf/edit/ui/provider/AdapterFactoryContentProvider.java
@@ -12,10 +12,12 @@ package org.eclipse.emf.edit.ui.provider;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -482,6 +484,10 @@ public class AdapterFactoryContentProvider
viewer.setSelection(StructuredSelection.EMPTY);
}
+ AbstractTreeViewer treeViewer = structuredViewer instanceof AbstractTreeViewer ? (AbstractTreeViewer)structuredViewer : null;
+ List<Object> expandedElements = treeViewer == null ? Collections.emptyList() : Arrays.asList(treeViewer.getExpandedElements());
+ boolean isStaleExpandedElements = AdapterFactoryEditingDomain.isStale(expandedElements);
+
if (element != null)
{
if (notification.isContentRefresh())
@@ -498,7 +504,7 @@ public class AdapterFactoryContentProvider
structuredViewer.refresh(notification.isLabelUpdate());
}
- if (isStaleSelection)
+ if (isStaleSelection || isStaleExpandedElements)
{
Object object = structuredViewer.getInput();
EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(object);
@@ -515,8 +521,16 @@ public class AdapterFactoryContentProvider
}
if (editingDomain instanceof AdapterFactoryEditingDomain)
{
- structuredViewer.setSelection
- (new StructuredSelection(((AdapterFactoryEditingDomain)editingDomain).resolve(((IStructuredSelection)selection).toList())), true);
+ AdapterFactoryEditingDomain adapterFactoryEditingDomain = (AdapterFactoryEditingDomain)editingDomain;
+ if (treeViewer != null && isStaleExpandedElements)
+ {
+ treeViewer.setExpandedElements(adapterFactoryEditingDomain.resolve(expandedElements).toArray());
+ }
+ if (isStaleSelection)
+ {
+ structuredViewer.setSelection
+ (new StructuredSelection(adapterFactoryEditingDomain.resolve(((IStructuredSelection)selection).toList())), true);
+ }
}
}
}