Java Code Examples for org.eclipse.core.commands.operations.IOperationHistory#canUndo()

The following examples show how to use org.eclipse.core.commands.operations.IOperationHistory#canUndo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XLIFFEditorActionHandler.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void runWithEvent(Event event) {
	if (viewer != null && !viewer.getTextWidget().isDisposed()) {
		XLIFFEditorImplWithNatTable xliffEditor = XLIFFEditorImplWithNatTable.getCurrent();
		// 先保存在撤销,除非以后取消两种模式,否则不要删除此判断
		if (viewer.canDoOperation(ITextOperationTarget.UNDO)) {
			HsMultiActiveCellEditor.commit(true);
		}
		IOperationHistory history = OperationHistoryFactory.getOperationHistory();
		IUndoContext undoContext = (IUndoContext) xliffEditor.getTable().getData(IUndoContext.class.getName());
		if (history.canUndo(undoContext)) {
			try {
				history.undo(undoContext, null, null);
				undoBean.setCrosseStep(undoBean.getCrosseStep() + 1);
			} catch (ExecutionException e) {
				e.printStackTrace();
			}
		}
		XLIFFEditorImplWithNatTable.getCurrent().redraw();
		updateActionsEnableState();
		return;
	}
	if (undoAction != null) {
		undoAction.runWithEvent(event);
		return;
	}
}
 
Example 2
Source File: CellEditorGlobalActionHanlder.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void runWithEvent(Event event) {
	TeActiveCellEditor.commit();
	IOperationHistory history = OperationHistoryFactory.getOperationHistory();
	IUndoContext context = PlatformUI.getWorkbench().getOperationSupport().getUndoContext();
	if (history.canUndo(context)) {
		try {
			history.undo(context, null, null);
			updateActionsEnableState();
		} catch (ExecutionException e) {
			e.printStackTrace();
		}
	}
}
 
Example 3
Source File: CellEditorGlobalActionHanlder.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Update the state.
 */
public void updateEnabledState() {
	IOperationHistory opHisotry = OperationHistoryFactory.getOperationHistory();
	IUndoContext context = PlatformUI.getWorkbench().getOperationSupport().getUndoContext();
	if (opHisotry.canUndo(context)) {
		setEnabled(true);
		return;
	}
	if (viewer != null && !viewer.getTextWidget().isDisposed()) {
		setEnabled(viewer.canDoOperation(ITextOperationTarget.UNDO));
		return;
	}
	setEnabled(false);
}