Used by the GraphClipboard to assign IDs for elements in the clipboard.
Inheritance Hierarchy
Remarks
IDs are created when items are copied (or cut) into the clipboard and queried when the items are pasted from the clipboard.
Providing a custom ID provider allows for identifying conceptually identical items across different graph instances.
The default implementation uses the IModelItem object reference as the ID.
Members
No filters for this type
Methods
Gets the ID for the given originalItem.
Gets the ID for the given
originalItem.abstract
Parameters
- context: IGraphClipboardContext
- The clipboard context
- originalItem: IModelItem
- The original item which is copied. The item is part of the original graph from which the item is copied.
Return Value
- any
- An ID for the given item. The object should be suitable for use in a HashMap<TKey, TValue>.
Gets the item which is represented by the given id.
Gets the item which is represented by the given
id.abstract
Parameters
- context: IGraphClipboardContext
- The clipboard context.
- id: any
- The ID to get the item for.
Return Value
- IModelItem
- The item which is represented by the given ID or
nullif the item cannot be located or is invalid. The item needs to be part of the target graph for paste operations.
Examples
/**
* @param _context - The information which items to copy.
* @param sourceLabel - The label to be duplicated from the source graph or copied from the ClipboardGraph.
*/
getTarget(
_context: ClipboardOperationContext,
sourceLabel: ILabel,
): ILabelOwner | null {
// sourceLabel lives in the clipboard graph
// get the original label, i.e. the label which has been copied from the original graph
const originalLabel = this.idProvider.getItem(
this.clipboardContext!,
this.getId(sourceLabel),
) as ILabel
// return the original label's owner as the pasted label's owner
return originalLabel.owner
}