java.awt.dnd.DropTargetContext Java Examples

The following examples show how to use java.awt.dnd.DropTargetContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TableDropAdapter.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
@Override
public void drop(DropTargetDropEvent e) {
  DropTargetContext targetContext = e.getDropTargetContext();

  if ((e.getSourceActions() & DnDConstants.ACTION_COPY) != 0)
    e.acceptDrop(DnDConstants.ACTION_COPY);
  else {
    e.rejectDrop();
    return;
  }

  // We know drag is coming from tree so just get selection:
  String typeName = annotationFeaturesViewer.getSelection();
  edit.addRow(typeName);
  targetContext.dropComplete(true);
}
 
Example #2
Source File: DnDHandler.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private DropTargetContext createDropTargetContext() throws SecurityException, NoSuchMethodException, IllegalArgumentException,
        InstantiationException, IllegalAccessException, InvocationTargetException {
    Constructor<DropTargetContext> c = DropTargetContext.class.getDeclaredConstructor(DropTarget.class);
    c.setAccessible(true);
    DropTargetContext inst = c.newInstance(dest.getDropTarget());
    inst.addNotify(createDropTargetContextPeer());
    return inst;
}
 
Example #3
Source File: DropedFileExtractor.java    From bigtable-sql with Apache License 2.0 5 votes vote down vote up
private static List<File> _getFiles(DropTargetDropEvent dtde, IApplication app, boolean allowMoreThanOneFile)
{
   try
   {
      DropTargetContext context = dtde.getDropTargetContext();
      dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
      Transferable t = dtde.getTransferable();
      List<File> filesToOpen = new ArrayList<File>();

      if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
          filesToOpen = handleJavaFileListFlavor(t, app, allowMoreThanOneFile);
      } else if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
          filesToOpen = handleStringFlavor(t, app, allowMoreThanOneFile);
      } else {
          filesToOpen = handleUriListFlavor(t);
      }
      context.dropComplete(true);

      if (null != filesToOpen)
      {
         return filesToOpen;
      }
      else
      {
         return new ArrayList<File>();
      }
   }
   catch (Exception e)
   {
      throw new RuntimeException(e);
   }
}
 
Example #4
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override public void drop(DropTargetDropEvent e) {
  try {
    DropTargetContext c = e.getDropTargetContext();
    Component o = c.getComponent();
    Transferable t = e.getTransferable();
    DataFlavor[] f = t.getTransferDataFlavors();

    if (o instanceof JTabbedPane) {
      JTabbedPane jtp = (JTabbedPane) o;
      JScrollPane sp = (JScrollPane) jtp.getComponentAt(targetTabIndex);
      JViewport vp = sp.getViewport();
      JList<String> targetList = (JList<String>) SwingUtilities.getUnwrappedView(vp);
      JList<String> sourceList = (JList<String>) t.getTransferData(f[0]);

      DefaultListModel<String> tm = (DefaultListModel<String>) targetList.getModel();
      DefaultListModel<String> sm = (DefaultListModel<String>) sourceList.getModel();

      int[] indices = sourceList.getSelectedIndices();
      for (int j = indices.length - 1; j >= 0; j--) {
        tm.addElement(sm.remove(indices[j]));
      }
      e.dropComplete(true);
    } else {
      e.dropComplete(false);
    }
  } catch (UnsupportedFlavorException | IOException ex) {
    e.dropComplete(false);
  }
}
 
Example #5
Source File: SunDropTargetContextPeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processMotionMessage(SunDropTargetEvent event,
                                  boolean operationChanged) {
    Component         c    = (Component)event.getSource();
    Point             hots = event.getPoint();
    int               id   = event.getID();
    DropTarget        dt   = c.getDropTarget();
    DropTargetContext dtc  = null;

    if (c.isShowing() && (dt != null) && dt.isActive()) {
        if (currentDT != dt) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDT  = dt;
            currentDTC = null;
        }

        dtc = currentDT.getDropTargetContext();
        if (dtc != currentDTC) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDTC = dtc;
            currentDTC.addNotify(this);
        }

        currentA = currentDT.getDefaultActions();

        try {
            DropTargetDragEvent dtde = new DropTargetDragEvent(dtc,
                                                               hots,
                                                               currentDA,
                                                               currentSA);
            DropTargetListener dtl = (DropTargetListener)dt;
            if (operationChanged) {
                dtl.dropActionChanged(dtde);
            } else {
                dtl.dragOver(dtde);
            }

            if (dragRejected) {
                currentDA = DnDConstants.ACTION_NONE;
            }
        } catch (Exception e) {
            e.printStackTrace();
            currentDA = DnDConstants.ACTION_NONE;
        }
    } else {
        currentDA = DnDConstants.ACTION_NONE;
    }
}
 
