## org.eclipse.emf.edit.command
Class DragAndDropCommand

    java.lang.Object
      org.eclipse.emf.common.command.AbstractCommand
          org.eclipse.emf.edit.command.DragAndDropCommand

All Implemented Interfaces:
  Command, DragAndDropFeedback

Direct Known Subclasses:
  DragAndDropOverrideCommand

    public class DragAndDropCommand

extends AbstractCommand
implements DragAndDropFeedback

The drag and drop command logically acts upon an owner object onto which a collection of things is being dragged. The static create method delegates command creation to `EditingDomain.createCommand`, which may or may not result in the actual creation of an instance of this class.

The implementation of this class is high-level and generic; it ultimately delegates all behaviour to other types of command, and is typically undoable as a result.

Nested Class Summary
`static class` `DragAndDropCommand.Detail` This class is used to encode the drag and drop arguments into an object that will be passed as the feature of a `CommandParameter`.

Nested classes/interfaces inherited from class org.eclipse.emf.common.command.AbstractCommand
`AbstractCommand.NonDirtying`

Field Summary
`protected java.util.Collection<?>` `collection` This keeps track of the collection of dragged sources.
`protected static java.lang.String` `DESCRIPTION` This caches the description.
`protected EditingDomain` `domain` This keeps track of the domain in which this command is created.
`protected Command` `dragCommand` This keeps track of the command that implements the drag side of the operation.
`protected Command` `dropCommand` This keeps track of the command that implements the drop side of the operation.
`protected int` `feedback` This keeps track of the feedback that will be returned by `getFeedback()`.
`protected boolean` `isDragCommandExecuted` This keeps track of whether execute has been called on the `dragCommand`.
`protected static java.lang.String` `LABEL` This caches the label.
`protected float` `location` This keeps track of the location of the drag and drop.
`protected float` `lowerLocationBound` This keeps track of the lower range of locations in which the effect of this command remains unchanged.
`protected int` `operation` This keeps track of the current operation that will be returned by `getOperation()`.
`protected int` `operations` This keeps track of the permitted operations.
`protected boolean` `optimize` This controls whether or not to optimize the `prepare()`.
`protected java.lang.Object` `optimizedDropCommandOwner` This is to remember which owner to use for the drop command in the optimized mode.
`protected java.lang.Object` `owner` This keeps track of the owner that is the target of the drag and drop.
`protected float` `upperLocationBound` This keeps track of the upper range of locations in which the effect of this command remains unchanged.

Fields inherited from class org.eclipse.emf.common.command.AbstractCommand
`description, isExecutable, isPrepared, label`

Fields inherited from interface org.eclipse.emf.edit.command.DragAndDropFeedback
`DROP_COPY, DROP_LINK, DROP_MOVE, DROP_NONE, FEEDBACK_INSERT_AFTER, FEEDBACK_INSERT_BEFORE, FEEDBACK_NONE, FEEDBACK_SELECT`

Constructor Summary
`DragAndDropCommand(EditingDomain domain, java.lang.Object owner, float location, int operations, int operation, java.util.Collection<?> collection)` This creates and instance in the given domain and for the given information.
`DragAndDropCommand(EditingDomain domain, java.lang.Object owner, float location, int operations, int operation, java.util.Collection<?> collection, boolean optimize)`

Method Summary
`protected boolean` `analyzeForNonContainment(Command command)`
`static Command` `create(EditingDomain domain, java.lang.Object owner, float location, int operations, int operation, java.util.Collection<?> collection)` This creates a command to perform a drag and drop operation upon the owner.
`void` `dispose()` Called to indicate that the command will never be used again.
`void` `execute()` Performs the command activity required for the effect.
`java.util.Collection<?>` `getAffectedObjects()` Returns an empty list.
`protected java.util.Collection<?>` `getChildren(java.lang.Object object)` This can be overridden to determine the children of an object; this implementation uses `EditingDomain.getChildren(java.lang.Object)`.
`java.util.Collection<?>` `getCollection()`
`int` `getFeedback()` This returns one of the FEEDBACK_* values.
`float` `getLocation()`
`int` `getOperation()` This returns one of the DROP_* values.
`int` `getOperations()`
`java.lang.Object` `getOwner()`
`protected java.lang.Object` `getParent(java.lang.Object object)` This can be overridden to determine the parent of an object; this implementation uses `EditingDomain.getParent(java.lang.Object)`.
`java.util.Collection<?>` `getResult()` Returns an empty list.
`protected boolean` `isCrossDomain()`
`protected boolean` `isNonContainment(EStructuralFeature feature)`
`protected boolean` `optimizedCanExecute()`
`protected boolean` `prepare()` This implementation of prepare is called again to implement `validate`.
`protected boolean` `prepareDropCopyInsert(java.lang.Object parent, java.util.Collection<?> children, int index)` This attempts to prepare a drop copy insert operation.
`protected boolean` `prepareDropCopyOn()` This attempts to prepare a drop copy on operation.
`protected boolean` `prepareDropInsert()` This attempts to prepare a drop insert operation.
`protected boolean` `prepareDropLinkInsert(java.lang.Object parent, java.util.Collection<?> children, int index)` This attempts to prepare a drop link insert operation.
`protected boolean` `prepareDropLinkOn()` This attempts to prepare a drop link on operation.
`protected boolean` `prepareDropMoveInsert(java.lang.Object parent, java.util.Collection<?> children, int index)` This attempts to prepare a drop move insert operation.
`protected boolean` `prepareDropMoveOn()` This attempts to prepare a drop move on operation.
`protected boolean` `prepareDropOn()` This attempts to prepare a drop on operation.
`void` `redo()` Performs the command activity required to `redo` the effect after undoing the effect.
`protected void` `reset()` This restores the command to its default initialized state, disposing an command that may have been contained.
`java.lang.String` `toString()` This gives an abbreviated name using this object's own class' name, without package qualification, followed by a space separated list of `field:value` pairs.
`void` `undo()` Throws a runtime exception.
`boolean` `validate(java.lang.Object owner, float location, int operations, int operation, java.util.Collection<?> collection)` This is called by EditingDomainViewerDropAdapter to determine if the drag and drop operation is still enabled.

