Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Add action to external editors
Add action to external editors [message #555905] Mon, 30 August 2010 03:39 Go to next message
Eclipse UserFriend
Hi,

I am working on an application in which I need to add an action to
context menu of editor. However, this action should be visible only for
external editors (i.e. for editing files which are external to the
workspace).
In my plugin, plugin.xml file if I use,
objectClass="org.eclipse.core.resources.IResource", this action is
visible and enabled in context menu of internal editors only.
If objectClass="org.eclipse.ui.IEditorInput" is used, the action is
visible and enabled in context menu of both internal and external editors.
Following is the code snipppet of plugin.xml for my plug-in.

<objectContribution
adaptable="true"
id="my.plugin.objectContributionAction1"
objectClass="org.eclipse.core.runtime.IResource">
<action
class="my.plugin.internal.Action1"
enablesFor="1"
icon="icons/obj/image.png"
id="my.plugin.Action1"
label="Action Label"
tooltip="Action Tooltip">
</action>
</objectContribution>

I am not able to find any hints on how to show the action in context
menu of external editors only.

Any suggestions would be of great help.

Thanks,
Sneha
Re: Add action to external editors [message #555950 is a reply to message #555905] Mon, 30 August 2010 06:58 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Please let me know if there are any pointers for this.

Thanks in advance,
Sneha

sneha wrote:
> Hi,
>
> I am working on an application in which I need to add an action to
> context menu of editor. However, this action should be visible only for
> external editors (i.e. for editing files which are external to the
> workspace).
> In my plugin, plugin.xml file if I use,
> objectClass="org.eclipse.core.resources.IResource", this action is
> visible and enabled in context menu of internal editors only.
> If objectClass="org.eclipse.ui.IEditorInput" is used, the action is
> visible and enabled in context menu of both internal and external editors.
> Following is the code snipppet of plugin.xml for my plug-in.
>
> <objectContribution
> adaptable="true"
> id="my.plugin.objectContributionAction1"
> objectClass="org.eclipse.core.runtime.IResource">
> <action
> class="my.plugin.internal.Action1"
> enablesFor="1"
> icon="icons/obj/image.png"
> id="my.plugin.Action1"
> label="Action Label"
> tooltip="Action Tooltip">
> </action>
> </objectContribution>
>
> I am not able to find any hints on how to show the action in context
> menu of external editors only.
>
> Any suggestions would be of great help.
>
> Thanks,
> Sneha
Re: Add action to external editors [message #555979 is a reply to message #555905] Mon, 30 August 2010 08:55 Go to previous message
Eclipse UserFriend
You would probably need to use a more complex <enablement> clause, so
you can evaluate that it is <not> an IResource.

With core expression, you would use <not><adapt
type="...IResource/></not>. That's used with org.eclipse.ui.menus
menuContributions.

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/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm
Previous Topic:Is there an equivalent to DreamWeaver's Library Asset?
Next Topic:IMarkers and Problems View for validation without any IResource?
Goto Forum:
  


Current Time: Wed Jul 23 00:59:42 EDT 2025

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

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

Back to the top