Example #6
Source File: SunDropTargetContextPeer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processDropMessage(SunDropTargetEvent event) {
    Component  c    = (Component)event.getSource();
    Point      hots = event.getPoint();
    DropTarget dt   = c.getDropTarget();

    dropStatus   = STATUS_WAIT; // drop pending ACK
    dropComplete = false;

    if (c.isShowing() && dt != null && dt.isActive()) {
        DropTargetContext dtc = dt.getDropTargetContext();

        currentDT = dt;

        if (currentDTC != null) {
            currentDTC.removeNotify();
        }

        currentDTC = dtc;
        currentDTC.addNotify(this);
        currentA = dt.getDefaultActions();

        synchronized(_globalLock) {
            if ((local = getJVMLocalSourceTransferable()) != null)
                setCurrentJVMLocalSourceTransferable(null);
        }

        dropInProcess = true;

        try {
            ((DropTargetListener)dt).drop(new DropTargetDropEvent(dtc,
                                                                  hots,
                                                                  currentDA,
                                                                  currentSA,
                                                                  local != null));
        } finally {
            if (dropStatus == STATUS_WAIT) {
                rejectDrop();
            } else if (dropComplete == false) {
                dropComplete(false);
            }
            dropInProcess = false;
        }
    } else {
        rejectDrop();
    }
}
 
Example #7
Source File: SunDropTargetContextPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processMotionMessage(SunDropTargetEvent event,
                                  boolean operationChanged) {
    Component         c    = (Component)event.getSource();
    Point             hots = event.getPoint();
    int               id   = event.getID();
    DropTarget        dt   = c.getDropTarget();
    DropTargetContext dtc  = null;

    if (c.isShowing() && (dt != null) && dt.isActive()) {
        if (currentDT != dt) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDT  = dt;
            currentDTC = null;
        }

        dtc = currentDT.getDropTargetContext();
        if (dtc != currentDTC) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDTC = dtc;
            currentDTC.addNotify(this);
        }

        currentA = currentDT.getDefaultActions();

        try {
            DropTargetDragEvent dtde = new DropTargetDragEvent(dtc,
                                                               hots,
                                                               currentDA,
                                                               currentSA);
            DropTargetListener dtl = (DropTargetListener)dt;
            if (operationChanged) {
                dtl.dropActionChanged(dtde);
            } else {
                dtl.dragOver(dtde);
            }

            if (dragRejected) {
                currentDA = DnDConstants.ACTION_NONE;
            }
        } catch (Exception e) {
            e.printStackTrace();
            currentDA = DnDConstants.ACTION_NONE;
        }
    } else {
        currentDA = DnDConstants.ACTION_NONE;
    }
}
 
Example #8
Source File: SunDropTargetContextPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

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;
    }
}
 
Example #9
Source File: SunDropTargetContextPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processMotionMessage(SunDropTargetEvent event,
                                  boolean operationChanged) {
    Component         c    = (Component)event.getSource();
    Point             hots = event.getPoint();
    int               id   = event.getID();
    DropTarget        dt   = c.getDropTarget();
    DropTargetContext dtc  = null;

    if (c.isShowing() && (dt != null) && dt.isActive()) {
        if (currentDT != dt) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDT  = dt;
            currentDTC = null;
        }

        dtc = currentDT.getDropTargetContext();
        if (dtc != currentDTC) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDTC = dtc;
            currentDTC.addNotify(this);
        }

        currentA = currentDT.getDefaultActions();

        try {
            DropTargetDragEvent dtde = new DropTargetDragEvent(dtc,
                                                               hots,
                                                               currentDA,
                                                               currentSA);
            DropTargetListener dtl = (DropTargetListener)dt;
            if (operationChanged) {
                dtl.dropActionChanged(dtde);
            } else {
                dtl.dragOver(dtde);
            }

            if (dragRejected) {
                currentDA = DnDConstants.ACTION_NONE;
            }
        } catch (Exception e) {
            e.printStackTrace();
            currentDA = DnDConstants.ACTION_NONE;
        }
    } else {
        currentDA = DnDConstants.ACTION_NONE;
    }
}
 
