use of org.eclipse.core.commands.operations.IUndoableOperation in project che by eclipse.
the class UndoManager2 method performRedo.
public void performRedo(IValidationCheckResultQuery query, IProgressMonitor pm) throws CoreException {
IUndoableOperation redo = fOperationHistory.getRedoOperation(RefactoringCorePlugin.getUndoContext());
UndoableOperation2ChangeAdapter changeOperation = getUnwrappedOperation(redo);
if (changeOperation == null)
throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IStatus.ERROR, RefactoringCoreMessages.UndoManager2_no_change, null));
if (query == null)
query = new NullQuery();
try {
fOperationHistory.redoOperation(redo, pm, new QueryAdapter(query));
} catch (ExecutionException e) {
handleException(e);
}
}
use of org.eclipse.core.commands.operations.IUndoableOperation in project che by eclipse.
the class UndoManager2 method aboutToPerformChange.
public void aboutToPerformChange(Change change) {
IUndoableOperation operation = new UndoableOperation2ChangeAdapter(change);
operation.addContext(RefactoringCorePlugin.getUndoContext());
fActiveOperation = new TriggeredOperations(operation, fOperationHistory);
fActiveOperation.addContext(RefactoringCorePlugin.getUndoContext());
fOperationHistory.openOperation(fActiveOperation, IOperationHistory.EXECUTE);
fIsOpen = true;
}
use of org.eclipse.core.commands.operations.IUndoableOperation in project che by eclipse.
the class UndoManager2 method performUndo.
public void performUndo(IValidationCheckResultQuery query, IProgressMonitor pm) throws CoreException {
IUndoableOperation undo = fOperationHistory.getUndoOperation(RefactoringCorePlugin.getUndoContext());
UndoableOperation2ChangeAdapter changeOperation = getUnwrappedOperation(undo);
if (changeOperation == null)
throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IStatus.ERROR, RefactoringCoreMessages.UndoManager2_no_change, null));
if (query == null)
query = new NullQuery();
try {
fOperationHistory.undoOperation(undo, pm, new QueryAdapter(query));
} catch (ExecutionException e) {
handleException(e);
}
}
use of org.eclipse.core.commands.operations.IUndoableOperation in project eclipse.platform.text by eclipse.
the class DocumentUndoManager method transferUndoHistory.
@Override
public void transferUndoHistory(IDocumentUndoManager manager) {
IUndoContext oldUndoContext = manager.getUndoContext();
// Get the history for the old undo context.
IUndoableOperation[] operations = OperationHistoryFactory.getOperationHistory().getUndoHistory(oldUndoContext);
for (IUndoableOperation operation : operations) {
// First replace the undo context
IUndoableOperation op = operation;
if (op instanceof IContextReplacingOperation) {
((IContextReplacingOperation) op).replaceContext(oldUndoContext, getUndoContext());
} else {
op.addContext(getUndoContext());
op.removeContext(oldUndoContext);
}
// Now update the manager that owns the text edit.
if (op instanceof UndoableTextChange) {
((UndoableTextChange) op).fDocumentUndoManager = this;
}
}
IUndoableOperation op = OperationHistoryFactory.getOperationHistory().getUndoOperation(getUndoContext());
if (op != null && !(op instanceof UndoableTextChange))
return;
// Record the transfer itself as an undoable change.
// If the transfer results from some open operation, recording this change will
// cause our undo context to be added to the outer operation. If there is no
// outer operation, there will be a local change to signify the transfer.
// This also serves to synchronize the modification stamps with the documents.
UndoableTextChange cmd = new UndoableTextChange(this);
cmd.fStart = cmd.fEnd = 0;
// $NON-NLS-1$
cmd.fText = cmd.fPreservedText = "";
if (fDocument instanceof IDocumentExtension4) {
cmd.fRedoModificationStamp = ((IDocumentExtension4) fDocument).getModificationStamp();
if (op != null)
cmd.fUndoModificationStamp = ((UndoableTextChange) op).fRedoModificationStamp;
}
addToOperationHistory(cmd);
}
use of org.eclipse.core.commands.operations.IUndoableOperation in project eclipse.platform.text by eclipse.
the class AddMarkerAction method run.
@Override
public void run() {
IResource resource = getResource();
if (resource == null)
return;
Map<String, Object> attributes = getInitialAttributes();
if (fAskForLabel) {
if (!askForLabel(attributes))
return;
}
String name = getToolTipText();
name = name == null ? TextEditorMessages.AddMarkerAction_addMarker : name;
final Shell shell = getTextEditor().getSite().getShell();
IAdaptable context = new IAdaptable() {
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Class<T> adapter) {
if (adapter == Shell.class)
return (T) shell;
return null;
}
};
IUndoableOperation operation = new CreateMarkersOperation(fMarkerType, attributes, resource, name);
IOperationHistory operationHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
try {
operationHistory.execute(operation, null, context);
} catch (ExecutionException x) {
Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
ILog log = Platform.getLog(bundle);
// $NON-NLS-2$ //$NON-NLS-1$
String msg = getString(fBundle, fPrefix + "error.dialog.message", fPrefix + "error.dialog.message");
log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, msg, x));
}
}
Aggregations