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


Java Clipboard類代碼示例

本文整理匯總了Java中org.eclipse.swt.dnd.Clipboard的典型用法代碼示例。如果您正苦於以下問題:Java Clipboard類的具體用法?Java Clipboard怎麽用?Java Clipboard使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Clipboard類屬於org.eclipse.swt.dnd包,在下文中一共展示了Clipboard類的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();
	}
}
 
開發者ID:Albertus82,項目名稱:JFaceUtils,代碼行數:22,代碼來源:SystemInformationDialog.java

示例2: initCopyPaste

import org.eclipse.swt.dnd.Clipboard; //導入依賴的package包/類
/**
 * Initialize copy paste by getting the clipboard and hooking 
 * the actions to global edit menu.
 * 
 * @param viewer
 */
private void initCopyPaste(TreeViewer viewer) {
    this.clipboard = new Clipboard(getSite().getShell().getDisplay());
    
    IActionBars bars = getSite().getActionBars();
    bars.setGlobalActionHandler(
            ActionFactory.CUT.getId(), 
            (Action)outlineActions.get(ACTION_CUT));
    
    bars.setGlobalActionHandler(
            ActionFactory.COPY.getId(),
            (Action)outlineActions.get(ACTION_COPY));
    
    bars.setGlobalActionHandler(
            ActionFactory.PASTE.getId(),
            (Action)outlineActions.get(ACTION_PASTE));
    
    bars.setGlobalActionHandler(
            ActionFactory.DELETE.getId(),
            (Action)outlineActions.get(ACTION_DELETE));
}
 
開發者ID:eclipse,項目名稱:texlipse,代碼行數:27,代碼來源:TexOutlinePage.java

示例3: addDefaultInternalCommands

import org.eclipse.swt.dnd.Clipboard; //導入依賴的package包/類
private static void addDefaultInternalCommands(InternalCommandContextProvider provider, KaviPickListDialog kaviPickList) {
	provider.addCommand("list: toggle view selected", (currentProvider) -> {
		currentProvider.toggleViewOnlySelected();
		kaviPickList.togglePreviousProvider().refreshFromContentProvider();
	});
	
	provider.addCommand("list: selected to clipboard", (currentProvider) -> {
		
		Clipboard clipboard = new Clipboard(kaviPickList.getShell().getDisplay());
		final List<BiFunction<Object, Integer, String>> fieldResolvers = currentProvider.getKaviListColumns().getColumnOptions().stream()
				   .filter(column -> column.isSearchable())
				   .map(column -> column.getColumnContentFn())
				   .collect(Collectors.toList());
		
		FieldCollectorTransform transform = new FieldCollectorTransform(fieldResolvers, currentProvider.getSelectedEntriesImplied().stream().map(rankedItem -> rankedItem.dataItem).collect(Collectors.toList()));

		clipboard.setContents(new Object[] { transform.asAlignedColumns() },	new Transfer[] { TextTransfer.getInstance() });
		kaviPickList.togglePreviousProvider().refreshFromContentProvider();
		clipboard.dispose();
	});
	
	provider.addCommand("working", "list: toggle sort name", (currentProvider) -> {
		kaviPickList.togglePreviousProvider().sortDefault().refreshFromContentProvider();
	});		
}
 
開發者ID:dakaraphi,項目名稱:eclipse-plugin-commander,代碼行數:26,代碼來源:InternalCommandContextProviderFactory.java

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

示例5: 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();
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:21,代碼來源:OpenTorrentWindow.java

示例6: copyToClipBoard

import org.eclipse.swt.dnd.Clipboard; //導入依賴的package包/類
public static void
copyToClipBoard(
  final String    data )
{
 Runnable do_it =
new Runnable()
 	{
  @Override
  public void
  run()
  {
	  new Clipboard(Utils.getDisplay()).setContents(
			  new Object[] {data.replaceAll("\\x00", " " )  },
			  new Transfer[] {TextTransfer.getInstance()});
  }
 	};

 if ( Utils.isSWTThread()){

  do_it.run();

 }else{

  Utils.execSWTThread( do_it );
 }
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:27,代碼來源:ClipboardCopy.java

示例7: addCopyToClipMenu

import org.eclipse.swt.dnd.Clipboard; //導入依賴的package包/類
public static void
 addCopyToClipMenu(
final Menu		menu,
final String	text )
 {
  MenuItem   item = new MenuItem( menu,SWT.NONE );

  String	msg_text_id= "label.copy.to.clipboard";

  item.setText( MessageText.getString( msg_text_id ));

  item.addSelectionListener(
	  new SelectionAdapter()
	  {
		  @Override
		  public void
		  widgetSelected(
				  SelectionEvent arg0)
		  {
			  new Clipboard(menu.getDisplay()).setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()});
		  }
	  });
 }
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:24,代碼來源:ClipboardCopy.java

