private void openEditorAndJump(final DataObject dataObj, final int line) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
EditorCookie ck = dataObj.getCookie(EditorCookie.class);
final Observable ec = dataObj.getCookie(Observable.class);
if (ck != null && ec != null) {
ec.open();
//open the document
JEditorPane[] p = ck.getOpenedPanes();
if (p.length > 0) {
//Need to do this since we're disabling the window system's
//auto focus mechanism
p[0].requestFocus();
if (dataObj != null) {
LineCookie lc = dataObj.getCookie(LineCookie.class);
if (lc == null) {
return;
}
Line l = lc.getLineSet().getOriginal(line);
l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
}
}
//highlight the line
StyledDocument document = ck.getDocument();
if(document != null) {
Element e = document.getDefaultRootElement();
if (e != null && line != -1) {
e = e.getElement(line);
final int startOfLine = e.getStartOffset();