List of usage examples for javax.swing JTextPane JTextPane
public JTextPane()
JTextPane
. From source file:org.tinymediamanager.ui.movies.settings.MovieImageSettingsPanel.java
/** * Instantiates a new movie image settings panel. *//*from w w w. ja v a 2 s . c om*/ public MovieImageSettingsPanel() { // data init List<String> enabledArtworkProviders = settings.getMovieArtworkScrapers(); int selectedIndex = -1; int counter = 0; for (MediaScraper scraper : MovieList.getInstance().getAvailableArtworkScrapers()) { ArtworkScraper artworkScraper = new ArtworkScraper(scraper); if (enabledArtworkProviders.contains(artworkScraper.getScraperId())) { artworkScraper.active = true; if (selectedIndex < 0) { selectedIndex = counter; } } scrapers.add(artworkScraper); counter++; } // init UI setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelMovieImages = new JPanel(); panelMovieImages.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.poster"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelMovieImages, "2, 2, default, fill"); panelMovieImages.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); scrollPaneScraperDetails = new JScrollPane(); scrollPaneScraperDetails.setBorder(null); scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); panelMovieImages.add(scrollPaneScraperDetails, "6, 1, 1, 7, fill, fill"); panelScraperDetails = new ScrollablePanel(); scrollPaneScraperDetails.setViewportView(panelScraperDetails); panelScraperDetails .setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); { // add a CSS rule to force body tags to use the default label font // instead of the value in javax.swing.text.html.default.csss Font font = UIManager.getFont("Label.font"); String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }"; tpScraperDescription = new JTextPane(); tpScraperDescription.setOpaque(false); tpScraperDescription.setEditorKit(new HTMLEditorKit()); ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule); panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top"); } panelScraperOptions = new JPanel(); panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top"); scrollPaneScraper = new JScrollPane(); panelMovieImages.add(scrollPaneScraper, "2, 2, 3, 1, fill, fill"); tableScraper = new JTable(); tableScraper.setRowHeight(29); scrollPaneScraper.setViewportView(tableScraper); JSeparator separator = new JSeparator(); panelMovieImages.add(separator, "2, 3, 3, 1"); JLabel lblImageTmdbPosterSize = new JLabel(BUNDLE.getString("image.poster.size")); panelMovieImages.add(lblImageTmdbPosterSize, "2, 5"); cbImagePosterSize = new JComboBox(PosterSizes.values()); panelMovieImages.add(cbImagePosterSize, "4, 5"); JLabel lblImageTmdbFanartSize = new JLabel(BUNDLE.getString("image.fanart.size")); panelMovieImages.add(lblImageTmdbFanartSize, "2, 7"); cbImageFanartSize = new JComboBox(FanartSizes.values()); panelMovieImages.add(cbImageFanartSize, "4, 7"); separator = new JSeparator(); panelMovieImages.add(separator, "2, 9, 5, 1"); panelFileNaming = new JPanel(); panelMovieImages.add(panelFileNaming, "2, 11, 5, 1, fill, fill"); panelFileNaming.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JLabel lblPosterFilename = new JLabel(BUNDLE.getString("image.poster.naming")); panelFileNaming.add(lblPosterFilename, "1, 1"); cbMoviePosterFilename7 = new JCheckBox("<dynamic>.ext"); panelFileNaming.add(cbMoviePosterFilename7, "3, 1"); cbMoviePosterFilename4 = new JCheckBox("poster.ext"); panelFileNaming.add(cbMoviePosterFilename4, "5, 1"); cbMoviePosterFilename2 = new JCheckBox("movie.ext"); panelFileNaming.add(cbMoviePosterFilename2, "7, 1"); cbMoviePosterFilename8 = new JCheckBox("<dynamic>-poster.ext"); panelFileNaming.add(cbMoviePosterFilename8, "9, 1"); cbMoviePosterFilename6 = new JCheckBox("folder.ext"); panelFileNaming.add(cbMoviePosterFilename6, "11, 1"); JLabel lblFanartFileNaming = new JLabel(BUNDLE.getString("image.fanart.naming")); panelFileNaming.add(lblFanartFileNaming, "1, 3"); cbMovieFanartFilename1 = new JCheckBox("<dynamic>-fanart.ext"); panelFileNaming.add(cbMovieFanartFilename1, "3, 3"); cbMovieFanartFilename3 = new JCheckBox("<dynamic>.fanart.ext"); panelFileNaming.add(cbMovieFanartFilename3, "5, 3"); cbMovieFanartFilename2 = new JCheckBox("fanart.ext"); panelFileNaming.add(cbMovieFanartFilename2, "7, 3"); tpFileNamingHint = new JTextPane(); panelFileNaming.add(tpFileNamingHint, "1, 5, 11, 1, fill, fill"); tpFileNamingHint.setText(BUNDLE.getString("Settings.naming.info")); //$NON-NLS-1$ tpFileNamingHint.setBackground(UIManager.getColor("Panel.background")); TmmFontHelper.changeFont(tpFileNamingHint, 0.833); panelExtraArtwork = new JPanel(); panelExtraArtwork.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.extraartwork"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelExtraArtwork, "2, 4, default, fill"); panelExtraArtwork.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); chckbxBanner = new JCheckBox(BUNDLE.getString("mediafiletype.banner")); panelExtraArtwork.add(chckbxBanner, "2, 2"); chckbxClearArt = new JCheckBox(BUNDLE.getString("mediafiletype.clearart")); panelExtraArtwork.add(chckbxClearArt, "4, 2"); chckbxThumb = new JCheckBox(BUNDLE.getString("mediafiletype.thumb")); panelExtraArtwork.add(chckbxThumb, "6, 2"); chckbxLogo = new JCheckBox(BUNDLE.getString("mediafiletype.logo")); panelExtraArtwork.add(chckbxLogo, "8, 2"); chckbxDiscArt = new JCheckBox(BUNDLE.getString("mediafiletype.discart")); panelExtraArtwork.add(chckbxDiscArt, "10, 2"); separator = new JSeparator(); panelExtraArtwork.add(separator, "2, 4, 9, 1"); chckbxEnableExtrathumbs = new JCheckBox(BUNDLE.getString("Settings.enable.extrathumbs")); panelExtraArtwork.add(chckbxEnableExtrathumbs, "2, 6, 3, 1"); chckbxResizeExtrathumbsTo = new JCheckBox(BUNDLE.getString("Settings.resize.extrathumbs")); panelExtraArtwork.add(chckbxResizeExtrathumbsTo, "6, 6, 3, 1"); spExtrathumbWidth = new JSpinner(); panelExtraArtwork.add(spExtrathumbWidth, "10, 6"); spExtrathumbWidth.setPreferredSize(new Dimension(49, 20)); lblDownload = new JLabel(BUNDLE.getString("Settings.amount.autodownload")); panelExtraArtwork.add(lblDownload, "2, 8, 7, 1, right, default"); spDownloadCountExtrathumbs = new JSpinner(); panelExtraArtwork.add(spDownloadCountExtrathumbs, "10, 8"); spDownloadCountExtrathumbs.setPreferredSize(new Dimension(49, 20)); chckbxEnableExtrafanart = new JCheckBox(BUNDLE.getString("Settings.enable.extrafanart")); panelExtraArtwork.add(chckbxEnableExtrafanart, "2, 10, 9, 1"); lblDownloadCount = new JLabel(BUNDLE.getString("Settings.amount.autodownload")); panelExtraArtwork.add(lblDownloadCount, "2, 12, 7, 1, right, default"); spDownloadCountExtrafanart = new JSpinner(); panelExtraArtwork.add(spDownloadCountExtrafanart, "10, 12"); spDownloadCountExtrafanart.setPreferredSize(new Dimension(49, 20)); separator = new JSeparator(); panelExtraArtwork.add(separator, "2, 14, 9, 1"); cbActorImages = new JCheckBox(BUNDLE.getString("Settings.actor.download")); panelExtraArtwork.add(cbActorImages, "2, 16, 9, 1"); separator = new JSeparator(); panelExtraArtwork.add(separator, "2, 18, 9, 1"); chckbxMovieSetArtwork = new JCheckBox(BUNDLE.getString("Settings.movieset.store.movie")); //$NON-NLS-1$ panelExtraArtwork.add(chckbxMovieSetArtwork, "2, 20, 9, 1"); chckbxStoreMoviesetArtwork = new JCheckBox(BUNDLE.getString("Settings.movieset.store")); //$NON-NLS-1$ panelExtraArtwork.add(chckbxStoreMoviesetArtwork, "2, 22, 9, 1"); lblFoldername = new JLabel(BUNDLE.getString("Settings.movieset.foldername")); //$NON-NLS-1$ panelExtraArtwork.add(lblFoldername, "2, 24, 3, 1, right, default"); tfMovieSetArtworkFolder = new JTextField(); panelExtraArtwork.add(tfMovieSetArtworkFolder, "6, 24, 3, 1"); tfMovieSetArtworkFolder.setColumns(10); btnSelectFolder = new JButton(BUNDLE.getString("Settings.movieset.buttonselect")); //$NON-NLS-1$ panelExtraArtwork.add(btnSelectFolder, "10, 24"); btnSelectFolder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.movieset.folderchooser")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { tfMovieSetArtworkFolder.setText(file.toAbsolutePath().toString()); } } }); initDataBindings(); // poster filenames List<MoviePosterNaming> moviePosterFilenames = settings.getMoviePosterFilenames(); if (moviePosterFilenames.contains(MoviePosterNaming.MOVIE_JPG)) { cbMoviePosterFilename2.setSelected(true); } if (moviePosterFilenames.contains(MoviePosterNaming.POSTER_JPG)) { cbMoviePosterFilename4.setSelected(true); } if (moviePosterFilenames.contains(MoviePosterNaming.FOLDER_JPG)) { cbMoviePosterFilename6.setSelected(true); } if (moviePosterFilenames.contains(MoviePosterNaming.FILENAME_JPG)) { cbMoviePosterFilename7.setSelected(true); } if (moviePosterFilenames.contains(MoviePosterNaming.FILENAME_POSTER_JPG)) { cbMoviePosterFilename8.setSelected(true); } // fanart filenames List<MovieFanartNaming> movieFanartFilenames = settings.getMovieFanartFilenames(); if (movieFanartFilenames.contains(MovieFanartNaming.FILENAME_FANART_JPG)) { cbMovieFanartFilename1.setSelected(true); } if (movieFanartFilenames.contains(MovieFanartNaming.FANART_JPG)) { cbMovieFanartFilename2.setSelected(true); } if (movieFanartFilenames.contains(MovieFanartNaming.FILENAME_FANART2_JPG)) { cbMovieFanartFilename3.setSelected(true); } // listen to changes of the checkboxes ItemListener listener = new ItemListener() { public void itemStateChanged(ItemEvent e) { checkChanges(); } }; cbMovieFanartFilename2.addItemListener(listener); cbMovieFanartFilename3.addItemListener(listener); cbMovieFanartFilename1.addItemListener(listener); cbMoviePosterFilename2.addItemListener(listener); cbMoviePosterFilename4.addItemListener(listener); cbMoviePosterFilename7.addItemListener(listener); cbMoviePosterFilename8.addItemListener(listener); cbMoviePosterFilename6.addItemListener(listener); // adjust table columns // Checkbox and Logo shall have minimal width TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2); TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2); TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5); tableScraper.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); ArtworkScraper changedScraper = scrapers.get(row); if (changedScraper.active) { settings.addMovieArtworkScraper(changedScraper.getScraperId()); } else { settings.removeMovieArtworkScraper(changedScraper.getScraperId()); } } } }); // implement selection listener to load settings tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow()); if (index > -1) { panelScraperOptions.removeAll(); if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) { panelScraperOptions .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider())); } panelScraperOptions.revalidate(); } } }); // select default artwork scraper if (selectedIndex < 0) { selectedIndex = 0; } if (counter > 0) { tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex); } }
From source file:org.tinymediamanager.ui.movies.settings.MovieRenamerSettingsPanel.java
public MovieRenamerSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("250dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:default"), FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, })); // the panel renamer JPanel panelRenamer = new JPanel(); panelRenamer.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.movie.renamer.title"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelRenamer, "2, 2, fill, fill"); panelRenamer.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("75dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow(3)"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); chckbxSpaceSubstitution = new JCheckBox(BUNDLE.getString("Settings.movie.renamer.spacesubstitution")); //$NON-NLS-1$ chckbxSpaceSubstitution.addActionListener(actionCreateRenamerExample); tfMoviePath = new JTextField(); tfMoviePath.getDocument().addDocumentListener(new DocumentListener() { @Override/*from w w w . j a v a2 s . c o m*/ public void removeUpdate(DocumentEvent arg0) { createRenamerExample(); } @Override public void insertUpdate(DocumentEvent arg0) { createRenamerExample(); } @Override public void changedUpdate(DocumentEvent arg0) { createRenamerExample(); } }); JLabel lblMoviePath = new JLabel(BUNDLE.getString("Settings.renamer.folder")); //$NON-NLS-1$ panelRenamer.add(lblMoviePath, "2, 4, right, default"); panelRenamer.add(tfMoviePath, "4, 4, fill, default"); tfMoviePath.setColumns(10); panelRenamer.add(chckbxSpaceSubstitution, "8, 4"); cbSeparator = new JComboBox(separators.toArray()); panelRenamer.add(cbSeparator, "10, 4, fill, default"); cbSeparator.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { checkChanges(); createRenamerExample(); } }); lblDefault1T = new JLabel(BUNDLE.getString("Settings.default")); TmmFontHelper.changeFont(lblDefault1T, 0.833); panelRenamer.add(lblDefault1T, "2, 6, right, top"); lblDefaultFolderPattern = new JLabel(MovieSettings.DEFAULT_RENAMER_FOLDER_PATTERN); TmmFontHelper.changeFont(lblDefaultFolderPattern, 0.833); panelRenamer.add(lblDefaultFolderPattern, "4, 6, default, top"); chckbxMoviesetSingleMovie = new JCheckBox(BUNDLE.getString("Settings.renamer.moviesetsinglemovie")); //$NON-NLS-1$ chckbxMoviesetSingleMovie.addActionListener(actionCreateRenamerExample); panelRenamer.add(chckbxMoviesetSingleMovie, "8, 6, 5, 1, fill, default"); lblMMDWarning = new JLabel(BUNDLE.getString("Settings.renamer.folder.warning")); //$NON-NLS-1$ panelRenamer.add(lblMMDWarning, "2, 8, 11, 1"); JLabel lblMovieFilename = new JLabel(BUNDLE.getString("Settings.renamer.file")); //$NON-NLS-1$ panelRenamer.add(lblMovieFilename, "2, 10, right, fill"); tfMovieFilename = new JTextField(); tfMovieFilename.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent arg0) { createRenamerExample(); } @Override public void insertUpdate(DocumentEvent arg0) { createRenamerExample(); } @Override public void changedUpdate(DocumentEvent arg0) { createRenamerExample(); } }); panelRenamer.add(tfMovieFilename, "4, 10, fill, default"); tfMovieFilename.setColumns(10); lblMovieFilename.setLabelFor(tfMovieFilename); chckbxAsciiReplacement = new JCheckBox(BUNDLE.getString("Settings.renamer.asciireplacement")); //$NON-NLS-1$ chckbxAsciiReplacement.addActionListener(actionCreateRenamerExample); panelRenamer.add(chckbxAsciiReplacement, "8, 10, 5, 1"); lblDefault2T = new JLabel(BUNDLE.getString("Settings.default")); TmmFontHelper.changeFont(lblDefault2T, 0.833); panelRenamer.add(lblDefault2T, "2, 12, right, top"); lblDefaultFilePattern = new JLabel(MovieSettings.DEFAULT_RENAMER_FILE_PATTERN); TmmFontHelper.changeFont(lblDefaultFilePattern, 0.833); panelRenamer.add(lblDefaultFilePattern, "4, 12, default, top"); JTextPane txtpntAsciiHint = new JTextPane(); txtpntAsciiHint.setOpaque(false); txtpntAsciiHint.setEditable(false); txtpntAsciiHint.setText(BUNDLE.getString("Settings.renamer.asciireplacement.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(txtpntAsciiHint, 0.833); txtpntAsciiHint.setBackground(UIManager.getColor("Panel.background")); panelRenamer.add(txtpntAsciiHint, "8, 12, 5, 1, fill, fill"); JTextPane txtrChooseAFolder = new JTextPane(); txtrChooseAFolder.setOpaque(false); txtrChooseAFolder.setEditable(false); TmmFontHelper.changeFont(txtrChooseAFolder, 0.833); txtrChooseAFolder.setText(BUNDLE.getString("Settings.movie.renamer.example")); //$NON-NLS-1$ txtrChooseAFolder.setBackground(UIManager.getColor("Panel.background")); panelRenamer.add(txtrChooseAFolder, "2, 14, 3, 3, fill, top"); chckbxRemoveOtherNfos = new JCheckBox(BUNDLE.getString("Settings.renamer.removenfo")); //$NON-NLS-1$ panelRenamer.add(chckbxRemoveOtherNfos, "8, 14, 5, 1"); lblSubtitleLanguage = new JLabel(BUNDLE.getString("Settings.renamer.language")); //$NON-NLS-1$ panelRenamer.add(lblSubtitleLanguage, "8, 16, right, default"); cbSubtitleLanguage = new JComboBox(LanguageStyle.values()); panelRenamer.add(cbSubtitleLanguage, "10, 16, 3, 1, fill, default"); exampleEventList = GlazedLists.threadSafeList(new ObservableElementList<>( new BasicEventList<MovieRenamerExample>(), GlazedLists.beanConnector(MovieRenamerExample.class))); DefaultEventTableModel<MovieRenamerExample> exampleTableModel = new DefaultEventTableModel<>( GlazedListsSwing.swingThreadProxyList(exampleEventList), new MovieRenamerExampleTableFormat()); panelExample = new JPanel(); panelExample.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.example"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelExample, "2, 4, fill, fill"); panelExample.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("50dlu:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, })); JLabel lblExampleT = new JLabel(BUNDLE.getString("tmm.movie")); //$NON-NLS-1$ panelExample.add(lblExampleT, "2, 2"); cbMovieForPreview = new JComboBox(); panelExample.add(cbMovieForPreview, "4, 2"); lblExample = new JLabel(""); panelExample.add(lblExample, "2, 4, 3, 1"); TmmFontHelper.changeFont(lblExample, 0.916, Font.BOLD); tableExamples = new ZebraJTable(exampleTableModel); scrollPane = ZebraJTable.createStripedJScrollPane(tableExamples); scrollPane.setViewportView(tableExamples); panelExample.add(scrollPane, "2, 6, 3, 1, fill, fill"); JTextPane txtpntTitle = new JTextPane(); txtpntTitle.setOpaque(false); panelExample.add(txtpntTitle, "2, 8, 3, 1"); TmmFontHelper.changeFont(txtpntTitle, 0.833); txtpntTitle.setBackground(UIManager.getColor("Panel.background")); txtpntTitle.setText(BUNDLE.getString("Settings.movie.renamer.optional")); //$NON-NLS-1$ txtpntTitle.setEditable(false); cbMovieForPreview.addActionListener(actionCreateRenamerExample); initDataBindings(); // space separator String replacement = settings.getMovieRenamerSpaceReplacement(); int index = separators.indexOf(replacement); if (index >= 0) { cbSeparator.setSelectedIndex(index); } // language style cbSubtitleLanguage.setSelectedItem(settings.getMovieRenamerLanguageStyle()); // examples exampleEventList.add(new MovieRenamerExample("$T")); exampleEventList.add(new MovieRenamerExample("$O")); exampleEventList.add(new MovieRenamerExample("$1")); exampleEventList.add(new MovieRenamerExample("$E")); exampleEventList.add(new MovieRenamerExample("$2")); exampleEventList.add(new MovieRenamerExample("$Y")); exampleEventList.add(new MovieRenamerExample("$M")); exampleEventList.add(new MovieRenamerExample("$N")); exampleEventList.add(new MovieRenamerExample("$I")); exampleEventList.add(new MovieRenamerExample("$C")); exampleEventList.add(new MovieRenamerExample("$D")); exampleEventList.add(new MovieRenamerExample("$G")); exampleEventList.add(new MovieRenamerExample("$L")); exampleEventList.add(new MovieRenamerExample("$R")); exampleEventList.add(new MovieRenamerExample("$A")); exampleEventList.add(new MovieRenamerExample("$V")); exampleEventList.add(new MovieRenamerExample("$F")); exampleEventList.add(new MovieRenamerExample("$S")); exampleEventList.add(new MovieRenamerExample("$#")); exampleEventList.add(new MovieRenamerExample("$3")); exampleEventList.add(new MovieRenamerExample("$U")); }
From source file:org.tinymediamanager.ui.movies.settings.MovieScraperSettingsPanel.java
/** * Instantiates a new movie scraper settings panel. */// ww w. j a va 2 s . c o m public MovieScraperSettingsPanel() { // data init MediaScraper defaultMediaScraper = MovieList.getInstance().getDefaultMediaScraper(); int selectedIndex = 0; int counter = 0; for (MediaScraper scraper : MovieList.getInstance().getAvailableMediaScrapers()) { MovieScraper movieScraper = new MovieScraper(scraper); if (scraper.equals(defaultMediaScraper)) { movieScraper.defaultScraper = true; selectedIndex = counter; } scrapers.add(movieScraper); counter++; } // UI init setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); JPanel panelMovieScrapers = new JPanel(); panelMovieScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("scraper.metadata"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$ add(panelMovieScrapers, "2, 2, 3, 1, fill, fill"); panelMovieScrapers.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("50dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("150dlu:grow"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); scrollPaneScraper = new JScrollPane(); panelMovieScrapers.add(scrollPaneScraper, "2, 2, 3, 1, fill, fill"); tableScraper = new JTable() { private static final long serialVersionUID = -144223066269069772L; @Override public java.awt.Component prepareRenderer(TableCellRenderer renderer, int row, int col) { java.awt.Component comp = super.prepareRenderer(renderer, row, col); String value = getModel().getValueAt(row, 2).toString(); if (!Globals.isDonator() && value.startsWith("Kodi")) { // FIXME: use scraper.isEnabled() somehow? comp.setBackground(Color.lightGray); comp.setEnabled(false); } else { comp.setBackground(Color.white); comp.setEnabled(true); } return comp; } }; tableScraper.setRowHeight(29); scrollPaneScraper.setViewportView(tableScraper); scrollPane = new JScrollPane(); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(null); panelMovieScrapers.add(scrollPane, "6, 1, 1, 7, fill, fill"); panelScraperDetails = new ScrollablePanel(); scrollPane.setViewportView(panelScraperDetails); panelScraperDetails .setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); { // add a CSS rule to force body tags to use the default label font // instead of the value in javax.swing.text.html.default.csss Font font = UIManager.getFont("Label.font"); String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }"; tpScraperDescription = new JTextPane(); tpScraperDescription.setOpaque(false); tpScraperDescription.setEditorKit(new HTMLEditorKit()); ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule); panelScraperDetails.add(tpScraperDescription, "1, 1, default, top"); } panelScraperOptions = new JPanel(); panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top"); JSeparator separator = new JSeparator(); panelMovieScrapers.add(separator, "2, 4, 3, 1"); JLabel lblScraperLanguage = new JLabel(BUNDLE.getString("Settings.preferredLanguage")); //$NON-NLS-1$ panelMovieScrapers.add(lblScraperLanguage, "2, 5, right, default"); cbScraperLanguage = new JComboBox(MediaLanguages.values()); panelMovieScrapers.add(cbScraperLanguage, "4, 5"); JLabel lblCountry = new JLabel(BUNDLE.getString("Settings.certificationCountry")); //$NON-NLS-1$ panelMovieScrapers.add(lblCountry, "2, 7, right, default"); cbCertificationCountry = new JComboBox(CountryCode.values()); panelMovieScrapers.add(cbCertificationCountry, "4, 7, fill, default"); panelMovieScrapers.add(new JSeparator(), "2, 8, 5, 1"); chckbxScraperFallback = new JCheckBox(BUNDLE.getString("Settings.scraperfallback")); //$NON-NLS-1$ panelMovieScrapers.add(chckbxScraperFallback, "2, 9, 5, 1"); panelScraperMetadataContainer = new JPanel(); panelScraperMetadataContainer.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("scraper.metadata.defaults"), TitledBorder.LEADING, TitledBorder.TOP, null, //$NON-NLS-1$ new Color(51, 51, 51))); add(panelScraperMetadataContainer, "2, 4, fill, fill"); panelScraperMetadataContainer.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("10dlu"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, })); panelScraperMetadata = new MovieScraperMetadataPanel( Settings.getInstance().getMovieScraperMetadataConfig()); panelScraperMetadataContainer.add(panelScraperMetadata, "1, 1, 4, 1, fill, default"); chckbxAutomaticallyScrapeImages = new JCheckBox(BUNDLE.getString("Settings.default.autoscrape")); //$NON-NLS-1$ panelScraperMetadataContainer.add(chckbxAutomaticallyScrapeImages, "2, 3, 3, 1"); chckbxImageLanguage = new JCheckBox(BUNDLE.getString("Settings.default.autoscrape.language"));//$NON-NLS-1$ panelScraperMetadataContainer.add(chckbxImageLanguage, "4, 5"); panelAutomaticScraper = new JPanel(); panelAutomaticScraper.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.automaticscraper"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelAutomaticScraper, "4, 4, fill, fill"); panelAutomaticScraper.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JLabel lblScraperTreshold = new JLabel(BUNDLE.getString("Settings.scraperTreshold")); //$NON-NLS-1$ panelAutomaticScraper.add(lblScraperTreshold, "1, 2, default, top"); sliderThreshold = new JSlider(); sliderThreshold.setMinorTickSpacing(5); sliderThreshold.setMajorTickSpacing(10); sliderThreshold.setPaintTicks(true); sliderThreshold.setPaintLabels(true); sliderThreshold.setValue((int) (settings.getScraperThreshold() * 100)); Hashtable<Integer, JLabel> labelTable = new java.util.Hashtable<>(); labelTable.put(100, new JLabel("1.0")); labelTable.put(75, new JLabel("0.75")); labelTable.put(50, new JLabel("0.50")); labelTable.put(25, new JLabel("0.25")); labelTable.put(0, new JLabel("0.0")); sliderThreshold.setLabelTable(labelTable); sliderThreshold.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { settings.setScraperThreshold(sliderThreshold.getValue() / 100.0); } }); panelAutomaticScraper.add(sliderThreshold, "3, 2"); lblScraperThresholdHint = new JTextPane(); panelAutomaticScraper.add(lblScraperThresholdHint, "1, 6, 3, 1"); lblScraperThresholdHint.setOpaque(false); TmmFontHelper.changeFont(lblScraperThresholdHint, 0.833); lblScraperThresholdHint.setText(BUNDLE.getString("Settings.scraperTreshold.hint")); //$NON-NLS-1$ initDataBindings(); // adjust table columns // Checkbox and Logo shall have minimal width TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2); TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2); TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5); // implement listener to simulate button group tableScraper.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); MovieScraper changedScraper = scrapers.get(row); // if flag default scraper was changed, change all other flags if (changedScraper.getDefaultScraper()) { settings.setMovieScraper(changedScraper.getScraperId()); for (MovieScraper scraper : scrapers) { if (scraper != changedScraper) { scraper.setDefaultScraper(Boolean.FALSE); } } } } } }); // implement selection listener to load settings tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow()); if (index > -1) { panelScraperOptions.removeAll(); if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) { panelScraperOptions .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider())); } panelScraperOptions.revalidate(); } } }); // select default movie scraper if (counter > 0) { tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex); } }
From source file:org.tinymediamanager.ui.movies.settings.MovieSettingsPanel.java
/** * Instantiates a new movie settings panel. *///from ww w . j a v a2 s .c om public MovieSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); JPanel panelGeneral = new JPanel(); panelGeneral.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.general"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelGeneral, "2, 2, fill, fill"); panelGeneral.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblVisiblecolumns = new JLabel(BUNDLE.getString("Settings.movie.visiblecolumns")); //$NON-NLS-1$ panelGeneral.add(lblVisiblecolumns, "2, 2, right, default"); chckbxYear = new JCheckBox(BUNDLE.getString("metatag.year")); //$NON-NLS-1$ panelGeneral.add(chckbxYear, "4, 2"); chckbxRating = new JCheckBox(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$ panelGeneral.add(chckbxRating, "6, 2"); chckbxNfo = new JCheckBox(BUNDLE.getString("metatag.nfo")); //$NON-NLS-1$ panelGeneral.add(chckbxNfo, "8, 2"); chckbxMetadata = new JCheckBox(BUNDLE.getString("tmm.metadata")); //$NON-NLS-1$ panelGeneral.add(chckbxMetadata, "10, 2"); chckbxDateAdded = new JCheckBox(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$ panelGeneral.add(chckbxDateAdded, "12, 2"); chckbxImages = new JCheckBox(BUNDLE.getString("metatag.images")); //$NON-NLS-1$ panelGeneral.add(chckbxImages, "4, 4"); chckbxTrailer = new JCheckBox(BUNDLE.getString("metatag.trailer")); //$NON-NLS-1$ panelGeneral.add(chckbxTrailer, "6, 4"); chckbxSubtitles = new JCheckBox(BUNDLE.getString("metatag.subtitles")); //$NON-NLS-1$ panelGeneral.add(chckbxSubtitles, "8, 4"); chckbxWatched = new JCheckBox(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$ panelGeneral.add(chckbxWatched, "10, 4"); JLabel lblSaveUiFilter = new JLabel(BUNDLE.getString("Settings.movie.persistuifilter")); //$NON-NLS-1$ panelGeneral.add(lblSaveUiFilter, "2, 6, right, default"); chckbxSaveUiFilter = new JCheckBox(""); panelGeneral.add(chckbxSaveUiFilter, "4, 6"); JSeparator separator_4 = new JSeparator(); panelGeneral.add(separator_4, "2, 8, 11, 1"); JLabel lblImageCache = new JLabel(BUNDLE.getString("Settings.imagecacheimport")); panelGeneral.add(lblImageCache, "2, 10, right, default"); chckbxImageCache = new JCheckBox(BUNDLE.getString("Settings.imagecacheimporthint")); //$NON-NLS-1$ TmmFontHelper.changeFont(chckbxImageCache, 0.833); panelGeneral.add(chckbxImageCache, "4, 10, 7, 1"); JLabel lblRuntimeFromMedia = new JLabel(BUNDLE.getString("Settings.runtimefrommediafile")); panelGeneral.add(lblRuntimeFromMedia, "2, 12, right, default"); chckbxRuntimeFromMf = new JCheckBox(""); panelGeneral.add(chckbxRuntimeFromMf, "4, 12"); JSeparator separator = new JSeparator(); panelGeneral.add(separator, "2, 14, 11, 1"); final JLabel lblAutomaticRename = new JLabel(BUNDLE.getString("Settings.movie.automaticrename")); //$NON-NLS-1$ panelGeneral.add(lblAutomaticRename, "2, 16, right, default"); chckbxRename = new JCheckBox(BUNDLE.getString("Settings.movie.automaticrename.desc")); //$NON-NLS-1$ panelGeneral.add(chckbxRename, "4, 16, 7, 1"); JLabel lblTraktTv = new JLabel(BUNDLE.getString("Settings.trakt"));//$NON-NLS-1$ panelGeneral.add(lblTraktTv, "2, 18"); chckbxTraktTv = new JCheckBox(""); panelGeneral.add(chckbxTraktTv, "4, 18"); JButton btnClearTraktTvMovies = new JButton(BUNDLE.getString("Settings.trakt.clearmovies"));//$NON-NLS-1$ btnClearTraktTvMovies.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int confirm = JOptionPane.showOptionDialog(null, BUNDLE.getString("Settings.trakt.clearmovies.hint"), BUNDLE.getString("Settings.trakt.clearmovies"), JOptionPane.YES_NO_OPTION, //$NON-NLS-1$ JOptionPane.QUESTION_MESSAGE, null, null, null); if (confirm == JOptionPane.YES_OPTION) { TmmTask task = new ClearTraktTvTask(true, false); TmmTaskManager.getInstance().addUnnamedTask(task); } } }); panelGeneral.add(btnClearTraktTvMovies, "6, 18, 3, 1, left, default"); JPanel panelMovieDataSources = new JPanel(); panelMovieDataSources.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.movie.datasource"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelMovieDataSources, "2, 4, 3, 1, fill, fill"); panelMovieDataSources.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150dlu:grow(2)"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("100px:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblDataSource = new JLabel(BUNDLE.getString("Settings.source")); //$NON-NLS-1$ panelMovieDataSources.add(lblDataSource, "2, 2, 5, 1"); JLabel lblIngore = new JLabel(BUNDLE.getString("Settings.ignore")); //$NON-NLS-1$ panelMovieDataSources.add(lblIngore, "12, 2"); JScrollPane scrollPaneDataSources = new JScrollPane(); panelMovieDataSources.add(scrollPaneDataSources, "2, 4, 5, 1, fill, fill"); listDataSources = new JList<>(); scrollPaneDataSources.setViewportView(listDataSources); JPanel panelMovieSourcesButtons = new JPanel(); panelMovieDataSources.add(panelMovieSourcesButtons, "8, 4, fill, top"); panelMovieSourcesButtons .setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JButton btnAdd = new JButton(IconManager.LIST_ADD); btnAdd.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAdd.setMargin(new Insets(2, 2, 2, 2)); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.datasource.folderchooser")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { settings.addMovieDataSources(file.toAbsolutePath().toString()); } } }); panelMovieSourcesButtons.add(btnAdd, "1, 1, fill, top"); JButton btnRemove = new JButton(IconManager.LIST_REMOVE); btnRemove.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemove.setMargin(new Insets(2, 2, 2, 2)); btnRemove.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listDataSources.getSelectedIndex(); if (row != -1) { // nothing selected String path = MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource().get(row); String[] choices = { BUNDLE.getString("Button.continue"), BUNDLE.getString("Button.abort") }; //$NON-NLS-1$ int decision = JOptionPane.showOptionDialog(null, String.format(BUNDLE.getString("Settings.movie.datasource.remove.info"), path), BUNDLE.getString("Settings.datasource.remove"), JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, choices, BUNDLE.getString("Button.abort")); //$NON-NLS-1$ if (decision == 0) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); MovieModuleManager.MOVIE_SETTINGS.removeMovieDataSources(path); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } } }); panelMovieSourcesButtons.add(btnRemove, "1, 3, fill, top"); JScrollPane scrollPaneIgnore = new JScrollPane(); panelMovieDataSources.add(scrollPaneIgnore, "12, 4, fill, fill"); listIgnore = new JList<>(); scrollPaneIgnore.setViewportView(listIgnore); JPanel panelIgnoreButtons = new JPanel(); panelMovieDataSources.add(panelIgnoreButtons, "14, 4, fill, fill"); panelIgnoreButtons.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JButton btnAddIgnore = new JButton(IconManager.LIST_ADD); btnAddIgnore.setToolTipText(BUNDLE.getString("Settings.addignore")); //$NON-NLS-1$ btnAddIgnore.setMargin(new Insets(2, 2, 2, 2)); btnAddIgnore.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.ignore")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { settings.addMovieSkipFolder(file.toAbsolutePath().toString()); } } }); panelIgnoreButtons.add(btnAddIgnore, "1, 1"); JButton btnRemoveIgnore = new JButton(IconManager.LIST_REMOVE); btnRemoveIgnore.setToolTipText(BUNDLE.getString("Settings.removeignore")); //$NON-NLS-1$ btnRemoveIgnore.setMargin(new Insets(2, 2, 2, 2)); btnRemoveIgnore.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int row = listIgnore.getSelectedIndex(); if (row != -1) { // nothing selected String ingore = settings.getMovieSkipFolders().get(row); settings.removeMovieSkipFolder(ingore); } } }); panelIgnoreButtons.add(btnRemoveIgnore, "1, 3"); JPanel panel = new JPanel(); panelMovieDataSources.add(panel, "2, 8, 13, 1, fill, fill"); panel.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("20dlu"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JLabel lblNfoFormat = new JLabel(BUNDLE.getString("Settings.nfoFormat")); panel.add(lblNfoFormat, "1, 1, right, default"); cbNfoFormat = new JComboBox(MovieConnectors.values()); panel.add(cbNfoFormat, "3, 1, fill, default"); JLabel lblNfoFileNaming = new JLabel(BUNDLE.getString("Settings.nofFileNaming")); //$NON-NLS-1$ panel.add(lblNfoFileNaming, "7, 1, right, default"); cbMovieNfoFilename1 = new JCheckBox(BUNDLE.getString("Settings.moviefilename") + ".nfo"); //$NON-NLS-1$ panel.add(cbMovieNfoFilename1, "9, 1"); cbMovieNfoFilename2 = new JCheckBox("movie.nfo"); panel.add(cbMovieNfoFilename2, "9, 2"); cbMovieNfoFilename2.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); cbMovieNfoFilename3 = new JCheckBox(BUNDLE.getString("Settings.nfo.discstyle")); //$NON-NLS-1$ panel.add(cbMovieNfoFilename3, "9, 3"); cbMovieNfoFilename3.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); final JLabel lblCertificationStyle = new JLabel(BUNDLE.getString("Settings.certificationformat")); //$NON-NLS-1$ panel.add(lblCertificationStyle, "1, 5, right, default"); cbCertificationStyle = new JComboBox(); panel.add(cbCertificationStyle, "3, 5, 7, 1, fill, default"); JPanel panelBadWords = new JPanel(); panelBadWords.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.movie.badwords"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelBadWords, "4, 2, fill, fill"); panelBadWords.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JTextPane txtpntBadWordsHint = new JTextPane(); txtpntBadWordsHint.setBackground(UIManager.getColor("Panel.background")); txtpntBadWordsHint.setText(BUNDLE.getString("Settings.movie.badwords.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(txtpntBadWordsHint, 0.833); panelBadWords.add(txtpntBadWordsHint, "2, 2, 3, 1, fill, default"); JScrollPane scpBadWords = new JScrollPane(); panelBadWords.add(scpBadWords, "2, 4, fill, fill"); listBadWords = new JList<>(); scpBadWords.setViewportView(listBadWords); JButton btnRemoveBadWord = new JButton(IconManager.LIST_REMOVE); btnRemoveBadWord.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemoveBadWord.setMargin(new Insets(2, 2, 2, 2)); btnRemoveBadWord.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listBadWords.getSelectedIndex(); if (row != -1) { String badWord = MovieModuleManager.MOVIE_SETTINGS.getBadWords().get(row); MovieModuleManager.MOVIE_SETTINGS.removeBadWord(badWord); } } }); panelBadWords.add(btnRemoveBadWord, "4, 4, default, bottom"); tfAddBadword = new JTextField(); tfAddBadword.setColumns(10); panelBadWords.add(tfAddBadword, "2, 6, fill, default"); JButton btnAddBadWord = new JButton(IconManager.LIST_ADD); btnAddBadWord.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAddBadWord.setMargin(new Insets(2, 2, 2, 2)); btnAddBadWord.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (StringUtils.isNotEmpty(tfAddBadword.getText())) { MovieModuleManager.MOVIE_SETTINGS.addBadWord(tfAddBadword.getText()); tfAddBadword.setText(""); } } }); panelBadWords.add(btnAddBadWord, "4, 6"); initDataBindings(); { // NFO filenames List<MovieNfoNaming> movieNfoFilenames = settings.getMovieNfoFilenames(); if (movieNfoFilenames.contains(MovieNfoNaming.FILENAME_NFO)) { cbMovieNfoFilename1.setSelected(true); } if (movieNfoFilenames.contains(MovieNfoNaming.MOVIE_NFO)) { cbMovieNfoFilename2.setSelected(true); } if (movieNfoFilenames.contains(MovieNfoNaming.DISC_NFO)) { cbMovieNfoFilename3.setSelected(true); } if (!Globals.isDonator()) { chckbxTraktTv.setSelected(false); chckbxTraktTv.setEnabled(false); btnClearTraktTvMovies.setEnabled(false); } // set default certification style cbNfoFormat.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (cbNfoFormat.getSelectedItem() == MovieConnectors.MP) { for (int i = 0; i < cbCertificationStyle.getItemCount(); i++) { CertificationStyleWrapper wrapper = cbCertificationStyle.getItemAt(i); if (wrapper.style == CertificationStyle.TECHNICAL) { cbCertificationStyle.setSelectedItem(wrapper); break; } } } else if (cbNfoFormat.getSelectedItem() == MovieConnectors.XBMC || cbNfoFormat.getSelectedItem() == MovieConnectors.KODI) { for (int i = 0; i < cbCertificationStyle.getItemCount(); i++) { CertificationStyleWrapper wrapper = cbCertificationStyle.getItemAt(i); if (wrapper.style == CertificationStyle.LARGE) { cbCertificationStyle.setSelectedItem(wrapper); break; } } } } }); // certification examples for (CertificationStyle style : CertificationStyle.values()) { CertificationStyleWrapper wrapper = new CertificationStyleWrapper(); wrapper.style = style; cbCertificationStyle.addItem(wrapper); if (style == settings.getMovieCertificationStyle()) { cbCertificationStyle.setSelectedItem(wrapper); } } cbCertificationStyle.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); // item listener cbMovieNfoFilename1.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); } }
From source file:org.tinymediamanager.ui.movies.settings.MovieSubtitleSettingsPanel.java
private void initComponents() { // data init//w ww .ja v a2 s.c o m List<String> enabledSubtitleProviders = settings.getMovieSubtitleScrapers(); int selectedIndex = -1; int counter = 0; for (MediaScraper scraper : MovieList.getInstance().getAvailableSubtitleScrapers()) { SubtitleScraper subtitleScraper = new SubtitleScraper(scraper); if (enabledSubtitleProviders.contains(subtitleScraper.getScraperId())) { subtitleScraper.active = true; if (selectedIndex < 0) { selectedIndex = counter; } } scrapers.add(subtitleScraper); counter++; } // UI init setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelSubtitleScrapers = new JPanel(); panelSubtitleScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("scraper.subtitle"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$ add(panelSubtitleScrapers, "2, 2, 5, 1, fill, fill"); panelSubtitleScrapers.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), })); final JScrollPane scrollPaneScraperDetails = new JScrollPane(); scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPaneScraperDetails.setBorder(null); panelSubtitleScrapers.add(scrollPaneScraperDetails, "4, 1, 1, 2, fill, fill"); JPanel panelScraperDetails = new JPanel(); scrollPaneScraperDetails.setViewportView(panelScraperDetails); panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), }, new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); { // add a CSS rule to force body tags to use the default label font // instead of the value in javax.swing.text.html.default.csss Font font = UIManager.getFont("Label.font"); String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }"; tpScraperDescription = new JTextPane(); tpScraperDescription.setOpaque(false); tpScraperDescription.setEditorKit(new HTMLEditorKit()); ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule); panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top"); } panelScraperOptions = new ScrollablePanel(); panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top"); JScrollPane scrollPaneScraper = new JScrollPane(); panelSubtitleScrapers.add(scrollPaneScraper, "2, 2, fill, fill"); tableScraper = new JTable(); tableScraper.setRowHeight(29); scrollPaneScraper.setViewportView(tableScraper); final JLabel lblScraperLanguage = new JLabel(BUNDLE.getString("Settings.preferredLanguage")); //$NON-NLS-1$ add(lblScraperLanguage, "2, 4, right, default"); cbScraperLanguage = new JComboBox(MediaLanguages.values()); add(cbScraperLanguage, "4, 4, fill, default"); initDataBindings(); // adjust table columns // Checkbox and Logo shall have minimal width TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2); TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2); TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5); tableScraper.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); SubtitleScraper changedScraper = scrapers.get(row); if (changedScraper.active) { settings.addMovieSubtitleScraper(changedScraper.getScraperId()); } else { settings.removeMovieSubtitleScraper(changedScraper.getScraperId()); } } } }); // implement selection listener to load settings tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow()); if (index > -1) { panelScraperOptions.removeAll(); if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) { panelScraperOptions .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider())); } panelScraperOptions.revalidate(); } } }); // select default movie scraper if (selectedIndex < 0) { selectedIndex = 0; } if (counter > 0) { tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex); } }
From source file:org.tinymediamanager.ui.movies.settings.MovieTrailerSettingsPanel.java
public MovieTrailerSettingsPanel() { // data init//from ww w . j a v a 2 s.c o m List<String> enabledTrailerProviders = settings.getMovieTrailerScrapers(); int selectedIndex = -1; int counter = 0; for (MediaScraper scraper : MovieList.getInstance().getAvailableTrailerScrapers()) { TrailerScraper trailerScraper = new TrailerScraper(scraper); if (enabledTrailerProviders.contains(trailerScraper.getScraperId())) { trailerScraper.active = true; if (selectedIndex < 0) { selectedIndex = counter; } } scrapers.add(trailerScraper); counter++; } // UI init setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelTrailerScrapers = new JPanel(); panelTrailerScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("scraper.trailer"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$ add(panelTrailerScrapers, "2, 2, fill, fill"); panelTrailerScrapers.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); final JScrollPane scrollPaneScraperDetails = new JScrollPane(); scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPaneScraperDetails.setBorder(null); panelTrailerScrapers.add(scrollPaneScraperDetails, "8, 1, 1, 2, fill, fill"); JPanel panelScraperDetails = new JPanel(); scrollPaneScraperDetails.setViewportView(panelScraperDetails); panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), }, new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); { // add a CSS rule to force body tags to use the default label font // instead of the value in javax.swing.text.html.default.csss Font font = UIManager.getFont("Label.font"); String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }"; tpScraperDescription = new JTextPane(); tpScraperDescription.setOpaque(false); tpScraperDescription.setEditorKit(new HTMLEditorKit()); ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule); panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top"); } panelScraperOptions = new ScrollablePanel(); panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top"); JScrollPane scrollPaneScraper = new JScrollPane(); panelTrailerScrapers.add(scrollPaneScraper, "2, 2, 5, 1, fill, fill"); tableTrailerScraper = new JTable(); tableTrailerScraper.setRowHeight(29); scrollPaneScraper.setViewportView(tableTrailerScraper); JSeparator separator = new JSeparator(); panelTrailerScrapers.add(separator, "2, 4, 7, 1"); checkBox = new JCheckBox(BUNDLE.getString("Settings.trailer.preferred")); //$NON-NLS-1$ panelTrailerScrapers.add(checkBox, "2, 6, 7, 1"); JLabel lblTrailerSource = new JLabel(BUNDLE.getString("Settings.trailer.source")); //$NON-NLS-1$ panelTrailerScrapers.add(lblTrailerSource, "4, 8, right, default"); cbTrailerSource = new JComboBox<>(); cbTrailerSource.setModel(new DefaultComboBoxModel<>(MovieTrailerSources.values())); panelTrailerScrapers.add(cbTrailerSource, "6, 8, fill, default"); JLabel lblTrailerQuality = new JLabel(BUNDLE.getString("Settings.trailer.quality")); //$NON-NLS-1$ panelTrailerScrapers.add(lblTrailerQuality, "4, 10, right, default"); cbTrailerQuality = new JComboBox<>(); cbTrailerQuality.setModel(new DefaultComboBoxModel<>(MovieTrailerQuality.values())); panelTrailerScrapers.add(cbTrailerQuality, "6, 10, fill, default"); chckbxAutomaticTrailerDownload = new JCheckBox(BUNDLE.getString("Settings.trailer.automaticdownload")); //$NON-NLS-1$ panelTrailerScrapers.add(chckbxAutomaticTrailerDownload, "2, 12, 7, 1"); JLabel lblAutomaticTrailerDownloadHint = new JLabel( BUNDLE.getString("Settings.trailer.automaticdownload.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(lblAutomaticTrailerDownloadHint, 0.833); panelTrailerScrapers.add(lblAutomaticTrailerDownloadHint, "4, 14, 5, 1"); initDataBindings(); // adjust table columns // Checkbox and Logo shall have minimal width TableColumnResizer.setMaxWidthForColumn(tableTrailerScraper, 0, 2); TableColumnResizer.setMaxWidthForColumn(tableTrailerScraper, 1, 2); TableColumnResizer.adjustColumnPreferredWidths(tableTrailerScraper, 5); tableTrailerScraper.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); TrailerScraper changedScraper = scrapers.get(row); if (changedScraper.active) { settings.addMovieTrailerScraper(changedScraper.getScraperId()); } else { settings.removeMovieTrailerScraper(changedScraper.getScraperId()); } } } }); // implement selection listener to load settings tableTrailerScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int index = tableTrailerScraper.convertRowIndexToModel(tableTrailerScraper.getSelectedRow()); if (index > -1) { panelScraperOptions.removeAll(); if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) { panelScraperOptions .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider())); } panelScraperOptions.revalidate(); } } }); // select default movie scraper if (selectedIndex < 0) { selectedIndex = 0; } if (counter > 0) { tableTrailerScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex); } }
From source file:org.tinymediamanager.ui.moviesets.dialogs.MovieSetEditorDialog.java
/** * Instantiates a new movie set editor.//from w w w. j a v a 2s . c o m * * @param movieSet * the movie set * @param inQueue * the in queue */ public MovieSetEditorDialog(MovieSet movieSet, boolean inQueue) { super(BUNDLE.getString("movieset.edit"), "movieSetEditor"); //$NON-NLS-1$ setBounds(5, 5, 800, 500); movieSetToEdit = movieSet; try { List<String> enabledScrapers = new ArrayList<>(); if (MovieModuleManager.MOVIE_SETTINGS.getMovieArtworkScrapers().contains(Constants.TMDB)) { enabledScrapers.add(Constants.TMDB); } if (MovieModuleManager.MOVIE_SETTINGS.getMovieArtworkScrapers().contains(Constants.FANART_TV)) { enabledScrapers.add(Constants.FANART_TV); } artworkScrapers.addAll(movieList.getArtworkScrapers(enabledScrapers)); // artworkScrapers.addAll(movieList.getArtworkScrapers(Arrays.asList(Constants.TMDB, Constants.FANART_TV))); } catch (Exception e2) { LOGGER.warn("error getting IMediaArtworkProvider " + e2.getMessage()); } getContentPane().setLayout(new BorderLayout()); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.NORTH); getContentPane().add(tabbedPane, BorderLayout.CENTER); JPanel panelContent = new JPanel(); panelContent.setLayout(new FormLayout(new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("100px"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("300px:grow"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("75px:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.NARROW_LINE_GAP_ROWSPEC, })); tabbedPane.addTab(BUNDLE.getString("metatag.details"), panelContent); //$NON-NLS-1$ JLabel lblName = new JLabel(BUNDLE.getString("movieset.title")); //$NON-NLS-1$ panelContent.add(lblName, "2, 2, right, default"); tfName = new JTextField(); panelContent.add(tfName, "4, 2, 3, 1, fill, default"); tfName.setColumns(10); lblPoster = new ImageLabel(); lblPoster.setAlternativeText(BUNDLE.getString("image.notfound.poster")); //$NON-NLS-1$ lblPoster.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int tmdbId = 0; try { tmdbId = Integer.parseInt(tfTmdbId.getText()); } catch (Exception e1) { } HashMap<String, Object> ids = new HashMap<>(movieSetToEdit.getIds()); ids.put(Constants.TMDB, tmdbId); // MovieSetImageChooserDialog dialog = new MovieSetImageChooserDialog(tmdbId, ImageType.POSTER, lblPoster); ImageChooserDialog dialog = new ImageChooserDialog(ids, ImageType.POSTER, artworkScrapers, lblPoster, null, null, MediaType.MOVIE_SET); dialog.setLocationRelativeTo(MainWindow.getActiveInstance()); dialog.setVisible(true); } }); panelContent.add(lblPoster, "8, 2, 1, 9, fill, fill"); JLabel lblTmdbid = new JLabel(BUNDLE.getString("metatag.tmdb")); //$NON-NLS-1$ panelContent.add(lblTmdbid, "2, 4, right, default"); tfTmdbId = new JTextField(); panelContent.add(tfTmdbId, "4, 4, fill, default"); tfTmdbId.setColumns(10); JButton btnSearchTmdbId = new JButton(""); btnSearchTmdbId.setAction(actionSearchTmdbId); panelContent.add(btnSearchTmdbId, "6, 4, left, default"); JLabel lblOverview = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$ panelContent.add(lblOverview, "2, 6, right, top"); JScrollPane scrollPaneOverview = new JScrollPane(); panelContent.add(scrollPaneOverview, "4, 6, 3, 1, fill, fill"); tpOverview = new JTextPane(); scrollPaneOverview.setViewportView(tpOverview); JLabel lblMovies = new JLabel(BUNDLE.getString("tmm.movies")); //$NON-NLS-1$ panelContent.add(lblMovies, "2, 8, right, top"); JScrollPane scrollPaneMovies = new JScrollPane(); panelContent.add(scrollPaneMovies, "4, 8, 3, 9, fill, fill"); tableMovies = new JTable(); scrollPaneMovies.setViewportView(tableMovies); JButton btnRemoveMovie = new JButton(""); btnRemoveMovie.setAction(actionRemoveMovie); panelContent.add(btnRemoveMovie, "2, 10, right, top"); lblFanart = new ImageLabel(); lblFanart.setAlternativeText(BUNDLE.getString("image.notfound.fanart")); //$NON-NLS-1$ lblFanart.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int tmdbId = 0; try { tmdbId = Integer.parseInt(tfTmdbId.getText()); } catch (Exception e1) { } HashMap<String, Object> ids = new HashMap<>(movieSetToEdit.getIds()); ids.put(Constants.TMDB, tmdbId); ImageChooserDialog dialog = new ImageChooserDialog(ids, ImageType.FANART, artworkScrapers, lblFanart, null, null, MediaType.MOVIE_SET); dialog.setLocationRelativeTo(MainWindow.getActiveInstance()); dialog.setVisible(true); } }); panelContent.add(lblFanart, "8, 12, 1, 5, fill, fill"); /** * Artwork pane */ { JPanel artworkPanel = new JPanel(); tabbedPane.addTab(BUNDLE.getString("metatag.extraartwork"), null, artworkPanel, null); //$NON-NLS-1$ artworkPanel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("150px:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("50px:grow(2)"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("200px:grow(2)"), FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); { JLabel lblLogoT = new JLabel(BUNDLE.getString("mediafiletype.logo")); //$NON-NLS-1$ artworkPanel.add(lblLogoT, "2, 2"); } { lblLogo = new ImageLabel(); lblLogo.setAlternativeText(BUNDLE.getString("image.notfound.logo")); //$NON-NLS-1$ lblLogo.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { ImageChooserDialog dialog = new ImageChooserDialog(movieSetToEdit.getIds(), ImageType.LOGO, movieList.getDefaultArtworkScrapers(), lblLogo, null, null, MediaType.MOVIE); dialog.setLocationRelativeTo(MainWindow.getActiveInstance()); dialog.setVisible(true); } }); { final JLabel lblClearlogoT = new JLabel(BUNDLE.getString("mediafiletype.clearlogo")); //$NON-NLS-1$ artworkPanel.add(lblClearlogoT, "4, 2"); } lblLogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); artworkPanel.add(lblLogo, "2, 4, fill, fill"); } { lblClearlogo = new ImageLabel(); lblClearlogo.setAlternativeText(BUNDLE.getString("image.notfound.clearlogo")); //$NON-NLS-1$ lblClearlogo.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { ImageChooserDialog dialog = new ImageChooserDialog(movieSetToEdit.getIds(), ImageType.CLEARLOGO, movieList.getDefaultArtworkScrapers(), lblClearlogo, null, null, MediaType.MOVIE); dialog.setLocationRelativeTo(MainWindow.getActiveInstance()); dialog.setVisible(true); } }); lblClearlogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); artworkPanel.add(lblClearlogo, "4, 4, fill, fill"); } { JLabel lblClearartT = new JLabel(BUNDLE.getString("mediafiletype.clearart")); //$NON-NLS-1$ artworkPanel.add(lblClearartT, "2, 6"); } { lblClearart = new ImageLabel(); lblClearart.setAlternativeText(BUNDLE.getString("image.notfound.clearart")); //$NON-NLS-1$ lblClearart.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { ImageChooserDialog dialog = new ImageChooserDialog(movieSetToEdit.getIds(), ImageType.CLEARART, movieList.getDefaultArtworkScrapers(), lblClearart, null, null, MediaType.MOVIE); dialog.setLocationRelativeTo(MainWindow.getActiveInstance()); dialog.setVisible(true); } }); { JLabel lblBannerT = new JLabel(BUNDLE.getString("mediafiletype.banner")); //$NON-NLS-1$ artworkPanel.add(lblBannerT, "4, 6"); } lblClearart.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); artworkPanel.add(lblClearart, "2, 8, fill, fill"); } { lblBanner = new ImageLabel(); lblBanner.setAlternativeText(BUNDLE.getString("image.notfound.banner")); //$NON-NLS-1$ lblBanner.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { ImageChooserDialog dialog = new ImageChooserDialog(movieSetToEdit.getIds(), ImageType.BANNER, movieList.getDefaultArtworkScrapers(), lblBanner, null, null, MediaType.MOVIE); dialog.setLocationRelativeTo(MainWindow.getActiveInstance()); dialog.setVisible(true); } }); lblBanner.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); artworkPanel.add(lblBanner, "4, 8, 3, 1, fill, fill"); } // extra artwork lblBanner.setImagePath(movieSetToEdit.getArtworkFilename(MediaFileType.BANNER)); } /** * Button pane */ { JPanel buttonPane = new JPanel(); getContentPane().add(buttonPane, BorderLayout.SOUTH); EqualsLayout layout = new EqualsLayout(5); buttonPane.setBorder(new EmptyBorder(4, 4, 4, 4)); layout.setMinWidth(100); buttonPane.setLayout(layout); { JButton btnOk = new JButton(BUNDLE.getString("Button.ok")); //$NON-NLS-1$ btnOk.setAction(actionOk); buttonPane.add(btnOk); getRootPane().setDefaultButton(btnOk); JButton btnCancel = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$ btnCancel.setAction(actionCancel); buttonPane.add(btnCancel); if (inQueue) { JButton abortButton = new JButton(BUNDLE.getString("Button.abortqueue")); //$NON-NLS-1$ buttonPane.add(abortButton); abortButton.setAction(actionAbort); } } } { tfName.setText(movieSetToEdit.getTitle()); tfTmdbId.setText(String.valueOf(movieSetToEdit.getTmdbId())); tpOverview.setText(movieSetToEdit.getPlot()); moviesInSet.addAll(movieSetToEdit.getMovies()); if (StringUtils.isNotBlank(movieSetToEdit.getArtworkFilename(MediaFileType.POSTER))) { lblPoster.setImagePath(movieSetToEdit.getArtworkFilename(MediaFileType.POSTER)); } else { lblPoster.setImageUrl(movieSetToEdit.getArtworkUrl(MediaFileType.POSTER)); } if (StringUtils.isNotBlank(movieSetToEdit.getArtworkFilename(MediaFileType.FANART))) { lblFanart.setImagePath(movieSetToEdit.getArtworkFilename(MediaFileType.FANART)); } else { lblFanart.setImageUrl(movieSetToEdit.getArtworkUrl(MediaFileType.FANART)); } lblLogo.setImagePath(movieSetToEdit.getArtworkFilename(MediaFileType.LOGO)); lblClearlogo.setImagePath(movieSetToEdit.getArtworkFilename(MediaFileType.CLEARLOGO)); lblClearart.setImagePath(movieSetToEdit.getArtworkFilename(MediaFileType.CLEARART)); } initDataBindings(); // adjust table columns // name column tableMovies.getTableHeader().getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); // year column int width = tableMovies.getFontMetrics(tableMovies.getFont()).stringWidth(" 2000"); int titleWidth = tableMovies.getFontMetrics(tableMovies.getFont()) .stringWidth(BUNDLE.getString("metatag.year")); //$NON-NLS-1$ if (titleWidth > width) { width = titleWidth; } tableMovies.getTableHeader().getColumnModel().getColumn(1).setPreferredWidth(width); tableMovies.getTableHeader().getColumnModel().getColumn(1).setMinWidth(width); tableMovies.getTableHeader().getColumnModel().getColumn(1).setMaxWidth((int) (width * 1.5)); tableMovies.getTableHeader().getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.year")); // watched column tableMovies.getTableHeader().getColumnModel().getColumn(2).setPreferredWidth(70); tableMovies.getTableHeader().getColumnModel().getColumn(2).setMinWidth(70); tableMovies.getTableHeader().getColumnModel().getColumn(2).setMaxWidth(85); tableMovies.getTableHeader().getColumnModel().getColumn(2) .setHeaderValue(BUNDLE.getString("metatag.watched")); }
From source file:org.tinymediamanager.ui.moviesets.MovieSetInformationPanel.java
/** * Instantiates a new movie set information panel. * //from ww w . j a va 2s . c om * @param model * the model */ public MovieSetInformationPanel(MovieSetSelectionModel model) { this.selectionModel = model; movieEventList = new ObservableElementList<>( GlazedListsSwing.swingThreadProxyList(new BasicEventList<Movie>()), GlazedLists.beanConnector(Movie.class)); setLayout(new BorderLayout(0, 0)); panel = new JPanel(); add(panel, BorderLayout.CENTER); panel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("180px:grow"), ColumnSpec.decode("1px"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("pref:grow"), RowSpec.decode("bottom:default"), })); lblMovieSetName = new JLabel(""); TmmFontHelper.changeFont(lblMovieSetName, 1.5, Font.BOLD); panel.add(lblMovieSetName, "2,1, fill, fill"); layeredPane = new JLayeredPane(); panel.add(layeredPane, "1, 3, 2, 1, fill, fill"); layeredPane.setLayout(new FormLayout( new ColumnSpec[] { ColumnSpec.decode("10px"), ColumnSpec.decode("120px"), ColumnSpec.decode("200px:grow"), }, new RowSpec[] { RowSpec.decode("10px"), RowSpec.decode("180px"), RowSpec.decode("default:grow"), })); lblMovieSetPoster = new ImageLabel(); lblMovieSetPoster.setAlternativeText(BUNDLE.getString("image.notfound.poster")); //$NON-NLS-1$ lblMovieSetPoster.enableLightbox(); layeredPane.setLayer(lblMovieSetPoster, 1); layeredPane.add(lblMovieSetPoster, "2, 2, fill, fill"); lblMovieSetFanart = new ImageLabel(false, true); lblMovieSetFanart.setAlternativeText(BUNDLE.getString("image.notfound.fanart")); //$NON-NLS-1$ lblMovieSetFanart.enableLightbox(); layeredPane.add(lblMovieSetFanart, "1, 1, 3, 3, fill, fill"); panelSouth = new JSplitPane(); panelSouth.setContinuousLayout(true); panelSouth.setResizeWeight(0.5); add(panelSouth, BorderLayout.SOUTH); panelOverview = new JPanel(); panelSouth.setLeftComponent(panelOverview); panelOverview.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("100px:grow"), }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("24px:grow"), })); lblOverview = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$ panelOverview.add(lblOverview, "1, 2"); scrollPaneOverview = new JScrollPane(); panelOverview.add(scrollPaneOverview, "1, 4, fill, fill"); tpOverview = new JTextPane(); tpOverview.setEditable(false); scrollPaneOverview.setViewportView(tpOverview); JPanel panelMovies = new JPanel(); panelSouth.setRightComponent(panelMovies); panelMovies.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("200px:grow(3)"), }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("203px:grow"), })); movieTableModel = new DefaultEventTableModel<>(GlazedListsSwing.swingThreadProxyList(movieEventList), new MovieInMovieSetTableFormat()); // tableAssignedMovies = new JTable(movieTableModel); tableAssignedMovies = new ZebraJTable(movieTableModel); // JScrollPane scrollPaneMovies = new JScrollPane(); JScrollPane scrollPaneMovies = ZebraJTable.createStripedJScrollPane(tableAssignedMovies); panelMovies.add(scrollPaneMovies, "1, 2, fill, fill"); tableAssignedMovies.setPreferredScrollableViewportSize(new Dimension(450, 200)); scrollPaneMovies.setViewportView(tableAssignedMovies); initDataBindings(); // adjust table columns // year column int width = tableAssignedMovies.getFontMetrics(tableAssignedMovies.getFont()).stringWidth(" 2000"); int titleWidth = tableAssignedMovies.getFontMetrics(tableAssignedMovies.getFont()) .stringWidth(BUNDLE.getString("metatag.year")); //$NON-NLS-1$ if (titleWidth > width) { width = titleWidth; } tableAssignedMovies.getTableHeader().getColumnModel().getColumn(1).setPreferredWidth(width); tableAssignedMovies.getTableHeader().getColumnModel().getColumn(1).setMinWidth(width); tableAssignedMovies.getTableHeader().getColumnModel().getColumn(1).setMaxWidth((int) (width * 1.5)); // watched column tableAssignedMovies.getTableHeader().getColumnModel().getColumn(2).setPreferredWidth(70); tableAssignedMovies.getTableHeader().getColumnModel().getColumn(2).setMinWidth(70); tableAssignedMovies.getTableHeader().getColumnModel().getColumn(2).setMaxWidth(85); // install the propertychangelistener PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { String property = propertyChangeEvent.getPropertyName(); Object source = propertyChangeEvent.getSource(); // react on selection of a movie and change of media files if ((source.getClass() == MovieSetSelectionModel.class && "selectedMovieSet".equals(property)) || (source.getClass() == MovieSet.class && "movies".equals(property))) { movieEventList.clear(); movieEventList.addAll(selectionModel.getSelectedMovieSet().getMovies()); if (StringUtils.isNotBlank( selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.POSTER))) { lblMovieSetPoster.setImagePath( selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.POSTER)); } else { lblMovieSetPoster.setImagePath(""); lblMovieSetPoster.setImageUrl( selectionModel.getSelectedMovieSet().getArtworkUrl(MediaFileType.POSTER)); } if (StringUtils.isNotBlank( selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.FANART))) { lblMovieSetFanart.setImagePath( selectionModel.getSelectedMovieSet().getArtworkFilename(MediaFileType.FANART)); } else { lblMovieSetFanart.setImagePath(""); lblMovieSetFanart.setImageUrl( selectionModel.getSelectedMovieSet().getArtworkUrl(MediaFileType.FANART)); } } // react on changes of the images if ((source.getClass() == MovieSet.class && FANART.equals(property))) { MovieSet movieSet = (MovieSet) source; lblMovieSetFanart.clearImage(); lblMovieSetFanart.setImagePath(movieSet.getArtworkFilename(MediaFileType.FANART)); } if ((source.getClass() == MovieSet.class && POSTER.equals(property))) { MovieSet movieSet = (MovieSet) source; lblMovieSetPoster.clearImage(); lblMovieSetPoster.setImagePath(movieSet.getArtworkFilename(MediaFileType.POSTER)); } } }; selectionModel.addPropertyChangeListener(propertyChangeListener); }
From source file:org.tinymediamanager.ui.settings.FileTypesSettingsPanel.java
/** * Instantiates a new general settings panel. */// www . j av a2s . c o m public FileTypesSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("left:max(200px;min)"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(200px;default)"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(200px;default)"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(200px;default)"), }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("top:default"), FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("top:default"), FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); panelVideoFiletypes = new JPanel(); panelVideoFiletypes.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), //$NON-NLS-1$ BUNDLE.getString("Settings.videofiletypes"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); panelVideoFiletypes.setLayout(new FormLayout(new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("100px:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JScrollPane scrollPaneVideoFiletypes = new JScrollPane(); panelVideoFiletypes.add(scrollPaneVideoFiletypes, "2, 2, 5, 1, fill, fill"); listVideoFiletypes = new JList(); scrollPaneVideoFiletypes.setViewportView(listVideoFiletypes); tfVideoFiletype = new JTextField(); panelVideoFiletypes.add(tfVideoFiletype, "2, 4, fill, default"); tfVideoFiletype.setColumns(10); JButton btnAddVideoFiletype = new JButton(IconManager.LIST_ADD); btnAddVideoFiletype.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAddVideoFiletype.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (StringUtils.isNotEmpty(tfVideoFiletype.getText())) { Globals.settings.addVideoFileTypes(tfVideoFiletype.getText()); tfVideoFiletype.setText(""); } } }); panelVideoFiletypes.add(btnAddVideoFiletype, "4, 4"); add(panelVideoFiletypes, "2, 2, fill, fill"); JButton btnRemoveVideoFiletype = new JButton(IconManager.LIST_REMOVE); btnRemoveVideoFiletype.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemoveVideoFiletype.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listVideoFiletypes.getSelectedIndex(); if (row != -1) { String prefix = Globals.settings.getVideoFileType().get(row); Globals.settings.removeVideoFileType(prefix); } } }); panelVideoFiletypes.add(btnRemoveVideoFiletype, "6, 4, default, bottom"); panelSubtitleFiletypes = new JPanel(); add(panelSubtitleFiletypes, "4, 2, fill, fill"); panelSubtitleFiletypes.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), //$NON-NLS-1$ BUNDLE.getString("Settings.extrafiletypes"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); panelSubtitleFiletypes.setLayout(new FormLayout(new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("100px:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JScrollPane scrollPaneSubtitleFiletypes = new JScrollPane(); panelSubtitleFiletypes.add(scrollPaneSubtitleFiletypes, "2, 2, 5, 1, fill, fill"); listSubtitleFiletypes = new JList(); scrollPaneSubtitleFiletypes.setViewportView(listSubtitleFiletypes); tfSubtitleFiletype = new JTextField(); panelSubtitleFiletypes.add(tfSubtitleFiletype, "2, 4, fill, default"); tfSubtitleFiletype.setColumns(10); JButton btnAddSubtitleFiletype = new JButton(IconManager.LIST_ADD); btnAddSubtitleFiletype.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAddSubtitleFiletype.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (StringUtils.isNotEmpty(tfSubtitleFiletype.getText())) { Globals.settings.addSubtitleFileTypes(tfSubtitleFiletype.getText()); tfSubtitleFiletype.setText(""); } } }); panelSubtitleFiletypes.add(btnAddSubtitleFiletype, "4, 4"); JButton btnRemoveSubtitleFiletype = new JButton(IconManager.LIST_REMOVE); btnRemoveSubtitleFiletype.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemoveSubtitleFiletype.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listSubtitleFiletypes.getSelectedIndex(); if (row != -1) { String prefix = Globals.settings.getSubtitleFileType().get(row); Globals.settings.removeSubtitleFileType(prefix); } } }); panelSubtitleFiletypes.add(btnRemoveSubtitleFiletype, "6, 4, default, bottom"); panelAudioFiletypes = new JPanel(); add(panelAudioFiletypes, "6, 2, fill, fill"); panelAudioFiletypes.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), //$NON-NLS-1$ BUNDLE.getString("Settings.audiofiletypes"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); panelAudioFiletypes.setLayout(new FormLayout(new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("100px:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JScrollPane scrollPaneAudioFiletypes = new JScrollPane(); panelAudioFiletypes.add(scrollPaneAudioFiletypes, "2, 2, 5, 1, fill, fill"); listAudioFiletypes = new JList(); scrollPaneAudioFiletypes.setViewportView(listAudioFiletypes); tfAudioFiletype = new JTextField(); panelAudioFiletypes.add(tfAudioFiletype, "2, 4, fill, default"); tfAudioFiletype.setColumns(10); JButton btnAddAudioFiletype = new JButton(IconManager.LIST_ADD); btnAddAudioFiletype.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAddAudioFiletype.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (StringUtils.isNotEmpty(tfAudioFiletype.getText())) { Globals.settings.addAudioFileTypes(tfAudioFiletype.getText()); tfAudioFiletype.setText(""); } } }); panelAudioFiletypes.add(btnAddAudioFiletype, "4, 4"); JButton btnRemoveAudioFiletype = new JButton(IconManager.LIST_REMOVE); btnRemoveAudioFiletype.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemoveAudioFiletype.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listAudioFiletypes.getSelectedIndex(); if (row != -1) { String prefix = Globals.settings.getAudioFileType().get(row); Globals.settings.removeAudioFileType(prefix); } } }); panelAudioFiletypes.add(btnRemoveAudioFiletype, "6, 4, default, bottom"); JPanel panelSortOptions = new JPanel(); panelSortOptions.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("Settings.sorting"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$ add(panelSortOptions, "2, 4, 3, 1, fill, fill"); panelSortOptions.setLayout(new FormLayout(new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JScrollPane scrollPaneSortPrefixes = new JScrollPane(); panelSortOptions.add(scrollPaneSortPrefixes, "2, 2, 5, 1, fill, fill"); listSortPrefixes = new JList(); scrollPaneSortPrefixes.setViewportView(listSortPrefixes); tfSortPrefix = new JTextField(); panelSortOptions.add(tfSortPrefix, "2, 4, fill, default"); tfSortPrefix.setColumns(10); JButton btnAddSortPrefix = new JButton(IconManager.LIST_ADD); btnAddSortPrefix.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAddSortPrefix.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (StringUtils.isNotEmpty(tfSortPrefix.getText())) { Globals.settings.addTitlePrefix(tfSortPrefix.getText()); tfSortPrefix.setText(""); MovieList.getInstance().invalidateTitleSortable(); TvShowList.getInstance().invalidateTitleSortable(); } } }); panelSortOptions.add(btnAddSortPrefix, "4, 4"); JButton btnRemoveSortPrefix = new JButton(IconManager.LIST_REMOVE); btnRemoveSortPrefix.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemoveSortPrefix.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listSortPrefixes.getSelectedIndex(); if (row != -1) { String prefix = Globals.settings.getTitlePrefix().get(row); Globals.settings.removeTitlePrefix(prefix); MovieList.getInstance().invalidateTitleSortable(); TvShowList.getInstance().invalidateTitleSortable(); } } }); panelSortOptions.add(btnRemoveSortPrefix, "6, 4, default, bottom"); JTextPane tpSortingHints = new JTextPane(); TmmFontHelper.changeFont(tpSortingHints, 0.833); tpSortingHints.setText(BUNDLE.getString("Settings.sorting.info")); //$NON-NLS-1$ tpSortingHints.setBackground(UIManager.getColor("Panel.background")); panelSortOptions.add(tpSortingHints, "2, 6, 3, 1, fill, fill"); initDataBindings(); }
From source file:org.tinymediamanager.ui.settings.GeneralSettingsPanel.java
/** * Instantiates a new general settings panel. *///from w w w. j av a 2 s. c om public GeneralSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("left:max(200px;min):grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(200px;default):grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelUI = new JPanel(); panelUI.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.ui"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelUI, "2, 2, 3, 1, fill, fill"); panelUI.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); LocaleComboBox actualLocale = null; // cbLanguage = new JComboBox(Utils.getLanguages().toArray()); Locale settingsLang = Utils.getLocaleFromLanguage(Globals.settings.getLanguage()); for (Locale l : Utils.getLanguages()) { LocaleComboBox localeComboBox = new LocaleComboBox(l); locales.add(localeComboBox); if (l.equals(settingsLang)) { actualLocale = localeComboBox; } } JLabel lblUiLanguage = new JLabel(BUNDLE.getString("Settings.language")); panelUI.add(lblUiLanguage, "2, 2"); cbLanguage = new JComboBox(locales.toArray()); panelUI.add(cbLanguage, "4, 2"); if (actualLocale != null) { cbLanguage.setSelectedItem(actualLocale); } JSeparator separator = new JSeparator(); separator.setOrientation(SwingConstants.VERTICAL); panelUI.add(separator, "8, 2, 1, 7"); JLabel lblFontFamily = new JLabel(BUNDLE.getString("Settings.fontfamily")); //$NON-NLS-1$ panelUI.add(lblFontFamily, "10, 2, right, default"); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); cbFontFamily = new JComboBox(env.getAvailableFontFamilyNames()); cbFontFamily.setSelectedItem(Globals.settings.getFontFamily()); int index = cbFontFamily.getSelectedIndex(); if (index < 0) { cbFontFamily.setSelectedItem("Dialog"); index = cbFontFamily.getSelectedIndex(); } if (index < 0) { cbFontFamily.setSelectedIndex(0); } panelUI.add(cbFontFamily, "12, 2, fill, default"); JLabel lblFontSize = new JLabel(BUNDLE.getString("Settings.fontsize")); //$NON-NLS-1$ panelUI.add(lblFontSize, "10, 4, right, default"); cbFontSize = new JComboBox(DEFAULT_FONT_SIZES); cbFontSize.setSelectedItem(Globals.settings.getFontSize()); index = cbFontSize.getSelectedIndex(); if (index < 0) { cbFontSize.setSelectedIndex(0); } panelUI.add(cbFontSize, "12, 4, fill, default"); JPanel panel = new JPanel(); panelUI.add(panel, "2, 6, 5, 1, fill, fill"); panel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JLabel lblMissingTranslation = new JLabel(BUNDLE.getString("tmm.helptranslate")); panel.add(lblMissingTranslation, "1, 1, 5, 1"); lblLinkTransifex = new LinkLabel("https://www.transifex.com/projects/p/tinymediamanager/"); panel.add(lblLinkTransifex, "1, 3, 5, 1"); lblLinkTransifex.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { TmmUIHelper.browseUrl(lblLinkTransifex.getNormalText()); } catch (Exception e) { LOGGER.error(e.getMessage()); MessageManager.instance .pushMessage(new Message(MessageLevel.ERROR, lblLinkTransifex.getNormalText(), "message.erroropenurl", new String[] { ":", e.getLocalizedMessage() }));//$NON-NLS-2$ } } }); tpFontHint = new JTextPane(); tpFontHint.setOpaque(false); TmmFontHelper.changeFont(tpFontHint, 0.833); tpFontHint.setText(BUNDLE.getString("Settings.fonts.hint")); //$NON-NLS-1$ panelUI.add(tpFontHint, "10, 6, 5, 1"); lblLanguageHint = new JLabel(""); TmmFontHelper.changeFont(lblLanguageHint, Font.BOLD); panelUI.add(lblLanguageHint, "2, 8, 5, 1"); lblFontChangeHint = new JLabel(""); TmmFontHelper.changeFont(lblFontChangeHint, Font.BOLD); panelUI.add(lblFontChangeHint, "10, 8, 5, 1"); JPanel panelMemory = new JPanel(); panelMemory.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.memoryborder"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelMemory, "2, 4, fill, fill"); panelMemory.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow(4)"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(20dlu;default)"), ColumnSpec.decode("left:default:grow(5)"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, })); JLabel lblMemoryT = new JLabel(BUNDLE.getString("Settings.memory")); //$NON-NLS-1$ panelMemory.add(lblMemoryT, "2, 1"); sliderMemory = new JSlider(); sliderMemory.setPaintLabels(true); sliderMemory.setPaintTicks(true); sliderMemory.setSnapToTicks(true); sliderMemory.setMajorTickSpacing(512); sliderMemory.setMinorTickSpacing(128); sliderMemory.setMinimum(256); sliderMemory.setMaximum(1536); sliderMemory.setValue(512); panelMemory.add(sliderMemory, "4, 1, fill, default"); lblMemory = new JLabel("512"); //$NON-NLS-1$ panelMemory.add(lblMemory, "6, 1, right, default"); JLabel lblMb = new JLabel("MB"); panelMemory.add(lblMb, "7, 1, left, default"); tpMemoryHint = new JTextPane(); tpMemoryHint.setOpaque(false); tpMemoryHint.setText(BUNDLE.getString("Settings.memory.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(tpMemoryHint, 0.833); panelMemory.add(tpMemoryHint, "2, 3, 6, 1, fill, fill"); JPanel panelProxySettings = new JPanel(); panelProxySettings.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.proxy"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelProxySettings, "4, 4, fill, fill"); panelProxySettings.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, })); JLabel lblProxyHost = new JLabel(BUNDLE.getString("Settings.proxyhost")); //$NON-NLS-1$ panelProxySettings.add(lblProxyHost, "2, 2, right, default"); tfProxyHost = new JTextField(); lblProxyHost.setLabelFor(tfProxyHost); panelProxySettings.add(tfProxyHost, "4, 2, fill, default"); tfProxyHost.setColumns(10); JLabel lblProxyPort = new JLabel(BUNDLE.getString("Settings.proxyport")); //$NON-NLS-1$ panelProxySettings.add(lblProxyPort, "2, 4, right, default"); tfProxyPort = new JTextField(); lblProxyPort.setLabelFor(tfProxyPort); panelProxySettings.add(tfProxyPort, "4, 4, fill, default"); tfProxyPort.setColumns(10); JLabel lblProxyUser = new JLabel(BUNDLE.getString("Settings.proxyuser")); //$NON-NLS-1$ panelProxySettings.add(lblProxyUser, "2, 6, right, default"); tfProxyUsername = new JTextField(); lblProxyUser.setLabelFor(tfProxyUsername); panelProxySettings.add(tfProxyUsername, "4, 6, fill, default"); tfProxyUsername.setColumns(10); JLabel lblProxyPassword = new JLabel(BUNDLE.getString("Settings.proxypass")); //$NON-NLS-1$ panelProxySettings.add(lblProxyPassword, "2, 8, right, default"); tfProxyPassword = new JPasswordField(); lblProxyPassword.setLabelFor(tfProxyPassword); panelProxySettings.add(tfProxyPassword, "4, 8, fill, default"); JPanel panelMediaPlayer = new JPanel(); panelMediaPlayer.setBorder( new TitledBorder(null, "MediaPlayer", TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelMediaPlayer, "2, 6, fill, fill"); panelMediaPlayer.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); tpMediaPlayer = new JTextPane(); tpMediaPlayer.setOpaque(false); TmmFontHelper.changeFont(tpMediaPlayer, 0.833); tpMediaPlayer.setText(BUNDLE.getString("Settings.mediaplayer.hint")); //$NON-NLS-1$ panelMediaPlayer.add(tpMediaPlayer, "2, 2, 3, 1, fill, fill"); tfMediaPlayer = new JTextField(); panelMediaPlayer.add(tfMediaPlayer, "2, 4, fill, default"); tfMediaPlayer.setColumns(10); btnSearchMediaPlayer = new JButton(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$ btnSearchMediaPlayer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Path file = TmmUIHelper.selectFile(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$ if (file != null && Utils.isRegularFile(file) || Platform.isMac()) { tfMediaPlayer.setText(file.toAbsolutePath().toString()); } } }); panelMediaPlayer.add(btnSearchMediaPlayer, "4, 4"); JPanel panelCache = new JPanel(); panelCache.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.cache"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelCache, "4, 6, fill, fill"); panelCache.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); chckbxImageCache = new JCheckBox(BUNDLE.getString("Settings.imagecache"));//$NON-NLS-1$ panelCache.add(chckbxImageCache, "2, 2, 3, 1"); JLabel lblImageCacheQuality = new JLabel(BUNDLE.getString("Settings.imagecachetype"));//$NON-NLS-1$ panelCache.add(lblImageCacheQuality, "2, 4, right, default"); cbImageCacheQuality = new JComboBox(ImageCache.CacheType.values()); panelCache.add(cbImageCacheQuality, "4, 4, fill, default"); JPanel panelAnalytics = new JPanel(); panelAnalytics.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.analytics.border"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelAnalytics, "2, 8, fill, fill"); panelAnalytics.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, })); chckbxAnalytics = new JCheckBox(BUNDLE.getString("Settings.analytics"));//$NON-NLS-1$ panelAnalytics.add(chckbxAnalytics, "2, 2"); JTextPane tpAnalyticsDescription = new JTextPane(); tpAnalyticsDescription.setText(BUNDLE.getString("Settings.analytics.desc"));//$NON-NLS-1$ tpAnalyticsDescription.setOpaque(false); panelAnalytics.add(tpAnalyticsDescription, "2, 4, fill, fill"); JPanel panelMisc = new JPanel(); panelMisc.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.misc"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelMisc, "4, 8, fill, fill"); panelMisc.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, })); chckbxDeleteTrash = new JCheckBox(BUNDLE.getString("Settings.deletetrash")); panelMisc.add(chckbxDeleteTrash, "2, 2, 3, 1"); initDataBindings(); initMemorySlider(); // listen to changes of the combo box ItemListener listener = new ItemListener() { public void itemStateChanged(ItemEvent e) { checkChanges(); } }; cbLanguage.addItemListener(listener); cbFontSize.addItemListener(listener); cbFontFamily.addItemListener(listener); }