Interface IFileDropHandler
- All Known Implementing Classes:
BaseView,DemoMapView,DrawingView,GeometrySliceDemoView,ImageEvolutionDemoView,JsonView,LogView,MapView2D,NetworkDeclutterDemoView,NetworkLayoutDemoView,PlotView,SimulationView,TspDemoView,VirtualView
This interface is the application-level contract for file drops.
It is deliberately separate from the Swing plumbing (FileDropHandler)
so that the view layer never has to reference Swing transfer internals
directly.
Intended usage
Concrete views do not implement this interface manually.
Instead they extend BaseView, which already
implements it, and they activate drop support through a single call:
// In a BaseView subclass constructor, after super(...):
enableFileDrop(f -> f.getName().endsWith(".csv"));
@Override
public void filesDropped(List<File> files) {
openCsvFile(files.get(0));
}
Filter semantics
The filter is applied by FileDropHandler before
filesDropped(java.util.List<java.io.File>) is called. Only files that pass the predicate are
forwarded. Passing null as the filter accepts every dropped file.
Threading
filesDropped(java.util.List<java.io.File>) is called on the Swing Event Dispatch Thread.
-
Method Summary
Modifier and TypeMethodDescriptionvoidfilesDropped(List<File> files) Called on the EDT when one or more accepted files have been dropped onto this component.Returns the current file filter.voidsetFileFilter(Predicate<File> filter) Set the file filter used to screen dropped files.
-
Method Details
-
setFileFilter
Set the file filter used to screen dropped files.The
FileDropHandlerevaluates this predicate against each candidate file and forwards only those that returntrue. Anullfilter accepts every file without screening.- Parameters:
filter- the acceptance predicate, ornullto accept all files
-
getFileFilter
Returns the current file filter.- Returns:
- the acceptance predicate, or
nullif no filter is set
-
filesDropped
Called on the EDT when one or more accepted files have been dropped onto this component.The list contains only files that passed the current filter (or all dropped files if no filter is set). The list is never
nulland is never empty.- Parameters:
files- the accepted dropped files; nevernull, never empty
-