Java Code Examples for javax.swing.ComboBoxModel#getSize()

The following examples show how to use javax.swing.ComboBoxModel#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: SampleRepositoryConfigPanel.java    From jeddict with Apache License 2.0 6 votes vote down vote up
@Override
public void init(String _package, Project project, SourceGroup sourceGroup) {
    pref = ProjectUtils.getPreferences(project, SampleRepositoryConfigData.class, true);
    if (sourceGroup != null) {
        packageCombo.setRenderer(PackageView.listRenderer());
        ComboBoxModel model = PackageView.createListView(sourceGroup);
        if (model.getSize() > 0) {
            model.setSelectedItem(model.getElementAt(0));
        }
        packageCombo.setModel(model);
        addChangeListener(packageCombo);
        if (StringUtils.isBlank(_package)) {
            setPackage(DEFAULT_PACKAGE);
        } else {
            setPackage(_package + '.' + DEFAULT_PACKAGE);
        }
    }
    addChangeListener(prefixField);
    addChangeListener(suffixField);
}
 
Example 2
Source File: AllLocalProductsRepositoryPanel.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
public void addMissionIfMissing(String mission) {
    ComboBoxModel<String> missionsModel = this.remoteMissionsComboBox.getModel();
    boolean foundMission = false;
    for (int i = 0; i < missionsModel.getSize() && !foundMission; i++) {
        String existingMission = missionsModel.getElementAt(i);
        if (existingMission != null && existingMission.equalsIgnoreCase(mission)) {
            foundMission = true;
        }
    }
    if (!foundMission) {
        if (missionsModel.getSize() == 0) {
            this.remoteMissionsComboBox.addItem(null);
        }
        this.remoteMissionsComboBox.addItem(mission);
    }
}
 
Example 3
Source File: AllLocalProductsRepositoryPanel.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
public void addLocalRepositoryFolderIfMissing(LocalRepositoryFolder localRepositoryFolder) {
    ComboBoxModel<LocalRepositoryFolder> foldersModel = this.foldersComboBox.getModel();
    boolean foundFolder = false;
    for (int i = 0; i < foldersModel.getSize() && !foundFolder; i++) {
        LocalRepositoryFolder existingFolder = foldersModel.getElementAt(i);
        if (existingFolder != null && existingFolder.getId() == localRepositoryFolder.getId()) {
            foundFolder = true;
        }
    }
    if (!foundFolder) {
        if (foldersModel.getSize() == 0) {
            this.foldersComboBox.addItem(null);
        }
        this.foldersComboBox.addItem(localRepositoryFolder);
    }
}
 
Example 4
Source File: ScopePanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Change the selected scope to one with the specified id. If the id does
 * not exist, nothing is changed. When the id is from a CustomScopeProvider
 * and it returns an empty scope, the preferred scope is selected.
 *
 * @see ScopeProvider.CustomScopeProvider
 *
 * @param id the id of the scope to select
 */
public void selectScopeById(@NonNull String id) {
    ComboBoxModel m = scopeCombobox.getModel();

    for (int i = 0; i < m.getSize(); i++) {
        DelegatingScopeInformation sd = (DelegatingScopeInformation) m.getElementAt(i);

        if (sd.getId().equals(id)) {
            if (sd instanceof ScopeProvider.CustomScopeProvider) {
                Scope s = sd.getScope();
                if (s != null
                        && s.getFiles().isEmpty()
                        && s.getFolders().isEmpty()
                        && s.getSourceRoots().isEmpty()) {
                    selectPreferredScope();
                    return;
                }
            }
            scopeCombobox.setSelectedItem(sd);
            return;
        }
    }
}
 
Example 5
Source File: SettingsPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Selects a given template.
 *
 * @param  templatePath  path of the template which should be selected;
 *                       may be <code>null</code> - then no item is selected
 */
void selectTemplate(String templatePath) {
    if (templatePath == null) {
        return;
    }
    
    ComboBoxModel model = cboTemplate.getModel();
    int itemsCount = model.getSize();
    
    if (itemsCount == 0) {
        return;
    }
    
    for (int i = 0; i < itemsCount; i++) {
        NamedObject namedObj = (NamedObject) model.getElementAt(i);
        FileObject template = (FileObject) namedObj.object;
        if (template.getPath().equals(templatePath)) {
            cboTemplate.setSelectedIndex(i);
            return;
        }
    }
}
 
Example 6
Source File: ColorPaletteChooser.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private ColorPaletteDef findColorPalette(String name) {
    final ComboBoxModel<ColorPaletteWrapper> model = getModel();
    for (int i = 0; i < model.getSize(); i++) {
        final ColorPaletteWrapper paletteWrapper = model.getElementAt(i);
        if (paletteWrapper.name.equals(name)) {
            return paletteWrapper.cpd;
        }
    }
    return null;
}
 
Example 7
Source File: UpdateSummaryTable.java    From bigtable-sql with Apache License 2.0 5 votes vote down vote up
private void setModel(JComboBox box, ArtifactAction... actions) {
	ComboBoxModel oldModel = box.getModel();
	box.setModel(getComboBoxModel(actions));
	if (oldModel.getSize() != actions.length) {
		box.firePropertyChange("itemCount", oldModel.getSize(), actions.length);
	}
}
 
