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 javax.swing.JFileChooser;
|
||||||
|
|
||||||
import com.apple.eio.FileManager;
|
|
||||||
import com.sun.jna.platform.FileUtils;
|
|
||||||
|
|
||||||
import net.filebot.platform.mac.MacAppUtilities;
|
import net.filebot.platform.mac.MacAppUtilities;
|
||||||
import net.filebot.util.FileUtilities;
|
import net.filebot.util.FileUtilities;
|
||||||
import net.filebot.util.FileUtilities.ExtensionFileFilter;
|
import net.filebot.util.FileUtilities.ExtensionFileFilter;
|
||||||
|
@ -35,20 +32,16 @@ public class UserFiles {
|
||||||
|
|
||||||
public static void trash(File file) throws IOException {
|
public static void trash(File file) throws IOException {
|
||||||
// use system trash if possible
|
// use system trash if possible
|
||||||
|
if (Desktop.getDesktop().isSupported(Desktop.Action.MOVE_TO_TRASH)) {
|
||||||
try {
|
try {
|
||||||
if (isMacApp()) {
|
if (Desktop.getDesktop().moveToTrash(file)) {
|
||||||
// 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 });
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
debug.log(Level.WARNING, message("Failed to move file to trash", file));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
debug.log(Level.WARNING, e::toString);
|
debug.log(Level.WARNING, e::toString);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// delete permanently if necessary
|
// delete permanently if necessary
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
|
@ -57,10 +50,11 @@ public class UserFiles {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void revealFiles(Collection<File> files) {
|
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) -> {
|
files.stream().collect(groupingBy(File::getParentFile, LinkedHashMap::new, toList())).forEach((parent, children) -> {
|
||||||
try {
|
try {
|
||||||
FileManager.revealInFinder(children.get(children.size() - 1));
|
Desktop.getDesktop().browseFileDirectory(children.get(children.size() - 1));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
debug.log(Level.WARNING, e::toString);
|
debug.log(Level.WARNING, e::toString);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue