Example usage for com.jgoodies.binding.adapter BasicComponentFactory createComboBox

List of usage examples for com.jgoodies.binding.adapter BasicComponentFactory createComboBox

Introduction

In this page you can find the example usage for com.jgoodies.binding.adapter BasicComponentFactory createComboBox.

Prototype

public static <E> JComboBox createComboBox(SelectionInList<E> selectionInList) 

Source Link

Document

Creates and returns a non-editable JComboBox that is bound to the given SelectionInList.

Usage

From source file:ambit2.dbui.dictionary.DictionaryQueryPanel.java

License:Open Source License

@Override
protected JComponent createConditionComponent() {
    return BasicComponentFactory.createComboBox(new SelectionInList<StringCondition>(
            new StringCondition[] { StringCondition.getInstance(StringCondition.C_EQ),
                    StringCondition.getInstance(StringCondition.C_LIKE),
                    StringCondition.getInstance(StringCondition.C_NOTLIKE),
                    StringCondition.getInstance(StringCondition.C_REGEXP),
                    StringCondition.getInstance(StringCondition.C_SOUNDSLIKE), },
            presentationModel.getModel("condition")));
}

From source file:ambit2.dbui.dictionary.DictionaryQueryPanel.java

License:Open Source License

protected JComponent createFieldnameComponent() {
    ValueHolder vh = new ValueHolder();
    SelectionInList<Dictionary> fieldnames = new SelectionInList<Dictionary>(new RowsModel<Dictionary>(parents),
            vh);//from www .  j  ava2 s  . c o m
    fieldnames.addPropertyChangeListener("value", new PropertyChangeListener() {
        final TemplateQuery tq = new TemplateQuery();

        public void propertyChange(PropertyChangeEvent evt) {
            try {

                if (evt.getNewValue() != null) {
                    tq.setCondition(StringCondition.getInstance(StringCondition.C_EQ));
                    tq.setValue(((Dictionary) evt.getNewValue()).getTemplate());
                    details.setQuery(tq);
                    if (details.size() == 0)
                        details.close();
                    else {
                        details.beforeFirst();
                        while (details.next()) {
                            profile.add(details.getObject());
                        }
                    }
                }

            } catch (Exception x) {
                x.printStackTrace();
            }

        }
    });

    JComboBox box = BasicComponentFactory.createComboBox(fieldnames);
    box.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if ((value != null) && (c instanceof JLabel))
                ((JLabel) c).setText(((Dictionary) value).getTemplate());
            return c;
        }
    });
    return box;

}

From source file:ambit2.dbui.QueryChemicalEditor.java

License:Open Source License

@Override
protected JComponent createConditionComponent() {
    JComboBox box = BasicComponentFactory.createComboBox(new SelectionInList<StringCondition>(
            new StringCondition[] { StringCondition.getInstance(StringCondition.C_EQ),
                    StringCondition.getInstance(StringCondition.C_LIKE),
                    StringCondition.getInstance(StringCondition.C_NOTLIKE),
                    StringCondition.getInstance(StringCondition.C_REGEXP),
                    StringCondition.getInstance(StringCondition.C_SOUNDSLIKE), },
            presentationModel.getModel("condition")));
    AutoCompleteDecorator.decorate(box);
    return box;/*  w  ww .j  a  v  a 2  s . c o m*/
}

From source file:ambit2.dbui.QueryChemicalEditor.java

License:Open Source License

@Override
protected JComponent createFieldnameComponent() {
    JComboBox box = BasicComponentFactory
            .createComboBox(new SelectionInList<String>(
                    new String[] { ExactStructureSearchMode.inchi.name(),
                            ExactStructureSearchMode.smiles.name(), ExactStructureSearchMode.formula.name(), },
                    presentationModel.getModel("fieldname")));
    AutoCompleteDecorator.decorate(box);
    return box;// w w w . j a v a 2 s . com
}

From source file:ambit2.dbui.QueryDatasetEditor.java

License:Open Source License

