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


Java IUndoableOperation类代码示例

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


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

示例1: performUndo

import org.eclipse.core.commands.operations.IUndoableOperation; //导入依赖的package包/类
public void performUndo(IValidationCheckResultQuery query, IProgressMonitor pm)
    throws CoreException {
  IUndoableOperation undo =
      fOperationHistory.getUndoOperation(RefactoringCorePlugin.getUndoContext());
  UndoableOperation2ChangeAdapter changeOperation = getUnwrappedOperation(undo);
  if (changeOperation == null)
    throw new CoreException(
        new Status(
            IStatus.ERROR,
            RefactoringCorePlugin.getPluginId(),
            IStatus.ERROR,
            RefactoringCoreMessages.UndoManager2_no_change,
            null));
  if (query == null) query = new NullQuery();
  try {
    fOperationHistory.undoOperation(undo, pm, new QueryAdapter(query));
  } catch (ExecutionException e) {
    handleException(e);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:UndoManager2.java

示例2: performRedo

import org.eclipse.core.commands.operations.IUndoableOperation; //导入依赖的package包/类
public void performRedo(IValidationCheckResultQuery query, IProgressMonitor pm)
    throws CoreException {
  IUndoableOperation redo =
      fOperationHistory.getRedoOperation(RefactoringCorePlugin.getUndoContext());
  UndoableOperation2ChangeAdapter changeOperation = getUnwrappedOperation(redo);
  if (changeOperation == null)
    throw new CoreException(
        new Status(
            IStatus.ERROR,
            RefactoringCorePlugin.getPluginId(),
            IStatus.ERROR,
            RefactoringCoreMessages.UndoManager2_no_change,
            null));
  if (query == null) query = new NullQuery();
  try {
    fOperationHistory.redoOperation(redo, pm, new QueryAdapter(query));
  } catch (ExecutionException e) {
    handleException(e);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:UndoManager2.java

示例3: getUndoApproval

import org.eclipse.core.commands.operations.IUndoableOperation; //导入依赖的package包/类
private IStatus getUndoApproval(IUndoableOperation operation,
		IAdaptable info) {

	final Object[] approverArray = approvers.getListeners();

	for (int i = 0; i < approverArray.length; i++) {
		IOperationApprover approver = (IOperationApprover) approverArray[i];
		IStatus approval = approver.proceedUndoing(operation, this, info);
		if (!approval.isOK()) {
			if (DEBUG_OPERATION_HISTORY_APPROVAL) {
				Tracing.printTrace("OPERATIONHISTORY", //$NON-NLS-1$
						"Undo not approved by " + approver //$NON-NLS-1$
								+ "for operation " + operation //$NON-NLS-1$
								+ " with status " + approval); //$NON-NLS-1$
			}
			return approval;
		}
	}
	return Status.OK_STATUS;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:21,代码来源:DefaultOperationHistory.java

示例4: executeExpansionOperation

import org.eclipse.core.commands.operations.IUndoableOperation; //导入依赖的package包/类
public static void executeExpansionOperation(EPlanElement element, boolean expanded) {
	CommonMember member = element.getMember(CommonMember.class);
	String action = (expanded ? "expanded" : "collapsed");
	IUndoableOperation operation = new FeatureTransactionChangeOperation(action + " " + getElementNameForDisplay(element), member, PlanPackage.Literals.COMMON_MEMBER__EXPANDED, expanded);
	try {
		InternalTransaction existingTransaction = null;
		TransactionalEditingDomain te = TransactionUtils.getDomain(element);
		if (te instanceof FixedTransactionEditingDomain) {
			FixedTransactionEditingDomain domain = (FixedTransactionEditingDomain) te;
			existingTransaction = domain.getThreadTransaction();
		};
		if (existingTransaction != null && !existingTransaction.isReadOnly()) {
			LogUtil.warn("There is an existing transaction executing so the expansion operation cannot be executed at this point");
			return;
		}				
		operation.execute(new NullProgressMonitor(), null);
	} catch (ExecutionException e) {
		LogUtil.error(e);
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:21,代码来源:PlanUtils.java

示例5: modify

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

示例6: getExecuteApproval

import org.eclipse.core.commands.operations.IUndoableOperation; //导入依赖的package包/类
private IStatus getExecuteApproval(IUndoableOperation operation,
		IAdaptable info) {

	final Object[] approverArray = approvers.getListeners();

	for (int i = 0; i < approverArray.length; i++) {
		if (approverArray[i] instanceof IOperationApprover2) {
			IOperationApprover2 approver = (IOperationApprover2) approverArray[i];
			IStatus approval = approver.proceedExecuting(operation, this,
					info);
			if (!approval.isOK()) {
				if (DEBUG_OPERATION_HISTORY_APPROVAL) {
					Tracing.printTrace("OPERATIONHISTORY", //$NON-NLS-1$
							"Execute not approved by " + approver //$NON-NLS-1$
									+ "for operation " + operation //$NON-NLS-1$
									+ " with status " + approval); //$NON-NLS-1$
				}
				return approval;
			}
		}
	}
	return Status.OK_STATUS;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:24,代码来源:DefaultOperationHistory.java

示例7: createMoveSuggestion

import org.eclipse.core.commands.operations.IUndoableOperation; //导入依赖的package包/类
/**
 * Suggest moving the element's timepoint to the suggestedTime,
 * where oldExtent is the old extent of the element, or null if none.
 * 
 * @param element
 * @param timepoint
 * @param suggestedTime
 * @param oldExtent
 * @return
 */
protected Suggestion createMoveSuggestion(EPlanElement element, Timepoint timepoint,
		Date suggestedTime, TemporalExtent oldExtent) {
	String description = "Move the " + TemporalPrinter.getText(ConstraintUtils.createConstraintPoint(element, timepoint))
	                   + " to " + DATE_STRINGIFIER.getDisplayString(suggestedTime);
	EPlan plan = EPlanUtils.getPlan(element);
	TemporalExtentsCache temporalExtentsCache = new TemporalExtentsCache(plan);
	IPlanModifier modifier = PlanModifierMember.get(plan).getModifier();
	TemporalExtentsCache cache = new TemporalExtentsCache(plan);
	Map<EPlanElement, TemporalExtent> changedTimes;
	if (timepoint == Timepoint.START) {
		changedTimes = modifier.moveToStart(element, suggestedTime, cache);
	} else {
		changedTimes = modifier.moveToEnd(element, suggestedTime, cache);
	}
	String operationDescription = "move the " + TemporalPrinter.getText(ConstraintUtils.createConstraintPoint(element, timepoint));
	IUndoableOperation operation = new SetExtentsOperation(operationDescription, plan, changedTimes, temporalExtentsCache);
	ImageDescriptor icon = ConstraintsPlugin.getImageDescriptor("icons/move_later.png");
	if ((oldExtent != null) && suggestedTime.before(oldExtent.getTimepointDate(timepoint))) {
		icon = ConstraintsPlugin.getImageDescriptor("icons/move_earlier.png");
	}
	return new Suggestion(icon, description, operation);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:33,代码来源:TemporalViolation.java

示例8: undo

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

import org.eclipse.core.commands.operations.IUndoableOperation; //导入依赖的package包/类
private void testCuttingActivities(final ChainTestPlan plan, final EPlanElement[] planElementsToCut) {
	ISelection selection = new StructuredSelection(planElementsToCut);
	IStructureModifier modifier = PLAN_STRUCTURE_MODIFIER;
	ITransferable transferable = modifier.getTransferable(selection);
	IUndoableOperation operation = new PlanClipboardCutOperation(transferable, modifier);
	final Runnable postcondition1 = new RemovingChainActivitiesPostconditionRunnable("cut", plan, planElementsToCut);
	final Runnable postcondition2 = new ClipboardContentsPostconditionRunnable(planElementsToCut, false);
	testUndoableOperation(plan.plan, operation, new Runnable() {
		@Override
		public void run() {
			postcondition1.run();
			postcondition2.run();
		}
	});
	plan.clearHistory();
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:TestChainCuts.java

示例10: setCalculatedVariable

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

示例11: createRemoveConstraintSuggestion

import org.eclipse.core.commands.operations.IUndoableOperation; //导入依赖的package包/类
private Suggestion createRemoveConstraintSuggestion() {
	IUndoableOperation operation = null;
	if (constraint instanceof ProfileConstraint) {
		EcoreEList<ProfileConstraint> currentConstraints = (EcoreEList)target.getMember(ProfileMember.class).getConstraints();
		operation = new FeatureTransactionRemoveOperation("Remove Profile Constraint", currentConstraints, constraint);
	} else if (constraint instanceof BinaryTemporalConstraint) {
		operation = new DeleteTemporalRelationOperation((BinaryTemporalConstraint)constraint);
	} else if (constraint instanceof PeriodicTemporalConstraint) {
		operation = new DeleteTemporalBoundOperation((PeriodicTemporalConstraint)constraint);
	} else if (constraint instanceof TemporalChain) {
		operation = new UnchainOperation(((TemporalChain)constraint).getElements());
	}
	if (operation != null) {
		return new Suggestion(UPDATE_ACTIVITY_ICON, "Remove Constraint from Plan", operation);
	}
	return null;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:18,代码来源:PlanDiffViolation.java

示例12: createToggleWaiveSuggestion

import org.eclipse.core.commands.operations.IUndoableOperation; //导入依赖的package包/类
protected Suggestion createToggleWaiveSuggestion(String objectName, IWaivable waivable) {
	String waiverRationale = waivable.getWaiverRationale();
	String description;
	IUndoableOperation operation;
	ImageDescriptor icon;
	if (waiverRationale != null) {
		description = "Unwaive the " + objectName;
		operation = new RemoveWaiverOperation(description, waivable);
		icon = null;
	} else {
		description = "Waive the " + objectName;
		operation = new CreateWaiverOperation(description, waivable);
		icon = WAIVE_ICON;
	}
	return new Suggestion(icon, description, operation);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:Violation.java

示例13: historyNotification

import org.eclipse.core.commands.operations.IUndoableOperation; //导入依赖的package包/类
@Override
	public void historyNotification(OperationHistoryEvent event) {
		
		IUndoableOperation op = event.getOperation();
		String typeString = decodeEventType(event.getEventType());
//		System.out.println("type='"+typeString+"' operation='"+op+"' of type '"+op.getClass().getName()+"' e="+op.canExecute()+" u="+op.canUndo()+" r="+op.canRedo());
//		for(IUndoContext c : op.getContexts()) {
//			System.out.println("\t"+c.getLabel());
//		}
		
		switch(event.getEventType()) {
			case OperationHistoryEvent.OPERATION_ADDED:
			case OperationHistoryEvent.OPERATION_CHANGED:
			case OperationHistoryEvent.OPERATION_REMOVED:
			case OperationHistoryEvent.ABOUT_TO_EXECUTE:
			case OperationHistoryEvent.ABOUT_TO_REDO:
			case OperationHistoryEvent.ABOUT_TO_UNDO:
				break;
			default:
				EnsembleUsageLogger.logUsage(op.getLabel() + " - " + typeString + "\n" + op.toString());
		}
		
	}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:24,代码来源:OperationHistoryMonitor.java

示例14: run

import org.eclipse.core.commands.operations.IUndoableOperation; //导入依赖的package包/类
@Override
public void run(IAction action) {
	IWorkbench workbench = PlatformUI.getWorkbench();
	PlanEditorModel model = PlanEditorModelRegistry.getCurrent(workbench);
	EPlan plan = null;
	if (model != null) {
		plan = model.getEPlan();
	}
	if (model == null || plan == null) {
		LogUtil.error("Could not retrieve the current plan.");
		return;
	}
	// Delete the selected profiles
	ProfileTreeView profileTreeView = (ProfileTreeView)view;
	PlanProfileTreePage planProfileTreePage = (PlanProfileTreePage) profileTreeView.getCurrentPage();
	if (planProfileTreePage == null) {
		LogUtil.error("Could not retrieve current PlanProfileTreePage.");
		return;
	}
	// SPF-10328 -- Changed the call from removeRows to getSelectedProfiles as .condition files
	// should not be affected until the plan editor is saved in order for undo to work properly
	List<Profile> removedProfileList = planProfileTreePage.getSelectedProfiles();
	// Set the operation for undo/redo functionality
	final IUndoableOperation op = new RemoveProfileOperation(plan, removedProfileList);
	CommonUtils.execute(op, model.getUndoContext());
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:27,代码来源:DeleteProfileMemberAction.java

示例15: modify

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


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