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


Java OperationHistoryFactory类代码示例

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


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

示例1: undoDocumentChanges

import org.eclipse.core.commands.operations.OperationHistoryFactory; //导入依赖的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

示例2: execute

import org.eclipse.core.commands.operations.OperationHistoryFactory; //导入依赖的package包/类
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;
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:18,代码来源:SetEntryKindCommand.java

示例3: execute

import org.eclipse.core.commands.operations.OperationHistoryFactory; //导入依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
	view = unwrap(HandlerUtil.getCurrentSelection(event));

	TransactionalEditingDomain editingDomain = TransactionUtil
			.getEditingDomain(view);
	ToggleCommand toggleCommand = new ToggleCommand(editingDomain, view);

	try {
		OperationHistoryFactory.getOperationHistory().execute(
				toggleCommand, new NullProgressMonitor(), null);
	} catch (ExecutionException e) {
		e.printStackTrace();
	}

	return null;
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:17,代码来源:ToggleSubRegionLayoutCommand.java

示例4: executeOperation

import org.eclipse.core.commands.operations.OperationHistoryFactory; //导入依赖的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.OperationHistoryFactory; //导入依赖的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: createAddOperation

import org.eclipse.core.commands.operations.OperationHistoryFactory; //导入依赖的package包/类
private void createAddOperation(PlanEditorModel model, final EPlanElement parent, final EPlanElement child) {
	IStructureModifier modifier = PlanStructureModifier.INSTANCE;
	PlanTransferable transferable = new PlanTransferable();
	transferable.setPlanElements(Collections.singletonList(child));
	IStructureLocation location = modifier.getInsertionLocation(transferable, new StructuredSelection(parent), InsertionSemantics.ON);
	AddOperation operation = new PlanAddOperation(transferable, modifier, location);
	IUndoContext undoContext = model.getUndoContext();
	operation.addContext(undoContext);
	try {
		IOperationHistory history = OperationHistoryFactory.getOperationHistory();
		IStatus status = history.execute(operation, null, null);
		if (status instanceof JobOperationStatus) {
			((JobOperationStatus) status).getJob().join();
		}
	} catch (Exception e) {
		trace.error("OneOfEachAction.createAddGroupOperation:operation", e);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:19,代码来源:OneOfEachAction.java

示例7: modify

import org.eclipse.core.commands.operations.OperationHistoryFactory; //导入依赖的package包/类
@Override
public void modify(DataPoint oldDataPoint, Object value, IUndoContext undoContext) {
	if (value instanceof Date) {
		DataPoint newDataPoint = JScienceFactory.eINSTANCE.createEDataPoint((Date) value, oldDataPoint.getValue());
		SwapProfileDataPointOperation op = new SwapProfileDataPointOperation(profile, oldDataPoint, newDataPoint);
		if (undoContext != null) {
			op.addContext(undoContext);
		}
		IOperationHistory history = OperationHistoryFactory.getOperationHistory();
		try {
			history.execute(op, null, null);
		} catch (ExecutionException e) {
			LogUtil.error(e);
		}
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:ProfileDataPointColumnProvider.java

示例8: setCalculatedVariable

import org.eclipse.core.commands.operations.OperationHistoryFactory; //导入依赖的package包/类
private void setCalculatedVariable(TemporalMember target, CalculatedVariable calculatedVariable) {
	Object oldValue = target.eGet(CALCULATED_VARIABLE_FEATURE);
	if (oldValue == calculatedVariable) {
		if (oldValue != CalculatedVariable.END) {
			calculatedVariable = CalculatedVariable.END;
		} else if (TemporalMemberUtils.hasDurationFormula(target)) {
			calculatedVariable = CalculatedVariable.START;
		} else {
			calculatedVariable = CalculatedVariable.DURATION;
		}
	}
	IUndoableOperation operation = new FeatureTransactionChangeOperation("Set calculated variable", target, CALCULATED_VARIABLE_FEATURE, oldValue, calculatedVariable);
	operation.addContext(EMFUtils.getUndoContext(target));
	IOperationHistory history = OperationHistoryFactory.getOperationHistory();
	try {
		history.execute(operation, null, null);
	} catch (ExecutionException e) {
		LogUtil.error("failed to set calculated variable", e);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:21,代码来源:TemporalDetailProvider.java

示例9: addVisibleLabel

import org.eclipse.core.commands.operations.OperationHistoryFactory; //导入依赖的package包/类
private void addVisibleLabel(IFigure figure) {
	visibleLabel = new Label();
	visibleLabel.setBorder(new SimpleRaisedBorder());
	visibleLabel.addMouseListener(new MouseListener.Stub() {
		@Override
		public void mousePressed(MouseEvent me) {
			EPlanElement node = getModel();
			TriState oldValue = SpifePlanUtils.getVisible(node);
			if (!PlanEditApproverRegistry.getInstance().canModify(node)) {
				return;
			}
			try {
				VisibleOperation op = new VisibleOperation(node, oldValue == TriState.FALSE);
				op.addContext(TransactionUtils.getUndoContext(node));
				IOperationHistory history = OperationHistoryFactory.getOperationHistory();
				history.execute(op, null, null);
			} catch (Exception e) {
				trace.error(e.getMessage(), e);
			}
		}
	});
	updateVisibleVisual();
	figure.add(visibleLabel);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:25,代码来源:PlanElementRowEditPart.java

示例10: runImpl

import org.eclipse.core.commands.operations.OperationHistoryFactory; //导入依赖的package包/类
protected void runImpl(MultiPagePlanEditor editor, EPlan plan) {
	EPlanElement parent = getSelection(editor);
	if (parent==null){
		parent=plan;
	}
	List<EPlanChild> childList = new ArrayList<EPlanChild>();
	for (EPlanChild child : parent.getChildren()) {
		childList.add(child);
	}
	Collections.sort(childList, new ScheduledActivtyComparator());
	IStructureModifier modifier = PlanStructureModifier.INSTANCE;
	PlanTransferable transferable = new PlanTransferable();
	transferable.setPlanElements(childList);
	IStructureLocation location = modifier.getInsertionLocation(transferable, new StructuredSelection(parent), InsertionSemantics.ON);
	PlanEditorModel model = editor.getPlanEditorModel();
	MoveOperation operation = new PlanMoveOperation(transferable, modifier, location);
	IUndoContext undoContext = model.getUndoContext();
	operation.addContext(undoContext);
	try {
		IOperationHistory history = OperationHistoryFactory.getOperationHistory();
		history.execute(operation, null, null);
	} catch (Exception e) {
		LogUtil.error(OrderEventsAscendingHandler.class.getName(), e);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:26,代码来源:OrderEventsAscendingHandler.java

示例11: doSetValue

import org.eclipse.core.commands.operations.OperationHistoryFactory; //导入依赖的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);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:23,代码来源:UndoableObservableValue.java

示例12: execute

import org.eclipse.core.commands.operations.OperationHistoryFactory; //导入依赖的package包/类
/**
 * Execute the operation in the undo context, in a job.
 * 
 * If the operation is an IDisplayOperation, and both the widget and site are provided,
 * then the job will be created as a DisplayOperationJob.
 * 
 * If the operation can not be executed, it will be disposed.
 * 
 * @param operation
 * @param undoContext
 * @param widget
 * @param site
 */
public static void execute(final IUndoableOperation operation, IUndoContext undoContext, final Widget widget, final IWorkbenchSite site) {
	IOperationHistory history = OperationHistoryFactory.getOperationHistory();
	IAdaptable adaptable = null;
	if ((operation instanceof IDisplayOperation) && (widget != null) && (site != null)) {
		IDisplayOperation displayOperation = (IDisplayOperation) operation;
		adaptable = new IDisplayOperation.Adaptable(displayOperation, widget, site);
	}
	if (undoContext != null) {
		operation.addContext(undoContext);
	}
	try {
		history.execute(operation, null, adaptable);
	} catch (ExecutionException e) {
		// should never occur
		LogUtil.error(e);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:31,代码来源:WidgetUtils.java

示例13: cutPasteElements

import org.eclipse.core.commands.operations.OperationHistoryFactory; //导入依赖的package包/类
/**
 * @param plan
 * @param selectedElements
 * @param targetElements
 * @param assertPostconditions
 */
private void cutPasteElements(final OperationTestPlanRecord plan, final EPlanElement[] selectedElements, final EPlanElement[] targetElements, Runnable assertPostconditions) {
	final IStructuredSelection selection = new StructuredSelection(selectedElements);
	final IStructureModifier modifier = PlanStructureModifier.INSTANCE;
	ITransferable transferable = modifier.getTransferable(selection);
	IUndoableOperation cut = new PlanClipboardCutOperation(transferable, modifier);
	cut.addContext(TransactionUtils.getUndoContext(plan.plan));
	// cut
	try {
		IOperationHistory history = OperationHistoryFactory.getOperationHistory();
		IStatus result = history.execute(cut, null, null);
		assertTrue("failed to execute: " + cut.getLabel(), result.isOK());
	} catch (ExecutionException ee) {
		fail("failed to execute");
	}

	final IStructuredSelection targetSelection = new StructuredSelection(targetElements);
	IUndoableOperation paste = new PlanClipboardPasteOperation(targetSelection, modifier);
	testUndoableOperation(plan.plan, paste, assertPostconditions);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:26,代码来源:TestCutPasteOperation.java

示例14: copyPasteElements

import org.eclipse.core.commands.operations.OperationHistoryFactory; //导入依赖的package包/类
/**
 * @param plan
 * @param selectedElements
 * @param targetElements
 * @param assertPostconditions
 */
private void copyPasteElements(final OperationTestPlanRecord plan, final EPlanElement[] selectedElements, final EPlanElement[] targetElements, final PasteOperationRunnable assertPostconditions) {
	final IStructuredSelection selection = new StructuredSelection(selectedElements);
	final IStructureModifier modifier = PlanStructureModifier.INSTANCE;
	ITransferable transferable = modifier.getTransferable(selection);
	IUndoableOperation copy = new ClipboardCopyOperation(transferable, modifier);

	// copy
	try {
		IOperationHistory history = OperationHistoryFactory.getOperationHistory();
		history.execute(copy, null, null);
	} catch (ExecutionException ee) {
		fail("failed to execute");
	}

	final IStructuredSelection targetSelection = new StructuredSelection(targetElements);
	final PlanClipboardPasteOperation paste = new PlanClipboardPasteOperation(targetSelection, modifier);
	
	testUndoableOperation(plan.plan, paste, 
			new Runnable() {
				@Override
				public void run() {
					assertPostconditions.run(paste);
				}
			});
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:32,代码来源:TestCopyPasteOperation.java

示例15: execute

import org.eclipse.core.commands.operations.OperationHistoryFactory; //导入依赖的package包/类
public static <T> void execute(String label, EcoreEList<T> list, T object) {
	if (list.getEStructuralFeature().isUnique() && list.contains(object)) {
		return;
	}
	IUndoableOperation op = new FeatureTransactionAddOperation<T>(label, list, object);
	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,代码行数:17,代码来源:FeatureTransactionAddOperation.java


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