IAction vs IViewActionDelegate [message #316780] |
Mon, 18 June 2007 15:38  |
Eclipse User |
|
|
|
Originally posted by: ku_long.hotmail.com
Hey,
Some buttons on the toolbar of my view are supposed to be
enabled/disabled by the status of an background thread.
I added the buttons into the toolbar of the view through
implementing the IViewActionDelegate. I know the buttons
can be disabled/enabled through the method setEnabled(boolean)
of an IAction. But in IViewActionDelegate, an IAction instace
can be got when the action occurred. I don't know how to
make a button on the toolbar of the view disabled when the
view is initially displayed?
If I create my action through extending from the Action class,
it is easy to implement this function. But how can I do if I
create those buttons through implementing IViewActionDelegate?
Thanks.
|
|
|
Re: IAction vs IViewActionDelegate [message #316801 is a reply to message #316780] |
Tue, 19 June 2007 07:07  |
Eclipse User |
|
|
|
Raymond wrote:
> Hey,
>
> Some buttons on the toolbar of my view are supposed to be
> enabled/disabled by the status of an background thread. I added the
> buttons into the toolbar of the view through implementing the
> IViewActionDelegate. I know the buttons can be disabled/enabled through
> the method setEnabled(boolean) of an IAction. But in
> IViewActionDelegate, an IAction instace can be got when the action
> occurred. I don't know how to make a button on the toolbar of the view
> disabled when the view is initially displayed?
>
> If I create my action through extending from the Action class,
> it is easy to implement this function. But how can I do if I
> create those buttons through implementing IViewActionDelegate?
The delegates are part of a lazily loaded system. As you found out,
they're not easy to retrieve.
Your best bet is to have each of your IViewActionDelegates register with
your "view/system/background thread" when they are created. Your thread
can then tell the delegate when it is enabled, and then when the
delegate is asked to refresh its enablement (usually with a call to
selectionChanged(*) that passes in the IAction) you can update the
IAction then.
BTW: you will usually get at least 2 instances of each IViewActionDelegate.
Later,
PW
|
|
|
Powered by
FUDForum. Page generated in 0.02793 seconds