org.eclipse.ui.operations.UndoRedoActionGroup#org.eclipse.core.commands.operations.IOperationHistory源码实例Demo

下面列出了org.eclipse.ui.operations.UndoRedoActionGroup#org.eclipse.core.commands.operations.IOperationHistory 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: xtext-eclipse   文件: ProblemHoverTest.java
@Test public void testBug357516_bookmark() throws Exception {
	IResource resource = editor.getResource();
	HashMap<String, Object> attributes = new HashMap<String, Object>();
	attributes.put(IMarker.MESSAGE, CUSTOM_MARKER_TEST_MESSAGE);
	attributes.put(IMarker.LINE_NUMBER, 1);
	attributes.put(IMarker.LOCATION, resource.getFullPath().toPortableString());
	IUndoableOperation operation= new CreateMarkersOperation(IMarker.BOOKMARK, attributes, resource, CUSTOM_MARKER_TEST_MESSAGE);
	IOperationHistory operationHistory= PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
	try {
		operationHistory.execute(operation, null, null);
	} catch (ExecutionException x) {
		fail(x.getMessage());
	}
	String hoverInfo = hover.getHoverInfo(editor.getInternalSourceViewer(), 0);
	assertNotNull(hoverInfo);
	assertTrue(hoverInfo.contains(CUSTOM_MARKER_TEST_MESSAGE));
}
 
源代码2 项目: gef   文件: HistoricizingDomain.java
/**
 * Sets the {@link IOperationHistory} that is used by this
 * {@link HistoricizingDomain} to the given value. Operation history
 * listeners are un-/registered accordingly.
 *
 * @param operationHistory
 *            The new {@link IOperationHistory} for this domain.
 */
@Inject
public void setOperationHistory(IOperationHistory operationHistory) {
	if (this.operationHistory != null
			&& this.operationHistory != operationHistory) {
		this.operationHistory
				.removeOperationHistoryListener(transactionListener);
	}
	if (this.operationHistory != operationHistory) {
		this.operationHistory = operationHistory;
		if (this.operationHistory != null) {
			this.operationHistory
					.addOperationHistoryListener(transactionListener);
			if (undoContext != null) {
				this.operationHistory.setLimit(undoContext,
						DEFAULT_UNDO_LIMIT);
			}
		}
	}
}
 
源代码3 项目: gef   文件: FitToViewportLockAction.java
/**
 * Disables all viewport listeners that react to scroll offset, viewport
 * transformation, or viewport-/scrollable-/content-bounds changes.
 */
protected void disableViewportListeners() {
	infiniteCanvas.horizontalScrollOffsetProperty()
			.removeListener(scrollOffsetChangeListener);
	infiniteCanvas.verticalScrollOffsetProperty()
			.removeListener(scrollOffsetChangeListener);
	contentTransform.removeEventHandler(
			TransformChangedEvent.TRANSFORM_CHANGED, trafoChangeListener);
	contentBoundsProperty.removeListener(contentBoundsChangeListener);
	infiniteCanvas.widthProperty().removeListener(sizeChangeListener);
	infiniteCanvas.heightProperty().removeListener(sizeChangeListener);

	IDomain domain = getViewer().getDomain();
	if (domain instanceof HistoricizingDomain) {
		IOperationHistory history = ((HistoricizingDomain) domain)
				.getOperationHistory();
		history.removeOperationHistoryListener(operationHistoryListener);
	}
}
 
源代码4 项目: gef   文件: FitToViewportLockAction.java
/**
 * Enables all viewport listeners that react to scroll offset, viewport
 * transformation, or viewport-/scrollable-/content-bounds changes.
 * <p>
 * Moreover, stores the content bounds size, so that the size can later be
 * tested for changes.
 */
protected void enableViewportListeners() {
	infiniteCanvas.horizontalScrollOffsetProperty()
			.addListener(scrollOffsetChangeListener);
	infiniteCanvas.verticalScrollOffsetProperty()
			.addListener(scrollOffsetChangeListener);
	contentTransform.addEventHandler(
			TransformChangedEvent.TRANSFORM_CHANGED, trafoChangeListener);
	contentBoundsProperty.addListener(contentBoundsChangeListener);
	infiniteCanvas.widthProperty().addListener(sizeChangeListener);
	infiniteCanvas.heightProperty().addListener(sizeChangeListener);

	IDomain domain = getViewer().getDomain();
	if (domain instanceof HistoricizingDomain) {
		IOperationHistory history = ((HistoricizingDomain) domain)
				.getOperationHistory();
		history.addOperationHistoryListener(operationHistoryListener);
	}
}
 
