* enable/disable combo boxes depending on datasource capabilities
This commit is contained in:
parent
d5fd7ba772
commit
bc87b59811
|
@ -41,7 +41,10 @@ import net.filebot.format.ExpressionFormat;
|
||||||
import net.filebot.format.MediaBindingBean;
|
import net.filebot.format.MediaBindingBean;
|
||||||
import net.filebot.ui.HeaderPanel;
|
import net.filebot.ui.HeaderPanel;
|
||||||
import net.filebot.util.FileUtilities.ExtensionFileFilter;
|
import net.filebot.util.FileUtilities.ExtensionFileFilter;
|
||||||
|
import net.filebot.web.AnidbClient;
|
||||||
import net.filebot.web.Datasource;
|
import net.filebot.web.Datasource;
|
||||||
|
import net.filebot.web.EpisodeListProvider;
|
||||||
|
import net.filebot.web.MovieIdentificationService;
|
||||||
import net.filebot.web.SortOrder;
|
import net.filebot.web.SortOrder;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
|
@ -70,6 +73,7 @@ public class PresetEditor extends JDialog {
|
||||||
|
|
||||||
private JRadioButton selectRadio;
|
private JRadioButton selectRadio;
|
||||||
private JRadioButton inheritRadio;
|
private JRadioButton inheritRadio;
|
||||||
|
private JPanel inputPanel;
|
||||||
|
|
||||||
public PresetEditor(Window owner) {
|
public PresetEditor(Window owner) {
|
||||||
super(owner, "Preset Editor", ModalityType.APPLICATION_MODAL);
|
super(owner, "Preset Editor", ModalityType.APPLICATION_MODAL);
|
||||||
|
@ -90,7 +94,7 @@ public class PresetEditor extends JDialog {
|
||||||
matchModeCombo = createMatchModeCombo();
|
matchModeCombo = createMatchModeCombo();
|
||||||
languageCombo = createLanguageCombo();
|
languageCombo = createLanguageCombo();
|
||||||
|
|
||||||
JPanel inputPanel = new JPanel(new MigLayout("insets 0, fill"));
|
inputPanel = new JPanel(new MigLayout("insets 0, fill"));
|
||||||
inputPanel.setOpaque(false);
|
inputPanel.setOpaque(false);
|
||||||
inputPanel.add(new JLabel("Input Folder:"), "gap indent");
|
inputPanel.add(new JLabel("Input Folder:"), "gap indent");
|
||||||
inputPanel.add(pathInput, "growx, gap rel");
|
inputPanel.add(pathInput, "growx, gap rel");
|
||||||
|
@ -132,14 +136,23 @@ public class PresetEditor extends JDialog {
|
||||||
inputButtonGroup.add(inheritRadio);
|
inputButtonGroup.add(inheritRadio);
|
||||||
inputButtonGroup.add(selectRadio);
|
inputButtonGroup.add(selectRadio);
|
||||||
inheritRadio.setSelected(true);
|
inheritRadio.setSelected(true);
|
||||||
inputPanel.setVisible(false);
|
selectRadio.addItemListener((evt) -> updateComponentStates());
|
||||||
selectRadio.addItemListener((evt) -> {
|
providerCombo.addItemListener((evt) -> updateComponentStates());
|
||||||
inputPanel.setVisible(selectRadio.isSelected());
|
updateComponentStates();
|
||||||
});
|
|
||||||
|
|
||||||
setSize(650, 570);
|
setSize(650, 570);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateComponentStates() {
|
||||||
|
Datasource ds = (Datasource) providerCombo.getSelectedItem();
|
||||||
|
boolean input = selectRadio.isSelected();
|
||||||
|
|
||||||
|
inputPanel.setVisible(input);
|
||||||
|
sortOrderCombo.setEnabled(ds instanceof EpisodeListProvider && ((EpisodeListProvider) ds).hasSeasonSupport());
|
||||||
|
languageCombo.setEnabled(ds instanceof EpisodeListProvider || ds instanceof MovieIdentificationService);
|
||||||
|
matchModeCombo.setEnabled(ds instanceof EpisodeListProvider || ds instanceof MovieIdentificationService);
|
||||||
|
}
|
||||||
|
|
||||||
public void setPreset(Preset p) {
|
public void setPreset(Preset p) {
|
||||||
presetNameHeader.getTitleLabel().setText(p.getName());
|
presetNameHeader.getTitleLabel().setText(p.getName());
|
||||||
pathInput.setText(p.getInputFolder() == null ? "" : p.getInputFolder().getPath());
|
pathInput.setText(p.getInputFolder() == null ? "" : p.getInputFolder().getPath());
|
||||||
|
@ -159,10 +172,10 @@ public class PresetEditor extends JDialog {
|
||||||
ExpressionFilter includes = inheritRadio.isSelected() ? null : new ExpressionFilter(filterEditor.getText());
|
ExpressionFilter includes = inheritRadio.isSelected() ? null : new ExpressionFilter(filterEditor.getText());
|
||||||
ExpressionFormat format = formatEditor.getText().trim().isEmpty() ? null : new ExpressionFormat(formatEditor.getText());
|
ExpressionFormat format = formatEditor.getText().trim().isEmpty() ? null : new ExpressionFormat(formatEditor.getText());
|
||||||
Datasource database = ((Datasource) providerCombo.getSelectedItem());
|
Datasource database = ((Datasource) providerCombo.getSelectedItem());
|
||||||
SortOrder sortOrder = ((SortOrder) sortOrderCombo.getSelectedItem());
|
SortOrder sortOrder = sortOrderCombo.isEnabled() ? ((SortOrder) sortOrderCombo.getSelectedItem()) : null;
|
||||||
String matchMode = (String) matchModeCombo.getSelectedItem();
|
String matchMode = matchModeCombo.isEnabled() ? (String) matchModeCombo.getSelectedItem() : null;
|
||||||
Language language = ((Language) languageCombo.getSelectedItem());
|
Language language = languageCombo.isEnabled() ? ((Language) languageCombo.getSelectedItem()) : null;
|
||||||
StandardRenameAction action = (StandardRenameAction) actionCombo.getSelectedItem();
|
StandardRenameAction action = actionCombo.isEnabled() ? (StandardRenameAction) actionCombo.getSelectedItem() : null;
|
||||||
|
|
||||||
return new Preset(name, path, includes, format, database, sortOrder, matchMode, language, action);
|
return new Preset(name, path, includes, format, database, sortOrder, matchMode, language, action);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue