Home » Eclipse Projects » Eclipse Platform » Building dynamic context menus using Eclipse Commands(How to build dynamic context menu based on the Outline view selection)
Building dynamic context menus using Eclipse Commands [message #881690] |
Tue, 05 June 2012 04:49 |
Ramesh Nachimuthu Messages: 10 Registered: May 2012 |
Junior Member |
|
|
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 04:52] Report message to a moderator
|
|
| | | |
Re: Building dynamic context menus using Eclipse Commands [message #885473 is a reply to message #883449] |
Wed, 13 June 2012 04:26 |
Ramesh Nachimuthu Messages: 10 Registered: May 2012 |
Junior Member |
|
|
My Problem is getting complicated more now..
My Domain objects (List of Objects) are selected based on Tree Selection. But I want to attach each of them in different menu items in the same context menu.
For example domain objects list (X1, X2, X3) is created out of the tree selection then I want to attach X1 to 'Insert X1' option, X2 to 'Insert X2' option,X3 to 'Insert X3' option, in the same context menu. As on work around i am attaching string 'X1 or 'X2' as parameter then I am retrieving the domain Object again from the Tree selection inside my command handler.
Is there any other way to avoid this work around?.
I am facing one more issues.
I have to disable some menu items in the above dynamic context menu based some domain specific logic. For example I want to disable 'Insert X1' option but 'Insert X2' and 'Insert X3' should be active.
Regards,
Ramesh
[Updated on: Wed, 13 June 2012 04:28] Report message to a moderator
|
|
| |
Re: Building dynamic context menus using Eclipse Commands [message #886002 is a reply to message #885678] |
Thu, 14 June 2012 02:49 |
Ramesh Nachimuthu Messages: 10 Registered: May 2012 |
Junior Member |
|
|
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: Thu, 14 June 2012 03:07] Report message to a moderator
|
|
| | |
Goto Forum:
Current Time: Thu Apr 25 06:36:04 GMT 2024
Powered by FUDForum. Page generated in 0.04065 seconds
|