|
Runtime | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.gmf.runtime.emf.clipboard.core.ClipboardOperation
org.eclipse.gmf.runtime.emf.clipboard.core.BasePasteOperation
org.eclipse.gmf.runtime.emf.clipboard.core.PasteChildOperation
public class PasteChildOperation
An operation to paste a child object into a new target parent object.
Field Summary | |
---|---|
protected static java.lang.String |
COPY
Localized prefix to prepend onto element names to disambiguate them in resolving paste collisions. |
protected static PasteChildOperation[] |
EMPTY_ARRAY
A reusable empty array of paste child operations. |
Fields inherited from class org.eclipse.gmf.runtime.emf.clipboard.core.BasePasteOperation |
---|
PASTE |
Fields inherited from class org.eclipse.gmf.runtime.emf.clipboard.core.ClipboardOperation |
---|
TOTAL_WORK, WORK_UNIT |
Constructor Summary | |
---|---|
protected |
PasteChildOperation(PasteChildOperation mainChildPasteProcess)
Initializes me as an override- or post-paste operation. |
|
PasteChildOperation(org.eclipse.gmf.runtime.emf.clipboard.core.internal.PasteIntoParentOperation parentPasteProcess,
ObjectInfo childEObjectInfo)
Initializes me. |
Method Summary | |
---|---|
protected boolean |
canBeReplaced(org.eclipse.emf.ecore.EObject eObject)
Queries whether the specified object that already exists in the target resource can be replaced by an element being pasted, in case of a collision that is resolved by replacement. |
protected org.eclipse.emf.ecore.EObject |
doPasteInto(org.eclipse.emf.ecore.EObject pasteIntoEObject)
Pastes my child object into the specified object. |
protected org.eclipse.emf.ecore.EObject |
doPasteInto(org.eclipse.emf.ecore.EObject pasteIntoEObject,
org.eclipse.emf.ecore.EReference reference)
Pastes my child object into the specified containment reference of an object. |
protected org.eclipse.emf.ecore.EObject |
doPasteInto(PasteTarget pasteTarget)
Pastes my child object into the specified object. |
protected org.eclipse.emf.ecore.EObject |
doPasteInto(org.eclipse.emf.ecore.resource.Resource pasteIntoResource)
Pastes my child object into the specified resource |
protected java.util.List |
getAlwaysCopyObjectPasteOperations()
Obtains a list of operations to paste the "copy always" objects related to the object that I am pasting. |
protected PasteChildOperation |
getAuxiliaryChildPasteProcess(ObjectInfo auxiliaryChildEObjectInfo)
Obtains the paste operation that pastes the auxiliary object indicated by the specified object info. |
protected ObjectInfo |
getChildObjectInfo()
Gets the object info meta-data for the object that I am pasting. |
protected org.eclipse.emf.ecore.EReference |
getContainmentFeature()
Gets the containment feature into which I would prefer to paste my child element into the parent. |
protected org.eclipse.emf.ecore.EObject |
getCopyParentEObject()
Gets the original parent of the object that I am pasting, if it was copied along with the child. |
protected ObjectInfo |
getCopyParentObjectInfo()
Gets the object meta-data for my copy object's parent, if it was serialized along with the child. |
org.eclipse.emf.ecore.EObject |
getEObject()
Retrieves the object that I am pasting from the deserialized clipboard string into the target parent object. |
protected org.eclipse.emf.ecore.EObject |
getEObject(java.lang.String objId)
Looks up an object in the resource to which we are pasting, by its ID. |
protected java.lang.String |
getEObjectID(org.eclipse.emf.ecore.EObject eObject)
Looks up the ID of an object in the resource to which we are pasting. |
protected org.eclipse.emf.ecore.EObject |
getLoadedDirectContainerEObject()
Obtains the direct container object, from the deserialized copied elements, of the object that I am pasting. |
protected org.eclipse.emf.ecore.EObject |
getLoadedEObject(java.lang.String objId)
Looks up an object deserialized from the clipboard string by its ID. |
protected java.lang.String |
getLoadedEObjectID(org.eclipse.emf.ecore.EObject eObject)
Looks up the ID of an object deserialized from the clipboard string. |
protected PasteChildOperation |
getMainChildPasteProcess()
Gets the child paste operation that I am overriding or extending, if I am an auxiliary paste operation. |
org.eclipse.emf.ecore.EObject |
getParentEObject()
Gets the target object into which we are pasting a child. |
org.eclipse.gmf.runtime.emf.clipboard.core.internal.PasteIntoParentOperation |
getParentPasteProcess()
Obtains the paste operation that created me to paste a child into the target parent element. |
org.eclipse.emf.ecore.xmi.XMLResource |
getParentResource()
Obtains the XML resource into which we are pasting. |
PasteTarget |
getParentTarget()
Gets the target object into which we are pasting a child. |
org.eclipse.emf.ecore.EReference |
getPasteContainmentFeature(org.eclipse.emf.ecore.EObject parentEObject)
Consults the clipboard support to get the best-match containment feature of the specified parent object to paste my child object into, according to the copied object's original containment feature. |
protected org.eclipse.emf.ecore.EObject |
getPastedDirectCopyParent()
After pasting has completed, obtains the pasted object corresponding to the specified originally copied object's parent. |
org.eclipse.emf.ecore.EObject |
getPastedElement()
After pasting is completed, obtains the element that I pasted. |
protected org.eclipse.emf.ecore.EObject |
getPastedEObject(org.eclipse.emf.ecore.EObject eObject)
After pasting has completed, obtains the pasted object corresponding to the specified originally copied object. |
PasteChildOperation |
getPostPasteOperation()
Gets an operation to be invoked after I have completed my pasting, to do some follow-up pasting. |
protected PasteTarget |
getSuitableParentUsingAncestry(java.lang.String preferredTypeName)
Finds some parent in the containment chain (ancestry) of the parent element into which I am pasting that my child element can be pasted into. |
protected boolean |
handleCollision(org.eclipse.emf.ecore.EReference reference,
org.eclipse.emf.ecore.EObject object,
org.eclipse.emf.ecore.EObject eObject,
ObjectInfo eObjectInfo)
Handles the collision of an eObject that is to be pasted
into the specified scalar reference, where it collides with the
existing element. |
protected boolean |
handleCollision(org.eclipse.emf.ecore.EReference reference,
java.util.List list,
org.eclipse.emf.ecore.EObject eObject,
ObjectInfo eObjectInfo)
Handles the collision of an eObject that is to be pasted
into the specified values of a reference, where it collides with one or
more of these existing elements. |
protected boolean |
hasCopyParent()
Queries whether the object that I am pasting had its parent object copied along with it, as an alternative element to try to paste when I can't be directly pasted into the target element. |
boolean |
isAuxiliaryOperation()
Queries whether I am an auxiliary operation. |
protected boolean |
isCopyAlways()
Queries whether the object that I am pasting was copied because it is always copied along with an element that was originally selected for copying. |
protected boolean |
isCopyParentDirectParent()
Queries whether my copy object's parent object that was copied along with it was a direct container or not. |
protected PasteChildOperation |
makeAuxiliaryChildPasteProcess(ObjectInfo auxiliaryChildEObjectInfo)
Constructs a paste operation to paste the auxiliary object indicated by its object info. |
protected void |
mergeEObjects(boolean weakMerge,
org.eclipse.emf.ecore.EObject targetEObject,
org.eclipse.emf.ecore.EObject eObject,
ObjectInfo objectInfo)
Merges an elements to be pasted with an existing element that collides. |
protected java.util.List |
mergeLists(org.eclipse.emf.ecore.EReference reference,
java.util.List targetObjectList,
java.util.List objectList,
ObjectInfo objectInfo)
Merges the elements to be pasted into a many containment reference with those objects already in that reference with which they collide. |
void |
paste()
Performs the paste operation. |
protected void |
setPastedElement(org.eclipse.emf.ecore.EObject pastedElement)
After pasting has completed, records the element that I have successfully (or not) pasted from the original copy. |
protected boolean |
shouldPasteAlwaysCopyObject(ObjectInfo alwaysCopyObjectInfo)
Queries whether we should paste the specified "copy always" object associated with the element we are pasting. |
Methods inherited from class org.eclipse.gmf.runtime.emf.clipboard.core.BasePasteOperation |
---|
addCriticalResolveFailure, addMergedElementEntry, addPastedElement, addPasteFailuresObject, getAllCriticalResolveFailuresSet, getAllMergedElementsMap, getAllPastedElementSet, getAllPasteFailuresObjectSet, getCriticalResolveFailuresSet, getLoadOptionsMap, getMergedElementsMap, getPastedElementSet, getPasteFailuresObjectSet, getResourceInfo, getSpawningPasteOperation, removeCriticalResolveFailure, throwCancelException |
Methods inherited from class org.eclipse.gmf.runtime.emf.clipboard.core.ClipboardOperation |
---|
catchException, getClipboardOperationHelper, getProgressMonitor, isCancelled, throwCancelException, throwException |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String COPY
protected static final PasteChildOperation[] EMPTY_ARRAY
Constructor Detail |
---|
public PasteChildOperation(org.eclipse.gmf.runtime.emf.clipboard.core.internal.PasteIntoParentOperation parentPasteProcess, ObjectInfo childEObjectInfo)
parentPasteProcess
- my superordinate operation, that created me
in order to paste one of its copied objects into its target parent
objectchildEObjectInfo
- the metadata for the child object to be pastedprotected PasteChildOperation(PasteChildOperation mainChildPasteProcess)
mainChildPasteProcess
- the paste-child process that I am overriding
or extendingMethod Detail |
---|
protected org.eclipse.emf.ecore.EReference getContainmentFeature()
protected org.eclipse.emf.ecore.EObject getLoadedDirectContainerEObject()
public org.eclipse.gmf.runtime.emf.clipboard.core.internal.PasteIntoParentOperation getParentPasteProcess()
protected PasteChildOperation getAuxiliaryChildPasteProcess(ObjectInfo auxiliaryChildEObjectInfo)
auxiliaryChildEObjectInfo
- the auxiliary object's info
protected PasteChildOperation makeAuxiliaryChildPasteProcess(ObjectInfo auxiliaryChildEObjectInfo)
auxiliaryChildEObjectInfo
- the auxiliary object's info
public org.eclipse.emf.ecore.EObject getEObject()
public org.eclipse.emf.ecore.EObject getPastedElement()
null
if I did not succeed
in pastingprotected org.eclipse.emf.ecore.EObject getLoadedEObject(java.lang.String objId)
objId
- the object ID to look up
null
if not foundprotected java.lang.String getLoadedEObjectID(org.eclipse.emf.ecore.EObject eObject)
eObject
- the object whose ID we want to look up
null
if not foundprotected boolean hasCopyParent()
protected boolean isCopyAlways()
protected org.eclipse.emf.ecore.EObject getCopyParentEObject()
null
if it was not copiedhasCopyParent()
protected org.eclipse.emf.ecore.EObject getEObject(java.lang.String objId)
objId
- the object ID to look up
null
if not foundprotected java.lang.String getEObjectID(org.eclipse.emf.ecore.EObject eObject)
eObject
- the object to look up its ID
null
if not foundprotected PasteTarget getSuitableParentUsingAncestry(java.lang.String preferredTypeName)
preferredTypeName
- the fully-qualified class name of the preferred
element type to paste into
null
protected org.eclipse.emf.ecore.EObject getPastedEObject(org.eclipse.emf.ecore.EObject eObject)
eObject
- the originally copied object
null
if the
eObject
was not successfully pastedprotected org.eclipse.emf.ecore.EObject getPastedDirectCopyParent()
null
if the
copy parent was not successfully pastedpublic org.eclipse.emf.ecore.EObject getParentEObject()
public PasteTarget getParentTarget()
public org.eclipse.emf.ecore.xmi.XMLResource getParentResource()
public PasteChildOperation getPostPasteOperation()
OverridePasteChildOperation
s can
redefine this method to provide custom post-paste behaviour.
IMPORTANT: This function must be invoked AFTER the paste() function has been called.
public void paste() throws java.lang.Exception
BasePasteOperation
paste
in class BasePasteOperation
java.lang.Exception
- if anything goes wrong in pastingprotected org.eclipse.emf.ecore.EObject doPasteInto(org.eclipse.emf.ecore.EObject pasteIntoEObject)
pasteIntoEObject
- the object to paste into
null
if the paste did
not succeedprotected org.eclipse.emf.ecore.EObject doPasteInto(PasteTarget pasteTarget)
pasteTarget
- the object to paste into
null
if the paste did
not succeedprotected org.eclipse.emf.ecore.EObject doPasteInto(org.eclipse.emf.ecore.EObject pasteIntoEObject, org.eclipse.emf.ecore.EReference reference)
pasteIntoEObject
- the object to paste intoreference
- the containment reference to paste into
null
if the paste did
not succeedprotected org.eclipse.emf.ecore.EObject doPasteInto(org.eclipse.emf.ecore.resource.Resource pasteIntoResource)
pasteIntoResource
- the resource to paste into
null
if the paste did
not succeedprotected java.util.List getAlwaysCopyObjectPasteOperations()
getPostPasteOperation()
protected boolean shouldPasteAlwaysCopyObject(ObjectInfo alwaysCopyObjectInfo)
alwaysCopyObjectInfo
- info indicating the "copy always" object
true
if the "copy always" object should be pasted;
false
, otherwisepublic org.eclipse.emf.ecore.EReference getPasteContainmentFeature(org.eclipse.emf.ecore.EObject parentEObject)
parentEObject
- the parent to paste into
null
if the parent cannot contain the child at allprotected boolean handleCollision(org.eclipse.emf.ecore.EReference reference, java.util.List list, org.eclipse.emf.ecore.EObject eObject, ObjectInfo eObjectInfo)
eObject
that is to be pasted
into the specified values of a reference, where it collides with one or
more of these existing elements. This may involve, among other things,
renaming the object to be pasted in order to make its name unique.
reference
- the many containment reference into which we want to
paste the eObject
list
- the current value (list of EObject
s) of the
containment referenceeObject
- the object that we want to paste, which collides with one
or more elements in the list
eObjectInfo
- the eObject
's object info meta-data
true
if the collision was resolved so that we
can go ahead and paste the eObject
as intended;
false, otherwiseprotected boolean handleCollision(org.eclipse.emf.ecore.EReference reference, org.eclipse.emf.ecore.EObject object, org.eclipse.emf.ecore.EObject eObject, ObjectInfo eObjectInfo)
eObject
that is to be pasted
into the specified scalar reference, where it collides with the
existing element.
reference
- the scalar containment reference into which we want to
paste the eObject
object
- the current value of the containment referenceeObject
- the object that we want to paste, which collides with one
or more elements in the list
eObjectInfo
- the eObject
's object info meta-data
true
if the collision was resolved so that we
can go ahead and paste the eObject
as intended;
false, otherwiseprotected java.util.List mergeLists(org.eclipse.emf.ecore.EReference reference, java.util.List targetObjectList, java.util.List objectList, ObjectInfo objectInfo)
reference
- the many containment reference to merge objects intotargetObjectList
- the existing objects in the reference collectionobjectList
- the objects that we need to merge into the targetsobjectInfo
- object info
handleCollision(EReference, List, EObject, ObjectInfo)
,
PasteAction.MERGE
protected void mergeEObjects(boolean weakMerge, org.eclipse.emf.ecore.EObject targetEObject, org.eclipse.emf.ecore.EObject eObject, ObjectInfo objectInfo)
weakMerge
- true
to perform a
weak merge;
false
for a
strong mergetargetEObject
- the existing object to merge intoeObject
- the object that we need to merge into the targetobjectInfo
- the eObject
's object infohandleCollision(EReference, List, EObject, ObjectInfo)
,
handleCollision(EReference, EObject, EObject, ObjectInfo)
,
PasteAction.MERGE
protected ObjectInfo getChildObjectInfo()
protected PasteChildOperation getMainChildPasteProcess()
null
if nonepublic boolean isAuxiliaryOperation()
true
if I am an auxiliary paste operation;
false
, otherwiseprotected ObjectInfo getCopyParentObjectInfo()
null
if noneprotected boolean isCopyParentDirectParent()
true
if my copy object's parent was copied and was
its direct container; false
, otherwiseprotected void setPastedElement(org.eclipse.emf.ecore.EObject pastedElement)
pastedElement
- the pasted element, or null
if pasting
failedprotected boolean canBeReplaced(org.eclipse.emf.ecore.EObject eObject)
eObject
- an object in the target model that might be replaced
true
if it can be replaced;
false
, otherwisePasteAction.REPLACE
|
Runtime | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.