Example usage for javax.swing JTextPane setBackground

List of usage examples for javax.swing JTextPane setBackground

Introduction

In this page you can find the example usage for javax.swing JTextPane setBackground.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.")
public void setBackground(Color bg) 

Source Link

Document

Sets the background color of this component.

Usage

From source file:org.drugis.addis.gui.wizard.AddStudyWizard.java

private static JComponent buildTip(String tip) {
    JTextPane area = new JTextPane();
    StyledDocument doc = area.getStyledDocument();
    addStylesToDoc(doc);//w  w  w .  ja  va  2  s  .  co  m

    area.setBackground(new Color(255, 180, 180));

    try {
        doc.insertString(0, "x", doc.getStyle("tip"));
        doc.insertString(doc.getLength(), " Tip: \n", doc.getStyle("bold"));
        doc.insertString(doc.getLength(), tip, doc.getStyle("regular"));
    } catch (BadLocationException e) {
        e.printStackTrace();
    }

    area.setEditable(false);

    JScrollPane pane = new JScrollPane(area);
    pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    pane.setPreferredSize(TextComponentFactory.textPaneDimension(area, 270, 70));

    pane.setWheelScrollingEnabled(true);
    pane.getVerticalScrollBar().setValue(0);

    return pane;
}

From source file:org.echocat.velma.dialogs.AboutDialog.java

protected void createIntroduction(@Nonnull Resources resources) {
    final URL iconUrl = resources.getIconUrl(48);

    final StringBuilder body = new StringBuilder();
    body.append("<html>");
    body.append("<head><style>" + "td { margin-right: 10px; }" + "</style></head>");
    body.append("<body style='font-family: sans; font-size: 1em'><table><tr>");
    body.append("<td valign='top'><img src='").append(iconUrl).append("' /></td>");
    body.append("<td valign='top'>");
    body.append("<h2>").append(escapeHtml4(resources.getApplicationName()));
    final String version = resources.getVersion();
    if (!isEmpty(version)) {
        body.append("<br/><span style='font-size: 0.6em'>")
                .append(resources.formatEscaped("versionText", version)).append("</span>");
    }/*  w w  w .  ja v  a  2  s  .  c  o m*/
    body.append("</h2>");

    body.append("<p>Copyright 2011-2012 <a href='https://echocat.org'>echocat</a></p>");
    body.append("<p><a href='http://mozilla.org/MPL/2.0/'>")
            .append(resources.formatEscaped("licensedUnder", "MPL 2.0")).append("</a></p>");

    body.append("<p><table cellpadding='0' cellspacing='0'>");
    body.append("<tr><td>").append(resources.formatEscaped("xHomepage", "echocat"))
            .append(":</td><td><a href='https://echocat.org'>echocat.org</a></td></tr>");
    body.append("<tr><td>").append(resources.formatEscaped("xHomepage", "Velma"))
            .append(":</td><td><a href='https://velma.echocat.org'>velma.echocat.org</a></td></tr>");
    body.append("</table></p>");

    body.append("<h4>").append(resources.formatEscaped("developers"))
            .append("</h4><table cellpadding='0' cellspacing='0'>");
    body.append(
            "<tr><td>Gregor Noczinski</td><td><a href='mailto:gregor@noczinski.eu'>gregor@noczinski.eu</a></td><td><a href='https://github.com/blaubaer'>github.com/blaubaer</a></td></tr>");
    body.append("</table>");

    body.append("</td>");
    body.append("</tr></table></body></html>");

    final JTextPane text = new JTextPane();
    text.setMargin(new Insets(0, 0, 0, 0));
    text.setContentType("text/html");
    text.setText(body.toString());
    text.setFont(new Font(DIALOG, PLAIN, 12));
    text.setBackground(new Color(255, 255, 255, 0));
    text.setEditable(false);
    text.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == ACTIVATED && isDesktopSupported()) {
                final Desktop desktop = getDesktop();
                if (desktop.isSupported(BROWSE)) {
                    try {
                        desktop.browse(e.getURL().toURI());
                    } catch (IOException | URISyntaxException exception) {
                        LOG.error("Could not open " + e.getURL() + " because of an exception.", exception);
                    }
                } else {
                    LOG.error("Could not open " + e.getURL() + " because browse is not supported by desktop.");
                }
            }
            repaint();
        }
    });
    text.addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            repaint();
        }

        @Override
        public void mousePressed(MouseEvent e) {
            repaint();
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            repaint();
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            repaint();
        }

        @Override
        public void mouseExited(MouseEvent e) {
            repaint();
        }
    });
    add(text, new CC().spanX(2).growX().minWidth("10px"));
}

