Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » disable rename action for specific navigator content
disable rename action for specific navigator content [message #329958] Fri, 11 July 2008 13:12 Go to next message
Eclipse UserFriend
Originally posted by: klammer.utanet.at

I searched for a solution to following problem for some hours now:

I want to disable the 'default' rename action for a specific resource
(identified by file extension). Both 'F2' button and 'context menue
entry' should be disabled.

What I've done so far:
1.) introduced own handler for commands
'org.eclipse.ltk.ui.refactoring.commands.renameResource' and
'org.eclipse.ui.edit.rename' which does nothing when the commands are
executed. This works except the action is still displayed as
'executable' which I do not know how to solve.

2.) So I tried to find a solution to get rid of the menu action entry
completely. But so far I had no luck when trying to overwrite the
org.eclipse.ui.navigator.resources.actions.RefactorActionPro vider for
the specific navigatorContent

Any hints are welcome!
Regards,
Claus Klammer


using Eclipse 3.4.0 I20080617-2000
Re: disable rename action for specific navigator content [message #329993 is a reply to message #329958] Fri, 11 July 2008 17:41 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
You are using the Project Explorer (Common Navigator)?

If so, then you will need to split the RefactorActionProvider into two
classes, one for rename and one for move.

Then make content extensions that define the enablement of each of these
using the org.eclipse.ui.navigatorContent extention point.

Finally in the org.eclipse.ui.navigatorViewer extension point bind to
the new content extensions and remove the binding to the one that comes
with eclipse. (You may need to remove a wildcard binding and specify
all of the content extensions you want directly).

I assume this is for an RCP application and not a plugin. If it's a
plugin things are more complicated because you don't control the use of
the extension points that defined the Project Explorer and there are
other types of resources where you will not want to interfere. I would
have to think about solving the problem in that case.

Claus Klammer wrote:
> I searched for a solution to following problem for some hours now:
>
> I want to disable the 'default' rename action for a specific resource
> (identified by file extension). Both 'F2' button and 'context menue
> entry' should be disabled.
>
> What I've done so far:
> 1.) introduced own handler for commands
> 'org.eclipse.ltk.ui.refactoring.commands.renameResource' and
> 'org.eclipse.ui.edit.rename' which does nothing when the commands are
> executed. This works except the action is still displayed as
> 'executable' which I do not know how to solve.
>
> 2.) So I tried to find a solution to get rid of the menu action entry
> completely. But so far I had no luck when trying to overwrite the
> org.eclipse.ui.navigator.resources.actions.RefactorActionPro vider for
> the specific navigatorContent
>
> Any hints are welcome!
> Regards,
> Claus Klammer
>
>
> using Eclipse 3.4.0 I20080617-2000


