Summary: | [Viewers] StructuredViewer.update calls LabelProvider before updating expandedState | ||
---|---|---|---|
Product: | [Eclipse Project] Platform | Reporter: | George C. Hetrick <hetrick> |
Component: | UI | Assignee: | Nick Edgar <n.a.edgar> |
Status: | RESOLVED WORKSFORME | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | n.a.edgar, steve_northover |
Version: | 2.1 | Keywords: | api |
Target Milestone: | 3.0 M9 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
George C. Hetrick
2003-05-15 09:43:16 EDT
Looks like JFace to me. Please move back if it turns out to be SWT. Thanks. It is not StructuredViewer.update's responsibility to update the expanded state. Te problem is that during the Tree expand or collapse callback from SWT, the expanded/collapsed state of the item has not yet changed. A better name for the event would be treeExpanding/treeCollapsing. The JFace event name is consistent with SWT's TreeListener. Note that the underlying SWT event name constants are SWT.Expand/SWT.Collapse. We have received many PRs and newsgroup questions about this behaviour. We should do something to address it. At a minimum, the specs for the events at both the SWT and JFace level should be clarified. A name change would be better. Is there something different that I, as a coder, should be doing? Nick's comment seems to suggest a documentation change, rather than a behavior change. Correct, this is a spec. problem, not an implementation bug. One workaround is to queue the update using Display.asyncExec so that it gets run after the treeExpanded/treeCollapsed callback returns. For example: public void treeCollapsed(final TreeExpansionEvent event) { final AbstractTreeViewer viewer = event.getTreeViewer(); viewer.getControl().getDisplay().asyncExec( new Runnable() { public void run() { viewer.update(event.getElement(), null); } } ); } Moving to SWT for comment. Steve, is it the intent that a TreeItem.getExpanded() call during a Collapse event should still return true (and vice versa for Expand)? Are there platform differences here? Can you comment on the suggested workaround above? This is the intent. I have verified that the behavior is the same on every platform. ITreeViewerListener's method names could be improved, but that would be a breaking API change. Will add a clarification to the Javadoc. |