List of usage examples for javax.swing.event ChangeListener ChangeListener
ChangeListener
From source file:org.p_vcd.ui.VcdDialog.java
public void updateDatabases(String defaultValue) { List<VideoDatabase> refDbs = VideoDatabase.getReferenceDatabases(); // remove from map List<VideoDatabase> entriesToRemove = new ArrayList<VideoDatabase>(); for (VideoDatabase edb : map_refDbCheck.keySet()) { if (!refDbs.contains(edb)) entriesToRemove.add(edb);// ww w. jav a 2s . c o m } for (VideoDatabase edb : entriesToRemove) map_refDbCheck.remove(edb); // add to map List<VideoDatabase> entriesToAdd = new ArrayList<VideoDatabase>(); for (VideoDatabase db : refDbs) { if (!map_refDbCheck.containsKey(db)) entriesToAdd.add(db); } for (VideoDatabase db : entriesToAdd) { JCheckBox chkbox = new JCheckBox(db.getName() + " (" + db.getFileList().size() + " files, " + MyUtil.getSecondsToHHMMSS(db.getTotalSeconds()) + " length)"); chkbox.setBackground(Color.WHITE); chkbox.setFont(new Font("Tahoma", Font.PLAIN, 13)); chkbox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateReferenceDbDetail(); } }); map_refDbCheck.put(db, chkbox); } // draw checkboxes panel_refDatabasesList.removeAll(); int cont = 0; for (JCheckBox chkbox : map_refDbCheck.values()) { panel_refDatabasesList.add(chkbox, "cell 0 " + cont); cont++; } panel_refDatabasesList.validate(); // default value if (defaultValue != null) { for (Map.Entry<VideoDatabase, JCheckBox> entry : map_refDbCheck.entrySet()) { if (!defaultValue.equals(entry.getKey().getName())) continue; JCheckBox chkbox = entry.getValue(); chkbox.setSelected(true); chkbox.requestFocus(); break; } } List<String> listQ = new ArrayList<String>(); listQ.add("-- select a db --"); for (VideoDatabase db : refDbs) { listQ.add(db.getName()); } comboBox_queryDb.setModel(new DefaultComboBoxModel<String>(listQ.toArray(new String[0]))); updateReferenceDbDetail(); updateQueryDbDetail(); }
From source file:org.rdv.ui.ControlPanel.java
/** * Setup the UI.//w w w .jav a 2 s. c o m */ private void initPanel() { setLayout(new BorderLayout()); GridBagConstraints c = new GridBagConstraints(); JPanel container = new JPanel(); container.setLayout(new GridBagLayout()); Box firstRowPanel = new Box(BoxLayout.LINE_AXIS); beginButton = new JButton(); beginButton.setName("beginButton"); beginButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLocationBegin(); } }); firstRowPanel.add(beginButton); rtButton = new JButton(); rtButton.setName("rtButton"); rtButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (rtButton.isSelected()) { rbnbController.pause(); } else { rbnbController.monitor(); } } }); firstRowPanel.add(rtButton); playButton = new JButton(); playButton.setName("playButton"); playButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (playButton.isSelected()) { rbnbController.pause(); } else { rbnbController.play(); } } }); firstRowPanel.add(playButton); endButton = new JButton(); endButton.setName("endButton"); endButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLocationEnd(); } }); firstRowPanel.add(endButton); firstRowPanel.add(Box.createHorizontalStrut(8)); SpinnerListModel playbackRateModel = new SpinnerListModel(playbackRates); playbackRateSpinner = new JSpinner(playbackRateModel); playbackRateSpinner.setName("playbackRateSpinner"); JSpinner.ListEditor playbackRateEditor = new JSpinner.ListEditor(playbackRateSpinner); playbackRateEditor.getTextField().setEditable(false); playbackRateSpinner.setEditor(playbackRateEditor); playbackRateSpinner.setPreferredSize(new Dimension(80, playbackRateSpinner.getPreferredSize().height)); playbackRateSpinner.setMinimumSize(playbackRateSpinner.getPreferredSize()); playbackRateSpinner.setMaximumSize(playbackRateSpinner.getPreferredSize()); playbackRateSpinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { playbackRateChanged(); } }); firstRowPanel.add(playbackRateSpinner); firstRowPanel.add(Box.createHorizontalStrut(8)); timeScaleComboBox = new JComboBox(); timeScaleComboBox.setName("timeScaleComboBox"); timeScaleComboBox.setEditable(true); timeScaleComboBox.setPreferredSize(new Dimension(96, timeScaleComboBox.getPreferredSize().height)); timeScaleComboBox.setMinimumSize(timeScaleComboBox.getPreferredSize()); timeScaleComboBox.setMaximumSize(timeScaleComboBox.getPreferredSize()); for (int i = 0; i < timeScales.length; i++) { timeScaleComboBox.addItem(DataViewer.formatSeconds(timeScales[i])); } timeScaleComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { timeScaleChange(); } }); firstRowPanel.add(timeScaleComboBox); firstRowPanel.add(Box.createHorizontalGlue()); locationButton = new JButton(); locationButton.setName("locationButton"); locationButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { TimeRange timeRange = RBNBHelper.getChannelsTimeRange(); double time = DateTimeDialog.showDialog(ControlPanel.this, rbnbController.getLocation(), timeRange.start, timeRange.end); if (time >= 0) { rbnbController.setLocation(time); } } }); firstRowPanel.add(locationButton); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.weighty = 0; c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; c.insets = new java.awt.Insets(8, 8, 8, 8); c.anchor = GridBagConstraints.NORTHWEST; container.add(firstRowPanel, c); zoomTimeSlider = new TimeSlider(); zoomTimeSlider.setRangeChangeable(false); zoomTimeSlider.addTimeAdjustmentListener(this); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.weighty = 0; c.gridx = 0; c.gridy = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; c.insets = new java.awt.Insets(0, 8, 0, 8); c.anchor = GridBagConstraints.NORTHWEST; container.add(zoomTimeSlider, c); JPanel zoomTimePanel = new JPanel(); zoomTimePanel.setLayout(new BorderLayout()); zoomMinimumLabel = new JLabel(); zoomMinimumLabel.setName("zoomMinimumLabel"); zoomTimePanel.add(zoomMinimumLabel, BorderLayout.WEST); zoomRangeLabel = new JLabel(); zoomRangeLabel.setName("zoomRangeLabel"); zoomRangeLabel.setHorizontalAlignment(JLabel.CENTER); zoomTimePanel.add(zoomRangeLabel, BorderLayout.CENTER); zoomMaximumLabel = new JLabel(); zoomMaximumLabel.setName("zoomMaximumLabel"); zoomTimePanel.add(zoomMaximumLabel, BorderLayout.EAST); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.weighty = 0; c.gridx = 0; c.gridy = 2; c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; c.insets = new java.awt.Insets(8, 8, 0, 8); c.anchor = GridBagConstraints.NORTHWEST; container.add(zoomTimePanel, c); globalTimeSlider = new TimeSlider(); globalTimeSlider.setValueChangeable(false); globalTimeSlider.addTimeAdjustmentListener(this); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.weighty = 1; c.gridx = 0; c.gridy = 3; c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; c.insets = new java.awt.Insets(8, 8, 8, 8); c.anchor = GridBagConstraints.NORTHWEST; container.add(globalTimeSlider, c); add(container, BorderLayout.CENTER); log.info("Initialized control panel."); }
From source file:org.shaman.rpg.editor.dialog.DialogVisualElement.java
public DialogVisualElement(Lookup lkp) { obj = lkp.lookup(DialogDataObject.class); assert obj != null; undoRedo = new UndoRedo.Manager(); undoRedo.addChangeListener(new ChangeListener() { @Override/*from w ww .j ava 2 s.c om*/ public void stateChanged(ChangeEvent e) { obj.setModified(true); } }); initComponents(); contentPanel = new JPanel() { @Override public void paint(Graphics g) { super.paint(g); for (JComponent c : overlayComponents) { c.setBounds(this.getBounds()); c.paint(g); } } }; contentPanel.setLayout(new VerticalFlowLayout(GAP_Y * 2)); contentPanel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (!e.isConsumed()) { requestFocus(); callback.requestActive(); } } }); personsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { personsListSelectionEvent(); } }); removeButton.setEnabled(false); Action editNames = new EditListAction(); ListAction ls = new ListAction(personsList, editNames); personsList.getModel().addListDataListener(new ListDataListener() { @Override public void intervalAdded(ListDataEvent e) { updatePersons(); } @Override public void intervalRemoved(ListDataEvent e) { updatePersons(); } @Override public void contentsChanged(ListDataEvent e) { updatePersons(); } }); setupVisuals(); contentParent = new JPanel(); contentParent.setLayout(new BorderLayout()); // contentPanel.setBounds(contentPanel.getBounds()); // contentParent.setBounds(contentPanel.getBounds()); contentParent.add(contentPanel); scrollPane.setViewportView(contentParent); jumpListener = new JumpListener(this); dropListener = new DropListener(this); DropTarget dt = new DropTarget(contentParent, dropListener); contentParent.setDropTarget(dt); obj.getPrimaryFile().addFileChangeListener(new FileChangeAdapter() { @Override public void fileChanged(FileEvent fe) { refresh(); } }); obj.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (DataObject.PROP_MODIFIED.equals(evt.getPropertyName()) && callback != null) { if (obj.isModified()) { callback.updateTitle("<html><b>" + obj.getName() + "</b></html>"); } else { callback.updateTitle("<html>" + obj.getName() + "</html>"); } } } }); }
From source file:org.sikuli.ide.SikuliIDE.java
private JComponent createCommandPane() { JXTaskPaneContainer con = new JXTaskPaneContainer(); PreferencesUser pref = PreferencesUser.getInstance(); JCheckBox chkAutoCapture = new JCheckBox(_I("cmdListAutoCapture"), pref.getAutoCaptureForCmdButtons()); chkAutoCapture.addChangeListener(new ChangeListener() { @Override//from ww w. ja v a2s. c o m public void stateChanged(javax.swing.event.ChangeEvent e) { boolean flag = ((JCheckBox) e.getSource()).isSelected(); PreferencesUser pref = PreferencesUser.getInstance(); pref.setAutoCaptureForCmdButtons(flag); } }); JXTaskPane setPane = new JXTaskPane(); setPane.setTitle(_I("cmdListSettings")); setPane.add(chkAutoCapture); setPane.setCollapsed(true); con.add(setPane); int cat = 0; JXTaskPane taskPane = new JXTaskPane(); taskPane.setTitle(getCommandCategories()[cat++]); con.add(taskPane); String[][] CommandsOnToolbar = getCommandsOnToolbar(); boolean collapsed; for (int i = 0; i < CommandsOnToolbar.length; i++) { String cmd = CommandsOnToolbar[i++][0]; String[] params = CommandsOnToolbar[i++]; String[] desc = CommandsOnToolbar[i]; //TODO: more elegeant way, to handle special cases if (cmd.equals("----")) { if (cat == 2) { collapsed = true; } else { collapsed = false; } if (cat == 3) { if (prefs.getUserType() == PreferencesUser.NEWBEE) { break; } else { collapsed = true; } } taskPane = new JXTaskPane(); taskPane.setTitle(getCommandCategories()[cat++]); con.add(taskPane); taskPane.setCollapsed(collapsed); } else { taskPane.add(new ButtonGenCommand(cmd, desc[0], params)); } } Dimension conDim = con.getSize(); con.setPreferredSize(new Dimension(250, 1000)); _cmdList = new JXCollapsiblePane(JXCollapsiblePane.Direction.LEFT); _cmdList.setMinimumSize(new Dimension(0, 0)); _cmdList.add(new JScrollPane(con)); _cmdList.setCollapsed(false); return _cmdList; }
From source file:org.sikuli.ide.SikuliIDE.java
private void initTabPane() { tabPane = new CloseableTabbedPane(); tabPane.setUI(new AquaCloseableTabbedPaneUI()); tabPane.addCloseableTabbedPaneListener(new CloseableTabbedPaneListener() { @Override// w w w.j a v a 2 s. c om public boolean closeTab(int i) { EditorPane codePane; try { codePane = getPaneAtIndex(i); tabPane.setLastClosed(codePane.getSrcBundle()); Debug.log(4, "close tab " + i + " n:" + tabPane.getComponentCount()); boolean ret = codePane.close(); Debug.log(4, "after close tab n:" + tabPane.getComponentCount()); if (ret && tabPane.getTabCount() < 2) { (new FileAction()).doNew(null); } return ret; } catch (Exception e) { log(-1, "Problem closing tab %d\nError: %s", i, e.getMessage()); return false; } } }); tabPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(javax.swing.event.ChangeEvent e) { EditorPane codePane = null; JTabbedPane tab = (JTabbedPane) e.getSource(); int i = tab.getSelectedIndex(); if (i >= 0) { codePane = getPaneAtIndex(i); String fname = codePane.getCurrentSrcDir(); if (fname == null) { SikuliIDE.this.setTitle(tab.getTitleAt(i)); } else { ImagePath.setBundlePath(fname); SikuliIDE.this.setTitle(fname); } SikuliIDE.this.chkShowThumbs.setState(SikuliIDE.this.getCurrentCodePane().showThumbs); } updateUndoRedoStates(); if (codePane != null) { SikuliIDE.getStatusbar() .setCurrentContentType(SikuliIDE.this.getCurrentCodePane().getSikuliContentType()); } } }); }
From source file:org.simmi.GeneSetHead.java
License:asdf
public Set<String> getSelspec(Component comp, final List<String> specs, final JCheckBox... contigs) { final JTable table = new JTable(); table.setDragEnabled(true);/*w w w . ja v a2 s . c om*/ JScrollPane scroll = new JScrollPane(table); table.setAutoCreateRowSorter(true); final List<Sequence> ctgs = new ArrayList<Sequence>(geneset.contigmap.values()); final TableModel contigmodel = new TableModel() { @Override public int getRowCount() { return ctgs.size(); } @Override public int getColumnCount() { return 1; } @Override public String getColumnName(int columnIndex) { return "Contigs/Scaffolds"; } @Override public Class<?> getColumnClass(int columnIndex) { return String.class; } @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return false; } @Override public Object getValueAt(int rowIndex, int columnIndex) { return ctgs.get(rowIndex).toString(); } @Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { } @Override public void addTableModelListener(TableModelListener l) { } @Override public void removeTableModelListener(TableModelListener l) { } }; final TableModel specmodel = new TableModel() { @Override public int getRowCount() { return specs.size(); } @Override public int getColumnCount() { return 2; } @Override public String getColumnName(int columnIndex) { return columnIndex == 0 ? "Id" : "Spec"; } @Override public Class<?> getColumnClass(int columnIndex) { return String.class; } @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return false; } @Override public Object getValueAt(int rowIndex, int columnIndex) { if (columnIndex == 1) return Sequence.nameFix(specs.get(rowIndex), true); else return specs.get(rowIndex); } @Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { } @Override public void addTableModelListener(TableModelListener l) { } @Override public void removeTableModelListener(TableModelListener l) { } }; table.setModel(specmodel); TransferHandler th = dragRows(table, specs); table.setTransferHandler(th); if (contigs != null && contigs.length > 0 && !contigs[0].getText().equals("Plasmid")) contigs[0].addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (contigs[0] != null && contigs[0].isSelected()) table.setModel(contigmodel); else table.setModel(specmodel); } }); Object[] ctls = new Object[] { scroll, contigs }; //Object[] ctls2 = new Object[] { scroll }; //if( contigs != null ) JOptionPane.showMessageDialog(comp, ctls); //else JOptionPane.showMessageDialog( comp, ctls2 ); Set<String> selspec = new LinkedHashSet<>(); for (int i = 0; i < table.getRowCount(); i++) { if (table.isRowSelected(i)) { String spec = (String) table.getValueAt(i, 0); System.err.println("test " + spec); selspec.add(spec); } } return selspec; }
From source file:org.squidy.designer.zoom.impl.VisualizationShape.java
/** * /* w ww. j a v a2 s . co m*/ */ private final void initTimeSpinner() { PBounds bounds = getBoundsReference(); final JSpinner spinner = new JSpinner(new SpinnerNumberModel(sampleTime, 1000, 10000, 500)); spinner.addChangeListener(new ChangeListener() { /* * (non-Javadoc) * * @see * javax.swing.event.ChangeListener#stateChanged(javax.swing.event * .ChangeEvent) */ public void stateChanged(ChangeEvent e) { sampleTime = ((Double) spinner.getValue()).longValue(); invalidatePaint(); } }); timeSpinner = new JComponentWrapper(spinner); timeSpinner.setOffset((bounds.getWidth() * 0.25) - (timeSpinner.getWidth() / 2), bounds.getHeight() * 0.75 + 0.25); addChild(timeSpinner); }
From source file:org.tinymediamanager.ui.movies.MovieExtendedSearchPanel.java
/** * Instantiates a new movie extended search * //from ww w . j av a 2 s . com * @param model * the model */ public MovieExtendedSearchPanel(MovieSelectionModel model) { super(); setOpaque(false); shadowAlpha = 100; arcs = new Dimension(10, 10); this.movieSelectionModel = model; Map<MovieSearchOptions, Object> savedSearchOptions = MovieModuleManager.MOVIE_SETTINGS.getUiFilters(); // add a dummy mouse listener to prevent clicking through addMouseListener(new MouseAdapter() { }); listCheckListener = new ListCheckListener() { @Override public void removeCheck(ListEvent event) { actionFilter.actionPerformed(new ActionEvent(event.getSource(), 1, "checked")); } @Override public void addCheck(ListEvent event) { actionFilter.actionPerformed(new ActionEvent(event.getSource(), 1, "checked")); } }; setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.UNRELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_GAP_ROWSPEC, })); JLabel lblFilterBy = new JLabel(BUNDLE.getString("movieextendedsearch.filterby")); //$NON-NLS-1$ setComponentFont(lblFilterBy); add(lblFilterBy, "2, 2, 3, 1"); cbFilterNewMovies = new JCheckBox(""); cbFilterNewMovies.setUI(CHECKBOX_UI); // $hide$ cbFilterNewMovies.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.NEW_MOVIES)); cbFilterNewMovies.setAction(actionFilter); add(cbFilterNewMovies, "2, 4"); lblNewMovies = new JLabel(BUNDLE.getString("movieextendedsearch.newmovies")); //$NON-NLS-1$ setComponentFont(lblNewMovies); add(lblNewMovies, "4, 4, right, default"); cbFilterDuplicates = new JCheckBox(""); cbFilterDuplicates.setUI(CHECKBOX_UI); // $hide$ cbFilterDuplicates.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.DUPLICATES)); cbFilterDuplicates.setAction(actionFilter); add(cbFilterDuplicates, "2, 5"); JLabel lblShowDuplicates = new JLabel(BUNDLE.getString("movieextendedsearch.duplicates")); //$NON-NLS-1$ setComponentFont(lblShowDuplicates); add(lblShowDuplicates, "4, 5, right, default"); cbFilterWatched = new JCheckBox(""); cbFilterWatched.setUI(CHECKBOX_UI); // $hide$ cbFilterWatched.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.WATCHED)); cbFilterWatched.setAction(actionFilter); add(cbFilterWatched, "2, 6"); JLabel lblWatchedFlag = new JLabel(BUNDLE.getString("movieextendedsearch.watched")); //$NON-NLS-1$ setComponentFont(lblWatchedFlag); add(lblWatchedFlag, "4, 6, right, default"); cbWatched = new SmallComboBox(WatchedFlag.values()); setComponentFont(cbWatched); cbWatched.setAction(actionFilter); add(cbWatched, "6, 6, fill, default"); cbFilterGenre = new JCheckBox(""); cbFilterGenre.setUI(CHECKBOX_UI); // $hide$ cbFilterGenre.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.GENRE)); cbFilterGenre.setAction(actionFilter); add(cbFilterGenre, "2, 7"); JLabel lblGenre = new JLabel(BUNDLE.getString("movieextendedsearch.genre")); //$NON-NLS-1$ setComponentFont(lblGenre); add(lblGenre, "4, 7, right, default"); cbGenre = new SmallComboBox(MediaGenres.values()); setComponentFont(cbGenre); cbGenre.setAction(actionFilter); add(cbGenre, "6, 7, fill, default"); cbFilterCertification = new JCheckBox(""); cbFilterCertification.setUI(CHECKBOX_UI); // $hide$ cbFilterCertification.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.CERTIFICATION)); cbFilterCertification.setAction(actionFilter); add(cbFilterCertification, "2, 8"); lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$ setComponentFont(lblCertification); add(lblCertification, "4, 8, right, default"); cbCertification = new SmallComboBox(); setComponentFont(cbCertification); cbCertification.setAction(actionFilter); add(cbCertification, "6, 8, fill, default"); cbFilterYear = new JCheckBox(""); cbFilterYear.setUI(CHECKBOX_UI); // $hide$ cbFilterYear.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.YEAR)); cbFilterYear.setAction(actionFilter); add(cbFilterYear, "2, 9"); lblYear = new JLabel(BUNDLE.getString("metatag.year")); //$NON-NLS-1$ setComponentFont(lblYear); add(lblYear, "4, 9, right, default"); int year = Calendar.getInstance().get(Calendar.YEAR); spYear = new JSpinner(); setComponentFont(spYear); spYear.setUI(new SmallSpinnerUI());// $hide$ spYear.setModel(new SpinnerNumberModel(year, 0, 3000, 1)); spYear.setEditor(new JSpinner.NumberEditor(spYear, "#")); spYear.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { actionFilter.actionPerformed(null); } }); add(spYear, "6, 9"); cbFilterCast = new JCheckBox(""); cbFilterCast.setUI(CHECKBOX_UI); // $hide$ cbFilterCast.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.CAST)); cbFilterCast.setAction(actionFilter); add(cbFilterCast, "2, 10"); JLabel lblCastMember = new JLabel(BUNDLE.getString("movieextendedsearch.cast")); //$NON-NLS-1$ setComponentFont(lblCastMember); add(lblCastMember, "4, 10, right, default"); tfCastMember = new JTextField(); setComponentFont(tfCastMember); tfCastMember.setBorder(new SmallTextFieldBorder()); add(tfCastMember, "6, 10, fill, default"); tfCastMember.setColumns(10); tfCastMember.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { actionFilter.actionPerformed(null); } public void insertUpdate(DocumentEvent e) { actionFilter.actionPerformed(null); } public void removeUpdate(DocumentEvent e) { actionFilter.actionPerformed(null); } }); cbFilterTag = new JCheckBox(""); cbFilterTag.setUI(CHECKBOX_UI); // $hide$ cbFilterTag.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.TAG)); cbFilterTag.setAction(actionFilter); add(cbFilterTag, "2, 11"); JLabel lblTag = new JLabel(BUNDLE.getString("movieextendedsearch.tag")); //$NON-NLS-1$ setComponentFont(lblTag); add(lblTag, "4, 11, right, default"); cbTag = new SmallCheckComboBox(); cbTag.setTextFor(CheckComboBox.NONE, BUNDLE.getString("movieextendedsearch.tags.selected.none")); //$NON-NLS-1$ cbTag.setTextFor(CheckComboBox.MULTIPLE, BUNDLE.getString("movieextendedsearch.tags.selected.multiple")); //$NON-NLS-1$ cbTag.setTextFor(CheckComboBox.ALL, BUNDLE.getString("movieextendedsearch.tags.selected.all")); //$NON-NLS-1$ cbTag.getModel().addListCheckListener(listCheckListener); add(cbTag, "6, 11, fill, default"); cbFilterMovieset = new JCheckBox(""); cbFilterMovieset.setUI(CHECKBOX_UI); // $hide$ cbFilterMovieset.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MOVIESET)); cbFilterMovieset.setAction(actionFilter); add(cbFilterMovieset, "2, 12"); JLabel lblMoviesInMovieset = new JLabel(BUNDLE.getString("movieextendedsearch.movieset")); //$NON-NLS-1$ setComponentFont(lblMoviesInMovieset); add(lblMoviesInMovieset, "4, 12, right, default"); cbMovieset = new SmallComboBox(MovieInMovieSet.values()); setComponentFont(cbMovieset); cbMovieset.setAction(actionFilter); add(cbMovieset, "6, 12, fill, default"); cbFilterVideoFormat = new JCheckBox(""); cbFilterVideoFormat.setUI(CHECKBOX_UI); // $hide$ cbFilterVideoFormat.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.VIDEO_FORMAT)); cbFilterVideoFormat.setAction(actionFilter); add(cbFilterVideoFormat, "2, 13"); JLabel lblVideoFormat = new JLabel(BUNDLE.getString("metatag.resolution")); //$NON-NLS-1$ setComponentFont(lblVideoFormat); add(lblVideoFormat, "4, 13, right, default"); cbVideoFormat = new SmallComboBox(getVideoFormats()); setComponentFont(cbVideoFormat); cbVideoFormat.setAction(actionFilter); add(cbVideoFormat, "6, 13, fill, default"); cbFilterVideoCodec = new JCheckBox(""); cbFilterVideoCodec.setUI(CHECKBOX_UI); // $hide$ cbFilterVideoCodec.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.VIDEO_CODEC)); cbFilterVideoCodec.setAction(actionFilter); add(cbFilterVideoCodec, "2, 14"); JLabel lblVideoCodec = new JLabel(BUNDLE.getString("metatag.videocodec")); //$NON-NLS-1$ setComponentFont(lblVideoCodec); add(lblVideoCodec, "4, 14, right, default"); cbVideoCodec = new SmallComboBox(); setComponentFont(cbVideoCodec); cbVideoCodec.setAction(actionFilter); add(cbVideoCodec, "6, 14, fill, default"); cbFilterVideo3D = new JCheckBox(""); cbFilterVideo3D.setUI(CHECKBOX_UI); // $hide$ cbFilterVideo3D.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.VIDEO_3D)); cbFilterVideo3D.addActionListener(actionFilter); add(cbFilterVideo3D, "2, 15"); JLabel lblVideo3D = new JLabel(BUNDLE.getString("metatag.3d")); //$NON-NLS-1$ setComponentFont(lblVideo3D); add(lblVideo3D, "4, 15, right, default"); cbFilterAudioCodec = new JCheckBox(""); cbFilterAudioCodec.setUI(CHECKBOX_UI); // $hide$ cbFilterAudioCodec.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.AUDIO_CODEC)); cbFilterAudioCodec.setAction(actionFilter); add(cbFilterAudioCodec, "2, 16"); JLabel lblAudioCodec = new JLabel(BUNDLE.getString("metatag.audiocodec")); //$NON-NLS-1$ setComponentFont(lblAudioCodec); add(lblAudioCodec, "4, 16, right, default"); cbAudioCodec = new SmallComboBox(); setComponentFont(cbAudioCodec); cbAudioCodec.setAction(actionFilter); add(cbAudioCodec, "6, 16, fill, default"); cbFilterDatasource = new JCheckBox(""); cbFilterDatasource.setUI(CHECKBOX_UI); // $hide$ cbFilterDatasource.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.DATASOURCE)); cbFilterDatasource.setAction(actionFilter); add(cbFilterDatasource, "2, 17"); JLabel lblDatasource = new JLabel(BUNDLE.getString("metatag.datasource")); //$NON-NLS-1$ setComponentFont(lblDatasource); add(lblDatasource, "4, 17, right, default"); cbDatasource = new SmallCheckComboBox(); cbDatasource.setTextFor(CheckComboBox.NONE, BUNDLE.getString("checkcombobox.selected.none")); //$NON-NLS-1$ cbDatasource.setTextFor(CheckComboBox.MULTIPLE, BUNDLE.getString("checkcombobox.selected.multiple")); //$NON-NLS-1$ cbDatasource.setTextFor(CheckComboBox.ALL, BUNDLE.getString("checkcombobox.selected.all")); //$NON-NLS-1$ cbDatasource.getModel().addListCheckListener(listCheckListener); add(cbDatasource, "6, 17, fill, default"); cbFilterMediaSource = new JCheckBox(""); cbFilterMediaSource.setUI(CHECKBOX_UI); // $hide$ cbFilterMediaSource.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MEDIA_SOURCE)); cbFilterMediaSource.addActionListener(actionFilter); add(cbFilterMediaSource, "2, 18"); JLabel lblMediaSource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$ setComponentFont(lblMediaSource); add(lblMediaSource, "4, 18, right, default"); cbMediaSource = new SmallComboBox(MediaSource.values()); setComponentFont(cbMediaSource); cbMediaSource.setAction(actionFilter); add(cbMediaSource, "6, 18, fill, default"); cbFilterMissingMetadata = new JCheckBox(""); cbFilterMissingMetadata.setUI(CHECKBOX_UI); // $hide$ cbFilterMissingMetadata.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MISSING_METADATA)); cbFilterMissingMetadata.setAction(actionFilter); add(cbFilterMissingMetadata, "2, 19"); JLabel lblMissingMetadata = new JLabel(BUNDLE.getString("movieextendedsearch.missingmetadata")); //$NON-NLS-1$ setComponentFont(lblMissingMetadata); add(lblMissingMetadata, "4, 19, right, default"); cbFilterMissingArtwork = new JCheckBox(""); cbFilterMissingArtwork.setUI(CHECKBOX_UI); // $hide$ cbFilterMissingArtwork.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MISSING_ARTWORK)); cbFilterMissingArtwork.setAction(actionFilter); add(cbFilterMissingArtwork, "2, 20"); JLabel lblMissingArtwork = new JLabel(BUNDLE.getString("movieextendedsearch.missingartwork")); //$NON-NLS-1$ setComponentFont(lblMissingArtwork); add(lblMissingArtwork, "4, 20, right, default"); cbFilterMissingSubtitles = new JCheckBox(""); cbFilterMissingSubtitles.setUI(CHECKBOX_UI); // $hide$ cbFilterMissingSubtitles.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MISSING_SUBTITLES)); cbFilterMissingSubtitles.setAction(actionFilter); add(cbFilterMissingSubtitles, "2, 21"); JLabel lblMissingSubtitles = new JLabel(BUNDLE.getString("movieextendedsearch.missingsubtitles")); //$NON-NLS-1$ setComponentFont(lblMissingSubtitles); add(lblMissingSubtitles, "4, 21, right, default"); cbFilterOffline = new JCheckBox(""); cbFilterOffline.setUI(CHECKBOX_UI); // $hide$ cbFilterOffline.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.OFFLINE)); cbFilterOffline.setAction(actionFilter); add(cbFilterOffline, "2, 22"); lblOffline = new JLabel(BUNDLE.getString("movieextendedsearch.offline")); //$NON-NLS-1$ setComponentFont(lblOffline); add(lblOffline, "4, 22, right, default"); cbOffline = new SmallComboBox(OfflineMovie.values()); cbOffline.setAction(actionFilter); add(cbOffline, "6, 22, fill, default"); JSeparator separator = new JSeparator(); add(separator, "2, 24, 5, 1"); JLabel lblSortBy = new JLabel(BUNDLE.getString("movieextendedsearch.sortby")); //$NON-NLS-1$ setComponentFont(lblSortBy); add(lblSortBy, "2, 26, 3, 1"); cbSortColumn = new SmallComboBox(SortColumn.values()); setComponentFont(cbSortColumn); cbSortColumn.setAction(actionSort); add(cbSortColumn, "2, 28, 3, 1, fill, default"); cbSortOrder = new SmallComboBox(SortOrder.values()); setComponentFont(cbSortOrder); cbSortOrder.setAction(actionSort); add(cbSortOrder, "6, 28, fill, default"); PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getSource() instanceof MovieList && "tag".equals(evt.getPropertyName())) { buildAndInstallTagsArray(); } if (evt.getSource() instanceof MovieList && "videoCodec".equals(evt.getPropertyName())) { buildAndInstallCodecArray(); } if (evt.getSource() instanceof MovieList && "audioCodec".equals(evt.getPropertyName())) { buildAndInstallCodecArray(); } if (evt.getSource() instanceof MovieSettings && "movieDataSource".equals(evt.getPropertyName())) { buildAndInstallDatasourceArray(); } if (evt.getSource() instanceof MovieList && "certification".equals(evt.getPropertyName())) { buildAndInstallCertificationArray(); } } }; movieList.addPropertyChangeListener(propertyChangeListener); MovieModuleManager.MOVIE_SETTINGS.addPropertyChangeListener(propertyChangeListener); buildAndInstallTagsArray(); buildAndInstallCodecArray(); buildAndInstallDatasourceArray(); buildAndInstallCertificationArray(); }
From source file:org.tinymediamanager.ui.movies.settings.MovieScraperSettingsPanel.java
/** * Instantiates a new movie scraper settings panel. *///from w w w.ja va 2s. com public MovieScraperSettingsPanel() { // data init MediaScraper defaultMediaScraper = MovieList.getInstance().getDefaultMediaScraper(); int selectedIndex = 0; int counter = 0; for (MediaScraper scraper : MovieList.getInstance().getAvailableMediaScrapers()) { MovieScraper movieScraper = new MovieScraper(scraper); if (scraper.equals(defaultMediaScraper)) { movieScraper.defaultScraper = true; selectedIndex = counter; } scrapers.add(movieScraper); counter++; } // UI init setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); JPanel panelMovieScrapers = new JPanel(); panelMovieScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("scraper.metadata"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$ add(panelMovieScrapers, "2, 2, 3, 1, fill, fill"); panelMovieScrapers.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("50dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("150dlu:grow"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); scrollPaneScraper = new JScrollPane(); panelMovieScrapers.add(scrollPaneScraper, "2, 2, 3, 1, fill, fill"); tableScraper = new JTable() { private static final long serialVersionUID = -144223066269069772L; @Override public java.awt.Component prepareRenderer(TableCellRenderer renderer, int row, int col) { java.awt.Component comp = super.prepareRenderer(renderer, row, col); String value = getModel().getValueAt(row, 2).toString(); if (!Globals.isDonator() && value.startsWith("Kodi")) { // FIXME: use scraper.isEnabled() somehow? comp.setBackground(Color.lightGray); comp.setEnabled(false); } else { comp.setBackground(Color.white); comp.setEnabled(true); } return comp; } }; tableScraper.setRowHeight(29); scrollPaneScraper.setViewportView(tableScraper); scrollPane = new JScrollPane(); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(null); panelMovieScrapers.add(scrollPane, "6, 1, 1, 7, fill, fill"); panelScraperDetails = new ScrollablePanel(); scrollPane.setViewportView(panelScraperDetails); panelScraperDetails .setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); { // add a CSS rule to force body tags to use the default label font // instead of the value in javax.swing.text.html.default.csss Font font = UIManager.getFont("Label.font"); String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }"; tpScraperDescription = new JTextPane(); tpScraperDescription.setOpaque(false); tpScraperDescription.setEditorKit(new HTMLEditorKit()); ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule); panelScraperDetails.add(tpScraperDescription, "1, 1, default, top"); } panelScraperOptions = new JPanel(); panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top"); JSeparator separator = new JSeparator(); panelMovieScrapers.add(separator, "2, 4, 3, 1"); JLabel lblScraperLanguage = new JLabel(BUNDLE.getString("Settings.preferredLanguage")); //$NON-NLS-1$ panelMovieScrapers.add(lblScraperLanguage, "2, 5, right, default"); cbScraperLanguage = new JComboBox(MediaLanguages.values()); panelMovieScrapers.add(cbScraperLanguage, "4, 5"); JLabel lblCountry = new JLabel(BUNDLE.getString("Settings.certificationCountry")); //$NON-NLS-1$ panelMovieScrapers.add(lblCountry, "2, 7, right, default"); cbCertificationCountry = new JComboBox(CountryCode.values()); panelMovieScrapers.add(cbCertificationCountry, "4, 7, fill, default"); panelMovieScrapers.add(new JSeparator(), "2, 8, 5, 1"); chckbxScraperFallback = new JCheckBox(BUNDLE.getString("Settings.scraperfallback")); //$NON-NLS-1$ panelMovieScrapers.add(chckbxScraperFallback, "2, 9, 5, 1"); panelScraperMetadataContainer = new JPanel(); panelScraperMetadataContainer.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("scraper.metadata.defaults"), TitledBorder.LEADING, TitledBorder.TOP, null, //$NON-NLS-1$ new Color(51, 51, 51))); add(panelScraperMetadataContainer, "2, 4, fill, fill"); panelScraperMetadataContainer.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("10dlu"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, })); panelScraperMetadata = new MovieScraperMetadataPanel( Settings.getInstance().getMovieScraperMetadataConfig()); panelScraperMetadataContainer.add(panelScraperMetadata, "1, 1, 4, 1, fill, default"); chckbxAutomaticallyScrapeImages = new JCheckBox(BUNDLE.getString("Settings.default.autoscrape")); //$NON-NLS-1$ panelScraperMetadataContainer.add(chckbxAutomaticallyScrapeImages, "2, 3, 3, 1"); chckbxImageLanguage = new JCheckBox(BUNDLE.getString("Settings.default.autoscrape.language"));//$NON-NLS-1$ panelScraperMetadataContainer.add(chckbxImageLanguage, "4, 5"); panelAutomaticScraper = new JPanel(); panelAutomaticScraper.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.automaticscraper"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelAutomaticScraper, "4, 4, fill, fill"); panelAutomaticScraper.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JLabel lblScraperTreshold = new JLabel(BUNDLE.getString("Settings.scraperTreshold")); //$NON-NLS-1$ panelAutomaticScraper.add(lblScraperTreshold, "1, 2, default, top"); sliderThreshold = new JSlider(); sliderThreshold.setMinorTickSpacing(5); sliderThreshold.setMajorTickSpacing(10); sliderThreshold.setPaintTicks(true); sliderThreshold.setPaintLabels(true); sliderThreshold.setValue((int) (settings.getScraperThreshold() * 100)); Hashtable<Integer, JLabel> labelTable = new java.util.Hashtable<>(); labelTable.put(100, new JLabel("1.0")); labelTable.put(75, new JLabel("0.75")); labelTable.put(50, new JLabel("0.50")); labelTable.put(25, new JLabel("0.25")); labelTable.put(0, new JLabel("0.0")); sliderThreshold.setLabelTable(labelTable); sliderThreshold.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { settings.setScraperThreshold(sliderThreshold.getValue() / 100.0); } }); panelAutomaticScraper.add(sliderThreshold, "3, 2"); lblScraperThresholdHint = new JTextPane(); panelAutomaticScraper.add(lblScraperThresholdHint, "1, 6, 3, 1"); lblScraperThresholdHint.setOpaque(false); TmmFontHelper.changeFont(lblScraperThresholdHint, 0.833); lblScraperThresholdHint.setText(BUNDLE.getString("Settings.scraperTreshold.hint")); //$NON-NLS-1$ initDataBindings(); // adjust table columns // Checkbox and Logo shall have minimal width TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2); TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2); TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5); // implement listener to simulate button group tableScraper.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); MovieScraper changedScraper = scrapers.get(row); // if flag default scraper was changed, change all other flags if (changedScraper.getDefaultScraper()) { settings.setMovieScraper(changedScraper.getScraperId()); for (MovieScraper scraper : scrapers) { if (scraper != changedScraper) { scraper.setDefaultScraper(Boolean.FALSE); } } } } } }); // implement selection listener to load settings tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow()); if (index > -1) { panelScraperOptions.removeAll(); if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) { panelScraperOptions .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider())); } panelScraperOptions.revalidate(); } } }); // select default movie scraper if (counter > 0) { tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex); } }
From source file:org.tinymediamanager.ui.tvshows.dialogs.TvShowEpisodeEditorDialog.java
/** * Instantiates a new tv show episode scrape dialog. * // www . j a v a 2s . com * @param episode * the episode * @param inQueue * the in queue */ public TvShowEpisodeEditorDialog(TvShowEpisode episode, boolean inQueue) { super(BUNDLE.getString("tvshowepisode.scrape"), "tvShowEpisodeScraper"); //$NON-NLS-1$ setBounds(5, 5, 964, 632); for (MediaFile mf : episode.getMediaFiles()) { mediaFiles.add(new MediaFile(mf)); } this.episodeToEdit = episode; getContentPane().setLayout(new BorderLayout()); { JPanel panelFilename = new JPanel(); getContentPane().add(panelFilename, BorderLayout.NORTH); panelFilename.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 lblFilenameT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$ panelFilename.add(lblFilenameT, "2, 2, left, top"); lblFilename = new JLabel(""); TmmFontHelper.changeFont(lblFilename, 1.166, Font.BOLD); panelFilename.add(lblFilename, "5, 2, left, top"); } JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.NORTH); getContentPane().add(tabbedPane, BorderLayout.CENTER); /** * DetailsPanel */ { JPanel detailsPanel = new JPanel(); tabbedPane.addTab(BUNDLE.getString("metatag.details"), detailsPanel); //$NON-NLS-1$ detailsPanel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("40dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("20dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("30dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, 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("100dlu:grow"), FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("35dlu:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblTitle = new JLabel(BUNDLE.getString("metatag.title")); //$NON-NLS-1$ detailsPanel.add(lblTitle, "2, 4, right, default"); tfTitle = new JTextField(); detailsPanel.add(tfTitle, "4, 4, 19, 1"); tfTitle.setColumns(10); JLabel lblSeason = new JLabel(BUNDLE.getString("metatag.season")); //$NON-NLS-1$ detailsPanel.add(lblSeason, "2, 6, right, default"); spSeason = new JSpinner(); detailsPanel.add(spSeason, "4, 6"); JLabel lblEpisode = new JLabel(BUNDLE.getString("metatag.episode")); //$NON-NLS-1$ detailsPanel.add(lblEpisode, "8, 6, right, default"); spEpisode = new JSpinner(); detailsPanel.add(spEpisode, "10, 6"); JLabel lblDvdSeason = new JLabel(BUNDLE.getString("metatag.dvdseason")); //$NON-NLS-1$ detailsPanel.add(lblDvdSeason, "2, 8, right, default"); spDvdSeason = new JSpinner(); detailsPanel.add(spDvdSeason, "4, 8"); JLabel lblDvdEpisode = new JLabel(BUNDLE.getString("metatag.dvdepisode")); //$NON-NLS-1$ detailsPanel.add(lblDvdEpisode, "8, 8, right, default"); spDvdEpisode = new JSpinner(); detailsPanel.add(spDvdEpisode, "10, 8"); JLabel lblDvdOrder = new JLabel(BUNDLE.getString("metatag.dvdorder")); //$NON-NLS-1$ detailsPanel.add(lblDvdOrder, "14, 8, right, default"); cbDvdOrder = new JCheckBox(""); detailsPanel.add(cbDvdOrder, "16, 8"); cbDvdOrder.setSelected(episodeToEdit.isDvdOrder()); JLabel lblDisplaySeason = new JLabel(BUNDLE.getString("metatag.displayseason")); //$NON-NLS-1$ detailsPanel.add(lblDisplaySeason, "2, 10, right, default"); spDisplaySeason = new JSpinner(); detailsPanel.add(spDisplaySeason, "4, 10"); JLabel lblDisplayEpisode = new JLabel(BUNDLE.getString("metatag.displayepisode")); //$NON-NLS-1$ detailsPanel.add(lblDisplayEpisode, "8, 10, right, default"); spDisplayEpisode = new JSpinner(); detailsPanel.add(spDisplayEpisode, "10, 10"); JLabel lblRating = new JLabel(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$ detailsPanel.add(lblRating, "2, 12, right, default"); spRating = new JSpinner(); detailsPanel.add(spRating, "4, 12"); JLabel lblFirstAired = new JLabel(BUNDLE.getString("metatag.aired")); //$NON-NLS-1$ detailsPanel.add(lblFirstAired, "8, 12, right, default"); dpFirstAired = new DatePicker(episode.getFirstAired()); detailsPanel.add(dpFirstAired, "10, 12, 3, 1, fill, default"); JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$ detailsPanel.add(lblWatched, "2, 14, right, default"); chckbxWatched = new JCheckBox(""); detailsPanel.add(chckbxWatched, "4, 14"); JLabel lblDateAdded = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$ detailsPanel.add(lblDateAdded, "8, 14, right, default"); spDateAdded = new JSpinner(new SpinnerDateModel()); detailsPanel.add(spDateAdded, "10, 14, 3, 1, fill, default"); JLabel lblMediasource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$ detailsPanel.add(lblMediasource, "2, 16, right, default"); cbMediaSource = new JComboBox(MediaSource.values()); detailsPanel.add(cbMediaSource, "4, 16, 4, 1, fill, default"); JLabel lblPlot = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$ detailsPanel.add(lblPlot, "2, 18, right, top"); JScrollPane scrollPane = new JScrollPane(); detailsPanel.add(scrollPane, "4, 18, 13, 1, fill, fill"); taPlot = new JTextArea(); taPlot.setLineWrap(true); taPlot.setWrapStyleWord(true); scrollPane.setViewportView(taPlot); lblThumb = new ImageLabel(); lblThumb.setAlternativeText(BUNDLE.getString("image.notfound.thumb")); //$NON-NLS-1$ lblThumb.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { Path file = TmmUIHelper.selectFile(BUNDLE.getString("image.choose")); //$NON-NLS-1$ if (file != null && Utils.isRegularFile(file)) { String fileName = file.toAbsolutePath().toString(); lblThumb.setImageUrl("file:/" + fileName); } } }); lblThumb.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); detailsPanel.add(lblThumb, "20, 6, 3, 13"); JLabel lblDirector = new JLabel(BUNDLE.getString("metatag.director")); //$NON-NLS-1$ detailsPanel.add(lblDirector, "2, 20, right, default"); tfDirector = new JTextField(); tfDirector.setText((String) null); tfDirector.setColumns(10); detailsPanel.add(tfDirector, "4, 20, 13, 1, fill, default"); JLabel lblWriter = new JLabel(BUNDLE.getString("metatag.writer")); //$NON-NLS-1$ detailsPanel.add(lblWriter, "2, 22, right, default"); tfWriter = new JTextField(); tfWriter.setText((String) null); tfWriter.setColumns(10); detailsPanel.add(tfWriter, "4, 22, 13, 1, fill, default"); JLabel lblGuests = new JLabel(BUNDLE.getString("metatag.guests")); //$NON-NLS-1$ detailsPanel.add(lblGuests, "2, 24, right, top"); JScrollPane scrollPaneGuests = new JScrollPane(); detailsPanel.add(scrollPaneGuests, "4, 24, 13, 7, fill, fill"); tableGuests = new JTable(); tableGuests.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); scrollPaneGuests.setViewportView(tableGuests); JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$ detailsPanel.add(lblTags, "20, 24, default, top"); JScrollPane scrollPaneTags = new JScrollPane(); detailsPanel.add(scrollPaneTags, "22, 24, 1, 5, fill, fill"); listTags = new JList(); scrollPaneTags.setViewportView(listTags); JButton btnAddActor = new JButton(""); btnAddActor.setMargin(new Insets(2, 2, 2, 2)); btnAddActor.setAction(new AddActorAction()); btnAddActor.setIcon(IconManager.LIST_ADD); detailsPanel.add(btnAddActor, "2, 26, right, top"); JButton btnAddTag = new JButton(""); btnAddTag.setMargin(new Insets(2, 2, 2, 2)); btnAddTag.setAction(new AddTagAction()); btnAddTag.setIcon(IconManager.LIST_ADD); detailsPanel.add(btnAddTag, "20, 26, right, top"); JButton btnRemoveActor = new JButton(""); btnRemoveActor.setMargin(new Insets(2, 2, 2, 2)); btnRemoveActor.setAction(new RemoveActorAction()); btnRemoveActor.setIcon(IconManager.LIST_REMOVE); detailsPanel.add(btnRemoveActor, "2, 28, right, top"); JButton btnRemoveTag = new JButton(""); btnRemoveTag.setMargin(new Insets(2, 2, 2, 2)); btnRemoveTag.setAction(new RemoveTagAction()); btnRemoveTag.setIcon(IconManager.LIST_REMOVE); detailsPanel.add(btnRemoveTag, "20, 28, right, top"); cbTags = new AutocompleteComboBox(tvShowList.getTagsInEpisodes().toArray()); cbTags.setEditable(true); detailsPanel.add(cbTags, "22, 30, fill, default"); } /** * Media Files panel */ { mediaFilesPanel = new MediaFileEditorPanel(mediaFiles); tabbedPane.addTab(BUNDLE.getString("metatag.mediafiles"), null, mediaFilesPanel, null); //$NON-NLS-1$ } { JPanel bottomPanel = new JPanel(); getContentPane().add(bottomPanel, BorderLayout.SOUTH); bottomPanel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("25px"), FormFactory.RELATED_GAP_ROWSPEC, })); cbScraper = new MediaScraperComboBox(tvShowList.getAvailableMediaScrapers()); MediaScraper defaultScraper = tvShowList.getDefaultMediaScraper(); cbScraper.setSelectedItem(defaultScraper); bottomPanel.add(cbScraper, "2, 2, fill, default"); JButton btnScrape = new JButton(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$ btnScrape.setPreferredSize(new Dimension(100, 23)); btnScrape.setMaximumSize(new Dimension(0, 0)); btnScrape.setMinimumSize(new Dimension(100, 23)); btnScrape.setActionCommand("Scrape"); btnScrape.addActionListener(this); bottomPanel.add(btnScrape, "4, 2, left, fill"); JButton btnSearch = new JButton(BUNDLE.getString("tvshowepisodechooser.search")); //$NON-NLS-1$ btnSearch.setActionCommand("Search"); btnSearch.addActionListener(this); btnSearch.setIcon(IconManager.SEARCH); bottomPanel.add(btnSearch, "6, 2, left, fill"); { JPanel buttonPane = new JPanel(); bottomPanel.add(buttonPane, "8, 2, fill, fill"); EqualsLayout layout = new EqualsLayout(5); layout.setMinWidth(100); buttonPane.setLayout(layout); JButton okButton = new JButton(BUNDLE.getString("Button.ok")); //$NON-NLS-1$ okButton.setToolTipText(BUNDLE.getString("tvshow.change")); okButton.setIcon(IconManager.APPLY); buttonPane.add(okButton); okButton.setActionCommand("OK"); okButton.addActionListener(this); JButton cancelButton = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$ cancelButton.setToolTipText(BUNDLE.getString("edit.discard")); cancelButton.setIcon(IconManager.CANCEL); buttonPane.add(cancelButton); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(this); if (inQueue) { JButton abortButton = new JButton(BUNDLE.getString("Button.abortqueue")); //$NON-NLS-1$ abortButton.setToolTipText(BUNDLE.getString("tvshow.edit.abortqueue.desc")); //$NON-NLS-1$ abortButton.setIcon(IconManager.PROCESS_STOP); buttonPane.add(abortButton); abortButton.setActionCommand("Abort"); abortButton.addActionListener(this); } } } initDataBindings(); // fill data { MediaFile mediaFile = episodeToEdit.getMediaFiles().get(0); lblFilename.setText(mediaFile.getFileAsPath().toString()); tfTitle.setText(episodeToEdit.getTitle()); spSeason.setModel(new SpinnerNumberModel(episodeToEdit.getAiredSeason(), -1, Integer.MAX_VALUE, 1)); spEpisode.setModel(new SpinnerNumberModel(episodeToEdit.getAiredEpisode(), -1, Integer.MAX_VALUE, 1)); spDvdSeason.setModel(new SpinnerNumberModel(episodeToEdit.getDvdSeason(), -1, Integer.MAX_VALUE, 1)); spDvdEpisode.setModel(new SpinnerNumberModel(episodeToEdit.getDvdEpisode(), -1, Integer.MAX_VALUE, 1)); spDisplaySeason .setModel(new SpinnerNumberModel(episodeToEdit.getDisplaySeason(), -1, Integer.MAX_VALUE, 1)); spDisplayEpisode .setModel(new SpinnerNumberModel(episodeToEdit.getDisplayEpisode(), -1, Integer.MAX_VALUE, 1)); spDateAdded.setValue(episodeToEdit.getDateAdded()); lblThumb.setImagePath(episodeToEdit.getArtworkFilename(MediaFileType.THUMB)); spRating.setModel(new SpinnerNumberModel(episodeToEdit.getRating(), 0.0, 10.0, 0.1)); spRating.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { voteCount = 1; } }); voteCount = episodeToEdit.getVotes(); chckbxWatched.setSelected(episodeToEdit.isWatched()); taPlot.setText(episodeToEdit.getPlot()); taPlot.setCaretPosition(0); tfDirector.setText(episodeToEdit.getDirector()); tfWriter.setText(episodeToEdit.getWriter()); cbMediaSource.setSelectedItem(episodeToEdit.getMediaSource()); for (TvShowActor origCast : episodeToEdit.getGuests()) { TvShowActor actor = new TvShowActor(); actor.setName(origCast.getName()); actor.setCharacter(origCast.getCharacter()); actor.setThumbUrl(origCast.getThumbUrl()); cast.add(actor); } for (String tag : episodeToEdit.getTags()) { tags.add(tag); } } // adjust table columns tableGuests.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$ tableGuests.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$ }