Example usage for javax.swing DefaultComboBoxModel addElement

List of usage examples for javax.swing DefaultComboBoxModel addElement

Introduction

In this page you can find the example usage for javax.swing DefaultComboBoxModel addElement.

Prototype

public void addElement(E anObject) 

Source Link

Usage

From source file:co.com.soinsoftware.hotelero.view.JFRoomService.java

private void setServiceTypeModel() {
    this.serviceTypeList = serviceTypeController.select();
    final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
    model.addElement("Seleccione uno...");
    for (final ServiceType serviceType : this.serviceTypeList) {
        model.addElement(serviceType.getName());
    }/*  www . ja  v  a 2s  . c  om*/
    this.jcbServiceCategory.setModel(model);
}

From source file:co.com.soinsoftware.hotelero.view.JFRoomService.java

private void setServiceModel(final ServiceType serviceType) {
    this.serviceList = this.serviceController.selectByServiceType(serviceType);
    final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
    model.addElement("Seleccione uno...");
    for (final Service service : this.serviceList) {
        if (service.isEnabled()) {
            model.addElement(service.getName());
        }//  w w  w  .  j  a v a2  s. c  o  m
    }
    this.jcbService.setModel(model);
}

From source file:gtu._work.ui.SvnLastestCommitInfoUI.java

void reloadAuthorComboBox() {
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    model.addElement("");
    for (String author : authorSet) {
        boolean findRef = false;
        for (Map.Entry<?, ?> _entry : authorProps.entrySet()) {
            if (_entry.getKey().equals(author)) {
                model.addElement(_entry);
                findRef = true;//from ww  w.  j a va2s.  c  om
                break;
            }
        }
        if (!findRef) {
            model.addElement(author);
        }
    }
    authorComboBox.setModel(model);
}

From source file:com.mirth.connect.connectors.tcp.TcpListener.java

public TcpListener() {
    this.parent = PlatformUI.MIRTH_FRAME;
    initComponents();/*from w w w  .  j  a v  a2s.c o m*/
    initToolTips();
    initLayout();

    reconnectIntervalField.setDocument(new MirthFieldConstraints(0, false, false, true));
    receiveTimeoutField.setDocument(new MirthFieldConstraints(0, false, false, true));
    bufferSizeField.setDocument(new MirthFieldConstraints(0, false, false, true));
    maxConnectionsField.setDocument(new MirthFieldConstraints(0, false, false, true));

    DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
    model.addElement("Basic TCP");
    selectedMode = "Basic TCP";

    for (String pluginPointName : LoadedExtensions.getInstance().getTransmissionModePlugins().keySet()) {
        model.addElement(pluginPointName);
        if (pluginPointName.equals("MLLP")) {
            defaultProvider = LoadedExtensions.getInstance().getTransmissionModePlugins().get(pluginPointName)
                    .createProvider();
        }
    }

    transmissionModeComboBox.setModel(model);

    parent.setupCharsetEncodingForConnector(charsetEncodingComboBox);
}

From source file:edu.ku.brc.af.tasks.subpane.formeditor.EditorPropPanelBase.java

/**
 * @param fc//from w w  w. jav a2s  .  co m
 * @param rows
 * @param rowInx
 * @param cols
 * @param colInx
 * @param enableNaming
 */