Example #10
Source File: SunDropTargetContextPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processDropMessage(SunDropTargetEvent event) {
    Component  c    = (Component)event.getSource();
    Point      hots = event.getPoint();
    DropTarget dt   = c.getDropTarget();

    dropStatus   = STATUS_WAIT; // drop pending ACK
    dropComplete = false;

    if (c.isShowing() && dt != null && dt.isActive()) {
        DropTargetContext dtc = dt.getDropTargetContext();

        currentDT = dt;

        if (currentDTC != null) {
            currentDTC.removeNotify();
        }

        currentDTC = dtc;
        currentDTC.addNotify(this);
        currentA = dt.getDefaultActions();

        synchronized(_globalLock) {
            if ((local = getJVMLocalSourceTransferable()) != null)
                setCurrentJVMLocalSourceTransferable(null);
        }

        dropInProcess = true;

        try {
            ((DropTargetListener)dt).drop(new DropTargetDropEvent(dtc,
                                                                  hots,
                                                                  currentDA,
                                                                  currentSA,
                                                                  local != null));
        } finally {
            if (dropStatus == STATUS_WAIT) {
                rejectDrop();
            } else if (dropComplete == false) {
                dropComplete(false);
            }
            dropInProcess = false;
        }
    } else {
        rejectDrop();
    }
}
 
Example #11
Source File: SunDropTargetContextPeer.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 *
 */

