當前位置: 首頁>>代碼示例>>Java>>正文


Java DND.ERROR_CANNOT_SET_CLIPBOARD屬性代碼示例

本文整理匯總了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);
		}
	}
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:29,代碼來源:CopyAction.java

示例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);
		}
	}
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:27,代碼來源:EditActionProvider.java

示例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);
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:19,代碼來源:CopyToClipboardAction.java

示例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();
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:21,代碼來源:LocationCopyAction.java

示例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);
	}
}
 
開發者ID:grosenberg,項目名稱:fluentmark,代碼行數:10,代碼來源:CopyToClipboardAction.java

示例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);
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:11,代碼來源:CopyToClipboardAction.java

示例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
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:10,代碼來源:ClipboardOperationAction.java

示例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);
}
     }
 }
 
開發者ID:heartsome,項目名稱:translationstudio8,代碼行數:35,代碼來源:CopyAction.java


注:本文中的org.eclipse.swt.dnd.DND.ERROR_CANNOT_SET_CLIPBOARD屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。