Java 类org.eclipse.swt.dnd.DropTarget 实例源码

项目:Hydrograph    文件:ExcelFormattingDialog.java   
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();

        }
    });
}
项目:avro-schema-editor    文件:SchemaViewer.java   
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);

  }
项目:bts    文件:SWTUtil.java   
/**
 * 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;
}
项目:statecharts    文件:ExampleDropTargetInstaller.java   
protected void registerWithExistingTarget(DropTarget target) {
    Transfer[] transfers = target.getTransfer();
    boolean exists = false;
    if (transfers != null) {
        for (Transfer transfer : transfers) {
            if (transfer instanceof URLTransfer) {
                exists = true;
                break;
            }
        }
        if (!exists) {
            Transfer[] newTransfers = new Transfer[transfers.length + 1];
            System.arraycopy(transfers, 0, newTransfers, 0, transfers.length);
            newTransfers[transfers.length] = URLTransfer.getInstance();
            target.setTransfer(newTransfers);
        }
    }
}
项目:statecharts    文件:ExampleDropTargetListener.java   
@Override
public void drop(DropTargetEvent event) {
    if (!URLTransfer.getInstance().isSupportedType(event.currentDataType)) {
        return;
    }
    final String url = getUrl(event.data);

    if (ExampleURLHandler.isValidExample(url)) {
        DropTarget source = (DropTarget) event.getSource();
        Display display = source.getDisplay();
        display.asyncExec(new Runnable() {
            public void run() {
                proceedInstallation(url);
            }
        });
    }
}
项目:APICloud-Studio    文件:SWTUtil.java   
/**
 * 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;
}
项目:Eclipse-Postfix-Code-Completion    文件:SWTUtil.java   
/**
 * 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;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:SWTUtil.java   
/**
 * 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;
}
项目:tmxeditor8    文件:TmxEditorViewer.java   
@Override
public void createPartControl(Composite parent) {
    parent.setLayout(new FillLayout());
    this.container = parent;
    CellEditorGlobalActionHanlder.getInstance().setIActionBars(getViewSite().getActionBars());
    DropTarget target = new DropTarget(parent, DND.DROP_MOVE | DND.DROP_COPY);
    Transfer[] tfs = new Transfer[] { FileTransfer.getInstance() };
    target.setTransfer(tfs);
    target.addDropListener(new DropTargetAdapter() {
        @Override
        public void drop(DropTargetEvent event) {
            Object o = event.data;
            if (o instanceof String[]) {
                String[] s = (String[]) o;
                if (s.length == 0 && s[0] == null || s[0].length() == 0) {
                    return;
                }
                File f = new File(s[0]);
                if (f.exists() && f.isFile()) {
                    open(f);
                }
            }
        }
    });
}
项目:Mailster    文件:MailBoxView.java   
public static void setupFileDrop(Control ctrl)
{
    DropTarget dt = new DropTarget(ctrl, DND.DROP_DEFAULT | DND.DROP_MOVE);
    dt.setTransfer(new Transfer[] {FileTransfer.getInstance()});
    dt.addDropListener(new DropTargetAdapter() {
        public void drop(DropTargetEvent event)
        {
            FileTransfer ft = FileTransfer.getInstance();
            if (ft.isSupportedType(event.currentDataType))
            {
                String[] files = (String[]) event.data;
                for (String file : files)
                {
                    if (file.toLowerCase().endsWith(".eml"))
                        ImportExportUtilities.importFromEmailFile(file);
                    else if (file.toLowerCase().endsWith(".mbx"))
                        ImportExportUtilities.importFromMbox(file);
                }
            }
        }
    });
}
项目:Pydev    文件:SWTUtil.java   
/**
 * 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;
}
项目:elexis-3-core    文件:PersistentObjectDropTarget.java   
/**
 * 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);
}
项目:olca-app    文件:Trees.java   
public static void addDropSupport(TreeViewer tree,
        final IModelDropHandler handler) {
    final Transfer transfer = ModelTransfer.getInstance();
    DropTarget dropTarget = new DropTarget(tree.getTree(), DND.DROP_COPY
            | DND.DROP_MOVE | DND.DROP_DEFAULT);
    dropTarget.setTransfer(new Transfer[] { transfer });
    dropTarget.addDropListener(new DropTargetAdapter() {
        @Override
        public void drop(DropTargetEvent event) {
            if (!transfer.isSupportedType(event.currentDataType))
                return;
            List<BaseDescriptor> list = ModelTransfer
                    .getBaseDescriptors(event.data);
            handler.handleDrop(list);
        }
    });
}
项目:neoscada    文件:ChartManager.java   
public DropTarget createDropTarget ( final Transfer[] transfers, final DropTargetListener dropTargetListener )
{
    checkWidget ();

    final DropTarget target = new DropTarget ( this.chartArea, DND.DROP_DEFAULT | DND.DROP_COPY | DND.DROP_LINK );
    target.setTransfer ( transfers );
    target.addDropListener ( dropTargetListener );
    return target;
}
项目:JavaFX-FrameRateMeter    文件:OldFXCanvas.java   
void setDropTarget(DropTarget newTarget) {
    if (dropTarget != null) {
        targets.remove(dropTarget);
        dropTarget.dispose();
    }
    dropTarget = newTarget;
    if (dropTarget != null) {
        targets.add(dropTarget);
    }
}
项目:JavaFX-FrameRateMeter    文件:OldFXCanvas.java   
static void updateDropTarget() {
    // Update all drop targets rather than just this target
    //
    // In order for a drop target to recognise a custom format,
    // the format must be registered and the transfer type added
    // to the list of transfers that the target accepts.  This
    // must happen before the drag and drop operations starts
    // or the drop target will not accept the format.  Therefore,
    // set all transfers for all targets before any drag and drop
    // operation starts
    //
    for (DropTarget target : targets) {
        target.setTransfer(getAllTransfers());
    }
}
项目:Hydrograph    文件:CategoriesDialogTargetComposite.java   
private void addDropSupport() {
    DropTarget dropTarget = new DropTarget(targetList, DND.DROP_MOVE);
    dropTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
    dropTarget.addDropListener(new DropTargetAdapter() {
        public void drop(DropTargetEvent event) {
            for (String formattedPackageName : ExpressionEditorUtil.INSTANCE.getformatedData((String) event.data)) {
                if (isFieldAvailable(formattedPackageName)){
                    targetList.add(formattedPackageName);
                    removeAddedPackageNameFromSourceList(formattedPackageName);
                    categoriesDialogSourceComposite.enableOrDisableAddLabelsOnComboSelection();
                }
            }
        }
    });
}
项目:Hydrograph    文件:ExpressionEditorComposite.java   
private void addDropSupport() {
    DropTarget dropTarget = new DropTarget(expressionEditor, DND.DROP_MOVE);
    dropTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
    dropTarget.addDropListener(new DropTargetAdapter() {
        public void drop(DropTargetEvent event) {
            for (String fieldName :ExpressionEditorUtil.INSTANCE.getformatedData((String) event.data)){
                expressionEditor.insert(SWT.SPACE+fieldName+SWT.SPACE);
            }
        }
    });
}
项目:Hydrograph    文件:DragDropUtility.java   
public void applyDrop(final TableViewer tableViewerOpOuter,DragDropOperation dragDropOperation) {

    Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
    int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
    DropTarget target = new DropTarget(tableViewerOpOuter.getTable(), operations);
    target.setTransfer(types);
    target.addDropListener(new DradDropUtilityListener(dragDropOperation));
}
项目:fluentmark    文件:DndConfigurationStrategy.java   
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());
    }
项目:cft    文件:ApplicationDetailsPart.java   
private void addDropSupport(Section section) {
    int ops = DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT;
    Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };

    DropTarget dropTarget = new DropTarget(section, ops);
    dropTarget.setTransfer(transfers);
    dropTarget.addDropListener(servicesDropListener);
}
项目:triquetrum    文件:PaletteTreeViewer.java   
/**
 * Creates or disposes a DropTarget as needed, and sets the supported transfer types. Clients should not need to call or
 * override this method.
 */
