Runtime

## org.eclipse.gmf.runtime.emf.type.core.requests
Class DestroyDependentsRequest

    java.lang.Object
      org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest
          org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest
              org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest

All Implemented Interfaces:
  IEditCommandRequest

    public class DestroyDependentsRequest

extends DestroyRequest

Request to destroy the dependents of a model element. It is expected that the request will be served primarily by advice, which can invoke the `getDestroyDependentCommand(EObject)` to obtain a command to destroy an object dependent on the element being destroyed and have it added to the edit command. However, an edit helper can also provide an "instead" command by overriding its `getDestroyDependentsCommand(DestroyDependentsRequest)` method to do the same.

The destruction of dependents is an edit requested of the element being destroyed, unlike the `DestroyElementRequest`, which is requested of the container of the element being destroyed.

Field Summary

Fields inherited from interface org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest
`REPLACE_DEFAULT_COMMAND`

Constructor Summary
`DestroyDependentsRequest(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain, org.eclipse.emf.ecore.EObject elementToDestroy, boolean confirmationRequired)` Constructs a new request to destroy the dependents of a model element.

Method Summary
`protected boolean` `addDependentElementToDestroy(org.eclipse.emf.ecore.EObject dependent)` Indicates that the command that fulfils this request will also destroy the specified dependent of the `element to be destroyed`.
`org.eclipse.emf.ecore.EObject` `getContainer()` Gets the container of the element to be destroyed.
`protected java.lang.String` `getDefaultLabel()` Gets the default edit command label.
`java.util.Set` `getDependentElementsToDestroy()` Obtains an immutable view of the set of dependent elements to destroy.
`ICommand` `getDestroyDependentCommand(org.eclipse.emf.ecore.EObject dependent)` Obtains a command that destroys the specified `dependent` of the element to be destroyed, if it is not already being destroyed by the processing of the current `DestroyElementRequest`.
`ICommand` `getDestroyDependentsCommand(java.util.Collection dependents)` Obtains a command that destroys the specified `dependents` of the element to be destroyed, if they are not already being destroyed by the processing of the current `DestroyElementRequest`.
`java.lang.Object` `getEditHelperContext()` Gets the edit helper context for this request.
`org.eclipse.emf.transaction.TransactionalEditingDomain` `getEditingDomain()` Derives the editing domain from the object to be destroyed, if it hasn't already been specified.
`java.util.List` `getElementsToEdit()` Gets the elements that will be changed when the work is done for this request.
`org.eclipse.emf.ecore.EObject` `getElementToDestroy()` Gets the element to be destroyed.
`protected java.util.Set` `internalGetDependentElementsToDestroy()` Obtains the mutable set of dependent elements to destroy.
`protected boolean` `isElementToBeDestroyed(org.eclipse.emf.ecore.EObject eObject)` Queries whether the specified element will be destroyed as a result of the fulfillment of this request.
`void` `setElementToDestroy(org.eclipse.emf.ecore.EObject elementToDestroy)` Sets the element to be destroyed.

Methods inherited from class org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest
`isConfirmationRequired, setConfirm`

Methods inherited from class org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest
`addParameters, getClientContext, getLabel, getParameter, getParameters, setClientContext, setEditingDomain, setLabel, setParameter`

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

Constructor Detail

### DestroyDependentsRequest

    public DestroyDependentsRequest(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain,
                                    org.eclipse.emf.ecore.EObject elementToDestroy,
                                    boolean confirmationRequired)

  Constructs a new request to destroy the dependents of a model element.

  Parameters:
    `editingDomain` - the editing domain in which I am requesting to make model
    `elementToDestroy` - the element to be destroyed
    `confirmationRequired` - `true` if the user should be prompted to confirm the element deletion, `false` otherwise.

Method Detail

### getElementToDestroy

    public final org.eclipse.emf.ecore.EObject getElementToDestroy()

  Gets the element to be destroyed.

  Returns:
    the element to be destroyed

### setElementToDestroy

    public final void setElementToDestroy(org.eclipse.emf.ecore.EObject elementToDestroy)

  Sets the element to be destroyed.

  Parameters:
    `elementToDestroy` - the element to be destroyed

### getContainer

    public org.eclipse.emf.ecore.EObject getContainer()

  Description copied from class: `DestroyRequest`
  Gets the container of the element to be destroyed.

  Specified by:
    `getContainer` in class `DestroyRequest`
  Returns:
    the container of the element to be destroyed

### getElementsToEdit

    public java.util.List getElementsToEdit()

  Description copied from interface: `IEditCommandRequest`
  Gets the elements that will be changed when the work is done for this request.

  Specified by:
    `getElementsToEdit` in interface `IEditCommandRequest`
  Overrides:
    `getElementsToEdit` in class `DestroyRequest`
  Returns:
    the elements that will be edited

