Java 类java.awt.datatransfer.FlavorMap 实例源码

项目:javify    文件:DropTarget.java   
/**
 * Creates a <code>DropTarget</code> object.
 *
 * @exception HeadlessException If GraphicsEnvironment.isHeadless()
 * returns true.
 */
public DropTarget (Component c, int i, DropTargetListener dtl, boolean b,
                   FlavorMap fm)
{
  if (GraphicsEnvironment.isHeadless ())
    throw new HeadlessException ();

  setComponent(c);
  setDefaultActions(i);
  dropTargetListener = dtl;

  if (fm == null)
    flavorMap = SystemFlavorMap.getDefaultFlavorMap();
  else
    flavorMap = fm;

  setActive (b);

  if (c != null)
    c.setDropTarget(this);
}
项目:intellij-ce-playground    文件:FileCopyPasteUtil.java   
public static DataFlavor createDataFlavor(@NotNull final String mimeType, @Nullable final Class<?> klass, final boolean register) {
  try {
    final DataFlavor flavor =
      klass != null ? new DataFlavor(mimeType + ";class=" + klass.getName(), null, klass.getClassLoader()) : new DataFlavor(mimeType);

    if (register) {
      final FlavorMap map = SystemFlavorMap.getDefaultFlavorMap();
      if (map instanceof SystemFlavorMap) {
        ((SystemFlavorMap)map).addUnencodedNativeForFlavor(flavor, mimeType);
      }
    }

    return flavor;
  }
  catch (ClassNotFoundException e) {
    LOG.error(e);
    //noinspection ConstantConditions
    return null;
  }
}
项目:jvm-stm    文件:DropTarget.java   
/**
 * Creates a <code>DropTarget</code> object.
 *
 * @exception HeadlessException If GraphicsEnvironment.isHeadless()
 * returns true.
 */
public DropTarget (Component c, int i, DropTargetListener dtl, boolean b,
                   FlavorMap fm)
{
  if (GraphicsEnvironment.isHeadless ())
    throw new HeadlessException ();

  setComponent(c);
  setDefaultActions(i);
  dropTargetListener = dtl;

  if (fm == null)
    flavorMap = SystemFlavorMap.getDefaultFlavorMap();
  else
    flavorMap = fm;

  setActive (b);

  if (c != null)
    c.setDropTarget(this);
}
项目:VarJ    文件:DropTarget.java   
/**
    * Creates a new DropTarget given the <code>Component</code> 
    * to associate itself with, an <code>int</code> representing
    * the default acceptable action(s) to 
    * support, a <code>DropTargetListener</code>
    * to handle event processing, a <code>boolean</code> indicating 
    * if the <code>DropTarget</code> is currently accepting drops, and 
    * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
    * <P>
    * The Component will receive drops only if it is enabled.
    * @param c  The <code>Component</code> with which this <code>DropTarget</code> is associated
    * @param ops    The default acceptable actions for this <code>DropTarget</code>
    * @param dtl    The <code>DropTargetListener</code> for this <code>DropTarget</code>
    * @param act    Is the <code>DropTarget</code> accepting drops.
    * @param fm The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE> 
    * @exception HeadlessException if GraphicsEnvironment.isHeadless()
    *            returns true
    * @see java.awt.GraphicsEnvironment#isHeadless
    */
   public DropTarget(Component c, int ops, DropTargetListener dtl,
          boolean act, FlavorMap fm)
       throws HeadlessException
   {
       if (GraphicsEnvironment.isHeadless()) {
           throw new HeadlessException();
       }

component = c;

setDefaultActions(ops);

if (dtl != null) try {
    addDropTargetListener(dtl);
} catch (TooManyListenersException tmle) {
    // do nothing!
}

if (c != null) {
    c.setDropTarget(this);
    setActive(act);
}

       if (fm != null) flavorMap = fm;
   }
项目:jo-widgets    文件:SwingClipboard.java   
public SwingClipboard() {
    super(SwingOptions.getClipbaordPollingMillis());
    if (!SwingUtilities.isEventDispatchThread()) {
        throw new IllegalStateException("The clipboard must be created in the event dispatcher thread");
    }

    this.systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();

    final FlavorMap map = SystemFlavorMap.getDefaultFlavorMap();
    if (map instanceof SystemFlavorMap) {
        final SystemFlavorMap systemMap = (SystemFlavorMap) map;
        systemMap.addFlavorForUnencodedNative(TransferContainer.MIME_TYPE, TRANSFER_CONTAINER_FLAVOR);
        systemMap.addUnencodedNativeForFlavor(TRANSFER_CONTAINER_FLAVOR, TransferContainer.MIME_TYPE);
    }

    checkContentChanged();
}
项目:cn1    文件:DragSource.java   
public void startDrag(DragGestureEvent trigger, Cursor dragCursor, 
                      Image dragImage, Point imageOffset, 
                      Transferable transferable, DragSourceListener dsl,
                      FlavorMap flavorMap)
        throws InvalidDnDOperationException {

    if (curContext != null) {
        // awt.171=Attempt to start a drag while an existing drag operation is still executing.
        throw new InvalidDnDOperationException(Messages.getString("awt.171"));  //$NON-NLS-1$
    }

    DragSourceContextPeer peer =
        Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);
    curContext = createDragSourceContext(peer, trigger, dragCursor,
                                         dragImage, imageOffset,
                                         transferable, dsl);

    peer.startDrag(curContext, dragCursor, dragImage, imageOffset);
    curContext = null;
}
项目:cn1    文件:DropTargetTest.java   
public void testDropTargetComponentintDropTargetListenerbooleanFlavorMap() {
    Component c = new Component() {};
    int ops = 1;
    DropTargetListener dtl = new DTL();
    FlavorMap fm = new FM();
    DropTarget dt = new DropTarget(c, ops, dtl, false, fm);
    assertSame(c, dt.getComponent());
    assertSame(dt, c.getDropTarget());
    assertEquals(ops, dt.getDefaultActions());
    assertFalse(dt.isActive());
    assertSame(fm, dt.getFlavorMap());
    try {
        dt.removeDropTargetListener(new DTL());
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    }
    dt.removeDropTargetListener(dtl);
}
项目:JamVM-PH    文件:DropTarget.java   
/**
 * Creates a <code>DropTarget</code> object.
 *
 * @exception HeadlessException If GraphicsEnvironment.isHeadless()
 * returns true.
 */