From source file:org.languagetool.gui.Tools.java

static void showRuleInfoDialog(Component parent, String title, String message, Rule rule, URL matchUrl,
        ResourceBundle messages, String lang) {
    int dialogWidth = 320;
    JTextPane textPane = new JTextPane();
    textPane.setEditable(false);/*  w  w w .  j a v  a 2s .c  om*/
    textPane.setContentType("text/html");
    textPane.setBorder(BorderFactory.createEmptyBorder());
    textPane.setOpaque(false);
    textPane.setBackground(new Color(0, 0, 0, 0));
    Tools.addHyperlinkListener(textPane);
    textPane.setSize(dialogWidth, Short.MAX_VALUE);
    String messageWithBold = message.replaceAll("<suggestion>", "<b>").replaceAll("</suggestion>", "</b>");
    String exampleSentences = getExampleSentences(rule, messages);
    String url = "http://community.languagetool.org/rule/show/" + encodeUrl(rule) + "?lang=" + lang
            + "&amp;ref=standalone-gui";
    boolean isExternal = rule.getCategory().getLocation() == Category.Location.EXTERNAL;
    String ruleDetailLink = rule instanceof FalseFriendPatternRule || isExternal ? ""
            : "<a href='" + url + "'>" + messages.getString("ruleDetailsLink") + "</a>";
    textPane.setText("<html>" + messageWithBold + exampleSentences + formatURL(matchUrl) + "<br><br>"
            + ruleDetailLink + "</html>");
    JScrollPane scrollPane = new JScrollPane(textPane);
    scrollPane.setPreferredSize(new Dimension(dialogWidth, textPane.getPreferredSize().height));
    scrollPane.setBorder(BorderFactory.createEmptyBorder());

    String cleanTitle = title.replace("<suggestion>", "'").replace("</suggestion>", "'");
    JOptionPane.showMessageDialog(parent, scrollPane, cleanTitle, JOptionPane.INFORMATION_MESSAGE);
}

From source file:org.nebulaframework.ui.swing.node.NodeMainUI.java

/**
 * Setup General (Control Center) Tab/*from   w  w w .ja  v a 2s  .  c  o m*/
 * 
 * @return JPanel for Control Center
 */