@Override
protected void refreshDropTargetAdapter() {
  if (getControl() == null)
    return;
  if (getDelegatingDropAdapter().isEmpty())
    setDropTarget(null);
  else {
    if (getDropTarget() == null)
      setDropTarget(new DropTarget(getTreeControl(), DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK));
    getDropTarget().setTransfer(getDelegatingDropAdapter().getTransfers());
  }
}
项目:statecharts    文件:ExampleDropTargetInstaller.java   
protected void hookRecursive(Control child, DropTargetListener dropListener) {
    DropTarget childTarget = findDropTarget(child);
    if (childTarget != null) {
        registerWithExistingTarget(childTarget);
        registerDropListener(childTarget, dropListener);
    }
    if (child instanceof Composite) {
        Composite composite = (Composite) child;
        Control[] children = composite.getChildren();
        for (Control control : children) {
            hookRecursive(control, dropListener);
        }
    }
}
项目:statecharts    文件:ExampleDropTargetInstaller.java   
protected DropTarget findDropTarget(Control control) {
    Object object = control.getData(DND.DROP_TARGET_KEY);
    if (object instanceof DropTarget) {
        return (DropTarget) object;
    }
    return null;
}
项目:LogViewer    文件:LogViewer.java   
public void createPartControl(Composite parent) {
    //viewer
    this.parent = parent;
    documentListener = new ViewDocumentListener();
    tabfolder = new TabFolder(parent,0);
    tabfolder.addSelectionListener(new TabSelectionListener());
    viewer = new LogFileViewer(tabfolder,SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);

    // DnD
    DropTarget target = new DropTarget(parent, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
    target.setTransfer(new Transfer[] {FileTransfer.getInstance(), TextTransfer.getInstance()});
    target.addDropListener (new DropTargetAdapter() {
        public void dragEnter(DropTargetEvent e) {
            if (e.detail == DND.DROP_NONE)
                e.detail = DND.DROP_COPY;
        }
        public void drop(DropTargetEvent event) {
            if (event.data == null || ((String[])event.data).length < 1) {
                event.detail = DND.DROP_NONE;
                return;
            }
            //File file = new File(((String[])event.data)[0]);
            if (!checkAndOpenFile(LogFileType.LOGFILE_SYSTEM_FILE,((String[])event.data)[0], false))
                event.detail = DND.DROP_NONE;
        }
    });

    // fill the menues
    makeActions();
    hookContextMenu();
    contributeToActionBars();
    openAllLastOpenFiles();
}
项目:dockerfoundry    文件:ApplicationDetailsPart.java   
private void addDropSupport(Section section) {
    int ops = DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT;
    Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };

    DropTarget dropTarget = new DropTarget(section, ops);
    dropTarget.setTransfer(transfers);
    dropTarget.addDropListener(servicesDropListener);
}
项目:org.csstudio.display.builder    文件:TextAsPVDropTarget.java   
/** Initialize
 *  @param target Control that should receive 'dropped' items
 */
