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


Java LineCookie.getLineSet方法代码示例

本文整理汇总了Java中org.openide.cookies.LineCookie.getLineSet方法的典型用法代码示例。如果您正苦于以下问题:Java LineCookie.getLineSet方法的具体用法?Java LineCookie.getLineSet怎么用?Java LineCookie.getLineSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.cookies.LineCookie的用法示例。


在下文中一共展示了LineCookie.getLineSet方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareLine

import org.openide.cookies.LineCookie; //导入方法依赖的package包/类
private void prepareLine() {
    if (dobj == null || !dobj.isValid()) {
        lineObj = null;
    } else if (lineObj == null) { // try to get Line from DataObject
        LineCookie lineCookie = dobj.getLookup().lookup(LineCookie.class);
        if (lineCookie != null) {
            Line.Set lineSet = lineCookie.getLineSet();
            try {
                lineObj = lineSet.getOriginal(line - 1);
            } catch (IndexOutOfBoundsException ioobex) {
                // The line doesn't exist - go to the last line
                lineObj = lineSet.getOriginal(findMaxLine(lineSet));
                column = markLength = 0;
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:TextDetail.java

示例2: getLineSet

import org.openide.cookies.LineCookie; //导入方法依赖的package包/类
Line.Set getLineSet (String url, Object timeStamp) {
    DataObject dataObject = getDataObject (url);
    if (dataObject == null) {
        return null;
    }
    
    if (timeStamp != null) {
        // get original
        synchronized (this) {
            Registry registry = timeStampToRegistry.get (timeStamp);
            if (registry != null) {
                Line.Set ls = registry.getLineSet (dataObject);
                if (ls != null) {
                    return ls;
                }
            }
        }
    }
    
    // get current
    LineCookie lineCookie = dataObject.getLookup().lookup(LineCookie.class);
    if (lineCookie == null) {
        return null;
    }
    return lineCookie.getLineSet ();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:LineTranslations.java

示例3: getLine

import org.openide.cookies.LineCookie; //导入方法依赖的package包/类
private Line getLine (FileObject file, int lineNumber) {
    if (file == null) return null;
    DataObject dataObject;
    try {
        dataObject = DataObject.find (file);
    } catch (DataObjectNotFoundException ex) {
        return null;
    }
    if (dataObject == null) return null;
    LineCookie lineCookie = dataObject.getLookup().lookup(LineCookie.class);
    if (lineCookie == null) return null;
    Line.Set ls = lineCookie.getLineSet ();
    if (ls == null) return null;
    try {
        return ls.getCurrent (lineNumber);
    } catch (IndexOutOfBoundsException | IllegalArgumentException e) {
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:WatchAnnotationProvider.java

示例4: getLine

import org.openide.cookies.LineCookie; //导入方法依赖的package包/类
public static Line getLine(final FileObject fileObject, final int lineNumber) {
    if (fileObject != null) {
        LineCookie lineCookie = JSUtils.getLineCookie(fileObject);
        if (lineCookie != null) {
            Line.Set ls = lineCookie.getLineSet();
            if (ls != null) {
                try {
                    return ls.getCurrent(lineNumber - 1);
                } catch (IndexOutOfBoundsException ioob) {
                    List<? extends Line> lines = ls.getLines();
                    if (lines.size() > 0) {
                        return lines.get(lines.size() - 1);
                    } else {
                        return null;
                    }
                }
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:JSUtils.java

示例5: setLineNumber

import org.openide.cookies.LineCookie; //导入方法依赖的package包/类
@Override
public void setLineNumber(int lineNumber) {
    lineNumber--; // Line works with 0-based lines.
    if (line.getLineNumber() == lineNumber) {
        return ;
    }
    LineCookie lineCookie = line.getLookup().lookup(LineCookie.class);
    Line.Set lineSet = lineCookie.getLineSet();
    List<? extends Line> lines = lineSet.getLines();
    if (lines.size() > 0) {
        int lastLineNumber = lines.get(lines.size() - 1).getLineNumber();
        if (lineNumber > lastLineNumber) {
            lineNumber = lastLineNumber;
        }
    }
    Line cline;
    try {
        cline = lineSet.getCurrent(lineNumber);
    } catch (IndexOutOfBoundsException ioobex) {
        cline = lineSet.getCurrent(0);
    }
    setLine(cline);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:LineDelegate.java

示例6: getLine

import org.openide.cookies.LineCookie; //导入方法依赖的package包/类
/** Get the line object from the given position.
* @param doc document for which the line is being retrieved
* @param offset position in the document
* @param original whether to retrieve the original line (true) before
*   the modifications were done or the current line (false)
* @return the line object
* @deprecated Replaced by more generic method having {@link javax.swing.text.Document} parameter.
*/
public static Line getLine(BaseDocument doc, int offset, boolean original) {
    DataObject dob = getDataObject(doc);
    if (dob != null) {
        LineCookie lc = (LineCookie)dob.getCookie(LineCookie.class);
        if (lc != null) {
            Line.Set lineSet = lc.getLineSet();
            if (lineSet != null) {
                try {
                    int lineOffset = Utilities.getLineOffset(doc, offset);
                    return original
                           ? lineSet.getOriginal(lineOffset)
                           : lineSet.getCurrent(lineOffset);
                } catch (BadLocationException e) {
                }

            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:NbEditorUtilities.java

示例7: attachAnnotationsTo

import org.openide.cookies.LineCookie; //导入方法依赖的package包/类
@Override
public void attachAnnotationsTo(Options options, DataObject dataObject, Set<ScanMessage> scanMessages) {
    final FileObject fileObject = dataObject.getPrimaryFile();

    if (attachedAnnotations.containsKey(fileObject)) {
        throw new IllegalArgumentException("EasyPmd annotations have already been attached to this file.\nYou must detach them before attaching new ones.");
    }

    LineCookie lineCookie = dataObject.getLookup().lookup(LineCookie.class);
    Line.Set lineSet = lineCookie.getLineSet();

    Set<Annotation> annotations = scanMessages
            .stream()
            .map(scanMessage -> {
                Annotation annotation = scanMessage.createAnnotation(options);

                Line line = lineSet.getOriginal(scanMessage.getLineNumber() - 1);
                annotation.attach(line);
                return annotation;
            }).collect(Collectors.toSet());

    attachedAnnotations.put(fileObject, annotations);

    registerFileEventHandlers(fileObject);
}
 
开发者ID:giancosta86,项目名称:EasyPmd,代码行数:26,代码来源:DefaultAnnotationService.java

示例8: show

import org.openide.cookies.LineCookie; //导入方法依赖的package包/类
void show () {
    DataObject dataObject = NbEditorUtilities.getDataObject (document);
    LineCookie lineCookie = dataObject.getCookie (LineCookie.class);
    Line.Set lineSet = lineCookie.getLineSet ();
    Line line = lineSet.getCurrent (NbDocument.findLineNumber (document, item.getOffset ()));
    int column = NbDocument.findLineColumn (document, item.getOffset ());
    line.show (ShowOpenType.OPEN, ShowVisibilityType.FOCUS, column);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:LanguagesNavigatorModel.java

示例9: openAt

import org.openide.cookies.LineCookie; //导入方法依赖的package包/类
private boolean openAt( LineCookie lineCookie, int lineNo ) {
    Line.Set lines = lineCookie.getLineSet();
    try {
        Line line = lines.getCurrent( lineNo );
        if( null == line )
            line = lines.getCurrent( 0 );
        if( null != line ) {
            line.show( ShowOpenType.OPEN , ShowVisibilityType.FOCUS);
            return true;
        }
    } catch( IndexOutOfBoundsException e ) {
        //probably the document has been modified but not saved yet
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:OpenTaskAction.java

示例10: getLineSet

import org.openide.cookies.LineCookie; //导入方法依赖的package包/类
private static Line.Set getLineSet(DataObject dataObject) {
    LineCookie lineCookie = dataObject.getLookup().lookup(LineCookie.class);
    if (lineCookie != null) {
        return lineCookie.getLineSet();
    }
    return null;
}
 
开发者ID:junichi11,项目名称:netbeans-textlint-plugin,代码行数:8,代码来源:TextlintPushTaskScanner.java

示例11: open

import org.openide.cookies.LineCookie; //导入方法依赖的package包/类
@Override
    public void open(final FileObject file, final int lineno) {
        // FIXME this should not be needed
        if (!SwingUtilities.isEventDispatchThread()) {
            SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        open(file, lineno);
                    }
                });

            return; // not exactly accurate, but....
        }

        try {
            DataObject od = DataObject.find(file);
            EditorCookie ec = od.getCookie(EditorCookie.class);
            LineCookie lc = od.getCookie(LineCookie.class);

            if ((ec != null) && (lc != null)) {
                Document doc = ec.openDocument();

                if (doc != null) {
                    int line = lineno;

                    if (line < 1) {
                        line = 1;
                    }

                    // XXX .size() call is super-slow for large files, see issue
                    // #126531. So we fallback to catching IOOBE
//                    int nOfLines = lines.getLines().size();
//                    if (line > nOfLines) {
//                        line = nOfLines;
//                    }
                    try {
                        Line.Set lines = lc.getLineSet();
                        Line l = lines.getCurrent(line - 1);
                        if (l != null) {
                            l.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS);
                            return;
                        }
                    } catch (IndexOutOfBoundsException ioobe) {
                        // OK, since .size() cannot be used, see above
                    }
                }
            }

            OpenCookie oc = od.getCookie(OpenCookie.class);

            if (oc != null) {
                oc.open();
                return;
            }
        } catch (IOException e) {
            LOGGER.log(Level.INFO, null, e);
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:58,代码来源:NbFileOpenHandler.java


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