Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Hiding/Preventing editor popup menu items
Hiding/Preventing editor popup menu items [message #289117] Fri, 29 July 2005 15:12 Go to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

I have implemented a couple of editors by extending the eclipse TextEditor.
My problem is that since Eclipse 3.1, the editor popup menu (right-click
within editor part) shows a couple of new menu items: "Run as..." and "Debug
as...".
However, these items are not really appropriate for my editor since there is
nothing to run or debug.
Investigating further reveals that these are object contributions from the
debug UI plugin and have been registered for the Object class (how
helpful!)- i.e., there's no escaping them.
Is there any way to prevent these popup menu items from being displayed?
Would IContributorResourceAdapter be of any use?
---
TIA,
Sunil
Re: Hiding/Preventing editor popup menu items [message #289243 is a reply to message #289117] Tue, 02 August 2005 18:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: douglas.pollock.magma.ca

Sunil Kamath wrote:

> I have implemented a couple of editors by extending the eclipse
> TextEditor. My problem is that since Eclipse 3.1, the editor popup menu
> (right-click within editor part) shows a couple of new menu items: "Run
> as..." and "Debug as...".
> However, these items are not really appropriate for my editor since there
> is nothing to run or debug.
> Investigating further reveals that these are object contributions from the
> debug UI plugin and have been registered for the Object class (how
> helpful!)- i.e., there's no escaping them.
> Is there any way to prevent these popup menu items from being displayed?

There are two options of which I am aware.

In your particular case, you can register the context menu using
EditorSite.registerContextMenu(MenuManager,ISelectionProvide r,boolean) or
EditorSite.registerContextMenu(String,MenuManager,ISelection Provider,boolean).
If you pass "false" as the "includeEditorInput" parameter, then the "Run
as..." and "Debug as..." items should disappear. However, I'm not sure how
you would control this is you were subclassing TextEditor. You'd have to
ask the Platform/Text guys (possibly by filing a bug)....

The other way is to use Capabilities (née Activites). These can be used to
filter out menu items based on their ID. The only problem is that this
would also filter out these menu items from other editors. If it still
interests you, I'd recommend looking at the "org.eclipse.ui.activities"
extension point.



cheers,
d.
Re: Hiding/Preventing editor popup menu items [message #289255 is a reply to message #289243] Tue, 02 August 2005 21:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Douglas Pollock" <douglas.pollock@magma.ca> wrote in message
news:dcoe8f$ej7$1@news.eclipse.org...
> Sunil Kamath wrote:
>
>> I have implemented a couple of editors by extending the eclipse
>> TextEditor. My problem is that since Eclipse 3.1, the editor popup menu
>> (right-click within editor part) shows a couple of new menu items: "Run
>> as..." and "Debug as...".
>> However, these items are not really appropriate for my editor since there
>> is nothing to run or debug.
>> Investigating further reveals that these are object contributions from
>> the
>> debug UI plugin and have been registered for the Object class (how
>> helpful!)- i.e., there's no escaping them.
>> Is there any way to prevent these popup menu items from being displayed?
>
> There are two options of which I am aware.
>
> In your particular case, you can register the context menu using
> EditorSite.registerContextMenu(MenuManager,ISelectionProvide r,boolean) or
> EditorSite.registerContextMenu(String,MenuManager,ISelection Provider,boolean).
> If you pass "false" as the "includeEditorInput" parameter, then the "Run
> as..." and "Debug as..." items should disappear. However, I'm not sure
> how
> you would control this is you were subclassing TextEditor. You'd have to
> ask the Platform/Text guys (possibly by filing a bug)....
>

This cannot be done for a text editor since the context menu is registered
in the AbstractTextEditor.createPartControl().
I tried it for a non-text editor (I also have a GEF editor which has the
same problem) and setting includeEditorInput to false had no effect.
The Run as.. and Debug as.. still show up.

> The other way is to use Capabilities (n
Re: Hiding/Preventing editor popup menu items [message #289266 is a reply to message #289255] Wed, 03 August 2005 02:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Sunil Kamath" <sunil_kamath@nohotspammail.com> wrote in message
news:dconl4$plq$1@news.eclipse.org...
>
> "Douglas Pollock" <douglas.pollock@magma.ca> wrote in message
> news:dcoe8f$ej7$1@news.eclipse.org...
>> Sunil Kamath wrote:
>>
>>
>> In your particular case, you can register the context menu using
>> EditorSite.registerContextMenu(MenuManager,ISelectionProvide r,boolean) or
>> EditorSite.registerContextMenu(String,MenuManager,ISelection Provider,boolean).
>> If you pass "false" as the "includeEditorInput" parameter, then the "Run
>> as..." and "Debug as..." items should disappear. However, I'm not sure
>> how
>> you would control this is you were subclassing TextEditor. You'd have to
>> ask the Platform/Text guys (possibly by filing a bug)....
>>
>
> This cannot be done for a text editor since the context menu is registered
> in the AbstractTextEditor.createPartControl().
> I tried it for a non-text editor (I also have a GEF editor which has the
> same problem) and setting includeEditorInput to false had no effect.
> The Run as.. and Debug as.. still show up.
>
I misspoke. The Run as... and Debug as... did indeed disappear- as did other
context menu items which I wanted to appear.
So this is an all-or-nothing solution.
I don't understand why the Debug plugin has a context menu contribution to
the Object class- it is just too sweeping a generalization.
---
Sunil
Re: Hiding/Preventing editor popup menu items [message #289289 is a reply to message #289266] Wed, 03 August 2005 13:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: douglas.pollock.magma.ca

Sunil Kamath wrote:
> I don't understand why the Debug plugin has a context menu contribution to
> the Object class- it is just too sweeping a generalization.

Then I would suggest filing a bug with Platform/Debug.



d.
Re: Hiding/Preventing editor popup menu items [message #289314 is a reply to message #289289] Wed, 03 August 2005 16:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Douglas Pollock" <douglas.pollock@magma.ca> wrote in message
news:dcqikh$kin$1@news.eclipse.org...
> Sunil Kamath wrote:
>> I don't understand why the Debug plugin has a context menu contribution
>> to
>> the Object class- it is just too sweeping a generalization.
>
> Then I would suggest filing a bug with Platform/Debug.
>
Exactly what I was planning to do.
---
Sunil
Re: Hiding/Preventing editor popup menu items [message #541557 is a reply to message #289117] Mon, 21 June 2010 14:31 Go to previous messageGo to next message
Cameron Ross is currently offline Cameron RossFriend
Messages: 31
Registered: May 2010
Member
I'm also trying to hide/prevent the "Run As, Debug As, Team..." popup menu items from my specialization of TextEditor. Is there any current advice as to how to do this?

Cameron.
Re: Hiding/Preventing editor popup menu items [message #1859011 is a reply to message #541557] Sat, 06 May 2023 02:37 Go to previous message
motein Xor is currently offline motein XorFriend
Messages: 3
Registered: August 2020
Junior Member
It looks like no one has solved this problem. Now I can give the standard answer.
Just add the code below into your editor.
	@Override
	protected boolean isEditorInputIncludedInContextMenu() {
		return false;
	}
Previous Topic:Refactor Deprecated ('classic') search APIs
Next Topic:IDE Core Dump after glib/webgtk update
Goto Forum:
  


Current Time: Fri Mar 29 06:53:19 GMT 2024

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

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

Back to the top