Methods inherited from class org.eclipse.emf.common.command.AbstractCommand
`canExecute, canUndo, chain, getDescription, getLabel, setDescription, setLabel`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### LABEL

    protected static final java.lang.String LABEL

  This caches the label.

### DESCRIPTION

    protected static final java.lang.String DESCRIPTION

  This caches the description.

### domain

    protected EditingDomain domain

  This keeps track of the domain in which this command is created.

### owner

    protected java.lang.Object owner

  This keeps track of the owner that is the target of the drag and drop.

### location

    protected float location

  This keeps track of the location of the drag and drop.

### lowerLocationBound

    protected float lowerLocationBound

  This keeps track of the lower range of locations in which the effect of this command remains unchanged.

### upperLocationBound

    protected float upperLocationBound

  This keeps track of the upper range of locations in which the effect of this command remains unchanged.

### operations

    protected int operations

  This keeps track of the permitted operations.

### operation

    protected int operation

  This keeps track of the current operation that will be returned by `getOperation()`.

### feedback

    protected int feedback

  This keeps track of the feedback that will be returned by `getFeedback()`.

### collection

    protected java.util.Collection<?> collection

  This keeps track of the collection of dragged sources.

### dragCommand

    protected Command dragCommand

  This keeps track of the command that implements the drag side of the operation.

### isDragCommandExecuted

    protected boolean isDragCommandExecuted

  This keeps track of whether execute has been called on the `dragCommand`.

### dropCommand

    protected Command dropCommand

  This keeps track of the command that implements the drop side of the operation.

### optimize

    protected boolean optimize

  This controls whether or not to optimize the `prepare()`.

### optimizedDropCommandOwner

    protected java.lang.Object optimizedDropCommandOwner

  This is to remember which owner to use for the drop command in the optimized mode.

Constructor Detail

### DragAndDropCommand

    public DragAndDropCommand(EditingDomain domain,
                              java.lang.Object owner,
                              float location,
                              int operations,
                              int operation,
                              java.util.Collection<?> collection)

  This creates and instance in the given domain and for the given information. The location should be in the range of 0.0 to 1.0, indicating the relative vertical location of the drag operation, where 0.0 is at the top and 1.0 is at the bottom. The operations is a bitwise mask of the DROP_* values. The operation is the desired operation as specified by a DROP_* value. And the collection contains the source objects being dragged.

### DragAndDropCommand

    public DragAndDropCommand(EditingDomain domain,
                              java.lang.Object owner,
                              float location,
                              int operations,
                              int operation,
                              java.util.Collection<?> collection,
                              boolean optimize)

Method Detail

### create

    public static Command create(EditingDomain domain,
                                 java.lang.Object owner,
                                 float location,
                                 int operations,
                                 int operation,
                                 java.util.Collection<?> collection)

  This creates a command to perform a drag and drop operation upon the owner. See `DragAndDropCommand` for a description of the arguments.

### analyzeForNonContainment

    protected boolean analyzeForNonContainment(Command command)

### isNonContainment

    protected boolean isNonContainment(EStructuralFeature feature)

### getOwner

    public java.lang.Object getOwner()

### getLocation

    public float getLocation()

### getOperations

    public int getOperations()

### getCollection

    public java.util.Collection<?> getCollection()

