Example usage for javax.swing.event DocumentListener DocumentListener

List of usage examples for javax.swing.event DocumentListener DocumentListener

Introduction

In this page you can find the example usage for javax.swing.event DocumentListener DocumentListener.

Prototype

DocumentListener

Source Link

Usage

From source file:org.orbisgis.core.ui.plugins.views.geocatalog.Catalog.java

private JPanel getNorthPanel() {
    JPanel ret = new JPanel();
    ret.setLayout(new BorderLayout());
    JPanel pnlTextFilter = new JPanel();
    CRFlowLayout layout = new CRFlowLayout();
    layout.setAlignment(CRFlowLayout.LEFT);
    pnlTextFilter.setLayout(layout);//from   ww  w .  ja  va 2 s. c  o  m
    txtFilter = new JButtonTextField();
    txtFilter.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            doFilter();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            doFilter();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            doFilter();
        }
    });
    pnlTextFilter.add(txtFilter);
    btnToggleFilters = new JToggleButton(OrbisGISIcon.FILTER);
    btnToggleFilters.setMargin(new Insets(0, 0, 0, 0));
    btnToggleFilters.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            pnlFilters.setVisible(!pnlFilters.isVisible());
        }
    });
    btnToggleFilters.setBorderPainted(false);
    btnToggleFilters.setContentAreaFilled(false);
    pnlTextFilter.add(btnToggleFilters);
    ret.add(pnlTextFilter, BorderLayout.NORTH);
    JPanel pnlFilters = getFilterAndTagPanel();
    ret.add(pnlFilters, BorderLayout.CENTER);
    return ret;
}

From source file:org.panbox.desktop.common.gui.PanboxClientGUI.java

public PanboxClientGUI(final PanboxClient client) {
    this.client = client;

    this.shareModel = client.getShareList();
    this.contactModel = client.getContactList();
    this.deviceModel = client.getDeviceList();

    initComponents();/*  www  .  java2s. c  om*/

    ActionListener changesDetectedActionListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setSettingsChangesDetected();
        }
    };

    DocumentListener changesDetectedDocumentListener = new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent e) {
            setSettingsChangesDetected();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            setSettingsChangesDetected();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {

        }
    };

    dropboxSettingsPanel = new DropboxSettingsPanel(changesDetectedActionListener,
            changesDetectedDocumentListener);

    initSettingsConfig();

    // set the icon
    Toolkit kit = Toolkit.getDefaultToolkit();
    Image img = kit.createImage(getClass().getResource("panbox-icon-big.png"));
    setIconImage(img);

    // set the default locale for popup messages
    JOptionPane.setDefaultLocale(Settings.getInstance().getLocale());

    // Hide these for now. Do we still need this?
    syncStatusLabel.setVisible(false);
    syncStatusTextField.setVisible(false);

    cspInfoTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); // NOI18N

    shareList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            refreshShare();
        }
    });
    shareList.setSelectedIndex(0); // always try to select first share

    enableDisableAddDeviceContactForShare();

    addressbookList.addListSelectionListener(new ListSelectionListener() {

        private DocumentListener firstNameFieldDocListener = new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                changed();
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
                changed();
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
            }

            public void changed() {
                if (!firstNameTextField.getText().equals(contact.getFirstName()) && !unsavedContactChanges) {
                    setContactChangesDetected();
                }
            }
        };
        private DocumentListener lastNameFieldDocListener = new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                changed();
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
                changed();
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
            }

            public void changed() {
                if (!lastNameTextField.getText().equals(contact.getName()) && !unsavedContactChanges) {
                    setContactChangesDetected();
                }
            }
        };
        private ListSelectionListener cspListSelectionListener = new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                int selectedIndex = cspInfoTable.getSelectedRow();
                int max = ((CSPTableModel) cspInfoTable.getModel()).getMax();
                if (selectedIndex != -1 && selectedIndex < max) {
                    removeCSPInfoButton.setEnabled(true);
                } else {
                    removeCSPInfoButton.setEnabled(false);
                }
            }
        };

        boolean manuallySetSelection = false;

        @Override
        public void valueChanged(ListSelectionEvent e) {
            final List<PanboxGUIContact> selected = addressbookList.getSelectedValuesList();

            firstNameTextField.getDocument().removeDocumentListener(firstNameFieldDocListener);
            lastNameTextField.getDocument().removeDocumentListener(lastNameFieldDocListener);
            cspInfoTable.getSelectionModel().removeListSelectionListener(cspListSelectionListener);

            if (!manuallySetSelection) {
                if (!uneditedCSPsExist()) {
                    if (unsavedContactChanges) {
                        int saveUnchanged = JOptionPane.showConfirmDialog(null,
                                bundle.getString("PanboxClientGUI.unsavedChangesToContact"), // NOI18N
                                bundle.getString("PanboxClientGUI.panboxMessage"), // NOI18N
                                JOptionPane.YES_NO_CANCEL_OPTION);
                        if (saveUnchanged == JOptionPane.YES_OPTION) {
                            saveContactChanges();
                            refreshContact();
                            resetContactApplyDiscardButtons();
                        } else if (saveUnchanged == JOptionPane.CANCEL_OPTION) {
                            manuallySetSelection = true;
                            int previousIndex = e.getFirstIndex() == addressbookList.getSelectedIndex()
                                    ? e.getLastIndex()
                                    : e.getFirstIndex();
                            addressbookList.setSelectedIndex(previousIndex);
                        } else {
                            refreshContact();
                            resetContactApplyDiscardButtons();
                        }
                        unsavedContactChanges = false;
                    }

                    int selectedIndex = addressbookList.getSelectedIndex();
                    if (selectedIndex != -1) {
                        // enable Buttons
                        removeContactButton.setEnabled(true);
                        exportContactButton.setEnabled(true);

                        // refresh contact infos
                        contact = contactModel.getElementAt(selectedIndex);
                        contacts = selected;
                        firstNameTextField.setText(contact.getFirstName());
                        lastNameTextField.setText(contact.getName());
                        emailTextField.setText(contact.getEmail());
                        cspInfoTable.setModel(contact.generateCspInfoTableModel());
                        cspInfoTable.getSelectionModel().addListSelectionListener(cspListSelectionListener);

                        // show certificate info
                        encKeyFprintTextField.setText(contact.getCertEncFingerprint());
                        signKeyFprintTextField.setText(contact.getCertSignFingerprint());
                        validFromUntilLabel.setText(bundle.getString("valid.from") + " " + contact.getFromDate()
                                + " " + bundle.getString("valid.to") + " " + contact.getUntilDate());

                        // disable apply and discard buttons when contact
                        // selection
                        // changes
                        contactApplyButton.setEnabled(false);
                        contactDiscardButton.setEnabled(false);

                        // disable csp add button when no further csps are
                        // available to add
                        if (contact.getAvailableCSPs() > 0) {
                            addCSPInfoButton.setEnabled(true);
                        } else {
                            addCSPInfoButton.setEnabled(false);
                        }
                        removeCSPInfoButton.setEnabled(false);

                        if (contact instanceof PanboxMyContact) {
                            firstNameTextField.setEnabled(false);
                            lastNameTextField.setEnabled(false);
                            removeContactButton.setEnabled(false);
                            contactVerificationStatusCheckBox.setEnabled(false);
                        } else {
                            firstNameTextField.setEnabled(true);
                            lastNameTextField.setEnabled(true);
                            removeContactButton.setEnabled(true);
                            firstNameTextField.getDocument().addDocumentListener(firstNameFieldDocListener);
                            lastNameTextField.getDocument().addDocumentListener(lastNameFieldDocListener);
                            contactVerificationStatusCheckBox.setEnabled(true);
                        }

                    } else {
                        // disable export and remove button when no item is
                        // selected
                        removeContactButton.setEnabled(false);
                        exportContactButton.setEnabled(false);
                    }
                } else {
                    manuallySetSelection = true;
                    int previousIndex = e.getFirstIndex() == addressbookList.getSelectedIndex()
                            ? e.getLastIndex()
                            : e.getFirstIndex();
                    addressbookList.setSelectedIndex(previousIndex);
                }
            } else {
                manuallySetSelection = false;
            }

            if (contact.isVerified()) {
                contactVerificationStatusCheckBox.setSelected(true);
                contactVerificationStatusCheckBox.setText(bundle.getString("PanboxClientGUI.contact.verified"));
            } else {
                contactVerificationStatusCheckBox.setSelected(false);
                contactVerificationStatusCheckBox.setText(bundle.getString("PanboxClientGUI.contact.verified"));
            }
        }
    });
    addressbookList.setSelectedIndex(0); // always try to select first
    // contact

    // contact
    firstNameTextField.setDisabledTextColor(Color.BLACK);
    lastNameTextField.setDisabledTextColor(Color.BLACK);
    emailTextField.setDisabledTextColor(Color.BLACK);
    encKeyFprintTextField.setDisabledTextColor(Color.BLACK);
    signKeyFprintTextField.setDisabledTextColor(Color.BLACK);

    deviceList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            int selected = deviceList.getSelectedIndex();
            if (!e.getValueIsAdjusting() && selected != -1) {
                device = deviceModel.getElementAt(selected);

                deviceKeyFprintTextField.setText(device.getDevicePubKeyFingerprint());

                deviceShareList.setModel(client.getDeviceShares(device));

                checkIfRemoveDeviceShouldBeEnabled();
            }
        }
    });
    deviceList.setSelectedIndex(0); // always try to select first device

    checkIfRemoveDeviceShouldBeEnabled();

    // expert mode visible/invisible
    expertModeCheckBoxActionPerformed(null);

    languageComboBox.addActionListener(changesDetectedActionListener);
    expertModeCheckBox.addActionListener(changesDetectedActionListener);
    networkAddressComboBox.addActionListener(changesDetectedActionListener);
    networkInterfaceComboBox.addActionListener(changesDetectedActionListener);

    panboxFolderTextField.getDocument().addDocumentListener(changesDetectedDocumentListener);
    settingsFolderTextField.getDocument().addDocumentListener(changesDetectedDocumentListener);

    // disable settings apply and discard buttons
    settingsApplyButton.setEnabled(false);
    settingsRevertButton.setEnabled(false);

    // TODO: add action and document listeners to the csp settings after it
    // has been fixed (see trac ticket #139)

    // Disable device pairing for SLAVE devices and enable the click for MASTER devices!
    if (Settings.getInstance().isSlave()) {
        addDeviceButton.setEnabled(false);
        addDeviceButton.setToolTipText(bundle.getString("client.disabledPairingSlave"));
    } else {
        addDeviceButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                addDeviceButtonMousePressed(evt);
            }
        });
    }

    if (OS.getOperatingSystem().isWindows()) {
        panboxFolderLabel.setText(bundle.getString("client.settings.panboxDrive")); // NOI18N

        panboxFolderChooseButton.setVisible(false);
    }
}

