Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Create TreeViewer using Workspace Content
icon5.gif  Create TreeViewer using Workspace Content [message #989063] Tue, 04 December 2012 13:47 Go to next message
Diogo Falcao is currently offline Diogo Falcao
Messages: 3
Registered: December 2012
Junior Member
How can i set the content of TreeViewer, using informations from a workspace?

Load files, projects and etc from the workspace on the treeviewer?

Thanks
Re: Create TreeViewer using Workspace Content [message #989141 is a reply to message #989063] Tue, 04 December 2012 19:14 Go to previous messageGo to next message
John Steele is currently offline John Steele
Messages: 49
Registered: January 2010
Member
Get the workspace root:
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();


Get the projects:
IProject [] projects = root.getProjects()
viewer.setInput(projects)


Create your viewer, content provider, and label provider. You can set the input to the viewer as the array of projects or the workspace root.

Your content/label provider will need to use instanceof to determine the type of object you are currently working with, cast it, then return the respective property value.

You could also check out the common navigator framework.

[Updated on: Tue, 04 December 2012 19:16]

Report message to a moderator

Re: Create TreeViewer using Workspace Content [message #989347 is a reply to message #989063] Wed, 05 December 2012 18:38 Go to previous messageGo to next message
Diogo Falcao is currently offline Diogo Falcao
Messages: 3
Registered: December 2012
Junior Member
And how can I select a workspace and create custom projects for my RCP application? Thank you.
Re: Create TreeViewer using Workspace Content [message #989798 is a reply to message #989347] Fri, 07 December 2012 20:53 Go to previous message
John Steele is currently offline John Steele
Messages: 49
Registered: January 2010
Member
You will need to add the resources bundle to the project's dependencies list. As well to the launch configuration, along with it's dependencies.

You can get the workspace location by calling:
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
root.getLocation()


In RCP, you can get the default location by calling:
Platform.getLocation() or Platform.getInstanceLocation().


You can change the default location by specifying the -data or osgi.instance.area system propery.

Happy hunting.
Previous Topic:Can we compare two jface treeviewers model data using org.eclipse.compare
Next Topic:Contributed adapter not available
Goto Forum:
  


Current Time: Thu Oct 23 08:58:42 GMT 2014

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

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