本文整理匯總了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;
}