mirror of
https://github.com/processing/processing4.git
synced 2026-02-20 13:55:37 +01:00
Disable file drag & drop for read-only sketches
This commit is contained in:
@@ -313,15 +313,20 @@ public abstract class Editor extends JFrame implements RunnerListener {
|
||||
* "Sketch → Add File" for each file.
|
||||
*/
|
||||
class FileDropHandler extends TransferHandler {
|
||||
public boolean canImport(JComponent dest, DataFlavor[] flavors) {
|
||||
return true;
|
||||
public boolean canImport(TransferHandler.TransferSupport support) {
|
||||
return !sketch.isReadOnly();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean importData(JComponent src, Transferable transferable) {
|
||||
public boolean importData(TransferHandler.TransferSupport support) {
|
||||
int successful = 0;
|
||||
|
||||
if (!canImport(support)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
Transferable transferable = support.getTransferable();
|
||||
DataFlavor uriListFlavor =
|
||||
new DataFlavor("text/uri-list;class=java.lang.String");
|
||||
|
||||
@@ -2906,4 +2911,4 @@ public abstract class Editor extends JFrame implements RunnerListener {
|
||||
super.show(component, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user