0

I am making use of SWT Clipboard for copying multiple items to the clipboard using the method setContents(Object[] data, Transfer[] dataTypes), where in the same method works well with more than one type of data having their respective Transfer types placed on the system clipboard. When multiple items belonging to the same type of data placed on the system clipboard does not work, wanted to make sure whether this is supported or not? Are there any alternatives available for copy/paste feature for holding multiple items belonging to the same data type as well as different data types?

 Object[] items = nodeItemsToCopy.toArray(new NodeItem[nodeItemsToCopy.size()]);
 List<TransferNodeItem> transferNodeItem = getTransferNodeItem();
 Transfer[] types = transferNodeItem.toArray(new Transfer[transferNodeItem.size()]);
 clipboard.setContents(items, transferNodeItem);

Here items are multiple items belonging to the same data type as well as different type with their respective transfer types.

  • I think you would have to define your own `Transfer` type for an array of objects to do this, but that would only work for code that understands the new transfer type. – greg-449 Oct 26 '15 at 08:23
  • @greg-449 Example : I have two items say A and B that belong to the same data type then I will have to register a transfer type for A and B to be unique ? (using org.eclipse.swt.dnd.Transfer.registerType(String formatName)) probably guess your hinting at this ? – Arun Kumar M Oct 26 '15 at 10:14
  • You would have to create a complete new transfer class probably based on `ByteArrayTransfer`, one of the things that would call would be `registerType`. But this will only work if the receiving program also knows about this transfer type. – greg-449 Oct 26 '15 at 10:22
  • @greg-449 Creation of the new class seems to be fine, but wanted clarification on the point that suppose there are 2 data types with 2 items belonging to each of them then in such a case I will have to register all the 4 items? Currently I have the same setup where in a separate transfer class does exist but I am just registering the datatypes and not the items individually, then reusing the registered data type for the items that belong to it respectively – Arun Kumar M Oct 27 '15 at 12:25

0 Answers0