* refactor revealFiles
This commit is contained in:
parent
58c2f87671
commit
943c6db865
|
@ -10,6 +10,7 @@ import java.awt.Dialog;
|
|||
import java.awt.FileDialog;
|
||||
import java.awt.Frame;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
@ -23,16 +24,21 @@ import net.filebot.util.FileUtilities.ExtensionFileFilter;
|
|||
|
||||
public class UserFiles {
|
||||
|
||||
public static void revealFile(File file) {
|
||||
try {
|
||||
public static void revealFiles(Collection<File> files) {
|
||||
if (isMacApp()) {
|
||||
MacAppUtilities.revealInFinder(file);
|
||||
} else {
|
||||
Desktop.getDesktop().open(file.getParentFile());
|
||||
for (File it : files) {
|
||||
MacAppUtilities.revealInFinder(it);
|
||||
}
|
||||
} else {
|
||||
// if we can't reveal the file in folder, just reveal the parent folder
|
||||
files.stream().map(it -> it.getParentFile()).distinct().forEach(it -> {
|
||||
try {
|
||||
Desktop.getDesktop().open(it);
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(UserFiles.class.getName()).log(Level.WARNING, e.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static FileChooser defaultFileChooser = getPreferredFileChooser();
|
||||
|
|
|
@ -158,13 +158,7 @@ public class DropToUnlock extends JList<File> {
|
|||
|
||||
// open required folders for easy drag and drop (a few milliseconds after the dialog has become visible)
|
||||
invokeLater(500, () -> {
|
||||
try {
|
||||
for (File it : model) {
|
||||
revealFile(it);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(DropToUnlock.class.getName()).log(Level.WARNING, e.toString());
|
||||
}
|
||||
revealFiles(model);
|
||||
});
|
||||
|
||||
// show and wait for user input
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.filebot.ui.analyze;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static net.filebot.ui.NotificationLogging.*;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -15,7 +14,6 @@ import java.util.Iterator;
|
|||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
|
@ -29,7 +27,6 @@ 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;
|
||||
|
||||
|
@ -118,13 +115,7 @@ public class FileTree extends JTree {
|
|||
}
|
||||
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
try {
|
||||
for (Object file : (Collection<?>) getValue("files")) {
|
||||
UserFiles.revealFile((File) file);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
UILogger.log(Level.WARNING, ExceptionUtilities.getRootCauseMessage(e), e);
|
||||
}
|
||||
UserFiles.revealFiles((Collection<File>) getValue("files"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -247,8 +247,7 @@ public class RenamePanel extends JComponent {
|
|||
try {
|
||||
JList list = (JList) evt.getSource();
|
||||
if (list.getSelectedIndex() >= 0) {
|
||||
File item = (File) list.getSelectedValue();
|
||||
UserFiles.revealFile(item);
|
||||
UserFiles.revealFiles((List<File>) list.getSelectedValuesList());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(RenamePanel.class.getName()).log(Level.WARNING, e.getMessage());
|
||||
|
|
Loading…
Reference in New Issue