Java Code Examples for javax.swing.ListModel#getSize()
The following examples show how to use
javax.swing.ListModel#getSize() .
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: AbstractDumpParser.java From tda with GNU Lesser General Public License v2.1 | 6 votes |
/** * check threads in given thread dump and add appropriate * custom categories (if any defined). * @param threadDump the thread dump info object. */ public void addCustomCategories(DefaultMutableTreeNode threadDump) { ThreadDumpInfo tdi = (ThreadDumpInfo) threadDump.getUserObject(); Category threads = tdi.getThreads(); ListModel cats = PrefManager.get().getCategories(); for(int i = 0; i < cats.getSize(); i++) { Category cat = new TableCategory(((CustomCategory) cats.getElementAt(i)).getName(), IconFactory.CUSTOM_CATEGORY); for(int j = 0; j < threads.getNodeCount(); j++) { Iterator filterIter = ((CustomCategory) cats.getElementAt(i)).iterOfFilters(); boolean matches = true; ThreadInfo ti = (ThreadInfo) ((DefaultMutableTreeNode) threads.getNodeAt(j)).getUserObject(); while (matches && filterIter.hasNext()) { Filter filter = (Filter) filterIter.next(); matches = filter.matches(ti, true); } if(matches) { cat.addToCatNodes(new DefaultMutableTreeNode(ti)); } } if(cat.getNodeCount() > 0) { cat.setName(cat.getName() + " (" + cat.getNodeCount() + " Threads overall)"); threadDump.add(new DefaultMutableTreeNode(cat)); } } }
Example 2
Source File: ReplaySearch.java From sc2gears with Apache License 2.0 | 6 votes |
/** * Saves the replay sources to the specified replay source file. * @param replaySource replay source file to save to */ private void saveReplaySourceFile( final File replaySource ) { try ( final PrintWriter output = new PrintWriter( replaySource, "UTF-8" ) ) { final ListModel< File > model = sourceList.getModel(); final int size = model.getSize(); for ( int i = 0; i < size; i++ ) output.println( model.getElementAt( i ) ); output.flush(); MainFrame.INSTANCE.refreshNavigationTree(); GuiUtils.showInfoDialog( Language.getText( "module.repSearch.tab.source.repSourceSaved" ) ); } catch ( final Exception e ) { e.printStackTrace(); GuiUtils.showErrorDialog( Language.getText( "module.repSearch.tab.source.failedToSaveRepSource" ) ); } }
Example 3
Source File: WebSocketUiHelper.java From zap-extensions with Apache License 2.0 | 6 votes |
public void setSelectedOpcodes(List<String> opcodes) { JList<String> opcodesList = getOpcodeList(); if (opcodes == null || opcodes.contains(SELECT_ALL_OPCODES)) { opcodesList.setSelectedIndex(0); } else { int j = 0; int[] selectedIndices = new int[opcodes.size()]; ListModel<String> model = opcodesList.getModel(); for (int i = 0; i < model.getSize(); i++) { String item = model.getElementAt(i); if (opcodes.contains(item)) { selectedIndices[j++] = i; } } opcodesList.setSelectedIndices(selectedIndices); } }
Example 4
Source File: CategoryPanelFormatters.java From netbeans with Apache License 2.0 | 6 votes |
@Override public boolean isChanged() { ListModel formattersModel = formattersList.getModel(); VariablesFormatter[] formatters = new VariablesFormatter[formattersModel.getSize()]; for (int i = 0; i < formatters.length; i++) { formatters[i] = (VariablesFormatter) formattersModel.getElementAt(i); } VariablesFormatter[] saved = VariablesFormatter.loadFormatters(); if(saved == null) { return false; } if(saved.length != formatters.length) { return true; } for (int i = 0; i < saved.length; i++) { VariablesFormatter savedFormatter = saved[i]; VariablesFormatter currentFormatter = (VariablesFormatter) formattersModel.getElementAt(i); if(!areVariablesFormattersEqual(savedFormatter, currentFormatter)) { return true; } } return false; }
Example 5
Source File: JdbcDataSourceDialog.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected void setScriptingLanguage( final String lang, final JComboBox languageField ) { if ( lang == null ) { languageField.setSelectedItem( null ); return; } final ListModel model = languageField.getModel(); for ( int i = 0; i < model.getSize(); i++ ) { final ScriptEngineFactory elementAt = (ScriptEngineFactory) model.getElementAt( i ); if ( elementAt == null ) { continue; } if ( elementAt.getNames().contains( lang ) ) { languageField.setSelectedItem( elementAt ); return; } } }
Example 6
Source File: BeansTestCase.java From netbeans with Apache License 2.0 | 6 votes |
public boolean openDialog(EditorOperator operator) { operator.pressKey(KeyEvent.VK_INSERT, KeyEvent.ALT_DOWN_MASK); JDialogOperator jdo = new JDialogOperator(); JListOperator list = new JListOperator(jdo); ListModel lm = list.getModel(); for (int i = 0; i < lm.getSize(); i++) { CodeGenerator cg = (CodeGenerator) lm.getElementAt(i); if(cg.getDisplayName().equals("Add Property...")) { list.setSelectedIndex(i); jdo.pushKey(KeyEvent.VK_ENTER); new EventTool().waitNoEvent(250); return true; } } fail("Dialog not found"); return false; }
Example 7
Source File: UnitType.java From freecol with GNU General Public License v2.0 | 6 votes |
@Override public int getMaximumIndex(Colony colony, JList<BuildableType> buildQueueList, int UNABLE_TO_BUILD) { ListModel<BuildableType> buildQueue = buildQueueList.getModel(); final int buildQueueLastPos = buildQueue.getSize(); boolean canBuild = false; if (colony.canBuild(this)) { canBuild = true; } // does not depend on anything, nothing depends on it // can be built at any time if (canBuild) return buildQueueLastPos; // check for building in queue that allows builting this unit for (int index = 0; index < buildQueue.getSize(); index++) { BuildableType toBuild = buildQueue.getElementAt(index); if (toBuild == this) continue; if (toBuild.hasAbility(Ability.BUILD, this)) { return buildQueueLastPos; } } return UNABLE_TO_BUILD; }
Example 8
Source File: BuildingType.java From freecol with GNU General Public License v2.0 | 6 votes |
@Override public int getMinimumIndex(Colony colony, JList<BuildableType> buildQueueList, int UNABLE_TO_BUILD) { ListModel<BuildableType> buildQueue = buildQueueList.getModel(); BuildingType upgradesFrom = this.getUpgradesFrom(); if (upgradesFrom == null) return 0; Building building = colony.getBuilding(this); BuildingType buildingType = (building == null) ? null : building.getType(); if (buildingType == upgradesFrom) return 0; for (int index = 0; index < buildQueue.getSize(); index++) { if (upgradesFrom.equals(buildQueue.getElementAt(index))) { return index + 1; } } return UNABLE_TO_BUILD; }
Example 9
Source File: PmdDataSourceEditor.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private void setSelectedQuery( final String query ) { final ListModel listModel = queryNameList.getModel(); for ( int i = 0; i < listModel.getSize(); i++ ) { final DataSetQuery dataSet = (DataSetQuery) listModel.getElementAt( i ); if ( dataSet.getQueryName().equals( query ) ) { queryNameList.setSelectedValue( dataSet, true ); break; } } }
Example 10
Source File: FontChooserPanel.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Initializes the contents of the dialog from the given font * object. * * @param font the font from which to read the properties. */ public void setSelectedFont( Font font) { if (font == null) { throw new NullPointerException(); } this.bold.setSelected(font.isBold()); this.italic.setSelected(font.isItalic()); String fontName = font.getName(); ListModel model = this.fontlist.getModel(); this.fontlist.clearSelection(); for (int i = 0; i < model.getSize(); i++) { if (fontName.equals(model.getElementAt(i))) { this.fontlist.setSelectedIndex(i); break; } } String fontSize = String.valueOf(font.getSize()); model = this.sizelist.getModel(); this.sizelist.clearSelection(); for (int i = 0; i < model.getSize(); i++) { if (fontSize.equals(model.getElementAt(i))) { this.sizelist.setSelectedIndex(i); break; } } }
Example 11
Source File: ClasspathCustomEditorOperator.java From netbeans with Apache License 2.0 | 5 votes |
/** returns complete class path from editor * @return String[] class paths */ public String[] getClasspathValue() { ArrayList<String> data=new ArrayList<String>(); ListModel model=lstClasspath().getModel(); for (int i=0; i<model.getSize(); i++) { data.add(model.getElementAt(i).toString()); } return data.toArray(new String[data.size()]); }
Example 12
Source File: BaseTextListComp.java From scelight with Apache License 2.0 | 5 votes |
@Override public void actionPerformed( final ActionEvent event ) { final ListModel< String > model = textList.getModel(); final int length = model.getSize(); final StringBuilder sb = new StringBuilder( length * 40 ); for ( int i = 0; i < length; i++ ) sb.append( model.getElementAt( i ) ).append( '\n' ); Utils.copyToClipboard( sb.toString() ); }
Example 13
Source File: PsychoPanel2.java From psychoPATH with GNU General Public License v3.0 | 5 votes |
private void breakupHexFormatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_breakupHexFormatActionPerformed if(editorFormat=="HEX") return; breakupHexFormat.setSelected(true); breakupASCIIFormat.setSelected(false); editorFormat="HEX"; // convert all from ASCII to HEX ListModel breakupListModel = breakupList.getModel(); String newValues[] = new String[breakupListModel.getSize()]; for(int i=0;i<breakupListModel.getSize();i++) { String currval=breakupListModel.getElementAt(i).toString(); String newVal=""; for(int j=0;j<currval.length();j++) { char currChar = currval.charAt(j); String hex = Integer.toHexString(currChar); newVal+=hex; } newValues[i]=newVal; // now, we convert it from ASCII to HEX //brutDocrootSuffixes.add(suffix); } breakupList.setListData(newValues); }
Example 14
Source File: BreakpointNestedGroupsDialog.java From netbeans with Apache License 2.0 | 5 votes |
String[] getDisplayedGroups() { ListModel model = displayedGroupsList.getModel(); int n = model.getSize(); String[] groupNames = new String[n]; for (int i = 0; i < n; i++) { GroupElement ge = (GroupElement) model.getElementAt(i); groupNames[i] = ge.getGroup().name(); } return groupNames; }
Example 15
Source File: EditWhereColsPanel.java From bigtable-sql with Apache License 2.0 | 5 votes |
/** * Move selected fields from "used" to "not used" */ private void moveToNotUsed() { // get the values from the "not use" list and convert to sorted set ListModel notUseColsModel = notUseColsList.getModel(); SortedSet<String> notUseColsSet = new TreeSet<String>(); for (int i=0; i<notUseColsModel.getSize(); i++) notUseColsSet.add((String)notUseColsModel.getElementAt(i)); // get the values from the "use" list ListModel useColsModel = useColsList.getModel(); // create an empty set for the "use" list SortedSet<Object> useColsSet = new TreeSet<Object>(); // for each element in the "use" set, if selected then add to "not use", // otherwise add to new "use" set for (int i=0; i<useColsModel.getSize(); i++) { String colName = (String)useColsModel.getElementAt(i); if (useColsList.isSelectedIndex(i)) notUseColsSet.add(colName); else useColsSet.add(colName); } useColsList.setListData(useColsSet.toArray()); notUseColsList.setListData(notUseColsSet.toArray()); }
Example 16
Source File: AbbreviationsAddRemovePerformer.java From netbeans with Apache License 2.0 | 5 votes |
public static void useHint(final EditorOperator editor, final int lineNumber, String hintPrefix) throws InterruptedException { Object annots = new Waiter(new Waitable() { public Object actionProduced(Object arg0) { Object[] annotations = editor.getAnnotations(lineNumber); if (annotations.length == 0) { return null; } else { return annotations; } } public String getDescription() { return "Waiting for annotations for current line"; } }).waitAction(null); editor.pressKey(KeyEvent.VK_ENTER, KeyEvent.ALT_DOWN_MASK); JListOperator jlo = new JListOperator(MainWindowOperator.getDefault()); int index = -1; ListModel model = jlo.getModel(); for (int i = 0; i < model.getSize(); i++) { Object element = model.getElementAt(i); String desc = getText(element); if (desc.startsWith(hintPrefix)) { index = i; } } assertTrue("Requested hint not found", index != -1); jlo.selectItem(index); jlo.pushKey(KeyEvent.VK_ENTER); }
Example 17
Source File: PeakSelectionComponent.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
public List<PeakSelection> getValue() { List<PeakSelection> items = Lists.newArrayList(); ListModel<PeakSelection> model = selectionList.getModel(); for (int i = 0; i < model.getSize(); i++) items.add(model.getElementAt(i)); return items; }
Example 18
Source File: BuildQueuePanel.java From freecol with GNU General Public License v2.0 | 5 votes |
private List<BuildableType> getBuildableTypes(JList<? extends BuildableType> list) { if (list == null) return Collections.<BuildableType>emptyList(); ListModel<? extends BuildableType> model = list.getModel(); List<BuildableType> result = new ArrayList<>(model.getSize()); for (int index = 0; index < model.getSize(); index++) { result.add(model.getElementAt(index)); } return result; }
Example 19
Source File: TableGeneratorPanel.java From netbeans with Apache License 2.0 | 5 votes |
private List<String> getAllColumns() { List<String> result = new ArrayList<>(); ListModel model = columnList.getModel(); for (int i = 0; i < model.getSize(); i++) { Object element = model.getElementAt(i); if (!(element instanceof Selectable)) { continue; } Selectable columnEl = (Selectable) element; result.add(columnEl.getDisplayName()); } return result; }
Example 20
Source File: TileLocationBrowserUI.java From pumpernickel with MIT License | 4 votes |
@Override protected void synchronizeDirectoryContents() { List<IOLocation> v = new ArrayList<IOLocation>(); ListModel model = browser.getListModel(); synchronized (model) { for (int a = 0; a < model.getSize(); a++) { IOLocation loc = (IOLocation) model.getElementAt(a); if (loc.isHidden() == false) v.add(loc); } } Collections.sort(v, getLocationComparator()); synchronized (threadsafeListModel) { threadsafeListModel.setAll(v); } // synchronize the selection if (adjustingModels > 0) return; adjustingModels++; try { IOLocation[] obj = browser.getSelectionModel().getSelection(); List<Integer> ints = new ArrayList<Integer>(); Rectangle visibleBounds = null; int[] indices; synchronized (threadsafeListModel) { for (int a = 0; a < obj.length; a++) { int k = threadsafeListModel.indexOf(obj[a]); if (k != -1) { ints.add(new Integer(k)); } } indices = new int[ints.size()]; for (int a = 0; a < ints.size(); a++) { indices[a] = (ints.get(a)).intValue(); } list.setSelectedIndices(indices); if (indices.length > 0) { visibleBounds = list.getCellBounds(indices[0], indices[0]); } } if (visibleBounds != null) { try { list.scrollRectToVisible(visibleBounds); } catch (RuntimeException e) { System.err.println("indices[0] = " + indices[0] + " out of:"); for (int a = 0; a < list.getModel().getSize(); a++) { System.err.println("\tlist[a] = " + list.getModel().getElementAt(a)); } throw e; } } } finally { adjustingModels--; } }