Search in sources :

Example 61 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project CodenameOne by codenameone.

the class PasswordManagerTestCase2741 method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form f = new Form("Form 1", BoxLayout.y());
    TextField tf1 = new TextField();
    tf1.setConstraint(TextField.PASSWORD);
    f.add(tf1);
    Button b = new Button("Login");
    b.addActionListener(e -> {
        Form f2 = new Form("F2", BoxLayout.y());
        TextField t2 = new TextField();
        ComboBox cb = new ComboBox("Red", "Green", "Blue");
        f2.addAll(t2, cb);
        Button b2 = new Button("Submit");
        f2.add(b2);
        f2.show();
    });
    f.add(b);
    f.show();
}
Also used : Form(com.codename1.ui.Form) Button(com.codename1.ui.Button) ComboBox(com.codename1.ui.ComboBox) TextField(com.codename1.ui.TextField)

Example 62 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project CodenameOne by codenameone.

the class DefaultLookAndFeel method getComboBoxPreferredSize.

/**
 * {@inheritDoc}
 */
public Dimension getComboBoxPreferredSize(List cb) {
    Dimension d = getListPreferredSize(cb);
    Image comboBoxImage = ((ComboBox) cb).getComboBoxImage() != null ? ((ComboBox) cb).getComboBoxImage() : comboImage;
    if (comboBoxImage != null) {
        d.setWidth(d.getWidth() + comboBoxImage.getWidth());
        d.setHeight(Math.max(d.getHeight(), comboBoxImage.getHeight()));
    }
    return d;
}
Also used : ComboBox(com.codename1.ui.ComboBox) Dimension(com.codename1.ui.geom.Dimension) FontImage(com.codename1.ui.FontImage) Image(com.codename1.ui.Image)

Example 63 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project CodenameOne by codenameone.

the class DefaultLookAndFeel method drawComboBox.

/**
 * {@inheritDoc}
 */
public void drawComboBox(Graphics g, List cb) {
    int border = 2;
    Style style = cb.getStyle();
    int leftPadding = style.getPaddingLeft(cb.isRTL());
    int rightPadding = style.getPaddingRight(cb.isRTL());
    setFG(g, cb);
    ListModel model = cb.getModel();
    ListCellRenderer renderer = cb.getRenderer();
    Object value = model.getItemAt(model.getSelectedIndex());
    Image comboBoxImage = ((ComboBox) cb).getComboBoxImage() != null ? ((ComboBox) cb).getComboBoxImage() : comboImage;
    int comboImageWidth;
    if (comboBoxImage != null) {
        comboImageWidth = comboBoxImage.getWidth();
    } else {
        comboImageWidth = style.getFont().getHeight();
    }
    int cellX = cb.getX() + style.getPaddingTop();
    if (cb.isRTL()) {
        cellX += comboImageWidth;
    }
    if (model.getSize() > 0) {
        Component cmp = renderer.getListCellRendererComponent(cb, value, model.getSelectedIndex(), cb.hasFocus());
        cmp.setX(cellX);
        cmp.setY(cb.getY() + style.getPaddingTop());
        cmp.setWidth(cb.getWidth() - comboImageWidth - rightPadding - leftPadding);
        cmp.setHeight(cb.getHeight() - style.getPaddingTop() - style.getPaddingBottom());
        cmp.paint(g);
    }
    g.setColor(style.getBgColor());
    int y = cb.getY();
    int height = cb.getHeight();
    int width = comboImageWidth + border;
    int x = cb.getX();
    if (cb.isRTL()) {
        x += leftPadding;
    } else {
        x += cb.getWidth() - comboImageWidth - rightPadding;
    }
    if (comboBoxImage != null) {
        g.drawImage(comboBoxImage, x, y + height / 2 - comboBoxImage.getHeight() / 2);
    } else {
        int color = g.getColor();
        // brighten or darken the color slightly
        int destColor = findDestColor(color);
        if (style.getBgTransparency() > 0) {
            g.fillLinearGradient(g.getColor(), destColor, x, y, width, height, false);
        }
        g.setColor(color);
        int alpha = g.concatenateAlpha(style.getFgAlpha());
        g.drawRect(x, y, width, height - 1);
        g.setAlpha(alpha);
        width--;
        height--;
        // g.drawRect(x, y, width, height);
        g.translate(x + 1, y + 1);
        g.setColor(0x111111);
        int x1 = scaleCoordinate(2.5652081f, 16, width);
        int y1 = scaleCoordinate(4.4753664f, 16, height);
        int x2 = scaleCoordinate(8.2872691f, 16, width);
        int y2 = scaleCoordinate(10f, 16, height);
        int x3 = scaleCoordinate(13.516078f, 16, width);
        int y3 = y1;
        g.fillTriangle(x1, y1, x2, y2, x3, y3);
        g.translate(-1, -1);
        g.setColor(style.getFgColor());
        alpha = g.concatenateAlpha(style.getFgAlpha());
        g.fillTriangle(x1, y1, x2, y2, x3, y3);
        g.setAlpha(alpha);
        g.translate(-x, -y);
    }
}
Also used : ComboBox(com.codename1.ui.ComboBox) ListModel(com.codename1.ui.list.ListModel) ListCellRenderer(com.codename1.ui.list.ListCellRenderer) FontImage(com.codename1.ui.FontImage) Image(com.codename1.ui.Image) Component(com.codename1.ui.Component)

