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


Java CommandResult.newErrorCommandResult方法代码示例

本文整理汇总了Java中org.eclipse.gmf.runtime.common.core.command.CommandResult.newErrorCommandResult方法的典型用法代码示例。如果您正苦于以下问题:Java CommandResult.newErrorCommandResult方法的具体用法?Java CommandResult.newErrorCommandResult怎么用?Java CommandResult.newErrorCommandResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.gmf.runtime.common.core.command.CommandResult的用法示例。


在下文中一共展示了CommandResult.newErrorCommandResult方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: modify

import org.eclipse.gmf.runtime.common.core.command.CommandResult; //导入方法依赖的package包/类
/**
 * Executes the modification in a transactional command.
 */
public void modify() {
	if (! isApplicable()) throw new IllegalStateException("Modification " + getClass().getSimpleName() + " is not executable.");
	
	final EObject semanticObject = getTargetView().getElement();
	AbstractTransactionalCommand refactoringCommand = new AbstractTransactionalCommand(
			TransactionUtil.getEditingDomain(semanticObject), getClass().getName(), Collections.EMPTY_LIST) {
		@Override
		protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
				throws ExecutionException {
			try {
				AbstractSemanticModification.this.execute(semanticObject, getTargetView());
			} catch (Exception ex) {
				ex.printStackTrace();
				return CommandResult.newErrorCommandResult(ex);
			}
			return CommandResult.newOKCommandResult();
		}
	};
	executeCommand(refactoringCommand, semanticObject.eResource());
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:24,代码来源:AbstractSemanticModification.java

示例2: getAfterConfigureCommand

import org.eclipse.gmf.runtime.common.core.command.CommandResult; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected ICommand getAfterConfigureCommand(final ConfigureRequest request) {

	ICommand command = new ConfigureElementCommand(request) {

		@Override
		protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
			EObject elementToConfigure = request.getElementToConfigure();
			if (!(elementToConfigure instanceof Class)) {
				return CommandResult.newErrorCommandResult("Element to configure was not a Class: " + elementToConfigure);//$NON-NLS-1$
			}
			
			// retrieve stereotype 
			Stereotype st = ((Class)elementToConfigure).getAppliedStereotype(EXTLIBRARY_PERIODICAL);
			if (st == null) {
				return CommandResult.newErrorCommandResult("Element to configure did not have required stereotype"); //$NON-NLS-1$
			}
			((Class) elementToConfigure).setValue(st, ISSUES_PER_YEAR, 12);

			// change name
			String name = NamedElementUtil.getDefaultNameWithIncrementFromBase(MONTHLY, elementToConfigure.eContainer().eContents());
			((Class) elementToConfigure).setName(name);

			return CommandResult.newOKCommandResult(elementToConfigure);
		}
	};

	return command.compose(super.getAfterConfigureCommand(request));
}
 
开发者ID:bmaggi,项目名称:library-training,代码行数:33,代码来源:MonthlyPeriodicalEditHelperAdvice.java

示例3: doExecuteWithResult

import org.eclipse.gmf.runtime.common.core.command.CommandResult; //导入方法依赖的package包/类
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
		IAdaptable info) throws ExecutionException {

	final View parentView = TreeLayoutUtil.getTreeNodeParentView(editPart
			.getNotationView());

	if (parentView != null) {
		final IGraphicalEditPart parentEditPart = (IGraphicalEditPart) editPart
				.findEditPart(editPart.getParent(), parentView.getElement());
		if (parentEditPart != null) {
			final List<IGraphicalEditPart> treeChildren = new ArrayList<IGraphicalEditPart>(

			TreeLayoutUtil.getOrderedTreeChildren(parentEditPart));
			if (!treeChildren.isEmpty()) {
				final int oldPos = treeChildren.indexOf(editPart);
				final int newPos = layoutConstraint.getTreeInnerRankIndex();

				if (newPos != -1) {
					if (oldPos != newPos) {
						final IGraphicalEditPart element = treeChildren
								.get(oldPos);
						treeChildren.remove(oldPos);
						treeChildren.add(newPos, element);
						TreeLayoutUtil
								.setTreeNodesPositionAnnotation(TreeLayoutUtil
										.getViews(treeChildren));
					}
				}
				return CommandResult.newOKCommandResult();
			}

		}
	}
	return CommandResult
			.newErrorCommandResult("Parent view or parent edit part not found!");
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:38,代码来源:UpdateAnnotationsOnMoveCommand.java

示例4: doExecuteWithResult

import org.eclipse.gmf.runtime.common.core.command.CommandResult; //导入方法依赖的package包/类
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
		IAdaptable info) throws ExecutionException {
	if (CommandUtil.executeUndoableOperation(
			annotateElements(TreeLayoutUtil
					.getOrderedTreeChildren(treeRootNodeEditPart))).isOK()) {
		return CommandResult.newOKCommandResult();
	}
	return CommandResult.newErrorCommandResult(new ExecutionException(
			"Error while annotating model elements!"));
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:12,代码来源:InitializeTreeNodeAnnotationsCommand.java

示例5: doExecuteWithResult

import org.eclipse.gmf.runtime.common.core.command.CommandResult; //导入方法依赖的package包/类
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
		IAdaptable info) throws ExecutionException {

	if (viewElements != null) {
		TreeLayoutUtil.setTreeNodesPositionAnnotation(viewElements);
		return CommandResult.newOKCommandResult();
	}

	return CommandResult
			.newErrorCommandResult("SetTreeNodesPositionAnnotationCommand: viewElements is null!");
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:13,代码来源:SetTreeNodesPositionAnnotationCommand.java


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