本文整理汇总了Java中org.eclipse.swt.dnd.TransferData类的典型用法代码示例。如果您正苦于以下问题:Java TransferData类的具体用法?Java TransferData怎么用?Java TransferData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TransferData类属于org.eclipse.swt.dnd包,在下文中一共展示了TransferData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: javaToNative
import org.eclipse.swt.dnd.TransferData; //导入依赖的package包/类
@Override
public void javaToNative (Object object, TransferData transferData) {
if (!checkCustom(object) || !isSupportedType(transferData)) {
DND.error(DND.ERROR_INVALID_DATA);
}
byte [] bytes = null;
if (object instanceof ByteBuffer) {
bytes = ((ByteBuffer)object).array();
} else {
if (object instanceof byte []) {
bytes = (byte []) object;
}
}
if (bytes == null) {
DND.error(DND.ERROR_INVALID_DATA);
}
super.javaToNative(bytes, transferData);
}
示例2: nativeToJava
import org.eclipse.swt.dnd.TransferData; //导入依赖的package包/类
@Override
public Object nativeToJava(TransferData transferData) {
Object result = urlTransfer.nativeToJava(transferData);
if (DISABLED || result != null) {
return result;
}
if (DEBUG) System.out.println("nativeToJava called");
try {
if (isSupportedType(transferData)) {
byte [] buffer = (byte[]) super.nativeToJava(transferData);
return bytebufferToJava(buffer);
}
} catch (Exception e) {
Debug.out(e);
}
return null;
}
示例3: javaToNative
import org.eclipse.swt.dnd.TransferData; //导入依赖的package包/类
@Override
protected void javaToNative(final Object object, final TransferData transferData) {
if (object instanceof Integer) {
final byte[] bytes = ByteBuffer.allocate(4).putInt((Integer) object).array();
if (bytes != null) {
super.javaToNative(bytes, transferData);
}
} else if (object instanceof String) {
if (! TextTransfer.getInstance().isSupportedType(transferData)) {
// FIXME this is a hack - works on Linux x64...
// no danger for now as treegroups are disabled on drag side
long type = transferData.type;
for (final TransferData data : TextTransfer.getInstance().getSupportedTypes()) {
type = data.type;
}
// on 32bit you need int instead of long, to avoid compile errors there use this here
transferData.type = (int) type;
}
TextTransfer.getInstance().javaToNative(object, transferData);
}
}
示例4: getStructuredSelection
import org.eclipse.swt.dnd.TransferData; //导入依赖的package包/类
private IStructuredSelection getStructuredSelection(Object data, TransferData currentDataType) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(currentDataType)) {
return (IStructuredSelection) data;
}
if (URLTransfer.getInstance().isSupportedType(currentDataType)) {
try {
return new StructuredSelection(new URL((String) data));
} catch (MalformedURLException e) {
// ignore
}
}
if (FileTransfer.getInstance().isSupportedType(currentDataType)) {
return new StructuredSelection(Arrays.stream((String[]) data).map(Path::new).collect(Collectors.toList()));
}
return new StructuredSelection();
}
示例5: validateDrop
import org.eclipse.swt.dnd.TransferData; //导入依赖的package包/类
@Override
public boolean validateDrop(Object target, int operation, TransferData type) {
overrideOperation(DND.DROP_COPY);
// if (application == null)
// return false;
if (operation == DND.DROP_COPY || operation == DND.DROP_DEFAULT) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(type)) {
IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer()
.getSelection();
Object[] objects = selection.toArray();
for (Object obj : objects) {
if (obj instanceof CFServiceInstance) {
return true;
}
}
}
}
return false;
}
示例6: validateDrop
import org.eclipse.swt.dnd.TransferData; //导入依赖的package包/类
@Override
public boolean validateDrop(Object target, int operation, TransferData type) {
overrideOperation(DND.DROP_COPY);
// if (application == null)
// return false;
if (operation == DND.DROP_COPY || operation == DND.DROP_DEFAULT) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(type)) {
IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer()
.getSelection();
Object[] objects = selection.toArray();
for (Object obj : objects) {
if (obj instanceof CloudService) {
return true;
}
}
}
}
return false;
}
示例7: javaToNative
import org.eclipse.swt.dnd.TransferData; //导入依赖的package包/类
@Override
public void javaToNative(Object object, TransferData transferData) {
if (!checkMyType(object) || !isSupportedType(transferData)) {
DND.error(DND.ERROR_INVALID_DATA);
}
MyDummyType2 myTypes = (MyDummyType2) object;
try {
// write data to a byte array and then ask super to convert to
// pMedium
ByteArrayOutputStream out = new ByteArrayOutputStream();
DataOutputStream writeOut = new DataOutputStream(out);
writeOut.writeInt(myTypes.dummy);
byte[] buffer2 = out.toByteArray();
writeOut.close();
super.javaToNative(buffer2, transferData);
} catch (IOException e) {
}
}
示例8: nativeToJava
import org.eclipse.swt.dnd.TransferData; //导入依赖的package包/类
@Override
public Object nativeToJava(TransferData transferData) {
if (isSupportedType(transferData)) {
byte[] buffer = (byte[]) super.nativeToJava(transferData);
if (buffer == null)
return null;
MyDummyType2 datum = new MyDummyType2();
try {
ByteArrayInputStream in = new ByteArrayInputStream(buffer);
DataInputStream readIn = new DataInputStream(in);
datum.dummy = readIn.readInt();
readIn.close();
} catch (IOException ex) {
return null;
}
return datum;
}
return null;
}
示例9: javaToNative
import org.eclipse.swt.dnd.TransferData; //导入依赖的package包/类
@Override
public void javaToNative(Object object, TransferData transferData) {
if (!checkMyType(object) || !isSupportedType(transferData)) {
DND.error(DND.ERROR_INVALID_DATA);
}
MyDummyType myTypes = (MyDummyType) object;
try {
// write data to a byte array and then ask super to convert to
// pMedium
ByteArrayOutputStream out = new ByteArrayOutputStream();
DataOutputStream writeOut = new DataOutputStream(out);
writeOut.writeInt(myTypes.dummy);
byte[] buffer2 = out.toByteArray();
writeOut.close();
super.javaToNative(buffer2, transferData);
} catch (IOException e) {
}
}
示例10: nativeToJava
import org.eclipse.swt.dnd.TransferData; //导入依赖的package包/类
@Override
public Object nativeToJava(TransferData transferData) {
if (isSupportedType(transferData)) {
byte[] buffer = (byte[]) super.nativeToJava(transferData);
if (buffer == null)
return null;
MyDummyType datum = new MyDummyType();
try {
ByteArrayInputStream in = new ByteArrayInputStream(buffer);
DataInputStream readIn = new DataInputStream(in);
datum.dummy = readIn.readInt();
readIn.close();
} catch (IOException ex) {
return null;
}
return datum;
}
return null;
}
示例11: javaToNative
import org.eclipse.swt.dnd.TransferData; //导入依赖的package包/类
@Override
public void javaToNative(Object object, TransferData transferData) {
try {
if (!checkMyType(object) || !isSupportedType(transferData)) {
MessageDialog.openError(Application.getShell(), "Error", "You cannot drop this item here!");
DND.error(DND.ERROR_INVALID_DATA);
}
Server server = (Server) object;
// write data to a byte array and then ask super to convert to pMedium
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream writeOut = new ObjectOutputStream(out);
writeOut.writeObject(server);
byte[] buffer = out.toByteArray();
writeOut.close();
super.javaToNative(buffer, transferData);
} catch (IOException e) {
}
}
示例12: nativeToJava
import org.eclipse.swt.dnd.TransferData; //导入依赖的package包/类
@Override
public Object nativeToJava(TransferData transferData) {
if (isSupportedType(transferData)) {
byte[] buffer = (byte[]) super.nativeToJava(transferData);
if (buffer == null)
return null;
Server server;
try {
ByteArrayInputStream in = new ByteArrayInputStream(buffer);
ObjectInputStream readIn = new ObjectInputStream(in);
server = (Server) readIn.readObject();
readIn.close();
} catch (IOException | ClassNotFoundException ex) {
return null;
}
return server;
}
return null;
}
示例13: javaToNative
import org.eclipse.swt.dnd.TransferData; //导入依赖的package包/类
@Override
public void javaToNative(Object object, TransferData transferData) {
try {
if (!checkMyType(object) || !isSupportedType(transferData)) {
MessageDialog.openError(Application.getShell(), "Error", "You cannot drop this item here!");
DND.error(DND.ERROR_INVALID_DATA);
}
I2b2Project server = (I2b2Project) object;
// write data to a byte array and then ask super to convert to pMedium
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream writeOut = new ObjectOutputStream(out);
writeOut.writeObject(server);
byte[] buffer = out.toByteArray();
writeOut.close();
super.javaToNative(buffer, transferData);
} catch (IOException e) {
}
}
示例14: nativeToJava
import org.eclipse.swt.dnd.TransferData; //导入依赖的package包/类
@Override
public Object nativeToJava(TransferData transferData) {
if (isSupportedType(transferData)) {
byte[] buffer = (byte[]) super.nativeToJava(transferData);
if (buffer == null)
return null;
I2b2Project server;
try {
ByteArrayInputStream in = new ByteArrayInputStream(buffer);
ObjectInputStream readIn = new ObjectInputStream(in);
server = (I2b2Project) readIn.readObject();
readIn.close();
} catch (IOException | ClassNotFoundException ex) {
return null;
}
return server;
}
return null;
}
示例15: javaToNative
import org.eclipse.swt.dnd.TransferData; //导入依赖的package包/类
@Override
protected void javaToNative(Object object, TransferData transferData)
{
if (object instanceof SnippetElement)
{
SnippetElement snippetElement = (SnippetElement) object;
byte[] bytes = getBytes(snippetElement);
if (bytes != null)
{
super.javaToNative(bytes, transferData);
}
}
else
{
super.javaToNative(object, transferData);
}
}