本文整理汇总了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());
}
示例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));
}
示例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!");
}
示例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!"));
}
示例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!");
}