public DropTarget (Component c, int i, DropTargetListener dtl, boolean b,
                   FlavorMap fm)
{
  if (GraphicsEnvironment.isHeadless ())
    throw new HeadlessException ();

  setComponent(c);
  setDefaultActions(i);
  dropTargetListener = dtl;

  if (fm == null)
    flavorMap = SystemFlavorMap.getDefaultFlavorMap();
  else
    flavorMap = fm;

  setActive (b);

  if (c != null)
    c.setDropTarget(this);
}
项目:tools-idea    文件:FileCopyPasteUtil.java   
public static DataFlavor createDataFlavor(@NotNull final String mimeType, @Nullable final Class<?> klass, final boolean register) {
  try {
    final String typeString = klass != null ? mimeType + ";class=" + klass.getName() : mimeType;
    final DataFlavor flavor = new DataFlavor(typeString);

    if (register) {
      final FlavorMap map = SystemFlavorMap.getDefaultFlavorMap();
      if (map instanceof SystemFlavorMap) {
        ((SystemFlavorMap)map).addUnencodedNativeForFlavor(flavor, mimeType);
      }
    }

    return flavor;
  }
  catch (ClassNotFoundException e) {
    LOG.error(e);
    //noinspection ConstantConditions
    return null;
  }
}
项目:classpath    文件:DropTarget.java   
/**
 * Creates a <code>DropTarget</code> object.
 *
 * @exception HeadlessException If GraphicsEnvironment.isHeadless()
 * returns true.
 */
