Example usage for javax.swing.event TableModelEvent getColumn

List of usage examples for javax.swing.event TableModelEvent getColumn

Introduction

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

Prototype

public int getColumn() 

Source Link

Document

Returns the column for the event.

Usage

From source file:org.hibernate.search.demo.SearchDemo.java

private void initWidgets() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setDefaultLookAndFeelDecorated(true);

    BorderLayout borderLayout = new BorderLayout();
    getContentPane().setLayout(borderLayout);

    // the main table
    model = new DefaultTableModel(headers, 0) {
        public boolean isCellEditable(int row, int column) {
            // at the moment only allows the editing of the title
            return column == 2;
        }//from w ww .j  a  v a 2  s.com
    };
    modelListener = new TableModelListener() {
        public void tableChanged(TableModelEvent e) {
            int row = e.getFirstRow();
            int column = e.getColumn();
            TableModel model = (TableModel) e.getSource();
            Object data = model.getValueAt(row, column);
            EntityManager em = emf.createEntityManager();
            updateTitle((Long) model.getValueAt(row, 0), (String) data);
            log.info("new value: {}", data);
        }
    };
    model.addTableModelListener(modelListener);
    final JTable table = new JTable(model);

    table.setFont(new Font("Courier New", Font.PLAIN, 14));
    getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);

    // build  the controls
    JPanel controlPanel = new JPanel();
    controlPanel.setLayout(new FlowLayout());

    final JTextField searchField = new JTextField(30);
    controlPanel.add(searchField);

    JButton searchButton = new JButton("Search");
    searchButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            List<Product> products;

            try {
                products = search(searchField.getText());
            } catch (ParseException pe) {
                JOptionPane.showMessageDialog(null, pe.getMessage(), "alert", JOptionPane.ERROR_MESSAGE);
                return;
            }

            DefaultTableModel model = (DefaultTableModel) table.getModel();
            model.removeTableModelListener(modelListener);
            model.setRowCount(0);
            for (int i = 0; i < products.size(); i++) {
                Object[] data = new Object[headers.length];
                Product p = products.get(i);
                data[0] = p.getProductId();
                data[1] = p.getASIN();
                data[2] = p.getTitle();
                //data[3] = p.getDescription();
                String actors = "";
                for (Actor actor : p.getActors()) {
                    actors = actors + actor.getName() + ", ";
                }
                data[3] = actors.length() == 0 ? actors : actors.substring(0, actors.length() - 2);
                String categories = "";
                for (Category category : p.getCategories()) {
                    categories = categories + category.getName() + ", ";
                }
                data[4] = categories.length() == 0 ? categories
                        : categories.substring(0, categories.length() - 2);
                model.insertRow(i, data);
            }
            model.addTableModelListener(modelListener);
        }
    });
    controlPanel.add(searchButton);

    JButton indexButton = new JButton("Index");
    indexButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            index();
        }
    });
    controlPanel.add(indexButton);

    JButton purgeButton = new JButton("Purge");
    purgeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            purge();
        }
    });
    controlPanel.add(purgeButton);

    getContentPane().add(controlPanel, BorderLayout.NORTH);
    getRootPane().setDefaultButton(searchButton);

    setSize(800, 200);
    setVisible(true);
}

From source file:org.nuclos.client.ui.collect.SubForm.java

public void setupTableModelListener() {
    this.tblmdllistener = new TableModelListener() {
        @Override/*from  w w  w.ja  va 2 s.co m*/
        public void tableChanged(TableModelEvent ev) {
            // recalculate the optimal column widths when custom column widths are not used yet and
            // a row is inserted (the first time):
            //@todo: this here is entered not only the first time a row is entered but also on startup (sort fires a tableDataChanged)
            if (!useCustomColumnWidths) {
                // Now this is an example for an API that sucks :(
                final boolean bRowsInserted = (ev.getType() == TableModelEvent.INSERT) ||
                // @todo: The first condition (INSERT) is clear, but what for the second (complete UPDATE)?
                (ev.getType() == TableModelEvent.UPDATE && ev.getColumn() == TableModelEvent.ALL_COLUMNS
                        && ev.getLastRow() == Integer.MAX_VALUE);
                if (bRowsInserted) {
                    resetDefaultColumnWidths();
                    LOG.debug("Custom column widths should be used here."); // Setting them manually.");
                }
            }
            // TableModelEvents caused by sorting don't change the subform state:
            if (!(ev instanceof SortableTableModelEvent)) {
                fireStateChanged();
            }
        }
    };
    subformtbl.getModel().addTableModelListener(this.tblmdllistener);
}

From source file:org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent.java

