* refactoring

This commit is contained in:
Reinhard Pointner 2014-11-03 12:22:45 +00:00
parent 8c7d6985c5
commit 327219679c
7 changed files with 17 additions and 12 deletions

View File

@ -3,6 +3,7 @@ package net.filebot.mac;
import java.awt.Window;
import java.io.File;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -85,4 +86,8 @@ public class MacAppUtilities {
return folder.isDirectory() && !folder.canRead() && !folder.canWrite();
}
public static boolean askUnlockFolders(final Window owner, final Collection<File> files) {
return DropToUnlock.showUnlockFoldersDialog(owner, files);
}
}

View File

@ -14,7 +14,7 @@ import java.util.logging.Level;
import javax.swing.tree.TreeNode;
import net.filebot.mac.DropToUnlock;
import net.filebot.mac.MacAppUtilities;
import net.filebot.ui.analyze.FileTree.FileNode;
import net.filebot.ui.analyze.FileTree.FolderNode;
import net.filebot.ui.transfer.BackgroundFileTransferablePolicy;
@ -59,7 +59,7 @@ class FileTreeTransferablePolicy extends BackgroundFileTransferablePolicy<TreeNo
// make sure we have access to the parent folder structure, not just the dropped file
if (isMacSandbox()) {
DropToUnlock.showUnlockFoldersDialog(getWindow(tree), files);
MacAppUtilities.askUnlockFolders(getWindow(tree), files);
}
}

View File

@ -65,7 +65,7 @@ import net.filebot.Settings;
import net.filebot.format.BindingException;
import net.filebot.format.ExpressionFormat;
import net.filebot.format.MediaBindingBean;
import net.filebot.mac.DropToUnlock;
import net.filebot.mac.MacAppUtilities;
import net.filebot.util.DefaultThreadFactory;
import net.filebot.util.ExceptionUtilities;
import net.filebot.util.PreferencesList;
@ -220,7 +220,7 @@ public class FormatDialog extends JDialog {
public void propertyChange(PropertyChangeEvent evt) {
if (isMacSandbox()) {
if (sample != null && sample.getMediaFile() != null && sample.getMediaFile().exists()) {
DropToUnlock.showUnlockFoldersDialog(getWindow(evt.getSource()), singleton(sample.getMediaFile()));
MacAppUtilities.askUnlockFolders(getWindow(evt.getSource()), singleton(sample.getMediaFile()));
}
}
checkFormatInBackground();

View File

@ -72,7 +72,7 @@ import net.filebot.History.Element;
import net.filebot.History.Sequence;
import net.filebot.ResourceManager;
import net.filebot.Settings;
import net.filebot.mac.DropToUnlock;
import net.filebot.mac.MacAppUtilities;
import net.filebot.media.MetaAttributes;
import net.filebot.ui.transfer.FileExportHandler;
import net.filebot.ui.transfer.FileTransferablePolicy;
@ -533,7 +533,7 @@ class HistoryDialog extends JDialog {
private void rename(File directory, List<Element> elements) {
Map<File, File> renamePlan = getRenameMap(directory);
if (isMacSandbox()) {
if (!DropToUnlock.showUnlockFoldersDialog(parent(), Stream.of(renamePlan.keySet(), renamePlan.values()).flatMap(c -> c.stream()).collect(Collectors.toList()))) {
if (!MacAppUtilities.askUnlockFolders(parent(), Stream.of(renamePlan.keySet(), renamePlan.values()).flatMap(c -> c.stream()).collect(Collectors.toList()))) {
return;
}
}

View File

@ -47,7 +47,7 @@ import net.filebot.HistorySpooler;
import net.filebot.NativeRenameAction;
import net.filebot.ResourceManager;
import net.filebot.StandardRenameAction;
import net.filebot.mac.DropToUnlock;
import net.filebot.mac.MacAppUtilities;
import net.filebot.media.MediaDetection;
import net.filebot.similarity.Match;
import net.filebot.util.ui.ProgressDialog;
@ -155,7 +155,7 @@ class RenameAction extends AbstractAction {
private Map<File, File> checkRenamePlan(List<Entry<File, File>> renamePlan, Window parent) throws IOException {
// ask for user permissions to output paths
if (isMacSandbox()) {
if (!DropToUnlock.showUnlockFoldersDialog(parent, renamePlan.stream().flatMap(e -> Stream.of(e.getKey(), resolveDestination(e.getKey(), e.getValue()))).map(f -> new File(f.getAbsolutePath())).collect(Collectors.toList()))) {
if (!MacAppUtilities.askUnlockFolders(parent, renamePlan.stream().flatMap(e -> Stream.of(e.getKey(), resolveDestination(e.getKey(), e.getValue()))).map(f -> new File(f.getAbsolutePath())).collect(Collectors.toList()))) {
return emptyMap();
}
}

View File

@ -55,7 +55,7 @@ import net.filebot.StandardRenameAction;
import net.filebot.UserFiles;
import net.filebot.WebServices;
import net.filebot.format.MediaBindingBean;
import net.filebot.mac.DropToUnlock;
import net.filebot.mac.MacAppUtilities;
import net.filebot.media.MediaDetection;
import net.filebot.similarity.Match;
import net.filebot.ui.rename.FormatDialog.Mode;
@ -665,7 +665,7 @@ public class RenamePanel extends JComponent {
final boolean autodetection = !isShiftOrAltDown(evt); // skip name auto-detection if SHIFT is pressed
if (isMacSandbox()) {
if (!DropToUnlock.showUnlockFoldersDialog(getWindow(RenamePanel.this), remainingFiles)) {
if (!MacAppUtilities.askUnlockFolders(getWindow(RenamePanel.this), remainingFiles)) {
return;
}
}

View File

@ -60,7 +60,7 @@ import javax.swing.table.DefaultTableCellRenderer;
import net.filebot.Analytics;
import net.filebot.ResourceManager;
import net.filebot.mac.DropToUnlock;
import net.filebot.mac.MacAppUtilities;
import net.filebot.similarity.EpisodeMetrics;
import net.filebot.similarity.MetricCascade;
import net.filebot.similarity.SimilarityMetric;
@ -270,7 +270,7 @@ class SubtitleAutoMatchDialog extends JDialog {
// make sure we have access to the parent folder structure, not just the dropped file
if (isMacSandbox()) {
DropToUnlock.showUnlockFoldersDialog(getWindow(evt.getSource()), mappingModel.getVideoFiles());
MacAppUtilities.askUnlockFolders(getWindow(evt.getSource()), mappingModel.getVideoFiles());
}
// collect the subtitles that will be fetched