From source file:org.pentaho.ui.xul.swing.tags.SwingTree.java

private TableCellEditor getCellEditor(final SwingTreeCol col) {
    return new DefaultCellEditor(new JComboBox()) {

        JComponent control;//from  w  w  w  .  j a va 2s. com

        @Override
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected,
                final int row, final int column) {
            Component comp;
            ColumnType colType = col.getColumnType();
            if (colType == ColumnType.DYNAMIC) {
                colType = ColumnType.valueOf(extractDynamicColType(elements.toArray()[row], column));
            }

            final XulTreeCell cell = getRootChildren().getItem(row).getRow().getCell(column);
            switch (colType) {
            case CHECKBOX:
                final JCheckBox checkbox = new JCheckBox();
                final JTable tbl = table;
                checkbox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent event) {
                        SwingTree.this.table.setValueAt(checkbox.isSelected(), row, column);
                        tbl.getCellEditor().stopCellEditing();
                    }
                });

                control = checkbox;
                if (value instanceof String) {
                    checkbox.setSelected(((String) value).equalsIgnoreCase("true")); //$NON-NLS-1$
                } else if (value instanceof Boolean) {
                    checkbox.setSelected((Boolean) value);
                } else if (value == null) {
                    checkbox.setSelected(false);
                }
                if (isSelected) {
                    checkbox.setBackground(Color.LIGHT_GRAY);
                }
                comp = checkbox;
                checkbox.setEnabled(!cell.isDisabled());
                break;
            case EDITABLECOMBOBOX:
            case COMBOBOX:
                Vector val = (value != null && value instanceof Vector) ? (Vector) value : new Vector();
                final JComboBox comboBox = new JComboBox(val);

                if (isSelected) {
                    comboBox.setBackground(Color.LIGHT_GRAY);
                }

                if (colType == ColumnType.EDITABLECOMBOBOX) {

                    comboBox.setEditable(true);
                    final JTextComponent textComp = (JTextComponent) comboBox.getEditor().getEditorComponent();

                    textComp.addKeyListener(new KeyListener() {
                        private String oldValue = ""; //$NON-NLS-1$

                        public void keyPressed(KeyEvent e) {
                            oldValue = textComp.getText();
                        }

                        public void keyReleased(KeyEvent e) {
                            if (oldValue != null && !oldValue.equals(textComp.getText())) {
                                SwingTree.this.table.setValueAt(textComp.getText(), row, column);

                                oldValue = textComp.getText();
                            } else if (oldValue == null) {
                                // AWT error where sometimes the keyReleased is fired before keyPressed.
                                oldValue = textComp.getText();
                            } else {
                                logger.debug("Special key pressed, ignoring"); //$NON-NLS-1$
                            }
                        }

                        public void keyTyped(KeyEvent e) {
                        }
                    });

                    comboBox.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent event) {
                            // if(textComp.hasFocus() == false && comboBox.hasFocus()){
                            SwingTree.logger.debug("Setting ComboBox value from editor: " //$NON-NLS-1$
                                    + comboBox.getSelectedItem() + ", " + row + ", " + column); //$NON-NLS-1$ //$NON-NLS-2$

                            SwingTree.this.table.setValueAt(comboBox.getSelectedIndex(), row, column);
                            // }
                        }
                    });
                } else {
                    comboBox.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent event) {

                            SwingTree.logger.debug("Setting ComboBox value from editor: " //$NON-NLS-1$
                                    + comboBox.getSelectedItem() + ", " + row + ", " + column); //$NON-NLS-1$ //$NON-NLS-2$

                            SwingTree.this.table.setValueAt(comboBox.getSelectedIndex(), row, column);
                        }
                    });
                }

                control = comboBox;
                comboBox.setEnabled(!cell.isDisabled());
                comp = comboBox;
                break;
            case LABEL:
                JLabel lbl = new JLabel(cell.getLabel());
                comp = lbl;
                control = lbl;
                break;
            case CUSTOM:
                return new CustomCellEditorWrapper(cell, customEditors.get(col.getType()));
            default:
                final JTextField label = new JTextField((String) value);

                label.getDocument().addDocumentListener(new DocumentListener() {

                    public void changedUpdate(DocumentEvent arg0) {
                        SwingTree.this.table.setValueAt(label.getText(), row, column);
                    }

                    public void insertUpdate(DocumentEvent arg0) {
                        SwingTree.this.table.setValueAt(label.getText(), row, column);
                    }

                    public void removeUpdate(DocumentEvent arg0) {
                        SwingTree.this.table.setValueAt(label.getText(), row, column);
                    }

                });
                if (isSelected) {
                    label.setOpaque(true);
                    // label.setBackground(Color.LIGHT_GRAY);
                }

                control = label;
                comp = label;
                label.setEnabled(!cell.isDisabled());
                label.setDisabledTextColor(Color.DARK_GRAY);
                break;
            }

            return comp;
        }

        @Override
        public Object getCellEditorValue() {
            if (control instanceof JCheckBox) {
                return ((JCheckBox) control).isSelected();
            } else if (control instanceof JComboBox) {
                JComboBox box = (JComboBox) control;
                if (box.isEditable()) {
                    return ((JTextComponent) box.getEditor().getEditorComponent()).getText();
                } else {
                    return box.getSelectedIndex();
                }
            } else if (control instanceof JTextField) {
                return ((JTextField) control).getText();
            } else {
                return ((JLabel) control).getText();
            }
        }

    };

}

