use of net.pms.util.CoverSupplier in project UniversalMediaServer by UniversalMediaServer.
the class NavigationShareTab method initSimpleComponents.
private void initSimpleComponents(CellConstraints cc) {
// Thumbnail seeking position
seekpos = new JTextField("" + configuration.getThumbnailSeekPos());
seekpos.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
try {
int ab = Integer.parseInt(seekpos.getText());
configuration.setThumbnailSeekPos(ab);
if (configuration.getUseCache()) {
PMS.get().getDatabase().init(true);
}
} catch (NumberFormatException nfe) {
LOGGER.debug("Could not parse thumbnail seek position from \"" + seekpos.getText() + "\"");
}
}
});
if (configuration.isThumbnailGenerationEnabled()) {
seekpos.setEnabled(true);
} else {
seekpos.setEnabled(false);
}
// Generate thumbnails
thumbgenCheckBox = new JCheckBox(Messages.getString("NetworkTab.2"), configuration.isThumbnailGenerationEnabled());
thumbgenCheckBox.setContentAreaFilled(false);
thumbgenCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setThumbnailGenerationEnabled((e.getStateChange() == ItemEvent.SELECTED));
seekpos.setEnabled(configuration.isThumbnailGenerationEnabled());
mplayer_thumb.setEnabled(configuration.isThumbnailGenerationEnabled());
}
});
// Use MPlayer for video thumbnails
mplayer_thumb = new JCheckBox(Messages.getString("FoldTab.14"), configuration.isUseMplayerForVideoThumbs());
mplayer_thumb.setToolTipText(Messages.getString("FoldTab.61"));
mplayer_thumb.setContentAreaFilled(false);
mplayer_thumb.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setUseMplayerForVideoThumbs((e.getStateChange() == ItemEvent.SELECTED));
}
});
if (configuration.isThumbnailGenerationEnabled()) {
mplayer_thumb.setEnabled(true);
} else {
mplayer_thumb.setEnabled(false);
}
// DVD ISO thumbnails
dvdiso_thumb = new JCheckBox(Messages.getString("FoldTab.19"), configuration.isDvdIsoThumbnails());
dvdiso_thumb.setContentAreaFilled(false);
dvdiso_thumb.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setDvdIsoThumbnails((e.getStateChange() == ItemEvent.SELECTED));
}
});
// Image thumbnails
image_thumb = new JCheckBox(Messages.getString("FoldTab.21"), configuration.getImageThumbnailsEnabled());
image_thumb.setContentAreaFilled(false);
image_thumb.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setImageThumbnailsEnabled((e.getStateChange() == ItemEvent.SELECTED));
}
});
// Audio thumbnails import
final KeyedComboBoxModel<CoverSupplier, String> thumbKCBM = new KeyedComboBoxModel<>(new CoverSupplier[] { CoverSupplier.NONE, CoverSupplier.COVER_ART_ARCHIVE }, new String[] { Messages.getString("FoldTab.35"), Messages.getString("FoldTab.73") });
audiothumbnail = new JComboBox<>(thumbKCBM);
audiothumbnail.setEditable(false);
thumbKCBM.setSelectedKey(configuration.getAudioThumbnailMethod());
audiothumbnail.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
configuration.setAudioThumbnailMethod(thumbKCBM.getSelectedKey());
LOGGER.info("Setting {} {}", Messages.getRootString("FoldTab.26"), thumbKCBM.getSelectedValue());
}
}
});
// Alternate video cover art folder
defaultThumbFolder = new JTextField(configuration.getAlternateThumbFolder());
defaultThumbFolder.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
configuration.setAlternateThumbFolder(defaultThumbFolder.getText());
}
});
// Alternate video cover art folder button
select = new CustomJButton("...");
select.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser chooser;
try {
chooser = new JFileChooser();
} catch (Exception ee) {
chooser = new JFileChooser(new RestrictedFileSystemView());
}
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = chooser.showDialog((Component) e.getSource(), Messages.getString("FoldTab.28"));
if (returnVal == JFileChooser.APPROVE_OPTION) {
defaultThumbFolder.setText(chooser.getSelectedFile().getAbsolutePath());
configuration.setAlternateThumbFolder(chooser.getSelectedFile().getAbsolutePath());
}
}
});
// Show Server Settings folder
isShowFolderServerSettings = new JCheckBox(Messages.getString("FoldTab.38"), configuration.isShowServerSettingsFolder());
isShowFolderServerSettings.setContentAreaFilled(false);
isShowFolderServerSettings.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setShowServerSettingsFolder((e.getStateChange() == ItemEvent.SELECTED));
}
});
// Show #--TRANSCODE--# folder
isShowFolderTranscode = new JCheckBox(Messages.getString("FoldTab.33"), configuration.isShowTranscodeFolder());
isShowFolderTranscode.setContentAreaFilled(false);
isShowFolderTranscode.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setShowTranscodeFolder((e.getStateChange() == ItemEvent.SELECTED));
}
});
// Show Media Library folder
isShowFolderMediaLibrary = new JCheckBox(Messages.getString("FoldTab.32"), configuration.isShowMediaLibraryFolder());
isShowFolderMediaLibrary.setContentAreaFilled(false);
isShowFolderMediaLibrary.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setShowMediaLibraryFolder((e.getStateChange() == ItemEvent.SELECTED));
}
});
// Browse compressed archives
archive = new JCheckBox(Messages.getString("NetworkTab.1"), configuration.isArchiveBrowsing());
archive.setContentAreaFilled(false);
archive.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setArchiveBrowsing(e.getStateChange() == ItemEvent.SELECTED);
}
});
// Enable the cache
cacheenable = new JCheckBox(Messages.getString("NetworkTab.17"), configuration.getUseCache());
cacheenable.setToolTipText(Messages.getString("FoldTab.48"));
cacheenable.setContentAreaFilled(false);
cacheenable.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setUseCache((e.getStateChange() == ItemEvent.SELECTED));
cachereset.setEnabled(configuration.getUseCache());
setScanLibraryEnabled(configuration.getUseCache());
}
});
// Reset cache
cachereset = new CustomJButton(Messages.getString("NetworkTab.18"));
cachereset.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int option = JOptionPane.showConfirmDialog(looksFrame, Messages.getString("NetworkTab.13") + "\n" + Messages.getString("NetworkTab.19"), Messages.getString("Dialog.Question"), JOptionPane.YES_NO_OPTION);
if (option == JOptionPane.YES_OPTION) {
PMS.get().getDatabase().init(true);
}
}
});
cachereset.setEnabled(configuration.getUseCache());
// Hide file extensions
hideextensions = new JCheckBox(Messages.getString("FoldTab.5"), configuration.isHideExtensions());
hideextensions.setContentAreaFilled(false);
if (configuration.isPrettifyFilenames()) {
hideextensions.setEnabled(false);
}
hideextensions.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setHideExtensions((e.getStateChange() == ItemEvent.SELECTED));
}
});
// Hide transcoding engine names
hideengines = new JCheckBox(Messages.getString("FoldTab.8"), configuration.isHideEngineNames());
hideengines.setToolTipText(Messages.getString("FoldTab.46"));
hideengines.setContentAreaFilled(false);
hideengines.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setHideEngineNames((e.getStateChange() == ItemEvent.SELECTED));
}
});
// Hide empty folders
hideemptyfolders = new JCheckBox(Messages.getString("FoldTab.31"), configuration.isHideEmptyFolders());
hideemptyfolders.setToolTipText(Messages.getString("FoldTab.59"));
hideemptyfolders.setContentAreaFilled(false);
hideemptyfolders.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setHideEmptyFolders((e.getStateChange() == ItemEvent.SELECTED));
}
});
// Show iTunes library
itunes = new JCheckBox(Messages.getString("FoldTab.30"), configuration.isShowItunesLibrary());
itunes.setToolTipText(Messages.getString("FoldTab.47"));
itunes.setContentAreaFilled(false);
if (!(Platform.isMac() || Platform.isWindows())) {
itunes.setEnabled(false);
}
itunes.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setShowItunesLibrary((e.getStateChange() == ItemEvent.SELECTED));
}
});
// Show iPhoto library
iphoto = new JCheckBox(Messages.getString("FoldTab.29"), configuration.isShowIphotoLibrary());
iphoto.setContentAreaFilled(false);
if (!Platform.isMac()) {
iphoto.setEnabled(false);
}
iphoto.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setShowIphotoLibrary((e.getStateChange() == ItemEvent.SELECTED));
}
});
// Show aperture library
aperture = new JCheckBox(Messages.getString("FoldTab.34"), configuration.isShowApertureLibrary());
aperture.setContentAreaFilled(false);
if (!Platform.isMac()) {
aperture.setEnabled(false);
}
aperture.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setShowApertureLibrary((e.getStateChange() == ItemEvent.SELECTED));
}
});
// File order
final KeyedComboBoxModel<Integer, String> kcbm = new KeyedComboBoxModel<>(new Integer[] { // alphabetical
UMSUtils.SORT_LOC_SENS, // natural sort
UMSUtils.SORT_LOC_NAT, // ASCIIbetical
UMSUtils.SORT_INS_ASCII, // newest first
UMSUtils.SORT_MOD_NEW, // oldest first
UMSUtils.SORT_MOD_OLD, // random
UMSUtils.SORT_RANDOM, // no sorting
UMSUtils.SORT_NO_SORT }, new String[] { Messages.getString("FoldTab.15"), Messages.getString("FoldTab.22"), Messages.getString("FoldTab.20"), Messages.getString("FoldTab.16"), Messages.getString("FoldTab.17"), Messages.getString("FoldTab.58"), Messages.getString("FoldTab.62") });
sortmethod = new JComboBox<>(kcbm);
sortmethod.setEditable(false);
kcbm.setSelectedKey(configuration.getSortMethod(null));
sortmethod.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
configuration.setSortMethod(kcbm.getSelectedKey());
LOGGER.info("Setting {} {}", Messages.getRootString("FoldTab.18"), kcbm.getSelectedValue());
}
}
});
// Ignore the word "the" while sorting
ignorethewordthe = new JCheckBox(Messages.getString("FoldTab.39"), configuration.isIgnoreTheWordAandThe());
ignorethewordthe.setToolTipText(Messages.getString("FoldTab.44"));
ignorethewordthe.setContentAreaFilled(false);
ignorethewordthe.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setIgnoreTheWordAandThe((e.getStateChange() == ItemEvent.SELECTED));
}
});
atzLimit = new JTextField("" + configuration.getATZLimit());
atzLimit.setToolTipText(Messages.getString("FoldTab.49"));
atzLimit.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
try {
int ab = Integer.parseInt(atzLimit.getText());
configuration.setATZLimit(ab);
} catch (NumberFormatException nfe) {
LOGGER.debug("Could not parse ATZ limit from \"" + atzLimit.getText() + "\"");
LOGGER.debug("The full error was: " + nfe);
}
}
});
isShowFolderLiveSubtitles = new JCheckBox(Messages.getString("FoldTab.42"), configuration.isShowLiveSubtitlesFolder());
isShowFolderLiveSubtitles.setContentAreaFilled(false);
isShowFolderLiveSubtitles.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setShowLiveSubtitlesFolder((e.getStateChange() == ItemEvent.SELECTED));
}
});
prettifyfilenames = new JCheckBox(Messages.getString("FoldTab.43"), configuration.isPrettifyFilenames());
prettifyfilenames.setToolTipText(Messages.getString("FoldTab.45"));
prettifyfilenames.setContentAreaFilled(false);
prettifyfilenames.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setPrettifyFilenames((e.getStateChange() == ItemEvent.SELECTED));
hideextensions.setEnabled((e.getStateChange() != ItemEvent.SELECTED));
episodeTitles.setEnabled((e.getStateChange() == ItemEvent.SELECTED));
}
});
episodeTitles = new JCheckBox(Messages.getString("FoldTab.74"), configuration.isUseInfoFromIMDb());
episodeTitles.setToolTipText(Messages.getString("FoldTab.64"));
episodeTitles.setContentAreaFilled(false);
if (!configuration.isPrettifyFilenames()) {
episodeTitles.setEnabled(false);
}
episodeTitles.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setUseInfoFromIMDb((e.getStateChange() == ItemEvent.SELECTED));
}
});
isShowFolderNewMedia = new JCheckBox(Messages.getString("FoldTab.54"), configuration.isShowNewMediaFolder());
isShowFolderNewMedia.setToolTipText(Messages.getString("FoldTab.66"));
isShowFolderNewMedia.setContentAreaFilled(false);
isShowFolderNewMedia.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setShowNewMediaFolder((e.getStateChange() == ItemEvent.SELECTED));
}
});
resume = new JCheckBox(Messages.getString("NetworkTab.68"), configuration.isResumeEnabled());
resume.setToolTipText(Messages.getString("NetworkTab.69"));
resume.setContentAreaFilled(false);
resume.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setResume((e.getStateChange() == ItemEvent.SELECTED));
}
});
isShowFolderRecentlyPlayed = new JCheckBox(Messages.getString("FoldTab.55"), configuration.isShowRecentlyPlayedFolder());
isShowFolderRecentlyPlayed.setContentAreaFilled(false);
isShowFolderRecentlyPlayed.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setShowRecentlyPlayedFolder((e.getStateChange() == ItemEvent.SELECTED));
}
});
// Fully played action
final KeyedComboBoxModel<FullyPlayedAction, String> fullyPlayedActionModel = new KeyedComboBoxModel<>(new FullyPlayedAction[] { FullyPlayedAction.NO_ACTION, FullyPlayedAction.MARK, FullyPlayedAction.HIDE_VIDEO, FullyPlayedAction.MOVE_FOLDER, FullyPlayedAction.MOVE_TRASH }, new String[] { Messages.getString("FoldTab.67"), Messages.getString("FoldTab.68"), Messages.getString("FoldTab.69"), Messages.getString("FoldTab.70"), Messages.getString("FoldTab.71") });
fullyPlayedAction = new JComboBox<>(fullyPlayedActionModel);
fullyPlayedAction.setEditable(false);
fullyPlayedActionModel.setSelectedKey(configuration.getFullyPlayedAction());
fullyPlayedAction.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
configuration.setFullyPlayedAction(fullyPlayedActionModel.getSelectedKey());
fullyPlayedOutputDirectory.setEnabled(fullyPlayedActionModel.getSelectedKey() == FullyPlayedAction.MOVE_FOLDER);
selectFullyPlayedOutputDirectory.setEnabled(fullyPlayedActionModel.getSelectedKey() == FullyPlayedAction.MOVE_FOLDER);
if (configuration.getUseCache() && fullyPlayedActionModel.getSelectedKey() == FullyPlayedAction.NO_ACTION) {
PMS.get().getDatabase().init(true);
}
}
}
});
// Watched video output directory
fullyPlayedOutputDirectory = new JTextField(configuration.getFullyPlayedOutputDirectory());
fullyPlayedOutputDirectory.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
configuration.setFullyPlayedOutputDirectory(fullyPlayedOutputDirectory.getText());
}
});
fullyPlayedOutputDirectory.setEnabled(configuration.getFullyPlayedAction() == FullyPlayedAction.MOVE_FOLDER);
// Watched video output directory selection button
selectFullyPlayedOutputDirectory = new CustomJButton("...");
selectFullyPlayedOutputDirectory.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser chooser;
try {
chooser = new JFileChooser();
} catch (Exception ee) {
chooser = new JFileChooser(new RestrictedFileSystemView());
}
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = chooser.showDialog((Component) e.getSource(), Messages.getString("FoldTab.28"));
if (returnVal == JFileChooser.APPROVE_OPTION) {
fullyPlayedOutputDirectory.setText(chooser.getSelectedFile().getAbsolutePath());
configuration.setFullyPlayedOutputDirectory(chooser.getSelectedFile().getAbsolutePath());
}
}
});
selectFullyPlayedOutputDirectory.setEnabled(configuration.getFullyPlayedAction() == FullyPlayedAction.MOVE_FOLDER);
}
Aggregations