public DropTarget (Component c, int i, DropTargetListener dtl, boolean b,
                   FlavorMap fm)
{
  if (GraphicsEnvironment.isHeadless ())
    throw new HeadlessException ();

  setComponent(c);
  setDefaultActions(i);
  dropTargetListener = dtl;

  if (fm == null)
    flavorMap = SystemFlavorMap.getDefaultFlavorMap();
  else
    flavorMap = fm;

  setActive (b);

  if (c != null)
    c.setDropTarget(this);
}
项目:freeVM    文件:DragSource.java   
public void startDrag(DragGestureEvent trigger, Cursor dragCursor, 
                      Image dragImage, Point imageOffset, 
                      Transferable transferable, DragSourceListener dsl,
                      FlavorMap flavorMap)
        throws InvalidDnDOperationException {

    if (curContext != null) {
        // awt.171=Attempt to start a drag while an existing drag operation is still executing.
        throw new InvalidDnDOperationException(Messages.getString("awt.171"));  //$NON-NLS-1$
    }

    DragSourceContextPeer peer =
        Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);
    curContext = createDragSourceContext(peer, trigger, dragCursor,
                                         dragImage, imageOffset,
                                         transferable, dsl);

    peer.startDrag(curContext, dragCursor, dragImage, imageOffset);
    curContext = null;
}
项目:freeVM    文件:DropTargetTest.java   
public void testDropTargetComponentintDropTargetListenerbooleanFlavorMap() {
    Component c = new Component() {};
    int ops = 1;
    DropTargetListener dtl = new DTL();
    FlavorMap fm = new FM();
    DropTarget dt = new DropTarget(c, ops, dtl, false, fm);
    assertSame(c, dt.getComponent());
    assertSame(dt, c.getDropTarget());
    assertEquals(ops, dt.getDefaultActions());
    assertFalse(dt.isActive());
    assertSame(fm, dt.getFlavorMap());
    try {
        dt.removeDropTargetListener(new DTL());
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    }
    dt.removeDropTargetListener(dtl);
}
项目:freeVM    文件:DragSource.java   
public void startDrag(DragGestureEvent trigger, Cursor dragCursor, 
                      Image dragImage, Point imageOffset, 
                      Transferable transferable, DragSourceListener dsl,
                      FlavorMap flavorMap)
        throws InvalidDnDOperationException {

    if (curContext != null) {
        // awt.171=Attempt to start a drag while an existing drag operation is still executing.
        throw new InvalidDnDOperationException(Messages.getString("awt.171"));  //$NON-NLS-1$
    }

    DragSourceContextPeer peer =
        Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);
    curContext = createDragSourceContext(peer, trigger, dragCursor,
                                         dragImage, imageOffset,
                                         transferable, dsl);

    peer.startDrag(curContext, dragCursor, dragImage, imageOffset);
    curContext = null;
}
项目:freeVM    文件:DropTargetTest.java   
public void testDropTargetComponentintDropTargetListenerbooleanFlavorMap() {
    Component c = new Component() {};
    int ops = 1;
    DropTargetListener dtl = new DTL();
    FlavorMap fm = new FM();
    DropTarget dt = new DropTarget(c, ops, dtl, false, fm);
    assertSame(c, dt.getComponent());
    assertSame(dt, c.getDropTarget());
    assertEquals(ops, dt.getDefaultActions());
    assertFalse(dt.isActive());
    assertSame(fm, dt.getFlavorMap());
    try {
        dt.removeDropTargetListener(new DTL());
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    }
    dt.removeDropTargetListener(dtl);
}
项目:consulo    文件:FileCopyPasteUtil.java   
public static DataFlavor createDataFlavor(@Nonnull final String mimeType, @Nullable final Class<?> klass, final boolean register) {
  try {
    final DataFlavor flavor =
            klass != null ? new DataFlavor(mimeType + ";class=" + klass.getName(), null, klass.getClassLoader()) : new DataFlavor(mimeType);

    if (register) {
      final FlavorMap map = SystemFlavorMap.getDefaultFlavorMap();
      if (map instanceof SystemFlavorMap) {
        ((SystemFlavorMap)map).addUnencodedNativeForFlavor(flavor, mimeType);
      }
    }

    return flavor;
  }
  catch (ClassNotFoundException e) {
    LOG.error(e);
    //noinspection ConstantConditions
    return null;
  }
}
项目:OpenJSharp    文件:DropTarget.java   
/**
 * Creates a new DropTarget given the <code>Component</code>
 * to associate itself with, an <code>int</code> representing
 * the default acceptable action(s) to
 * support, a <code>DropTargetListener</code>
 * to handle event processing, a <code>boolean</code> indicating
 * if the <code>DropTarget</code> is currently accepting drops, and
 * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The <code>Component</code> with which this <code>DropTarget</code> is associated
 * @param ops       The default acceptable actions for this <code>DropTarget</code>
 * @param dtl       The <code>DropTargetListener</code> for this <code>DropTarget</code>
 * @param act       Is the <code>DropTarget</code> accepting drops.
 * @param fm        The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 *            returns true
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public DropTarget(Component c, int ops, DropTargetListener dtl,
                  boolean act, FlavorMap fm)
    throws HeadlessException
{
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    component = c;

    setDefaultActions(ops);

    if (dtl != null) try {
        addDropTargetListener(dtl);
    } catch (TooManyListenersException tmle) {
        // do nothing!
    }

    if (c != null) {
        c.setDropTarget(this);
        setActive(act);
    }

    if (fm != null) {
        flavorMap = fm;
    } else {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }
}
项目:OpenJSharp    文件:DragSource.java   
/**
 * Start a drag, given the <code>DragGestureEvent</code>
 * that initiated the drag, the initial
 * <code>Cursor</code> to use,
 * the <code>Image</code> to drag,
 * the offset of the <code>Image</code> origin
 * from the hotspot of the <code>Cursor</code> at
 * the instant of the trigger,
 * the <code>Transferable</code> subject data
 * of the drag, the <code>DragSourceListener</code>,
 * and the <code>FlavorMap</code>.
 * <P>
 * @param trigger        the <code>DragGestureEvent</code> that initiated the drag
 * @param dragCursor     the initial {@code Cursor} for this drag operation
 *                       or {@code null} for the default cursor handling;
 *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
 *                       for more details on the cursor handling mechanism during drag and drop
 * @param dragImage      the image to drag or {@code null}
 * @param imageOffset    the offset of the <code>Image</code> origin from the hotspot
 *                       of the <code>Cursor</code> at the instant of the trigger
 * @param transferable   the subject data of the drag
 * @param dsl            the <code>DragSourceListener</code>
 * @param flavorMap      the <code>FlavorMap</code> to use, or <code>null</code>
 * <P>
 * @throws java.awt.dnd.InvalidDnDOperationException
 *    if the Drag and Drop
 *    system is unable to initiate a drag operation, or if the user
 *    attempts to start a drag while an existing drag operation
 *    is still executing
 */

