int renderToInt() { if (doc != null) { doc.render(this); } return retInt; }
int renderToInt() { doc.render(this); return retInt; }
int renderToInt() { doc.render(this); return retInt; }
/** Registers line, but only after obtaining the lock of the document. * This is a fix to issue 37767 as this creates ordering of locks (first * of all obtain documentrenderer, then ask for any other locks like * Line.Set.lines. * * @param line line we want to register * @return the line or some line that already was registered */ private Line safelyRegisterLine (final Line line) { class DocumentRenderer implements Runnable { public Line result; public void run () { result = DocumentLine.Set.super.registerLine (line); } } DocumentRenderer renderer = new DocumentRenderer (); listener.doc.render (renderer); return renderer.result; } }
/** Registers line, but only after obtaining the lock of the document. * This is a fix to issue 37767 as this creates ordering of locks (first * of all obtain documentrenderer, then ask for any other locks like * Line.Set.lines. * * @param line line we want to register * @return the line or some line that already was registered */ private Line safelyRegisterLine (final Line line) { class DocumentRenderer implements Runnable { public Line result; public void run () { result = DocumentLine.Set.super.registerLine (line); } } DocumentRenderer renderer = new DocumentRenderer (); listener.doc.render (renderer); return renderer.result; } }
private static Position getPosition(final StyledDocument doc, final int offset) { class Impl implements Runnable { private Position pos; @Override public void run() { if (offset < 0 || offset >= doc.getLength()) { return; } try { pos = doc.createPosition(offset - NbDocument.findLineColumn(doc, offset)); } catch (BadLocationException ex) { //should not happen? Logger.getLogger(BaseAnnotation.class.getName()).log(Level.FINE, null, ex); } } } Impl i = new Impl(); doc.render(i); if (i.pos == null) { i.pos = new Position() { @Override public int getOffset() { return -1; } }; } return i.pos; }
void render() { StyledDocument d = mgr.getDoc(); Object prev = DOCUMENT.get(); try { if (d != null) { DOCUMENT.set(d); d.render(this); } else { DOCUMENT.set(mgr); this.run(); } } finally { DOCUMENT.set(prev); } }
void render() { StyledDocument d = mgr.getDoc (); Object prev = DOCUMENT.get (); try { if (d != null) { DOCUMENT.set (d); d.render(this); } else { DOCUMENT.set (mgr); this.run(); } } finally { DOCUMENT.set (prev); } }
void render() { StyledDocument d = mgr.getDoc (); Object prev = DOCUMENT.get (); try { if (d != null) { DOCUMENT.set (d); d.render(this); } else { DOCUMENT.set (mgr); this.run(); } } finally { DOCUMENT.set (prev); } }
public String getText() { final StyledDocument doc = position.getCloneableEditorSupport ().getDocument (); // document is not opened if (doc == null) return null; final String[] retStringArray = new String[1]; doc.render(new Runnable() { public void run() { // Part of #33165 - the following code is wrapped by doc.render() try { retStringArray[0] = doc.getText(position.getOffset(), getLength()); } catch (BadLocationException ex) { ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex); retStringArray[0] = null; } // End of the code wrapped by doc.render() }}); return retStringArray[0]; }
public DocLockedRun(int type, StyledDocument doc, int intValue, boolean readLock) { this.type = type; this.intResult = intValue; if (!readLock && (doc instanceof NbDocument.WriteLockable)) { ((NbDocument.WriteLockable) doc).runAtomic(this); } else { if (readLock && doc != null) { doc.render(this); } else { // if the document is not one of "NetBeans ready" // that supports locking we do not have many // chances to do something. Maybe check for AbstractDocument // and call writeLock using reflection, but better than // that, let's leave this simple for now and wait for // bug reports (if any appear) run(); } } }
public String getText() { final StyledDocument doc = position.getCloneableEditorSupport ().getDocument (); // document is not opened if (doc == null) return null; final String[] retStringArray = new String[1]; doc.render(new Runnable() { public void run() { // Part of #33165 - the following code is wrapped by doc.render() try { retStringArray[0] = doc.getText(position.getOffset(), getLength()); } catch (BadLocationException ex) { ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex); retStringArray[0] = null; } // End of the code wrapped by doc.render() }}); return retStringArray[0]; }
/** Registers line, but only after obtaining the lock of the document. * This is a fix to issue 37767 as this creates ordering of locks (first * of all obtain documentrenderer, then ask for any other locks like * Line.Set.lines. * * @param line line we want to register * @return the line or some line that already was registered */ private Line safelyRegisterLine(final Line line) { assert line != null; class DocumentRenderer implements Runnable { public Line result; public void run() { result = DocumentLine.Set.super.registerLine(line); } } StyledDocument doc = listener.support.getDocument(); DocumentRenderer renderer = new DocumentRenderer(); if (doc != null) { doc.render(renderer); } else { renderer.run(); } return renderer.result; } }
public void run() { try { synchronized (getAnnotations()) { if (!anno.isInDocument()) { anno.setInDocument(true); // #33165 - find position that is surely at begining of line FindAnnotationPosition fap = new FindAnnotationPosition(doc, pos.getPosition()); doc.render(fap); NbDocument.addAnnotation(doc, fap.getAnnotationPosition(), -1, anno); } } } catch (IOException ex) { Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex); } } });
/** Remove annotation to this Annotatable class * @param anno annotation which will be detached from this class */ @Override protected void removeAnnotation(final Annotation anno) { super.removeAnnotation(anno); final StyledDocument doc = position.getCloneableEditorSupport().getDocument(); // document is not opened and so no annotation is attached to it if (doc == null) { return; } position.getCloneableEditorSupport().prepareDocument().waitFinished(); doc.render(new Runnable() { public void run() { synchronized (getAnnotations()) { if (anno.isInDocument()) { anno.setInDocument(false); NbDocument.removeAnnotation(doc, anno); } } } }); }
/** Remove annotation to this Annotatable class * @param anno annotation which will be detached from this class */ @Override protected void removeAnnotation(final Annotation anno) { super.removeAnnotation(anno); final StyledDocument doc = pos.getCloneableEditorSupport().getDocument(); // document is not opened and so no annotation is attached to it if (doc == null) { return; } pos.getCloneableEditorSupport().prepareDocument().waitFinished(); doc.render(new Runnable() { public void run() { synchronized (getAnnotations()) { if (anno.isInDocument()) { anno.setInDocument(false); NbDocument.removeAnnotation(doc, anno); } } } }); }
/** Add annotation to this Annotatable class * @param anno annotation which will be attached to this class */ @Override protected void addAnnotation(final Annotation anno) { super.addAnnotation(anno); final StyledDocument doc = position.getCloneableEditorSupport().getDocument(); // document is not opened and so the annotation will be added to document later if (doc == null) { return; } position.getCloneableEditorSupport().prepareDocument().waitFinished(); doc.render(new Runnable() { public void run() { try { synchronized (getAnnotations()) { if (!anno.isInDocument()) { anno.setInDocument(true); NbDocument.addAnnotation(doc, position.getPosition(), length, anno); } } } catch (IOException ex) { Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex); } } }); }
/** Add annotation to this Annotatable class * @param anno annotation which will be attached to this class */ @Override protected void addAnnotation(final Annotation anno) { super.addAnnotation(anno); final StyledDocument doc = pos.getCloneableEditorSupport().getDocument(); // document is not opened and so the annotation will be added to document later if (doc == null) { return; } pos.getCloneableEditorSupport().prepareDocument().waitFinished(); doc.render(new Runnable() { public void run() { try { synchronized (getAnnotations()) { if (!anno.isInDocument()) { anno.setInDocument(true); // #33165 - find position that is surely at begining of line FindAnnotationPosition fap = new FindAnnotationPosition(doc, pos.getPosition()); doc.render(fap); NbDocument.addAnnotation(doc, fap.getAnnotationPosition(), -1, anno); } } } catch (IOException ex) { Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex); } } }); }
/** Add annotation to this Annotatable class * @param anno annotation which will be attached to this class */ protected void addAnnotation(Annotation anno) { super.addAnnotation(anno); StyledDocument doc = pos.getCloneableEditorSupport ().getDocument (); // document is not opened and so the annotation will be added to document later if (doc == null) return; pos.getCloneableEditorSupport().prepareDocument().waitFinished(); try { if (!anno.isInDocument()) { anno.setInDocument(true); // #33165 - find position that is surely at begining of line FindAnnotationPosition fap = new FindAnnotationPosition(doc, pos.getPosition()); doc.render(fap); NbDocument.addAnnotation (doc, fap.getAnnotationPosition(), -1, anno); } } catch (IOException ex) { ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex); } }
/** Add annotation to this Annotatable class * @param anno annotation which will be attached to this class */ protected void addAnnotation(Annotation anno) { super.addAnnotation(anno); StyledDocument doc = pos.getCloneableEditorSupport ().getDocument (); // document is not opened and so the annotation will be added to document later if (doc == null) return; pos.getCloneableEditorSupport().prepareDocument().waitFinished(); try { if (!anno.isInDocument()) { anno.setInDocument(true); // #33165 - find position that is surely at begining of line FindAnnotationPosition fap = new FindAnnotationPosition(doc, pos.getPosition()); doc.render(fap); NbDocument.addAnnotation (doc, fap.getAnnotationPosition(), -1, anno); } } catch (IOException ex) { ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex); } }