Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Override definitions in plugin.xml
Override definitions in plugin.xml [message #633851] Tue, 19 October 2010 15:35 Go to next message
andy is currently offline andyFriend
Messages: 13
Registered: October 2010
Junior Member
is it possible to override definitions in plugin.xml?

For example, I want the definition "org.eclipse.ui.examples.contributions.view.inView" to return true for some views I have added for which it is not turning true, so I have added:

	<extension
       point="org.eclipse.core.expressions.definitions">
    <definition id="org.eclipse.ui.examples.contributions.view.inView">
       <or>
          <instanceof
                value="com.acme.navigator.ContainerObject">
          </instanceof>
          <instanceof
                value="com.acme.navigator.RootObject">
          </instanceof>
          <adapt type="org.eclipse.core.resources.IResource">
             <test
                   property="org.eclipse.core.resources.projectNature"
                   value="com.acme.navigator.nature">
             </test>
          </adapt>
       </or>
    </definition>
 </extension>


To the top of my eclipse plugins plugin.xml. It doesn't appear to be working, should it be?
Re: Override definitions in plugin.xml [message #633906 is a reply to message #633851] Tue, 19 October 2010 18:44 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

No. When you provide multiple extensions with elements with the same
ID, it's left up to the extension point consumer to determine how to
deal with them.

I've seen "first in", "last in", and "all in" (with the first 2
sometimes generating error logs, sometime not :-) To make it more
interesting, the IExtensionRegistry states it will return extensions in
a non-deterministic order. Some extension point consumers sort
extensions by id ... but not all.

In this particular case, see
org.eclipse.core.internal.expressions.DefinitionRegistry for its
implementation.

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: Override definitions in plugin.xml [message #634008 is a reply to message #633851] Wed, 20 October 2010 09:14 Go to previous messageGo to next message
andy is currently offline andyFriend
Messages: 13
Registered: October 2010
Junior Member
Edit: Thanks for the response paul, the below post was written having not read it. I will look in to that register now.

(I'm trying to change File -> Refresh so that 'Refresh' is enabled more often than it currently is - I have some views for which Refresh should work, but eclipse won't let me push it!)

So far I have tried

1. Adding a commandListener to to the command 'org.eclipse.ui.file.refresh' to setEnabled(true) whenever it changes.

This does not work, I assume the change is fired before <enabledWhen> is evaluated.

2. Override the "org.eclipse.ui.examples.contributions.view.inView" definition by adding my own "org.eclipse.ui.examples.contributions.view.inView" definition to my plugin.xml

This does not work, I assume that the attempt to override is being ignored.

I can't believe there is no way to modify the behaviour of the standard menu in eclipse, what am I missing here?

[Updated on: Wed, 20 October 2010 09:16]

Report message to a moderator

Re: Override definitions in plugin.xml [message #634021 is a reply to message #633851] Wed, 20 October 2010 09:53 Go to previous messageGo to next message
andy is currently offline andyFriend
Messages: 13
Registered: October 2010
Junior Member
I appear to be making progress with help from this blog post: http://www.wickedshell.net/blog/?p=39
Re: Override definitions in plugin.xml [message #634042 is a reply to message #633851] Wed, 20 October 2010 11:24 Go to previous messageGo to next message
andy is currently offline andyFriend
Messages: 13
Registered: October 2010
Junior Member
So from my investigations I've realised that 'Refresh' is not always enabled because it doesn't have handlers that match the expression (which I sort of knew already but it makes a lot more sense now).

So I tried this:

IHandlerService iHandlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
RefreshHandler refresh = new RefreshHandler();
iHandlerService.activateHandler("org.eclipse.ui.file.refresh",refresh);


With my own RefreshHandler (extends AbstractHandler). However, I do not want refresh to be enabled for everything, so this presented the problem of refresh always being enabled. I was initially under the impression that isHandled() dealt with whether or not the command should be enabled for this handler, but that isn't the case.

So now my solution is this, to add to my plugin.xml:

 <extension
       point="org.eclipse.ui.handlers">
    <handler
          class="location.of.the.class.RefreshHandler"
          commandId="org.eclipse.ui.file.refresh">
       <enabledWhen>
          <or>
             <with
                   variable="activePart">
                <equals
                      value="part-1-that-refresh-should-work-for">
                </equals>
             </with>
             <with
                   variable="activePart">
                <equals
                      value="part-2-that-refresh-should-work-for">
                </equals>
             </with>
          </or>
       </enabledWhen>
    </handler>
 </extension>


But this also doesn't work! Is there something that I'm clearly doing wrong there? It seems that it should work from what I have seen. If it should work how can I look deeper (i.e. investigate the actual values of activePart)

Thanks!
Re: Override definitions in plugin.xml [message #634045 is a reply to message #634042] Wed, 20 October 2010 11:31 Go to previous message
andy is currently offline andyFriend
Messages: 13
Registered: October 2010
Junior Member
oops! activePartId not activePart. Simple as that and it's working.

Sorry to spam but will leave it up to help those like me in the future!
Previous Topic:IntroPart/ configExtension & the debugging thereof
Next Topic:Why can't I pull in org.eclipse.ui.workbench to my MANIFEST file?
Goto Forum:
  


Current Time: Wed Sep 18 23:26:54 GMT 2024

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

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

Back to the top