--
*new* Common Navigator Framework section in:
3.4RC4 Platform Plugin Developer Guide (Programmer's Guide)
http://help.eclipse.org/ganymede/topic/org.eclipse.platform. doc.isv/guide/cnf.htm
http://dev.eclipse.org/blogs/francis
http://wiki.eclipse.org/Common_Navigator_Framework
http://wiki.eclipse.org/Common_Navigator_Framework_Use_Cases


You have brains in your head.
You have feet in your shoes.
- Dr Seuss, Oh the Places You'll Go


Re: disable rename action for specific navigator content [message #330052 is a reply to message #329993] Mon, 14 July 2008 09:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: klammer.utanet.at

You're right I'm using the Project Explorer and want to adapt its menu
for an RCP application.

Despite your hints I was not able to remove the Rename-Action from the
context menu. As a first step I want to remove the
RefactorActionProvider completely - to see that thing can be configured
like expected. But unfortunately this did not work either (see below).

org.eclipse.ui.navigator.resources plugin in declares content and action
bindings for the Project Explorer:

<viewerContentBinding
viewerId="org.eclipse.ui.navigator.ProjectExplorer">
<includes>
<contentExtension
pattern="org.eclipse.ui.navigator.resourceContent" />
<contentExtension
pattern="org.eclipse.ui.navigator.resources.filters.*"/>
<contentExtension
pattern="org.eclipse.ui.navigator.resources.linkHelper"/>
<contentExtension
pattern="org.eclipse.ui.navigator.resources.workingSets"/>
</includes>
</viewerContentBinding>
<viewerActionBinding
viewerId="org.eclipse.ui.navigator.ProjectExplorer">
<includes>
<actionExtension
pattern="org.eclipse.ui.navigator.resources.*" />
</includes>
</viewerActionBinding>

In turn the viewerContent org.eclipse.ui.navigator.resourceContent
specifies the 'RefactorActionProvider' internally which I want to get
rid of.

<actionProvider

class=" org.eclipse.ui.internal.navigator.resources.actions.Refactor ActionProvider "

id="org.eclipse.ui.navigator.resources.actions.RefactorActions "/>

So I tried to exclude this content by redeclare it in my own plugin.

<extension
point="org.eclipse.ui.navigator.viewer">

<viewerContentBinding
viewerId="org.eclipse.ui.navigator.ProjectExplorer">
<excludes>
<contentExtension
pattern="org.eclipse.ui.navigator.resourceContent" />
</excludes>
</viewerContentBinding>
</extension>

But this does not work, the refactor context menue entries are still
there. What I'm doing wrong? How can I control the merge of content
declarations (is it now included or excluded)?
Any tips how I can find out/debug this are very appreciated!

Thanks in advance,
Claus Klammer



Francis Upton (News) schrieb:
> You are using the Project Explorer (Common Navigator)?
>
> If so, then you will need to split the RefactorActionProvider into two
> classes, one for rename and one for move.
>
> Then make content extensions that define the enablement of each of these
> using the org.eclipse.ui.navigatorContent extention point.
>
> Finally in the org.eclipse.ui.navigatorViewer extension point bind to
> the new content extensions and remove the binding to the one that comes
> with eclipse. (You may need to remove a wildcard binding and specify
> all of the content extensions you want directly).
>
> I assume this is for an RCP application and not a plugin. If it's a
> plugin things are more complicated because you don't control the use of
> the extension points that defined the Project Explorer and there are
> other types of resources where you will not want to interfere. I would
> have to think about solving the problem in that case.
>
> Claus Klammer wrote:
>> I searched for a solution to following problem for some hours now:
>>
>> I want to disable the 'default' rename action for a specific resource
>> (identified by file extension). Both 'F2' button and 'context menue
>> entry' should be disabled.
>>
>> What I've done so far:
>> 1.) introduced own handler for commands
>> 'org.eclipse.ltk.ui.refactoring.commands.renameResource' and
>> 'org.eclipse.ui.edit.rename' which does nothing when the commands are
>> executed. This works except the action is still displayed as
>> 'executable' which I do not know how to solve.
>>
>> 2.) So I tried to find a solution to get rid of the menu action entry
>> completely. But so far I had no luck when trying to overwrite the
>> org.eclipse.ui.navigator.resources.actions.RefactorActionPro vider for
>> the specific navigatorContent
>>
>> Any hints are welcome!
>> Regards,
>> Claus Klammer
>>
>>
>> using Eclipse 3.4.0 I20080617-2000
>
>
Re: disable rename action for specific navigator content [message #330088 is a reply to message #330052] Mon, 14 July 2008 15:28 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
If you are doing an RCP application, give your viewer a different Id,
and make your own viewerContentBinding and navigatorContentExtension
extension points. You can copy much of them from the ones defined in
org.eclipse.ui.resources.

I don't think you can really modify the definition for the
ProjectExplorer instance in this way, as I'm not sure that the excludes
mechanism will work across extension point declarations (one of the
extensions is defined in your plugin, the other in the
org.eclipse.ui.navigator.resources plugin). This might be an
interesting enhancement request.

Francis

Claus Klammer wrote:
> You're right I'm using the Project Explorer and want to adapt its menu
> for an RCP application.
>
> Despite your hints I was not able to remove the Rename-Action from the
> context menu. As a first step I want to remove the
> RefactorActionProvider completely - to see that thing can be configured
> like expected. But unfortunately this did not work either (see below).
>
> org.eclipse.ui.navigator.resources plugin in declares content and action
> bindings for the Project Explorer:
>
> <viewerContentBinding
> viewerId="org.eclipse.ui.navigator.ProjectExplorer">
> <includes>
> <contentExtension
> pattern="org.eclipse.ui.navigator.resourceContent" />
> <contentExtension
> pattern="org.eclipse.ui.navigator.resources.filters.*"/>
> <contentExtension
> pattern="org.eclipse.ui.navigator.resources.linkHelper"/>
> <contentExtension
> pattern="org.eclipse.ui.navigator.resources.workingSets"/>
> </includes>
> </viewerContentBinding>
> <viewerActionBinding
> viewerId="org.eclipse.ui.navigator.ProjectExplorer">
> <includes>
> <actionExtension
> pattern="org.eclipse.ui.navigator.resources.*" />
> </includes>
> </viewerActionBinding>
>
> In turn the viewerContent org.eclipse.ui.navigator.resourceContent
> specifies the 'RefactorActionProvider' internally which I want to get
> rid of.
>
> <actionProvider
>
> class=" org.eclipse.ui.internal.navigator.resources.actions.Refactor ActionProvider "
>
>
> id="org.eclipse.ui.navigator.resources.actions.RefactorActions "/>
>
> So I tried to exclude this content by redeclare it in my own plugin.
>
> <extension
> point="org.eclipse.ui.navigator.viewer">
>
> <viewerContentBinding
> viewerId="org.eclipse.ui.navigator.ProjectExplorer">
> <excludes>
> <contentExtension
> pattern="org.eclipse.ui.navigator.resourceContent" />
> </excludes>
> </viewerContentBinding>
> </extension>
>
> But this does not work, the refactor context menue entries are still
> there. What I'm doing wrong? How can I control the merge of content
> declarations (is it now included or excluded)?
> Any tips how I can find out/debug this are very appreciated!
>
> Thanks in advance,
> Claus Klammer
>
>
>
> Francis Upton (News) schrieb:
>> You are using the Project Explorer (Common Navigator)?
>>
>> If so, then you will need to split the RefactorActionProvider into
>> two classes, one for rename and one for move.
>>
>> Then make content extensions that define the enablement of each of
>> these using the org.eclipse.ui.navigatorContent extention point.
>>
>> Finally in the org.eclipse.ui.navigatorViewer extension point bind to
>> the new content extensions and remove the binding to the one that
>> comes with eclipse. (You may need to remove a wildcard binding and
>> specify all of the content extensions you want directly).
>>
>> I assume this is for an RCP application and not a plugin. If it's a
>> plugin things are more complicated because you don't control the use
>> of the extension points that defined the Project Explorer and there
>> are other types of resources where you will not want to interfere. I
>> would have to think about solving the problem in that case.
>>
>> Claus Klammer wrote:
>>> I searched for a solution to following problem for some hours now:
>>>
>>> I want to disable the 'default' rename action for a specific resource
>>> (identified by file extension). Both 'F2' button and 'context menue
>>> entry' should be disabled.
>>>
>>> What I've done so far:
>>> 1.) introduced own handler for commands
>>> 'org.eclipse.ltk.ui.refactoring.commands.renameResource' and
>>> 'org.eclipse.ui.edit.rename' which does nothing when the commands are
>>> executed. This works except the action is still displayed as
>>> 'executable' which I do not know how to solve.
>>>
>>> 2.) So I tried to find a solution to get rid of the menu action entry
>>> completely. But so far I had no luck when trying to overwrite the
>>> org.eclipse.ui.navigator.resources.actions.RefactorActionPro vider for
>>> the specific navigatorContent
>>>
>>> Any hints are welcome!
>>> Regards,
>>> Claus Klammer
>>>
>>>
>>> using Eclipse 3.4.0 I20080617-2000
>>
>>