public void addViews() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();

    // Champ Module
    c.gridx = 0;// ww  w  . j  a  v a2  s . c  o  m
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
    this.setAdditionalFieldsPanel(new FormLayouter(addP, 1));
    this.add(addP, c);

    c.gridy++;
    c.gridwidth = 1;

    this.textTotalHT.setOpaque(false);
    this.textTotalTVA.setOpaque(false);
    this.textTotalTTC.setOpaque(false);

    this.selectCommande = new ElementComboBox();
    // Numero
    JLabel labelNum = new JLabel(getLabelFor("NUMERO"));
    labelNum.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(labelNum, c);

    this.textNumeroUnique = new JUniqueTextField(16);
    c.gridx++;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    DefaultGridBagConstraints.lockMinimumSize(this.textNumeroUnique);
    this.add(this.textNumeroUnique, c);

    // Date
    JLabel labelDate = new JLabel(getLabelFor("DATE"));
    labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx++;
    c.weightx = 0;
    this.add(labelDate, c);

    JDate date = new JDate(true);
    c.gridx++;
    c.weightx = 0;
    c.weighty = 0;
    this.add(date, c);
    // Reference
    c.gridy++;
    c.gridx = 0;
    final JLabel labelNom = new JLabel(getLabelFor("NOM"));
    labelNom.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(labelNom, c);
    c.gridx++;
    c.fill = GridBagConstraints.HORIZONTAL;
    DefaultGridBagConstraints.lockMinimumSize(this.textReference);
    this.add(this.textReference, c);
    // Fournisseur
    JLabel labelFournisseur = new JLabel(getLabelFor("ID_FOURNISSEUR"));
    labelFournisseur.setHorizontalAlignment(SwingConstants.RIGHT);
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.weighty = 0;
    this.add(labelFournisseur, c);

    this.fournisseur = new ElementComboBox();
    c.gridx++;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(this.fournisseur, c);

    // Devise
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c);

    final ElementComboBox boxDevise = new ElementComboBox();
    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(boxDevise, c);
    this.addView(boxDevise, "ID_DEVISE");

    // Element du bon
    this.tableBonItem = new BonReceptionItemTable();
    c.gridx = 0;
    c.gridy++;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    this.add(this.tableBonItem, c);
    this.fournisseur.addValueListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            tableBonItem.setFournisseur(fournisseur.getSelectedRow());
        }
    });

    c.anchor = GridBagConstraints.EAST;
    // Totaux
    reconfigure(this.textTotalHT);
    reconfigure(this.textTotalTVA);
    reconfigure(this.textTotalTTC);

    // Poids Total
    c.gridy++;
    c.gridx = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.EAST;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;

    DefaultProps props = DefaultNXProps.getInstance();
    Boolean b = props.getBooleanValue("ArticleShowPoids");
    if (b) {
        JPanel panelPoids = new JPanel(new GridBagLayout());
        GridBagConstraints c2 = new DefaultGridBagConstraints();
        c2.fill = GridBagConstraints.NONE;

        panelPoids.add(new JLabel(getLabelFor("TOTAL_POIDS")), c2);
        // Necessaire pour ne pas avoir de saut de layout
        DefaultGridBagConstraints.lockMinimumSize(this.textPoidsTotal);
        this.textPoidsTotal.setEnabled(false);
        this.textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT);
        this.textPoidsTotal.setDisabledTextColor(Color.BLACK);
        c2.gridx++;
        c2.weightx = 1;
        c2.fill = GridBagConstraints.HORIZONTAL;
        panelPoids.add(this.textPoidsTotal, c2);
        this.add(panelPoids, c);

    }

    c.gridx = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    final GridBagConstraints cTotalPan = new DefaultGridBagConstraints();

    JPanel panelTotalHT = new JPanel();
    panelTotalHT.setLayout(new GridBagLayout());
    cTotalPan.gridx = 0;
    cTotalPan.weightx = 0;
    cTotalPan.fill = GridBagConstraints.HORIZONTAL;
    cTotalPan.anchor = GridBagConstraints.WEST;
    final JLabelBold labelTotalHT = new JLabelBold(getLabelFor("TOTAL_HT"));
    panelTotalHT.add(labelTotalHT, cTotalPan);
    cTotalPan.anchor = GridBagConstraints.EAST;
    cTotalPan.gridx++;
    cTotalPan.weightx = 1;
    this.textTotalHT.setFont(labelTotalHT.getFont());
    DefaultGridBagConstraints.lockMinimumSize(this.textTotalHT);
    panelTotalHT.add(this.textTotalHT, cTotalPan);
    this.add(panelTotalHT, c);

    JPanel panelTotalTVA = new JPanel();
    panelTotalTVA.setLayout(new GridBagLayout());
    cTotalPan.gridx = 0;
    cTotalPan.weightx = 0;
    cTotalPan.anchor = GridBagConstraints.WEST;
    cTotalPan.fill = GridBagConstraints.HORIZONTAL;
    panelTotalTVA.add(new JLabelBold(getLabelFor("TOTAL_TVA")), cTotalPan);
    cTotalPan.anchor = GridBagConstraints.EAST;
    cTotalPan.gridx++;
    cTotalPan.weightx = 1;
    DefaultGridBagConstraints.lockMinimumSize(this.textTotalTVA);
    panelTotalTVA.add(this.textTotalTVA, cTotalPan);
    c.gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(panelTotalTVA, c);

    JPanel panelTotalTTC = new JPanel();
    panelTotalTTC.setLayout(new GridBagLayout());
    cTotalPan.gridx = 0;
    cTotalPan.anchor = GridBagConstraints.WEST;
    cTotalPan.gridwidth = GridBagConstraints.REMAINDER;
    cTotalPan.fill = GridBagConstraints.BOTH;
    cTotalPan.weightx = 1;
    panelTotalTTC.add(new JSeparator(), cTotalPan);
    cTotalPan.gridwidth = 1;
    cTotalPan.fill = GridBagConstraints.NONE;
    cTotalPan.weightx = 0;
    cTotalPan.gridy++;
    panelTotalTTC.add(new JLabelBold(getLabelFor("TOTAL_TTC")), cTotalPan);
    cTotalPan.anchor = GridBagConstraints.EAST;
    cTotalPan.gridx++;
    this.textTotalTTC.setFont(labelTotalHT.getFont());
    DefaultGridBagConstraints.lockMinimumSize(this.textTotalTTC);
    panelTotalTTC.add(this.textTotalTTC, cTotalPan);
    c.gridy++;
    // probleme de tremblement vertical
    this.add(panelTotalTTC, c);
    c.anchor = GridBagConstraints.WEST;

    /*******************************************************************************************
     * * INFORMATIONS COMPLEMENTAIRES
     ******************************************************************************************/
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy++;
    TitledSeparator sep = new TitledSeparator("Informations complmentaires");
    c.insets = new Insets(10, 2, 1, 2);
    this.add(sep, c);
    c.insets = new Insets(2, 2, 1, 2);

    c.gridx = 0;
    c.gridy++;
    c.gridheight = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.BOTH;
    final ITextArea textInfos = new ITextArea(4, 4);
    JScrollPane scrollPane = new JScrollPane(textInfos);
    DefaultGridBagConstraints.lockMinimumSize(scrollPane);

    this.add(textInfos, c);

    this.addRequiredSQLObject(date, "DATE");
    this.addSQLObject(textInfos, "INFOS");
    this.addSQLObject(this.textReference, "NOM");
    this.addSQLObject(this.selectCommande, "ID_COMMANDE");
    this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO");
    this.addSQLObject(this.textPoidsTotal, "TOTAL_POIDS");
    this.addRequiredSQLObject(this.textTotalHT, "TOTAL_HT");
    this.addRequiredSQLObject(this.textTotalTVA, "TOTAL_TVA");
    this.addRequiredSQLObject(this.textTotalTTC, "TOTAL_TTC");
    this.addRequiredSQLObject(this.fournisseur, "ID_FOURNISSEUR");

    this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(BonReceptionSQLElement.class));

    // Listeners
    this.tableBonItem.getModel().addTableModelListener(new TableModelListener() {
        public void tableChanged(TableModelEvent e) {

            int columnIndexHT = BonReceptionSQLComponent.this.tableBonItem.getModel().getColumnIndexForElement(
                    BonReceptionSQLComponent.this.tableBonItem.getPrixTotalHTElement());
            int columnIndexTTC = BonReceptionSQLComponent.this.tableBonItem.getModel().getColumnIndexForElement(
                    BonReceptionSQLComponent.this.tableBonItem.getPrixTotalTTCElement());
            int columnIndexPoids = BonReceptionSQLComponent.this.tableBonItem.getModel()
                    .getColumnIndexForElement(
                            BonReceptionSQLComponent.this.tableBonItem.getPoidsTotalElement());

            if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == columnIndexHT
                    || e.getColumn() == columnIndexTTC) {
                updateTotal();
            }
            if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == columnIndexPoids) {
                BonReceptionSQLComponent.this.textPoidsTotal.setText(String
                        .valueOf(Math.round(BonReceptionSQLComponent.this.tableBonItem.getPoidsTotal() * 1000)
                                / 1000.0));
            }
        }
    });

    // Lock UI
    DefaultGridBagConstraints.lockMinimumSize(this.fournisseur);

}

From source file:org.tinymediamanager.ui.movies.dialogs.MovieEditorDialog.java

/**
 * Create the dialog.// ww  w . ja v  a  2  s .  com
 * 
 * @param movie
 *          the movie
 * @param inQueue
 *          the in queue
 */
