/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The <code>DropTarget</code> is associated
* with a <code>Component</code> when that <code>Component</code>
* wishes
* to accept drops during Drag and Drop operations.
* <P>
* Each
* <code>DropTarget</code> is associated with a <code>FlavorMap</code>.
* The default <code>FlavorMap</code> hereafter designates the
* <code>FlavorMap</code> returned by <code>SystemFlavorMap.getDefaultFlavorMap()</code>.
*
* @since 1.2
*/
/**
* 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
*/
throws HeadlessException
{
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
component = c;
} catch (TooManyListenersException tmle) {
// do nothing!
}
if (c != null) {
c.setDropTarget(this);
}
} else {
}
}
/**
* Creates a <code>DropTarget</code> 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, and a <code>boolean</code> indicating
* if the <code>DropTarget</code> is currently accepting drops.
* <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.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see java.awt.GraphicsEnvironment#isHeadless
*/
boolean act)
throws HeadlessException
{
}
/**
* Creates a <code>DropTarget</code>.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see java.awt.GraphicsEnvironment#isHeadless
*/
}
/**
* Creates a <code>DropTarget</code> given the <code>Component</code>
* to associate itself with, and the <code>DropTargetListener</code>
* to handle event processing.
* <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 dtl The <code>DropTargetListener</code> for this <code>DropTarget</code>
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see java.awt.GraphicsEnvironment#isHeadless
*/
throws HeadlessException
{
}
/**
* Creates a <code>DropTarget</code> given the <code>Component</code>
* to associate itself with, an <code>int</code> representing
* the default acceptable action(s) to support, and a
* <code>DropTargetListener</code> to handle event processing.
* <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>
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see java.awt.GraphicsEnvironment#isHeadless
*/
throws HeadlessException
{
}
/**
* Note: this interface is required to permit the safe association
* of a DropTarget with a Component in one of two ways, either:
* <code> component.setDropTarget(droptarget); </code>
* or <code> droptarget.setComponent(component); </code>
* <P>
* The Component will receive drops only if it is enabled.
* @param c The new <code>Component</code> this <code>DropTarget</code>
* is to be associated with.<P>
*/
return;
if (componentPeer != null) {
}
}
c.setDropTarget(this);
} catch (Exception e) { // undo the change
old.setDropTarget(this);
}
}
}
/**
* Gets the <code>Component</code> associated
* with this <code>DropTarget</code>.
* <P>
* @return the current <code>Component</code>
*/
return component;
}
/**
* Sets the default acceptable actions for this <code>DropTarget</code>
* <P>
* @param ops the default actions
* <P>
* @see java.awt.dnd.DnDConstants
*/
getDropTargetContext().setTargetActions(ops & (DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_REFERENCE));
}
/*
* Called by DropTargetContext.setTargetActions()
* with appropriate synchronization.
*/
}
/**
* Gets an <code>int</code> representing the
* current action(s) supported by this <code>DropTarget</code>.
* <P>
* @return the current default actions
*/
public int getDefaultActions() {
return actions;
}
/**
* Sets the DropTarget active if <code>true</code>,
* inactive if <code>false</code>.
* <P>
* @param isActive sets the <code>DropTarget</code> (in)active.
*/
}
if (!active) clearAutoscroll();
}
/**
* Reports whether or not
* this <code>DropTarget</code>
* is currently active (ready to accept drops).
* <P>
* @return <CODE>true</CODE> if active, <CODE>false</CODE> if not
*/
public boolean isActive() {
return active;
}
/**
* Adds a new <code>DropTargetListener</code> (UNICAST SOURCE).
* <P>
* @param dtl The new <code>DropTargetListener</code>
* <P>
* @throws <code>TooManyListenersException</code> if a
* <code>DropTargetListener</code> is already added to this
* <code>DropTarget</code>.
*/
public synchronized void addDropTargetListener(DropTargetListener dtl) throws TooManyListenersException {
if (dtListener == null)
dtListener = dtl;
else
throw new TooManyListenersException();
}
/**
* Removes the current <code>DropTargetListener</code> (UNICAST SOURCE).
* <P>
* @param dtl the DropTargetListener to deregister.
*/
dtListener = null;
else
throw new IllegalArgumentException("listener mismatch");
}
}
/**
* Calls <code>dragEnter</code> on the registered
* <code>DropTargetListener</code> and passes it
* the specified <code>DropTargetDragEvent</code>.
* Has no effect if this <code>DropTarget</code>
* is not active.
*
* @param dtde the <code>DropTargetDragEvent</code>
*
* @throws NullPointerException if this <code>DropTarget</code>
* is active and <code>dtde</code> is <code>null</code>
*
* @see #isActive
*/
if (!active) return;
if (dtListener != null) {
} else
}
/**
* Calls <code>dragOver</code> on the registered
* <code>DropTargetListener</code> and passes it
* the specified <code>DropTargetDragEvent</code>.
* Has no effect if this <code>DropTarget</code>
* is not active.
*
* @param dtde the <code>DropTargetDragEvent</code>
*
* @throws NullPointerException if this <code>DropTarget</code>
* is active and <code>dtde</code> is <code>null</code>
*
* @see #isActive
*/
if (!active) return;
}
/**
* Calls <code>dropActionChanged</code> on the registered
* <code>DropTargetListener</code> and passes it
* the specified <code>DropTargetDragEvent</code>.
* Has no effect if this <code>DropTarget</code>
* is not active.
*
* @param dtde the <code>DropTargetDragEvent</code>
*
* @throws NullPointerException if this <code>DropTarget</code>
* is active and <code>dtde</code> is <code>null</code>
*
* @see #isActive
*/
if (!active) return;
}
/**
* Calls <code>dragExit</code> on the registered
* <code>DropTargetListener</code> and passes it
* the specified <code>DropTargetEvent</code>.
* Has no effect if this <code>DropTarget</code>
* is not active.
* <p>
* This method itself does not throw any exception
* for null parameter but for exceptions thrown by
* the respective method of the listener.
*
* @param dte the <code>DropTargetEvent</code>
*
* @see #isActive
*/
if (!active) return;
}
/**
* Calls <code>drop</code> on the registered
* <code>DropTargetListener</code> and passes it
* the specified <code>DropTargetDropEvent</code>
* if this <code>DropTarget</code> is active.
*
* @param dtde the <code>DropTargetDropEvent</code>
*
* @throws NullPointerException if <code>dtde</code> is null
* and at least one of the following is true: this
* <code>DropTarget</code> is not active, or there is
* no a <code>DropTargetListener</code> registered.
*
* @see #isActive
*/
else { // we should'nt get here ...
dtde.rejectDrop();
}
}
/**
* Gets the <code>FlavorMap</code>
* associated with this <code>DropTarget</code>.
* If no <code>FlavorMap</code> has been set for this
* <code>DropTarget</code>, it is associated with the default
* <code>FlavorMap</code>.
* <P>
* @return the FlavorMap for this DropTarget
*/
/**
* Sets the <code>FlavorMap</code> associated
* with this <code>DropTarget</code>.
* <P>
* @param fm the new <code>FlavorMap</code>, or null to
* associate the default FlavorMap with this DropTarget.
*/
}
/**
* Notify the DropTarget that it has been associated with a Component
*
**********************************************************************
* This method is usually called from java.awt.Component.addNotify() of
* the Component associated with this DropTarget to notify the DropTarget
* that a ComponentPeer has been associated with that Component.
*
* Calling this method, other than to notify this DropTarget of the
* association of the ComponentPeer with the Component may result in
* a malfunction of the DnD system.
**********************************************************************
* <P>
* @param peer The Peer of the Component we are associated with!
*
*/
if (peer == componentPeer) return;
}
if (peer instanceof DropTargetPeer) {
nativePeer = peer;
} else {
nativePeer = null;
}
}
/**
* Notify the DropTarget that it has been disassociated from a Component
*
**********************************************************************
* This method is usually called from java.awt.Component.removeNotify() of
* the Component associated with this DropTarget to notify the DropTarget
* that a ComponentPeer has been disassociated with that Component.
*
* Calling this method, other than to notify this DropTarget of the
* disassociation of the ComponentPeer from the Component may result in
* a malfunction of the DnD system.
**********************************************************************
* <P>
* @param peer The Peer of the Component we are being disassociated from!
*/
if (nativePeer != null)
}
/**
* Gets the <code>DropTargetContext</code> associated
* with this <code>DropTarget</code>.
* <P>
* @return the <code>DropTargetContext</code> associated with this <code>DropTarget</code>.
*/
return dropTargetContext;
}
/**
* Creates the DropTargetContext associated with this DropTarget.
* Subclasses may override this method to instantiate their own
* DropTargetContext subclass.
*
* This call is typically *only* called by the platform's
* DropTargetContextPeer as a drag operation encounters this
* DropTarget. Accessing the Context while no Drag is current
* has undefined results.
*/
return new DropTargetContext(this);
}
/**
* Serializes this <code>DropTarget</code>. Performs default serialization,
* and then writes out this object's <code>DropTargetListener</code> if and
* only if it can be serialized. If not, <code>null</code> is written
* instead.
*
* @serialData The default serializable fields, in alphabetical order,
* followed by either a <code>DropTargetListener</code>
* instance, or <code>null</code>.
* @since 1.4
*/
s.defaultWriteObject();
? dtListener : null);
}
/**
* Deserializes this <code>DropTarget</code>. This method first performs
* default deserialization for all non-<code>transient</code> fields. An
* attempt is then made to deserialize this object's
* <code>DropTargetListener</code> as well. This is first attempted by
* deserializing the field <code>dtListener</code>, because, in releases
* prior to 1.4, a non-<code>transient</code> field of this name stored the
* <code>DropTargetListener</code>. If this fails, the next object in the
* stream is used instead.
*
* @since 1.4
*/
throws ClassNotFoundException, IOException
{
try {
} catch (IllegalArgumentException e) {
// Pre-1.4 support. 'dropTargetContext' was previoulsy transient
}
if (dropTargetContext == null) {
}
// Pre-1.4 support. 'dtListener' was previously non-transient
try {
} catch (IllegalArgumentException e) {
// 1.4-compatible byte stream. 'dtListener' was written explicitly
}
}
/*********************************************************************/
/**
* this protected nested class implements autoscrolling
*/
/**
* construct a DropTargetAutoScroller
* <P>
* @param c the <code>Component</code>
* @param p the <code>Point</code>
*/
super();
component = c;
try {
} catch (Exception e) {
// ignore
}
try {
} catch (Exception e) {
// ignore
}
timer.setCoalesce(true);
locn = p;
prev = p;
try {
} catch (Exception e) {
// ignore
}
}
/**
* update the geometry of the autoscroll region
*/
private void updateRegion() {
}
/**
* cause autoscroll to occur
* <P>
* @param newLocn the <code>Point</code>
*/
} else {
}
}
/**
* cause autoscrolling to stop
*/
/**
* cause autoscroll to occur
* <P>
* @param e the <code>ActionEvent</code>
*/
updateRegion();
}
/*
* fields
*/
}
/*********************************************************************/
/**
* create an embedded autoscroller
* <P>
* @param c the <code>Component</code>
* @param p the <code>Point</code>
*/
return new DropTargetAutoScroller(c, p);
}
/**
* initialize autoscrolling
* <P>
* @param p the <code>Point</code>
*/
}
/**
* update autoscrolling with current cursor locn
* <P>
* @param dragCursorLocn the <code>Point</code>
*/
}
/**
* clear autoscrolling
*/
protected void clearAutoscroll() {
if (autoScroller != null) {
autoScroller.stop();
autoScroller = null;
}
}
/**
* The DropTargetContext associated with this DropTarget.
*
* @serial
*/
/**
* The Component associated with this DropTarget.
*
* @serial
*/
/*
* That Component's Peer
*/
/*
* That Component's "native" Peer
*/
/**
* Default permissible actions supported by this DropTarget.
*
* @see #setDefaultActions
* @see #getDefaultActions
* @serial
*/
/**
* <code>true</code> if the DropTarget is accepting Drag & Drop operations.
*
* @serial
*/
boolean active = true;
/*
* the auto scrolling object
*/
/*
* The delegate
*/
/*
* The FlavorMap
*/
}