Java Code Examples for javax.swing.DefaultComboBoxModel#removeElement()
The following examples show how to use
javax.swing.DefaultComboBoxModel#removeElement() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectProjectPanel.java From netbeans with Apache License 2.0 | 6 votes |
private void btnProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProjectActionPerformed JFileChooser chooser = ProjectChooser.projectChooser(); int res = chooser.showOpenDialog(SwingUtilities.getWindowAncestor(this)); if (res == JFileChooser.APPROVE_OPTION) { File fil = chooser.getSelectedFile(); FileObject fo = FileUtil.toFileObject(fil); if (fo != null) { try { Project p = ProjectManager.getDefault().findProject(fo); DefaultComboBoxModel model = (DefaultComboBoxModel)comProject.getModel(); model.addElement(p); model.setSelectedItem(p); if (EMPTY == model.getElementAt(0)) { model.removeElement(EMPTY); } } catch (IOException exc) { ErrorManager.getDefault().notify(exc); } } } }
Example 2
Source File: DriverSettings.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 6 votes |
private void renameEmulator() { String oldName = browserCombo.getSelectedItem().toString(); String newEmName = browserCombo.getEditor().getItem().toString(); if (!oldName.equals(newEmName)) { if (!getTotalBrowserList().contains(newEmName)) { Emulator emulator = settings.getEmulators().getEmulator(oldName); emulator.setName(newEmName); DefaultComboBoxModel combomodel = (DefaultComboBoxModel) browserCombo.getModel(); DefaultComboBoxModel dupCombomodel = (DefaultComboBoxModel) dupDriverCombo.getModel(); int index = browserCombo.getSelectedIndex(); combomodel.removeElement(oldName); dupCombomodel.removeElement(oldName); combomodel.insertElementAt(newEmName, index); dupCombomodel.insertElementAt(newEmName, index); browserCombo.setSelectedIndex(index); } else { Notification.show("Emulator/Browser [" + newEmName + "] already Present"); } } }
Example 3
Source File: DirectorySelectorCombo.java From netbeans with Apache License 2.0 | 5 votes |
private void fileMRUPopupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_fileMRUPopupMenuWillBecomeVisible DefaultComboBoxModel model = (DefaultComboBoxModel)fileMRU.getModel(); Collection mukls = new ArrayList(); for(int i=0;i<model.getSize();i++) { if (!(model.getElementAt(i) instanceof ComboListElement)) continue; if (((ComboListElement)model.getElementAt(i)).isVolatile()) mukls.add(model.getElementAt(i)); } for (Iterator it = mukls.iterator(); it.hasNext();) { Object elem = (Object) it.next(); model.removeElement(elem); it.remove(); } }
Example 4
Source File: RunAsRemoteWeb.java From netbeans with Apache License 2.0 | 5 votes |
private void selectRemoteConnection(String remoteConnection) { if (remoteConnection == null) { remoteConnection = getValue(PhpProjectProperties.REMOTE_CONNECTION); } // #141849 - can be null if one adds remote config for the first time for a project but already has some remote connection DefaultComboBoxModel<RemoteConfiguration> model = (DefaultComboBoxModel<RemoteConfiguration>) remoteConnectionComboBox.getModel(); if (remoteConnection == null || RunConfigRemote.NO_CONFIG_NAME.equals(remoteConnection)) { if (model.getIndexOf(RunConfigRemote.NO_REMOTE_CONFIGURATION) < 0) { model.insertElementAt(RunConfigRemote.NO_REMOTE_CONFIGURATION, 0); } remoteConnectionComboBox.setSelectedItem(RunConfigRemote.NO_REMOTE_CONFIGURATION); return; } int size = remoteConnectionComboBox.getModel().getSize(); for (int i = 0; i < size; ++i) { RemoteConfiguration rc = remoteConnectionComboBox.getItemAt(i); if (remoteConnection.equals(rc.getName())) { remoteConnectionComboBox.setSelectedItem(rc); return; } } // remote connection is missing (probably removed?) remoteConnectionComboBox.addItem(RunConfigRemote.MISSING_REMOTE_CONFIGURATION); remoteConnectionComboBox.setSelectedItem(RunConfigRemote.MISSING_REMOTE_CONFIGURATION); // # 162230 model.removeElement(RunConfigRemote.NO_REMOTE_CONFIGURATION); }
Example 5
Source File: TMSettings.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
private void renameModule() { if (moduleCombo.getSelectedIndex() != -1) { String moduleName = moduleCombo.getSelectedItem().toString(); String newModuleName = moduleCombo.getEditor().getItem().toString(); if (!newModuleName.trim().isEmpty()) { testMgmtModule.getModule(moduleName).setModule(newModuleName); DefaultComboBoxModel combomodel = (DefaultComboBoxModel) moduleCombo.getModel(); int index = moduleCombo.getSelectedIndex(); combomodel.removeElement(moduleName); combomodel.insertElementAt(newModuleName, index); moduleCombo.setSelectedIndex(index); } } }
Example 6
Source File: JdbcDataSourceDialog.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public void actionPerformed( final ActionEvent e ) { final NamedDataSourceDialogModel dialogModel = getDialogModel(); final DefaultComboBoxModel queries = dialogModel.getQueries(); queries.removeElement( queries.getSelectedItem() ); if ( queryNameList.getLastVisibleIndex() != -1 ) { queryNameList.setSelectedValue( dialogModel.getQueries().getQuery( queryNameList.getLastVisibleIndex() ), true ); queryNameList.setSelectedIndex( queryNameList.getLastVisibleIndex() ); queries.setSelectedItem( dialogModel.getQueries().getQuery( queryNameList.getLastVisibleIndex( ) ) ); queryTextArea.setEnabled( true ); } else { queries.setSelectedItem( null ); queryNameList.clearSelection(); queryTextArea.setEnabled( false ); } }
Example 7
Source File: ConfigureDataView.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
private void guessDateFormatForPreview(String preferredPattern) { if (!requiresDateFormat) { return; } // Keep the currentCustomFormat, lastCustomFormat and the dataSetMetaData format List<String> customPatterns = new ArrayList<>(); Optional.ofNullable(dateFormatField.getSelectedItem()).map(Object::toString).ifPresent(customPatterns::add); Optional.ofNullable(lastCustomDateFormat).map(MatchingEntry::getEntryName).ifPresent(customPatterns::add); Stream.of(dataSetMetaData.getDateFormat()).filter(SimpleDateFormat.class::isInstance).map(SimpleDateFormat.class::cast).map(SimpleDateFormat::toPattern).forEach(customPatterns::add); DateFormatGuesser dateFormatGuesser = null; try { dateFormatGuesser = DateFormatGuesser.guessDateFormat(tableModel.getDataSet(), customPatterns, preferredPattern); } catch (DataSetException e) { SwingTools.invokeLater(() -> showErrorNotification(ERROR_LOADING_DATA_KEY, e.getMessage())); } if (dateFormatGuesser == null) { dfg = null; return; } SimpleDateFormat bestDateFormat = dateFormatGuesser.getBestMatch(DATE_COLUMN_CONFIDENCE); String bestPattern = bestDateFormat != null ? bestDateFormat.toPattern() : null; MatchingEntry bestMatchingEntry = null; Map<String, Double> results = dateFormatGuesser.getResults(DATE_COLUMN_CONFIDENCE); /// update existing entries with new match values for (MatchingEntry matchingEntry : matchingEntries) { String entryName = matchingEntry.getEntryName(); double match = results.getOrDefault(entryName, 0d); matchingEntry.setMatch(match); if (entryName.equals(bestPattern)) { bestMatchingEntry = matchingEntry; } } // add new entry if (bestPattern != null && bestMatchingEntry == null) { bestMatchingEntry = MatchingEntry.create(bestPattern, results.getOrDefault(bestPattern, 0d)); DefaultComboBoxModel<MatchingEntry> comboBoxModel = (DefaultComboBoxModel<MatchingEntry>) dateFormatField.getModel(); if (lastCustomDateFormat != null) { comboBoxModel.removeElement(lastCustomDateFormat); } comboBoxModel.addElement(bestMatchingEntry); lastCustomDateFormat = bestMatchingEntry; } matchingEntries.sort(MatchingEntry::compareTo); if (bestDateFormat != null) { dataSetMetaData.setDateFormat(bestDateFormat); } if (guessedDateFormat == null) { guessedDateFormat = bestPattern != null ? bestPattern : ""; } dfg = dateFormatGuesser; }
Example 8
Source File: QueryRemoveAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void actionPerformed( final ActionEvent e ) { final DefaultComboBoxModel comboBoxModel = queries.getQueries(); comboBoxModel.removeElement( comboBoxModel.getSelectedItem() ); comboBoxModel.setSelectedItem( null ); }