public MovieEditorDialog(Movie movie, boolean inQueue) {
    super(BUNDLE.getString("movie.edit"), "movieEditor"); //$NON-NLS-1$
    setBounds(5, 5, 950, 650);

    movieToEdit = movie;
    ids = MediaIdTable.convertIdMapToEventList(movieToEdit.getIds());
    for (MediaFile mf : movie.getMediaFiles()) {
        mediaFiles.add(new MediaFile(mf));
    }

    getContentPane().setLayout(new BorderLayout());
    {
        JPanel panelPath = new JPanel();
        getContentPane().add(panelPath, BorderLayout.NORTH);
        panelPath.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("15px"),
                        FormFactory.RELATED_GAP_ROWSPEC, }));

        JLabel lblMoviePathT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$
        panelPath.add(lblMoviePathT, "2, 2, left, top");

        lblMoviePath = new JLabel("");
        TmmFontHelper.changeFont(lblMoviePath, 1.166, Font.BOLD);
        panelPath.add(lblMoviePath, "5, 2, left, top");
    }

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.NORTH);
    getContentPane().add(tabbedPane, BorderLayout.CENTER);

    /**
     * DetailsPanel 1
     */
    {
        details1Panel.setBorder(new EmptyBorder(5, 5, 5, 5));
        details1Panel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC,
                ColumnSpec.decode("max(40dlu;default)"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"),
                FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                ColumnSpec.decode("25dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("24dlu"),
                FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow(2)"),
                FormSpecs.RELATED_GAP_COLSPEC, },
                new 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.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("50px:grow"),
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        RowSpec.decode("15dlu"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        RowSpec.decode("fill:50dlu:grow"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        RowSpec.decode("50px"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        RowSpec.decode("fill:default:grow"), }));

        {
            JLabel lblTitle = new JLabel(BUNDLE.getString("metatag.title")); //$NON-NLS-1$
            details1Panel.add(lblTitle, "2, 4, right, default");
        }
        {
            tfTitle = new JTextField();
            details1Panel.add(tfTitle, "4, 4, 15, 1, fill, default");
            tfTitle.setColumns(10);
        }
        {
            // JLabel lblPoster = new JLabel("");
            lblPoster = new ImageLabel();
            lblPoster.setAlternativeText(BUNDLE.getString("image.notfound.poster")); //$NON-NLS-1$
            lblPoster.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.POSTER,
                            movieList.getDefaultArtworkScrapers(), lblPoster, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblPoster.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            details1Panel.add(lblPoster, "22, 4, 3, 23, fill, fill");
        }
        {
            JLabel lblOriginalTitle = new JLabel(BUNDLE.getString("metatag.originaltitle")); //$NON-NLS-1$
            details1Panel.add(lblOriginalTitle, "2, 6, right, default");
        }
        {
            tfOriginalTitle = new JTextField();
            details1Panel.add(tfOriginalTitle, "4, 6, 15, 1, fill, top");
            tfOriginalTitle.setColumns(10);
        }
        {
            JLabel lblSorttitle = new JLabel(BUNDLE.getString("metatag.sorttitle")); //$NON-NLS-1$
            details1Panel.add(lblSorttitle, "2, 8, right, default");
        }
        {
            tfSorttitle = new JTextField();
            details1Panel.add(tfSorttitle, "4, 8, 15, 1, fill, default");
            tfSorttitle.setColumns(10);
        }
        {
            JLabel lblTagline = new JLabel(BUNDLE.getString("metatag.tagline")); //$NON-NLS-1$
            details1Panel.add(lblTagline, "2, 10, right, top");
        }
        {
            JScrollPane scrollPaneTagline = new JScrollPane();
            tpTagline = new JTextPane();
            scrollPaneTagline.setViewportView(tpTagline);
            details1Panel.add(scrollPaneTagline, "4, 10, 15, 1, fill, fill");
        }
        {
            JLabel lblYear = new JLabel(BUNDLE.getString("metatag.year")); //$NON-NLS-1$
            details1Panel.add(lblYear, "2, 12, right, default");
        }
        {
            spYear = new YearSpinner();
            details1Panel.add(spYear, "4, 12, fill, top");
        }
        {
            JLabel lblRuntime = new JLabel(BUNDLE.getString("metatag.runtime")); //$NON-NLS-1$
            details1Panel.add(lblRuntime, "8, 12, right, default");
        }
        {
            spRuntime = new JSpinner();
            details1Panel.add(spRuntime, "10, 12, fill, default");
        }
        {
            JLabel lblMin = new JLabel(BUNDLE.getString("metatag.minutes")); //$NON-NLS-1$
            details1Panel.add(lblMin, "12, 12");
        }
        {
            JLabel lblRating = new JLabel(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$
            details1Panel.add(lblRating, "16, 12, right, default");
        }
        {
            spRating = new JSpinner();
            details1Panel.add(spRating, "18, 12");
        }

        spRating.setModel(new SpinnerNumberModel(movie.getRating(), 0.0, 10.0, 0.1));
        {
            JLabel lblReleaseDate = new JLabel(BUNDLE.getString("metatag.releasedate")); //$NON-NLS-1$
            details1Panel.add(lblReleaseDate, "2, 14, right, default");
        }
        {
            dpReleaseDate = new DatePicker(movie.getReleaseDate());
            details1Panel.add(dpReleaseDate, "4, 14");
        }
        {
            JLabel lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$
            details1Panel.add(lblCertification, "8, 14, right, default");
        }
        cbCertification = new JComboBox();
        details1Panel.add(cbCertification, "10, 14, 3, 1, fill, default");
        {
            JLabel lblTop = new JLabel(BUNDLE.getString("metatag.top250")); //$NON-NLS-1$
            details1Panel.add(lblTop, "16, 14, right, default");
        }
        {
            spTop250 = new JSpinner();
            details1Panel.add(spTop250, "18, 14");
        }
        spTop250.setValue(movie.getTop250());
        {
            JLabel lblIds = new JLabel("Ids");
            details1Panel.add(lblIds, "2, 16, right, bottom");
        }
        {
            JScrollPane scrollPaneIds = new JScrollPane();
            details1Panel.add(scrollPaneIds, "4, 16, 9, 5, fill, fill");
            {
                tableIds = new MediaIdTable(ids, ScraperType.MOVIE);
                scrollPaneIds.setViewportView(tableIds);
            }
        }
        {
            JButton btnAddId = new JButton("");
            btnAddId.setAction(new AddIdAction());
            btnAddId.setIcon(IconManager.LIST_ADD);
            btnAddId.setMargin(new Insets(2, 2, 2, 2));
            details1Panel.add(btnAddId, "2, 18, right, top");
        }
        {
            JButton btnRemoveId = new JButton("");
            btnRemoveId.setAction(new RemoveIdAction());
            btnRemoveId.setIcon(IconManager.LIST_REMOVE);
            btnRemoveId.setMargin(new Insets(2, 2, 2, 2));
            details1Panel.add(btnRemoveId, "2, 20, right, top");
        }
        {
            JLabel lblSpokenLanguages = new JLabel(BUNDLE.getString("metatag.spokenlanguages")); //$NON-NLS-1$
            details1Panel.add(lblSpokenLanguages, "2, 22, right, default");
        }
        {
            tfSpokenLanguages = new JTextField();
            details1Panel.add(tfSpokenLanguages, "4, 22, fill, default");
            tfSpokenLanguages.setColumns(10);
        }
        {
            JLabel lblCountry = new JLabel(BUNDLE.getString("metatag.country")); //$NON-NLS-1$
            details1Panel.add(lblCountry, "8, 22, right, default");
        }
        {
            tfCountry = new JTextField();
            details1Panel.add(tfCountry, "10, 22, 3, 1, fill, default");
            tfCountry.setColumns(10);
        }
        {
            JLabel lblMovieSet = new JLabel(BUNDLE.getString("metatag.movieset")); //$NON-NLS-1$
            details1Panel.add(lblMovieSet, "2, 24, right, default");
        }
        {
            cbMovieSet = new JComboBox();
            cbMovieSet.addItem("");
            details1Panel.add(cbMovieSet, "4, 24, 9, 1, fill, default");
        }
        {
            JLabel lblDateAdded = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$
            details1Panel.add(lblDateAdded, "2, 26, right, default");
        }
        {
            spDateAdded = new JSpinner(new SpinnerDateModel());
            // JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(spDateAdded,
            // "dd.MM.yyyy HH:mm:ss");
            // spDateAdded.setEditor(timeEditor);
            details1Panel.add(spDateAdded, "4, 26");
        }
        spDateAdded.setValue(movie.getDateAdded());
        JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$
        details1Panel.add(lblWatched, "8, 26, right, default");
        {
            cbWatched = new JCheckBox("");
            details1Panel.add(cbWatched, "10, 26");
        }
        cbWatched.setSelected(movie.isWatched());
        lblWatched.setLabelFor(cbWatched);
        {
            JLabel lblSourceT = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$
            details1Panel.add(lblSourceT, "2, 28, right, default");
        }
        {
            cbSource = new JComboBox(MediaSource.values());
            details1Panel.add(cbSource, "4, 28, fill, default");
        }
        cbSource.setSelectedItem(movie.getMediaSource());
        {
            final JLabel lblEditionT = new JLabel(BUNDLE.getString("metatag.edition")); //$NON-NLS-1$
            details1Panel.add(lblEditionT, "8, 28, right, default");
        }
        {
            cbEdition = new JComboBox(MovieEdition.values());
            details1Panel.add(cbEdition, "10, 28, 3, 1, fill, default");
        }
        {
            JLabel lblVideod = new JLabel(BUNDLE.getString("metatag.3d")); //$NON-NLS-1$
            details1Panel.add(lblVideod, "16, 28, right, default");
        }
        {
            chckbxVideo3D = new JCheckBox("");
            details1Panel.add(chckbxVideo3D, "18, 28");
        }
        chckbxVideo3D.setSelected(movie.isVideoIn3D());
        {
            JLabel lblPlot = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$
            details1Panel.add(lblPlot, "2, 30, right, top");
        }
        {
            JScrollPane scrollPanePlot = new JScrollPane();
            details1Panel.add(scrollPanePlot, "4, 30, 15, 1, fill, fill");
            {
                tpPlot = new JTextPane();
                scrollPanePlot.setViewportView(tpPlot);
            }
        }
        {
            lblFanart = new ImageLabel();
            lblFanart.setAlternativeText(BUNDLE.getString("image.notfound.fanart")); //$NON-NLS-1$
            lblFanart.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            lblFanart.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.FANART,
                            movieList.getDefaultArtworkScrapers(), lblFanart, extrathumbs, extrafanarts,
                            MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            details1Panel.add(lblFanart, "22, 30, 3, 5, fill, fill");
        }
        lblFanart.setImagePath(movie.getArtworkFilename(MediaFileType.FANART));
        {
            JLabel lblDirector = new JLabel(BUNDLE.getString("metatag.director")); //$NON-NLS-1$
            details1Panel.add(lblDirector, "2, 32, right, default");
        }
        {
            tfDirector = new JTextField();
            details1Panel.add(tfDirector, "4, 32, 15, 1, fill, top");
            tfDirector.setColumns(10);
        }
        {
            JLabel lblWriter = new JLabel(BUNDLE.getString("metatag.writer")); //$NON-NLS-1$
            details1Panel.add(lblWriter, "2, 34, right, default");
        }
        {
            tfWriter = new JTextField();
            details1Panel.add(tfWriter, "4, 34, 15, 1, fill, top");
            tfWriter.setColumns(10);
        }
        {
            JLabel lblCompany = new JLabel(BUNDLE.getString("metatag.production")); //$NON-NLS-1$
            details1Panel.add(lblCompany, "2, 36, right, top");
        }
        {
            JScrollPane scrollPaneProduction = new JScrollPane();
            details1Panel.add(scrollPaneProduction, "4, 36, 15, 1, fill, fill");
            tfProductionCompanies = new JTextPane();
            scrollPaneProduction.setViewportView(tfProductionCompanies);
        }
        tabbedPane.addTab(BUNDLE.getString("metatag.details"), details1Panel); //$NON-NLS-1$
    }

    /**
     * DetailsPanel 2
     */
    {
        tabbedPane.addTab(BUNDLE.getString("metatag.details2"), details2Panel); //$NON-NLS-1$
        details2Panel.setBorder(new EmptyBorder(5, 5, 5, 5));
        details2Panel.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(40dlu;default)"),
                        FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"),
                        FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("100px: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("fill:default"),
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow(2)"), }));
        {
            JLabel lblActors = new JLabel(BUNDLE.getString("metatag.actors")); //$NON-NLS-1$
            details2Panel.add(lblActors, "2, 2, right, default");
        }
        {
            JScrollPane scrollPane = new JScrollPane();
            details2Panel.add(scrollPane, "4, 2, 1, 11");
            tableActors = new JTable();
            tableActors.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
            scrollPane.setViewportView(tableActors);
        }
        {
            JLabel lblProducers = new JLabel(BUNDLE.getString("metatag.producers")); //$NON-NLS-1$
            details2Panel.add(lblProducers, "6, 2, right, default");
        }
        {
            JScrollPane scrollPane = new JScrollPane();
            details2Panel.add(scrollPane, "8, 2, 1, 11");
            tableProducers = new JTable();
            tableProducers.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
            scrollPane.setViewportView(tableProducers);
        }
        {
            JButton btnAddActor = new JButton(BUNDLE.getString("cast.actor.add")); //$NON-NLS-1$
            btnAddActor.setMargin(new Insets(2, 2, 2, 2));
            btnAddActor.setAction(new AddActorAction());
            btnAddActor.setIcon(IconManager.LIST_ADD);
            details2Panel.add(btnAddActor, "2, 4, right, top");
        }
        {
            JButton btnAddProducer = new JButton((String) null);
            btnAddProducer.setMargin(new Insets(2, 2, 2, 2));
            btnAddProducer.setAction(new AddProducerAction());
            btnAddProducer.setIcon(IconManager.LIST_ADD);
            details2Panel.add(btnAddProducer, "6, 4, right, top");
        }
        {
            JButton btnRemoveActor = new JButton(BUNDLE.getString("cast.actor.remove")); //$NON-NLS-1$
            btnRemoveActor.setMargin(new Insets(2, 2, 2, 2));
            btnRemoveActor.setAction(new RemoveActorAction());
            btnRemoveActor.setIcon(IconManager.LIST_REMOVE);
            details2Panel.add(btnRemoveActor, "2,6, right, top");
        }
        {
            JButton btnRemoveProducer = new JButton((String) null);
            btnRemoveProducer.setMargin(new Insets(2, 2, 2, 2));
            btnRemoveProducer.setAction(new RemoveProducerAction());
            btnRemoveProducer.setIcon(IconManager.LIST_REMOVE);
            details2Panel.add(btnRemoveProducer, "6, 6, right, top");
        }
        {
            JButton btnMoveActorUp = new JButton((String) null);
            btnMoveActorUp.setMargin(new Insets(2, 2, 2, 2));
            btnMoveActorUp.setAction(new MoveActorUpAction());
            btnMoveActorUp.setIcon(IconManager.ARROW_UP);
            details2Panel.add(btnMoveActorUp, "2, 8, right, top");
        }
        {
            JButton btnMoveProducerUp = new JButton((String) null);
            btnMoveProducerUp.setMargin(new Insets(2, 2, 2, 2));
            btnMoveProducerUp.setAction(new MoveProducerUpAction());
            btnMoveProducerUp.setIcon(IconManager.ARROW_UP);
            details2Panel.add(btnMoveProducerUp, "6, 8, right, top");
        }
        {
            JButton btnMoveActorDown = new JButton((String) null);
            btnMoveActorDown.setMargin(new Insets(2, 2, 2, 2));
            btnMoveActorDown.setAction(new MoveActorDownAction());
            btnMoveActorDown.setIcon(IconManager.ARROW_DOWN);
            details2Panel.add(btnMoveActorDown, "2, 10, right, top");
        }
        {
            JButton btnMoveProducerDown = new JButton((String) null);
            btnMoveProducerDown.setMargin(new Insets(2, 2, 2, 2));
            btnMoveProducerDown.setAction(new MoveProducerDownAction());
            btnMoveProducerDown.setIcon(IconManager.ARROW_DOWN);
            details2Panel.add(btnMoveProducerDown, "6, 10, right, top");
        }
        {
            JLabel lblGenres = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$
            details2Panel.add(lblGenres, "2, 14, right, default");
        }
        {
            JScrollPane scrollPaneGenres = new JScrollPane();
            details2Panel.add(scrollPaneGenres, "4, 14, 1, 5");
            {
                listGenres = new JList();
                scrollPaneGenres.setViewportView(listGenres);
            }
        }
        {
            JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$
            details2Panel.add(lblTags, "6, 14, right, default");
        }
        {
            JScrollPane scrollPaneTags = new JScrollPane();
            details2Panel.add(scrollPaneTags, "8, 14, 1, 5");
            listTags = new JList();
            scrollPaneTags.setViewportView(listTags);
        }
        {
            JButton btnAddGenre = new JButton("");
            btnAddGenre.setAction(new AddGenreAction());
            btnAddGenre.setIcon(IconManager.LIST_ADD);
            btnAddGenre.setMargin(new Insets(2, 2, 2, 2));
            details2Panel.add(btnAddGenre, "2, 16, right, top");
        }
        {
            JButton btnAddTag = new JButton("");
            btnAddTag.setAction(new AddTagAction());
            btnAddTag.setIcon(IconManager.LIST_ADD);
            btnAddTag.setMargin(new Insets(2, 2, 2, 2));
            details2Panel.add(btnAddTag, "6, 16, right, top");
        }

        {
            JButton btnRemoveGenre = new JButton("");
            btnRemoveGenre.setAction(new RemoveGenreAction());
            btnRemoveGenre.setMargin(new Insets(2, 2, 2, 2));
            btnRemoveGenre.setIcon(IconManager.LIST_REMOVE);
            details2Panel.add(btnRemoveGenre, "2, 18, right, top");
        }
        {
            JButton btnRemoveTag = new JButton("");
            btnRemoveTag.setAction(new RemoveTagAction());
            btnRemoveTag.setIcon(IconManager.LIST_REMOVE);
            btnRemoveTag.setMargin(new Insets(2, 2, 2, 2));
            details2Panel.add(btnRemoveTag, "6, 18, right, top");
        }
        {
            cbGenres = new AutocompleteComboBox(MediaGenres.values());
            details2Panel.add(cbGenres, "4, 20");
        }
        {
            cbTags = new AutocompleteComboBox(movieList.getTagsInMovies());
            details2Panel.add(cbTags, "8, 20");
        }

        {
            JLabel lblTrailer = new JLabel(BUNDLE.getString("metatag.trailer")); //$NON-NLS-1$
            details2Panel.add(lblTrailer, "2, 22, right, default");
        }
        {
            JScrollPane scrollPaneTrailer = new JScrollPane();
            details2Panel.add(scrollPaneTrailer, "4, 22, 5, 5");
            tableTrailer = new JTable();
            tableTrailer.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
            scrollPaneTrailer.setViewportView(tableTrailer);
        }
        {
            JButton btnAddTrailer = new JButton("");
            btnAddTrailer.setAction(new AddTrailerAction());
            btnAddTrailer.setIcon(IconManager.LIST_ADD);
            btnAddTrailer.setMargin(new Insets(2, 2, 2, 2));
            details2Panel.add(btnAddTrailer, "2, 24, right, top");
        }
        {
            JButton btnRemoveTrailer = new JButton("");
            btnRemoveTrailer.setAction(new RemoveTrailerAction());
            btnRemoveTrailer.setIcon(IconManager.LIST_REMOVE);
            btnRemoveTrailer.setMargin(new Insets(2, 2, 2, 2));
            details2Panel.add(btnRemoveTrailer, "2, 26, right, top");
        }
    }

    /**
     * extra artwork pane
     */
    {
        JPanel artworkPanel = new JPanel();
        tabbedPane.addTab(BUNDLE.getString("metatag.extraartwork"), null, artworkPanel, null); //$NON-NLS-1$
        artworkPanel.setLayout(new FormLayout(
                new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"),
                        FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"),
                        FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150px:grow"),
                        FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("50px:grow(2)"),
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        RowSpec.decode("50px:grow(2)"), FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        RowSpec.decode("200px:grow(2)"), FormSpecs.RELATED_GAP_ROWSPEC,
                        RowSpec.decode("default:grow"), }));
        {
            JLabel lblLogoT = new JLabel(BUNDLE.getString("mediafiletype.logo")); //$NON-NLS-1$
            artworkPanel.add(lblLogoT, "2, 2");
        }
        {
            lblLogo = new ImageLabel();
            lblLogo.setAlternativeText(BUNDLE.getString("image.notfound.logo")); //$NON-NLS-1$
            lblLogo.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.LOGO,
                            movieList.getDefaultArtworkScrapers(), lblLogo, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblLogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblLogo, "2, 4, fill, fill");
        }
        {
            final JLabel lblClearlogoT = new JLabel(BUNDLE.getString("mediafiletype.clearlogo")); //$NON-NLS-1$
            artworkPanel.add(lblClearlogoT, "4, 2");
        }
        {
            lblClearlogo = new ImageLabel();
            lblClearlogo.setAlternativeText(BUNDLE.getString("image.notfound.clearlogo")); //$NON-NLS-1$
            lblClearlogo.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(),
                            ImageType.CLEARLOGO, movieList.getDefaultArtworkScrapers(), lblClearlogo, null,
                            null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblClearlogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblClearlogo, "4, 4, fill, fill");
        }
        {
            JLabel lblBannerT = new JLabel(BUNDLE.getString("mediafiletype.banner")); //$NON-NLS-1$
            artworkPanel.add(lblBannerT, "2, 6");
        }
        {
            lblBanner = new ImageLabel();
            lblBanner.setAlternativeText(BUNDLE.getString("image.notfound.banner")); //$NON-NLS-1$
            lblBanner.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.BANNER,
                            movieList.getDefaultArtworkScrapers(), lblBanner, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblBanner.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblBanner, "2, 8, 3, 1, fill, fill");
        }

        {
            JLabel lblClearartT = new JLabel("ClearArt");
            artworkPanel.add(lblClearartT, "2, 10");
        }
        {
            lblClearart = new ImageLabel();
            lblClearart.setAlternativeText(BUNDLE.getString("image.notfound.clearart")); //$NON-NLS-1$
            lblClearart.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.CLEARART,
                            movieList.getDefaultArtworkScrapers(), lblClearart, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblClearart.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblClearart, "2, 12, fill, fill");
        }
        {
            JLabel lblThumbT = new JLabel("Thumb");
            artworkPanel.add(lblThumbT, "4, 10");
        }
        {
            lblThumb = new ImageLabel();
            lblThumb.setAlternativeText(BUNDLE.getString("image.notfound.thumb")); //$NON-NLS-1$
            lblThumb.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.THUMB,
                            movieList.getDefaultArtworkScrapers(), lblThumb, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblThumb.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblThumb, "4, 12, fill, fill");
        }
        {
            JLabel lblDiscT = new JLabel("Disc");
            artworkPanel.add(lblDiscT, "6, 10");
        }
        {
            lblDisc = new ImageLabel();
            lblDisc.setAlternativeText(BUNDLE.getString("image.notfound.disc")); //$NON-NLS-1$
            lblDisc.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.DISC,
                            movieList.getDefaultArtworkScrapers(), lblDisc, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblDisc.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblDisc, "6, 12, fill, fill");
        }
    }

    /**
     * Media Files
     */
    {
        mediaFilesPanel = new MediaFileEditorPanel(mediaFiles);
        tabbedPane.addTab(BUNDLE.getString("metatag.mediafiles"), null, mediaFilesPanel, null); //$NON-NLS-1$
    }

    /**
     * Button pane
     */
    {
        JPanel bottomPane = new JPanel();
        getContentPane().add(bottomPane, BorderLayout.SOUTH);
        bottomPane.setLayout(new FormLayout(
                new ColumnSpec[] { ColumnSpec.decode("371px:grow"), FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.LINE_GAP_ROWSPEC, }));

        JPanel buttonPane = new JPanel();
        bottomPane.add(buttonPane, "2, 2, left, top");
        EqualsLayout layout = new EqualsLayout(5);
        layout.setMinWidth(100);
        buttonPane.setLayout(layout);
        {
            JButton okButton = new JButton(BUNDLE.getString("Button.ok")); //$NON-NLS-1$
            buttonPane.add(okButton, "2, 1, fill, top");
            okButton.setAction(new ChangeMovieAction());
            okButton.setActionCommand("OK");
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$
            buttonPane.add(cancelButton, "4, 1, fill, top");
            cancelButton.setAction(new DiscardAction());
            cancelButton.setActionCommand("Cancel");
        }
        if (inQueue) {
            JButton btnAbort = new JButton(BUNDLE.getString("Button.abortqueue")); //$NON-NLS-1$
            btnAbort.setAction(new AbortQueueAction());
            buttonPane.add(btnAbort, "6, 1, fill, top");
        }

    }
    initDataBindings();

    {
        int year = 0;
        try {
            year = Integer.parseInt(movieToEdit.getYear());
        } catch (Exception ignored) {
        }

        SimpleDateFormat dateFormat = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.MEDIUM);

        for (Certification cert : Certification
                .getCertificationsforCountry(MovieModuleManager.MOVIE_SETTINGS.getCertificationCountry())) {
            cbCertification.addItem(cert);
        }

        tfTitle.setText(movieToEdit.getTitle());
        tfOriginalTitle.setText(movieToEdit.getOriginalTitle());
        tfSorttitle.setText(movieToEdit.getSortTitle());
        tpTagline.setText(movieToEdit.getTagline());
        tpPlot.setText(movieToEdit.getPlot());
        tpPlot.setCaretPosition(0);
        tfDirector.setText(movieToEdit.getDirector());
        tfWriter.setText(movieToEdit.getWriter());
        lblPoster.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.POSTER));
        tfProductionCompanies.setText(movieToEdit.getProductionCompany());
        spRuntime.setValue(movieToEdit.getRuntime());
        cbEdition.setSelectedItem(movieToEdit.getEdition());

        tfSpokenLanguages.setText(movieToEdit.getSpokenLanguages());
        tfCountry.setText(movieToEdit.getCountry());
        spYear.setValue(year);
        cbCertification.setSelectedItem(movieToEdit.getCertification());

        lblMoviePath.setText(movieToEdit.getPath());
        lblLogo.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.LOGO));
        lblClearlogo.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.CLEARLOGO));
        lblClearart.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.CLEARART));
        lblThumb.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.THUMB));
        lblDisc.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.DISCART));
        lblBanner.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.BANNER));

        for (MovieActor origCast : movieToEdit.getActors()) {
            MovieActor actor = new MovieActor();
            actor.setName(origCast.getName());
            actor.setCharacter(origCast.getCharacter());
            actor.setThumbUrl(origCast.getThumbUrl());
            cast.add(actor);
        }

        for (MovieProducer origProducer : movieToEdit.getProducers()) {
            MovieProducer producer = new MovieProducer();
            producer.setName(origProducer.getName());
            producer.setRole(origProducer.getRole());
            producer.setThumbUrl(origProducer.getThumbUrl());
            producers.add(producer);
        }

        for (MediaGenres genre : movieToEdit.getGenres()) {
            genres.add(genre);
        }

        for (MovieTrailer trailer : movieToEdit.getTrailer()) {
            trailers.add(trailer);
        }

        for (String tag : movieToEdit.getTags()) {
            if (StringUtils.isNotBlank(tag)) {
                tags.add(tag);
            }
        }

        extrathumbs.addAll(movieToEdit.getExtraThumbs());
        extrafanarts.addAll(movieToEdit.getExtraFanarts());
        for (MovieSet movieSet : movieList.getSortedMovieSetList()) {
            cbMovieSet.addItem(movieSet);
            if (movieToEdit.getMovieSet() == movieSet) {
                cbMovieSet.setSelectedItem(movieSet);
            }
        }
    }
    // adjust columnn titles - we have to do it this way - thx to windowbuilder pro
    tableActors.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$
    tableActors.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$
    tableProducers.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$
    tableProducers.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$

    tableTrailer.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.nfo")); //$NON-NLS-1$
    tableTrailer.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$
    tableTrailer.getColumnModel().getColumn(2).setHeaderValue(BUNDLE.getString("metatag.source")); //$NON-NLS-1$
    tableTrailer.getColumnModel().getColumn(3).setHeaderValue(BUNDLE.getString("metatag.quality")); //$NON-NLS-1$
    tableTrailer.getColumnModel().getColumn(4).setHeaderValue(BUNDLE.getString("metatag.url")); //$NON-NLS-1$

    // adjust table columns
    tableTrailer.getColumnModel().getColumn(0).setMaxWidth(55);

    // implement listener to simulate button group
    tableTrailer.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            // click on the checkbox
            if (arg0.getColumn() == 0) {
                int row = arg0.getFirstRow();
                MovieTrailer changedTrailer = trailers.get(row);
                // if flag inNFO was changed, change all other trailers flags
                if (changedTrailer.getInNfo()) {
                    for (MovieTrailer trailer : trailers) {
                        if (trailer != changedTrailer) {
                            trailer.setInNfo(Boolean.FALSE);
                        }
                    }
                }
            }
        }
    });
}

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

