Search code examples
pluginseclipse-pdeeclipse-plugin

Eclipse plugin development: how to add functionality to editor


I have been trying there last days to extend the default editor (java, xml, all of them) functionality,

what I want to do is add a big ruler with text on the side of every editor.

example: a default editor page looks like this:

|-----------|
|source     |
|code       |
|           |
|-----------|

but i want it to be like this

|------|----|
|source|    |
|code  |line|
|      |text|
|------|----|

also i can't use a view because the text in my ruler corresponds to a certain line and has to scroll along with the source code.

I have tried to do this by implementing IEditorActionDelegate since I don't want a new editor, but to add functionality, but I could not find any solutions.


Wanted to mention that for putting my solution in practice i extended AbstractContributedRulerColumn

public class MyRuler extends AbstractContributedRulerColumn {
 ....
}

Solution

  • I think you are after the extension point org.eclipse.ui.workbench.texteditor.rulerColumns. The component that displays the line numbers in text editors is added using this point, so it should be possible to add other information, too.

    Example from the API doc:

    <extension
      point="org.eclipse.ui.workbench.texteditor.rulerColumns">
      <column
        id="org.eclipse.ui.editors.columns.linenumbers"
        name="Line Numbers"
        class="org.eclipse.ui.internal.texteditor.LineNumberColumn"
        enabled="false"
        global="true"
        includeInMenu="false">
        <placement
           gravity="0.9">
           <after id="org.eclipse.ui.editors.columns.annotations"/>
        </placement>
        <targetClass
           class="org.eclipse.ui.texteditor.AbstractDecoratedTextEditor">
        </targetClass>
      </column>
    </extension>