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 TypeMethodDescriptionvoid
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
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.copy
(TaskMonitor monitor) Triggers the default copy operationcopySpecial
(ClipboardType copyType, TaskMonitor monitor) Triggers a special copy with the specified copy type.default void
Customize the given action.boolean
Returns true if copy should be enabled; false if it should be disabled.boolean
Returns true if copySpecial actions should be enabled;boolean
Returns true if paste should be enabled; false if it should be disabled.default String
Provide an alternative action owner.Returns the component provider associated with this serviceGets the currently active ClipboardTypes for copying with the current contextboolean
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 transferablevoid
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
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
Triggers a special copy with the specified copy type.- Parameters:
copyType
- contains the data flavor of the clipboard contentsmonitor
- monitor that shows progress of the copy to clipboard, and may be canceled- Returns:
- the created transferable; null if the copy was unsuccessful
-
paste
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
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 withcopy(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 withpaste(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
Notification that the clipboard owner has lost its ownership.- Parameters:
transferable
- the contents which the owner had placed on the clipboard
-
addChangeListener
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
Removes the given change listener.- Parameters:
listener
- The listener to remove.- See Also:
-
canPaste
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
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
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:
-