|Initialize Action and View simultaneously [message #534195]
||Tue, 18 May 2010 10:35
| Adrien Mayer
Registered: May 2010
First, sorry for my English.
In my RCP application, a view contains some actions in tool bar (org.eclipse.ui.viewActions). These actions are initialized when they are executed (when clicking on it). I would like to initialize them at the same time at the view initialization. Then, I would be able to enable or disable the action according to a parameter in my application before the first execution of the action.
For now, if the action is not possible and if I click on it, I have the message "The chosen operation is not enabled" after the initialization and the test I want to do. After that, the action is disabled (button becomes grey).
I have tried several things (but nothing works) :
- First, in MANIFEST file, the Bundle-ActivationPolicy command value is lazy. I can add include:="package1","package2" or exclude:="package1","package2" to specify packages which will not use the lazy actionvation policy.
- in plugin.xml, I can add :
Then, Myaction implements earlyStartup() method of IStartup interface, which allows to execute code at application launching. But, at this time, I can't initialize my action like I want, since nothing is instanciated yet.
- In tha action declaration in plugin.xml, I can add an "enablement" element which allows to define the action state (enable or disable) before the action initialization. For exemple :
But, I can't use any of the sub elements of enablement (see org.eclipse.ui.viewActions) to define my condition.
- Last, the action can use two initialization methods (init(IViewPart part) and init(IAction action)), but init(IViewPart part), but init(IViewPart part) can't initialize the action at the same time at the view initialization.
So, any of these tries allows me to enable or disable the action with my condition before launching the action a first time (the action is initialize only at this time). Did I miss something ?
Thanks for your time and may be your future answers,
Powered by FUDForum
. Page generated in 0.11191 seconds