自定义转到行对话框eclipse
Custom go to line dialog eclipse
是否可以子类化 eclipse 的 Go To Line 对话框。
我想创建一个带有自定义 "OK" 操作的类似对话框 "Go To Index"。
Go to Line 对话框是 org.eclipse.ui.texteditor.GotoLineAction
的内部 class,因此不能被子class编辑。
然而,它只是 InputDialog
的扩展,实际移动到一行的代码很简单:
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
}
是否可以子类化 eclipse 的 Go To Line 对话框。
我想创建一个带有自定义 "OK" 操作的类似对话框 "Go To Index"。
Go to Line 对话框是 org.eclipse.ui.texteditor.GotoLineAction
的内部 class,因此不能被子class编辑。
然而,它只是 InputDialog
的扩展,实际移动到一行的代码很简单:
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
}