Outline view flickers when updated [message #1062901] |
Tue, 11 June 2013 10:24 |
Niek Hulsman Messages: 7 Registered: June 2013 |
Junior Member |
|
|
The outline views flickers when editing a large document in Eclipse 4.2 with XText 2.3.1 You can reproduce this flickering by creating a large document using the default Hello World grammar.
I've probed the XText source code and found that the outline treeviewer get's updated with a call to setInput. I'm not sure if this is by design...
My question is if the current implementation could be changed to an implementation with a call to refresh() instead of setInput()?
Relevant source code below:
From Xtext/OutlinePage
protected void refreshViewer(final IOutlineNode rootNode, final Collection<IOutlineNode> nodesToBeExpanded,
final Collection<IOutlineNode> selectedNodes) {
DisplayRunHelper.runAsyncInDisplayThread(new Runnable() {
public void run() {
try {
TreeViewer treeViewer = getTreeViewer();
if (!treeViewer.getTree().isDisposed()) {
treeViewer.setInput(rootNode);
treeViewer.expandToLevel(1);
treeViewer.setExpandedElements(Iterables.toArray(nodesToBeExpanded, IOutlineNode.class));
treeViewer.setSelection(new StructuredSelection(Iterables.toArray(selectedNodes,
IOutlineNode.class)));
treeUpdated();
}
} catch (Throwable t) {
LOG.error("Error refreshing outline", t);
}
}
});
}
From JFace/TreeViewer:
public void setInput(Object input) {
Control control = getControl();
if (control == null || control.isDisposed()) {
throw new IllegalStateException(
"Need an underlying widget to be able to set the input." + //$NON-NLS-1$
"(Has the widget been disposed?)"); //$NON-NLS-1$
}
Assert.isTrue(getContentProvider() != null,
"ContentViewer must have a content provider when input is set."); //$NON-NLS-1$
Object oldInput = getInput();
contentProvider.inputChanged(this, oldInput, input);
this.input = input;
// call input hook
inputChanged(this.input, oldInput);
}
protected void inputChanged(Object input, Object oldInput) {
preservingSelection(new Runnable() {
public void run() {
Control tree = getControl();
tree.setRedraw(false);
try {
removeAll(tree);
tree.setData(getRoot());
internalInitializeTree(tree);
} finally {
tree.setRedraw(true);
}
}
});
}
|
|
|
Re: Outline view flickers when updated [message #1062960 is a reply to message #1062901] |
Tue, 11 June 2013 14:23 |
Jan Koehnlein Messages: 760 Registered: July 2009 Location: Hamburg |
Senior Member |
|
|
Sound familiar somehow. I cannot find a bugzilla, but I assume this has
been solved for 2.4. So why not upgrade? 2.4.2 is just around the corner
(26th of June)
Am 11.06.13 14:51, schrieb Niek Hulsman:
> The outline views flickers when editing a large document in Eclipse 4.2
> with XText 2.3.1 You can reproduce this flickering by creating a large
> document using the default Hello World grammar.
>
> I've probed the XText source code and found that the outline treeviewer
> get's updated with a call to setInput. I'm not sure if this is by design...
> My question is if the current implementation could be changed to an
> implementation with a call to refresh() instead of setInput()?
>
> Relevant source code below:
>
> From Xtext/OutlinePage
>
> protected void refreshViewer(final IOutlineNode rootNode, final
> Collection<IOutlineNode> nodesToBeExpanded,
> final Collection<IOutlineNode> selectedNodes) {
> DisplayRunHelper.runAsyncInDisplayThread(new Runnable() {
> public void run() {
> try {
> TreeViewer treeViewer = getTreeViewer();
> if (!treeViewer.getTree().isDisposed()) {
> treeViewer.setInput(rootNode);
> treeViewer.expandToLevel(1);
>
> treeViewer.setExpandedElements(Iterables.toArray(nodesToBeExpanded,
> IOutlineNode.class));
> treeViewer.setSelection(new
> StructuredSelection(Iterables.toArray(selectedNodes,
> IOutlineNode.class)));
> treeUpdated();
> }
> } catch (Throwable t) {
> LOG.error("Error refreshing outline", t);
> }
> }
> });
> }
>
>
> From JFace/TreeViewer:
>
> public void setInput(Object input) {
> Control control = getControl();
> if (control == null || control.isDisposed()) {
> throw new IllegalStateException(
> "Need an underlying widget to be able to set the
> input." + //$NON-NLS-1$
> "(Has the widget been disposed?)"); //$NON-NLS-1$
> }
> Assert.isTrue(getContentProvider() != null,
> "ContentViewer must have a content provider when input is
> set."); //$NON-NLS-1$
>
> Object oldInput = getInput();
> contentProvider.inputChanged(this, oldInput, input);
> this.input = input;
>
> // call input hook
> inputChanged(this.input, oldInput);
> }
>
>
> protected void inputChanged(Object input, Object oldInput) {
> preservingSelection(new Runnable() {
> public void run() {
> Control tree = getControl();
> tree.setRedraw(false);
> try {
> removeAll(tree);
> tree.setData(getRoot());
> internalInitializeTree(tree);
> } finally {
> tree.setRedraw(true);
> }
> }
> });
> }
>
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
---
Get professional support from the Xtext committers at www.typefox.io
|
|
|
Powered by
FUDForum. Page generated in 0.02995 seconds