|
|
|
|
|
|
|
|
Re: Get the selected menu item [message #965766 is a reply to message #940285] |
Wed, 31 October 2012 13:43 |
Linus Pettersson Messages: 8 Registered: October 2012 |
Junior Member |
|
|
So, there is a problem.
I have created two new classes, CreateTrackableChildAction and CreateTrackableSiblingAction which extends CreateChildAction and CreateSiblingAction. In the run() method we capture the action and saves it in a static hashmap. So, the latest used children/siblings will be in these hashmaps. They are then added to the menu in the ElementsActionBarContributor. So far so good.
The issue now is that the latest siblings and children are very separated, I mean if you add a children to a node and then right click on one of the children of this node, this newly created child should show up amongst the "latest siblings". But it doesn't, of course. The "latest siblings" is only populated when the sibling menu is used...
Maybe this approach is not the best and maybe we need to re-think this. Maybe to traverse the tree instead and get the latest used children/siblings this way?
If I traverse the tree and get a node, how can I create a menu item for this? I should do "new CreateChildAction(activeEditorPart, selection, descriptor)" but how do I get the descriptor?
|
|
|
Re: Get the selected menu item [message #965802 is a reply to message #965766] |
Wed, 31 October 2012 14:09 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Linus,
Comments below.
On 31/10/2012 2:43 PM, Linus Pettersson wrote:
> So, there is a problem.
>
> I have created two new classes, CreateTrackableChildAction and
> CreateTrackableSiblingAction which extends CreateChildAction and
> CreateSiblingAction. In the run() method we capture the action and
> saves it in a static hashmap.
You'd need to ensure that you create a new command.
> So, the latest used children/siblings will be in these hashmaps. They
> are then added to the menu in the ElementsActionBarContributor. So far
> so good.
>
> The issue now is that the latest siblings and children are very
> separated, I mean if you add a children to a node and then right click
> on one of the children of this node, this newly created child should
> show up amongst the "latest siblings". But it doesn't, of course. The
> "latest siblings" is only populated when the sibling menu is used...
Sorry, I don't follow. In fact I really don't understand what design
you're trying to achieve...
>
> Maybe this approach is not the best and maybe we need to re-think
> this. Maybe to traverse the tree instead and get the latest used
> children/siblings this way?
What do you mean by "used"?
>
>
> If I traverse the tree and get a node, how can I create a menu item
> for this?
That's what's normally happening already for populating the context menu...
> I should do "new CreateChildAction(activeEditorPart, selection,
> descriptor)" but how do I get the descriptor?
You can see how the code in the action bar contributor currently gets
the descriptors.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Get the selected menu item [message #965840 is a reply to message #965802] |
Wed, 31 October 2012 14:46 |
Linus Pettersson Messages: 8 Registered: October 2012 |
Junior Member |
|
|
Ed Merks wrote on Wed, 31 October 2012 10:09
....
> I should do "new CreateChildAction(activeEditorPart, selection,
> descriptor)" but how do I get the descriptor?
You can see how the code in the action bar contributor currently gets
the descriptors.
Well, yes it gets all the descriptors by calling "domain.getNewChildDescriptors(object, null);". It returns all the descriptors, but what if I just want to create one specific.
What I want to achieve. Let's say you're creating a tree and you right click > New Child and this list is veeery long. Then when you add a child through this menu, it then shows up at the top of the "New Child" menu. So, at the top of the "New Child" menu we display the 5 latest added children. The same goes for the "New Sibling" menu.
The problem is that as it works now, it keeps two lists, one for latest used children and one for the latest used siblings. The thing is that if you add a children B to a node A using the "New Child" menu, and then right click on another children to A it should show B in its list of latest used siblings.
The same issue appears if you add a sibling to B and then right click its parent, A, it should show up as a recently added children.
The above doesn't work though, as we keep the lists of children/siblings separate. Do you see the issue?
Maybe our approach is bad and instead of storing lists of the recently added Children/Siblings we could traverse the tree instead and find the latest added elements and create menu items based on this?
|
|
|
Re: Get the selected menu item [message #965865 is a reply to message #965840] |
Wed, 31 October 2012 15:07 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Linus,
Comments below.
On 31/10/2012 3:46 PM, Linus Pettersson wrote:
> Ed Merks wrote on Wed, 31 October 2012 10:09
>> ....
>> > I should do "new CreateChildAction(activeEditorPart, selection, >
>> descriptor)" but how do I get the descriptor?
>> You can see how the code in the action bar contributor currently gets
>> the descriptors.
>
>
> Well, yes it gets all the descriptors by calling
> "domain.getNewChildDescriptors(object, null);". It returns all the
> descriptors, but what if I just want to create one specific.
There's no support for that. You'll have to find your specific one
among these.
>
>
>
> What I want to achieve. Let's say you're creating a tree and you right
> click > New Child and this list is veeery long. Then when you add a
> child through this menu, it then shows up at the top of the "New
> Child" menu. So, at the top of the "New Child" menu we display the 5
> latest added children. The same goes for the "New Sibling" menu.
So basically you want to sort the list where the most recently used ones
come first. You should look closely at what's in the descriptors
because those will be what you want to record and what you want to use
as the basis for sorting.
>
> The problem is that as it works now, it keeps two lists, one for
> latest used children and one for the latest used siblings. The thing
> is that if you add a children B to a node A using the "New Child"
> menu, and then right click on another children to A it should show B
> in its list of latest used siblings.
> The same issue appears if you add a sibling to B and then right click
> its parent, A, it should show up as a recently added children.
You can't reuse the actions. The object they'll add has already been
added. You need new commands with new descriptors. As I said, it sounds
like an ordering concern.
>
> The above doesn't work though, as we keep the lists of
> children/siblings separate. Do you see the issue? :)
>
>
> Maybe our approach is bad and instead of storing lists of the recently
> added Children/Siblings we could traverse the tree instead and find
> the latest added elements and create menu items based on this?
I imagine you should keep the information about the descriptor in a
list, and you should use that list to sort the new list of descriptors.
The descriptors of typically CommandParameter instances where the
feature and the value will be what you want to use as the basis for
sorting. Keep in mind that it's the eClass() of the value that will
help with finding the corresponding feature/object-of-that-class command
parameter in the new list.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03892 seconds