final OpenFileDescriptor desc = new OpenFileDescriptor(project, script);
if (desc.canNavigateToSource()) {
desc.navigate(true);
final FileEditor fileEditor = fileMgr.getSelectedEditor(script);
if (fileEditor instanceof TextEditor) {
final Editor editor = ((TextEditor) fileEditor).getEditor();
final Document document = editor.getDocument();
final PsiFile psiFile = psiMgr.getPsiFile(document);
if (!(psiFile instanceof XmlFile))
return;
final XmlFile xmlFile = (XmlFile) psiFile;
final XmlDocument xmlDoc = xmlFile.getDocument();
if (xmlDoc == null)
return;
final XmlTag projectTag = xmlDoc.getRootTag();
if (projectTag == null)
return;
final XmlTag[] goals = projectTag.findSubTags("goal");
final String goalName = pGoal.getName();
for (XmlTag goalTag : goals) {
if (goalName.equals(goalTag.getAttributeValue("name"))) {
final int offset = goalTag.getTextOffset();
editor.getCaretModel().moveToOffset(offset);
editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
break;
}
}
}
}