Example usage for com.vaadin.ui ComboBox ComboBox

List of usage examples for com.vaadin.ui ComboBox ComboBox

Introduction

In this page you can find the example usage for com.vaadin.ui ComboBox ComboBox.

Prototype

public ComboBox() 

Source Link

Document

Constructs an empty combo box without a caption.

Usage

From source file:com.save.common.CommonComboBox.java

public static ComboBox clientType() {
    ComboBox select = new ComboBox();
    select.setCaption("Client Type: ");
    select.setWidth("100%");
    select.setNullSelectionAllowed(false);

    for (String s : ConstantData.CLIENT_TYPE) {
        select.addItem(s);/*from   w  ww  .  j a va2s. com*/
    }

    select.addStyleName("small");
    select.setImmediate(true);
    return select;
}

From source file:com.save.common.CommonComboBox.java

public static ComboBox getAllClients() {
    ComboBox select = new ComboBox();
    select.setCaption("Clients: ");
    select.setWidth("100%");
    select.setNullSelectionAllowed(false);
    select.addContainerProperty("y", String.class, "");
    select.setItemCaptionPropertyId("y");

    Item i;/*from   ww w.  j  av  a  2  s .c o  m*/
    ClientService cs = new ClientServiceImpl();
    for (Client c : cs.getAllClients()) {
        i = select.addItem(c.getClientId());
        i.getItemProperty("y").setValue(c.getClientName());
    }

    select.addStyleName("small");
    select.setImmediate(true);
    return select;
}

From source file:com.save.common.CommonComboBox.java

public static ComboBox getAllEmpployees(String caption) {
    ComboBox select = new ComboBox();
    select.setCaption(caption);//from  ww  w.  j a  v a2  s .  c  o  m
    select.setWidth("100%");
    select.setNullSelectionAllowed(false);
    select.addContainerProperty("y", String.class, "");
    select.setItemCaptionPropertyId("y");

    Item i;
    EmployeeService es = new EmployeeServiceImpl();
    for (Employee e : es.getAllEmployees()) {
        i = select.addItem(e.getEmployeeId());
        i.getItemProperty("y").setValue(e.getName());
    }

    select.addStyleName("small");
    select.setImmediate(true);
    return select;
}

From source file:com.save.common.CommonComboBox.java

public static ComboBox employmentStatus(String caption) {
    ComboBox select = new ComboBox();
    select.setCaption(caption);// w w  w.j  a v  a  2s  . c  o  m
    select.setInputPrompt("Select a Position..");
    select.setWidth("100%");
    select.setNullSelectionAllowed(false);
    select.setRequired(true);
    select.setRequiredError("Required Status");

    for (String s : ConstantData.EMPLOYMENT_STATUS) {
        select.addItem(s);
    }

    select.addStyleName("small");
    select.setImmediate(true);
    return select;
}

From source file:com.save.common.CommonComboBox.java

public static ComboBox yearList() {
    ComboBox select = new ComboBox();
    select.setWidth("100%");
    select.setNullSelectionAllowed(false);

    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());

    for (int i = 2012; i < (cal.get(Calendar.YEAR) + 1); i++) {
        select.addItem(String.valueOf(i).replace(",", ""));
    }//from   ww  w .  j  a va  2 s .c o  m

    select.addStyleName("small");
    select.setImmediate(true);
    return select;
}

From source file:com.skysql.manager.ui.MonitorsLayout.java

License:Open Source License

/**
 * Adds a new monitor row.// w  w w. j a  v a  2 s  .c o m
 *
 * @param monitorID the monitor id
 * @return the component
 */
private Component addRow(String monitorID) {
    HorizontalLayout row = new HorizontalLayout();
    ComboBox selectMonitor = new ComboBox();
    for (MonitorRecord availMonitor : availableMonitors.values()) {
        selectMonitor.addItem(availMonitor.getID());
        selectMonitor.setItemCaption(availMonitor.getID(), availMonitor.getName());
    }
    row.addComponent(selectMonitor);
    selectMonitorList.add(selectMonitor);

    selectMonitor.setValue(monitorID);
    selectMonitor.setNullSelectionAllowed(false);
    selectMonitor.setImmediate(true);
    selectMonitor.addValueChangeListener(monitorSelectListener);

    if (getComponentCount() > componentIndex) {
        Button deleteButton = new Button("X");
        row.addComponent(deleteButton);
        deleteButton.setData(selectMonitor);
        deleteButton.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 0x4C656F6E6172646FL;

            public void buttonClick(ClickEvent event) {
                // remove combobox from list
                Button button = event.getButton();
                ComboBox select = (ComboBox) button.getData();
                selectMonitorList.remove(select);

                // remove layout from dialog
                int layoutIndex = getComponentIndex(button.getParent());
                HorizontalLayout layout = (HorizontalLayout) getComponent(layoutIndex);
                removeComponent(layout);

                refreshMonitors();
            }
        });
    }

    focus();

    return (row);

}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentComplaintsPanel.java

private void createCombo() {
    complaintType = new ComboBox();
    complaintType.setTextInputAllowed(false);
    complaintType.setInputPrompt("Seleccione un motivo...");
    complaintType.setWidth("100%");
}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentView.java

