org.eclipse.gmf.runtime.emf.clipboard.core
Class ClipboardUtil
java.lang.Object
org.eclipse.gmf.runtime.emf.clipboard.core.ClipboardUtil
-
public class ClipboardUtil
- extends java.lang.Object
Utility for the creation of
IClipboardSupport
instances for
specific EMF metamodels, and for copy/paste operations to and from a String
form for use on the system clipboard.
Field Summary
|
static java.lang.String
|
HARVESTED_ELEMENT
Hint indicating that the elements to be pasted were harvested, rather
than just copied. |
static java.lang.String
|
IGNORE_RECYCLE_HINT_ID
Hint to ignore the recycle hint when pasting objects that were copied
with the recycle hint. |
static java.lang.String
|
MERGE_HINT_STRONG
Hint to perform "strong" merges when resolving paste collisions by merging. |
static java.lang.String
|
MERGE_HINT_WEAK
Hint to perform "weak" merges when resolving paste collisions by merging. |
static java.lang.String
|
PASTE_TO_TARGET_PARENT
Hint to attempt to paste into the parent of target element if target
element doesn't accept the copied element. |
static java.lang.String
|
RECYCLE_HINT_ID
Hint to retain the original element's ID when pasting it. |
Method Summary
|
static java.lang.String
|
copyElementsToString
(java.util.Collection eObjects,
java.util.Map hints,
IProgressMonitor monitor)
Serializes elements to a string suitable for putting on the system
clipboard. |
static
IClipboardSupport
|
createClipboardSupport
(org.eclipse.emf.ecore.EClass eClass)
Obtains the clipboard copy/paste support utility, if any, for the
specified eClass 's metamodel. |
static java.util.Collection
|
pasteElementsFromString
(java.lang.String string,
org.eclipse.emf.ecore.EObject targetElement,
java.util.Map hints,
IProgressMonitor monitor)
Deerializes elements from a string (obtained from the system clipboard)
and pastes them into the specified target element. |
static java.util.Collection
|
pasteElementsFromString
(java.lang.String string,
org.eclipse.emf.ecore.resource.Resource targetElement,
java.util.Map hints,
IProgressMonitor monitor)
Deerializes elements from a string (obtained from the system clipboard)
and pastes them into the specified target element. |
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
|
MERGE_HINT_WEAK
public static final java.lang.String MERGE_HINT_WEAK
- Hint to perform "weak" merges when resolving paste collisions by merging.
Weak merges will merge the content of multiplicity-many features but
will not replace existing values in scalar features.
This hint is specified on a per-object basis.
-
See Also:
-
MERGE_HINT_STRONG
,
Constant Field Values
MERGE_HINT_STRONG
public static final java.lang.String MERGE_HINT_STRONG
- Hint to perform "strong" merges when resolving paste collisions by merging.
Strong merges will merge the content of multiplicity-many features and
will also replace existing values in scalar features. This is the
default merge behaviour.
This hint is specified on a per-object basis.
-
See Also:
-
MERGE_HINT_WEAK
,
Constant Field Values
RECYCLE_HINT_ID
public static final java.lang.String RECYCLE_HINT_ID
- Hint to retain the original element's ID when pasting it. Normally used
only when implementing a "move" operation, rather than a "copy".
This hint is specified on a per-object basis.
-
See Also:
-
Constant Field Values
IGNORE_RECYCLE_HINT_ID
public static final java.lang.String IGNORE_RECYCLE_HINT_ID
- Hint to ignore the recycle hint when pasting objects that were copied
with the recycle hint. This essentially forces IDs to be regenerated
even when the copier asked for them to be reused. This would be
appropriate, for example, on the second and subsequent paste of elements
that had been cut and already pasted once.
This hint applies to all objects: use it as a key in the hint map with
a boolean value to indicate whether it is enabled.
-
See Also:
-
Constant Field Values
PASTE_TO_TARGET_PARENT
public static final java.lang.String PASTE_TO_TARGET_PARENT
- Hint to attempt to paste into the parent of target element if target
element doesn't accept the copied element.
This hint is specified on a per-object basis.
-
See Also:
-
Constant Field Values
HARVESTED_ELEMENT
public static final java.lang.String HARVESTED_ELEMENT
- Hint indicating that the elements to be pasted were harvested, rather
than just copied.
This hint is specified on a per-object basis.
-
See Also:
-
Constant Field Values
copyElementsToString
public static java.lang.String copyElementsToString(java.util.Collection eObjects,
java.util.Map hints,
IProgressMonitor monitor)
- Serializes elements to a string suitable for putting on the system
clipboard.
-
-
Parameters:
-
eObjects
- a collection of EObject
s to be serialized -
hints
- a mapping of hints (defined as constants on this class), or
null
to provide no hints -
monitor
- a progress monitor to track progress, or
null
if no progress feedback is required
-
Returns:
- the serial form of the
eObjects
pasteElementsFromString
public static java.util.Collection pasteElementsFromString(java.lang.String string,
org.eclipse.emf.ecore.EObject targetElement,
java.util.Map hints,
IProgressMonitor monitor)
- Deerializes elements from a string (obtained from the system clipboard)
and pastes them into the specified target element.
-
-
Parameters:
-
string
- the string containing the elements to be pasted -
targetElement
- the element into which the new elements are to be
pasted -
hints
- a mapping of hints (defined as constants on this class), or
null
to provide no hints -
monitor
- a progress monitor to track progress, or
null
if no progress feedback is required
-
Returns:
- the newly pasted
EObject
s
pasteElementsFromString
public static java.util.Collection pasteElementsFromString(java.lang.String string,
org.eclipse.emf.ecore.resource.Resource targetElement,
java.util.Map hints,
IProgressMonitor monitor)
- Deerializes elements from a string (obtained from the system clipboard)
and pastes them into the specified target element.
-
-
Parameters:
-
string
- the string containing the elements to be pasted -
targetElement
- the element into which the new elements are to be
pasted -
hints
- a mapping of hints (defined as constants on this class), or
null
to provide no hints -
monitor
- a progress monitor to track progress, or
null
if no progress feedback is required
-
Returns:
- the newly pasted
EObject
s
createClipboardSupport
public static
IClipboardSupport createClipboardSupport(org.eclipse.emf.ecore.EClass eClass)
- Obtains the clipboard copy/paste support utility, if any, for the
specified
eClass
's metamodel. If the metamodel does not
have a dedicated clipboard support implementation, then a default
implementation is provided that implements semantics similar to the
EcoreUtil.Copier
class.
-
-
Parameters:
-
eClass
- a metaclass
-
Returns:
- the
eClass
's metamodel's clipboard support
utility, or a null implementation if none is registered for it
(not actually null
)
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.