public void startDrag(DragGestureEvent   trigger,
                      Cursor             dragCursor,
                      Image              dragImage,
                      Point              imageOffset,
                      Transferable       transferable,
                      DragSourceListener dsl,
                      FlavorMap          flavorMap) throws InvalidDnDOperationException {

    SunDragSourceContextPeer.setDragDropInProgress(true);

    try {
        if (flavorMap != null) this.flavorMap = flavorMap;

        DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);

        DragSourceContext     dsc = createDragSourceContext(dscp,
                                                            trigger,
                                                            dragCursor,
                                                            dragImage,
                                                            imageOffset,
                                                            transferable,
                                                            dsl
                                                            );

        if (dsc == null) {
            throw new InvalidDnDOperationException();
        }

        dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
    } catch (RuntimeException e) {
        SunDragSourceContextPeer.setDragDropInProgress(false);
        throw e;
    }
}
项目:OpenJSharp    文件:DragSource.java   
/**
 * Deserializes this <code>DragSource</code>. This method first performs
 * default deserialization. Next, this object's <code>FlavorMap</code> is
 * deserialized by using the next object in the stream.
 * If the resulting <code>FlavorMap</code> is <code>null</code>, this
 * object's <code>FlavorMap</code> is set to the default FlavorMap for
 * this thread's <code>ClassLoader</code>.
 * Next, this object's listeners are deserialized by reading a
 * <code>null</code>-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is
 * deserialized using the corresponding value object and added to this
 * <code>DragSource</code>.
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceMotionListenerK</code>, a
 * <code>DragSourceMotionListener</code> is deserialized using the
 * corresponding value object and added to this <code>DragSource</code>.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
项目:jdk8u-jdk    文件:DropTarget.java   
/**
 * Creates a new DropTarget given the <code>Component</code>
 * to associate itself with, an <code>int</code> representing
 * the default acceptable action(s) to
 * support, a <code>DropTargetListener</code>
 * to handle event processing, a <code>boolean</code> indicating
 * if the <code>DropTarget</code> is currently accepting drops, and
 * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The <code>Component</code> with which this <code>DropTarget</code> is associated
 * @param ops       The default acceptable actions for this <code>DropTarget</code>
 * @param dtl       The <code>DropTargetListener</code> for this <code>DropTarget</code>
 * @param act       Is the <code>DropTarget</code> accepting drops.
 * @param fm        The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 *            returns true
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public DropTarget(Component c, int ops, DropTargetListener dtl,
                  boolean act, FlavorMap fm)
    throws HeadlessException
{
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    component = c;

    setDefaultActions(ops);

    if (dtl != null) try {
        addDropTargetListener(dtl);
    } catch (TooManyListenersException tmle) {
        // do nothing!
    }

    if (c != null) {
        c.setDropTarget(this);
        setActive(act);
    }

    if (fm != null) {
        flavorMap = fm;
    } else {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }
}
项目:jdk8u-jdk    文件:DragSource.java   
/**
 * Start a drag, given the <code>DragGestureEvent</code>
 * that initiated the drag, the initial
 * <code>Cursor</code> to use,
 * the <code>Image</code> to drag,
 * the offset of the <code>Image</code> origin
 * from the hotspot of the <code>Cursor</code> at
 * the instant of the trigger,
 * the <code>Transferable</code> subject data
 * of the drag, the <code>DragSourceListener</code>,
 * and the <code>FlavorMap</code>.
 * <P>
 * @param trigger        the <code>DragGestureEvent</code> that initiated the drag
 * @param dragCursor     the initial {@code Cursor} for this drag operation
 *                       or {@code null} for the default cursor handling;
 *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
 *                       for more details on the cursor handling mechanism during drag and drop
 * @param dragImage      the image to drag or {@code null}
 * @param imageOffset    the offset of the <code>Image</code> origin from the hotspot
 *                       of the <code>Cursor</code> at the instant of the trigger
 * @param transferable   the subject data of the drag
 * @param dsl            the <code>DragSourceListener</code>
 * @param flavorMap      the <code>FlavorMap</code> to use, or <code>null</code>
 * <P>
 * @throws java.awt.dnd.InvalidDnDOperationException
 *    if the Drag and Drop
 *    system is unable to initiate a drag operation, or if the user
 *    attempts to start a drag while an existing drag operation
 *    is still executing
 */

