Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Outline view flickers when updated
Outline view flickers when updated [message #1062901] Tue, 11 June 2013 10:24 Go to next message
Niek Hulsman is currently offline Niek HulsmanFriend
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 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
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
Previous Topic:AutoEdit slows down editing of large documents
Next Topic:How to access EMF objects into a transaction
Goto Forum:
  


Current Time: Thu Apr 25 01:23:21 GMT 2024

Powered by FUDForum. Page generated in 0.02868 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top