@Override
protected JComponent createConditionComponent() {

    JComboBox box = BasicComponentFactory.createComboBox(new SelectionInList<StringCondition>(
            new StringCondition[] { StringCondition.getInstance(StringCondition.C_EQ),
                    StringCondition.getInstance(StringCondition.C_NOTEQ),
                    StringCondition.getInstance(StringCondition.C_LIKE),
                    StringCondition.getInstance(StringCondition.C_NOTLIKE),
                    StringCondition.getInstance(StringCondition.C_REGEXP),
                    StringCondition.getInstance(StringCondition.C_SOUNDSLIKE), },
            presentationModel.getModel("condition")));
    //AutoCompleteDecorator.decorate(box);
    return box;/*from  ww  w .  j a  v  a  2s  . c  o  m*/
}

From source file:ambit2.dbui.QueryDatasetEditor.java

License:Open Source License

@Override
protected JComponent createValueComponent() {
    ListModel fieldnames = new RowsModel<SourceDataset>(datasets);
    JComboBox box = BasicComponentFactory.createComboBox(
            new SelectionInList<SourceDataset>(fieldnames, presentationModel.getModel("dataset")));
    AutoCompleteDecorator.decorate(box);
    return box;//w ww .j a va  2 s .  co  m
}

From source file:ambit2.dbui.QueryFieldNumericEditor.java

License:Open Source License

@Override
protected JComponent createFieldnameComponent() {

    ListModel fieldnames = new RowsModel<Property>(properties) {
        @Override// w  w  w  .  jav a 2 s  .c o m
        public int getSize() {
            return super.getSize() + 1;
        }

        @Override
        public Property getElementAt(int index) {
            if (index == 0)
                return null;
            else
                return super.getElementAt(index - 1);
        }
    };
    SelectionInList<Property> p = new SelectionInList<Property>(fieldnames,
            presentationModel.getModel("fieldname"));
    p.addPropertyChangeListener("value", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            statsQuery.setFieldname((Property) evt.getNewValue());

        }
    });
    JComboBox box = BasicComponentFactory.createComboBox(p);
    AutoCompleteDecorator.decorate(box);
    return box;

}

From source file:ambit2.dbui.QueryFieldNumericEditor.java

License:Open Source License

@Override
protected JComponent createConditionComponent() {
    NumberCondition[] nc = new NumberCondition[NumberCondition.conditions.length];
    for (int i = 0; i < nc.length; i++)
        nc[i] = NumberCondition.getInstance(NumberCondition.conditions[i]);

    SelectionInList<NumberCondition> selectionInList = new SelectionInList<NumberCondition>(nc,
            presentationModel.getModel("condition"));
    selectionInList.addPropertyChangeListener("value", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            presentationModel.getComponentModel("maxValue")
                    .setVisible(NumberCondition.between.equals(evt.getNewValue().toString()));
        }//from   w ww .j a v a 2  s  . com
    });
    JComboBox box = BasicComponentFactory.createComboBox(selectionInList);
    AutoCompleteDecorator.decorate(box);
    return box;
}

From source file:ambit2.dbui.QuerySimilarityEditor.java

License:Open Source License

@Override
protected JComponent createConditionComponent() {
    NumberCondition[] nc = new NumberCondition[NumberCondition.conditions.length - 1];
    for (int i = 0; i < nc.length; i++) {
        nc[i] = NumberCondition.getInstance(NumberCondition.conditions[i]);
    }//from  w ww .j a v a2s  .  com
    SelectionInList<NumberCondition> selectionInList = new SelectionInList<NumberCondition>(nc,
            presentationModel.getModel("condition"));
    JComboBox box = BasicComponentFactory.createComboBox(selectionInList);
    AutoCompleteDecorator.decorate(box);
    return box;
}

From source file:ambit2.dbui.QuerySimilarityEditor.java

License:Open Source License

@Override
protected JComponent createFieldnameComponent() {
    SelectionInList<ClassHolder> selectionInList = new SelectionInList<ClassHolder>(
            QuerySimilarityStructure.methods, presentationModel.getModel("fieldname"));
    JComboBox box = BasicComponentFactory.createComboBox(selectionInList);
    AutoCompleteDecorator.decorate(box);
    return box;//from www  .  j a  va  2s. c o m
}