public void startDrag(DragGestureEvent   trigger,
                      Cursor             dragCursor,
                      Image              dragImage,
                      Point              imageOffset,
                      Transferable       transferable,
                      DragSourceListener dsl,
                      FlavorMap          flavorMap) throws InvalidDnDOperationException {

    SunDragSourceContextPeer.setDragDropInProgress(true);

    try {
        if (flavorMap != null) this.flavorMap = flavorMap;

        DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);

        DragSourceContext     dsc = createDragSourceContext(dscp,
                                                            trigger,
                                                            dragCursor,
                                                            dragImage,
                                                            imageOffset,
                                                            transferable,
                                                            dsl
                                                            );

        if (dsc == null) {
            throw new InvalidDnDOperationException();
        }

        dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
    } catch (RuntimeException e) {
        SunDragSourceContextPeer.setDragDropInProgress(false);
        throw e;
    }
}
项目:jdk8u-jdk    文件:DragSource.java   
/**
 * Deserializes this <code>DragSource</code>. This method first performs
 * default deserialization. Next, this object's <code>FlavorMap</code> is
 * deserialized by using the next object in the stream.
 * If the resulting <code>FlavorMap</code> is <code>null</code>, this
 * object's <code>FlavorMap</code> is set to the default FlavorMap for
 * this thread's <code>ClassLoader</code>.
 * Next, this object's listeners are deserialized by reading a
 * <code>null</code>-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is
 * deserialized using the corresponding value object and added to this
 * <code>DragSource</code>.
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceMotionListenerK</code>, a
 * <code>DragSourceMotionListener</code> is deserialized using the
 * corresponding value object and added to this <code>DragSource</code>.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
项目:openjdk-jdk10    文件:DropTarget.java   
/**
 * Creates a new DropTarget given the {@code Component}
 * to associate itself with, an {@code int} representing
 * the default acceptable action(s) to
 * support, a {@code DropTargetListener}
 * to handle event processing, a {@code boolean} indicating
 * if the {@code DropTarget} is currently accepting drops, and
 * a {@code FlavorMap} to use (or null for the default {@code FlavorMap}).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The {@code Component} with which this {@code DropTarget} is associated
 * @param ops       The default acceptable actions for this {@code DropTarget}
 * @param dtl       The {@code DropTargetListener} for this {@code DropTarget}
 * @param act       Is the {@code DropTarget} accepting drops.
 * @param fm        The {@code FlavorMap} to use, or null for the default {@code FlavorMap}
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 *            returns true
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public DropTarget(Component c, int ops, DropTargetListener dtl,
                  boolean act, FlavorMap fm)
    throws HeadlessException
{
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    component = c;

    setDefaultActions(ops);

    if (dtl != null) try {
        addDropTargetListener(dtl);
    } catch (TooManyListenersException tmle) {
        // do nothing!
    }

    if (c != null) {
        c.setDropTarget(this);
        setActive(act);
    }

    if (fm != null) {
        flavorMap = fm;
    } else {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }
}
项目:openjdk-jdk10    文件:DragSource.java   
/**
 * Deserializes this {@code DragSource}. This method first performs
 * default deserialization. Next, this object's {@code FlavorMap} is
 * deserialized by using the next object in the stream.
 * If the resulting {@code FlavorMap} is {@code null}, this
 * object's {@code FlavorMap} is set to the default FlavorMap for
 * this thread's {@code ClassLoader}.
 * Next, this object's listeners are deserialized by reading a
 * {@code null}-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a {@code String} equal to
 * {@code dragSourceListenerK}, a {@code DragSourceListener} is
 * deserialized using the corresponding value object and added to this
 * {@code DragSource}.
 * <li>If a key object is a {@code String} equal to
 * {@code dragSourceMotionListenerK}, a
 * {@code DragSourceMotionListener} is deserialized using the
 * corresponding value object and added to this {@code DragSource}.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
项目:openjdk-jdk10    文件:DesktopDatatransferServiceImpl.java   
@Override
public FlavorMap getFlavorMap(Supplier<FlavorMap> supplier) {
    AppContext context = AppContext.getAppContext();
    FlavorMap fm = (FlavorMap) context.get(FLAVOR_MAP_KEY);
    if (fm == null) {
        fm = supplier.get();
        context.put(FLAVOR_MAP_KEY, fm);
    }
    return fm;
}
项目:openjdk-jdk10    文件:DataFlavorUtil.java   
@Override
public FlavorMap getFlavorMap(Supplier<FlavorMap> supplier) {
    FlavorMap map = flavorMap;
    if (map == null) {
        synchronized (this) {
            map = flavorMap;
            if (map == null) {
                flavorMap = map = supplier.get();
            }
        }
    }
    return map;
}
项目:openjdk9    文件:DropTarget.java   
/**
 * Creates a new DropTarget given the {@code Component}
 * to associate itself with, an {@code int} representing
 * the default acceptable action(s) to
 * support, a {@code DropTargetListener}
 * to handle event processing, a {@code boolean} indicating
 * if the {@code DropTarget} is currently accepting drops, and
 * a {@code FlavorMap} to use (or null for the default {@code FlavorMap}).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The {@code Component} with which this {@code DropTarget} is associated
 * @param ops       The default acceptable actions for this {@code DropTarget}
 * @param dtl       The {@code DropTargetListener} for this {@code DropTarget}
 * @param act       Is the {@code DropTarget} accepting drops.
 * @param fm        The {@code FlavorMap} to use, or null for the default {@code FlavorMap}
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 *            returns true
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public DropTarget(Component c, int ops, DropTargetListener dtl,
                  boolean act, FlavorMap fm)
    throws HeadlessException
{
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    component = c;

    setDefaultActions(ops);

    if (dtl != null) try {
        addDropTargetListener(dtl);
    } catch (TooManyListenersException tmle) {
        // do nothing!
    }

    if (c != null) {
        c.setDropTarget(this);
        setActive(act);
    }

    if (fm != null) {
        flavorMap = fm;
    } else {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }
}
项目:openjdk9    文件:DragSource.java   
/**
 * Deserializes this {@code DragSource}. This method first performs
 * default deserialization. Next, this object's {@code FlavorMap} is
 * deserialized by using the next object in the stream.
 * If the resulting {@code FlavorMap} is {@code null}, this
 * object's {@code FlavorMap} is set to the default FlavorMap for
 * this thread's {@code ClassLoader}.
 * Next, this object's listeners are deserialized by reading a
 * {@code null}-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a {@code String} equal to
 * {@code dragSourceListenerK}, a {@code DragSourceListener} is
 * deserialized using the corresponding value object and added to this
 * {@code DragSource}.
 * <li>If a key object is a {@code String} equal to
 * {@code dragSourceMotionListenerK}, a
 * {@code DragSourceMotionListener} is deserialized using the
 * corresponding value object and added to this {@code DragSource}.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
项目:openjdk9    文件:DesktopDatatransferServiceImpl.java   
@Override
public FlavorMap getFlavorMap(Supplier<FlavorMap> supplier) {
    AppContext context = AppContext.getAppContext();
    FlavorMap fm = (FlavorMap) context.get(FLAVOR_MAP_KEY);
    if (fm == null) {
        fm = supplier.get();
        context.put(FLAVOR_MAP_KEY, fm);
    }
    return fm;
}
项目:openjdk9    文件:DataFlavorUtil.java   
@Override
public FlavorMap getFlavorMap(Supplier<FlavorMap> supplier) {
    FlavorMap map = flavorMap;
    if (map == null) {
        synchronized (this) {
            map = flavorMap;
            if (map == null) {
                flavorMap = map = supplier.get();
            }
        }
    }
    return map;
}
项目:Java8CN    文件:DropTarget.java   
/**
 * Creates a new DropTarget given the <code>Component</code>
 * to associate itself with, an <code>int</code> representing
 * the default acceptable action(s) to
 * support, a <code>DropTargetListener</code>
 * to handle event processing, a <code>boolean</code> indicating
 * if the <code>DropTarget</code> is currently accepting drops, and
 * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The <code>Component</code> with which this <code>DropTarget</code> is associated
 * @param ops       The default acceptable actions for this <code>DropTarget</code>
 * @param dtl       The <code>DropTargetListener</code> for this <code>DropTarget</code>
 * @param act       Is the <code>DropTarget</code> accepting drops.
 * @param fm        The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 *            returns true
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public DropTarget(Component c, int ops, DropTargetListener dtl,
                  boolean act, FlavorMap fm)
    throws HeadlessException
{
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    component = c;

    setDefaultActions(ops);

    if (dtl != null) try {
        addDropTargetListener(dtl);
    } catch (TooManyListenersException tmle) {
        // do nothing!
    }

    if (c != null) {
        c.setDropTarget(this);
        setActive(act);
    }

    if (fm != null) {
        flavorMap = fm;
    } else {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }
}
项目:Java8CN    文件:DragSource.java   
/**
 * Start a drag, given the <code>DragGestureEvent</code>
 * that initiated the drag, the initial
 * <code>Cursor</code> to use,
 * the <code>Image</code> to drag,
 * the offset of the <code>Image</code> origin
 * from the hotspot of the <code>Cursor</code> at
 * the instant of the trigger,
 * the <code>Transferable</code> subject data
 * of the drag, the <code>DragSourceListener</code>,
 * and the <code>FlavorMap</code>.
 * <P>
 * @param trigger        the <code>DragGestureEvent</code> that initiated the drag
 * @param dragCursor     the initial {@code Cursor} for this drag operation
 *                       or {@code null} for the default cursor handling;
 *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
 *                       for more details on the cursor handling mechanism during drag and drop
 * @param dragImage      the image to drag or {@code null}
 * @param imageOffset    the offset of the <code>Image</code> origin from the hotspot
 *                       of the <code>Cursor</code> at the instant of the trigger
 * @param transferable   the subject data of the drag
 * @param dsl            the <code>DragSourceListener</code>
 * @param flavorMap      the <code>FlavorMap</code> to use, or <code>null</code>
 * <P>
 * @throws java.awt.dnd.InvalidDnDOperationException
 *    if the Drag and Drop
 *    system is unable to initiate a drag operation, or if the user
 *    attempts to start a drag while an existing drag operation
 *    is still executing
 */