protected void processExitMessage(SunDropTargetEvent event) {
    Component         c   = (Component)event.getSource();
    DropTarget        dt  = c.getDropTarget();
    DropTargetContext dtc = null;
    DropTargetContextAccessor acc =
            AWTAccessor.getDropTargetContextAccessor();

    if (dt == null) {
        currentDT = null;
        currentT  = null;

        if (currentDTC != null) {
            acc.reset(currentDTC);
        }

        currentDTC = null;

        return;
    }

    if (dt != currentDT) {

        if (currentDTC != null) {
            acc.reset(currentDTC);
        }

        currentDT  = dt;
        currentDTC = dt.getDropTargetContext();

        acc.setDropTargetContextPeer(currentDTC, 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;

        acc.reset(currentDTC);
        currentDTC = null;

        local = null;

        dragRejected = false;
    }
}
 
Example #12
Source File: SunDropTargetContextPeer.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 *
 */

protected void processDropMessage(SunDropTargetEvent event) {
    Component  c    = (Component)event.getSource();
    Point      hots = event.getPoint();
    DropTarget dt   = c.getDropTarget();

    dropStatus   = STATUS_WAIT; // drop pending ACK
    dropComplete = false;

    if (c.isShowing() && dt != null && dt.isActive()) {
        DropTargetContext dtc = dt.getDropTargetContext();

        currentDT = dt;
        DropTargetContextAccessor acc =
                AWTAccessor.getDropTargetContextAccessor();

        if (currentDTC != null) {
            acc.reset(currentDTC);
        }

        currentDTC = dtc;
        acc.setDropTargetContextPeer(currentDTC, this);
        currentA = dt.getDefaultActions();

        synchronized(_globalLock) {
            if ((local = getJVMLocalSourceTransferable()) != null)
                setCurrentJVMLocalSourceTransferable(null);
        }

        dropInProcess = true;

        try {
            ((DropTargetListener)dt).drop(new DropTargetDropEvent(dtc,
                                                                  hots,
                                                                  currentDA,
                                                                  currentSA,
                                                                  local != null));
        } finally {
            if (dropStatus == STATUS_WAIT) {
                rejectDrop();
            } else if (dropComplete == false) {
                dropComplete(false);
            }
            dropInProcess = false;
        }
    } else {
        rejectDrop();
    }
}
 
Example #13
Source File: SunDropTargetContextPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processExitMessage(SunDropTargetEvent event) {
    Component         c   = (Component)event.getSource();
    DropTarget        dt  = c.getDropTarget();
    DropTargetContext dtc = null;
    DropTargetContextAccessor acc =
            AWTAccessor.getDropTargetContextAccessor();

    if (dt == null) {
        currentDT = null;
        currentT  = null;

        if (currentDTC != null) {
            acc.reset(currentDTC);
        }

        currentDTC = null;

        return;
    }

    if (dt != currentDT) {

        if (currentDTC != null) {
            acc.reset(currentDTC);
        }

        currentDT  = dt;
        currentDTC = dt.getDropTargetContext();

        acc.setDropTargetContextPeer(currentDTC, 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;

        acc.reset(currentDTC);
        currentDTC = null;

        local = null;

        dragRejected = false;
    }
}
 
Example #14
Source File: SunDropTargetContextPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processMotionMessage(SunDropTargetEvent event,
                                  boolean operationChanged) {
    Component         c    = (Component)event.getSource();
    Point             hots = event.getPoint();
    int               id   = event.getID();
    DropTarget        dt   = c.getDropTarget();
    DropTargetContext dtc  = null;
    DropTargetContextAccessor acc =
            AWTAccessor.getDropTargetContextAccessor();

    if (c.isShowing() && (dt != null) && dt.isActive()) {
        if (currentDT != dt) {
            if (currentDTC != null) {
                acc.reset(currentDTC);
            }

            currentDT  = dt;
            currentDTC = null;
        }

        dtc = currentDT.getDropTargetContext();
        if (dtc != currentDTC) {
            if (currentDTC != null) {
                acc.reset(currentDTC);
            }

            currentDTC = dtc;
            acc.setDropTargetContextPeer(currentDTC, this);
        }

        currentA = currentDT.getDefaultActions();

        try {
            DropTargetDragEvent dtde = new DropTargetDragEvent(dtc,
                                                               hots,
                                                               currentDA,
                                                               currentSA);
            DropTargetListener dtl = (DropTargetListener)dt;
            if (operationChanged) {
                dtl.dropActionChanged(dtde);
            } else {
                dtl.dragOver(dtde);
            }

            if (dragRejected) {
                currentDA = DnDConstants.ACTION_NONE;
            }
        } catch (Exception e) {
            e.printStackTrace();
            currentDA = DnDConstants.ACTION_NONE;
        }
    } else {
        currentDA = DnDConstants.ACTION_NONE;
    }
}
 
Example #15
Source File: SunDropTargetContextPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processDropMessage(SunDropTargetEvent event) {
    Component  c    = (Component)event.getSource();
    Point      hots = event.getPoint();
    DropTarget dt   = c.getDropTarget();

    dropStatus   = STATUS_WAIT; // drop pending ACK
    dropComplete = false;

    if (c.isShowing() && dt != null && dt.isActive()) {
        DropTargetContext dtc = dt.getDropTargetContext();

        currentDT = dt;
        DropTargetContextAccessor acc =
                AWTAccessor.getDropTargetContextAccessor();

        if (currentDTC != null) {
            acc.reset(currentDTC);
        }

        currentDTC = dtc;
        acc.setDropTargetContextPeer(currentDTC, this);
        currentA = dt.getDefaultActions();

        synchronized(_globalLock) {
            if ((local = getJVMLocalSourceTransferable()) != null)
                setCurrentJVMLocalSourceTransferable(null);
        }

        dropInProcess = true;

        try {
            ((DropTargetListener)dt).drop(new DropTargetDropEvent(dtc,
                                                                  hots,
                                                                  currentDA,
                                                                  currentSA,
                                                                  local != null));
        } finally {
            if (dropStatus == STATUS_WAIT) {
                rejectDrop();
            } else if (dropComplete == false) {
                dropComplete(false);
            }
            dropInProcess = false;
        }
    } else {
        rejectDrop();
    }
}
 
Example #16
Source File: AWTAccessor.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static DropTargetContextAccessor getDropTargetContextAccessor() {
    if (dropTargetContextAccessor == null) {
        unsafe.ensureClassInitialized(DropTargetContext.class);
    }
    return dropTargetContextAccessor;
}
 
Example #17
Source File: AWTAccessor.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public static DropTargetContextAccessor getDropTargetContextAccessor() {
    if (dropTargetContextAccessor == null) {
        unsafe.ensureClassInitialized(DropTargetContext.class);
    }
    return dropTargetContextAccessor;
}
 
Example #18
Source File: SunDropTargetContextPeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processDropMessage(SunDropTargetEvent event) {
    Component  c    = (Component)event.getSource();
    Point      hots = event.getPoint();
    DropTarget dt   = c.getDropTarget();

    dropStatus   = STATUS_WAIT; // drop pending ACK
    dropComplete = false;

    if (c.isShowing() && dt != null && dt.isActive()) {
        DropTargetContext dtc = dt.getDropTargetContext();

        currentDT = dt;

        if (currentDTC != null) {
            currentDTC.removeNotify();
        }

        currentDTC = dtc;
        currentDTC.addNotify(this);
        currentA = dt.getDefaultActions();

        synchronized(_globalLock) {
            if ((local = getJVMLocalSourceTransferable()) != null)
                setCurrentJVMLocalSourceTransferable(null);
        }

        dropInProcess = true;

        try {
            ((DropTargetListener)dt).drop(new DropTargetDropEvent(dtc,
                                                                  hots,
                                                                  currentDA,
                                                                  currentSA,
                                                                  local != null));
        } finally {
            if (dropStatus == STATUS_WAIT) {
                rejectDrop();
            } else if (dropComplete == false) {
                dropComplete(false);
            }
            dropInProcess = false;
        }
    } else {
        rejectDrop();
    }
}
 
Example #19
Source File: SunDropTargetContextPeer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

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;
    }
}
 
