List of usage examples for javax.swing JSeparator JSeparator
public JSeparator()
From source file:org.tinymediamanager.ui.movies.settings.MovieSettingsPanel.java
/** * Instantiates a new movie settings panel. *//*from w w w . j a va 2 s .co m*/ public MovieSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); JPanel panelGeneral = new JPanel(); panelGeneral.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.general"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelGeneral, "2, 2, fill, fill"); panelGeneral.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblVisiblecolumns = new JLabel(BUNDLE.getString("Settings.movie.visiblecolumns")); //$NON-NLS-1$ panelGeneral.add(lblVisiblecolumns, "2, 2, right, default"); chckbxYear = new JCheckBox(BUNDLE.getString("metatag.year")); //$NON-NLS-1$ panelGeneral.add(chckbxYear, "4, 2"); chckbxRating = new JCheckBox(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$ panelGeneral.add(chckbxRating, "6, 2"); chckbxNfo = new JCheckBox(BUNDLE.getString("metatag.nfo")); //$NON-NLS-1$ panelGeneral.add(chckbxNfo, "8, 2"); chckbxMetadata = new JCheckBox(BUNDLE.getString("tmm.metadata")); //$NON-NLS-1$ panelGeneral.add(chckbxMetadata, "10, 2"); chckbxDateAdded = new JCheckBox(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$ panelGeneral.add(chckbxDateAdded, "12, 2"); chckbxImages = new JCheckBox(BUNDLE.getString("metatag.images")); //$NON-NLS-1$ panelGeneral.add(chckbxImages, "4, 4"); chckbxTrailer = new JCheckBox(BUNDLE.getString("metatag.trailer")); //$NON-NLS-1$ panelGeneral.add(chckbxTrailer, "6, 4"); chckbxSubtitles = new JCheckBox(BUNDLE.getString("metatag.subtitles")); //$NON-NLS-1$ panelGeneral.add(chckbxSubtitles, "8, 4"); chckbxWatched = new JCheckBox(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$ panelGeneral.add(chckbxWatched, "10, 4"); JLabel lblSaveUiFilter = new JLabel(BUNDLE.getString("Settings.movie.persistuifilter")); //$NON-NLS-1$ panelGeneral.add(lblSaveUiFilter, "2, 6, right, default"); chckbxSaveUiFilter = new JCheckBox(""); panelGeneral.add(chckbxSaveUiFilter, "4, 6"); JSeparator separator_4 = new JSeparator(); panelGeneral.add(separator_4, "2, 8, 11, 1"); JLabel lblImageCache = new JLabel(BUNDLE.getString("Settings.imagecacheimport")); panelGeneral.add(lblImageCache, "2, 10, right, default"); chckbxImageCache = new JCheckBox(BUNDLE.getString("Settings.imagecacheimporthint")); //$NON-NLS-1$ TmmFontHelper.changeFont(chckbxImageCache, 0.833); panelGeneral.add(chckbxImageCache, "4, 10, 7, 1"); JLabel lblRuntimeFromMedia = new JLabel(BUNDLE.getString("Settings.runtimefrommediafile")); panelGeneral.add(lblRuntimeFromMedia, "2, 12, right, default"); chckbxRuntimeFromMf = new JCheckBox(""); panelGeneral.add(chckbxRuntimeFromMf, "4, 12"); JSeparator separator = new JSeparator(); panelGeneral.add(separator, "2, 14, 11, 1"); final JLabel lblAutomaticRename = new JLabel(BUNDLE.getString("Settings.movie.automaticrename")); //$NON-NLS-1$ panelGeneral.add(lblAutomaticRename, "2, 16, right, default"); chckbxRename = new JCheckBox(BUNDLE.getString("Settings.movie.automaticrename.desc")); //$NON-NLS-1$ panelGeneral.add(chckbxRename, "4, 16, 7, 1"); JLabel lblTraktTv = new JLabel(BUNDLE.getString("Settings.trakt"));//$NON-NLS-1$ panelGeneral.add(lblTraktTv, "2, 18"); chckbxTraktTv = new JCheckBox(""); panelGeneral.add(chckbxTraktTv, "4, 18"); JButton btnClearTraktTvMovies = new JButton(BUNDLE.getString("Settings.trakt.clearmovies"));//$NON-NLS-1$ btnClearTraktTvMovies.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int confirm = JOptionPane.showOptionDialog(null, BUNDLE.getString("Settings.trakt.clearmovies.hint"), BUNDLE.getString("Settings.trakt.clearmovies"), JOptionPane.YES_NO_OPTION, //$NON-NLS-1$ JOptionPane.QUESTION_MESSAGE, null, null, null); if (confirm == JOptionPane.YES_OPTION) { TmmTask task = new ClearTraktTvTask(true, false); TmmTaskManager.getInstance().addUnnamedTask(task); } } }); panelGeneral.add(btnClearTraktTvMovies, "6, 18, 3, 1, left, default"); JPanel panelMovieDataSources = new JPanel(); panelMovieDataSources.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.movie.datasource"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelMovieDataSources, "2, 4, 3, 1, fill, fill"); panelMovieDataSources.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150dlu:grow(2)"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("100px:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblDataSource = new JLabel(BUNDLE.getString("Settings.source")); //$NON-NLS-1$ panelMovieDataSources.add(lblDataSource, "2, 2, 5, 1"); JLabel lblIngore = new JLabel(BUNDLE.getString("Settings.ignore")); //$NON-NLS-1$ panelMovieDataSources.add(lblIngore, "12, 2"); JScrollPane scrollPaneDataSources = new JScrollPane(); panelMovieDataSources.add(scrollPaneDataSources, "2, 4, 5, 1, fill, fill"); listDataSources = new JList<>(); scrollPaneDataSources.setViewportView(listDataSources); JPanel panelMovieSourcesButtons = new JPanel(); panelMovieDataSources.add(panelMovieSourcesButtons, "8, 4, fill, top"); panelMovieSourcesButtons .setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JButton btnAdd = new JButton(IconManager.LIST_ADD); btnAdd.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAdd.setMargin(new Insets(2, 2, 2, 2)); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.datasource.folderchooser")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { settings.addMovieDataSources(file.toAbsolutePath().toString()); } } }); panelMovieSourcesButtons.add(btnAdd, "1, 1, fill, top"); JButton btnRemove = new JButton(IconManager.LIST_REMOVE); btnRemove.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemove.setMargin(new Insets(2, 2, 2, 2)); btnRemove.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listDataSources.getSelectedIndex(); if (row != -1) { // nothing selected String path = MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource().get(row); String[] choices = { BUNDLE.getString("Button.continue"), BUNDLE.getString("Button.abort") }; //$NON-NLS-1$ int decision = JOptionPane.showOptionDialog(null, String.format(BUNDLE.getString("Settings.movie.datasource.remove.info"), path), BUNDLE.getString("Settings.datasource.remove"), JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, choices, BUNDLE.getString("Button.abort")); //$NON-NLS-1$ if (decision == 0) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); MovieModuleManager.MOVIE_SETTINGS.removeMovieDataSources(path); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } } }); panelMovieSourcesButtons.add(btnRemove, "1, 3, fill, top"); JScrollPane scrollPaneIgnore = new JScrollPane(); panelMovieDataSources.add(scrollPaneIgnore, "12, 4, fill, fill"); listIgnore = new JList<>(); scrollPaneIgnore.setViewportView(listIgnore); JPanel panelIgnoreButtons = new JPanel(); panelMovieDataSources.add(panelIgnoreButtons, "14, 4, fill, fill"); panelIgnoreButtons.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JButton btnAddIgnore = new JButton(IconManager.LIST_ADD); btnAddIgnore.setToolTipText(BUNDLE.getString("Settings.addignore")); //$NON-NLS-1$ btnAddIgnore.setMargin(new Insets(2, 2, 2, 2)); btnAddIgnore.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.ignore")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { settings.addMovieSkipFolder(file.toAbsolutePath().toString()); } } }); panelIgnoreButtons.add(btnAddIgnore, "1, 1"); JButton btnRemoveIgnore = new JButton(IconManager.LIST_REMOVE); btnRemoveIgnore.setToolTipText(BUNDLE.getString("Settings.removeignore")); //$NON-NLS-1$ btnRemoveIgnore.setMargin(new Insets(2, 2, 2, 2)); btnRemoveIgnore.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int row = listIgnore.getSelectedIndex(); if (row != -1) { // nothing selected String ingore = settings.getMovieSkipFolders().get(row); settings.removeMovieSkipFolder(ingore); } } }); panelIgnoreButtons.add(btnRemoveIgnore, "1, 3"); JPanel panel = new JPanel(); panelMovieDataSources.add(panel, "2, 8, 13, 1, fill, fill"); panel.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("20dlu"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JLabel lblNfoFormat = new JLabel(BUNDLE.getString("Settings.nfoFormat")); panel.add(lblNfoFormat, "1, 1, right, default"); cbNfoFormat = new JComboBox(MovieConnectors.values()); panel.add(cbNfoFormat, "3, 1, fill, default"); JLabel lblNfoFileNaming = new JLabel(BUNDLE.getString("Settings.nofFileNaming")); //$NON-NLS-1$ panel.add(lblNfoFileNaming, "7, 1, right, default"); cbMovieNfoFilename1 = new JCheckBox(BUNDLE.getString("Settings.moviefilename") + ".nfo"); //$NON-NLS-1$ panel.add(cbMovieNfoFilename1, "9, 1"); cbMovieNfoFilename2 = new JCheckBox("movie.nfo"); panel.add(cbMovieNfoFilename2, "9, 2"); cbMovieNfoFilename2.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); cbMovieNfoFilename3 = new JCheckBox(BUNDLE.getString("Settings.nfo.discstyle")); //$NON-NLS-1$ panel.add(cbMovieNfoFilename3, "9, 3"); cbMovieNfoFilename3.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); final JLabel lblCertificationStyle = new JLabel(BUNDLE.getString("Settings.certificationformat")); //$NON-NLS-1$ panel.add(lblCertificationStyle, "1, 5, right, default"); cbCertificationStyle = new JComboBox(); panel.add(cbCertificationStyle, "3, 5, 7, 1, fill, default"); JPanel panelBadWords = new JPanel(); panelBadWords.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.movie.badwords"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelBadWords, "4, 2, fill, fill"); panelBadWords.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JTextPane txtpntBadWordsHint = new JTextPane(); txtpntBadWordsHint.setBackground(UIManager.getColor("Panel.background")); txtpntBadWordsHint.setText(BUNDLE.getString("Settings.movie.badwords.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(txtpntBadWordsHint, 0.833); panelBadWords.add(txtpntBadWordsHint, "2, 2, 3, 1, fill, default"); JScrollPane scpBadWords = new JScrollPane(); panelBadWords.add(scpBadWords, "2, 4, fill, fill"); listBadWords = new JList<>(); scpBadWords.setViewportView(listBadWords); JButton btnRemoveBadWord = new JButton(IconManager.LIST_REMOVE); btnRemoveBadWord.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemoveBadWord.setMargin(new Insets(2, 2, 2, 2)); btnRemoveBadWord.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listBadWords.getSelectedIndex(); if (row != -1) { String badWord = MovieModuleManager.MOVIE_SETTINGS.getBadWords().get(row); MovieModuleManager.MOVIE_SETTINGS.removeBadWord(badWord); } } }); panelBadWords.add(btnRemoveBadWord, "4, 4, default, bottom"); tfAddBadword = new JTextField(); tfAddBadword.setColumns(10); panelBadWords.add(tfAddBadword, "2, 6, fill, default"); JButton btnAddBadWord = new JButton(IconManager.LIST_ADD); btnAddBadWord.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAddBadWord.setMargin(new Insets(2, 2, 2, 2)); btnAddBadWord.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (StringUtils.isNotEmpty(tfAddBadword.getText())) { MovieModuleManager.MOVIE_SETTINGS.addBadWord(tfAddBadword.getText()); tfAddBadword.setText(""); } } }); panelBadWords.add(btnAddBadWord, "4, 6"); initDataBindings(); { // NFO filenames List<MovieNfoNaming> movieNfoFilenames = settings.getMovieNfoFilenames(); if (movieNfoFilenames.contains(MovieNfoNaming.FILENAME_NFO)) { cbMovieNfoFilename1.setSelected(true); } if (movieNfoFilenames.contains(MovieNfoNaming.MOVIE_NFO)) { cbMovieNfoFilename2.setSelected(true); } if (movieNfoFilenames.contains(MovieNfoNaming.DISC_NFO)) { cbMovieNfoFilename3.setSelected(true); } if (!Globals.isDonator()) { chckbxTraktTv.setSelected(false); chckbxTraktTv.setEnabled(false); btnClearTraktTvMovies.setEnabled(false); } // set default certification style cbNfoFormat.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (cbNfoFormat.getSelectedItem() == MovieConnectors.MP) { for (int i = 0; i < cbCertificationStyle.getItemCount(); i++) { CertificationStyleWrapper wrapper = cbCertificationStyle.getItemAt(i); if (wrapper.style == CertificationStyle.TECHNICAL) { cbCertificationStyle.setSelectedItem(wrapper); break; } } } else if (cbNfoFormat.getSelectedItem() == MovieConnectors.XBMC || cbNfoFormat.getSelectedItem() == MovieConnectors.KODI) { for (int i = 0; i < cbCertificationStyle.getItemCount(); i++) { CertificationStyleWrapper wrapper = cbCertificationStyle.getItemAt(i); if (wrapper.style == CertificationStyle.LARGE) { cbCertificationStyle.setSelectedItem(wrapper); break; } } } } }); // certification examples for (CertificationStyle style : CertificationStyle.values()) { CertificationStyleWrapper wrapper = new CertificationStyleWrapper(); wrapper.style = style; cbCertificationStyle.addItem(wrapper); if (style == settings.getMovieCertificationStyle()) { cbCertificationStyle.setSelectedItem(wrapper); } } cbCertificationStyle.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); // item listener cbMovieNfoFilename1.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); } }
From source file:org.tinymediamanager.ui.movies.settings.MovieTrailerSettingsPanel.java
public MovieTrailerSettingsPanel() { // data init/* w w w. j ava2s . c om*/ 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.settings.GeneralSettingsPanel.java
/** * Instantiates a new general settings panel. *///from w ww. j a va 2s. c om public GeneralSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("left:max(200px;min):grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(200px;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, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelUI = new JPanel(); panelUI.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.ui"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelUI, "2, 2, 3, 1, fill, fill"); panelUI.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); LocaleComboBox actualLocale = null; // cbLanguage = new JComboBox(Utils.getLanguages().toArray()); Locale settingsLang = Utils.getLocaleFromLanguage(Globals.settings.getLanguage()); for (Locale l : Utils.getLanguages()) { LocaleComboBox localeComboBox = new LocaleComboBox(l); locales.add(localeComboBox); if (l.equals(settingsLang)) { actualLocale = localeComboBox; } } JLabel lblUiLanguage = new JLabel(BUNDLE.getString("Settings.language")); panelUI.add(lblUiLanguage, "2, 2"); cbLanguage = new JComboBox(locales.toArray()); panelUI.add(cbLanguage, "4, 2"); if (actualLocale != null) { cbLanguage.setSelectedItem(actualLocale); } JSeparator separator = new JSeparator(); separator.setOrientation(SwingConstants.VERTICAL); panelUI.add(separator, "8, 2, 1, 7"); JLabel lblFontFamily = new JLabel(BUNDLE.getString("Settings.fontfamily")); //$NON-NLS-1$ panelUI.add(lblFontFamily, "10, 2, right, default"); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); cbFontFamily = new JComboBox(env.getAvailableFontFamilyNames()); cbFontFamily.setSelectedItem(Globals.settings.getFontFamily()); int index = cbFontFamily.getSelectedIndex(); if (index < 0) { cbFontFamily.setSelectedItem("Dialog"); index = cbFontFamily.getSelectedIndex(); } if (index < 0) { cbFontFamily.setSelectedIndex(0); } panelUI.add(cbFontFamily, "12, 2, fill, default"); JLabel lblFontSize = new JLabel(BUNDLE.getString("Settings.fontsize")); //$NON-NLS-1$ panelUI.add(lblFontSize, "10, 4, right, default"); cbFontSize = new JComboBox(DEFAULT_FONT_SIZES); cbFontSize.setSelectedItem(Globals.settings.getFontSize()); index = cbFontSize.getSelectedIndex(); if (index < 0) { cbFontSize.setSelectedIndex(0); } panelUI.add(cbFontSize, "12, 4, fill, default"); JPanel panel = new JPanel(); panelUI.add(panel, "2, 6, 5, 1, fill, fill"); panel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JLabel lblMissingTranslation = new JLabel(BUNDLE.getString("tmm.helptranslate")); panel.add(lblMissingTranslation, "1, 1, 5, 1"); lblLinkTransifex = new LinkLabel("https://www.transifex.com/projects/p/tinymediamanager/"); panel.add(lblLinkTransifex, "1, 3, 5, 1"); lblLinkTransifex.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { TmmUIHelper.browseUrl(lblLinkTransifex.getNormalText()); } catch (Exception e) { LOGGER.error(e.getMessage()); MessageManager.instance .pushMessage(new Message(MessageLevel.ERROR, lblLinkTransifex.getNormalText(), "message.erroropenurl", new String[] { ":", e.getLocalizedMessage() }));//$NON-NLS-2$ } } }); tpFontHint = new JTextPane(); tpFontHint.setOpaque(false); TmmFontHelper.changeFont(tpFontHint, 0.833); tpFontHint.setText(BUNDLE.getString("Settings.fonts.hint")); //$NON-NLS-1$ panelUI.add(tpFontHint, "10, 6, 5, 1"); lblLanguageHint = new JLabel(""); TmmFontHelper.changeFont(lblLanguageHint, Font.BOLD); panelUI.add(lblLanguageHint, "2, 8, 5, 1"); lblFontChangeHint = new JLabel(""); TmmFontHelper.changeFont(lblFontChangeHint, Font.BOLD); panelUI.add(lblFontChangeHint, "10, 8, 5, 1"); JPanel panelMemory = new JPanel(); panelMemory.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.memoryborder"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelMemory, "2, 4, fill, fill"); panelMemory.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow(4)"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(20dlu;default)"), ColumnSpec.decode("left:default:grow(5)"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, })); JLabel lblMemoryT = new JLabel(BUNDLE.getString("Settings.memory")); //$NON-NLS-1$ panelMemory.add(lblMemoryT, "2, 1"); sliderMemory = new JSlider(); sliderMemory.setPaintLabels(true); sliderMemory.setPaintTicks(true); sliderMemory.setSnapToTicks(true); sliderMemory.setMajorTickSpacing(512); sliderMemory.setMinorTickSpacing(128); sliderMemory.setMinimum(256); sliderMemory.setMaximum(1536); sliderMemory.setValue(512); panelMemory.add(sliderMemory, "4, 1, fill, default"); lblMemory = new JLabel("512"); //$NON-NLS-1$ panelMemory.add(lblMemory, "6, 1, right, default"); JLabel lblMb = new JLabel("MB"); panelMemory.add(lblMb, "7, 1, left, default"); tpMemoryHint = new JTextPane(); tpMemoryHint.setOpaque(false); tpMemoryHint.setText(BUNDLE.getString("Settings.memory.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(tpMemoryHint, 0.833); panelMemory.add(tpMemoryHint, "2, 3, 6, 1, fill, fill"); JPanel panelProxySettings = new JPanel(); panelProxySettings.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.proxy"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelProxySettings, "4, 4, fill, fill"); panelProxySettings.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, 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, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, })); JLabel lblProxyHost = new JLabel(BUNDLE.getString("Settings.proxyhost")); //$NON-NLS-1$ panelProxySettings.add(lblProxyHost, "2, 2, right, default"); tfProxyHost = new JTextField(); lblProxyHost.setLabelFor(tfProxyHost); panelProxySettings.add(tfProxyHost, "4, 2, fill, default"); tfProxyHost.setColumns(10); JLabel lblProxyPort = new JLabel(BUNDLE.getString("Settings.proxyport")); //$NON-NLS-1$ panelProxySettings.add(lblProxyPort, "2, 4, right, default"); tfProxyPort = new JTextField(); lblProxyPort.setLabelFor(tfProxyPort); panelProxySettings.add(tfProxyPort, "4, 4, fill, default"); tfProxyPort.setColumns(10); JLabel lblProxyUser = new JLabel(BUNDLE.getString("Settings.proxyuser")); //$NON-NLS-1$ panelProxySettings.add(lblProxyUser, "2, 6, right, default"); tfProxyUsername = new JTextField(); lblProxyUser.setLabelFor(tfProxyUsername); panelProxySettings.add(tfProxyUsername, "4, 6, fill, default"); tfProxyUsername.setColumns(10); JLabel lblProxyPassword = new JLabel(BUNDLE.getString("Settings.proxypass")); //$NON-NLS-1$ panelProxySettings.add(lblProxyPassword, "2, 8, right, default"); tfProxyPassword = new JPasswordField(); lblProxyPassword.setLabelFor(tfProxyPassword); panelProxySettings.add(tfProxyPassword, "4, 8, fill, default"); JPanel panelMediaPlayer = new JPanel(); panelMediaPlayer.setBorder( new TitledBorder(null, "MediaPlayer", TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelMediaPlayer, "2, 6, fill, fill"); panelMediaPlayer.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); tpMediaPlayer = new JTextPane(); tpMediaPlayer.setOpaque(false); TmmFontHelper.changeFont(tpMediaPlayer, 0.833); tpMediaPlayer.setText(BUNDLE.getString("Settings.mediaplayer.hint")); //$NON-NLS-1$ panelMediaPlayer.add(tpMediaPlayer, "2, 2, 3, 1, fill, fill"); tfMediaPlayer = new JTextField(); panelMediaPlayer.add(tfMediaPlayer, "2, 4, fill, default"); tfMediaPlayer.setColumns(10); btnSearchMediaPlayer = new JButton(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$ btnSearchMediaPlayer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Path file = TmmUIHelper.selectFile(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$ if (file != null && Utils.isRegularFile(file) || Platform.isMac()) { tfMediaPlayer.setText(file.toAbsolutePath().toString()); } } }); panelMediaPlayer.add(btnSearchMediaPlayer, "4, 4"); JPanel panelCache = new JPanel(); panelCache.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.cache"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelCache, "4, 6, fill, fill"); panelCache.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, })); chckbxImageCache = new JCheckBox(BUNDLE.getString("Settings.imagecache"));//$NON-NLS-1$ panelCache.add(chckbxImageCache, "2, 2, 3, 1"); JLabel lblImageCacheQuality = new JLabel(BUNDLE.getString("Settings.imagecachetype"));//$NON-NLS-1$ panelCache.add(lblImageCacheQuality, "2, 4, right, default"); cbImageCacheQuality = new JComboBox(ImageCache.CacheType.values()); panelCache.add(cbImageCacheQuality, "4, 4, fill, default"); JPanel panelAnalytics = new JPanel(); panelAnalytics.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.analytics.border"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelAnalytics, "2, 8, fill, fill"); panelAnalytics.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.LINE_GAP_ROWSPEC, })); chckbxAnalytics = new JCheckBox(BUNDLE.getString("Settings.analytics"));//$NON-NLS-1$ panelAnalytics.add(chckbxAnalytics, "2, 2"); JTextPane tpAnalyticsDescription = new JTextPane(); tpAnalyticsDescription.setText(BUNDLE.getString("Settings.analytics.desc"));//$NON-NLS-1$ tpAnalyticsDescription.setOpaque(false); panelAnalytics.add(tpAnalyticsDescription, "2, 4, fill, fill"); JPanel panelMisc = new JPanel(); panelMisc.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.misc"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelMisc, "4, 8, fill, fill"); panelMisc.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, })); chckbxDeleteTrash = new JCheckBox(BUNDLE.getString("Settings.deletetrash")); panelMisc.add(chckbxDeleteTrash, "2, 2, 3, 1"); initDataBindings(); initMemorySlider(); // listen to changes of the combo box ItemListener listener = new ItemListener() { public void itemStateChanged(ItemEvent e) { checkChanges(); } }; cbLanguage.addItemListener(listener); cbFontSize.addItemListener(listener); cbFontFamily.addItemListener(listener); }
From source file:org.tinymediamanager.ui.tvshows.settings.TvShowScraperSettingsPanel.java
/** * Instantiates a new movie scraper settings panel. *///from w ww .j a v a 2 s . c o m public TvShowScraperSettingsPanel() { // data init MediaScraper defaultMediaScraper = TvShowList.getInstance().getDefaultMediaScraper(); int selectedIndex = 0; int counter = 0; for (MediaScraper scraper : TvShowList.getInstance().getAvailableMediaScrapers()) { TvShowScraper tvShowScraper = new TvShowScraper(scraper); if (scraper.equals(defaultMediaScraper)) { tvShowScraper.defaultScraper = true; selectedIndex = counter; } scrapers.add(tvShowScraper); counter++; } List<String> enabledArtworkProviders = settings.getTvShowArtworkScrapers(); int artworkSelectedIndex = -1; int counterAW = 0; for (MediaScraper scraper : TvShowList.getInstance().getAvailableArtworkScrapers()) { ArtworkScraper artworkScraper = new ArtworkScraper(scraper); if (enabledArtworkProviders.contains(artworkScraper.getScraperId())) { artworkScraper.active = true; if (artworkSelectedIndex < 0) { artworkSelectedIndex = counterAW; } } artworkScrapers.add(artworkScraper); counterAW++; } // UI init setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelTvShowScrapers = new JPanel(); panelTvShowScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("scraper.metadata.defaults"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$ add(panelTvShowScrapers, "2, 2, fill, top"); panelTvShowScrapers.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, })); scrollPaneScraper = new JScrollPane(); panelTvShowScrapers.add(scrollPaneScraper, "1, 2, 3, 1, fill, fill"); tableScraper = new JTable(); tableScraper.setRowHeight(29); scrollPaneScraper.setViewportView(tableScraper); scrollPaneScraperDetails = new JScrollPane(); scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPaneScraperDetails.setBorder(null); panelTvShowScrapers.add(scrollPaneScraperDetails, "5, 2, fill, fill"); panelScraperDetails = new ScrollablePanel(); scrollPaneScraperDetails.setViewportView(panelScraperDetails); panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("200dlu:grow"), }, new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); // add a CSS rule to force body tags to use the default label font // instead of the value in javax.swing.text.html.default.csss Font font = UIManager.getFont("Label.font"); String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }"; tpScraperDescription = new JTextPane(); tpScraperDescription.setOpaque(false); tpScraperDescription.setEditorKit(new HTMLEditorKit()); ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule); panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top"); panelScraperOptions = new JPanel(); panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top"); JSeparator separator = new JSeparator(); panelTvShowScrapers.add(separator, "1, 4, 5, 1"); JLabel lblScraperLanguage = new JLabel(BUNDLE.getString("Settings.preferredLanguage")); //$NON-NLS-1$ panelTvShowScrapers.add(lblScraperLanguage, "1, 6, right, default"); cbScraperTmdbLanguage = new JComboBox(MediaLanguages.values()); panelTvShowScrapers.add(cbScraperTmdbLanguage, "3, 6"); JLabel lblCountry = new JLabel(BUNDLE.getString("Settings.certificationCountry")); //$NON-NLS-1$ panelTvShowScrapers.add(lblCountry, "1, 8, right, default"); cbCountry = new JComboBox(CountryCode.values()); panelTvShowScrapers.add(cbCountry, "3, 8, fill, default"); btnGroupThumbFilenaming = new ButtonGroup(); panelArtworkScrapers = new JPanel(); panelArtworkScrapers.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.images"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelArtworkScrapers, "2, 4, fill, fill"); panelArtworkScrapers.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("80dlu:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, })); scrollPaneArtworkScraper = new JScrollPane(); panelArtworkScrapers.add(scrollPaneArtworkScraper, "2, 2, fill, fill"); tableArtworkScraper = new JTable(); tableArtworkScraper.setRowHeight(29); scrollPaneArtworkScraper.setViewportView(tableArtworkScraper); scrollPaneArtworkScraperDetails = new JScrollPane(); scrollPaneArtworkScraperDetails.setBorder(null); panelArtworkScrapers.add(scrollPaneArtworkScraperDetails, "4, 2, fill, fill"); panelArtworkScraperDetails = new JPanel(); scrollPaneArtworkScraperDetails.setViewportView(panelArtworkScraperDetails); panelArtworkScraperDetails.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"), }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); tpArtworkScraperDescription = new JTextPane(); tpArtworkScraperDescription.setEditorKit(new HTMLEditorKit()); ((HTMLDocument) tpArtworkScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule); tpArtworkScraperDescription.setOpaque(false); panelArtworkScraperDetails.add(tpArtworkScraperDescription, "2, 2, fill, fill"); panelArtworkScraperOptions = new JPanel(); panelArtworkScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelArtworkScraperDetails.add(panelArtworkScraperOptions, "2, 4, fill, fill"); separator = new JSeparator(); panelArtworkScrapers.add(separator, "2, 4, 3, 1"); panelImages = new JPanel(); panelArtworkScrapers.add(panelImages, "2, 6, 3, 1, fill, fill"); panelImages.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { RowSpec.decode("23px"), })); lblNewLabel = new JLabel(BUNDLE.getString("image.thumb.naming")); panelImages.add(lblNewLabel, "1, 1, left, center"); rdbtnThumbWithPostfix = new JRadioButton("<dynamic>-thumb.ext"); panelImages.add(rdbtnThumbWithPostfix, "3, 1, fill, top"); btnGroupThumbFilenaming.add(rdbtnThumbWithPostfix); rdbtnThumbTbn = new JRadioButton("<dynamic>.tbn"); btnGroupThumbFilenaming.add(rdbtnThumbTbn); rdbtnThumbWoPostfix = new JRadioButton("<dynamic>.ext"); panelImages.add(rdbtnThumbWoPostfix, "5, 1, fill, top"); btnGroupThumbFilenaming.add(rdbtnThumbWoPostfix); panelImages.add(rdbtnThumbTbn, "7, 1"); panelScraperMetadataContainer = new JPanel(); panelScraperMetadataContainer.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("scraper.metadata.defaults"), TitledBorder.LEADING, TitledBorder.TOP, null, //$NON-NLS-1$ new Color(51, 51, 51))); add(panelScraperMetadataContainer, "2, 6, fill, top"); panelScraperMetadataContainer.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); panelScraperMetadata = new TvShowScraperMetadataPanel( Settings.getInstance().getTvShowScraperMetadataConfig()); panelScraperMetadataContainer.add(panelScraperMetadata, "1, 1, 2, 1, fill, default"); chckbxAutomaticallyScrapeImages = new JCheckBox(BUNDLE.getString("Settings.default.autoscrape")); //$NON-NLS-1$ panelScraperMetadataContainer.add(chckbxAutomaticallyScrapeImages, "2, 3"); initDataBindings(); { // adjust table columns // Checkbox and Logo shall have minimal width TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2); TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2); TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5); TableColumnResizer.setMaxWidthForColumn(tableArtworkScraper, 0, 2); TableColumnResizer.setMaxWidthForColumn(tableArtworkScraper, 1, 2); TableColumnResizer.adjustColumnPreferredWidths(tableArtworkScraper, 5); // implement listener to simulate button group tableScraper.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); TvShowScraper changedScraper = scrapers.get(row); // if flag inNFO was changed, change all other trailers flags if (changedScraper.getDefaultScraper()) { settings.setTvShowScraper(changedScraper.getScraperId()); for (TvShowScraper scraper : scrapers) { if (scraper != changedScraper) { scraper.setDefaultScraper(Boolean.FALSE); } } } } } }); // implement selection listener to load settings tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow()); if (index > -1) { panelScraperOptions.removeAll(); if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) { panelScraperOptions.add( new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider())); } panelScraperOptions.revalidate(); } } }); tableArtworkScraper.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); ArtworkScraper changedScraper = artworkScrapers.get(row); if (changedScraper.active) { settings.addTvShowArtworkScraper(changedScraper.getScraperId()); } else { settings.removeTvShowArtworkScraper(changedScraper.getScraperId()); } } } }); // implement selection listener to load settings tableArtworkScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int index = tableArtworkScraper.convertRowIndexToModel(tableArtworkScraper.getSelectedRow()); if (index > -1) { panelArtworkScraperOptions.removeAll(); if (artworkScrapers.get(index).getMediaProvider().getProviderInfo().getConfig() .hasConfig()) { panelArtworkScraperOptions.add(new MediaScraperConfigurationPanel( artworkScrapers.get(index).getMediaProvider())); } panelArtworkScraperOptions.revalidate(); } } }); // select default TV show scraper if (counter > 0) { tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex); } // select default artwork scraper if (counterAW > 0) { tableArtworkScraper.getSelectionModel().setSelectionInterval(artworkSelectedIndex, artworkSelectedIndex); } ItemListener itemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }; rdbtnThumbWoPostfix.addItemListener(itemListener); rdbtnThumbWithPostfix.addItemListener(itemListener); rdbtnThumbTbn.addItemListener(itemListener); switch (settings.getTvShowEpisodeThumbFilename()) { case FILENAME_THUMB_POSTFIX: rdbtnThumbWithPostfix.setSelected(true); break; case FILENAME_THUMB: rdbtnThumbWoPostfix.setSelected(true); break; case FILENAME_THUMB_TBN: rdbtnThumbTbn.setSelected(true); break; default: break; } } }
From source file:org.tinymediamanager.ui.tvshows.settings.TvShowSettingsPanel.java
/** * Instantiates a new tv show settings panel. *//* w w w .ja v a 2 s . co m*/ public TvShowSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow(3)"), })); JPanel panelGeneral = new JPanel(); panelGeneral.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.general"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelGeneral, "2, 2, fill, fill"); panelGeneral.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); lblImageCache = new JLabel(BUNDLE.getString("Settings.imagecacheimport")); panelGeneral.add(lblImageCache, "2, 2"); chckbxImageCache = new JCheckBox(""); panelGeneral.add(chckbxImageCache, "4, 2"); lblImageCacheHint = new JLabel(BUNDLE.getString("Settings.imagecacheimporthint")); //$NON-NLS-1$ panelGeneral.add(lblImageCacheHint, "6, 2, 3, 1"); TmmFontHelper.changeFont(lblImageCacheHint, 0.833); final JSeparator separator = new JSeparator(); panelGeneral.add(separator, "2, 4, 7, 1"); JLabel lblTraktTv = new JLabel(BUNDLE.getString("Settings.trakt"));//$NON-NLS-1$ panelGeneral.add(lblTraktTv, "2, 6"); chckbxTraktTv = new JCheckBox(""); panelGeneral.add(chckbxTraktTv, "4, 6"); btnClearTraktTvShows = new JButton(BUNDLE.getString("Settings.trakt.cleartvshows"));//$NON-NLS-1$ btnClearTraktTvShows.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int confirm = JOptionPane.showOptionDialog(null, BUNDLE.getString("Settings.trakt.cleartvshows.hint"), BUNDLE.getString("Settings.trakt.cleartvshows"), JOptionPane.YES_NO_OPTION, //$NON-NLS-1$ JOptionPane.QUESTION_MESSAGE, null, null, null); if (confirm == JOptionPane.YES_OPTION) { TmmTask task = new ClearTraktTvTask(false, true); TmmTaskManager.getInstance().addUnnamedTask(task); } } }); panelGeneral.add(btnClearTraktTvShows, "6, 6"); JPanel panelBadWords = new JPanel(); panelBadWords.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.tvshow.badwords"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelBadWords, "4, 2, fill, fill"); panelBadWords.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JTextPane txtpntBadWordsHint = new JTextPane(); txtpntBadWordsHint.setBackground(UIManager.getColor("Panel.background")); txtpntBadWordsHint.setText(BUNDLE.getString("Settings.tvshow.badwords.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(txtpntBadWordsHint, 0.833); panelBadWords.add(txtpntBadWordsHint, "2, 2, 3, 1, fill, default"); JScrollPane scpBadWords = new JScrollPane(); panelBadWords.add(scpBadWords, "2, 4, fill, fill"); listBadWords = new JList<>(); scpBadWords.setViewportView(listBadWords); JButton btnRemoveBadWord = new JButton(IconManager.LIST_REMOVE); btnRemoveBadWord.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemoveBadWord.setMargin(new Insets(2, 2, 2, 2)); btnRemoveBadWord.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listBadWords.getSelectedIndex(); if (row != -1) { String badWord = TvShowModuleManager.SETTINGS.getBadWords().get(row); TvShowModuleManager.SETTINGS.removeBadWord(badWord); } } }); panelBadWords.add(btnRemoveBadWord, "4, 4, default, bottom"); tfAddBadword = new JTextField(); tfAddBadword.setColumns(10); panelBadWords.add(tfAddBadword, "2, 6, fill, default"); JButton btnAddBadWord = new JButton(IconManager.LIST_ADD); btnAddBadWord.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAddBadWord.setMargin(new Insets(2, 2, 2, 2)); btnAddBadWord.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (StringUtils.isNotEmpty(tfAddBadword.getText())) { TvShowModuleManager.SETTINGS.addBadWord(tfAddBadword.getText()); tfAddBadword.setText(""); } } }); panelBadWords.add(btnAddBadWord, "4, 6"); { JPanel panelTvShowDataSources = new JPanel(); panelTvShowDataSources.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.tvshowdatasource"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelTvShowDataSources, "2, 4, 3, 1, fill, top"); panelTvShowDataSources.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("50dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow(2)"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("160px:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblDataSource = new JLabel(BUNDLE.getString("Settings.source")); //$NON-NLS-1$ panelTvShowDataSources.add(lblDataSource, "2, 2, 5, 1"); JLabel lblSkipFolders = new JLabel(BUNDLE.getString("Settings.ignore"));//$NON-NLS-1$ panelTvShowDataSources.add(lblSkipFolders, "12, 2, 3, 1"); JScrollPane scrollPaneDatasource = new JScrollPane(); panelTvShowDataSources.add(scrollPaneDatasource, "2, 4, 5, 1, fill, fill"); listDatasources = new JList<>(); scrollPaneDatasource.setViewportView(listDatasources); JPanel panelTvShowSourcesButtons = new JPanel(); panelTvShowDataSources.add(panelTvShowSourcesButtons, "8, 4, default, top"); panelTvShowSourcesButtons.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JButton btnAdd = new JButton(IconManager.LIST_ADD); btnAdd.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAdd.setMargin(new Insets(2, 2, 2, 2)); btnAdd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Path file = TmmUIHelper .selectDirectory(BUNDLE.getString("Settings.tvshowdatasource.folderchooser")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { settings.addTvShowDataSources(file.toAbsolutePath().toString()); } } }); panelTvShowSourcesButtons.add(btnAdd, "1, 1, fill, top"); JButton btnRemove = new JButton(IconManager.LIST_REMOVE); btnRemove.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemove.setMargin(new Insets(2, 2, 2, 2)); btnRemove.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listDatasources.getSelectedIndex(); if (row != -1) { // nothing selected String path = settings.getTvShowDataSource().get(row); String[] choices = { BUNDLE.getString("Button.continue"), //$NON-NLS-1$ BUNDLE.getString("Button.abort") }; int decision = JOptionPane.showOptionDialog(null, String.format(BUNDLE.getString("Settings.tvshowdatasource.remove.info"), path), BUNDLE.getString("Settings.datasource.remove"), JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, choices, BUNDLE.getString("Button.abort")); //$NON-NLS-1$ if (decision == 0) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); settings.removeTvShowDataSources(path); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } } }); panelTvShowSourcesButtons.add(btnRemove, "1, 3, fill, top"); JScrollPane scrollPane = new JScrollPane(); panelTvShowDataSources.add(scrollPane, "12, 4, fill, fill"); listExclude = new JList<>(); scrollPane.setViewportView(listExclude); JPanel panelSkipFolderButtons = new JPanel(); panelTvShowDataSources.add(panelSkipFolderButtons, "14, 4, fill, fill"); panelSkipFolderButtons.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JButton btnAddSkipFolder = new JButton(IconManager.LIST_ADD); btnAddSkipFolder.setToolTipText(BUNDLE.getString("Settings.addignore")); //$NON-NLS-1$ btnAddSkipFolder.setMargin(new Insets(2, 2, 2, 2)); btnAddSkipFolder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.ignore")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { settings.addTvShowSkipFolder(file.toAbsolutePath().toString()); } } }); panelSkipFolderButtons.add(btnAddSkipFolder, "1, 1"); JButton btnRemoveSkipFolder = new JButton(IconManager.LIST_REMOVE); btnRemoveSkipFolder.setToolTipText(BUNDLE.getString("Settings.removeignore")); //$NON-NLS-1$ btnRemoveSkipFolder.setMargin(new Insets(2, 2, 2, 2)); btnRemoveSkipFolder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int row = listExclude.getSelectedIndex(); if (row != -1) { // nothing selected String ingore = settings.getTvShowSkipFolders().get(row); settings.removeTvShowSkipFolder(ingore); } } }); panelSkipFolderButtons.add(btnRemoveSkipFolder, "1, 3"); JLabel lblDvdOrder = new JLabel(BUNDLE.getString("Settings.dvdorder")); //$NON-NLS-1$ panelTvShowDataSources.add(lblDvdOrder, "2, 6, right, default"); cbDvdOrder = new JCheckBox(""); panelTvShowDataSources.add(cbDvdOrder, "4, 6"); } initDataBindings(); if (!Globals.isDonator()) { chckbxTraktTv.setSelected(false); chckbxTraktTv.setEnabled(false); btnClearTraktTvShows.setEnabled(false); } }
From source file:org.tranche.gui.AnnotationPanel.java
public AnnotationPanel() { setSize(400, 400);// w ww.ja va 2s . c o m setLayout(new BorderLayout()); // add the menu bar { GenericMenuItem blankMenuItem = new GenericMenuItem("Blank"); blankMenuItem.setMnemonic('b'); blankMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Thread t = new Thread() { @Override public void run() { model.addRow("", ""); } }; t.setDaemon(true); t.start(); } }); addMenu.add(blankMenuItem); JSeparator separator = new JSeparator(); separator.setForeground(blankMenuItem.getForeground()); addMenu.add(separator); GenericMenuItem removeMenuItem = new GenericMenuItem("Remove"); removeMenuItem.setMnemonic('r'); removeMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Thread t = new Thread() { @Override public void run() { int[] rows = table.getSelectedRows(); for (int i = rows.length - 1; i >= 0; i--) { model.rows.remove(rows[i]); } model.fireTableDataChanged(); } }; t.setDaemon(true); t.start(); } }); selectionMenu.add(removeMenuItem); addMenu.setMnemonic('a'); menuBar.add(addMenu); selectionMenu.setMnemonic('s'); menuBar.add(selectionMenu); add(menuBar, BorderLayout.NORTH); } // set up the table model = new TagTableModel(); table = new GenericTable(model, ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); GenericScrollPane scrollPane = new GenericScrollPane(table); scrollPane.setBorder(Styles.BORDER_NONE); scrollPane.setBackground(table.getTableHeader().getBackground()); scrollPane.setVerticalScrollBar(new GenericScrollBar()); scrollPane.setHorizontalScrollBar(new GenericScrollBar()); add(scrollPane, BorderLayout.CENTER); }
From source file:org.webcat.plugintester.ui.MainFrameBuilder.java
/** * Creates and lays out the Swing components for the window. * * @param frame the JFrame instance that will contain the components *//*from ww w . j ava 2 s .c o m*/ private void constructFrame(JFrame frame) { GridBagConstraints gridBagConstraints; fileChooser = new JFileChooser(); bottomPanel = new JPanel(); runButton = new JButton(); mainPanel = new JPanel(); JLabel webCatHomeLabel = new JLabel(); webCatHomeField = new JTextField(); webCatHomeBrowseButton = new JButton(); JSeparator jSeparator0 = new JSeparator(); JLabel submissionLabel = new JLabel(); submissionField = new JTextField(); submissionBrowseButton = new JButton(); JSeparator jSeparator1 = new JSeparator(); JLabel pluginsLabel = new JLabel(); JPanel pluginsPanel = new JPanel(); JScrollPane pluginsScrollPane = new JScrollPane(); pluginsTable = new JTable(); pluginAddButton = new JButton(); pluginRemoveButton = new JButton(); JSeparator jSeparator2 = new JSeparator(); JTabbedPane tabPane = new JTabbedPane(); propertiesPanel = new JPanel(); JScrollPane propertiesScrollPane = new JScrollPane(); propertiesEditor = new JEditorPane(); documentationPanel = new JPanel(); JScrollPane documentationScrollPane = new JScrollPane(); documentationEditor = new JEditorPane(); // File chooser fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); // Bottom panel bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 4, 4)); // Run button runButton.setText("Run Plug-ins"); runButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { runButtonActionPerformed(evt); } }); bottomPanel.add(runButton); frame.getContentPane().add(bottomPanel, BorderLayout.PAGE_END); // Main panel mainPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); mainPanel.setLayout(new GridBagLayout()); // Web-CAT Home field gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = GridBagConstraints.RELATIVE; gridBagConstraints.anchor = GridBagConstraints.LINE_START; webCatHomeLabel.setText("Web-CAT Home:"); mainPanel.add(webCatHomeLabel, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; webCatHomeField.setTransferHandler(new WebCATHomeTransferHandler()); mainPanel.add(webCatHomeField, gridBagConstraints); // Web-CAT Home browse button webCatHomeBrowseButton.setText("Browse..."); webCatHomeBrowseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { webCatHomeBrowseButtonActionPerformed(evt); } }); mainPanel.add(webCatHomeBrowseButton, new GridBagConstraints()); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(jSeparator0, gridBagConstraints); // Submission field gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = GridBagConstraints.RELATIVE; gridBagConstraints.anchor = GridBagConstraints.LINE_START; submissionLabel.setText("Submission:"); mainPanel.add(submissionLabel, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1.0; submissionField.setTransferHandler(new SubmissionTransferHandler()); mainPanel.add(submissionField, gridBagConstraints); // Submission browse button submissionBrowseButton.setText("Browse..."); submissionBrowseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { submissionBrowseButtonActionPerformed(evt); } }); mainPanel.add(submissionBrowseButton, new GridBagConstraints()); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(jSeparator1, gridBagConstraints); // Plug-ins area pluginsLabel.setText("Plug-ins to run:"); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(pluginsLabel, gridBagConstraints); pluginsPanel.setPreferredSize(new Dimension(400, 80)); pluginsPanel.setLayout(new GridBagLayout()); pluginsModel = new PluginsTableModel(); pluginsTable.setModel(pluginsModel); pluginsTable.setColumnSelectionAllowed(true); pluginsTable.getTableHeader().setReorderingAllowed(false); pluginsScrollPane.setViewportView(pluginsTable); pluginsTable.getColumnModel().getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); pluginsTable.getColumnModel().getColumn(0).setResizable(false); pluginsScrollPane.setTransferHandler(new PluginsTransferHandler()); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; pluginsPanel.add(pluginsScrollPane, gridBagConstraints); pluginAddButton.setText("Add..."); pluginAddButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pluginAddButtonActionPerformed(evt); } }); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = GridBagConstraints.PAGE_START; pluginsPanel.add(pluginAddButton, gridBagConstraints); pluginRemoveButton.setText("Remove"); pluginRemoveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pluginRemoveButtonActionPerformed(evt); } }); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = GridBagConstraints.PAGE_START; pluginsPanel.add(pluginRemoveButton, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 0.25; mainPanel.add(pluginsPanel, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(jSeparator2, gridBagConstraints); tabPane.setPreferredSize(new Dimension(466, 150)); propertiesPanel.setLayout(new GridBagLayout()); propertiesEditor.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { propertiesTimer.restart(); } }); propertiesTimer = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent e) { updateGradingProperties(); } }); propertiesScrollPane.setViewportView(propertiesEditor); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; propertiesPanel.add(propertiesScrollPane, gridBagConstraints); tabPane.addTab("Properties", propertiesPanel); documentationPanel.setLayout(new GridBagLayout()); documentationEditor.setContentType("text/html"); documentationEditor.setEditable(false); documentationScrollPane.setViewportView(documentationEditor); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; documentationPanel.add(documentationScrollPane, gridBagConstraints); tabPane.addTab("Documentation", documentationPanel); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.gridheight = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weighty = 1.0; mainPanel.add(tabPane, gridBagConstraints); frame.getContentPane().add(mainPanel, BorderLayout.CENTER); frame.pack(); }
From source file:org.zaproxy.zap.extension.cmss.CMSSFrame.java
/** Create the frame. */ public CMSSFrame() { setTitle("Fingerprinting tools"); setResizable(false);/* ww w . j av a 2 s . com*/ setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setBounds(100, 100, 756, 372); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JLayeredPane layeredPane = new JLayeredPane(); contentPane.add(layeredPane, BorderLayout.CENTER); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.setBounds(0, 0, 725, 323); layeredPane.add(tabbedPane); JLayeredPane layeredPane_1 = new JLayeredPane(); tabbedPane.addTab("Fingerprint", null, layeredPane_1, null); JLabel label = new JLabel("App name:"); label.setBounds(35, 188, 76, 14); layeredPane_1.add(label); JLabel label_1 = new JLabel("Version:"); label_1.setBounds(35, 230, 76, 14); layeredPane_1.add(label_1); textField = new JTextField(); textField.setColumns(10); textField.setBounds(121, 188, 109, 29); layeredPane_1.add(textField); textField_1 = new JTextField(); textField_1.setColumns(10); textField_1.setBounds(121, 223, 109, 29); layeredPane_1.add(textField_1); JSeparator separator = new JSeparator(); separator.setBounds(35, 72, 665, 2); layeredPane_1.add(separator); JSeparator separator_1 = new JSeparator(); separator_1.setBounds(196, 11, 1, 201); layeredPane_1.add(separator_1); JSeparator separator_2 = new JSeparator(); separator_2.setOrientation(SwingConstants.VERTICAL); separator_2.setBounds(260, 81, 1, 201); layeredPane_1.add(separator_2); final JCheckBox chckbxGetVersion = new JCheckBox("Get version"); chckbxGetVersion.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (textField_1.isEnabled() && !chckbxGetVersion.isSelected()) textField_1.setEnabled(false); if (!textField_1.isEnabled() && chckbxGetVersion.isSelected()) textField_1.setEnabled(true); } }); chckbxGetVersion.setBounds(35, 81, 195, 23); layeredPane_1.add(chckbxGetVersion); final JCheckBox chckbxPassiveFingerprinting = new JCheckBox("Passive"); chckbxPassiveFingerprinting.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); chckbxPassiveFingerprinting.setBounds(35, 107, 195, 23); chckbxPassiveFingerprinting.setSelected(true); // layeredPane_1.add(chckbxPassiveFingerprinting); final JCheckBox chckbxAgressive = new JCheckBox("Agressive"); chckbxAgressive.setBounds(35, 133, 195, 23); layeredPane_1.add(chckbxAgressive); JLabel lblWhatToFingerprint = new JLabel("What to fingerprint ?"); lblWhatToFingerprint.setBounds(287, 81, 109, 14); layeredPane_1.add(lblWhatToFingerprint); JCheckBox chckbxCms = new JCheckBox("cms"); chckbxCms.setBounds(280, 102, 134, 23); layeredPane_1.add(chckbxCms); JCheckBox chckbxMessageboards = new JCheckBox("message-boards"); chckbxMessageboards.setBounds(280, 128, 134, 23); layeredPane_1.add(chckbxMessageboards); JCheckBox chckbxJavascriptframeworks = new JCheckBox("javascript-frameworks"); chckbxJavascriptframeworks.setBounds(281, 154, 133, 23); layeredPane_1.add(chckbxJavascriptframeworks); JCheckBox chckbxWebframeworks = new JCheckBox("web-frameworks"); chckbxWebframeworks.setBounds(281, 178, 133, 23); layeredPane_1.add(chckbxWebframeworks); JCheckBox chckbxWebservers = new JCheckBox("web-servers"); chckbxWebservers.setBounds(281, 204, 133, 23); layeredPane_1.add(chckbxWebservers); JSeparator separator_4 = new JSeparator(); separator_4.setOrientation(SwingConstants.VERTICAL); separator_4.setBounds(435, 81, 1, 201); layeredPane_1.add(separator_4); JCheckBox chckbxDatabases = new JCheckBox("databases"); chckbxDatabases.setBounds(281, 228, 133, 23); layeredPane_1.add(chckbxDatabases); JButton btnMore = new JButton("More"); btnMore.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { wtfpFrame = new WhatToFingerPrintFrame(); wtfpFrame.setLocationRelativeTo(null); wtfpFrame.setVisible(true); } }); btnMore.setBounds(291, 261, 123, 23); layeredPane_1.add(btnMore); JLabel lblFingerprintingTimeAnd = new JLabel("Fingerprinting time and occuracy settings:"); lblFingerprintingTimeAnd.setBounds(490, 81, 210, 14); layeredPane_1.add(lblFingerprintingTimeAnd); JButton btnFingerprint = new JButton("Fingerprint"); btnFingerprint.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!chckbxPassiveFingerprinting.isSelected() && !chckbxAgressive.isSelected()) chckbxPassiveFingerprinting.setSelected(true); if (chckbxPassiveFingerprinting.isSelected() && !chckbxAgressive.isSelected()) POrAOption = 1; else if (!chckbxPassiveFingerprinting.isSelected() && chckbxAgressive.isSelected()) POrAOption = 2; else if (chckbxPassiveFingerprinting.isSelected() && chckbxAgressive.isSelected()) POrAOption = 3; try { targetUrl = new URL(txtHttp.getText()); } catch (MalformedURLException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } System.out.println("POrAOption : " + POrAOption); // we concatenate the two ArrayLists ArrayList<String> wtfpList = getWhatToFingerprint(); for (String wtfp : wtfpFrame.getWhatToFingerprint()) { wtfpList.add(wtfp); } // we call FastFingerprinter.filterResults on the global whatToFingerPrint // List fpThread = new FingerPrintingThread(targetUrl, wtfpList, POrAOption); fpThread.start(); while (fpThread.isAlive()) { // waiting; } ArrayList<String> resultList = fpThread.getFingerPrintingResult(); for (String app : resultList) { textField.setText(textField.getText() + app + " , "); } if (chckbxGetVersion.isSelected()) { System.out.println("wiw"); ArrayList<String> versions = new ArrayList<String>(); if (resultList.contains("wordpress")) { textField_1.setText(textField_1.getText() + "wordpress :"); for (String version : FastFingerprinter.WordpressFastFingerprint(targetUrl)) { textField_1.setText(textField_1.getText() + version + " ; "); } } if (resultList.contains("joomla")) { textField_1.setText(textField_1.getText() + "joomla :"); for (String version : FastFingerprinter.JoomlaFastFingerprint(targetUrl)) { textField_1.setText(textField_1.getText() + version + " ; "); } } // blindelephant for (String app : resultList) { System.out.println("---->" + app); try { versions = WebAppGuesser.fingerPrintFile(app); textField_1.setText(textField_1.getText() + app + " : "); for (String version : versions) { textField_1.setText(textField_1.getText() + version + " ; "); } } catch (NoSuchAlgorithmException | IOException | DecoderException e1) { e1.printStackTrace(); } } } } }); btnFingerprint.setBounds(35, 154, 195, 23); layeredPane_1.add(btnFingerprint); JButton btnDetailedView = new JButton("Detailed view "); btnDetailedView.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); btnDetailedView.setBounds(35, 259, 195, 23); layeredPane_1.add(btnDetailedView); this.checkBoxesList.add(chckbxCms); this.checkBoxesList.add(chckbxJavascriptframeworks); this.checkBoxesList.add(chckbxWebframeworks); this.checkBoxesList.add(chckbxWebservers); this.checkBoxesList.add(chckbxDatabases); this.checkBoxesList.add(chckbxMessageboards); txtHttp = new JTextField(); txtHttp.setText("http://"); txtHttp.setBounds(128, 22, 568, 29); layeredPane_1.add(txtHttp); txtHttp.setColumns(10); JLabel lblTarget = new JLabel("Target : "); lblTarget.setBounds(51, 29, 46, 14); layeredPane_1.add(lblTarget); JLayeredPane layeredPane_2 = new JLayeredPane(); tabbedPane.addTab("Details", null, layeredPane_2, null); JTabbedPane tabbedPane_1 = new JTabbedPane(JTabbedPane.TOP); tabbedPane_1.setBounds(0, 0, 720, 223); layeredPane_2.add(tabbedPane_1); JLayeredPane layeredPane_4 = new JLayeredPane(); tabbedPane_1.addTab("Detailed result", null, layeredPane_4, null); JLayeredPane layeredPane_3 = new JLayeredPane(); tabbedPane_1.addTab("Passive fingerprint", null, layeredPane_3, null); JTabbedPane tabbedPane_2 = new JTabbedPane(JTabbedPane.TOP); tabbedPane_1.addTab("Agressive fingerprint", null, tabbedPane_2, null); }
From source file:pcgen.gui2.dialog.OptionsPathDialog.java
private void initComponents() { setResizable(false);//w w w .j av a 2 s.c o m setTitle("Directory for options.ini location"); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); getContentPane().setLayout(new GridBagLayout()); GridBagConstraints gridBagConstraints = new GridBagConstraints(); JLabel label = new JLabel("Select a directory to store PCGen options in:"); gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.insets = new Insets(4, 4, 0, 4); getContentPane().add(label, gridBagConstraints); gridBagConstraints.insets = new Insets(2, 0, 2, 0); getContentPane().add(new JSeparator(), gridBagConstraints); label = new JLabel( "If you have an existing options.ini file," + "then select the directory containing that file"); gridBagConstraints.insets = new Insets(4, 4, 4, 4); getContentPane().add(label, gridBagConstraints); ActionListener handler = new ActionHandler(); ButtonGroup group = new ButtonGroup(); gridBagConstraints.insets = new Insets(0, 4, 0, 4); addRadioButton("<html><b>PCGen Dir</b>: This is the directory that PCGen is installed into", SettingsFilesPath.pcgen.name(), group, handler, gridBagConstraints); // Remark: do mac user really need to be able to put the file either in a specific mac dir or home? if (SystemUtils.IS_OS_MAC_OSX) { addRadioButton("<html><b>Mac User Dir</b>", SettingsFilesPath.mac_user.name(), group, handler, gridBagConstraints); } else if (SystemUtils.IS_OS_UNIX) { // putting it the same way as mac. merging all and using a system config dir instead would be better IMHO. addRadioButton("<html><b>Freedesktop configuration sub-directory</b> Use for most Linux/BSD", SettingsFilesPath.FD_USER.name(), group, handler, gridBagConstraints); } addRadioButton("<html><b>Home Dir</b>: This is your home directory", SettingsFilesPath.user.name(), group, handler, gridBagConstraints); addRadioButton("Select a directory to use", "select", group, handler, gridBagConstraints); dirField.setText(ConfigurationSettings.getSettingsDirFromFilePath(selectedDir)); dirField.setEditable(false); gridBagConstraints.gridwidth = GridBagConstraints.RELATIVE; gridBagConstraints.weightx = 1; gridBagConstraints.insets = new Insets(0, 4, 0, 0); getContentPane().add(dirField, gridBagConstraints); dirButton.setText("..."); dirButton.setEnabled(false); dirButton.addActionListener(handler); dirButton.setActionCommand("custom"); dirButton.setMargin(new Insets(2, 2, 2, 2)); GridBagConstraints bagConstraints = new GridBagConstraints(); bagConstraints.gridwidth = GridBagConstraints.REMAINDER; bagConstraints.insets = new Insets(0, 0, 0, 4); getContentPane().add(dirButton, bagConstraints); JButton okButton = new JButton("OK"); okButton.setPreferredSize(new Dimension(75, 23)); okButton.setActionCommand("ok"); okButton.addActionListener(handler); bagConstraints.insets = new Insets(4, 0, 4, 0); getContentPane().add(okButton, bagConstraints); getRootPane().setDefaultButton(okButton); pack(); setLocationRelativeTo(null); }
From source file:phex.gui.dialogs.AboutDialog.java
/** * /*w w w . j a v a 2 s.com*/ */ private void prepareComponent() { CloseEventHandler closeEventHandler = new CloseEventHandler(); addWindowListener(closeEventHandler); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); JPanel contentPanel = new JPanel(); //JPanel contentPanel = new FormDebugPanel(); contentPane.add(contentPanel, BorderLayout.CENTER); CellConstraints cc = new CellConstraints(); FormLayout layout = new FormLayout("4dlu, fill:d:grow, 4dlu", // columns "p, p, 2dlu, p, 4dlu, p, 4dlu"); //row PanelBuilder contentPB = new PanelBuilder(layout, contentPanel); Object[] objArr = { PrivateNetworkConstants.PRIVATE_BUILD_ID + VersionUtils.getProgramVersion(), VersionUtils.getBuild() }; DialogBanner banner = new DialogBanner("Phex", Localizer.getFormatedString("AboutPhex_VersionInfo", objArr)); contentPB.add(banner, cc.xywh(1, 1, 3, 1)); contentPB.add(new JSeparator(), cc.xywh(1, 2, 3, 1)); JTabbedPane tabbedPane = new JTabbedPane(); contentPB.add(tabbedPane, cc.xy(2, 4)); JButton closeBtn = new JButton(Localizer.getString("Close")); closeBtn.addActionListener(closeEventHandler); contentPB.add(ButtonBarFactory.buildCloseBar(closeBtn), cc.xy(2, 6)); JPanel aboutPanel = new JPanel(); layout = new FormLayout("4dlu, fill:d:grow, 4dlu", // columns "4dlu, p, 4dlu"); //row PanelBuilder aboutPB = new PanelBuilder(layout, aboutPanel); tabbedPane.addTab(Localizer.getString("AboutPhex_About"), aboutPanel); Object[] objArr2 = { Res.getStr("Program.Url") }; HTMLMultiLinePanel aboutHtml = new HTMLMultiLinePanel( Localizer.getFormatedString("AboutPhex_AboutText", objArr2)); aboutPB.add(aboutHtml, cc.xy(2, 2)); JPanel envPanel = new JPanel(); layout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "2dlu, p, 2dlu, p, 2dlu"); //row PanelBuilder envPB = new PanelBuilder(layout, envPanel); tabbedPane.addTab(Localizer.getString("AboutPhex_Environment"), envPanel); environmentInfo = new JTextArea(12, 55); environmentInfo.setEditable(false); envPB.add(new JScrollPane(environmentInfo), cc.xy(2, 2)); StringBuffer envTextBuffer = new StringBuffer(); Properties pros = System.getProperties(); ArrayList<String> list = new ArrayList(pros.keySet()); Collections.sort(list); Iterator<String> iterator = list.iterator(); while (iterator.hasNext()) { String key = iterator.next(); String value = (String) pros.get(key); envTextBuffer.append(key).append(" = ").append(value).append(SystemUtils.LINE_SEPARATOR); } environmentInfo.setText(envTextBuffer.toString()); environmentInfo.setCaretPosition(0); JButton copyBtn = new JButton(Localizer.getString("Copy")); copyBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Toolkit.getDefaultToolkit().getSystemClipboard() .setContents(new StringSelection(environmentInfo.getText()), null); } }); envPB.add(ButtonBarFactory.buildLeftAlignedBar(copyBtn), cc.xy(2, 4)); pack(); setLocationRelativeTo(getParent()); }