Refactor com.apple.* usages to JDK 9
This commit is contained in:
parent
4916e83083
commit
a1457cc63a
|
@ -24,9 +24,6 @@ import java.util.logging.Level;
|
|||
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
import com.apple.eio.FileManager;
|
||||
import com.sun.jna.platform.FileUtils;
|
||||
|
||||
import net.filebot.platform.mac.MacAppUtilities;
|
||||
import net.filebot.util.FileUtilities;
|
||||
import net.filebot.util.FileUtilities.ExtensionFileFilter;
|
||||
|
@ -35,20 +32,16 @@ public class UserFiles {
|
|||
|
||||
public static void trash(File file) throws IOException {
|
||||
// use system trash if possible
|
||||
if (Desktop.getDesktop().isSupported(Desktop.Action.MOVE_TO_TRASH)) {
|
||||
try {
|
||||
if (isMacApp()) {
|
||||
// use com.apple.eio package on OS X platform
|
||||
if (FileManager.moveToTrash(file)) {
|
||||
return;
|
||||
}
|
||||
} else if (FileUtils.getInstance().hasTrash()) {
|
||||
// use com.sun.jna.platform package on Windows and Linux
|
||||
FileUtils.getInstance().moveToTrash(new File[] { file });
|
||||
if (Desktop.getDesktop().moveToTrash(file)) {
|
||||
return;
|
||||
}
|
||||
debug.log(Level.WARNING, message("Failed to move file to trash", file));
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.WARNING, e::toString);
|
||||
}
|
||||
}
|
||||
|
||||
// delete permanently if necessary
|
||||
if (file.exists()) {
|
||||
|
@ -57,10 +50,11 @@ public class UserFiles {
|
|||
}
|
||||
|
||||
public static void revealFiles(Collection<File> files) {
|
||||
if (isMacApp()) {
|
||||
// try to reveal file in folder
|
||||
if (Desktop.getDesktop().isSupported(Desktop.Action.BROWSE_FILE_DIR)) {
|
||||
files.stream().collect(groupingBy(File::getParentFile, LinkedHashMap::new, toList())).forEach((parent, children) -> {
|
||||
try {
|
||||
FileManager.revealInFinder(children.get(children.size() - 1));
|
||||
Desktop.getDesktop().browseFileDirectory(children.get(children.size() - 1));
|
||||
} catch (Exception e) {
|
||||
debug.log(Level.WARNING, e::toString);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue