下面列出了javax.swing.TransferHandler.TransferSupport#isDataFlavorSupported ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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;
}
@Override
public boolean canImport(TransferSupport ts) {
return ts.getComponent().equals(tree)
&& ts.isDataFlavorSupported(OBJECT_FLAVOR)
&& getDestinationObject(ts) != null
&& !(getDestinationObject(ts) instanceof ORRootInf);
}
/**
* {@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;
}
@Override
public boolean canImport(TransferSupport info) {
return info.isDrop() && info.isDataFlavorSupported(localObjectFlavor);
}