Example 8
Source File: AllLocalProductsRepositoryPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
public void deleteLocalRepositoryFolder(LocalRepositoryFolder localRepositoryFolderToRemove) {
    ComboBoxModel<LocalRepositoryFolder> foldersModel = this.foldersComboBox.getModel();
    for (int i = 0; i < foldersModel.getSize(); i++) {
        LocalRepositoryFolder existingFolder = foldersModel.getElementAt(i);
        if (existingFolder != null && existingFolder.getId() == localRepositoryFolderToRemove.getId()) {
            this.foldersComboBox.removeItemAt(i);
            break;
        }
    }
    if (foldersModel.getSize() == 1 && foldersModel.getElementAt(0) == null) {
        this.foldersComboBox.removeItemAt(0);
    }
}
 
Example 9
Source File: JaxRsConfigurationPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateSourceGroupPackages() {
    SourceGroup sg = getSourceGroup();
    if (sg != null) {
        ComboBoxModel model = PackageView.createListView(sg);
        if (model.getSelectedItem()!= null && model.getSelectedItem().toString().startsWith("META-INF")
                && model.getSize() > 1) { // NOI18N
            model.setSelectedItem(model.getElementAt(1));
        }
        String oldValue = ((JTextComponent)restAppPackage.getEditor().getEditorComponent()).getText();
        restAppPackage.setModel(model);
        if (oldValue.length() > 0) {
            ((JTextComponent)restAppPackage.getEditor().getEditorComponent()).setText(oldValue);
        }
    }
}
 
Example 10
Source File: DesignerTablePanel.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
private boolean hasEmpty(ComboBoxModel model) {
	int size = model.getSize();
	for (int i=0; i<size; i++) {
		if ("".equals(model.getElementAt(i))) {
			return true;
		}
	}
	return false;
}
 
Example 11
Source File: ScopePanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void selectPreferredScope() {
    ComboBoxModel m = scopeCombobox.getModel();

    for (int i = 0; i < m.getSize(); i++) {
        DelegatingScopeInformation sd = (DelegatingScopeInformation) m.getElementAt(i);

        if (sd.getPosition() >= 0) {
            scopeCombobox.setSelectedItem(sd);
            return;
        }
    }
}
 
Example 12
Source File: JFileChooserOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private int findFileTypeIndex(String fileType, StringComparator comparator) {
    ComboBoxModel<?> cbModel = getFileTypesCombo().getModel();
    for (int i = 0; i < cbModel.getSize(); i++) {
        if (comparator.equals(((FileFilter) cbModel.getElementAt(i)).getDescription(),
                fileType)) {
            return i;
        }
    }
    return -1;
}
 
Example 13
Source File: RunAsRemoteWeb.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void manageRemoteConnectionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manageRemoteConnectionButtonActionPerformed
    if (RemoteConnections.get().openManager((RemoteConfiguration) remoteConnectionComboBox.getSelectedItem())) {
        populateRemoteConnectionComboBox();
        // # 162233
        String selected = null;
        ComboBoxModel model = remoteConnectionComboBox.getModel();
        if (model.getSize() == 1) {
            selected = ((RemoteConfiguration) model.getElementAt(0)).getName();
        }
        selectRemoteConnection(selected);
        updateRemoteConnectionHint();
    }
}
 
Example 14
Source File: CDebuggerComboBox.java    From binnavi with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new debugger combobox.
 *
 * @param model The list model used to fill the combobox.
 */
public CDebuggerComboBox(final ComboBoxModel<CDebuggerTemplateWrapper> model) {
  super(model);

  if (model != null && model.getSize() != 0) {
    setSelectedIndex(0);
  }
}
 
Example 15
Source File: FunctionField.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the function list.
 *
 * @return the function list
 */
protected List<String> getFunctionList() {
    List<String> functionList = new ArrayList<>();

    ComboBoxModel<String> model = functionComboBox.getModel();
    for (int i = 0; i < model.getSize(); i++) {
        functionList.add(model.getElementAt(i));
    }

    return functionList;
}
 
