From afd60354d0b80888894065b744405906d56ef7d0 Mon Sep 17 00:00:00 2001 From: Philippe Delodder Date: Mon, 13 Apr 2015 08:20:06 +0200 Subject: [PATCH] Fix rename functionality --- .../gui/dialog/PreferenceDialog.java | 4 +- .../gui/dialog/RenameDialog.java | 4 +- .../gui/panels/EpisodeLibraryPanel.java | 4 +- .../gui/panels/MovieLibraryPanel.java | 4 +- .../gui/panels/VideoLibraryPanel.java | 50 ++++++++++++------- 5 files changed, 40 insertions(+), 26 deletions(-) diff --git a/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/dialog/PreferenceDialog.java b/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/dialog/PreferenceDialog.java index e20bd657..42424ed7 100755 --- a/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/dialog/PreferenceDialog.java +++ b/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/dialog/PreferenceDialog.java @@ -250,13 +250,13 @@ public void actionPerformed(ActionEvent arg0) { { pnlEpisodeLibrary = - new EpisodeLibraryPanel(settingsCtrl.getSettings().getEpisodeLibrarySettings(), manager); + new EpisodeLibraryPanel(settingsCtrl.getSettings().getEpisodeLibrarySettings(), manager, false); tabbedPane.addTab(Messages.getString("PreferenceDialog.SerieLibrary"), null, pnlEpisodeLibrary, null); } { pnlMovieLibrary = - new MovieLibraryPanel(settingsCtrl.getSettings().getMovieLibrarySettings(), manager); + new MovieLibraryPanel(settingsCtrl.getSettings().getMovieLibrarySettings(), manager, false); tabbedPane.addTab(Messages.getString("PreferenceDialog.MovieLibrary"), null, pnlMovieLibrary, null); } diff --git a/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/dialog/RenameDialog.java b/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/dialog/RenameDialog.java index 179f7e00..6daa6fa2 100755 --- a/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/dialog/RenameDialog.java +++ b/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/dialog/RenameDialog.java @@ -126,9 +126,9 @@ public void actionPerformed(ActionEvent arg0) { } { if (videoType == VideoType.EPISODE) { - pnlLibrary = new EpisodeLibraryPanel(settings.getEpisodeLibrarySettings(), manager); + pnlLibrary = new EpisodeLibraryPanel(settings.getEpisodeLibrarySettings(), manager, true); } else { - pnlLibrary = new MovieLibraryPanel(settings.getMovieLibrarySettings(), manager); + pnlLibrary = new MovieLibraryPanel(settings.getMovieLibrarySettings(), manager, true); } GridBagConstraints gbc_panel = new GridBagConstraints(); diff --git a/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/panels/EpisodeLibraryPanel.java b/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/panels/EpisodeLibraryPanel.java index 17bd2bdf..39e8ec49 100755 --- a/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/panels/EpisodeLibraryPanel.java +++ b/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/panels/EpisodeLibraryPanel.java @@ -11,8 +11,8 @@ public class EpisodeLibraryPanel extends VideoLibraryPanel { private static final long serialVersionUID = -9175813173306481849L; - public EpisodeLibraryPanel(LibrarySettings libSettings, Manager manager) { - super(libSettings, VideoType.EPISODE, manager); + public EpisodeLibraryPanel(LibrarySettings libSettings, Manager manager, Boolean renameMode) { + super(libSettings, VideoType.EPISODE, manager, renameMode); repaint(); } diff --git a/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/panels/MovieLibraryPanel.java b/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/panels/MovieLibraryPanel.java index ba5111c3..6c5cb94f 100755 --- a/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/panels/MovieLibraryPanel.java +++ b/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/panels/MovieLibraryPanel.java @@ -11,8 +11,8 @@ public class MovieLibraryPanel extends VideoLibraryPanel { private static final long serialVersionUID = -9175813173306481849L; - public MovieLibraryPanel(LibrarySettings libSettings, Manager manager) { - super(libSettings, VideoType.MOVIE, manager); + public MovieLibraryPanel(LibrarySettings libSettings, Manager manager, Boolean renameMode) { + super(libSettings, VideoType.MOVIE, manager, renameMode); repaint(); } diff --git a/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/panels/VideoLibraryPanel.java b/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/panels/VideoLibraryPanel.java index 73466628..b35d0dc7 100755 --- a/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/panels/VideoLibraryPanel.java +++ b/MultiSubDownloader/src/main/java/org/lodder/subtools/multisubdownloader/gui/panels/VideoLibraryPanel.java @@ -9,6 +9,7 @@ import java.io.File; import java.io.IOException; +import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -46,12 +47,15 @@ public abstract class VideoLibraryPanel extends JPanel { private PartialDisableComboBox cbxLibraryOtherFileAction; private SubtitleBackupPanel pnlBackup; private Manager manager; - + private Boolean renameMode; + private static final Logger LOGGER = LoggerFactory.getLogger(VideoLibraryPanel.class); - public VideoLibraryPanel(LibrarySettings libSettings, VideoType videoType, Manager manager) { + public VideoLibraryPanel(LibrarySettings libSettings, VideoType videoType, Manager manager, + Boolean renameMode) { this.videoType = videoType; this.manager = manager; + this.renameMode = renameMode; initialize_ui(); setLibrarySettings(libSettings); // repaint(); @@ -115,7 +119,8 @@ private void checkEnableStatus(JPanel panel, boolean status) { if (!(VideoType.MOVIE == videoType && c.equals(chkUseTVDBNaming))) { if (c instanceof JTextField && ((JTextField) c).getText().isEmpty() && VideoType.MOVIE == videoType && !c.equals(pnlStructureFolder.getStructure()) - && !c.equals(pnlStructureFile.getTxtDefaultNlText()) && !c.equals(pnlStructureFile.getTxtDefaultEnText())) { + && !c.equals(pnlStructureFile.getTxtDefaultNlText()) + && !c.equals(pnlStructureFile.getTxtDefaultEnText())) { c.setVisible(false); } else if (c instanceof JButton && c.equals(pnlStructureFile.getBtnBuildStructure()) && VideoType.MOVIE == videoType) { @@ -142,7 +147,8 @@ public boolean isValidPanelValues() { "Geen geldig pad is ingegeven in 'Map - Locatie' op Bibliotheek info "; JOptionPane.showConfirmDialog(this, message, "MultiSubDownloader", JOptionPane.CLOSED_OPTION, JOptionPane.ERROR_MESSAGE); - LOGGER.debug("isValidPanelValues: Geen geldig pad is ingegeven in 'Map - Locatie' op Bibliotheek info."); + LOGGER + .debug("isValidPanelValues: Geen geldig pad is ingegeven in 'Map - Locatie' op Bibliotheek info."); return false; } } catch (HeadlessException | IOException e) { @@ -156,9 +162,12 @@ public boolean isValidPanelValues() { public void setLibrarySettings(final LibrarySettings libSettings) { this.libSettings = libSettings; - pnlBackup.setBackupSubtitleSelected(libSettings.isLibraryBackupSubtitle()); - pnlBackup.setBackupSubtitlePath(libSettings.getLibraryBackupSubtitlePath().getAbsolutePath()); - pnlBackup.setBackupUseWebsiteFilenameSelected(libSettings.isLibraryBackupUseWebsiteFileName()); + if (!renameMode) { + pnlBackup.setBackupSubtitleSelected(libSettings.isLibraryBackupSubtitle()); + pnlBackup.setBackupSubtitlePath(libSettings.getLibraryBackupSubtitlePath().getAbsolutePath()); + pnlBackup + .setBackupUseWebsiteFilenameSelected(libSettings.isLibraryBackupUseWebsiteFileName()); + } this.cbxLibraryAction.setSelectedItem(libSettings.getLibraryAction()); this.chkUseTVDBNaming.setSelected(libSettings.isLibraryUseTVDBNaming()); this.chkReplaceWindowsChar.setSelected(libSettings.isLibraryReplaceChars()); @@ -187,10 +196,12 @@ public void setLibrarySettings(final LibrarySettings libSettings) { } public LibrarySettings getLibrarySettings() { - this.libSettings.setLibraryBackupSubtitle(pnlBackup.isBackupSubtitleSelected()); - this.libSettings.setLibraryBackupSubtitlePath(new File(pnlBackup.getBackupSubtitlePath())); - this.libSettings.setLibraryBackupUseWebsiteFileName(pnlBackup - .isBackupUseWebsiteFilenameSelected()); + if (!renameMode) { + this.libSettings.setLibraryBackupSubtitle(pnlBackup.isBackupSubtitleSelected()); + this.libSettings.setLibraryBackupSubtitlePath(new File(pnlBackup.getBackupSubtitlePath())); + this.libSettings.setLibraryBackupUseWebsiteFileName(pnlBackup + .isBackupUseWebsiteFilenameSelected()); + } this.libSettings.setLibraryAction((LibraryActionType) this.cbxLibraryAction.getSelectedItem()); this.libSettings.setLibraryUseTVDBNaming(this.chkUseTVDBNaming.isSelected()); this.libSettings.setLibraryReplaceChars(this.chkReplaceWindowsChar.isSelected()); @@ -207,12 +218,12 @@ public LibrarySettings getLibrarySettings() { if (pnlStructureFile.isReplaceSpaceSelected()) { this.libSettings.setLibraryFilenameReplacingSpaceSign(pnlStructureFile.getReplaceSpaceChar()); } - this.libSettings - .setLibraryFolderReplaceSpace(pnlStructureFolder.isReplaceSpaceSelected()); + this.libSettings.setLibraryFolderReplaceSpace(pnlStructureFolder.isReplaceSpaceSelected()); if (pnlStructureFolder.isReplaceSpaceSelected()) { this.libSettings.setLibraryFolderReplacingSpaceSign(pnlStructureFolder.getReplaceSpaceChar()); } - this.libSettings.setLibraryIncludeLanguageCode(pnlStructureFile.isIncludeLanguageCodeSelected()); + this.libSettings + .setLibraryIncludeLanguageCode(pnlStructureFile.isIncludeLanguageCodeSelected()); this.libSettings.setDefaultEnText(pnlStructureFile.getTxtDefaultEnText().getText()); this.libSettings.setDefaultNlText(pnlStructureFile.getTxtDefaultNlText().getText()); @@ -227,13 +238,16 @@ private void initialize_ui() { add(new JLabel("Bibiliotheek opties"), "cell 0 0 2 1,gapy 5"); add(new JSeparator(), "cell 0 0 2 1,growx,gapy 5"); - createBackupPanel(); - add(pnlBackup, "cell 0 1 2 1,grow"); + if (!renameMode) { + createBackupPanel(); + add(pnlBackup, "cell 0 1 2 1,grow"); + } add(new JLabel("Volgende acties uitvoeren:"), "cell 0 2,alignx left"); - cbxLibraryAction = new JComboBox(LibraryActionType.values()); - // cbxLibraryAction = new JComboBox(); + cbxLibraryAction = new JComboBox(); + cbxLibraryAction.setModel(new DefaultComboBoxModel(LibraryActionType + .values())); cbxLibraryAction.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { checkEnableStatusPanel();