protected void setDataIntoBase(final FormCell fc, final int rows, final int rowDefs, final int rowInx,
        final int cols, final int colDefs, final int colInx, final boolean enableNaming) {
    if (formViewObj == null) {
        return;
    }

    int inx;
    int cnt;

    String fName = fc.getName();
    ValComboBox nameCBX = (ValComboBox) formViewObj.getControlByName("namecbx"); //$NON-NLS-1$
    if (StringUtils.isNotEmpty(fName) || enableNaming) {
        DefaultComboBoxModel model = (DefaultComboBoxModel) nameCBX.getModel();
        inx = -1;
        cnt = 0;
        for (DBFieldInfo fi : tableInfo.getFields()) {
            model.addElement(fi.getTitle());
            //System.out.println("["+fi.getName()+"]["+fName+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            if (fi.getTitle().equals(fName) || fi.getName().equals(fName)) {
                inx = cnt;
            }
            cnt++;
        }
        for (DBRelationshipInfo ri : tableInfo.getRelationships()) {
            if (ri.getType() == DBRelationshipInfo.RelationshipType.ManyToOne) {
                model.addElement(ri.getTitle());
                if (inx == -1) {
                    //System.out.println("*["+ri.getTitle()+"]["+fName+"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                    if (ri.getTitle().equals(fName) || ri.getName().equals(fName)) {
                        inx = cnt;
                    }
                }
                cnt++;
            }
        }
        nameCBX.getComboBox().setSelectedIndex(inx);
        nameCBX.setEnabled(true);

    } else {
        nameCBX.setEnabled(false);
    }

    if (true) {
        int rowDefsLeft = rowDefs - rows;

        ValComboBox rowSpanCBX = (ValComboBox) formViewObj.getControlByName("rowspancbx"); //$NON-NLS-1$
        DefaultComboBoxModel model = (DefaultComboBoxModel) rowSpanCBX.getModel();
        if (rowDefsLeft == 0) {
            model.addElement("1"); //$NON-NLS-1$
            inx = 0;
            rowSpanCBX.setEnabled(false);

        } else {
            inx = 0;
            cnt = 0;
            for (int i = 1; i <= rowDefsLeft; i++) {
                model.addElement(Integer.toString(i));
                if (i == fc.getRowspan()) {
                    inx = cnt;
                }
            }
            rowSpanCBX.setEnabled(rowDefsLeft > 1);
            rowSpanCBX.getComboBox().setSelectedIndex(inx);
        }

        ValComboBox colSpanCBX = (ValComboBox) formViewObj.getControlByName("colspancbx"); //$NON-NLS-1$
        model = (DefaultComboBoxModel) colSpanCBX.getModel();
        int colDefsLeft = colDefs - cols;
        if (colDefsLeft == 0) {
            model.addElement("1"); //$NON-NLS-1$
            inx = 1;
            colSpanCBX.setEnabled(false);

        } else {
            inx = 0;
            cnt = 0;
            for (int i = 1; i <= colDefsLeft; i++) {
                model.addElement(Integer.toString(i));
                if (i == fc.getColspan()) {
                    inx = cnt;
                }
            }
            colSpanCBX.setEnabled(colDefsLeft > 1);
            colSpanCBX.getComboBox().setSelectedIndex(inx);
        }
    }

    ValCheckBox chkbx = (ValCheckBox) formViewObj.getControlByName("ignoreSetGet"); //$NON-NLS-1$
    chkbx.setSelected(fc.isIgnoreSetGet());

    chkbx = (ValCheckBox) formViewObj.getControlByName("changeListenerOnly"); //$NON-NLS-1$
    chkbx.setSelected(fc.isChangeListenerOnly());
}

From source file:edu.ku.brc.specify.datamodel.busrules.PickListBusRules.java

/**
 * // ww  w  .j  ava  2  s  .  co m
 */
