ides.api.copypaste
Interface CopyPasteManager


public interface CopyPasteManager

Interface to the IDES CopyPasteManager. The manager is responsible for keeping track of whether cut, copy and paste options should be available to the user. Registered UI elements are automatically updated with the changing status of the cut, copy and paste system. The CopyPasteManager keeps track of the active CopyPastePresentation, which is the presentation that is queried for cut, copy and paste enabled status and for appropriate actions. Also provides actions to overwrite those in default swing components if required.

Author:
Valerie Sugarman

Method Summary
 void bindCutCopy(javax.swing.AbstractButton element)
          Registers an AbstractButton to be updated when the cut/copy state changes.
 void bindPaste(javax.swing.AbstractButton element)
          Registers an AbstractButton to be updated when the paste state changes.
 CopyPastePresentation getActiveCopyPastePresentation()
          Returns the active CopyPastePresentation, or null if there is no currently active CopyPastePresentation.
 java.awt.datatransfer.Clipboard getClipboard()
          Returns the clipboard used by IDES.
 javax.swing.Action getCopyOverwriteAction()
           In order for copy and paste to work for swing components that already have a copy and paste implementation, the default functionality must be overwritten.
 javax.swing.Action getCutOverwriteAction()
           In order for copy and paste to work for swing components that already have a copy and paste implementation, the default functionality must be overwritten.
 javax.swing.Action getPasteOverwriteAction()
           In order for copy and paste to work for swing components that already have a copy and paste implementation, the default functionality must be overwritten.
 void refresh()
           Updates the enabled status of the cut/copy/paste items on the menu and toolbar.
 void unbind(javax.swing.AbstractButton element)
          Unregisters an AbstractButton so that it is no longer updated when the cut/copy/paste state changes.
 

Method Detail

bindCutCopy

void bindCutCopy(javax.swing.AbstractButton element)
Registers an AbstractButton to be updated when the cut/copy state changes.

Parameters:
element - the UI element to be registered for automatic updates

bindPaste

void bindPaste(javax.swing.AbstractButton element)
Registers an AbstractButton to be updated when the paste state changes.

Parameters:
element - the UI element to be registered for automatic updates

unbind

void unbind(javax.swing.AbstractButton element)
Unregisters an AbstractButton so that it is no longer updated when the cut/copy/paste state changes.

Parameters:
element - the UI element to be unregistered from automatic updates

refresh

void refresh()

Updates the enabled status of the cut/copy/paste items on the menu and toolbar. If the clipboard contents have changed, calls newItemOnClipboard on the active CopyPastePresentation. Refreshes whenever there is a new active CopyPastePresentation or any of the other presentations call this method.

CopyPastePresentations should call this method when there is a change in some aspect such as a selection that could change whether cut, copy and paste should be enabled.


getClipboard

java.awt.datatransfer.Clipboard getClipboard()
Returns the clipboard used by IDES.

Returns:
the clipboard used by IDES

getActiveCopyPastePresentation

CopyPastePresentation getActiveCopyPastePresentation()
Returns the active CopyPastePresentation, or null if there is no currently active CopyPastePresentation.

Returns:
the active CopyPastePresentation, or null if there is no currently active CopyPastePresentation.

getCutOverwriteAction

javax.swing.Action getCutOverwriteAction()

In order for copy and paste to work for swing components that already have a copy and paste implementation, the default functionality must be overwritten. This action is meant to overwrite the default cut action in the ActionMap of a swing component.

An example of this is copy and pasting events represented in a JTable. In order to integrate with the IDES copy and paste system, and call the proper action defined in CopyPastePresentation's getCutAction(), the ActionMap must be overwritten as follows:

JTable table = new JTable();
Action cutAction = Hub.getCopyPasteManager().getCutOverwriteAction();
Action copyAction = Hub.getCopyPasteManager().getCopyOverwriteAction();
Action pasteAction = Hub.getCopyPasteManager().getPasteOverwriteAction();
table.getActionMap().put("cut", cutAction);
table.getActionMap().put("copy", copyAction);
table.getActionMap().put("paste", pasteAction);

Returns:
the cut action to be used when creating copy and paste for IDES elements using a swing component that already has a default copy and paste implementation.

getCopyOverwriteAction

javax.swing.Action getCopyOverwriteAction()

In order for copy and paste to work for swing components that already have a copy and paste implementation, the default functionality must be overwritten. This action is meant to overwrite the default cut action in the ActionMap of the swing component.

An example of this is copy and pasting events represented in a JTable. In order to integrate with the IDES copy and paste system, and call the proper action defined in CopyPastePresentation's getCopyAction(), the ActionMap must be overwritten as follows:

JTable table = new JTable();
Action cutAction = Hub.getCopyPasteManager().getCutOverwriteAction();
Action copyAction = Hub.getCopyPasteManager().getCopyOverwriteAction();
Action pasteAction = Hub.getCopyPasteManager().getPasteOverwriteAction();
table.getActionMap().put("cut", cutAction);
table.getActionMap().put("copy", copyAction);
table.getActionMap().put("paste", pasteAction);

Returns:
the copy action to be used when creating copy and paste for IDES elements using a swing component that already has a default copy and paste implementation.

getPasteOverwriteAction

javax.swing.Action getPasteOverwriteAction()

In order for copy and paste to work for swing components that already have a copy and paste implementation, the default functionality must be overwritten. This action is meant to overwrite the default cut action in the ActionMap of the swing component.

An example of this is copy and pasting events represented in a JTable. In order to integrate with the IDES copy and paste system, and call the proper action defined in CopyPastePresentation's getPasteAction(), the ActionMap must be overwritten as follows:

JTable table = new JTable();
Action cutAction = Hub.getCopyPasteManager().getCutOverwriteAction();
Action copyAction = Hub.getCopyPasteManager().getCopyOverwriteAction();
Action pasteAction = Hub.getCopyPasteManager().getPasteOverwriteAction();
table.getActionMap().put("cut", cutAction);
table.getActionMap().put("copy", copyAction);
table.getActionMap().put("paste", pasteAction);

Returns:
the paste action to be used when creating copy and paste for IDES elements using a swing component that already has a default copy and paste implementation.