本文整理汇总了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);
}
示例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());
}
});
}
示例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();
}
示例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;
}
示例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);
}
示例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();
}
}
示例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});
}
示例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();
}
示例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 });
}
示例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 } );
}
示例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 });
}
示例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;
}
示例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();
}
}
示例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 } );
}
}
}
示例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);
}