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


Java Clipboard.getContents方法代码示例

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


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

示例1: updateUI

import org.eclipse.swt.dnd.Clipboard; //导入方法依赖的package包/类
@Override
public void updateUI() {
	boolean bTorrentInClipboard = false;

	Clipboard clipboard = new Clipboard(Display.getDefault());

	String sClipText = (String) clipboard.getContents(TextTransfer.getInstance());
	if (sClipText != null)
		bTorrentInClipboard = addTorrentsFromTextList(sClipText, true) > 0;

	if (btnPasteOpen != null && !btnPasteOpen.isDisposed()
			&& btnPasteOpen.isVisible() != bTorrentInClipboard) {
		btnPasteOpen.setVisible(bTorrentInClipboard);
		if (bTorrentInClipboard) {
			btnPasteOpen.setToolTipText(sClipText);
		}
	}

	clipboard.dispose();
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:21,代码来源:OpenTorrentWindow.java

示例2: getStructuredSelectionFromClipboard

import org.eclipse.swt.dnd.Clipboard; //导入方法依赖的package包/类
private IStructuredSelection getStructuredSelectionFromClipboard(Display display) {
	Clipboard clipboard = new Clipboard(display);
	try {
		String text = (String) clipboard.getContents(URLTransfer.getInstance());
		if (text == null) {
			text = (String) clipboard.getContents(TextTransfer.getInstance());
		}
		if (text != null) {
			try {
				URL url = new URL(text);
				return new StructuredSelection(url);
			} catch (MalformedURLException e) {

			}
		}
		String[] paths = (String[]) clipboard.getContents(FileTransfer.getInstance());
		if (paths != null) {
			return new StructuredSelection(Arrays.stream(paths).map(Path::new).collect(Collectors.toList()));
		}
		return new StructuredSelection();
	} finally {
		clipboard.dispose();
	}
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:25,代码来源:PasteBookmarkOperation.java

示例3: fromClipboard

import org.eclipse.swt.dnd.Clipboard; //导入方法依赖的package包/类
protected String fromClipboard(IEditorPart editor) {
       Shell shell = editor.getSite().getShell();
       Display display = shell.getDisplay();
       Clipboard clip = new Clipboard(display);
       try {
           TextTransfer transfer = TextTransfer.getInstance();
           return (String)clip.getContents(transfer);
       }
       catch(Exception e) {
       	ElementHelper.panic(log, "from clipboard", e);
       	throw new RuntimeException(e);
       }
       finally {
           clip.dispose();
       }
}
 
开发者ID:insweat,项目名称:hssd,代码行数:17,代码来源:AbstractCommandHandler.java

示例4: test

import org.eclipse.swt.dnd.Clipboard; //导入方法依赖的package包/类
@Override
public boolean test(Object receiver, String property, Object[] args,
        Object expectedValue) {
    if("hasTextContent".equals(property)) {
        IWorkbenchPart part = Helper.getActivePart();
        if(part == null) {
            return false;
        }
        
        Display display = part.getSite().getShell().getDisplay();
        Clipboard clip = new Clipboard(display);
        Object content = clip.getContents(TextTransfer.getInstance());
        clip.dispose();
        return expectedValue.equals(content != null);
    }
    return false;
}
 
开发者ID:insweat,项目名称:hssd,代码行数:18,代码来源:ClipboardTester.java

示例5: getContents

import org.eclipse.swt.dnd.Clipboard; //导入方法依赖的package包/类
private ITransferableSpi getContents(final Clipboard clipboard) {
    final Map<TransferTypeSpi, Object> transferMap = new LinkedHashMap<TransferTypeSpi, Object>();
    for (final TransferData transferData : clipboard.getAvailableTypes()) {
        if (TEXT_TRANSFER.isSupportedType(transferData)) {
            transferMap.put(new TransferTypeSpi(String.class), clipboard.getContents(TEXT_TRANSFER));
        }
        else if (OBJECT_TRANSFER.isSupportedType(transferData)) {
            final Object data = clipboard.getContents(OBJECT_TRANSFER);
            if (data instanceof TransferContainer) {
                for (final TransferObject transferObject : ((TransferContainer) data).getTransferObjetcs()) {
                    transferMap.put(transferObject.getTransferType(), transferObject.getData());
                }
            }
        }
    }
    if (!transferMap.isEmpty()) {
        return new TransferableSpiAdapter(transferMap);
    }
    else {
        return null;
    }
}
 
开发者ID:jo-source,项目名称:jo-widgets,代码行数:23,代码来源:SwtClipboard.java

示例6: getCachedContents

import org.eclipse.swt.dnd.Clipboard; //导入方法依赖的package包/类
/**
 * Return the clipboard contents from our local cache, if the contents are present and support the acceptableType
 * 
 * @param acceptableTypes
 * @param clipboard
 * @return ClipboardContents
 */
private ClipboardContents getCachedContents(List<TransferData> acceptableTypes, Clipboard clipboard) {
	TransferData type = getMatchingType(acceptableTypes);
	if (type != null) {
		Transfer markerTransfer = markerTransferProvider.getTransfer();
		Object markerTransferObject = clipboard.getContents(markerTransfer);
		if (markerTransferObject instanceof byte[]) {
			ITransferable transferable = markerTransferProvider.unpackTransferObject((byte[]) markerTransferObject);
			if (transferable instanceof MarkerTransferable) {
				MarkerTransferable markerTransferable = (MarkerTransferable) transferable;
				if (markerTransferable.getMarker() == cachedClipboardMarker.getMarker()) {
					return new ClipboardContents(type, cachedClipboardTransferable);
				}
			}
		}
	}
	return null;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:25,代码来源:TransferRegistry.java

示例7: copy

import org.eclipse.swt.dnd.Clipboard; //导入方法依赖的package包/类
/**
 * 执行复制时对标记的处理,复制后在OS系统中不能包含标记占位符 ;
 */
private void copy() {
	super.doOperation(ITextOperationTarget.COPY);
	TextTransfer plainTextTransfer = TextTransfer.getInstance();
	XLiffTextTransfer hsTextTransfer = XLiffTextTransfer.getInstance();
	Clipboard clipboard = new Clipboard(getTextWidget().getDisplay());
	String plainText = (String) clipboard.getContents(plainTextTransfer);
	if (plainText == null || plainText.length() == 0) {
		return;
	}
	plainText = plainText.replaceAll(Utils.getLineSeparator(), "\n");
	plainText = plainText.replaceAll(Constants.LINE_SEPARATOR_CHARACTER + "", "");
	plainText = plainText.replaceAll(Constants.TAB_CHARACTER + "", "\t");
	plainText = plainText.replaceAll(Constants.SPACE_CHARACTER + "", " ");
	plainText = plainText.replaceAll("\u200B", "");
	clipboard.clearContents();
	Object[] data = new Object[] { PATTERN.matcher(plainText).replaceAll(""), plainText };
	Transfer[] types = new Transfer[] { plainTextTransfer, hsTextTransfer };

	clipboard.setContents(data, types, DND.CLIPBOARD);
	clipboard.dispose();
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:25,代码来源:SegmentViewer.java

示例8: updateUI

import org.eclipse.swt.dnd.Clipboard; //导入方法依赖的package包/类
public void updateUI() {
	boolean bTorrentInClipboard = false;

	Clipboard clipboard = new Clipboard(Display.getDefault());

	String sClipText = (String) clipboard.getContents(TextTransfer.getInstance());
	if (sClipText != null)
		bTorrentInClipboard = addTorrentsFromTextList(sClipText, true) > 0;

	if (btnPasteOpen != null && !btnPasteOpen.isDisposed()
			&& btnPasteOpen.isVisible() != bTorrentInClipboard) {
		btnPasteOpen.setVisible(bTorrentInClipboard);
		if (bTorrentInClipboard) {
			btnPasteOpen.setToolTipText(sClipText);
		}
	}

	clipboard.dispose();
}
 
开发者ID:AcademicTorrents,项目名称:AcademicTorrents-Downloader,代码行数:20,代码来源:OpenTorrentWindow.java

示例9: copy

import org.eclipse.swt.dnd.Clipboard; //导入方法依赖的package包/类
/**
 * 执行复制时对标记的处理,复制后在OS系统中不能包含标记占位符 ;
 */
private void copy() {
	super.doOperation(ITextOperationTarget.COPY);
	TextTransfer plainTextTransfer = TextTransfer.getInstance();
	HSTextTransfer hsTextTransfer = HSTextTransfer.getInstance();
	Clipboard clipboard = new Clipboard(getTextWidget().getDisplay());
	String plainText = (String) clipboard.getContents(plainTextTransfer);
	if (plainText == null || plainText.length() == 0) {
		return;
	}
	plainText = plainText.replaceAll(System.getProperty("line.separator"), "\n");
	plainText = plainText.replaceAll(TmxEditorConstanst.LINE_SEPARATOR_CHARACTER + "", "");
	plainText = plainText.replaceAll(TmxEditorConstanst.TAB_CHARACTER + "", "\t");
	plainText = plainText.replaceAll(TmxEditorConstanst.SPACE_CHARACTER + "", " ");
	plainText = plainText.replaceAll("\u200B", "");
	clipboard.clearContents();
	Object[] data = new Object[] { PATTERN.matcher(plainText).replaceAll(""), plainText };
	Transfer[] types = new Transfer[] { plainTextTransfer, hsTextTransfer };

	clipboard.setContents(data, types);
	clipboard.dispose();
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:25,代码来源:CellEditorTextViewer.java

示例10: run

import org.eclipse.swt.dnd.Clipboard; //导入方法依赖的package包/类
public void run() {
	Display display = Display.getDefault();
	Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);		
	
	Shell shell = getParentShell();
	shell.setCursor(waitCursor);
       
	try {
   		ProjectExplorerView explorerView = getProjectExplorerView();
   		TreeObject selectedTreeObject = explorerView.getFirstSelectedTreeObject();
   		
   		String source = null;
   		if (!clipboardManager.isCut) {
        	Clipboard clipboard = new Clipboard(display);
        	TextTransfer textTransfer = TextTransfer.getInstance();
        	source = (String)clipboard.getContents(textTransfer);
        	clipboard.dispose();
   		}
   		
   		if (explorerView.isEditing()) {
   			explorerView.setEditingText(source);
   		}
   		else paste(source, shell, explorerView, selectedTreeObject);
	}
	catch (Throwable e) {
		ConvertigoPlugin.logException(e, "Unable to paste!");
	}
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:33,代码来源:ClipboardPasteAction.java

示例11: execute

import org.eclipse.swt.dnd.Clipboard; //导入方法依赖的package包/类
protected void execute(IAction action)
throws InvocationTargetException, InterruptedException {
       Clipboard clipboard = new Clipboard(getShell().getDisplay());
       final ISVNRemoteResource resource = (ISVNRemoteResource)clipboard.getContents(RemoteResourceTransfer.getInstance());
       clipboard.dispose();

          RepositoryManager manager = SVNUIPlugin.getPlugin().getRepositoryManager();
          final String message = manager.promptForComment(getShell(), new IResource[]{});

          if (message == null)
              return; // canceled
          
          ISVNRemoteResource selectedResource = getSelectedRemoteResources()[0];
          final ISVNRemoteFolder destination = 
              (selectedResource.isFolder()?
                  (ISVNRemoteFolder)selectedResource:selectedResource.getParent());
          
          run(new IRunnableWithProgress() {
              public void run(IProgressMonitor monitor)throws  InvocationTargetException {
                  try {
                      SVNProviderPlugin.getPlugin().getRepositoryResourcesManager().
                          copyRemoteResource(resource,destination,message,monitor);
                  } catch (TeamException e) {
                      throw new InvocationTargetException(e);
                  }
              }
          }, true /* cancelable */, PROGRESS_BUSYCURSOR); //$NON-NLS-1$
  }
 
开发者ID:subclipse,项目名称:subclipse,代码行数:29,代码来源:PasteRemoteResourceAction.java

示例12: isEnabled

import org.eclipse.swt.dnd.Clipboard; //导入方法依赖的package包/类
protected boolean isEnabled() {
       if (getSelectedRemoteResources().length != 1)
           return false;
       
       boolean result;
       Clipboard clipboard = new Clipboard(getShell().getDisplay());
       result = clipboard.getContents(RemoteResourceTransfer.getInstance()) != null;
       clipboard.dispose();
	return result;
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:11,代码来源:PasteRemoteResourceAction.java

示例13: getTextClipboardContents

import org.eclipse.swt.dnd.Clipboard; //导入方法依赖的package包/类
private String getTextClipboardContents(Display display) {
	Clipboard clipboard = new Clipboard(display);
	String textData;
	try {
		TextTransfer textTransfer = TextTransfer.getInstance();
		textData = (String) clipboard.getContents(textTransfer);
	} finally {
		clipboard.dispose();
	}
	return textData;
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:12,代码来源:PasteBookmarkOperation.java

示例14: getClipboardText

import org.eclipse.swt.dnd.Clipboard; //导入方法依赖的package包/类
public String getClipboardText() {
    final String result;
    Display display = Display.getCurrent();
    Clipboard clipboard = new Clipboard(display);
    result = (String) clipboard.getContents(TextTransfer.getInstance());
    clipboard.dispose();
    return result == null ? "" : result; //$NON-NLS-1$
}
 
开发者ID:nilsschmidt1337,项目名称:ldparteditor,代码行数:9,代码来源:VM99Clipboard.java

示例15: test

import org.eclipse.swt.dnd.Clipboard; //导入方法依赖的package包/类
@Override
public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
	final Clipboard clipBoard = new Clipboard(PlatformUI.getWorkbench().getDisplay());
	final FileTransfer transfer = FileTransfer.getInstance();
	final String[] selection = (String[]) clipBoard.getContents(transfer);
	return selection != null;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:8,代码来源:ClipboardTester.java


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