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(String caption, Collection<T> options) 

Source Link

Document

Constructs a combo box with a static in-memory data provider with the given options.

Usage

From source file:org.jpos.qi.QIEntityView.java

License:Open Source License

protected List<Validator> getValidators(String propertyId) {
    List<Validator> validators = new ArrayList<>();
    ViewConfig.FieldConfig config = viewConfig.getFields().get(propertyId);
    if (config != null) {
        String regex = config.getRegex();
        int length = config.getLength();
        String[] options = config.getOptions();
        if (options != null) {
            //Change the field to a Combo loaded with the options
            ComboBox combo = new ComboBox(getCaptionFromId("field." + propertyId), Arrays.asList(options));
            getBinder().bind(combo, propertyId);
            return null;
        }//from   w ww.  j  a v  a2  s  . c  om
        if (regex != null) {
            validators.add(
                    new RegexpValidator(getApp().getMessage("errorMessage.invalidField", propertyId), regex));
        }
        if (length > 0) {
            validators.add(new StringLengthValidator(
                    getApp().getMessage("errorMessage.invalidField", propertyId), 0, length));
        }
    }
    return validators;
}

From source file:org.jpos.util.FieldFactory.java

License:Open Source License

public List<Validator> getValidators(String propertyId) {
    if (viewConfig == null)
        return Collections.EMPTY_LIST;
    List<Validator> validators = new ArrayList<>();
    ViewConfig.FieldConfig config = viewConfig.getFields().get(propertyId);
    if (config != null) {
        String regex = config.getRegex();
        int length = config.getLength();
        String[] options = config.getOptions();
        if (options != null) {
            //Change the field to a Combo loaded with the options
            ComboBox combo = new ComboBox(getCaptionFromId("field." + propertyId), Arrays.asList(options));
            getBinder().bind(combo, propertyId);
            return null;
        }//from  w w  w.j a  v  a  2  s .  c  om
        if (regex != null)
            validators.add(
                    new RegexpValidator(getApp().getMessage("errorMessage.invalidField", propertyId), regex));
        if (length > 0)
            validators.add(new StringLengthValidator(
                    getApp().getMessage("errorMessage.invalidField", propertyId), 0, length));
    }
    return validators;
}

From source file:org.milleni.dunning.ui.customer.CustomerSearchPanel.java

License:Apache License