private void initComponents() {
    // data init//from  w w  w . j  a  v  a 2s  . c  om
    List<String> enabledSubtitleProviders = settings.getMovieSubtitleScrapers();
    int selectedIndex = -1;
    int counter = 0;
    for (MediaScraper scraper : MovieList.getInstance().getAvailableSubtitleScrapers()) {
        SubtitleScraper subtitleScraper = new SubtitleScraper(scraper);
        if (enabledSubtitleProviders.contains(subtitleScraper.getScraperId())) {
            subtitleScraper.active = true;
            if (selectedIndex < 0) {
                selectedIndex = counter;
            }
        }
        scrapers.add(subtitleScraper);
        counter++;
    }

    // UI init
    setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    JPanel panelSubtitleScrapers = new JPanel();
    panelSubtitleScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"),
            BUNDLE.getString("scraper.subtitle"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$
    add(panelSubtitleScrapers, "2, 2, 5, 1, fill, fill");
    panelSubtitleScrapers.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), }));

    final JScrollPane scrollPaneScraperDetails = new JScrollPane();
    scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPaneScraperDetails.setBorder(null);
    panelSubtitleScrapers.add(scrollPaneScraperDetails, "4, 1, 1, 2, fill, fill");

    JPanel panelScraperDetails = new JPanel();
    scrollPaneScraperDetails.setViewportView(panelScraperDetails);
    panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, }));
    {
        // add a CSS rule to force body tags to use the default label font
        // instead of the value in javax.swing.text.html.default.csss
        Font font = UIManager.getFont("Label.font");
        String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize()
                + "pt; }";
        tpScraperDescription = new JTextPane();
        tpScraperDescription.setOpaque(false);
        tpScraperDescription.setEditorKit(new HTMLEditorKit());
        ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule);
        panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top");
    }
    panelScraperOptions = new ScrollablePanel();
    panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT));
    panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top");

    JScrollPane scrollPaneScraper = new JScrollPane();
    panelSubtitleScrapers.add(scrollPaneScraper, "2, 2, fill, fill");

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

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

    cbScraperLanguage = new JComboBox(MediaLanguages.values());
    add(cbScraperLanguage, "4, 4, fill, default");

    initDataBindings();

    // adjust table columns
    // Checkbox and Logo shall have minimal width
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2);
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2);
    TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5);

    tableScraper.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            // click on the checkbox
            if (arg0.getColumn() == 0) {
                int row = arg0.getFirstRow();
                SubtitleScraper changedScraper = scrapers.get(row);
                if (changedScraper.active) {
                    settings.addMovieSubtitleScraper(changedScraper.getScraperId());
                } else {
                    settings.removeMovieSubtitleScraper(changedScraper.getScraperId());
                }
            }
        }
    });

    // implement selection listener to load settings
    tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow());
            if (index > -1) {
                panelScraperOptions.removeAll();
                if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) {
                    panelScraperOptions
                            .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider()));
                }
                panelScraperOptions.revalidate();
            }
        }
    });

    // select default movie scraper
    if (selectedIndex < 0) {
        selectedIndex = 0;
    }
    if (counter > 0) {
        tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
    }
}

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

