Runtime

org.eclipse.gmf.runtime.common.core.command
Class CommandResult

java.lang.Object
  extended by org.eclipse.gmf.runtime.common.core.command.CommandResult

public final class CommandResult
extends java.lang.Object

The result of a command execution. Command results have an IStatus and optionally a return value (if applicable). GMF commands are assigned a command result when they are executed, undone, or redone.

See Also:
IStatus

Constructor Summary
CommandResult(IStatus status)
          Constructs a new command result with the specified status and a default return value.
CommandResult(IStatus status, java.lang.Object returnValue)
          Constructs a new command result with the specified status and return value.
 
Method Summary
 java.lang.Object getReturnValue()
          The value returned by the execute, undo or redo of a GMF operation.
 IStatus getStatus()
          Retrieves the status of the command that is executed, undone or redone.
static CommandResult newCancelledCommandResult()
          Creates a new IStatus.CANCEL command result with no return value.
static CommandResult newErrorCommandResult(java.lang.String errorMessage)
          Creates a new IStatus.ERROR command result with no return value.
static CommandResult newErrorCommandResult(java.lang.Throwable throwable)
          Creates a new IStatus.ERROR command result with no return value.
static CommandResult newOKCommandResult()
          Creates a new IStatus.OK command result.
static CommandResult newOKCommandResult(java.lang.Object result)
          Creates a new IStatus.OK command result with the specified return value.
static CommandResult newWarningCommandResult(java.lang.String warningMessage, java.lang.Object result)
          Creates a new IStatus.WARNING command result with a return value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandResult

public CommandResult(IStatus status)
Constructs a new command result with the specified status and a default return value.

Parameters:
status - The status for the new command result.

CommandResult

public CommandResult(IStatus status,
                     java.lang.Object returnValue)
Constructs a new command result with the specified status and return value.

Parameters:
status - The status for the new command result.
returnValue - The return value for the new command result.
Method Detail

newOKCommandResult

public static final CommandResult newOKCommandResult()
Creates a new IStatus.OK command result.

Returns:
a new OK command result with no return value

newOKCommandResult

public static final CommandResult newOKCommandResult(java.lang.Object result)
Creates a new IStatus.OK command result with the specified return value.

Parameters:
value - the command return result
Returns:
a new OK command result with the return value

newCancelledCommandResult

public static final CommandResult newCancelledCommandResult()
Creates a new IStatus.CANCEL command result with no return value.

Returns:
a new CANCEL command result with no return value

newErrorCommandResult

public static final CommandResult newErrorCommandResult(java.lang.String errorMessage)
Creates a new IStatus.ERROR command result with no return value.

Parameters:
errorMessage - the error message
Returns:
a new ERROR command result with no return value

newErrorCommandResult

public static final CommandResult newErrorCommandResult(java.lang.Throwable throwable)
Creates a new IStatus.ERROR command result with no return value.

Parameters:
errorMessage - the error message
Returns:
a new ERROR command result with no return value

newWarningCommandResult

public static final CommandResult newWarningCommandResult(java.lang.String warningMessage,
                                                          java.lang.Object result)
Creates a new IStatus.WARNING command result with a return value.

Parameters:
warningMessage - the warning message
value - the command return result
Returns:
a new WARNING command result with the return value

getStatus

public IStatus getStatus()
Retrieves the status of the command that is executed, undone or redone.

Returns:
The status.

getReturnValue

public java.lang.Object getReturnValue()
The value returned by the execute, undo or redo of a GMF operation.

Returns:
the return value; may be null

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.