本文整理匯總了Java中org.eclipse.swt.dnd.TextTransfer類的典型用法代碼示例。如果您正苦於以下問題:Java TextTransfer類的具體用法?Java TextTransfer怎麽用?Java TextTransfer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TextTransfer類屬於org.eclipse.swt.dnd包,在下文中一共展示了TextTransfer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: copy
import org.eclipse.swt.dnd.TextTransfer; //導入依賴的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: attachDropListener
import org.eclipse.swt.dnd.TextTransfer; //導入依賴的package包/類
private void attachDropListener() {
dropTarget = new DropTarget(targetTable, DND.DROP_MOVE);
dropTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
dropTarget.addDropListener(new DropTargetAdapter() {
public void drop(DropTargetEvent event) {
for (String fieldName : getformatedData((String) event.data)) {
if(isPropertyAlreadyExists(fieldName)){
return;
}else{
ExcelConfigurationDataStructure excelConfigurationDataStructure = new ExcelConfigurationDataStructure();
excelConfigurationDataStructure.setFieldName(fieldName);
listOfExcelConfiguration.add(excelConfigurationDataStructure);
targetTableViewer.refresh();
draggedFields.add(fieldName);
enableDeleteButton();
}
}
combo.setItems(convertToArray(draggedFields));
combo.select(0);
top_composite.layout();
top_composite.getParent().layout();
highlightDropFields();
}
});
}
示例3: setClipboard
import org.eclipse.swt.dnd.TextTransfer; //導入依賴的package包/類
/**
* Set the clipboard contents. Prompt to retry if clipboard is busy.
*
* @param resources
* the resources to copy to the clipboard
* @param fileNames
* file names of the resources to copy to the clipboard
* @param names
* string representation of all names
*/
private void setClipboard(final IResource[] resources, final String[] fileNames, final String names) {
try {
// set the clipboard contents
if (fileNames.length > 0) {
clipboard.setContents(new Object[] { resources, fileNames, names }, new Transfer[] {
ResourceTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() });
} else {
clipboard.setContents(new Object[] { resources, names },
new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance() });
}
} catch (final SWTError e) {
if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) { throw e; }
if (MessageDialog.openQuestion(shell, "Problem with copy title", // TODO //$NON-NLS-1$
// ResourceNavigatorMessages.CopyToClipboardProblemDialog_title,
"Problem with copy.")) { //$NON-NLS-1$
setClipboard(resources, fileNames, names);
}
}
}
示例4: addDefaultInternalCommands
import org.eclipse.swt.dnd.TextTransfer; //導入依賴的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
示例5: 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);
}
示例6: getMime
import org.eclipse.swt.dnd.TextTransfer; //導入依賴的package包/類
String getMime(Transfer transfer) {
if (transfer.equals(TextTransfer.getInstance())) {
return "text/plain";
}
if (transfer.equals(RTFTransfer.getInstance())) {
return "text/rtf";
} ;
if (transfer.equals( HTMLTransfer.getInstance())) {
return "text/html";
}
if (transfer.equals(URLTransfer.getInstance())) {
return "text/uri-list";
}
if (transfer.equals( ImageTransfer.getInstance())) {
return "application/x-java-rawimage";
}
if (transfer.equals(FileTransfer.getInstance())) {
return "application/x-java-file-list";
}
if (transfer instanceof CustomTransfer) {
return ((CustomTransfer)transfer).getMime();
}
return null;
}
示例7: 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());
}
});
}
示例8: 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();
}
示例9: updateUI
import org.eclipse.swt.dnd.TextTransfer; //導入依賴的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();
}
示例10: copyToClipBoard
import org.eclipse.swt.dnd.TextTransfer; //導入依賴的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 );
}
}
示例11: addCopyToClipMenu
import org.eclipse.swt.dnd.TextTransfer; //導入依賴的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()});
}
});
}
示例12: pasteFromClipboard
import org.eclipse.swt.dnd.TextTransfer; //導入依賴的package包/類
public void pasteFromClipboard() {
final String text = (String) getClipboard().getContents(TextTransfer.getInstance());
if (text == null) {
return;
}
final WorkingFolderData[] workingFolders = getWorkingFoldersFromClipboardText(text);
if (workingFolders.length == 0) {
return;
}
final WorkingFolderDataCollection collection = getWorkingFolderDataCollection();
for (int i = 0; i < workingFolders.length; i++) {
collection.add(workingFolders[i]);
}
refresh();
}
示例13: addNewNote
import org.eclipse.swt.dnd.TextTransfer; //導入依賴的package包/類
/**
* Adds a new note to the notepad.
*/
public void addNewNote() {
String noteText = "";
if (preferences.getBoolean(PreferenceConstants.PREF_PASTE_CLIPBOARD_IN_NEW_NOTES,
PreferenceConstants.PREF_PASTE_CLIPBOARD_IN_NEW_NOTES_DEFAULT)) {
noteText = (String) clipboard.getContents(TextTransfer.getInstance(), DND.CLIPBOARD);
}
String noteTitle = preferences.get(PreferenceConstants.PREF_NAME_PREFIX,
PreferenceConstants.PREF_NAME_PREFIX_DEFAULT) + " " + (tabFolder.getItemCount() + 1);
// Add a new note tab with a number appended to its name (Note 1, Note 2, Note 3, etc.).
addNewNoteTab(noteTitle, noteText, null, true, null);
CTabItem previousSelectedTab = tabFolder.getSelection();
// Remove lock for currently selected tab.
if (previousSelectedTab != null && previousSelectedTab.getText().startsWith(LOCK_PREFIX)) {
previousSelectedTab.setText(previousSelectedTab.getText().substring(LOCK_PREFIX.length()));
}
tabFolder.setSelection(tabFolder.getItemCount() - 1);
}
示例14: dragSetData
import org.eclipse.swt.dnd.TextTransfer; //導入依賴的package包/類
public void dragSetData(final DragSourceEvent event) {
final IStructuredSelection selection = (IStructuredSelection) viewer
.getSelection();
if (selection.getFirstElement() instanceof PwsEntryBean) {
final PwsEntryBean firstElement = (PwsEntryBean) selection.getFirstElement();
if (PwsEntryBeanTransfer.getInstance().isSupportedType(event.dataType)) {
event.data = firstElement.getStoreIndex();
}
} else if (selection.getFirstElement() instanceof PasswordTreeContentProvider.TreeGroup) {
event.doit = false; // disable for now
final PasswordTreeContentProvider.TreeGroup group =
(PasswordTreeContentProvider.TreeGroup) selection.getFirstElement();
if (PwsEntryBeanTransfer.getInstance().isSupportedType(event.dataType)) {
event.data = group.getGroupPath();
}
if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
event.data = group.getGroupPath();
}
} else {
log.warn("Unknown type: " + selection.getFirstElement().getClass());
}
}
示例15: javaToNative
import org.eclipse.swt.dnd.TextTransfer; //導入依賴的package包/類
@Override
protected void javaToNative(final Object object, final TransferData transferData) {
if (object instanceof Integer) {
final byte[] bytes = ByteBuffer.allocate(4).putInt((Integer) object).array();
if (bytes != null) {
super.javaToNative(bytes, transferData);
}
} else if (object instanceof String) {
if (! TextTransfer.getInstance().isSupportedType(transferData)) {
// FIXME this is a hack - works on Linux x64...
// no danger for now as treegroups are disabled on drag side
long type = transferData.type;
for (final TransferData data : TextTransfer.getInstance().getSupportedTypes()) {
type = data.type;
}
// on 32bit you need int instead of long, to avoid compile errors there use this here
transferData.type = (int) type;
}
TextTransfer.getInstance().javaToNative(object, transferData);
}
}