Example #20
Source File: SunDropTargetContextPeer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processDropMessage(SunDropTargetEvent event) {
    Component  c    = (Component)event.getSource();
    Point      hots = event.getPoint();
    DropTarget dt   = c.getDropTarget();

    dropStatus   = STATUS_WAIT; // drop pending ACK
    dropComplete = false;

    if (c.isShowing() && dt != null && dt.isActive()) {
        DropTargetContext dtc = dt.getDropTargetContext();

        currentDT = dt;

        if (currentDTC != null) {
            currentDTC.removeNotify();
        }

        currentDTC = dtc;
        currentDTC.addNotify(this);
        currentA = dt.getDefaultActions();

        synchronized(_globalLock) {
            if ((local = getJVMLocalSourceTransferable()) != null)
                setCurrentJVMLocalSourceTransferable(null);
        }

        dropInProcess = true;

        try {
            ((DropTargetListener)dt).drop(new DropTargetDropEvent(dtc,
                                                                  hots,
                                                                  currentDA,
                                                                  currentSA,
                                                                  local != null));
        } finally {
            if (dropStatus == STATUS_WAIT) {
                rejectDrop();
            } else if (dropComplete == false) {
                dropComplete(false);
            }
            dropInProcess = false;
        }
    } else {
        rejectDrop();
    }
}
 
Example #21
Source File: SunDropTargetContextPeer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processMotionMessage(SunDropTargetEvent event,
                                  boolean operationChanged) {
    Component         c    = (Component)event.getSource();
    Point             hots = event.getPoint();
    int               id   = event.getID();
    DropTarget        dt   = c.getDropTarget();
    DropTargetContext dtc  = null;

    if (c.isShowing() && (dt != null) && dt.isActive()) {
        if (currentDT != dt) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDT  = dt;
            currentDTC = null;
        }

        dtc = currentDT.getDropTargetContext();
        if (dtc != currentDTC) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDTC = dtc;
            currentDTC.addNotify(this);
        }

        currentA = currentDT.getDefaultActions();

        try {
            DropTargetDragEvent dtde = new DropTargetDragEvent(dtc,
                                                               hots,
                                                               currentDA,
                                                               currentSA);
            DropTargetListener dtl = (DropTargetListener)dt;
            if (operationChanged) {
                dtl.dropActionChanged(dtde);
            } else {
                dtl.dragOver(dtde);
            }

            if (dragRejected) {
                currentDA = DnDConstants.ACTION_NONE;
            }
        } catch (Exception e) {
            e.printStackTrace();
            currentDA = DnDConstants.ACTION_NONE;
        }
    } else {
        currentDA = DnDConstants.ACTION_NONE;
    }
}
 