protected void initInputField() {
    /*// ww  w.j  av a  2 s  .  c o m
            
    BeanFieldGroup<Customer>personBinder = new BeanFieldGroup<Customer>(PersonVo.class);
    personBinder.setItemDataSource(person);
    myFormLayout.addComponent(personBinder.buildAndBind("Firstname", "firstName"));
    myFormLayout.addComponent(personBinder.buildAndBind("Country", "country.name"));
            
    */

    formLayout = new FormLayout();

    //txtCustomerId = new TextField(i18nManager.getMessage(Constants.CUSTOMER_ID));
    //formLayout.addComponent(txtCustomerId);

    txtCustomerName = new TextField(i18nManager.getMessage(Constants.CUSTOMER_NAME));
    //formLayout.addComponent(txtCustomerName);

    formLayout.setWidth(100, UNITS_PERCENTAGE); // 99, otherwise the Panel will
    // display scrollbars
    //formLayout.setSpacing(true);
    //formLayout.setMargin(false, false, true, true);

    customer = new Customer();

    Form customerSearchForm = new Form();

    customerSearchForm.setFormFieldFactory(new FormFieldFactory() {
        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {
            Field field = DefaultFieldFactory.get().createField(item, propertyId, uiContext);
            if (field instanceof TextField) {
                ((TextField) field).setNullRepresentation("");
            }

            if ("customerId".equals(propertyId)) {
                ((TextField) field).setCaption(i18nManager.getMessage(Constants.CUSTOMER_ID));
                txtCustomerId = (TextField) field;
                ((TextField) field).setPropertyDataSource(new PropertyFormatter() {

                    @Override
                    public Object parse(String formattedValue) throws Exception {
                        if (StringUtils.hasText(formattedValue))
                            try {
                                return Long.parseLong(formattedValue);
                            } catch (Exception e) {
                                return null;
                            }

                        else
                            return null;
                    }

                    @Override
                    public String format(Object value) {
                        return String.valueOf(value);
                    }
                });

            } else if ("customerName".equals(propertyId)) {
                ((TextField) field).setCaption(i18nManager.getMessage(Constants.CUSTOMER_NAME));
            } else if ("customerType".equals(propertyId)) {
                List<CustomerType> customerTypesList = new ArrayList<CustomerType>();
                Iterable<CustomerType> types = DaoHelper.getInstance().getCustomerService()
                        .listAllCustomerTypes();
                for (CustomerType customerType : types) {
                    customerTypesList.add(customerType);
                }
                BeanItemContainer<CustomerType> objects = new BeanItemContainer(CustomerType.class,
                        customerTypesList);

                ComboBox combo = new ComboBox(i18nManager.getMessage(Constants.CUSTOMER_TYPE), objects);
                combo.setItemCaptionPropertyId("typeName");
                return combo;
            } else if ("customerGroup".equals(propertyId)) {
                List<CustomerGroup> customerGroupList = new ArrayList<CustomerGroup>();
                Iterable<CustomerGroup> groups = DaoHelper.getInstance().getCustomerService()
                        .listAllCustomerGroups();
                for (CustomerGroup customerGroup : groups) {
                    customerGroupList.add(customerGroup);
                }
                BeanItemContainer<CustomerGroup> objects = new BeanItemContainer(CustomerGroup.class,
                        customerGroupList);

                ComboBox combo = new ComboBox(i18nManager.getMessage(Constants.CUSTOMER_GROUP), objects);
                combo.setItemCaptionPropertyId("groupName");
                return combo;
            }
            return field;
        }

    });

    BeanItem<Customer> item = new BeanItem<Customer>(customer,
            new String[] { "customerId", "customerName", "customerType", "customerGroup" });
    //item.addItemProperty(i18nManager.getMessage(Constants.CUSTOMER_ID), new NestedMethodProperty(customer, "customerId"));
    customerSearchForm.setItemDataSource(item);

    formLayout.addComponent(customerSearchForm);

    setContent(formLayout);

}

From source file:org.milleni.dunning.ui.dpdetail.DunningProcessDetailSearchPanel.java

License:Apache License

