use of org.eclipse.swt.dnd.Transfer in project yamcs-studio by yamcs.
the class SerializableItemTransfer method getTransfers.
/**
* @param classes Types to be transferred
* @return Transfers for those types
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Transfer[] getTransfers(Class[] classes) {
final Transfer[] transfers = new Transfer[classes.length];
for (int i = 0; i < classes.length; i++) {
Transfer transfer = getTransfer(classes[i]);
transfers[i] = transfer;
}
return transfers;
}
use of org.eclipse.swt.dnd.Transfer in project liferay-ide by liferay.
the class KaleoPaletteHelper method updateDragSource.
protected void updateDragSource() {
Transfer[] supportedTypes = { TextTransfer.getInstance() };
/*
* TRH suggested use of the event's doit field by the fListeners, but
* there's no other way to guarantee that TextTransfer is considered
* last
*/
Iterator<TransferDragSourceListener> iterator = getTransferDragSourceListeners().iterator();
ArrayList<TransferDragSourceListener> oldListeners = new ArrayList<>();
while (iterator.hasNext()) {
TransferDragSourceListener listener = iterator.next();
oldListeners.add(listener);
iterator.remove();
}
boolean addTextTransfer = false;
for (int i = 0; i < supportedTypes.length; i++) {
if (TextTransfer.class.equals(supportedTypes[i].getClass())) {
addTextTransfer = true;
} else {
TransferDragSourceListener listener = new TransferDragSourceListenerImpl(supportedTypes[i]);
_getPaletteViewer().addDragSourceListener(listener);
getTransferDragSourceListeners().add(listener);
}
}
iterator = oldListeners.iterator();
while (iterator.hasNext()) {
TransferDragSourceListener listener = iterator.next();
_getPaletteViewer().removeDragSourceListener(listener);
iterator.remove();
}
if (addTextTransfer) {
addTextTransferListener();
}
}
use of org.eclipse.swt.dnd.Transfer in project egit by eclipse.
the class CopyHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Repository repo = getRepository(event);
RevCommit commit = getSelectedCommit(event, repo);
if (commit != null) {
Clipboard clipboard = new Clipboard(null);
try {
TextTransfer textTransfer = TextTransfer.getInstance();
Transfer[] transfers = new Transfer[] { textTransfer };
Object[] data = new Object[] { ObjectId.toString(commit) };
clipboard.setContents(data, transfers);
} finally {
clipboard.dispose();
}
}
return null;
}
use of org.eclipse.swt.dnd.Transfer in project tdq-studio-se by Talend.
the class AnalysisColumnNominalIntervalTreeViewer method addSourceDND.
/**
* DOC bZhou Comment method "addSourceDND".
*
* @param newTree
*/
private void addSourceDND(final Tree newTree) {
final LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
Transfer[] types = new Transfer[] { transfer };
int operations = DND.DROP_COPY | DND.DROP_MOVE;
final DragSource source = new DragSource(newTree, operations);
source.setTransfer(types);
final TreeItem[] dragSourceItem = new TreeItem[1];
source.addDragListener(new DragSourceListener() {
public void dragStart(DragSourceEvent event) {
TreeItem[] selection = newTree.getSelection();
dragSourceItem[0] = selection[0];
if (selection.length > 0) {
event.doit = true;
transfer.setSelection(new StructuredSelection(selection[0].getData(COLUMN_INDICATOR_KEY)));
getColumnSetMultiValueList().remove(selection[0].getData(COLUMN_INDICATOR_KEY));
} else {
event.doit = false;
}
}
public void dragSetData(DragSourceEvent event) {
event.data = dragSourceItem[0];
}
public void dragFinished(DragSourceEvent event) {
if (event.detail == DND.DROP_MOVE) {
removeItemBranch(dragSourceItem[0]);
tree.forceFocus();
}
dragSourceItem[0] = null;
}
});
}
use of org.eclipse.swt.dnd.Transfer in project tdq-studio-se by Talend.
the class WhereClauseDND method installDND.
public static void installDND(final Text targetControl) {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
DQRespositoryView findView = (DQRespositoryView) activePage.findView(DQRespositoryView.ID);
final CommonViewer commonViewer = findView.getCommonViewer();
final LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
int operations = DND.DROP_COPY | DND.DROP_MOVE;
Transfer[] transfers = new Transfer[] { transfer };
DropTarget dropTarget = new DropTarget(targetControl, operations);
dropTarget.setTransfer(transfers);
dropTarget.addDropListener(new DropTargetAdapter() {
@Override
public void dragEnter(DropTargetEvent event) {
Object obj = ((IStructuredSelection) commonViewer.getSelection()).getFirstElement();
if (!(obj instanceof DBColumnRepNode)) {
event.detail = DND.DROP_NONE;
} else {
// event.detail = DND.DROP_MOVE;
event.feedback = DND.FEEDBACK_INSERT_AFTER;
}
}
@Override
public void dropAccept(DropTargetEvent event) {
}
@Override
public void drop(DropTargetEvent event) {
if (event.detail != DND.DROP_NONE) {
IStructuredSelection selection = (IStructuredSelection) commonViewer.getSelection();
if (!selection.isEmpty()) {
Iterator<DBColumnRepNode> it = selection.iterator();
IEditorPart currentActiveEditor = CorePlugin.getDefault().getCurrentActiveEditor();
if (currentActiveEditor instanceof DQRuleEditor) {
// // Analysis analysis = AnaResourceFileHelper.getInstance().findAnalysis(input.getFile());
while (it.hasNext()) {
// DbmsLanguage language = DbmsLanguageFactory.createDbmsLanguage(lang, null);
DBColumnRepNode next = it.next();
String name = next.getTdColumn().getName();
targetControl.insert(name);
targetControl.forceFocus();
}
}
}
}
}
});
}
Aggregations