public void startDrag(DragGestureEvent   trigger,
                      Cursor             dragCursor,
                      Image              dragImage,
                      Point              imageOffset,
                      Transferable       transferable,
                      DragSourceListener dsl,
                      FlavorMap          flavorMap) throws InvalidDnDOperationException {

    SunDragSourceContextPeer.setDragDropInProgress(true);

    try {
        if (flavorMap != null) this.flavorMap = flavorMap;

        DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);

        DragSourceContext     dsc = createDragSourceContext(dscp,
                                                            trigger,
                                                            dragCursor,
                                                            dragImage,
                                                            imageOffset,
                                                            transferable,
                                                            dsl
                                                            );

        if (dsc == null) {
            throw new InvalidDnDOperationException();
        }

        dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
    } catch (RuntimeException e) {
        SunDragSourceContextPeer.setDragDropInProgress(false);
        throw e;
    }
}
项目:Java8CN    文件:DragSource.java   
/**
 * Deserializes this <code>DragSource</code>. This method first performs
 * default deserialization. Next, this object's <code>FlavorMap</code> is
 * deserialized by using the next object in the stream.
 * If the resulting <code>FlavorMap</code> is <code>null</code>, this
 * object's <code>FlavorMap</code> is set to the default FlavorMap for
 * this thread's <code>ClassLoader</code>.
 * Next, this object's listeners are deserialized by reading a
 * <code>null</code>-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is
 * deserialized using the corresponding value object and added to this
 * <code>DragSource</code>.
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceMotionListenerK</code>, a
 * <code>DragSourceMotionListener</code> is deserialized using the
 * corresponding value object and added to this <code>DragSource</code>.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
项目:jdk8u_jdk    文件:DropTarget.java   
/**
 * Creates a new DropTarget given the <code>Component</code>
 * to associate itself with, an <code>int</code> representing
 * the default acceptable action(s) to
 * support, a <code>DropTargetListener</code>
 * to handle event processing, a <code>boolean</code> indicating
 * if the <code>DropTarget</code> is currently accepting drops, and
 * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The <code>Component</code> with which this <code>DropTarget</code> is associated
 * @param ops       The default acceptable actions for this <code>DropTarget</code>
 * @param dtl       The <code>DropTargetListener</code> for this <code>DropTarget</code>
 * @param act       Is the <code>DropTarget</code> accepting drops.
 * @param fm        The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 *            returns true
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public DropTarget(Component c, int ops, DropTargetListener dtl,
                  boolean act, FlavorMap fm)
    throws HeadlessException
{
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    component = c;

    setDefaultActions(ops);

    if (dtl != null) try {
        addDropTargetListener(dtl);
    } catch (TooManyListenersException tmle) {
        // do nothing!
    }

    if (c != null) {
        c.setDropTarget(this);
        setActive(act);
    }

    if (fm != null) {
        flavorMap = fm;
    } else {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }
}
项目:jdk8u_jdk    文件:DragSource.java   
/**
 * Start a drag, given the <code>DragGestureEvent</code>
 * that initiated the drag, the initial
 * <code>Cursor</code> to use,
 * the <code>Image</code> to drag,
 * the offset of the <code>Image</code> origin
 * from the hotspot of the <code>Cursor</code> at
 * the instant of the trigger,
 * the <code>Transferable</code> subject data
 * of the drag, the <code>DragSourceListener</code>,
 * and the <code>FlavorMap</code>.
 * <P>
 * @param trigger        the <code>DragGestureEvent</code> that initiated the drag
 * @param dragCursor     the initial {@code Cursor} for this drag operation
 *                       or {@code null} for the default cursor handling;
 *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
 *                       for more details on the cursor handling mechanism during drag and drop
 * @param dragImage      the image to drag or {@code null}
 * @param imageOffset    the offset of the <code>Image</code> origin from the hotspot
 *                       of the <code>Cursor</code> at the instant of the trigger
 * @param transferable   the subject data of the drag
 * @param dsl            the <code>DragSourceListener</code>
 * @param flavorMap      the <code>FlavorMap</code> to use, or <code>null</code>
 * <P>
 * @throws java.awt.dnd.InvalidDnDOperationException
 *    if the Drag and Drop
 *    system is unable to initiate a drag operation, or if the user
 *    attempts to start a drag while an existing drag operation
 *    is still executing
 */

