List of usage examples for javax.swing DefaultListModel DefaultListModel
DefaultListModel
From source file:paquete.HollywoodUI.java
private void cb_list_modificaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cb_list_modificaItemStateChanged this.tf_nombre_modificar.setText(((Actor) cb_list_modifica.getSelectedItem()).getNombre()); this.tf_edad_modificar.setText(((Actor) cb_list_modifica.getSelectedItem()).getEdad() + ""); this.tf_nacionalidad_modificar.setText(((Actor) cb_list_modifica.getSelectedItem()).getNacionalidad()); //aplicando todos las peliculas a la lista DefaultListModel<Pelicula> lista_peliculas_actor = new DefaultListModel<>(); for (int i = 0; i < ((Actor) cb_list_modifica.getSelectedItem()).getListPelicula().size(); i++) { lista_peliculas_actor.addElement(((Actor) cb_list_modifica.getSelectedItem()).getListPelicula().get(i)); System.out.println(i + 1 + ")" + ((Actor) cb_list_modifica.getSelectedItem()).getListPelicula().get(i)); }/*from w w w. j av a2 s. co m*/ this.list_peliculas_modificar.setModel(lista_peliculas_actor); }
From source file:pcgen.gui.sources.SourceSelectionDialog.java
/** * This method is called from within the constructor to * initialize the form./*from www . j av a 2 s.c om*/ */ private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(new java.awt.GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(4, 4, 4, 4); JLabel jLabel1 = new JLabel(LanguageBundle.getString("in_qsrc_intro")); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0.0, 0.0); getContentPane().add(jLabel1, gbc); sourceList = new javax.swing.JList(); sourceModel = new DefaultListModel(); List<String> strings = getSourceNames(); for (String string : strings) { sourceModel.addElement(string); } sourceList.setModel(sourceModel); sourceList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); sourceList.setLayoutOrientation(JList.VERTICAL_WRAP); sourceList.setVisibleRowCount(2); sourceList.setCellRenderer(new SourceListCellRenderer()); JScrollPane listScrollPane = new JScrollPane(sourceList); listScrollPane.setPreferredSize(new Dimension(480, 260)); if (lastLoadedCollection != null && lastLoadedCollection.length() > 0) { sourceList.setSelectedValue(lastLoadedCollection, true); } Utility.buildRelativeConstraints(gbc, 2, 5, 100, 100, GridBagConstraints.BOTH, GridBagConstraints.WEST); getContentPane().add(listScrollPane, gbc); JButton addButton = new JButton(LanguageBundle.getString("in_add")); addButton.setActionCommand(ACTION_ADD); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); getContentPane().add(addButton, gbc); modifyButton = new JButton(LanguageBundle.getString("in_modify")); modifyButton.setActionCommand(ACTION_MODIFY); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); getContentPane().add(modifyButton, gbc); JButton hideButton = new JButton(LanguageBundle.getString("in_hide")); hideButton.setActionCommand(ACTION_HIDE); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH); getContentPane().add(hideButton, gbc); JButton unhideButton = new JButton(LanguageBundle.getString("in_unhide")); unhideButton.setActionCommand(ACTION_UNHIDE); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH); getContentPane().add(unhideButton, gbc); deleteButton = new JButton(LanguageBundle.getString("in_delete")); deleteButton.setActionCommand(ACTION_DELETE); Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH); getContentPane().add(deleteButton, gbc); JButton advancedButton = new JButton(LanguageBundle.getString("in_qsrc_advanced")); advancedButton.setActionCommand(ACTION_ADVANCED); getRootPane().setDefaultButton(advancedButton); Utility.buildRelativeConstraints(gbc, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST); getContentPane().add(advancedButton, gbc); JButton loadButton = new JButton(LanguageBundle.getString("in_load")); loadButton.setActionCommand(ACTION_LOAD); getRootPane().setDefaultButton(loadButton); Utility.buildRelativeConstraints(gbc, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.EAST); getContentPane().add(loadButton, gbc); JButton cancelButton = new JButton(LanguageBundle.getString("in_cancel")); cancelButton.setActionCommand(ACTION_CANCEL); Utility.buildRelativeConstraints(gbc, 1, 1, 0, 0); getContentPane().add(cancelButton, gbc); //Listen for actions on the buttons addButton.addActionListener(this); modifyButton.addActionListener(this); deleteButton.addActionListener(this); hideButton.addActionListener(this); unhideButton.addActionListener(this); advancedButton.addActionListener(this); loadButton.addActionListener(this); cancelButton.addActionListener(this); sourceList.addListSelectionListener(this); valueChanged(null); //Listen for actions on the list sourceList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { sourceListMouseClicked(evt); } }); pack(); }
From source file:pipeline.parameter_cell_views.MultiList.java
private void update() { boolean saveSilenceUpdate = silenceUpdate; silenceUpdate = true;// w w w. jav a 2s. c om String[] choices = currentParameter.getChoices(); model = new DefaultListModel<>(); for (String choice : choices) { model.addElement(choice); } list.setModel(model); int[] desiredSelection = currentParameter.getSelection(); currentChoices = new int[desiredSelection.length]; System.arraycopy(desiredSelection, 0, currentChoices, 0, desiredSelection.length); list.setSelectedIndices(currentChoices); if (currentChoices.length > 0) list.ensureIndexIsVisible(currentChoices[0]); scrollPane.setPreferredSize(list.getPreferredSize()); Dimension d = scrollPane.getPreferredSize(); d.height = Math.min(d.height, maximalHeight); scrollPane.setPreferredSize(d); this.setPreferredSize(d); int heightWanted = (int) Math.min(list.getPreferredSize().getHeight(), maximalHeight); if (owningTable != null && heightWanted > owningTable.getRowHeight(ourRow)) owningTable.setRowHeight(ourRow, heightWanted); setToolTipText( Utils.encodeHTML(WordUtils.wrap(currentParameter.getParamNameDescription()[1], 50, null, true)) .replace("\n", "<br>\n")); silenceUpdate = saveSilenceUpdate; }
From source file:pl.otros.logview.filter.MultipleSelectionFilter.java
public MultipleSelectionFilter(String name, String desc, String label, char mnemonic) { super(name, desc); this.name = name; this.desc = desc; this.label = label; this.mnemonic = mnemonic; selectedItems = new HashSet<>(); listModel = new DefaultListModel<>(); jList = new JList<>(listModel); jList.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); jList.addListSelectionListener(e -> { if (!e.getValueIsAdjusting()) { selectedItems.clear();/*from w ww . j a v a 2s . c o m*/ Object[] selectedValues = jList.getSelectedValues(); for (Object selectedValue : selectedValues) { selectedItems.add((String) selectedValue); } listener.valueChanged(); } }); JLabel jLabel = new JLabel(label); jLabel.setLabelFor(jList); jLabel.setDisplayedMnemonic(mnemonic); panel = new JPanel(new MigLayout()); panel.add(jLabel, "wrap"); jList.setVisibleRowCount(5); JScrollPane jScrollPane = new JScrollPane(jList); jScrollPane.setPreferredSize(new Dimension(100, 100)); jScrollPane.setMinimumSize(new Dimension(100, 100)); panel.add(new JScrollPane(jList), "wrap, right, growx"); panel.add(new JLabel("Use CTRL for multi selection"), "wrap"); panel.add(new JXHyperlink(new AbstractAction("Invert selection") { @Override public void actionPerformed(ActionEvent e) { invertSelection(); } }), "wrap"); panel.add(new JXHyperlink(new AbstractAction("Clear selection") { @Override public void actionPerformed(ActionEvent e) { clearSelection(); } }), "wrap"); panel.add(new JXHyperlink(new AbstractAction("Reload threads") { @Override public void actionPerformed(ActionEvent e) { reloadFilterSet(); } }), "wrap"); }
From source file:pl.otros.logview.filter.ThreadFilter.java
public ThreadFilter() { super(NAME, DESCRIPTION); selectedThread = new HashSet<String>(); listModel = new DefaultListModel(); jList = new JList(listModel); jList.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); jList.addListSelectionListener(new ListSelectionListener() { @Override/*from w w w. ja v a 2s .co m*/ public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { selectedThread.clear(); Object[] selectedValues = jList.getSelectedValues(); for (Object selectedValue : selectedValues) { selectedThread.add((String) selectedValue); } listener.valueChanged(); } } }); JLabel jLabel = new JLabel("Threads:"); jLabel.setLabelFor(jList); jLabel.setDisplayedMnemonic('t'); panel = new JPanel(new MigLayout()); panel.add(jLabel, "wrap"); panel.add(new JScrollPane(jList), "wrap, right, growx"); panel.add(new JLabel("Use CTRL for multi selection"), "wrap"); panel.add(new JXHyperlink(new AbstractAction("Invert selection") { @Override public void actionPerformed(ActionEvent e) { invertSelection(); } }), "wrap"); panel.add(new JXHyperlink(new AbstractAction("Clear selection") { @Override public void actionPerformed(ActionEvent e) { clearSelection(); } }), "wrap"); panel.add(new JXHyperlink(new AbstractAction("Reload threads") { @Override public void actionPerformed(ActionEvent e) { reloadThreads(); } }), "wrap"); }
From source file:pro.miner.classess.MergeListFreqCounter.java
public static void countFreq() { Form_domain_expert.pbofwordnet.setIndeterminate(true); list1_list2_freq_model.removeAllElements(); Form_domain_expert.list1_list2_freq.removeAll(); mergeListFreq.clear();//from w w w .ja v a 2 s.com mergeListProb.clear(); DefaultListModel list1_list2_model = new DefaultListModel(); for (int i = 0; i < Form_domain_expert.list1_list2.getModel().getSize(); i++) { String word = Form_domain_expert.list1_list2.getModel().getElementAt(i).toString(); fillProbAndFreq(word); Double Frequency = Double.parseDouble(mergeListFreq.get(word).toString()); if (Frequency > 1.0) { list1_list2_model.addElement(Form_domain_expert.list1_list2.getModel().getElementAt(i)); list1_list2_freq_model.addElement(Double.parseDouble(mergeListFreq.get(word).toString())); } } Form_domain_expert.pbofwordnet.setIndeterminate(false); Form_domain_expert.list1_list2_freq.setModel(list1_list2_freq_model); Form_domain_expert.list1_list2.setModel(list1_list2_model); }
From source file:ro.nextreports.designer.querybuilder.RuntimeParametersPanel.java
private void initUI() { setLayout(new GridBagLayout()); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); components = new ArrayList<JComponent>(); checks = new ArrayList<JCheckBox>(); int size = paramList.size(); boolean shouldExpand = false; boolean needScroll = false; for (int i = 0; i < size; i++) { final int pos = i; final QueryParameter param = paramList.get(i); if (param.isHidden()) { components.add(null);/*w w w .j a va 2 s.c o m*/ checks.add(null); initHiddenParameterValues(param); continue; } String source = param.getSource(); String defaultSource = param.getDefaultSource(); if ((defaultSource != null) && !defaultSource.trim().equals("")) { try { param.setDefaultSourceValues(Globals.getDBViewer().getDefaultSourceValues(con, param)); } catch (NextSqlException e) { Show.error(e); } } final JComponent component; int anchor = GridBagConstraints.WEST; double y = 0.0; int expand = GridBagConstraints.HORIZONTAL; if ((source != null) && !source.equals("")) { List<IdName> values = new ArrayList<IdName>(); try { if (param.isManualSource()) { if (!param.isDependent()) { values = Globals.getDBViewer().getValues(con, source, true, param.getOrderBy()); } } else { int index = source.indexOf("."); int index2 = source.lastIndexOf("."); String tableName = source.substring(0, index); String columnName; String shownColumnName = null; if (index == index2) { columnName = source.substring(index + 1); } else { columnName = source.substring(index + 1, index2); shownColumnName = source.substring(index2 + 1); } values = Globals.getDBViewer().getColumnValues(con, param.getSchema(), tableName, columnName, shownColumnName, param.getOrderBy()); } } catch (NextSqlException e) { error = true; Show.error(e); } catch (InvalidSqlException e) { String m = I18NSupport.getString("source.dialog.valid"); Show.info(m + " : \"select <exp1> , <exp2> from ...\""); } if (param.getSelection().equals(ParameterEditPanel.SINGLE_SELECTION)) { component = new JComboBox(); final JComboBox combo = (JComboBox) component; combo.setRenderer(new IdNameRenderer()); combo.addItem("-- " + I18NSupport.getString("parameter.value.select") + " --"); for (int j = 0, len = values.size(); j < len; j++) { combo.addItem(values.get(j)); } combo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { IdName in = null; if (combo.getSelectedIndex() > 0) { in = (IdName) combo.getSelectedItem(); } parameterSelection(pos, in); } } }); AutoCompleteDecorator.decorate(combo); needScroll = false; } else { anchor = GridBagConstraints.NORTHWEST; y = 1.0; expand = GridBagConstraints.BOTH; DefaultListModel model = new DefaultListModel(); for (int j = 0, len = values.size(); j < len; j++) { model.addElement(values.get(j)); } List srcList = Arrays.asList(model.toArray()); component = new ListSelectionPanel(srcList, new ArrayList(), "", "", true, false) { protected void onAdd() { selection(); } protected void onRemove() { selection(); } // needed for saved parameters on rerun protected void onSetRight() { selection(); } private void selection() { if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) { Object[] values = getDestinationElements().toArray(); if (values.length == 0) { values = new Object[] { ParameterUtil.NULL }; } parameterSelection(pos, values); } } }; ((ListSelectionPanel) component).setListSize(scrListDim); ((ListSelectionPanel) component).setRenderer(new IdNameRenderer(), new IdNameComparator(param.getOrderBy())); shouldExpand = true; } } else { if (param.getSelection().equals(QueryParameter.MULTIPLE_SELECTION)) { anchor = GridBagConstraints.NORTHWEST; y = 1.0; expand = GridBagConstraints.BOTH; ; component = new ListAddPanel(param) { protected void onAdd() { selection(); } protected void onRemove() { selection(); } private void selection() { if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) { Object[] values = getElements().toArray(); parameterSelection(pos, values); } } }; } else { needScroll = false; if (param.getValueClassName().equals("java.util.Date")) { component = new JXDatePicker(); ((JXDatePicker) component).addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if ("date".equals(e.getPropertyName())) { parameterSelection(pos, ((JXDatePicker) component).getDate()); } } }); // hack to fix bug with big popup button JButton popupButton = (JButton) component.getComponent(1); //popupButton.setMargin(new Insets(2, 2, 2, 2)); popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY)); } else if (param.getValueClassName().equals("java.sql.Timestamp") || param.getValueClassName().equals("java.sql.Time")) { component = new JDateTimePicker() { protected void onChange() { parameterSelection(pos, getDate()); } }; // hack to fix bug with big popup button JButton popupButton = (JButton) (((JDateTimePicker) component).getDatePicker()) .getComponent(1); //popupButton.setMargin(new Insets(2, 2, 2, 2)); popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY)); } else if (param.getValueClassName().equals("java.lang.Boolean")) { component = new JCheckBox(); ((JCheckBox) component).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); parameterSelection(pos, selected); } }); } else { component = new JTextField(25); ((JTextField) component).getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { updateFromTextField(e); } @Override public void insertUpdate(DocumentEvent e) { updateFromTextField(e); } @Override public void removeUpdate(DocumentEvent e) { updateFromTextField(e); } private void updateFromTextField(DocumentEvent e) { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { Object value = null; try { if ("".equals(((JTextField) component).getText().trim())) { value = null; } else { value = ParameterUtil.getParameterValueFromString( param.getValueClassName(), ((JTextField) component).getText()); } parameterSelection(pos, value); } catch (Exception e) { e.printStackTrace(); LOG.error(e.getMessage(), e); } } }); } }); } } } components.add(component); final JCheckBox cb = new JCheckBox(I18NSupport.getString("run.parameter.ignore")); checks.add(cb); final JLabel label = new JLabel(getRuntimeParameterName(param)); panel.add(label, new GridBagConstraints(0, i, 1, 1, 0.0, 0.0, anchor, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); final JComponent addComponent; if (needScroll) { JScrollPane scr = new JScrollPane(component, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scr.setPreferredSize(listDim); addComponent = scr; } else { addComponent = component; } panel.add(addComponent, new GridBagConstraints(1, i, 1, 1, 1.0, y, GridBagConstraints.WEST, expand, new Insets(5, 0, 5, 5), 0, 0)); int checkAnchor = GridBagConstraints.WEST; if ((addComponent instanceof JScrollPane) || (addComponent instanceof ListSelectionPanel)) { checkAnchor = GridBagConstraints.NORTHWEST; } if (Globals.getParametersIgnore()) { panel.add(cb, new GridBagConstraints(2, i, 1, 1, 0.0, 0.0, checkAnchor, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); } cb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (cb.isSelected()) { if (addComponent instanceof JScrollPane) { component.setEnabled(false); } label.setEnabled(false); addComponent.setEnabled(false); param.setIgnore(true); } else { if (addComponent instanceof JScrollPane) { component.setEnabled(true); } label.setEnabled(true); addComponent.setEnabled(true); param.setIgnore(false); } } }); } // populate hidden dependent parameters (this will be done if a parameter depends only on a single hidden parameter) // if a parameter depends on a hidden parameter and other parameters, it cannot be populated here for (int i = 0; i < size; i++) { final QueryParameter param = paramList.get(i); if (param.isHidden()) { populateDependentParameters(param, false); } } if (!shouldExpand) { panel.add(new JLabel(), new GridBagConstraints(0, size, 3, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } JScrollPane scrPanel = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrPanel.setPreferredSize(scrDim); scrPanel.setMinimumSize(scrDim); add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); setParameterValues(parametersValues); setParameterIgnore(parametersIgnore); }
From source file:ro.nextreports.designer.querybuilder.RuntimeParametersPanel.java
@SuppressWarnings("unchecked") private void initParameterValue(JComponent component, Object value, String paramName, List<Serializable> defaultValues) { if (value == null) { return;// ww w.j a va 2 s.co m } if (component instanceof JTextField) { ((JTextField) component).setText(value.toString()); } else if (component instanceof JComboBox) { JComboBox combo = ((JComboBox) component); List<IdName> values = (List<IdName>) value; combo.removeAllItems(); combo.addItem("-- " + I18NSupport.getString("parameter.value.select") + " --"); for (int j = 0, len = values.size(); j < len; j++) { combo.addItem(values.get(j)); } Object old = parametersValues.get(paramName); if (old != null) { combo.setSelectedItem(old); } else if ((defaultValues != null) && (defaultValues.size() > 0)) { Serializable id = defaultValues.get(0); if (id instanceof IdName) { id = ((IdName) id).getId(); } combo.setSelectedItem(findIdName(combo.getModel(), id)); } } else if (component instanceof ListSelectionPanel) { ListSelectionPanel lsp = (ListSelectionPanel) component; DefaultListModel model = new DefaultListModel(); if (value != null) { List<IdName> values = (List<IdName>) value; for (int j = 0, len = values.size(); j < len; j++) { model.addElement(values.get(j)); } } ArrayList srcList = new ArrayList(Arrays.asList(model.toArray())); Object old = parametersValues.get(paramName); Object[] selected = new Object[0]; if (old != null) { selected = (Object[]) old; } else if ((defaultValues != null) && (defaultValues.size() > 0)) { selected = new Object[defaultValues.size()]; for (int k = 0, len = selected.length; k < len; k++) { Serializable id = defaultValues.get(k); if (id instanceof IdName) { id = ((IdName) id).getId(); } IdName in = findIdName(srcList, id); selected[k] = in; } } List dstList = Arrays.asList(selected); if (!srcList.containsAll(dstList)) { dstList = new ArrayList(); parametersValues.put(paramName, null); } else { srcList.removeAll(dstList); } if ((dstList.size() == 1) && ParameterUtil.NULL.equals(dstList.get(0))) { dstList = new ArrayList(); } lsp.setLists(srcList, dstList); } else if (component instanceof ListAddPanel) { ListAddPanel lap = (ListAddPanel) component; DefaultListModel model = new DefaultListModel(); if (value != null) { List<Object> values = (List<Object>) value; for (int j = 0, len = values.size(); j < len; j++) { model.addElement(values.get(j)); } } ArrayList srcList = new ArrayList(Arrays.asList(model.toArray())); Object old = parametersValues.get(paramName); Object[] selected = new Object[0]; if (old != null) { selected = (Object[]) old; } else if ((defaultValues != null) && (defaultValues.size() > 0)) { selected = new Object[defaultValues.size()]; for (int k = 0, len = selected.length; k < len; k++) { Serializable id = defaultValues.get(k); if (id instanceof IdName) { id = ((IdName) id).getId(); } selected[k] = id; } } List dstList = Arrays.asList(selected); if (!srcList.containsAll(dstList)) { dstList = new ArrayList(); parametersValues.put(paramName, null); } else { srcList.removeAll(dstList); } if ((dstList.size() == 1) && ParameterUtil.NULL.equals(dstList.get(0))) { dstList = new ArrayList(); } lap.setElements(dstList); } else if (component instanceof JDateTimePicker) { ((JDateTimePicker) component).setDate((Date) value); } else if (component instanceof JXDatePicker) { ((JXDatePicker) component).setDate((Date) value); } else if (component instanceof JCheckBox) { ((JCheckBox) component).setSelected((Boolean) value); } }
From source file:ru.apertum.qsystem.client.forms.FReception.java
private void showServiceInfo(QService service) { listLine.setModel(new DefaultListModel<>()); String s = ""; //NOI18N for (QServiceLang sl : service.getLangs()) { s = s + ", " + sl.getLang(); //NOI18N }//from ww w . j av a 2 s. c om s = s.length() > 1 ? "[" + s.substring(2) + "]" : ""; //NOI18N labelServiceInfo.setText("<html><body text=\"#336699\"> " + (service.getEnable() == 1 ? "" : "<font color=\"#FF0000\">!*** </font>") + s + " " + getLocaleMessage("service.service") + service.getSeqId() + ": \"" + "<font color=\"#000000\">" + service.getName() + "\" " + "</font>" //NOI18N + "<font color=\"#" + (service.getStatus() == 1 //NOI18N //NOI18N ? "00AA00\">" + getLocaleMessage("service.kind.active") //NOI18N : (service.getStatus() == 0 ? "CCAA00\">" + getLocaleMessage("service.kind.not_active") : "DD0000\">" + getLocaleMessage("service.kind.unavailable"))) + "/" + service.getPoint() //NOI18N + "</font>" + "; " + getLocaleMessage("service.prefix") + ": " + "<font color=\"#DD0000\">" + service.getPrefix() + "</font>" + "; " + getLocaleMessage("service.description") + ": " + service.getDescription() //NOI18N //NOI18N + ";<br>" + getLocaleMessage("service.restrict_day_reg") + ": " + (service.getDayLimit() == 0 ? getLocaleMessage("service.work_calendar.no") : service.getDayLimit()) //NOI18N + ";<br>" + getLocaleMessage("service.restrict_adv_reg") + " " + service.getAdvanceTimePeriod() + " " + getLocaleMessage("service.min") + ": " + service.getAdvanceLimit() //NOI18N + ";<br> " + getLocaleMessage("service.restrict_adv_period") + ": " + service.getAdvanceLimitPeriod() //NOI18N + ";<br>"// + getLocaleMessage("service.work_calendar") + ": " + "<font color=\"#" + (service.getCalendar() == null ? "DD0000\">" + getLocaleMessage("service.work_calendar.no") : "000000\">" + service.getCalendar().toString()) + "</font>" + "; " + getLocaleMessage("service.work_calendar.plan") + ": " + "<font color=\"#" + (service.getSchedule() == null ? "DD0000\">" + getLocaleMessage("service.work_calendar.no") : "000000\">" + service.getSchedule().toString()) + "</font>" + ";<br>" //NOI18N + (service.getInput_required() ? getLocaleMessage("service.required_client_data") + ": \"" + service.getInput_caption().replaceAll("<[^>]*>", "") + "\"(" + service.getPersonDayLimit() + ")" : getLocaleMessage("service.required_client_data.not")) + ";<br> " + (service.getResult_required() ? getLocaleMessage("service.required_result") : getLocaleMessage("service.required_result.not")) + ";"); // final LinkedList<QUser> usr = new LinkedList<>(); for (int i = 0; i < listUsers.getModel().getSize(); i++) { final QUser user = ((DefaultComboBoxModel<QUser>) listUsers.getModel()).getElementAt(i); if (user.hasService(service)) { usr.add(user); } } listUsersOfService.setModel(new DefaultComboBoxModel(usr.toArray())); }
From source file:sd_conexion_bd.Servicios.java
/** * Cargar la lista de los contactos del usuario de la base de datos y mostararla como lista en el tab contactos * lista es la lista donde se va a presentar los contactos del usuario *//*from w ww . j a v a 2 s. c om*/ public void cargar_contactos(JList lista, String userName, int u_id) { try { this.conectar("localhost:3306", "mensajeria", "mensajeria", "1234"); ////this.conectar("192.168.43.21:3306", "mensajeria","mensajeria","1234"); this.consulta = this.conexion .prepareStatement("call consultar_contactos(\"" + userName + "\",\"" + u_id + "\");"); this.datos = this.consulta.executeQuery(); DefaultListModel modelo = new DefaultListModel(); while (this.datos.next()) { modelo.addElement(datos.getString("nombre") + " " + datos.getString("apellido")); } lista.setModel(modelo); } catch (ClassNotFoundException | SQLException ex) { Logger.getLogger(Servicios.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(null, "No se pudo conectar correctamente a la base de datos"); } }