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


Java ByteArrayTransfer类代码示例

本文整理汇总了Java中org.eclipse.swt.dnd.ByteArrayTransfer的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayTransfer类的具体用法?Java ByteArrayTransfer怎么用?Java ByteArrayTransfer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ByteArrayTransfer类属于org.eclipse.swt.dnd包,在下文中一共展示了ByteArrayTransfer类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDataTypeArray

import org.eclipse.swt.dnd.ByteArrayTransfer; //导入依赖的package包/类
private static Transfer[] createDataTypeArray(IResource[] resources, IJavaElement[] javaElements, String[] fileNames, TypedSource[] typedSources) {
	List<ByteArrayTransfer> result= new ArrayList<ByteArrayTransfer>(4);
	if (resources.length != 0)
		result.add(ResourceTransfer.getInstance());
	if (javaElements.length != 0)
		result.add(JavaElementTransfer.getInstance());
	if (fileNames.length != 0)
		result.add(FileTransfer.getInstance());
	if (typedSources.length != 0)
		result.add(TypedSourceTransfer.getInstance());
	result.add(TextTransfer.getInstance());
	return result.toArray(new Transfer[result.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:CopyToClipboardAction.java

示例2: doCutCopyWithImportsOperation

import org.eclipse.swt.dnd.ByteArrayTransfer; //导入依赖的package包/类
private void doCutCopyWithImportsOperation() {
	ITextEditor editor= getTextEditor();
	ITypeRoot inputElement= JavaUI.getEditorInputTypeRoot(editor.getEditorInput());
	ISelection selection= editor.getSelectionProvider().getSelection();

	Object clipboardData= null;
	if (inputElement != null && selection instanceof ITextSelection && !selection.isEmpty()) {
		ITextSelection textSelection= (ITextSelection) selection;
		if (isNonTrivialSelection(textSelection)) {
			clipboardData= getClipboardData(inputElement, textSelection.getOffset(), textSelection.getLength());
		}
	}

	fOperationTarget.doOperation(fOperationCode);

	if (clipboardData != null) {
		/*
		 * We currently make assumptions about what the styled text widget sets,
		 * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=61876
		 */
		Clipboard clipboard= new Clipboard(getDisplay());
		try {
			Object textData= clipboard.getContents(TextTransfer.getInstance());
			/*
			 * Don't add if we didn't get any text data from the clipboard, see:
			 * - https://bugs.eclipse.org/bugs/show_bug.cgi?id=70077
			 * - https://bugs.eclipse.org/bugs/show_bug.cgi?id=200743
			 */
			if (textData == null)
				return;

			ArrayList<Object> datas= new ArrayList<Object>(3);
			ArrayList<ByteArrayTransfer> transfers= new ArrayList<ByteArrayTransfer>(3);
			datas.add(textData);
			transfers.add(TextTransfer.getInstance());

			Object rtfData= clipboard.getContents(RTFTransfer.getInstance());
			if (rtfData != null) {
				datas.add(rtfData);
				transfers.add(RTFTransfer.getInstance());
			}

			datas.add(clipboardData);
			transfers.add(fgTransferInstance);

			Transfer[] dataTypes= transfers.toArray(new Transfer[transfers.size()]);
			Object[] data= datas.toArray();
			setClipboardContents(clipboard, data, dataTypes);
		} finally {
			clipboard.dispose();
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:54,代码来源:ClipboardOperationAction.java


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