Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Adding a command to multiple views
Adding a command to multiple views [message #336555] Mon, 22 June 2009 18:20 Go to next message
Eric Jain is currently offline Eric JainFriend
Messages: 266
Registered: July 2009
Senior Member
I have "Refresh" Handler that can be used for any Part that implements an
interface called RefreshablePart:

<handler class="test.RefreshPartHandler"
commandId="org.eclipse.ui.file.refresh">
<activeWhen>
<with variable="activePart">
<instanceof value="test.RefreshablePart"/>
</with>
</activeWhen>
</handler>

Here is how a refresh icon is added to a view:

<menuContribution locationURI="toolbar:testView">
<command commandId="org.eclipse.ui.file.refresh"
icon="icons/refresh.gif" style="push">
</command>
</menuContribution>

This works fine -- except that the Refresh icon appears disabled unless
the view is in focus, even though it still is clickable and works as
expected (clicking the icon makes the view receive focus).

One workaround is to specify the same icon as a disabledIcon. This is not
a perfect solution as there are still some subtle differences (mouse
over), and of course this causes issues if I actually wanted to disable
the command under certain circumstances.

But perhaps there is a better way to approach this?
Re: Adding a command to multiple views [message #336563 is a reply to message #336555] Tue, 23 June 2009 13:05 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

This is the behaviour you will see if you restrict your handler to being
active when the activePart meets your requirements.

But you're going about it the correct way, since refresh is a command
that is implemented on a per-part basis.

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/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Previous Topic:Content Assist question
Next Topic:something better than java.lang.Runtime.exec()
Goto Forum:
  


Current Time: Wed Apr 24 23:58:14 GMT 2024

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

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

Back to the top