Java Code Examples for javax.swing.TransferHandler.TransferSupport#isDataFlavorSupported()

The following examples show how to use javax.swing.TransferHandler.TransferSupport#isDataFlavorSupported() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileDropHandler.java    From audiveris with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public boolean canImport (TransferSupport support)
{
    /* For the time being, only support drops (not clipboard paste) */
    if (!support.isDrop()) {
        return false;
    }

    /* Check that the drop contains a list of files */
    if (!support.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
        return false;
    }

    /* Check to see if the source actions contains the COPY action */
    boolean copySupported = (COPY & support.getSourceDropActions()) == COPY;

    /* If COPY is supported, choose COPY and accept the transfer */
    if (copySupported) {
        support.setDropAction(COPY);

        return true;
    }

    /* COPY isn't supported, so reject the transfer */
    return false;
}
 
Example 2
Source File: ObjectDnD.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canImport(TransferSupport ts) {
    return ts.getComponent().equals(tree)
            && ts.isDataFlavorSupported(OBJECT_FLAVOR)
            && getDestinationObject(ts) != null
            && !(getDestinationObject(ts) instanceof ORRootInf);
}
 
Example 3
Source File: FileDropHandler.java    From libreveris with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean canImport (TransferSupport support)
{
    /* For the time being, only support drops (not clipboard paste) */
    if (!support.isDrop()) {
        return false;
    }

    /* Check that the drop contains a list of files */
    if (!support.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
        return false;
    }

    /* Check to see if the source actions contains the COPY action */
    boolean copySupported = (COPY & support.getSourceDropActions()) == COPY;

    /* If COPY is supported, choose COPY and accept the transfer */
    if (copySupported) {
        support.setDropAction(COPY);

        return true;
    }

    /* COPY isn't supported, so reject the transfer */
    return false;
}
 
Example 4
Source File: ShowToolSettingsPanel.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean canImport(TransferSupport info) {
	return info.isDrop() && info.isDataFlavorSupported(localObjectFlavor);
}