本文整理汇总了Java中org.openide.cookies.EditorCookie.getLineSet方法的典型用法代码示例。如果您正苦于以下问题:Java EditorCookie.getLineSet方法的具体用法?Java EditorCookie.getLineSet怎么用?Java EditorCookie.getLineSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.cookies.EditorCookie
的用法示例。
在下文中一共展示了EditorCookie.getLineSet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openEditor
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
public static void openEditor(EditorCookie ec, int lineIndex) {
Line.Set lineSet = ec.getLineSet();
if (lineSet != null) {
try {
Line line = lineSet.getCurrent(lineIndex);
if (line != null) {
line.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
}
} catch (IndexOutOfBoundsException ex) {
// attempt at least to open the editor
ec.open();
// expected, bookmark contains an invalid line
StatusDisplayer.getDefault().setStatusText(
NbBundle.getMessage(BookmarkUtils.class, "MSG_InvalidLineNumnber", lineIndex));
}
JEditorPane[] panes = ec.getOpenedPanes();
if (panes.length > 0) {
panes[0].requestFocusInWindow();
}
}
}
示例2: getMostRecentLine
import org.openide.cookies.EditorCookie; //导入方法依赖的package包/类
/**
* Get the line of the caret in the most recent editor.
* This returns the current line in the current editor if there's one,
* or a line of the caret in the editor, that was most recently active.
* @return the line or <code>null</code> when there was no recent active editor.
*/
public Line getMostRecentLine() {
EditorCookie e = getMostRecentEditorCookie ();
if (e == null) return null;
JEditorPane ep = getMostRecentEditor ();
if (ep == null) return null;
StyledDocument d = e.getDocument ();
if (d == null) return null;
Caret caret = ep.getCaret ();
if (caret == null) return null;
int lineNumber = NbDocument.findLineNumber(d, caret.getDot());
Line.Set lineSet = e.getLineSet();
try {
return lineSet.getCurrent(lineNumber);
} catch (IndexOutOfBoundsException ex) {
return null;
}
}