Proposal 

VOTE

Cut, Copy, Paste

Summary
 

The Eclipse workbench defines global actions for Cut, Copy, and Paste. The goal of this proposal is for all relevant platform workbench parts to provide semantically consistent handlers for these actions. Specifically, the handlers will provide a clipboard-based implementation of cut, copy, and paste. The main benefits of this proposal are:

1.      clipboard-based cut, copy, paste for moving and copying resources in the navigator

2.      copying textual representations of the selected item in most platform workbench parts (the equivalent of "Copy as text")

3.      consistently implementing cut/copy/paste to be the "keyboard equivalent" of drag and drop
 

By Karice McIntyre and Randy Giffen, OTI
Last Modified: December 14, 2001
 


Proposed Changes

1. Navigator View

2. Bookmarks View

3. Properties View

4. Outline View

5. Tasks View

Changes dependant upon work from other teams

·                                [CORE – P2]

[SWT – P1/P2]

Discussion

Current issues (this proposal is not intended to address all these issues)

  1. Not consistently implementing Cut, Copy, and Paste where drag and drop implemented (e.g. Navigator, Tasks).
  2. Requiring user interaction in copy implementation; using dialogs to copy resources (again, see Navigator)
  3. Need to be able to Cut, Copy, Paste all resources (projects, files, folders)
    1. within a workspace
    2. between workspaces
    3. between the workspace and other applications
  4. Need make sure we have transfer types for all known copy-able objects in the Resource perspective; this will be useful for those who want to use the clipboard to implement cut, copy, paste.
  5. Need to implement re-usable cut, copy, paste action handlers for all known objects in all views of the Resource perspective.
  6. Need to provide visual indication of cut.
  7. Need to be able to cancel Cut or Copy using Esc key. Need to check with SWT if this is currently possible (if not, enter a PR).
  8. F2 (Rename) is implemented in the Navigator, but not in the Packages view. Getting ISVs to consistently implement the same keyboard controls seems like a difficult thing to do.

Background

The most interesting case (for the UI team) of the Cut, Copy, and Paste implementation is in the Navigator. The best way to utilize Cut, Copy, and Paste and be consistent with drag and drop is to use the system clipboard to transfer resources within a workspace, between workspaces, and between a workspace and another application.

 
The clipboard model is fairly well understood by most users; it is frequently used to support text editing. Its use can be extended however, to support the idea of putting objects such as files on a clipboard (ex.MS File Explorer). Moving and copying files for example, can be achieved without requiring the use of a dedicated dialog that typically is used to indicate the destination of the operation. However, not all ISVs who implement Cut, Copy, Paste may want to or will be able to use a conceptual clipboard to perform these actions, so we will not impose this restriction upon everyone implementing these global actions.
 

The underlying clipboard support in SWT uses the concept of a Transfer (org.eclipse.swt.dnd.Transfer). A Transfer is essentially code that knows how to move something on and off the clipboard as bytes (note it may only put a reference on the clipboard such as a filename). Transfers have a stateless singleton instance accessed via a static getInstance method. SWT provides the following concrete types of transfers:

  1. TextTransfer - used to transfer plain text
  2. RTFTransfer - used to transfer text with rtf format
  3. FileTransfer - used to transfer files

The workbench defines the following transfer types:

  1. MarkerTansfer - used to transfer a marker (serializes resource path and marker id)
  2. PluginTransfer - used to support the drop action extension (not sure why this is used – Navigator uses this transfer type in DND, along with FileTransfer and ResourceTransfer)
  3. ResourceTransfer -used to transfer an IResource (includes path and type information; does not include bookmark or task markers, or metadata for projects – not yet anyway)

Of course if a plug-in wants to transfer an object that is not supported by one of the currently existing Transfer classes, a custom transfer can be implemented (see org.eclipse.ui.part.ResourceTransfer as an example). When one implements a transfer type, they must be sure not to lose any information pertaining to the object being transferred.It does not appear that additional transfer types are required to complete the transfer story for objects that exist in the Resource perspective.

An important point to note is that more than one type of transfer can be placed on the clipboard at a time. For example, performing a copy in the Navigator should cause a ResourceTransfer, a FileTransfer, and a TextTransfer to be placed on the clipboard (see Proposed Changes item 2 below for details on each of these transfer types). The enablement of a paste action, and the type of paste that is actually performed are determined by the target of the paste based on:

1.      its state (ex. current selection)

2.      the contents of the clipboard (the type of transfers available).

A frequently requested feature is the ability to copy a "selection as text" so that it can be used in a text editor. The use of a simple TextTransfer makes this easy. This should be performed by the Copy action. There is no need to define an additional "Copy Names" action as appears in the Packages view. In the case of a part using a standard JFace StructuredViewer, the copy action would use the labels of the selected items as the text to put on the clipboard but this could be customized as required.

Semantics of Cut/Copy/Paste in the Navigator

Vote Termination Date

The period for voting ends one week from the date the request for vote is submitted to the mailing list.