From source file:org.qcc.modules.learningpalette.OptionsPlugin.LearningPalettePanel.java

void load() {

    //Populate language list.
    if (languageList.isEmpty()) {
        for (int i = 0; i < languageCombo.getItemCount(); i++) {
            languageList.add(languageCombo.getItemAt(i).toString());
        }/*  w ww.j  av a 2s.  c  om*/
    }

    loadPaletteItems("");

    codeText.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent e) {
            codeTextChanged();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            codeTextChanged();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            codeTextChanged();
        }
    });

}

From source file:org.rdv.ui.ChannelListPanel.java

/**
 * Create the UI panel that contains the controls to filter the channel list.
 * //from  w w  w  .  j  a v  a2s.c  o m
 * @return  the UI component dealing with filtering
 */
private JComponent createFilterPanel() {
    JPanel filterPanel = new JPanel();
    filterPanel.setLayout(new BorderLayout(5, 5));
    filterPanel.setBackground(Color.white);
    filterPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JLabel filterIconLabel = new JLabel(DataViewer.getIcon("icons/filter.gif"));
    filterPanel.add(filterIconLabel, BorderLayout.WEST);

    filterTextField = new JTextField();
    filterTextField.setToolTipText("Enter text here to filter the channel list");
    filterTextField.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            treeModel.setFilter(filterTextField.getText());
        }

        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }
    });
    filterPanel.add(filterTextField, BorderLayout.CENTER);

    Action focusFilterAction = new AbstractAction() {
        /** serialization version identifier */
        private static final long serialVersionUID = -2443410059209958411L;

        public void actionPerformed(ActionEvent e) {
            filterTextField.requestFocusInWindow();
            filterTextField.selectAll();
        }
    };

    int modifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    filterTextField.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_F, modifier), "focusFilter");
    filterTextField.getActionMap().put("focusFilter", focusFilterAction);

    Action cancelFilterAction = new AbstractAction(null, DataViewer.getIcon("icons/cancel.gif")) {
        /** serialization version identifier */
        private static final long serialVersionUID = 8913797349366699615L;

        public void actionPerformed(ActionEvent e) {
            treeModel.setFilter(null);
        }
    };
    cancelFilterAction.putValue(Action.SHORT_DESCRIPTION, "Cancel filter");

    filterTextField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancelFilter");
    filterTextField.getActionMap().put("cancelFilter", cancelFilterAction);

    clearFilterButton = new JButton(cancelFilterAction);
    clearFilterButton.setBorderPainted(false);
    clearFilterButton.setVisible(false);
    filterPanel.add(clearFilterButton, BorderLayout.EAST);

    return filterPanel;
}

From source file:org.signserver.admin.gui.AddWorkerDialog.java

/** Creates new form AddWorkerDialog */
public AddWorkerDialog(java.awt.Frame parent, boolean modal) {
    super(parent, modal);
    initComponents();// w w  w . j a  va  2 s  . c om

    stage = Stage.INITIAL_CONFIG;
    mode = Mode.LOAD_FROM_FILE;
    loadFromFileRadioButton.setSelected(true);
    updateControls();

    // initially set the Next button to be greyed-out, so that it can be
    // enabled based on the state
    nextApplyButton.setEnabled(false);

    invalidWorkerIdStatusLabel.setVisible(false);

    propertiesTable.setDefaultRenderer(String.class, new DefaultTableCellRenderer() {
        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean selected,
                boolean focused, int row, int column) {
            setEnabled(table == null || table.isEnabled());
            super.getTableCellRendererComponent(table, value, selected, focused, row, column);

            return this;
        }
    });

    propertiesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(final ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                final boolean enable = propertiesTable.getSelectedRowCount() == 1;
                editPropertyButton.setEnabled(enable);
                removePropertyButton.setEnabled(enable);
            }
        }
    });

    // add a document listner to update the UI when the content of the ID
    // combobox changes
    final JTextComponent component = (JTextComponent) workerIdComboBox.getEditor().getEditorComponent();
    component.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent ev) {
            updateControls();
        }

        @Override
        public void removeUpdate(DocumentEvent ev) {
            updateControls();
        }

        @Override
        public void changedUpdate(DocumentEvent ev) {
            updateControls();
        }
    });

    // add a document listner to update the UI on updates of the configuration text
    configurationTextArea.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent ev) {
            configurationEdited = true;
            updateControls();
        }

        @Override
        public void removeUpdate(DocumentEvent ev) {
            configurationEdited = true;
            updateControls();
        }

        @Override
        public void changedUpdate(DocumentEvent ev) {
            configurationEdited = true;
            updateControls();
        }
    });
}

From source file:org.sintef.thingml.ThingMLPanel.java