public TextAsPVDropTarget(final Control target)
{
    this.target = new DropTarget(target, DND.DROP_MOVE | DND.DROP_COPY);
    this.target.setTransfer(new Transfer[]
    {
        TextTransfer.getInstance()
    });
    this.target.addDropListener(this);
}
项目:APICloud-Studio    文件:AbstractThemeableEditor.java   
@Override
protected void initializeDragAndDrop(ISourceViewer viewer)
{
    super.initializeDragAndDrop(viewer);

    // Adds snippet drag/drop support
    IDragAndDropService dndService = (IDragAndDropService) getSite().getService(IDragAndDropService.class);
    if (dndService == null)
    {
        return;
    }
    StyledText st = viewer.getTextWidget();
    DropTarget dropTarget = (DropTarget) st.getData(DND.DROP_TARGET_KEY);
    if (dropTarget != null)
    {
        Transfer[] transfers = dropTarget.getTransfer();
        List<Transfer> allTransfers = CollectionsUtil.newList(transfers);
        allTransfers.add(SnippetTransfer.getInstance());
        dropTarget.setTransfer(allTransfers.toArray(new Transfer[allTransfers.size()]));
        dropTarget.addDropListener(new SnippetDropTargetListener());
    }
    else
    {
        dndService.addMergedDropTarget(st, DND.DROP_COPY, new Transfer[] { SnippetTransfer.getInstance() },
                new SnippetDropTargetListener());
    }
}
项目:jo-widgets    文件:SwtDropTarget.java   
private void createDropTargetIfNecessary() {
    if (dropTarget == null && isActive() && !EmptyCheck.isEmpty(actions) && !EmptyCheck.isEmpty(supportedTypes)) {
        this.dropTarget = new DropTarget(control, DragDropUtil.createOperations(actions));
        dropTarget.setTransfer(DragDropUtil.createTransfers(supportedTypes));
        dropTarget.addDropListener(new DropTargetListenerImpl());
    }
}
项目:OpenSPIFe    文件:TreeTableViewerDropTargetListener.java   
@Override
protected void cursorMoved(
        DropTarget target, Item targetItem, long time,
        int x, int y, TransferData[] dataTypes,
        int operations, DropTargetEventModifier event
) {
    TreeTableContentProvider contentProvider = (TreeTableContentProvider) viewer.getContentProvider();
    Map.Entry<Object, InsertionSemantics> map = getTargetAndSemantics(targetItem, x, y, event);
    Object targetElement = map.getKey();
    InsertionSemantics semantics = map.getValue();
    TransferData sourceType = event.getCurrentDataType();
    trace.debug("cursorMoved - "+targetElement+": "+semantics);
    ISelection selection = new StructuredSelection(targetElement);
    boolean isDragSourceEditorModel = EnsembleDragAndDropOracle.isDragSourceEditorModel(planEditorModel);
    if ((isDragSourceEditorModel && !contentProvider.isValidDrop(viewer.getSelection(), targetElement)) || 
        !contentProvider.acceptsDrop(sourceType, selection, semantics)) {
        event.setDetail(DND.DROP_NONE);
        event.setFeedback(DND.FEEDBACK_NONE);
    } else {
        if (!isDragSourceEditorModel
            && ((operations & DND.DROP_COPY) != 0)) {
            event.setDetail(DND.DROP_COPY);
        } else if (event.getDetail() == DND.DROP_NONE) {
            if ((operations & DND.DROP_MOVE) != 0) {
                event.setDetail(DND.DROP_MOVE);
            } else if ((operations & DND.DROP_COPY) != 0) {
                event.setDetail(DND.DROP_COPY);
            }
        }
        event.setFeedback(getFeedback(semantics));
        if (targetItem == null) {
            doFeedbackForNullItem(event);
            event.setFeedback(DND.FEEDBACK_INSERT_AFTER);
        }
    }
    if (shouldScroll(y)) {
        event.setFeedback(DND.FEEDBACK_SCROLL);
    }
}
项目:OpenSPIFe    文件:TreeTableViewerDropTargetListener.java   
@Override
protected void cursorLeftOrDropCancelledOrDataAboutToDrop(
        DropTarget target, Item targetItem, long time, int x, int y, 
        TransferData[] dataTypes, int operations, 
        TransferData currentDataType, int detail) {
    // nothing interesting to do here
}
项目:OpenSPIFe    文件:TreeTableViewerDropTargetListener.java   
@Override
protected boolean executeDrop(DropTarget target, Item targetItem, long time,
        int x, int y, TransferData currentDataType, int detail, Object data) {
    Map.Entry<Object, InsertionSemantics> map = getTargetAndSemantics(targetItem, x, y, null);
    Object targetElement = map.getKey();
    InsertionSemantics semantics = map.getValue();
    TreeTableContentProvider contentProvider = (TreeTableContentProvider) viewer.getContentProvider();
    IUndoableOperation operation = contentProvider.createDropOperation(targetElement, semantics, currentDataType, detail, data);
    IUndoContext undoContext = viewer.getModel().getUndoContext();
    WidgetUtils.execute(operation, undoContext, viewer.getControl(), viewer.getSite());
    return true;
}
项目:OpenSPIFe    文件:TransferDropTargetListener.java   
/**
 * Overriden to call EnsembleDragAndDropOracle.acquireDropping so that a more efficient form
 * of drag data can be used for a same process drag and drop.
 * 
 * @see gov.nasa.ensemble.common.ui.transfers.TransferRegistry#getDragData(gov.nasa.ensemble.common.ui.transfers.ITransferable, org.eclipse.swt.dnd.TransferData)
 */
