//获得当前java编辑器的文本编辑对象
//设置光标的位置
CompilationUnitEditor currenteditor = (CompilationUnitEditor) editorPart.getPages().get(1);
//获得文本编辑对象的document
IDocument document = currenteditor.getViewer().getDocument();
//根据字符串获取到字符的位置
position = document.get().indexOf("{",position)+1;
//将当前编辑器设为活动编辑器
editorPart.setActiveEditor(currenteditor);//设置光标的位置
currenteditor.selectAndReveal(position, 0);//这个0 就是选中光标位置后面的文本长度
//编辑器获得焦点
currenteditor.setFocus();
到此,就可以定位到java 文件中某个字符串中的位置