List of usage examples for javax.swing.event DocumentListener DocumentListener
DocumentListener
From source file:org.tinymediamanager.ui.panels.MediaScraperConfigurationPanel.java
private JPanel createConfigPanel() { JPanel panel = new JPanel(); GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 0 }; gridBagLayout.rowHeights = new int[] { 0 }; gridBagLayout.columnWeights = new double[] { Double.MIN_VALUE }; gridBagLayout.rowWeights = new double[] { Double.MIN_VALUE }; panel.setLayout(gridBagLayout);/* ww w .ja v a 2s . c om*/ GridBagConstraints constraints = new GridBagConstraints(); constraints.gridy = 0; // build up the panel for being displayed in the popup MediaProviderConfig config = mediaProvider.getProviderInfo().getConfig(); for (Entry<String, MediaProviderConfigObject> entry : config.getConfigObjects().entrySet()) { if (!entry.getValue().isVisible()) { continue; } constraints.anchor = GridBagConstraints.LINE_START; constraints.ipadx = 20; // label JLabel label = new JLabel(entry.getValue().getKeyDescription()); constraints.gridx = 0; panel.add(label, constraints); JComponent comp; switch (entry.getValue().getType()) { case BOOL: // display as checkbox JCheckBox checkbox = new JCheckBox(); checkbox.setSelected(entry.getValue().getValueAsBool()); checkbox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dirty = true; } }); comp = checkbox; break; case SELECT: case SELECT_INDEX: // display as combobox JComboBox<String> combobox = new JComboBox<>( entry.getValue().getPossibleValues().toArray(new String[0])); combobox.setSelectedItem(entry.getValue().getValueAsString()); combobox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dirty = true; } }); comp = combobox; break; default: // display as text JTextField tf; if (entry.getValue().isEncrypt()) { tf = new JPasswordField(config.getValue(entry.getKey())); } else { tf = new JTextField(config.getValue(entry.getKey())); } tf.setPreferredSize(new Dimension(100, 24)); tf.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { dirty = true; } @Override public void insertUpdate(DocumentEvent e) { dirty = true; } @Override public void changedUpdate(DocumentEvent e) { dirty = true; } }); comp = tf; break; } comp.putClientProperty(entry.getKey(), entry.getKey()); constraints.ipadx = 0; constraints.gridx = 1; panel.add(comp, constraints); // add a hint if a long text has been found try { String desc = BUNDLE.getString( "scraper." + mediaProvider.getProviderInfo().getId() + "." + entry.getKey() + ".desc"); //$NON-NLS-1$ if (StringUtils.isNotBlank(desc)) { JLabel lblHint = new JLabel(IconManager.HINT); lblHint.setToolTipText(desc); constraints.gridx = 2; panel.add(lblHint, constraints); } } catch (Exception ignored) { } constraints.gridy++; } return panel; }
From source file:org.tinymediamanager.ui.tvshows.settings.TvShowRenamerSettingsPanel.java
public TvShowRenamerSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { 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, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, })); exampleEventList = GlazedLists.threadSafeList(new ObservableElementList<>( new BasicEventList<TvShowRenamerExample>(), GlazedLists.beanConnector(TvShowRenamerExample.class))); DefaultEventTableModel<TvShowRenamerExample> exampleTableModel = new DefaultEventTableModel<>( GlazedListsSwing.swingThreadProxyList(exampleEventList), new TvShowRenamerExampleTableFormat()); // the panel renamer ActionListener renamerActionListener = new ActionListener() { @Override/* w ww. j ava 2s . c om*/ public void actionPerformed(ActionEvent arg0) { checkChanges(); createRenamerExample(); } }; DocumentListener documentListener = new DocumentListener() { @Override public void removeUpdate(DocumentEvent arg0) { createRenamerExample(); } @Override public void insertUpdate(DocumentEvent arg0) { createRenamerExample(); } @Override public void changedUpdate(DocumentEvent arg0) { createRenamerExample(); } }; JPanel panelRenamer = new JPanel(); panelRenamer.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.tvshow.renamer.title"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelRenamer, "2, 2, fill, fill"); panelRenamer.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), 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.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); { final JLabel lblDefault = new JLabel(BUNDLE.getString("Settings.default")); //$NON-NLS-1$ TmmFontHelper.changeFont(lblDefault, 0.833); panelRenamer.add(lblDefault, "6, 2"); } lblTvShowFolder = new JLabel(BUNDLE.getString("Settings.tvshowfoldername")); //$NON-NLS-1$ panelRenamer.add(lblTvShowFolder, "2, 3, right, default"); tfTvShowFolder = new JTextField(); panelRenamer.add(tfTvShowFolder, "4, 3, fill, default"); tfTvShowFolder.getDocument().addDocumentListener(documentListener); { final JLabel lblDefaultFolderName = new JLabel("$N ($Y)"); //$NON-NLS-1$ TmmFontHelper.changeFont(lblDefaultFolderName, 0.833); panelRenamer.add(lblDefaultFolderName, "6, 3"); } lblSeasonFolderName = new JLabel(BUNDLE.getString("Settings.tvshowseasonfoldername")); //$NON-NLS-1$ panelRenamer.add(lblSeasonFolderName, "2, 5, right, default"); tfSeasonFoldername = new JTextField(); panelRenamer.add(tfSeasonFoldername, "4, 5, fill, default"); tfSeasonFoldername.getDocument().addDocumentListener(documentListener); { final JLabel lblDefaultSeasonFoldername = new JLabel("Season $1"); //$NON-NLS-1$ TmmFontHelper.changeFont(lblDefaultSeasonFoldername, 0.833); panelRenamer.add(lblDefaultSeasonFoldername, "6, 5"); } lblEpisodeFileName = new JLabel(BUNDLE.getString("Settings.tvshowfilename"));//$NON-NLS-1$ panelRenamer.add(lblEpisodeFileName, "2, 7, right, default"); tfEpisodeFilename = new JTextField(); panelRenamer.add(tfEpisodeFilename, "4, 7, fill, default"); tfEpisodeFilename.getDocument().addDocumentListener(documentListener); chckbxAsciiReplacement = new JCheckBox(BUNDLE.getString("Settings.renamer.asciireplacement")); //$NON-NLS-1$ chckbxAsciiReplacement.addActionListener(renamerActionListener); chckbxSpaceReplacement = new JHintCheckBox(BUNDLE.getString("Settings.movie.renamer.spacesubstitution")); //$NON-NLS-1$ chckbxSpaceReplacement.setHintIcon(IconManager.HINT); chckbxSpaceReplacement.setToolTipText(BUNDLE.getString("Settings.tvshowspacereplacement.hint")); //$NON-NLS-1$ chckbxSpaceReplacement.addActionListener(renamerActionListener); { final JLabel lblDefaultEpisodeFilename = new JLabel("$N - S$2E$E - $T"); //$NON-NLS-1$ TmmFontHelper.changeFont(lblDefaultEpisodeFilename, 0.833); panelRenamer.add(lblDefaultEpisodeFilename, "6, 7"); } panelRenamer.add(chckbxSpaceReplacement, "2, 11, right, default"); cbSpaceReplacement = new JComboBox(spaceReplacement.toArray()); panelRenamer.add(cbSpaceReplacement, "4, 11, fill, default"); cbSpaceReplacement.addActionListener(renamerActionListener); panelRenamer.add(chckbxAsciiReplacement, "2, 13, 9, 1"); txtpntAsciiHint = new JTextPane(); txtpntAsciiHint.setText(BUNDLE.getString("Settings.renamer.asciireplacement.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(txtpntAsciiHint, 0.833); txtpntAsciiHint.setBackground(UIManager.getColor("Panel.background")); panelRenamer.add(txtpntAsciiHint, "2, 15, 7, 1, fill, fill"); JLabel lblLanguageStyle = new JLabel(BUNDLE.getString("Settings.renamer.language")); //$NON-NLS-1$ panelRenamer.add(lblLanguageStyle, "2, 17, right, default"); cbLanguageStyle = new JComboBox(LanguageStyle.values()); panelRenamer.add(cbLanguageStyle, "4, 17, 3, 1, fill, default"); panelExample = new JPanel(); panelExample.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.example"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelExample, "2, 4, fill, fill"); panelExample.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("50dlu:grow"), FormFactory.RELATED_GAP_ROWSPEC, })); JLabel lblExampleTvShowT = new JLabel(BUNDLE.getString("metatag.tvshow")); panelExample.add(lblExampleTvShowT, "2, 2, right, default"); cbTvShowForPreview = new JComboBox(); cbTvShowForPreview.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { buildAndInstallEpisodeArray(); createRenamerExample(); } }); panelExample.add(cbTvShowForPreview, "4, 2"); JLabel lblExampleEpisodeT = new JLabel(BUNDLE.getString("metatag.episode")); panelExample.add(lblExampleEpisodeT, "2, 4, right, default"); cbEpisodeForPreview = new JComboBox(); cbEpisodeForPreview.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { createRenamerExample(); } }); panelExample.add(cbEpisodeForPreview, "4, 4, fill, default"); lblExample = new JLabel(""); TmmFontHelper.changeFont(lblExample, Font.BOLD); panelExample.add(lblExample, "2, 6, 3, 1"); tableExamples = new ZebraJTable(exampleTableModel); scrollPane = ZebraJTable.createStripedJScrollPane(tableExamples); scrollPane.setViewportView(tableExamples); panelExample.add(scrollPane, "2, 8, 3, 1, fill, fill"); initDataBindings(); String spaceReplacement = settings.getRenamerSpaceReplacement(); int index = this.spaceReplacement.indexOf(spaceReplacement); if (index >= 0) { cbSpaceReplacement.setSelectedIndex(index); } // examples exampleEventList.add(new TvShowRenamerExample("$T")); exampleEventList.add(new TvShowRenamerExample("$1")); exampleEventList.add(new TvShowRenamerExample("$2")); exampleEventList.add(new TvShowRenamerExample("$3")); exampleEventList.add(new TvShowRenamerExample("$4")); exampleEventList.add(new TvShowRenamerExample("$E")); exampleEventList.add(new TvShowRenamerExample("$D")); exampleEventList.add(new TvShowRenamerExample("$Y")); exampleEventList.add(new TvShowRenamerExample("$N")); exampleEventList.add(new TvShowRenamerExample("$M")); exampleEventList.add(new TvShowRenamerExample("$R")); exampleEventList.add(new TvShowRenamerExample("$A")); exampleEventList.add(new TvShowRenamerExample("$V")); exampleEventList.add(new TvShowRenamerExample("$F")); exampleEventList.add(new TvShowRenamerExample("$S")); }
From source file:org.tinymediamanager.ui.tvshows.TvShowExtendedSearchPanel.java
public TvShowExtendedSearchPanel(TvShowTreeModel model, JTree tree) { super();//from w ww . j ava2 s.c o m setOpaque(false); shadowAlpha = 100; arcs = new Dimension(10, 10); this.tvShowTreeModel = model; this.tree = tree; // 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.UNRELATED_GAP_ROWSPEC, })); JLabel lblFilterBy = new JLabel(BUNDLE.getString("movieextendedsearch.filterby")); //$NON-NLS-1$ setComponentFont(lblFilterBy); add(lblFilterBy, "2, 2, 3, 1"); cbFilterNewEpisodes = new JCheckBox(""); cbFilterNewEpisodes.setAction(actionFilter); add(cbFilterNewEpisodes, "2, 4"); JLabel lblNewEpisodes = new JLabel(BUNDLE.getString("movieextendedsearch.newepisodes")); //$NON-NLS-1$ setComponentFont(lblNewEpisodes); add(lblNewEpisodes, "4, 4, right, default"); cbFilterWatched = new JCheckBox(""); cbFilterWatched.setAction(actionFilter); cbFilterWatched.setUI(CHECKBOX_UI); // $hide$ add(cbFilterWatched, "2, 5"); JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$ setComponentFont(lblWatched); add(lblWatched, "4, 5, right, default"); cbWatched = new SmallComboBox(WatchedFlag.values()); setComponentFont(cbWatched); cbWatched.setAction(actionFilter); add(cbWatched, "6, 5, fill, default"); cbFilterGenres = new JCheckBox(""); cbFilterGenres.setAction(actionFilter); cbFilterGenres.setUI(CHECKBOX_UI); // $hide$ add(cbFilterGenres, "2, 6"); JLabel lblGenres = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$ setComponentFont(lblGenres); add(lblGenres, "4, 6, right, default"); cbGenres = new SmallComboBox(MediaGenres.values()); setComponentFont(cbGenres); cbGenres.setAction(actionFilter); add(cbGenres, "6, 6, fill, default"); cbFilterCast = new JCheckBox(""); cbFilterCast.setAction(actionFilter); cbFilterCast.setUI(CHECKBOX_UI); // $hide$ add(cbFilterCast, "2, 7"); JLabel lblCastMember = new JLabel(BUNDLE.getString("movieextendedsearch.cast")); //$NON-NLS-1$ setComponentFont(lblCastMember); add(lblCastMember, "4, 7, right, default"); tfCastMember = new JTextField(); setComponentFont(tfCastMember); tfCastMember.setBorder(new SmallTextFieldBorder()); add(tfCastMember, "6, 7, fill, default"); tfCastMember.setColumns(10); tfCastMember.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { actionFilter.actionPerformed(null); } @Override public void insertUpdate(DocumentEvent e) { actionFilter.actionPerformed(null); } @Override public void removeUpdate(DocumentEvent e) { actionFilter.actionPerformed(null); } }); cbFilterTag = new JCheckBox(""); cbFilterTag.setAction(actionFilter); cbFilterTag.setUI(CHECKBOX_UI); // $hide$ add(cbFilterTag, "2, 8"); JLabel lblTag = new JLabel(BUNDLE.getString("movieextendedsearch.tag")); //$NON-NLS-1$ setComponentFont(lblTag); add(lblTag, "4, 8, 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, 8, fill, default"); cbFilterVideoFormat = new JCheckBox(""); cbFilterVideoFormat.setUI(CHECKBOX_UI); // $hide$ cbFilterVideoFormat.setAction(actionFilter); add(cbFilterVideoFormat, "2, 9"); JLabel lblVideoFormat = new JLabel(BUNDLE.getString("metatag.resolution")); //$NON-NLS-1$ setComponentFont(lblVideoFormat); add(lblVideoFormat, "4, 9, right, default"); cbVideoFormat = new SmallComboBox(getVideoFormats()); setComponentFont(cbVideoFormat); cbVideoFormat.setAction(actionFilter); add(cbVideoFormat, "6, 9, fill, default"); cbFilterVideoCodec = new JCheckBox(""); cbFilterVideoCodec.setAction(actionFilter); cbFilterVideoCodec.setUI(CHECKBOX_UI); // $hide$ add(cbFilterVideoCodec, "2, 10"); JLabel lblVideoCodec = new JLabel(BUNDLE.getString("metatag.videocodec")); //$NON-NLS-1$ setComponentFont(lblVideoCodec); add(lblVideoCodec, "4, 10, right, default"); cbVideoCodec = new SmallComboBox(); setComponentFont(cbVideoCodec); cbVideoCodec.setAction(actionFilter); add(cbVideoCodec, "6, 10, fill, default"); cbFilterAudioCodec = new JCheckBox(""); cbFilterAudioCodec.setAction(actionFilter); cbFilterAudioCodec.setUI(CHECKBOX_UI); // $hide$ add(cbFilterAudioCodec, "2, 11"); JLabel lblAudioCodec = new JLabel(BUNDLE.getString("metatag.audiocodec")); //$NON-NLS-1$ setComponentFont(lblAudioCodec); add(lblAudioCodec, "4, 11, right, default"); cbAudioCodec = new SmallComboBox(); setComponentFont(cbAudioCodec); cbAudioCodec.setAction(actionFilter); add(cbAudioCodec, "6, 11, fill, default"); cbFilterDatasource = new JCheckBox(""); cbFilterDatasource.setAction(actionFilter); cbFilterDatasource.setUI(CHECKBOX_UI); // $hide$ add(cbFilterDatasource, "2, 12"); JLabel lblDatasource = new JLabel(BUNDLE.getString("metatag.datasource")); //$NON-NLS-1$ setComponentFont(lblDatasource); add(lblDatasource, "4, 12, 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, 12, fill, default"); cbFilterMediaSource = new JCheckBox(""); cbFilterMediaSource.setAction(actionFilter); cbFilterMediaSource.setUI(CHECKBOX_UI); // $hide$ add(cbFilterMediaSource, "2, 13"); lblMediaSource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$ setComponentFont(lblMediaSource); add(lblMediaSource, "4, 13, right, default"); cbMediaSource = new SmallComboBox(MediaSource.values()); setComponentFont(cbMediaSource); cbMediaSource.setAction(actionFilter); add(cbMediaSource, "6, 13, fill, default"); cbFilterMissingMetadata = new JCheckBox(""); cbFilterMissingMetadata.setAction(actionFilter); cbFilterMissingMetadata.setUI(CHECKBOX_UI); // $hide$ add(cbFilterMissingMetadata, "2, 14"); JLabel lblMissingMetadata = new JLabel(BUNDLE.getString("movieextendedsearch.missingmetadata")); //$NON-NLS-1$ setComponentFont(lblMissingMetadata); add(lblMissingMetadata, "4, 14, right, default"); cbFilterMissingArtwork = new JCheckBox(""); cbFilterMissingArtwork.setAction(actionFilter); cbFilterMissingArtwork.setUI(CHECKBOX_UI); // $hide$ add(cbFilterMissingArtwork, "2, 15"); JLabel lblMissingArtwork = new JLabel(BUNDLE.getString("movieextendedsearch.missingartwork")); //$NON-NLS-1$ setComponentFont(lblMissingArtwork); add(lblMissingArtwork, "4, 15, right, default"); cbFilterMissingSubtitles = new JCheckBox(""); cbFilterMissingSubtitles.setAction(actionFilter); cbFilterMissingSubtitles.setUI(CHECKBOX_UI); // $hide$ add(cbFilterMissingSubtitles, "2, 16"); JLabel lblMissingSubtitles = new JLabel(BUNDLE.getString("movieextendedsearch.missingsubtitles")); //$NON-NLS-1$ setComponentFont(lblMissingSubtitles); add(lblMissingSubtitles, "4, 16, right, default"); cbFilterNewEpisodes.setUI(CHECKBOX_UI); // $hide$ PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getSource() instanceof TvShowSettings && "tvShowDataSource".equals(evt.getPropertyName())) { buildAndInstallDatasourceArray(); } if (evt.getSource() instanceof TvShowList && "tag".equals(evt.getPropertyName())) { buildAndInstallTagsArray(); } if (evt.getSource() instanceof TvShowList && ("audioCodec".equals(evt.getPropertyName()) || "videoCodec".equals(evt.getPropertyName()))) { buildAndInstallCodecArray(); } } }; tvShowList.addPropertyChangeListener(propertyChangeListener); TvShowModuleManager.SETTINGS.addPropertyChangeListener(propertyChangeListener); buildAndInstallDatasourceArray(); buildAndInstallTagsArray(); buildAndInstallCodecArray(); }
From source file:org.tinymediamanager.ui.tvshows.TvShowPanel.java
/** * Instantiates a new tv show panel./*w w w . ja va2 s . c o m*/ */ public TvShowPanel() { super(); treeModel = new TvShowTreeModel(tvShowList.getTvShows()); tvShowSeasonSelectionModel = new TvShowSeasonSelectionModel(); tvShowEpisodeSelectionModel = new TvShowEpisodeSelectionModel(); // build menu menu = new JMenu(BUNDLE.getString("tmm.tvshows")); //$NON-NLS-1$ JFrame mainFrame = MainWindow.getFrame(); JMenuBar menuBar = mainFrame.getJMenuBar(); menuBar.add(menu); setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("850px:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); JSplitPane splitPane = new JSplitPane(); splitPane.setContinuousLayout(true); add(splitPane, "2, 2, fill, fill"); JPanel panelTvShowTree = new JPanel(); splitPane.setLeftComponent(panelTvShowTree); panelTvShowTree.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.UNRELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("3px:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); textField = EnhancedTextField.createSearchTextField(); panelTvShowTree.add(textField, "4, 1, right, bottom"); textField.setColumns(12); textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(final DocumentEvent e) { applyFilter(); } @Override public void removeUpdate(final DocumentEvent e) { applyFilter(); } @Override public void changedUpdate(final DocumentEvent e) { applyFilter(); } public void applyFilter() { TvShowTreeModel filteredModel = (TvShowTreeModel) tree.getModel(); if (StringUtils.isNotBlank(textField.getText())) { filteredModel.setFilter(SearchOptions.TEXT, textField.getText()); } else { filteredModel.removeFilter(SearchOptions.TEXT); } filteredModel.filter(tree); } }); final JToggleButton btnFilter = new JToggleButton(IconManager.FILTER); btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$ panelTvShowTree.add(btnFilter, "6, 1, default, bottom"); JScrollPane scrollPane = new JScrollPane(); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); panelTvShowTree.add(scrollPane, "2, 3, 5, 1, fill, fill"); JToolBar toolBar = new JToolBar(); toolBar.setRollover(true); toolBar.setFloatable(false); toolBar.setOpaque(false); panelTvShowTree.add(toolBar, "2, 1"); // toolBar.add(actionUpdateDatasources); final JSplitButton buttonUpdateDatasource = new JSplitButton(IconManager.REFRESH); // temp fix for size of the button buttonUpdateDatasource.setText(" "); buttonUpdateDatasource.setHorizontalAlignment(JButton.LEFT); // buttonScrape.setMargin(new Insets(2, 2, 2, 24)); buttonUpdateDatasource.setSplitWidth(18); buttonUpdateDatasource.setToolTipText(BUNDLE.getString("update.datasource")); //$NON-NLS-1$ buttonUpdateDatasource.addSplitButtonActionListener(new SplitButtonActionListener() { public void buttonClicked(ActionEvent e) { actionUpdateDatasources.actionPerformed(e); } public void splitButtonClicked(ActionEvent e) { // build the popupmenu on the fly buttonUpdateDatasource.getPopupMenu().removeAll(); buttonUpdateDatasource.getPopupMenu().add(new JMenuItem(actionUpdateDatasources2)); buttonUpdateDatasource.getPopupMenu().addSeparator(); for (String ds : TvShowModuleManager.SETTINGS.getTvShowDataSource()) { buttonUpdateDatasource.getPopupMenu() .add(new JMenuItem(new TvShowUpdateSingleDatasourceAction(ds))); } buttonUpdateDatasource.getPopupMenu().addSeparator(); buttonUpdateDatasource.getPopupMenu().add(new JMenuItem(actionUpdateTvShow)); buttonUpdateDatasource.getPopupMenu().pack(); } }); JPopupMenu popup = new JPopupMenu("popup"); buttonUpdateDatasource.setPopupMenu(popup); toolBar.add(buttonUpdateDatasource); JSplitButton buttonScrape = new JSplitButton(IconManager.SEARCH); // temp fix for size of the button buttonScrape.setText(" "); buttonScrape.setHorizontalAlignment(JButton.LEFT); buttonScrape.setSplitWidth(18); buttonScrape.setToolTipText(BUNDLE.getString("tvshow.scrape.selected")); //$NON-NLS-1$ // register for listener buttonScrape.addSplitButtonActionListener(new SplitButtonActionListener() { @Override public void buttonClicked(ActionEvent e) { actionScrape.actionPerformed(e); } @Override public void splitButtonClicked(ActionEvent e) { } }); popup = new JPopupMenu("popup"); JMenuItem item = new JMenuItem(actionScrape2); popup.add(item); // item = new JMenuItem(actionScrapeUnscraped); // popup.add(item); item = new JMenuItem(actionScrapeSelected); popup.add(item); item = new JMenuItem(actionScrapeNewItems); popup.add(item); buttonScrape.setPopupMenu(popup); toolBar.add(buttonScrape); toolBar.add(actionEdit); JButton btnMediaInformation = new JButton(); btnMediaInformation.setAction(actionMediaInformation); toolBar.add(btnMediaInformation); // install drawing of full with tree = new ZebraJTree(treeModel) { private static final long serialVersionUID = 2422163883324014637L; @Override public void paintComponent(Graphics g) { width = this.getWidth(); super.paintComponent(g); } }; tvShowSelectionModel = new TvShowSelectionModel(tree); TreeUI ui = new TreeUI() { @Override protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) { bounds.width = width - bounds.x; super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf); } }; tree.setUI(ui); tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.setCellRenderer(new TvShowTreeCellRenderer()); tree.setRowHeight(0); scrollPane.setViewportView(tree); JPanel panelHeader = new JPanel() { private static final long serialVersionUID = -6914183798172482157L; @Override public void paintComponent(Graphics g) { super.paintComponent(g); JTattooUtilities.fillHorGradient(g, AbstractLookAndFeel.getTheme().getColHeaderColors(), 0, 0, getWidth(), getHeight()); } }; scrollPane.setColumnHeaderView(panelHeader); panelHeader.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("center:20px"), ColumnSpec.decode("center:20px"), ColumnSpec.decode("center:20px") }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, })); JLabel lblTvShowsColumn = new JLabel(BUNDLE.getString("metatag.tvshow")); //$NON-NLS-1$ lblTvShowsColumn.setHorizontalAlignment(JLabel.CENTER); panelHeader.add(lblTvShowsColumn, "2, 1"); JLabel lblNfoColumn = new JLabel(""); lblNfoColumn.setHorizontalAlignment(JLabel.CENTER); lblNfoColumn.setIcon(IconManager.INFO); lblNfoColumn.setToolTipText(BUNDLE.getString("metatag.nfo"));//$NON-NLS-1$ panelHeader.add(lblNfoColumn, "4, 1"); JLabel lblImageColumn = new JLabel(""); lblImageColumn.setHorizontalAlignment(JLabel.CENTER); lblImageColumn.setIcon(IconManager.IMAGE); lblImageColumn.setToolTipText(BUNDLE.getString("metatag.images"));//$NON-NLS-1$ panelHeader.add(lblImageColumn, "5, 1"); JLabel lblSubtitleColumn = new JLabel(""); lblSubtitleColumn.setHorizontalAlignment(JLabel.CENTER); lblSubtitleColumn.setIcon(IconManager.SUBTITLE); lblSubtitleColumn.setToolTipText(BUNDLE.getString("metatag.subtitles"));//$NON-NLS-1$ panelHeader.add(lblSubtitleColumn, "6, 1"); JPanel panel = new JPanel(); panelTvShowTree.add(panel, "2, 5, 3, 1, fill, fill"); panel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JLabel lblTvShowsT = new JLabel(BUNDLE.getString("metatag.tvshows") + ":"); //$NON-NLS-1$ panel.add(lblTvShowsT, "1, 2, fill, fill"); lblTvShows = new JLabel(""); panel.add(lblTvShows, "3, 2"); JLabel labelSlash = new JLabel("/"); panel.add(labelSlash, "5, 2"); JLabel lblEpisodesT = new JLabel(BUNDLE.getString("metatag.episodes") + ":"); //$NON-NLS-1$ panel.add(lblEpisodesT, "7, 2"); lblEpisodes = new JLabel(""); panel.add(lblEpisodes, "9, 2"); JLayeredPane layeredPaneRight = new JLayeredPane(); layeredPaneRight.setLayout( new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default"), ColumnSpec.decode("default:grow") }, new RowSpec[] { RowSpec.decode("default"), RowSpec.decode("default:grow") })); panelRight = new JPanel(); layeredPaneRight.add(panelRight, "1, 1, 2, 2, fill, fill"); layeredPaneRight.setLayer(panelRight, 0); // glass pane final TvShowExtendedSearchPanel panelExtendedSearch = new TvShowExtendedSearchPanel(treeModel, tree); panelExtendedSearch.setVisible(false); // panelMovieList.add(panelExtendedSearch, "2, 5, 2, 1, fill, fill"); btnFilter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (panelExtendedSearch.isVisible() == true) { panelExtendedSearch.setVisible(false); } else { panelExtendedSearch.setVisible(true); } } }); // add a propertychangelistener which reacts on setting a filter tree.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("filterChanged".equals(evt.getPropertyName())) { if (Boolean.TRUE.equals(evt.getNewValue())) { btnFilter.setIcon(IconManager.FILTER_ACTIVE); btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options.active")); //$NON-NLS-1$ } else { btnFilter.setIcon(IconManager.FILTER); btnFilter.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$ } } } }); layeredPaneRight.add(panelExtendedSearch, "1, 1, fill, fill"); layeredPaneRight.setLayer(panelExtendedSearch, 1); splitPane.setRightComponent(layeredPaneRight); panelRight.setLayout(new CardLayout(0, 0)); JPanel panelTvShow = new TvShowInformationPanel(tvShowSelectionModel); panelRight.add(panelTvShow, "tvShow"); JPanel panelTvShowSeason = new TvShowSeasonInformationPanel(tvShowSeasonSelectionModel); panelRight.add(panelTvShowSeason, "tvShowSeason"); JPanel panelTvShowEpisode = new TvShowEpisodeInformationPanel(tvShowEpisodeSelectionModel); panelRight.add(panelTvShowEpisode, "tvShowEpisode"); tree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node != null) { // click on a tv show if (node.getUserObject() instanceof TvShow) { TvShow tvShow = (TvShow) node.getUserObject(); tvShowSelectionModel.setSelectedTvShow(tvShow); CardLayout cl = (CardLayout) (panelRight.getLayout()); cl.show(panelRight, "tvShow"); } // click on a season if (node.getUserObject() instanceof TvShowSeason) { TvShowSeason tvShowSeason = (TvShowSeason) node.getUserObject(); tvShowSeasonSelectionModel.setSelectedTvShowSeason(tvShowSeason); CardLayout cl = (CardLayout) (panelRight.getLayout()); cl.show(panelRight, "tvShowSeason"); } // click on an episode if (node.getUserObject() instanceof TvShowEpisode) { TvShowEpisode tvShowEpisode = (TvShowEpisode) node.getUserObject(); tvShowEpisodeSelectionModel.setSelectedTvShowEpisode(tvShowEpisode); CardLayout cl = (CardLayout) (panelRight.getLayout()); cl.show(panelRight, "tvShowEpisode"); } } else { // check if there is at least one tv show in the model TvShowRootTreeNode root = (TvShowRootTreeNode) tree.getModel().getRoot(); if (root.getChildCount() == 0) { // sets an inital show tvShowSelectionModel.setSelectedTvShow(null); } } } }); addComponentListener(new ComponentAdapter() { @Override public void componentHidden(ComponentEvent e) { menu.setVisible(false); super.componentHidden(e); } @Override public void componentShown(ComponentEvent e) { menu.setVisible(true); super.componentHidden(e); } }); // further initializations init(); initDataBindings(); // selecting first TV show at startup if (tvShowList.getTvShows() != null && tvShowList.getTvShows().size() > 0) { DefaultMutableTreeNode firstLeaf = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) tree.getModel() .getRoot()).getFirstChild(); tree.setSelectionPath(new TreePath(((DefaultMutableTreeNode) firstLeaf.getParent()).getPath())); tree.setSelectionPath(new TreePath(firstLeaf.getPath())); } }
From source file:org.trzcinka.intellitrac.view.toolwindow.tickets.tickets_list.TicketsListForm.java
private void createUIComponents() { constantToolbarForm = new ConstantToolbarForm(); sorter = new TableRowSorter<TicketsListModel>(ticketsModel.getTicketsListTableModel()); ticketsList = new JTable(ticketsModel.getTicketsListTableModel()); ticketsList.setRowSorter(sorter);//from w w w . j a v a2s . co m filterColumnsModel = new FilterColumnsComboModel(); filterColumnsComboBox = new JComboBox(filterColumnsModel); filterColumnsComboBox.setSelectedIndex(0); filterColumnsComboBox.setRenderer(new FilterColumnsComboRenderer()); filterStringTextField = new JTextField(); filterStringTextField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { newFilter(); } public void insertUpdate(DocumentEvent e) { newFilter(); } public void removeUpdate(DocumentEvent e) { newFilter(); } }); }
From source file:org.yccheok.jstock.gui.AjaxAutoCompleteJComboBox.java
private DocumentListener getDocumentListener() { return new DocumentListener() { @Override/*from w w w. j a v a 2 s. co m*/ public void insertUpdate(DocumentEvent e) { try { final String string = e.getDocument().getText(0, e.getDocument().getLength()).trim(); _handle(string); } catch (BadLocationException ex) { log.error(null, ex); } } @Override public void removeUpdate(DocumentEvent e) { try { final String string = e.getDocument().getText(0, e.getDocument().getLength()).trim(); _handle(string); } catch (BadLocationException ex) { log.error(null, ex); } } @Override public void changedUpdate(DocumentEvent e) { try { final String string = e.getDocument().getText(0, e.getDocument().getLength()).trim(); _handle(string); } catch (BadLocationException ex) { log.error(null, ex); } } private void _handle(final String string) { // We are no longer busy. busySubject.notify(AjaxAutoCompleteJComboBox.this, false); if (AjaxAutoCompleteJComboBox.this.getSelectedItem() != null) { if (AjaxAutoCompleteJComboBox.this.getSelectedItem().toString().equals(string)) { // We need to differentiate, whether "string" is from user // typing, or drop down list selection. This is because when // user perform selection, document change event will be triggered // too. When string is from drop down list selection, user // are not expecting any auto complete suggestion. Return early. return; } } if (string.isEmpty()) { // Empty string. Return early. Do not perform hidePopup and // removeAllItems right here. As when user performs list // selection, previous text field item will be removed, and // cause us fall into this scope. We do not want to hidePopup // and removeAllItems when user is selecting his item. // // hidePopup and removeAllItems when user clears off all items // in text field, will be performed through keyReleased. return; } // We are busy contacting server right now. busySubject.notify(AjaxAutoCompleteJComboBox.this, true); canRemoveAllItems = true; ajaxYahooSearchEngineMonitor.clearAndPut(string); ajaxGoogleSearchEngineMonitor.clearAndPut(string); } }; }
From source file:org.yccheok.jstock.gui.AutoCompleteJComboBox.java
private DocumentListener getDocumentListener() { return new DocumentListener() { private volatile boolean ignore = false; @Override//from w w w.j a v a2 s. c o m public void insertUpdate(DocumentEvent e) { try { final String string = e.getDocument().getText(0, e.getDocument().getLength()).trim(); handle(string); } catch (BadLocationException ex) { log.error(null, ex); } } @Override public void removeUpdate(DocumentEvent e) { try { final String string = e.getDocument().getText(0, e.getDocument().getLength()).trim(); handle(string); } catch (BadLocationException ex) { log.error(null, ex); } } @Override public void changedUpdate(DocumentEvent e) { try { final String string = e.getDocument().getText(0, e.getDocument().getLength()).trim(); handle(string); } catch (BadLocationException ex) { log.error(null, ex); } } private void _handle(final String string) { // We are no longer busy. busySubject.notify(AutoCompleteJComboBox.this, false); if (AutoCompleteJComboBox.this.getSelectedItem() != null) { // Remember to use toString(). As getSelectedItem() can be // either StockInfo, or ResultSet. if (AutoCompleteJComboBox.this.getSelectedItem().toString().equals(string)) { // We need to differentiate, whether "string" is from user // typing, or drop down list selection. This is because when // user perform selection, document change event will be triggered // too. When string is from drop down list selection, user // are not expecting any auto complete suggestion. Return early. return; } } if (string.isEmpty()) { // Empty string. Return early. Do not perform hidePopup and // removeAllItems right here. As when user performs list // selection, previous text field item will be removed, and // cause us fall into this scope. We do not want to hidePopup // and removeAllItems when user is selecting his item. // // hidePopup and removeAllItems when user clears off all items // in text field, will be performed through keyReleased. return; } // Use to avoid endless DocumentEvent triggering. ignore = true; // During _handle operation, there will be a lot of ListDataListeners // trying to modify the content of our text field. We will not allow // them to do so. // // Without setReadOnly(true), when we type the first character "w", IME // will suggest ... However, when we call removeAllItems and addItem, // JComboBox will "commit" this suggestion to JComboBox's text field. // Hence, if we continue to type second character "m", the string displayed // at JComboBox's text field will be ... // AutoCompleteJComboBox.this.jComboBoxEditor.setReadOnly(true); // Must hide popup. If not, the pop up windows will not be // resized. AutoCompleteJComboBox.this.hidePopup(); AutoCompleteJComboBox.this.removeAllItems(); boolean shouldShowPopup = false; if (AutoCompleteJComboBox.this.stockInfoDatabase != null) { java.util.List<StockInfo> stockInfos = greedyEnabled ? stockInfoDatabase.greedySearchStockInfos(string) : stockInfoDatabase.searchStockInfos(string); sortStockInfosIfPossible(stockInfos); if (stockInfos.isEmpty() == false) { // Change to offline mode before adding any item. changeMode(Mode.Offline); } for (StockInfo stockInfo : stockInfos) { AutoCompleteJComboBox.this.addItem(stockInfo); shouldShowPopup = true; } if (shouldShowPopup) { AutoCompleteJComboBox.this.showPopup(); } else { } // if (shouldShowPopup) } // if (AutoCompleteJComboBox.this.stockInfoDatabase != null) if (shouldShowPopup == false) { // OK. We found nothing from offline database. Let's // ask help from online database. // We are busy contacting server right now. // TODO // Only enable ajaxYahooSearchEngineMonitor, till we solve // http://sourceforge.net/apps/mediawiki/jstock/index.php?title=TechnicalDisability busySubject.notify(AutoCompleteJComboBox.this, true); canRemoveAllItems = true; ajaxYahooSearchEngineMonitor.clearAndPut(string); ajaxGoogleSearchEngineMonitor.clearAndPut(string); } // When we are in windows look n feel, the text will always be selected. We do not want that. final Component component = AutoCompleteJComboBox.this.getEditor().getEditorComponent(); if (component instanceof JTextField) { JTextField jTextField = (JTextField) component; jTextField.setSelectionStart(jTextField.getText().length()); jTextField.setSelectionEnd(jTextField.getText().length()); jTextField.setCaretPosition(jTextField.getText().length()); } // Restore. AutoCompleteJComboBox.this.jComboBoxEditor.setReadOnly(false); ignore = false; } private void handle(final String string) { if (ignore) { return; } // Submit to GUI event queue. Used to avoid // Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Attempt to mutate in notification SwingUtilities.invokeLater(new Runnable() { @Override public void run() { _handle(string); } }); } }; }
From source file:org.yccheok.jstock.gui.StockDatabaseJDialog.java
/** This method is called from within the constructor to * initialize the form./* w w w . j ava 2 s . c o m*/ * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jComboBox1 = new AjaxAutoCompleteJComboBox(); jPanel6 = new javax.swing.JPanel(); jXHeader1 = new org.jdesktop.swingx.JXHeader(); jPanel4 = new javax.swing.JPanel(); jPanel1 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jPanel3 = new javax.swing.JPanel(); jTextField1 = new javax.swing.JTextField(); jPanel2 = new javax.swing.JPanel(); jScrollPane2 = new javax.swing.JScrollPane(); jTable2 = new javax.swing.JTable(); jPanel5 = new javax.swing.JPanel(); jPanel10 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jPanel7 = new javax.swing.JPanel(); jPanel8 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jPanel9 = new javax.swing.JPanel(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jComboBox1.setEditable(true); jComboBox1.setPreferredSize(new java.awt.Dimension(160, 24)); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui"); // NOI18N setTitle(bundle.getString("StockDatabaseJDialog_StockDatabase")); // NOI18N addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { formMouseClicked(evt); } }); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosed(java.awt.event.WindowEvent evt) { formWindowClosed(evt); } }); jPanel6.setLayout(new java.awt.BorderLayout(5, 5)); jXHeader1.setDescription(bundle.getString("StockDatabaseJDialog_Description")); // NOI18N jXHeader1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/64x64/db_add.png"))); // NOI18N jXHeader1.setTitle(bundle.getString("StockDatabaseJDialog_StockDatabase")); // NOI18N jPanel6.add(jXHeader1, java.awt.BorderLayout.CENTER); getContentPane().add(jPanel6, java.awt.BorderLayout.NORTH); jPanel4.setLayout(new java.awt.GridLayout(1, 0)); jPanel1.setBorder(javax.swing.BorderFactory .createTitledBorder(bundle.getString("StockDatabaseJDialog_StockExchangeServer"))); // NOI18N jPanel1.setLayout(new java.awt.BorderLayout()); jTable1.setAutoCreateRowSorter(true); jTable1.setModel(getSystemDefinedStockInfoTableModel()); this.jTable1.setDefaultRenderer(Symbol.class, new StockTableCellRenderer()); this.jTable1.setDefaultRenderer(Code.class, new StockTableCellRenderer()); if (JStock.instance().getJStockOptions().useLargeFont()) { this.jTable1.setRowHeight((int) (this.jTable1.getRowHeight() * Constants.FONT_ENLARGE_FACTOR)); } jScrollPane1.setViewportView(jTable1); jPanel1.add(jScrollPane1, java.awt.BorderLayout.CENTER); jTextField1.setColumns(10); jTextField1.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { newFilter(); } public void insertUpdate(DocumentEvent e) { newFilter(); } public void removeUpdate(DocumentEvent e) { newFilter(); } }); jPanel3.add(jTextField1); jPanel1.add(jPanel3, java.awt.BorderLayout.NORTH); jPanel4.add(jPanel1); jPanel2.setBorder( javax.swing.BorderFactory.createTitledBorder(bundle.getString("StockDatabaseJDialog_UserDefined"))); // NOI18N jPanel2.setLayout(new java.awt.BorderLayout()); this.jScrollPane2.addMouseListener(new TableRowPopupListener(true)); jTable2.setAutoCreateRowSorter(true); jTable2.setModel(getUserDefinedStockInfoTableModel()); this.jTable2.addMouseListener(new TableRowPopupListener()); this.jTable2.setDefaultRenderer(Code.class, new StockTableCellRenderer()); this.jTable2.setDefaultRenderer(Symbol.class, new StockTableCellRenderer()); this.jTable2.setDefaultEditor(Code.class, this.getCellEditor(Code.class)); this.jTable2.setDefaultEditor(Symbol.class, this.getCellEditor(Symbol.class)); //this.jTable2.setDefaultEditor(Object.class, this.getSymbolCellEditor()); if (JStock.instance().getJStockOptions().useLargeFont()) { this.jTable2.setRowHeight((int) (this.jTable2.getRowHeight() * Constants.FONT_ENLARGE_FACTOR)); } jTable2.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { jTable2KeyPressed(evt); } }); jScrollPane2.setViewportView(jTable2); jPanel2.add(jScrollPane2, java.awt.BorderLayout.CENTER); jPanel2.add(jPanel5, java.awt.BorderLayout.NORTH); jLabel2.setFont(jLabel2.getFont().deriveFont(jLabel2.getFont().getSize() - 1f)); jLabel2.setText(bundle.getString("StockDatabaseJDialog_NeedHelpVisit")); // NOI18N jPanel10.add(jLabel2); jLabel3.setFont(jLabel3.getFont().deriveFont(jLabel3.getFont().getSize() - 1f)); jLabel3.setText(bundle.getString("StockDatabaseJDialog_HelpURL")); // NOI18N jLabel3.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLabel3MouseClicked(evt); } public void mouseEntered(java.awt.event.MouseEvent evt) { jLabel3MouseEntered(evt); } public void mouseExited(java.awt.event.MouseEvent evt) { jLabel3MouseExited(evt); } }); jPanel10.add(jLabel3); jPanel2.add(jPanel10, java.awt.BorderLayout.SOUTH); jPanel4.add(jPanel2); getContentPane().add(jPanel4, java.awt.BorderLayout.CENTER); jPanel7.setLayout(new java.awt.BorderLayout()); jLabel1.setForeground(new java.awt.Color(0, 0, 255)); jLabel1.setText(getTotalStockString()); jPanel8.add(jLabel1); jPanel7.add(jPanel8, java.awt.BorderLayout.NORTH); jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/apply.png"))); // NOI18N jButton3.setText(bundle.getString("StockDatabaseJDialog_OK")); // NOI18N jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jPanel9.add(jButton3); jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/button_cancel.png"))); // NOI18N jButton4.setText(bundle.getString("StockDatabaseJDialog_Cancel")); // NOI18N jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); jPanel9.add(jButton4); jPanel7.add(jPanel9, java.awt.BorderLayout.CENTER); getContentPane().add(jPanel7, java.awt.BorderLayout.PAGE_END); pack(); }
From source file:org.zaproxy.zap.extension.dynssl.DynamicSSLPanel.java
/** * Create the panel.//from w w w . ja v a 2 s .c om */ public DynamicSSLPanel(ExtensionDynSSL extension) { super(); this.extension = extension; setName(Constant.messages.getString("dynssl.options.name")); setLayout(new BorderLayout(0, 0)); final JPanel panel = new JPanel(); panel.setBorder(new EmptyBorder(2, 2, 2, 2)); add(panel); final JLabel lbl_Cert = new JLabel(Constant.messages.getString("dynssl.label.rootca")); txt_PubCert = new ZapTextArea(); txt_PubCert.setFont(FontUtils.getFont("Monospaced")); txt_PubCert.setEditable(false); txt_PubCert.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { checkAndEnableButtons(); } @Override public void insertUpdate(DocumentEvent e) { checkAndEnableButtons(); } @Override public void changedUpdate(DocumentEvent e) { checkAndEnableButtons(); } private void checkAndEnableButtons() { checkAndEnableViewButton(); checkAndEnableSaveButton(); } }); final JScrollPane pubCertScrollPane = new JScrollPane(txt_PubCert); final JButton bt_generate = new JButton(Constant.messages.getString("dynssl.button.generate")); bt_generate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doGenerate(); } }); bt_generate.setIcon(new ImageIcon(DynamicSSLPanel.class.getResource("/resource/icon/16/041.png"))); bt_save = new JButton(Constant.messages.getString("menu.file.save")); checkAndEnableSaveButton(); bt_save.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSave(); } }); bt_save.setIcon(new ImageIcon(DynamicSSLPanel.class.getResource("/resource/icon/16/096.png"))); bt_view = new JButton(Constant.messages.getString("menu.view")); checkAndEnableViewButton(); bt_view.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doView(); } }); bt_view.setIcon(new ImageIcon(DynamicSSLPanel.class.getResource("/resource/icon/16/049.png"))); final JButton bt_import = new JButton(Constant.messages.getString("dynssl.button.import")); bt_import.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doImport(); } }); bt_import.setIcon(new ImageIcon(DynamicSSLPanel.class.getResource("/resource/icon/16/047.png"))); final GroupLayout gl_panel = new GroupLayout(panel); gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addGroup(gl_panel .createSequentialGroup().addContainerGap() .addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false).addGroup(gl_panel .createSequentialGroup() .addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false) .addComponent(lbl_Cert, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE) .addGroup(gl_panel.createSequentialGroup() .addPreferredGap(ComponentPlacement.RELATED).addComponent(bt_generate))) .addGap(6)) .addGroup(gl_panel.createSequentialGroup().addComponent(bt_import) .addPreferredGap(ComponentPlacement.RELATED))) .addGroup(gl_panel.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel.createSequentialGroup().addComponent(bt_view) .addPreferredGap(ComponentPlacement.RELATED).addComponent(bt_save)) .addComponent(pubCertScrollPane, GroupLayout.DEFAULT_SIZE, 369, Short.MAX_VALUE)) .addContainerGap())); gl_panel.setVerticalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addGroup(gl_panel .createSequentialGroup().addGap(10) .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE) .addGroup(gl_panel.createSequentialGroup().addComponent(lbl_Cert).addGap(10) .addComponent(bt_generate, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(bt_import, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)) .addComponent(pubCertScrollPane, GroupLayout.PREFERRED_SIZE, 400, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE) .addComponent(bt_save, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE) .addComponent(bt_view, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)) .addGap(0, 29, Short.MAX_VALUE))); panel.setLayout(gl_panel); }
From source file:org.zaproxy.zap.extension.encoder2.EncodeDecodeDialog.java
private ZapTextArea getInputField() { if (inputField == null) { inputField = newField(true);/* www .ja v a 2 s . c om*/ inputField.setName(ENCODE_DECODE_FIELD); inputField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent documentEvent) { updateEncodeDecodeFields(); } @Override public void removeUpdate(DocumentEvent documentEvent) { updateEncodeDecodeFields(); } @Override public void changedUpdate(DocumentEvent documentEvent) { } }); inputField.addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mousePressed(java.awt.event.MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { View.getSingleton().getPopupMenu().show(e.getComponent(), e.getX(), e.getY()); } } }); } return inputField; }