Initialize Action and View simultaneously [message #534195] |
Tue, 18 May 2010 06:35  |
Eclipse User |
|
|
|
Hi,
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 :
<extension point="org.eclipse.ui.startup">
<startup class="mypackage.Myaction"/>
</extension>
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 :
<action [...]>
<enablement>
<objectState
name=""
value="">
</objectState>
</enablement>
</action>
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,
Adrien Mayer
|
|
|
|
Re: Initialize Action and View simultaneously [message #534271 is a reply to message #534248] |
Tue, 18 May 2010 10:39  |
Eclipse User |
|
|
|
Paul Webster wrote on Tue, 18 May 2010 09:10 | Are your viewActions defined in the same plugin as your view itself?
|
Yes.
Paul Webster wrote on Tue, 18 May 2010 09:10 | When you open your view menu the first time, do you see any of your IViewActionDelegate methods called?
|
No.
Thanks for your answer. That confirms what I guessed. After all, behaviour is not bad : the action is not done and I just have an information message (it would be perfect in French ^^).
Adrien Mayer
|
|
|
Powered by
FUDForum. Page generated in 0.03401 seconds