Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 374744 - ModelClipboard uses LocalSelectionTransfer wrong
Summary: ModelClipboard uses LocalSelectionTransfer wrong
Status: CLOSED FIXED
Alias: None
Product: Graphiti
Classification: Modeling
Component: Core (show other bugs)
Version: 0.8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 0.9.0   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: Juno M7 Theme_bugs
Keywords:
Depends on:
Blocks: 374918
  Show dependency tree
 
Reported: 2012-03-20 07:14 EDT by Felix Velasco CLA
Modified: 2012-06-29 04:24 EDT (History)
2 users (show)

See Also:
michael.wenz: iplog+
michael.wenz: juno+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Felix Velasco CLA 2012-03-20 07:14:39 EDT
Build Identifier: 

LocalSelectionTransfer is different from the other available transfers. Instead of using the data set in the Clipboard.setContents method, if uses the selection set by calling LocalSelectionTransfer.setSelection. This is because it's supposed to work only within the same running eclipse instance, so the data doesn't make it the OS's clipboard.

Currently, ModelClipboard.setNativeContentObjects "activates" the LocalSelectionTransfer, by calling setContents with it, but doesn't call setSelection, so either it's empty, or, even worse, it contains info from a previous, unrelated copy.

Solution proposed:
Change the toTransferObjects method of ModelClipboard, from:
> result.put(LocalSelectionTransfer.getTransfer(), new StructuredSelection(objects));

to:
> ISelection localSelection = new StructuredSelection(objects);
> LocalSelectionTransfer.getTransfer().setSelection(localSelection);
> result.put(LocalSelectionTransfer.getTransfer(), new Object());


Reproducible: Always
Comment 1 Michael Wenz CLA 2012-03-21 09:59:06 EDT
Indeed, this seems to be missing. But at least from a first look, I didn't get what effect this will have. Do you have an example where this causes an issue?
Comment 2 Felix Velasco CLA 2012-03-21 10:39:50 EDT
It prevents me from using the defaultCopyFeature, since I'm  using the LocalSelection for the paste.
Besides, since it activates the LocalSelection but leaves the content untouched, the workspace is left in a weird state. I can copy a text fragment, then copy from a diagram, and paste the original text fragment.
Comment 3 Michael Wenz CLA 2012-03-21 10:58:22 EDT
(In reply to comment #2)
> It prevents me from using the defaultCopyFeature, since I'm  using the
> LocalSelection for the paste.
> Besides, since it activates the LocalSelection but leaves the content
> untouched, the workspace is left in a weird state. I can copy a text fragment,
> then copy from a diagram, and paste the original text fragment.

Ok, understood. Thanks!
Comment 4 Michael Wenz CLA 2012-03-22 08:40:05 EDT
Thanks for this contribution! I have changed the coding as you suggested.

Checked-in and pusched to Eclipse:
commit ca8407ecd4cf174ff80cb01cb97c5b15f34557b3
Author: mwenz <michael.wenz@sap.com> 2012-03-22 13:38:02
Committer: mwenz <michael.wenz@sap.com> 2012-03-22 13:38:02
Parent: c6e6d127c3f1ab1da0f5ca33c581ee6669bf7d2b (Updated News&Noteworthy for M6)
Branches: origin/master, master
Comment 5 Michael Wenz CLA 2012-04-11 10:58:32 EDT
Bookkeeping: Set target release
Comment 6 Michael Wenz CLA 2012-06-29 04:24:55 EDT
Part of Graphiti 0.9.0 (Eclipse Juno)