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


Java TextTransfer.getInstance方法代碼示例

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


在下文中一共展示了TextTransfer.getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTransferType

import org.eclipse.swt.dnd.TextTransfer; //導入方法依賴的package包/類
Transfer getTransferType(String mime) {
    if (mime.equals("text/plain")) {
      return TextTransfer.getInstance();
    }
    if (mime.equals("text/rtf")) {
      return RTFTransfer.getInstance();
    }
    if (mime.equals("text/html")) {
      return HTMLTransfer.getInstance();
    }
    if (mime.equals("text/uri-list")) {
      return URLTransfer.getInstance();
    }
    if (mime.equals("application/x-java-rawimage")) {
      return ImageTransfer.getInstance();
    }
    if (mime.equals("application/x-java-file-list") || mime.equals("java.file-list")) {
        return FileTransfer.getInstance();
    }
    return getCustomTransfer(mime);
}
 
開發者ID:TRUEJASONFANS,項目名稱:JavaFX-FrameRateMeter,代碼行數:22,代碼來源:OldFXCanvas.java

示例2: applyDragFromTableViewer

import org.eclipse.swt.dnd.TextTransfer; //導入方法依賴的package包/類
public void applyDragFromTableViewer(Control sourceControl, int index) {
	Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
	final String portLabel = "in" + index + ".";
	int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
	final Table table = (Table) sourceControl;
	DragSource source = new DragSource(table, operations);
	source.setTransfer(types);
	final String[] columnData = new String[1];
	source.addDragListener(new DragSourceAdapter() {
		public void dragSetData(DragSourceEvent event) {
			// Set the data to be the first selected item's text
			event.data = addDelimeter(portLabel, table.getSelection());
		}
	});

}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:17,代碼來源:ELTSWTWidgets.java

示例3: copySelectedAsTabDelimited

import org.eclipse.swt.dnd.TextTransfer; //導入方法依賴的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

示例4: execute

import org.eclipse.swt.dnd.TextTransfer; //導入方法依賴的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

示例5: runWithEvent

import org.eclipse.swt.dnd.TextTransfer; //導入方法依賴的package包/類
@Override
public void runWithEvent(Event event) {
	ISelection selection = selectionProvider.getSelection();
	Collection<IProductModel> productModels = ProductSupport.toProductModels(selection);
	Collection<IFeatureModel> featureModels = FeatureSupport.toFeatureModels(selection);
	Collection<IPluginModelBase> pluginModels = PluginSupport.toPluginModels(selection);

	Collection<IProject> projects = new HashSet<IProject>();
	addUnderlyingResources(projects, productModels);
	addUnderlyingResources(projects, featureModels);
	addUnderlyingResources(projects, pluginModels);

	String[] fileData = new String[projects.size()];
	int i = 0;
	for (IProject project : projects) {
		fileData[i++] = project.getLocation().toOSString();
	}

	String textData = getTextData(productModels, featureModels, pluginModels);

	Object[] data = { projects.toArray(new IResource[projects.size()]), textData, fileData };
	Transfer[] dataTypes = { ResourceTransfer.getInstance(), TextTransfer.getInstance(), FileTransfer.getInstance() };
	clipboard.setContents(data, dataTypes);
}
 
開發者ID:secondfiddle,項目名稱:pep-tools,代碼行數:25,代碼來源:FeatureAndPluginCopyAction.java

示例6: run

import org.eclipse.swt.dnd.TextTransfer; //導入方法依賴的package包/類
@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,代碼行數:22,代碼來源:LocationCopyAction.java

示例7: serialize

import org.eclipse.swt.dnd.TextTransfer; //導入方法依賴的package包/類
public void serialize() {
	final Clipboard clipboard = command.getClipboard();
	final String cellDelimeter = command.getCellDelimeter();
	final String rowDelimeter = command.getRowDelimeter();
	
	final TextTransfer textTransfer = TextTransfer.getInstance();
	final StringBuilder textData = new StringBuilder();
	int currentRow = 0;
	for (LayerCell[] cells : copiedCells) {
		int currentCell = 0;
		for (LayerCell cell : cells) {
			final String delimeter = ++currentCell < cells.length ? cellDelimeter : "";
			if (cell != null) {
				textData.append(cell.getDataValue() + delimeter);
			} else {
				textData.append(delimeter);
			} 
		}
		if (++currentRow < copiedCells.length) {
			textData.append(rowDelimeter);
		}
	}
	clipboard.setContents(new Object[]{textData.toString()}, new Transfer[]{textTransfer});
}
 
開發者ID:heartsome,項目名稱:translationstudio8,代碼行數:25,代碼來源:CopyDataToClipboardSerializer.java

示例8: copyTaskAsHTML

import org.eclipse.swt.dnd.TextTransfer; //導入方法依賴的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();
}
 
開發者ID:turesheim,項目名稱:eclipse-timekeeper,代碼行數:17,代碼來源:CopyTaskDetailsToHTML.java

示例9: clipSelected

import org.eclipse.swt.dnd.TextTransfer; //導入方法依賴的package包/類
private void clipSelected()
{
	if (clipboard!=null) 
	{
		clipboard.dispose();
		clipboard=null;
	}

	clipboard = new Clipboard(getDisplay());
	TextTransfer tran = TextTransfer.getInstance();

	String clip = getSelectedText();
	
	if (clip==null) return;
	
	clipboard.setContents(new String[] { clip }, new Transfer[] { tran });
}
 