protected void initInputField() {
    /*//  w  w  w .  j av a2 s .c  o  m
            
    BeanFieldGroup<Customer>personBinder = new BeanFieldGroup<Customer>(PersonVo.class);
    personBinder.setItemDataSource(person);
    myFormLayout.addComponent(personBinder.buildAndBind("Firstname", "firstName"));
    myFormLayout.addComponent(personBinder.buildAndBind("Country", "country.name"));
            
    */

    formLayout = new FormLayout();

    //txtCustomerId = new TextField(i18nManager.getMessage(Constants.CUSTOMER_ID));
    //formLayout.addComponent(txtCustomerId);

    txtCustomerName = new TextField(i18nManager.getMessage(Constants.CUSTOMER_NAME));
    //formLayout.addComponent(txtCustomerName);

    formLayout.setWidth(100, UNITS_PERCENTAGE); // 99, otherwise the Panel will
    // display scrollbars
    //formLayout.setSpacing(true);
    //formLayout.setMargin(false, false, true, true);

    dpMaster = new DunningProcessMaster();
    dpDetail = new DunningProcessDetail();
    Form dpSearchForm = new Form();
    Form dpDetailSearchForm = new Form();

    dpSearchForm.setFormFieldFactory(new FormFieldFactory() {
        @SuppressWarnings("serial")
        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {
            Field field = DefaultFieldFactory.get().createField(item, propertyId, uiContext);
            if (field instanceof TextField) {
                ((TextField) field).setNullRepresentation("");
            }

            if ("dunningPolicyId".equals(propertyId)) {
                List<DunningPolicy> dunningPolicyList = new ArrayList<DunningPolicy>();
                Iterable<DunningPolicy> dunningPolicies = DaoHelper.getInstance().getDunningPolicyRepository()
                        .findAll();
                for (DunningPolicy dunningPolicy : dunningPolicies) {
                    dunningPolicyList.add(dunningPolicy);
                }
                BeanItemContainer<DunningPolicy> objects = new BeanItemContainer(DunningPolicy.class,
                        dunningPolicyList);

                policyCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_POLICY_TYPE), objects);
                policyCombo.addListener(new ValueChangeListener() {

                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        DunningPolicy selectedDunningPolicy = (DunningPolicy) event.getProperty().getValue();
                        List<ProcessSteps> processSteps = DaoHelper.getInstance().getDunningPolicyRepository()
                                .retrieveDunningProcessSteps(selectedDunningPolicy.getPolicyId());
                        BeanItemContainer<ProcessSteps> objects = new BeanItemContainer(ProcessSteps.class,
                                processSteps);
                        stepCombo.setContainerDataSource(objects);
                    }

                });
                policyCombo.setItemCaptionPropertyId("policyName");
                return policyCombo;
            } else if ("processLastStepId".equals(propertyId)) {
                stepCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_POLICY_STEP));
                stepCombo.setItemCaptionPropertyId("stepText");
                return stepCombo;
            } else if ("status".equals(propertyId)) {
                statusCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_PROCESS_STATUS));
                statusCombo.setItemCaptionPropertyId("statusText");
                List<DunningProcessMasterStatus> statusList = DaoHelper.getInstance()
                        .getDunningPolicyRepository().retrieveAllDunningProcessMasterStatus();
                BeanItemContainer<DunningProcessMasterStatus> objects = new BeanItemContainer(
                        DunningProcessMasterStatus.class, statusList);
                statusCombo.setContainerDataSource(objects);
                /*
                statusCombo.addItem(Constants.SUCCESS);
                statusCombo.setItemCaption(Constants.SUCCESS, "Baarl");
                statusCombo.addItem(Constants.WARNING);
                statusCombo.setItemCaption(Constants.WARNING, "Uyar");
                statusCombo.addItem(Constants.ERROR);
                statusCombo.setItemCaption(Constants.ERROR, "Hatal");
                statusCombo.addItem(Constants.INITIAL);
                statusCombo.setItemCaption(Constants.INITIAL, "Balang");
                */
                return statusCombo;
            } else if ("createDate".equals(propertyId)) {
                processStartDate = new DateField("Process Balama Zaman");
                return processStartDate;
            } else if ("customerId".equals(propertyId)) {
                txtCustomerId = (TextField) field;
                txtCustomerId.setCaption(i18nManager.getMessage(Constants.CUSTOMER_ID));
                txtCustomerId.setPropertyDataSource(new PropertyFormatter() {

                    @Override
                    public Object parse(String formattedValue) throws Exception {
                        if (StringUtils.hasText(formattedValue))
                            try {
                                return new Customer(Long.parseLong(formattedValue));
                            } catch (Exception e) {
                                return null;
                            }

                        else
                            return null;
                    }

                    @Override
                    public String format(Object value) {
                        if (value instanceof Customer)
                            return String.valueOf(((Customer) value).getCustomerId());
                        return String.valueOf(value);
                    }
                });
                return txtCustomerId;
            }

            return field;
        }

    });

    dpDetailSearchForm.setFormFieldFactory(new FormFieldFactory() {
        @SuppressWarnings("serial")
        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {
            Field field = DefaultFieldFactory.get().createField(item, propertyId, uiContext);
            if (field instanceof TextField) {
                ((TextField) field).setNullRepresentation("");
            }

            if ("processStepId".equals(propertyId)) {
                stepCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_POLICY_LAST_STEP));
                stepCombo.setItemCaptionPropertyId("stepText");
                return stepCombo;
            } else if ("status".equals(propertyId)) {
                statusCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_PROCESS_STEP_STATUS));
                statusCombo.setItemCaptionPropertyId("statusText");
                List<DunningProcessDetailStatus> statusList = DaoHelper.getInstance()
                        .getDunningPolicyRepository().retrieveAllDunningProcessDetailStatus();
                BeanItemContainer<DunningProcessDetailStatus> objects = new BeanItemContainer(
                        DunningProcessDetailStatus.class, statusList);
                statusCombo.setContainerDataSource(objects);
                return statusCombo;
            } else if ("createDate".equals(propertyId)) {
                stepCreateDate = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STEP_START));
                return stepCreateDate;
            } else if ("statusDate".equals(propertyId)) {
                statusChangeDate = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STEP_STOP));
                return statusChangeDate;
            }

            return field;
        }

    });

    BeanItem<DunningProcessMaster> item = new BeanItem<DunningProcessMaster>(dpMaster,
            new String[] { "dunningPolicyId", "processLastStepId", "createDate", "status" });
    BeanItem<DunningProcessDetail> items = new BeanItem<DunningProcessDetail>(dpDetail,
            new String[] { "status" });

    dpSearchForm.setItemDataSource(item);
    dpDetailSearchForm.setItemDataSource(items);

    stepCreateDateEnd = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STEP_START_END));
    stepCreateDate = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STEP_START));

    statusChangeDate = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STEP_STOP));
    statusChangeDateEnd = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STEP_STOP_END));

    formLayout.addComponent(dpSearchForm);
    formLayout.addComponent(dpDetailSearchForm);

    FormLayout layout = (FormLayout) dpSearchForm.getLayout();
    layout.addComponent(stepCreateDate);
    layout.addComponent(stepCreateDateEnd);
    layout.addComponent(statusChangeDate);
    layout.addComponent(statusChangeDateEnd);

    setContent(formLayout);

}

