本文整理匯總了Java中org.eclipse.swt.dnd.Clipboard.dispose方法的典型用法代碼示例。如果您正苦於以下問題:Java Clipboard.dispose方法的具體用法?Java Clipboard.dispose怎麽用?Java Clipboard.dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.dnd.Clipboard
的用法示例。
在下文中一共展示了Clipboard.dispose方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: copy
import org.eclipse.swt.dnd.Clipboard; //導入方法依賴的package包/類
/**
* Copies the current selection to the clipboard.
*
* @param list the data source
*/
protected void copy(final List list) {
if (canCopy(list)) {
final StringBuilder data = new StringBuilder();
for (int row = 0; row < list.getSelectionCount(); row++) {
data.append(list.getSelection()[row]);
if (row != list.getSelectionCount() - 1) {
data.append(NewLine.SYSTEM_LINE_SEPARATOR);
}
}
final Clipboard clipboard = new Clipboard(list.getDisplay());
clipboard.setContents(new String[] { data.toString() }, new TextTransfer[] { TextTransfer.getInstance() });
clipboard.dispose();
}
}
示例2: copySelectedAsTabDelimited
import org.eclipse.swt.dnd.Clipboard; //導入方法依賴的package包/類
private void copySelectedAsTabDelimited() {
StringBuffer stringBuffer = new StringBuffer();
int totalRowCount = debugDataViewer.getTableViewer().getTable().getItemCount();
int totalColumnCount = debugDataViewer.getTableViewer().getTable().getColumnCount();
boolean hasRow=false;
for (int rowCount = 0; rowCount < totalRowCount; rowCount++) {
for (int columnCount = 0; columnCount < totalColumnCount; columnCount++) {
Point cell = new Point(rowCount, columnCount);
if(debugDataViewer.getSelectedCell().contains(cell)){
stringBuffer.append(debugDataViewer.getTableViewer().getTable().getItem(rowCount).getText(columnCount) + "\t");
hasRow=true;
}
cell=null;
}
if(hasRow){
stringBuffer.append("\n");
hasRow=false;
}
}
Clipboard cb = new Clipboard(Display.getCurrent());
TextTransfer textTransfer = TextTransfer.getInstance();
String textData = stringBuffer.toString();
cb.setContents(new Object[] { textData }, new Transfer[] { textTransfer });
cb.dispose();
}
示例3: 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();
}
示例4: run
import org.eclipse.swt.dnd.Clipboard; //導入方法依賴的package包/類
/**
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
PasswordSafeJFace app = PasswordSafeJFace.getApp();
PwsEntryBean selected = app.getSelectedRecord();
if (selected == null)
return;
// retrieve filled Entry, always needed for passwords
PwsEntryBean theEntry = app.getPwsDataStore().getEntry(selected.getStoreIndex());
Clipboard cb = new Clipboard(app.getShell().getDisplay());
app.copyToClipboard(cb, theEntry.getPassword().toString());
final IPreferenceStore thePrefs = JFacePreferences.getPreferenceStore();
final boolean recordAccessTime = thePrefs
.getBoolean(JpwPreferenceConstants.RECORD_LAST_ACCESS_TIME);
if (recordAccessTime) { // this could/should be sent to a background
// thread
app.updateAccessTime(theEntry);
}
cb.dispose();
}
示例5: execute
import org.eclipse.swt.dnd.Clipboard; //導入方法依賴的package包/類
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
String url = getBookmarkUrl(selection);
if (url == null) {
return null;
}
Clipboard clipboard = new Clipboard(null);
try {
TextTransfer textTransfer = TextTransfer.getInstance();
Transfer[] transfers = new Transfer[] { textTransfer };
Object[] data = new Object[] { url };
clipboard.setContents(data, transfers);
} finally {
clipboard.dispose();
}
return null;
}
示例6: 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();
}
}
示例7: 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();
}
}
示例8: 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;
}
示例9: run
import org.eclipse.swt.dnd.Clipboard; //導入方法依賴的package包/類
public void run() {
ISelection sel = viewer.getSelection();
if (sel instanceof StructuredSelection) {
if (sel.isEmpty())
return;
List<String> paths = new ArrayList<String>();
@SuppressWarnings("unchecked")
Iterator<File> i = ((StructuredSelection)sel).iterator();
while (i.hasNext()) {
File file = i.next();
if (file.isDirectory()) continue;
paths.add(file.getAbsolutePath());
}
Clipboard clipboard = new Clipboard(Display.getDefault());
clipboard.setContents(new Object[] { (String[])paths.toArray(new String[paths.size()]) }, new Transfer[] { FileTransfer.getInstance() });
clipboard.dispose();
}
}
示例10: copySelected
import org.eclipse.swt.dnd.Clipboard; //導入方法依賴的package包/類
/***************************************************************************
* Copy selected source rows
**************************************************************************/
public void copySelected()
{
GridItem[] selection = getGrid().getSelection();
Clipboard clipboard = new Clipboard(Display.getCurrent());
String data = "";
for (GridItem item : selection)
{
if (!data.isEmpty())
data += "\n";
String line = item.getText(CodeViewerColumn.CODE.ordinal());
if (line != null)
{
line = line.trim();
}
else
{
line = "";
}
data += line;
}
clipboard.setContents(new Object[] { data }, new Transfer[] { TextTransfer.getInstance() });
clipboard.dispose();
}
示例11: copyToClipboard
import org.eclipse.swt.dnd.Clipboard; //導入方法依賴的package包/類
protected void copyToClipboard(IStructuredSelection selection) {
StringBuilder sb = new StringBuilder();
for (Object object : (List<?>) selection.toList()) {
if(object instanceof TreeParent){
TreeParent tp = (TreeParent) object;
object = tp.getNamedElement();
if(object != null){
NamedElement elt = (NamedElement) object;
sb.append(elt.getNameAndVersion()).append("\n");
} else if(tp instanceof TreeProblem) {
sb.append(((TreeProblem) tp).getProblem()).append("\n");
}
}
}
TextTransfer textTransfer = TextTransfer.getInstance();
final Clipboard cb = new Clipboard(getSite().getShell().getDisplay());
try {
cb.setContents(new Object[]{sb.toString()}, new Transfer[]{textTransfer});
} finally {
cb.dispose();
}
}
示例12: 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();
}
示例13: copyTaskAsHTML
import org.eclipse.swt.dnd.Clipboard; //導入方法依賴的package包/類
public void copyTaskAsHTML(ITask task) {
StringBuilder sb = new StringBuilder();
String taskKey = task.getTaskId();
if (taskKey != null) {
sb.append("<a href=\"" + task.getUrl() + "\">");
sb.append(taskKey);
sb.append("</a>");
sb.append(": ");
}
sb.append(task.getSummary());
HTMLTransfer textTransfer = HTMLTransfer.getInstance();
TextTransfer tt = TextTransfer.getInstance();
Clipboard clipboard = new Clipboard(Display.getCurrent());
clipboard.setContents(new String[] { sb.toString(), sb.toString() }, new Transfer[] { textTransfer, tt });
clipboard.dispose();
}
示例14: 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();
}
示例15: 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();
if (explorerView != null) {
String sXml;
if (explorerView.isEditing()) {
sXml = explorerView.getEditingText();
}
else {
// copy to clipboard manager
sXml = copy(explorerView);
}
// copy to system clipboard
if (sXml != null) {
Clipboard clipboard = new Clipboard(display);
TextTransfer textTransfer = TextTransfer.getInstance();
clipboard.setContents(new String[]{sXml}, new Transfer[]{textTransfer});
clipboard.dispose();
}
}
}
catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to copy!");
}
finally {
shell.setCursor(null);
waitCursor.dispose();
}
}