jdk/src/share/classes/java/awt/dnd/DropTargetContext.java
changeset 23588 b0269b21e313
parent 5506 202f599c92aa
equal deleted inserted replaced
23587:55ccc7b19f84 23588:b0269b21e313
    59     private static final long serialVersionUID = -634158968993743371L;
    59     private static final long serialVersionUID = -634158968993743371L;
    60 
    60 
    61     /**
    61     /**
    62      * Construct a <code>DropTargetContext</code>
    62      * Construct a <code>DropTargetContext</code>
    63      * given a specified <code>DropTarget</code>.
    63      * given a specified <code>DropTarget</code>.
    64      * <P>
    64      *
    65      * @param dt the DropTarget to associate with
    65      * @param dt the DropTarget to associate with
    66      */
    66      */
    67 
    67 
    68     DropTargetContext(DropTarget dt) {
    68     DropTargetContext(DropTarget dt) {
    69         super();
    69         super();
    72     }
    72     }
    73 
    73 
    74     /**
    74     /**
    75      * This method returns the <code>DropTarget</code> associated with this
    75      * This method returns the <code>DropTarget</code> associated with this
    76      * <code>DropTargetContext</code>.
    76      * <code>DropTargetContext</code>.
    77      * <P>
    77      *
    78      * @return the <code>DropTarget</code> associated with this <code>DropTargetContext</code>
    78      * @return the <code>DropTarget</code> associated with this <code>DropTargetContext</code>
    79      */
    79      */
    80 
    80 
    81     public DropTarget getDropTarget() { return dropTarget; }
    81     public DropTarget getDropTarget() { return dropTarget; }
    82 
    82 
    83     /**
    83     /**
    84      * This method returns the <code>Component</code> associated with
    84      * This method returns the <code>Component</code> associated with
    85      * this <code>DropTargetContext</code>.
    85      * this <code>DropTargetContext</code>.
    86      * <P>
    86      *
    87      * @return the Component associated with this Context
    87      * @return the Component associated with this Context
    88      */
    88      */
    89 
    89 
    90     public Component getComponent() { return dropTarget.getComponent(); }
    90     public Component getComponent() { return dropTarget.getComponent(); }
    91 
    91 
    92     /**
    92     /**
    93      * Called when associated with the <code>DropTargetContextPeer</code>.
    93      * Called when associated with the <code>DropTargetContextPeer</code>.
    94      * <P>
    94      *
    95      * @param dtcp the <code>DropTargetContextPeer</code>
    95      * @param dtcp the <code>DropTargetContextPeer</code>
    96      */
    96      */
    97 
    97 
    98     public void addNotify(DropTargetContextPeer dtcp) {
    98     public void addNotify(DropTargetContextPeer dtcp) {
    99         dropTargetContextPeer = dtcp;
    99         dropTargetContextPeer = dtcp;
   109     }
   109     }
   110 
   110 
   111     /**
   111     /**
   112      * This method sets the current actions acceptable to
   112      * This method sets the current actions acceptable to
   113      * this <code>DropTarget</code>.
   113      * this <code>DropTarget</code>.
   114      * <P>
   114      *
   115      * @param actions an <code>int</code> representing the supported action(s)
   115      * @param actions an <code>int</code> representing the supported action(s)
   116      */
   116      */
   117 
   117 
   118     protected void setTargetActions(int actions) {
   118     protected void setTargetActions(int actions) {
   119         DropTargetContextPeer peer = getDropTargetContextPeer();
   119         DropTargetContextPeer peer = getDropTargetContextPeer();
   128     }
   128     }
   129 
   129 
   130     /**
   130     /**
   131      * This method returns an <code>int</code> representing the
   131      * This method returns an <code>int</code> representing the
   132      * current actions this <code>DropTarget</code> will accept.
   132      * current actions this <code>DropTarget</code> will accept.
   133      * <P>
   133      *
   134      * @return the current actions acceptable to this <code>DropTarget</code>
   134      * @return the current actions acceptable to this <code>DropTarget</code>
   135      */
   135      */
   136 
   136 
   137     protected int getTargetActions() {
   137     protected int getTargetActions() {
   138         DropTargetContextPeer peer = getDropTargetContextPeer();
   138         DropTargetContextPeer peer = getDropTargetContextPeer();
   143     }
   143     }
   144 
   144 
   145     /**
   145     /**
   146      * This method signals that the drop is completed and
   146      * This method signals that the drop is completed and
   147      * if it was successful or not.
   147      * if it was successful or not.
   148      * <P>
   148      *
   149      * @param success true for success, false if not
   149      * @param success true for success, false if not
   150      * <P>
   150      *
   151      * @throws InvalidDnDOperationException if a drop is not outstanding/extant
   151      * @throws InvalidDnDOperationException if a drop is not outstanding/extant
   152      */
   152      */
   153 
   153 
   154     public void dropComplete(boolean success) throws InvalidDnDOperationException{
   154     public void dropComplete(boolean success) throws InvalidDnDOperationException{
   155         DropTargetContextPeer peer = getDropTargetContextPeer();
   155         DropTargetContextPeer peer = getDropTargetContextPeer();
   158         }
   158         }
   159     }
   159     }
   160 
   160 
   161     /**
   161     /**
   162      * accept the Drag.
   162      * accept the Drag.
   163      * <P>
   163      *
   164      * @param dragOperation the supported action(s)
   164      * @param dragOperation the supported action(s)
   165      */
   165      */
   166 
   166 
   167     protected void acceptDrag(int dragOperation) {
   167     protected void acceptDrag(int dragOperation) {
   168         DropTargetContextPeer peer = getDropTargetContextPeer();
   168         DropTargetContextPeer peer = getDropTargetContextPeer();
   184 
   184 
   185     /**
   185     /**
   186      * called to signal that the drop is acceptable
   186      * called to signal that the drop is acceptable
   187      * using the specified operation.
   187      * using the specified operation.
   188      * must be called during DropTargetListener.drop method invocation.
   188      * must be called during DropTargetListener.drop method invocation.
   189      * <P>
   189      *
   190      * @param dropOperation the supported action(s)
   190      * @param dropOperation the supported action(s)
   191      */
   191      */
   192 
   192 
   193     protected void acceptDrop(int dropOperation) {
   193     protected void acceptDrop(int dropOperation) {
   194         DropTargetContextPeer peer = getDropTargetContextPeer();
   194         DropTargetContextPeer peer = getDropTargetContextPeer();
   210     }
   210     }
   211 
   211 
   212     /**
   212     /**
   213      * get the available DataFlavors of the
   213      * get the available DataFlavors of the
   214      * <code>Transferable</code> operand of this operation.
   214      * <code>Transferable</code> operand of this operation.
   215      * <P>
   215      *
   216      * @return a <code>DataFlavor[]</code> containing the
   216      * @return a <code>DataFlavor[]</code> containing the
   217      * supported <code>DataFlavor</code>s of the
   217      * supported <code>DataFlavor</code>s of the
   218      * <code>Transferable</code> operand.
   218      * <code>Transferable</code> operand.
   219      */
   219      */
   220 
   220 
   225 
   225 
   226     /**
   226     /**
   227      * This method returns a the currently available DataFlavors
   227      * This method returns a the currently available DataFlavors
   228      * of the <code>Transferable</code> operand
   228      * of the <code>Transferable</code> operand
   229      * as a <code>java.util.List</code>.
   229      * as a <code>java.util.List</code>.
   230      * <P>
   230      *
   231      * @return the currently available
   231      * @return the currently available
   232      * DataFlavors as a <code>java.util.List</code>
   232      * DataFlavors as a <code>java.util.List</code>
   233      */
   233      */
   234 
   234 
   235     protected List<DataFlavor> getCurrentDataFlavorsAsList() {
   235     protected List<DataFlavor> getCurrentDataFlavorsAsList() {
   238 
   238 
   239     /**
   239     /**
   240      * This method returns a <code>boolean</code>
   240      * This method returns a <code>boolean</code>
   241      * indicating if the given <code>DataFlavor</code> is
   241      * indicating if the given <code>DataFlavor</code> is
   242      * supported by this <code>DropTargetContext</code>.
   242      * supported by this <code>DropTargetContext</code>.
   243      * <P>
   243      *
   244      * @param df the <code>DataFlavor</code>
   244      * @param df the <code>DataFlavor</code>
   245      * <P>
   245      *
   246      * @return if the <code>DataFlavor</code> specified is supported
   246      * @return if the <code>DataFlavor</code> specified is supported
   247      */
   247      */
   248 
   248 
   249     protected boolean isDataFlavorSupported(DataFlavor df) {
   249     protected boolean isDataFlavorSupported(DataFlavor df) {
   250         return getCurrentDataFlavorsAsList().contains(df);
   250         return getCurrentDataFlavorsAsList().contains(df);
   251     }
   251     }
   252 
   252 
   253     /**
   253     /**
   254      * get the Transferable (proxy) operand of this operation
   254      * get the Transferable (proxy) operand of this operation
   255      * <P>
   255      *
   256      * @throws InvalidDnDOperationException if a drag is not outstanding/extant
   256      * @throws InvalidDnDOperationException if a drag is not outstanding/extant
   257      * <P>
   257      *
   258      * @return the <code>Transferable</code>
   258      * @return the <code>Transferable</code>
   259      */
   259      */
   260 
   260 
   261     protected Transferable getTransferable() throws InvalidDnDOperationException {
   261     protected Transferable getTransferable() throws InvalidDnDOperationException {
   262         DropTargetContextPeer peer = getDropTargetContextPeer();
   262         DropTargetContextPeer peer = getDropTargetContextPeer();
   277         }
   277         }
   278     }
   278     }
   279 
   279 
   280     /**
   280     /**
   281      * Get the <code>DropTargetContextPeer</code>
   281      * Get the <code>DropTargetContextPeer</code>
   282      * <P>
   282      *
   283      * @return the platform peer
   283      * @return the platform peer
   284      */
   284      */
   285 
   285 
   286     DropTargetContextPeer getDropTargetContextPeer() {
   286     DropTargetContextPeer getDropTargetContextPeer() {
   287         return dropTargetContextPeer;
   287         return dropTargetContextPeer;
   320          * Constructs a <code>TransferableProxy</code> given
   320          * Constructs a <code>TransferableProxy</code> given
   321          * a specified <code>Transferable</code> object representing
   321          * a specified <code>Transferable</code> object representing
   322          * data transfer for a particular drag-n-drop operation and
   322          * data transfer for a particular drag-n-drop operation and
   323          * a <code>boolean</code> which indicates whether the
   323          * a <code>boolean</code> which indicates whether the
   324          * drag-n-drop operation is local (within the same JVM).
   324          * drag-n-drop operation is local (within the same JVM).
   325          * <p>
   325          *
   326          * @param t the <code>Transferable</code> object
   326          * @param t the <code>Transferable</code> object
   327          * @param local <code>true</code>, if <code>t</code> represents
   327          * @param local <code>true</code>, if <code>t</code> represents
   328          *        the result of local drag-n-drop operation
   328          *        the result of local drag-n-drop operation
   329          */
   329          */
   330         TransferableProxy(Transferable t, boolean local) {
   330         TransferableProxy(Transferable t, boolean local) {
   334         }
   334         }
   335 
   335 
   336         /**
   336         /**
   337          * Returns an array of DataFlavor objects indicating the flavors
   337          * Returns an array of DataFlavor objects indicating the flavors
   338          * the data can be provided in by the encapsulated transferable.
   338          * the data can be provided in by the encapsulated transferable.
   339          * <p>
   339          *
   340          * @return an array of data flavors in which the data can be
   340          * @return an array of data flavors in which the data can be
   341          *         provided by the encapsulated transferable
   341          *         provided by the encapsulated transferable
   342          */
   342          */
   343         public DataFlavor[] getTransferDataFlavors() {
   343         public DataFlavor[] getTransferDataFlavors() {
   344             return proxy.getTransferDataFlavors();
   344             return proxy.getTransferDataFlavors();