Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Changing visibility of the toolbar items in IViewPart
Changing visibility of the toolbar items in IViewPart [message #631547] Thu, 07 October 2010 22:13 Go to next message
Alex Molochnikov is currently offline Alex Molochnikov
Messages: 25
Registered: July 2009
Junior Member
I ran into the following problem:

There are several editors (IEditorParts) in the app. There is also an
IViewPart that has a toolbar with several items. The IViewPart provides
supplementary content for some, but not all editors.

When an unsupported editor becomes active, the IViewPart goes empty.
However, its toolbar remains populated. I need to empty it out as well.

I tried the PropertyTester, wired up the plugin.xml, to control the
visibility of the commands, among other things, but no matter what I
tried, the toolbar items' status was updated only when the IViewPart
became active. The problem is that I need the toolbar refreshed as the
editors become active/inactive; the IViewPart may never gain focus.

Is there any solution based on the documented framework features (as
opposed to possible hacks)?

Alex Molochnikov
Kelman Technologies Inc.
Re: Changing visibility of the toolbar items in IViewPart [message #631576 is a reply to message #631547] Fri, 08 October 2010 04:35 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.
Messages: 621
Registered: July 2009
Senior Member
On 08/10/10 3:43 AM, Alex Molochnikov wrote:
> When an unsupported editor becomes active, the IViewPart goes empty.
> However, its toolbar remains populated. I need to empty it out as well.


I tried to put the New Wizard command on the Package Explorer and made
it visible only when PackageExplorer or Plugin manifest editor is
active. It works:

<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="toolbar:org.eclipse.jdt.ui.PackageExplorer">
<command
commandId="org.eclipse.ui.newWizard"
style="push">
<visibleWhen
checkEnabled="false">
<with
variable="activePartId">
<or>
<equals
value="org.eclipse.jdt.ui.PackageExplorer">
</equals>
<equals
value="org.eclipse.pde.ui.manifestEditor">
</equals>
</or>
</with>
</visibleWhen>
</command>
</menuContribution>
</extension>



--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: Changing visibility of the toolbar items in IViewPart [message #631658 is a reply to message #631547] Fri, 08 October 2010 11:44 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

If you are using propertyTesters, remember they are not event driven.
If you need to re-evaluate a property tester because you think it might
have changed, use
org.eclipse.ui.services.IEvaluationService.requestEvaluation (String)

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
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: Changing visibility of the toolbar items in IViewPart [message #631764 is a reply to message #631658] Fri, 08 October 2010 15:41 Go to previous message
Alex Molochnikov is currently offline Alex Molochnikov
Messages: 25
Registered: July 2009
Junior Member
Thank you, Paul. I am aware of this. However, my problem is in timing of
the testing. It does not fire until the IViewPart that owns the toolbar
gains focus. Hence there is no change in the toolbar status (items
adder/removed, enabled/disabled) when IEditorParts change their state.

Alex Molochnikov

Paul Webster wrote:
> If you are using propertyTesters, remember they are not event driven. If
> you need to re-evaluate a property tester because you think it might
> have changed, use
> org.eclipse.ui.services.IEvaluationService.requestEvaluation (String)
>
> PW
>
Previous Topic:Open View via Context Menu
Next Topic:Writing custom visibleWhen rules
Goto Forum:
  


Current Time: Fri Oct 24 09:44:39 GMT 2014

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

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