源代码5 项目: gef   文件: UndoablePropertySheetEntry.java
/**
 * Constructs a new root entry.
 *
 * @param workbenchPart
 *            The {@link IWorkbenchPart} to adapt for an
 *            {@link IPropertySource}, in case no values are provided.
 * @param operationHistory
 *            The {@link IOperationHistory} to use.
 * @param undoContext
 *            The {@link IUndoContext} to use.
 */
public UndoablePropertySheetEntry(IWorkbenchPart workbenchPart,
		IOperationHistory operationHistory, IUndoContext undoContext) {
	this.workbenchPart = workbenchPart;
	this.operationHistory = operationHistory;
	this.undoContext = undoContext;
	this.operationHistoryListener = new IOperationHistoryListener() {

		@Override
		public void historyNotification(OperationHistoryEvent event) {
			refreshFromRoot();
		}
	};
	this.operationHistory
			.addOperationHistoryListener(operationHistoryListener);
}
 
源代码6 项目: gef   文件: UndoablePropertySheetPage.java
/**
 * Constructs a new {@link UndoablePropertySheetPage} using the provided
 * {@link IOperationHistory}.
 *
 * @param operationHistory
 *            The {@link IOperationHistory} shared with the editor/view.
 * @param undoContext
 *            The {@link IUndoContext} shared with the editor/view.
 * @param workbenchPart
 *            The {@link IWorkbenchPart} this
 *            {@link UndoablePropertySheetPage} is related to. .
 *
 */
@Inject
public UndoablePropertySheetPage(@Assisted IWorkbenchPart workbenchPart,
		IOperationHistory operationHistory, IUndoContext undoContext) {
	this.workbenchPart = workbenchPart;
	this.operationHistory = operationHistory;
	this.undoContext = undoContext;
	this.operationHistoryListener = new IOperationHistoryListener() {

		@Override
		public void historyNotification(OperationHistoryEvent event) {
			if (event.getEventType() == OperationHistoryEvent.ABOUT_TO_REDO
					|| event.getEventType() == OperationHistoryEvent.ABOUT_TO_UNDO) {
				refresh();
			}
		}
	};
	operationHistory.addOperationHistoryListener(operationHistoryListener);
	setRootEntry(createRootEntry());
}
 
源代码7 项目: gef   文件: MvcFxUiModule.java
/**
 * Binds a factory for the creation of
 * {@link HistoryBasedDirtyStateProvider} as {@link IDirtyStateProvider}.
 */
protected void bindIDirtyStateProviderFactory() {
	binder().bind(IDirtyStateProviderFactory.class)
			.toInstance(new IDirtyStateProviderFactory() {

				@Override
				public IDirtyStateProvider create(
						IWorkbenchPart workbenchPart) {
					return new HistoryBasedDirtyStateProvider(
							(IOperationHistory) workbenchPart
									.getAdapter(IOperationHistory.class),
							(IUndoContext) workbenchPart
									.getAdapter(IUndoContext.class));
				}
			});
}
 
源代码8 项目: xtext-xtend   文件: WaitForRefactoringCondition.java
@Override
public boolean test() throws Exception {
  boolean _xblockexpression = false;
  {
    final IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
    IUndoableOperation _xifexpression = null;
    if (this.isRedo) {
      _xifexpression = operationHistory.getRedoOperation(this.getUndoContext());
    } else {
      _xifexpression = operationHistory.getUndoOperation(this.getUndoContext());
    }
    String _label = null;
    if (_xifexpression!=null) {
      _label=_xifexpression.getLabel();
    }
    final String label = _label;
    _xblockexpression = label.startsWith("Rename ");
  }
  return _xblockexpression;
}
 
源代码9 项目: statecharts   文件: CreateSubdiagramCommand.java
protected void executeCommand(AbstractTransactionalCommand operation) {
	IOperationHistory history = OperationHistoryFactory.getOperationHistory();
	try {
		history.execute(operation, new NullProgressMonitor(), null);
	} catch (ExecutionException e) {
		e.printStackTrace();
	}
}
 
源代码10 项目: statecharts   文件: SetEntryKindCommand.java
public Object execute(ExecutionEvent event) throws ExecutionException {
	entry = unwrap(HandlerUtil.getCurrentSelection(event));
	
	if (entry == null)
		return null;
	SetValueCommand setCommand = new SetValueCommand(new SetRequest(entry,
			SGraphPackage.Literals.ENTRY__KIND, getEntryKind()));
	IOperationHistory history = OperationHistoryFactory
			.getOperationHistory();
	try {
		history.execute(setCommand, new NullProgressMonitor(), null);
	} catch (ExecutionException e) {
		e.printStackTrace();
	}
	
	return null;
}
 
