2c00L
2c00L

Reputation: 514

Custom go to line dialog eclipse

Is it possible to subclass the Go To Line dialog of the eclipse.

I want to create a similar dialog "Go To Index" with a custom "OK" action.

Upvotes: 0

Views: 43

Answers (1)

greg-449
greg-449

Reputation: 111142

The Go to Line dialog is an inner class of org.eclipse.ui.texteditor.GotoLineAction so it cannot be subclassed.

However it is just an extension of InputDialog and the code to actually move to a line is simply:

    int line = .... line number ...
    ITextEditor editor = getTextEditor();

    IDocumentProvider provider = editor.getDocumentProvider();
    IDocument document = provider.getDocument(editor.getEditorInput());
    try {
        int start = document.getLineOffset(line);
        editor.selectAndReveal(start, 0);
    } catch (BadLocationException x) {
        // ignore
    }

Upvotes: 1

Related Questions