当前位置: 首页>>代码示例>>Java>>正文


Java TransferData类代码示例

本文整理汇总了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);
}
 
开发者ID:TRUEJASONFANS,项目名称:JavaFX-FrameRateMeter,代码行数:19,代码来源:CustomTransfer.java

示例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;
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:20,代码来源:FixedURLTransfer.java

示例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);
	}
}
 
开发者ID:nresare,项目名称:javapasswordsafe,代码行数:23,代码来源:PwsEntryBeanTransfer.java

示例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();
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:17,代码来源:BookmarksViewerDropListener.java

示例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;
	}
 
开发者ID:eclipse,项目名称:cft,代码行数:21,代码来源:ServicesViewerDropListener.java

示例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;
	}
 
开发者ID:osswangxining,项目名称:dockerfoundry,代码行数:21,代码来源:ServicesViewerDropListener.java

示例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) {
    }
}
 
开发者ID:nilsschmidt1337,项目名称:ldparteditor,代码行数:19,代码来源:MyDummyTransfer2.java

示例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;
}
 
开发者ID:nilsschmidt1337,项目名称:ldparteditor,代码行数:22,代码来源:MyDummyTransfer2.java

示例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) {
    }
}
 
开发者ID:nilsschmidt1337,项目名称:ldparteditor,代码行数:19,代码来源:MyDummyTransfer.java

示例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;
}
 
开发者ID:nilsschmidt1337,项目名称:ldparteditor,代码行数:22,代码来源:MyDummyTransfer.java

示例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) {
		
	}
}
 
开发者ID:tmfev,项目名称:IDRT-Import-and-Mapping-Tool,代码行数:21,代码来源:ServerTransferType.java

示例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;
}
 
开发者ID:tmfev,项目名称:IDRT-Import-and-Mapping-Tool,代码行数:23,代码来源:ServerTransferType.java

示例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) {
		
	}
}
 
开发者ID:tmfev,项目名称:IDRT-Import-and-Mapping-Tool,代码行数:21,代码来源:I2b2ProjectTransferType.java

示例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;
}
 
开发者ID:tmfev,项目名称:IDRT-Import-and-Mapping-Tool,代码行数:23,代码来源:I2b2ProjectTransferType.java

示例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);
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:18,代码来源:SnippetTransfer.java


注:本文中的org.eclipse.swt.dnd.TransferData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。