public void run() { // Part of #33165 - the following code is wrapped by doc.render() try { int p = position.getOffset(); if (p >= doc.getLength()) { retStringArray[0] = ""; } else { retStringArray[0] = doc.getText(position.getOffset(), getLength()); } } catch (BadLocationException ex) { Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex); retStringArray[0] = null; } // End of the code wrapped by doc.render() } }
/** When document is opened or closed the annotations must be added or * removed.*/ void attachDetachAnnotations(StyledDocument doc, boolean closing) { List<? extends Annotation> list = getAnnotations(); synchronized(list) { for (Annotation anno : list) { if (!closing) { try { if (!anno.isInDocument()) { anno.setInDocument(true); NbDocument.addAnnotation(doc, position.getPosition(), getLength(), anno); } } catch (IOException ex) { Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex); } } else { if (anno.isInDocument()) { anno.setInDocument(false); NbDocument.removeAnnotation(doc, anno); } } } } }
/** Handle DocumentChange event. If the change affect this Part, fire * the PROP_TEXT event. */ void handleDocumentChange(DocumentEvent p0) { if (p0.getType().equals(DocumentEvent.EventType.INSERT)) { if (p0.getOffset() >= previousOffset && p0.getOffset() < (previousOffset+getLength()) ) { firePropertyChange(Annotatable.PROP_TEXT, null, null); } } if (p0.getType().equals(DocumentEvent.EventType.REMOVE)) { if ( (p0.getOffset() >= previousOffset && p0.getOffset() < previousOffset+getLength()) || (p0.getOffset() < previousOffset && p0.getOffset()+p0.getLength() > previousOffset) ) { firePropertyChange(Annotatable.PROP_TEXT, null, null); } } if ((p0.getType().equals(DocumentEvent.EventType.INSERT) || p0.getType().equals(DocumentEvent.EventType.REMOVE)) && p0.getOffset() < previousOffset) { firePropertyChange(Line.Part.PROP_COLUMN, null, null); } previousOffset = position.getOffset(); }
/** Handle DocumentChange event. If the change affect this Part, fire * the PROP_TEXT event. */ void handleDocumentChange(DocumentEvent p0) { if (p0.getType().equals(DocumentEvent.EventType.INSERT)) { if ((p0.getOffset() >= previousOffset) && (p0.getOffset() < (previousOffset + getLength()))) { firePropertyChange(Annotatable.PROP_TEXT, null, null); } } if (p0.getType().equals(DocumentEvent.EventType.REMOVE)) { if ( ((p0.getOffset() >= previousOffset) && (p0.getOffset() < (previousOffset + getLength()))) || ((p0.getOffset() < previousOffset) && ((p0.getOffset() + p0.getLength()) > previousOffset)) ) { length = limitLength(length); firePropertyChange(Annotatable.PROP_TEXT, null, null); } } if ( (p0.getType().equals(DocumentEvent.EventType.INSERT) || p0.getType().equals(DocumentEvent.EventType.REMOVE)) && (p0.getOffset() < previousOffset) ) { firePropertyChange(Line.Part.PROP_COLUMN, null, null); } previousOffset = position.getOffset(); } }
/** When document is opened or closed the annotations must be added or * removed.*/ void attachDetachAnnotations(StyledDocument doc, boolean closing) { java.util.List list = getAnnotations(); for (int i=0; i<list.size(); i++) { Annotation anno = (Annotation)list.get(i); if (!closing) { try { if (!anno.isInDocument()) { anno.setInDocument(true); NbDocument.addAnnotation (doc, position.getPosition(), getLength(), anno); } } catch (IOException ex) { ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex); } } else { if (anno.isInDocument()) { anno.setInDocument(false); NbDocument.removeAnnotation(doc, anno); } } } }
/** When document is opened or closed the annotations must be added or * removed.*/ void attachDetachAnnotations(StyledDocument doc, boolean closing) { java.util.List list = getAnnotations(); for (int i=0; i<list.size(); i++) { Annotation anno = (Annotation)list.get(i); if (!closing) { try { if (!anno.isInDocument()) { anno.setInDocument(true); NbDocument.addAnnotation (doc, position.getPosition(), getLength(), anno); } } catch (IOException ex) { ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex); } } else { if (anno.isInDocument()) { anno.setInDocument(false); NbDocument.removeAnnotation(doc, anno); } } } }
/** Handle DocumentChange event. If the change affect this Part, fire * the PROP_TEXT event. */ void handleDocumentChange(DocumentEvent p0) { if (p0.getType().equals(DocumentEvent.EventType.INSERT)) { if (p0.getOffset() >= previousOffset && p0.getOffset() < (previousOffset+getLength()) ) { firePropertyChange(Annotatable.PROP_TEXT, null, null); } } if (p0.getType().equals(DocumentEvent.EventType.REMOVE)) { if ( (p0.getOffset() >= previousOffset && p0.getOffset() < previousOffset+getLength()) || (p0.getOffset() < previousOffset && p0.getOffset()+p0.getLength() > previousOffset) ) { firePropertyChange(Annotatable.PROP_TEXT, null, null); } } if ((p0.getType().equals(DocumentEvent.EventType.INSERT) || p0.getType().equals(DocumentEvent.EventType.REMOVE)) && p0.getOffset() < previousOffset) { firePropertyChange(Line.Part.PROP_COLUMN, null, null); } previousOffset = position.getOffset(); }