--
*new* Common Navigator Framework section in:
3.4RC4 Platform Plugin Developer Guide (Programmer's Guide)
http://help.eclipse.org/ganymede/topic/org.eclipse.platform. doc.isv/guide/cnf.htm
http://dev.eclipse.org/blogs/francis
http://wiki.eclipse.org/Common_Navigator_Framework
http://wiki.eclipse.org/Common_Navigator_Framework_Use_Cases


You have brains in your head.
You have feet in your shoes.
- Dr Seuss, Oh the Places You'll Go


Re: disable rename action for specific navigator content [message #330102 is a reply to message #330088] Tue, 15 July 2008 06:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: klammer.utanet.at

Francis, thanks for your help!

Because of your hints I was able to find a feasible solution for my
problem finally.

I defined my own navigatorContent which overrides the default navigator
resource content and uses a custom ActionProvider which overrides the
standard navigator RefactorActions and provides only the 'Move' action.

<override
suppressedExtensionId="org.eclipse.ui.navigator.resourceContent ">
</override>
<actionProvider
class="com.xx.xx.xx.ui.actions.RefactorActionProvider"
id="com.xx.xx.xx.actions.RefactorActions"

overrides="org.eclipse.ui.navigator.resources.actions.RefactorActions "
priority="highest">
<enablement>
<test
property="org.eclipse.core.resources.name"
value="*.whatever">
</test>
</enablement>
</actionProvider>

If the extension name of the resource matches the defined value the user
defined action provider is used instead of the default one -> rename is
not available anymore.

Although I solve my problem, I would appreciate a 'problem - solution'
page (wiki?) for such - more or less - tricky declaration challenges.
Even the declaration point description is good in my point of view a
more problem solution oriented help would be very useful. Escpecially
since the required declarations are often spread around many extension
points. Perhaps a link to an existing configuration that issues the same
problem might help.

Regards,
Claus


Francis Upton (News) schrieb:
> If you are doing an RCP application, give your viewer a different Id,
> and make your own viewerContentBinding and navigatorContentExtension
> extension points. You can copy much of them from the ones defined in
> org.eclipse.ui.resources.
>
> I don't think you can really modify the definition for the
> ProjectExplorer instance in this way, as I'm not sure that the excludes
> mechanism will work across extension point declarations (one of the
> extensions is defined in your plugin, the other in the
> org.eclipse.ui.navigator.resources plugin). This might be an
> interesting enhancement request.
>
> Francis
>
> Claus Klammer wrote:
>> You're right I'm using the Project Explorer and want to adapt its menu
>> for an RCP application.
>>
>> Despite your hints I was not able to remove the Rename-Action from
>> the context menu. As a first step I want to remove the
>> RefactorActionProvider completely - to see that thing can be
>> configured like expected. But unfortunately this did not work either
>> (see below).
>>
>> org.eclipse.ui.navigator.resources plugin in declares content and
>> action bindings for the Project Explorer:
>>
>> <viewerContentBinding
>> viewerId="org.eclipse.ui.navigator.ProjectExplorer">
>> <includes>
>> <contentExtension
>> pattern="org.eclipse.ui.navigator.resourceContent" />
>> <contentExtension
>> pattern="org.eclipse.ui.navigator.resources.filters.*"/>
>> <contentExtension
>> pattern="org.eclipse.ui.navigator.resources.linkHelper"/>
>> <contentExtension
>> pattern="org.eclipse.ui.navigator.resources.workingSets"/>
>> </includes>
>> </viewerContentBinding>
>> <viewerActionBinding
>> viewerId="org.eclipse.ui.navigator.ProjectExplorer">
>> <includes>
>> <actionExtension
>> pattern="org.eclipse.ui.navigator.resources.*" />
>> </includes>
>> </viewerActionBinding>
>>
>> In turn the viewerContent org.eclipse.ui.navigator.resourceContent
>> specifies the 'RefactorActionProvider' internally which I want to get
>> rid of.
>>
>> <actionProvider
>>
>> class=" org.eclipse.ui.internal.navigator.resources.actions.Refactor ActionProvider "
>>
>>
>> id="org.eclipse.ui.navigator.resources.actions.RefactorActions "/>
>>
>> So I tried to exclude this content by redeclare it in my own plugin.
>>
>> <extension
>> point="org.eclipse.ui.navigator.viewer">
>>
>> <viewerContentBinding
>> viewerId="org.eclipse.ui.navigator.ProjectExplorer">
>> <excludes>
>> <contentExtension
>> pattern="org.eclipse.ui.navigator.resourceContent" />
>> </excludes>
>> </viewerContentBinding>
>> </extension>
>>
>> But this does not work, the refactor context menue entries are still
>> there. What I'm doing wrong? How can I control the merge of content
>> declarations (is it now included or excluded)?
>> Any tips how I can find out/debug this are very appreciated!
>>
>> Thanks in advance,
>> Claus Klammer
>>
>>
>>
>> Francis Upton (News) schrieb:
>>> You are using the Project Explorer (Common Navigator)?
>>>
>>> If so, then you will need to split the RefactorActionProvider into
>>> two classes, one for rename and one for move.
>>>
>>> Then make content extensions that define the enablement of each of
>>> these using the org.eclipse.ui.navigatorContent extention point.
>>>
>>> Finally in the org.eclipse.ui.navigatorViewer extension point bind to
>>> the new content extensions and remove the binding to the one that
>>> comes with eclipse. (You may need to remove a wildcard binding and
>>> specify all of the content extensions you want directly).
>>>
>>> I assume this is for an RCP application and not a plugin. If it's a
>>> plugin things are more complicated because you don't control the use
>>> of the extension points that defined the Project Explorer and there
>>> are other types of resources where you will not want to interfere. I
>>> would have to think about solving the problem in that case.
>>>
>>> Claus Klammer wrote:
>>>> I searched for a solution to following problem for some hours now:
>>>>
>>>> I want to disable the 'default' rename action for a specific
>>>> resource (identified by file extension). Both 'F2' button and
>>>> 'context menue entry' should be disabled.
>>>>
>>>> What I've done so far:
>>>> 1.) introduced own handler for commands
>>>> 'org.eclipse.ltk.ui.refactoring.commands.renameResource' and
>>>> 'org.eclipse.ui.edit.rename' which does nothing when the commands
>>>> are executed. This works except the action is still displayed as
>>>> 'executable' which I do not know how to solve.
>>>>
>>>> 2.) So I tried to find a solution to get rid of the menu action
>>>> entry completely. But so far I had no luck when trying to overwrite
>>>> the
>>>> org.eclipse.ui.navigator.resources.actions.RefactorActionPro vider
>>>> for the specific navigatorContent
>>>>
>>>> Any hints are welcome!
>>>> Regards,
>>>> Claus Klammer
>>>>
>>>>
>>>> using Eclipse 3.4.0 I20080617-2000
>>>
>>>
>
>
Re: disable rename action for specific navigator content [message #330132 is a reply to message #330102] Wed, 16 July 2008 06:19 Go to previous message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
> Although I solve my problem, I would appreciate a 'problem - solution'
> page (wiki?) for such - more or less - tricky declaration challenges.
> Even the declaration point description is good in my point of view a
> more problem solution oriented help would be very useful. Escpecially
> since the required declarations are often spread around many extension
> points. Perhaps a link to an existing configuration that issues the same
> problem might help.

That's the beauty of the wiki, you can start a page like this yourself.
There is already a page for the common navigator (see the links
below). I agree with you it would be useful to have such a page as you
suggest, and would love it if you started one. I'm rather pressed for
time these days (like we all are I'm sure).

Thanks,

Francis


--
*new* Common Navigator Framework section in:
3.4RC4 Platform Plugin Developer Guide (Programmer's Guide)
http://help.eclipse.org/ganymede/topic/org.eclipse.platform. doc.isv/guide/cnf.htm
http://dev.eclipse.org/blogs/francis
http://wiki.eclipse.org/Common_Navigator_Framework
http://wiki.eclipse.org/Common_Navigator_Framework_Use_Cases


You have brains in your head.
You have feet in your shoes.
- Dr Seuss, Oh the Places You'll Go


Previous Topic:headless not entirely headless
Next Topic:Editing workset bug - Ganymede (Eclipse IDE for Java EE Developers)
Goto Forum:
  


Current Time: Fri Dec 27 03:15:50 GMT 2024

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

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

Back to the top