本文整理了Java中org.openide.cookies.LineCookie
类的一些代码示例,展示了LineCookie
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LineCookie
类的具体详情如下:
包路径:org.openide.cookies.LineCookie
类名称:LineCookie
[英]Cookie for data objects that want to provide support for accessing lines in a document. Lines may change absolute position as changes are made around them in a document.
[中]用于希望为访问文档中的行提供支持的数据对象的Cookie。在文档中,行的绝对位置可能会随着行周围的更改而更改。
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui
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);
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);
l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
return true;
代码示例来源:origin: hmvictor/radar-netbeans
private boolean isFileOpen(FileObject fileObject) throws DataObjectNotFoundException {
DataObject dataObject = DataObject.find(fileObject);
Lookup lookup = dataObject.getLookup();
LineCookie lineCookie = lookup.lookup(LineCookie.class);
Line.Set lineSet = lineCookie.getLineSet();
return !lineSet.getLines().isEmpty();
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-toolchain
private void showLine(boolean openTab) {
try {
DataObject dob = DataObject.find(file);
LineCookie lc = dob.getLookup().lookup(LineCookie.class);
if (lc != null) {
try {
Line l = lc.getLineSet().getOriginal(line);
if (!l.isDeleted()) {
if (openTab) {
l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
} else {
l.show(Line.ShowOpenType.NONE, Line.ShowVisibilityType.NONE);
if (dob.isValid()) {
EditorCookie ec = dob.getLookup().lookup(EditorCookie.class);
if (ec != null) {
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-inspect
DataObject dob = DataObject.find(fob);
Lookup dobLookup = dob.getLookup();
EditorCookie ec = dobLookup.lookup(EditorCookie.class);
LineCookie lc = dobLookup.lookup(LineCookie.class);
int column = offset ? columnNo - NbDocument.findLineOffset(doc, line) : columnNo;
if (line != -1) {
Line l = lc.getLineSet().getCurrent(line);
if (l != null) {
l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS, column);
return true;
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript2-debug-ui
@Override
public FileObject getFileObject() {
if (line instanceof FutureLine) {
URL url = getURL();
FileObject fo = URLMapper.findFileObject(url);
if (fo != null) {
try {
DataObject dobj = DataObject.find(fo);
LineCookie lineCookie = dobj.getLookup().lookup(LineCookie.class);
if (lineCookie == null) {
return null;
}
Line l = lineCookie.getLineSet().getCurrent(getLineNumber() - 1);
setLine(l);
} catch (DataObjectNotFoundException ex) {
}
}
return fo;
} else {
return line.getLookup().lookup(FileObject.class);
}
}
代码示例来源:origin: dcaoyuan/nbscala
DataObject dataObject;
try {
dataObject = DataObject.find(fo);
} catch (DataObjectNotFoundException donfex) {
donfex.printStackTrace();
return ;
LineCookie lc = dataObject.getCookie(LineCookie.class);
if (lc == null) return;
List<DebuggerBreakpointAnnotation> annotations = new ArrayList<DebuggerBreakpointAnnotation>();
for (int l : lines) {
try {
Line line = lc.getLineSet().getCurrent(l - 1);
DebuggerBreakpointAnnotation annotation = new DebuggerBreakpointAnnotation (annotationType, line, b);
annotations.add(annotation);
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-apisupport-project
DataObject dobj = DataObject.find(props);
EditorCookie ec = dobj.getLookup().lookup(EditorCookie.class);
try {
ec.openDocument();
Exceptions.printStackTrace(ex);
LineCookie lc = dobj.getLookup().lookup(LineCookie.class);
if (lc != null) {
Line.Set ls = lc.getLineSet();
for (Line line : ls.getLines()) {
if (line.getText().contains(name + "=")) {
return line;
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projectsui
synchronized void register (DataObject dataObject) {
LineCookie lc = dataObject.getLookup().lookup (LineCookie.class);
if (lc == null) {
return;
}
dataObjectToLineSet.put (dataObject, lc.getLineSet ());
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projects
String text = l.getText();
if (text.trim().length() == 0 && text.indexOf('\n') >= 0) {
line.removePropertyChangeListener(this);
if (dataObject == null) {
return ;
LineCookie lc = dobj.getLookup().lookup (LineCookie.class);
Line newLine;
try {
int lineNumber = l.getLineNumber();
int newLineNumber = lc.getLineSet().getOriginal(lineNumber).getLineNumber();
for (int i = lineNumber + 1; i < newLineNumber; i++) {
if (lc.getLineSet().getCurrent(i).getText().trim().length() != 0) {
newLineNumber = i;
break;
newLine = lc.getLineSet().getCurrent(newLineNumber);
LineCookie lc = dobj.getLookup().lookup (LineCookie.class);
newLine = lc.getLineSet().getCurrent(lb.getLineNumber() - 1);
newLine = lc.getLineSet().getCurrent(lb.getLineNumber() - 1);
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-spring-beans
private static boolean openFileAtOffset(DataObject dataObject, int offset) throws IOException {
EditorCookie ec = dataObject.getCookie(EditorCookie.class);
LineCookie lc = dataObject.getCookie(LineCookie.class);
if (ec != null && lc != null) {
StyledDocument doc = ec.openDocument();
if (doc != null) {
int lineNumber = NbDocument.findLineNumber(doc, offset);
if (lineNumber != -1) {
Line line = lc.getLineSet().getCurrent(lineNumber);
if (line != null) {
int lineOffset = NbDocument.findLineOffset(doc, lineNumber);
int column = offset - lineOffset;
line.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS, column);
return true;
}
}
}
}
return false;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projects
dobj = this.dataObject;
LineCookie lc = dobj.getLookup().lookup (LineCookie.class);
if (lc == null) {
return ;
final Line lineNew = lc.getLineSet().getCurrent(lb.getLineNumber() - 1);
synchronized (this) {
if (line != null) {
line.removePropertyChangeListener(this);
lineNew.addPropertyChangeListener(this);
StyledDocument document = NbDocument.getDocument(new Lookup.Provider() {
@Override
代码示例来源:origin: dcaoyuan/nbscala
synchronized void register (DataObject dataObject) {
LineCookie lc = dataObject.getCookie (LineCookie.class);
if (lc == null) return;
dataObjectToLineSet.put (dataObject, lc.getLineSet ());
}
代码示例来源:origin: stackoverflow.com
FileObject fo = null;
LineCookie lc = DataObject.find(fo).getLookup().lookup(LineCookie.class);
int lineNumber=42;
int colNumber=43;
Line line = lc.getLineSet().getOriginal(lineNumber);
line.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FRONT, colNumber);
代码示例来源:origin: dcaoyuan/nbscala
boolean haveDocL = line != null;
try {
line = lc.getLineSet().getCurrent(lb.getLineNumber() - 1);
if (!haveDocL) {
line.addPropertyChangeListener(this);
line.removePropertyChangeListener(this);
line = null;
line.removePropertyChangeListener(this);
this.lc = dataObject.getCookie (LineCookie.class);
try {
this.line = lc.getLineSet().getCurrent(lb.getLineNumber() - 1);
line.addPropertyChangeListener(this);
} catch (IndexOutOfBoundsException ioobex) {
代码示例来源:origin: dcaoyuan/nbscala
public synchronized void attach() throws IOException {
this.lc = dataObject.getCookie (LineCookie.class);
if (lc == null) return ;
lb.addPropertyChangeListener(this);
try {
this.line = lc.getLineSet().getCurrent(lb.getLineNumber() - 1);
line.addPropertyChangeListener(this);
} catch (IndexOutOfBoundsException ioobex) {
// ignore document changes for BP with bad line number
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript2-debug-ui
@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);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript2-debug-ui
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;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript2-debug-ui
@Override
public EditorLineHandler get(FileObject fo, int lineNumber) {
try {
DataObject dobj = DataObject.find(fo);
LineCookie lineCookie = dobj.getLookup().lookup(LineCookie.class);
if (lineCookie == null) {
return null;
}
try {
Line line = lineCookie.getLineSet().getCurrent(lineNumber - 1);
return new LineDelegate(line);
} catch (IndexOutOfBoundsException ioobex) {
// The line is gone.
return null;
}
} catch (DataObjectNotFoundException ex) {
return null;
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-toolchain-ui
private void showLine(boolean openTab) {
try {
DataObject dob = DataObject.find(file);
LineCookie lc = dob.getLookup().lookup(LineCookie.class);
if (lc != null) {
try {
Line l = lc.getLineSet().getOriginal(line);
if (!l.isDeleted()) {
if (openTab) {
l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
} else {
l.show(Line.ShowOpenType.NONE, Line.ShowVisibilityType.NONE);
if (dob.isValid()) {
EditorCookie ec = dob.getLookup().lookup(EditorCookie.class);
if (ec != null) {
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-project
dataObject = DataObject.find(fileObject);
} catch (DataObjectNotFoundException ex) {
LOGGER.log(Level.INFO, "DataObject not found for {0}", file);
EditorCookie ec = dataObject.getCookie(EditorCookie.class);
ec.open();
return;
LineCookie lineCookie = dataObject.getCookie(LineCookie.class);
if (lineCookie == null) {
LOGGER.log(Level.INFO, "LineCookie not found for {0}", file);
return;
Set lineSet = lineCookie.getLineSet();
try {
final Line currentLine = lineSet.getCurrent(line - 1);
Mutex.EVENT.readAccess(new Runnable() {
@Override
内容来源于网络,如有侵权,请联系作者删除!