private void buildContactInfo() {
    contactInfo = new ComboBox();
    contactInfo.setContainerDataSource(containerContacts);
    contactInfo.setTextInputAllowed(false);
    contactInfo.setInputPrompt("Seleccione un contacto...");
    contactInfo.setWidth("100%");
    rootLayout.addComponent(contactInfo);

    contactInfoDetails = new Button(FontAwesome.PHONE);
    contactInfoDetails.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    contactInfoDetails.addClickListener(new Button.ClickListener() {
        @Override//from w w  w . j a  v  a2  s.com
        public void buttonClick(Button.ClickEvent event) {
            if (appointment.getContactInfo() != null) {
                Notification.show("Funcionalidad en desarrollo.", Notification.Type.ASSISTIVE_NOTIFICATION);
                //customerView.open(appointment.getCustomer());
            }
        }
    });

    HorizontalLayout wrapper = new HorizontalLayout();
    wrapper.setCaption("Contacto");
    wrapper.addComponent(contactInfo);
    wrapper.addComponent(contactInfoDetails);
    wrapper.setWidth("100%");
    wrapper.setExpandRatio(contactInfo, 1);
    rootLayout.addComponent(wrapper);
}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentView.java

private void buildAddress() {
    address = new ComboBox();
    address.setContainerDataSource(containerAddresses);
    address.setTextInputAllowed(false);//ww w.  j a v  a2s. c  o m
    address.setInputPrompt("Seleccione una direccin...");
    address.setWidth("100%");
    rootLayout.addComponent(address);

    addressDetails = new Button(FontAwesome.MAP_MARKER);
    addressDetails.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    addressDetails.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (appointment.getAddress() != null) {
                Notification.show("Funcionalidad en desarrollo.", Notification.Type.ASSISTIVE_NOTIFICATION);
                //customerView.open(appointment.getCustomer());
            }
        }
    });

    HorizontalLayout wrapper = new HorizontalLayout();
    wrapper.setCaption("Direccin");
    wrapper.addComponent(address);
    wrapper.addComponent(addressDetails);
    wrapper.setWidth("100%");
    wrapper.setExpandRatio(address, 1);
    rootLayout.addComponent(wrapper);
}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentView.java

private void buildCustomer() {
    customer = new ComboBox();
    customer.setContainerDataSource(containerCustomers);
    customer.setFilteringMode(FilteringMode.CONTAINS);
    customer.setInputPrompt("Seleccione un cliente...");
    customer.setWidth("100%");
    //<editor-fold defaultstate="collapsed" desc="Adjust ContactInfo and Addresses according to the selected Customer">
    customer.addValueChangeListener(new ValueChangeListener() {

        @Override//from w w  w  . j  a v a 2 s .c  om
        public void valueChange(Property.ValueChangeEvent event) {
            updateCustomerCombos((CustomerCRM) event.getProperty().getValue());
        }

        private void updateCustomerCombos(CustomerCRM customerCRM) {
            if (customerCRM != null) {
                containerAddresses.removeAllItems();
                address.setValue(null);
                containerAddresses.addAll(customerCRMService.find(customerCRM.getId()).getAddressList());
                if (containerAddresses.size() > 0) {
                    address.select(containerAddresses.getIdByIndex(0));
                }

                containerContacts.removeAllItems();
                contactInfo.setValue(null);
                containerContacts.addAll(customerCRMService.find(customerCRM.getId()).getContactInfoList());
                if (containerContacts.size() > 0) {
                    contactInfo.select(containerContacts.getIdByIndex(0));
                }
            } else {
                containerAddresses.removeAllItems();
                address.setValue(null);

                containerContacts.removeAllItems();
                contactInfo.setValue(null);
            }
        }
    });
    //</editor-fold>

    customerDetails = new Button(FontAwesome.EYE);
    customerDetails.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    customerDetails.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (appointment.getCustomer() != null) {
                customerView.open(appointment.getCustomer());
            }
        }
    });

    HorizontalLayout customerWrapper = new HorizontalLayout();
    customerWrapper.setCaption("Cliente");
    customerWrapper.addComponent(customer);
    customerWrapper.addComponent(customerDetails);
    customerWrapper.setWidth("100%");
    customerWrapper.setExpandRatio(customer, 1);
    rootLayout.addComponent(customerWrapper);

    //<editor-fold defaultstate="collapsed" desc="Antiguo buscador de clientes">
    //        Button searchCustomerBtn = new Button("Busca!");
    //        searchCustomerBtn.addClickListener(new Button.ClickListener() {
    //
    //            @Override
    //            public void buttonClick(Button.ClickEvent event) {
    //                CustomerFinderDialogWindow dlgWin = new CustomerFinderDialogWindow(appointment.getCustomer(), customerCRMService){
    //
    //                    @Override
    //                    protected void onButtonCancelClicked() {
    //                        this.close();
    //                    }
    //
    //                    @Override
    //                    protected void onButtonOKClicked() {
    //                        //appointment.setCustomer(this.getSelectedCustomer());
    //                        customer.setValue(this.getSelectedCustomer());
    //                        //updateCustomerCombos(appointment.getCustomer());
    //                        this.close();
    //                    }
    //
    //
    //
    //                };
    //                UI.getCurrent().addWindow(dlgWin);
    //                dlgWin.focus();
    //            }
    //        });
    //        rootLayout.addComponent(searchCustomerBtn);
    //</editor-fold>    
}