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; } } }
private void init(Collection dataSourceQueryChoosers) { // Some components may be shared, so use a Set. [Jon Aquino] HashSet components = new HashSet(); for (Iterator i = dataSourceQueryChoosers.iterator(); i.hasNext(); ) { DataSourceQueryChooser chooser = (DataSourceQueryChooser) i.next(); formatComboBox.addItem(chooser); components.add(chooser.getComponent()); } int j = 0; for (Iterator i = components.iterator(); i.hasNext(); ) { Component component = (Component) i.next(); // Can't use DataSourceQueryChooser name because several DataSourceQueryChoosers may // share a component (e.g. FileDataSourceQueryChooser). [Jon Aquino] j++; componentToNameMap.put( component, I18N.get("datasource.DataSourceQueryChooserDialog.card") + " " + j); mainPanel.add(component, name(component)); } }