List of usage examples for javax.swing DefaultComboBoxModel addElement
public void addElement(E anObject)
From source file:edu.ku.brc.af.tasks.subpane.formeditor.EditorPropPanel.java
/** * @param imageName// w w w . j av a 2s . c o m * @return */ protected ValComboBox processImageNameCBX(final String imageName) { List<Pair<String, ImageIcon>> icons = IconManager.getListByType("datamodel", IconManager.IconSize.Std16); //$NON-NLS-1$ ValComboBox cbx = (ValComboBox) formViewObj.getControlByName("imageNameCBX"); //$NON-NLS-1$ DefaultComboBoxModel model = (DefaultComboBoxModel) cbx.getModel(); model.addElement(getResourceString("EditorPropPanel.NONE")); //$NON-NLS-1$ int inx = 0; int cnt = 1; for (Pair<String, ImageIcon> iconPair : icons) { model.addElement(iconPair.first); if (StringUtils.isNotEmpty(imageName) && iconPair.first.equals(imageName)) { inx = cnt; } cnt++; } cbx.getComboBox().setSelectedIndex(inx); return cbx; }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.EditorPropPanelOld.java
/** * @param labelFor//from w ww . ja v a2 s .com * @return */ protected ValComboBox getIdCombobox(final String labelFor) { ValComboBox cbx = (ValComboBox) formViewObj.getControlByName("labelForCBX"); //$NON-NLS-1$ DefaultComboBoxModel model = (DefaultComboBoxModel) cbx.getModel(); model.addElement(getResourceString("EditorPropPanelOld.NONE")); //$NON-NLS-1$ int inx = 0; if (StringUtils.isNotEmpty(labelFor)) { model.addElement(getNameForId(labelFor)); inx = 1; } for (FormCellField fcf : fieldsNotUsedByLabels) { model.addElement(fcf.getName()); } cbx.getComboBox().setSelectedIndex(inx); return cbx; }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.EditorPropPanelOld.java
/** * @param imageName// w w w . j av a2 s . c om * @return */ protected ValComboBox processImageNameCBX(final String imageName) { List<Pair<String, ImageIcon>> icons = IconManager.getListByType("datamodel", IconManager.IconSize.Std16); //$NON-NLS-1$ ValComboBox cbx = (ValComboBox) formViewObj.getControlByName("imageNameCBX"); //$NON-NLS-1$ DefaultComboBoxModel model = (DefaultComboBoxModel) cbx.getModel(); model.addElement(getResourceString("EditorPropPanelOld.NONE")); //$NON-NLS-1$ int inx = 0; int cnt = 1; for (Pair<String, ImageIcon> iconPair : icons) { model.addElement(iconPair.first); if (StringUtils.isNotEmpty(imageName) && iconPair.first.equals(imageName)) { inx = cnt; } cnt++; } cbx.getComboBox().setSelectedIndex(inx); return cbx; }
From source file:com.mirth.connect.client.ui.panels.export.MessageExportPanel.java
private void initComponents() { contentComboBox.setToolTipText(/*from ww w .j a v a2s . co m*/ "<html>The content that will be exported: Either the entire message serialized into XML, or a specific content type<br />from either the source connector message or the destination connector messages.</html>"); encryptCheckBox.setToolTipText("<html>If checked, the exported message content will be encrypted.</html>"); attachmentsCheckBox.setToolTipText( "<html>If checked and the content type is set to XML serialized message,<br/>the exported message will contain any attachments.</html>"); compressComboBox.setToolTipText( "<html>When compression is enabled, the files/folders created according to the<br />File Pattern will be put into a compressed file in the Root Path.</html>"); exportServerRadio.setToolTipText( "<html>Store exported files on the Mirth Connect Server, in the Root Path specified below.</html>"); exportLocalRadio.setToolTipText( "<html>Store exported files on this computer, in the Root Path specified below.</html>"); rootPathTextField.setToolTipText( "<html>The root path to store the exported files/folders or compressed file.<br/>Relative paths will be resolved against the Mirth Connect Server home directory.</html>"); filePatternTextPane.setToolTipText( "<html>The file/folder pattern in which to write the exported message files.<br />Variables from the Variables list to the right may be used in the pattern.</html>"); archiverBlockSizeField.setToolTipText( "<html>The number of messages that will be cached by the archiver. Increase this value<br/>to improve performance. Decrease this value to reduce memory usage. This value<br/>must be between 1 and 1000. The recommended value for most servers is 50.</html>"); archiveYes = new MirthRadioButton("Yes"); archiveNo = new MirthRadioButton("No"); DefaultComboBoxModel model = new DefaultComboBoxModel(); model.addElement(XML_EXPORT_FORMAT); model.addElement(new ExportFormat(false, "Source", ContentType.RAW)); model.addElement(new ExportFormat(false, "Source", ContentType.PROCESSED_RAW)); model.addElement(new ExportFormat(false, "Source", ContentType.TRANSFORMED)); model.addElement(new ExportFormat(false, "Source", ContentType.ENCODED)); model.addElement(new ExportFormat(false, "Source", ContentType.RESPONSE)); model.addElement(new ExportFormat(true, "Destination", ContentType.RAW)); model.addElement(new ExportFormat(true, "Destination", ContentType.TRANSFORMED)); model.addElement(new ExportFormat(true, "Destination", ContentType.ENCODED)); model.addElement(new ExportFormat(true, "Destination", ContentType.SENT)); model.addElement(new ExportFormat(true, "Destination", ContentType.RESPONSE)); model.addElement(new ExportFormat(true, "Destination", ContentType.PROCESSED_RESPONSE)); model.addElement(new ExportFormat(false, "", ContentType.SOURCE_MAP)); model.addElement(new ExportFormat(false, "", ContentType.CHANNEL_MAP)); model.addElement(new ExportFormat(false, "", ContentType.RESPONSE_MAP)); contentComboBox.setModel(model); contentComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!contentComboBox.getSelectedItem().toString().equalsIgnoreCase(XML_EXPORT_FORMAT)) { attachmentsCheckBox.setEnabled(false); attachmentsCheckBox.setSelected(false); } else { attachmentsCheckBox.setEnabled(true); } } }); model = new DefaultComboBoxModel(); model.addElement(NO_COMPRESSION); for (ArchiveFormat archiveFormat : ArchiveFormat.values()) { model.addElement(archiveFormat); } compressComboBox.setModel(model); ArrayList<String> variables = new ArrayList<String>(); variables.add("Message ID"); variables.add("Server ID"); variables.add("Channel ID"); variables.add("Original File Name"); variables.add("Formatted Message Date"); variables.add("Formatted Current Date"); variables.add("Timestamp"); variables.add("Unique ID"); variables.add("Count"); varListScrollPane.setBackground(UIConstants.BACKGROUND_COLOR); varListPanel.setBackground(UIConstants.BACKGROUND_COLOR); varListPanel.setBorder(BorderFactory.createEmptyBorder()); varListPanel.setLayout(new BorderLayout()); varListPanel.add(varListScrollPane); varListScrollPane.setViewportView(varList); varList.setListData(variables.toArray()); archiveButtonGroup.add(archiveYes); archiveButtonGroup.add(archiveNo); archiveYes.setSelected(true); archiverBlockSizeField.setDocument(new MirthFieldConstraints(4, false, false, true)); if (archiverMode) { rootPathExtLabel.setText("/" + ARCHIVER_MODE_PATTERN + "/"); } else { rootPathExtLabel.setVisible(false); } exportButtonGroup.add(exportServerRadio); exportButtonGroup.add(exportLocalRadio); exportServerRadio.setSelected(true); browseButton.setEnabled(false); filePatternTextPane.setText("message_${message.messageId}.xml"); filePatternScrollPane.setViewportView(filePatternTextPane); // this is the list of components that will be disabled when the archive radio "No" is selected, see archiveChanged() archiveComponents = new Component[] { archiverBlockSizeLabel, archiverBlockSizeField, contentLabel, contentComboBox, encryptCheckBox, attachmentsCheckBox, varList, varListScrollPane, varListPanel, compressLabel, compressComboBox, exportToLabel, exportServerRadio, exportLocalRadio, browseButton, rootPathLabel, rootPathTextField, rootPathExtLabel, filePatternLabel, filePatternScrollPane, filePatternTextPane }; // @formatter:off archiveYes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { archiveChanged(); } }); archiveNo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { archiveChanged(); } }); compressComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { compressComboBoxChanged(); } }); browseButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { browseSelected(); } }); exportServerRadio.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { exportDestinationChanged(); } }); exportLocalRadio.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { exportDestinationChanged(); } }); // @formatter:on }
From source file:edu.ku.brc.specify.prefs.FormattingPrefsPanel.java
/** * /* www . j a v a 2 s.com*/ */ protected void fillFormTypes() { String[] formTypeArray = { "win", "lnx", "mac", "exp" }; String[] formTypeDesc = { "Small Font Format (ideal for Windows)", "Medium Font Format (ideal for Linux)", "Large Font Format (ideal for Mac)", "Elastic Layout" }; // I18N String curFormType = AppPreferences.getLocalPrefs().get("ui.formatting.formtype", UIHelper.getOSTypeAsStr()); int selectedInx = 0; int inx = 0; DefaultComboBoxModel model = (DefaultComboBoxModel) formTypesCBX.getModel(); for (String type : formTypeArray) { model.addElement(formTypeDesc[inx]); formTypeHash.put(formTypeDesc[inx], type); if (curFormType != null && curFormType.equals(type)) { selectedInx = inx; } inx++; } formTypesCBX.getComboBox().setSelectedIndex(selectedInx); formTypesCBX.getComboBox().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { form.getValidator().dataChanged(null, null, null); } }); }
From source file:edu.ku.brc.af.ui.forms.formatters.DataObjAggregatorDlg.java
protected void updateFieldValueCombo() { // clear combo box list DefaultComboBoxModel cboModel = (DefaultComboBoxModel) fieldOrderCbo.getModel(); cboModel.removeAllElements();/*from w w w. j a v a 2 s.c o m*/ // add an empty entry at the beginning so the user can clear the selection if he wants to cboModel.addElement(getResourceString("NONE")); // add fields to combo box List<DBFieldInfo> fields = tableInfo.getFields(); int selectedFieldIndex = 0; for (int i = 0; i < fields.size(); ++i) { DBFieldInfo currentField = fields.get(i); cboModel.addElement(currentField); if (selectedAggregator != null && currentField.getName().equals(selectedAggregator.getOrderFieldName())) { // found the selected field // current combo index is (i+1) because of empty entry at the beginning selectedFieldIndex = i + 1; } } // set selected field fieldOrderCbo.setSelectedIndex(selectedFieldIndex); }
From source file:ch.zhaw.simulation.diagram.charteditor.DefaultPlotEditor.java
/** * Standard constructor - constructs a panel for editing the properties of * the specified plot.//w w w .java 2 s.co m * <P> * In designing the panel, we need to be aware that subclasses of Plot will * need to implement subclasses of PlotPropertyEditPanel - so we need to * leave one or two 'slots' where the subclasses can extend the user * interface. * * @param plot * the plot, which should be changed. */ public DefaultPlotEditor(Plot plot) { this.plotInsets = plot.getInsets(); this.backgroundPaintSample = new PaintSample(plot.getBackgroundPaint()); this.outlineStrokeSample = new StrokeSample(plot.getOutlineStroke()); this.outlinePaintSample = new PaintSample(plot.getOutlinePaint()); // Disabled because makes no sense for us // if (plot instanceof CategoryPlot) { // this.plotOrientation = ((CategoryPlot) plot).getOrientation(); // } else if (plot instanceof XYPlot) { // this.plotOrientation = ((XYPlot) plot).getOrientation(); // } if (plot instanceof CategoryPlot) { CategoryItemRenderer renderer = ((CategoryPlot) plot).getRenderer(); if (renderer instanceof LineAndShapeRenderer) { LineAndShapeRenderer r = (LineAndShapeRenderer) renderer; this.drawLines = BooleanUtilities.valueOf(r.getBaseLinesVisible()); this.drawShapes = BooleanUtilities.valueOf(r.getBaseShapesVisible()); } } else if (plot instanceof XYPlot) { XYItemRenderer renderer = ((XYPlot) plot).getRenderer(); if (renderer instanceof StandardXYItemRenderer) { StandardXYItemRenderer r = (StandardXYItemRenderer) renderer; this.drawLines = BooleanUtilities.valueOf(r.getPlotLines()); this.drawShapes = BooleanUtilities.valueOf(r.getBaseShapesVisible()); } } setLayout(new BorderLayout()); this.availableStrokeSamples = new StrokeSample[4]; this.availableStrokeSamples[0] = new StrokeSample(null); this.availableStrokeSamples[1] = new StrokeSample(new BasicStroke(1.0f)); this.availableStrokeSamples[2] = new StrokeSample(new BasicStroke(2.0f)); this.availableStrokeSamples[3] = new StrokeSample(new BasicStroke(3.0f)); // create a panel for the settings... JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), plot.getPlotType() + localizationResources.getString(":"))); JPanel general = new JPanel(new BorderLayout()); general.setBorder(BorderFactory.createTitledBorder(localizationResources.getString("General"))); JPanel interior = new JPanel(new LCBLayout(7)); interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); interior.add(new JLabel(localizationResources.getString("Outline_stroke"))); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (StrokeSample s : this.availableStrokeSamples) { model.addElement(s.getStroke()); } this.cbOutlineStroke = new JComboBox(model); this.cbOutlineStroke.setSelectedItem(this.outlineStrokeSample.getStroke()); this.cbOutlineStroke.setRenderer(new StrokeComboboxRenderer()); interior.add(this.cbOutlineStroke); interior.add(new JLabel()); interior.add(new JLabel(localizationResources.getString("Outline_Paint"))); JButton button = new JButton(localizationResources.getString("Select...")); button.setActionCommand("OutlinePaint"); button.addActionListener(this); interior.add(this.outlinePaintSample); interior.add(button); interior.add(new JLabel(localizationResources.getString("Background_paint"))); button = new JButton(localizationResources.getString("Select...")); button.setActionCommand("BackgroundPaint"); button.addActionListener(this); interior.add(this.backgroundPaintSample); interior.add(button); // Disabled because makes no sense for us // if (this.plotOrientation != null) { // boolean isVertical = // this.plotOrientation.equals(PlotOrientation.VERTICAL); // int index = isVertical ? ORIENTATION_VERTICAL : // ORIENTATION_HORIZONTAL; // interior.add(new // JLabel(localizationResources.getString("Orientation"))); // this.orientationCombo = new JComboBox(orientationNames); // this.orientationCombo.setSelectedIndex(index); // this.orientationCombo.setActionCommand("Orientation"); // this.orientationCombo.addActionListener(this); // interior.add(this.orientationCombo); // interior.add(new JPanel()); // } if (this.drawLines != null) { interior.add(new JLabel(localizationResources.getString("Draw_lines"))); this.drawLinesCheckBox = new JCheckBox(); this.drawLinesCheckBox.setSelected(this.drawLines.booleanValue()); this.drawLinesCheckBox.setActionCommand("DrawLines"); this.drawLinesCheckBox.addActionListener(this); interior.add(new JPanel()); interior.add(this.drawLinesCheckBox); } if (this.drawShapes != null) { interior.add(new JLabel(localizationResources.getString("Draw_shapes"))); this.drawShapesCheckBox = new JCheckBox(); this.drawShapesCheckBox.setSelected(this.drawShapes.booleanValue()); this.drawShapesCheckBox.setActionCommand("DrawShapes"); this.drawShapesCheckBox.addActionListener(this); interior.add(new JPanel()); interior.add(this.drawShapesCheckBox); } general.add(interior, BorderLayout.NORTH); JPanel appearance = new JPanel(new BorderLayout()); appearance.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); appearance.add(general, BorderLayout.NORTH); JTabbedPane tabs = new JTabbedPane(); tabs.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); Axis domainAxis = null; if (plot instanceof CategoryPlot) { domainAxis = ((CategoryPlot) plot).getDomainAxis(); } else if (plot instanceof XYPlot) { domainAxis = ((XYPlot) plot).getDomainAxis(); } this.domainAxisPropertyPanel = DefaultAxisEditor.getInstance(domainAxis); if (this.domainAxisPropertyPanel != null) { this.domainAxisPropertyPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); tabs.add(localizationResources.getString("Domain_Axis"), this.domainAxisPropertyPanel); } Axis rangeAxis = null; if (plot instanceof CategoryPlot) { rangeAxis = ((CategoryPlot) plot).getRangeAxis(); } else if (plot instanceof XYPlot) { rangeAxis = ((XYPlot) plot).getRangeAxis(); } this.rangeAxisPropertyPanel = DefaultAxisEditor.getInstance(rangeAxis); if (this.rangeAxisPropertyPanel != null) { this.rangeAxisPropertyPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); tabs.add(localizationResources.getString("Range_Axis"), this.rangeAxisPropertyPanel); } tabs.add(localizationResources.getString("Appearance"), appearance); panel.add(tabs); add(panel); }
From source file:edu.ku.brc.specify.prefs.FormattingPrefsPanel.java
/** * // w w w.ja v a 2 s . c o m */ protected void fillDateFormat() { String currentFormat = AppPreferences.getRemote().get("ui.formatting.scrdateformat", null); TimeZone tz = TimeZone.getDefault(); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()); dateFormatter.setTimeZone(tz); String dateStr = dateFormatter.format(Calendar.getInstance().getTime()); Character ch = null; for (int i = 0; i < 10; i++) { if (!StringUtils.isNumeric(dateStr.substring(i, i + 1))) { ch = dateStr.charAt(i); break; } } if (ch != null) { boolean skip = false; Vector<String> formats = new Vector<String>(); if (ch == '/') { addFormats(formats, '/'); skip = true; } if (ch != '.') { addFormats(formats, '.'); skip = true; } if (ch != '-') { addFormats(formats, '-'); skip = true; } if (!skip) { addFormats(formats, ch); } int selectedInx = 0; int inx = 0; DefaultComboBoxModel model = (DefaultComboBoxModel) dateFieldCBX.getModel(); for (String fmt : formats) { model.addElement(fmt); if (currentFormat != null && currentFormat.equals(fmt)) { selectedInx = inx; } inx++; } dateFieldCBX.getComboBox().setSelectedIndex(selectedInx); } }
From source file:edu.ku.brc.specify.datamodel.busrules.PickListBusRules.java
/** * @param tablesCBX//from w w w . j a v a 2 s.com */ private void fillTableNameCBX(final ValComboBox tablesCBX) { if (tablesCBX.getComboBox().getModel().getSize() == 0) { DefaultComboBoxModel tblModel = (DefaultComboBoxModel) tablesCBX.getComboBox().getModel(); String noneStr = getResourceString("NONE"); DBTableInfo none = new DBTableInfo(-1, PickList.class.getName(), "none", "", ""); none.setTitle(noneStr); tblModel.addElement(none); for (DBTableInfo ti : DBTableIdMgr.getInstance().getTables()) { if (DataModelObjBase.class.isAssignableFrom(ti.getClassObj()) && !ti.getName().startsWith("sp") && !ti.getName().startsWith("workbench") && !ti.getName().startsWith("user") && !ti.getName().startsWith("appres")) { tblModel.addElement(ti); } } } }
From source file:gtu._work.ui.SvnLastestCommitInfoUI.java
void reloadFileExtensionComboBox() { DefaultComboBoxModel model = new DefaultComboBoxModel(); model.addElement(""); for (String extension : fileExtenstionSet) { model.addElement(extension);/*from w w w . j a v a 2s . c o m*/ } fileExtensionComboBox.setModel(model); fileExtensionFilter.setModel(model); }