Example 64 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project CodenameOne by codenameone.

the class HTMLForm method reset.

/**
 * Called when a form reset is needed and resets all the form fields to their default values.
 */
void reset() {
    for (Enumeration e = defaultValues.keys(); e.hasMoreElements(); ) {
        Object input = e.nextElement();
        if (input instanceof TextArea) {
            // catches both textareas and text input fields
            String defVal = (String) defaultValues.get(input);
            if (defVal == null) {
                defVal = "";
            }
            ((TextArea) input).setText(defVal);
        } else if (input instanceof ComboBox) {
            OptionItem defVal = (OptionItem) defaultValues.get(input);
            ComboBox combo = ((ComboBox) input);
            if (defVal != null) {
                combo.setSelectedItem(defVal);
            } else if (combo.size() > 0) {
                combo.setSelectedIndex(0);
            }
        }
    }
    for (Enumeration e = defaultCheckedButtons.elements(); e.hasMoreElements(); ) {
        Button b = (Button) e.nextElement();
        if (!b.isSelected()) {
            setButton(b, true);
        }
    }
    for (Enumeration e = defaultUncheckedButtons.elements(); e.hasMoreElements(); ) {
        Button b = (Button) e.nextElement();
        if (b.isSelected()) {
            setButton(b, false);
        }
    }
}
Also used : Enumeration(java.util.Enumeration) TextArea(com.codename1.ui.TextArea) RadioButton(com.codename1.ui.RadioButton) Button(com.codename1.ui.Button) ComboBox(com.codename1.ui.ComboBox)

Example 65 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project ANNIS by korpling.

the class FlatQueryBuilderTest method setup.