Example 16
Source File: LaunchPanel.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
public void postInit() {
    // Plugable browsers (like JxBrowser) can be added after this add-ons
    // options have been loaded
    String def = this.getExtQuickStart().getQuickStartParam().getLaunchDefaultBrowser();
    if (def == null || def.length() == 0) {
        // no default
        return;
    }
    ComboBoxModel<ProvidedBrowserUI> model = this.getBrowserComboBox().getModel();
    for (int idx = 0; idx < model.getSize(); idx++) {
        ProvidedBrowserUI el = model.getElementAt(idx);
        if (el.getName().equals(def)) {
            model.setSelectedItem(el);
            break;
        }
    }

    JPanel hudPanel = new QuickStartBackgroundPanel();
    hudPanel.add(getHudCheckbox(), LayoutHelper.getGBC(0, 0, 1, 0));
    hudPanel.add(getHudIsInScopeOnly(), LayoutHelper.getGBC(1, 0, 1, 0));
    hudPanel.add(new JLabel(), LayoutHelper.getGBC(1, 0, 2, 1.0));

    this.getContentPanel().add(hudPanel, LayoutHelper.getGBC(1, hudOffset, 3, 0.25D));

    PlugableHud hud = getExtQuickStart().getHudProvider();
    if (hud != null) {
        // Build up a model just with the browsers supported by the HUD
        List<ProvidedBrowserUI> hudBrowsers = new ArrayList<ProvidedBrowserUI>();
        List<String> browserIds = hud.getSupportedBrowserIds();
        for (int i = 0; i < allBrowserModel.getSize(); i++) {
            ProvidedBrowserUI browser = allBrowserModel.getElementAt(i);
            if (browserIds.contains(browser.getBrowser().getProviderId())) {
                hudBrowsers.add(browser);
            }
        }
        hudBrowserModel = new ProvidedBrowsersComboBoxModel(hudBrowsers);
        setBrowserOptions(this.getHudCheckbox().isSelected());
    }
}
 
Example 17
Source File: GenerateCodeDialog.java    From jeddict with Apache License 2.0 5 votes vote down vote up
private void setPackage(JComboBox packageCombo, String _package) {
    ComboBoxModel model = packageCombo.getModel();
    for (int i = 0; i < model.getSize(); i++) {
        if (model.getElementAt(i).toString().equals(_package)) {
            model.setSelectedItem(model.getElementAt(i));
            return;
        }
    }
    ((JTextComponent) packageCombo.getEditor().getEditorComponent()).setText(_package);
}
 
Example 18
Source File: AllLocalProductsRepositoryPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
public List<LocalRepositoryFolder> getLocalRepositoryFolders() {
    ComboBoxModel<LocalRepositoryFolder> foldersModel = this.foldersComboBox.getModel();
    List<LocalRepositoryFolder> result = new ArrayList<>(foldersModel.getSize());
    for (int i = 0; i < foldersModel.getSize(); i++) {
        LocalRepositoryFolder existingFolder = foldersModel.getElementAt(i);
        if (existingFolder != null) {
            result.add(existingFolder);
        }
    }
    return result;
}
 
Example 19
Source File: LookAndFeelsComboBox.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
public int getIndexOfLookAndFeel( String className ) {
	ComboBoxModel<LookAndFeelInfo> model = getModel();
	int size = model.getSize();
	for( int i = 0; i < size; i++ ) {
		if( className.equals( model.getElementAt( i ).getClassName() ) )
			return i;
	}
	return -1;
}
 
Example 20
Source File: ActiveBagContentControlPanel.java    From jclic with GNU General Public License v2.0 4 votes vote down vote up
public void setActiveBagContent(ActiveBagContent abc, ActiveBagContent altAbc) {
  this.abc = abc;
  this.altAbc = altAbc;

  altNull = (altAbc == null);
  if (abc != null && !simpleMode)
    abc.checkCells();
  if (altAbc != null && !simpleMode)
    altAbc.checkCells();

  altChk.setSelected(!altNull);
  altChk.setEnabled(abc != null);
  toggleAlt.setSelected(false);
  toggleAlt.setEnabled(!altNull);
  imgButton.setMediaBagEditor(parent.mediaBagEditor);
  imgButton.setImgName(abc != null ? abc.imgName : null);
  imgButton.setEnabled(abc != null);
  boxBaseButton.setBoxBase(abc != null ? abc.bb : null);
  parent.abcpp.setActiveBagContent(visualIndex, abc, altAbc, null);
  boxBaseButton.setPreview(parent.abcpp.getAbstractBox(visualIndex));
  boxBaseButton.setEnabled(abc != null);
  Shaper sh = (abc != null ? abc.getShaper() : null);
  ComboBoxModel model = shaperCombo.getModel();
  int modelSize = model.getSize();
  int i = -1;
  if (sh != null) {
    String s = sh.getClassName();
    for (i = 0; i < modelSize; i++) {
      TripleString ts = (TripleString) model.getElementAt(i);
      if (s.equals(ts.getClassName()))
        break;
    }
  }
  shaperCombo.setSelectedIndex(i < modelSize ? i : -1);
  shaperCombo.setEnabled(abc != null);
  shaperEditBtn.setEnabled(sh != null && sh.getEditorPanelClassName() != null);
  nColsEdit.setValue(sh != null ? sh.getNumColumns() : 1);
  nColsEdit.setEnabled(abc != null);
  nRowsEdit.setValue(sh != null ? sh.getNumRows() : 1);
  nRowsEdit.setEnabled(abc != null);
  widthEdit.setValue(abc != null ? (int) abc.w : 30);
  widthEdit.setEnabled(abc != null);
  heightEdit.setValue(abc != null ? (int) abc.h : 20);
  heightEdit.setEnabled(abc != null);
  borderChk.setSelected(abc != null ? abc.border : false);
  borderChk.setEnabled(abc != null);
}