private void tableSelected(final FormViewObj fvo) {
    ValComboBox formatterCBX = (ValComboBox) fvo.getControlByName("formatterCBX");
    ValComboBox tablesCBX = (ValComboBox) fvo.getControlByName("tablesCBX");
    ValComboBox fieldsCBX = (ValComboBox) fvo.getControlByName("fieldsCBX");

    fvo.getValidator().setHasChanged(true);
    tablesCBX.setChanged(true);

    //int typeIndex = typesCBX.getComboBox().getSelectedIndex();

    String noneStr = getResourceString("NONE");

    PickList pickList = (PickList) fvo.getDataObj();
    if (pickList == null) {
        return;
    }

    JComboBox tableCbx = tablesCBX.getComboBox();
    DBTableInfo tblInfo = (DBTableInfo) tableCbx.getSelectedItem();
    if (tblInfo != null) {
        if (tblInfo.getName().equals(noneStr)) {
            pickList.setTableName(null);
            pickList.setFieldName(null);
            pickList.setFormatter(null);

        } else {
            pickList.setTableName(tblInfo.getName());

            DefaultComboBoxModel fldModel = (DefaultComboBoxModel) fieldsCBX.getComboBox().getModel();
            fldModel.removeAllElements();

            for (DBFieldInfo fi : tblInfo.getFields()) {
                if (fi.getDataClass() == String.class) {
                    fldModel.addElement(fi);
                }
            }

            Vector<DataObjSwitchFormatter> list = new Vector<DataObjSwitchFormatter>();
            for (DataObjSwitchFormatter fmt : DataObjFieldFormatMgr.getInstance().getFormatters()) {
                if (fmt.getDataClass() == tblInfo.getClassObj()) {
                    list.add(fmt);
                }
            }

            DefaultComboBoxModel fmtModel = (DefaultComboBoxModel) formatterCBX.getComboBox().getModel();
            fmtModel.removeAllElements();

            if (list.size() > 0) {
                Collections.sort(list);

                for (DataObjSwitchFormatter fmt : list) {
                    fmtModel.addElement(fmt);
                }
                formatterCBX.setEnabled(true);
            } else {
                formatterCBX.setEnabled(false);
            }
        }

    } else {
        fieldsCBX.setEnabled(false);
    }
}

From source file:edu.ku.brc.af.tasks.subpane.formeditor.EditorPropPanelBase.java

/**
 * @param fcf/*w w w .  jav a 2s.  c om*/
 * @param rows
 * @param rowInx
 * @param cols
 * @param colInx
 */
public void setDataIntoUI(final FormCellField fcf, final int rows, final int rowDefs, final int rowInx,
        final int cols, final int colDefs, final int colInx) {
    if (formViewObj == null) {
        return;
    }
    currentData = fcf;

    //viewPanel.getMultiView().setData(fcf);
    int inx;
    int cnt;

    setDataIntoBase(fcf, rows, rowDefs, rowInx, cols, colDefs, colInx, true);
    setDataIntoBase(fcf);

    JTextField typeLabel = (JTextField) formViewObj.getControlByName("type"); //$NON-NLS-1$
    typeLabel.setText(fcf.getUiType().toString());

    /*
    ValComboBox typeCBX = (ValComboBox)formViewObj.getControlByName("typecbx");
    DefaultComboBoxModel model = (DefaultComboBoxModel)typeCBX.getModel();
    inx = -1;
    cnt = 0;
    for (String type : subcontrolHash.keySet())
    {
    model.addElement(type);
    if (type.equals(fcf.getUiType().toString()))
    {
        inx = cnt;
    }
    cnt++;
    }
    typeCBX.getComboBox().setSelectedIndex(inx);*/

    if (fcf.getUiType() == FormCellFieldIFace.FieldType.combobox) {
        DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession();
        List<?> pickLists = session.getDataList(PickList.class);
        ValComboBox pickListCBX = (ValComboBox) formViewObj.getControlByName("picklistcbx"); //$NON-NLS-1$
        DefaultComboBoxModel model = (DefaultComboBoxModel) pickListCBX.getModel();
        inx = 0;
        cnt = 1;

        String dataPickListName = fcf.getPickListName();

        pickList.clear();
        model.addElement(getResourceString("EditorPropPanelBase.NONE")); //$NON-NLS-1$
        for (Iterator<?> iter = pickLists.iterator(); iter.hasNext();) {
            PickList pl = (PickList) iter.next();
            String name = pl.getName();
            pickList.put(pl.getName(), pl.getIdentityTitle());
            model.addElement(name);
            if (StringUtils.isNotEmpty(dataPickListName) && dataPickListName.equals(name)) {
                inx = cnt;
            }
            cnt++;
        }
        session.close();
        pickListCBX.getComboBox().setSelectedIndex(inx);

        ValTextArea textArea = (ValTextArea) formViewObj.getControlByName("list"); //$NON-NLS-1$
        String list = fcf.getProperty("list"); //$NON-NLS-1$
        if (list != null) {
            textArea.setText(list);
        }
    }

    multiView.validateAll();
}