Example #22
Source File: SunDropTargetContextPeer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processDropMessage(SunDropTargetEvent event) {
    Component  c    = (Component)event.getSource();
    Point      hots = event.getPoint();
    DropTarget dt   = c.getDropTarget();

    dropStatus   = STATUS_WAIT; // drop pending ACK
    dropComplete = false;

    if (c.isShowing() && dt != null && dt.isActive()) {
        DropTargetContext dtc = dt.getDropTargetContext();

        currentDT = dt;

        if (currentDTC != null) {
            currentDTC.removeNotify();
        }

        currentDTC = dtc;
        currentDTC.addNotify(this);
        currentA = dt.getDefaultActions();

        synchronized(_globalLock) {
            if ((local = getJVMLocalSourceTransferable()) != null)
                setCurrentJVMLocalSourceTransferable(null);
        }

        dropInProcess = true;

        try {
            ((DropTargetListener)dt).drop(new DropTargetDropEvent(dtc,
                                                                  hots,
                                                                  currentDA,
                                                                  currentSA,
                                                                  local != null));
        } finally {
            if (dropStatus == STATUS_WAIT) {
                rejectDrop();
            } else if (dropComplete == false) {
                dropComplete(false);
            }
            dropInProcess = false;
        }
    } else {
        rejectDrop();
    }
}
 
Example #23
Source File: SunDropTargetContextPeer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

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;
    }
}
 
Example #24
Source File: SunDropTargetContextPeer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processMotionMessage(SunDropTargetEvent event,
                                  boolean operationChanged) {
    Component         c    = (Component)event.getSource();
    Point             hots = event.getPoint();
    int               id   = event.getID();
    DropTarget        dt   = c.getDropTarget();
    DropTargetContext dtc  = null;

    if (c.isShowing() && (dt != null) && dt.isActive()) {
        if (currentDT != dt) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDT  = dt;
            currentDTC = null;
        }

        dtc = currentDT.getDropTargetContext();
        if (dtc != currentDTC) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDTC = dtc;
            currentDTC.addNotify(this);
        }

        currentA = currentDT.getDefaultActions();

        try {
            DropTargetDragEvent dtde = new DropTargetDragEvent(dtc,
                                                               hots,
                                                               currentDA,
                                                               currentSA);
            DropTargetListener dtl = (DropTargetListener)dt;
            if (operationChanged) {
                dtl.dropActionChanged(dtde);
            } else {
                dtl.dragOver(dtde);
            }

            if (dragRejected) {
                currentDA = DnDConstants.ACTION_NONE;
            }
        } catch (Exception e) {
            e.printStackTrace();
            currentDA = DnDConstants.ACTION_NONE;
        }
    } else {
        currentDA = DnDConstants.ACTION_NONE;
    }
}
 
Example #25
Source File: SunDropTargetContextPeer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processDropMessage(SunDropTargetEvent event) {
    Component  c    = (Component)event.getSource();
    Point      hots = event.getPoint();
    DropTarget dt   = c.getDropTarget();

    dropStatus   = STATUS_WAIT; // drop pending ACK
    dropComplete = false;

    if (c.isShowing() && dt != null && dt.isActive()) {
        DropTargetContext dtc = dt.getDropTargetContext();

        currentDT = dt;

        if (currentDTC != null) {
            currentDTC.removeNotify();
        }

        currentDTC = dtc;
        currentDTC.addNotify(this);
        currentA = dt.getDefaultActions();

        synchronized(_globalLock) {
            if ((local = getJVMLocalSourceTransferable()) != null)
                setCurrentJVMLocalSourceTransferable(null);
        }

        dropInProcess = true;

        try {
            ((DropTargetListener)dt).drop(new DropTargetDropEvent(dtc,
                                                                  hots,
                                                                  currentDA,
                                                                  currentSA,
                                                                  local != null));
        } finally {
            if (dropStatus == STATUS_WAIT) {
                rejectDrop();
            } else if (dropComplete == false) {
                dropComplete(false);
            }
            dropInProcess = false;
        }
    } else {
        rejectDrop();
    }
}
 
