use of org.eclipse.emf.common.command.CompoundCommand in project webtools.sourceediting by eclipse.
the class StructuredTextUndoManager method redo.
public void redo(IDocumentSelectionMediator requester) {
IStructuredModel model = findStructuredModel(fDocument);
if (redoable()) {
IDocumentExtension4 docExt4 = null;
DocumentRewriteSession rewriteSession = null;
try {
if (model != null)
model.aboutToChangeModel();
Command redoCommand = getRedoCommand();
if (redoCommand instanceof CompoundCommand && model.getStructuredDocument() instanceof IDocumentExtension4) {
docExt4 = (IDocumentExtension4) model.getStructuredDocument();
}
rewriteSession = (docExt4 == null) ? null : docExt4.startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);
// make sure to redo before setting document selection
fCommandStack.redo();
// set document selection
setRedoDocumentSelection(requester, redoCommand);
} finally {
if (docExt4 != null && rewriteSession != null)
docExt4.stopRewriteSession(rewriteSession);
if (model != null) {
model.changedModel();
model.releaseFromRead();
}
}
}
}
use of org.eclipse.emf.common.command.CompoundCommand in project webtools.sourceediting by eclipse.
the class StructuredTextUndoManager method undo.
public void undo(IDocumentSelectionMediator requester) {
// Therefore, this force ending of recording is not needed in redo.
if (fRecording)
endRecording(this);
if (undoable()) {
IStructuredModel model = findStructuredModel(fDocument);
IDocumentExtension4 docExt4 = null;
DocumentRewriteSession rewriteSession = null;
try {
if (model != null)
model.aboutToChangeModel();
Command undoCommand = getUndoCommand();
if (undoCommand instanceof CompoundCommand && model.getStructuredDocument() instanceof IDocumentExtension4) {
docExt4 = (IDocumentExtension4) model.getStructuredDocument();
}
rewriteSession = (docExt4 == null) ? null : docExt4.startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);
// make sure to undo before setting document selection
fCommandStack.undo();
// set document selection
setUndoDocumentSelection(requester, undoCommand);
} finally {
if (docExt4 != null && rewriteSession != null)
docExt4.stopRewriteSession(rewriteSession);
if (model != null) {
model.changedModel();
model.releaseFromRead();
}
}
}
}
use of org.eclipse.emf.common.command.CompoundCommand in project InformationSystem by ObeoNetwork.
the class EditUserStoryHandler method execute.
/**
* {@inheritDoc}
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof UserStoriesView) {
UserStoriesView view = (UserStoriesView) activePart;
EditingDomain editingDomain = view.getEditingDomain();
if (editingDomain != null) {
UserStory userStory = view.getSelectedStories().get(0);
UserStoryDialog dialog = new UserStoryDialog(HandlerUtil.getActiveShell(event), userStory);
int open = dialog.open();
if (open == Window.OK) {
CompoundCommand cc = new CompoundCommand();
cc.append(SetCommand.create(editingDomain, userStory, GraalPackage.eINSTANCE.getNamedElement_Name(), dialog.getName()));
cc.append(SetCommand.create(editingDomain, userStory, EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description(), dialog.getDescription()));
editingDomain.getCommandStack().execute(cc);
view.refresh();
}
}
}
return null;
}
Aggregations