mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-02 08:25:02 -04:00
* use revealInFinder when possible
This commit is contained in:
parent
af120ad517
commit
8b01e2e05d
@ -72,6 +72,10 @@ public final class Settings {
|
||||
return Boolean.parseBoolean(System.getProperty("useCreationDate"));
|
||||
}
|
||||
|
||||
public static boolean isMacApp() {
|
||||
return "mas".equals(getApplicationDeployment()) || "app".equals(getApplicationDeployment());
|
||||
}
|
||||
|
||||
public static boolean isAppStore() {
|
||||
return "mas".equals(getApplicationDeployment()) || "usc".equals(getApplicationDeployment());
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import static java.util.Collections.*;
|
||||
import static net.filebot.Settings.*;
|
||||
import static net.filebot.util.ui.SwingUI.*;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.FileDialog;
|
||||
import java.awt.Frame;
|
||||
@ -12,13 +13,28 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.FutureTask;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
import net.filebot.mac.MacAppUtilities;
|
||||
import net.filebot.util.FileUtilities.ExtensionFileFilter;
|
||||
|
||||
public class UserFiles {
|
||||
|
||||
public static void revealFile(File file) {
|
||||
try {
|
||||
if (isMacApp()) {
|
||||
MacAppUtilities.revealInFinder(file);
|
||||
} else {
|
||||
Desktop.getDesktop().open(file.getParentFile());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(UserFiles.class.getName()).log(Level.WARNING, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static FileChooser defaultFileChooser = getPreferredFileChooser();
|
||||
|
||||
public static void setDefaultFileChooser(FileChooser fileChooser) {
|
||||
|
@ -11,7 +11,6 @@ import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Dialog.ModalExclusionType;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
@ -158,14 +157,14 @@ public class DropToUnlock extends JList<File> {
|
||||
dialog.setAlwaysOnTop(true);
|
||||
|
||||
// open required folders for easy drag and drop (a few milliseconds after the dialog has become visible)
|
||||
invokeLater(750, () -> {
|
||||
model.stream().map(f -> f.getParentFile()).sorted().distinct().forEach(f -> {
|
||||
try {
|
||||
Desktop.getDesktop().open(f);
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(DropToUnlock.class.getName()).log(Level.WARNING, e.toString());
|
||||
invokeLater(500, () -> {
|
||||
try {
|
||||
for (File it : model) {
|
||||
revealFile(it);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(DropToUnlock.class.getName()).log(Level.WARNING, e.toString());
|
||||
}
|
||||
});
|
||||
|
||||
// show and wait for user input
|
||||
|
@ -54,6 +54,16 @@ public class MacAppUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
public static void revealInFinder(File file) {
|
||||
try {
|
||||
Class<?> fileManager = Class.forName("com.apple.eio.FileManager");
|
||||
Method revealInFinder = fileManager.getMethod("revealInFinder", new Class<?>[] { File.class });
|
||||
revealInFinder.invoke(null, file);
|
||||
} catch (Throwable t) {
|
||||
Logger.getLogger(MacAppUtilities.class.getName()).log(Level.WARNING, "revealInFinder not supported: " + t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setUIDefaults() {
|
||||
UIManager.put("TitledBorder.border", UIManager.getBorder("InsetBorder.aquaVariant"));
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ public class MainFrame extends JFrame {
|
||||
selectEnabled = true;
|
||||
|
||||
// bring window to front when on dnd
|
||||
if (Settings.isMacSandbox()) {
|
||||
if (Settings.isMacApp()) {
|
||||
MacAppUtilities.requestForeground();
|
||||
} else {
|
||||
SwingUtilities.getWindowAncestor(((DropTarget) dtde.getSource()).getComponent()).toFront();
|
||||
|
@ -3,7 +3,6 @@ package net.filebot.ui.analyze;
|
||||
import static java.util.Collections.*;
|
||||
import static net.filebot.ui.NotificationLogging.*;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
@ -29,6 +28,7 @@ import javax.swing.tree.TreePath;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
|
||||
import net.filebot.ResourceManager;
|
||||
import net.filebot.UserFiles;
|
||||
import net.filebot.util.ExceptionUtilities;
|
||||
import net.filebot.util.FilterIterator;
|
||||
import net.filebot.util.TreeIterator;
|
||||
@ -120,7 +120,7 @@ public class FileTree extends JTree {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
try {
|
||||
for (Object file : (Collection<?>) getValue("files")) {
|
||||
Desktop.getDesktop().open((File) file);
|
||||
UserFiles.revealFile((File) file);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
UILogger.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
|
||||
|
@ -11,7 +11,6 @@ import static net.filebot.util.ui.SwingUI.*;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@ -52,6 +51,7 @@ import net.filebot.Language;
|
||||
import net.filebot.ResourceManager;
|
||||
import net.filebot.Settings;
|
||||
import net.filebot.StandardRenameAction;
|
||||
import net.filebot.UserFiles;
|
||||
import net.filebot.WebServices;
|
||||
import net.filebot.format.MediaBindingBean;
|
||||
import net.filebot.media.MediaDetection;
|
||||
@ -248,7 +248,7 @@ public class RenamePanel extends JComponent {
|
||||
JList list = (JList) evt.getSource();
|
||||
if (list.getSelectedIndex() >= 0) {
|
||||
File item = (File) list.getSelectedValue();
|
||||
Desktop.getDesktop().open(item.getParentFile());
|
||||
UserFiles.revealFile(item);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(RenamePanel.class.getName()).log(Level.WARNING, e.getMessage());
|
||||
|
Loading…
Reference in New Issue
Block a user