From source file:org.milleni.dunning.ui.dpmaster.DunningProcessSearchPanel.java

License:Apache License

protected void initInputField() {
    /*/*ww w  .  j ava  2  s .c  om*/
            
    BeanFieldGroup<Customer>personBinder = new BeanFieldGroup<Customer>(PersonVo.class);
    personBinder.setItemDataSource(person);
    myFormLayout.addComponent(personBinder.buildAndBind("Firstname", "firstName"));
    myFormLayout.addComponent(personBinder.buildAndBind("Country", "country.name"));
            
    */

    formLayout = new FormLayout();

    //txtCustomerId = new TextField(i18nManager.getMessage(Constants.CUSTOMER_ID));
    //formLayout.addComponent(txtCustomerId);

    txtCustomerName = new TextField(i18nManager.getMessage(Constants.CUSTOMER_NAME));
    //formLayout.addComponent(txtCustomerName);

    formLayout.setWidth(100, UNITS_PERCENTAGE); // 99, otherwise the Panel will
    // display scrollbars
    //formLayout.setSpacing(true);
    //formLayout.setMargin(false, false, true, true);

    dpMaster = new DunningProcessMaster();

    Form dpSearchForm = new Form();

    dpSearchForm.setFormFieldFactory(new FormFieldFactory() {
        @SuppressWarnings("serial")
        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {
            Field field = DefaultFieldFactory.get().createField(item, propertyId, uiContext);
            if (field instanceof TextField) {
                ((TextField) field).setNullRepresentation("");
            }

            if ("dunningPolicyId".equals(propertyId)) {
                List<DunningPolicy> dunningPolicyList = new ArrayList<DunningPolicy>();
                Iterable<DunningPolicy> dunningPolicies = DaoHelper.getInstance().getDunningPolicyRepository()
                        .findAll();
                for (DunningPolicy dunningPolicy : dunningPolicies) {
                    dunningPolicyList.add(dunningPolicy);
                }
                BeanItemContainer<DunningPolicy> objects = new BeanItemContainer(DunningPolicy.class,
                        dunningPolicyList);

                policyCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_POLICY_TYPE), objects);
                policyCombo.addListener(new ValueChangeListener() {

                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        DunningPolicy selectedDunningPolicy = (DunningPolicy) event.getProperty().getValue();
                        List<ProcessSteps> processSteps = DaoHelper.getInstance().getDunningPolicyRepository()
                                .retrieveDunningProcessSteps(selectedDunningPolicy.getPolicyId());
                        BeanItemContainer<ProcessSteps> objects = new BeanItemContainer(ProcessSteps.class,
                                processSteps);
                        stepCombo.setContainerDataSource(objects);
                        nextStepCombo.setContainerDataSource(objects);
                        currentStepCombo.setContainerDataSource(objects);
                    }

                });
                policyCombo.setItemCaptionPropertyId("policyName");
                return policyCombo;
            } else if ("currentStepId".equals(propertyId)) {
                currentStepCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_POLICY_CURRENT_STEP));
                currentStepCombo.setItemCaptionPropertyId("stepText");
                return currentStepCombo;
            } else if ("processLastStepId".equals(propertyId)) {
                stepCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_POLICY_LAST_STEP));
                stepCombo.setItemCaptionPropertyId("stepText");
                return stepCombo;
            } else if ("nextStepId".equals(propertyId)) {
                nextStepCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_NEXT_STEP));
                nextStepCombo.setItemCaptionPropertyId("stepText");
                return nextStepCombo;
            } else if ("status".equals(propertyId)) {
                statusCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_PROCESS_STATUS));
                statusCombo.setItemCaptionPropertyId("statusText");
                List<DunningProcessMasterStatus> statusList = DaoHelper.getInstance()
                        .getDunningPolicyRepository().retrieveAllDunningProcessMasterStatus();
                BeanItemContainer<DunningProcessMasterStatus> objects = new BeanItemContainer(
                        DunningProcessMasterStatus.class, statusList);
                statusCombo.setContainerDataSource(objects);
                return statusCombo;
            } else if ("customerId".equals(propertyId)) {
                txtCustomerId = (TextField) field;
                txtCustomerId.setCaption(i18nManager.getMessage(Constants.CUSTOMER_ID));
                txtCustomerId.setPropertyDataSource(new PropertyFormatter() {

                    @Override
                    public Object parse(String formattedValue) throws Exception {
                        if (StringUtils.hasText(formattedValue))
                            try {
                                return new Customer(Long.parseLong(formattedValue));
                            } catch (Exception e) {
                                return null;
                            }

                        else
                            return null;
                    }

                    @Override
                    public String format(Object value) {
                        if (value instanceof Customer)
                            return String.valueOf(((Customer) value).getCustomerId());
                        return String.valueOf(value);
                    }
                });
                return txtCustomerId;
            }

            return field;
        }

    });

    BeanItem<DunningProcessMaster> item = new BeanItem<DunningProcessMaster>(dpMaster, new String[] {
            "dunningPolicyId", "currentStepId", "processLastStepId", "nextStepId", "customerId", "status" });
    dpSearchForm.setItemDataSource(item);

    nextStepDateStart = new DateField(i18nManager.getMessage(Constants.DUNNING_NEXT_STEP_DATE_START));
    nextStepDateStart.setDateFormat("dd.MM.yyyy");

    nextStepDateEnd = new DateField(i18nManager.getMessage(Constants.DUNNING_NEXT_STEP_DATE_END));
    nextStepDateEnd.setDateFormat("dd.MM.yyyy");

    processStartDate = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_DATE_START));
    processStartDate.setDateFormat("dd.MM.yyyy");

    processStartEnd = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_DATE_END));
    processStartEnd.setDateFormat("dd.MM.yyyy");

    processStatusDateStart = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STATUS_DATE_START));
    processStatusDateStart.setDateFormat("dd.MM.yyyy");

    processStatusDateEnd = new DateField(i18nManager.getMessage(Constants.DUNNING_PROCESS_STATUS_DATE_END));
    processStatusDateEnd.setDateFormat("dd.MM.yyyy");

    invoiceDateStart = new DateField(i18nManager.getMessage(Constants.DUNNING_INVOICE_DATE_START));
    invoiceDateStart.setDateFormat("dd.MM.yyyy");

    invoiceDateEnd = new DateField(i18nManager.getMessage(Constants.DUNNING_INVOICE_DATE_END));
    invoiceDateEnd.setDateFormat("dd.MM.yyyy");

    //dpSearchForm.addField(processStartFinishDate, processStartFinishDate);

    FormLayout layout = (FormLayout) dpSearchForm.getLayout();
    layout.addComponent(nextStepDateStart);
    layout.addComponent(nextStepDateEnd);
    layout.addComponent(processStartDate);
    layout.addComponent(processStartEnd);
    layout.addComponent(processStatusDateStart);
    layout.addComponent(processStatusDateEnd);
    layout.addComponent(invoiceDateStart);
    layout.addComponent(invoiceDateEnd);

    formLayout.addComponent(dpSearchForm);
    setContent(formLayout);
}

