Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2012-04-10 20:57:15 +0000
committerPawel Piech2012-04-10 20:57:15 +0000
commitaceb2f12bf2c1dc85000f600f1865049d1605b87 (patch)
treec944a9ec9f07d1d44f8448430098000c205fc4b7
parentc5f4e83dcce152ab653d22968e4c60ddf30896d6 (diff)
downloadeclipse.platform.debug-aceb2f12bf2c1dc85000f600f1865049d1605b87.tar.gz
eclipse.platform.debug-aceb2f12bf2c1dc85000f600f1865049d1605b87.tar.xz
eclipse.platform.debug-aceb2f12bf2c1dc85000f600f1865049d1605b87.zip
Bug 376443 - [expressions] Adding multiple expressions to view can leave the "Add New Expression" at top
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java41
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ExpressionManagerModelProxy.java13
2 files changed, 39 insertions, 15 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java
index 03ce0a716..b420da1b2 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java
@@ -1185,6 +1185,11 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon
protected void handleAdd(IModelDelta delta) {
IModelDelta parentDelta = delta.getParentDelta();
+ if (parentDelta == null) {
+ DebugUIPlugin.log(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), "Invalid viewer update: " + delta + ", in " + getPresentationContext().getId(), null ));
+ return;
+ }
+
TreePath parentPath = getViewerTreePath(parentDelta);
Object element = delta.getElement();
int count = parentDelta.getChildCount();
@@ -1352,7 +1357,12 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon
protected void handleInsert(IModelDelta delta) {
// TODO: filters
- getViewer().insert(getViewerTreePath(delta.getParentDelta()), delta.getElement(), delta.getIndex());
+ IModelDelta parentDelta = delta.getParentDelta();
+ if (parentDelta == null) {
+ DebugUIPlugin.log(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), "Invalid viewer update: " + delta + ", in " + getPresentationContext().getId(), null ));
+ return;
+ }
+ getViewer().insert(getViewerTreePath(parentDelta), delta.getElement(), delta.getIndex());
}
protected void handleRemove(IModelDelta delta) {
@@ -1360,6 +1370,10 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon
DebugUIPlugin.trace("handleRemove(" + delta.getElement() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
}
IModelDelta parentDelta = delta.getParentDelta();
+ if (parentDelta == null) {
+ DebugUIPlugin.log(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), "Invalid viewer update: " + delta + ", in " + getPresentationContext().getId(), null ));
+ return;
+ }
IInternalTreeModelViewer treeViewer = getViewer();
TreePath parentPath = getViewerTreePath(parentDelta);
Object element = delta.getElement();
@@ -1425,7 +1439,12 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon
}
protected void handleReplace(IModelDelta delta) {
- TreePath parentPath = getViewerTreePath(delta.getParentDelta());
+ IModelDelta parentDelta = delta.getParentDelta();
+ if (parentDelta == null) {
+ DebugUIPlugin.log(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), "Invalid viewer update: " + delta + ", in " + getPresentationContext().getId(), null ));
+ return;
+ }
+ TreePath parentPath = getViewerTreePath(parentDelta);
int index = delta.getIndex();
if (index < 0) {
index = fTransform.indexOfFilteredElement(parentPath, delta.getElement());
@@ -1471,7 +1490,11 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon
// empty the selection before replacing elements to avoid materializing elements (@see bug 305739)
treeViewer.clearSelectionQuiet();
if (modelIndex >= 0) {
- IModelDelta parentDelta = delta.getParentDelta();
+ IModelDelta parentDelta = delta.getParentDelta();
+ if (parentDelta == null) {
+ DebugUIPlugin.log(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), "Invalid viewer update: " + delta + ", in " + getPresentationContext().getId(), null ));
+ return;
+ }
TreePath parentPath = getViewerTreePath(parentDelta);
int viewIndex = modelToViewIndex(parentPath, modelIndex);
if (viewIndex >= 0) {
@@ -1502,11 +1525,13 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon
protected void handleReveal(IModelDelta delta) {
IModelDelta parentDelta = delta.getParentDelta();
- if (parentDelta != null) {
- handleExpand(parentDelta);
- reveal(delta);
- cancelRestore(getViewerTreePath(delta), IModelDelta.REVEAL);
- }
+ if (parentDelta == null) {
+ DebugUIPlugin.log(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), "Invalid viewer update: " + delta + ", in " + getPresentationContext().getId(), null ));
+ return;
+ }
+ handleExpand(parentDelta);
+ reveal(delta);
+ cancelRestore(getViewerTreePath(delta), IModelDelta.REVEAL);
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ExpressionManagerModelProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ExpressionManagerModelProxy.java
index 8e5d77991..aad31ce9c 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ExpressionManagerModelProxy.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/ExpressionManagerModelProxy.java
@@ -68,15 +68,15 @@ public class ExpressionManagerModelProxy extends AbstractModelProxy implements I
* @see org.eclipse.debug.internal.core.IExpressionsListener2#expressionsMoved(org.eclipse.debug.core.model.IExpression[], int)
*/
public void expressionsMoved(IExpression[] expressions, int index){
- ModelDelta delta = new ModelDelta(getExpressionManager(), IModelDelta.NO_CHANGE);
int count = getElementsCount();
+ ModelDelta delta = new ModelDelta(getExpressionManager(), -1, IModelDelta.NO_CHANGE, count);
for (int i = 0; i < expressions.length; i++) {
IExpression expression = expressions[i];
delta.addNode(expression, IModelDelta.REMOVED);
}
for (int i = 0; i < expressions.length; i++) {
IExpression expression = expressions[i];
- delta.addNode(expression, index+i, IModelDelta.ADDED, count);
+ delta.addNode(expression, index+i, IModelDelta.ADDED, -1);
}
fireModelChanged(delta);
}
@@ -86,10 +86,10 @@ public class ExpressionManagerModelProxy extends AbstractModelProxy implements I
*/
public void expressionsInserted(IExpression[] expressions, int index){
int count = getElementsCount();
- ModelDelta delta = new ModelDelta(getExpressionManager(), IModelDelta.NO_CHANGE);
+ ModelDelta delta = new ModelDelta(getExpressionManager(), -1, IModelDelta.NO_CHANGE, count);
for (int i = 0; i < expressions.length; i++) {
IExpression expression = expressions[i];
- delta.addNode(expression, index+i, IModelDelta.ADDED | IModelDelta.INSTALL, count);
+ delta.addNode(expression, index+i, IModelDelta.ADDED | IModelDelta.INSTALL, -1);
}
fireModelChanged(delta);
}
@@ -100,13 +100,12 @@ public class ExpressionManagerModelProxy extends AbstractModelProxy implements I
public void expressionsAdded(IExpression[] expressions) {
int index = getExpressionManager().getExpressions().length - expressions.length;
int count = getElementsCount();
- ModelDelta delta = new ModelDelta(getExpressionManager(), IModelDelta.NO_CHANGE);
+ ModelDelta delta = new ModelDelta(getExpressionManager(), -1, IModelDelta.NO_CHANGE, count);
for (int i = 0; i < expressions.length; i++) {
IExpression expression = expressions[i];
- delta.addNode(expression, index+i, IModelDelta.ADDED | IModelDelta.INSTALL, count);
+ delta.addNode(expression, index+i, IModelDelta.ADDED | IModelDelta.INSTALL, -1);
}
fireModelChanged(delta);
- updateExpressions(expressions, IModelDelta.ADDED | IModelDelta.INSTALL);
}
/* (non-Javadoc)

Back to the top