blob: 924c02950b885e36c438157fd1ef5751d17638ce [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2001, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Jens Lukowski/Innoopract - initial renaming/restructuring
*
*******************************************************************************/
package org.eclipse.wst.sse.core.events;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.wst.sse.core.text.IStructuredDocument;
/**
* IStructuredDocument events are generated by the IStructuredDocument, after
* the IStructuredDocument acts on a request. Not intended to be instantiated,
* except by subclasses.
*
* @since 1.0
*/
public abstract class StructuredDocumentEvent extends DocumentEvent {
private String fDeletedText;
private Object fOriginalRequester;
/**
* We assume (and require) that an IStructuredDocument's are always the
* source of StructuredDocument events.
*/
protected StructuredDocumentEvent(IStructuredDocument document) {
super();
if (document == null)
throw new IllegalArgumentException("null source"); //$NON-NLS-1$
fDocument = document;
fOriginalRequester = document;
}
protected StructuredDocumentEvent(IStructuredDocument document, Object originalRequester) {
this(document);
fOriginalRequester = originalRequester;
}
protected StructuredDocumentEvent(IStructuredDocument document, Object originalRequester, String changes, int offset, int lengthToReplace) {
this(document);
fOriginalRequester = originalRequester;
fText = changes;
fOffset = offset;
fLength = lengthToReplace;
}
/**
* Provides the text that is being deleted.
*
* @return the text that is being deleted
*/
public java.lang.String getDeletedText() {
return fDeletedText;
}
/**
* This method returns the object that originally caused the event to
* fire. This is typically not the object that created the event (the
* IStructuredDocument) but instead the object that made a request to the
* IStructuredDocument.
*
* @return the object that made the request to the document
*/
public Object getOriginalRequester() {
return fOriginalRequester;
}
/**
* This method is equivalent to 'getDocument' except it returns an object
* of the appropriate type (namely, a IStructuredDocument, instead of
* IDocument).
*/
public IStructuredDocument getStructuredDocument() {
// a safe case, since constructor can only be called with a
// IStructuredDocument
return (IStructuredDocument) fDocument;
}
/**
* @param newDeletedText
* java.lang.String
*/
public void setDeletedText(java.lang.String newDeletedText) {
fDeletedText = newDeletedText;
}
/**
* for debugging only
*
* @deprecated - need to fix unit tests, then delete this
*/
public String toString() {
// return getClass().getName() + "[source=" + source + "]";
return getClass().getName();
}
}