Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use toURI method to handle #268

Merged
merged 3 commits into from
Feb 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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