public ThingMLPanel(Boolean ArduinoPlugin, final ObservableString transferBuf) {
    try {//from   w  w  w  .  ja  va 2 s.  c o m
        this.setLayout(new BorderLayout());
        jsyntaxpane.DefaultSyntaxKit.initKit();
        jsyntaxpane.DefaultSyntaxKit.registerContentType("text/thingml",
                Class.forName("org.sintef.thingml.ThingMLJSyntaxKit").getName());
        JScrollPane scrPane = new JScrollPane(codeEditor);
        codeEditor.setContentType("text/thingml; charset=UTF-8");

        Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
        reg.getExtensionToFactoryMap().put("thingml", new ThingmlResourceFactory());

        //codeEditor.setBackground(Color.LIGHT_GRAY)

        JMenuBar menubar = new JMenuBar();
        JInternalFrame menuframe = new JInternalFrame();

        menuframe.setSize(getWidth(), getHeight());
        menuframe.setJMenuBar(menubar);

        menuframe.setLayout(new BorderLayout());
        menuframe.add(scrPane, BorderLayout.CENTER);

        if (!ArduinoPlugin) {
            try {
                this.transferBuf = transferBuf;
                EditorKit editorKit = codeEditor.getEditorKit();
                JToolBar toolPane = new JToolBar();
                ((ThingMLJSyntaxKit) editorKit).addToolBarActions(codeEditor, toolPane);
                menuframe.add(toolPane, BorderLayout.NORTH);
            } catch (Exception e) {
                if (ThingMLApp.debug)
                    e.printStackTrace();
            }
        }

        menuframe.setVisible(true);
        ((BasicInternalFrameUI) menuframe.getUI()).setNorthPane(null);
        menuframe.setBorder(BorderFactory.createEmptyBorder());
        add(menuframe, BorderLayout.CENTER);

        if (!ArduinoPlugin) {//FIXME: Nicolas, avoid code duplication
            final ThingMLCompilerRegistry registry = ThingMLCompilerRegistry.getInstance();

            JMenu newCompilersMenu = new JMenu("Compile to");
            for (final String id : registry.getCompilerIds()) {
                JMenuItem item = new JMenuItem(id);
                ThingMLCompiler c = registry.createCompilerInstanceByName(id);
                if (c.getConnectorCompilers().size() > 0) {
                    JMenu compilerMenu = new JMenu(c.getID());
                    newCompilersMenu.add(compilerMenu);
                    compilerMenu.add(item);
                    for (final Map.Entry<String, CfgExternalConnectorCompiler> connectorCompiler : c
                            .getConnectorCompilers().entrySet()) {
                        JMenuItem connectorMenu = new JMenuItem(connectorCompiler.getKey());
                        compilerMenu.add(connectorMenu);
                        connectorMenu.addActionListener(new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent e) {
                                ThingMLModel thingmlModel = ThingMLCompiler.loadModel(targetFile);
                                for (Configuration cfg : ThingMLHelpers.allConfigurations(thingmlModel)) {
                                    final ThingMLCompiler compiler = registry.createCompilerInstanceByName(id);
                                    for (NetworkPlugin np : loadedPlugins) {
                                        if (np.getTargetedLanguages().contains(compiler.getID())) {
                                            compiler.addNetworkPlugin(np);
                                        }
                                    }
                                    for (SerializationPlugin sp : loadedSerPlugins) {
                                        if (sp.getTargetedLanguages().contains(compiler.getID())) {
                                            compiler.addSerializationPlugin(sp);
                                        }
                                    }
                                    compiler.setOutputDirectory(new File(System.getProperty("java.io.tmpdir")
                                            + "/ThingML_temp/" + cfg.getName()));
                                    compiler.compileConnector(connectorCompiler.getKey(), cfg);
                                }
                            }
                        });
                    }
                } else {
                    newCompilersMenu.add(item);
                }

                item.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        System.out.println("Input file : " + targetFile);
                        if (targetFile == null)
                            return;
                        try {
                            ThingMLModel thingmlModel = ThingMLCompiler.loadModel(targetFile);
                            if (thingmlModel != null) {
                                for (Configuration cfg : ThingMLHelpers.allConfigurations(thingmlModel)) {
                                    final ThingMLCompiler compiler = registry.createCompilerInstanceByName(id);
                                    for (NetworkPlugin np : loadedPlugins) {
                                        if (np.getTargetedLanguages().contains(compiler.getID())) {
                                            compiler.addNetworkPlugin(np);
                                        }
                                    }
                                    for (SerializationPlugin sp : loadedSerPlugins) {
                                        if (sp.getTargetedLanguages().contains(compiler.getID())) {
                                            compiler.addSerializationPlugin(sp);
                                        }
                                    }
                                    compiler.setOutputDirectory(new File(System.getProperty("java.io.tmpdir")
                                            + "/ThingML_temp/" + cfg.getName()));
                                    compiler.compile(cfg);
                                }
                            }
                        } catch (Exception ex) {
                            if (ThingMLApp.debug)
                                ex.printStackTrace();
                        }
                    }
                });
                c = null;
            }

            menubar.add(newCompilersMenu);
        } else {

            final ThingMLCompilerRegistry registry = ThingMLCompilerRegistry.getInstance();

            JMenu newCompilersMenu = new JMenu("Compile to");
            for (final String id : registry.getCompilerIds()) {
                if (id.compareToIgnoreCase("arduino") == 0) {
                    JMenuItem item = new JMenuItem(id);
                    ThingMLCompiler c = registry.createCompilerInstanceByName(id);
                    if (c.getConnectorCompilers().size() > 0) {
                        JMenu compilerMenu = new JMenu(c.getID());
                        newCompilersMenu.add(compilerMenu);
                        compilerMenu.add(item);
                        for (final Map.Entry<String, CfgExternalConnectorCompiler> connectorCompiler : c
                                .getConnectorCompilers().entrySet()) {
                            JMenuItem connectorMenu = new JMenuItem(connectorCompiler.getKey());
                            compilerMenu.add(connectorMenu);
                            connectorMenu.addActionListener(new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent e) {
                                    ThingMLModel thingmlModel = ThingMLCompiler.loadModel(targetFile);
                                    for (Configuration cfg : ThingMLHelpers.allConfigurations(thingmlModel)) {
                                        final ThingMLCompiler compiler = registry
                                                .createCompilerInstanceByName(id);
                                        for (NetworkPlugin np : loadedPlugins) {
                                            if (np.getTargetedLanguages().contains(compiler.getID())) {
                                                compiler.addNetworkPlugin(np);
                                            }
                                        }
                                        for (SerializationPlugin sp : loadedSerPlugins) {
                                            if (sp.getTargetedLanguages().contains(compiler.getID())) {
                                                compiler.addSerializationPlugin(sp);
                                            }
                                        }
                                        compiler.setOutputDirectory(
                                                new File(System.getProperty("java.io.tmpdir") + "/ThingML_temp/"
                                                        + cfg.getName()));
                                        compiler.compileConnector(connectorCompiler.getKey(), cfg);
                                    }
                                }
                            });
                        }
                    } else {
                        newCompilersMenu.add(item);
                    }

                    item.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            System.out.println("Input file : " + targetFile);
                            if (targetFile == null)
                                return;
                            try {
                                ThingMLModel thingmlModel = ThingMLCompiler.loadModel(targetFile);
                                for (Configuration cfg : ThingMLHelpers.allConfigurations(thingmlModel)) {
                                    final ThingMLCompiler compiler = registry.createCompilerInstanceByName(id);
                                    for (NetworkPlugin np : loadedPlugins) {
                                        if (np.getTargetedLanguages().contains(compiler.getID())) {
                                            compiler.addNetworkPlugin(np);
                                        }
                                    }
                                    for (SerializationPlugin sp : loadedSerPlugins) {
                                        if (sp.getTargetedLanguages().contains(compiler.getID())) {
                                            compiler.addSerializationPlugin(sp);
                                        }
                                    }

                                    File myFileBuf = new File(System.getProperty("java.io.tmpdir")
                                            + "/ThingML_temp/" + cfg.getName());
                                    compiler.setOutputDirectory(myFileBuf);
                                    compiler.compile(cfg);

                                    final InputStream input = new FileInputStream(myFileBuf.getAbsolutePath()
                                            + "/" + cfg.getName() + "/" + cfg.getName() + ".pde");

                                    //System.out.println("tmp file: " + myFileBuf.getAbsolutePath() + "/" + cfg.getName() + "/" + cfg.getName() + ".pde");

                                    //final InputStream input = new FileInputStream(myFileBuf);
                                    String result = null;
                                    try {
                                        if (input != null) {
                                            result = org.apache.commons.io.IOUtils.toString(input);
                                            input.close();
                                            transferBuf.setString(result);
                                            transferBuf.hasChanged();
                                            transferBuf.notifyObservers();
                                        } else {
                                            //System.out.println("WHY");
                                        }
                                    } catch (Exception exce) {
                                        if (ThingMLApp.debug)
                                            System.out.println("OH REALLY?");
                                    }

                                }
                            } catch (Exception ex) {
                                if (ThingMLApp.debug)
                                    ex.printStackTrace();
                            }
                        }
                    });
                    c = null;
                }
            }

            menubar.add(newCompilersMenu);
        }

        codeEditor.getDocument().addDocumentListener(new DocumentListener() {
            public void removeUpdate(DocumentEvent e) {
                lastUpdate.set(System.currentTimeMillis());
                checkNeeded.set(true);
            }

            public void insertUpdate(DocumentEvent e) {
                lastUpdate.set(System.currentTimeMillis());
                checkNeeded.set(true);
            }

            public void changedUpdate(DocumentEvent e) {
                lastUpdate.set(System.currentTimeMillis());
                checkNeeded.set(true);
            }
        });

        java.util.Timer timer = new Timer();
        timer.scheduleAtFixedRate(new SeamlessNotification(), 250, 250);

    } catch (Exception e) {
        if (ThingMLApp.debug)
            e.printStackTrace();
    }
}

From source file:org.sleuthkit.autopsy.experimental.autoingest.FileExporterSettingsPanel.java

public FileExporterSettingsPanel(JDialog jDialog) {
    timeSettings.setFormatForDisplayTime(
            PickerUtilities.createFormatterFromPatternString("HH:mm:ss", timeSettings.getLocale()));
    timeSettings.setFormatForMenuTimes(/*from  w  w w.  j  a va 2 s  .  com*/
            PickerUtilities.createFormatterFromPatternString("HH:mm", timeSettings.getLocale()));

    initComponents();
    rootNode = new DefaultMutableTreeNode(new Item(ROOTNODE, ROOTNODE, ItemType.RULE_SET));
    trRuleList.setModel(new DefaultTreeModel(rootNode));
    this.jDialog = jDialog;

    attributeListModel = (DefaultListModel<String>) lsAttributeList.getModel();

    rootDirectoryChooser
            .setCurrentDirectory(rootDirectoryChooser.getFileSystemView().getParentDirectory(new File("C:\\"))); //NON-NLS
    rootDirectoryChooser.setAcceptAllFileFilterUsed(false);
    rootDirectoryChooser.setDialogTitle(NbBundle.getMessage(FileExporterSettingsPanel.class,
            "FileExporterSettingsPanel.ChooseRootDirectory"));
    rootDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    reportDirectoryChooser.setCurrentDirectory(
            reportDirectoryChooser.getFileSystemView().getParentDirectory(new File("C:\\"))); //NON-NLS
    reportDirectoryChooser.setAcceptAllFileFilterUsed(false);
    reportDirectoryChooser.setDialogTitle(NbBundle.getMessage(FileExporterSettingsPanel.class,
            "FileExporterSettingsPanel.ChooseReportDirectory"));
    reportDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    // Add text prompt to the text box fields
    TextPrompt textPromptRuleName = new TextPrompt(
            NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.RuleName"),
            tbRuleName);
    textPromptRuleName.setForeground(Color.LIGHT_GRAY);
    textPromptRuleName.changeAlpha(0.9f);

    TextPrompt textPromptRootDirectory = new TextPrompt(
            NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.RootDirectory"),
            tbRootDirectory);
    textPromptRootDirectory.setForeground(Color.LIGHT_GRAY);
    textPromptRootDirectory.changeAlpha(0.9f);

    TextPrompt textPromptReportDirectory = new TextPrompt(
            NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.ReportDirectory"),
            tbReportDirectory);
    textPromptReportDirectory.setForeground(Color.LIGHT_GRAY);
    textPromptReportDirectory.changeAlpha(0.9f);

    TextPrompt textPromptReportAttributeValue = new TextPrompt(
            NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.AttributeValue"),
            tbAttributeValue);
    textPromptReportAttributeValue.setForeground(Color.LIGHT_GRAY);
    textPromptReportAttributeValue.changeAlpha(0.9f);

    for (SizeUnit item : SizeUnit.values()) {
        comboBoxFileSizeUnits.addItem(item.toString());
    }

    for (RelationalOp item : RelationalOp.values()) {
        comboBoxFileSizeComparison.addItem(item.getSymbol());
        comboBoxAttributeComparison.addItem(item.getSymbol());
    }

    comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.INTEGER.getLabel());
    comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.LONG.getLabel());
    comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DOUBLE.getLabel());
    comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.STRING.getLabel());
    comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME.getLabel());
    comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.BYTE.getLabel());
    comboBoxValueType.addItem(UNSET);

    load();
    trRuleList.setCellRenderer(new DefaultTreeCellRenderer() {
        private static final long serialVersionUID = 1L;
        private final ImageIcon ruleSetIcon = new ImageIcon(
                ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/ruleset-icon.png", false));
        private final ImageIcon ruleIcon = new ImageIcon(ImageUtilities
                .loadImage("org/sleuthkit/autopsy/experimental/images/extracted_content.png", false));
        private final ImageIcon sizeIcon = new ImageIcon(
                ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/file-size-16.png", false));
        private final ImageIcon artifactIcon = new ImageIcon(
                ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/artifact-icon.png", false));
        private final ImageIcon mimetypeIcon = new ImageIcon(
                ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/mime-icon.png", false));
        private final ImageIcon otherIcon = new ImageIcon(
                ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/knownbad-icon.png", false));

        @Override
        public Component getTreeCellRendererComponent(javax.swing.JTree tree, Object value, boolean selected,
                boolean expanded, boolean isLeaf, int row, boolean focused) {
            Component component = super.getTreeCellRendererComponent(tree, value, selected, expanded, isLeaf,
                    row, focused);
            Icon icon;
            switch (((Item) ((DefaultMutableTreeNode) value).getUserObject()).getItemType()) {
            case ARTIFACT_CLAUSE:
                icon = artifactIcon;
                break;
            case MIME_TYPE_CLAUSE:
                icon = mimetypeIcon;
                break;
            case RULE:
                icon = ruleIcon;
                break;
            case SIZE_CLAUSE:
                icon = sizeIcon;
                break;
            case RULE_SET:
                icon = ruleSetIcon;
                break;
            default:
                icon = otherIcon;
                break;
            }
            setIcon(icon);
            return component;
        }
    });
    populateMimeTypes();
    populateArtifacts();
    populateAttributes();
    populateRuleTree();

    tbRuleName.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void changedUpdate(DocumentEvent e) {
            setSaveButton();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            setSaveButton();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            setSaveButton();
        }
    });

    comboBoxMimeValue.getEditor().getEditorComponent().addFocusListener(new java.awt.event.FocusListener() {
        @Override
        public void focusGained(FocusEvent e) {
            comboBoxMimeValue.showPopup();
            comboBoxMimeValue.getEditor().selectAll();
        }

        @Override
        public void focusLost(FocusEvent e) {
            // do nothing
        }
    });

    comboBoxArtifactName.getEditor().getEditorComponent().addFocusListener(new java.awt.event.FocusListener() {
        @Override
        public void focusGained(FocusEvent e) {
            comboBoxArtifactName.showPopup();
            comboBoxArtifactName.getEditor().selectAll();
        }

        @Override
        public void focusLost(FocusEvent e) {
            // do nothing
        }
    });

    comboBoxAttributeName.getEditor().getEditorComponent().addFocusListener(new java.awt.event.FocusListener() {
        @Override
        public void focusGained(FocusEvent e) {
            comboBoxAttributeName.showPopup();
            comboBoxAttributeName.getEditor().selectAll();
        }

        @Override
        public void focusLost(FocusEvent e) {
            // do nothing
        }
    });

    comboBoxMimeTypeComparison.addItem(RelationalOp.Equals.getSymbol());
    comboBoxMimeTypeComparison.addItem(RelationalOp.NotEquals.getSymbol());
    treeSelectionModel = trRuleList.getSelectionModel();
    defaultTreeModel = (DefaultTreeModel) trRuleList.getModel();
    bnDeleteRule.setEnabled(false);
    String selectedAttribute = comboBoxAttributeName.getSelectedItem().toString();
    comboBoxValueType.setSelectedItem(selectedAttribute);
    localRule = makeRuleFromUserInput();

    listSelectionListener = this::lsAttributeListValueChanged;
    lsAttributeList.addListSelectionListener(listSelectionListener);

    treeSelectionListener = this::trRuleListValueChanged;
    trRuleList.addTreeSelectionListener(treeSelectionListener);
    setDeleteAttributeButton();
    setSaveButton();
}

From source file:org.tinymediamanager.ui.movies.MovieExtendedSearchPanel.java

/**
 * Instantiates a new movie extended search
 * //from   w  ww.j  av a2 s  .co m
 * @param model
 *          the model
 */
public MovieExtendedSearchPanel(MovieSelectionModel model) {
    super();
    setOpaque(false);
    shadowAlpha = 100;
    arcs = new Dimension(10, 10);

    this.movieSelectionModel = model;
    Map<MovieSearchOptions, Object> savedSearchOptions = MovieModuleManager.MOVIE_SETTINGS.getUiFilters();

    // add a dummy mouse listener to prevent clicking through
    addMouseListener(new MouseAdapter() {
    });

    listCheckListener = new ListCheckListener() {
        @Override
        public void removeCheck(ListEvent event) {
            actionFilter.actionPerformed(new ActionEvent(event.getSource(), 1, "checked"));
        }

        @Override
        public void addCheck(ListEvent event) {
            actionFilter.actionPerformed(new ActionEvent(event.getSource(), 1, "checked"));
        }
    };

    setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
            FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC,
            ColumnSpec.decode("default:grow"), FormSpecs.UNRELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_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, }));

    JLabel lblFilterBy = new JLabel(BUNDLE.getString("movieextendedsearch.filterby")); //$NON-NLS-1$
    setComponentFont(lblFilterBy);
    add(lblFilterBy, "2, 2, 3, 1");

    cbFilterNewMovies = new JCheckBox("");
    cbFilterNewMovies.setUI(CHECKBOX_UI); // $hide$
    cbFilterNewMovies.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.NEW_MOVIES));
    cbFilterNewMovies.setAction(actionFilter);
    add(cbFilterNewMovies, "2, 4");

    lblNewMovies = new JLabel(BUNDLE.getString("movieextendedsearch.newmovies")); //$NON-NLS-1$
    setComponentFont(lblNewMovies);
    add(lblNewMovies, "4, 4, right, default");

    cbFilterDuplicates = new JCheckBox("");
    cbFilterDuplicates.setUI(CHECKBOX_UI); // $hide$
    cbFilterDuplicates.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.DUPLICATES));
    cbFilterDuplicates.setAction(actionFilter);
    add(cbFilterDuplicates, "2, 5");

    JLabel lblShowDuplicates = new JLabel(BUNDLE.getString("movieextendedsearch.duplicates")); //$NON-NLS-1$
    setComponentFont(lblShowDuplicates);
    add(lblShowDuplicates, "4, 5, right, default");

    cbFilterWatched = new JCheckBox("");
    cbFilterWatched.setUI(CHECKBOX_UI); // $hide$
    cbFilterWatched.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.WATCHED));
    cbFilterWatched.setAction(actionFilter);
    add(cbFilterWatched, "2, 6");

    JLabel lblWatchedFlag = new JLabel(BUNDLE.getString("movieextendedsearch.watched")); //$NON-NLS-1$
    setComponentFont(lblWatchedFlag);
    add(lblWatchedFlag, "4, 6, right, default");

    cbWatched = new SmallComboBox(WatchedFlag.values());
    setComponentFont(cbWatched);
    cbWatched.setAction(actionFilter);
    add(cbWatched, "6, 6, fill, default");

    cbFilterGenre = new JCheckBox("");
    cbFilterGenre.setUI(CHECKBOX_UI); // $hide$
    cbFilterGenre.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.GENRE));
    cbFilterGenre.setAction(actionFilter);
    add(cbFilterGenre, "2, 7");

    JLabel lblGenre = new JLabel(BUNDLE.getString("movieextendedsearch.genre")); //$NON-NLS-1$
    setComponentFont(lblGenre);
    add(lblGenre, "4, 7, right, default");

    cbGenre = new SmallComboBox(MediaGenres.values());
    setComponentFont(cbGenre);
    cbGenre.setAction(actionFilter);
    add(cbGenre, "6, 7, fill, default");

    cbFilterCertification = new JCheckBox("");
    cbFilterCertification.setUI(CHECKBOX_UI); // $hide$
    cbFilterCertification.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.CERTIFICATION));
    cbFilterCertification.setAction(actionFilter);
    add(cbFilterCertification, "2, 8");

    lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$
    setComponentFont(lblCertification);
    add(lblCertification, "4, 8, right, default");

    cbCertification = new SmallComboBox();
    setComponentFont(cbCertification);
    cbCertification.setAction(actionFilter);
    add(cbCertification, "6, 8, fill, default");

    cbFilterYear = new JCheckBox("");
    cbFilterYear.setUI(CHECKBOX_UI); // $hide$
    cbFilterYear.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.YEAR));
    cbFilterYear.setAction(actionFilter);
    add(cbFilterYear, "2, 9");

    lblYear = new JLabel(BUNDLE.getString("metatag.year")); //$NON-NLS-1$
    setComponentFont(lblYear);
    add(lblYear, "4, 9, right, default");

    int year = Calendar.getInstance().get(Calendar.YEAR);
    spYear = new JSpinner();
    setComponentFont(spYear);
    spYear.setUI(new SmallSpinnerUI());// $hide$
    spYear.setModel(new SpinnerNumberModel(year, 0, 3000, 1));
    spYear.setEditor(new JSpinner.NumberEditor(spYear, "#"));
    spYear.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            actionFilter.actionPerformed(null);
        }
    });
    add(spYear, "6, 9");

    cbFilterCast = new JCheckBox("");
    cbFilterCast.setUI(CHECKBOX_UI); // $hide$
    cbFilterCast.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.CAST));
    cbFilterCast.setAction(actionFilter);
    add(cbFilterCast, "2, 10");

    JLabel lblCastMember = new JLabel(BUNDLE.getString("movieextendedsearch.cast")); //$NON-NLS-1$
    setComponentFont(lblCastMember);
    add(lblCastMember, "4, 10, right, default");

    tfCastMember = new JTextField();
    setComponentFont(tfCastMember);
    tfCastMember.setBorder(new SmallTextFieldBorder());
    add(tfCastMember, "6, 10, fill, default");
    tfCastMember.setColumns(10);
    tfCastMember.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            actionFilter.actionPerformed(null);
        }

        public void insertUpdate(DocumentEvent e) {
            actionFilter.actionPerformed(null);
        }

        public void removeUpdate(DocumentEvent e) {
            actionFilter.actionPerformed(null);
        }
    });

    cbFilterTag = new JCheckBox("");
    cbFilterTag.setUI(CHECKBOX_UI); // $hide$
    cbFilterTag.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.TAG));
    cbFilterTag.setAction(actionFilter);
    add(cbFilterTag, "2, 11");

    JLabel lblTag = new JLabel(BUNDLE.getString("movieextendedsearch.tag")); //$NON-NLS-1$
    setComponentFont(lblTag);
    add(lblTag, "4, 11, right, default");

    cbTag = new SmallCheckComboBox();
    cbTag.setTextFor(CheckComboBox.NONE, BUNDLE.getString("movieextendedsearch.tags.selected.none")); //$NON-NLS-1$
    cbTag.setTextFor(CheckComboBox.MULTIPLE, BUNDLE.getString("movieextendedsearch.tags.selected.multiple")); //$NON-NLS-1$
    cbTag.setTextFor(CheckComboBox.ALL, BUNDLE.getString("movieextendedsearch.tags.selected.all")); //$NON-NLS-1$
    cbTag.getModel().addListCheckListener(listCheckListener);
    add(cbTag, "6, 11, fill, default");

    cbFilterMovieset = new JCheckBox("");
    cbFilterMovieset.setUI(CHECKBOX_UI); // $hide$
    cbFilterMovieset.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MOVIESET));
    cbFilterMovieset.setAction(actionFilter);
    add(cbFilterMovieset, "2, 12");

    JLabel lblMoviesInMovieset = new JLabel(BUNDLE.getString("movieextendedsearch.movieset")); //$NON-NLS-1$
    setComponentFont(lblMoviesInMovieset);
    add(lblMoviesInMovieset, "4, 12, right, default");

    cbMovieset = new SmallComboBox(MovieInMovieSet.values());
    setComponentFont(cbMovieset);
    cbMovieset.setAction(actionFilter);
    add(cbMovieset, "6, 12, fill, default");

    cbFilterVideoFormat = new JCheckBox("");
    cbFilterVideoFormat.setUI(CHECKBOX_UI); // $hide$
    cbFilterVideoFormat.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.VIDEO_FORMAT));
    cbFilterVideoFormat.setAction(actionFilter);
    add(cbFilterVideoFormat, "2, 13");

    JLabel lblVideoFormat = new JLabel(BUNDLE.getString("metatag.resolution")); //$NON-NLS-1$
    setComponentFont(lblVideoFormat);
    add(lblVideoFormat, "4, 13, right, default");

    cbVideoFormat = new SmallComboBox(getVideoFormats());
    setComponentFont(cbVideoFormat);
    cbVideoFormat.setAction(actionFilter);
    add(cbVideoFormat, "6, 13, fill, default");

    cbFilterVideoCodec = new JCheckBox("");
    cbFilterVideoCodec.setUI(CHECKBOX_UI); // $hide$
    cbFilterVideoCodec.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.VIDEO_CODEC));
    cbFilterVideoCodec.setAction(actionFilter);
    add(cbFilterVideoCodec, "2, 14");

    JLabel lblVideoCodec = new JLabel(BUNDLE.getString("metatag.videocodec")); //$NON-NLS-1$
    setComponentFont(lblVideoCodec);
    add(lblVideoCodec, "4, 14, right, default");

    cbVideoCodec = new SmallComboBox();
    setComponentFont(cbVideoCodec);
    cbVideoCodec.setAction(actionFilter);
    add(cbVideoCodec, "6, 14, fill, default");

    cbFilterVideo3D = new JCheckBox("");
    cbFilterVideo3D.setUI(CHECKBOX_UI); // $hide$
    cbFilterVideo3D.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.VIDEO_3D));
    cbFilterVideo3D.addActionListener(actionFilter);
    add(cbFilterVideo3D, "2, 15");

    JLabel lblVideo3D = new JLabel(BUNDLE.getString("metatag.3d")); //$NON-NLS-1$
    setComponentFont(lblVideo3D);
    add(lblVideo3D, "4, 15, right, default");

    cbFilterAudioCodec = new JCheckBox("");
    cbFilterAudioCodec.setUI(CHECKBOX_UI); // $hide$
    cbFilterAudioCodec.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.AUDIO_CODEC));
    cbFilterAudioCodec.setAction(actionFilter);
    add(cbFilterAudioCodec, "2, 16");

    JLabel lblAudioCodec = new JLabel(BUNDLE.getString("metatag.audiocodec")); //$NON-NLS-1$
    setComponentFont(lblAudioCodec);
    add(lblAudioCodec, "4, 16, right, default");

    cbAudioCodec = new SmallComboBox();
    setComponentFont(cbAudioCodec);
    cbAudioCodec.setAction(actionFilter);
    add(cbAudioCodec, "6, 16, fill, default");

    cbFilterDatasource = new JCheckBox("");
    cbFilterDatasource.setUI(CHECKBOX_UI); // $hide$
    cbFilterDatasource.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.DATASOURCE));
    cbFilterDatasource.setAction(actionFilter);
    add(cbFilterDatasource, "2, 17");

    JLabel lblDatasource = new JLabel(BUNDLE.getString("metatag.datasource")); //$NON-NLS-1$
    setComponentFont(lblDatasource);
    add(lblDatasource, "4, 17, right, default");

    cbDatasource = new SmallCheckComboBox();
    cbDatasource.setTextFor(CheckComboBox.NONE, BUNDLE.getString("checkcombobox.selected.none")); //$NON-NLS-1$
    cbDatasource.setTextFor(CheckComboBox.MULTIPLE, BUNDLE.getString("checkcombobox.selected.multiple")); //$NON-NLS-1$
    cbDatasource.setTextFor(CheckComboBox.ALL, BUNDLE.getString("checkcombobox.selected.all")); //$NON-NLS-1$
    cbDatasource.getModel().addListCheckListener(listCheckListener);
    add(cbDatasource, "6, 17, fill, default");

    cbFilterMediaSource = new JCheckBox("");
    cbFilterMediaSource.setUI(CHECKBOX_UI); // $hide$
    cbFilterMediaSource.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MEDIA_SOURCE));
    cbFilterMediaSource.addActionListener(actionFilter);
    add(cbFilterMediaSource, "2, 18");

    JLabel lblMediaSource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$
    setComponentFont(lblMediaSource);
    add(lblMediaSource, "4, 18, right, default");

    cbMediaSource = new SmallComboBox(MediaSource.values());
    setComponentFont(cbMediaSource);
    cbMediaSource.setAction(actionFilter);
    add(cbMediaSource, "6, 18, fill, default");

    cbFilterMissingMetadata = new JCheckBox("");
    cbFilterMissingMetadata.setUI(CHECKBOX_UI); // $hide$
    cbFilterMissingMetadata.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MISSING_METADATA));
    cbFilterMissingMetadata.setAction(actionFilter);
    add(cbFilterMissingMetadata, "2, 19");

    JLabel lblMissingMetadata = new JLabel(BUNDLE.getString("movieextendedsearch.missingmetadata")); //$NON-NLS-1$
    setComponentFont(lblMissingMetadata);
    add(lblMissingMetadata, "4, 19, right, default");

    cbFilterMissingArtwork = new JCheckBox("");
    cbFilterMissingArtwork.setUI(CHECKBOX_UI); // $hide$
    cbFilterMissingArtwork.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MISSING_ARTWORK));
    cbFilterMissingArtwork.setAction(actionFilter);
    add(cbFilterMissingArtwork, "2, 20");

    JLabel lblMissingArtwork = new JLabel(BUNDLE.getString("movieextendedsearch.missingartwork")); //$NON-NLS-1$
    setComponentFont(lblMissingArtwork);
    add(lblMissingArtwork, "4, 20, right, default");

    cbFilterMissingSubtitles = new JCheckBox("");
    cbFilterMissingSubtitles.setUI(CHECKBOX_UI); // $hide$
    cbFilterMissingSubtitles.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MISSING_SUBTITLES));
    cbFilterMissingSubtitles.setAction(actionFilter);
    add(cbFilterMissingSubtitles, "2, 21");

    JLabel lblMissingSubtitles = new JLabel(BUNDLE.getString("movieextendedsearch.missingsubtitles")); //$NON-NLS-1$
    setComponentFont(lblMissingSubtitles);
    add(lblMissingSubtitles, "4, 21, right, default");

    cbFilterOffline = new JCheckBox("");
    cbFilterOffline.setUI(CHECKBOX_UI); // $hide$
    cbFilterOffline.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.OFFLINE));
    cbFilterOffline.setAction(actionFilter);
    add(cbFilterOffline, "2, 22");

    lblOffline = new JLabel(BUNDLE.getString("movieextendedsearch.offline")); //$NON-NLS-1$
    setComponentFont(lblOffline);
    add(lblOffline, "4, 22, right, default");

    cbOffline = new SmallComboBox(OfflineMovie.values());
    cbOffline.setAction(actionFilter);
    add(cbOffline, "6, 22, fill, default");

    JSeparator separator = new JSeparator();
    add(separator, "2, 24, 5, 1");

    JLabel lblSortBy = new JLabel(BUNDLE.getString("movieextendedsearch.sortby")); //$NON-NLS-1$
    setComponentFont(lblSortBy);
    add(lblSortBy, "2, 26, 3, 1");

    cbSortColumn = new SmallComboBox(SortColumn.values());
    setComponentFont(cbSortColumn);
    cbSortColumn.setAction(actionSort);
    add(cbSortColumn, "2, 28, 3, 1, fill, default");

    cbSortOrder = new SmallComboBox(SortOrder.values());
    setComponentFont(cbSortOrder);
    cbSortOrder.setAction(actionSort);
    add(cbSortOrder, "6, 28, fill, default");

    PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getSource() instanceof MovieList && "tag".equals(evt.getPropertyName())) {
                buildAndInstallTagsArray();
            }
            if (evt.getSource() instanceof MovieList && "videoCodec".equals(evt.getPropertyName())) {
                buildAndInstallCodecArray();
            }
            if (evt.getSource() instanceof MovieList && "audioCodec".equals(evt.getPropertyName())) {
                buildAndInstallCodecArray();
            }
            if (evt.getSource() instanceof MovieSettings && "movieDataSource".equals(evt.getPropertyName())) {
                buildAndInstallDatasourceArray();
            }
            if (evt.getSource() instanceof MovieList && "certification".equals(evt.getPropertyName())) {
                buildAndInstallCertificationArray();
            }
        }
    };
    movieList.addPropertyChangeListener(propertyChangeListener);
    MovieModuleManager.MOVIE_SETTINGS.addPropertyChangeListener(propertyChangeListener);
    buildAndInstallTagsArray();
    buildAndInstallCodecArray();
    buildAndInstallDatasourceArray();
    buildAndInstallCertificationArray();
}

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/* www .ja v a  2s. c o  m*/
        public void removeUpdate(DocumentEvent arg0) {
            createRenamerExample();
        }

        @Override
        public void insertUpdate(DocumentEvent arg0) {
            createRenamerExample();
        }

        @Override
        public void changedUpdate(DocumentEvent arg0) {
            createRenamerExample();
        }
    });

    JLabel lblMoviePath = new JLabel(BUNDLE.getString("Settings.renamer.folder")); //$NON-NLS-1$
    panelRenamer.add(lblMoviePath, "2, 4, right, default");
    panelRenamer.add(tfMoviePath, "4, 4, fill, default");
    tfMoviePath.setColumns(10);
    panelRenamer.add(chckbxSpaceSubstitution, "8, 4");

    cbSeparator = new JComboBox(separators.toArray());
    panelRenamer.add(cbSeparator, "10, 4, fill, default");
    cbSeparator.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            checkChanges();
            createRenamerExample();
        }
    });

    lblDefault1T = new JLabel(BUNDLE.getString("Settings.default"));
    TmmFontHelper.changeFont(lblDefault1T, 0.833);
    panelRenamer.add(lblDefault1T, "2, 6, right, top");

    lblDefaultFolderPattern = new JLabel(MovieSettings.DEFAULT_RENAMER_FOLDER_PATTERN);
    TmmFontHelper.changeFont(lblDefaultFolderPattern, 0.833);
    panelRenamer.add(lblDefaultFolderPattern, "4, 6, default, top");

    chckbxMoviesetSingleMovie = new JCheckBox(BUNDLE.getString("Settings.renamer.moviesetsinglemovie")); //$NON-NLS-1$
    chckbxMoviesetSingleMovie.addActionListener(actionCreateRenamerExample);
    panelRenamer.add(chckbxMoviesetSingleMovie, "8, 6, 5, 1, fill, default");

    lblMMDWarning = new JLabel(BUNDLE.getString("Settings.renamer.folder.warning")); //$NON-NLS-1$
    panelRenamer.add(lblMMDWarning, "2, 8, 11, 1");

    JLabel lblMovieFilename = new JLabel(BUNDLE.getString("Settings.renamer.file")); //$NON-NLS-1$
    panelRenamer.add(lblMovieFilename, "2, 10, right, fill");

    tfMovieFilename = new JTextField();
    tfMovieFilename.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(DocumentEvent arg0) {
            createRenamerExample();
        }

        @Override
        public void insertUpdate(DocumentEvent arg0) {
            createRenamerExample();
        }

        @Override
        public void changedUpdate(DocumentEvent arg0) {
            createRenamerExample();
        }
    });
    panelRenamer.add(tfMovieFilename, "4, 10, fill, default");
    tfMovieFilename.setColumns(10);
    lblMovieFilename.setLabelFor(tfMovieFilename);

    chckbxAsciiReplacement = new JCheckBox(BUNDLE.getString("Settings.renamer.asciireplacement")); //$NON-NLS-1$
    chckbxAsciiReplacement.addActionListener(actionCreateRenamerExample);
    panelRenamer.add(chckbxAsciiReplacement, "8, 10, 5, 1");

    lblDefault2T = new JLabel(BUNDLE.getString("Settings.default"));
    TmmFontHelper.changeFont(lblDefault2T, 0.833);
    panelRenamer.add(lblDefault2T, "2, 12, right, top");

    lblDefaultFilePattern = new JLabel(MovieSettings.DEFAULT_RENAMER_FILE_PATTERN);
    TmmFontHelper.changeFont(lblDefaultFilePattern, 0.833);
    panelRenamer.add(lblDefaultFilePattern, "4, 12, default, top");

    JTextPane txtpntAsciiHint = new JTextPane();
    txtpntAsciiHint.setOpaque(false);
    txtpntAsciiHint.setEditable(false);
    txtpntAsciiHint.setText(BUNDLE.getString("Settings.renamer.asciireplacement.hint")); //$NON-NLS-1$
    TmmFontHelper.changeFont(txtpntAsciiHint, 0.833);
    txtpntAsciiHint.setBackground(UIManager.getColor("Panel.background"));
    panelRenamer.add(txtpntAsciiHint, "8, 12, 5, 1, fill, fill");

    JTextPane txtrChooseAFolder = new JTextPane();
    txtrChooseAFolder.setOpaque(false);
    txtrChooseAFolder.setEditable(false);
    TmmFontHelper.changeFont(txtrChooseAFolder, 0.833);
    txtrChooseAFolder.setText(BUNDLE.getString("Settings.movie.renamer.example")); //$NON-NLS-1$
    txtrChooseAFolder.setBackground(UIManager.getColor("Panel.background"));
    panelRenamer.add(txtrChooseAFolder, "2, 14, 3, 3, fill, top");

    chckbxRemoveOtherNfos = new JCheckBox(BUNDLE.getString("Settings.renamer.removenfo")); //$NON-NLS-1$
    panelRenamer.add(chckbxRemoveOtherNfos, "8, 14, 5, 1");

    lblSubtitleLanguage = new JLabel(BUNDLE.getString("Settings.renamer.language")); //$NON-NLS-1$
    panelRenamer.add(lblSubtitleLanguage, "8, 16, right, default");

    cbSubtitleLanguage = new JComboBox(LanguageStyle.values());
    panelRenamer.add(cbSubtitleLanguage, "10, 16, 3, 1, fill, default");

    exampleEventList = GlazedLists.threadSafeList(new ObservableElementList<>(
            new BasicEventList<MovieRenamerExample>(), GlazedLists.beanConnector(MovieRenamerExample.class)));
    DefaultEventTableModel<MovieRenamerExample> exampleTableModel = new DefaultEventTableModel<>(
            GlazedListsSwing.swingThreadProxyList(exampleEventList), new MovieRenamerExampleTableFormat());

    panelExample = new JPanel();
    panelExample.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.example"), TitledBorder.LEADING, //$NON-NLS-1$
            TitledBorder.TOP, null, null));
    add(panelExample, "2, 4, fill, fill");
    panelExample.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("50dlu:grow"),
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, }));

    JLabel lblExampleT = new JLabel(BUNDLE.getString("tmm.movie")); //$NON-NLS-1$
    panelExample.add(lblExampleT, "2, 2");

    cbMovieForPreview = new JComboBox();
    panelExample.add(cbMovieForPreview, "4, 2");

    lblExample = new JLabel("");
    panelExample.add(lblExample, "2, 4, 3, 1");
    TmmFontHelper.changeFont(lblExample, 0.916, Font.BOLD);
    tableExamples = new ZebraJTable(exampleTableModel);
    scrollPane = ZebraJTable.createStripedJScrollPane(tableExamples);
    scrollPane.setViewportView(tableExamples);
    panelExample.add(scrollPane, "2, 6, 3, 1, fill, fill");

    JTextPane txtpntTitle = new JTextPane();
    txtpntTitle.setOpaque(false);
    panelExample.add(txtpntTitle, "2, 8, 3, 1");
    TmmFontHelper.changeFont(txtpntTitle, 0.833);
    txtpntTitle.setBackground(UIManager.getColor("Panel.background"));
    txtpntTitle.setText(BUNDLE.getString("Settings.movie.renamer.optional")); //$NON-NLS-1$
    txtpntTitle.setEditable(false);
    cbMovieForPreview.addActionListener(actionCreateRenamerExample);

    initDataBindings();

    // space separator
    String replacement = settings.getMovieRenamerSpaceReplacement();
    int index = separators.indexOf(replacement);
    if (index >= 0) {
        cbSeparator.setSelectedIndex(index);
    }

    // language style
    cbSubtitleLanguage.setSelectedItem(settings.getMovieRenamerLanguageStyle());

    // examples
    exampleEventList.add(new MovieRenamerExample("$T"));
    exampleEventList.add(new MovieRenamerExample("$O"));
    exampleEventList.add(new MovieRenamerExample("$1"));
    exampleEventList.add(new MovieRenamerExample("$E"));
    exampleEventList.add(new MovieRenamerExample("$2"));
    exampleEventList.add(new MovieRenamerExample("$Y"));
    exampleEventList.add(new MovieRenamerExample("$M"));
    exampleEventList.add(new MovieRenamerExample("$N"));
    exampleEventList.add(new MovieRenamerExample("$I"));
    exampleEventList.add(new MovieRenamerExample("$C"));
    exampleEventList.add(new MovieRenamerExample("$D"));
    exampleEventList.add(new MovieRenamerExample("$G"));
    exampleEventList.add(new MovieRenamerExample("$L"));
    exampleEventList.add(new MovieRenamerExample("$R"));
    exampleEventList.add(new MovieRenamerExample("$A"));
    exampleEventList.add(new MovieRenamerExample("$V"));
    exampleEventList.add(new MovieRenamerExample("$F"));
    exampleEventList.add(new MovieRenamerExample("$S"));
    exampleEventList.add(new MovieRenamerExample("$#"));
    exampleEventList.add(new MovieRenamerExample("$3"));
    exampleEventList.add(new MovieRenamerExample("$U"));
}