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.Line.ShowOpenType; +import org.openide.text.Line.ShowVisibilityType; +import org.openide.text.NbDocument; 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 NbDocument.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 @@ -43,7 +43,6 @@ */ package org.netbeans.modules.csl.api; -import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -60,7 +59,6 @@ import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.JTextComponent; -import javax.swing.text.StyledDocument; import org.netbeans.api.lexer.TokenHierarchy; import org.netbeans.api.lexer.TokenSequence; import org.netbeans.api.progress.ProgressUtils; @@ -77,16 +75,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.Line; import org.openide.text.NbDocument; import org.openide.util.NbBundle; -import org.openide.util.UserQuestionException; /** @@ -250,51 +244,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 NbDocument.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 @@ -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 = NbDocument.getDocument(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 NbDocument.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 @@ -183,6 +130,7 @@ org.netbeans.modules.python.project org.netbeans.modules.refactoring.java org.netbeans.modules.ruby.project + org.netbeans.modules.testng org.netbeans.spi.gototest 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,10 @@ import org.openide.cookies.EditorCookie; import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; +import org.openide.loaders.DataObjectNotFoundException; 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 +166,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(GotoOppositeAction.class.getName()).log(Level.WARNING, null, ex); + } + NbDocument.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 @@ -94,9 +94,6 @@ import org.netbeans.spi.java.classpath.support.ClassPathSupport; import org.openide.awt.DropDownButtonFactory; import org.openide.awt.HtmlBrowser.URLDisplayer; -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; @@ -107,7 +104,7 @@ import org.openide.windows.Mode; import org.openide.windows.TopComponent; import org.openide.windows.WindowManager; -import static org.netbeans.modules.kenai.collab.chat.ChatTopComponent.*; +import org.openide.text.NbDocument; /** * Panel representing single ChatRoom @@ -366,34 +363,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 NbDocument.openDocument(od, line, -1, Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS); } catch (IOException e) { Exceptions.printStackTrace(e); } diff --git a/openide.text/apichanges.xml b/openide.text/apichanges.xml --- a/openide.text/apichanges.xml +++ b/openide.text/apichanges.xml @@ -49,6 +49,26 @@ Text API + + + Added methods NbDocument.getDocument, + NbDocument.openDocument with offset parameter and + NbDocument.openDocument with line and column parameter + + + + + +

+ First method gets the StyledDocument associated with a file while the other two + are used to open the document associated with a file in the Editor window + in a position specified by the offset or line and column while + controlling open and visibility behavior. +

+
+ + +
fix hole in commit-groups about empty commit group diff --git a/openide.text/manifest.mf b/openide.text/manifest.mf --- a/openide.text/manifest.mf +++ b/openide.text/manifest.mf @@ -1,7 +1,7 @@ Manifest-Version: 1.0 OpenIDE-Module: org.openide.text OpenIDE-Module-Install: org/netbeans/modules/openide/text/Installer.class -OpenIDE-Module-Specification-Version: 6.44 +OpenIDE-Module-Specification-Version: 6.45 OpenIDE-Module-Localizing-Bundle: org/openide/text/Bundle.properties AutoUpdate-Essential-Module: true diff --git a/openide.text/src/org/openide/text/NbDocument.java b/openide.text/src/org/openide/text/NbDocument.java --- a/openide.text/src/org/openide/text/NbDocument.java +++ b/openide.text/src/org/openide/text/NbDocument.java @@ -45,13 +45,24 @@ import java.awt.Color; import java.awt.Component; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.JEditorPane; import javax.swing.JToolBar; import javax.swing.SwingUtilities; import javax.swing.text.*; +import org.netbeans.api.actions.Openable; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; import org.openide.cookies.EditorCookie; +import org.openide.cookies.LineCookie; +import org.openide.util.Lookup; +import org.openide.util.Mutex; +import org.openide.util.NbBundle; +import org.openide.util.UserQuestionException; /** Dummy class holding utility methods for working with NetBeans document conventions. @@ -518,6 +529,164 @@ } ((Annotatable) doc).removeAnnotation(annotation); } + + /** + * 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 provider for example a {@link DataObject} + * @return {@link javax.swing.text.StyledDocument} or null + * @since org.openide.text 6.45 + */ + @NbBundle.Messages("TXT_Question=Question") + public static StyledDocument getDocument(Lookup.Provider provider) { + try { + EditorCookie ec = provider.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(), + Bundle.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(NbDocument.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 but blocks until the document is opened. + * + * @param provider for example a {@link 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} + * would typically be used + * @param visibilityType control visibility behavior, {@link org.openide.text.Line.ShowVisibilityType#FOCUS} + * would typically be used + * @return true if the Document is opened - false otherwise + * @see #getDocument + * UserQuestionException handling + * @since org.openide.text 6.45 + */ + public static boolean openDocument(Lookup.Provider provider, int offset, Line.ShowOpenType openType, Line.ShowVisibilityType visibilityType) { + assert provider != null; + LineCookie lc = provider.getLookup().lookup(LineCookie.class); + if ((lc != null) && (offset != -1)) { + StyledDocument doc = getDocument(provider); + + 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 = provider.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 but blocks until the document is opened. + * + * @param provider for example a {@link 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} + * would typically be used + * @param visibilityType control visibility behavior, {@link org.openide.text.Line.ShowVisibilityType#FOCUS} + * would typically be used + * @return true if the Document is opened - false otherwise + * @see #getDocument + * UserQuestionException handling + * @since org.openide.text 6.45 + */ + public static boolean openDocument(Lookup.Provider provider, int line, int column, Line.ShowOpenType openType, Line.ShowVisibilityType visibilityType) { + assert provider != null; + LineCookie lc = provider.getLookup().lookup(LineCookie.class); + if ((lc != null) && (line >= 0) && (column >= -1)) { + StyledDocument doc = getDocument(provider); + + 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; + } + } + } + + final Openable oc = provider.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) { + Mutex.EVENT.writeAccess(new Runnable() { + + @Override + public void run() { + l.show(openType, visibilityType, column); + } + }); + } + + private static void doOpen(final Openable oc) { + Mutex.EVENT.writeAccess(new Runnable() { + + @Override + public void run() { + oc.open(); + } + }); + } /** Specialized version of document that knows how to lock the document * for complex modifications. 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 @@ -45,7 +45,6 @@ import com.sun.source.util.TreePath; import java.awt.EventQueue; import java.awt.Image; -import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -63,7 +62,6 @@ import javax.lang.model.type.TypeVariable; import javax.lang.model.type.WildcardType; import javax.swing.Icon; -import javax.swing.text.StyledDocument; import org.netbeans.api.java.source.CompilationInfo; import org.netbeans.api.java.source.ElementHandle; import org.netbeans.api.java.source.TreePathHandle; @@ -72,8 +70,6 @@ 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; @@ -81,7 +77,6 @@ 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 +395,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 = NbDocument.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,11 +74,10 @@ 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.Line.ShowOpenType; +import org.openide.text.Line.ShowVisibilityType; import org.openide.text.NbDocument; /** @@ -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 NbDocument.openDocument(od, offset, ShowOpenType.OPEN, ShowVisibilityType.FOCUS); } catch (IOException ex) { Logger.getLogger(JavadocUtilities.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); }