本文整理匯總了Java中org.eclipse.swt.dnd.DragSourceListener類的典型用法代碼示例。如果您正苦於以下問題:Java DragSourceListener類的具體用法?Java DragSourceListener怎麽用?Java DragSourceListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DragSourceListener類屬於org.eclipse.swt.dnd包,在下文中一共展示了DragSourceListener類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: configureDragAndDrop
import org.eclipse.swt.dnd.DragSourceListener; //導入依賴的package包/類
protected void configureDragAndDrop(DragAndDropConfiguration dragAndDropConfiguration, TreeViewer treeViewer) {
// drop
Transfer[] transferTypes = new Transfer[] { LocalSelectionTransfer.getTransfer() };
int operations = dragAndDropConfiguration.getSupportedDropOperations(this);
DropTarget target = new DropTarget(treeViewer.getControl(), operations);
target.setTransfer(transferTypes);
// Drop listeners pour le drop des elements sur l'arbre
SchemaViewerDropPolicy dropPolicy = dragAndDropConfiguration.getDropPolicy(this);
DnDTargetListener targetListener = new DnDTargetListener(this, nodeConverter, dropPolicy);
target.addDropListener(targetListener);
// Drag listener pour le drag des elements de l'arbre
DragSourceListener sourceListener = new DnDSourceListener(this);
operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT;
transferTypes = new Transfer[] { LocalSelectionTransfer.getTransfer() };
treeViewer.addDragSupport(operations, transferTypes, sourceListener);
}
示例2: getDragSourceAdapter
import org.eclipse.swt.dnd.DragSourceListener; //導入依賴的package包/類
protected DragSourceListener getDragSourceAdapter(
final TableViewer inViewer) {
return new DragSourceAdapter() {
@Override
public void dragSetData(final DragSourceEvent inEvent) {
final IStructuredSelection lSelected = (IStructuredSelection) inViewer
.getSelection();
if (!lSelected.isEmpty()) {
final Object[] lItems = lSelected.toArray();
final UniqueID[] lIDs = new UniqueID[lItems.length];
for (int i = 0; i < lItems.length; i++) {
final ILightWeightItem lItem = (ILightWeightItem) lItems[i];
lIDs[i] = new UniqueID(lItem.getItemType(),
lItem.getID());
}
inEvent.data = lIDs;
}
}
};
}
示例3: addDragSupport
import org.eclipse.swt.dnd.DragSourceListener; //導入依賴的package包/類
@Override
public void addDragSupport(int operations, Transfer[] transferTypes, DragSourceListener listener) {
fViewer.addDragSupport(operations, transferTypes, listener);
}
示例4: addDragSupport
import org.eclipse.swt.dnd.DragSourceListener; //導入依賴的package包/類
/**
* Adds support for dragging items out of this viewer via a user
* drag-and-drop operation.
*
* @param operations
* a bitwise OR of the supported drag and drop operation types (
* <code>DROP_COPY</code>,<code>DROP_LINK</code>, and
* <code>DROP_MOVE</code>)
* @param transferTypes
* the transfer types that are supported by the drag operation
* @param listener
* the callback that will be invoked to set the drag data and to
* cleanup after the drag and drop operation finishes
* @see org.eclipse.swt.dnd.DND
*/
public void addDragSupport(int operations, Transfer[] transferTypes,
DragSourceListener listener) {
Control myControl = getControl();
final DragSource dragSource = new DragSource(myControl, operations);
dragSource.setTransfer(transferTypes);
dragSource.addDragListener(listener);
}