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