private JPanel setupGeneral() {

    JPanel generalPanel = new JPanel();
    generalPanel.setLayout(new BorderLayout());

    /* -- Stats Panel -- */
    JPanel statsPanel = new JPanel();
    generalPanel.add(statsPanel, BorderLayout.NORTH);

    statsPanel.setLayout(new GridLayout(0, 2, 10, 10));

    JPanel eastPanel = new JPanel();
    statsPanel.add(eastPanel, BorderLayout.EAST);
    eastPanel.setLayout(new BorderLayout());

    JPanel westPanel = new JPanel();
    statsPanel.add(westPanel, BorderLayout.WEST);
    westPanel.setLayout(new BorderLayout());

    // Grid Information Panel
    JPanel gridInfoPanel = new JPanel();
    eastPanel.add(gridInfoPanel, BorderLayout.NORTH);

    gridInfoPanel.setBorder(BorderFactory.createTitledBorder("Grid Information"));
    gridInfoPanel.setLayout(new GridLayout(0, 2, 10, 10));

    JLabel nodeIdLabel = new JLabel("Node ID :");
    gridInfoPanel.add(nodeIdLabel);
    JLabel nodeId = new JLabel("#nodeid#");
    gridInfoPanel.add(nodeId);
    addUIElement("general.stats.nodeid", nodeId); // Add to components map

    JLabel nodeIpLabel = new JLabel("Node IP :");
    gridInfoPanel.add(nodeIpLabel);
    JLabel nodeIp = new JLabel("#nodeip#");
    gridInfoPanel.add(nodeIp);
    addUIElement("general.stats.nodeip", nodeIp); // Add to components map

    JLabel clusterIdLabel = new JLabel("Cluster ID :");
    gridInfoPanel.add(clusterIdLabel);
    JLabel clusterId = new JLabel("#clusterid#");
    gridInfoPanel.add(clusterId);
    addUIElement("general.stats.clusterid", clusterId); // Add to components map

    JLabel clusterServiceLabel = new JLabel("Cluster Service :");
    gridInfoPanel.add(clusterServiceLabel);
    JLabel clusterService = new JLabel("#clusterservice#");
    gridInfoPanel.add(clusterService);
    addUIElement("general.stats.clusterservice", clusterService); // Add to components map

    // Node Status Panel 
    JPanel nodeStatusPanel = new JPanel();
    eastPanel.add(nodeStatusPanel, BorderLayout.SOUTH);

    nodeStatusPanel.setBorder(BorderFactory.createTitledBorder("GridNode Status"));
    nodeStatusPanel.setLayout(new GridLayout(0, 2, 10, 10));

    JLabel statusLabel = new JLabel("Status :");
    nodeStatusPanel.add(statusLabel);
    JLabel status = new JLabel("#status#");
    nodeStatusPanel.add(status);
    addUIElement("general.stats.status", status); // Add to components map

    JLabel uptimeLabel = new JLabel("Node Up Time :");
    nodeStatusPanel.add(uptimeLabel);
    JLabel uptime = new JLabel("#uptime#");
    nodeStatusPanel.add(uptime);
    addUIElement("general.stats.uptime", uptime); // Add to components map

    JLabel execTimeLabel = new JLabel("Execution Time :");
    nodeStatusPanel.add(execTimeLabel);
    JLabel execTime = new JLabel("#exectime#");
    nodeStatusPanel.add(execTime);
    addUIElement("general.stats.exectime", execTime); // Add to components map

    // Execution Statistics Panel
    JPanel execStatsPanel = new JPanel();
    westPanel.add(execStatsPanel, BorderLayout.NORTH);

    execStatsPanel.setLayout(new GridLayout(0, 2, 10, 10));
    execStatsPanel.setBorder(BorderFactory.createTitledBorder("Execution Statistics"));

    JLabel totalJobsLabel = new JLabel("Total Jobs :");
    execStatsPanel.add(totalJobsLabel);
    JLabel totalJobs = new JLabel("0");
    execStatsPanel.add(totalJobs);
    addUIElement("general.stats.totaljobs", totalJobs); // Add to components map

    JLabel totalTasksLabel = new JLabel("Total Tasks :");
    execStatsPanel.add(totalTasksLabel);
    JLabel totalTasks = new JLabel("0");
    execStatsPanel.add(totalTasks);
    addUIElement("general.stats.totaltasks", totalTasks); // Add to components map

    JLabel totalBansLabel = new JLabel("Banments :");
    execStatsPanel.add(totalBansLabel);
    JLabel totalBans = new JLabel("0");
    execStatsPanel.add(totalBans);
    addUIElement("general.stats.totalbans", totalBans); // Add to components map

    // Execution Active Job Panel
    JPanel activeJobPanel = new JPanel();
    westPanel.add(activeJobPanel, BorderLayout.SOUTH);

    activeJobPanel.setLayout(new GridLayout(0, 2, 10, 10));
    activeJobPanel.setBorder(BorderFactory.createTitledBorder("Active Job"));

    JLabel jobNameLabel = new JLabel("GridJob Name :");
    activeJobPanel.add(jobNameLabel);
    JLabel jobName = new JLabel("#jobname#");
    activeJobPanel.add(jobName);
    addUIElement("general.stats.jobname", jobName); // Add to components map

    JLabel durationLabel = new JLabel("Duration :");
    activeJobPanel.add(durationLabel);
    JLabel duration = new JLabel("#duration#");
    activeJobPanel.add(duration);
    addUIElement("general.stats.duration", duration); // Add to components map

    JLabel tasksLabel = new JLabel("Tasks Executed :");
    activeJobPanel.add(tasksLabel);
    JLabel tasks = new JLabel("#xyz#");
    activeJobPanel.add(tasks);
    addUIElement("general.stats.tasks", tasks); // Add to components map

    JLabel failuresLabel = new JLabel("Failures :");
    activeJobPanel.add(failuresLabel);
    JLabel failures = new JLabel("#failures#");
    activeJobPanel.add(failures);
    addUIElement("general.stats.failures", failures); // Add to components map

    /* -- Log Panel -- */
    JPanel logPanel = new JPanel();
    generalPanel.add(logPanel, BorderLayout.CENTER);

    logPanel.setLayout(new BorderLayout());
    logPanel.setBorder(BorderFactory.createTitledBorder("Log Output"));
    JTextPane logTextPane = new JTextPane();
    logTextPane.setEditable(false);
    logTextPane.setBackground(Color.BLACK);
    logTextPane.setForeground(Color.WHITE);

    logPanel.add(new JScrollPane(logTextPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
    addUIElement("general.log", logTextPane); // Add to component map

    JPanel logOptionsPanel = new JPanel();
    logPanel.add(logOptionsPanel, BorderLayout.SOUTH);
    logOptionsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    final JCheckBox logScrollCheckbox = new JCheckBox("Auto-Scroll Log");
    logScrollCheckbox.setSelected(true);
    logScrollCheckbox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JTextPaneAppender.setAutoScroll(logScrollCheckbox.isSelected());
        }

    });
    logOptionsPanel.add(logScrollCheckbox);

    // Enable Logging
    JTextPaneAppender.setTextPane(logTextPane);

    /* -- Buttons Panel -- */
    JPanel buttonsPanel = new JPanel();
    generalPanel.add(buttonsPanel, BorderLayout.SOUTH);

    buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    // Shutdown Button
    JButton shutdownButton = new JButton("Shutdown");
    buttonsPanel.add(shutdownButton);
    shutdownButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            doShutdownNode();
        }

    });

    // Start Up time Thread
    Thread t = new Thread(new Runnable() {
        public void run() {

            long start = System.currentTimeMillis();

            while (true) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    log.warn("Interrupted Exception in Up Time Thread", e);
                }

                final String uptime = TimeUtils.timeDifference(start);

                SwingUtilities.invokeLater(new Runnable() {

                    public void run() {
                        JLabel upTime = getUIElement("general.stats.uptime");
                        upTime.setText(uptime);
                    }

                });
            }

        }
    });
    t.setDaemon(true);
    t.start();

    // Auto-Discovery Thread
    Thread autoDiscovery = new Thread(new Runnable() {
        public void run() {

            while (true) {
                try {

                    // Attempt every 30 seconds
                    Thread.sleep(30000);

                } catch (InterruptedException e) {
                    log.warn("Interrupted Exception in Up Time Thread", e);
                }

                if (autodiscover && (!Grid.isNode())) {
                    // 30 Second Intervals
                    doDiscover(true);
                }

            }
        }
    });
    autoDiscovery.setDaemon(true);
    autoDiscovery.start();

    return generalPanel;
}

