List of usage examples for javax.swing DefaultComboBoxModel addElement
public void addElement(E anObject)
From source file:org.fhaes.fhsamplesize.view.FHSampleSize.java
/** * Generate the SSIZAnalysisModel representing the data and parameters for this analysis. * //from www .j av a2 s. co m * @param model */ @SuppressWarnings({ "rawtypes", "unchecked" }) public void populateFromAnalysisModel(SSIZAnalysisModel model) { DefaultComboBoxModel combomodel = new DefaultComboBoxModel(); for (SegmentModel segment : model.getSegments()) combomodel.addElement(segment); cboSegment.setModel(combomodel); cboSegment.setEnabled(model.getSegments().size() > 1); // cboSegment.setSelectedIndex(segmentsDone); cboChartMetric.setEnabled(true); }
From source file:co.com.soinsoftware.hotelero.view.JFRoom.java
public void setCompanyModel() { this.companyList = this.companyController.select(); final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>(); model.addElement("Ninguna"); for (final Company company : this.companyList) { model.addElement(company.getName()); }// w w w . j a va 2 s .c o m this.jcbCompany.setModel(model); }
From source file:edu.ku.brc.specify.tools.schemalocale.FieldItemPanel.java
/** * @param webLinkDef/*from w ww. j a v a 2s .com*/ */ protected void setSelectedWebLink(final WebLinkDef webLinkDef) { DefaultComboBoxModel model = (DefaultComboBoxModel) webLinkCombo.getModel(); model.removeAllElements(); model.addElement(webLinkDefNone); int fndInx = 0; int index = 0; for (WebLinkDef wld : webLinkMgrCache.getWebLinkDefs(null)) { model.addElement(wld); if (webLinkDef == wld) { setHasChanged(true); webLinkCombo.setSelectedIndex(index); fndInx = index; break; } index++; } if (fndInx > 0) { webLinkCombo.setSelectedItem(webLinkDef); setHasChanged(true); } webLinkCombo.setEnabled(webLinkCombo.getModel().getSize() > 1); }
From source file:de.tor.tribes.ui.views.DSWorkbenchReTimerFrame.java
private void startCalculation() { jideRetimeTabbedPane.setSelectedIndex(0); if (parsedAttack == null || parsedAttack.getSource() == null || parsedAttack.getTarget() == null || parsedAttack.getUnit() == null || parsedAttack.getArriveTime() == null) { JOptionPaneHelper.showInformationBox(this, "Bitte fge zuerst einen gltigen Angriff ein und whle eine Einheit", "Information"); return;/* w w w.j a v a 2s . c o m*/ } jCalculationSettingsDialog.pack(); jCalculationSettingsDialog.setLocationRelativeTo(DSWorkbenchReTimerFrame.this); DefaultListModel tagModel = new DefaultListModel(); tagModel.addElement(NoTag.getSingleton()); for (ManageableType e : TagManager.getSingleton().getAllElements()) { tagModel.addElement((Tag) e); } jTagList.setModel(tagModel); jRelationBox.setSelected(true); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (UnitHolder unit : DataHolder.getSingleton().getUnits()) { model.addElement(unit); } jUnitBox.setModel(model); jUnitBox.setRenderer(new UnitListCellRenderer()); // <editor-fold defaultstate="collapsed" desc="Build attack plan table"> DefaultTableModel attackPlanTableModel = new javax.swing.table.DefaultTableModel(new Object[][] {}, new String[] { "Angriffsplan", "Abgleichen" }) { Class[] types = new Class[] { String.class, Boolean.class }; @Override public Class getColumnClass(int columnIndex) { return types[columnIndex]; } @Override public boolean isCellEditable(int row, int col) { if (col == 0) { return false; } return true; } }; String[] plans = AttackManager.getSingleton().getGroups(); for (String plan : plans) { attackPlanTableModel.addRow(new Object[] { plan, false }); } jAttackPlanTable.setModel(attackPlanTableModel); DefaultTableCellRenderer headerRenderer = new SortableTableHeaderRenderer(); for (int i = 0; i < jAttackPlanTable.getColumnCount(); i++) { jAttackPlanTable.getColumn(jAttackPlanTable.getColumnName(i)).setHeaderRenderer(headerRenderer); } // </editor-fold> jCalculationSettingsDialog.setVisible(true); }
From source file:edu.ku.brc.specify.tools.schemalocale.FieldItemPanel.java
/** * @return// w ww .j a v a2 s . co m */ protected UIFieldFormatterIFace fillWithFieldFormatter(final UIFieldFormatterIFace formatter) { formatHash.clear(); DefaultComboBoxModel cbxModel = (DefaultComboBoxModel) formatCombo.getModel(); cbxModel.removeAllElements(); cbxModel.addElement(SL_NONE); // Add None if (fieldInfo.getDataClass() == String.class || UIHelper.isClassNumeric(fieldInfo.getDataClass(), true)) { formatCombo.setEnabled(true); formatMoreBtn.setEnabled(true); } int selectedInx = 0; // default to 'None' UIFieldFormatterIFace selectedFmt = null; List<UIFieldFormatterIFace> fList = schemaPanel.getUiFieldFormatterMgrCache() .getFormatterList(tableInfo.getClassObj(), fieldInfo.getName()); // list must be sorted in the same way it's sorted on UIFormatterDlg because selection index is considered equivalent between combo boxes Collections.sort(fList, new Comparator<UIFieldFormatterIFace>() { public int compare(UIFieldFormatterIFace o1, UIFieldFormatterIFace o2) { return o1.toPattern().compareTo(o2.toPattern()); } }); if (fList != null && fList.size() > 0) { for (UIFieldFormatterIFace fmt : fList) { log.debug("[" + (formatter != null ? formatter.getName() : "null") + "][" + fmt.getTitle() + "]"); cbxModel.addElement(fmt); if (formatter != null && formatter.getName().equals(fmt.getName())) { selectedInx = cbxModel.getSize() - 1; selectedFmt = fmt; } } } // I think this should be moved to the AppContext and made generic as possible boolean enableFormatter = true; if (tableInfo.getTableId() == CollectionObject.getClassTableId() && fieldInfo.getName().equals("catalogNumber")) { Collection collection = AppContextMgr.getInstance().getClassObject(Collection.class); if (collection != null && collection.getNumberingSchemes().size() > 0) { enableFormatter = AppPreferences.getLocalPrefs().getBoolean("EDIT_CATNUM", false); } } boolean hasFormat = selectedInx > 0; webLinkCombo.setEnabled(hasFormat); formatCombo.setSelectedIndex(selectedInx); formatSwitcherCombo.setEnabled(enableFormatter && schemaType != SpLocaleContainer.WORKBENCH_SCHEMA); formatCombo.setEnabled(enableFormatter && schemaType != SpLocaleContainer.WORKBENCH_SCHEMA); formatMoreBtn.setEnabled(enableFormatter && schemaType != SpLocaleContainer.WORKBENCH_SCHEMA); return selectedFmt; }
From source file:gtu._work.ui.DirectoryCompareUI.java
private void initComponents() { DefaultTableModel dirCompareModel = getDefaultTableModel(); DefaultComboBoxModel extensionModel = new DefaultComboBoxModel(); extensionModel.addElement(EXTENSION_ALL); while (extensionNameComboBox.getModel().getSize() != extensionModel.getSize()) { extensionNameComboBox.setModel(extensionModel); System.out.println("reset extensionNameComboBox"); }/* ww w . j a v a 2s .c o m*/ while (dirCompareTable.getModel().getRowCount() != dirCompareModel.getRowCount()) { dirCompareTable.setModel(dirCompareModel); System.out.println("reset dirCompareTable"); } searchText.setText(""); setTitle(""); compareStyleComboBox.setSelectedItem(EXTENSION_ALL); if (diffMergeChkBox != null) { for (JCheckBox chk : diffMergeChkBox) { chk.setSelected(true); } } }
From source file:edu.ku.brc.specify.tools.schemalocale.FieldItemPanel.java
/** * Fills the format Combobox with the available formatters. */// ww w . j a va 2s. c o m protected void fillWebLinkBox() { if (webLinkCombo != null) { DefaultComboBoxModel wlModel = (DefaultComboBoxModel) webLinkCombo.getModel(); wlModel.removeAllElements(); //if (wlModel.getSize() == 0) { wlModel.addElement(webLinkDefNone); for (WebLinkDef wld : webLinkMgrCache.getWebLinkDefs(null)) { wlModel.addElement(wld); } } //wbLnkCombo.setEnabled(false); webLinkMoreBtn.setEnabled(true); //wbLnkCombo.setEnabled(false); int selInx = webLinkCombo.getModel().getSize() > 0 ? 0 : -1; LocalizableItemIFace fld = getSelectedFieldItem(); if (fld != null) { String webLinkName = fld.getWebLinkName(); if (StringUtils.isNotEmpty(webLinkName)) { DefaultComboBoxModel model = (DefaultComboBoxModel) webLinkCombo.getModel(); for (int i = 0; i < model.getSize(); i++) { WebLinkDef wld = (WebLinkDef) model.getElementAt(i); if (wld.getName().equals(webLinkName)) { selInx = i; break; } } } } webLinkCombo.setSelectedIndex(selInx); } }
From source file:edu.ku.brc.specify.tools.schemalocale.FieldItemPanel.java
/** * @param dspName//ww w .j a v a2 s . c o m * @param fld */ protected void loadPickLists(final String dspName, final LocalizableItemIFace fld) { if (disciplineName == null || !dspName.equals(disciplineName)) { disciplineName = dspName; pickLists.clear(); List<PickList> plList = localizableIO.getPickLists(null); if (plList != null) { pickLists.addAll(plList); } //for (PickList pl : pickLists) System.out.println("0: "+pl.getName()); if (disciplineName != null) { plList = localizableIO.getPickLists(disciplineName); if (plList != null) { pickLists.addAll(plList); } //for (PickList pl : localizableIO.getPickLists(disciplineName)) System.out.println("1: "+pl.getName()); } Collections.sort(pickLists); } if (pickLists != null) { DBRelationshipInfo.RelationshipType relType = relInfo != null ? relInfo.getType() : null; Class<?> typeCls = fieldInfo != null ? fieldInfo.getDataClass() : null; boolean isTypeOK = typeCls != null && (typeCls == String.class || UIHelper.isClassNumeric(typeCls, true)); int selectedIndex = 0; DefaultComboBoxModel plCbxModel = (DefaultComboBoxModel) pickListCBX.getModel(); if (isTypeOK) { plCbxModel.removeAllElements(); plCbxModel.addElement(pickListNone); int inx = 1; for (PickList pl : pickLists) { if (pl.getType() == PickListIFace.PL_WITH_ITEMS || pl.getType() == PickListIFace.PL_TABLE_FIELD) { plCbxModel.addElement(pl); String plName = fld.getPickListName(); if (selectedIndex == 0 && StringUtils.isNotEmpty(plName) && plName.equals(pl.getName())) { selectedIndex = inx; } inx++; } } } else if (relType != null && relType == DBRelationshipInfo.RelationshipType.ManyToOne) { plCbxModel.removeAllElements(); plCbxModel.addElement(pickListNone); int inx = 1; for (PickList pl : pickLists) { if (pl.getType() == PickListIFace.PL_WHOLE_TABLE) { DBTableInfo tblInfo = DBTableIdMgr.getInstance().getInfoByTableName(pl.getTableName()); if (relInfo.getDataClass() == tblInfo.getClassObj()) { plCbxModel.addElement(pl); String plName = fld.getPickListName(); //System.out.println(plName+" "+pl.getName()); if (StringUtils.isNotEmpty(plName) && plName.equals(pl.getName())) { selectedIndex = inx; } inx++; } } } } pickListCBX.setEnabled(isTypeOK || relType != null); pickListCBX.setSelectedIndex(pickListCBX.getModel().getSize() > 0 ? selectedIndex : -1); } else { pickListCBX.setEnabled(false); } }
From source file:edu.ku.brc.specify.tools.schemalocale.FieldItemPanel.java
/** * @param localeContainer/*from ww w . j a v a 2 s. c o m*/ */ protected void fillWithDate(final SpLocaleContainer localeContainer) { formatHash.clear(); DefaultComboBoxModel cbxModel = (DefaultComboBoxModel) formatCombo.getModel(); cbxModel.removeAllElements(); DBFieldInfo precision = tableInfo.getFieldByName(fieldInfo.getName() + "Precision"); if (precision != null) { cbxModel.addElement(getResourceString("SL_PARTIAL_DATE")); } else { cbxModel.addElement(getResourceString("SL_DATE")); } formatCombo.setSelectedIndex(0); formatCombo.setEnabled(false); formatMoreBtn.setEnabled(false); }
From source file:gtu._work.ui.DirectoryCompareUI.java
private JComboBox getDiffToolComboBox() { if (diffToolComboBox == null) { DefaultComboBoxModel diffToolComboBoxModel = new DefaultComboBoxModel(); for (DiffMergeCommand e : DiffMergeCommand.values()) { diffToolComboBoxModel.addElement(e); }/*from w w w. j a va 2s. co m*/ diffToolComboBox = new JComboBox(); diffToolComboBox.setModel(diffToolComboBoxModel); diffToolComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { DiffMergeCommand e = (DiffMergeCommand) diffToolComboBox.getSelectedItem(); if (e == DiffMergeCommand.StarTeam) { String path = getStarTeamPath_FileCompareMerge(false); if (StringUtils.isBlank(path)) { try { File file = JCommonUtil._jFileChooser_selectFileOnly(); if (file == null) { Validate.isTrue(false, "!"); } Validate.isTrue( StringUtils.equalsIgnoreCase("File Compare Merge.exe", file.getName()), "??File Compare Merge.exe"); String starTeamConfig = file.getCanonicalPath(); Properties prop = configBean.getConfigProp(); prop.setProperty(STARTEAM_KEY, starTeamConfig); configBean.store(); JCommonUtil._jOptionPane_showMessageDialog_info("?!"); } catch (Exception ex) { JCommonUtil.handleException(ex, false); } } } } }); } return diffToolComboBox; }