Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » CheckboxTreeViewer with custom input
CheckboxTreeViewer with custom input [message #534677] Wed, 19 May 2010 20:27 Go to next message
Bahar Sateli is currently offline Bahar SateliFriend
Messages: 19
Registered: May 2010
Location: Canada
Junior Member
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 Go to previous messageGo to next message
Bahar Sateli is currently offline Bahar SateliFriend
Messages: 19
Registered: May 2010
Location: Canada
Junior Member
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
Re: CheckboxTreeViewer with custom input [message #534704 is a reply to message #534677] Thu, 20 May 2010 04:27 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
On 20/05/10 1:57 AM, Bahar Sateli wrote:
> 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.


Why can't you use the standard selection dialogs?

http://eclipse-tips.com/index.php/how-to-guides/5-selection- dialogs-in-eclipse

--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: CheckboxTreeViewer with custom input [message #534949 is a reply to message #534704] Thu, 20 May 2010 18:38 Go to previous messageGo to next message
Bahar Sateli is currently offline Bahar SateliFriend
Messages: 19
Registered: May 2010
Location: Canada
Junior Member
Wow! Thank you Parkash!! I was not aware of such standard selection dialogs.

So now I have the structure that I need by using CheckedTreeSelectionDialog Very Happy

Just one other question: does anybody know how I can get rid of that help button on the bottom left of the dialog?

Merci Beaucoup!
Bahar

[Updated on: Thu, 20 May 2010 20:33]

Report message to a moderator

Re: CheckboxTreeViewer with custom input [message #537294 is a reply to message #534949] Tue, 01 June 2010 19:55 Go to previous message
Bahar Sateli is currently offline Bahar SateliFriend
Messages: 19
Registered: May 2010
Location: Canada
Junior Member
Okay... since nobody answered I'm gonna answer it myself. Very Happy

By invoking the method setDialogHelpAvailable(boolean helpAvailable) from class TrayDialog with false argument, you can get rid of the context help button.

Cheers,
Bahar

[Updated on: Tue, 01 June 2010 19:55]

Report message to a moderator

Previous Topic:cell traverse
Next Topic:Different behavior for right, left arrow keys when Quick Assist is invoked
Goto Forum:
  


Current Time: Mon Sep 23 10:28:15 GMT 2024

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

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

Back to the top