Lines 79-89
Link Here
|
79 |
import java.util.Collection; |
79 |
import java.util.Collection; |
80 |
import javax.swing.JEditorPane; |
80 |
import javax.swing.JEditorPane; |
81 |
import javax.swing.SwingUtilities; |
81 |
import javax.swing.SwingUtilities; |
82 |
import javax.swing.text.BadLocationException; |
82 |
import javax.swing.text.*; |
83 |
import javax.swing.text.Document; |
|
|
84 |
import javax.swing.text.JTextComponent; |
85 |
import javax.swing.text.Position; |
86 |
import javax.swing.text.StyledDocument; |
87 |
import org.netbeans.api.editor.mimelookup.MimeLookup; |
83 |
import org.netbeans.api.editor.mimelookup.MimeLookup; |
88 |
import org.netbeans.api.lexer.InputAttributes; |
84 |
import org.netbeans.api.lexer.InputAttributes; |
89 |
import org.netbeans.api.lexer.Language; |
85 |
import org.netbeans.api.lexer.Language; |
Lines 107-112
Link Here
|
107 |
import org.openide.loaders.DataObject; |
103 |
import org.openide.loaders.DataObject; |
108 |
import org.openide.filesystems.FileUtil; |
104 |
import org.openide.filesystems.FileUtil; |
109 |
import org.openide.loaders.DataObjectNotFoundException; |
105 |
import org.openide.loaders.DataObjectNotFoundException; |
|
|
106 |
import org.openide.text.Line; |
110 |
import org.openide.util.Exceptions; |
107 |
import org.openide.util.Exceptions; |
111 |
import org.openide.util.RequestProcessor; |
108 |
import org.openide.util.RequestProcessor; |
112 |
import org.openide.windows.TopComponent; |
109 |
import org.openide.windows.TopComponent; |
Lines 773-778
Link Here
|
773 |
if (dob != null) { |
770 |
if (dob != null) { |
774 |
final EditorCookie.Observable ec = dob.getCookie(EditorCookie.Observable.class); |
771 |
final EditorCookie.Observable ec = dob.getCookie(EditorCookie.Observable.class); |
775 |
if (ec != null) { |
772 |
if (ec != null) { |
|
|
773 |
final Document doc; |
774 |
try { |
775 |
doc = ec.openDocument(); |
776 |
} catch (IOException ex) { |
777 |
// Document could not be loaded (e.g. user refused loading of large document) |
778 |
return false; |
779 |
} |
780 |
// jumpToElement() copied and modified |
781 |
doc.render(new Runnable() { |
782 |
@Override |
783 |
public void run() { |
784 |
int start; |
785 |
int lineIndex; |
786 |
final int column; |
787 |
Offsetable offsetable = element.getOffsetable(); |
788 |
Point point = element.getPoint(); |
789 |
Element lineRoot = doc.getDefaultRootElement(); |
790 |
if (offsetable == null) { |
791 |
lineIndex = point.line - 1; |
792 |
column = point.column; |
793 |
start = lineRoot.getElement(lineIndex).getStartOffset(); |
794 |
start += point.column; |
795 |
} else { |
796 |
start = offsetable.getOffset(); |
797 |
lineIndex = lineRoot.getElementIndex(start); |
798 |
column = start - lineRoot.getElement(lineIndex).getStartOffset(); |
799 |
} |
800 |
if (start >= 0 && start < doc.getLength()) { |
801 |
final Line line = ec.getLineSet().getCurrent(lineIndex); |
802 |
SwingUtilities.invokeLater(new Runnable() { |
803 |
@Override |
804 |
public void run() { |
805 |
line.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS, column); |
806 |
} |
807 |
}); |
808 |
if (DEBUG) { |
809 |
System.err.println("I'm going to " + start + " for element " + element); |
810 |
} |
811 |
} |
812 |
StatusDisplayer.getDefault().setStatusText(""); // NOI18N |
813 |
} |
814 |
}); |
815 |
// End-of-jumpToElement() copy |
816 |
if (true) return true; |
817 |
|
776 |
SwingUtilities.invokeLater(new Runnable() { |
818 |
SwingUtilities.invokeLater(new Runnable() { |
777 |
|
819 |
|
778 |
@Override |
820 |
@Override |