本文整理汇总了Java中org.eclipse.swt.dnd.DND.ERROR_CANNOT_SET_CLIPBOARD属性的典型用法代码示例。如果您正苦于以下问题:Java DND.ERROR_CANNOT_SET_CLIPBOARD属性的具体用法?Java DND.ERROR_CANNOT_SET_CLIPBOARD怎么用?Java DND.ERROR_CANNOT_SET_CLIPBOARD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.swt.dnd.DND
的用法示例。
在下文中一共展示了DND.ERROR_CANNOT_SET_CLIPBOARD属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setClipboard
/**
* Set the clipboard contents. Prompt to retry if clipboard is busy.
*
* @param resources
* the resources to copy to the clipboard
* @param fileNames
* file names of the resources to copy to the clipboard
* @param names
* string representation of all names
*/
private void setClipboard(final IResource[] resources, final String[] fileNames, final String names) {
try {
// set the clipboard contents
if (fileNames.length > 0) {
clipboard.setContents(new Object[] { resources, fileNames, names }, new Transfer[] {
ResourceTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() });
} else {
clipboard.setContents(new Object[] { resources, names },
new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance() });
}
} catch (final SWTError e) {
if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) { throw e; }
if (MessageDialog.openQuestion(shell, "Problem with copy title", // TODO //$NON-NLS-1$
// ResourceNavigatorMessages.CopyToClipboardProblemDialog_title,
"Problem with copy.")) { //$NON-NLS-1$
setClipboard(resources, fileNames, names);
}
}
}
示例2: setClipboard
/**
* Set the clipboard contents. Prompt to retry if clipboard is busy.
*
* @param resources
* the resources to copy to the clipboard
* @param fileNames
* file names of the resources to copy to the clipboard
* @param names
* string representation of all names
*/
private void setClipboard(IResource[] resources, String[] fileNames, String names) {
try {
// set the clipboard contents
if (fileNames.length > 0) {
clipboard.setContents(new Object[] { resources, fileNames, names }, new Transfer[] { ResourceTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() });
} else {
clipboard.setContents(new Object[] { resources, names }, new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance() });
}
} catch (SWTError e) {
if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
throw e;
}
if (MessageDialog.openQuestion(shell, "Problem Copying to Clipboard", "There was a problem when accessing the system clipboard. Retry?")) {
setClipboard(resources, fileNames, names);
}
}
}
示例3: copyToClipboard
private void copyToClipboard(IResource[] resources, String[] fileNames, String names, IJavaElement[] javaElements, TypedSource[] typedSources, int repeat, Clipboard clipboard) {
final int repeat_max_count= 10;
try{
clipboard.setContents(createDataArray(resources, javaElements, fileNames, names, typedSources),
createDataTypeArray(resources, javaElements, fileNames, typedSources));
} catch (SWTError e) {
if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD || repeat >= repeat_max_count)
throw e;
if (fAutoRepeatOnFailure) {
try {
Thread.sleep(500);
} catch (InterruptedException e1) {
// do nothing.
}
}
if (fAutoRepeatOnFailure || MessageDialog.openQuestion(fShell, ReorgMessages.CopyToClipboardAction_4, ReorgMessages.CopyToClipboardAction_5))
copyToClipboard(resources, fileNames, names, javaElements, typedSources, repeat + 1, clipboard);
}
}
示例4: run
@Override
public void run() {
IStructuredSelection selection= (IStructuredSelection) fLocationViewer.getSelection();
StringBuffer buf= new StringBuffer();
for (Iterator<?> iterator= selection.iterator(); iterator.hasNext();) {
CallLocation location= (CallLocation) iterator.next();
buf.append(location.getLineNumber()).append('\t').append(location.getCallText());
buf.append('\n');
}
TextTransfer plainTextTransfer = TextTransfer.getInstance();
try {
fClipboard.setContents(
new String[]{ CopyCallHierarchyAction.convertLineTerminators(buf.toString()) },
new Transfer[]{ plainTextTransfer });
} catch (SWTError e){
if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
throw e;
if (MessageDialog.openQuestion(fViewSite.getShell(), CallHierarchyMessages.CopyCallHierarchyAction_problem, CallHierarchyMessages.CopyCallHierarchyAction_clipboard_busy))
run();
}
}
示例5: run
@Override
public void run() {
StringBuffer buf= new StringBuffer();
addCalls(fViewer.getTree().getSelection()[0], 0, buf);
TextTransfer plainTextTransfer= TextTransfer.getInstance();
try {
fClipboard.setContents(
new String[] { convertLineTerminators(buf.toString()) },
new Transfer[] { plainTextTransfer });
} catch (SWTError e) {
if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
throw e;
if (MessageDialog.openQuestion(fView.getViewSite().getShell(), CallHierarchyMessages.CopyCallHierarchyAction_problem, CallHierarchyMessages.CopyCallHierarchyAction_clipboard_busy))
run();
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:17,代码来源:CopyCallHierarchyAction.java
示例6: copyToClipboard
private void copyToClipboard(Clipboard clipboard, String str, Shell shell) {
try {
clipboard.setContents(new String[] { str }, new Transfer[] { TextTransfer.getInstance() });
} catch (SWTError ex) {
if (ex.code != DND.ERROR_CANNOT_SET_CLIPBOARD) throw ex;
String title = ActionMessages.CopyToClipboardAction_error_title;
String message = ActionMessages.CopyToClipboardAction_error_message;
if (MessageDialog.openQuestion(shell, title, message)) copyToClipboard(clipboard, str, shell);
}
}
示例7: copyToClipboard
private void copyToClipboard(ITextSelection selection, int repeatCount) {
try{
fClipboard.setContents(new String[] { selection.getText() }, new Transfer[] { TextTransfer.getInstance() });
} catch (SWTError e) {
if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD || repeatCount >= MAX_REPEAT_COUNT)
throw e;
if (MessageDialog.openQuestion(getShell(), InfoViewMessages.CopyToClipboard_error_title, InfoViewMessages.CopyToClipboard_error_message))
copyToClipboard(selection, repeatCount + 1);
}
}
示例8: setClipboardContents
private void setClipboardContents(Clipboard clipboard, Object[] datas, Transfer[] transfers) {
try {
clipboard.setContents(datas, transfers);
} catch (SWTError e) {
if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
throw e;
}
// silently fail. see e.g. https://bugs.eclipse.org/bugs/show_bug.cgi?id=65975
}
}
示例9: setClipboard
/**
* Set the clipboard contents. Prompt to retry if clipboard is busy.
*
* @param resources the resources to copy to the clipboard
* @param fileNames file names of the resources to copy to the clipboard
* @param names string representation of all names
*/
private void setClipboard(IResource[] resources, String[] fileNames,
String names) {
try {
// set the clipboard contents
if (fileNames.length > 0) {
clipboard.setContents(new Object[] { resources, fileNames,
names },
new Transfer[] { ResourceTransfer.getInstance(),
FileTransfer.getInstance(),
TextTransfer.getInstance() });
} else {
clipboard.setContents(new Object[] { resources, names },
new Transfer[] { ResourceTransfer.getInstance(),
TextTransfer.getInstance() });
}
} catch (SWTError e) {
if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
throw e;
}
if (MessageDialog
.openQuestion(
shell,
WorkbenchNavigatorMessages.actions_CopyAction_msgTitle, // TODO ResourceNavigatorMessages.CopyToClipboardProblemDialog_title, //$NON-NLS-1$
WorkbenchNavigatorMessages.actions_CopyAction_msg)) { //$NON-NLS-1$
setClipboard(resources, fileNames, names);
}
}
}