### prepare

    protected boolean prepare()

  This implementation of prepare is called again to implement `validate`. The method `reset()` will have been called before doing so.

  Overrides:
    `prepare` in class `AbstractCommand`
  Returns:
    whether the command is executable.

### getParent

    protected java.lang.Object getParent(java.lang.Object object)

  This can be overridden to determine the parent of an object; this implementation uses `EditingDomain.getParent(java.lang.Object)`.

### getChildren

    protected java.util.Collection<?> getChildren(java.lang.Object object)

  This can be overridden to determine the children of an object; this implementation uses `EditingDomain.getChildren(java.lang.Object)`.

### prepareDropInsert

    protected boolean prepareDropInsert()

  This attempts to prepare a drop insert operation.

### prepareDropMoveInsert

    protected boolean prepareDropMoveInsert(java.lang.Object parent,
                                            java.util.Collection<?> children,
                                            int index)

  This attempts to prepare a drop move insert operation.

### isCrossDomain

    protected boolean isCrossDomain()

### prepareDropCopyInsert

    protected boolean prepareDropCopyInsert(java.lang.Object parent,
                                            java.util.Collection<?> children,
                                            int index)

  This attempts to prepare a drop copy insert operation.

### prepareDropLinkInsert

    protected boolean prepareDropLinkInsert(java.lang.Object parent,
                                            java.util.Collection<?> children,
                                            int index)

  This attempts to prepare a drop link insert operation.

### prepareDropOn

    protected boolean prepareDropOn()

  This attempts to prepare a drop on operation.

### prepareDropMoveOn

    protected boolean prepareDropMoveOn()

  This attempts to prepare a drop move on operation.

### prepareDropCopyOn

    protected boolean prepareDropCopyOn()

  This attempts to prepare a drop copy on operation.

### prepareDropLinkOn

    protected boolean prepareDropLinkOn()

  This attempts to prepare a drop link on operation.

### optimizedCanExecute

    protected boolean optimizedCanExecute()

### reset

    protected void reset()

  This restores the command to its default initialized state, disposing an command that may have been contained.

### validate

    public boolean validate(java.lang.Object owner,
                            float location,
                            int operations,
                            int operation,
                            java.util.Collection<?> collection)

  This is called by EditingDomainViewerDropAdapter to determine if the drag and drop operation is still enabled.

  Specified by:
    `validate` in interface `DragAndDropFeedback`

### getFeedback

    public int getFeedback()

  Description copied from interface: `DragAndDropFeedback`
  This returns one of the FEEDBACK_* values.

  Specified by:
    `getFeedback` in interface `DragAndDropFeedback`

### getOperation

    public int getOperation()

  Description copied from interface: `DragAndDropFeedback`
  This returns one of the DROP_* values.

  Specified by:
    `getOperation` in interface `DragAndDropFeedback`

### execute

    public void execute()

  Description copied from interface: `Command`
  Performs the command activity required for the effect. The effect of calling `execute` when `canExecute` returns `false`, or when `canExecute` hasn't been called, is undefined.

  Specified by:
    `execute` in interface `Command`

### undo

    public void undo()

  Description copied from class: `AbstractCommand`
  Throws a runtime exception.

  Specified by:
    `undo` in interface `Command`
  Overrides:
    `undo` in class `AbstractCommand`

### redo

    public void redo()

  Description copied from interface: `Command`
  Performs the command activity required to `redo` the effect after undoing the effect. The effect, if any, of calling `redo` before `undo` is called is undefined. Note that if you implement `redo` to call `execute` then any derived class will be restricted by that decision also.

  Specified by:
    `redo` in interface `Command`

### dispose

    public void dispose()

  Description copied from interface: `Command`
  Called to indicate that the command will never be used again. Calling any other method after this one has undefined results.

  Specified by:
    `dispose` in interface `Command`
  Overrides:
    `dispose` in class `AbstractCommand`

### getResult

    public java.util.Collection<?> getResult()

  Description copied from class: `AbstractCommand`
  Returns an empty list.

  Specified by:
    `getResult` in interface `Command`
  Overrides:
    `getResult` in class `AbstractCommand`
  Returns:
    an empty list.

### getAffectedObjects

    public java.util.Collection<?> getAffectedObjects()

  Description copied from class: `AbstractCommand`
  Returns an empty list.

  Specified by:
    `getAffectedObjects` in interface `Command`
  Overrides:
    `getAffectedObjects` in class `AbstractCommand`
  Returns:
    an empty list.

### toString

    public java.lang.String toString()

  This gives an abbreviated name using this object's own class' name, without package qualification, followed by a space separated list of `field:value` pairs.

  Overrides:
    `toString` in class `AbstractCommand`
  Returns:
    string representation.

Copyright 2001-2006 IBM Corporation and others. All Rights Reserved.