List of usage examples for javax.swing DefaultComboBoxModel getSize
public int getSize()
From source file:edu.ku.brc.specify.tools.schemalocale.FieldItemPanel.java
/** * /* ww w.j a va 2 s .co m*/ */ public void buildUI() { setIgnoreChanges(true); fieldsList = createList(fieldsModel); fieldsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { getAllDataFromUI(); fieldSelected(); } } }); fieldsList.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { super.focusLost(e); //lastIndex = fieldsList.getSelectedIndex(); } }); fieldDescText.addKeyListener(new LengthWatcher(255)); // setting min and pref sizes to some bogus values so that textarea shrinks with dialog fieldNameText.addKeyListener(new LengthWatcher(64)); CellConstraints cc = new CellConstraints(); int y = 1; JScrollPane fldsp = UIHelper.createScrollPane(fieldsList); // LocalizableNameDescIFace PanelBuilder pb = new PanelBuilder(new FormLayout("max(200px;p),4px,p,2px,p,10px,p,2px,p,f:p:g", (includeHiddenUI ? "p,2px," : "") + (isDBSchema ? "p,2px,p,2px," : "") + (includeFormatAndAutoNumUI ? "p,2px,p,2px," : "") + "p,2px,p,2px,p,2px,p,2px,p,2px,p,2px,f:p:g"), this); pb.add(fldsp, cc.xywh(1, y, 1, 7 + (isDBSchema ? 4 : 0))); pb.add(fieldNameLbl = createI18NFormLabel("SL_LABEL", SwingConstants.RIGHT), cc.xy(3, y)); pb.add(fieldNameText, cc.xywh(5, y, 6, 1)); y += 2; if (includeHiddenUI) { pb.add(fieldHideChk, cc.xy(5, y)); y += 2; } pb.add(fieldDescLbl = createI18NFormLabel("SL_DESC", SwingConstants.RIGHT), cc.xy(3, y)); JScrollPane sp = new JScrollPane(fieldDescText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); pb.add(sp, cc.xywh(5, y, 6, 1)); y += 2; fieldDescText.setLineWrap(true); fieldDescText.setWrapStyleWord(true); if (isDBSchema) { fieldTypeTxt = createLabel(""); fieldLengthTxt = createLabel(""); pb.add(fieldTypeLbl = createI18NFormLabel("SL_TYPE", SwingConstants.RIGHT), cc.xy(3, y)); pb.add(fieldTypeTxt, cc.xy(5, y)); pb.add(fieldReqChk = createCheckBox(getResourceString("SL_REQ")), cc.xy(9, y)); y += 2; pb.add(fieldLengthLbl = createI18NFormLabel("SL_LENGTH", SwingConstants.RIGHT), cc.xy(3, y)); pb.add(fieldLengthTxt, cc.xy(5, y)); y += 2; fieldTypeTxt.setBackground(Color.WHITE); fieldLengthTxt.setBackground(Color.WHITE); fieldTypeTxt.setOpaque(true); fieldLengthTxt.setOpaque(true); } if (includeFormatAndAutoNumUI) { PanelBuilder inner = new PanelBuilder(new FormLayout("p,2px,p", "p")); formatSwitcherCombo = createComboBox(); fmtCardLayout = new CardLayout(); formatterPanel = new JPanel(fmtCardLayout); pb.add(formatLbl = createI18NFormLabel("SL_FMTTYPE", SwingConstants.RIGHT), cc.xy(3, y)); inner.add(formatSwitcherCombo, cc.xy(1, 1)); inner.add(formatterPanel, cc.xy(3, 1)); pb.add(inner.getPanel(), cc.xywh(5, y, 6, 1)); y += 2; ActionListener switchAL = new ActionListener() { public void actionPerformed(ActionEvent e) { String item = (String) formatSwitcherCombo.getSelectedItem(); if (item != null) { fmtCardLayout.show(formatterPanel, item); webLinkCombo.setEnabled(item.equals(SL_WEBLINK)); if (formatSwitcherCombo.getSelectedIndex() == 0) { if (webLinkCombo.getModel().getSize() > 0) { webLinkCombo.setSelectedIndex(0); } if (formatCombo.getModel().getSize() > 0) { formatCombo.setSelectedIndex(0); } if (pickListCBX.getModel().getSize() > 0) { pickListCBX.setSelectedIndex(0); } } } } }; formatSwitcherCombo.addActionListener(switchAL); formatterPanel.add(SL_NONE, new JPanel()); //-------------------------- // UIFieldFormatter //-------------------------- inner = new PanelBuilder(new FormLayout("max(p;150px),2px,min", "p")); formatCombo = createComboBox(new DefaultComboBoxModel()); formatMoreBtn = createButton(ELIPSES); inner.add(formatCombo, cc.xy(1, 1)); inner.add(formatMoreBtn, cc.xy(3, 1)); formatMoreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UIFormatterListEdtDlg dlg = new UIFormatterListEdtDlg((Frame) UIRegistry.getTopWindow(), fieldInfo, true, schemaPanel.getUiFieldFormatterMgrCache()); dlg.setVisible(true); if (!dlg.isCancelled() && dlg.hasChanged()) { //schemaPanel.setHasChanged(true); formHasChanged(); //fillFormatBox(dlg.getSelectedFormat()); setSelectedFieldFormatter(dlg.getSelectedFormat()); } } }); formatterPanel.add(SL_FORMAT, inner.getPanel()); ActionListener changed = new ActionListener() { public void actionPerformed(ActionEvent e) { formHasChanged(); boolean hasFormat = formatCombo.getSelectedIndex() > 0; webLinkCombo.setEnabled(!hasFormat); if (hasFormat) { webLinkCombo.setSelectedIndex(webLinkCombo.getModel().getSize() > 0 ? 0 : -1); pickListCBX.setSelectedIndex(pickListCBX.getModel().getSize() > 0 ? 0 : -1); } } }; formatCombo.addActionListener(changed); //-------------------------- // WebLinks //-------------------------- webLinkMoreBtn = createButton(ELIPSES); webLinkMoreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { WebLinkDef selectedWL = (WebLinkDef) webLinkCombo.getSelectedItem(); WebLinkConfigDlg dlg = webLinkMgrCache.editWebLinks(tableInfo, false); if (dlg.getBtnPressed() == CustomDialog.OK_BTN) { fillWebLinkBox(); formHasChanged(); if (selectedWL != null && !selectedWL.getName().equals(SL_WEBLINK)) { dlg.setWebLink(selectedWL.getName()); } if (dlg.getBtnPressed() == CustomDialog.OK_BTN) { setSelectedWebLink(dlg.getSelectedItem()); } } } }); inner = new PanelBuilder(new FormLayout("max(p;150px),2px,min", "p")); webLinkCombo = createComboBox(); DefaultComboBoxModel model = (DefaultComboBoxModel) webLinkCombo.getModel(); model.addElement(webLinkDefNone); webLinkCombo.setSelectedIndex(0); inner.add(webLinkCombo, cc.xy(1, 1)); inner.add(webLinkMoreBtn, cc.xy(3, 1)); ActionListener wlchanged = new ActionListener() { public void actionPerformed(ActionEvent e) { formHasChanged(); boolean hasWL = webLinkCombo.getSelectedIndex() > 0; webLinkCombo.setEnabled(hasWL); if (hasWL) { formatCombo.setSelectedIndex(formatCombo.getModel().getSize() > 0 ? 0 : -1); pickListCBX.setSelectedIndex(pickListCBX.getModel().getSize() > 0 ? 0 : -1); } } }; webLinkCombo.addActionListener(wlchanged); formatterPanel.add(SL_WEBLINK, inner.getPanel()); } //-------------------------- // PickList //-------------------------- pickListCBX = createComboBox(new DefaultComboBoxModel()); pickListCBX.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { formHasChanged(); if (formatCombo != null && pickListCBX.getSelectedIndex() > 0) { formatCombo.setSelectedIndex(formatCombo.getModel().getSize() > 0 ? 0 : -1); webLinkCombo.setSelectedIndex(webLinkCombo.getModel().getSize() > 0 ? 0 : -1); } } }); pickListMoreBtn = createButton(ELIPSES); pickListMoreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { LocalizableItemIFace currentField = prevField; prevField = getSelectedFieldItem(); PickList selectedItem = (PickList) pickListCBX.getSelectedItem(); PickListEditorDlg dlg = new PickListEditorDlg( localizableIO.hasUpdatablePickLists() ? null : localizableIO, true, true); dlg.setTableInfo(tableInfo); dlg.setFieldInfo(fieldInfo); dlg.createUI(); dlg.setSize(400, 500); dlg.setVisible(true); if (!dlg.isCancelled()) { if (dlg.hasChanged()) { hasChanged = true; Vector<PickList> list = dlg.getNewPickLists(); DefaultComboBoxModel plCbxModel = (DefaultComboBoxModel) pickListCBX.getModel(); for (int i = 0; i < plCbxModel.getSize(); i++) { list.add((PickList) plCbxModel.getElementAt(i)); } Collections.sort(list); plCbxModel.removeAllElements(); plCbxModel.addElement(pickListNone); int inx = -1; int i = 0; for (PickList pl : list) { plCbxModel.addElement(pl); if (inx == -1 && selectedItem != null && ((selectedItem.getId() != null && pl.getId() != null && selectedItem.getId().equals(pl.getId())) || (selectedItem.getName() != null && pl.getName() != null && selectedItem.getName().equals(pl.getName())))) { inx = i; } i++; } pickListCBX.setSelectedIndex(inx + 1); } } prevField = currentField; } }); if (includeFormatAndAutoNumUI) { PanelBuilder inner = new PanelBuilder(new FormLayout("max(p;150px),2px,min", "p")); inner.add(pickListCBX, cc.xy(1, 1)); inner.add(pickListMoreBtn, cc.xy(3, 1)); formatterPanel.add(SL_PICKLIST, inner.getPanel()); } else { pb.add(pickListLbl = createI18NFormLabel(SL_PICKLIST, SwingConstants.RIGHT), cc.xy(3, y)); pb.add(pickListCBX, cc.xy(5, y)); pb.add(pickListMoreBtn, cc.xy(7, y)); y += 2; } nxtBtn = createI18NButton("SL_NEXT"); nxtEmptyBtn = createI18NButton("SL_NEXT_EMPTY"); fldSpellChkBtn = createI18NButton("SL_SPELL_CHECK"); //JPanel bbp = ButtonBarFactory.buildCenteredBar(adjustButtonArray(new JButton[] {nxtEmptyBtn, nxtBtn, fldSpellChkBtn})); //bbp.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); //pb.add(bbp, cc.xywh(3, y, 8, 1)); nxtBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { next(); } }); nxtEmptyBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { nextEmpty(); } }); fldSpellChkBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (checker != null) { checker.spellCheck(fieldDescText); checker.spellCheck(fieldNameText); } } }); fieldHideChk.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { formHasChanged(); } }); fieldReqChk.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { formHasChanged(); } }); DocumentListener dl = new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { formHasChanged(); } }; fieldNameText.getDocument().addDocumentListener(dl); fieldDescText.getDocument().addDocumentListener(dl); /* if (formatTxt != null) { formatTxt.getDocument().addDocumentListener(dl); } */ SchemaI18NService.getInstance().checkCurrentLocaleMenu(); enableUIControls(false); setIgnoreChanges(false); }
From source file:gtu._work.ui.DirectoryCompareUI.java
/** * TODO/* w w w . java 2 s .co m*/ */ private void compareStart() { try { String leftStr = leftDirText.getText(); String rightStr = rightDirText.getText(); Validate.notBlank(leftStr, "??"); Validate.notBlank(rightStr, "???"); initComponents(); File leftFile = new File(StringUtils.trim(leftStr)); File rightFile = new File(StringUtils.trim(rightStr)); if (!leftFile.exists()) { leftFile = File.createTempFile("left_", ".txt"); if (leftFile.exists()) { leftFile.delete(); } FileUtils.write(leftFile, leftStr, "utf8"); } if (!rightFile.exists()) { rightFile = File.createTempFile("right_", ".txt"); if (rightFile.exists()) { rightFile.delete(); } FileUtils.write(rightFile, rightStr, "utf8"); } File mainFile = leftFile; File compareFile = rightFile; modelOrignList.clear(); compareSearch = new MainCompareSearch(mainFile, compareFile) { @Override void compareFileNotExists(FileZ mainFile, FileZ compareToFile, boolean mainFileIsLeft) { modelOrignList .add(getCreateRow(mainFile, compareToFile, mainFileIsLeft, DiffMergeStatus.NOT_EXISTS)); } @Override void sameFile(FileZ mainFile, FileZ compareToFile, boolean mainFileIsLeft) { modelOrignList.add(getCreateRow(mainFile, compareToFile, mainFileIsLeft, DiffMergeStatus.SAME)); } @Override void differentFile(FileZ mainFile, FileZ compareToFile, boolean mainFileIsLeft) { modelOrignList .add(getCreateRow(mainFile, compareToFile, mainFileIsLeft, DiffMergeStatus.DIFFERENT)); } @Override void complete() { DefaultTableModel dirCompareModel = getDefaultTableModel(); DefaultComboBoxModel extensionModel = new DefaultComboBoxModel(); Set<String> extensionSet = new TreeSet<String>(); for (Object[] rows : modelOrignList) { dirCompareModel.addRow(rows); InfoObj infoObj = (InfoObj) rows[0]; // ??? checkExtensionName(infoObj, extensionSet); } extensionModel.addElement(EXTENSION_ALL); extensionModel.addElement(EXTENSION_CUSTOM); for (String name : extensionSet) { extensionModel.addElement(name); } while (extensionNameComboBox.getModel().getSize() != extensionModel.getSize()) { extensionNameComboBox.setModel(extensionModel); System.out.println("reset extensionNameComboBox"); } while (dirCompareTable.getModel().getRowCount() != dirCompareModel.getRowCount()) { dirCompareTable.setModel(dirCompareModel); System.out.println("reset dirCompareTable"); } System.out.println( "extensionNameComboBox = " + (extensionNameComboBox.getModel() == extensionModel)); System.out.println("dirCompareTable = " + (dirCompareTable.getModel() == dirCompareModel)); System.out.println("extensionNameComboBox = " + extensionNameComboBox.getModel().getSize()); System.out.println("dirCompareTable = " + dirCompareTable.getModel().getRowCount()); setTitle(":" + mainFileCount + "/?:" + compareToFileCount + ", :" + completeTime); JCommonUtil._jOptionPane_showMessageDialog_info(// "???" + // "\n?:" + this.countSameFile + // "\n??:" + this.countDifferentFile + // "\n?:" + this.countNotExists + // "\n:" + completeTime + // "\n?merge:" + modelOrignList.size()); } }; if (leftFile.isDirectory() && rightFile.isDirectory()) { if (StringUtils.equals(FINDFUNCTION_ABS, String.valueOf(compareStyleComboBox.getSelectedItem()))) { compareSearch.executeSameDirectory(); } else if (StringUtils.equals(FINDFUNCTION_REL, String.valueOf(compareStyleComboBox.getSelectedItem()))) { List<File> mainFileList = new ArrayList<File>(); List<File> compareFileList = new ArrayList<File>(); FileUtil.searchFilefind(mainFile, ".*", mainFileList); FileUtil.searchFilefind(compareFile, ".*", compareFileList); compareSearch.executeTwoDirectoryButNotSame(mainFileList, compareFileList); } else { Validate.isTrue(false, "??!"); } } else if (leftFile.isFile() && rightFile.isFile()) { compareSearch.executeTwoFile(); } else if (leftFile.isDirectory() && rightFile.isFile()) { List<File> mainFileList = new ArrayList<File>(); List<File> compareFileList = new ArrayList<File>(); FileUtil.searchFilefind(mainFile, ".*", mainFileList); compareFileList.add(compareFile); compareSearch.executeTwoDirectoryButNotSame(mainFileList, compareFileList); compareStyleComboBox.setSelectedItem(FINDFUNCTION_REL); } else if (leftFile.isFile() && rightFile.isDirectory()) { List<File> mainFileList = new ArrayList<File>(); List<File> compareFileList = new ArrayList<File>(); mainFileList.add(mainFile); FileUtil.searchFilefind(compareFile, ".*", compareFileList); compareSearch.executeTwoDirectoryButNotSame(mainFileList, compareFileList); compareStyleComboBox.setSelectedItem(FINDFUNCTION_REL); } else { Validate.isTrue(false, "???!"); } } catch (Exception ex) { JCommonUtil.handleException(ex, false); } }
From source file:edu.harvard.i2b2.query.ui.GroupPanel.java
public void setTimingComboText(String text) { DefaultComboBoxModel model = ((DefaultComboBoxModel) jTimingComboBox.getModel()); //model.removeElementAt(1); if (text.equalsIgnoreCase("Items instance will be same")) { if (model.getSize() == 2) { model.insertElementAt(text, 2); }//from w w w . java 2s.c o m } else { if (model.getSize() == 3) { model.removeElementAt(2); } } }
From source file:edu.ku.brc.specify.tools.schemalocale.FieldItemPanel.java
/** * @return//ww w .ja va2 s . c o 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:edu.ku.brc.specify.datamodel.busrules.BaseTreeBusRules.java
/** * @param parentField//from ww w. j av a 2 s .c o m * @param rankComboBox * @param nodeInForm */ @SuppressWarnings("unchecked") protected void adjustRankComboBoxModel(final GetSetValueIFace parentField, final ValComboBox rankComboBox, final T nodeInForm) { log.debug("Adjusting the model for the 'rank' combo box in a tree node form"); if (nodeInForm == null) { return; } log.debug("nodeInForm = " + nodeInForm.getName()); DefaultComboBoxModel<I> model = (DefaultComboBoxModel<I>) rankComboBox.getModel(); model.removeAllElements(); // this is the highest rank the edited item can possibly be I topItem = null; // this is the lowest rank the edited item can possibly be I bottomItem = null; Object value = parentField.getValue(); T parent = null; if (value instanceof String) { // this happens when the combobox is in view mode, which means it's really a textfield // in that case, the parent of the node in the form will do, since the user can't change the parents parent = nodeInForm.getParent(); } else { parent = (T) parentField.getValue(); } if (parent == null) { return; } // grab all the def items from just below the parent's item all the way to the next enforced level // or to the level of the highest ranked child topItem = parent.getDefinitionItem().getChild(); log.debug("highest valid tree level: " + topItem); if (topItem == null) { // this only happens if a parent was chosen that cannot have children b/c it is at the // lowest defined level in the tree log.warn("Chosen node cannot be a parent node. It is at the lowest defined level of the tree."); return; } // find the child with the highest rank and set that child's def item as the bottom of the range if (!nodeInForm.getChildren().isEmpty()) { for (T child : nodeInForm.getChildren()) { if (bottomItem == null || child.getRankId() > bottomItem.getRankId()) { bottomItem = child.getDefinitionItem().getParent(); } } } log.debug("lowest valid tree level: " + bottomItem); I item = topItem; boolean done = false; while (!done) { model.addElement(item); if (item.getChild() == null || item.getIsEnforced() == Boolean.TRUE || (bottomItem != null && item.getRankId().intValue() == bottomItem.getRankId().intValue())) { done = true; } item = item.getChild(); } if (nodeInForm.getDefinitionItem() != null) { I defItem = nodeInForm.getDefinitionItem(); for (int i = 0; i < model.getSize(); ++i) { I modelItem = (I) model.getElementAt(i); if (modelItem.getRankId().equals(defItem.getRankId())) { log.debug("setting rank selected value to " + modelItem); model.setSelectedItem(modelItem); } } // if (model.getIndexOf(defItem) != -1) // { // model.setSelectedItem(defItem); // } } else if (model.getSize() == 1) { Object defItem = model.getElementAt(0); log.debug("setting rank selected value to the only available option: " + defItem); model.setSelectedItem(defItem); } }
From source file:nz.govt.natlib.ndha.manualdeposit.MetaDataTest.java
@Test public final void testSetup() { formIsVisible = false;/*w w w. j av a2 s. c o m*/ try { metaDataPresenter.setup(); } catch (Exception ex) { fail(); } assertTrue(formIsVisible); DefaultComboBoxModel model = (DefaultComboBoxModel) theFrame.cmbDataType.getModel(); assertTrue(model.getSize() == EDataType.values().length); assertFalse(theFrame.cursorIsWaiting); }
From source file:op.care.med.inventory.DlgNewStocks.java
private void txtBWSucheCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtBWSucheCaretUpdate if (ignoreEvent || !txtBWSuche.isEnabled()) { return;/*from w w w . j av a2 s .c o m*/ } if (txtBWSuche.getText().isEmpty()) { cmbBW.setModel(new DefaultComboBoxModel()); resident = null; } else { DefaultComboBoxModel dcbm = new DefaultComboBoxModel(); EntityManager em = OPDE.createEM(); if (txtBWSuche.getText().trim().length() == 3) { // Knnte eine Suche nach der Kennung sein resident = em.find(Resident.class, txtBWSuche.getText().trim()); if (resident != null) { dcbm = new DefaultComboBoxModel(new Resident[] { resident }); } } if (dcbm.getSize() == 0) { // Vielleicht Suche nach Nachname Query query = em.createQuery( " SELECT b FROM Resident b WHERE b.station IS NOT NULL AND b.name like :nachname ORDER BY b.name, b.firstname "); query.setParameter("nachname", txtBWSuche.getText().trim() + "%"); java.util.List<Resident> listbw = query.getResultList(); dcbm = new DefaultComboBoxModel(listbw.toArray()); } if (dcbm.getSize() > 0) { cmbBW.setModel(dcbm); cmbBW.setSelectedIndex(0); resident = (Resident) cmbBW.getSelectedItem(); } else { cmbBW.setModel(new DefaultComboBoxModel()); resident = null; } em.close(); } if (ovrBW.getOverlayComponents().length > 0) { ovrBW.removeOverlayComponent(ovrBW.getOverlayComponents()[0]); } if (resident == null) { ovrBW.addOverlayComponent(attentionIconBW, DefaultOverlayable.SOUTH_WEST); attentionIconBW.setToolTipText("<html>Keine(n) BewohnerIn ausgewhlt.<html>"); } initCmbVorrat(); }
From source file:op.care.med.inventory.DlgNewStocks.java
private void initCmbVorrat() { if (ovrVorrat.getOverlayComponents().length > 0) { ovrVorrat.removeOverlayComponent(ovrVorrat.getOverlayComponents()[0]); }//w ww. ja va2 s. com if (resident != null) { // ovrVorrat.removeOverlayComponent(ovrVorrat.getOverlayComponents()[0]); // ovrVorrat.addOverlayComponent(questionIconVorrat, DefaultOverlayable.SOUTH_WEST); // cmbVorrat.setRenderer(MedInventoryTools.getInventoryRenderer()); if (tradeForm == null) { cmbVorrat.setModel(new DefaultComboBoxModel()); inventory = null; } else { List<MedInventory> vorraete = new ArrayList<MedInventory>(); inventory = TradeFormTools.getInventory4TradeForm(resident, tradeForm); if (inventory == null) { vorraete = TradeFormTools.getSuitableInventoriesForThisTradeForm(resident, tradeForm); } else { vorraete.add(inventory); } cmbVorrat.setModel(new DefaultComboBoxModel(vorraete.toArray())); } // ovrVorrat.removeOverlayComponent(ovrVorrat.getOverlayComponents()[0]); if (tradeForm != null) { if (inventory == null) { DefaultComboBoxModel dcbm = (DefaultComboBoxModel) cmbVorrat.getModel(); dcbm.insertElementAt(new MedInventory(resident, "<AUTOMATISCH>"), 0); cmbVorrat.setSelectedIndex(0); if (dcbm.getSize() > 1) { ovrVorrat.addOverlayComponent(attentionIconVorrat, DefaultOverlayable.SOUTH_WEST); attentionIconVorrat.setToolTipText( "<html>Keinen <b>exakt</b> passender Vorrat gefunden. Whlen Sie selbst einen passenden aus oder verwenden Sie <b>automatisch</b>.<html>"); cmbVorrat.showPopup(); } else { ovrVorrat.addOverlayComponent(infoIconVorrat, DefaultOverlayable.SOUTH_WEST); infoIconVorrat .setToolTipText("<html>Ein neuer Vorrat wird <b>automatisch</b> erstellt.</html>"); } } else { correctIconVorrat.setToolTipText(null); ovrVorrat.addOverlayComponent(correctIconVorrat, DefaultOverlayable.SOUTH_WEST); } } else { ovrVorrat.addOverlayComponent(questionIconVorrat, DefaultOverlayable.SOUTH_WEST); questionIconVorrat.setToolTipText("<html>Kein Medikament ausgewhlt.<html>"); } } }
From source file:op.tools.SYSTools.java
public static DefaultListModel cmb2lst(DefaultComboBoxModel dcbm) { DefaultListModel dlm = new DefaultListModel(); for (int i = 0; i < dcbm.getSize(); i++) { dlm.addElement(dcbm.getElementAt(i)); }/* w ww. j ava 2s .c om*/ return dlm; }
From source file:org.nuclos.client.ui.collect.component.CollectableComboBox.java
/** * @return the list of (possible) values (dropdown list) *//*from w w w . j av a2s.co m*/ public List<CollectableField> getValueList() { final List<CollectableField> result = new ArrayList<CollectableField>(); final DefaultComboBoxModel model = getDefaultComboBoxModel(); for (int i = 0; i < model.getSize(); i++) { result.add((CollectableField) model.getElementAt(i)); } return result; }