Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » label update for command/handler/contribution
label update for command/handler/contribution [message #323701] Sun, 06 January 2008 18:06 Go to next message
Eclipse UserFriend
Hi,

for "old" retargetable actions, there were the option allowLabelUpdate and
an action could set another label for its menu item (as example).
Is there a similar function for the new menu contribution mechanism
(org.eclipse.ui.menus) and command handlers? So, that the active handler can
add additional info to its menu item label?

Thanks,
Teddy
Re: label update for command/handler/contribution [message #323784 is a reply to message #323701] Tue, 08 January 2008 10:58 Go to previous messageGo to next message
Eclipse UserFriend
A handler can implement org.eclipse.ui.commands.IElementUpdater. That
will allow the handler access to an object with setText(*) and
setImageDescriptor(*) methods.

A call to ICommandService#refreshElements(*) will allow the active
handler to update the label.

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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Re: label update for command/handler/contribution [message #323930 is a reply to message #323784] Sun, 13 January 2008 13:57 Go to previous messageGo to next message
Eclipse UserFriend
Paul,
thank you very much! That's what I was looking for.
I works fine, but on startup. It is not updated automatically, calling
refreshElements in constructor of the handler is too early. As workaround, I
call it on first request of isEnabled. Is it a bug?

Teddy


"Paul Webster" <pwebster@ca.ibm.com> schrieb im Newsbeitrag
news:fm06gf$b7s$3@build.eclipse.org...
>A handler can implement org.eclipse.ui.commands.IElementUpdater. That will
>allow the handler access to an object with setText(*) and
>setImageDescriptor(*) methods.
>
> A call to ICommandService#refreshElements(*) will allow the active handler
> to update the label.
>
> 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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
>
Re: label update for command/handler/contribution [message #323955 is a reply to message #323930] Mon, 14 January 2008 12:39 Go to previous messageGo to next message
Eclipse UserFriend
Teddy Walker wrote:
> Paul,
> thank you very much! That's what I was looking for.
> I works fine, but on startup. It is not updated automatically, calling
> refreshElements in constructor of the handler is too early. As
> workaround, I call it on first request of isEnabled. Is it a bug?

On startup your handler would not normally be loaded, but it would be
proxied (probably by a HandlerProxy). If your handler was the default
handler it would be the active handler.

If you are worried that the menu item is not being updated right away,
that is normal (since your handler won't be loaded until a user action).

Or is it a slightly different scenario than I outline here?

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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Re: label update for command/handler/contribution [message #324345 is a reply to message #323955] Wed, 23 January 2008 05:53 Go to previous messageGo to next message
Eclipse UserFriend
Hi Paul,
It is a toolbar button and the default handler. The handler object is
created and the method #isEnabled() is called via HandlerProxy#isEnabled() .
It seems, it is not updated, after the proxy loaded the real handler?

Ciao,
Teddy


"Paul Webster" <pwebster@ca.ibm.com> schrieb im Newsbeitrag
news:fmg6ko$b0a$2@build.eclipse.org...
> Teddy Walker wrote:
>> Paul,
>> thank you very much! That's what I was looking for.
>> I works fine, but on startup. It is not updated automatically, calling
>> refreshElements in constructor of the handler is too early. As
>> workaround, I call it on first request of isEnabled. Is it a bug?
>
> On startup your handler would not normally be loaded, but it would be
> proxied (probably by a HandlerProxy). If your handler was the default
> handler it would be the active handler.
>
> If you are worried that the menu item is not being updated right away,
> that is normal (since your handler won't be loaded until a user action).
>
> Or is it a slightly different scenario than I outline here?
>
> 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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
>
Re: label update for command/handler/contribution [message #324358 is a reply to message #324345] Wed, 23 January 2008 09:57 Go to previous messageGo to next message
Eclipse UserFriend
Teddy Walker wrote:
> Hi Paul,
> It is a toolbar button and the default handler. The handler object is
> created and the method #isEnabled() is called via
> HandlerProxy#isEnabled() .
> It seems, it is not updated, after the proxy loaded the real handler?

What is not updated after the proxy loads the real handler? The enabled
state (if you change it in your handler, you need to fire a property
change event)? Or the call to refreshElements(*)?

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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Re: label update for command/handler/contribution [message #324412 is a reply to message #324358] Thu, 24 January 2008 04:57 Go to previous messageGo to next message
Eclipse UserFriend
Paul Webster wrote:
> What is not updated after the proxy loads the real handler? The enabled
> state (if you change it in your handler, you need to fire a property
> change event)? Or the call to refreshElements(*)?

refreshElements(*) is not updated after the proxy loads the real handler.
Should it be called (by the proxy)?
(The enablement state is correct, the real handler is requested.)
Re: label update for command/handler/contribution [message #324428 is a reply to message #324412] Thu, 24 January 2008 09:31 Go to previous message
Eclipse UserFriend
Teddy Walker wrote:
>
> refreshElements(*) is not updated after the proxy loads the real
> handler. Should it be called (by the proxy)?
> (The enablement state is correct, the real handler is requested.)
>

Right, the handler proxy won't call refresh elements (that's been left
to the developer or the handler implementation itself). Maybe open a
bug at:

https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=UI&short_desc=[Contributions]

It sounds like having the HandlerProxy ask for a refresh if it
instantiates a handler that implements IElementUpdater might be reasonable.

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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Previous Topic:Is there a eclipse plugin which can compile Java source to class files?
Next Topic:Plugins installed but classes not found
Goto Forum:
  


Current Time: Wed Jul 16 13:23:38 EDT 2025

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

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

Back to the top