try {
model = StructuredModelManager.getModelManager().getModelForEdit(document);
if(model != null) {
//makes it so one undo will undo all the edits to the document
model.beginRecording(this, SSEUIMessages.AddBlockComment_label, SSEUIMessages.AddBlockComment_description);
//keeps listeners from doing anything until updates are all done
model.aboutToChangeModel();
if(document instanceof IDocumentExtension4) {
session = ((IDocumentExtension4)document).startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);