file associations
This commit is contained in:
parent
896eafe62b
commit
78cea4d18d
@ -891,10 +891,28 @@ public class FilePanelTab extends JPanel {
|
||||
}
|
||||
} else if (item.isDirectory()) {
|
||||
loadDirectory(item.getFile());
|
||||
} else if (item.getFile().isFile()) {
|
||||
openFileNative(item.getFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void openFileNative(File file) {
|
||||
try {
|
||||
if (file.canExecute() && !file.isDirectory()) {
|
||||
new ProcessBuilder(file.getAbsolutePath())
|
||||
.directory(file.getParentFile())
|
||||
.start();
|
||||
} else if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.OPEN)) {
|
||||
Desktop.getDesktop().open(file);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
try {
|
||||
JOptionPane.showMessageDialog(this, "Error opening file: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
|
||||
} catch (Exception ignore) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the item located at the given point (used for double-clicks while
|
||||
* mouse-driven selection is blocked). This mirrors the behavior of
|
||||
@ -931,6 +949,8 @@ public class FilePanelTab extends JPanel {
|
||||
}
|
||||
} else if (item.isDirectory()) {
|
||||
loadDirectory(item.getFile());
|
||||
} else if (item.getFile().isFile()) {
|
||||
openFileNative(item.getFile());
|
||||
}
|
||||
}
|
||||
|
||||
@ -949,13 +969,7 @@ public class FilePanelTab extends JPanel {
|
||||
if (item.isDirectory()) {
|
||||
loadDirectory(item.getFile());
|
||||
} else {
|
||||
try {
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
Desktop.getDesktop().open(item.getFile());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
try { JOptionPane.showMessageDialog(FilePanelTab.this, "Cannot open: " + ex.getMessage()); } catch (Exception ignore) {}
|
||||
}
|
||||
openFileNative(item.getFile());
|
||||
}
|
||||
});
|
||||
menu.add(openItem);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user