This commit is contained in:
Reinhard Pointner 2014-08-28 19:06:22 +00:00
parent 07a9577c99
commit c6099ddb58
1 changed files with 10 additions and 4 deletions

View File

@ -23,12 +23,14 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.geom.RoundRectangle2D; import java.awt.geom.RoundRectangle2D;
import java.io.File; import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask; import java.util.concurrent.FutureTask;
import java.util.concurrent.RunnableFuture; import java.util.concurrent.RunnableFuture;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@ -182,17 +184,21 @@ public class DropToUnlock extends JList<File> {
// show dialog on EDT and wait for user input // show dialog on EDT and wait for user input
try { try {
if (SwingUtilities.isEventDispatchThread()) {
showPermissionDialog.run();
} else {
SwingUtilities.invokeAndWait(showPermissionDialog); SwingUtilities.invokeAndWait(showPermissionDialog);
}
// store security-scoped bookmark if dialog was accepted // store security-scoped bookmark if dialog was accepted
if (showPermissionDialog.get()) { if (showPermissionDialog.get()) {
storeSecurityScopedBookmarks(model); storeSecurityScopedBookmarks(model);
return true; return true;
} }
} catch (Exception e) {
Logger.getLogger(DropToUnlock.class.getName()).log(Level.WARNING, "NSURL.bookmarkDataWithOptions: " + e.toString());
}
return false; return false;
} catch (InterruptedException | InvocationTargetException | ExecutionException e) {
throw new RuntimeException("Failed to request permissions: " + e.getMessage(), e);
}
} }
public DropToUnlock(Collection<File> model) { public DropToUnlock(Collection<File> model) {