Skip to content

Commit

Permalink
Merge pull request #268 from jburel/qa30780
Browse files Browse the repository at this point in the history
use toURI method to handle
  • Loading branch information
jburel authored Feb 18, 2022
2 parents 1a4044d + d71338d commit 414ae3f
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2011 University of Dundee & Open Microscopy Environment.
* Copyright (C) 2006-2022 University of Dundee & Open Microscopy Environment.
* All rights reserved.
*
*
Expand All @@ -25,6 +25,7 @@
import java.awt.event.ActionListener;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Paths;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
Expand Down Expand Up @@ -63,11 +64,16 @@ public class GenericFileChooser
*/
private void handleFileSelection(File f)
{
if (box == null || f == null) return;
if (Files.isSymbolicLink(Paths.get(f.getAbsolutePath())) || f.getName().endsWith(".lnk")) {
JOptionPane.showMessageDialog(null, "Cannot use shortcut " +
"from selection box.");
box.setSelectedItem(f.getParentFile());
if (box == null || f == null)
return;
try {
if (Files.isSymbolicLink(Paths.get(f.toURI())) || f.getName().endsWith(".lnk")) {
JOptionPane.showMessageDialog(null, "Cannot use shortcut " +
"from selection box.");
box.setSelectedItem(f.getParentFile());
}
} catch (InvalidPathException e) {
// this is thrown on Windows 10 when "This PC" selected, just ignore.
}
}

Expand Down

0 comments on commit 414ae3f

Please sign in to comment.