Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Expand Outline View on startup
Expand Outline View on startup [message #876323] Thu, 24 May 2012 11:28 Go to next message
kon f is currently offline kon fFriend
Messages: 152
Registered: March 2012
Senior Member
Hey,

I would like to expand the Outline View by default. I found this topic [1], but it seams to be outdated. Then I tried following code snippet:

public class MyDSLOutlineTreeProvider extends DefaultOutlineTreeProvider {

	@Inject
	private OutlinePage outlinePage;

	// skip Root-Element
	protected void _createChildren(DocumentRootNode parentNode, Program program) {
		this.outlinePage.getTreeViewer().expandAll();
                // further code for my outline view

	}
}


Unfortunately, this call produces a SWTExeption, here is the stack trace:

org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:4282)
at org.eclipse.swt.SWT.error(SWT.java:4197)
at org.eclipse.swt.SWT.error(SWT.java:4168)
at org.eclipse.swt.widgets.Widget.error(Widget.java:466)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:404)
at org.eclipse.swt.widgets.Tree.getItems(Tree.java:1610)
at org.eclipse.jface.viewers.TreeViewer.getChildren(TreeViewer.java:171)
at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:774)
at org.eclipse.jface.viewers.TreeViewer.createChildren(TreeViewer.java:644)
at org.eclipse.jface.viewers.AbstractTreeViewer.internalExpandToLevel(AbstractTreeViewer.java:1755)
at org.eclipse.jface.viewers.AbstractTreeViewer.expandToLevel(AbstractTreeViewer.java:1060)
at org.eclipse.jface.viewers.AbstractTreeViewer.expandToLevel(AbstractTreeViewer.java:1041)
at org.eclipse.jface.viewers.AbstractTreeViewer.expandAll(AbstractTreeViewer.java:1030)


How do I expand all nodes on start up? Thank you! Smile

Kon

[1] eclipse.org/forums/index.php/m/489829/
Re: Expand Outline View on startup [message #876499 is a reply to message #876323] Thu, 24 May 2012 18:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13493
Registered: July 2009
Senior Member
Hi,

what about

package org.xtext.example.mydsl.ui;

import org.eclipse.xtext.ui.editor.outline.impl.OutlinePage;

public class MyOutlinePage extends OutlinePage {
	
	@Override
	protected int getDefaultExpansionLevel() {
		return Integer.MAX_VALUE;
	}

}


public class MyDslUiModule extends org.xtext.example.mydsl.ui.AbstractMyDslUiModule {
	public MyDslUiModule(AbstractUIPlugin plugin) {
		super(plugin);
	}
	
	public Class<? extends IContentOutlinePage> bindIContentOutlinePage() {
		return MyOutlinePage.class;
	}
}


~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Expand Outline View on startup [message #876533 is a reply to message #876499] Thu, 24 May 2012 19:46 Go to previous message
kon f is currently offline kon fFriend
Messages: 152
Registered: March 2012
Senior Member
Thank you Christian, it worked like a charm Smile
Previous Topic:greedy option in xtext
Next Topic:CrossReference Side-effect
Goto Forum:
  


Current Time: Fri Jul 10 13:59:55 GMT 2020

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

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

Back to the top