public MovieTrailerSettingsPanel() {
    // data init/*from   w  ww . j  a va  2  s . c o  m*/
    List<String> enabledTrailerProviders = settings.getMovieTrailerScrapers();
    int selectedIndex = -1;
    int counter = 0;
    for (MediaScraper scraper : MovieList.getInstance().getAvailableTrailerScrapers()) {
        TrailerScraper trailerScraper = new TrailerScraper(scraper);
        if (enabledTrailerProviders.contains(trailerScraper.getScraperId())) {
            trailerScraper.active = true;
            if (selectedIndex < 0) {
                selectedIndex = counter;
            }
        }
        scrapers.add(trailerScraper);
        counter++;
    }

    // UI init
    setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    JPanel panelTrailerScrapers = new JPanel();
    panelTrailerScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"),
            BUNDLE.getString("scraper.trailer"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$
    add(panelTrailerScrapers, "2, 2, fill, fill");
    panelTrailerScrapers.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("200dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.UNRELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    final JScrollPane scrollPaneScraperDetails = new JScrollPane();
    scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPaneScraperDetails.setBorder(null);
    panelTrailerScrapers.add(scrollPaneScraperDetails, "8, 1, 1, 2, fill, fill");

    JPanel panelScraperDetails = new JPanel();
    scrollPaneScraperDetails.setViewportView(panelScraperDetails);
    panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, }));
    {
        // add a CSS rule to force body tags to use the default label font
        // instead of the value in javax.swing.text.html.default.csss
        Font font = UIManager.getFont("Label.font");
        String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize()
                + "pt; }";
        tpScraperDescription = new JTextPane();
        tpScraperDescription.setOpaque(false);
        tpScraperDescription.setEditorKit(new HTMLEditorKit());
        ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule);
        panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top");
    }
    panelScraperOptions = new ScrollablePanel();
    panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT));
    panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top");

    JScrollPane scrollPaneScraper = new JScrollPane();
    panelTrailerScrapers.add(scrollPaneScraper, "2, 2, 5, 1, fill, fill");

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

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

    checkBox = new JCheckBox(BUNDLE.getString("Settings.trailer.preferred")); //$NON-NLS-1$
    panelTrailerScrapers.add(checkBox, "2, 6, 7, 1");

    JLabel lblTrailerSource = new JLabel(BUNDLE.getString("Settings.trailer.source")); //$NON-NLS-1$
    panelTrailerScrapers.add(lblTrailerSource, "4, 8, right, default");

    cbTrailerSource = new JComboBox<>();
    cbTrailerSource.setModel(new DefaultComboBoxModel<>(MovieTrailerSources.values()));
    panelTrailerScrapers.add(cbTrailerSource, "6, 8, fill, default");

    JLabel lblTrailerQuality = new JLabel(BUNDLE.getString("Settings.trailer.quality")); //$NON-NLS-1$
    panelTrailerScrapers.add(lblTrailerQuality, "4, 10, right, default");

    cbTrailerQuality = new JComboBox<>();
    cbTrailerQuality.setModel(new DefaultComboBoxModel<>(MovieTrailerQuality.values()));
    panelTrailerScrapers.add(cbTrailerQuality, "6, 10, fill, default");

    chckbxAutomaticTrailerDownload = new JCheckBox(BUNDLE.getString("Settings.trailer.automaticdownload")); //$NON-NLS-1$
    panelTrailerScrapers.add(chckbxAutomaticTrailerDownload, "2, 12, 7, 1");

    JLabel lblAutomaticTrailerDownloadHint = new JLabel(
            BUNDLE.getString("Settings.trailer.automaticdownload.hint")); //$NON-NLS-1$
    TmmFontHelper.changeFont(lblAutomaticTrailerDownloadHint, 0.833);
    panelTrailerScrapers.add(lblAutomaticTrailerDownloadHint, "4, 14, 5, 1");

    initDataBindings();

    // adjust table columns
    // Checkbox and Logo shall have minimal width
    TableColumnResizer.setMaxWidthForColumn(tableTrailerScraper, 0, 2);
    TableColumnResizer.setMaxWidthForColumn(tableTrailerScraper, 1, 2);
    TableColumnResizer.adjustColumnPreferredWidths(tableTrailerScraper, 5);

    tableTrailerScraper.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            // click on the checkbox
            if (arg0.getColumn() == 0) {
                int row = arg0.getFirstRow();
                TrailerScraper changedScraper = scrapers.get(row);
                if (changedScraper.active) {
                    settings.addMovieTrailerScraper(changedScraper.getScraperId());
                } else {
                    settings.removeMovieTrailerScraper(changedScraper.getScraperId());
                }
            }
        }
    });

    // implement selection listener to load settings
    tableTrailerScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int index = tableTrailerScraper.convertRowIndexToModel(tableTrailerScraper.getSelectedRow());
            if (index > -1) {
                panelScraperOptions.removeAll();
                if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) {
                    panelScraperOptions
                            .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider()));
                }
                panelScraperOptions.revalidate();
            }
        }
    });

    // select default movie scraper
    if (selectedIndex < 0) {
        selectedIndex = 0;
    }
    if (counter > 0) {
        tableTrailerScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
    }
}

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

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

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

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

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

    panelScraperDetails = new ScrollablePanel();
    scrollPaneScraperDetails.setViewportView(panelScraperDetails);
    panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("200dlu:grow"), },
            new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, }));

    // add a CSS rule to force body tags to use the default label font
    // instead of the value in javax.swing.text.html.default.csss
    Font font = UIManager.getFont("Label.font");
    String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize()
            + "pt; }";
    tpScraperDescription = new JTextPane();
    tpScraperDescription.setOpaque(false);
    tpScraperDescription.setEditorKit(new HTMLEditorKit());
    ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule);
    panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top");
    panelScraperOptions = new JPanel();
    panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT));
    panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top");

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

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

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

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

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

    btnGroupThumbFilenaming = new ButtonGroup();

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

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

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

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

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

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

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

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

    panelImages = new JPanel();
    panelArtworkScrapers.add(panelImages, "2, 6, 3, 1, fill, fill");
    panelImages.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("23px"), }));

    lblNewLabel = new JLabel(BUNDLE.getString("image.thumb.naming"));
    panelImages.add(lblNewLabel, "1, 1, left, center");
    rdbtnThumbWithPostfix = new JRadioButton("<dynamic>-thumb.ext");
    panelImages.add(rdbtnThumbWithPostfix, "3, 1, fill, top");
    btnGroupThumbFilenaming.add(rdbtnThumbWithPostfix);
    rdbtnThumbTbn = new JRadioButton("<dynamic>.tbn");
    btnGroupThumbFilenaming.add(rdbtnThumbTbn);
    rdbtnThumbWoPostfix = new JRadioButton("<dynamic>.ext");
    panelImages.add(rdbtnThumbWoPostfix, "5, 1, fill, top");
    btnGroupThumbFilenaming.add(rdbtnThumbWoPostfix);
    panelImages.add(rdbtnThumbTbn, "7, 1");

    panelScraperMetadataContainer = new JPanel();
    panelScraperMetadataContainer.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"),
            BUNDLE.getString("scraper.metadata.defaults"), TitledBorder.LEADING, TitledBorder.TOP, null, //$NON-NLS-1$
            new Color(51, 51, 51)));
    add(panelScraperMetadataContainer, "2, 6, fill, top");
    panelScraperMetadataContainer.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
            new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC,
                    FormFactory.DEFAULT_ROWSPEC, }));

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

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

    initDataBindings();

    {
        // adjust table columns
        // Checkbox and Logo shall have minimal width
        TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2);
        TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2);
        TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5);

        TableColumnResizer.setMaxWidthForColumn(tableArtworkScraper, 0, 2);
        TableColumnResizer.setMaxWidthForColumn(tableArtworkScraper, 1, 2);
        TableColumnResizer.adjustColumnPreferredWidths(tableArtworkScraper, 5);

        // implement listener to simulate button group
        tableScraper.getModel().addTableModelListener(new TableModelListener() {
            @Override
            public void tableChanged(TableModelEvent arg0) {
                // click on the checkbox
                if (arg0.getColumn() == 0) {
                    int row = arg0.getFirstRow();
                    TvShowScraper changedScraper = scrapers.get(row);
                    // if flag inNFO was changed, change all other trailers flags
                    if (changedScraper.getDefaultScraper()) {
                        settings.setTvShowScraper(changedScraper.getScraperId());
                        for (TvShowScraper scraper : scrapers) {
                            if (scraper != changedScraper) {
                                scraper.setDefaultScraper(Boolean.FALSE);
                            }
                        }
                    }
                }
            }
        });

        // implement selection listener to load settings
        tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow());
                if (index > -1) {
                    panelScraperOptions.removeAll();
                    if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) {
                        panelScraperOptions.add(
                                new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider()));
                    }
                    panelScraperOptions.revalidate();
                }
            }
        });

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

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

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

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

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

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

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

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

        default:
            break;
        }
    }
}

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