From source file:org.owasp.jbrofuzz.fuzz.ui.FuzzingPanel.java

private JTextPane createEditablePane() {

    JTextPane textPane = new JTextPane();

    // Get the preferences for wrapping lines of text
    final boolean wrapText = JBroFuzz.PREFS.getBoolean(JBroFuzzPrefs.FUZZING[2].getId(), false);

    if (wrapText) {
        textPane = new JTextPane();
    } else {// w  ww .  j  av a 2s . co m
        textPane = new NonWrappingTextPane();
    }

    textPane.putClientProperty("charset", "UTF-8");
    textPane.setEditable(true);
    textPane.setVisible(true);
    textPane.setFont(new Font("Verdana", Font.PLAIN, 12));
    textPane.setMargin(new Insets(1, 1, 1, 1));
    textPane.setBackground(Color.WHITE);
    textPane.setForeground(Color.BLACK);

    // Set the editor kit responsible for highlighting
    textPane.setEditorKit(new StyledEditorKit() {

        private static final long serialVersionUID = -6085642347022880064L;

        public Document createDefaultDocument() {
            return new TextHighlighter();
        }

    });

    // Right click: Cut, Copy, Paste, Select All
    RightClickPopups.rightClickRequestTextComponent(this, textPane);

    return textPane;
}

