Search in sources :

Example 1 with DocumentChanged

use of org.eclipse.wst.sse.core.internal.provisional.DocumentChanged in project webtools.sourceediting by eclipse.

the class AbstractStructuredModel method setStructuredDocument.

public void setStructuredDocument(IStructuredDocument newStructuredDocument) {
    boolean lifeCycleNotification = false;
    if (fStructuredDocument != null) {
        fStructuredDocument.removeDocumentChangedListener(fDirtyStateWatcher);
        fStructuredDocument.removeDocumentAboutToChangeListener(fDocumentToModelNotifier);
        fStructuredDocument.removeDocumentChangedListener(fDocumentToModelNotifier);
        // prechange notification
        lifeCycleNotification = true;
        ModelLifecycleEvent modelLifecycleEvent = new DocumentChanged(ModelLifecycleEvent.PRE_EVENT, this, fStructuredDocument, newStructuredDocument);
        signalLifecycleEvent(modelLifecycleEvent);
    }
    // hold for life cycle notification
    IStructuredDocument previousDocument = fStructuredDocument;
    // the actual change
    fStructuredDocument = newStructuredDocument;
    // so we can set our dirty state flag
    if (fStructuredDocument != null) {
        fStructuredDocument.addDocumentChangedListener(fDirtyStateWatcher);
        fStructuredDocument.addDocumentAboutToChangeListener(fDocumentToModelNotifier);
        fStructuredDocument.addDocumentChangedListener(fDocumentToModelNotifier);
    }
    if (lifeCycleNotification) {
        // post change notification
        ModelLifecycleEvent modelLifecycleEvent = new DocumentChanged(ModelLifecycleEvent.POST_EVENT, this, previousDocument, newStructuredDocument);
        signalLifecycleEvent(modelLifecycleEvent);
    }
}
Also used : DocumentChanged(org.eclipse.wst.sse.core.internal.provisional.DocumentChanged) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Aggregations

DocumentChanged (org.eclipse.wst.sse.core.internal.provisional.DocumentChanged)1 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)1