Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 374918 - Let default paste use LocalSelectionTransfer
Summary: Let default paste use LocalSelectionTransfer
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: 374744
Blocks:
  Show dependency tree
 
Reported: 2012-03-21 10:43 EDT by Felix Velasco CLA
Modified: 2012-06-29 04:25 EDT (History)
2 users (show)

See Also:
michael.wenz: juno+


Attachments
Proposed patch (2.86 KB, patch)
2012-03-22 07:40 EDT, Felix Velasco CLA
michael.wenz: iplog+
Details | Diff
New test case (6.92 KB, patch)
2012-03-22 07:42 EDT, Felix Velasco CLA
michael.wenz: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Felix Velasco CLA 2012-03-21 10:43:12 EDT
Build Identifier: 

Currently, the default copy behavior is to store the copied objects URIs in the clipboard, and the obvious paste implementation is to use AbstractPasteFeature.getCopiesFromClipBoard(diagram) to retrieve them.

This way, ModelClipboard resolves the URIs in the target diagram's resourceSet. Even if the copied objects are modified, the ResourceSet resolves the URI to the live, in-memory version of the eobject. However, if we try to paste the eobject in a different diagram, that diagram's resourceset resolves the URI with the stale, in-disk version of the eobject, which may even not exist.

If we were using the LocalSelectionTransfer as per bug #374744, it could be used in ModelClipboard.getContentAsEObjects to retrieve the live eobjects. The current logic in the inner class CopyCommand should succeed in copying the objects in the target editing domain.

For more info, see http://www.eclipse.org/forums/index.php/t/313337/

Reproducible: Always
Comment 1 Felix Velasco CLA 2012-03-22 07:40:48 EDT
Created attachment 213051 [details]
Proposed patch

Use LocalSelectionTransfer both for copying and pasting. Solves both this bug and bug #374744.
Comment 2 Felix Velasco CLA 2012-03-22 07:42:33 EDT
Created attachment 213052 [details]
New test case

New test case, copying between two unsaved diagrams, that failed before this bug, yet works after applying the previous patch.
Comment 3 Michael Wenz CLA 2012-03-26 09:12:49 EDT
Thanks for the contributions! I have taken included them into our codebase (with minor changes) and submitted the stuff to Eclipse.
Comment 4 Michael Wenz CLA 2012-03-26 09:15:20 EDT
Besides I stumbled over another bug while testing this: the DefaultCopyFeature always made the editor dirty although nothing was changed; to fix this I have overridden the method hasDoneChanges and returned fase in that feature.
Comment 5 Michael Wenz CLA 2012-04-11 10:58:48 EDT
Bookkeeping: Set target release
Comment 6 Michael Wenz CLA 2012-06-29 04:25:06 EDT
Part of Graphiti 0.9.0 (Eclipse Juno)