Runtime

org.eclipse.gmf.runtime.diagram.ui.commands
Class OpenDiagramCommand

java.lang.Object
  extended byorg.eclipse.core.commands.operations.AbstractOperation
      extended byorg.eclipse.gmf.runtime.common.core.command.AbstractCommand
          extended byorg.eclipse.gmf.runtime.diagram.ui.commands.OpenDiagramCommand
All Implemented Interfaces:
ICommand, org.eclipse.gmf.runtime.common.core.internal.command.ICommandWithSettableResult, IUndoableOperation

public class OpenDiagramCommand
extends AbstractCommand

Command to open a diagram.


Constructor Summary
OpenDiagramCommand(EObject element)
          Create an instance.
OpenDiagramCommand(java.lang.String label, EObject element)
          Create an instance.
 
Method Summary
 boolean canExecute()
          This command can only be executed if the element is a diagram.
 boolean canRedo()
           
 boolean canUndo()
           
protected  CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info)
          Create a new editor to display the corresponding diagram.
protected  CommandResult doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info)
          Performs the actual work of redoing this command.
protected  CommandResult doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info)
          Performs the actual work of undoing this command.
protected  EObject getElement()
          returns the element associated with that command
protected  void setElement(EObject element)
          set the element to open
 
Methods inherited from class org.eclipse.gmf.runtime.common.core.command.AbstractCommand
compose, dispose, execute, getAffectedFiles, getCommandResult, internalSetResult, redo, reduce, setResult, undo
 
Methods inherited from class org.eclipse.core.commands.operations.AbstractOperation
addContext, getContexts, getLabel, hasContext, removeContext, setLabel, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.core.commands.operations.IUndoableOperation
addContext, getContexts, getLabel, hasContext, removeContext
 

Constructor Detail

OpenDiagramCommand

public OpenDiagramCommand(java.lang.String label,
                          EObject element)
Create an instance.

Parameters:
label - command label
element - to be opened.

OpenDiagramCommand

public OpenDiagramCommand(EObject element)
Create an instance.

Parameters:
element - to be opened.
Method Detail

getElement

protected EObject getElement()
returns the element associated with that command

Returns:
the element associated with that command

setElement

protected void setElement(EObject element)
set the element to open

Parameters:
element - the element to open

canExecute

public boolean canExecute()
This command can only be executed if the element is a diagram.

See Also:
org.eclipse.gmf.runtime.common.core.command.ICommand#isExecutable()

doExecuteWithResult

protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor,
                                            IAdaptable info)
                                     throws ExecutionException
Create a new editor to display the corresponding diagram.

Specified by:
doExecuteWithResult in class AbstractCommand
Parameters:
progressMonitor - the progress monitor provided by the operation history. Must never be null.
info - the IAdaptable (or null) provided by the caller in order to supply UI information for prompting the user if necessary. When this parameter is not null, it should minimally contain an adapter for the org.eclipse.swt.widgets.Shell.class.
Returns:
The result of executing this command. May be null if the execution status is OK, but there is no meaningful result to be returned.
Throws:
ExecutionException - if, for some reason, I fail to complete the operation
See Also:
org.eclipse.gmf.runtime.common.core.sandbox.AbstractCommand2#doExecute(org.eclipse.core.runtime.IProgressMonitor)

canUndo

public boolean canUndo()

canRedo

public boolean canRedo()

doRedoWithResult

protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor,
                                         IAdaptable info)
                                  throws ExecutionException
Description copied from class: AbstractCommand
Performs the actual work of redoing this command. Subclasses must implement this method to perform the redo.

Specified by:
doRedoWithResult in class AbstractCommand
Parameters:
progressMonitor - the progress monitor provided by the operation history. Must never be null.
info - the IAdaptable (or null) provided by the caller in order to supply UI information for prompting the user if necessary. When this parameter is not null, it should minimally contain an adapter for the org.eclipse.swt.widgets.Shell.class.
Returns:
The result of redoing this command. May be null if the execution status is OK, but there is no meaningful result to be returned.
Throws:
ExecutionException - on failure to redo

doUndoWithResult

protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor,
                                         IAdaptable info)
                                  throws ExecutionException
Description copied from class: AbstractCommand
Performs the actual work of undoing this command. Subclasses must implement this method to perform the undo.

Specified by:
doUndoWithResult in class AbstractCommand
Parameters:
progressMonitor - the progress monitor provided by the operation history. Must never be null.
info - the IAdaptable (or null) provided by the caller in order to supply UI information for prompting the user if necessary. When this parameter is not null, it should minimally contain an adapter for the org.eclipse.swt.widgets.Shell.class.
Returns:
The result of undoing this command. May be null if the execution status is OK, but there is no meaningful result to be returned.
Throws:
ExecutionException - on failure to undo

Runtime

Guidelines for using Eclipse APIs.

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