当前位置: 首页>>代码示例>>Java>>正文


Java IUndoContext类代码示例

本文整理汇总了Java中org.eclipse.core.commands.operations.IUndoContext的典型用法代码示例。如果您正苦于以下问题:Java IUndoContext类的具体用法?Java IUndoContext怎么用?Java IUndoContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IUndoContext类属于org.eclipse.core.commands.operations包,在下文中一共展示了IUndoContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: installUndoRedoSupport

import org.eclipse.core.commands.operations.IUndoContext; //导入依赖的package包/类
protected OperationHistoryListener installUndoRedoSupport(SourceViewer viewer, IDocument document, final EmbeddedEditorActions actions) {
			IDocumentUndoManager undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
			final IUndoContext context = undoManager.getUndoContext();
			
			// XXX cp uncommented
			
//			IOperationHistory operationHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
			OperationHistoryListener operationHistoryListener = new OperationHistoryListener(context, new IUpdate() {
				public void update() {
					actions.updateAction(ITextEditorActionConstants.REDO);
					actions.updateAction(ITextEditorActionConstants.UNDO);
				}
			});
			viewer.addTextListener(new ITextListener() {
				
				public void textChanged(TextEvent event) {
					actions.updateAction(ITextEditorActionConstants.REDO);
					actions.updateAction(ITextEditorActionConstants.UNDO);
					
				}
			});
//			
//			operationHistory.addOperationHistoryListener(operationHistoryListener);
			return operationHistoryListener;
		}
 
开发者ID:cplutte,项目名称:bts,代码行数:26,代码来源:EmbeddedEditorFactory.java

示例2: undoDocumentChanges

