Package ghidra.app.services

# Interface ClipboardContentProviderService

public interface ClipboardContentProviderService
Determines what types of transfer data can be placed on the clipboard, as well as if cut, copy, and paste operations are supported

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addChangeListener(ChangeListener listener)`
  Adds a change listener that will be notified when the state of the service provider changes such that the ability to perform some actions has changed.
  `boolean`
  `canCopy()`
  Returns true if the given service provider can currently perform a copy operation.
  `boolean`
  `canCopySpecial()`
  Returns true if the given service provider can currently perform a 'copy special' operation.
  `boolean`
  `canPaste(DataFlavor[] availableFlavors)`
  Returns true if the service can perform a paste operation using the given transferable.
  `Transferable`
  `copy(TaskMonitor monitor)`
  Triggers the default copy operation
  `Transferable`
  `copySpecial(ClipboardType copyType, TaskMonitor monitor)`
  Triggers a special copy with the specified copy type.
  `default void`
  `customizeClipboardAction(DockingAction action)`
  Customize the given action.
  `boolean`
  `enableCopy()`
  Returns true if copy should be enabled; false if it should be disabled.
  `boolean`
  `enableCopySpecial()`
  Returns true if copySpecial actions should be enabled;
  `boolean`
  `enablePaste()`
  Returns true if paste should be enabled; false if it should be disabled.
  `default String`
  `getClipboardActionOwner()`
  Provide an alternative action owner.
  `ComponentProvider`
  `getComponentProvider()`
  Returns the component provider associated with this service
  `List<ClipboardType>`
  `getCurrentCopyTypes()`
  Gets the currently active ClipboardTypes for copying with the current context
  `boolean`
  `isValidContext(ActionContext context)`
  Return whether the given context is valid for actions on popup menus.
  `void`
  `lostOwnership(Transferable transferable)`
  Notification that the clipboard owner has lost its ownership.
  `boolean`
  `paste(Transferable pasteData)`
  Triggers the default paste operation for the given transferable
  `void`
  `removeChangeListener(ChangeListener listener)`
  Removes the given change listener.

- ## Method Details

  - ### getComponentProvider

    ComponentProvider getComponentProvider()
    Returns the component provider associated with this service
    Returns:
      the provider

  - ### copy

    Transferable copy(TaskMonitor monitor)
    Triggers the default copy operation
    Parameters:
      `monitor` - monitor that shows progress of the copy to clipboard, and may be canceled
    Returns:
      the created transferable; null if the copy was unsuccessful

  - ### copySpecial

    Transferable copySpecial(ClipboardType copyType, TaskMonitor monitor)
    Triggers a special copy with the specified copy type.
    Parameters:
      `copyType` - contains the data flavor of the clipboard contents
      `monitor` - monitor that shows progress of the copy to clipboard, and may be canceled
    Returns:
      the created transferable; null if the copy was unsuccessful

  - ### paste

    boolean paste(Transferable pasteData)
    Triggers the default paste operation for the given transferable
    Parameters:
      `pasteData` - the paste transferable
    Returns:
      true of the paste was successful

  - ### getCurrentCopyTypes

    List<ClipboardType> getCurrentCopyTypes()
    Gets the currently active ClipboardTypes for copying with the current context
    Returns:
      the types

  - ### isValidContext

    boolean isValidContext(ActionContext context)
    Return whether the given context is valid for actions on popup menus.
    Parameters:
      `context` - the context of where the popup menu will be positioned.
    Returns:
      true if valid

  - ### enableCopy

    boolean enableCopy()
    Returns true if copy should be enabled; false if it should be disabled. This method can be used in conjunction with `copy(TaskMonitor)` in order to add menu items to popup menus but to have them enabled when appropriate.
    Returns:
      true if copy should be enabled

  - ### enableCopySpecial

    boolean enableCopySpecial()
    Returns true if copySpecial actions should be enabled;
    Returns:
      true if copySpecial actions should be enabled;

  - ### enablePaste

    boolean enablePaste()
    Returns true if paste should be enabled; false if it should be disabled. This method can be used in conjunction with `paste(Transferable)` in order to add menu items to popup menus but to have them enabled when appropriate.
    Returns:
      true if paste should be enabled

  - ### lostOwnership

    void lostOwnership(Transferable transferable)
    Notification that the clipboard owner has lost its ownership.
    Parameters:
      `transferable` - the contents which the owner had placed on the clipboard

  - ### addChangeListener

    void addChangeListener(ChangeListener listener)
    Adds a change listener that will be notified when the state of the service provider changes such that the ability to perform some actions has changed. For example, the given listener will be called when a copy action can be performed when it was previously not possible.
    Parameters:
      `listener` - The listener to add.

  - ### removeChangeListener

    void removeChangeListener(ChangeListener listener)
    Removes the given change listener.
    Parameters:
      `listener` - The listener to remove.
    See Also:
      - `addChangeListener(ChangeListener)`

  - ### canPaste

    boolean canPaste(DataFlavor[] availableFlavors)
    Returns true if the service can perform a paste operation using the given transferable.
    Parameters:
      `availableFlavors` - data flavors available for the current clipboard transferable
    Returns:
      true if the service can perform a paste operation using the given transferable.

  - ### canCopy

    boolean canCopy()
    Returns true if the given service provider can currently perform a copy operation.
    Returns:
      true if the given service provider can currently perform a copy operation.

  - ### canCopySpecial

    boolean canCopySpecial()
    Returns true if the given service provider can currently perform a 'copy special' operation.
    Returns:
      true if copy special is enabled

  - ### getClipboardActionOwner

    default String getClipboardActionOwner()
    Provide an alternative action owner.

    This may be necessary if the key bindings or other user-customizable attributes need to be separated from the standard clipboard actions. By default, the clipboard service will create actions with a shared owner so that one keybinding, e.g., Ctrl-C, is shared across all Copy actions.

    Returns:
      the alternative owner, or null for the standard owner
    See Also:
      - `customizeClipboardAction(DockingAction)`

  - ### customizeClipboardAction

    default void customizeClipboardAction(DockingAction action)
    Customize the given action.

    This method is called at the end of the action's constructor, which takes placed before the action is added to the provider. By default, this method does nothing. Likely, you will need to know which action you are customizing. Inspect the action name.

    Parameters:
      `action` - the action
    See Also:
      - `getClipboardActionOwner()`