Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 39258 Details for
Bug 31841
[Clipboard] Provide support for "cut" from the clipboard
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
An implementation for the Preferred Drop Effect
PreferredDropEffectTransfer.java (text/plain), 3.81 KB, created by
Thomas Braun
on 2006-04-23 11:32:57 EDT
(
hide
)
Description:
An implementation for the Preferred Drop Effect
Filename:
MIME Type:
Creator:
Thomas Braun
Created:
2006-04-23 11:32:57 EDT
Size:
3.81 KB
patch
obsolete
>package org.eclipse.swt.dnd; > > >import org.eclipse.swt.internal.ole.win32.COM; >import org.eclipse.swt.internal.ole.win32.FORMATETC; >import org.eclipse.swt.internal.ole.win32.IDataObject; >import org.eclipse.swt.internal.ole.win32.STGMEDIUM; >import org.eclipse.swt.internal.win32.OS; > > >/** > * The class provides a platform specific mechanism for reading and writing > * the preffered drop effect (copy or paste) from and to the clipboard.<br> > * This class is intended to be used in addition to {@link FileTransfer}. > * See {@link Transfer} for additional information. > * <p> > * An example is shown below: > * </p> > * <code><pre> > * PreferredDropEffectTransfer pdet = PreferredDropEffectTransfer.getInstance(); > * FileTransfer ft = FileTransfer.getInstance(); > * String[] files = (String[]) clipboard.getContents(ft); > * int effect = ((Integer) clipboard.getContents(pdet)).intValue(); > * // copy files > * if ((effect & DND.DROP_MOVE) != 0) > * for (int i = 0; i < files.length; i++) > * new File(files[i]).delete(); > * </code></pre> > * > * @author Thomas Braun > */ >public class PreferredDropEffectTransfer extends ByteArrayTransfer >{ > private static PreferredDropEffectTransfer _instance = > new PreferredDropEffectTransfer(); > private static final String CFSTR_PREFERREDDROPEFFECT = > "Preferred DropEffect"; //$NON-NLS-1$ > private static final int CF_ID = > registerType(CFSTR_PREFERREDDROPEFFECT); > > private PreferredDropEffectTransfer() > {} > > /** > * Returns the singleton instance of the class. > * > * @return the singleton instance of the class > */ > public static PreferredDropEffectTransfer getInstance() > { > return _instance; > } > > /** > * Not emplemented because the transfer type "Preferred DropEffect" > * generated by windows seems not compatible to the one of SWT. > */ > @Override > public void javaToNative(Object object, TransferData transferData) > { > if (!validate(object) || !isSupportedType(transferData)) { > DND.error(DND.ERROR_INVALID_DATA); > } > > // ... > } > > /** > * The method returns the preferred drop operation as integer object. > * The default result is DND.DROP_COPY. > * > * @see DND#DROP_COPY > * @see DND#DROP_LINK > * @see DND#DROP_MOVE > * @return an <code>Integer</code> containing the preferred drop operation > */ > @Override > public Object nativeToJava(TransferData transferData) > { > if (!isSupportedType(transferData) || transferData.pIDataObject == 0) > return DND.DROP_COPY; > > IDataObject dataObject = new IDataObject(transferData.pIDataObject); > dataObject.AddRef(); > FORMATETC formatetc = new FORMATETC(); > formatetc.cfFormat = CF_ID; > formatetc.ptd = 0; > formatetc.dwAspect = COM.DVASPECT_CONTENT; > formatetc.lindex = -1; > formatetc.tymed = COM.TYMED_HGLOBAL; > STGMEDIUM stgmedium = new STGMEDIUM(); > stgmedium.tymed = COM.TYMED_HGLOBAL; > transferData.result = dataObject.GetData(formatetc, stgmedium); > int[] i1 = new int[1]; > OS.MoveMemory(i1, stgmedium.unionField, 4); > int[] i2 = new int[1]; > OS.MoveMemory(i2, i1[0], 4); > dataObject.Release(); > > if (transferData.result != COM.S_OK) > return DND.DROP_COPY; > else > return osToOp(i2[0]); > } > > @Override > protected int[] getTypeIds() > { > return new int[]{ > CF_ID > }; > } > > private int osToOp(int osOperation) > { > int operation = 0; > if ((osOperation & COM.DROPEFFECT_COPY) != 0) { > operation |= DND.DROP_COPY; > } > if ((osOperation & COM.DROPEFFECT_LINK) != 0) { > operation |= DND.DROP_LINK; > } > if ((osOperation & COM.DROPEFFECT_MOVE) != 0) { > operation |= DND.DROP_MOVE; > } > return operation; > } > > @Override > protected String[] getTypeNames() > { > return new String[]{ > CFSTR_PREFERREDDROPEFFECT > }; > } > > @Override > protected boolean validate(Object object) > { > return object instanceof Integer; > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 31841
:
39258
|
39900