@Override
public void dropAccept(DropTargetEvent event) {
    super.dropAccept(event);
    DropTarget target = (DropTarget)event.widget;
    EnsembleDragAndDropOracle.acquireDropping(target);
}
项目:Eclipse-Postfix-Code-Completion    文件:CallHierarchyViewPart.java   
private void initDragAndDrop() {
    addDragAdapters(fCallHierarchyViewer);
    addDropAdapters(fCallHierarchyViewer);
    addDropAdapters(fLocationViewer);

    //dnd on empty hierarchy
    DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
    dropTarget.setTransfer(new Transfer[] { LocalSelectionTransfer.getInstance() });
    dropTarget.addDropListener(new CallHierarchyTransferDropAdapter(this, fCallHierarchyViewer));
}
项目:Eclipse-Postfix-Code-Completion    文件:TypeHierarchyViewPart.java   
private void initDragAndDrop() {
    for (int i= 0; i < fAllViewers.length; i++) {
        addDragAdapters(fAllViewers[i]);
        addDropAdapters(fAllViewers[i]);
    }
    addDragAdapters(fMethodsViewer);
    fMethodsViewer.addDropSupport(DND.DROP_NONE, new Transfer[0], new DropTargetAdapter());

    //DND on empty hierarchy
    DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
    dropTarget.setTransfer(new Transfer[] { LocalSelectionTransfer.getInstance() });
    dropTarget.addDropListener(new TypeHierarchyTransferDropAdapter(this, fAllViewers[0]));
}
项目:DropTillLate_Application    文件:ViewController.java   
/**
 * Register DragDropAdapter
 */