源代码11 项目: tmxeditor8   文件: AddTuHandler.java
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	TmxEditorViewer viewer = TmxEditorViewer.getInstance();
	if(viewer == null){
		return null;
	}
	TmxEditor editor = viewer.getTmxEditor();
	if(editor == null){
		return null;
	}
	String srcLang = editor.getSrcLang();
	String tgtLang = editor.getTgtLang();
	TmxTU tu = TmxEditorUtils.createTmxTu(srcLang, tgtLang);
	editor.addTu(tu);
	IOperationHistory histor = OperationHistoryFactory.getOperationHistory();
	histor.dispose(PlatformUI.getWorkbench().getOperationSupport().getUndoContext(), true, true, true);
	return null;
}
 
源代码12 项目: tmxeditor8   文件: DeleteTuHandler.java
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	TmxEditorViewer viewer = TmxEditorViewer.getInstance();
	if (viewer == null) {
		return null;
	}
	TmxEditor editor = viewer.getTmxEditor();
	if (editor == null) {
		return null;
	}
	if (editor.getTmxDataAccess().getDisplayTuCount() == 0
			|| editor.getTmxEditorImpWithNattable().getSelectedRows().length == 0) {
		OpenMessageUtils.openMessage(IStatus.INFO, Messages.getString("tmxeditor.deleteTuHandler.noSelectedMsg"));
		return null;
	}
	boolean confirm = MessageDialog.openConfirm(HandlerUtil.getActiveShell(event),
			Messages.getString("tmxeditor.deleteTuHandler.warn.msg"),
			Messages.getString("tmxeditor.deleteTuHandler.warn.desc"));
	if (!confirm) {
		return null;
	}
	editor.deleteSelectedTu();
	IOperationHistory histor = OperationHistoryFactory.getOperationHistory();
	histor.dispose(PlatformUI.getWorkbench().getOperationSupport().getUndoContext(), true, true, true);
	return null;
}
 
源代码13 项目: tmxeditor8   文件: TmxEditorViewer.java
/**
 * 关闭TmxEditor,同时关闭AbstractDataAccess
 **/
public boolean closeTmx() {
	if (tmxEditor == null) {
		return true;
	}
	if (!tmxEditor.closeTmxEditor()) {
		return false;
	}
	tmxEditor = null;
	Control[] childs = container.getChildren();
	for (Control c : childs) {
		if (c != null && !c.isDisposed()) {
			c.dispose();
		}
	}
	fireCloseEvent();
	IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
	operationHistory.dispose(getSite().getWorkbenchWindow().getWorkbench().getOperationSupport().getUndoContext(),
			true, true, true);
	setFocus();
	String title = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getText();
	String[] s = title.split("-");
	PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setText(s[0]);
	return true;
}
 
源代码14 项目: bonita-studio   文件: UndoCommandHandler.java
@Override
public boolean isEnabled() {
	final IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() ;
	if(editor != null){
		final IOperationHistory history = (IOperationHistory) editor.getAdapter(IOperationHistory.class);
		final IUndoContext context = (IUndoContext) editor.getAdapter(IUndoContext.class);
		if(history != null && context != null){
			final IUndoableOperation[] undoHistory = history.getUndoHistory(context);
               if (undoHistory != null && undoHistory.length != 0) {
                   final IUndoableOperation ctxt = undoHistory[undoHistory.length - 1];
				final String ctxtLabel = ctxt.getLabel();
                   if(ctxtLabel != null && ctxtLabel.contains("Lane")){//Avoid Exception on undo //$NON-NLS-1$
					return false ;
				} else {
					return ctxt.canUndo();
				}
			}
		} else {
			return false;
		}
	}
	return false;
}
 
源代码15 项目: xtext-eclipse   文件: EmbeddedEditorFactory.java
protected OperationHistoryListener installUndoRedoSupport(SourceViewer viewer, IDocument document, final EmbeddedEditorActions actions) {
	IDocumentUndoManager undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
	final IUndoContext context = undoManager.getUndoContext();
	IOperationHistory operationHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
	OperationHistoryListener operationHistoryListener = new OperationHistoryListener(context, new IUpdate() {
		@Override
		public void update() {
			actions.updateAction(ITextEditorActionConstants.REDO);
			actions.updateAction(ITextEditorActionConstants.UNDO);
		}
	});
	operationHistory.addOperationHistoryListener(operationHistoryListener);
	return operationHistoryListener;
}
 
