List of usage examples for javax.swing JComboBox addItem
public void addItem(E item)
From source file:org.tinymediamanager.ui.movies.dialogs.MovieBatchEditorDialog.java
/** * Instantiates a new movie batch editor. * /* w w w.jav a 2 s . co m*/ * @param movies * the movies */ public MovieBatchEditorDialog(final List<Movie> movies) { super(BUNDLE.getString("movie.edit"), "movieBatchEditor"); //$NON-NLS-1$ setBounds(5, 5, 350, 230); getContentPane().setLayout(new BorderLayout(0, 0)); { JPanel panelContent = new JPanel(); getContentPane().add(panelContent, BorderLayout.CENTER); panelContent.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), 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, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblGenres = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$ panelContent.add(lblGenres, "2, 2, 2, 1, right, default"); // cbGenres = new JComboBox(MediaGenres2.values()); cbGenres = new AutocompleteComboBox(MediaGenres.values()); cbGenres.setEditable(true); panelContent.add(cbGenres, "5, 2, fill, default"); JButton btnAddGenre = new JButton(""); btnAddGenre.setIcon(IconManager.LIST_ADD); btnAddGenre.setMargin(new Insets(2, 2, 2, 2)); btnAddGenre.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); MediaGenres genre = null; Object item = cbGenres.getSelectedItem(); // genre if (item instanceof MediaGenres) { genre = (MediaGenres) item; } // newly created genre? if (item instanceof String) { genre = MediaGenres.getGenre((String) item); } // MediaGenres2 genre = (MediaGenres2) cbGenres.getSelectedItem(); if (genre != null) { for (Movie movie : moviesToEdit) { movie.addGenre(genre); } } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnAddGenre, "7, 2"); JButton btnRemoveGenre = new JButton(""); btnRemoveGenre.setIcon(IconManager.LIST_REMOVE); btnRemoveGenre.setMargin(new Insets(2, 2, 2, 2)); btnRemoveGenre.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); MediaGenres genre = (MediaGenres) cbGenres.getSelectedItem(); for (Movie movie : moviesToEdit) { movie.removeGenre(genre); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnRemoveGenre, "9, 2"); JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$ panelContent.add(lblTags, "2, 4, 2, 1, right, default"); cbTags = new AutocompleteComboBox(movieList.getTagsInMovies().toArray()); cbTags.setEditable(true); panelContent.add(cbTags, "5, 4, fill, default"); JButton btnAddTag = new JButton(""); btnAddTag.setIcon(IconManager.LIST_ADD); btnAddTag.setMargin(new Insets(2, 2, 2, 2)); btnAddTag.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); String tag = (String) cbTags.getSelectedItem(); if (StringUtils.isBlank(tag)) { return; } for (Movie movie : moviesToEdit) { movie.addToTags(tag); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnAddTag, "7, 4"); JButton btnRemoveTag = new JButton(""); btnRemoveTag.setIcon(IconManager.LIST_REMOVE); btnRemoveTag.setMargin(new Insets(2, 2, 2, 2)); btnRemoveTag.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); String tag = (String) cbTags.getSelectedItem(); for (Movie movie : moviesToEdit) { movie.removeFromTags(tag); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnRemoveTag, "9, 4"); JLabel lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$ panelContent.add(lblCertification, "2, 6, 2, 1, right, default"); final JComboBox cbCertification = new JComboBox(); for (Certification cert : Certification .getCertificationsforCountry(MovieModuleManager.MOVIE_SETTINGS.getCertificationCountry())) { cbCertification.addItem(cert); } panelContent.add(cbCertification, "5, 6, fill, default"); JButton btnCertification = new JButton(""); btnCertification.setMargin(new Insets(2, 2, 2, 2)); btnCertification.setIcon(IconManager.APPLY); btnCertification.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); Certification cert = (Certification) cbCertification.getSelectedItem(); for (Movie movie : moviesToEdit) { movie.setCertification(cert); ; } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnCertification, "7, 6"); JLabel lblMovieSet = new JLabel(BUNDLE.getString("metatag.movieset")); //$NON-NLS-1$ panelContent.add(lblMovieSet, "2, 8, 2, 1, right, default"); cbMovieSet = new JComboBox(); panelContent.add(cbMovieSet, "5, 8, fill, default"); JButton btnSetMovieSet = new JButton(""); btnSetMovieSet.setMargin(new Insets(2, 2, 2, 2)); btnSetMovieSet.setIcon(IconManager.APPLY); btnSetMovieSet.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // movie set Object obj = cbMovieSet.getSelectedItem(); for (Movie movie : moviesToEdit) { if (obj instanceof String) { movie.removeFromMovieSet(); } if (obj instanceof MovieSet) { MovieSet movieSet = (MovieSet) obj; if (movie.getMovieSet() != movieSet) { movie.removeFromMovieSet(); movie.setMovieSet(movieSet); movieSet.insertMovie(movie); } } } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnSetMovieSet, "7, 8"); JButton btnNewMovieset = new JButton(""); btnNewMovieset.setMargin(new Insets(2, 2, 2, 2)); btnNewMovieset.setAction(new MovieSetAddAction(false)); panelContent.add(btnNewMovieset, "9, 8"); JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$ panelContent.add(lblWatched, "2, 10, 2, 1, right, default"); chckbxWatched = new JCheckBox(""); panelContent.add(chckbxWatched, "5, 10"); JButton btnWatched = new JButton(""); btnWatched.setMargin(new Insets(2, 2, 2, 2)); btnWatched.setIcon(IconManager.APPLY); btnWatched.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (Movie movie : moviesToEdit) { movie.setWatched(chckbxWatched.isSelected()); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnWatched, "7, 10"); JLabel lblVideo3D = new JLabel(BUNDLE.getString("metatag.3d")); //$NON-NLS-1$ panelContent.add(lblVideo3D, "2, 12, 2, 1, right, default"); final JCheckBox chckbxVideo3D = new JCheckBox(""); panelContent.add(chckbxVideo3D, "5, 12"); JButton btnVideo3D = new JButton(""); btnVideo3D.setMargin(new Insets(2, 2, 2, 2)); btnVideo3D.setIcon(IconManager.APPLY); btnVideo3D.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (Movie movie : moviesToEdit) { movie.setVideoIn3D(chckbxVideo3D.isSelected()); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnVideo3D, "7, 12"); JLabel lblMediasource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$ panelContent.add(lblMediasource, "2, 14, 2, 1, right, default"); final JComboBox cbMediaSource = new JComboBox(MediaSource.values()); panelContent.add(cbMediaSource, "5, 14, fill, default"); JButton btnMediaSource = new JButton(""); btnMediaSource.setMargin(new Insets(2, 2, 2, 2)); btnMediaSource.setIcon(IconManager.APPLY); btnMediaSource.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; Object obj = cbMediaSource.getSelectedItem(); if (obj instanceof MediaSource) { MediaSource mediaSource = (MediaSource) obj; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (Movie movie : moviesToEdit) { movie.setMediaSource(mediaSource); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); panelContent.add(btnMediaSource, "7, 14"); JLabel lblLanguage = new JLabel(BUNDLE.getString("metatag.language")); //$NON-NLS-1$ panelContent.add(lblLanguage, "2, 16, 2, 1, right, default"); tfLanguage = new JTextField(); panelContent.add(tfLanguage, "5, 16, fill, default"); tfLanguage.setColumns(10); JButton btnLanguage = new JButton(""); btnLanguage.setMargin(new Insets(2, 2, 2, 2)); btnLanguage.setIcon(IconManager.APPLY); btnLanguage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (Movie movie : moviesToEdit) { movie.setSpokenLanguages(tfLanguage.getText()); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnLanguage, "7, 16"); { JLabel lblSorttitleT = new JLabel(BUNDLE.getString("metatag.sorttitle")); //$NON-NLS-1$ panelContent.add(lblSorttitleT, "2, 18, right, default"); JButton btnSetSorttitle = new JButton(BUNDLE.getString("edit.setsorttitle")); //$NON-NLS-1$ btnSetSorttitle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (Movie movie : moviesToEdit) { movie.setSortTitle(movie.getTitleSortable()); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); JLabel lblSorttitleInfo = new JLabel(IconManager.HINT); lblSorttitleInfo.setToolTipText(BUNDLE.getString("edit.setsorttitle.desc")); //$NON-NLS-1$ panelContent.add(lblSorttitleInfo, "3, 18"); panelContent.add(btnSetSorttitle, "5, 18"); JButton btnClearSorttitle = new JButton(BUNDLE.getString("edit.clearsorttitle")); //$NON-NLS-1$ btnClearSorttitle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (Movie movie : moviesToEdit) { movie.setSortTitle(""); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnClearSorttitle, "5, 20"); } } { JPanel panelButtons = new JPanel(); FlowLayout flowLayout = (FlowLayout) panelButtons.getLayout(); flowLayout.setAlignment(FlowLayout.RIGHT); getContentPane().add(panelButtons, BorderLayout.SOUTH); JButton btnClose = new JButton(BUNDLE.getString("Button.close")); //$NON-NLS-1$ btnClose.setIcon(IconManager.APPLY); btnClose.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { // rewrite movies, if anything changed if (changed) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (Movie movie : moviesToEdit) { movie.writeNFO(); movie.saveToDb(); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } setVisible(false); } }); panelButtons.add(btnClose); // add window listener to write changes (if the window close button "X" is // pressed) addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { // rewrite movies, if anything changed if (changed) { for (Movie movie : moviesToEdit) { movie.writeNFO(); movie.saveToDb(); } // if configured - sync with trakt.tv if (MovieModuleManager.MOVIE_SETTINGS.getSyncTrakt()) { TmmTask task = new SyncTraktTvTask(moviesToEdit, null); TmmTaskManager.getInstance().addUnnamedTask(task); } } } }); } { setMovieSets(); moviesToEdit = movies; PropertyChangeListener listener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("addedMovieSet".equals(evt.getPropertyName())) { setMovieSets(); } } }; movieList.addPropertyChangeListener(listener); } }
From source file:org.tinymediamanager.ui.movies.dialogs.MovieCreateOfflineDialog.java
public MovieCreateOfflineDialog() { super(BUNDLE.getString("movie.createoffline"), "movieCreateOffline"); //$NON-NLS-1$ setBounds(5, 5, 350, 230);// www.ja va 2s . c om getContentPane().setLayout(new BorderLayout(0, 0)); JPanel panelContent = new JPanel(); getContentPane().add(panelContent, BorderLayout.NORTH); panelContent.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu: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, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.PARAGRAPH_GAP_ROWSPEC, })); JLabel lblTitle = new JLabel(BUNDLE.getString("metatag.title")); //$NON-NLS-1$ panelContent.add(lblTitle, "2, 2, right, default"); final JTextField tfMovieName = new JTextField(); panelContent.add(tfMovieName, "4, 2, fill, default"); tfMovieName.setColumns(10); JLabel lblMediaSource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$ panelContent.add(lblMediaSource, "2, 4, right, default"); final JComboBox<MediaSource> cbMediaSource = new JComboBox(); cbMediaSource.addItem(MediaSource.UNKNOWN); cbMediaSource.addItem(MediaSource.DVD); cbMediaSource.addItem(MediaSource.BLURAY); cbMediaSource.addItem(MediaSource.HDDVD); cbMediaSource.addItem(MediaSource.VHS); panelContent.add(cbMediaSource, "4, 4, fill, default"); JLabel lblDatasource = new JLabel(BUNDLE.getString("metatag.datasource")); //$NON-NLS-1$ panelContent.add(lblDatasource, "2, 6, right, default"); final JComboBox<String> cbDatasource = new JComboBox(); panelContent.add(cbDatasource, "4, 6, fill, default"); JButton btnAdd = new JButton(IconManager.LIST_ADD); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String title = tfMovieName.getText(); String datasource = (String) cbDatasource.getSelectedItem(); MediaSource mediaSource = (MediaSource) cbMediaSource.getSelectedItem(); if (StringUtils.isNoneBlank(title, datasource)) { movieList.addOfflineMovie(title, datasource, mediaSource); } } }); panelContent.add(btnAdd, "6, 2, right, default"); { JPanel panelBottom = new JPanel(); getContentPane().add(panelBottom, BorderLayout.SOUTH); panelBottom.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, })); JPanel panelButtons = new JPanel(); EqualsLayout layout = new EqualsLayout(5); layout.setMinWidth(100); panelButtons.setLayout(layout); panelBottom.add(panelButtons, "2, 2, right, fill"); JButton btnClose = new JButton(BUNDLE.getString("Button.close")); //$NON-NLS-1$ btnClose.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); panelButtons.add(btnClose); } { // initializations for (String datasource : MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource()) { cbDatasource.addItem(datasource); } } }
From source file:org.ut.biolab.medsavant.client.filter.TagFilterView.java
public TagFilterView(int queryID) { super(FILTER_NAME, queryID); setLayout(new BorderLayout()); setBorder(ViewUtil.getBigBorder());/*from w w w. j ava 2s .c om*/ setMaximumSize(new Dimension(200, 80)); JPanel cp = new JPanel(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; cp.setLayout(gbl); variantTags = new ArrayList<VariantTag>(); appliedTags = new ArrayList<VariantTag>(); clear = new JButton("Clear"); applyButton = new JButton("Apply"); try { final JComboBox tagNameCB = new JComboBox(); //tagNameCB.setMaximumSize(new Dimension(1000,30)); final JComboBox tagValueCB = new JComboBox(); //tagValueCB.setMaximumSize(new Dimension(1000,30)); JPanel bottomContainer = new JPanel(); ViewUtil.applyHorizontalBoxLayout(bottomContainer); List<String> tagNames = MedSavantClient.VariantManager .getDistinctTagNames(LoginController.getSessionID()); for (String tag : tagNames) { tagNameCB.addItem(tag); } ta = new JTextArea(); ta.setRows(10); ta.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); ta.setEditable(false); applyButton.setEnabled(false); JLabel addButton = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.ADD)); addButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (tagNameCB.getSelectedItem() == null || tagValueCB.getSelectedItem() == null) { return; } VariantTag tag = new VariantTag((String) tagNameCB.getSelectedItem(), (String) tagValueCB.getSelectedItem()); if (variantTags.isEmpty()) { ta.append(tag.toString() + "\n"); } else { ta.append("AND " + tag.toString() + "\n"); } variantTags.add(tag); applyButton.setEnabled(true); } }); clear.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { variantTags.clear(); ta.setText(""); applyButton.setEnabled(true); } }); int width = 150; ta.setPreferredSize(new Dimension(width, width)); ta.setMaximumSize(new Dimension(width, width)); tagNameCB.setPreferredSize(new Dimension(width, 25)); tagValueCB.setPreferredSize(new Dimension(width, 25)); tagNameCB.setMaximumSize(new Dimension(width, 25)); tagValueCB.setMaximumSize(new Dimension(width, 25)); cp.add(new JLabel("Name"), c); c.gridx++; cp.add(tagNameCB, c); c.gridx++; c.gridx = 0; c.gridy++; cp.add(new JLabel("Value"), c); c.gridx++; cp.add(tagValueCB, c); c.gridx++; cp.add(addButton, c); tagNameCB.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent ie) { updateTagValues((String) tagNameCB.getSelectedItem(), tagValueCB); } }); if (tagNameCB.getItemCount() > 0) { tagNameCB.setSelectedIndex(0); updateTagValues((String) tagNameCB.getSelectedItem(), tagValueCB); } al = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { applyButton.setEnabled(false); appliedTags = new ArrayList<VariantTag>(variantTags); Filter f = new Filter() { @Override public Condition[] getConditions() { try { List<Integer> uploadIDs = MedSavantClient.VariantManager .getUploadIDsMatchingVariantTags(LoginController.getSessionID(), TagFilterView.tagsToStringArray(variantTags)); Condition[] uploadIDConditions = new Condition[uploadIDs.size()]; TableSchema table = MedSavantClient.CustomTablesManager.getCustomTableSchema( LoginController.getSessionID(), MedSavantClient.ProjectManager.getVariantTableName( LoginController.getSessionID(), ProjectController.getInstance().getCurrentProjectID(), ReferenceController.getInstance().getCurrentReferenceID(), true)); for (int i = 0; i < uploadIDs.size(); i++) { uploadIDConditions[i] = BinaryCondition.equalTo( table.getDBColumn(BasicVariantColumns.UPLOAD_ID), uploadIDs.get(i)); } return new Condition[] { ComboCondition.or(uploadIDConditions) }; } catch (Exception ex) { ClientMiscUtils.reportError("Error getting upload IDs: %s", ex); } return new Condition[0]; } @Override public String getName() { return FILTER_NAME; } @Override public String getID() { return FILTER_ID; } }; FilterController.getInstance().addFilter(f, TagFilterView.this.queryID); } }; applyButton.addActionListener(al); bottomContainer.add(Box.createHorizontalGlue()); bottomContainer.add(clear); bottomContainer.add(applyButton); add(ViewUtil.getClearBorderedScrollPane(ta), BorderLayout.CENTER); add(bottomContainer, BorderLayout.SOUTH); } catch (Exception ex) { ClientMiscUtils.checkSQLException(ex); } add(cp, BorderLayout.NORTH); this.showViewCard(); }
From source file:org.ut.biolab.medsavant.client.filter.TagFilterView.java
private static void updateTagValues(String tagName, JComboBox tagValueCB) { tagValueCB.removeAllItems();//from w w w. jav a2s .com if (tagName != null) { List<String> values; try { values = MedSavantClient.VariantManager.getValuesForTagName(LoginController.getSessionID(), tagName); for (String val : values) { tagValueCB.addItem(val); } } catch (Exception ex) { ClientMiscUtils.reportError("Error updating tag values: %s", ex); } } tagValueCB.updateUI(); }
From source file:org.zaproxy.zap.extension.ascan.PolicyAllCategoryPanel.java
/** * This method initializes tableTest/*w w w.ja va 2 s . c om*/ * * @return javax.swing.JTable */ private JTable getTableTest() { if (tableTest == null) { tableTest = new JTable(); tableTest.setModel(getAllCategoryTableModel()); tableTest.setRowHeight(DisplayUtils.getScaledSize(18)); tableTest.setIntercellSpacing(new java.awt.Dimension(1, 1)); tableTest.setAutoCreateRowSorter(true); //Default sort by name (column 0) List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(1); sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING)); tableTest.getRowSorter().setSortKeys(sortKeys); for (int i = 0; i < tableTest.getColumnCount() - 1; i++) { TableColumn column = tableTest.getColumnModel().getColumn(i); column.setPreferredWidth(width[i]); } JComboBox<String> jcb1 = new JComboBox<>(); jcb1.addItem(""); // Always show a blank one for where they are not all the same for (AlertThreshold level : AlertThreshold.values()) { jcb1.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase())); } tableTest.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(jcb1)); JComboBox<String> jcb2 = new JComboBox<>(); jcb2.addItem(""); // Always show a blank one for where they are not all the same for (AttackStrength level : AttackStrength.values()) { jcb2.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase())); } tableTest.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(jcb2)); } return tableTest; }
From source file:org.zaproxy.zap.extension.customFire.PolicyAllCategoryPanel.java
/** * Creates a {@code JComboBox} with scanners' statuses, "all", release, beta and alpha. * * @return a {@code JComboBox} with scanners' statuses *///w ww . j a v a 2 s . c om private JComboBox<String> createStatusComboBox() { JComboBox<String> comboBox = new JComboBox<>(); comboBox.addItem(Constant.messages.getString("customFire.custom.policy.table.quality.all")); View view = View.getSingleton(); //View view = new View(); // comboBox.addItem("Release"); // comboBox.addItem("Beta"); // comboBox.addItem("Alpha"); comboBox.addItem(view.getStatusUI(AddOn.Status.release).toString()); comboBox.addItem(view.getStatusUI(AddOn.Status.beta).toString()); comboBox.addItem(view.getStatusUI(AddOn.Status.alpha).toString()); return comboBox; }
From source file:org.zaproxy.zap.extension.customFire.PolicyAllCategoryPanel.java
/** * This method initializes tableTest/*from w w w. ja v a 2 s. c o m*/ * * @return javax.swing.JTable */ private JTable getTableTest() { if (tableTest == null) { tableTest = new JTable(); tableTest.setModel(getAllCategoryTableModel()); tableTest.setRowHeight(DisplayUtils.getScaledSize(18)); tableTest.setIntercellSpacing(new java.awt.Dimension(1, 1)); tableTest.setAutoCreateRowSorter(true); //Default sort by name (column 0) List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(1); sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING)); tableTest.getRowSorter().setSortKeys(sortKeys); for (int i = 0; i < tableTest.getColumnCount() - 1; i++) { TableColumn column = tableTest.getColumnModel().getColumn(i); column.setPreferredWidth(width[i]); } JComboBox<String> jcb1 = new JComboBox<>(); jcb1.addItem(""); // Always show a blank one for where they are not all the same for (AlertThreshold level : AlertThreshold.values()) { jcb1.addItem(Constant.messages .getString("customFire.custom.policy.level." + level.name().toLowerCase())); } tableTest.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(jcb1)); JComboBox<String> jcb2 = new JComboBox<>(); jcb2.addItem(""); // Always show a blank one for where they are not all the same for (AttackStrength level : AttackStrength.values()) { jcb2.addItem(Constant.messages .getString("customFire.custom.policy.level." + level.name().toLowerCase())); } tableTest.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(jcb2)); } return tableTest; }
From source file:ro.nextreports.designer.querybuilder.RuntimeParametersPanel.java
private void initUI() { setLayout(new GridBagLayout()); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); components = new ArrayList<JComponent>(); checks = new ArrayList<JCheckBox>(); int size = paramList.size(); boolean shouldExpand = false; boolean needScroll = false; for (int i = 0; i < size; i++) { final int pos = i; final QueryParameter param = paramList.get(i); if (param.isHidden()) { components.add(null);// w ww . j a v a 2 s . c om checks.add(null); initHiddenParameterValues(param); continue; } String source = param.getSource(); String defaultSource = param.getDefaultSource(); if ((defaultSource != null) && !defaultSource.trim().equals("")) { try { param.setDefaultSourceValues(Globals.getDBViewer().getDefaultSourceValues(con, param)); } catch (NextSqlException e) { Show.error(e); } } final JComponent component; int anchor = GridBagConstraints.WEST; double y = 0.0; int expand = GridBagConstraints.HORIZONTAL; if ((source != null) && !source.equals("")) { List<IdName> values = new ArrayList<IdName>(); try { if (param.isManualSource()) { if (!param.isDependent()) { values = Globals.getDBViewer().getValues(con, source, true, param.getOrderBy()); } } else { int index = source.indexOf("."); int index2 = source.lastIndexOf("."); String tableName = source.substring(0, index); String columnName; String shownColumnName = null; if (index == index2) { columnName = source.substring(index + 1); } else { columnName = source.substring(index + 1, index2); shownColumnName = source.substring(index2 + 1); } values = Globals.getDBViewer().getColumnValues(con, param.getSchema(), tableName, columnName, shownColumnName, param.getOrderBy()); } } catch (NextSqlException e) { error = true; Show.error(e); } catch (InvalidSqlException e) { String m = I18NSupport.getString("source.dialog.valid"); Show.info(m + " : \"select <exp1> , <exp2> from ...\""); } if (param.getSelection().equals(ParameterEditPanel.SINGLE_SELECTION)) { component = new JComboBox(); final JComboBox combo = (JComboBox) component; combo.setRenderer(new IdNameRenderer()); combo.addItem("-- " + I18NSupport.getString("parameter.value.select") + " --"); for (int j = 0, len = values.size(); j < len; j++) { combo.addItem(values.get(j)); } combo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { IdName in = null; if (combo.getSelectedIndex() > 0) { in = (IdName) combo.getSelectedItem(); } parameterSelection(pos, in); } } }); AutoCompleteDecorator.decorate(combo); needScroll = false; } else { anchor = GridBagConstraints.NORTHWEST; y = 1.0; expand = GridBagConstraints.BOTH; DefaultListModel model = new DefaultListModel(); for (int j = 0, len = values.size(); j < len; j++) { model.addElement(values.get(j)); } List srcList = Arrays.asList(model.toArray()); component = new ListSelectionPanel(srcList, new ArrayList(), "", "", true, false) { protected void onAdd() { selection(); } protected void onRemove() { selection(); } // needed for saved parameters on rerun protected void onSetRight() { selection(); } private void selection() { if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) { Object[] values = getDestinationElements().toArray(); if (values.length == 0) { values = new Object[] { ParameterUtil.NULL }; } parameterSelection(pos, values); } } }; ((ListSelectionPanel) component).setListSize(scrListDim); ((ListSelectionPanel) component).setRenderer(new IdNameRenderer(), new IdNameComparator(param.getOrderBy())); shouldExpand = true; } } else { if (param.getSelection().equals(QueryParameter.MULTIPLE_SELECTION)) { anchor = GridBagConstraints.NORTHWEST; y = 1.0; expand = GridBagConstraints.BOTH; ; component = new ListAddPanel(param) { protected void onAdd() { selection(); } protected void onRemove() { selection(); } private void selection() { if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) { Object[] values = getElements().toArray(); parameterSelection(pos, values); } } }; } else { needScroll = false; if (param.getValueClassName().equals("java.util.Date")) { component = new JXDatePicker(); ((JXDatePicker) component).addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if ("date".equals(e.getPropertyName())) { parameterSelection(pos, ((JXDatePicker) component).getDate()); } } }); // hack to fix bug with big popup button JButton popupButton = (JButton) component.getComponent(1); //popupButton.setMargin(new Insets(2, 2, 2, 2)); popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY)); } else if (param.getValueClassName().equals("java.sql.Timestamp") || param.getValueClassName().equals("java.sql.Time")) { component = new JDateTimePicker() { protected void onChange() { parameterSelection(pos, getDate()); } }; // hack to fix bug with big popup button JButton popupButton = (JButton) (((JDateTimePicker) component).getDatePicker()) .getComponent(1); //popupButton.setMargin(new Insets(2, 2, 2, 2)); popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY)); } else if (param.getValueClassName().equals("java.lang.Boolean")) { component = new JCheckBox(); ((JCheckBox) component).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); parameterSelection(pos, selected); } }); } else { component = new JTextField(25); ((JTextField) component).getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { updateFromTextField(e); } @Override public void insertUpdate(DocumentEvent e) { updateFromTextField(e); } @Override public void removeUpdate(DocumentEvent e) { updateFromTextField(e); } private void updateFromTextField(DocumentEvent e) { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { Object value = null; try { if ("".equals(((JTextField) component).getText().trim())) { value = null; } else { value = ParameterUtil.getParameterValueFromString( param.getValueClassName(), ((JTextField) component).getText()); } parameterSelection(pos, value); } catch (Exception e) { e.printStackTrace(); LOG.error(e.getMessage(), e); } } }); } }); } } } components.add(component); final JCheckBox cb = new JCheckBox(I18NSupport.getString("run.parameter.ignore")); checks.add(cb); final JLabel label = new JLabel(getRuntimeParameterName(param)); panel.add(label, new GridBagConstraints(0, i, 1, 1, 0.0, 0.0, anchor, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); final JComponent addComponent; if (needScroll) { JScrollPane scr = new JScrollPane(component, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scr.setPreferredSize(listDim); addComponent = scr; } else { addComponent = component; } panel.add(addComponent, new GridBagConstraints(1, i, 1, 1, 1.0, y, GridBagConstraints.WEST, expand, new Insets(5, 0, 5, 5), 0, 0)); int checkAnchor = GridBagConstraints.WEST; if ((addComponent instanceof JScrollPane) || (addComponent instanceof ListSelectionPanel)) { checkAnchor = GridBagConstraints.NORTHWEST; } if (Globals.getParametersIgnore()) { panel.add(cb, new GridBagConstraints(2, i, 1, 1, 0.0, 0.0, checkAnchor, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); } cb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (cb.isSelected()) { if (addComponent instanceof JScrollPane) { component.setEnabled(false); } label.setEnabled(false); addComponent.setEnabled(false); param.setIgnore(true); } else { if (addComponent instanceof JScrollPane) { component.setEnabled(true); } label.setEnabled(true); addComponent.setEnabled(true); param.setIgnore(false); } } }); } // populate hidden dependent parameters (this will be done if a parameter depends only on a single hidden parameter) // if a parameter depends on a hidden parameter and other parameters, it cannot be populated here for (int i = 0; i < size; i++) { final QueryParameter param = paramList.get(i); if (param.isHidden()) { populateDependentParameters(param, false); } } if (!shouldExpand) { panel.add(new JLabel(), new GridBagConstraints(0, size, 3, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } JScrollPane scrPanel = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrPanel.setPreferredSize(scrDim); scrPanel.setMinimumSize(scrDim); add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); setParameterValues(parametersValues); setParameterIgnore(parametersIgnore); }
From source file:ro.nextreports.designer.querybuilder.RuntimeParametersPanel.java
@SuppressWarnings("unchecked") private void initParameterValue(JComponent component, Object value, String paramName, List<Serializable> defaultValues) { if (value == null) { return;//from w w w .ja v a2 s. c o m } if (component instanceof JTextField) { ((JTextField) component).setText(value.toString()); } else if (component instanceof JComboBox) { JComboBox combo = ((JComboBox) component); List<IdName> values = (List<IdName>) value; combo.removeAllItems(); combo.addItem("-- " + I18NSupport.getString("parameter.value.select") + " --"); for (int j = 0, len = values.size(); j < len; j++) { combo.addItem(values.get(j)); } Object old = parametersValues.get(paramName); if (old != null) { combo.setSelectedItem(old); } else if ((defaultValues != null) && (defaultValues.size() > 0)) { Serializable id = defaultValues.get(0); if (id instanceof IdName) { id = ((IdName) id).getId(); } combo.setSelectedItem(findIdName(combo.getModel(), id)); } } else if (component instanceof ListSelectionPanel) { ListSelectionPanel lsp = (ListSelectionPanel) component; DefaultListModel model = new DefaultListModel(); if (value != null) { List<IdName> values = (List<IdName>) value; for (int j = 0, len = values.size(); j < len; j++) { model.addElement(values.get(j)); } } ArrayList srcList = new ArrayList(Arrays.asList(model.toArray())); Object old = parametersValues.get(paramName); Object[] selected = new Object[0]; if (old != null) { selected = (Object[]) old; } else if ((defaultValues != null) && (defaultValues.size() > 0)) { selected = new Object[defaultValues.size()]; for (int k = 0, len = selected.length; k < len; k++) { Serializable id = defaultValues.get(k); if (id instanceof IdName) { id = ((IdName) id).getId(); } IdName in = findIdName(srcList, id); selected[k] = in; } } List dstList = Arrays.asList(selected); if (!srcList.containsAll(dstList)) { dstList = new ArrayList(); parametersValues.put(paramName, null); } else { srcList.removeAll(dstList); } if ((dstList.size() == 1) && ParameterUtil.NULL.equals(dstList.get(0))) { dstList = new ArrayList(); } lsp.setLists(srcList, dstList); } else if (component instanceof ListAddPanel) { ListAddPanel lap = (ListAddPanel) component; DefaultListModel model = new DefaultListModel(); if (value != null) { List<Object> values = (List<Object>) value; for (int j = 0, len = values.size(); j < len; j++) { model.addElement(values.get(j)); } } ArrayList srcList = new ArrayList(Arrays.asList(model.toArray())); Object old = parametersValues.get(paramName); Object[] selected = new Object[0]; if (old != null) { selected = (Object[]) old; } else if ((defaultValues != null) && (defaultValues.size() > 0)) { selected = new Object[defaultValues.size()]; for (int k = 0, len = selected.length; k < len; k++) { Serializable id = defaultValues.get(k); if (id instanceof IdName) { id = ((IdName) id).getId(); } selected[k] = id; } } List dstList = Arrays.asList(selected); if (!srcList.containsAll(dstList)) { dstList = new ArrayList(); parametersValues.put(paramName, null); } else { srcList.removeAll(dstList); } if ((dstList.size() == 1) && ParameterUtil.NULL.equals(dstList.get(0))) { dstList = new ArrayList(); } lap.setElements(dstList); } else if (component instanceof JDateTimePicker) { ((JDateTimePicker) component).setDate((Date) value); } else if (component instanceof JXDatePicker) { ((JXDatePicker) component).setDate((Date) value); } else if (component instanceof JCheckBox) { ((JCheckBox) component).setSelected((Boolean) value); } }
From source file:se.cambio.cds.gdl.editor.view.panels.DescriptionPanel.java
public JPanel getAuthorshipLifeCycle() { if (authorshipLifecyclePanel == null) { authorshipLifecyclePanel = new JPanel(new SpringLayout()); authorshipLifecyclePanel//from ww w .j a v a 2 s . c o m .add(new JLabel(GDLEditorLanguageManager.getMessage("AuthorshipLyfecycle") + ":")); JComboBox lyfeCB = new JComboBox(); //TODO Translations? lyfeCB.addItem("Not set"); lyfeCB.addItem("Initial"); lyfeCB.addItem("Author draft"); lyfeCB.addItem("Committee draft"); lyfeCB.addItem("Organisation draft"); lyfeCB.addItem("Submitted"); lyfeCB.addItem("Candidate"); lyfeCB.addItem("Approved candidate"); lyfeCB.addItem("Published"); lyfeCB.addItem("Rejected"); lyfeCB.addItem("Obsolete"); lyfeCB.setSelectedIndex(2); connect(_descriptionContext, "/lifecycleState", lyfeCB); authorshipLifecyclePanel.add(lyfeCB); authorshipLifecyclePanel.add(new JLabel(GDLEditorLanguageManager.getMessage("Copyright") + ":")); JTextField copyrightTF = new JTextField(); String lang = _controller.getCurrentGuideLanguageCode(); connect(_descriptionContext, "/details/" + lang + "/copyright", copyrightTF); authorshipLifecyclePanel.add(copyrightTF); SpringUtilities.makeCompactGrid(authorshipLifecyclePanel, 2, 2, //rows, cols 6, 6, //initX, initY 6, 6); } return authorshipLifecyclePanel; }