本文整理匯總了Java中org.eclipse.swt.dnd.DragSource類的典型用法代碼示例。如果您正苦於以下問題:Java DragSource類的具體用法?Java DragSource怎麽用?Java DragSource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DragSource類屬於org.eclipse.swt.dnd包,在下文中一共展示了DragSource類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addDragSupport
import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
private void addDragSupport(final List sourcePackageList, final Combo comboJarList) {
DragSource dragSource = ExpressionEditorUtil.INSTANCE.getDragSource(sourcePackageList);
dragSource.addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) {
event.data = formatDataToTransfer(sourcePackageList.getSelection());
}
private Object formatDataToTransfer(String[] selection) {
StringBuffer buffer = new StringBuffer();
for (String field : selection) {
buffer.append(field + Constants.DOT + Constants.ASTERISK + SWT.SPACE + Constants.DASH + SWT.SPACE
+ comboJarList.getItem(comboJarList.getSelectionIndex())
+ Constants.FIELD_SEPRATOR_FOR_DRAG_DROP);
}
return buffer.toString();
}
});
}
示例2: createXhtmlTree
import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
private void createXhtmlTree() {
sourcePicker.createXhtmlTree(treesSashForm);
// DND support
int ops = DND.DROP_COPY | DND.DROP_MOVE;
Transfer[] transfers = new Transfer[] {StepSourceTransfer.getInstance()};
DragSource source = new DragSource(sourcePicker.getTwsDomTree().getTree(), ops);
source.setTransfer(transfers);
source.addDragListener(new DragSourceAdapter() {
@Override
public void dragStart(DragSourceEvent event) {
event.doit = true;
StepSourceTransfer.getInstance().setStepSource(sourcePicker.getDragData());
}
});
}
示例3: applyDragFromTableViewer
import org.eclipse.swt.dnd.DragSource; //導入依賴的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());
}
});
}
示例4: getShell
import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
/**
* Returns the shell for the given widget. If the widget doesn't represent a
* SWT object that manage a shell, <code>null</code> is returned.
*
* @param widget
* the widget
*
* @return the shell for the given widget
*/
public static Shell getShell(Widget widget) {
if (widget instanceof Control)
return ((Control) widget).getShell();
if (widget instanceof Caret)
return ((Caret) widget).getParent().getShell();
if (widget instanceof DragSource)
return ((DragSource) widget).getControl().getShell();
if (widget instanceof DropTarget)
return ((DropTarget) widget).getControl().getShell();
if (widget instanceof Menu)
return ((Menu) widget).getParent().getShell();
if (widget instanceof ScrollBar)
return ((ScrollBar) widget).getParent().getShell();
return null;
}
示例5: getDragSelection
import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
private List<MDataAdapter> getDragSelection(DragSourceEvent event){
if(event.getSource() instanceof DragSource){
List<MDataAdapter> dataAdapters = new ArrayList<MDataAdapter>();
Control control = ((DragSource)event.getSource()).getControl();
if(control instanceof Tree &&
((Tree) control).getSelection().length>0){
for(TreeItem tItem : ((Tree) control).getSelection()){
Object data = tItem.getData();
if(data instanceof MDataAdapter){
dataAdapters.add((MDataAdapter) data);
}
}
return dataAdapters;
}
}
return new ArrayList<MDataAdapter>(0);
}
示例6: getShell
import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
/**
* Returns the shell for the given widget. If the widget doesn't represent a SWT object that manage a shell,
* <code>null</code> is returned.
*
* @return the shell for the given widget
*/
public static Shell getShell(Widget widget)
{
if (widget instanceof Control)
return ((Control) widget).getShell();
if (widget instanceof Caret)
return ((Caret) widget).getParent().getShell();
if (widget instanceof DragSource)
return ((DragSource) widget).getControl().getShell();
if (widget instanceof DropTarget)
return ((DropTarget) widget).getControl().getShell();
if (widget instanceof Menu)
return ((Menu) widget).getParent().getShell();
if (widget instanceof ScrollBar)
return ((ScrollBar) widget).getParent().getShell();
return null;
}
示例7: getTransferable
import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
@Override
protected ITransferable getTransferable(DragSource source, long time) {
ISelection selection = viewer.getSelection();
if (!(selection instanceof StructuredSelection)) {
return null;
}
List<ENumericResourceDef> nrdefs = getNumericResourceDefs(selection);
List<EStateResourceDef> srdefs = getStateResourceDefs(selection);
if (nrdefs.size() == 0 && srdefs.size() == 0) {
return null;
} else
if (nrdefs.size() != 0 && srdefs.size() != 0) {
return null;
}
// one is guranteed to have defs in it
if (nrdefs.size() > 0) {
return new NumericResourceDefTransferable(nrdefs);
} // else...
return new StateResourceDefTransferable(srdefs);
}
示例8: getShell
import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
/**
* Returns the shell for the given widget. If the widget doesn't represent
* a SWT object that manage a shell, <code>null</code> is returned.
* @param widget the widget
*
* @return the shell for the given widget
*/
public static Shell getShell(Widget widget) {
if (widget instanceof Control)
return ((Control)widget).getShell();
if (widget instanceof Caret)
return ((Caret)widget).getParent().getShell();
if (widget instanceof DragSource)
return ((DragSource)widget).getControl().getShell();
if (widget instanceof DropTarget)
return ((DropTarget)widget).getControl().getShell();
if (widget instanceof Menu)
return ((Menu)widget).getParent().getShell();
if (widget instanceof ScrollBar)
return ((ScrollBar)widget).getParent().getShell();
return null;
}
示例9: getShell
import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
/**
* Returns the shell for the given widget. If the widget doesn't represent
* a SWT object that manage a shell, <code>null</code> is returned.
* @param widget the widget
*
* @return the shell for the given widget
*/
public static Shell getShell(Widget widget) {
if (widget instanceof Control) {
return ((Control) widget).getShell();
}
if (widget instanceof Caret) {
return ((Caret) widget).getParent().getShell();
}
if (widget instanceof DragSource) {
return ((DragSource) widget).getControl().getShell();
}
if (widget instanceof DropTarget) {
return ((DropTarget) widget).getControl().getShell();
}
if (widget instanceof Menu) {
return ((Menu) widget).getParent().getShell();
}
if (widget instanceof ScrollBar) {
return ((ScrollBar) widget).getParent().getShell();
}
return null;
}
示例10: setEmbeddedScene
import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
@Override
public void setEmbeddedScene(EmbeddedSceneInterface embeddedScene) {
scenePeer = embeddedScene;
if (scenePeer == null) {
return;
}
if (pWidth > 0 && pHeight > 0) {
scenePeer.setSize(pWidth, pHeight);
}
double scaleFactor = getScaleFactor();
resizePixelBuffer(scaleFactor);
lastScaleFactor = scaleFactor;
scenePeer.setPixelScaleFactor((float)scaleFactor);
scenePeer.setDragStartListener((fxDragSource, dragAction) -> {
Platform.runLater(() -> {
DragSource dragSource = createDragSource(fxDragSource, dragAction);
if (dragSource == null) {
fxDragSource.dragDropEnd(null);
} else {
updateDropTarget();
OldFXCanvas.this.notifyListeners(SWT.DragDetect, null);
}
});
});
//Force the old drop target to be disposed before creating a new one
setDropTarget(null);
setDropTarget(createDropTarget(embeddedScene));
}
示例11: addDragSupport
import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
public void addDragSupport(final Control widget) {
DragSource dragSource = getDragSource(widget);
dragSource.addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) {
if (widget instanceof Table) {
event.data = formatDataToTransfer(((Table) widget).getSelection());
}
if (widget instanceof List) {
event.data = formatDataToTransfer(((List) widget).getSelection());
}
}
});
}
示例12: attachDragListener
import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
private void attachDragListener() {
dragSource = new DragSource(table_1, DND.DROP_MOVE);
dragSource.setTransfer(new Transfer[] { TextTransfer.getInstance() });
dragSource.addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) {
// Set the data to be the first selected item's text
event.data = formatDataToTransfer(table_1.getSelection());
}
});
}
示例13: createSourceTable
import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
private void createSourceTable(Composite composite_2) {
sourceTable = new Table(composite_2, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
sourceTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
if(sourceTable.getSelection().length==1){
addNewProperty(targetTableViewer, sourceTable.getSelection()[0].getText());
enableControlButtons();
}
}
});
GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2);
gd_table.widthHint = 221;
gd_table.heightHint = 407;
sourceTable.setLayoutData(gd_table);
sourceTable.setHeaderVisible(true);
sourceTable.setLinesVisible(true);
TableColumn sourceTableColumnFieldName = new TableColumn(sourceTable, SWT.LEFT);
if(OSValidator.isMac()){
sourceTableColumnFieldName.setWidth(212);
}else{
sourceTableColumnFieldName.setWidth(202);
}
sourceTableColumnFieldName.setText(Messages.AVAILABLE_FIELDS_HEADER);
getSourceFieldsFromPropagatedSchema(sourceTable);
dragSource = new DragSource(sourceTable, DND.DROP_MOVE);
dragSource.setTransfer(new Transfer[] { TextTransfer.getInstance() });
dragSource.addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) {
// Set the data to be the first selected item's text
event.data = formatDataToTransfer(sourceTable.getSelection());
}
});
}
示例14: addDoubleClickListener
import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
private void addDoubleClickListener(TableViewer availableFieldtableViewer) {
DragSource dragSource = new DragSource(availableFieldsTable, DND.DROP_COPY);
dragSource.setTransfer(new Transfer[] { ObjectTransfer.getInstance() });
dragSource.addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) { // Set the data to be the first selected item's text
List<Object> list=new ArrayList<Object>();
for(TableItem tableItem:availableFieldsTable.getSelection()){
list.add(tableItem.getData());
}
event.data=list.toArray(new Object[list.size()]);
}
});
}
示例15: configure
import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
public void configure(CommandManager commandManager, Control control, ISelectionProvider provider) {
dragAdapter = new DelegatingDragAdapter();
dragSource = new DragSource(control, DND.DROP_COPY | DND.DROP_MOVE);
dragAdapter.addDragSourceListener(new OutlineDragSourceListener(provider));
dragSource.addDragListener(dragAdapter);
dragSource.setTransfer(dragAdapter.getTransfers());
dropAdapter = new DelegatingDropAdapter();
dropTarget = new DropTarget(control, DND.DROP_COPY | DND.DROP_MOVE);
dropAdapter.addDropTargetListener(new OutlineDropTargetListener(commandManager));
dropTarget.addDropListener(dropAdapter);
dropTarget.setTransfer(dropAdapter.getTransfers());
}