List of usage examples for javax.swing.event TableModelEvent getFirstRow
public int getFirstRow()
From source file:dbseer.gui.user.DBSeerDataSet.java
@Override public void tableChanged(TableModelEvent tableModelEvent) { if (tableModelEvent.getFirstRow() == DBSeerDataSet.TYPE_USE_ENTIRE_DATASET && tableModelEvent.getColumn() == 1) { if (((Boolean) table.getValueAt(DBSeerDataSet.TYPE_USE_ENTIRE_DATASET, 1)).booleanValue() == true) { tableModel.setUseEntireDataSet(true); } else {/*from www. ja v a 2s.c o m*/ tableModel.setUseEntireDataSet(false); } } // if (tableModelEvent.getFirstRow() == DBSeerDataSet.TYPE_NUM_TRANSACTION_TYPE && // tableModelEvent.getColumn() == 1) // { // int numTransactionType = (Integer.parseInt((String)table.getValueAt(DBSeerDataSet.TYPE_NUM_TRANSACTION_TYPE, 1))); // int currentRowCount = tableModel.getRowCount(); // // ArrayList<String> previousTypeNames = new ArrayList<String>(); // for (int i = DBSeerDataSet.TYPE_NUM_TRANSACTION_TYPE + 1; i < DBSeerDataSet.TYPE_NUM_TRANSACTION_TYPE + 1 + numTransactionTypes; ++i) //tableModel.getRowCount(); ++i) // { // previousTypeNames.add((String)table.getValueAt(i, 1)); // } // //// for (int i = currentRowCount-1; i > DBSeerDataSet.TYPE_NUM_TRANSACTION_TYPE; --i) // for (int i = DBSeerDataSet.TYPE_NUM_TRANSACTION_TYPE + numTransactionTypes; i > DBSeerDataSet.TYPE_NUM_TRANSACTION_TYPE; --i) // { // tableModel.removeRow(i); // } // // for (int i = 0; i < numTransactionType; ++i) // { // String name = (i < previousTypeNames.size()) ? previousTypeNames.get(i) : "Type " + (i+1); // tableModel.addRow(new Object[]{"Name of Transaction Type " + (i+1), name}); // } // } }
From source file:it.cnr.icar.eric.client.ui.swing.RegistryObjectsTable.java
/** * This fine grain notification tells listeners the exact range * of cells, rows, or columns that changed. * * Overrides base class behaviour by setting selection when first * row (destination) is added to model./* w w w. j a v a2 s.co m*/ */ public void tableChanged(TableModelEvent e) { if (e == null || e.getFirstRow() == TableModelEvent.HEADER_ROW) { // The whole thing changed // This will effect invalidation of the JTable and JTableHeader. createDefaultColumnsFromModel(); // Reset cachedTableCellRenderer cachedTableCellRenderers = new TableCellRenderer[getColumnCount()]; return; } else { super.tableChanged(e); } // If no selectedRow, set selectedRow to firstRow if ((selectedRow == -1) && (e.getType() == TableModelEvent.INSERT)) { // Following will result in a software initiated selection // of the first row in table ListSelectionModel rowSM = getSelectionModel(); rowSM.setSelectionInterval(0, 0); } }
From source file:org.executequery.gui.browser.TableDataTab.java
public void tableChanged(TableModelEvent e) { if (isDatabaseTable()) { int row = e.getFirstRow(); if (row >= 0) { List<RecordDataItem> rowDataForRow = tableModel.getRowDataForRow(row); for (RecordDataItem recordDataItem : rowDataForRow) { if (recordDataItem.isChanged()) { Log.debug("Change detected in column [ " + recordDataItem.getName() + " ] - value [ " + recordDataItem.getValue() + " ]"); asDatabaseTable().addTableDataChange(new TableDataChange(rowDataForRow)); return; }// w w w . jav a2 s. co m } } } }
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 w w .j av a 2s . c om*/ }; 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.openthinclient.console.util.FilterTableModel.java
public void tableChanged(TableModelEvent e) { updateFilteredRows();/*from w w w. j a v a2s .c o m*/ if (e.getFirstRow() == TableModelEvent.HEADER_ROW) fireTableStructureChanged(); else fireTableDataChanged(); }
From source file:org.quackbot.gui.InfoPlugins.java
public InfoPlugins(final Controller controller) { super();// www .jav a 2s . c om setBorder(BorderFactory.createTitledBorder("Active plugins")); //Configure the table model pluginTableModel = new DefaultTableModel() { @Override public Class getColumnClass(int c) { return getValueAt(0, c).getClass(); } }; pluginTableModel.addColumn("Name"); pluginTableModel.addColumn("Type"); pluginTableModel.addColumn("Enabled"); pluginTableModel.addColumn("Admin Only"); pluginTableModel.addColumn("Required"); pluginTableModel.addColumn("Optional"); pluginTableModel.addColumn("Help"); //Toggle command enabled status when changed on the table pluginTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { if (e.getType() != TableModelEvent.UPDATE) return; TableModel model = ((TableModel) e.getSource()); String plugin = StringUtils .trimToNull((String) ((TableModel) e.getSource()).getValueAt(e.getFirstRow(), 0)); Command command = controller.getHookManager().getCommand(plugin); if (command != null) { command.setEnabled((Boolean) model.getValueAt(e.getFirstRow(), 1)); log.debug((command.isEnabled() ? "Enabled" : "Disabled") + " command " + command.getName()); } } }); //Configure the table pluginTable = new JTable(pluginTableModel) { @Override public String getToolTipText(MouseEvent e) { Point p = e.getPoint(); int rowIndex = pluginTable.rowAtPoint(p); int colIndex = pluginTable.columnAtPoint(p); if ((colIndex == 0 || colIndex == 5 || colIndex == 6) && getValueAt(rowIndex, colIndex) != null) return getValueAt(rowIndex, colIndex).toString(); return ""; } }; pluginTable.setRowSelectionAllowed(false); pluginTable.setColumnSelectionAllowed(false); pluginTable.setCellSelectionEnabled(false); pluginTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); //Configure the default column widths TableColumnModel columnModel = pluginTable.getColumnModel(); columnModel.getColumn(0).setPreferredWidth(120); columnModel.getColumn(1).setPreferredWidth(50); columnModel.getColumn(2).setPreferredWidth(75); columnModel.getColumn(3).setPreferredWidth(50); columnModel.getColumn(4).setPreferredWidth(40); columnModel.getColumn(5).setPreferredWidth(520); //Add the table to the scroll pane add(pluginTable); //Get notified of hook changes controller.getHookManager().addHook(new QListener("QBGuiPluginPanel") { @Override public void onHookLoad(HookLoadEvent event) { //TODO: Inform user about exception if (event.getException() != null) return; QListener hook = event.getHook(); if (hook instanceof Command) { Command command = (Command) hook; pluginTableModel.addRow( new Object[] { command.getName(), "Command", command.isEnabled(), command.isAdmin(), command.getRequiredParams(), command.getOptionalParams(), command.getHelp() }); } else { pluginTableModel.addRow(new Object[] { hook.getName(), "Hook", null, null, null, null, null }); } } @Override public void onHookLoadStart(HookLoadStartEvent event) { pluginTableModel.setRowCount(0); } }); }
From source file:org.tinymediamanager.ui.movies.dialogs.MovieEditorDialog.java
/** * Create the dialog.// ww w . java 2 s .co m * * @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//ww w . j a v a 2s.com List<String> enabledSubtitleProviders = settings.getMovieSubtitleScrapers(); int selectedIndex = -1; int counter = 0; for (MediaScraper scraper : MovieList.getInstance().getAvailableSubtitleScrapers()) { SubtitleScraper subtitleScraper = new SubtitleScraper(scraper); if (enabledSubtitleProviders.contains(subtitleScraper.getScraperId())) { subtitleScraper.active = true; if (selectedIndex < 0) { selectedIndex = counter; } } scrapers.add(subtitleScraper); counter++; } // UI init setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelSubtitleScrapers = new JPanel(); panelSubtitleScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("scraper.subtitle"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$ add(panelSubtitleScrapers, "2, 2, 5, 1, fill, fill"); panelSubtitleScrapers.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), })); final JScrollPane scrollPaneScraperDetails = new JScrollPane(); scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPaneScraperDetails.setBorder(null); panelSubtitleScrapers.add(scrollPaneScraperDetails, "4, 1, 1, 2, fill, fill"); JPanel panelScraperDetails = new JPanel(); scrollPaneScraperDetails.setViewportView(panelScraperDetails); panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), }, new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); { // add a CSS rule to force body tags to use the default label font // instead of the value in javax.swing.text.html.default.csss Font font = UIManager.getFont("Label.font"); String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }"; tpScraperDescription = new JTextPane(); tpScraperDescription.setOpaque(false); tpScraperDescription.setEditorKit(new HTMLEditorKit()); ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule); panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top"); } panelScraperOptions = new ScrollablePanel(); panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top"); JScrollPane scrollPaneScraper = new JScrollPane(); panelSubtitleScrapers.add(scrollPaneScraper, "2, 2, fill, fill"); tableScraper = new JTable(); tableScraper.setRowHeight(29); scrollPaneScraper.setViewportView(tableScraper); final JLabel lblScraperLanguage = new JLabel(BUNDLE.getString("Settings.preferredLanguage")); //$NON-NLS-1$ add(lblScraperLanguage, "2, 4, right, default"); cbScraperLanguage = new JComboBox(MediaLanguages.values()); add(cbScraperLanguage, "4, 4, fill, default"); initDataBindings(); // adjust table columns // Checkbox and Logo shall have minimal width TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2); TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2); TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5); tableScraper.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); SubtitleScraper changedScraper = scrapers.get(row); if (changedScraper.active) { settings.addMovieSubtitleScraper(changedScraper.getScraperId()); } else { settings.removeMovieSubtitleScraper(changedScraper.getScraperId()); } } } }); // implement selection listener to load settings tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow()); if (index > -1) { panelScraperOptions.removeAll(); if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) { panelScraperOptions .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider())); } panelScraperOptions.revalidate(); } } }); // select default movie scraper if (selectedIndex < 0) { selectedIndex = 0; } if (counter > 0) { tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex); } }
From source file:org.tinymediamanager.ui.movies.settings.MovieTrailerSettingsPanel.java
public MovieTrailerSettingsPanel() { // data init//from w w w. j a v a 2s .co 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 ww w . ja v a2 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; } } }