当前位置: 首页>>代码示例>>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;未经允许,请勿转载。