Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Initialize Action and View simultaneously
Initialize Action and View simultaneously [message #534195] Tue, 18 May 2010 10:35 Go to next message
Adrien Mayer is currently offline Adrien MayerFriend
Messages: 2
Registered: May 2010
Junior Member
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 #534248 is a reply to message #534195] Tue, 18 May 2010 13:10 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

That's standard behaviour for declarative actions. The good news is the
system is working as designed. The bad news is that's now quite what
you want.

Are your viewActions defined in the same plugin as your view itself?

When you open your view menu the first time, do you see any of your
IViewActionDelegate methods called?

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Initialize Action and View simultaneously [message #534271 is a reply to message #534248] Tue, 18 May 2010 14:39 Go to previous message
Adrien Mayer is currently offline Adrien MayerFriend
Messages: 2
Registered: May 2010
Junior Member
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
Previous Topic:Radio button in menu
Next Topic:Dialog based application?
Goto Forum:
  


Current Time: Fri May 10 22:47:34 GMT 2024

Powered by FUDForum. Page generated in 0.02759 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top