piątek, 2 kwietnia 2010

How to force line numbering when opening a file with TextEditor?

Generally Eclipse workbench use global setting for line-numbering feature. Thus one need to perform following code to on the numbering.

IPreferenceStore store = EditorsUI.getPreferenceStore();
store.setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, true);

But remember: DO not happing others by force ;). Thus if for some reason you decide your editor absolutely needs the numbering, take care to reset the setting then close the editor.

static private String NUMBERING = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER;
private boolean numbering;


IPreferenceStore store = EditorsUI.getPreferenceStore();
numbering = store.getBoolean(NUMBERING);
store.setValue(NUMBERING, true);


// when dispose
IPreferenceStore store= EditorsUI.getPreferenceStore();
store.setValue(NUMBERING, numbering);

Brak komentarzy:

Prześlij komentarz