From 977e7a46660a944dbec3dafdd59ce360c301714f Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 3 Nov 2014 14:31:09 +0000 Subject: [PATCH] + "Change Folder" button in Format Dialog for quickly switching the absolute folder part of the format --- .../net/filebot/resources/action.folder.png | Bin 0 -> 499 bytes .../net/filebot/ui/rename/FormatDialog.java | 37 +++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 source/net/filebot/resources/action.folder.png diff --git a/source/net/filebot/resources/action.folder.png b/source/net/filebot/resources/action.folder.png new file mode 100644 index 0000000000000000000000000000000000000000..5d2655e49c403c9fe79643c126a9d6909fea0739 GIT binary patch literal 499 zcmV$BXap9y+30vOm)uz99Jxuw#s=D7Wsg zwfnq40x~EA!r1edKfm64;t0kndy+3u7Ww2WVR^*j_&uZY3MfGKND+uslSc*0*BwS> zjwkpP$S(==8P((-<%R8`(BDM$iEa~;b&gJPy85!Kr*4S4_n002ovPDHLkV1nX!*J1zw literal 0 HcmV?d00001 diff --git a/source/net/filebot/ui/rename/FormatDialog.java b/source/net/filebot/ui/rename/FormatDialog.java index 0a281158..fbc7bfae 100644 --- a/source/net/filebot/ui/rename/FormatDialog.java +++ b/source/net/filebot/ui/rename/FormatDialog.java @@ -6,6 +6,7 @@ import static javax.swing.BorderFactory.*; import static net.filebot.Settings.*; import static net.filebot.ui.NotificationLogging.*; import static net.filebot.util.ExceptionUtilities.*; +import static net.filebot.util.FileUtilities.*; import static net.filebot.util.ui.SwingUI.*; import java.awt.Color; @@ -62,6 +63,7 @@ import javax.swing.text.BadLocationException; import net.filebot.ResourceManager; import net.filebot.Settings; +import net.filebot.UserFiles; import net.filebot.format.BindingException; import net.filebot.format.ExpressionFormat; import net.filebot.format.MediaBindingBean; @@ -198,7 +200,8 @@ public class FormatDialog extends JDialog { content.add(editorScrollPane, "w 120px:min(pref, 420px), h 40px!, growx, wrap 4px, id editor"); content.add(createImageButton(changeSampleAction), "sg action, w 25!, h 19!, pos n editor.y2+1 editor.x2 n"); - content.add(createImageButton(showRecentAction), "sg action, w 25!, h 19!, pos n editor.y2+1 editor.x2-27 n"); + content.add(createImageButton(selectFolderAction), "sg action, w 25!, h 19!, pos n editor.y2+1 editor.x2-(27*1) n"); + content.add(createImageButton(showRecentAction), "sg action, w 25!, h 19!, pos n editor.y2+1 editor.x2-(27*2) n"); content.add(help, "growx, wrap 25px:push"); @@ -657,7 +660,37 @@ public class FormatDialog extends JDialog { } }; - protected final Action showRecentAction = new AbstractAction("Recent", ResourceManager.getIcon("action.expand")) { + protected final Action selectFolderAction = new AbstractAction("Change Folder", ResourceManager.getIcon("action.folder")) { + + @Override + public void actionPerformed(ActionEvent evt) { + String relativeFormat = editor.getText().trim(); + File absoluteFolder = null; + + if (relativeFormat.length() > 0) { + File templatePath = new File(relativeFormat); + if (templatePath.isAbsolute()) { + File existingPath = null; + for (File next : listPath(templatePath)) { + if (existingPath != null && !next.exists()) { + absoluteFolder = existingPath; + relativeFormat = relativeFormat.substring(existingPath.getPath().length() + 1); // account for file separator + break; + } + existingPath = next; + } + } + } + + File selectedFolder = UserFiles.showOpenDialogSelectFolder(absoluteFolder, "Select Folder", evt.getSource()); + if (selectedFolder != null) { + editor.setText(normalizePathSeparators(selectedFolder.getAbsolutePath()) + "/" + relativeFormat); + } + } + + }; + + protected final Action showRecentAction = new AbstractAction("Change Format", ResourceManager.getIcon("action.expand")) { @Override public void actionPerformed(ActionEvent evt) {