Example usage for javax.swing UIManager getBorder

List of usage examples for javax.swing UIManager getBorder

Introduction

In this page you can find the example usage for javax.swing UIManager getBorder.

Prototype

public static Border getBorder(Object key) 

Source Link

Document

Returns a border from the defaults.

Usage

From source file:org.tinymediamanager.ui.movies.settings.MovieScraperSettingsPanel.java

/**
 * Instantiates a new movie scraper settings panel.
 *//*from w ww  . j av  a2  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.MovieSubtitleSettingsPanel.java

private void initComponents() {
    // data init/*  w w  w . j a v a2  s.co 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  w  w  w . java 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.settings.FileTypesSettingsPanel.java

/**
 * Instantiates a new general settings panel.
 *//*from  w w w. j a v  a  2s . 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.tvshows.settings.TvShowScraperSettingsPanel.java

/**
 * Instantiates a new movie scraper settings panel.
 *///from w w  w  .jav a  2  s  . c  o  m
public TvShowScraperSettingsPanel() {
    // data init
    MediaScraper defaultMediaScraper = TvShowList.getInstance().getDefaultMediaScraper();
    int selectedIndex = 0;
    int counter = 0;
    for (MediaScraper scraper : TvShowList.getInstance().getAvailableMediaScrapers()) {
        TvShowScraper tvShowScraper = new TvShowScraper(scraper);
        if (scraper.equals(defaultMediaScraper)) {
            tvShowScraper.defaultScraper = true;
            selectedIndex = counter;
        }
        scrapers.add(tvShowScraper);
        counter++;
    }
    List<String> enabledArtworkProviders = settings.getTvShowArtworkScrapers();
    int artworkSelectedIndex = -1;
    int counterAW = 0;
    for (MediaScraper scraper : TvShowList.getInstance().getAvailableArtworkScrapers()) {
        ArtworkScraper artworkScraper = new ArtworkScraper(scraper);
        if (enabledArtworkProviders.contains(artworkScraper.getScraperId())) {
            artworkScraper.active = true;
            if (artworkSelectedIndex < 0) {
                artworkSelectedIndex = counterAW;
            }
        }
        artworkScrapers.add(artworkScraper);
        counterAW++;
    }
    // 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, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, }));
    JPanel panelTvShowScrapers = new JPanel();
    panelTvShowScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"),
            BUNDLE.getString("scraper.metadata.defaults"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$
    add(panelTvShowScrapers, "2, 2, fill, top");
    panelTvShowScrapers.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), },
            new RowSpec[] { FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"),
                    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, }));

    scrollPaneScraper = new JScrollPane();
    panelTvShowScrapers.add(scrollPaneScraper, "1, 2, 3, 1, fill, fill");

    tableScraper = new JTable();
    tableScraper.setRowHeight(29);
    scrollPaneScraper.setViewportView(tableScraper);

    scrollPaneScraperDetails = new JScrollPane();
    scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPaneScraperDetails.setBorder(null);
    panelTvShowScrapers.add(scrollPaneScraperDetails, "5, 2, fill, fill");

    panelScraperDetails = new ScrollablePanel();
    scrollPaneScraperDetails.setViewportView(panelScraperDetails);
    panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("200dlu: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 JPanel();
    panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT));
    panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top");

    JSeparator separator = new JSeparator();
    panelTvShowScrapers.add(separator, "1, 4, 5, 1");

    JLabel lblScraperLanguage = new JLabel(BUNDLE.getString("Settings.preferredLanguage")); //$NON-NLS-1$
    panelTvShowScrapers.add(lblScraperLanguage, "1, 6, right, default");

    cbScraperTmdbLanguage = new JComboBox(MediaLanguages.values());
    panelTvShowScrapers.add(cbScraperTmdbLanguage, "3, 6");

    JLabel lblCountry = new JLabel(BUNDLE.getString("Settings.certificationCountry")); //$NON-NLS-1$
    panelTvShowScrapers.add(lblCountry, "1, 8, right, default");

    cbCountry = new JComboBox(CountryCode.values());
    panelTvShowScrapers.add(cbCountry, "3, 8, fill, default");

    btnGroupThumbFilenaming = new ButtonGroup();

    panelArtworkScrapers = new JPanel();
    panelArtworkScrapers.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.images"), //$NON-NLS-1$
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panelArtworkScrapers, "2, 4, fill, fill");
    panelArtworkScrapers.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.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("80dlu:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, }));

    scrollPaneArtworkScraper = new JScrollPane();
    panelArtworkScrapers.add(scrollPaneArtworkScraper, "2, 2, fill, fill");

    tableArtworkScraper = new JTable();
    tableArtworkScraper.setRowHeight(29);
    scrollPaneArtworkScraper.setViewportView(tableArtworkScraper);

    scrollPaneArtworkScraperDetails = new JScrollPane();
    scrollPaneArtworkScraperDetails.setBorder(null);
    panelArtworkScrapers.add(scrollPaneArtworkScraperDetails, "4, 2, fill, fill");

    panelArtworkScraperDetails = new JPanel();
    scrollPaneArtworkScraperDetails.setViewportView(panelArtworkScraperDetails);
    panelArtworkScraperDetails.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"), },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), }));

    tpArtworkScraperDescription = new JTextPane();
    tpArtworkScraperDescription.setEditorKit(new HTMLEditorKit());
    ((HTMLDocument) tpArtworkScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule);
    tpArtworkScraperDescription.setOpaque(false);
    panelArtworkScraperDetails.add(tpArtworkScraperDescription, "2, 2, fill, fill");

    panelArtworkScraperOptions = new JPanel();
    panelArtworkScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT));
    panelArtworkScraperDetails.add(panelArtworkScraperOptions, "2, 4, fill, fill");

    separator = new JSeparator();
    panelArtworkScrapers.add(separator, "2, 4, 3, 1");

    panelImages = new JPanel();
    panelArtworkScrapers.add(panelImages, "2, 6, 3, 1, fill, fill");
    panelImages.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, ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("23px"), }));

    lblNewLabel = new JLabel(BUNDLE.getString("image.thumb.naming"));
    panelImages.add(lblNewLabel, "1, 1, left, center");
    rdbtnThumbWithPostfix = new JRadioButton("<dynamic>-thumb.ext");
    panelImages.add(rdbtnThumbWithPostfix, "3, 1, fill, top");
    btnGroupThumbFilenaming.add(rdbtnThumbWithPostfix);
    rdbtnThumbTbn = new JRadioButton("<dynamic>.tbn");
    btnGroupThumbFilenaming.add(rdbtnThumbTbn);
    rdbtnThumbWoPostfix = new JRadioButton("<dynamic>.ext");
    panelImages.add(rdbtnThumbWoPostfix, "5, 1, fill, top");
    btnGroupThumbFilenaming.add(rdbtnThumbWoPostfix);
    panelImages.add(rdbtnThumbTbn, "7, 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, 6, fill, top");
    panelScraperMetadataContainer.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
            new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
                    FormFactory.DEFAULT_ROWSPEC, }));

    panelScraperMetadata = new TvShowScraperMetadataPanel(
            Settings.getInstance().getTvShowScraperMetadataConfig());
    panelScraperMetadataContainer.add(panelScraperMetadata, "1, 1, 2, 1, fill, default");

    chckbxAutomaticallyScrapeImages = new JCheckBox(BUNDLE.getString("Settings.default.autoscrape")); //$NON-NLS-1$
    panelScraperMetadataContainer.add(chckbxAutomaticallyScrapeImages, "2, 3");

    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);

        TableColumnResizer.setMaxWidthForColumn(tableArtworkScraper, 0, 2);
        TableColumnResizer.setMaxWidthForColumn(tableArtworkScraper, 1, 2);
        TableColumnResizer.adjustColumnPreferredWidths(tableArtworkScraper, 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();
                    TvShowScraper changedScraper = scrapers.get(row);
                    // if flag inNFO was changed, change all other trailers flags
                    if (changedScraper.getDefaultScraper()) {
                        settings.setTvShowScraper(changedScraper.getScraperId());
                        for (TvShowScraper 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();
                }
            }
        });

        tableArtworkScraper.getModel().addTableModelListener(new TableModelListener() {
            @Override
            public void tableChanged(TableModelEvent arg0) {
                // click on the checkbox
                if (arg0.getColumn() == 0) {
                    int row = arg0.getFirstRow();
                    ArtworkScraper changedScraper = artworkScrapers.get(row);
                    if (changedScraper.active) {
                        settings.addTvShowArtworkScraper(changedScraper.getScraperId());
                    } else {
                        settings.removeTvShowArtworkScraper(changedScraper.getScraperId());
                    }
                }
            }
        });
        // implement selection listener to load settings
        tableArtworkScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                int index = tableArtworkScraper.convertRowIndexToModel(tableArtworkScraper.getSelectedRow());
                if (index > -1) {
                    panelArtworkScraperOptions.removeAll();
                    if (artworkScrapers.get(index).getMediaProvider().getProviderInfo().getConfig()
                            .hasConfig()) {
                        panelArtworkScraperOptions.add(new MediaScraperConfigurationPanel(
                                artworkScrapers.get(index).getMediaProvider()));
                    }
                    panelArtworkScraperOptions.revalidate();
                }
            }
        });

        // select default TV show scraper
        if (counter > 0) {
            tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
        }

        // select default artwork scraper
        if (counterAW > 0) {
            tableArtworkScraper.getSelectionModel().setSelectionInterval(artworkSelectedIndex,
                    artworkSelectedIndex);
        }

        ItemListener itemListener = new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                checkChanges();
            }
        };

        rdbtnThumbWoPostfix.addItemListener(itemListener);
        rdbtnThumbWithPostfix.addItemListener(itemListener);
        rdbtnThumbTbn.addItemListener(itemListener);

        switch (settings.getTvShowEpisodeThumbFilename()) {
        case FILENAME_THUMB_POSTFIX:
            rdbtnThumbWithPostfix.setSelected(true);
            break;

        case FILENAME_THUMB:
            rdbtnThumbWoPostfix.setSelected(true);
            break;

        case FILENAME_THUMB_TBN:
            rdbtnThumbTbn.setSelected(true);
            break;

        default:
            break;
        }
    }
}

