当前位置: 首页>>代码示例>>Java>>正文


Java EditorCookie.getLineSet方法代码示例

本文整理汇总了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();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:BookmarkUtils.java

示例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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:EditorContextDispatcher.java


注:本文中的org.openide.cookies.EditorCookie.getLineSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。