private void initComponents() {
    // data init//www . j a  v  a2  s . c o m
    List<String> enabledSubtitleProviders = settings.getTvShowSubtitleScrapers();
    int selectedIndex = -1;
    int counter = 0;
    for (MediaScraper scraper : TvShowList.getInstance().getAvailableSubtitleScrapers()) {
        SubtitleScraper subtitleScraper = new SubtitleScraper(scraper);
        if (enabledSubtitleProviders.contains(subtitleScraper.getScraperId())) {
            subtitleScraper.active = true;
            if (selectedIndex < 0) {
                selectedIndex = counter;
            }
        }
        scrapers.add(subtitleScraper);
        counter++;
    }

    // UI init
    setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, }));

    JPanel panelSubtitleScrapers = new JPanel();
    panelSubtitleScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"),
            BUNDLE.getString("scraper.subtitle"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$
    add(panelSubtitleScrapers, "2, 2, 5, 1, fill, fill");
    panelSubtitleScrapers.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), }));

    final JScrollPane scrollPaneScraperDetails = new JScrollPane();
    scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPaneScraperDetails.setBorder(null);
    panelSubtitleScrapers.add(scrollPaneScraperDetails, "4, 1, 1, 2, fill, fill");

    JPanel panelScraperDetails = new JPanel();
    scrollPaneScraperDetails.setViewportView(panelScraperDetails);
    panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, }));
    {
        // add a CSS rule to force body tags to use the default label font
        // instead of the value in javax.swing.text.html.default.csss
        Font font = UIManager.getFont("Label.font");
        String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize()
                + "pt; }";
        tpScraperDescription = new JTextPane();
        tpScraperDescription.setOpaque(false);
        tpScraperDescription.setEditorKit(new HTMLEditorKit());
        ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule);
        panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top");
    }
    panelScraperOptions = new ScrollablePanel();
    panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT));
    panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top");

    JScrollPane scrollPaneScraper = new JScrollPane();
    panelSubtitleScrapers.add(scrollPaneScraper, "2, 2, fill, fill");

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

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

    cbScraperLanguage = new JComboBox(MediaLanguages.values());
    add(cbScraperLanguage, "4, 4, fill, default");

    initDataBindings();

    // adjust table columns
    // Checkbox and Logo shall have minimal width
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2);
    TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2);
    TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5);

    tableScraper.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            // click on the checkbox
            if (arg0.getColumn() == 0) {
                int row = arg0.getFirstRow();
                SubtitleScraper changedScraper = scrapers.get(row);
                if (changedScraper.active) {
                    settings.addTvShowSubtitleScraper(changedScraper.getScraperId());
                } else {
                    settings.removeTvShowSubtitleScraper(changedScraper.getScraperId());
                }
            }
        }
    });

    // implement selection listener to load settings
    tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow());
            if (index > -1) {
                panelScraperOptions.removeAll();
                if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) {
                    panelScraperOptions
                            .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider()));
                }
                panelScraperOptions.revalidate();
            }
        }
    });

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

