本文整理汇总了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;
}
}
}
}
示例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 ();
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}