示例8: 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();
}
 
開發者ID:nresare,項目名稱:javapasswordsafe,代碼行數:28,代碼來源:CopyPasswordAction.java

示例9: 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;
}
 
開發者ID:cchabanois,項目名稱:mesfavoris,代碼行數:20,代碼來源:CopyBookmarkUrlHandler.java

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

示例11: copyTable

import org.eclipse.swt.dnd.Clipboard; //導入依賴的package包/類
/**
 * テーブルの選択されている部分をヘッダー付きでクリップボードにコピーします
 *
 * @param header ヘッダー
 * @param table テーブル
 */
public static void copyTable(String[] header, Table table) {
    TableItem[] tableItems = table.getSelection();
    StringBuilder sb = new StringBuilder();
    sb.append(StringUtils.join(header, "\t"));
    sb.append("\r\n");
    for (TableItem column : tableItems) {
        String[] columns = new String[header.length];
        for (int i = 0; i < header.length; i++) {
            columns[i] = column.getText(i);
        }
        sb.append(StringUtils.join(columns, "\t"));
        sb.append("\r\n");
    }
    Clipboard clipboard = new Clipboard(Display.getDefault());
    clipboard.setContents(new Object[] { sb.toString() }, new Transfer[] { TextTransfer.getInstance() });
}
 
開發者ID:sanaehirotaka,項目名稱:logbook,代碼行數:23,代碼來源:TableToClipboardAdapter.java

示例12: copyTree

import org.eclipse.swt.dnd.Clipboard; //導入依賴的package包/類
/**
 * ツリーの選択されている部分をヘッダー付きでクリップボードにコピーします
 * 
 * @param header ヘッダー
 * @param tree ツリー
 */
public static void copyTree(String[] header, Tree tree) {
    TreeItem[] treeItems = tree.getSelection();
    StringBuilder sb = new StringBuilder();
    sb.append(StringUtils.join(header, "\t"));
    sb.append("\r\n");
    for (TreeItem column : treeItems) {
        String[] columns = new String[header.length];
        for (int i = 0; i < header.length; i++) {
            columns[i] = column.getText(i);
        }
        sb.append(StringUtils.join(columns, "\t"));
        sb.append("\r\n");
    }
    Clipboard clipboard = new Clipboard(Display.getDefault());
    clipboard.setContents(new Object[] { sb.toString() }, new Transfer[] { TextTransfer.getInstance() });
}
 
開發者ID:sanaehirotaka,項目名稱:logbook,代碼行數:23,代碼來源:TreeToClipboardAdapter.java

示例13: 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();
       }
}
 
開發者ID:insweat,項目名稱:hssd,代碼行數:17,代碼來源:AbstractCommandHandler.java

示例14: 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;
}
 
開發者ID:insweat,項目名稱:hssd,代碼行數:18,代碼來源:ClipboardTester.java

示例15: copyToClipboard

import org.eclipse.swt.dnd.Clipboard; //導入依賴的package包/類
private void copyToClipboard(TreeItem[] items, Clipboard clipboard) {
    StringBuilder sb = new StringBuilder();

    for (TreeItem item : items) {
        Object data = item.getData();
        if (data != null) {
            sb.append(data.toString());
            sb.append('\n');
        }
    }

    String content = sb.toString();
    if (content.length() > 0) {
        clipboard.setContents(
                new Object[] {sb.toString()},
                new Transfer[] {TextTransfer.getInstance()}
                );
    }
}
 
開發者ID:utds3lab,項目名稱:SMVHunter,代碼行數:20,代碼來源:NativeHeapPanel.java


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