public void startDrag(DragGestureEvent   trigger,
                      Cursor             dragCursor,
                      Image              dragImage,
                      Point              imageOffset,
                      Transferable       transferable,
                      DragSourceListener dsl,
                      FlavorMap          flavorMap) throws InvalidDnDOperationException {

    SunDragSourceContextPeer.setDragDropInProgress(true);

    try {
        if (flavorMap != null) this.flavorMap = flavorMap;

        DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);

        DragSourceContext     dsc = createDragSourceContext(dscp,
                                                            trigger,
                                                            dragCursor,
                                                            dragImage,
                                                            imageOffset,
                                                            transferable,
                                                            dsl
                                                            );

        if (dsc == null) {
            throw new InvalidDnDOperationException();
        }

        dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
    } catch (RuntimeException e) {
        SunDragSourceContextPeer.setDragDropInProgress(false);
        throw e;
    }
}
项目:jdk8u_jdk    文件:DragSource.java   
/**
 * Deserializes this <code>DragSource</code>. This method first performs
 * default deserialization. Next, this object's <code>FlavorMap</code> is
 * deserialized by using the next object in the stream.
 * If the resulting <code>FlavorMap</code> is <code>null</code>, this
 * object's <code>FlavorMap</code> is set to the default FlavorMap for
 * this thread's <code>ClassLoader</code>.
 * Next, this object's listeners are deserialized by reading a
 * <code>null</code>-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is
 * deserialized using the corresponding value object and added to this
 * <code>DragSource</code>.
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceMotionListenerK</code>, a
 * <code>DragSourceMotionListener</code> is deserialized using the
 * corresponding value object and added to this <code>DragSource</code>.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:DropTarget.java   
/**
 * Creates a new DropTarget given the <code>Component</code>
 * to associate itself with, an <code>int</code> representing
 * the default acceptable action(s) to
 * support, a <code>DropTargetListener</code>
 * to handle event processing, a <code>boolean</code> indicating
 * if the <code>DropTarget</code> is currently accepting drops, and
 * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
 * <P>
 * The Component will receive drops only if it is enabled.
 * @param c         The <code>Component</code> with which this <code>DropTarget</code> is associated
 * @param ops       The default acceptable actions for this <code>DropTarget</code>
 * @param dtl       The <code>DropTargetListener</code> for this <code>DropTarget</code>
 * @param act       Is the <code>DropTarget</code> accepting drops.
 * @param fm        The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 *            returns true
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public DropTarget(Component c, int ops, DropTargetListener dtl,
                  boolean act, FlavorMap fm)
    throws HeadlessException
{
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    component = c;

    setDefaultActions(ops);

    if (dtl != null) try {
        addDropTargetListener(dtl);
    } catch (TooManyListenersException tmle) {
        // do nothing!
    }

    if (c != null) {
        c.setDropTarget(this);
        setActive(act);
    }

    if (fm != null) {
        flavorMap = fm;
    } else {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:DragSource.java   
/**
 * Start a drag, given the <code>DragGestureEvent</code>
 * that initiated the drag, the initial
 * <code>Cursor</code> to use,
 * the <code>Image</code> to drag,
 * the offset of the <code>Image</code> origin
 * from the hotspot of the <code>Cursor</code> at
 * the instant of the trigger,
 * the <code>Transferable</code> subject data
 * of the drag, the <code>DragSourceListener</code>,
 * and the <code>FlavorMap</code>.
 * <P>
 * @param trigger        the <code>DragGestureEvent</code> that initiated the drag
 * @param dragCursor     the initial {@code Cursor} for this drag operation
 *                       or {@code null} for the default cursor handling;
 *                       see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
 *                       for more details on the cursor handling mechanism during drag and drop
 * @param dragImage      the image to drag or {@code null}
 * @param imageOffset    the offset of the <code>Image</code> origin from the hotspot
 *                       of the <code>Cursor</code> at the instant of the trigger
 * @param transferable   the subject data of the drag
 * @param dsl            the <code>DragSourceListener</code>
 * @param flavorMap      the <code>FlavorMap</code> to use, or <code>null</code>
 * <P>
 * @throws java.awt.dnd.InvalidDnDOperationException
 *    if the Drag and Drop
 *    system is unable to initiate a drag operation, or if the user
 *    attempts to start a drag while an existing drag operation
 *    is still executing
 */

