private void handleEntryAction(ActionEvent actionEvent) throws IOException, ParserConfigurationException, XPathExpressionException, SAXException, NoItemException { if (this.getGazetteer() == null) { Util.getLogger().severe("No gazeteer is registered"); return; } String lookupString; JComboBox cmb = ((JComboBox) actionEvent.getSource()); lookupString = cmb.getSelectedItem().toString(); if (lookupString == null || lookupString.length() < 1) return; java.util.List<PointOfInterest> results = this.gazetteer.findPlaces(lookupString); if (results == null || results.size() == 0) return; this.controller.moveToLocation(results.get(0)); // Add it to the list if not already there for (int i = 0; i < cmb.getItemCount(); i++) { Object oi = cmb.getItemAt(i); if (oi != null && oi.toString().trim().equals(lookupString)) return; // item exists } cmb.insertItemAt(lookupString, 0); }
private void setUpBrowserCombobox() { for (BrowsersConfiguration.BrowserFamily family : BrowsersConfiguration.getInstance().getActiveBrowsers()) { browserComboBox.addItem(family); } browserComboBox.setRenderer( new ListCellRendererWrapper<BrowsersConfiguration.BrowserFamily>(browserComboBox) { @Override public void customize( JList list, BrowsersConfiguration.BrowserFamily family, int index, boolean selected, boolean hasFocus) { if (family != null) { setText(family.getName()); setIcon(family.getIcon()); } } }); if (browserComboBox.getItemCount() < 2) { browserComboBox.setVisible(false); browserComboBox.setVisible(false); } else { browserComboBox.setSelectedItem(0); } }
public void setIndexer(LibrariesIndexer indexer) { this.indexer = indexer; DropdownItem<DownloadableContribution> previouslySelectedCategory = (DropdownItem<DownloadableContribution>) categoryChooser.getSelectedItem(); DropdownItem<DownloadableContribution> previouslySelectedType = (DropdownItem<DownloadableContribution>) typeChooser.getSelectedItem(); categoryChooser.removeActionListener(categoryChooserActionListener); typeChooser.removeActionListener(typeChooserActionListener); // TODO: Remove setIndexer and make getContribModel // return a FilteredAbstractTableModel getContribModel().setIndexer(indexer); categoryFilter = null; categoryChooser.removeAllItems(); // Load categories categoryChooser.addItem(new DropdownAllItem()); Collection<String> categories = indexer.getIndex().getCategories(); for (String category : categories) { categoryChooser.addItem(new DropdownLibraryOfCategoryItem(category)); } categoryChooser.setEnabled(categoryChooser.getItemCount() > 1); categoryChooser.addActionListener(categoryChooserActionListener); if (previouslySelectedCategory != null) { categoryChooser.setSelectedItem(previouslySelectedCategory); } else { categoryChooser.setSelectedIndex(0); } typeFilter = null; typeChooser.removeAllItems(); typeChooser.addItem(new DropdownAllItem()); typeChooser.addItem(new DropdownInstalledLibraryItem(indexer.getIndex())); java.util.List<String> types = new LinkedList<String>(indexer.getIndex().getTypes()); Collections.sort(types, new LibraryTypeComparator()); for (String type : types) { typeChooser.addItem(new DropdownLibraryOfTypeItem(type)); } typeChooser.setEnabled(typeChooser.getItemCount() > 1); typeChooser.addActionListener(typeChooserActionListener); if (previouslySelectedType != null) { typeChooser.setSelectedItem(previouslySelectedType); } else { typeChooser.setSelectedIndex(0); } filterField.setEnabled(contribModel.getRowCount() > 0); // Create LibrariesInstaller tied with the provided index installer = new LibraryInstaller(indexer, platform) { @Override public void onProgress(Progress progress) { setProgress(progress); } }; }
// Mode consultation public void modeConsultation() { resetCollection(); loadCollection(); comboCollection.setEnabled(true); textTitre.setVisible(false); textTitre.setEditable(false); textAnnee.setVisible(false); textAnnee.setEditable(false); comboType.setVisible(false); comboType.setEnabled(false); comboEval.setVisible(false); comboEval.setEnabled(false); // Juste au cas que ca foire scrollCom.setEnabled(true); scrollCat.setEnabled(true); textCommentaires.setEnabled(true); textCommentaires.setEditable(false); textCategories.setEnabled(true); textCategories.setEditable(false); textCommentaires.setBackground(GRIS); textCategories.setBackground(GRIS); for (int k = 0; k < infos_film.length; k++) { infos_film[k].setVisible(true); } // Place the first element of combobox in the grid DEPRECATED by Enoncé comboCollection.setSelectedIndex(comboCollection.getSelectedIndex()); for (int l = 0; l < modeButton.length; l++) { if (l < 2) { modeButton[0].setEnabled(false); modeButton[0].setVisible(true); if (comboCollection.getItemCount() > 1) { modeButton[l].setEnabled(true); modeButton[l].setVisible(true); } else { modeButton[l].setEnabled(false); modeButton[l].setVisible(true); } // modeButton[l].setEnabled(true); // modeButton[l].setVisible(true); } else { modeButton[l].setEnabled(false); modeButton[l].setVisible(false); } } optionCategories[0].setEnabled(false); optionCategories[1].setEnabled(false); // Get the collection and place in combobox Video video = this.obtenirVideo(comboCollection.getSelectedItem().toString()); afficherFilmChoisis(video.getTitre()); }
public static List getItems(JComboBox comboBox) { List result = new ArrayList(); for (int i = 0; i < comboBox.getItemCount(); i++) { Object element = comboBox.getItemAt(i); result.add(element); } return result; }
@SuppressWarnings("UseJBColor") // Colors are used for the graphics generator, not the plugin UI public RasterAssetSetStep( TemplateWizardState state, @Nullable Project project, @Nullable Module module, @Nullable Icon sidePanelIcon, UpdateListener updateListener, @Nullable VirtualFile invocationTarget) { super(state, project, module, sidePanelIcon, updateListener, invocationTarget); // Speed the scrolling of myScrollPane myScrollPane.getVerticalScrollBar().setUnitIncrement(16); register(ATTR_TEXT, myText); register(ATTR_SCALING, myCropRadioButton, Scaling.CROP); register(ATTR_SCALING, myCenterRadioButton, Scaling.CENTER); register(ATTR_SHAPE, myCircleRadioButton, GraphicGenerator.Shape.CIRCLE); register(ATTR_SHAPE, myNoneRadioButton, GraphicGenerator.Shape.NONE); register(ATTR_SHAPE, mySquareRadioButton, GraphicGenerator.Shape.SQUARE); register(ATTR_SHAPE, myVerticalRadioButton, GraphicGenerator.Shape.VRECT); register(ATTR_SHAPE, myHorizontalRadioButton, GraphicGenerator.Shape.HRECT); register(ATTR_DOGEAR, myDogEarEffectCheckBox); register(ATTR_PADDING, myPaddingSlider); register(ATTR_TRIM, myTrimBlankSpace); register(ATTR_FONT, myFontFamily); register(ATTR_SOURCE_TYPE, myImageRadioButton, AssetStudioAssetGenerator.SourceType.IMAGE); register(ATTR_SOURCE_TYPE, myClipartRadioButton, AssetStudioAssetGenerator.SourceType.CLIPART); register(ATTR_SOURCE_TYPE, myTextRadioButton, AssetStudioAssetGenerator.SourceType.TEXT); register(ATTR_FOREGROUND_COLOR, myForegroundColor); register(ATTR_BACKGROUND_COLOR, myBackgroundColor); register(ATTR_ASSET_TYPE, myAssetTypeComboBox); register(ATTR_ASSET_THEME, myChooseThemeComboBox); register(ATTR_ASSET_NAME, myResourceNameField); myImageFile.addBrowseFolderListener( null, null, null, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); myForegroundColor.setSelectedColor(Color.BLUE); myBackgroundColor.setSelectedColor(Color.WHITE); for (String font : GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()) { myFontFamily.addItem(new ComboBoxItem(font, font, 1, 1)); if (font.equals(myTemplateState.get(ATTR_FONT))) { myFontFamily.setSelectedIndex(myFontFamily.getItemCount() - 1); } } myChooseClipart.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { displayClipartDialog(); } }); populateComboBox(myAssetTypeComboBox, AssetType.class); populateComboBox(myChooseThemeComboBox, ActionBarIconGenerator.Theme.class); }
public void setSelectedFormat(String format) { for (int i = 0; i < formatComboBox.getItemCount(); i++) { DataSourceQueryChooser chooser = (DataSourceQueryChooser) formatComboBox.getItemAt(i); if (chooser.toString().equals(format)) { formatComboBox.setSelectedIndex(i); return; } } }
protected void createButtons(JPanel panel) { panel.add(new Filler(24, 20)); JComboBox drawingChoice = new JComboBox(); drawingChoice.addItem(fgUntitled); String param = getParameter("DRAWINGS"); if (param == null) { param = ""; } StringTokenizer st = new StringTokenizer(param); while (st.hasMoreTokens()) { drawingChoice.addItem(st.nextToken()); } if (drawingChoice.getItemCount() > 1) { panel.add(drawingChoice); } else { panel.add(new JLabel(fgUntitled)); } drawingChoice.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { loadDrawing((String) e.getItem()); } } }); panel.add(new Filler(6, 20)); JButton button; button = new CommandButton(new DeleteCommand("Delete", this)); panel.add(button); button = new CommandButton(new DuplicateCommand("Duplicate", this)); panel.add(button); button = new CommandButton(new GroupCommand("Group", this)); panel.add(button); button = new CommandButton(new UngroupCommand("Ungroup", this)); panel.add(button); button = new JButton("Help"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { showHelp(); } }); panel.add(button); fUpdateButton = new JButton("Simple Update"); fUpdateButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { if (fSimpleUpdate) { setBufferedDisplayUpdate(); } else { setSimpleDisplayUpdate(); } } }); }
@Override public void actionPerformed(ActionEvent arg0) { if (version.getItemCount() > 0) { Settings.getSettings() .setPackVer( (String.valueOf(version.getSelectedItem()).equalsIgnoreCase("recommended") ? "Recommended Version" : String.valueOf(version.getSelectedItem()))); Settings.getSettings().save(); } }
private void selectThread(ThreadReferenceProxyImpl toSelect) { int count = myThreadsCombo.getItemCount(); for (int idx = 0; idx < count; idx++) { ThreadDescriptorImpl item = (ThreadDescriptorImpl) myThreadsCombo.getItemAt(idx); if (toSelect.equals(item.getThreadReference())) { if (!item.equals(myThreadsCombo.getSelectedItem())) { myThreadsCombo.setSelectedIndex(idx); } return; } } }
private void applySelectedValue(JComboBox comboBox, Object value) { comboBox.removeItemListener(this); ValueLabelItem currentItem; for (int i = 0; i < comboBox.getItemCount(); i++) { currentItem = (ValueLabelItem) comboBox.getItemAt(i); if (currentItem.getValue().equals(value)) { comboBox.setSelectedIndex(i); break; } } comboBox.addItemListener(this); }
public void finalizeAssetType(AssetType type) { mySelectedAssetType = type; myTemplateState.put(ATTR_ASSET_TYPE, type.name()); for (int i = 0; i < myAssetTypeComboBox.getItemCount(); ++i) { if (((ComboBoxItem) myAssetTypeComboBox.getItemAt(i)).id.equals(type.name())) { myAssetTypeComboBox.setSelectedIndex(i); break; } } hide(myAssetTypeComboBox, myAssetTypeLabel); update(); }
@Override public void valueChanged(ListSelectionEvent lSE) { if (lSE.getSource().equals(siteTable.siteListModel) && lSE.getValueIsAdjusting() == false) { sourceTable.updateList(dbConn, siteTable.siteList.get(siteTable.getSelectedRow())); if (sourceTable.sourceListModel.isSelectionEmpty()) { plotButton.setEnabled(false); startDateS.removeAllItems(); endDateS.removeAllItems(); } } else if (lSE.getSource().equals(sourceTable.sourceListModel) && lSE.getValueIsAdjusting() == false) { if (sourceTable.sourceListModel.isSelectionEmpty() == false) { try { populateStartDate(); if (startDateS.getItemCount() > 0 && endDateS.getItemCount() > 0) { plotButton.setEnabled(true); } } catch (SQLException e) { plotButton.setEnabled(false); startDateS.removeAllItems(); endDateS.removeAllItems(); startDateS.addItem("ERR:NoData"); endDateS.addItem("ERR:NoData"); e.printStackTrace(); } catch (Exception e) { plotButton.setEnabled(false); startDateS.removeAllItems(); endDateS.removeAllItems(); startDateS.addItem(e.getMessage()); endDateS.addItem(e.getMessage()); } } else { plotButton.setEnabled(false); startDateS.removeAllItems(); endDateS.removeAllItems(); } } }
/** Sets up how the different GUI components should be viewed at startup. */ private void initializeDisplay() { if (itemNames.getItemCount() > 0) { itemNames.setSelectedIndex(0); } else { txtFlavor.setEnabled(false); txtStock.setEnabled(false); txtSalePrice.setEnabled(false); btnUpdate.setEnabled(false); btnDelete.setEnabled(false); btnNew.doClick(); } }
private void revisarCombo() { librosCombo.setModel(new DefaultComboBoxModel<Libro>(libros)); if (librosCombo.getItemCount() == 0) { limpiarCampos(); librosCombo.setEnabled(false); eliminarBoton.setEnabled(false); } else { librosCombo.setSelectedIndex(0); librosCombo.setEnabled(true); eliminarBoton.setEnabled(true); mostrarLibro(); } }
public void setAgent(String agentName) { int index = 0; debug("scanning " + agents.getItemCount() + " agents"); for (int i = 0; i < agents.getItemCount(); i++) { if (agents.getItemAt(i).toString().equals(agentName)) { index = i; debug("matched " + agentName); } else { debug("not matched " + agentName); } } agents.setSelectedIndex(index); }
public void updateLists(List<? extends ChangeList> lists) { //noinspection unchecked myChooser.setModel(new DefaultComboBoxModel(lists.toArray())); myChooser.setEnabled(lists.size() > 1); if (lists.contains(mySelectedChangeList)) { myChooser.setSelectedItem(mySelectedChangeList); } else { if (myChooser.getItemCount() > 0) { myChooser.setSelectedIndex(0); } } mySelectedChangeList = (ChangeList) myChooser.getSelectedItem(); }
/*invoked in swing thread*/ protected void rebuild(final boolean updateOnly) { if (!updateOnly) { myThreadsCombo.removeAllItems(); synchronized (myFramesList) { myFramesList.clear(); } } final DebugProcessImpl process = getContext().getDebugProcess(); if (process != null) { process .getManagerThread() .schedule(new RefreshFramePanelCommand(updateOnly && myThreadsCombo.getItemCount() != 0)); } }
/** * Set the fields from the ProjectionClass * * @param projClass projection class to use */ private void setFieldsWithClassParams(ProjectionClass projClass) { // set the projection in the JComboBox String want = projClass.toString(); for (int i = 0; i < projClassCB.getItemCount(); i++) { ProjectionClass pc = (ProjectionClass) projClassCB.getItemAt(i); if (pc.toString().equals(want)) { projClassCB.setSelectedItem((Object) pc); break; } } // set the parameter fields paramPanel.removeAll(); paramPanel.setVisible(0 < projClass.paramList.size()); List widgets = new ArrayList(); for (int i = 0; i < projClass.paramList.size(); i++) { ProjectionParam pp = (ProjectionParam) projClass.paramList.get(i); // construct the label String name = pp.name; String text = ""; // Create a decent looking label for (int cIdx = 0; cIdx < name.length(); cIdx++) { char c = name.charAt(cIdx); if (cIdx == 0) { c = Character.toUpperCase(c); } else { if (Character.isUpperCase(c)) { text += " "; c = Character.toLowerCase(c); } } text += c; } widgets.add(GuiUtils.rLabel(text + ": ")); // text input field JTextField tf = new JTextField(); pp.setTextField(tf); tf.setColumns(12); widgets.add(tf); } GuiUtils.tmpInsets = new Insets(4, 4, 4, 4); JPanel widgetPanel = GuiUtils.doLayout(widgets, 2, GuiUtils.WT_N, GuiUtils.WT_N); paramPanel.add("North", widgetPanel); paramPanel.add("Center", GuiUtils.filler()); }
/** _more_ */ private void setTimesInTimesBox() { DateTime[] theTimesArray = this.timesArray; if (theTimesArray == null) { return; } boolean oldValue = ignoreTimesCbxEvents; try { ignoreTimesCbxEvents = true; GuiUtils.setListData(timesCbx, theTimesArray); timesCbx.setVisible( timesCbxVisible && (theTimesArray != null) && (timesCbx.getItemCount() > 0)); } finally { ignoreTimesCbxEvents = oldValue; } }
/** Alter the bounds of the popup just before it is made visible. */ @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { JComboBox comboBox = (JComboBox) e.getSource(); if (comboBox.getItemCount() == 0) return; final Object child = comboBox.getAccessibleContext().getAccessibleChild(0); if (child instanceof BasicComboPopup) { SwingUtilities.invokeLater( new Runnable() { public void run() { customizePopup((BasicComboPopup) child); } }); } }
public void setSelectedDisplayOption(MatrixType[] options, boolean control) { if (control) { MatrixType originalMatrixType = (MatrixType) displayOptionComboBox.getSelectedItem(); displayOptionComboBox.setModel(new DefaultComboBoxModel<MatrixType>(options)); int indx = 0; for (int i = 0; i < displayOptionComboBox.getItemCount(); i++) { if (originalMatrixType.equals(displayOptionComboBox.getItemAt(i))) { indx = i; break; } } displayOptionComboBox.setSelectedIndex(indx); } else { displayOptionComboBox.setModel(new DefaultComboBoxModel<MatrixType>(options)); displayOptionComboBox.setSelectedIndex(0); } }
public void keyReleased(KeyEvent e) { char ch = e.getKeyChar(); if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch)) return; int pos = m_editor.getCaretPosition(); String str = m_editor.getText(); if (str.length() == 0) return; for (int k = 0; k < m_comboBox.getItemCount(); k++) { String item = m_comboBox.getItemAt(k).toString(); if (item.startsWith(str)) { m_editor.setText(item); m_editor.setCaretPosition(item.length()); m_editor.moveCaretPosition(pos); m_comboBox.setSelectedItem(item); break; } } }
public void loadData() { try { con = dbcon.myconnection(); st = con.createStatement(); rs = st.executeQuery("select * from screen_detail"); while (rs.next() == true) { jscreenName.addItem(rs.getString(2)); } int cnt = jscreenName.getItemCount() - 1; // int cnt1=Integer.parseInt(CDepno.getItem(cnt))+1 ; // screenRowVal.setText(String.valueOf(cnt)); st.close(); rs.close(); con.close(); System.out.println("Retrived successfully...."); } catch (IOException ex) { } catch (SQLException ex) { } }
private void addReflItem(String str, Con con) { reflectivities.put(con, reflBox.getItemCount()); reflBox.addItem(str); }
private void addConItem(String str, Con con) { conspicuities.put(con, conBox.getItemCount()); conBox.addItem(str); }
private void addCnsItem(String str, Cns cns) { constructions.put(cns, constrBox.getItemCount()); constrBox.addItem(str); }
private void addStsItem(String str, Sts sts) { statuses.put(sts, statusBox.getItemCount()); statusBox.addItem(str); }
public void gererEventBouttons(ActionEvent e) { if (e.getSource() == modeButton[0]) { // Boutton precedent // Verify if (comboCollection.getItemAt(comboCollection.getSelectedIndex() - 1) == null) { // modeButton[0].setVisible(false); modeButton[0].setEnabled(false); // messageErreur("Il n'y a pas d'element precedent a la collection"); messageErreur(MSG_ERREUR_BTN_PRECEDENT); } else { comboCollection.setSelectedIndex(comboCollection.getSelectedIndex() - 1); // Get Video video = this.obtenirVideo( comboCollection .getItemAt(comboCollection.getSelectedIndex()) .toString()); // String titre String catos = this.obtenirCategoriesEnString( comboCollection.getItemAt(comboCollection.getSelectedIndex()).toString()); afficherFilmChoisis(video.getTitre()); modeButton[1].setVisible(true); modeButton[1].setEnabled(true); if (comboCollection.getItemAt(comboCollection.getSelectedIndex() - 1) == null) { modeButton[0].setEnabled(false); } } } else if (e.getSource() == modeButton[1]) { // Boutton suivant // Verify if (comboCollection.getItemAt(comboCollection.getSelectedIndex() + 1) == null) { // modeButton[1].setVisible(false); modeButton[1].setEnabled(false); // messageErreur("Il n'y a pas d'element suivant a la collection"); messageErreur(MSG_ERREUR_BTN_SUIVANT); } else { comboCollection.setSelectedIndex(comboCollection.getSelectedIndex() + 1); // Get Video video = this.obtenirVideo( comboCollection .getItemAt(comboCollection.getSelectedIndex()) .toString()); // String titre String catos = this.obtenirCategoriesEnString( comboCollection.getItemAt(comboCollection.getSelectedIndex()).toString()); afficherFilmChoisis(video.getTitre()); modeButton[0].setVisible(true); modeButton[0].setEnabled(true); if (comboCollection.getItemAt(comboCollection.getSelectedIndex() + 1) == null) { modeButton[1].setEnabled(false); } } } else if (e.getSource() == modeButton[2]) { // Boutton ajouter // Verify if (textTitre.getText() == null || textTitre.getText().equals("")) { messageErreur(MSG_ERREUR_CHAMPS_TITRE); } else if (textAnnee.getText() == null || textAnnee.getText().equals("") || !textAnnee.getText().matches("^[0-9]+$")) { messageErreur(MSG_ERREUR_CHAMPS_ANNEE); } /*else if(textCommentaires.getText() == null){ messageErreur("Champs commentaires null"); } */ else if (textCategories.getText() == null) { messageErreur(MSG_ERREUR_CHAMP_CAT); } else { boolean type; if (comboType.getSelectedIndex() == 0) { messageErreur(MSG_ERREUR_CHAMP_TYPE); type = false; } else { if (comboType.getSelectedIndex() == 1) { type = true; } else { type = false; } int eval; if (comboEval.getSelectedIndex() == 0) { messageErreur(MSG_ERREUR_EVALUATION); } else { eval = comboEval.getSelectedIndex(); // Place this.ajouterVideo( textTitre.getText(), Integer.parseInt(textAnnee.getText()), type, eval, textCommentaires.getText(), textCategories .getText()); // String titre, int annee, boolean type, int eval, String // comments, String categories } } } } else if (e.getSource() == modeButton[3]) { // Boutton modifier // Verify if (textTitre.getText() == null || textTitre.getText().equals("")) { messageErreur(MSG_ERREUR_CHAMPS_TITRE); } else if (textAnnee.getText() == null || textAnnee.getText().equals("") || !textAnnee.getText().matches("^[0-9]+$")) { messageErreur(MSG_ERREUR_CHAMPS_ANNEE); } /*else if(textCommentaires.getText() == null){ messageErreur("Champs commentaires null"); } */ else if (textCategories.getText() == null) { messageErreur(MSG_ERREUR_CHAMP_CAT); } else { int eval; if (comboEval.getSelectedIndex() == 0) { messageErreur(MSG_ERREUR_EVALUATION); } else { eval = comboEval.getSelectedIndex(); boolean type; if (comboType.getSelectedIndex() == 0) { messageErreur(MSG_ERREUR_CHAMP_TYPE); type = false; } else if (comboType.getSelectedIndex() == 1) { type = true; } else { type = false; } // Place if (this.modifierVideo( comboCollection.getSelectedItem().toString(), textTitre.getText(), Integer.parseInt(textAnnee.getText()), eval, type, textCommentaires.getText(), textCategories .getText())) { // String titre, int annee, int eval, boolean type, String // comments, String categories messageSuccess("La video a ete modifier."); } else { messageSuccess("La video n'a pas ete modifier."); } } } } else if (e.getSource() == modeButton[4]) { // Boutton supprimer // Verify ... nothing... // Place if (this.supprimerVideo(comboCollection.getSelectedItem().toString())) { JOptionPane.showMessageDialog( fenetre, comboCollection.getSelectedItem().toString() + " a ete retirer de la collection!"); } else { messageErreur(MSG_ERREUR_FIM_NON_SUPPRIMER); } } else if (e.getSource() == modeButton[5]) { // Boutton rechercher int eval = comboEval.getSelectedIndex(); /* -1: Pas de recherche par evaluation 0: 0 étoile 1: 1 étoile 2: 2 étoiles 3: 3 étoiles 4: 4 étoiles 5: 5 étoiles */ /* -1: Pas de recherche par type 0: FILM 1: SERIE TV */ int type = comboType.getSelectedIndex() - 1; ArrayList<Video> videosTrouver = new ArrayList<Video>(); if (!textAnnee.getText().equals("")) { videosTrouver = rechercherVideos( textTitre.getText(), Integer.parseInt(textAnnee.getText()), eval, type, textCategories.getText()); } else { videosTrouver = rechercherVideos(textTitre.getText(), -1, eval, type, textCategories.getText()); } // comboCollection.removeAllItems(); ArrayList itemsInComboCollection = new ArrayList(); for (Video video : videosTrouver) { if (!itemsInComboCollection.contains(video)) { itemsInComboCollection.add(video); comboCollection.addItem(video.getTitre()); } } comboCollection.setEnabled(true); modeButton[0].setVisible(true); modeButton[1].setVisible(true); if (comboCollection.getSelectedIndex() != 0 && comboCollection.getItemCount() != 0) { modeButton[0].setEnabled(true); } else { modeButton[0].setEnabled(false); } if (comboCollection.getSelectedIndex() != comboCollection.getItemCount() && comboCollection.getItemCount() != 0) { modeButton[1].setEnabled(true); } else { modeButton[1].setEnabled(false); } modeButton[5].setVisible(false); modeButton[6].setVisible(true); } else if (e.getSource() == modeButton[6]) { // Bouton Nouvelle Recherche modeRecherche(); } else if (e.getSource() == optionCategories[0]) { // Boutton ajouter categorie // Get String[] categoriesDuFilm = textCategories.getText().split("\n"); ArrayList listeDeCategories = ArrayToArrayList(categoriesDuFilm); if (listeDeCategories.get(0).equals("")) { listeDeCategories.clear(); } selectionCategorie.removeAllItems(); ArrayList cater = new ArrayList(); for (String categorie : liste.obtenirCles()) { if (!cater.contains(categorie)) { cater.add(categorie); selectionCategorie.addItem(categorie); } } popUpSelection.add(selectionCategorie); fenetre.getContentPane().add(popUpSelection); int action = JOptionPane.showConfirmDialog( null, popUpSelection, "Categorie", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (action) { case 0: if (((String) selectionCategorie.getSelectedItem()).equals("Autres...")) { popUpSelection.remove(selectionCategorie); String categorieEntree = JOptionPane.showInputDialog(popUpSelection, "Ajouter une categorie"); if (categorieEntree != null) { if (!categorieExiste(listeDeCategories, categorieEntree)) { if (listeDeCategories.isEmpty()) { textCategories.setText(categorieEntree); } else { textCategories.setText(textCategories.getText() + "\n" + categorieEntree); } optionCategories[1].setEnabled(true); } else { messageErreur(MSG_ERREUR_CAT_EXST); } } else { messageErreur(MSG_ERREUR_ENTREE_NULL); } } else { if (!categorieExiste( listeDeCategories, (String) selectionCategorie.getSelectedItem())) { if (listeDeCategories.isEmpty()) { textCategories.setText(selectionCategorie.getSelectedItem().toString()); } else { textCategories.setText( textCategories.getText() + "\n" + (String) selectionCategorie.getSelectedItem()); } } else { messageErreur(MSG_ERREUR_CAT_EXST); } } break; case 1: break; } } else if (e.getSource() == optionCategories[1]) { // Boutton supprimer categorie // Get String[] categoriesDuFilm = textCategories.getText().trim().split("\\n"); ArrayList listeDeCategories = ArrayToArrayList(categoriesDuFilm); selectionCategorie.removeAllItems(); for (Object categorie : listeDeCategories) { selectionCategorie.addItem(categorie.toString()); } popUpSelection.add(selectionCategorie); fenetre.getContentPane().add(popUpSelection); int action = JOptionPane.showConfirmDialog( null, popUpSelection, "Categorie", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (action) { case 0: String categorieASupprimer = (String) selectionCategorie.getSelectedItem(); String output = ""; if (!listeDeCategories.isEmpty()) { listeDeCategories.remove(categorieASupprimer); for (int i = 0; i < listeDeCategories.size(); i++) { output += (String) listeDeCategories.get(i); if (i + 1 != listeDeCategories.size()) { output += "\n"; } } textCategories.setText(output); } else { optionCategories[1].setEnabled(false); } break; case 1: break; } } }
/* * I can't find any property on the scrollBar to determine if it will be * displayed or not so use brute force to determine this. */ protected int getScrollBarWidth(BasicComboPopup popup, JScrollPane scrollPane) { int scrollBarWidth = 0; JComboBox comboBox = (JComboBox) popup.getInvoker(); if (comboBox.getItemCount() > comboBox.getMaximumRowCount()) { JScrollBar vertical = scrollPane.getVerticalScrollBar(); scrollBarWidth = vertical.getPreferredSize().width; } return scrollBarWidth; }