Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » popupMenus objectContribution
popupMenus objectContribution [message #329460] Wed, 25 June 2008 09:01 Go to next message
Eclipse UserFriend
Originally posted by: nouha_benrhouma.yahoo.fr

Hi,
I have created an object contribution within a context menu and I have an
action associated with this object contribution.
This works good but I want to make this action visible only when I'm in a
specific perspective and a specific view. I'm working with eclipse 3.3.2
Is that possible please?
Thank you for help
Re: popupMenus objectContribution [message #329476 is a reply to message #329460] Wed, 25 June 2008 15:02 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

To target a specific view, use viewerContribution instead of
objectContribution. I'm not sure how you would restrict it to a
specific perspective.

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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: popupMenus objectContribution [message #329531 is a reply to message #329476] Fri, 27 June 2008 10:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nouha_benrhouma.yahoo.fr

Thank you for reply,
my problem is that I want to have a command or action that is only visible
in a specific view, with a specific object, under a specific perspective.
I have many plugins and each one has it's specific perspective.
Each perspective has it's views and in some views I use same objects.
Suppose that I have an object named com.test.sdk.Person
I use this object in the following views:
com.test.ui.FirstView
com.test.ui.SecondView

I have two plugins each one has it's perspective (com.test.perspective1
and com.test1.perspective1)
the two perspectives are showing several views and com.test.ui.FirstView
is common to the 2 perspectives.

I want to have the command (or action) visible only when I'm in
perspective com.test.perspective1, under the view com.test.ui.FirstView
with the object com.test.sdk.Person.

Can this be possible?
Re: popupMenus objectContribution [message #329538 is a reply to message #329531] Fri, 27 June 2008 12:14 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

not with org.eclipse.ui.popupMenus

With commands, you can use visibleWhen to determine when the current
perspective matches the one you care about.

See Command Core Expressions from my sig. In 3.4 we added a variable
for perspectives,
org.eclipse.ui.ISources.ACTIVE_WORKBENCH_WINDOW_ACTIVE_PERSP ECTIVE_NAME

In 3.3 it's extremely hard to do (although not impossible).

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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: popupMenus objectContribution [message #329691 is a reply to message #329538] Tue, 01 July 2008 11:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nouha_benrhouma.yahoo.fr

I tried it with command.I used instanceof (with visibleWhen), and
activePartId variable, but it seems there is a problem when using
instanceof because the command doesn't appears, is there something
specific with instanceof?
Re: popupMenus objectContribution [message #329745 is a reply to message #329691] Wed, 02 July 2008 14:32 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Nouha Br wrote:
> I tried it with command.I used instanceof (with visibleWhen), and
> activePartId variable, but it seems there is a problem when using
> instanceof because the command doesn't appears, is there something
> specific with instanceof?

activePartId is a String ... what is your instanceof checking, anyway?

If you post your visibleWhen snippet we might be able to make suggestions.

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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: popupMenus objectContribution [message #329772 is a reply to message #329745] Thu, 03 July 2008 13:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nouha_benrhouma.yahoo.fr

This is a sample extract of my plugin.xml

<menuContribution
locationURI="popup:org.eclipse.ui.popup.any?after=additions ">
<command
commandId="com.test.plugin.MyCommandName"
label="PersonCommand">
<visibleWhen>
<and>
<with
variable="activePartId">
<equals
value="com.test.plugin.ui.view.MyView">
</equals>
</with>
<instanceof
value="com.test.plugin..sdk.Person">
</instanceof></and></visibleWhen>
</command>
</menuContribution>


where com.test.plugin.ui.view.MyView is the id of the view where I want my
command to be shown and com.test.plugin..sdk.Person is the class of the
object (like object contribution).

I want the command to be shown when I right clic on Person in MyView, but
with this description, the command doesn't appear in MyView and appears
disabled in another view wherever I clic (though in my command handler,
isEnabled() method returns true.
Re: popupMenus objectContribution [message #329785 is a reply to message #329772] Thu, 03 July 2008 16:58 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Nouha Br wrote:
> This is a sample extract of my plugin.xml
>
> <menuContribution
> locationURI="popup:org.eclipse.ui.popup.any?after=additions ">
> <command
> commandId="com.test.plugin.MyCommandName"
> label="PersonCommand">
> <visibleWhen>
> <and>
> <with
> variable="activePartId">
> <equals
> value="com.test.plugin.ui.view.MyView">
> </equals>
> </with>
> <instanceof
> value="com.test.plugin..sdk.Person">
> </instanceof></and></visibleWhen>
> </command>
> </menuContribution>
>
>
> where com.test.plugin.ui.view.MyView is the id of the view where I want
> my command to be shown and com.test.plugin..sdk.Person is the class of
> the object (like object contribution).

The default variable and selection are collections (of sort). Check out
the examples in Menu Contributions and Command Core Expressions.

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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Previous Topic:column resizing in Properties view
Next Topic:Paths in Plugin
Goto Forum:
  


Current Time: Sun Jul 21 17:33:16 GMT 2024

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

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

Back to the top