org.aspectj.org.eclipse.jdt.internal.core
Class CopyElementsOperation

java.lang.Object
  extended by org.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation
      extended by org.aspectj.org.eclipse.jdt.internal.core.MultiOperation
          extended by org.aspectj.org.eclipse.jdt.internal.core.CopyElementsOperation
All Implemented Interfaces:
SuffixConstants
Direct Known Subclasses:
MoveElementsOperation

public class CopyElementsOperation
extends MultiOperation
implements SuffixConstants

This operation copies/moves a collection of elements from their current container to a new container, optionally renaming the elements.

Notes:


Nested Class Summary
 
Nested classes/interfaces inherited from class org.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation
JavaModelOperation.IPostAction
 
Field Summary
 
Fields inherited from class org.aspectj.org.eclipse.jdt.internal.core.MultiOperation
insertBeforeElements, newParents, renamings, renamingsList
 
Fields inherited from class org.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation
actions, actionsEnd, actionsStart, APPEND, attributes, elementsToProcess, force, HAS_MODIFIED_RESOURCE_ATTR, isNested, KEEP_EXISTING, NO_ELEMENTS, OPERATION_STACKS, parentElements, POST_ACTION_VERBOSE, progressMonitor, REMOVEALL_APPEND, resultElements, TRUE
 
Fields inherited from interface org.aspectj.org.eclipse.jdt.internal.compiler.util.SuffixConstants
EXTENSION_aj, EXTENSION_AJ, EXTENSION_class, EXTENSION_CLASS, EXTENSION_java, EXTENSION_JAVA, SUFFIX_aj, SUFFIX_AJ, SUFFIX_class, SUFFIX_CLASS, SUFFIX_java, SUFFIX_JAVA, SUFFIX_STRING_aj, SUFFIX_STRING_AJ, SUFFIX_STRING_class, SUFFIX_STRING_CLASS, SUFFIX_STRING_java, SUFFIX_STRING_JAVA
 
Constructor Summary
CopyElementsOperation(IJavaElement[] elementsToCopy, IJavaElement[] destContainers, boolean force)
          When executed, this operation will copy the given elements to the given containers.
CopyElementsOperation(IJavaElement[] elementsToCopy, IJavaElement destContainer, boolean force)
          When executed, this operation will copy the given elements to the given container.
 
Method Summary
protected  java.lang.String getMainTaskName()
          Returns the String to use as the main task name for progress monitoring.
protected  JavaModelOperation getNestedOperation(IJavaElement element)
          Returns the nested operation to use for processing this element
protected  boolean isRenamingMainType(IJavaElement element, IJavaElement dest)
          Returns true if this element is the main type of its compilation unit.
protected  void processElement(IJavaElement element)
          Copy/move the element from the source to destination, renaming the elements as specified, honoring the collision policy.
protected  IJavaModelStatus verify()
          Possible failures: NO_ELEMENTS_TO_PROCESS - no elements supplied to the operation INDEX_OUT_OF_BOUNDS - the number of renamings supplied to the operation does not match the number of elements that were supplied.
protected  void verify(IJavaElement element)
          This method is called for each IJavaElement before processElement.
 
Methods inherited from class org.aspectj.org.eclipse.jdt.internal.core.MultiOperation
error, executeOperation, getDestinationParent, getNewNameFor, isMove, isRename, processElements, setInsertBefore, setRenamings, verifyDestination, verifyRenaming, verifySibling
 
Methods inherited from class org.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation
addAction, addDelta, addReconcileDelta, applyTextEdit, beginTask, canModifyRoots, checkCanceled, commonVerify, copyResources, createFile, createFolder, deleteEmptyPackageFragment, deleteResource, deleteResources, done, equalsOneOf, executeNestedOperation, firstActionWithID, getAttribute, getCompilationUnitFor, getCurrentOperationStack, getDocument, getElementToProcess, getJavaModel, getNestedFolders, getParentElement, getParentElements, getResultElements, getSchedulingRule, getSubProgressMonitor, hasModifiedResource, internalWorked, isCanceled, isReadOnly, isTopLevelOperation, moveResources, newJavaElementDelta, popOperation, postAction, prefixesOneOf, pushOperation, removeAllPostAction, removeReconcileDelta, run, runOperation, runPostActions, setAttribute, setCanceled, setNested, setTaskName, subTask, worked
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CopyElementsOperation

public CopyElementsOperation(IJavaElement[] elementsToCopy,
                             IJavaElement[] destContainers,
                             boolean force)
When executed, this operation will copy the given elements to the given containers. The elements and destination containers must be in the correct order. If there is > 1 destination, the number of destinations must be the same as the number of elements being copied/moved/renamed.


CopyElementsOperation

public CopyElementsOperation(IJavaElement[] elementsToCopy,
                             IJavaElement destContainer,
                             boolean force)
When executed, this operation will copy the given elements to the given container.

Method Detail

getMainTaskName

protected java.lang.String getMainTaskName()
Returns the String to use as the main task name for progress monitoring.

Specified by:
getMainTaskName in class MultiOperation

getNestedOperation

protected JavaModelOperation getNestedOperation(IJavaElement element)
Returns the nested operation to use for processing this element


isRenamingMainType

protected boolean isRenamingMainType(IJavaElement element,
                                     IJavaElement dest)
                              throws JavaModelException
Returns true if this element is the main type of its compilation unit.

Throws:
JavaModelException

processElement

protected void processElement(IJavaElement element)
                       throws JavaModelException
Copy/move the element from the source to destination, renaming the elements as specified, honoring the collision policy.

Specified by:
processElement in class MultiOperation
Throws:
JavaModelException - if the operation is unable to be completed

verify

protected IJavaModelStatus verify()
Possible failures:

Overrides:
verify in class JavaModelOperation
See Also:
IJavaModelStatus

verify

protected void verify(IJavaElement element)
               throws JavaModelException
Description copied from class: MultiOperation
This method is called for each IJavaElement before processElement. It should check that this element can be processed.

Specified by:
verify in class MultiOperation
Throws:
JavaModelException
See Also:
Possible failure codes:
  • ELEMENT_DOES_NOT_EXIST - element or its specified destination is is null or does not exist. If a null element is supplied, no element is provided in the status, otherwise, the non-existant element is supplied in the status.
  • INVALID_ELEMENT_TYPES - element is not contained within a compilation unit. This operation only operates on elements contained within compilation units.
  • READ_ONLY - element is read only.
  • INVALID_DESTINATION - The destination parent specified for element is of an incompatible type. The destination for a package declaration or import declaration must be a compilation unit; the destination for a type must be a type or compilation unit; the destination for any type member (other than a type) must be a type. When this error occurs, the element provided in the operation status is the element.
  • INVALID_NAME - the new name for element does not have valid syntax. In this case the element and name are provided in the status.