From source file:org.tinymediamanager.ui.tvshows.settings.TvShowSubtitleSettingsPanel.java

private void initComponents() {
    // data init//  w  w  w  . ja  v a2s  .  c  o  m
    List<String> enabledSubtitleProviders = settings.getTvShowSubtitleScrapers();
    int selectedIndex = -1;
    int counter = 0;
    for (MediaScraper scraper : TvShowList.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.addTvShowSubtitleScraper(changedScraper.getScraperId());
                } else {
                    settings.removeTvShowSubtitleScraper(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 tv show subtitle scraper
    if (selectedIndex < 0) {
        selectedIndex = 0;
    }
    if (counter > 0) {
        tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
    }
}

From source file:org.ut.biolab.medsavant.MedSavantClient.java

private static void customizeForMac() {

    try {/*ww  w. j a v a2  s. c o m*/

        UIManager.put("Panel.background", new Color(237, 237, 237)); // the above line makes the bg dark, setting back

        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "MedSavant");

        batchApplyProperty(new String[] { "Button.font", "ToggleButton.font", "RadioButton.font",
                "CheckBox.font", "ColorChooser.font", "ComboBox.font", "Label.font", "List.font",
                "MenuBar.font", "MenuItem.font", "RadioButtonMenuItem.font", "CheckBoxMenuItem.font",
                "Menu.font", "PopupMenu.font", "OptionPane.font", "Panel.font", "ProgressBar.font",
                "ScrollPane.font", "Viewport.font", "TabbedPane.font", "Table.font", "TableHeader.font",
                "TextField.font", "PasswordField.font", "TextArea.font", "TextPane.font", "EditorPane.font",
                "TitledBorder.font", "ToolBar.font", "ToolTip.font", "Tree.font", "JOptionPane.font",
                "JDialog.font" }, FontFactory.getGeneralFont());

        System.setProperty("awt.useSystemAAFontSettings", "on");
        System.setProperty("swing.aatext", "true");

        UIManager.put("TitledBorder.border", UIManager.getBorder("TitledBorder.aquaVariant"));
        //com.apple.eawt.FullScreenUtilities.setWindowCanFullScreen(this, true);
        Application macOSXApplication = Application.getApplication();
        macOSXApplication.setAboutHandler(new AboutHandler() {
            @Override
            public void handleAbout(AppEvent.AboutEvent evt) {
                JOptionPane.showMessageDialog(MedSavantFrame.getInstance(), "MedSavant "
                        + VersionSettings.getVersionString() + "\nCreated by Biolab at University of Toronto.");
            }
        });
        macOSXApplication.setPreferencesHandler(new PreferencesHandler() {
            @Override
            public void handlePreferences(AppEvent.PreferencesEvent pe) {
                DialogUtils.displayMessage("Preferences available for Administrators only");
            }
        });
        macOSXApplication.setQuitHandler(new QuitHandler() {
            @Override
            public void handleQuitRequestWith(AppEvent.QuitEvent evt, QuitResponse resp) {
                MedSavantFrame.getInstance().requestClose();
                resp.cancelQuit(); // If user accepted close request, System.exit() was called and we never get here.
            }
        });
    } catch (Throwable x) {
        System.err.println(
                "Warning: MedSavant requires Java for Mac OS X 10.6 Update 3 (or later).\nPlease check Software Update for the latest version.");
    }
}

From source file:uk.ac.babraham.BamQC.Graphs.ScatterGraph.java

private void initialise(double[] data, double[] xCategories, String[] toolTipLabels, String xLabel,
        String yLabel, String graphTitle) {
    this.data = data;
    this.xCategories = xCategories;
    this.toolTipLabels = toolTipLabels;
    this.xLabel = xLabel;
    this.yLabel = yLabel;
    this.graphTitle = graphTitle;

    // calculate minX-maxX, minY-maxY and xInterval-yInterval
    double[] minmax = new double[] { Double.MAX_VALUE, Double.MIN_VALUE };
    calculateMinMax(this.data, minmax);
    minY = minmax[0];/*from  www. ja  va 2  s  . c o  m*/
    maxY = minmax[1] + minmax[1] * 0.1; // let's give some extra 10% space
    yInterval = findOptimalYInterval(maxY);

    minmax = new double[] { Double.MAX_VALUE, Double.MIN_VALUE };
    calculateMinMax(this.xCategories, minmax);
    minX = minmax[0];
    maxX = minmax[1] + minmax[1] * 0.1; // let's give some extra 10% space
    xInterval = findOptimalYInterval(maxX);

    // TOOL TIPS management
    label.setHorizontalAlignment(JLabel.CENTER);
    label.setOpaque(true);
    label.setBackground(Color.WHITE);
    label.setBorder(UIManager.getBorder("ToolTip.border"));
    if (!GraphicsEnvironment.isHeadless()) {
        toolTip = new JWindow();
        toolTip.add(label);
        // Tool tips
        tipster = new Tipster(this);
        addMouseMotionListener(tipster);
    }
    setOpaque(true);
}