Java Code Examples for javax.swing.DefaultListModel#size()
The following examples show how to use
javax.swing.DefaultListModel#size() .
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: J2SEProjectProperties.java From netbeans with Apache License 2.0 | 6 votes |
private void collectLibs(DefaultListModel model, List<String> libs, List<String> jarReferences) { for (int i = 0; i < model.size(); i++) { ClassPathSupport.Item item = (ClassPathSupport.Item) model.get(i); if (item.getType() == ClassPathSupport.Item.TYPE_LIBRARY) { if (!item.isBroken() && !libs.contains(item.getLibrary().getName())) { libs.add(item.getLibrary().getName()); } } if (item.getType() == ClassPathSupport.Item.TYPE_JAR) { if (item.getReference() != null && item.getVariableBasedProperty() == null && !jarReferences.contains(item.getReference())) { //TODO reference is null for not yet persisted items. // there seems to be no way to generate a reference string without actually // creating and writing the property.. jarReferences.add(item.getReference()); } } } }
Example 2
Source File: CustomizerLibraries.java From netbeans with Apache License 2.0 | 6 votes |
private static void collectLibs(DefaultListModel model, List<String> libs, List<String> jarReferences) { for (int i = 0; i < model.size(); i++) { ClassPathSupport.Item item = (ClassPathSupport.Item) model.get(i); if (item.getType() == ClassPathSupport.Item.TYPE_LIBRARY) { if (!item.isBroken() && !libs.contains(item.getLibrary().getName())) { libs.add(item.getLibrary().getName()); } } if (item.getType() == ClassPathSupport.Item.TYPE_JAR) { if (item.getReference() != null && item.getVariableBasedProperty() == null && !jarReferences.contains(item.getReference())) { //TODO reference is null for not yet persisted items. // there seems to be no way to generate a reference string without actually // creating and writing the property.. jarReferences.add(item.getReference()); } } } }
Example 3
Source File: CustomizerLibraries.java From netbeans with Apache License 2.0 | 6 votes |
private static void collectLibs(DefaultListModel model, List<String> libs, List<String> jarReferences) { for (int i = 0; i < model.size(); i++) { ClassPathSupport.Item item = (ClassPathSupport.Item) model.get(i); if (item.getType() == ClassPathSupport.Item.TYPE_LIBRARY) { if (!item.isBroken() && !libs.contains(item.getLibrary().getName())) { libs.add(item.getLibrary().getName()); } } if (item.getType() == ClassPathSupport.Item.TYPE_JAR) { if (item.getReference() != null && item.getVariableBasedProperty() == null && !jarReferences.contains(item.getReference())) { //TODO reference is null for not yet persisted items. // there seems to be no way to generate a reference string without actually // creating and writing the property.. jarReferences.add(item.getReference()); } } } }
Example 4
Source File: CodeCompletionPanel.java From netbeans with Apache License 2.0 | 6 votes |
private void updateExcluder(JList list) { DefaultListModel model = (DefaultListModel) list.getModel(); StringBuilder builder = new StringBuilder(); for (int i = 0 ; i < model.size() ; i++) { String entry = (String) model.getElementAt(i); if (builder.length() > 0) { builder.append(","); //NOI18N } builder.append(entry); } String pref; if (list == javaCompletionExcludeJlist) pref = JAVA_COMPLETION_BLACKLIST; else if (list == javaCompletionIncludeJlist) pref = JAVA_COMPLETION_WHITELIST; else throw new RuntimeException(list.getName()); preferences.put(pref, builder.toString()); }
Example 5
Source File: CodeCompletionPanel.java From netbeans with Apache License 2.0 | 6 votes |
private void javaCompletionExcluderDialogOkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderDialogOkButtonActionPerformed JList list = getSelectedExcluderList(); String text = javaCompletionExcluderDialogTextField.getText(); DefaultListModel model = (DefaultListModel) list.getModel(); int index = model.size(); if (javaExcluderEditing != null){ // if this was an "edit" rather than "add", then remove the old entry first index = model.indexOf(javaExcluderEditing); model.remove(index); javaExcluderEditing = null; } String[] entries = text.split(","); // NOI18N for (String entry : entries) { // strip zero width spaces entry = entry.replaceAll("\u200B", ""); // NOI18N entry = entry.trim(); if (entry.length() != 0 && entry.matches(JAVA_FQN_REGEX)){ model.insertElementAt(entry, index); index++; } } updateExcluder(list); javaCompletionExcluderDialog2.setVisible(false); javaCompletionExcluderDialogTextField.setText(null); }
Example 6
Source File: FolderList.java From netbeans with Apache License 2.0 | 6 votes |
private void addFiles (final File[] toAddArr, final Set<? super File> invalidRoots) { final int[] indecesToSelect = new int[toAddArr.length]; final DefaultListModel model = (DefaultListModel)this.roots.getModel(); final File[] relatedFolders = this.relatedFolderList == null ? new File[0] : this.relatedFolderList.getFiles(); for (int i=0, index=model.size(); i<toAddArr.length; i++) { File normalizedFile = toAddArr[i]; if (!isValidRoot(normalizedFile, relatedFolders, this.projectFolder)) { invalidRoots.add (normalizedFile); } else { int pos = model.indexOf (normalizedFile); if (pos == -1) { model.addElement (normalizedFile); indecesToSelect[i] = index; } else { indecesToSelect[i] = pos; } index++; } } this.roots.setSelectedIndices(indecesToSelect); this.firePropertyChange(PROP_FILES, null, null); }
Example 7
Source File: CustomizerCompile.java From netbeans with Apache License 2.0 | 5 votes |
private void removeProcessorButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeProcessorButtonActionPerformed DefaultListModel model = (DefaultListModel) annotationProcessorsList.getModel(); int[] indices = annotationProcessorsList.getSelectedIndices(); for (int i = indices.length - 1 ; i >= 0 ; i--) { model.remove(indices[i]); } if (!model.isEmpty()) { // Select reasonable item int selectedIndex = indices[indices.length - 1] - indices.length + 1; if (selectedIndex > model.size() - 1) { selectedIndex = model.size() - 1; } annotationProcessorsList.setSelectedIndex(selectedIndex); } }
Example 8
Source File: CheckListBox.java From nextreports-designer with Apache License 2.0 | 5 votes |
public void setSelected(boolean b) { DefaultListModel model = (DefaultListModel) this.getModel(); int size = model.size(); for (int i = 0; i < size; i++) { CheckListItem item = (CheckListItem) model.getElementAt(i); item.setSelected(b); } repaint(); }
Example 9
Source File: TroopFilterDialog.java From dsworkbench with Apache License 2.0 | 5 votes |
private void fireSaveFilterSettingsEvent(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_fireSaveFilterSettingsEvent String setName = jNewFilterName.getText(); DefaultListModel filterModel = (DefaultListModel) jFilterList.getModel(); if (setName == null || setName.length() == 0) { JOptionPaneHelper.showInformationBox(this, "Bitte einen Namen für das neue Filterset angeben", "Information"); return; } if (filterModel.getSize() == 0) { JOptionPaneHelper.showInformationBox(this, "Ein Filterset muss mindestens einen Eintrag enthalten", "Information"); return; } if (filterSets.get(setName) != null) { if (JOptionPaneHelper.showQuestionConfirmBox(this, "Das Filterset '" + setName + "' existiert bereits.\nMöchtest du es überschreiben?", "Bestätigung", "Nein", "Ja") != JOptionPane.OK_OPTION) { return; } } StringBuilder b = new StringBuilder(); b.append(setName).append(","); List<TroopFilterElement> elements = new LinkedList<>(); for (int j = 0; j < filterModel.size(); j++) { TroopFilterElement elem = (TroopFilterElement) filterModel.get(j); elements.add(new TroopFilterElement(elem.getUnit(), elem.getMin(), elem.getMax())); } filterSets.put(setName, elements); updateFilterSetList(); saveFilterSets(); }
Example 10
Source File: PrefManager.java From tda with GNU Lesser General Public License v2.1 | 5 votes |
/** * Populates the cached categories using a new list of categories. * * @param categories * populated object of {@link CustomCategory} objects */ private void setCategoryCache(DefaultListModel categories) { // remove existing categories this.cachedCategories.clear(); for (int f = 0; f < categories.size(); f++) { this.cachedCategories.add(categories.get(f)); } }
Example 11
Source File: LoadDistribution.java From ganttproject with GNU General Public License v3.0 | 5 votes |
private void processDaysOff(HumanResource resource) { DefaultListModel daysOff = resource.getDaysOff(); if (daysOff != null) { for (int l = 0; l < daysOff.size(); l++) { processDayOff((GanttDaysOff) daysOff.get(l)); } } }
Example 12
Source File: CheckListBox.java From nextreports-designer with Apache License 2.0 | 5 votes |
public void setSelected(String label, boolean b) { DefaultListModel model = (DefaultListModel) this.getModel(); for (int i = 0; i < model.size(); i++) { CheckListItem item = (CheckListItem) (model.getElementAt(i)); if (item.getText().equals(label)) { setSelected(i, b); return; } } }
Example 13
Source File: CustomizerLibraries.java From netbeans with Apache License 2.0 | 5 votes |
private void updateJars(DefaultListModel model) { for (int i = 0; i < model.size(); i++) { ClassPathSupport.Item item = (ClassPathSupport.Item) model.get(i); if (item.getType() == ClassPathSupport.Item.TYPE_JAR) { if (item.getReference() != null) { item.updateJarReference(uiProperties.getProject().getAntProjectHelper()); } } } }
Example 14
Source File: JCheckBoxList.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") public java.util.List getCheckedItems() { java.util.List list = new java.util.ArrayList(); DefaultListModel dlm = (DefaultListModel) getModel(); for (int i = 0; i < dlm.size(); ++i) { Object obj = getModel().getElementAt(i); if (obj instanceof JCheckBox) { JCheckBox checkbox = (JCheckBox) obj; if (checkbox.isSelected()) { list.add(checkbox); } } } return list; }
Example 15
Source File: ChangesetPickerPanel.java From netbeans with Apache License 2.0 | 5 votes |
private void applyFilter () { HgLogMessage selectedRevision = getSelectedRevision(); DefaultListModel targetsModel = new DefaultListModel(); targetsModel.removeAllElements(); HgLogMessage toSelectRevision = null; String filter = txtFilter.getText(); synchronized (LOCK) { for (HgLogMessage message : messages) { if (applies(filter, message)) { if (selectedRevision != null && message.getCSetShortID().equals(selectedRevision.getCSetShortID())) { toSelectRevision = message; } else if (parentRevision != null && message.getCSetShortID().equals(parentRevision.getCSetShortID())) { toSelectRevision = message; } targetsModel.addElement(message); } } } if (!Arrays.equals(targetsModel.toArray(), ((DefaultListModel) revisionsComboBox.getModel()).toArray())) { revisionsComboBox.setModel(targetsModel); if (toSelectRevision != null) { revisionsComboBox.setSelectedValue(toSelectRevision, true); } else if (targetsModel.size() > 0) { revisionsComboBox.setSelectedIndex(0); } } }
Example 16
Source File: CustomizerLibraries.java From netbeans with Apache License 2.0 | 5 votes |
private void updateJars(DefaultListModel model) { for (int i = 0; i < model.size(); i++) { ClassPathSupport.Item item = (ClassPathSupport.Item) model.get(i); if (item.getType() == ClassPathSupport.Item.TYPE_JAR) { if (item.getReference() != null) { item.updateJarReference(uiProperties.getProject().getAntProjectHelper()); } } } }
Example 17
Source File: TroopFilterDialog.java From dsworkbench with Apache License 2.0 | 5 votes |
public Village[] getIgnoredVillages(Village[] pVillageToFilter) { List<Village> ignored = new LinkedList<>(); //update list if filter is enabled DefaultListModel filterModel = (DefaultListModel) jFilterList.getModel(); for (Village v : pVillageToFilter) { boolean villageAllowed = false; //go through all rows in attack table and get source village for (int j = 0; j < filterModel.size(); j++) { //check for all filters if villag is allowed if (!((TroopFilterElement) filterModel.get(j)).allowsVillage(v)) { if (jStrictFilter.isSelected()) { //village is not allowed, add to remove list if strict filtering is enabled ignored.add(v); } } else { villageAllowed = true; if (!jStrictFilter.isSelected()) { break; } } } if (!jStrictFilter.isSelected()) { //if strict filtering is disabled remove village only if it is not allowed if (!villageAllowed) { ignored.add(v); } } } return ignored.toArray(new Village[ignored.size()]); }
Example 18
Source File: PrefManager.java From tda with GNU Lesser General Public License v2.1 | 5 votes |
/** * Populates the cached filters using a new list of filters. * * @param filters updated list of filters */ private void setFilterCache(DefaultListModel filters) { // remove existing filters this.cachedFilters.clear(); for (int f = 0; f < filters.size(); f++) { this.cachedFilters.add(filters.get(f)); } }
Example 19
Source File: JListFilterDecorator.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
private static <T> List<T> getItems(DefaultListModel<T> model) { List<T> list = new ArrayList<>(); for (int i = 0; i < model.size(); i++) { list.add(model.elementAt(i)); } return list; }
Example 20
Source File: CheckListBox.java From nextreports-designer with Apache License 2.0 | 5 votes |
public void setEnabledAll(boolean b) { DefaultListModel model = (DefaultListModel) this.getModel(); int size = model.size(); for (int i = 0; i < size; i++) { CheckListItem item = (CheckListItem) model.getElementAt(i); item.setEnabled(b); } repaint(); }