The sections below define the set of steps for usage of resource content and definition of own content for the CNF-based viewer. Finally, the steps needed for Action Binding are described. As described previously, in order to render content the viewer selects the corresponding NCEs based on the evaluation of the expressions on the selected objects.
One of the use cases of usage of the Common Navigator is the
manipulation of the workspace resources. The resources-related content
is defined by the org.eclipse.ui.navigator.resources
plugin. The example of the resource usage of CNF can be found in org.eclipse.ui.examples.navigator.resources
.
org.eclipse.ui.navigator.resources
org.eclipse.ui.navigator.viewer
extension
that has:
viewerContentBinding
, point this to Id of your
view (example.view)<extension point="org.eclipse.ui.navigator.viewer"> <viewerContentBinding viewerId="example.view"> <includes> <contentExtension pattern="org.eclipse.ui.navigator.resourceContent" /> <contentExtension pattern="org.eclipse.ui.navigator.resources.filters.*"/> </includes> </viewerContentBinding> </extension>
Please note, that using CNF inside of your own RCP requires three additional steps.
org.eclipse.ui.ide
as dependent plug-inIWorkspaceRoot
)
as default page input, override the WorkbenchAdvisor.getDefaultPageInput()
method in your WorkbenchAdvisor: public IAdaptable getDefaultPageInput() { return ResourcesPlugin.getWorkspace().getRoot(); }
WorkbenchAdvisor.initialize(IWorkbenchConfigurer)
method: public void initialize(IWorkbenchConfigurer configurer) { IDE.registerAdapters(); }
Along with resource content provided by the org.eclipse.ui.navigator.resources
plugin, application-specific content can be defined and presented in the
CNF-based viewer. In order to define and use application specific you
need to:
org.eclipse.ui.navigator.navigatorContent
and declare the NCE, with it providers and trigger conditions for the
content: <extension point="org.eclipse.ui.navigator.navigatorContent"> <navigatorContent id="org.eclipse.ui.examples.navigator.propertiesContent" name="Properties File Contents" contentProvider="org.eclipse.ui.examples.navigator.PropertiesContentProvider" labelProvider="org.eclipse.ui.examples.navigator.PropertiesLabelProvider" activeByDefault="true" icon="icons/prop_ps.gif" priority="normal" > <triggerPoints> <or> <and> <instanceof value="org.eclipse.core.resources.IResource"/> <test forcePluginActivation="true" property="org.eclipse.core.resources.extension" value="properties"/> </and> <instanceof value="org.eclipse.ui.examples.navigator.PropertiesTreeData"/> </or> </triggerPoints> <possibleChildren> <or> <instanceof value="org.eclipse.ui.examples.navigator.PropertiesTreeData"/> </or> </possibleChildren> </navigatorContent> </extension>For more details, please consult the CNF Configuration and Operational Topics.
org.eclipse.ui.navigator.viewer
extension. <extension point="org.eclipse.ui.navigator.viewer"> <viewerContentBinding viewerId="example.view"> <includes> <contentExtension pattern="org.eclipse.ui.examples.navigator.propertiesContent"/> </includes> </viewerContentBinding> </extension>Note, that instead of using the exact Id of the content, the usage of the regular expression is allowed in the
pattern
attribute, so org.eclipse.ui.examples.navigator.*
would
also work.The usage of actions in the viewer follows the same pattern as the content binding. For usage of existing
actions on resources defined in the org.eclipse.ui.navigator.resources
plugin:
org.eclipse.ui.navigator.resources
org.eclipse.ui.navigator.viewer
extension
that has:
actionContentBinding
, point this to Id of your
view (example.view)<extension point="org.eclipse.ui.navigator.viewer"> <viewerActionBinding viewerId="example.view"> <includes> <actionExtension pattern="org.eclipse.ui.navigator.resources.*" /> </includes> </viewerActionBinding> </extension>