From source file:org.owasp.jbrofuzz.fuzz.ui.FuzzingPanel.java

JTextPane createSimplePane() {
    JTextPane textPane = new JTextPane();
    textPane.setMargin(new Insets(1, 1, 1, 1));
    textPane.setBackground(Color.WHITE);
    textPane.setForeground(Color.BLACK);
    return textPane;

}

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 ww . j  ava 2 s.c  om*/
        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.MovieSettingsPanel.java

/**
 * Instantiates a new movie settings panel.
 */// w  ww .j  ava 2s  .  c o m
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.settings.FileTypesSettingsPanel.java

/**
 * Instantiates a new general settings panel.
 *///w  w w .jav  a 2 s . 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.TvShowSettingsPanel.java

/**
 * Instantiates a new tv show settings panel.
 *///from  w ww  . jav a 2s . c  o m
public TvShowSettingsPanel() {
    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, RowSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow(3)"), }));

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

    lblImageCache = new JLabel(BUNDLE.getString("Settings.imagecacheimport"));
    panelGeneral.add(lblImageCache, "2, 2");

    chckbxImageCache = new JCheckBox("");
    panelGeneral.add(chckbxImageCache, "4, 2");

    lblImageCacheHint = new JLabel(BUNDLE.getString("Settings.imagecacheimporthint")); //$NON-NLS-1$
    panelGeneral.add(lblImageCacheHint, "6, 2, 3, 1");
    TmmFontHelper.changeFont(lblImageCacheHint, 0.833);

    final JSeparator separator = new JSeparator();
    panelGeneral.add(separator, "2, 4, 7, 1");

    JLabel lblTraktTv = new JLabel(BUNDLE.getString("Settings.trakt"));//$NON-NLS-1$
    panelGeneral.add(lblTraktTv, "2, 6");

    chckbxTraktTv = new JCheckBox("");
    panelGeneral.add(chckbxTraktTv, "4, 6");
    btnClearTraktTvShows = new JButton(BUNDLE.getString("Settings.trakt.cleartvshows"));//$NON-NLS-1$
    btnClearTraktTvShows.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int confirm = JOptionPane.showOptionDialog(null,
                    BUNDLE.getString("Settings.trakt.cleartvshows.hint"),
                    BUNDLE.getString("Settings.trakt.cleartvshows"), JOptionPane.YES_NO_OPTION, //$NON-NLS-1$
                    JOptionPane.QUESTION_MESSAGE, null, null, null);
            if (confirm == JOptionPane.YES_OPTION) {
                TmmTask task = new ClearTraktTvTask(false, true);
                TmmTaskManager.getInstance().addUnnamedTask(task);
            }
        }
    });
    panelGeneral.add(btnClearTraktTvShows, "6, 6");

    JPanel panelBadWords = new JPanel();
    panelBadWords.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.tvshow.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.tvshow.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 = TvShowModuleManager.SETTINGS.getBadWords().get(row);
                TvShowModuleManager.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())) {
                TvShowModuleManager.SETTINGS.addBadWord(tfAddBadword.getText());
                tfAddBadword.setText("");
            }
        }
    });
    panelBadWords.add(btnAddBadWord, "4, 6");

    {
        JPanel panelTvShowDataSources = new JPanel();

        panelTvShowDataSources.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.tvshowdatasource"), //$NON-NLS-1$
                TitledBorder.LEADING, TitledBorder.TOP, null, null));
        add(panelTvShowDataSources, "2, 4, 3, 1, fill, top");
        panelTvShowDataSources.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("50dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC,
                FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow(2)"),
                FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("160px:grow"),
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, }));

        JLabel lblDataSource = new JLabel(BUNDLE.getString("Settings.source")); //$NON-NLS-1$
        panelTvShowDataSources.add(lblDataSource, "2, 2, 5, 1");

        JLabel lblSkipFolders = new JLabel(BUNDLE.getString("Settings.ignore"));//$NON-NLS-1$
        panelTvShowDataSources.add(lblSkipFolders, "12, 2, 3, 1");

        JScrollPane scrollPaneDatasource = new JScrollPane();
        panelTvShowDataSources.add(scrollPaneDatasource, "2, 4, 5, 1, fill, fill");

        listDatasources = new JList<>();
        scrollPaneDatasource.setViewportView(listDatasources);

        JPanel panelTvShowSourcesButtons = new JPanel();
        panelTvShowDataSources.add(panelTvShowSourcesButtons, "8, 4, default, top");
        panelTvShowSourcesButtons.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() {
            public void actionPerformed(ActionEvent arg0) {
                Path file = TmmUIHelper
                        .selectDirectory(BUNDLE.getString("Settings.tvshowdatasource.folderchooser")); //$NON-NLS-1$
                if (file != null && Files.isDirectory(file)) {
                    settings.addTvShowDataSources(file.toAbsolutePath().toString());
                }
            }
        });

        panelTvShowSourcesButtons.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 = settings.getTvShowDataSource().get(row);
                    String[] choices = { BUNDLE.getString("Button.continue"), //$NON-NLS-1$
                            BUNDLE.getString("Button.abort") };
                    int decision = JOptionPane.showOptionDialog(null,
                            String.format(BUNDLE.getString("Settings.tvshowdatasource.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));
                        settings.removeTvShowDataSources(path);
                        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    }
                }
            }
        });
        panelTvShowSourcesButtons.add(btnRemove, "1, 3, fill, top");

        JScrollPane scrollPane = new JScrollPane();
        panelTvShowDataSources.add(scrollPane, "12, 4, fill, fill");

        listExclude = new JList<>();
        scrollPane.setViewportView(listExclude);

        JPanel panelSkipFolderButtons = new JPanel();
        panelTvShowDataSources.add(panelSkipFolderButtons, "14, 4, fill, fill");
        panelSkipFolderButtons.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, },
                new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, }));

        JButton btnAddSkipFolder = new JButton(IconManager.LIST_ADD);
        btnAddSkipFolder.setToolTipText(BUNDLE.getString("Settings.addignore")); //$NON-NLS-1$
        btnAddSkipFolder.setMargin(new Insets(2, 2, 2, 2));
        btnAddSkipFolder.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.addTvShowSkipFolder(file.toAbsolutePath().toString());
                }
            }
        });
        panelSkipFolderButtons.add(btnAddSkipFolder, "1, 1");

        JButton btnRemoveSkipFolder = new JButton(IconManager.LIST_REMOVE);
        btnRemoveSkipFolder.setToolTipText(BUNDLE.getString("Settings.removeignore")); //$NON-NLS-1$
        btnRemoveSkipFolder.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveSkipFolder.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int row = listExclude.getSelectedIndex();
                if (row != -1) { // nothing selected
                    String ingore = settings.getTvShowSkipFolders().get(row);
                    settings.removeTvShowSkipFolder(ingore);
                }
            }
        });
        panelSkipFolderButtons.add(btnRemoveSkipFolder, "1, 3");

        JLabel lblDvdOrder = new JLabel(BUNDLE.getString("Settings.dvdorder")); //$NON-NLS-1$
        panelTvShowDataSources.add(lblDvdOrder, "2, 6, right, default");

        cbDvdOrder = new JCheckBox("");
        panelTvShowDataSources.add(cbDvdOrder, "4, 6");
    }

    initDataBindings();

    if (!Globals.isDonator()) {
        chckbxTraktTv.setSelected(false);
        chckbxTraktTv.setEnabled(false);
        btnClearTraktTvShows.setEnabled(false);
    }
}