Search in sources :

Example 26 with DropTarget

use of java.awt.dnd.DropTarget in project jdk8u_jdk by JetBrains.

the class SunDropTargetContextPeer method processExitMessage.

/**
     *
     */
protected void processExitMessage(SunDropTargetEvent event) {
    Component c = (Component) event.getSource();
    DropTarget dt = c.getDropTarget();
    DropTargetContext dtc = null;
    if (dt == null) {
        currentDT = null;
        currentT = null;
        if (currentDTC != null) {
            currentDTC.removeNotify();
        }
        currentDTC = null;
        return;
    }
    if (dt != currentDT) {
        if (currentDTC != null) {
            currentDTC.removeNotify();
        }
        currentDT = dt;
        currentDTC = dt.getDropTargetContext();
        currentDTC.addNotify(this);
    }
    dtc = currentDTC;
    if (dt.isActive())
        try {
            ((DropTargetListener) dt).dragExit(new DropTargetEvent(dtc));
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            currentA = DnDConstants.ACTION_NONE;
            currentSA = DnDConstants.ACTION_NONE;
            currentDA = DnDConstants.ACTION_NONE;
            currentDT = null;
            currentT = null;
            currentDTC.removeNotify();
            currentDTC = null;
            local = null;
            dragRejected = false;
        }
}
Also used : DropTargetContext(java.awt.dnd.DropTargetContext) DropTargetEvent(java.awt.dnd.DropTargetEvent) DropTarget(java.awt.dnd.DropTarget) Component(java.awt.Component) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException) InvalidDnDOperationException(java.awt.dnd.InvalidDnDOperationException)

Example 27 with DropTarget

use of java.awt.dnd.DropTarget in project pcgen by PCGen.

the class NotesView method initDnDComponents.

private void initDnDComponents() {
    filesBarDT = new DropTarget(filesBar, new DropBarListener());
    treeDT = new DropTarget(notesTree, new DropTreeListener());
}
Also used : DropTarget(java.awt.dnd.DropTarget)

Example 28 with DropTarget

use of java.awt.dnd.DropTarget in project knime-core by knime.

the class SelectionPanel method createIncludePanel.

private void createIncludePanel() {
    m_includePanel = new JPanel(new GridBagLayout());
    new DropTarget(m_includePanel, DnDConstants.ACTION_MOVE, this, true, null);
    m_scrollPane = new JScrollPane(m_includePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    m_scrollPane.setPreferredSize(new Dimension(300, 200));
    m_scrollPane.getVerticalScrollBar().setUnitIncrement(20);
    MouseMotionListener doScrollRectToVisible = new MouseMotionAdapter() {

        int lasty = 0;

        @Override
        public void mouseDragged(final MouseEvent e) {
            if (Math.abs(lasty - e.getY()) < 10) {
                int i = m_scrollPane.getVerticalScrollBar().getValue();
                if (e.getY() > lasty) {
                    m_scrollPane.getVerticalScrollBar().setValue(i + 2);
                } else if (e.getY() < lasty) {
                    m_scrollPane.getVerticalScrollBar().setValue(i - 2);
                }
            }
            if (e.getY() < 10) {
                lasty = 10;
            } else if (e.getY() > m_includePanel.getVisibleRect().getMaxY()) {
                lasty = (int) m_includePanel.getVisibleRect().getMaxY() - 10;
            } else if (Math.abs(lasty - e.getY()) > 10) {
                lasty = e.getY();
            }
        }
    };
    m_includePanel.addMouseMotionListener(doScrollRectToVisible);
    m_includePanel.setAutoscrolls(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) MouseMotionAdapter(java.awt.event.MouseMotionAdapter) MouseEvent(java.awt.event.MouseEvent) GridBagLayout(java.awt.GridBagLayout) DropTarget(java.awt.dnd.DropTarget) Dimension(java.awt.Dimension) MouseMotionListener(java.awt.event.MouseMotionListener)

Example 29 with DropTarget

use of java.awt.dnd.DropTarget in project com.revolsys.open by revolsys.

the class FileDropTargetListener method hierarchyChanged.

@Override
public void hierarchyChanged(final HierarchyEvent event) {
    final Component component = event.getComponent();
    final java.awt.Component parent = component.getParent();
    if (parent == null) {
        component.setDropTarget(null);
    } else {
        new DropTarget(component, this);
    }
}
Also used : DropTarget(java.awt.dnd.DropTarget) Component(java.awt.Component) Component(java.awt.Component)

Example 30 with DropTarget

use of java.awt.dnd.DropTarget in project com.revolsys.open by revolsys.

the class FileDropTargetListener method addDropTarget.

public void addDropTarget(final Component component) {
    if (component.getParent() != null) {
        new DropTarget(component, this);
    }
    component.addHierarchyListener(this);
    if (component.getParent() != null) {
        new DropTarget(component, this);
    }
    if (component instanceof Container) {
        final Container container = (Container) component;
        final Component[] components = container.getComponents();
        for (final Component child : components) {
            addDropTarget(child);
        }
    }
}
Also used : Container(java.awt.Container) DropTarget(java.awt.dnd.DropTarget) Component(java.awt.Component)

Aggregations

DropTarget (java.awt.dnd.DropTarget)39 DropTargetDropEvent (java.awt.dnd.DropTargetDropEvent)12 Component (java.awt.Component)9 DropTargetAdapter (java.awt.dnd.DropTargetAdapter)9 DropTargetDragEvent (java.awt.dnd.DropTargetDragEvent)9 Point (java.awt.Point)5 Container (java.awt.Container)4 DropTargetListener (java.awt.dnd.DropTargetListener)4 MouseEvent (java.awt.event.MouseEvent)4 IOException (java.io.IOException)4 JPanel (javax.swing.JPanel)4 JScrollPane (javax.swing.JScrollPane)4 EditorFragmentComponent (com.intellij.codeInsight.hint.EditorFragmentComponent)3 JBLayeredPane (com.intellij.ui.components.JBLayeredPane)3 Activatable (com.intellij.util.ui.update.Activatable)3 UiNotifyConnector (com.intellij.util.ui.update.UiNotifyConnector)3 Dimension (java.awt.Dimension)3 DropTargetContext (java.awt.dnd.DropTargetContext)3 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)2 DropTargetEvent (java.awt.dnd.DropTargetEvent)2