From source file:org.milleni.dunning.ui.prcstart.DunningProcessTimingOperationsPanel.java

License:Apache License

protected void initPageTitle() {
    HorizontalLayout layout = createHorizontalLayout();
    addDetailComponent(layout);/*from  www.j av a2  s.co m*/

    Embedded databaseImage = new Embedded(null, Images.DATABASE_50);
    layout.addComponent(databaseImage);

    Label groupName = new Label("Toplu Tarih Ve Adim Degistirme");
    groupName.setSizeUndefined();
    groupName.addStyleName(Reindeer.LABEL_H2);
    layout.addComponent(groupName);
    layout.setComponentAlignment(groupName, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(groupName, 1.0f);

    List<DunningPolicy> dunningPolicyList = new ArrayList<DunningPolicy>();
    Iterable<DunningPolicy> dunningPolicies = DaoHelper.getInstance().getDunningPolicyRepository().findAll();
    for (DunningPolicy dunningPolicy : dunningPolicies) {
        dunningPolicyList.add(dunningPolicy);
    }
    BeanItemContainer<DunningPolicy> objects = new BeanItemContainer(DunningPolicy.class, dunningPolicyList);

    policyCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_POLICY_TYPE), objects);
    policyCombo.setItemCaptionPropertyId("policyName");

    stepCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_NEXT_STEP));
    stepCombo.setItemCaptionPropertyId("stepText");

    nextStepCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_NEXT_STEP));
    nextStepCombo.setItemCaptionPropertyId("stepText");

    nextStepDateStart = new DateField(i18nManager.getMessage(Constants.DUNNING_NEXT_STEP_DATE_START));
    executionDate = new DateField(i18nManager.getMessage(Constants.DUNNING_NEXT_STEP_DATE_START));
    nextStepDateEnd = new DateField(i18nManager.getMessage(Constants.DUNNING_NEXT_STEP_DATE_END));

    policyCombo.addListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            selectedDunningPolicy = (DunningPolicy) event.getProperty().getValue();
            List<ProcessSteps> processSteps = DaoHelper.getInstance().getDunningPolicyRepository()
                    .retrieveDunningProcessSteps(selectedDunningPolicy.getPolicyId());
            BeanItemContainer<ProcessSteps> objects = new BeanItemContainer(ProcessSteps.class, processSteps);
            stepCombo.setContainerDataSource(objects);
            nextStepCombo.setContainerDataSource(objects);
        }

    });

    stepCombo.addListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            selectedProcessStep = (ProcessSteps) event.getProperty().getValue();
        }

    });

    nextStepCombo.addListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            nextSelectedProcessStep = (ProcessSteps) event.getProperty().getValue();
        }

    });

}

