Refine search
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;
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(); }
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) {
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;
@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); } }
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);
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;
synchronized void register (DataObject dataObject) { LineCookie lc = dataObject.getLookup().lookup (LineCookie.class); if (lc == null) { return; } dataObjectToLineSet.put (dataObject, lc.getLineSet ()); }
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);
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; }
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
synchronized void register (DataObject dataObject) { LineCookie lc = dataObject.getCookie (LineCookie.class); if (lc == null) return; dataObjectToLineSet.put (dataObject, lc.getLineSet ()); }
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);
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) {
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 } }
@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); }
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; }
@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; } }
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) {
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