CheckboxTreeViewer with custom input [message #534677] |
Wed, 19 May 2010 20:27 |
|
Hello everyone,
I've recently started to develop Eclipse plug-ins using SWT and JFace.
I'm writing my own custom dialog in which there is a CheckboxTreeViewer that is supposed to show all the projects in eclipse workspace along with their files and folders in a tree format.
I figured out that the input is set via the following code in the tree's TreeContentProvider class:
public Object[] getElements(Object parent) {
return SOMETHING;
}
Now what should I do if I want to pass the workspace projects, folders and files to this tree viewer as an input?
I tried to use the following code but it did not work as this method returns an object of type IWorkspaceRoot.
public Object[] getElements(Object parent) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
return workspace.getRoot();
}
I also tried to use the following code, but yet again it didn't work because it returns an array of type Project which can not be converted to File.
public Object[] getElements(Object parent) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
return root.getProjects();
}
Thank you very much,
Bahar
[Updated on: Wed, 19 May 2010 20:27] Report message to a moderator
|
|
|
Re: CheckboxTreeViewer with custom input [message #534698 is a reply to message #534677] |
Thu, 20 May 2010 01:28 |
|
Ok, I figured out that the problem was in the ContentProvider class.
There is this method in ContentProvider class:
public Object[] getElements(Object parent) {
IWorkspaceRoot root = workspace.getRoot();
return root.getProjects();
}
that returns all the projects in workspace as tree elements.
Now, how can I retrieve ALL the files in each project so I can create the tree structure myself?
Merci!
Bahar
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.47276 seconds