Reputation: 483
I want to add children to my file in Project Explorer in Eclipse 4.2. I made an RCP project using "Plug-in with a multi-page editor" template. Ran it, added my file type (.mpe) to some existing project using wizard, it all works fine. Now I want to allow my file type (1) to have click-able children as for example .h file have(2). How to do this?
Upvotes: 3
Views: 2161
Reputation: 606
You will have to provide extension for "org.eclipse.ui.navigator.viewer" and "org.eclipse.ui.navigator.navigatorContent". Project explorer is based on Common navigation framework which allows the user to extend the functionality.
An example
The "org.eclipse.ui.navigator.viewer" extension
<extension
id="navigator-viewbinding"
point="org.eclipse.ui.navigator.viewer">
<viewerContentBinding
viewerId="org.eclipse.ui.navigator.ProjectExplorer">
<includes>
<contentExtension
pattern="<plugin_name>.myResourceContent">
</contentExtension>
</includes>
</viewerContentBinding>
</extension>
And "org.eclipse.ui.navigator.navigatorContent" extension
<extension
id="navigator-content"
point="org.eclipse.ui.navigator.navigatorContent">
<navigatorContent
activeByDefault="true"
contentProvider="MyNavigatorContentProvider"
icon="icon.gif"
id="myResourceContent"
labelProvider="MyNavigatorLabelProvider"
name="Some Name"
priority="normal">
<triggerPoints>
<or>
<and>
<instanceof
value="org.eclipse.core.resources.IFile">
</instanceof>
<test
property="org.eclipse.core.resources.extension"
value="mpe">
</test>
</and>
</or>
</triggerPoints>
<possibleChildren>
<or>
<instanceof
value="<Class name of possible children>">
</instanceof>
</or>
</possibleChildren>
</extension>
The class "MyNavigatorContentProvider" is implements "ICommonContentProvider" where you will have to parse your file & get the children u want to display.. The class "MyNavigatorLabelProvider" is to decorate your children in the viewer..
Hopefully this link should help
Upvotes: 1