Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Group from tree view
Group from tree view [message #502736] Wed, 09 December 2009 15:13 Go to next message
John S. is currently offline John S.Friend
Messages: 22
Registered: October 2009
Junior Member
Hello,

I created my own treeviewer based upon Tom Schindl's article (http://www.eclipse.org/resources/resource.php?id=511).
So my plug-in looks like there is a tree viewer on the left hand side and when I click on an element (my metamodel is different from the one in the article), the details will appear on the right hand side. I would like to group some elements, for example I click on elements (ctrl+mouse) then the selected elements should appear in e.g. table if the user clicked on the Group button. I only have the basic code (treeview + element description) and I just started using JFace so it is quite difficult for me to figure out how a simple thing should be implemented. I would like to know how I should put the selected elements (mostly those elements which are contained in the top-level metaclass - these elements appear in the tree) on the left hand side (project explorer part) into a table which is found on the right hand side (project form area part). Actually, I do not even know what classes/methods should be used to access the list of selected elements from another class.

Thanks and best regards,
John S

[Updated on: Wed, 09 December 2009 15:40]

Report message to a moderator

Re: Group from tree view [message #502791 is a reply to message #502736] Wed, 09 December 2009 17:23 Go to previous messageGo to next message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 428
Registered: July 2009
Senior Member
Hi John,

If i understand your problem clearly.
You want wrappers for your tree elements.
The tree elements are populated from the TreeContentProvider.
It has a getChildren() method which should have the logic returning the children of your model.Your TreeContentProvider should have this logic.

Best Regards,
Saurav


Re: Group from tree view [message #502794 is a reply to message #502791] Wed, 09 December 2009 17:49 Go to previous messageGo to next message
John S. is currently offline John S.Friend
Messages: 22
Registered: October 2009
Junior Member
Hello,

Actually I have two Parts: ProjectExplorerPart (it has TreeViewer viewer) and ProjectFormAreaPart (it has Button button, Table table).

So when I click on the button I want to start eg. an viewer.addSelectionChangedListener (not sure I need this listener to get the current selected elements, or there is another way, treecontentprovider???). They are in two different classes.

I can listen the selection in the ProjectExplorerPart where there is the treeview, it continously listen and I can monitor it through the consol (println). BUT I should do it in the other ProjectFormAreaPart class, so i could put the selected entries into a table (only see the CURRENT selected elements in the treeview, when I click the button).

In the ProjectFormAreaPart class (Treeview is public in the other class, so I can access that):

button.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
TreeViewer tviewer = projectExplorer.viewer;
IStructuredSelection s = (IStructuredSelection) tviewer.getSelection();
System.out.println((IStructuredSelection)tviewer.getSelectio n());
...

When I click on the button, nothing happens, so there is something wrong with it, perhaps its not the proper way to do it, but I need something similar.

Best Regards,
John

[Updated on: Wed, 09 December 2009 18:08]

Report message to a moderator

Re: Group from tree view [message #502813 is a reply to message #502736] Wed, 09 December 2009 19:02 Go to previous message
John S. is currently offline John S.Friend
Messages: 22
Registered: October 2009
Junior Member
Hello,

Problem is solved with parameter (that is, Treeviewer) passing:

In the changeEditorView class:

public void run() {
projectExplorer = new ProjectExplorerPart(getViewSite(),
sashForm, toolkit, (ChangeModel)resource.getContents().get(0), defaultMgr);
projectDataForm = new ProjectFormAreaPart(getViewSite(),
sashForm, toolkit, editingDomain, resource, defaultMgr,
projectExplorer.getProjectObservable(),projectExplorer.viewe r);
}

Regards,
John
Previous Topic:How to use DeferredTreeContentManager?
Next Topic:Object in property view
Goto Forum:
  


Current Time: Thu Apr 25 04:37:25 GMT 2024

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

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

Back to the top