|Copy & Paste default behavior [message #825165]
||Tue, 20 March 2012 14:58
| Felix Velasco
Registered: July 2009
Current default copy and paste behavior has a couple of problems that could be easily solved (and I am willing to provide both time and code):
* Not using LocalSelectionTransfer properly in the copy behavior prevents it from integrating with other views (see bug #374744)
* The FileTransfer and ResourceTransfer implementations copy the file of the owner resource into the clipboard. Even if this may have some applications, I think they are more likely corner cases. (see bug #361414)
* Using UriTransfer, while allowing local copy very easily, has severe problems when copying into a different diagram.
* A proposed one-liner is already in the bug report
* The File and Resource transfers should be used only if, for every object to be copied, a)the selected object is the only element contained in the given file, or b)the selected object can be adapted to a IResource (to leave an open door for specific implementations). I could attach a patch to the code, if you agree on this proposal.
* The last problem is a bit tricky. 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 the first point, 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. Again, if you feel this is the way to go, I could provide a working patch.
Powered by FUDForum
. Page generated in 0.01835 seconds