/** Checks the number of removed lines and recalculate * LineAnnotations.line property */ public void removeUpdate(DocumentEvent e) { BaseDocumentEvent be = (BaseDocumentEvent)e; int countOfDeletedLines = be.getLFCount(); if (countOfDeletedLines == 0) return; int changedLine = be.getLine(); /* #33165 - line in line-annotations handled in a different way LineAnnotations annos; for (int i=0; i<lineAnnotationsArray.size(); i++) { annos = (LineAnnotations)lineAnnotationsArray.get(i); if (annos.getLine() > changedLine && annos.getLine() < changedLine+countOfDeletedLines) annos.setLine(changedLine); if (annos.getLine() > changedLine) annos.setLine(annos.getLine()-countOfDeletedLines); } */ // fire event to AnnotationsListeners that everything should be redraw fireChangedAll(); }
protected void documentModified(DocumentEvent e) { if (e instanceof BaseDocumentEvent) { BaseDocumentEvent bde = (BaseDocumentEvent) e; if (bde.isInRedo() || bde.isInUndo() || getTransactionCounter() == 0) { Thread.dumpStack(); // #159129. no sense in this synchronization. //synchronized (this) { if (!m_updateInProcess) { m_updateInProcess = true; SwingUtilities.invokeLater(new Runnable() { public void run() { m_updateInProcess = false; getDataObject().fireContentChanged(); } }); } //} } } setChanged(true); }
protected BaseDocumentEvent createDocumentEvent(int pos, int length, DocumentEvent.EventType type) { return new BaseDocumentEvent(this, pos, length, type); }
/** * Try to determine whether this event can replace the old one. This is used * to batch the one-letter modifications into larger parts (words) and * undoing/redoing them at once. This method returns true whether */ public boolean replaceEdit(UndoableEdit anEdit) { BaseDocument doc = (BaseDocument) getDocument(); if (anEdit instanceof BaseDocumentEvent) { BaseDocumentEvent evt = (BaseDocumentEvent) anEdit; if (!doc.undoMergeReset && canMerge(evt)) { previous = evt; return true; } } doc.undoMergeReset = false; return false; }
public void redo() throws CannotRedoException { inRedo = true; if (previous != null) { previous.redo(); BaseDocument doc = (BaseDocument)getDocument(); if (!canRedo()) { throw new CannotRedoException(); if (getType() == DocumentEvent.EventType.INSERT) { doc.fireInsertUpdate(this); } else if (getType() == DocumentEvent.EventType.REMOVE) { doc.fireRemoveUpdate(this); } else {
public void undo() throws CannotUndoException { BaseDocument doc = (BaseDocument)getDocument(); if (!canUndo()) { throw new CannotUndoException(); if (getType() == DocumentEvent.EventType.REMOVE) { doc.fireInsertUpdate(this); } else if (getType() == DocumentEvent.EventType.INSERT) { doc.fireRemoveUpdate(this); } else { previous.undo();
int y = getYFromPos(evt.getOffset()); int lineHeight = editorUI.getLineHeight(); if (bevt.getLFCount() > 0) { // one or more lines inserted int addHeight = bevt.getLFCount() * lineHeight; mainHeight += addHeight; editorUI.repaint(y); int syntaxY = getYFromPos(bevt.getSyntaxUpdateOffset()); if (bevt.getSyntaxUpdateOffset() == evt.getDocument().getLength()) { syntaxY += lineHeight;
public void removeUpdate(DocumentEvent evt) { if (!(evt instanceof BaseDocumentEvent)) return; BaseDocumentEvent bevt = (BaseDocumentEvent)evt; if (bevt.getLFCount() > 0) { // one or more lines removed refresh(); } }
public boolean addLayer(DrawLayer layer, int visibility) { if (drawLayerList.add(layer, visibility)) { BaseDocumentEvent evt = createDocumentEvent(0, 0, DocumentEvent.EventType.CHANGE); evt.addEdit(new BaseDocumentEvent.DrawLayerChange(layer.getName(), visibility)); fireChangedUpdate(evt); return true; } else { return false; } }
public void die() { // Super of die() int size = edits.size(); for (int i = size - 1; i >= 0; i--) { UndoableEdit e = (UndoableEdit) edits.elementAt(i); e.die(); } alive2 = false; // End super of die() if (previous != null) { previous.die(); previous = null; } }
/** * Insert contents of reader at specified position into document. * * @param reader * reader from which data will be read * @param pos * on which position that data will be inserted */ public void read(Reader reader, int pos) throws IOException, BadLocationException { extWriteLock(); try { if (pos < 0 || pos > getLength()) { throw new BadLocationException("BaseDocument.read()", pos); // NOI18N } if (inited || modified) { // was the document already initialized? Analyzer.read(this, reader, pos); } else { // not initialized yet, we can use initialRead() Analyzer.initialRead(this, reader, true); BaseDocumentEvent evt = createDocumentEvent(0, 0, DocumentEvent.EventType.INSERT); evt.end(); fireInsertUpdate(evt); // fire the insert event with zero // length to notify about the change inited = true; // initialized but not modified } } finally { extWriteUnlock(); } }
public void redo() throws CannotRedoException { inRedo = true; if (previous != null) { previous.redo(); BaseDocument doc = (BaseDocument) getDocument(); if (!canRedo()) { throw new CannotRedoException(); if (getType() == DocumentEvent.EventType.INSERT) { doc.fireInsertUpdate(this); else if (getType() == DocumentEvent.EventType.REMOVE) { doc.fireRemoveUpdate(this);
public void undo() throws CannotUndoException { BaseDocument doc = (BaseDocument) getDocument(); if (!canUndo()) { throw new CannotUndoException(); if (getType() == DocumentEvent.EventType.REMOVE) { doc.fireInsertUpdate(this); else if (getType() == DocumentEvent.EventType.INSERT) { doc.fireRemoveUpdate(this); previous.undo();
int y = getYFromPos(evt.getOffset()); int lineHeight = editorUI.getLineHeight(); if (bevt.getLFCount() > 0) { // one or more lines removed int removeHeight = bevt.getLFCount() * lineHeight; mainHeight -= removeHeight; editorUI.repaint(y); int syntaxY = getYFromPos(bevt.getSyntaxUpdateOffset()); if (bevt.getSyntaxUpdateOffset() == evt.getDocument().getLength()) { syntaxY += lineHeight;
public void removeUpdate(DocumentEvent evt) { if (!(evt instanceof BaseDocumentEvent)) return; BaseDocumentEvent bevt = (BaseDocumentEvent)evt; if (bevt.getLFCount() > 0) { // one or more lines removed repaint(); } }
/** Try to determine whether this event can replace the old one. * This is used to batch the one-letter modifications into larger * parts (words) and undoing/redoing them at once. * This method returns true whether */ public boolean replaceEdit(UndoableEdit anEdit) { BaseDocument doc = (BaseDocument)getDocument(); if (anEdit instanceof BaseDocumentEvent) { BaseDocumentEvent evt = (BaseDocumentEvent)anEdit; if (!doc.undoMergeReset && canMerge(evt)) { previous = evt; return true; } } doc.undoMergeReset = false; return false; }
public boolean addLayer(DrawLayer layer, int visibility) { if (drawLayerList.add(layer, visibility)) { BaseDocumentEvent evt = createDocumentEvent(0, 0, DocumentEvent.EventType.CHANGE); evt.addEdit(new BaseDocumentEvent.DrawLayerChange(layer.getName(), visibility)); fireChangedUpdate(evt); return true; } else { return false; } }
public void die() { // Super of die() int size = edits.size(); for (int i = size-1; i >= 0; i--) { UndoableEdit e = (UndoableEdit)edits.elementAt(i); e.die(); } alive2 = false; // End super of die() if (previous != null) { previous.die(); previous = null; } }