Java Code Examples for javax.swing.event.DocumentListener#removeUpdate()

The following examples show how to use javax.swing.event.DocumentListener#removeUpdate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WeakListenerImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Gives notification that a portion of the document has been removed.
* @param ev event describing the action
*/
@Override public void removeUpdate(DocumentEvent ev) {
    final DocumentListener l = docGet(ev);

    if (l != null) {
        l.removeUpdate(ev);
    }
}
 
Example 2
Source File: BaseDocument.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void firePreRemoveUpdate(DefaultDocumentEvent chng) {
    // Notify the remove update listeners - before the actual remove happens
    // so that it adheres to removeUpdate() logic; also the listeners can check
    // positions' offsets before the actual removal happens.
    for (DocumentListener listener: updateDocumentListenerList.getListeners()) {
        listener.removeUpdate(chng);
    }
}
 
Example 3
Source File: AbstractDocumentModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void removeUpdate(DocumentEvent e) {
    DocumentListener l = getDelegate();
    if (l != null) {
	l.removeUpdate(e);
    }
}
 
Example 4
Source File: PriorityDocumentListenerList.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Implementation of DocumentListener's method fires all the added
 * listeners according to their priority.
 */
public void removeUpdate(DocumentEvent evt) {
    logEvent(evt, "removeUpdate");
    // Fire the prioritized listeners
    EventListener[][] listenersArray = getListenersArray();
    // Attempt to fire to all listeners catching possible exception(s) and report first fired then
    RuntimeException runtimeException = null;
    for (int priority = listenersArray.length - 1; priority >= 0; priority--) {
        logPriority(priority);
        EventListener[] listeners = listenersArray[priority];
        for (int i = listeners.length - 1; i >= 0; i--) {
            DocumentListener l = (DocumentListener) listeners[i];
            logListener(l);
            try {
                l.removeUpdate(evt);
            } catch (RuntimeException ex) {
                if (runtimeException == null) { // Only record first thrown
                    runtimeException = ex;
                }
            }
        }
    }
    if (runtimeException != null) {
        throw runtimeException; // Re-throw remembered exception
    }
    logEventEnd("removeUpdate");
}
 
Example 5
Source File: FormulaDocument.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void fireRemoveEvent( final DocumentEvent event ) {
  final DocumentListener[] listeners = listenerList.getListeners( DocumentListener.class );
  for ( int i = 0; i < listeners.length; i++ ) {
    final DocumentListener documentListener = listeners[ i ];
    documentListener.removeUpdate( event );
  }
}
 
Example 6
Source File: BaseDocument.java    From netbeans with Apache License 2.0 4 votes vote down vote up
void handleRemove(int offset, int length) throws BadLocationException {
    if (length == 0) {
        return;
    }
    if (length < 0) {
        throw new IllegalArgumentException("len=" + length + " < 0"); // NOI18N
    }
    if (offset < 0) {
        throw new BadLocationException("Wrong remove position " + offset + " < 0", offset); // NOI18N
    }
    if (offset + length > getLength()) {
        throw new BadLocationException("Wrong (offset+length)=" + (offset+length) +
                " > getLength()=" + getLength(), offset + length); // NOI18N
    }

    incrementDocVersion();

    int docLen = getLength();
    if (offset < 0 || offset > docLen) {
        throw new BadLocationException("Wrong remove position " + offset, offset); // NOI18N
    }
    if (offset + length > docLen) {
        throw new BadLocationException("End offset of removed text " // NOI18N
                + (offset + length) + " > getLength()=" + docLen, // NOI18N
                offset + length); // NOI18N
    }

    preRemoveCheck(offset, length);

    BaseDocumentEvent evt = getDocumentEvent(offset, length, DocumentEvent.EventType.REMOVE, null);
    // Store modification text as an event's property
    org.netbeans.lib.editor.util.swing.DocumentUtilities.addEventPropertyStorage(evt);
    String removedText = getText(offset, length);
    org.netbeans.lib.editor.util.swing.DocumentUtilities.putEventProperty(evt, String.class, removedText);
    if (postModificationDepth > 0) {
        DocumentPostModificationUtils.markPostModification(evt);
    }

    removeUpdate(evt);

    UndoableEdit edit = ((EditorDocumentContent) getContent()).remove(offset, removedText);
    if (edit != null) {
        evt.addEdit(edit);

        lastModifyUndoEdit = edit; // #8692 check last modify undo edit
    }

    if (LOG.isLoggable(Level.FINE)) {
        StringBuilder sb = new StringBuilder(200);
        sb.append("remove(): doc="); // NOI18N
        appendInfoTerse(sb);
        sb.append(",origDocLen=").append(docLen); // NOI18N
        sb.append(", offset=").append(Utilities.offsetToLineColumnString(this, offset)); // NOI18N
        sb.append(",len=").append(length); // NOI18N
        if (!debugNoText) {
            sb.append(" \"");
            appendContext(sb, offset);
            sb.append("\" - \""); // NOI18N
            CharSequenceUtilities.debugText(sb, ((ContentEdit) edit).getText());
            sb.append("\""); // NOI18N
        }

        if (debugStack) {
            LOG.log(Level.FINE, sb.toString(), new Throwable("Remove text")); // NOI18N
        } else {
            LOG.log(Level.FINE, sb.toString());
        }
    }

    if (atomicDepth > 0) { // add edits as soon as possible
        ensureAtomicEditsInited();
        atomicEdits.addEdit(evt); // will be added
    }

    postRemoveUpdate(evt);

    evt.end();

    fireRemoveUpdate(evt);

    postModificationDepth++;
    try {
        if (postModificationDocumentListener != null) {
            postModificationDocumentListener.removeUpdate(evt);
        }
        if (postModificationDocumentListenerList.getListenerCount() > 0) {
            for (DocumentListener listener : postModificationDocumentListenerList.getListeners()) {
                listener.removeUpdate(evt);
            }
        }
    } finally {
        postModificationDepth--;
    }

    if (atomicDepth == 0 && !composedText) {
        fireUndoableEditUpdate(new UndoableEditEvent(this, evt));
    }
}