List of usage examples for javax.swing DefaultComboBoxModel insertElementAt
public void insertElementAt(E anObject, int index)
From source file:op.care.med.inventory.DlgNewStocks.java
private void cmbMProduktItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmbMProduktItemStateChanged if (ignoreEvent || (evt != null && evt.getStateChange() != ItemEvent.SELECTED)) { return;/*from w ww . j a va2 s. c o m*/ } tradeForm = (TradeForm) cmbMProdukt.getSelectedItem(); if (tradeForm != null) { DefaultComboBoxModel dcbm = new DefaultComboBoxModel(tradeForm.getPackages().toArray()); txtWeightControl.setVisible(tradeForm.isWeightControlled()); lblWeightControl.setVisible(tradeForm.isWeightControlled()); dcbm.insertElementAt("<Sonderpackung>", 0); cmbPackung.setModel(dcbm); cmbPackung.setRenderer(MedPackageTools.getMedPackungRenderer()); if (aPackage == null) { cmbPackung.setSelectedIndex(cmbPackung.getModel().getSize() - 1); } else { cmbPackung.setSelectedItem(aPackage); } cmbPackungItemStateChanged(null); } else { cmbPackung.setModel(new DefaultComboBoxModel()); aPackage = null; txtWeightControl.setVisible(false); lblWeightControl.setVisible(false); } initCmbVorrat(); }
From source file:op.care.med.inventory.DlgOpenStock.java
private void initDialog() { EntityManager em = OPDE.createEM();//from www . j av a 2 s . com Query query = em.createQuery(" " + " SELECT b FROM MedStock b " + " WHERE b.inventory = :vorrat AND b.out = :aus AND b.opened = :anbruch " + " ORDER BY b.in, b.id "); // Geht davon aus, dass die PKs immer fortlaufend, automatisch vergeben werden. query.setParameter("vorrat", inventory); query.setParameter("aus", SYSConst.DATE_UNTIL_FURTHER_NOTICE); query.setParameter("anbruch", SYSConst.DATE_UNTIL_FURTHER_NOTICE); DefaultComboBoxModel dcbm = new DefaultComboBoxModel(query.getResultList().toArray()); dcbm.insertElementAt(SYSTools.xx("misc.msg.none"), 0); cmbBestID.setModel(dcbm); cmbBestID.setRenderer(MedStockTools.getBestandOnlyIDRenderer()); int index = Math.min(2, cmbBestID.getItemCount()); cmbBestID.setSelectedIndex(index - 1); }
From source file:op.controlling.PnlQMSSchedule.java
private void initPanel() { i18n();// w w w .j av a2 s. c o m txtDueDays.setText(Integer.toString(qmssched.getDuedays())); spinTaeglich.setModel(new SpinnerNumberModel(1, 1, 365, 1)); spinWoche.setModel(new SpinnerNumberModel(1, 1, 52, 1)); spinMonat.setModel(new SpinnerNumberModel(1, 1, 12, 1)); spinYearly.setModel(new SpinnerNumberModel(1, 1, 10, 1)); spinDayInMonth.setModel(new SpinnerNumberModel(1, 1, 31, 1)); spinTaeglich.setValue(Math.max(qmssched.getDaily(), 1)); spinWoche.setValue(Math.max(qmssched.getWeekly(), 1)); spinMonat.setValue(Math.max(qmssched.getMonthly(), 1)); spinDayInMonth.setValue(Math.max(qmssched.getDayinmonth(), 1)); spinYearly.setValue(Math.max(qmssched.getYearly(), 1)); cbMon.setSelected(true); cmbMonth.setSelectedIndex(qmssched.isYearly() ? qmssched.getMonthinyear() - 1 : 0); spinDayInMonthInYear.setModel(new SpinnerNumberModel(qmssched.isYearly() ? qmssched.getDayinmonth() : 1, 1, maxdays[cmbMonth.getSelectedIndex()], 1)); cmbMonth.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { spinDayInMonthInYear .setModel(new SpinnerNumberModel(1, 1, maxdays[cmbMonth.getSelectedIndex()], 1)); } } }); if (qmssched.isDaily()) { tabWdh.setSelectedIndex(TAB_DAILY); } else if (qmssched.isWeekly()) { cbMon.setSelected(qmssched.getWeekday() == DateTimeConstants.MONDAY); cbDie.setSelected(qmssched.getWeekday() == DateTimeConstants.TUESDAY); cbMit.setSelected(qmssched.getWeekday() == DateTimeConstants.WEDNESDAY); cbDon.setSelected(qmssched.getWeekday() == DateTimeConstants.THURSDAY); cbFre.setSelected(qmssched.getWeekday() == DateTimeConstants.FRIDAY); cbSam.setSelected(qmssched.getWeekday() == DateTimeConstants.SATURDAY); cbSon.setSelected(qmssched.getWeekday() == DateTimeConstants.SUNDAY); tabWdh.setSelectedIndex(TAB_WEEKLY); } else if (qmssched.isMonthly()) { spinDayInMonth.setValue(qmssched.getDayinmonth()); cmbTag.setSelectedIndex(qmssched.getWeekday()); tabWdh.setSelectedIndex(TAB_MONTHLY); } else if (qmssched.isYearly()) { spinYearly.setValue(qmssched.getYearly()); spinDayInMonthInYear.setValue(qmssched.getDayinmonth()); cmbMonth.setSelectedIndex(qmssched.getMonthinyear() - 1); tabWdh.setSelectedIndex(TAB_YEARLY); } jdcStartingOn.setMinSelectableDate(new Date()); jdcStartingOn.setDate(qmssched.getStartingOn()); ArrayList<Date> timelist = SYSCalendar.getTimeList(); DefaultComboBoxModel dcbm = new DefaultComboBoxModel(timelist.toArray()); dcbm.insertElementAt(null, 0); txtBemerkung.setText(qmssched.getText()); txtQMS.setText(qmssched.getMeasure()); cmbLocation.setTreeModel(new DefaultTreeModel(StationTools.getCompleteStructure())); Object userObject = null; if (qmssched.getHome() != null) { userObject = qmssched.getHome(); } else if (qmssched.getStation() != null) { userObject = qmssched.getStation(); } int row = 0; if (userObject == null) { cmbLocation.setSelectedItem(null); } else { DefaultMutableTreeNode root = (DefaultMutableTreeNode) cmbLocation.getTreeModel().getRoot(); DefaultMutableTreeNode theNode = null; for (Enumeration e = root.depthFirstEnumeration(); e.hasMoreElements() && theNode == null;) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement(); if (userObject.equals(node.getUserObject())) { cmbLocation.setSelectedItem(node); break; } row++; } } }
From source file:phex.gui.dialogs.ExportDialog.java
private void initComponents() { closeEventHandler = new CloseEventHandler(); addWindowListener(closeEventHandler); DefaultComboBoxModel model = new DefaultComboBoxModel(); model.insertElementAt(Localizer.getString("ExportDialog_DefaultHTMLExport"), DEFAULT_HTML_INDEX); model.insertElementAt(Localizer.getString("ExportDialog_MagmaYAMLExport"), DEFAULT_MAGMA_YAML_INDEX); model.insertElementAt(Localizer.getString("ExportDialog_MetalinkXMLExport"), DEFAULT_METALINK_XML_INDEX); model.insertElementAt(Localizer.getString("ExportDialog_RSSXMLExport"), DEFAULT_RSS_XML_INDEX); standardExport = new JRadioButton(Localizer.getString("ExportDialog_StandardExportFormat")); standardExport.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { replaceFileExtForStandardExport(); }//from ww w.j ava 2 s . com }); customExport = new JRadioButton(Localizer.getString("ExportDialog_CustomExportFormat")); customExport.setToolTipText(Localizer.getString("ExportDialog_TTTCustomExportFormat")); ButtonGroup exportFormatGroup = new ButtonGroup(); exportFormatGroup.add(standardExport); exportFormatGroup.add(customExport); standardExport.setSelected(true); standardExportFormatCB = new JComboBox(model); standardExportFormatCB.addActionListener(new ExportTypeListener()); customExportFormatTF = new JTextField(40); customExportFormatTF.setToolTipText(Localizer.getString("ExportDialog_TTTCustomExportFormat")); customExportFormatTF.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { customExport.setSelected(true); } public void keyReleased(KeyEvent e) { customExport.setSelected(true); } public void keyTyped(KeyEvent e) { customExport.setSelected(true); } }); browseCustomFormat = new JButton(Localizer.getString("ExportDialog_Browse")); browseCustomFormat.addActionListener(new BrowseCustomFileBtnListener()); exportAllFiles = new JRadioButton(Localizer.getString("ExportDialog_ExportAllFiles")); // text will be set on initContent() exportSelectedFiles = new JRadioButton(); ButtonGroup exportSourceGroup = new ButtonGroup(); exportSourceGroup.add(exportAllFiles); exportSourceGroup.add(exportSelectedFiles); outputFileTF = new JTextField(40); File defOutFile = new File(SystemUtils.USER_HOME, "shared_files.html"); outputFileTF.setText(defOutFile.getAbsolutePath()); browseOutFile = new JButton(Localizer.getString("ExportDialog_Browse")); browseOutFile.addActionListener(new BrowseOutFileBtnListener()); magnetInclXs = new JCheckBox(Localizer.getString("ExportDialog_MagnetIncludeXS")); magnetInclXs.setToolTipText(Localizer.getString("ExportDialog_TTTMagnetIncludeXS")); magnetInclFreebase = new JCheckBox(Localizer.getString("ExportDialog_MagnetIncludeFreebase")); magnetInclFreebase.setToolTipText(Localizer.getString("ExportDialog_TTTMagnetIncludeFreebase")); // delay setting initial index to ensure all components are available standardExportFormatCB.setSelectedIndex(0); okBtn = new JButton(Localizer.getString("OK")); okBtn.addActionListener(new OkBtnListener()); cancelBtn = new JButton(Localizer.getString("Cancel")); cancelBtn.addActionListener(closeEventHandler); }
From source file:pl.otros.logview.gui.actions.search.SearchAction.java
public void performSearch(String text, SearchDirection direction) { StatusObserver statusObserver = getOtrosApplication().getStatusObserver(); JTabbedPane jTabbedPane = getOtrosApplication().getJTabbedPane(); LogViewPanelWrapper lvPanel = (LogViewPanelWrapper) jTabbedPane.getSelectedComponent(); if (lvPanel == null) { return;/*from w w w . j a v a 2 s . c o m*/ } JTable table = lvPanel.getLogViewPanel().getTable(); NextRowProvider nextRowProvider = NextRowProviderFactory.getFilteredTableRow(table, direction); SearchContext context = new SearchContext(); context.setDataTableModel(lvPanel.getDataTableModel()); SearchMatcher searchMatcher = null; String confKey = null; if (SearchMode.STRING_CONTAINS.equals(searchMode)) { searchMatcher = new StringContainsSearchMatcher(text); confKey = ConfKeys.SEARCH_LAST_STRING; } else if (SearchMode.REGEX.equals(searchMode)) { try { searchMatcher = new RegexMatcher(text); confKey = ConfKeys.SEARCH_LAST_REGEX; } catch (Exception e) { statusObserver.updateStatus("Error in regular expression: " + e.getMessage(), StatusObserver.LEVEL_ERROR); return; } } else if (SearchMode.QUERY.equals(searchMode)) { QueryAcceptCondition acceptCondition; try { acceptCondition = new QueryAcceptCondition(text); searchMatcher = new AcceptConditionSearchMatcher(acceptCondition); confKey = ConfKeys.SEARCH_LAST_QUERY; } catch (RuleException e) { statusObserver.updateStatus("Wrong query rule: " + e.getMessage(), StatusObserver.LEVEL_ERROR); return; } } updateList(confKey, getOtrosApplication().getConfiguration(), text); DefaultComboBoxModel model = (DefaultComboBoxModel) getOtrosApplication().getSearchField().getModel(); model.removeElement(text); model.insertElementAt(text, 0); model.setSelectedItem(text); int maxCount = getOtrosApplication().getConfiguration().getInt(ConfKeys.SEARCH_LAST_COUNT, 30); while (model.getSize() > maxCount) { model.removeElementAt(model.getSize() - 1); } context.setSearchMatcher(searchMatcher); SearchResult searchNext = searchEngine.searchNext(context, nextRowProvider); if (searchNext.isFound()) { int row = table.convertRowIndexToView(searchNext.getRow()); Rectangle rect = table.getCellRect(row, 0, true); table.scrollRectToVisible(rect); table.clearSelection(); table.setRowSelectionInterval(row, row); statusObserver.updateStatus(String.format("Found at row %d", row), StatusObserver.LEVEL_NORMAL); if (markFound) { lvPanel.getDataTableModel().markRows(markerColors, table.convertRowIndexToModel(row)); } scrollToSearchResult( searchMatcher.getFoundTextFragments( lvPanel.getDataTableModel().getLogData(table.convertRowIndexToModel(row))), lvPanel.getLogViewPanel().getLogDetailTextArea()); } else { statusObserver.updateStatus(String.format("\"%s\" not found", text), StatusObserver.LEVEL_WARNING); } }