From source file:edu.ku.brc.specify.datamodel.busrules.PickListBusRules.java

@Override
public void adjustForm(final FormViewObj fvo) {
    final ValComboBox formatterCBX = (ValComboBox) fvo.getControlByName("formatterCBX");
    final ValComboBox tablesCBX = (ValComboBox) fvo.getControlByName("tablesCBX");
    final ValComboBox fieldsCBX = (ValComboBox) fvo.getControlByName("fieldsCBX");
    final ValComboBox typesCBX = (ValComboBox) fvo.getControlByName("typesCBX");
    final ValCheckBox readOnlyChk = (ValCheckBox) fvo.getControlByName("readOnly");

    tablesCBX.getComboBox().addActionListener(new ActionListener() {
        @Override/*from   w  w w  .  j a  v a2 s . c o m*/
        public void actionPerformed(ActionEvent e) {
            tableSelected(fvo);
        }
    });

    typesCBX.getComboBox().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            typeSelected(fvo);
        }
    });

    readOnlyChk.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (!readOnlyChk.isSelected() && formViewObj.getDataObj() != null) {
                adjustSizeSpinner();
            }
        }
    });

    fieldsCBX.setEnabled(false);
    formatterCBX.setEnabled(false);

    fillTableNameCBX(tablesCBX);

    DefaultComboBoxModel model = (DefaultComboBoxModel) typesCBX.getComboBox().getModel();
    model.removeAllElements();
    String[] types = { getResourceString("PL_ITEMS"), getResourceString("PL_TABLE"),
            getResourceString("PLTABLEFIELD") };
    for (String title : types) {
        model.addElement(title);
    }
}

From source file:edu.ku.brc.af.ui.forms.formatters.DataObjFieldFormatDlg.java

/**
 * Populates the field value combo with fields and leaves the right one
 * selected (for multiple formats)//from w w w  . j a v a  2s  . co  m
 */
protected void addValueFieldsToCombo(DataObjSwitchFormatter switchFormatter) {
    // clear combo box list
    DefaultComboBoxModel cboModel = (DefaultComboBoxModel) valueFieldCbo.getModel();
    cboModel.removeAllElements();

    // add fields to combo box
    List<DBFieldInfo> fields = tableInfo.getFields();
    int selectedFieldIndex = -1;
    for (int i = 0; i < fields.size(); ++i) {
        DBFieldInfo currentField = fields.get(i);
        cboModel.addElement(currentField);
        if (switchFormatter != null && currentField.getName().equals(switchFormatter.getFieldName())) {
            // found the selected field
            selectedFieldIndex = i;
        }
    }

    // set selected field
    if (selectedFieldIndex != -1) {
        valueFieldCbo.setSelectedIndex(selectedFieldIndex);
    }
}

From source file:edu.ku.brc.specify.config.init.TaxonLoadSetupPanel.java

@Override
public void doingNext() {
    super.doingNext();

    DisciplineType disciplineType = (DisciplineType) properties.get("disciplineType");
    if (disciplineType != null) {
        DefaultComboBoxModel model = new DefaultComboBoxModel();
        Vector<TaxonFileDesc> taxonFileDescs = readTaxonLoadFiles();
        if (taxonFileDescs != null) {
            for (TaxonFileDesc tfd : taxonFileDescs) {
                if (tfd.getDiscipline().equals(disciplineType.getName())) {
                    model.addElement(tfd);
                }//from   w w  w. ja v  a  2  s. co m
            }

            fileCBX.setModel(model);
            if (model.getSize() > 0) {
                fileCBX.setSelectedIndex(0);
            }

            if (firstTime) {
                firstTime = false;
                fileCBX.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        fileSelected();
                    }
                });
            }
            fileSelected();

        } else {
            fileCBX.setEnabled(false);
            preloadChk.setEnabled(false);
        }
    }
}