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 Hulsman
Messages: 5
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 Koehnlein
Messages: 656
Registered: July 2009
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
Previous Topic:AutoEdit slows down editing of large documents
Next Topic:How to access EMF objects into a transaction
Goto Forum:
  


Current Time: Sun Sep 21 04:24:30 GMT 2014

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

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