Example #26
Source File: SunDropTargetContextPeer.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

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;
    }
}
 
Example #27
Source File: SunDropTargetContextPeer.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processMotionMessage(SunDropTargetEvent event,
                                  boolean operationChanged) {
    Component         c    = (Component)event.getSource();
    Point             hots = event.getPoint();
    int               id   = event.getID();
    DropTarget        dt   = c.getDropTarget();
    DropTargetContext dtc  = null;

    if (c.isShowing() && (dt != null) && dt.isActive()) {
        if (currentDT != dt) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDT  = dt;
            currentDTC = null;
        }

        dtc = currentDT.getDropTargetContext();
        if (dtc != currentDTC) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDTC = dtc;
            currentDTC.addNotify(this);
        }

        currentA = currentDT.getDefaultActions();

        try {
            DropTargetDragEvent dtde = new DropTargetDragEvent(dtc,
                                                               hots,
                                                               currentDA,
                                                               currentSA);
            DropTargetListener dtl = (DropTargetListener)dt;
            if (operationChanged) {
                dtl.dropActionChanged(dtde);
            } else {
                dtl.dragOver(dtde);
            }

            if (dragRejected) {
                currentDA = DnDConstants.ACTION_NONE;
            }
        } catch (Exception e) {
            e.printStackTrace();
            currentDA = DnDConstants.ACTION_NONE;
        }
    } else {
        currentDA = DnDConstants.ACTION_NONE;
    }
}
 
Example #28
Source File: SunDropTargetContextPeer.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processDropMessage(SunDropTargetEvent event) {
    Component  c    = (Component)event.getSource();
    Point      hots = event.getPoint();
    DropTarget dt   = c.getDropTarget();

    dropStatus   = STATUS_WAIT; // drop pending ACK
    dropComplete = false;

    if (c.isShowing() && dt != null && dt.isActive()) {
        DropTargetContext dtc = dt.getDropTargetContext();

        currentDT = dt;

        if (currentDTC != null) {
            currentDTC.removeNotify();
        }

        currentDTC = dtc;
        currentDTC.addNotify(this);
        currentA = dt.getDefaultActions();

        synchronized(_globalLock) {
            if ((local = getJVMLocalSourceTransferable()) != null)
                setCurrentJVMLocalSourceTransferable(null);
        }

        dropInProcess = true;

        try {
            ((DropTargetListener)dt).drop(new DropTargetDropEvent(dtc,
                                                                  hots,
                                                                  currentDA,
                                                                  currentSA,
                                                                  local != null));
        } finally {
            if (dropStatus == STATUS_WAIT) {
                rejectDrop();
            } else if (dropComplete == false) {
                dropComplete(false);
            }
            dropInProcess = false;
        }
    } else {
        rejectDrop();
    }
}
 
Example #29
Source File: SunDropTargetContextPeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

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;
    }
}
 
Example #30
Source File: SunDropTargetContextPeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 *
 */

protected void processMotionMessage(SunDropTargetEvent event,
                                  boolean operationChanged) {
    Component         c    = (Component)event.getSource();
    Point             hots = event.getPoint();
    int               id   = event.getID();
    DropTarget        dt   = c.getDropTarget();
    DropTargetContext dtc  = null;

    if (c.isShowing() && (dt != null) && dt.isActive()) {
        if (currentDT != dt) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDT  = dt;
            currentDTC = null;
        }

        dtc = currentDT.getDropTargetContext();
        if (dtc != currentDTC) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDTC = dtc;
            currentDTC.addNotify(this);
        }

        currentA = currentDT.getDefaultActions();

        try {
            DropTargetDragEvent dtde = new DropTargetDragEvent(dtc,
                                                               hots,
                                                               currentDA,
                                                               currentSA);
            DropTargetListener dtl = (DropTargetListener)dt;
            if (operationChanged) {
                dtl.dropActionChanged(dtde);
            } else {
                dtl.dragOver(dtde);
            }

            if (dragRejected) {
                currentDA = DnDConstants.ACTION_NONE;
            }
        } catch (Exception e) {
            e.printStackTrace();
            currentDA = DnDConstants.ACTION_NONE;
        }
    } else {
        currentDA = DnDConstants.ACTION_NONE;
    }
}