@BeforeEach
public void setup() {
    UIScopeImpl.setBeanStoreRetrievalStrategy(new SingletonBeanStoreRetrievalStrategy());
    this.ui = beanFactory.getBean(AnnisUI.class);
    MockVaadin.setup(() -> this.ui);
    ui.getQueryState().setSelectedCorpora(Sets.newSet("pcc2"));
    // Click on the query builder button and select the flat query builder
    _click(_get(Button.class, spec -> spec.withCaption("Query<br />Builder")));
    ComboBox queryBuilderChooser = _get(_get(QueryBuilderChooser.class), ComboBox.class);
    queryBuilderChooser.select("Word sequences and meta information");
    this.queryBuilder = _get(FlatQueryBuilder.class);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) MenuItem(com.vaadin.ui.MenuBar.MenuItem) CheckBox(com.vaadin.v7.ui.CheckBox) EdgeBox(org.corpus_tools.annis.gui.flatquerybuilder.EdgeBox) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) QueryBuilderChooser(org.corpus_tools.annis.gui.querybuilder.QueryBuilderChooser) Autowired(org.springframework.beans.factory.annotation.Autowired) FlatQueryBuilder(org.corpus_tools.annis.gui.flatquerybuilder.FlatQueryBuilder) ActiveProfiles(org.springframework.test.context.ActiveProfiles) LocatorJ._find(com.github.mvysny.kaributesting.v8.LocatorJ._find) ArrayList(java.util.ArrayList) SpanBox(org.corpus_tools.annis.gui.flatquerybuilder.SpanBox) SingletonBeanStoreRetrievalStrategy(org.corpus_tools.annis.gui.SingletonBeanStoreRetrievalStrategy) MockVaadin(com.github.mvysny.kaributesting.v8.MockVaadin) Sets(org.mockito.internal.util.collections.Sets) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) UIScopeImpl(com.vaadin.spring.internal.UIScopeImpl) LocatorJ._get(com.github.mvysny.kaributesting.v8.LocatorJ._get) MetaBox(org.corpus_tools.annis.gui.flatquerybuilder.MetaBox) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) WebAppConfiguration(org.springframework.test.context.web.WebAppConfiguration) SearchBox(org.corpus_tools.annis.gui.flatquerybuilder.SearchBox) MenuBar(com.vaadin.ui.MenuBar) TextChangeEvent(com.vaadin.v7.event.FieldEvents.TextChangeEvent) AnnisUI(org.corpus_tools.annis.gui.AnnisUI) ComboBox(com.vaadin.v7.ui.ComboBox) Collection(java.util.Collection) LocatorJ._click(com.github.mvysny.kaributesting.v8.LocatorJ._click) Mockito.when(org.mockito.Mockito.when) ValueField(org.corpus_tools.annis.gui.flatquerybuilder.ValueField) SensitiveComboBox(org.corpus_tools.annis.gui.flatquerybuilder.SensitiveComboBox) Test(org.junit.jupiter.api.Test) Button(com.vaadin.ui.Button) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) VerticalNode(org.corpus_tools.annis.gui.flatquerybuilder.VerticalNode) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) BeanFactory(org.springframework.beans.factory.BeanFactory) Mockito.mock(org.mockito.Mockito.mock) QueryBuilderChooser(org.corpus_tools.annis.gui.querybuilder.QueryBuilderChooser) Button(com.vaadin.ui.Button) AnnisUI(org.corpus_tools.annis.gui.AnnisUI) ComboBox(com.vaadin.v7.ui.ComboBox) SensitiveComboBox(org.corpus_tools.annis.gui.flatquerybuilder.SensitiveComboBox) FlatQueryBuilder(org.corpus_tools.annis.gui.flatquerybuilder.FlatQueryBuilder) SingletonBeanStoreRetrievalStrategy(org.corpus_tools.annis.gui.SingletonBeanStoreRetrievalStrategy) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ComboBox (com.vaadin.v7.ui.ComboBox)113 TextField (com.vaadin.v7.ui.TextField)43 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)31 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)28 Label (com.vaadin.ui.Label)24 Disease (de.symeda.sormas.api.Disease)24 TextArea (com.vaadin.v7.ui.TextArea)19 UserDto (de.symeda.sormas.api.user.UserDto)19 NullableOptionGroup (de.symeda.sormas.ui.utils.NullableOptionGroup)19 DateField (com.vaadin.v7.ui.DateField)18 List (java.util.List)18 CheckBox (com.vaadin.v7.ui.CheckBox)17 FacadeProvider (de.symeda.sormas.api.FacadeProvider)17 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)17 DateComparisonValidator (de.symeda.sormas.ui.utils.DateComparisonValidator)17 CommunityReferenceDto (de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto)16 AbstractEditForm (de.symeda.sormas.ui.utils.AbstractEditForm)16 Field (com.vaadin.v7.ui.Field)15 FieldVisibilityCheckers (de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers)15 Captions (de.symeda.sormas.api.i18n.Captions)14