本文整理汇总了Java中org.eclipse.core.commands.operations.IOperationHistory.getUndoOperation方法的典型用法代码示例。如果您正苦于以下问题:Java IOperationHistory.getUndoOperation方法的具体用法?Java IOperationHistory.getUndoOperation怎么用?Java IOperationHistory.getUndoOperation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.commands.operations.IOperationHistory
的用法示例。
在下文中一共展示了IOperationHistory.getUndoOperation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doSetValue
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
@Override
protected void doSetValue(final Object value) {
Object oldValue = doGetValue();
if (CommonUtils.equals(value, oldValue)) {
return; // nothing to do
}
EStructuralFeature feature = (EStructuralFeature) pd.getFeature(target);
String name = EMFUtils.getDisplayName(target, feature);
IUndoableOperation operation = new ChangeObservableOperation("Edit " + name, value);
EObject observed = (EObject) getObserved();
operation = EMFUtils.addContributorOperations(operation, observed, feature, oldValue, value);
IUndoContext context = gov.nasa.ensemble.emf.transaction.TransactionUtils.getUndoContext(observed);
IOperationHistory history = OperationHistoryFactory.getOperationHistory();
IUndoableOperation previous = history.getUndoOperation(context);
if (previous instanceof TextModifyUndoableObservableValue.TextModifyObservableOperation) {
// Reset the TextModifyObservableOperation to clear the dirty flag on its TextModifyUndoableObservableValue
((TextModifyUndoableObservableValue.TextModifyObservableOperation) previous).reset();
// Remove the TextModifyObservableOperation operation from the operation history as it should be replaced by the new operation
history.replaceOperation(previous, new IUndoableOperation[0]);
}
CommonUtils.execute(operation, context);
}
示例2: startRecording
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
public void startRecording(XtextEditor editor) {
this.editor = editor;
ISourceViewer viewer = editor.getInternalSourceViewer();
if (viewer instanceof ITextViewerExtension6) {
IUndoManager undoManager = ((ITextViewerExtension6) viewer).getUndoManager();
if (undoManager instanceof IUndoManagerExtension) {
IUndoManagerExtension undoManagerExtension = (IUndoManagerExtension) undoManager;
IUndoContext undoContext = undoManagerExtension.getUndoContext();
IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
startingUndoOperation = operationHistory.getUndoOperation(undoContext);
}
}
}
示例3: resetDirty
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
/**
* Modify the current dirty state
*/
public void resetDirty() {
IOperationHistory history = OperationHistoryFactory.getOperationHistory();
cleanStateOperation = history.getUndoOperation(getUndoContext());
if (dirty || dirtyByDefault) {
dirtyByDefault = false;
dirty = false;
fireDirtyStateChanged();
}
}
示例4: start
import org.eclipse.core.commands.operations.IOperationHistory; //导入方法依赖的package包/类
public void start() {
if (getActiveLinkedMode() != null) {
// for safety; should already be handled in RenameJavaElementAction
fgActiveLinkedMode.startFullDialog();
return;
}
ISourceViewer viewer = fEditor.getViewer();
IDocument document = viewer.getDocument();
ITypeScriptFile tsFile = fEditor.getTypeScriptFile();
tsFile.setDisableChanged(true);
fOriginalSelection = viewer.getSelectedRange();
int offset = fOriginalSelection.x;
try {
fLinkedPositionGroup = new LinkedPositionGroup();
if (viewer instanceof ITextViewerExtension6) {
IUndoManager undoManager = ((ITextViewerExtension6) viewer).getUndoManager();
if (undoManager instanceof IUndoManagerExtension) {
IUndoManagerExtension undoManagerExtension = (IUndoManagerExtension) undoManager;
IUndoContext undoContext = undoManagerExtension.getUndoContext();
IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
fStartingUndoOperation = operationHistory.getUndoOperation(undoContext);
}
}
// Find occurrences
List<OccurrencesResponseItem> occurrences = tsFile.occurrences(offset).get(1000, TimeUnit.MILLISECONDS);
// Create Eclipse linked position from the occurrences list.
int start, length;
for (int i = 0; i < occurrences.size(); i++) {
OccurrencesResponseItem item = occurrences.get(i);
start = tsFile.getPosition(item.getStart());
length = tsFile.getPosition(item.getEnd()) - start;
LinkedPosition linkedPosition = new LinkedPosition(document, start, length, i);
if (i == 0) {
fOriginalName = document.get(start, length);
fNamePosition = linkedPosition;
}
fLinkedPositionGroup.addPosition(linkedPosition);
}
fLinkedModeModel = new LinkedModeModel();
fLinkedModeModel.addGroup(fLinkedPositionGroup);
fLinkedModeModel.forceInstall();
fLinkedModeModel.addLinkingListener(new EditorHighlightingSynchronizer(fEditor));
fLinkedModeModel.addLinkingListener(new EditorSynchronizer());
LinkedModeUI ui = new EditorLinkedModeUI(fLinkedModeModel, viewer);
ui.setExitPosition(viewer, offset, 0, Integer.MAX_VALUE);
ui.setExitPolicy(new ExitPolicy(document));
ui.enter();
viewer.setSelectedRange(fOriginalSelection.x, fOriginalSelection.y); // by
// default,
// full
// word
// is
// selected;
// restore
// original
// selection
if (viewer instanceof IEditingSupportRegistry) {
IEditingSupportRegistry registry = (IEditingSupportRegistry) viewer;
registry.register(fFocusEditingSupport);
}
openSecondaryPopup();
// startAnimation();
fgActiveLinkedMode = this;
} catch (Exception e) {
JSDTTypeScriptUIPlugin.log(e);
}
}