|Building dynamic context menus using Eclipse Commands [message #881690]
||Tue, 05 June 2012 00:49
| Ramesh Nachimuthu
Registered: May 2012
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
Same way if element Y is selected, I should show
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.
[Updated on: Tue, 05 June 2012 00:52]
Report message to a moderator