/** Move Line.Part from this Line to a new one*/ void moveLinePart(DocumentLine.Part linePart, DocumentLine newLine) { lineParts.remove(linePart); newLine.addLinePart(linePart); linePart.changeLine(newLine); }
/** Notify Line.Part(s) that line was moved. */ void notifyMove() { updatePositionRef(); for (int i=0; i<lineParts.size(); i++) { ((DocumentLine.Part)lineParts.get(i)).firePropertyChange(Line.Part.PROP_LINE, null, null); } }
/** 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); } } } } }
part = (DocumentLine.Part)lineParts.get(i); part.handleDocumentChange(p0); if (NbDocument.findLineNumber(doc, part.getOffset()) != part.getLine().getLineNumber()) { DocumentLine line = (DocumentLine)set.getCurrent(NbDocument.findLineNumber(doc, part.getOffset())); moveLinePart(part, line); } else {
part = (DocumentLine.Part)lineParts.get(i); part.handleDocumentChange(p0); if (NbDocument.findLineNumber(doc, part.getOffset()) != part.getLine().getLineNumber()) { DocumentLine line = (DocumentLine)set.getCurrent(NbDocument.findLineNumber(doc, part.getOffset())); moveLinePart(part, line); } else {
part.handleDocumentChange(p0); if (NbDocument.findLineNumber(doc, part.getOffset()) != part.getLine().getLineNumber()) { DocumentLine line = (DocumentLine) set.getCurrent(NbDocument.findLineNumber(doc, part.getOffset())); moveLinePart(part, line); } else {
((DocumentLine.Part)lineParts.get(i)).attachDetachAnnotations(doc, closing);
p.attachDetachAnnotations(doc, closing);
((DocumentLine.Part)lineParts.get(i)).attachDetachAnnotations(doc, closing);
/** 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(); }
/** 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)) ) { 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(); } }
/** 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(); }
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() } }
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); } } });
/** Line can change during editting*/ void changeLine(Line line) { this.line = line; // TODO: check whether there is really some change firePropertyChange (PROP_LINE_NUMBER, null, line); }
/** Line can change during editting*/ void changeLine(Line line) { this.line = line; // TODO: check whether there is really some change firePropertyChange (PROP_LINE_NUMBER, null, line); }
/** This method will be used for annotation of part of the text on the line.*/ public Line.Part createPart( int column, int length ) { DocumentLine.Part part = new DocumentLine.Part(this, new PositionRef( pos.getCloneableEditorSupport().getPositionManager (), pos.getOffset() + column, Position.Bias.Forward), length); addLinePart(part); return part; }
/** Notify Line.Part(s) that line was moved. */ void notifyMove() { updatePositionRef(); for (int i=0; i<lineParts.size(); i++) { ((DocumentLine.Part)lineParts.get(i)).firePropertyChange(Line.Part.PROP_LINE, null, null); } }