public void startDrag(DragGestureEvent   trigger,
                      Cursor             dragCursor,
                      Image              dragImage,
                      Point              imageOffset,
                      Transferable       transferable,
                      DragSourceListener dsl,
                      FlavorMap          flavorMap) throws InvalidDnDOperationException {

    SunDragSourceContextPeer.setDragDropInProgress(true);

    try {
        if (flavorMap != null) this.flavorMap = flavorMap;

        DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);

        DragSourceContext     dsc = createDragSourceContext(dscp,
                                                            trigger,
                                                            dragCursor,
                                                            dragImage,
                                                            imageOffset,
                                                            transferable,
                                                            dsl
                                                            );

        if (dsc == null) {
            throw new InvalidDnDOperationException();
        }

        dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
    } catch (RuntimeException e) {
        SunDragSourceContextPeer.setDragDropInProgress(false);
        throw e;
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:DragSource.java   
/**
 * Deserializes this <code>DragSource</code>. This method first performs
 * default deserialization. Next, this object's <code>FlavorMap</code> is
 * deserialized by using the next object in the stream.
 * If the resulting <code>FlavorMap</code> is <code>null</code>, this
 * object's <code>FlavorMap</code> is set to the default FlavorMap for
 * this thread's <code>ClassLoader</code>.
 * Next, this object's listeners are deserialized by reading a
 * <code>null</code>-terminated sequence of 0 or more key/value pairs
 * from the stream:
 * <ul>
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is
 * deserialized using the corresponding value object and added to this
 * <code>DragSource</code>.
 * <li>If a key object is a <code>String</code> equal to
 * <code>dragSourceMotionListenerK</code>, a
 * <code>DragSourceMotionListener</code> is deserialized using the
 * corresponding value object and added to this <code>DragSource</code>.
 * <li>Otherwise, the key/value pair is skipped.
 * </ul>
 *
 * @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
 * @since 1.4
 */
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException {
    s.defaultReadObject();

    // 'flavorMap' was written explicitly
    flavorMap = (FlavorMap)s.readObject();

    // Implementation assumes 'flavorMap' is never null.
    if (flavorMap == null) {
        flavorMap = SystemFlavorMap.getDefaultFlavorMap();
    }

    Object keyOrNull;
    while (null != (keyOrNull = s.readObject())) {
        String key = ((String)keyOrNull).intern();

        if (dragSourceListenerK == key) {
            addDragSourceListener((DragSourceListener)(s.readObject()));
        } else if (dragSourceMotionListenerK == key) {
            addDragSourceMotionListener(
                (DragSourceMotionListener)(s.readObject()));
        } else {
            // skip value for unrecognized key
            s.readObject();
        }
    }
}
项目:j2se_for_android    文件:DragSource.java   
public void startDrag(DragGestureEvent   trigger,
                      Cursor             dragCursor,
                      Image              dragImage,
                      Point              imageOffset,
                      Transferable       transferable,
                      DragSourceListener dsl,
                      FlavorMap          flavorMap) throws InvalidDnDOperationException {
}
项目:VarJ    文件:DragSource.java   
/**
 * Start a drag, given the <code>DragGestureEvent</code> 
 * that initiated the drag, the initial 
 * <code>Cursor</code> to use,
 * the <code>Image</code> to drag, 
 * the offset of the <code>Image</code> origin 
 * from the hotspot of the <code>Cursor</code> at 
 * the instant of the trigger,
 * the <code>Transferable</code> subject data 
 * of the drag, the <code>DragSourceListener</code>, 
 * and the <code>FlavorMap</code>. 
 * <P>
 * @param trigger        the <code>DragGestureEvent</code> that initiated the drag
 * @param dragCursor     the initial <code>Cursor</code> or <code>null</code> for defaults
 * @param dragImage      the image to drag or null,
 * @param imageOffset    the offset of the <code>Image</code> origin from the hotspot
 *               of the <code>Cursor</code> at the instant of the trigger
 * @param transferable   the subject data of the drag
 * @param dsl        the <code>DragSourceListener</code>
 * @param flavorMap      the <code>FlavorMap</code> to use, or <code>null</code>
 * <P>
 * @throws <code>java.awt.dnd.InvalidDnDOperationException</code> 
 *    if the Drag and Drop
 *    system is unable to initiate a drag operation, or if the user
 *    attempts to start a drag while an existing drag operation 
 *    is still executing
 */

public void startDrag(DragGestureEvent   trigger,
 Cursor      dragCursor,
 Image           dragImage,
 Point           imageOffset,
 Transferable        transferable,
 DragSourceListener dsl,
 FlavorMap       flavorMap) throws InvalidDnDOperationException {

    SunDragSourceContextPeer.setDragDropInProgress(true);

    try {
        if (flavorMap != null) this.flavorMap = flavorMap;

        DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);

        DragSourceContext     dsc = createDragSourceContext(dscp,
                                                            trigger,
                                                            dragCursor,
                                                            dragImage,
                                                            imageOffset,
                                                            transferable,
                                                            dsl
                                                            );

        if (dsc == null) {
            throw new InvalidDnDOperationException();
        }

        dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
    } catch (RuntimeException e) {
        SunDragSourceContextPeer.setDragDropInProgress(false);
        throw e;
    }
}