diff --git a/bugtracking/src/org/netbeans/modules/bugtracking/util/StackTraceSupport.java b/bugtracking/src/org/netbeans/modules/bugtracking/util/StackTraceSupport.java --- a/bugtracking/src/org/netbeans/modules/bugtracking/util/StackTraceSupport.java +++ b/bugtracking/src/org/netbeans/modules/bugtracking/util/StackTraceSupport.java @@ -70,13 +70,12 @@ import org.netbeans.api.java.classpath.GlobalPathRegistry; import org.netbeans.modules.bugtracking.BugtrackingManager; import org.netbeans.modules.bugtracking.spi.VCSAccessor; -import org.openide.cookies.EditorCookie; -import org.openide.cookies.LineCookie; -import org.openide.cookies.OpenCookie; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.loaders.DataObject; -import org.openide.text.Line; +import org.openide.text.DataEditorSupport; +import org.openide.text.Line.ShowOpenType; +import org.openide.text.Line.ShowVisibilityType; import org.openide.util.Lookup; import org.openide.util.NbBundle; @@ -340,34 +339,7 @@ private static boolean doOpen(FileObject fo, int line) { try { DataObject od = DataObject.find(fo); - EditorCookie ec = od.getCookie(org.openide.cookies.EditorCookie.class); - LineCookie lc = od.getCookie(org.openide.cookies.LineCookie.class); - - if (ec != null && lc != null && line != -1) { - StyledDocument doc = ec.openDocument(); - if (doc != null) { - if (line != -1) { - Line l = null; - try { - l = lc.getLineSet().getCurrent(line); - } catch (IndexOutOfBoundsException e) { - BugtrackingManager.LOG.log(Level.FINE, null, e); - ec.open(); - return false; - } - if (l != null) { - l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS); - return true; - } - } - } - } - - OpenCookie oc = od.getCookie(org.openide.cookies.OpenCookie.class); - if (oc != null) { - oc.open(); - return true; - } + return DataEditorSupport.openDocument(od, line, -1, ShowOpenType.OPEN, ShowVisibilityType.FOCUS); } catch (IOException e) { BugtrackingManager.LOG.log(Level.SEVERE, null, e); } diff --git a/csl.api/src/org/netbeans/modules/csl/api/UiUtils.java b/csl.api/src/org/netbeans/modules/csl/api/UiUtils.java --- a/csl.api/src/org/netbeans/modules/csl/api/UiUtils.java +++ b/csl.api/src/org/netbeans/modules/csl/api/UiUtils.java @@ -77,16 +77,12 @@ import org.netbeans.modules.parsing.api.indexing.IndexingManager; import org.netbeans.modules.parsing.spi.ParseException; import org.netbeans.modules.parsing.spi.Parser; -import org.openide.DialogDisplayer; -import org.openide.NotifyDescriptor; -import org.openide.cookies.EditorCookie; -import org.openide.cookies.LineCookie; -import org.openide.cookies.OpenCookie; import org.openide.filesystems.FileObject; +import org.openide.loaders.DataObject; +import org.openide.loaders.DataObjectNotFoundException; +import org.openide.text.DataEditorSupport; import org.openide.text.Line; -import org.openide.text.NbDocument; import org.openide.util.NbBundle; -import org.openide.util.UserQuestionException; /** @@ -250,51 +246,11 @@ private static boolean doOpen(FileObject fo, int offset) { try { - EditorCookie ec = DataLoadersBridge.getDefault().getCookie(fo, EditorCookie.class); - LineCookie lc = DataLoadersBridge.getDefault().getCookie(fo, LineCookie.class); - - if ((ec != null) && (lc != null) && (offset != -1)) { - StyledDocument doc = null; - try { - doc = ec.openDocument(); - } catch (UserQuestionException uqe) { - final Object value = DialogDisplayer.getDefault().notify( - new NotifyDescriptor.Confirmation(uqe.getLocalizedMessage(), - NbBundle.getMessage(UiUtils.class, "TXT_Question"), - NotifyDescriptor.YES_NO_OPTION)); - if (value != NotifyDescriptor.YES_OPTION) { - return false; - } - uqe.confirmed(); - doc = ec.openDocument(); - } - - if (doc != null) { - int line = NbDocument.findLineNumber(doc, offset); - int lineOffset = NbDocument.findLineOffset(doc, line); - int column = offset - lineOffset; - - if (line != -1) { - Line l = lc.getLineSet().getCurrent(line); - - if (l != null) { - l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS, column); - return true; - } - } - } - } - - OpenCookie oc = DataLoadersBridge.getDefault().getCookie(fo, OpenCookie.class); - - if (oc != null) { - oc.open(); - return true; - } - } catch (IOException ioe) { - LOG.log(Level.WARNING, null, ioe); + DataObject od = DataObject.find(fo); + return DataEditorSupport.openDocument(od, offset, Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS); + } catch (DataObjectNotFoundException e) { + LOG.log(Level.WARNING, null, e); } - return false; } diff --git a/csl.api/src/org/netbeans/modules/csl/spi/GsfUtilities.java b/csl.api/src/org/netbeans/modules/csl/spi/GsfUtilities.java --- a/csl.api/src/org/netbeans/modules/csl/spi/GsfUtilities.java +++ b/csl.api/src/org/netbeans/modules/csl/spi/GsfUtilities.java @@ -82,8 +82,8 @@ import org.openide.loaders.DataObject; import org.openide.loaders.DataObjectNotFoundException; import org.openide.text.CloneableEditorSupport; +import org.openide.text.DataEditorSupport; import org.openide.text.Line; -import org.openide.text.NbDocument; import org.openide.util.Exceptions; import org.openide.util.UserQuestionException; @@ -284,7 +284,7 @@ // Simple text search if no known offset (e.g. broken/unparseable source) if ((ec != null) && (search != null) && (offset == -1)) { - StyledDocument doc = ec.openDocument(); + StyledDocument doc = DataEditorSupport.getStyledDocument(od); try { String text = doc.getText(0, doc.getLength()); @@ -302,34 +302,8 @@ LOG.log(Level.WARNING, null, ble); } } - - if ((ec != null) && (lc != null) && (offset != -1)) { - StyledDocument doc = ec.openDocument(); - - if (doc != null) { - int line = NbDocument.findLineNumber(doc, offset); - int lineOffset = NbDocument.findLineOffset(doc, line); - int column = offset - lineOffset; - - if (line != -1) { - Line l = lc.getLineSet().getCurrent(line); - - if (l != null) { - l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS, column); - - return true; - } - } - } - } - - OpenCookie oc = od.getCookie(OpenCookie.class); - - if (oc != null) { - oc.open(); - - return true; - } + + return DataEditorSupport.openDocument(od, offset, Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS); } catch (IOException e) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); } diff --git a/gototest/nbproject/project.xml b/gototest/nbproject/project.xml --- a/gototest/nbproject/project.xml +++ b/gototest/nbproject/project.xml @@ -50,59 +50,6 @@ org.netbeans.modules.gototest - org.netbeans.modules.csl.api - - - - 2 - 2.6 - - - - org.netbeans.modules.editor.lib - - - - 3 - 3.1 - - - - org.netbeans.modules.parsing.api - - - - 1 - 1.34 - - - - org.netbeans.modules.projectapi - - - - 1 - 1.3 - - - - org.netbeans.modules.projectuiapi - - - - 1 - - - - org.netbeans.modules.queries - - - - 1 - 1.5 - - - org.openide.awt diff --git a/gototest/src/org/netbeans/modules/gototest/GotoOppositeAction.java b/gototest/src/org/netbeans/modules/gototest/GotoOppositeAction.java --- a/gototest/src/org/netbeans/modules/gototest/GotoOppositeAction.java +++ b/gototest/src/org/netbeans/modules/gototest/GotoOppositeAction.java @@ -46,10 +46,11 @@ import java.awt.EventQueue; import java.util.Collection; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.Action; import javax.swing.JEditorPane; import javax.swing.text.Document; -import org.netbeans.modules.csl.api.UiUtils; import org.netbeans.spi.gototest.TestLocator; import org.netbeans.spi.gototest.TestLocator.FileType; import org.netbeans.spi.gototest.TestLocator.LocationListener; @@ -59,8 +60,11 @@ import org.openide.cookies.EditorCookie; import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; +import org.openide.loaders.DataObjectNotFoundException; +import org.openide.text.DataEditorSupport; import org.openide.nodes.Node; import org.openide.text.CloneableEditorSupport; +import org.openide.text.Line; import org.openide.text.NbDocument; import org.openide.util.HelpCtx; import org.openide.util.Lookup; @@ -163,7 +167,13 @@ private void handleResult(LocationResult opposite) { FileObject fileObject = opposite.getFileObject(); if (fileObject != null) { - UiUtils.open(fileObject, opposite.getOffset()); + DataObject dobj = null; + try { + dobj = DataObject.find(fileObject); + } catch (DataObjectNotFoundException ex) { + Logger.getLogger(DataEditorSupport.class.getName()).log(Level.WARNING, null, ex); + } + DataEditorSupport.openDocument(dobj, opposite.getOffset(), Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS); } else if (opposite.getErrorMessage() != null) { String msg = opposite.getErrorMessage(); NotifyDescriptor descr = new NotifyDescriptor.Message(msg, diff --git a/kenai.ui/src/org/netbeans/modules/kenai/collab/chat/ChatPanel.form b/kenai.ui/src/org/netbeans/modules/kenai/collab/chat/ChatPanel.form --- a/kenai.ui/src/org/netbeans/modules/kenai/collab/chat/ChatPanel.form +++ b/kenai.ui/src/org/netbeans/modules/kenai/collab/chat/ChatPanel.form @@ -1,4 +1,4 @@ - +
@@ -77,7 +77,7 @@ - + diff --git a/kenai.ui/src/org/netbeans/modules/kenai/collab/chat/ChatPanel.java b/kenai.ui/src/org/netbeans/modules/kenai/collab/chat/ChatPanel.java --- a/kenai.ui/src/org/netbeans/modules/kenai/collab/chat/ChatPanel.java +++ b/kenai.ui/src/org/netbeans/modules/kenai/collab/chat/ChatPanel.java @@ -108,6 +108,7 @@ import org.openide.windows.TopComponent; import org.openide.windows.WindowManager; import static org.netbeans.modules.kenai.collab.chat.ChatTopComponent.*; +import org.openide.text.DataEditorSupport; /** * Panel representing single ChatRoom @@ -366,34 +367,7 @@ private static boolean doOpen(FileObject fo, int line) { try { DataObject od = DataObject.find(fo); - EditorCookie ec = (EditorCookie) od.getCookie(EditorCookie.class); - LineCookie lc = (LineCookie) od.getCookie(LineCookie.class); - - if (ec != null && lc != null && line != -1) { - StyledDocument doc = ec.openDocument(); - if (doc != null) { - if (line != -1) { - Line l = null; - try { - l = lc.getLineSet().getCurrent(line - 1); - } catch (IndexOutOfBoundsException e) { // try to open at least the file (line no. is too high?) - l = lc.getLineSet().getCurrent(0); - } - - if (l != null) { - l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS); - return true; - } - } - } - } - - OpenCookie oc = (OpenCookie) od.getCookie(OpenCookie.class); - - if (oc != null) { - oc.open(); - return true; - } + return DataEditorSupport.openDocument(od, line, -1, Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS); } catch (IOException e) { Exceptions.printStackTrace(e); } diff --git a/openide.loaders/apichanges.xml b/openide.loaders/apichanges.xml --- a/openide.loaders/apichanges.xml +++ b/openide.loaders/apichanges.xml @@ -109,6 +109,55 @@ + + + Added method DataEditorSupport.getStyledDocument + + + + + +

+ Get the StyledDocument associated with a file. +

+
+ + +
+ + + Added method DataEditorSupport.openDocument with offset parameter + + + + + +

+ Open the document associated with a file in the Editor window + in a position specified by the offset while controlling + open and visibility behavior. +

+
+ + +
+ + + Added method DataEditorSupport.openDocument with line and column parameter + + + + + +

+ Open the document associated with a file in the Editor window + in a position specified by the line and column while + controlling open and visibility behavior. +

+
+ + +
ToolbarPool.isFinished diff --git a/openide.loaders/manifest.mf b/openide.loaders/manifest.mf --- a/openide.loaders/manifest.mf +++ b/openide.loaders/manifest.mf @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module: org.openide.loaders -OpenIDE-Module-Specification-Version: 7.33 +OpenIDE-Module-Specification-Version: 7.34 OpenIDE-Module-Localizing-Bundle: org/openide/loaders/Bundle.properties OpenIDE-Module-Provides: org.netbeans.modules.templates.v1_0 OpenIDE-Module-Layer: org/netbeans/modules/openide/loaders/layer.xml diff --git a/openide.loaders/src/org/openide/text/DataEditorSupport.java b/openide.loaders/src/org/openide/text/DataEditorSupport.java --- a/openide.loaders/src/org/openide/text/DataEditorSupport.java +++ b/openide.loaders/src/org/openide/text/DataEditorSupport.java @@ -75,10 +75,12 @@ import java.util.concurrent.Callable; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.SwingUtilities; import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.EditorKit; import javax.swing.text.StyledDocument; +import org.netbeans.api.actions.Openable; import org.netbeans.api.annotations.common.NullAllowed; import org.netbeans.api.queries.FileEncodingQuery; import org.netbeans.modules.openide.loaders.DataObjectAccessor; @@ -86,6 +88,7 @@ import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.cookies.EditorCookie; +import org.openide.cookies.LineCookie; import org.openide.cookies.OpenCookie; import org.openide.filesystems.FileAttributeEvent; import org.openide.filesystems.FileChangeAdapter; @@ -121,6 +124,7 @@ * Support for associating an editor and a Swing {@link Document} to a data object. * @author Jaroslav Tulach */ +@NbBundle.Messages("TXT_Question=Question") public class DataEditorSupport extends CloneableEditorSupport { /** error manager for CloneableEditorSupport logging and error reporting */ static final Logger ERR = Logger.getLogger("org.openide.text.DataEditorSupport"); // NOI18N @@ -594,6 +598,176 @@ } } + /** + * Get the document associated with a file. + * + *

Method will throw {@link org.openide.util.UserQuestionException} + * exception if file size is too big. This exception is caught and its + * method {@link org.openide.util.UserQuestionException#confirmed} is used + * for confirmation. + * + * + * @param dobj the DataObject + * @return {@link javax.swing.text.StyledDocument} or null + * @since org.openide.loaders 7.34 + */ + public static StyledDocument getStyledDocument(DataObject dobj) { + try { + EditorCookie ec = dobj.getLookup().lookup(EditorCookie.class); + if (ec != null) { + StyledDocument doc = null; + try { + doc = ec.openDocument(); + } catch (UserQuestionException uqe) { + final Object value = DialogDisplayer.getDefault().notify( + new NotifyDescriptor.Confirmation(uqe.getLocalizedMessage(), + "#TXT_Question", + NotifyDescriptor.YES_NO_OPTION)); + if (value != NotifyDescriptor.YES_OPTION) { + return null; + } + uqe.confirmed(); + doc = ec.openDocument(); + } + return doc; + } + } catch (IOException ioe) { + Logger.getLogger(DataEditorSupport.class.getName()).log(Level.WARNING, null, ioe); + } + return null; + } + + /** + * Open the document associated with a file in the Editor window in a + * position specified by the offset while controlling open and visibility behavior. + * This method can be called from any thread. + * + * @param dobj the DataObject + * @param offset the position the document should be opened (starting at 0) + * @param openType control open behavior, {@link org.openide.text.Line.ShowOpenType#OPEN} + * should be used + * @param visibilityType control visibility behavior, {@link org.openide.text.Line.ShowVisibilityType#FOCUS} + * should be used + * @return true if the Document is opened - false otherwise + * @see #getStyledDocument + * UserQuestionException handling + * @see org.openide.text.Line.ShowOpenType + * ShowOpenType + * @see org.openide.text.Line.ShowVisibilityType + * ShowVisibilityType + * @since org.openide.loaders 7.34 + */ + public static boolean openDocument(DataObject dobj, int offset, Line.ShowOpenType openType, Line.ShowVisibilityType visibilityType) { + assert dobj != null; + LineCookie lc = dobj.getLookup().lookup(LineCookie.class); + if ((lc != null) && (offset != -1)) { + StyledDocument doc = getStyledDocument(dobj); + + if (doc != null) { + int line = NbDocument.findLineNumber(doc, offset); + int column = NbDocument.findLineColumn(doc, offset); + + Line l = null; + try { + l = lc.getLineSet().getCurrent(line); + } catch (IndexOutOfBoundsException e) { // try to open at least the file (line no. is too high?) + l = lc.getLineSet().getCurrent(0); + } + + if (l != null) { + doShow(l, column, openType, visibilityType); + return true; + } + } + } + + Openable oc = dobj.getLookup().lookup(Openable.class); + + if (oc != null) { + doOpen(oc); + return true; + } + return false; + } + + /** + * Open the document associated with a file in the Editor window in a + * position specified by the line and column while controlling open and visibility behavior. + * This method can be called from any thread. + * + * @param dobj the DataObject + * @param line the line the document should be opened (starting at 0) + * @param column the column which should be selected (starting at 0), value + * -1 does not change previously selected column + * @param openType control open behavior, {@link org.openide.text.Line.ShowOpenType#OPEN} + * should be used + * @param visibilityType control visibility behavior, {@link org.openide.text.Line.ShowVisibilityType#FOCUS} + * should be used + * @return true if the Document is opened - false otherwise + * @see #getStyledDocument + * UserQuestionException handling + * @see org.openide.text.Line.ShowOpenType + * ShowOpenType + * @see org.openide.text.Line.ShowVisibilityType + * ShowVisibilityType + * @since org.openide.loaders 7.34 + */ + public static boolean openDocument(DataObject dobj, int line, int column, Line.ShowOpenType openType, Line.ShowVisibilityType visibilityType) { + assert dobj != null; + LineCookie lc = dobj.getLookup().lookup(LineCookie.class); + if ((lc != null) && (line >= 0) && (column >= -1)) { + StyledDocument doc = getStyledDocument(dobj); + + if (doc != null) { + Line l = null; + try { + l = lc.getLineSet().getCurrent(line); + } catch (IndexOutOfBoundsException e) { // try to open at least the file (line no. is too high?) + l = lc.getLineSet().getCurrent(0); + } + + if (l != null) { + doShow(l, column, openType, visibilityType); + return true; + } + } + } + + Openable oc = dobj.getLookup().lookup(Openable.class); + + if (oc != null) { + doOpen(oc); + return true; + } + return false; + } + + private static void doShow(final Line l, final int column, final Line.ShowOpenType openType, final Line.ShowVisibilityType visibilityType) { + if (SwingUtilities.isEventDispatchThread()) { + l.show(openType, visibilityType, column); + } else { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + l.show(openType, visibilityType, column); + } + }); + } + } + + private static void doOpen(final Openable oc) { + if (SwingUtilities.isEventDispatchThread()) { + oc.open(); + } else { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + oc.open(); + } + }); + } + } + /** Saves document. Overrides superclass method, adds checking * for read-only property of saving file and warns user in that case. */ diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/Call.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/Call.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/Call.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/Call.java @@ -72,16 +72,13 @@ import org.netbeans.modules.refactoring.java.RetoucheUtils; import org.openide.awt.StatusDisplayer; import org.openide.cookies.EditorCookie; -import org.openide.cookies.LineCookie; -import org.openide.cookies.OpenCookie; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.loaders.DataObject; import org.openide.loaders.DataObjectNotFoundException; +import org.openide.text.DataEditorSupport; import org.openide.text.Line; -import org.openide.text.NbDocument; import org.openide.text.PositionBounds; -import org.openide.util.Exceptions; import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; @@ -400,46 +397,23 @@ final int begin = bounds.getBegin().getOffset(); final int end = bounds.getEnd().getOffset(); DataObject od = DataObject.find(fo); - final EditorCookie ec = od.getCookie(org.openide.cookies.EditorCookie.class); - LineCookie lc = od.getCookie(org.openide.cookies.LineCookie.class); + final EditorCookie ec = od.getLookup().lookup(org.openide.cookies.EditorCookie.class); + boolean opened = DataEditorSupport.openDocument(od, begin, Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS); + if (opened) { + EventQueue.invokeLater(new Runnable() { - if (ec != null && lc != null && begin != -1) { - StyledDocument doc = ec.openDocument(); - if (doc != null) { - int line = NbDocument.findLineNumber(doc, begin); - int lineOffset = NbDocument.findLineOffset(doc, line); - int column = begin - lineOffset; - - if (line != -1) { - Line l = lc.getLineSet().getCurrent(line); - - if (l != null) { - l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS, column); - - EventQueue.invokeLater(new Runnable() { - - public void run() { - ec.getOpenedPanes()[0].setSelectionStart(begin); - ec.getOpenedPanes()[0].setSelectionEnd(end); - } - }); - return true; - } + @Override + public void run() { + ec.getOpenedPanes()[0].setSelectionStart(begin); + ec.getOpenedPanes()[0].setSelectionEnd(end); } - } - } - - OpenCookie oc = od.getCookie(org.openide.cookies.OpenCookie.class); - - if (oc != null) { - oc.open(); + }); return true; } + return opened; } catch (DataObjectNotFoundException e) { StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage( Call.class, "Call.open.warning", FileUtil.getFileDisplayName(fo))); // NOI18N - } catch (IOException e) { - Exceptions.printStackTrace(e); } return false; diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/JavadocUtilities.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/JavadocUtilities.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/JavadocUtilities.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/JavadocUtilities.java @@ -67,7 +67,6 @@ import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.Position; -import javax.swing.text.StyledDocument; import org.netbeans.api.java.lexer.JavaTokenId; import org.netbeans.api.java.lexer.JavadocTokenId; import org.netbeans.api.java.source.ClasspathInfo.PathKind; @@ -75,12 +74,11 @@ import org.netbeans.api.lexer.Token; import org.netbeans.api.lexer.TokenId; import org.netbeans.api.lexer.TokenSequence; -import org.openide.cookies.EditorCookie; -import org.openide.cookies.LineCookie; import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; -import org.openide.text.Line; -import org.openide.text.NbDocument; +import org.openide.text.DataEditorSupport; +import org.openide.text.Line.ShowOpenType; +import org.openide.text.Line.ShowVisibilityType; /** * copy paste from javadoc module @@ -585,26 +583,7 @@ private static boolean doOpenImpl(FileObject fo, int offset) { try { DataObject od = DataObject.find(fo); - EditorCookie ec = od.getCookie(EditorCookie.class); - LineCookie lc = od.getCookie(LineCookie.class); - - if (ec != null && lc != null && offset != -1) { - StyledDocument doc = ec.openDocument(); - if (doc != null) { - int line = NbDocument.findLineNumber(doc, offset); - int lineOffset = NbDocument.findLineOffset(doc, line); - int column = offset - lineOffset; - - if (line != -1) { - Line l = lc.getLineSet().getCurrent(line); - - if (l != null) { - l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS, column); - return true; - } - } - } - } + return DataEditorSupport.openDocument(od, offset, ShowOpenType.OPEN, ShowVisibilityType.FOCUS); } catch (IOException ex) { Logger.getLogger(JavadocUtilities.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); }