Runtime

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

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.DeferredCreateConnectionViewAndElementCommand
All Implemented Interfaces:
ICommand, org.eclipse.gmf.runtime.common.core.internal.command.ICommandWithSettableResult, IUndoableOperation

public class DeferredCreateConnectionViewAndElementCommand
extends AbstractCommand

a command to create the both of the View and Semantic of the connection, but the editparts of target and source to obtain the command has not been created yet, since we have the ViewAdapter to we can use it to get its editpart once it is created and hence on execution time we can get its editpart to get the command for our request and then execute it.

This command can handle both CreateConnectionViewAndElementRequest and CreateConnectionViewRequest.


Constructor Summary
DeferredCreateConnectionViewAndElementCommand(CreateConnectionViewAndElementRequest request, IAdaptable sourceViewAdapter, IAdaptable targetViewAdapter, EditPartViewer currentViewer)
          Constructor for DeferredCreateConnectionViewAndElementCommand.
DeferredCreateConnectionViewAndElementCommand(CreateRequest request, IAdaptable typeInfoAdapter, IAdaptable sourceViewAdapter, IAdaptable targetViewAdapter, EditPartViewer currentViewer)
          Constructor for DeferredCreateConnectionViewAndElementCommand.
DeferredCreateConnectionViewAndElementCommand(IElementType type, IAdaptable sourceViewAdapter, IAdaptable targetViewAdapter, EditPartViewer currentViewer, PreferencesHint preferencesHint)
          Constructor for DeferredCreateConnectionViewAndElementCommand.
 
Method Summary
 boolean canRedo()
           
 boolean canUndo()
           
protected  CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info)
          Finds the source and target editparts by extracting the views from the view adapaters and searching in the editpart viewer.
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.
 java.util.List getAffectedFiles()
          Returns the IFiles that may be modified when the operation is executed, undone or redone.
 java.lang.String getLabel()
           
protected  EditPart getSourceEditPart()
          gives access to the connection source edit part, which is the edit part of the connection's source View
protected  EditPart getTargetEditPart()
          gives access to the connection target edit part, which is the edit part of the connection's target View
 
Methods inherited from class org.eclipse.gmf.runtime.common.core.command.AbstractCommand
compose, dispose, execute, getCommandResult, internalSetResult, redo, reduce, setResult, undo
 
Methods inherited from class org.eclipse.core.commands.operations.AbstractOperation
addContext, canExecute, getContexts, 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, canExecute, getContexts, hasContext, removeContext
 

Constructor Detail

DeferredCreateConnectionViewAndElementCommand

public DeferredCreateConnectionViewAndElementCommand(CreateConnectionViewAndElementRequest request,
                                                     IAdaptable sourceViewAdapter,
                                                     IAdaptable targetViewAdapter,
                                                     EditPartViewer currentViewer)
Constructor for DeferredCreateConnectionViewAndElementCommand.

Parameters:
request - the ceate connection request
sourceViewAdapter - will adapt to the source view at execution time
targetViewAdapter - will adapt to the target view at execution time
currentViewer - used to find the editparts for the views

DeferredCreateConnectionViewAndElementCommand

public DeferredCreateConnectionViewAndElementCommand(IElementType type,
                                                     IAdaptable sourceViewAdapter,
                                                     IAdaptable targetViewAdapter,
                                                     EditPartViewer currentViewer,
                                                     PreferencesHint preferencesHint)
Constructor for DeferredCreateConnectionViewAndElementCommand.

Parameters:
type - the type to be used in a new CreateConnectionViewAndElementRequest
sourceViewAdapter - will adapt to the source view at execution time
targetViewAdapter - will adapt to the target view at execution time
currentViewer - used to find the editparts for the views

DeferredCreateConnectionViewAndElementCommand

public DeferredCreateConnectionViewAndElementCommand(CreateRequest request,
                                                     IAdaptable typeInfoAdapter,
                                                     IAdaptable sourceViewAdapter,
                                                     IAdaptable targetViewAdapter,
                                                     EditPartViewer currentViewer)
Constructor for DeferredCreateConnectionViewAndElementCommand.

Parameters:
request - the ceate connection request
typeInfoAdapter - extracts the type to be used in a new CreateConnectionViewAndElementRequest at execution time
sourceViewAdapter - will adapt to the source view at execution time
targetViewAdapter - will adapt to the target view at execution time
currentViewer - used to find the editparts for the views
Method Detail

getAffectedFiles

public java.util.List getAffectedFiles()
Description copied from class: AbstractCommand
Returns the IFiles that may be modified when the operation is executed, undone or redone.

Specified by:
getAffectedFiles in interface ICommand
Overrides:
getAffectedFiles in class AbstractCommand

canUndo

public boolean canUndo()

canRedo

public boolean canRedo()

getSourceEditPart

protected EditPart getSourceEditPart()
gives access to the connection source edit part, which is the edit part of the connection's source View

Returns:
the source edit part

getTargetEditPart

protected EditPart getTargetEditPart()
gives access to the connection target edit part, which is the edit part of the connection's target View

Returns:
the source edit part

doExecuteWithResult

protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor,
                                            IAdaptable info)
                                     throws ExecutionException
Finds the source and target editparts by extracting the views from the view adapaters and searching in the editpart viewer. Creates a connection view and element using the request.

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

getLabel

public java.lang.String getLabel()
See Also:
IUndoableOperation.getLabel()

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.