Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2006-11-15 18:05:57 +0000
committerDarin Wright2006-11-15 18:05:57 +0000
commit161787ce7b058fa78e76abcd190587d5ba7754d0 (patch)
treef45f32875d5de723826e86b93ac73b05777d211e
parent7a5539ae8ecc61815ae43236f126de2801d49736 (diff)
downloadeclipse.platform.debug-161787ce7b058fa78e76abcd190587d5ba7754d0.tar.gz
eclipse.platform.debug-161787ce7b058fa78e76abcd190587d5ba7754d0.tar.xz
eclipse.platform.debug-161787ce7b058fa78e76abcd190587d5ba7754d0.zip
Bug 153500 Asynchronous model viewer [expansion state pluggable per element]
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java20
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IElementMementoProvider.java5
2 files changed, 19 insertions, 6 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java
index 12210e79c..b58510188 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java
@@ -196,8 +196,8 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
*/
protected void restoreViewerState(final Object input) {
fPendingState = null;
- final IElementMementoProvider stateProvider = getViewerStateAdapter(input);
- if (stateProvider != null) {
+ final IElementMementoProvider defaultProvider = getViewerStateAdapter(input);
+ if (defaultProvider != null) {
// build a model delta representing expansion and selection state
final ModelDelta delta = new ModelDelta(input, IModelDelta.NO_CHANGE);
final XMLMemento inputMemento = XMLMemento.createWriteRoot("VIEWER_INPUT_MEMENTO"); //$NON-NLS-1$
@@ -244,7 +244,7 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.viewers.IMementoManager#processReqeusts()
*/
public void processReqeusts() {
- stateProvider.encodeElement(fRequest);
+ defaultProvider.encodeElement(fRequest);
}
/* (non-Javadoc)
@@ -280,6 +280,7 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
if (fPendingState == null) {
return;
}
+ final IElementMementoProvider defaultProvider = getViewerStateAdapter(getViewer().getInput());
IModelDeltaVisitor visitor = new IModelDeltaVisitor() {
public boolean visit(IModelDelta delta, int depth) {
if (delta.getParentDelta() == null) {
@@ -288,7 +289,10 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
Object element = delta.getElement();
Object potentialMatch = path.getSegment(depth - 1);
if (element instanceof IMemento) {
- IElementMementoProvider provider = getViewerStateAdapter(getViewer().getInput());
+ IElementMementoProvider provider = getViewerStateAdapter(element);
+ if (provider == null) {
+ provider = defaultProvider;
+ }
if (provider != null) {
provider.compareElement(
new ElementCompareRequest(ModelContentProvider.this,
@@ -330,7 +334,7 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
* @param delta
* @param stateProvider
*/
- protected void encodeDelta(final ModelDelta rootDelta, final IElementMementoProvider stateProvider) {
+ protected void encodeDelta(final ModelDelta rootDelta, final IElementMementoProvider defaultProvider) {
final XMLMemento inputMemento = XMLMemento.createWriteRoot("VIEWER_INPUT_MEMENTO"); //$NON-NLS-1$
final XMLMemento childrenMemento = XMLMemento.createWriteRoot("CHILDREN_MEMENTO"); //$NON-NLS-1$
final IMementoManager manager = new IMementoManager() {
@@ -373,7 +377,11 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
public void processReqeusts() {
IElementMementoRequest[] req = (IElementMementoRequest[]) requests.toArray(new IElementMementoRequest[requests.size()]);
for (int i = 0; i < req.length; i++) {
- stateProvider.encodeElement(req[i]);
+ IElementMementoProvider provider = getViewerStateAdapter(req[i].getElement());
+ if (provider == null) {
+ provider = defaultProvider;
+ }
+ provider.encodeElement(req[i]);
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IElementMementoProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IElementMementoProvider.java
index 4261d1410..e6912e613 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IElementMementoProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IElementMementoProvider.java
@@ -14,6 +14,11 @@ package org.eclipse.debug.internal.ui.viewers.model.provisional;
* Used to save and restore viewer selection/expansion state. A memento
* provider adapter should be available from a viewer input element
* in order to support viewer state save/restore.
+ * <p>
+ * Each element in a viewer may provide its own memento provider. The
+ * input element's memento provider is used for elements that do not provide
+ * their own.
+ * </p>
*
* @since 3.3
*/

Back to the top