本文整理汇总了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();
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}
示例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$
}
示例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;
}
示例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;
}
示例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$
}
示例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;
}