From source file:org.milleni.dunning.ui.prcstart.StepSelectStartDunningProcessPanel.java

License:Apache License

protected void initPageTitle() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, UNITS_PERCENTAGE);
    layout.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    layout.setSpacing(true);//from  w ww.j  av  a 2s .  co m
    layout.setMargin(false, false, true, false);
    addDetailComponent(layout);

    Embedded databaseImage = new Embedded(null, Images.DATABASE_50);
    layout.addComponent(databaseImage);

    Label groupName = new Label(i18nManager.getMessage(Messages.MAIN_MENU_DUNNING_PROCESS_BASLAT));
    groupName.setSizeUndefined();
    groupName.addStyleName(Reindeer.LABEL_H2);
    layout.addComponent(groupName);
    layout.setComponentAlignment(groupName, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(groupName, 1.0f);

    List<DunningPolicy> dunningPolicyList = new ArrayList<DunningPolicy>();
    Iterable<DunningPolicy> dunningPolicies = DaoHelper.getInstance().getDunningPolicyRepository().findAll();
    for (DunningPolicy dunningPolicy : dunningPolicies) {
        dunningPolicyList.add(dunningPolicy);
    }
    BeanItemContainer<DunningPolicy> objects = new BeanItemContainer(DunningPolicy.class, dunningPolicyList);

    policyCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_POLICY_TYPE), objects);
    policyCombo.setItemCaptionPropertyId("policyName");

    stepCombo = new ComboBox(i18nManager.getMessage(Constants.DUNNING_POLICY_STEP));
    stepCombo.setItemCaptionPropertyId("stepText");
    policyCombo.addListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            DunningPolicy selectedDunningPolicy = (DunningPolicy) event.getProperty().getValue();
            List<ProcessSteps> processSteps = DaoHelper.getInstance().getDunningPolicyRepository()
                    .retrieveDunningProcessSteps(selectedDunningPolicy.getPolicyId());
            BeanItemContainer<ProcessSteps> objects = new BeanItemContainer(ProcessSteps.class, processSteps);
            stepCombo.setContainerDataSource(objects);
        }

    });

    stepCombo.addListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            selectedProcessStep = (ProcessSteps) event.getProperty().getValue();
        }

    });

}