源代码16 项目: xtext-eclipse   文件: LinkedEditingUndoSupport.java
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);
		}
	}
}
 
源代码17 项目: gef   文件: AbstractFXView.java
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(final Class key) {
	// Provide a default selection provider (subclasses may overwrite by
	// handling the key and returning a different implementation
	// replace with binding
	if (ISelectionProvider.class.equals(key)) {
		if (selectionProvider != null) {
			return selectionProvider;
		}
	}
	// contribute to Properties view (only created if required)
	if (IPropertySheetPage.class.equals(key)) {
		if (propertySheetPage == null) {
			propertySheetPage = createPropertySheetPage();
		}
		if (propertySheetPage != null) {
			return propertySheetPage;
		}
	}
	if (IUndoContext.class.equals(key)) {
		if (domain instanceof HistoricizingDomain) {
			return ((HistoricizingDomain) domain).getUndoContext();
		}
	}
	if (IOperationHistory.class.equals(key)) {
		if (domain instanceof HistoricizingDomain) {
			return ((HistoricizingDomain) domain).getOperationHistory();
		}
	}
	return super.getAdapter(key);
}
 
源代码18 项目: gef   文件: HistoryBasedDirtyStateProvider.java
/**
 * Creates a new {@link HistoryBasedDirtyStateProvider}.
 *
 * @param operationHistory
 *            The {@link IOperationHistory} to use.
 * @param undoContext
 *            The {@link IUndoContext} to evaluate.
 */
public HistoryBasedDirtyStateProvider(IOperationHistory operationHistory,
		IUndoContext undoContext) {
	this.operationHistory = operationHistory;
	this.undoContext = undoContext;
	if (undoContext == null) {
		throw new IllegalArgumentException(
				"WorkbenchPart needs to be adaptable to IUndoContext");
	}

	operationHistoryListener = createOperationHistoryListener();
	operationHistory.addOperationHistoryListener(operationHistoryListener);
}
 
源代码19 项目: gef   文件: HistoryBasedDirtyStateProvider.java
@Override
public void dispose() {
	// unregister operation history listener
	IOperationHistory operationHistory = getOperationHistory();
	if (operationHistory != null) {
		operationHistory
				.removeOperationHistoryListener(operationHistoryListener);
	}
	operationHistoryListener = null;
	saveLocation = null;
}
 
源代码20 项目: gef   文件: UndoablePropertySheetEntry.java
/**
 * Returns the {@link IOperationHistory} that is used by this entry. It is
 * obtained from the parent in case the entry is not a root entry.
 *
 * @return the {@link IOperationHistory} to be used.
 */
protected IOperationHistory getOperationHistory() {
	// only the root has, and is listening too, the IOperationHistory
	if (getParent() != null) {
		return ((UndoablePropertySheetEntry) getParent())
				.getOperationHistory();
	}
	return operationHistory;
}
 
源代码21 项目: gef   文件: AbstractFXEditorTests.java
/**
 * Binds a factory for the creation of
 * {@link HistoryBasedDirtyStateProvider} as
 * {@link IDirtyStateProvider}.
 */
protected void bindIDirtyStateProviderFactory() {
	binder().bind(IDirtyStateProviderFactory.class).toInstance(new IDirtyStateProviderFactory() {

		@Override
		public IDirtyStateProvider create(IWorkbenchPart workbenchPart) {
			return new HistoryBasedDirtyStateProvider(
					(IOperationHistory) workbenchPart.getAdapter(IOperationHistory.class),
					(IUndoContext) workbenchPart.getAdapter(IUndoContext.class));
		}
	});
}
 
源代码22 项目: ermasterr   文件: TestEditor.java
/**
 * The <code>AbstractTextEditor</code> implementation of this
 * <code>IWorkbenchPart</code> method may be extended by subclasses.
 * Subclasses must call <code>super.dispose()</code>.
 * <p>
 * Note that many methods may return <code>null</code> after the editor is
 * disposed.
 * </p>
 */
