Beispiel #1
0
        /// <summary>
        /// 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> </summary>
        /// <param name="trigger">        the <code>DragGestureEvent</code> that initiated the drag </param>
        /// <param name="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>
        /// <param name="dragImage">      the image to drag or {@code null} </param>
        /// <param name="imageOffset">    the offset of the <code>Image</code> origin from the hotspot
        ///                       of the <code>Cursor</code> at the instant of the trigger </param>
        /// <param name="transferable">   the subject data of the drag </param>
        /// <param name="dsl">            the <code>DragSourceListener</code> </param>
        /// <param name="flavorMap">      the <code>FlavorMap</code> to use, or <code>null</code>
        /// <P> </param>
        /// <exception cref="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 </exception>

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void startDrag(DragGestureEvent trigger, java.awt.Cursor dragCursor, java.awt.Image dragImage, java.awt.Point imageOffset, java.awt.datatransfer.Transferable transferable, DragSourceListener dsl, java.awt.datatransfer.FlavorMap flavorMap) throws InvalidDnDOperationException
        public virtual void StartDrag(DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable transferable, DragSourceListener dsl, FlavorMap flavorMap)
        {
            SunDragSourceContextPeer.DragDropInProgress = true;

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

                DragSourceContextPeer dscp = Toolkit.DefaultToolkit.CreateDragSourceContextPeer(trigger);

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

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

                dscp.StartDrag(dsc, dsc.Cursor, dragImage, imageOffset);                 // may throw
            }
            catch (RuntimeException e)
            {
                SunDragSourceContextPeer.DragDropInProgress = false;
                throw e;
            }
        }
        /// <summary>
        /// Called from <code>DragSource</code>, this constructor creates a new
        /// <code>DragSourceContext</code> given the
        /// <code>DragSourceContextPeer</code> for this Drag, the
        /// <code>DragGestureEvent</code> that triggered the Drag, the initial
        /// <code>Cursor</code> to use for the Drag, an (optional)
        /// <code>Image</code> to display while the Drag is taking place, the offset
        /// of the <code>Image</code> origin from the hotspot at the instant of the
        /// triggering event, the <code>Transferable</code> subject data, and the
        /// <code>DragSourceListener</code> to use during the Drag and Drop
        /// operation.
        /// <br>
        /// If <code>DragSourceContextPeer</code> is <code>null</code>
        /// <code>NullPointerException</code> is thrown.
        /// <br>
        /// If <code>DragGestureEvent</code> is <code>null</code>
        /// <code>NullPointerException</code> is thrown.
        /// <br>
        /// If <code>Cursor</code> is <code>null</code> no exception is thrown and
        /// the default drag cursor behavior is activated for this drag operation.
        /// <br>
        /// If <code>Image</code> is <code>null</code> no exception is thrown.
        /// <br>
        /// If <code>Image</code> is not <code>null</code> and the offset is
        /// <code>null</code> <code>NullPointerException</code> is thrown.
        /// <br>
        /// If <code>Transferable</code> is <code>null</code>
        /// <code>NullPointerException</code> is thrown.
        /// <br>
        /// If <code>DragSourceListener</code> is <code>null</code> no exception
        /// is thrown.
        /// </summary>
        /// <param name="dscp">       the <code>DragSourceContextPeer</code> for this drag </param>
        /// <param name="trigger">    the triggering event </param>
        /// <param name="dragCursor">     the initial {@code Cursor} for this drag operation
        ///                       or {@code null} for the default cursor handling;
        ///                       see <a href="DragSourceContext.html#defaultCursor">class level documentation</a>
        ///                       for more details on the cursor handling mechanism during drag and drop </param>
        /// <param name="dragImage">  the <code>Image</code> to drag (or <code>null</code>) </param>
        /// <param name="offset">     the offset of the image origin from the hotspot at the
        ///                   instant of the triggering event </param>
        /// <param name="t">          the <code>Transferable</code> </param>
        /// <param name="dsl">        the <code>DragSourceListener</code>
        /// </param>
        /// <exception cref="IllegalArgumentException"> if the <code>Component</code> associated
        ///         with the trigger event is <code>null</code>. </exception>
        /// <exception cref="IllegalArgumentException"> if the <code>DragSource</code> for the
        ///         trigger event is <code>null</code>. </exception>
        /// <exception cref="IllegalArgumentException"> if the drag action for the
        ///         trigger event is <code>DnDConstants.ACTION_NONE</code>. </exception>
        /// <exception cref="IllegalArgumentException"> if the source actions for the
        ///         <code>DragGestureRecognizer</code> associated with the trigger
        ///         event are equal to <code>DnDConstants.ACTION_NONE</code>. </exception>
        /// <exception cref="NullPointerException"> if dscp, trigger, or t are null, or
        ///         if dragImage is non-null and offset is null </exception>
        public DragSourceContext(DragSourceContextPeer dscp, DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point offset, Transferable t, DragSourceListener dsl)
        {
            if (dscp == null)
            {
                throw new NullPointerException("DragSourceContextPeer");
            }

            if (trigger == null)
            {
                throw new NullPointerException("Trigger");
            }

            if (trigger.DragSource == null)
            {
                throw new IllegalArgumentException("DragSource");
            }

            if (trigger.Component == null)
            {
                throw new IllegalArgumentException("Component");
            }

            if (trigger.SourceAsDragGestureRecognizer.SourceActions == DnDConstants.ACTION_NONE)
            {
                throw new IllegalArgumentException("source actions");
            }

            if (trigger.DragAction == DnDConstants.ACTION_NONE)
            {
                throw new IllegalArgumentException("no drag action");
            }

            if (t == null)
            {
                throw new NullPointerException("Transferable");
            }

            if (dragImage != null && offset == null)
            {
                throw new NullPointerException("offset");
            }

            Peer = dscp;
            this.Trigger_Renamed  = trigger;
            Cursor_Renamed        = dragCursor;
            Transferable_Renamed  = t;
            Listener              = dsl;
            SourceActions_Renamed = trigger.SourceAsDragGestureRecognizer.SourceActions;

            UseCustomCursor = (dragCursor != null);

            UpdateCurrentCursor(trigger.DragAction, SourceActions, DEFAULT);
        }
        /// <summary>
        /// Deserializes this <code>DragSourceContext</code>. This method first
        /// performs default deserialization for all non-<code>transient</code>
        /// fields. This object's <code>Transferable</code> and
        /// <code>DragSourceListener</code> are then deserialized as well by using
        /// the next two objects in the stream. If the resulting
        /// <code>Transferable</code> is <code>null</code>, this object's
        /// <code>Transferable</code> is set to a dummy <code>Transferable</code>
        /// which supports no <code>DataFlavor</code>s.
        ///
        /// @since 1.4
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream s) throws ClassNotFoundException, java.io.IOException
        private void ReadObject(ObjectInputStream s)
        {
            ObjectInputStream.GetField f = s.ReadFields();

            DragGestureEvent newTrigger = (DragGestureEvent)f.Get("trigger", null);

            if (newTrigger == null)
            {
                throw new InvalidObjectException("Null trigger");
            }
            if (newTrigger.DragSource == null)
            {
                throw new InvalidObjectException("Null DragSource");
            }
            if (newTrigger.Component == null)
            {
                throw new InvalidObjectException("Null trigger component");
            }

            int newSourceActions = f.Get("sourceActions", 0) & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK);

            if (newSourceActions == DnDConstants.ACTION_NONE)
            {
                throw new InvalidObjectException("Invalid source actions");
            }
            int triggerActions = newTrigger.DragAction;

            if (triggerActions != DnDConstants.ACTION_COPY && triggerActions != DnDConstants.ACTION_MOVE && triggerActions != DnDConstants.ACTION_LINK)
            {
                throw new InvalidObjectException("No drag action");
            }
            Trigger_Renamed = newTrigger;

            Cursor_Renamed        = (Cursor)f.Get("cursor", null);
            UseCustomCursor       = f.Get("useCustomCursor", false);
            SourceActions_Renamed = newSourceActions;

            Transferable_Renamed = (Transferable)s.ReadObject();
            Listener             = (DragSourceListener)s.ReadObject();

            // Implementation assumes 'transferable' is never null.
            if (Transferable_Renamed == null)
            {
                if (EmptyTransferable == null)
                {
                    EmptyTransferable = new TransferableAnonymousInnerClassHelper(this);
                }
                Transferable_Renamed = EmptyTransferable;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Creates the {@code DragSourceContext} to handle the current drag
        /// operation.
        /// <para>
        /// To incorporate a new <code>DragSourceContext</code>
        /// subclass, subclass <code>DragSource</code> and
        /// override this method.
        /// </para>
        /// <para>
        /// If <code>dragImage</code> is <code>null</code>, no image is used
        /// to represent the drag over feedback for this drag operation, but
        /// <code>NullPointerException</code> is not thrown.
        /// </para>
        /// <para>
        /// If <code>dsl</code> is <code>null</code>, no drag source listener
        /// is registered with the created <code>DragSourceContext</code>,
        /// but <code>NullPointerException</code> is not thrown.
        ///
        /// </para>
        /// </summary>
        /// <param name="dscp">          The <code>DragSourceContextPeer</code> for this drag </param>
        /// <param name="dgl">           The <code>DragGestureEvent</code> that triggered the
        ///                      drag </param>
        /// <param name="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> class
        ///                       for more details on the cursor handling mechanism during drag and drop </param>
        /// <param name="dragImage">     The <code>Image</code> to drag or <code>null</code> </param>
        /// <param name="imageOffset">   The offset of the <code>Image</code> origin from the
        ///                      hotspot of the cursor at the instant of the trigger </param>
        /// <param name="t">             The subject data of the drag </param>
        /// <param name="dsl">           The <code>DragSourceListener</code>
        /// </param>
        /// <returns> the <code>DragSourceContext</code>
        /// </returns>
        /// <exception cref="NullPointerException"> if <code>dscp</code> is <code>null</code> </exception>
        /// <exception cref="NullPointerException"> if <code>dgl</code> is <code>null</code> </exception>
        /// <exception cref="NullPointerException"> if <code>dragImage</code> is not
        ///    <code>null</code> and <code>imageOffset</code> is <code>null</code> </exception>
        /// <exception cref="NullPointerException"> if <code>t</code> is <code>null</code> </exception>
        /// <exception cref="IllegalArgumentException"> if the <code>Component</code>
        ///         associated with the trigger event is <code>null</code>. </exception>
        /// <exception cref="IllegalArgumentException"> if the <code>DragSource</code> for the
        ///         trigger event is <code>null</code>. </exception>
        /// <exception cref="IllegalArgumentException"> if the drag action for the
        ///         trigger event is <code>DnDConstants.ACTION_NONE</code>. </exception>
        /// <exception cref="IllegalArgumentException"> if the source actions for the
        ///         <code>DragGestureRecognizer</code> associated with the trigger
        ///         event are equal to <code>DnDConstants.ACTION_NONE</code>. </exception>

        protected internal virtual DragSourceContext CreateDragSourceContext(DragSourceContextPeer dscp, DragGestureEvent dgl, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable t, DragSourceListener dsl)
        {
            return(new DragSourceContext(dscp, dgl, dragCursor, dragImage, imageOffset, t, dsl));
        }
Beispiel #5
0
        /// <summary>
        /// Start a drag, given the <code>DragGestureEvent</code>
        /// that initiated the drag, the initial
        /// <code>Cursor</code> to
        /// use,
        /// the <code>Transferable</code> subject data
        /// of the drag, and the <code>DragSourceListener</code>.
        /// <P> </summary>
        /// <param name="trigger">           the <code>DragGestureEvent</code> that initiated the drag </param>
        /// <param name="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> class
        ///                       for more details on the cursor handling mechanism during drag and drop </param>
        /// <param name="transferable">      the subject data of the drag </param>
        /// <param name="dsl">               the <code>DragSourceListener</code>
        /// <P> </param>
        /// <exception cref="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 </exception>

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void startDrag(DragGestureEvent trigger, java.awt.Cursor dragCursor, java.awt.datatransfer.Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationException
        public virtual void StartDrag(DragGestureEvent trigger, Cursor dragCursor, Transferable transferable, DragSourceListener dsl)
        {
            StartDrag(trigger, dragCursor, null, null, transferable, dsl, null);
        }
Beispiel #6
0
        /// <summary>
        /// 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 subject data of the drag, and
        /// the <code>DragSourceListener</code>.
        /// <P> </summary>
        /// <param name="trigger">           the <code>DragGestureEvent</code> that initiated the drag </param>
        /// <param name="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>
        /// <param name="dragImage">         the <code>Image</code> to drag or <code>null</code> </param>
        /// <param name="dragOffset">        the offset of the <code>Image</code> origin from the hotspot
        ///                          of the <code>Cursor</code> at the instant of the trigger </param>
        /// <param name="transferable">      the subject data of the drag </param>
        /// <param name="dsl">               the <code>DragSourceListener</code>
        /// <P> </param>
        /// <exception cref="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 </exception>

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void startDrag(DragGestureEvent trigger, java.awt.Cursor dragCursor, java.awt.Image dragImage, java.awt.Point dragOffset, java.awt.datatransfer.Transferable transferable, DragSourceListener dsl) throws InvalidDnDOperationException
        public virtual void StartDrag(DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point dragOffset, Transferable transferable, DragSourceListener dsl)
        {
            StartDrag(trigger, dragCursor, dragImage, dragOffset, transferable, dsl, null);
        }