Bug 31841 - [Clipboard] Provide support for "cut" from the clipboard
Summary: [Clipboard] Provide support for "cut" from the clipboard
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P3 enhancement with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: Kevin Barnes CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-13 17:52 EST by Kevin McGuire CLA
Modified: 2021-03-21 13:24 EDT (History)
8 users (show)

See Also:


Attachments
An implementation for the Preferred Drop Effect (3.81 KB, text/plain)
2006-04-23 11:32 EDT, Thomas Braun CLA
no flags Details
Clipboard class supporting delete-on-paste (4.95 KB, patch)
2006-04-30 04:01 EDT, Thomas Braun CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin McGuire CLA 2003-02-13 17:52:51 EST
M5

1. select a file in a windows explorer
2. cut it (cntrl-x)
3. select an eclipse project
4. select "Paste" from popup (or cntrl-v)

The file will be added to the project but the file in the windows explorer 
remains, and unfortunately is still in "cut" mode (ie. 'grayed').

It wasn't clear to me if we supported cut from windows.  If we don't, then 
maybe paste should be disabled but instead copy should work?
Comment 1 Simon Arsenault CLA 2003-02-14 15:30:27 EST
Knut, can you comment on this?
Comment 2 Knut Radloff CLA 2003-02-14 16:14:41 EST
I don't think we have a way of knowing if clipboard data was copied or cut to 
the clipboard. We only know that there is data on the clipboard.
CC'ing Veronika to confirm.

We do distinguish between copy and move when you drag a file from the Explorer 
to Eclipse Resource Navigator.
MS Word does the same we do. A paste inserts the data and leaves the file in 
the Explorer.
Comment 3 Veronika Irvine CLA 2003-02-17 09:23:43 EST
Currently there is no "cut" support on the clipboard in either direction 
(being a cut data source or a cut data destination).  New API would be 
required.

This would be a good enhancement for 2.2.
Comment 4 Simon Arsenault CLA 2003-02-17 09:56:28 EST
Reopening to reassign
Comment 5 Simon Arsenault CLA 2003-02-17 09:57:04 EST
To be considered for 2.2 stream then
Comment 6 Kevin McGuire CLA 2003-02-17 11:28:56 EST
Note that with the current behaviour, the user is left with an item in the 
windows explorer that is 'permanently' in cut (grayed) mode.  Its not 
terrible, but its likely somewhat disconcerting and looks funny.
Comment 7 Knut Radloff CLA 2003-02-17 19:06:32 EST
If you press ESC in the Windows Explorer the funny item state will go away. 
Agree that this is not good.
Comment 8 Veronika Irvine CLA 2003-06-16 10:42:19 EDT
The problem of having Windows in a "suspened" state is addressed by bug 38952.

Leaving this bug report open to track the requirement for a bi-
directional "cut" API.
Comment 9 Thomas Braun CLA 2006-03-13 07:07:05 EST
In one of my applications (a tool for file search) I'd like to add the possibility of cutting files so that they can be pastet in the windows explorer.
Is it such a problem to implement the cut-feature for SWT? Or is nobody elso out there who needs it? 
Comment 10 Daniel Spiewak CLA 2006-03-25 13:00:35 EST
It would be nice, but frankly impossible.  In Win Explorer, when a file is cut it is internally marked as having been cut.  Technically, the file still exists just as before until the file is pasted *in explorer.*  When the file is pasted, the file marked for cut is moved to the present location.  This isn't possible to implement in SWT, and seriously doubtful that it could be implemented in Eclipse without some flaky hack because it *is* internal to Windows Explorer.
Comment 11 Thomas Braun CLA 2006-03-26 03:40:29 EST
But why does it work in other windows applications, for example the image viewer ACDSee?

I have searched in MSDN and found the following article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_programming/transferring/datascenarios.asp

Please take a look at the sections "Handling Optimized Move Operations" and "Handling Delete-on-Paste Operations". I think this describes the way how to implement it.
Comment 12 Thomas Braun CLA 2006-04-23 11:32:57 EDT
Created attachment 39258 [details]
An implementation for the Preferred Drop Effect

The Windows Explorer stored the information whether to copy or paste the files in a transfer type named "Preferred DropEffect". (All documented in http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_programming/transferring/clipboard.asp?frame=true#CFSTR_PREFERREDDROPEFFECT).

I have implemented a PreferredDropEffectTransfer type which can read this information. It works well with files copied by the explorer. But I have problems with the "Preferred DropEffect" stored in the clipboard each time SWT puts something to the clipboard. Both data structures seem not to be compatible.

My knowledge about the whole DND/Clipboard internals is very limited and many of the SWT core methods are not commented. So I hope you will use the attached source code the fix the problem and integrate the clipboard drop effect support.
Comment 13 Thomas Braun CLA 2006-04-30 04:01:55 EDT
Created attachment 39900 [details]
Clipboard class supporting delete-on-paste

I've solved the problem. Two simple extensions to the Clipboard class enable the support for delete-on-paste. All changes are compatible to the existing implementation of the clipboard.

1. Setting the clipboard contents
The private method GetData(int, int) sets in its original version the preferred drop effect to COM.DROPEFFECT_COPY. I have changed this fixed value to a variable set by new setContents() methods.
If COM.DROPEFFECT_MOVE is provided the Explorer automatically moves the files instead of copying them.

2. Getting the clipboard contents
After (or before) calling Clipboard.getContents() you can call Clipboard.getPreferredDropEffect(). If the method returns DND.DROP_MOVE you know that you have to move and not to copy the files.
I'm reading the Preferred DropEffect using a separate Transfer class because it was easier for me to implement. I think you will implement this as a clipboard internal method.
Comment 14 Eclipse Webmaster CLA 2019-09-06 16:05:28 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.