Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Common Navigation Framework and popup menu item visibility(Need help understanding how to set up pop up menu's in CNF)
Common Navigation Framework and popup menu item visibility [message #1048659] Wed, 24 April 2013 15:48
Ken Keefe is currently offline Ken Keefe
Messages: 8
Registered: April 2012
Junior Member
I have an existing RCP project that uses menus, commands, and handlers to manage the menu bar menus. I'm adding a new tree navigation structure and I'd like to use CNF. I'm making progress, but I'm struggling with understanding how popup menus work in CNF.

I was able to add a pop up menu to my CNF viewer with a two menu items, Open Project and Close Project. Open Project always shows and it hooked right into my existing command nicely. The Close Project item should only show when a project node is selected in the CNF viewer and that project object should be passed to the command (and handler) as an argument somehow.

So, how do I do those two pieces for the Close Project menu item?:

1. Only show up when a Project node (or nodes) is selected in the CNF.
2. Pass the project object(s) to the Handler class somehow.

Here is an abridged plugin.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
...
<extension
point="org.eclipse.ui.commands">
<category
id="edu.illinois.mobius.core.projects.categories.ProjectOperations"
name="Project Operations">
</category>
...
<command
categoryId="edu.illinois.mobius.core.projects.categories.ProjectOperations"
id="edu.illinois.mobius.core.projects.commands.NewProject"
name="New Project">
</command>
<command
categoryId="edu.illinois.mobius.core.projects.categories.ProjectOperations"
id="edu.illinois.mobius.core.projects.commands.OpenProject"
name="Open Project">
</command>
<command
categoryId="edu.illinois.mobius.core.projects.categories.ProjectOperations"
id="edu.illinois.mobius.core.projects.commands.CloseProject"
name="Close Project">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
...
<handler
class="edu.illinois.mobius.core.projects.handlers.NewProjectHandler"
commandId="edu.illinois.mobius.core.projects.commands.NewProject">
</handler>
<handler
class="edu.illinois.mobius.core.projects.handlers.OpenProjectHandler"
commandId="edu.illinois.mobius.core.projects.commands.OpenProject">
</handler>
<handler
class="edu.illinois.mobius.core.projects.handlers.CloseProjectHandler"
commandId="edu.illinois.mobius.core.projects.commands.CloseProject">
</handler>
</extension>
<extension
point="org.eclipse.ui.menus">
...
<menuContribution
allPopups="false"
locationURI="popup:edu.illinois.mobius.projects.projectexplorer#PopupMenu">
<command
commandId="edu.illinois.mobius.core.projects.commands.OpenProject"
label="Open Project"
mnemonic="o"
style="push">
</command>
<command
commandId="edu.illinois.mobius.core.projects.commands.CloseProject"
label="Close Project"
mnemonic="c"
style="push">
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.views">
<view
allowMultiple="true"
category="edu.illinois.mobius.projects.category"
class="edu.illinois.mobius.core.projects.views.MobiusProjectExplorer"
icon="icons/resource_persp.gif"
id="edu.illinois.mobius.projects.projectexplorer"
name="Projects"
restorable="true">
</view>
</extension>
<extension
point="org.eclipse.ui.navigator.navigatorContent">
<navigatorContent
contentProvider="edu.illinois.mobius.core.projects.providers.ProjectContentProvider"
id="edu.illinois.mobius.core.projects.workspaceManagerNC"
labelProvider="edu.illinois.mobius.core.projects.providers.ProjectLabelProvider"
name="workspaceManagerNC">
<triggerPoints>
<instanceof
value="edu.illinois.mobius.core.projects.models.WorkspaceManager">
</instanceof></triggerPoints>
<commonSorter
class="edu.illinois.mobius.core.projects.providers.ProjectSorter">
</commonSorter>
</navigatorContent>
</extension>
<extension
point="org.eclipse.ui.navigator.viewer">
<viewer
viewerId="edu.illinois.mobius.projects.projectexplorer">
<popupMenu
allowsPlatformContributions="true"
id="edu.illinois.mobius.projects.projectexplorer#PopupMenu">
</popupMenu>
</viewer>
<viewerContentBinding
viewerId="edu.illinois.mobius.projects.projectexplorer">
<includes>
<contentExtension
isRoot="true"
pattern="edu.illinois.mobius.core.projects.workspaceManagerNC">
</contentExtension>
</includes>
</viewerContentBinding>
</extension>
</plugin>
Previous Topic:How to set global action handler.
Next Topic:org.eclipse.ui.activities conflict?
Goto Forum:
  


Current Time: Mon Jul 28 10:28:00 EDT 2014

Powered by FUDForum. Page generated in 0.04542 seconds