import org.eclipse.core.commands.operations.IUndoContext; //导入依赖的package包/类
public void undoDocumentChanges() {
	final ISourceViewer viewer = editor.getInternalSourceViewer();
	try {
		editor.getSite().getWorkbenchWindow().run(false, true, new IRunnableWithProgress() {
			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
				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();
						while (undoManager.undoable()) {
							if (startingUndoOperation != null
									&& startingUndoOperation.equals(operationHistory.getUndoOperation(undoContext)))
								return;
							undoManager.undo();
						}
					}
				}
			}
		});
		syncUtil.waitForReconciler(editor);
	} catch (Exception e) {
		LOG.error(e.getMessage(), e);
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:27,代码来源:LinkedEditingUndoSupport.java

示例3: stop

import org.eclipse.core.commands.operations.IUndoContext; //导入依赖的package包/类
public void stop(BundleContext context) throws Exception {
  if (fRefactoringUndoContext != null) {
    IUndoContext workspaceContext =
        (IUndoContext) ResourcesPlugin.getWorkspace().getAdapter(IUndoContext.class);
    if (workspaceContext instanceof ObjectUndoContext) {
      ((ObjectUndoContext) workspaceContext).removeMatch(fRefactoringUndoContext);
    }
  }
  if (fgUndoManager != null) fgUndoManager.shutdown();
  final RefactoringHistoryService service = RefactoringHistoryService.getInstance();
  service.disconnect();
  if (fRefactoringHistoryListener != null)
    service.removeHistoryListener(fRefactoringHistoryListener);
  RefactoringContributionManager.getInstance().disconnect();
  super.stop(context);
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:RefactoringCorePlugin.java

示例4: executeOperation

import org.eclipse.core.commands.operations.IUndoContext; //导入依赖的package包/类
/**
 * Execute the given operation in the supplied undo context
 * Tests that the operation can be executed, 
 * that the execute result isOK() and that no ExecutionException is thrown.
 * @param operation
 * @param undoContext
 */
public static final void executeOperation(IUndoableOperation operation, IUndoContext undoContext) {
	operation.addContext(undoContext);
	TestCase.assertTrue("Operation can't execute.", operation.canExecute());
	try {
		IOperationHistory history = OperationHistoryFactory.getOperationHistory();
		IStatus result = history.execute(operation, null, null);
		TestCase.assertTrue("failed to execute: " + operation.getLabel(), result.isOK());
	} catch (ExecutionException ee) {
		TestCase.fail("failed to execute");
	}
	TestCase.assertFalse(operation.canExecute());
	IUndoContext[] contexts = operation.getContexts();
	if ((contexts != null) && (contexts.length > 0)) { 
		// Operations that don't accept contexts don't need to be undoable.
		// An example such operation is ClipboardCopyOperation, 
		// or any other AbstractEnsembleDoableOperation
		TestCase.assertTrue("Operation is not undoable.", operation.canUndo());
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:27,代码来源:UndoableOperationTestUtil.java

示例5: toggleScheduledness

import org.eclipse.core.commands.operations.IUndoContext; //导入依赖的package包/类
public static void toggleScheduledness(EPlanElement element) {
	IPlanEditApprover registry = PlanEditApproverRegistry.getInstance();
	if (!registry.canModify(element)) {
		return;
	}
	TriState oldValue = SpifePlanUtils.getScheduled(element);
	boolean value = (oldValue == TriState.FALSE);
	ScheduledOperation op = new ScheduledOperation(element, value);
	IUndoContext undoContext = TransactionUtils.getUndoContext(element);
	op.addContext(undoContext);
	try {
		OperationHistoryFactory.getOperationHistory().execute(op, null, null);
	} catch (ExecutionException e) {
		// should never occur
		LogUtil.error(e);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:18,代码来源:ScheduledOperation.java

示例6: modify

import org.eclipse.core.commands.operations.IUndoContext; //导入依赖的package包/类
@Override
public void modify(ParameterFacet<Date> parameter, Object date, IUndoContext undoContext) {
	Date newStart = (Date)date;
	EPlanElement planElement = parameter.getElement();
	EPlan plan = EPlanUtils.getPlan(planElement);
	TemporalMember temporal = planElement.getMember(TemporalMember.class);
	Date startTime = temporal.getStartTime();
	IPlanModifier modifier = PlanModifierMember.get(plan).getModifier();
	if (modifier == null) {
		ParameterFacet<Date> facet = new ParameterFacet<Date>(parameter.getObject(), START_TIME_FEATURE, startTime);
		super.modify(facet, newStart, undoContext);
		return;
	}
	TemporalExtentsCache cache = new TemporalExtentsCache(plan);
	Map<EPlanElement, TemporalExtent> changedTimes = modifier.moveToStart(planElement, newStart, cache);
	IUndoableOperation operation = new SetExtentsOperation("set start times", plan, changedTimes, cache);
	operation = EMFUtils.addContributorOperations(operation, temporal, START_TIME_FEATURE, startTime, newStart);
	CommonUtils.execute(operation, undoContext);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:20,代码来源:StartTimeParameterColumn.java

示例7: doExecute

import org.eclipse.core.commands.operations.IUndoContext; //导入依赖的package包/类
@Override
public void doExecute() {
	TemporalMember member = (TemporalMember)getOwner();
	if ((member.getStartTime() == null) && (member.getEndTime() == null)) {
		operation = new FeatureTransactionChangeOperation("update duration", member, getFeature(), value);
	} else {
		operation = TemporalModifier.getInstance().set(member, getFeature(), value);
	}
	IUndoContext undoContext = TransactionUtils.getUndoContext(member);
	if (undoContext != null) {
		operation.addContext(undoContext);
	}
	try {
		operation.execute(MONITOR, null);
	} catch (ExecutionException e) {
		LogUtil.error(e);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:19,代码来源:TemporalMemberItemProvider.java

示例8: undo

import org.eclipse.core.commands.operations.IUndoContext; //导入依赖的package包/类
@Override
public IStatus undo(IUndoContext context, IProgressMonitor monitor,
		IAdaptable info) throws ExecutionException {
	Assert.isNotNull(context);
	IUndoableOperation operation = getUndoOperation(context);

	// info if there is no operation
	if (operation == null) {
		return IOperationHistory.NOTHING_TO_UNDO_STATUS;
	}

	// error if operation is invalid
	if (!operation.canUndo()) {
		if (DEBUG_OPERATION_HISTORY_UNEXPECTED) {
			Tracing.printTrace("OPERATIONHISTORY", //$NON-NLS-1$
					"Undo operation not valid - " + operation); //$NON-NLS-1$
		}
		return IOperationHistory.OPERATION_INVALID_STATUS;
	}

	return doUndo(monitor, info, operation);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:23,代码来源:DefaultOperationHistory.java

示例9: editOnActivate

import org.eclipse.core.commands.operations.IUndoContext; //导入依赖的package包/类
@Override
public boolean editOnActivate(T facet, IUndoContext undoContext, TreeItem item, int index) {
	Object feature = itemPropertyDescriptor.getFeature(facet);
	if (feature instanceof EAttribute) {
		EDataType eDataType = ((EAttribute)feature).getEAttributeType();
		if (eDataType != null
				&& (eDataType.getInstanceClass() == Boolean.class
					|| eDataType.getInstanceClass() == Boolean.TYPE)) {
			Boolean value = (Boolean) getValue(facet);
			boolean newValue = (value == null ? true : !value);
			modify(facet, newValue, undoContext);
			return true;
		}
	}
	return false;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:EMFTreeTableColumn.java

示例10: modify

import org.eclipse.core.commands.operations.IUndoContext; //导入依赖的package包/类
@Override
public void modify(T facet, Object value, IUndoContext undoContext) {
	IUndoableOperation operation = new PropertyDescriptorUpdateOperation("Set value", facet, itemPropertyDescriptor, value);
	operation = EMFDetailUtils.addContributorOperations(operation, facet, itemPropertyDescriptor, value);
	operation.addContext(undoContext);
	IWorkbenchOperationSupport operationSupport = PlatformUI.getWorkbench().getOperationSupport();
	IOperationHistory operationHistory = operationSupport.getOperationHistory();
	try {
		IStatus execute = operationHistory.execute(operation, null, null);
		if(execute.matches(IStatus.ERROR)) {
			throw new ExecutionException(execute.getMessage());
		}
	} catch (ExecutionException e) {
		LogUtil.error(e);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:EMFTreeTableColumn.java

示例11: ConstraintDialog

import org.eclipse.core.commands.operations.IUndoContext; //导入依赖的package包/类
/**
 * Create a constraint dialog that will create a new constraint between the two plan elements.
 * The dialog is set up so that it is possible to constrain A to be before, but not vice versa. 
 * 
 * @param parent
 * @param undoContext
 * @param elementA
 * @param elementB
 */
public ConstraintDialog(Shell parent, IUndoContext undoContext, EPlanElement elementA, EPlanElement elementB) {
	super(parent);
	setShellStyle(SWT.DIALOG_TRIM | getDefaultOrientation());
	setBlockOnOpen(false);
	if (undoContext == null) {
		throw new NullPointerException("null undo context");
	}
	if (elementA == null) {
		throw new NullPointerException("null elementA");
	}
	if (elementB == null) {
		throw new NullPointerException("null elementB");
	}
	this.undoContext = undoContext;
	this.elementA = elementA;
	this.elementB = elementB;
	this.oldConstraint = null;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:28,代码来源:ConstraintDialog.java

示例12: execute

import org.eclipse.core.commands.operations.IUndoContext; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) {
	ISelection selection = HandlerUtil.getCurrentSelection(event);
	EList<EPlanElement> elements = getSelectedTemporalElements(selection);
	ECollections.sort(elements, TemporalChainUtils.CHAIN_ORDER);
	EPlan plan = EPlanUtils.getPlan(elements.get(0));
	Map<EPlanElement, Date> startTimes = getChangedTimes(elements);
	// create moves for children			
	IPlanModifier modifier = PlanModifierMember.get(plan).getModifier();
	TemporalExtentsCache cache = new TemporalExtentsCache(plan);
	Map<EPlanElement, TemporalExtent> changedTimes = new LinkedHashMap<EPlanElement, TemporalExtent>();
	for (EPlanElement element: startTimes.keySet()) {
		Date start = startTimes.get(element);
		Map<EPlanElement, TemporalExtent> extents = modifier.moveToStart(element, start, cache);
		changedTimes.putAll(extents);
		if (!extents.containsKey(element)) {
			TemporalMember member = element.getMember(TemporalMember.class);
			TemporalExtent extent = member.getExtent();
			changedTimes.put(element, extent.moveToStart(start));
		}
	}
	IUndoableOperation op = new SetExtentsOperation(actionVerb, plan, changedTimes, cache);
	IUndoContext undoContext = TransactionUtils.getUndoContext(plan);
	CommonUtils.execute(op, undoContext);
	return null;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:27,代码来源:DrudgerySavingHandler.java

示例13: createPeriodicTemporalConstraintOperation

import org.eclipse.core.commands.operations.IUndoContext; //导入依赖的package包/类
private TemporalBoundEditOperation createPeriodicTemporalConstraintOperation(EPlanElement planElement, Amount<Duration> offset, IUndoContext undoContext) {
	ConstraintsMember facet = planElement.getMember(ConstraintsMember.class, true);
	Set<PeriodicTemporalConstraint> oldConstraints = getRelevantConstraints(facet);
	PeriodicTemporalConstraint newConstraint = null;
	for (PeriodicTemporalConstraint oldConstraint : oldConstraints) {
		Amount<Duration> time = getRelevantPartOfConstraint(oldConstraint);
		if (time.compareTo(offset) == 0) {
			return null; // same as an existing pin
		}
	}			
	newConstraint = createPeriodicTemporalConstraint(planElement, offset);
	TemporalBoundEditOperation operation = new TemporalBoundEditOperation(getEarliestOrLatestName(), planElement, oldConstraints, newConstraint);
	if (undoContext != null) {
		operation.addContext(undoContext);
	}
	operation.addContext(undoContext);
	return operation;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:19,代码来源:TimeOfDayConstraintHandler.java

示例14: execute

import org.eclipse.core.commands.operations.IUndoContext; //导入依赖的package包/类
public static <T> void execute(String label, EcoreEList<T> list, List<T> objects) {
	boolean containsOne = false;
	for (T item : list) {
		if (objects.contains(item)) {
			containsOne = true;
			break;
		}
	}
	if (!containsOne) {
		return;
	}
	IUndoableOperation op = new FeatureTransactionRemoveAllOperation<T>(label, list, objects);
	IUndoContext context = TransactionUtils.getUndoContext(list);
	if (context != null) {
		op.addContext(context);
		try {
	        IOperationHistory history = OperationHistoryFactory.getOperationHistory();
	    	history.execute(op, null, null);
	    } catch (Exception e) {
	    	LogUtil.error("execute", e);
	    }
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:24,代码来源:FeatureTransactionRemoveAllOperation.java

示例15: setLimit

import org.eclipse.core.commands.operations.IUndoContext; //导入依赖的package包/类
@Override
public void setLimit(IUndoContext context, int limit) {
	Assert.isTrue(limit >= 0);
	/*
	 * The limit checking methods interpret a null context as a global limit
	 * to be enforced. We do not wish to support a global limit in this
	 * implementation, so we throw an exception for a null context. The rest
	 * of the implementation can handle a null context, so subclasses can
	 * override this if a global limit is desired.
	 */
	Assert.isNotNull(context);
	limits.put(context, new Integer(limit));
	synchronized (undoRedoHistoryLock) {
		forceUndoLimit(context, limit);
		forceRedoLimit(context, limit);
	}

}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:19,代码来源:DefaultOperationHistory.java


注:本文中的org.eclipse.core.commands.operations.IUndoContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。