@TestOnly public String[] getVisibleFiles() { final ComboBoxModel model = myFileChooser.getModel(); String[] result = new String[model.getSize()]; for (int i = 0; i < model.getSize(); i++) { FileDescriptor o = (FileDescriptor) model.getElementAt(i); result[i] = o.getPresentableName(o.myFile.getVirtualFile()); } return result; }
/** * Find the class for the projection * * @param proj projection * @return corresponding ProjectionClass (or null if not found) */ private ProjectionClass findProjectionClass(Projection proj) { Class want = proj.getClass(); ComboBoxModel projClassList = projClassCB.getModel(); for (int i = 0; i < projClassList.getSize(); i++) { ProjectionClass pc = (ProjectionClass) projClassList.getElementAt(i); if (want.equals(pc.projClass)) { return pc; } } return null; }
private void initUI() { SortedMap<String, SourceIdentifier> stats = mainFrame.getAvailableStatistics(); List<WrappedSourceIdentifier> wrappedSources = new ArrayList<WrappedSourceIdentifier>(stats.size() + 1); wrappedSources.add(new WrappedSourceIdentifier("Global", new SourceIdentifier("global"))); for (Map.Entry<String, SourceIdentifier> current : stats.entrySet()) { WrappedSourceIdentifier wrapped = new WrappedSourceIdentifier(current.getKey(), current.getValue()); wrappedSources.add(wrapped); } Object[] newSourcesArray = wrappedSources.toArray(); if (!Arrays.equals(previousSourcesArray, newSourcesArray)) { previousSourcesArray = newSourcesArray; DefaultComboBoxModel model = new DefaultComboBoxModel(newSourcesArray); sourcesComboBox.setModel(model); } int index = 0; if (sourceIdentifier != null) { ComboBoxModel model = sourcesComboBox.getModel(); for (int i = 0; i < model.getSize(); i++) { Object current = model.getElementAt(i); if (current instanceof WrappedSourceIdentifier) { WrappedSourceIdentifier wrapped = (WrappedSourceIdentifier) current; if (sourceIdentifier.getIdentifier().equals(wrapped.sourceIdentifier.getIdentifier())) { if (logger.isDebugEnabled()) logger.debug("Equal"); index = i; break; } else { if (logger.isDebugEnabled()) { logger.debug("Not equal: {} != {}", sourceIdentifier, wrapped.sourceIdentifier); } } } else { if (logger.isWarnEnabled()) logger.warn("Not instanceof WrappedSourceIdentifier"); } } } sourcesComboBox.setSelectedIndex(index); }