From source file:org.milleni.dunning.ui.prcstart.TaskViewPanel.java

License:Apache License

protected void initPageTitle() {
    HorizontalLayout layout = createHorizontalLayout();
    addDetailComponent(layout);//  ww w .  jav a 2s  .  c o m

    Embedded databaseImage = new Embedded(null, Images.DATABASE_50);
    layout.addComponent(databaseImage);

    Label groupName = new Label("Task Durum Sorgula");
    groupName.setSizeUndefined();
    groupName.addStyleName(Reindeer.LABEL_H2);
    layout.addComponent(groupName);
    layout.setComponentAlignment(groupName, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(groupName, 1.0f);

    BeanItemContainer<DunningPolicy> objects = new BeanItemContainer(TaskDefObject.class, taskDefs);

    taskDefCombo = new ComboBox("Tasklar", objects);
    taskDefCombo.setItemCaptionPropertyId("desc");

    taskDefCombo.addListener(new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            selectedTaskDef = (TaskDefObject) event.getProperty().getValue();
        }
    });

}

From source file:org.opencms.ui.apps.CmsFileExplorer.java

License:Open Source License

/**
 * Creates the site selector combo box.<p>
 *
 * @param cms the current cms context//from  ww w.j  a  v a2 s  .  co  m
 *
 * @return the combo box
 */
private ComboBox createSiteSelect(CmsObject cms) {

    final IndexedContainer availableSites = CmsVaadinUtils.getAvailableSitesContainer(cms, SITE_CAPTION);
    ComboBox combo = new ComboBox(null, availableSites);
    combo.setTextInputAllowed(true);
    combo.setNullSelectionAllowed(false);
    combo.setWidth("200px");
    combo.setInputPrompt(
            Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_EXPLORER_CLICK_TO_EDIT_0));
    combo.setItemCaptionPropertyId(SITE_CAPTION);
    combo.select(cms.getRequestContext().getSiteRoot());
    combo.setFilteringMode(FilteringMode.CONTAINS);
    combo.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {

            String value = (String) event.getProperty().getValue();
            if (availableSites.containsId(value)) {
                changeSite(value, null);
                m_appContext.updateOnChange();
                availableSites.removeAllContainerFilters();
            }
        }
    });
    if (Page.getCurrent().getBrowserWindowHeight() > 650) {
        combo.setPageLength(20);
    }
    return combo;
}

From source file:org.opencms.ui.dialogs.CmsProjectSelectDialog.java

License:Open Source License

/**
 * Prepares a combo box.<p>//from   ww  w.ja  va2s  .  c  o m
 *
 * @param container the indexed item container
 * @param captionKey the caption message key
 *
 * @return the combo box
 */
private ComboBox prepareComboBox(IndexedContainer container, String captionKey) {

    ComboBox result = new ComboBox(CmsVaadinUtils.getWpMessagesForCurrentLocale().key(captionKey), container);
    result.setTextInputAllowed(true);
    result.setNullSelectionAllowed(false);
    result.setWidth("100%");
    result.setInputPrompt(
            Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_EXPLORER_CLICK_TO_EDIT_0));
    result.setItemCaptionPropertyId(CAPTION_PROPERTY);
    result.setFilteringMode(FilteringMode.CONTAINS);
    return result;
}