I need to update status line editor-specific information. I already have my own implementation, but I would like to take a look how is eclipse contribution item, which shows line number/column position in status line is implemented. Can anyone point me, where could I find the source code?
Thanks in advance,
AlexG.
I’ve been looking into it, it’s quite involved, and I’m not sure I got the complete picture, but in case this helps someone…
The declarative way of binding an Editor with the contributions to the StatusLine (and Menu and Toolbar) is through IEditorActionBarContributor class. This class is declared for a editor type in plugin.xml – and typically a single instance is created for each editor type (several running instances of a same editor type will share a
IEditorActionBarContributorinstance, calling itsdoSetActiveEditor()method when activated), and it will be disposed when when the last running editor of that type is closed.Lets take as an example how the default text editor in Eclipse updates the “Insert/Override” info in the status line (from Eclipse 3.7)
The default text editor is declared in
org.eclipse.ui.editors‘splugin.xml(some lines trimmed) as:TextEditorActionContributoris the key. What interest us is implemented in the parent class BasicTextEditorActionContributor; it defines (statically) the 4 status fields (STATUS_FIELD_DEFS) and it stores internally a fixed map (fStatusFields) of each statusField (the spec, say) to a StatusLineContributionItem object). When called from the Eclipse UI, it registers the 4 fields in the status line (the titles, basically) in the methodcontributeToStatusLine(IStatusLineManager statusLineManager)And each time a editor is activated, it passes to it -indoSetActiveEditor(IEditorPart part)– the full set ofStatusLineContributionItems , prepared with the corresponding actionHandlers. The editor understands all this because it implementsITextEditorExtension.setStatusField().In the case of
AbstractTextEditor, it has an private field of (inner class) typeToggleOverwriteModeAction, which callsThe editor looks if it has a
statusFieldstored with this category, if so it will callIStatusField.setText("Insert" / "Overwrite")and this will result in the update of the status line message.This is an example, but I guess it gives the general idea: an instance of
EditorActionContributor, binded to a editor type, mantains a list of the StatusLineContributionItem to be updated, and the editor must write into the objects of this list when the corresponding status changes. In this way, the editor is decoupled from the status line (it doesn’t know if/how a status change will be displayed in the UI).