### getDefaultLabel

    protected java.lang.String getDefaultLabel()

  Description copied from class: `AbstractEditCommandRequest`
  Gets the default edit command label.

  Overrides:
    `getDefaultLabel` in class `DestroyRequest`
  Returns:
    the default label

### getEditHelperContext

    public java.lang.Object getEditHelperContext()

  Description copied from interface: `IEditCommandRequest`
  Gets the edit helper context for this request. The context can be an `IElementType` or an `EObject`, or an `IEditHelperContext`. It determines which edit helper should be used to find a command to do the work in the request.

  Specified by:
    `getEditHelperContext` in interface `IEditCommandRequest`
  Overrides:
    `getEditHelperContext` in class `DestroyRequest`
  Returns:
    the edit helper context for this request

### getEditingDomain

    public org.eclipse.emf.transaction.TransactionalEditingDomain getEditingDomain()

  Derives the editing domain from the object to be destroyed, if it hasn't already been specified.

  Specified by:
    `getEditingDomain` in interface `IEditCommandRequest`
  Overrides:
    `getEditingDomain` in class `AbstractEditCommandRequest`
  Returns:
    the editing domain

### internalGetDependentElementsToDestroy

    protected final java.util.Set internalGetDependentElementsToDestroy()

  Obtains the mutable set of dependent elements to destroy.

  Returns:
    the set of dependent elements

### getDependentElementsToDestroy

    public final java.util.Set getDependentElementsToDestroy()

  Obtains an immutable view of the set of dependent elements to destroy.

  Returns:
    the immutable set of dependent elements

### getDestroyDependentCommand

    public ICommand getDestroyDependentCommand(org.eclipse.emf.ecore.EObject dependent)

  Obtains a command that destroys the specified `dependent` of the element to be destroyed, if it is not already being destroyed by the processing of the current `DestroyElementRequest`. This command can then be composed with others by the edit helper processing the `DestroyDependentsRequest`.

  Parameters:
    `dependent` - an object dependent on the element being destroyed, which must also be destroyed
  Returns:
    a command to destroy the `dependent`, or `null` if the element is already being destroyed
  Throws:
    `java.lang.IllegalArgumentException` - on an attempt to destroy the element to be destroyed (as a dependent of itself)
    `java.lang.NullPointerException` - on attempt to destroy a `null` dependent
  See Also:
    `getDestroyDependentsCommand(Collection)`

### getDestroyDependentsCommand

    public ICommand getDestroyDependentsCommand(java.util.Collection dependents)

  Obtains a command that destroys the specified `dependents` of the element to be destroyed, if they are not already being destroyed by the processing of the current `DestroyElementRequest`. This command can then be composed with others by the edit helper processing the `DestroyDependentsRequest`.

  Parameters:
    `dependents` - dependents of the element being destroyed
  Returns:
    a command to destroy all of the specified `dependents`, or `null` if they are all already being destroyed
  See Also:
    `getDestroyDependentCommand(EObject)`

### addDependentElementToDestroy

    protected boolean addDependentElementToDestroy(org.eclipse.emf.ecore.EObject dependent)

  Indicates that the command that fulfils this request will also destroy the specified dependent of the `element to be destroyed`. Note that contained elements are implicitly considered to be dependent; they need not be handled by this mechanism.

  Advice that provides a command to destroy a dependent element must indicate that fact by calling this method (only after checking whether it isn't already `being destroyed`, anyway).

  Parameters:
    `dependent` - another object to destroy, which is dependent on the element for which we are requesting destruction
  Returns:
    `true` if the `dependent` was not already in the set of elements being destroyed; `false`, otherwise
  Throws:
    `java.lang.IllegalArgumentException` - on an attempt to add the `element to be destroyed` as a dependent of itself
    `java.lang.NullPointerException` - on attempt to add a `null` object
  See Also:
    `isElementToBeDestroyed(EObject)`, `getElementToDestroy()`, `getDestroyDependentCommand(EObject)`

### isElementToBeDestroyed

    protected boolean isElementToBeDestroyed(org.eclipse.emf.ecore.EObject eObject)

  Queries whether the specified element will be destroyed as a result of the fulfillment of this request. An element will be destroyed if it or any of its ancestors is the element to be destroyed or one of its dependents.

  Parameters:
    `eObject` - an element
  Returns:
    `true` if the command that fulfils this request would destroy the specified element; `false` if a new command would have to be composed with it to destroy the element

Runtime

Guidelines for using Eclipse APIs.

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