How to add expandable content to a File

From Bioclipse
Jump to: navigation, search
Development tutorial
Responsible author:Ola
Bioclipse version:N/A
"N/A" is not a number.
Last updated:2009-10-10
Tags:


Objective

Expand a File into parsed children of a certain class. For example, an SDFile should expand to reveal its contained molecules and a FASTA-file might be expanded to reveal contained sequences.

Cnf.jpg

Architecture

Bioclipse makes use of the Common Navigator Framework (CNF) for the Bioclispe Navigator, see Eclipse resources investigation. A CNF can dynamically create child nodes for linking with open editors, outline, properties view etc.

Implementation

We need to provide a ContentProvider and a LabelProvider and register these in the plugin.xml for a certain File with extension. As an example, I will show trunkated example how sequence files can be expanded with Biojava to reveal their sequences (see net.bioclipse.biojava.ui.views package for complete source code).

public class SequenceContentProvider implements ITreeContentProvider{
 ...
}
public class SequenceLabelProvider implements ILabelProvider, IDescriptionProvider {
  ...
}

We now add the following to plugin.xml:

  <extension
        point="org.eclipse.ui.navigator.navigatorContent">
     <navigatorContent 
           contentProvider="net.bioclipse.biojava.ui.views.SequenceContentProvider"
           id="net.bioclipse.biojava.ui.views.SequenceContent"
           labelProvider="net.bioclipse.biojava.ui.views.SequenceLabelProvider"
           name="Sequence Content">
        <triggerPoints>
        <and>
           <instanceof value="org.eclipse.core.resources.IResource"/>
           <or>
           <test
           	forcePluginActivation="true"
           	property="org.eclipse.core.resources.extension"
           	value="fasta"/>
           <test
           	forcePluginActivation="true"
           	property="org.eclipse.core.resources.extension"
           	value="gbk"/>
           </or>
        </and>
        </triggerPoints>
     </navigatorContent>
  </extension>

We add the SequenceContent to expand Sequences with BioJava with the follwing in plugin.xml:

<extension
     point="org.eclipse.ui.navigator.viewer">
     <viewerContentBinding
           viewerId="net.bioclipse.navigator">
           <includes>
           <contentExtension
                 pattern="net.bioclipse.biojava.ui.views.SequenceContent">
           </contentExtension>
           </includes>
     </viewerContentBinding>
</extension>


Links