當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。