@Override
public void dispose() {

    if (fTitleImage != null) {
        fTitleImage.dispose();
        fTitleImage = null;
    }

    disposeDocumentProvider();

    if (fSourceViewer != null) {
        fSourceViewer = null;
    }

    if (fConfiguration != null)
        fConfiguration = null;

    final IOperationHistory history = OperationHistoryFactory.getOperationHistory();
    if (history != null) {
        if (fNonLocalOperationApprover != null)
            history.removeOperationApprover(fNonLocalOperationApprover);
        if (fLinearUndoViolationApprover != null)
            history.removeOperationApprover(fLinearUndoViolationApprover);
    }
    fNonLocalOperationApprover = null;
    fLinearUndoViolationApprover = null;

    super.dispose();
}
 
源代码23 项目: statecharts   文件: AbstractSemanticModification.java
protected void executeCommand(IUndoableOperation command, Resource resource) {
	IOperationHistory history = OperationHistoryFactory.getOperationHistory();
	try {
		history.execute(command, new NullProgressMonitor(), null);
	} catch (ExecutionException e) {
		e.printStackTrace();
	}
}
 
源代码24 项目: translationstudio8   文件: NattableUtil.java
/**
 * 添加或者取消疑问
 * @param selectedRowIds
 * @param state
 *            ;
 */
public void changIsQuestionState(List<String> selectedRowIds, String state) {
	IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
	try {
		operationHistory.execute(new NeedsReviewOperation("need-review", xliffEditor.getTable(), selectedRowIds,
				xliffEditor.getXLFHandler(), state), null, null);
	} catch (ExecutionException e) {
		LOGGER.error("", e);
		MessageDialog.openError(xliffEditor.getSite().getShell(),
				Messages.getString("utils.NattableUtil.msgTitle2"), e.getMessage());
		e.printStackTrace();
	}
}
 
源代码25 项目: translationstudio8   文件: NattableUtil.java
/**
 * 设置是否添加到记忆库
 * @param selectedRowIds
 * @param state
 *            "yes" or "no";
 */
public void changeSendToTmState(List<String> selectedRowIds, String state) {
	IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
	try {
		operationHistory.execute(new SendTOTmOperation("send-to-tm", xliffEditor.getTable(), selectedRowIds,
				xliffEditor.getXLFHandler(), state), null, null);
	} catch (ExecutionException e) {
		LOGGER.error("", e);
		MessageDialog.openError(xliffEditor.getSite().getShell(),
				Messages.getString("utils.NattableUtil.msgTitle2"), e.getMessage());
		e.printStackTrace();
	}
}
 
@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;
	}
}
 
public void runWithEvent(Event event) {
	if (viewer != null && !viewer.getTextWidget().isDisposed()) {
		// 如果跨越焦点撤销,则先撤销非焦点
		try {
			IOperationHistory history = OperationHistoryFactory.getOperationHistory();
			IUndoContext undoContext = (IUndoContext) XLIFFEditorImplWithNatTable.getCurrent().getTable()
					.getData(IUndoContext.class.getName());
			history.redo(undoContext, null, null);
			// int crossSegment = undoBean.getCrosseStep();
			// if (crossSegment > 0) {
			// history.redo(undoContext, null, null);
			// undoBean.setCrosseStep(crossSegment - 1);
			// undoBean.setSaveStatus(-1);
			// } else if (undoBean.getSaveStatus() == -1) {
			// XLIFFEditorImplWithNatTable.getCurrent().jumpToRow(undoBean.getUnSaveRow());
			// viewer.setText(undoBean.getUnSaveText());
			// undoBean.setCrosseStep(0);
			// undoBean.setSaveStatus(0);
			// } else {
			// viewer.doOperation(ITextOperationTarget.REDO);
			// }
		} catch (ExecutionException e) {
			e.printStackTrace();
		}
		System.out.println(undoBean.getCrosseStep());
		updateActionsEnableState();
		return;
	}
	if (redoAction != null) {
		redoAction.runWithEvent(event);
		return;
	}
}
 
源代码28 项目: tmxeditor8   文件: UpdateDataCommandHandler.java
@Override
protected boolean doCommand(UpdateDataCommand command) {
	IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
	try {
		UpdateDataOperation op = new UpdateDataOperation(table, bodyLayerStack, command);
		op.addContext(PlatformUI.getWorkbench().getOperationSupport().getUndoContext());
		operationHistory.execute(op, null, null);
	} catch (ExecutionException e) {
		e.printStackTrace();
	}
	return true;
}
 
源代码29 项目: tmxeditor8   文件: CellEditorGlobalActionHanlder.java
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();
		}
	}
}
 
源代码30 项目: tmxeditor8   文件: CellEditorGlobalActionHanlder.java
/**
 * 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);
}