Copyright (c) 2006, 2008 IBM Corporation and others. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ SPDX-License-Identifier: EPL-2.0 Contributors: IBM Corporation - initial API and implementation
/******************************************************************************* * Copyright (c) 2006, 2008 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/
package org.eclipse.text.undo; import org.eclipse.core.runtime.Assert; import org.eclipse.jface.text.IDocument;
Describes document changes initiated by undo or redo.

Clients are not supposed to subclass or create instances of this class.

See Also:
Since:3.2
@noinstantiateThis class is not intended to be instantiated by clients.
@noextendThis class is not intended to be subclassed by clients.
/** * Describes document changes initiated by undo or redo. * <p> * Clients are not supposed to subclass or create instances of this class. * </p> * * @see IDocumentUndoManager * @see IDocumentUndoListener * @since 3.2 * @noinstantiate This class is not intended to be instantiated by clients. * @noextend This class is not intended to be subclassed by clients. */
public class DocumentUndoEvent {
Indicates that the described document event is about to be undone.
/** * Indicates that the described document event is about to be * undone. */
public static final int ABOUT_TO_UNDO= 1 << 0;
Indicates that the described document event is about to be redone.
/** * Indicates that the described document event is about to be * redone. */
public static final int ABOUT_TO_REDO= 1 << 1;
Indicates that the described document event has been undone.
/** * Indicates that the described document event has been undone. */
public static final int UNDONE= 1 << 2;
Indicates that the described document event has been redone.
/** * Indicates that the described document event has been redone. */
public static final int REDONE= 1 << 3;
Indicates that the described document event is a compound undo or redo event.
/** * Indicates that the described document event is a compound undo * or redo event. */
public static final int COMPOUND= 1 << 4;
The changed document.
/** The changed document. */
private IDocument fDocument;
The document offset where the change begins.
/** The document offset where the change begins. */
private int fOffset;
Text inserted into the document.
/** Text inserted into the document. */
private String fText;
Text replaced in the document.
/** Text replaced in the document. */
private String fPreservedText;
Bit mask of event types describing the event
/** Bit mask of event types describing the event */
private int fEventType;
The source that triggered this event or null if unknown.
/** The source that triggered this event or <code>null</code> if unknown. */
private Object fSource;
Creates a new document event.
Params:
  • doc – the changed document
  • offset – the offset of the replaced text
  • text – the substitution text
  • preservedText – the replaced text
  • eventType – a bit mask describing the type(s) of event
  • source – the source that triggered this event or null if unknown
/** * Creates a new document event. * * @param doc the changed document * @param offset the offset of the replaced text * @param text the substitution text * @param preservedText the replaced text * @param eventType a bit mask describing the type(s) of event * @param source the source that triggered this event or <code>null</code> if unknown */
DocumentUndoEvent(IDocument doc, int offset, String text, String preservedText, int eventType, Object source) { Assert.isNotNull(doc); Assert.isTrue(offset >= 0); fDocument= doc; fOffset= offset; fText= text; fPreservedText= preservedText; fEventType= eventType; fSource= source; }
Returns the changed document.
Returns:the changed document
/** * Returns the changed document. * * @return the changed document */
public IDocument getDocument() { return fDocument; }
Returns the offset of the change.
Returns:the offset of the change
/** * Returns the offset of the change. * * @return the offset of the change */
public int getOffset() { return fOffset; }
Returns the text that has been inserted.
Returns:the text that has been inserted
/** * Returns the text that has been inserted. * * @return the text that has been inserted */
public String getText() { return fText; }
Returns the text that has been replaced.
Returns:the text that has been replaced
/** * Returns the text that has been replaced. * * @return the text that has been replaced */
public String getPreservedText() { return fPreservedText; }
Returns the type of event that is occurring.
Returns:the bit mask that indicates the type (or types) of the event
/** * Returns the type of event that is occurring. * * @return the bit mask that indicates the type (or types) of the event */
public int getEventType() { return fEventType; }
Returns the source that triggered this event.
Returns:the source that triggered this event.
/** * Returns the source that triggered this event. * * @return the source that triggered this event. */
public Object getSource() { return fSource; }
Returns whether the change was a compound change or not.
Returns: true if the undo or redo change is a compound change, false if it is not
/** * Returns whether the change was a compound change or not. * * @return <code>true</code> if the undo or redo change is a * compound change, <code>false</code> if it is not */
public boolean isCompound() { return (fEventType & COMPOUND) != 0; } }