From source file:org.wings.STable.java

public void tableChanged(TableModelEvent e) {
    // kill active editors
    //editingCanceled(null);

    if (e == null || e.getFirstRow() == TableModelEvent.HEADER_ROW) {
        // The whole thing changed
        clearSelectionAndLeadAnchor();/*from   w  w  w .j a  va 2s. c  om*/
        if (getAutoCreateColumnsFromModel())
            createDefaultColumnsFromModel();
    } else {
        switch (e.getType()) {
        case TableModelEvent.INSERT:
            if (e.getFirstRow() >= 0)
                getSelectionModel().insertIndexInterval(e.getFirstRow(), e.getLastRow(), true);
            break;

        case TableModelEvent.DELETE:
            if (e.getFirstRow() >= 0)
                getSelectionModel().removeIndexInterval(e.getFirstRow(), e.getLastRow());
            break;
        case TableModelEvent.UPDATE:
            /* event fire on javax.swing.table.AbstractTableModel.fireTableDataChanged() */
            if (e.getLastRow() == Integer.MAX_VALUE)
                clearSelectionAndLeadAnchor();
            break;
        }
    }

    if (model.getRowCount() != rowCountBackUp) {
        rowCountBackUp = model.getRowCount();
        fireViewportChanged(false);
    }
    if (columnModel.getColumnCount() != columnCountBackUp) {
        columnCountBackUp = columnModel.getColumnCount();
        fireViewportChanged(true);
    }

    if (e != null && e.getFirstRow() == e.getLastRow() && e.getFirstRow() != TableModelEvent.HEADER_ROW
            && e.getColumn() != TableModelEvent.ALL_COLUMNS && e.getType() == TableModelEvent.UPDATE) {
        if (isUpdatePossible() && STable.class.isAssignableFrom(getClass()))
            update(((TableCG) getCG()).getRenderCellUpdate(this, e.getFirstRow(), e.getColumn()));
        else
            reload();
    }
    /*        else if (e != null &&
    e.getFirstRow() == 0 &&
    e.getLastRow() == Integer.MAX_VALUE &&
    e.getColumn() == TableModelEvent.ALL_COLUMNS &&
    e.getType() == TableModelEvent.UPDATE) {
    update(((TableCG)getCG()).getDataUpdate(this));
            }*/
    else {
        reload();
    }
}

From source file:org.yccheok.jstock.gui.JStock.java

private javax.swing.event.TableModelListener getTableModelListener() {
    return new javax.swing.event.TableModelListener() {
        @Override//from  w ww  .j  a  va 2 s  .  c  o m
        public void tableChanged(javax.swing.event.TableModelEvent e) {
            int firstRow = e.getFirstRow();
            int lastRow = e.getLastRow();
            int mColIndex = e.getColumn();

            switch (e.getType()) {
            case javax.swing.event.TableModelEvent.INSERT:
                break;

            case javax.swing.event.TableModelEvent.UPDATE:
                break;

            case javax.swing.event.TableModelEvent.DELETE:
                break;
            }
        }
    };
}