private void registerDragDrop() {
    // Drag-Part //////////////////////////////////////////////////////////
    DragSource source = new DragSource(tree, DND.DROP_COPY | DND.DROP_MOVE);
    source.setTransfer(new Transfer[] { TextTransfer.getInstance() });
    source.addDragListener(new TreeDragSourceListener(tree));

    // Drop-Part //////////////////////////////////////////////////////////
    DropTarget dropTarget = new DropTarget(tree, DND.DROP_COPY
            | DND.DROP_DEFAULT);
    dropTarget.setTransfer(new Transfer[] { TextTransfer.getInstance(),
            FileTransfer.getInstance() });
    dropTarget.addDropListener(new TreeDropTargetAdapter(viewer, root));
}
项目:gef-gwt    文件:AbstractTransferDropTargetListener.java   
/**
 * Returns the current mouse location, as a {@link Point}. The location is
 * relative to the control's client area.
 * 
 * @return the drop location
 */
protected Point getDropLocation() {
    org.eclipse.swt.graphics.Point swt;
    swt = new org.eclipse.swt.graphics.Point(getCurrentEvent().x,
            getCurrentEvent().y);
    DropTarget target = (DropTarget) getCurrentEvent().widget;
    swt = target.getControl().toControl(swt);
    return new Point(swt.x, swt.y);
}
项目:gef-gwt    文件:AbstractEditPartViewer.java   
/**
 * Creates or disposes a DropTarget as needed, and sets the supported
 * transfer types. Clients should not need to call or override this method.
 */
protected void refreshDropTargetAdapter() {
    if (getControl() == null)
        return;
    if (getDelegatingDropAdapter().isEmpty())
        setDropTarget(null);
    else {
        if (getDropTarget() == null)
            setDropTarget(new DropTarget(getControl(), DND.DROP_MOVE
                    | DND.DROP_COPY | DND.DROP_LINK));
        getDropTarget().setTransfer(
                getDelegatingDropAdapter().getTransfers());
    }
}
项目:gef-gwt    文件:AbstractEditPartViewer.java   
/**
 * Sets the drop target. Called from {@link #refreshDropTargetAdapter()}.
 * 
 * @param target
 *            dropTarget <code>null</code> or a drop target
 */
protected void setDropTarget(DropTarget target) {
    if (dropTarget != null)
        dropTarget.dispose();
    dropTarget = target;
    if (dropTarget != null)
        hookDropTarget();
}
项目:idecore    文件:ForceIdeUrlDropHandler.java   
private void hookRecursive(Control child, DropTargetListener dropListener) {
    DropTarget childTarget = findDropTarget(child);
    if (childTarget != null) {
        registerWithExistingTarget(childTarget);
        registerDropListener(childTarget, dropListener);
    }
    if (child instanceof Composite) {
        Composite composite = (Composite) child;
        Control[] children = composite.getChildren();
        for (Control control : children) {
            hookRecursive(control, dropListener);
        }
    }
}