0

Accessing methods of tree node?

asked 2015-05-06 15:32:33 +0800

Tegomena gravatar image Tegomena
33 4

Hi,

I have a Tree for which I have written a model ("MyModel") and a node class ("MyNode"). In MyNode, I'm storing some additional information with getter/setter, for example a String in "MyNode.getMyString()".

When someone clicks now on the tree, I can access its items via TreeItem:

   @Listen("onSelect =#datasetsTree")
    public void onSelectDatasetsTree(Event ev){
        LOGGER.info(datasetsTree.getSelectedItem().getLabel());
    }

But how can I access now the "MyNode" object behind it, a casting doesn't works?

Thanks for any hints and in general I would like to say Thank You for the excellent help in this forum!

delete flag offensive retag edit

Comments

the datasetsTree is Tree class?

chillworld ( 2015-05-07 09:23:26 +0800 )edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2015-05-07 09:26:51 +0800

Tegomena gravatar image Tegomena
33 4

Thank you very much for your help, I figured it out!!

link publish delete flag offensive edit
1

answered 2015-05-07 09:20:32 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

updated 2015-05-07 09:27:37 +0800

If it's a Tree you have you can get the selected node by :

// maybe some more casting need to be done.
Set<MyNode> nodes = ((MyModel)tree.getModel()).getSelection();

This is of course true if MyModel extends AbstractTreeModel.

Greetz chill.

link publish delete flag offensive edit
1

answered 2015-05-07 02:05:40 +0800

echarish gravatar image echarish flag of Japan
1809 7
http://jp.linkedin.com/in...

Hello

event.getTarget() will give you the component on which the event is being triggered. once you have the target you can cast it to your component and call your methods.

Harish.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-05-06 15:32:33 +0800

Seen: 19 times

Last updated: May 07 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More