Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 39118 Details for
Bug 127025
system thread filter loses selection/collapses on first invocation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch
tree-clear-select.patch (text/plain), 20.01 KB, created by
Darin Wright
on 2006-04-20 18:25:37 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Darin Wright
Created:
2006-04-20 18:25:37 EDT
Size:
20.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.debug.ui >Index: ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTableViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTableViewer.java,v >retrieving revision 1.15 >diff -u -r1.15 AsynchronousTableViewer.java >--- ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTableViewer.java 17 Apr 2006 20:58:15 -0000 1.15 >+++ ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTableViewer.java 20 Apr 2006 22:14:12 -0000 >@@ -473,17 +473,13 @@ > } > } > >- public void nodeChanged(ModelNode node) { >- Widget widget = findItem(node); >- if (widget != null && !widget.isDisposed()) { >- if (widget instanceof TableItem) { >- clear(widget); >- return; >- } >- widget.setData(node.getElement()); >- internalRefresh(node); >- } >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.viewers.AsynchronousViewer#clearChildren(org.eclipse.swt.widgets.Widget) >+ */ >+ protected void clearChildren(Widget item) { >+ if (item instanceof Table) { >+ fTable.clearAll(); >+ } > } > >- > } >Index: ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeViewer.java,v >retrieving revision 1.45 >diff -u -r1.45 AsynchronousTreeViewer.java >--- ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeViewer.java 20 Apr 2006 16:56:36 -0000 1.45 >+++ ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeViewer.java 20 Apr 2006 22:14:12 -0000 >@@ -747,28 +747,6 @@ > return paths; > } > >- /** >- * Container status of a node changed >- * >- * @param node >- */ >- protected void nodeContainerChanged(ModelNode node) { >- Widget widget = findItem(node); >- if (widget != null && !widget.isDisposed()) { >- boolean expanded = true; >- if (node.isContainer() && getItemCount(widget) == 0) { >- setItemCount(widget, 1); >- } >- if (widget instanceof TreeItem) { >- expanded = ((TreeItem) widget).getExpanded(); >- } >- if (expanded) { >- updateChildren(node); >- } >- } >- attemptPendingUpdates(); >- } >- > protected int getItemCount(Widget widget) { > if (widget instanceof TreeItem) { > return ((TreeItem) widget).getItemCount(); >@@ -870,6 +848,18 @@ > fTree.clearAll(true); > } > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.ui.viewers.AsynchronousViewer#clearChildren(org.eclipse.swt.widgets.Widget) >+ */ >+ protected void clearChildren(Widget widget) { >+ if (widget instanceof TreeItem && !widget.isDisposed()) { >+ TreeItem item = (TreeItem) widget; >+ item.clearAll(true); >+ } else { >+ fTree.clearAll(true); >+ } >+ } > > /* > * (non-Javadoc) >@@ -1169,24 +1159,6 @@ > return new AsynchronousTreeModel(this); > } > >- >- /* (non-Javadoc) >- * @see org.eclipse.debug.internal.ui.viewers.AsynchronousModelViewer#nodeChanged(org.eclipse.debug.internal.ui.viewers.ModelNode) >- */ >- public void nodeChanged(ModelNode node) { >- Widget widget = findItem(node); >- if (widget != null && !widget.isDisposed()) { >- if (widget instanceof TreeItem) { >- clear(widget); >- return; >- } >- widget.setData(node.getElement()); >- mapElement(node, widget); >- internalRefresh(node); >- attemptPendingUpdates(); >- } >- } >- > /** > * Attempt pending udpates. Subclasses may override but should call super. > */ >@@ -1523,5 +1495,20 @@ > return bool.booleanValue(); > } > >+ protected void xxxContainerChanged(ModelNode node) { >+ Widget widget = findItem(node); >+ if (widget != null && !widget.isDisposed()) { >+ if (node.isContainer()) { >+ if (widget instanceof TreeItem) { >+ if (((TreeItem)widget).getExpanded()) { >+ updateChildren(node); >+ } >+ } else { >+ updateChildren(node); >+ } >+ attemptPendingUpdates(); >+ } >+ } >+ } > > } >Index: ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java,v >retrieving revision 1.35 >diff -u -r1.35 AsynchronousViewer.java >--- ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java 20 Apr 2006 16:52:51 -0000 1.35 >+++ ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java 20 Apr 2006 22:14:12 -0000 >@@ -113,16 +113,6 @@ > > protected static final String OLD_LABEL = "old_label"; //$NON-NLS-1$ > protected static final String OLD_IMAGE = "old_image"; //$NON-NLS-1$ >- >- /** >- * Map of parent nodes for which children were needed to "set data" >- * in the virtual widget. A parent is added to this map when we try go >- * get children but they aren't there yet. The children are retrieved >- * asynchronously, and later put back into the widgetry. >- * The value is an array of ints of the indicies of the children that >- * were requested. >- */ >- private Map fParentsPendingChildren = new HashMap(); > > /** > * Creates a new viewer >@@ -241,7 +231,6 @@ > * @see org.eclipse.jface.viewers.Viewer#inputChanged(java.lang.Object, java.lang.Object) > */ > protected synchronized void inputChanged(Object input, Object oldInput) { >- fParentsPendingChildren.clear(); > if (fUpdatePolicy == null) { > fUpdatePolicy = createUpdatePolicy(); > fUpdatePolicy.init(this); >@@ -736,11 +725,36 @@ > } > > protected synchronized void restoreSelection(ISelection oldSelection) { >- doAttemptSelectionToWidget(oldSelection, false); >+ ISelection remaining = doAttemptSelectionToWidget(oldSelection, false); > // send out notification if old and new differ > fCurrentSelection = newSelectionFromWidget(); >- if (!fCurrentSelection.equals(oldSelection)) >- handleInvalidSelection(oldSelection, fCurrentSelection); >+ if (!fCurrentSelection.equals(oldSelection)) { >+ handleInvalidSelection(oldSelection, fCurrentSelection); >+ // if the remaining selection still exists in the model, make it pending >+ if (selectionExists(remaining)) { >+ setSelection(remaining); >+ } >+ } >+ } >+ >+ /** >+ * Returns whether the selection exists in the model >+ */ >+ protected boolean selectionExists(ISelection selection) { >+ if (selection.isEmpty()) { >+ return false; >+ } >+ if (selection instanceof IStructuredSelection) { >+ IStructuredSelection ss = (IStructuredSelection) selection; >+ Iterator iterator = ss.iterator(); >+ while (iterator.hasNext()) { >+ Object element = iterator.next(); >+ if (getModel().getNodes(element) == null) { >+ return false; >+ } >+ } >+ } >+ return true; > } > > /** >@@ -818,14 +832,8 @@ > protected void nodeDisposed(ModelNode node) { > Widget widget = findItem(node); > if (widget != null) { >- unmapElement(node); >+ unmapNode(node); > widget.dispose(); >- ModelNode[] childrenNodes = node.getChildrenNodes(); >- if (childrenNodes != null) { >- for (int i = 0; i < childrenNodes.length; i++) { >- nodeDisposed(childrenNodes[i]); >- } >- } > } > } > >@@ -837,8 +845,8 @@ > public void nodeChanged(ModelNode node) { > Widget widget = findItem(node); > if (widget != null) { >- widget.setData(node.getElement()); >- internalRefresh(node); >+ clear(widget); >+ attemptPendingUpdates(); > } > } > >@@ -859,38 +867,18 @@ > } > > /** >- * Called when nodes are set in the model. The children may not have been >- * retrieved yet when the tree got the call to "set data". >+ * Clears the given widget > * >- * @param parent >- * @param children >+ * @param item > */ >- protected void nodeChildrenSet(ModelNode parent, ModelNode[] children) { >- int[] indicies = removePendingChildren(parent); >- Widget widget = findItem(parent); >- if (widget != null && !widget.isDisposed()) { >- if (indicies != null) { >- for (int i = 0; i < indicies.length; i++) { >- int index = indicies[i]; >- Widget item = getChildWidget(widget, index); >- if (item != null) { >- if (index < children.length) { >- ModelNode childNode = children[index]; >- mapElement(childNode, item); >- item.setData(childNode.getElement()); >- internalRefresh(childNode); >- } >- } >- } >- setItemCount(widget, children.length); >- } else { >- setItemCount(widget, children.length); >- } >- } >- attemptPendingUpdates(); >- } >- > protected abstract void clear(Widget item); >+ >+ /** >+ * Clears the children of the widget. >+ * >+ * @param item >+ */ >+ protected abstract void clearChildren(Widget item); > > /** > * Returns the child widet at the given index for the given parent or >@@ -916,22 +904,35 @@ > protected void attemptPendingUpdates() { > attemptSelection(false); > } >- >+ > /** >- * The children of a node have changed. >+ * Updates the child count for the parent's widget >+ * and clears children to be updated. > * >- * @param parent >+ * @param parentNode > */ >- protected void nodeChildrenChanged(ModelNode parentNode) { >- ModelNode[] childrenNodes = parentNode.getChildrenNodes(); >+ protected void xxxChildrenChanged(ModelNode parentNode) { >+ Widget widget = findItem(parentNode); >+ if (widget != null && !widget.isDisposed()) { >+ int childCount = parentNode.getChildCount(); >+ clearChildren(widget); >+ setItemCount(widget, childCount); >+ attemptPendingUpdates(); >+ } >+ } >+ >+ /** >+ * Unmaps the node from its widget and all of its children nodes from >+ * their widgets. >+ * >+ * @param node >+ */ >+ protected void unmapNode(ModelNode node) { >+ unmapElement(node); >+ ModelNode[] childrenNodes = node.getChildrenNodes(); > if (childrenNodes != null) { >- nodeChildrenSet(parentNode, childrenNodes); >- } else { >- Widget widget = findItem(parentNode); >- if (widget != null && !widget.isDisposed()) { >- int childCount = parentNode.getChildCount(); >- setItemCount(widget, childCount); >- attemptPendingUpdates(); >+ for (int i = 0; i < childrenNodes.length; i++) { >+ unmapNode(childrenNodes[i]); > } > } > } >@@ -964,38 +965,6 @@ > return findItem((Object)node); > } > >- /** >- * Note that the child at the specified index was requested by a widget >- * when revealed but that the data was not in the model yet. When the data >- * becomes available, map it to its widget. >- * >- * @param parent >- * @param index >- */ >- protected synchronized void addPendingChildIndex(ModelNode parent, int index) { >- int[] indicies = (int[]) fParentsPendingChildren.get(parent); >- if (indicies == null) { >- indicies = new int[]{index}; >- } else { >- int[] next = new int[indicies.length + 1]; >- System.arraycopy(indicies, 0, next, 0, indicies.length); >- next[indicies.length] = index; >- indicies = next; >- } >- fParentsPendingChildren.put(parent, indicies); >- } >- >- /** >- * Removes and returns and children indicies that were pending for the given >- * parent node. May return <code>null</code>. >- * >- * @param parent >- * @return indicies of children that data were requested for or <code>null</code> >- */ >- protected int[] removePendingChildren(ModelNode parent) { >- return (int[]) fParentsPendingChildren.remove(parent); >- } >- > /* > * (non-Javadoc) > * >@@ -1026,9 +995,7 @@ > internalRefresh(child); > } > }); >- } else { >- addPendingChildIndex(node, index); >- } >+ } > return; > } > } >Index: ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeModel.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeModel.java,v >retrieving revision 1.1 >diff -u -r1.1 AsynchronousTreeModel.java >--- ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeModel.java 2 Mar 2006 17:26:40 -0000 1.1 >+++ ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeModel.java 20 Apr 2006 22:14:12 -0000 >@@ -143,7 +143,6 @@ > preservingSelection(new Runnable() { > public void run() { > viewer.nodeDisposed(node); >- viewer.nodeChildrenChanged(parentNode); > } > }); > } >@@ -154,7 +153,7 @@ > * @param parent > * @param element > */ >- protected void add(ModelNode parent, Object element) { >+ protected void add(final ModelNode parent, Object element) { > Object[] children = filter(parent.getElement(), new Object[] { element }); > if (children.length == 0) { > return; // added element was filtered out. >@@ -173,7 +172,12 @@ > } > //TODO sort??? > // notify the viewer to update >- getTreeViewer().nodeChildrenChanged(parent); >+ preservingSelection(new Runnable() { >+ public void run() { >+ getTreeViewer().xxxChildrenChanged(parent); >+ } >+ }); >+ > } > > /** >@@ -246,7 +250,7 @@ > * @param node > * @param containsChildren > */ >- void setIsContainer(ModelNode node, boolean containsChildren) { >+ void setIsContainer(final ModelNode node, boolean containsChildren) { > ModelNode[] prevChildren = null; > synchronized (this) { > prevChildren = node.getChildrenNodes(); >@@ -261,20 +265,12 @@ > } > } > // update tree outside lock >- AsynchronousTreeViewer viewer = getTreeViewer(); >- if (containsChildren) { >- if (prevChildren == null) { >- viewer.nodeChildrenChanged(node); >- viewer.nodeContainerChanged(node); >- } else { >- viewer.nodeContainerChanged(node); >- } >- } else if (!containsChildren && prevChildren != null) { >- for (int i = 0; i < prevChildren.length; i++) { >- ModelNode child = prevChildren[i]; >- viewer.nodeDisposed(child); >- } >- viewer.nodeChildrenChanged(node); >- } >+ preservingSelection(new Runnable() { >+ public void run() { >+ getViewer().xxxChildrenChanged(node); >+ getTreeViewer().xxxContainerChanged(node); >+ } >+ }); >+ > } > } >Index: ui/org/eclipse/debug/internal/ui/viewers/AsynchronousModel.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousModel.java,v >retrieving revision 1.1 >diff -u -r1.1 AsynchronousModel.java >--- ui/org/eclipse/debug/internal/ui/viewers/AsynchronousModel.java 2 Mar 2006 17:26:40 -0000 1.1 >+++ ui/org/eclipse/debug/internal/ui/viewers/AsynchronousModel.java 20 Apr 2006 22:14:12 -0000 >@@ -252,7 +252,7 @@ > * @param element model element > * @return associated nodes or <code>null</code> > */ >- public ModelNode[] getNodes(Object element) { >+ public synchronized ModelNode[] getNodes(Object element) { > return (ModelNode[]) fElementToNodes.get(element); > } > >@@ -474,6 +474,7 @@ > > ModelNode[] prevKids = null; > ModelNode[] newChildren = null; >+ ModelNode[] unmap = null; > > synchronized (this) { > if (isDisposed()) { >@@ -489,55 +490,49 @@ > } > parentNode.setChildren(newChildren); > } else { >- for (int i = 0; i < prevKids.length; i++) { >- ModelNode kid = prevKids[i]; >- if (i >= children.length) { >- kid.dispose(); >- unmapNode(kid); >- } else { >- ModelNode prevNode = prevKids[i]; >- Object nextChild = children[i]; >- if (!prevNode.getElement().equals(nextChild)) { >- unmapNode(prevNode); >- } >- mapElement(nextChild, prevNode); >- } >- } >- // create new children >- if (children.length > prevKids.length) { >- newChildren = new ModelNode[children.length]; >- System.arraycopy(prevKids, 0, newChildren, 0, prevKids.length); >- for (int i = prevKids.length; i < children.length; i ++) { >- Object child = children[i]; >- ModelNode childNode = new ModelNode(parentNode, child); >- mapElement(child, childNode); >- newChildren[i] = childNode; >- } >- parentNode.setChildren(newChildren); >- } >- if (children.length < prevKids.length) { >- newChildren = new ModelNode[children.length]; >- System.arraycopy(prevKids, 0, newChildren, 0, children.length); >- parentNode.setChildren(newChildren); >- } >+ newChildren = new ModelNode[children.length]; >+ unmap = new ModelNode[prevKids.length]; >+ for (int i = 0; i < prevKids.length; i++) { >+ unmap[i] = prevKids[i]; >+ } >+ for (int i = 0; i < children.length; i++) { >+ Object child = children[i]; >+ boolean found = false; >+ for (int j = 0; j < prevKids.length; j++) { >+ ModelNode prevKid = prevKids[j]; >+ if (prevKid != null && child.equals(prevKid.getElement())) { >+ newChildren[i] = prevKid; >+ prevKids[j] = null; >+ found = true; >+ break; >+ } >+ } >+ if (!found) { >+ newChildren[i] = new ModelNode(parentNode, child); >+ mapElement(child, newChildren[i]); >+ } >+ } >+ for (int i = 0; i < prevKids.length; i++) { >+ ModelNode kid = prevKids[i]; >+ if (kid != null) { >+ kid.dispose(); >+ unmapNode(kid); >+ } >+ } >+ parentNode.setChildren(newChildren); > } > } > > //update viewer outside the lock >- final ModelNode[] finalPrevKids = prevKids; >+ final ModelNode[] finalUnmap = unmap; > preservingSelection(new Runnable() { > public void run() { >- if (finalPrevKids != null) { >- for (int i = 0; i < finalPrevKids.length; i++) { >- ModelNode kid = finalPrevKids[i]; >- if (i >= children.length) { >- viewer.nodeDisposed(kid); >- } else { >- viewer.nodeChanged(kid); >- } >- } >+ if (finalUnmap != null) { >+ for (int i = 0; i < finalUnmap.length; i++) { >+ viewer.unmapNode(finalUnmap[i]); >+ } > } >- viewer.nodeChildrenChanged(parentNode); >+ viewer.xxxChildrenChanged(parentNode); > } > }); > >Index: ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java,v >retrieving revision 1.11 >diff -u -r1.11 AsyncVirtualContentTableViewer.java >--- ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java 19 Apr 2006 22:10:13 -0000 1.11 >+++ ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java 20 Apr 2006 22:14:13 -0000 >@@ -488,11 +488,8 @@ > // is causing the table viewer to not scroll or move cursor properly. > // #interalRefresh on a child will never cause a structural > // change in a table viewer. As a result, there is no need to preserve selection >- internalRefresh(child); >- >- } else { >- addPendingChildIndex(node, index); >- } >+ internalRefresh(child); >+ } > return; > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 127025
: 39118 |
39194
|
39201
|
39227
|
39265
|
39347