開發者ID:bsspirit,項目名稱:kettle-4.4.0-stable,代碼行數:18,代碼來源:TableView.java

示例10: clipSelected

import org.eclipse.swt.dnd.TextTransfer; //導入方法依賴的package包/類
private void clipSelected() {
  if ( clipboard != null ) {
    clipboard.dispose();
    clipboard = null;
  }

  clipboard = new Clipboard( getDisplay() );
  TextTransfer tran = TextTransfer.getInstance();

  String clip = getSelectedText();

  if ( clip == null ) {
    return;
  }

  clipboard.setContents( new String[]{ clip }, new Transfer[]{ tran } );
}
 
開發者ID:pentaho,項目名稱:pentaho-kettle,代碼行數:18,代碼來源:TableView.java

示例11: clipSelected

import org.eclipse.swt.dnd.TextTransfer; //導入方法依賴的package包/類
private void clipSelected() {
  if (clipboard != null) {
    clipboard.dispose();
    clipboard = null;
  }

  clipboard = new Clipboard(getDisplay());
  TextTransfer tran = TextTransfer.getInstance();

  String clip = getSelectedText();

  if (clip == null)
    return;

  clipboard.setContents(new String[] { clip }, new Transfer[] { tran });
}
 
開發者ID:jjeb,項目名稱:kettle-trunk,代碼行數:17,代碼來源:TableView.java

示例12: construct

import org.eclipse.swt.dnd.TextTransfer; //導入方法依賴的package包/類
@Override
public Control construct(Composite parent) {
	composite = createComposit(parent);
	TableViewer tableA = createTable(composite, getItemsForA());
	TableViewer tableB = createTable(composite, getItemsForB());
	TableViewer tableC = createTable(composite, getItemsForC());

	int operations = DND.DROP_COPY | DND.DROP_MOVE;
	Transfer[] transferTypes = new Transfer[] { TextTransfer.getInstance() };
	tableA.addDragSupport(operations, transferTypes, new MyDragListener(tableA));
	tableC.addDragSupport(operations, transferTypes, new MyDragListener(tableC));

	tableB.addDropSupport(operations, transferTypes, new MyDropListener(tableB));

	text = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
	text.setLayoutData(new GridData(GridData.FILL_BOTH));

	return null;
}
 
開發者ID:xored,項目名稱:q7.quality.mockups,代碼行數:20,代碼來源:RCPTT351_DragAndDropAtTable.java

示例13: selectionToClipboard

import org.eclipse.swt.dnd.TextTransfer; //導入方法依賴的package包/類
private void selectionToClipboard()
{
	Clipboard cb = new Clipboard(Display.getDefault());
	try
	{
		
		StructuredSelection selection = getParentSelection();
		// Text
		TextTransfer textTransfer = TextTransfer.getInstance();
		String text = getTextRepresentation(selection);
		// Auswahl
		
		LocalSelectionTransfer selectionTransfer = LocalSelectionTransfer.getTransfer();
		selectionTransfer.setSelection(selection);

		cb.setContents(new Object[]   { text, 		  selection },
					   new Transfer[] { textTransfer, selectionTransfer });
	}
	finally
	{
		cb.dispose();
	}
}
 
開發者ID:TheWhiteShadow3,項目名稱:cuina,代碼行數:24,代碼來源:DatabaseUtil.java

示例14: widgetSelected

import org.eclipse.swt.dnd.TextTransfer; //導入方法依賴的package包/類
/**
 * Process the action generated from the user interface.
 *
 * @param se - The event that caused this method to be called
 */
public void widgetSelected( SelectionEvent se ) {
    Object src = se.getSource( );
    if ( src == clearButton ) {
        messageBuffer.clear( );
        text.setText( "" );
    }
    else if ( src == copyButton ) {
        if ( clipboard == null ) {
            clipboard = new Clipboard( display );
        }
        String textData = text.getText( );
        if ( textData.length( ) > 0 ) {
            TextTransfer textTransfer = TextTransfer.getInstance();
            clipboard.setContents( new Object[]{ textData }, new Transfer[]{ textTransfer } );
        }
    }
}
 
開發者ID:Norkart,項目名稱:NK-VirtualGlobe,代碼行數:23,代碼來源:ConsoleWindow.java

示例15: PersistentObjectDropTarget

import org.eclipse.swt.dnd.TextTransfer; //導入方法依賴的package包/類
/**
 * Register the provided target as {@link DropTarget} for a {@link PersistentObject}
 * @param target
 * @param r
 * @param colorizeControl whether the target control should change color during selection
 * @since 3.1.0
 */
public PersistentObjectDropTarget(String name, Control target, IReceiver r, boolean colorizeControl){
	if (colorizeControl) {
		normalColor = target.getBackground();
		highlightColor = target.getDisplay().getSystemColor(SWT.COLOR_RED);
	} else {
		normalColor = null;
		highlightColor = null;
	}
	
	this.name = name;
	mine = target;
	rc = r;
	DropTarget dtarget = new DropTarget(target, DND.DROP_COPY);
	final TextTransfer textTransfer = TextTransfer.getInstance();
	Transfer[] types = new Transfer[] {
		textTransfer
	};
	dtarget.setTransfer(types);
	dtarget.addDropListener(this);
}
 
開發者ID:elexis,項目名稱:elexis-3-core,代碼行數:28,代碼來源:PersistentObjectDropTarget.java


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