@Override
public void setDocument(IDocument document,
IAnnotationModel annotationModel, int modelRangeOffset,
int modelRangeLength) {
if (getDocument() instanceof IStructuredDocument) {
CommandStack commandStack = ((IStructuredDocument) getDocument())
.getUndoManager().getCommandStack();
if (commandStack instanceof BasicCommandStack) {
commandStack
.addCommandStackListener(getInternalCommandStackListener());
}
}
super.setDocument(document, annotationModel, modelRangeOffset,
modelRangeLength);
if (getDocument() instanceof IStructuredDocument) {
CommandStack commandStack = ((IStructuredDocument) getDocument())
.getUndoManager().getCommandStack();
if (commandStack instanceof BasicCommandStack) {
commandStack
.addCommandStackListener(getInternalCommandStackListener());
}
}
}