Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Common Navigator Framework - show standard menu items(Eclipse Plugin - View based on CNF - can't show standard menu items like copy/paste/delete)
Common Navigator Framework - show standard menu items [message #765543] Wed, 14 December 2011 09:32 Go to next message
Missing name Missing name is currently offline Missing name Missing name
Messages: 3
Registered: December 2011
Junior Member
Hi,
i'm writing an Eclipse Plugin to show a TreeViewer based on the Common Navigator Framework. The view should be a Namespace Explorer similar to the Package Explorer in Java. I want to use the context menu of the CNF with the standard menu items Copy/Paste/Delete, Open/Close Project, Team(SVN), Import/Export.

The viewer get a new content provider, which parse the filessystem and generate a model for displaying. After this, the only thing in the context menu is the Team menu with subclipse menu contribution. The model classes have their equivalent(IProject, IFolder, IFile) as attribute and the method getAdapter() return that attribute.

Searching the web i found several tutorials, but nothing solved the problem:

Menu contribution like org.eclipse.ui.edit.delete in the plugin.xml the menu items are shown but greyed out. Solution in Eclipse RCP caused of bug (bugs.eclipse.org/bugs/show_bug.cgi?id=270007), there is an ActionBarAdvisor class to register the actions , but in the view plugin there is no advisor class.

Adding in the viewer a popup menu in the plugin.xml with the standard insertion points didn't solve.

I'm very frustrated Sad
Please help.

plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         point="org.eclipse.ui.views">
      <category
            name="Namespace Explorer"
            id="com.myexample.xyz.namespaceexplorer">
      </category>
      <view
            name="Namespace Explorer"
            icon="icons/sample.gif"
            category="com.myexample.xyz.namespaceexplorer"
            class="com.myexample.xyz.namespaceexplorer.views.AquilaNavigator"
            id="com.myexample.xyz.namespaceexplorer">
      </view>
   </extension>
   <extension
         point="org.eclipse.ui.navigator.viewer">
      <viewer
            viewerId="com.myexample.xyz.namespaceexplorer">
		<popupMenu
			id="com.myexample.xyz.namespaceexplorer#PopupMenu">
				<insertionPoint
					name="group.edit"
					separator="true">
				</insertionPoint>
				<insertionPoint
					name="group.properties"
					separator="true">
				</insertionPoint>
        </popupMenu>
      </viewer>
      <viewerActionBinding
            viewerId="com.myexample.xyz.namespaceexplorer">
         <includes>
            <actionExtension
                  pattern="org.eclipse.ui.navigator.resources.*">
            </actionExtension>            
         </includes>
      </viewerActionBinding>
      <viewerContentBinding
            viewerId="com.myexample.xyz.namespaceexplorer">
         <includes>
            <contentExtension
                  pattern="com.myexample.xyz.namespaceexplorer.navigatorContent.virtualContent">
            </contentExtension>
            
            <contentExtension
                  pattern="org.eclipse.ui.navigator.resources.linkHelper">
            </contentExtension>
            <contentExtension
                  pattern="org.eclipse.ui.navigator.resources.filters.workingSet">
            </contentExtension>
            <contentExtension
                  pattern="com.myexample.xyz.namespaceexplorer.incFilters.*">
            </contentExtension>
         </includes>
      </viewerContentBinding>
   </extension>
   <extension
         point="org.eclipse.ui.perspectiveExtensions">
      <perspectiveExtension
            targetID="org.eclipse.ui.resourcePerspective">
         <view
               id="com.myexample.xyz.namespaceexplorer"
               ratio="0.5"
               relationship="stack"
               relative="org.eclipse.ui.navigator.ProjectExplorer">
         </view>
      </perspectiveExtension>
   </extension>
   <extension
         point="org.eclipse.help.contexts">
      <contexts
            file="contexts.xml">
      </contexts>
   </extension>
   <extension
         point="org.eclipse.ui.navigator.navigatorContent">
      <commonFilter
            activeByDefault="true"
            id="com.myexample.xyz.namespaceexplorer.incFilters.startsWithDot"
            name="starts with dot">
         <filterExpression>
            <and>
               <adapt
                     type="org.eclipse.core.resources.IResource">
                  <test
                        property="org.eclipse.core.resources.name"
                        value=".*">
                  </test>
               </adapt>
            </and>
         </filterExpression>
      </commonFilter>
      <commonFilter
            activeByDefault="true"
            id="com.myexample.xyz.namespaceexplorer.incFilters.allFilesNotEz"
            name="all files not ez">
         <filterExpression>
            <and>
               <adapt
                     type="org.eclipse.core.resources.IFile">
                  <test
                        property="org.eclipse.core.resources.extension"
                        value="*">
                  </test>
                  <not>
                     <test
                           property="org.eclipse.core.resources.extension"
                           value="ez">
                     </test>
                  </not>
               </adapt>
            </and>
         </filterExpression>
      </commonFilter>
      <navigatorContent
            activeByDefault="true"
            contentProvider="com.myexample.xyz.namespaceexplorer.navigatorContent.ViewContentProvider"
            id="com.myexample.xyz.namespaceexplorer.navigatorContent.virtualContent"
            labelProvider="com.myexample.xyz.namespaceexplorer.navigatorContent.ViewLabelProvider"
            name="Virtual Content"
            priority="high">
         <triggerPoints>
            <instanceof
                  value="org.eclipse.core.resources.IResource">
            </instanceof>
         </triggerPoints>
         <possibleChildren>
            <or>
               <instanceof
                     value="com.myexample.xyz.namespaceexplorer.model.TreeEzProject">
               </instanceof>
               <instanceof
                     value="com.myexample.xyz.namespaceexplorer.model.TreeEzNamespace">
               </instanceof>
               <instanceof
                     value="com.myexample.xyz.namespaceexplorer.model.TreeEzFile">
               </instanceof>
            </or>
         </possibleChildren>
         <commonSorter
               class="com.myexample.xyz.namespaceexplorer.views.ViewNameSorter">
         </commonSorter>
      </navigatorContent>
   </extension>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="popup:com.myexample.xyz.namespaceexplorer?before=additions">
         <command
               commandId="org.eclipse.ui.edit.copy"
               label="Copy"
               style="push">
         </command>
         <command
               commandId="org.eclipse.ui.edit.paste"
               label="Paste"
               style="push">
         </command>
         <command
               commandId="org.eclipse.ui.edit.delete"
               label="Delete"
               style="push">
         </command>
         
         <separator
               name="com.myexample.xyz.namespaceexplorer.separator1">
         </separator>
         <menu
               label="Refactor">
            <command
                  commandId="org.eclipse.ui.edit.rename"
                  label="Rename"
                  style="push">
            </command>
         </menu>
         <separator
               name="com.myexample.xyz.namespaceexplorer.separator2">
         </separator>
      </menuContribution>
   </extension>
   <extension
         point="org.eclipse.ui.handlers">
      <handler
            class=""
            commandId="org.eclipse.ui.edit.delete">
      </handler>
   </extension>  
</plugin>
Re: Common Navigator Framework - show standard menu items [message #765752 is a reply to message #765543] Wed, 14 December 2011 15:56 Go to previous messageGo to next message
John B is currently offline John B
Messages: 18
Registered: November 2011
Junior Member
I'm not the expert on this topic but I'm learning to be one, reluctantly. If you add org.eclipse.ui.navigator.resourceContent to
<code>
<viewerContentBinding
viewerId="com.myexample.xyz.namespaceexplorer">
<includes>
<contentExtension
pattern="com.myexample.xyz.namespaceexplorer.navigatorContent.virtualContent">
</contentExtension>

<contentExtension
pattern="org.eclipse.ui.navigator.resources.linkHelper">
</contentExtension>
<contentExtension
pattern="org.eclipse.ui.navigator.resources.filters.workingSet">
</contentExtension>
<contentExtension
pattern="com.myexample.xyz.namespaceexplorer.incFilters.*">
</contentExtension>
</includes>
</viewerContentBinding>
</code>

You will get the menu items you are missing but you may also have to define the popup menu to look more like the one defined in org.eclipse.ui.navigator.resources.
org.eclipse.ui.navigator.ProjectExplorer#PopupMenu
Re: Common Navigator Framework - show standard menu items [message #766145 is a reply to message #765752] Thu, 15 December 2011 09:24 Go to previous messageGo to next message
Missing name Missing name is currently offline Missing name Missing name
Messages: 3
Registered: December 2011
Junior Member
Thank you for your reply John,

your advice was the first i tried, the viewers popup menu was the standard with:

"group.new" separator="true"
"group.goto"
"group.open" separator="true"
"group.openWith"
"group.edit" separator="true"
"group.show" separator="true"
"group.reorganize"
"group.port"
"group.generate" separator="true"
"group.search" separator="true"
"group.build" separator="true"
"additions" separator="true"
"group.properties" separator="true"

described in article: scribbledideas.blogspot.com/2006/05/building-common-navigator-based-viewer.html

The ContentBinding was bind to org.eclipse.ui.navigator.resourceContent, that makes a "Project Explorer" in the view, after that i added my ContentProvider and the view displays the projects twice. Once as Project Explorer and twice with the namespaces. In the menubar of the view i can click "customize view" and in tab "Content" i can select the both ContentProvider.

Any other ideas? Or need somebody more informations?

Best regards
Re: Common Navigator Framework - show standard menu items [message #766957 is a reply to message #765543] Fri, 16 December 2011 18:32 Go to previous message
Francis Upton IV is currently offline Francis Upton IV
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
I guess I'm not clear on what you are trying to do.

Are you working with resources, and then have additional model objects? If that's the case, then you should use the resource stuff in org.eclipse.ui.navigator.resources and then adapt to your model objects as required. (This is what the JDT does in their use of the CNF/ProjectExplorer).

The org.eclipse.ui.menus extension point is not part of the CNF, nor are the actions for CCP that you have specified. I'm not sure what they do when they are not working with resources or how they are enabled.


Previous Topic:Updating resource decorators in Package Explorer
Next Topic:Confused about org.eclipse.jsch.core.IPasswordStore
Goto Forum:
  


Current Time: Sat Oct 25 13:01:23 GMT 2014

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

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