Building dynamic context menus using Eclipse Commands [message #881690] |
Tue, 05 June 2012 00:49  |
Eclipse User |
|
|
|
Hi,
I am trying to create a context menu for Outline View. This context menu should be dynamic based on the selection.
For example, If element X is selected , my context menu should show
Insert X1
Insert X2
Insert X3
Insert X4
Same way if element Y is selected, I should show
Insert Y1
Insert Y2.
This list is dynamically calculated based on the selection. Here all are 'Insert' action. So we are trying to create a command called 'Insert Command' and pass these X1 or X2 or Y1, etc as a parameter to this command. The context menu items should be created using the above 'Insert Command'.
We are facing three problems here,
1. How to pass these values (X1 or X2 or X3 etc) as a parameter to 'Insert Command'?
2. How to pass Domain Objects as a parameter to Command (not just String)?
3. How to create the list of menu items (Insert X1, Insert X2, Insert X3, etc) based on the single 'Insert Command'?.
See the attached image to see the UI how it will look.
Note: We are not trying to Enable/Disable context menu based on the selection. Our menu items will be which can be based on one paramterized command ('Insert Command')
This is easily achievable using Actions, but we wanted to use Eclipse Commands not Actions.
Regards,
Ramesh
[Updated on: Tue, 05 June 2012 00:52] by Moderator
|
|
|
|
|
|
|
|
Re: Building dynamic context menus using Eclipse Commands [message #886002 is a reply to message #885678] |
Wed, 13 June 2012 22:49   |
Eclipse User |
|
|
|
Regarding Domain Objects,
We are building a UI Designer. Outline will show all the UI Elements in hierarchical
manner. We have to enable the user to add new elements to existing element using context menus. For example,
If a user select a 'Frame' in Outline, Context Menu should show the following
options, 'Insert Toolbar', 'Insert Header', 'Insert Menubar', 'Insert Button', etc. Same way, if user selects a 'Toolbar' in Outline context menu options will be 'Insert Toolbar Item' only . We have a common 'InsertElement' command with one handler which can take care of all insertions. I just have to pass one parameter to inform the Handler about what is being inserted(Button or Toolbar, Menubar ,etc).
I am able to create the Context Menu dynamically based on tree selection and Dynamic Contribution. Currently using "String' parameters I am passing this element names and inside the handler I am retrieving the 'Element details'. It works fine.
Regarding Enable/Disable,
According to our UI Guidline, we have to make the context menus consistent for particular contexts. In the above example, If the selected 'Frame' already has a 'Toolbar'(It can have only one toolbar) I should show the 'Insert Toolbar' menu item in disabled mode instead of simple removing it. This is for better user interactions and accessibility reasons.
I have one more use case as well,
In the same dynamic context menu, if there are only 3 or less than 3 Insert options then I should show them in direct context menu, If menu items are more than 3 then I have to create 'Insert' sub menu and put all insert menu items inside the 'Insert' Sub menu. Here insert menu items are dynamically contributed as stated earlier. I can use the same Dynamic Contributor to contribute to Main Menu as well as 'Insert' sub menu. DO you have any idea about how this can implemented?
All these things are easily possible with Actions .
Thanks with Regards,
Ramesh
[Updated on: Wed, 13 June 2012 23:07] by Moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.10141 seconds