IEditorPart 에서 선택된 텍스트값 알아노는 방법이다.
일단 plugin.xml에 2개의 plug-in 추가한다.
1. org.eclipse.ui.editors
2 org.eclipse.jface.text
if (window == null) {
window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
}
IEditorPart editorPart = window.getActivePage().getActiveEditor();
if (editorPart instanceof ITextEditor) {
ISelectionProvider selectionProvider = ((ITextEditor) editorPart).getSelectionProvider();
ISelection selection = selectionProvider.getSelection();
if (selection instanceof ITextSelection) {
ITextSelection textSelection = (ITextSelection) selection;
System.out.println(textSelection.getText());
}
}