Example usage for com.vaadin.ui HorizontalLayout addComponent

List of usage examples for com.vaadin.ui HorizontalLayout addComponent

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:com.dungnv.streetfood.view.CategoryView.java

private void init() {
    header = new VerticalLayout();
    header.addStyleName("viewheader");
    header.setSpacing(true);/*w w  w .  jav a  2s  .co m*/
    header.setId("hehehe");

    titleLabel = new Label(BundleUtils.getLanguage("menu.CATEGORY"));
    titleLabel.setId(TITLE_ID);
    titleLabel.setWidth("100%");
    titleLabel.addStyleName(ValoTheme.LABEL_BOLD);
    header.addComponent(titleLabel);

    btnAdd = new Button();
    btnAdd.setCaption(FontAwesome.PLUS_CIRCLE.getLabel().setSize3x().getCssHtml());
    btnAdd.setCaptionAsHtml(true);
    btnAdd.addStyleName("float-button");
    //        add.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    //        add.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    //        add.addStyleName(ValoTheme.BUTTON_LARGE);
    header.addComponent(btnAdd);

    HorizontalLayout item = new HorizontalLayout();

    //        item.setSpacing(true);
    item.setWidth("100%");
    header.addComponent(item);

    txtSearch = new TextField();
    txtSearch.setImmediate(true);
    txtSearch.setTextChangeEventMode(TextChangeEventMode.TIMEOUT);
    txtSearch.setIcon(FontAwesome.SEARCH);
    txtSearch.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    txtSearch.setInputPrompt(BundleUtils.getLanguage("lbl.category.name.input"));
    txtSearch.setWidth("100%");

    item.addComponent(txtSearch);
    item.setComponentAlignment(txtSearch, Alignment.TOP_RIGHT);

    lbAdvanced = new Button();
    lbAdvanced.setCaption(BundleUtils.getLanguage("lbl.search.advanced"));
    lbAdvanced.addStyleName(ValoTheme.BUTTON_LINK);
    lbAdvanced.addStyleName(ValoTheme.BUTTON_LARGE);
    item.addComponent(lbAdvanced);
    item.setComponentAlignment(lbAdvanced, Alignment.BOTTOM_LEFT);

    uiSearchPaged = new CommonSearchPagedUI(1) {
        @Override
        public void cbChanged() {
            this.getCbPaged().addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent event) {
                    if (event.getProperty().getValue() != null) {
                        onSearch(false);
                    }
                }
            });
            this.getCbRecordPerPage().addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent event) {
                    if (event.getProperty().getValue() != null) {
                        onSearch(true);
                    }

                }
            });
        }
    };

    header.addComponent(uiSearchPaged);

    searchLayout = new VerticalLayout();
    //        searchLayout.setSpacing(true);
    searchLayout.setSizeFull();
    header.addComponent(searchLayout);

    searchDetail = new CategorySearchDetail(this);
}

From source file:com.dungnv.streetfood.view.DishSearchDetail.java

private void init() {
    layout = new VerticalLayout();
    layout.setSpacing(true);/*w  w  w  .j a  v a 2 s  . com*/
    layout.setMargin(true);

    form = new FormLayout();
    form.addStyleName("light");
    //                form.addStyleName("outlined");
    form.setSizeFull();
    form.setMargin(true);
    form.setSpacing(true);
    layout.addComponent(form);

    tfName = new TextField(BundleUtils.getLanguage("lbl.dish.name"));
    tfName.setWidth(80.0f, Unit.PERCENTAGE);
    form.addComponent(tfName);

    tfShortDescription = new TextField(BundleUtils.getLanguage("lbl.dish.shortDescription"));
    tfShortDescription.setWidth(80.0f, Unit.PERCENTAGE);
    form.addComponent(tfShortDescription);

    HorizontalLayout hlStatus = new HorizontalLayout();
    hlStatus.setCaption(BundleUtils.getLanguage("lbl.status"));
    hlStatus.addStyleName("horizontal");
    hlStatus.setSpacing(true);
    form.addComponent(hlStatus);

    cbActive = new CheckBox(BundleUtils.getLanguage("lbl.active"));
    cbActive.setValue(Boolean.TRUE);
    hlStatus.addComponent(cbActive);

    cbInActive = new CheckBox(BundleUtils.getLanguage("lbl.inActive"));
    cbInActive.setValue(Boolean.TRUE);
    hlStatus.addComponent(cbInActive);

    String regexDouble = "[0-9]*.?[0-9]?";
    String regexInteger = "[0-9]*";

    tfViewCountFrom = new TextField();
    tfViewCountFrom.setWidth(200.0f, Unit.PIXELS);
    tfViewCountFrom.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfViewCountFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);

    CSValidator vlViewCountFrom = new CSValidator();
    vlViewCountFrom.extend(tfViewCountFrom);
    vlViewCountFrom.setRegExp(regexInteger);
    vlViewCountFrom.setPreventInvalidTyping(true);
    tfViewCountFrom.addValidator(new RegexpValidator(regexInteger, "Not a number"));

    tfViewCountTo = new TextField();
    tfViewCountTo.setWidth(200.0f, Unit.PIXELS);
    tfViewCountTo.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfViewCountTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);
    CSValidator vlViewCountTo = new CSValidator();
    vlViewCountTo.extend(tfViewCountTo);
    vlViewCountTo.setRegExp(regexInteger);
    vlViewCountTo.setPreventInvalidTyping(true);
    tfViewCountTo.addValidator(new RegexpValidator(regexInteger, "Not a number"));

    HorizontalLayout hlViewCount = new HorizontalLayout(tfViewCountFrom, new Label("-"), tfViewCountTo);
    hlViewCount.setCaption(BundleUtils.getLanguage("lbl.dish.viewCount"));
    hlViewCount.setSpacing(true);
    form.addComponent(hlViewCount);

    tfCommentCountFrom = new TextField();
    tfCommentCountFrom.setWidth(200.0f, Unit.PIXELS);
    tfCommentCountFrom.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfCommentCountFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);

    CSValidator vlCommentCountFrom = new CSValidator();
    vlCommentCountFrom.extend(tfCommentCountFrom);
    vlCommentCountFrom.setRegExp(regexInteger);
    vlCommentCountFrom.setPreventInvalidTyping(true);
    tfCommentCountFrom.addValidator(new RegexpValidator(regexInteger, "Not a number"));

    tfCommentCountTo = new TextField();
    tfCommentCountTo.setWidth(200.0f, Unit.PIXELS);
    tfCommentCountTo.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfCommentCountTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);
    CSValidator vlCommentCountTo = new CSValidator();
    vlCommentCountTo.extend(tfCommentCountTo);
    vlCommentCountTo.setRegExp(regexInteger);
    vlCommentCountTo.setPreventInvalidTyping(true);
    tfCommentCountTo.addValidator(new RegexpValidator(regexInteger, "Not a number"));

    HorizontalLayout hlCommentCount = new HorizontalLayout(tfCommentCountFrom, new Label("-"),
            tfCommentCountTo);
    hlCommentCount.setCaption(BundleUtils.getLanguage("lbl.dish.commentCount"));
    hlCommentCount.setSpacing(true);
    form.addComponent(hlCommentCount);

    tfShareCountFrom = new TextField();
    tfShareCountFrom.setWidth(200.0f, Unit.PIXELS);
    tfShareCountFrom.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfShareCountFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);

    CSValidator vlShareCountFrom = new CSValidator();
    vlShareCountFrom.extend(tfShareCountFrom);
    vlShareCountFrom.setRegExp(regexInteger);
    vlShareCountFrom.setPreventInvalidTyping(true);
    tfShareCountFrom.addValidator(new RegexpValidator(regexInteger, "Not a number"));

    tfShareCountTo = new TextField();
    tfShareCountTo.setWidth(200.0f, Unit.PIXELS);
    tfShareCountTo.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfShareCountTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);
    CSValidator vlShareCountTo = new CSValidator();
    vlShareCountTo.extend(tfShareCountTo);
    vlShareCountTo.setRegExp(regexInteger);
    vlShareCountTo.setPreventInvalidTyping(true);
    tfShareCountTo.addValidator(new RegexpValidator(regexInteger, "Not a number"));

    HorizontalLayout hlShareCount = new HorizontalLayout(tfShareCountFrom, new Label("-"), tfShareCountTo);
    hlShareCount.setCaption(BundleUtils.getLanguage("lbl.dish.shareCount"));
    hlShareCount.setSpacing(true);
    form.addComponent(hlShareCount);

    tfRatingFrom = new TextField();
    tfRatingFrom.setWidth(200.0f, Unit.PIXELS);
    tfRatingFrom.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfRatingFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);

    CSValidator vlRatingFrom = new CSValidator();
    vlRatingFrom.extend(tfRatingFrom);
    vlRatingFrom.setRegExp(regexDouble);
    vlRatingFrom.setPreventInvalidTyping(true);
    tfRatingFrom.addValidator(new RegexpValidator(regexDouble, "Not a number"));

    tfRatingTo = new TextField();
    tfRatingTo.setWidth(200.0f, Unit.PIXELS);
    tfRatingTo.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfRatingTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);
    CSValidator vlRatingTo = new CSValidator();
    vlRatingTo.extend(tfRatingTo);
    vlRatingTo.setRegExp(regexDouble);
    vlRatingTo.setPreventInvalidTyping(true);
    tfRatingTo.addValidator(new RegexpValidator(regexDouble, "Not a number"));

    HorizontalLayout hlRating = new HorizontalLayout(tfRatingFrom, new Label("-"), tfRatingTo);
    hlRating.setCaption(BundleUtils.getLanguage("lbl.dish.rating"));
    hlRating.setSpacing(true);
    form.addComponent(hlRating);

    tagSuggestFieldUI = new TagSuggestFieldUI(false);
    tagSuggestFieldUI.setWidth(80.0f, Unit.PERCENTAGE);
    form.addComponent(tagSuggestFieldUI);

    Map<String, LocaleDTO> mapLocale = ClientServiceImpl.getAllLocales();
    if (mapLocale != null && !mapLocale.isEmpty()) {
        List<LocaleDTO> listLocale = new ArrayList<>(mapLocale.values());
        listLocale.stream().map((localeDTO) -> new OptionGroupUI(localeDTO.getLocale()//
                , localeDTO.getId())).forEach((ogLocale) -> {
                    form.addComponent(ogLocale);
                    listOgLocale.add(ogLocale);
                });
    }

    HorizontalLayout hlButton = new HorizontalLayout();
    hlButton.setSpacing(true);
    hlButton.setMargin(true);
    form.addComponent(hlButton);

    btnSearch = new Button(BundleUtils.getLanguage("lbl.search"), FontAwesome.SEARCH);
    hlButton.addComponent(btnSearch);

    btnExportExcel = new Button(BundleUtils.getLanguage("lbl.exportExcel"), FontAwesome.FILE_EXCEL_O);
    hlButton.addComponent(btnExportExcel);

    btnExportXML = new Button(BundleUtils.getLanguage("lbl.exportXML"), FontAwesome.FILE_CODE_O);
    hlButton.addComponent(btnExportXML);

    btnCancel = new Button(BundleUtils.getLanguage("lbl.cancel"), FontAwesome.BAN);
    hlButton.addComponent(btnCancel);

}

From source file:com.dungnv.streetfood.view.DishView.java

private void init() {
    header = new VerticalLayout();
    header.addStyleName("viewheader");
    header.setSpacing(true);//from   w w w.ja  v  a  2s .  c o  m
    header.setId("hehehe");

    titleLabel = new Label(BundleUtils.getLanguage("menu.DISH"));
    titleLabel.setId(TITLE_ID);
    titleLabel.setWidth("100%");
    titleLabel.addStyleName(ValoTheme.LABEL_BOLD);
    header.addComponent(titleLabel);

    btnAdd = new Button();
    btnAdd.setCaption(FontAwesome.PLUS_CIRCLE.getLabel().setSize3x().getCssHtml());
    btnAdd.setCaptionAsHtml(true);
    btnAdd.addStyleName("float-button");
    header.addComponent(btnAdd);

    HorizontalLayout item = new HorizontalLayout();

    //        item.setSpacing(true);
    item.setWidth("100%");
    header.addComponent(item);

    txtSearch = new TextField();
    txtSearch.setImmediate(true);
    txtSearch.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.TIMEOUT);
    txtSearch.setIcon(FontAwesome.SEARCH);
    txtSearch.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    txtSearch.setInputPrompt(BundleUtils.getLanguage("lbl.dish.name.input"));
    txtSearch.setWidth("100%");

    item.addComponent(txtSearch);
    item.setComponentAlignment(txtSearch, Alignment.TOP_RIGHT);

    lbAdvanced = new Button();
    lbAdvanced.setCaption(BundleUtils.getLanguage("lbl.search.advanced"));
    lbAdvanced.addStyleName(ValoTheme.BUTTON_LINK);
    lbAdvanced.addStyleName(ValoTheme.BUTTON_LARGE);
    item.addComponent(lbAdvanced);
    item.setComponentAlignment(lbAdvanced, Alignment.BOTTOM_LEFT);

    uiSearchPaged = new CommonSearchPagedUI(1) {
        @Override
        public void cbChanged() {
            this.getCbPaged().addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent event) {
                    if (event.getProperty().getValue() != null) {
                        onSearch(false);
                    }
                }
            });
            this.getCbRecordPerPage().addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent event) {
                    if (event.getProperty().getValue() != null) {
                        onSearch(true);
                    }

                }
            });
        }
    };

    header.addComponent(uiSearchPaged);

    searchLayout = new VerticalLayout();
    //        searchLayout.setSpacing(true);
    searchLayout.setSizeFull();
    header.addComponent(searchLayout);

    searchDetail = new DishSearchDetail(this);
}

From source file:com.dungnv.streetfood.view.RestaurantSearchDetail.java

private void init() {
    layout = new VerticalLayout();
    layout.setSpacing(true);/*  w  w  w  .j a  v a 2  s.  co  m*/
    layout.setMargin(true);

    form = new FormLayout();
    form.addStyleName("light");
    //                form.addStyleName("outlined");
    form.setSizeFull();
    form.setMargin(true);
    form.setSpacing(true);
    layout.addComponent(form);

    tfName = new TextField(BundleUtils.getLanguage("lbl.restaurant.name"));
    tfName.setWidth(80.0f, Unit.PERCENTAGE);
    form.addComponent(tfName);

    tfIntroduce = new TextField(BundleUtils.getLanguage("lbl.restaurant.introduce"));
    tfIntroduce.setWidth(80.0f, Unit.PERCENTAGE);
    form.addComponent(tfIntroduce);

    HorizontalLayout hlStatus = new HorizontalLayout();
    hlStatus.setCaption(BundleUtils.getLanguage("lbl.status"));
    hlStatus.addStyleName("horizontal");
    hlStatus.setSpacing(true);
    form.addComponent(hlStatus);

    cbActive = new CheckBox(BundleUtils.getLanguage("lbl.active"));
    cbActive.setValue(Boolean.TRUE);
    hlStatus.addComponent(cbActive);

    cbInActive = new CheckBox(BundleUtils.getLanguage("lbl.inActive"));
    cbInActive.setValue(Boolean.TRUE);
    hlStatus.addComponent(cbInActive);

    tfAddress = new TextField(BundleUtils.getLanguage("lbl.restaurant.address"));
    tfAddress.setWidth(80.0f, Unit.PERCENTAGE);
    form.addComponent(tfAddress);

    tfPhoneNumber = new TextField(BundleUtils.getLanguage("lbl.restaurant.phoneNumber"));
    tfPhoneNumber.setWidth(80.0f, Unit.PERCENTAGE);
    form.addComponent(tfPhoneNumber);

    tfCapacity = new TextField(BundleUtils.getLanguage("lbl.restaurant.capacity"));
    tfCapacity.setWidth(80.0f, Unit.PERCENTAGE);
    form.addComponent(tfCapacity);

    HorizontalLayout hlCarParking = new HorizontalLayout();
    hlCarParking.setCaption(BundleUtils.getLanguage("lbl.restaurant.carParking"));
    hlCarParking.addStyleName("horizontal");
    hlCarParking.setSpacing(true);
    form.addComponent(hlCarParking);

    cbCarParkingYes = new CheckBox(BundleUtils.getLanguage("lbl.yes"));
    cbCarParkingYes.setValue(Boolean.TRUE);
    hlCarParking.addComponent(cbCarParkingYes);

    cbCarParkingNo = new CheckBox(BundleUtils.getLanguage("lbl.no"));
    cbCarParkingNo.setValue(Boolean.TRUE);
    hlCarParking.addComponent(cbCarParkingNo);

    HorizontalLayout hlMotobikeParking = new HorizontalLayout();
    hlMotobikeParking.setCaption(BundleUtils.getLanguage("lbl.status"));
    hlMotobikeParking.addStyleName("horizontal");
    hlMotobikeParking.setSpacing(true);
    form.addComponent(hlMotobikeParking);

    cbMotobikeParkingYes = new CheckBox(BundleUtils.getLanguage("lbl.yes"));
    cbMotobikeParkingYes.setValue(Boolean.TRUE);
    hlMotobikeParking.addComponent(cbMotobikeParkingYes);

    cbMotobikeParkingNo = new CheckBox(BundleUtils.getLanguage("lbl.no"));
    cbMotobikeParkingNo.setValue(Boolean.TRUE);
    hlMotobikeParking.addComponent(cbMotobikeParkingNo);

    tfOperatingTimeStart = new TimeField();
    tfOperatingTimeEnd = new TimeField();

    HorizontalLayout hlOperatingTime = new HorizontalLayout(tfOperatingTimeStart, new Label(" - "),
            tfOperatingTimeEnd);
    hlOperatingTime.setCaption(BundleUtils.getLanguage("lbl.restaurant.operatingTime"));
    hlOperatingTime.setSpacing(true);
    form.addComponent(hlOperatingTime);

    String regexDouble = "[0-9]*.?[0-9]?";
    String regexInteger = "[0-9]*";

    tfViewCountFrom = new TextField();
    tfViewCountFrom.setWidth(200.0f, Unit.PIXELS);
    tfViewCountFrom.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfViewCountFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);

    CSValidator vlViewCountFrom = new CSValidator();
    vlViewCountFrom.extend(tfViewCountFrom);
    vlViewCountFrom.setRegExp(regexInteger);
    vlViewCountFrom.setPreventInvalidTyping(true);
    tfViewCountFrom.addValidator(new RegexpValidator(regexInteger, "Not a number"));

    tfViewCountTo = new TextField();
    tfViewCountTo.setWidth(200.0f, Unit.PIXELS);
    tfViewCountTo.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfViewCountTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);
    CSValidator vlViewCountTo = new CSValidator();
    vlViewCountTo.extend(tfViewCountTo);
    vlViewCountTo.setRegExp(regexInteger);
    vlViewCountTo.setPreventInvalidTyping(true);
    tfViewCountTo.addValidator(new RegexpValidator(regexInteger, "Not a number"));

    HorizontalLayout hlViewCount = new HorizontalLayout(tfViewCountFrom, new Label("-"), tfViewCountTo);
    hlViewCount.setCaption(BundleUtils.getLanguage("lbl.restaurant.viewCount"));
    hlViewCount.setSpacing(true);
    form.addComponent(hlViewCount);

    tfCommentCountFrom = new TextField();
    tfCommentCountFrom.setWidth(200.0f, Unit.PIXELS);
    tfCommentCountFrom.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfCommentCountFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);

    CSValidator vlCommentCountFrom = new CSValidator();
    vlCommentCountFrom.extend(tfCommentCountFrom);
    vlCommentCountFrom.setRegExp(regexInteger);
    vlCommentCountFrom.setPreventInvalidTyping(true);
    tfCommentCountFrom.addValidator(new RegexpValidator(regexInteger, "Not a number"));

    tfCommentCountTo = new TextField();
    tfCommentCountTo.setWidth(200.0f, Unit.PIXELS);
    tfCommentCountTo.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfCommentCountTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);
    CSValidator vlCommentCountTo = new CSValidator();
    vlCommentCountTo.extend(tfCommentCountTo);
    vlCommentCountTo.setRegExp(regexInteger);
    vlCommentCountTo.setPreventInvalidTyping(true);
    tfCommentCountTo.addValidator(new RegexpValidator(regexInteger, "Not a number"));

    HorizontalLayout hlCommentCount = new HorizontalLayout(tfCommentCountFrom, new Label("-"),
            tfCommentCountTo);
    hlCommentCount.setCaption(BundleUtils.getLanguage("lbl.restaurant.commentCount"));
    hlCommentCount.setSpacing(true);
    form.addComponent(hlCommentCount);

    tfShareCountFrom = new TextField();
    tfShareCountFrom.setWidth(200.0f, Unit.PIXELS);
    tfShareCountFrom.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfShareCountFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);

    CSValidator vlShareCountFrom = new CSValidator();
    vlShareCountFrom.extend(tfShareCountFrom);
    vlShareCountFrom.setRegExp(regexInteger);
    vlShareCountFrom.setPreventInvalidTyping(true);
    tfShareCountFrom.addValidator(new RegexpValidator(regexInteger, "Not a number"));

    tfShareCountTo = new TextField();
    tfShareCountTo.setWidth(200.0f, Unit.PIXELS);
    tfShareCountTo.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfShareCountTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);
    CSValidator vlShareCountTo = new CSValidator();
    vlShareCountTo.extend(tfShareCountTo);
    vlShareCountTo.setRegExp(regexInteger);
    vlShareCountTo.setPreventInvalidTyping(true);
    tfShareCountTo.addValidator(new RegexpValidator(regexInteger, "Not a number"));

    HorizontalLayout hlShareCount = new HorizontalLayout(tfShareCountFrom, new Label("-"), tfShareCountTo);
    hlShareCount.setCaption(BundleUtils.getLanguage("lbl.restaurant.shareCount"));
    hlShareCount.setSpacing(true);
    form.addComponent(hlShareCount);

    tfRatingFrom = new TextField();
    tfRatingFrom.setWidth(200.0f, Unit.PIXELS);
    tfRatingFrom.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfRatingFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);

    CSValidator vlRatingFrom = new CSValidator();
    vlRatingFrom.extend(tfRatingFrom);
    vlRatingFrom.setRegExp(regexDouble);
    vlRatingFrom.setPreventInvalidTyping(true);
    tfRatingFrom.addValidator(new RegexpValidator(regexDouble, "Not a number"));

    tfRatingTo = new TextField();
    tfRatingTo.setWidth(200.0f, Unit.PIXELS);
    tfRatingTo.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfRatingTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);
    CSValidator vlRatingTo = new CSValidator();
    vlRatingTo.extend(tfRatingTo);
    vlRatingTo.setRegExp(regexDouble);
    vlRatingTo.setPreventInvalidTyping(true);
    tfRatingTo.addValidator(new RegexpValidator(regexDouble, "Not a number"));

    HorizontalLayout hlRating = new HorizontalLayout(tfRatingFrom, new Label("-"), tfRatingTo);
    hlRating.setCaption(BundleUtils.getLanguage("lbl.restaurant.rating"));
    hlRating.setSpacing(true);
    form.addComponent(hlRating);

    tfPriceFromVn = new TextField();
    tfPriceFromVn.setWidth(200.0f, Unit.PIXELS);
    tfPriceFromVn.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfPriceFromVn.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);

    CSValidator vlPriceFromVn = new CSValidator();
    vlPriceFromVn.extend(tfPriceFromVn);
    vlPriceFromVn.setRegExp(regexDouble);
    vlPriceFromVn.setPreventInvalidTyping(true);
    tfPriceFromVn.addValidator(new RegexpValidator(regexDouble, "Not a number"));

    tfPriceToVn = new TextField();
    tfPriceToVn.setWidth(200.0f, Unit.PIXELS);
    tfPriceToVn.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfPriceToVn.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);

    CSValidator vlPriceToVn = new CSValidator();
    vlPriceToVn.extend(tfPriceToVn);
    vlPriceToVn.setRegExp(regexDouble);
    vlPriceToVn.setPreventInvalidTyping(true);
    tfPriceToVn.addValidator(new RegexpValidator(regexDouble, "Not a number"));

    HorizontalLayout hlPriceVn = new HorizontalLayout(tfPriceFromVn, new Label("-"), tfPriceToVn,
            new Label("VND"));
    hlPriceVn.setCaption(BundleUtils.getLanguage("lbl.restaurant.priceVn"));
    hlPriceVn.setSpacing(true);
    form.addComponent(hlPriceVn);

    tfPriceFromEn = new TextField();
    tfPriceFromEn.setWidth(200.0f, Unit.PIXELS);
    tfPriceFromEn.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfPriceFromEn.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);

    CSValidator vlPriceFromEn = new CSValidator();
    vlPriceFromEn.extend(tfPriceFromEn);
    vlPriceFromEn.setRegExp(regexDouble);
    vlPriceFromEn.setPreventInvalidTyping(true);
    tfPriceFromEn.addValidator(new RegexpValidator(regexDouble, "Not a number"));

    tfPriceToEn = new TextField();
    tfPriceToEn.setWidth(200.0f, Unit.PIXELS);
    tfPriceToEn.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfPriceToEn.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);

    CSValidator vlPriceToEn = new CSValidator();
    vlPriceToEn.extend(tfPriceToEn);
    vlPriceToEn.setRegExp(regexDouble);
    vlPriceToEn.setPreventInvalidTyping(true);
    tfPriceToEn.addValidator(new RegexpValidator(regexDouble, "Not a number"));

    HorizontalLayout hlPriceEn = new HorizontalLayout(tfPriceFromEn, new Label("-"), tfPriceToEn,
            new Label("USD"));
    hlPriceEn.setCaption(BundleUtils.getLanguage("lbl.restaurant.priceEn"));
    hlPriceEn.setSpacing(true);
    form.addComponent(hlPriceEn);

    tfWaitingTimeFrom = new TextField();
    tfWaitingTimeFrom.setWidth(200.0f, Unit.PIXELS);
    tfWaitingTimeFrom.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfWaitingTimeFrom.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);

    CSValidator vlWaitingTimeFrom = new CSValidator();
    vlWaitingTimeFrom.extend(tfWaitingTimeFrom);
    vlWaitingTimeFrom.setRegExp(regexDouble);
    vlWaitingTimeFrom.setPreventInvalidTyping(true);
    tfWaitingTimeFrom.addValidator(new RegexpValidator(regexDouble, "Not a number"));

    tfWaitingTimeTo = new TextField();
    tfWaitingTimeTo.setWidth(200.0f, Unit.PIXELS);
    tfWaitingTimeTo.addStyleName(ValoTheme.TEXTFIELD_TINY);
    tfWaitingTimeTo.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);
    CSValidator vlWaitingTimeTo = new CSValidator();
    vlWaitingTimeTo.extend(tfWaitingTimeTo);
    vlWaitingTimeTo.setRegExp(regexDouble);
    vlWaitingTimeTo.setPreventInvalidTyping(true);
    tfWaitingTimeTo.addValidator(new RegexpValidator(regexDouble, "Not a number"));

    HorizontalLayout hlWaitingTime = new HorizontalLayout(tfWaitingTimeFrom, new Label("-"), tfWaitingTimeTo);
    hlWaitingTime.setCaption(BundleUtils.getLanguage("lbl.dish.waitingTime"));
    hlWaitingTime.setSpacing(true);
    form.addComponent(hlWaitingTime);

    Map<String, LocaleDTO> mapLocale = ClientServiceImpl.getAllLocales();
    if (mapLocale != null && !mapLocale.isEmpty()) {
        List<LocaleDTO> listLocale = new ArrayList<>(mapLocale.values());
        listLocale.stream().map((localeDTO) -> new OptionGroupUI(localeDTO.getLocale()//
                , localeDTO.getId())).forEach((ogLocale) -> {
                    form.addComponent(ogLocale);
                    listOgLocale.add(ogLocale);
                });
    }

    tagSuggestFieldUI = new TagSuggestFieldUI(false);
    tagSuggestFieldUI.setWidth(80.0f, Unit.PERCENTAGE);
    form.addComponent(tagSuggestFieldUI);

    HorizontalLayout hlButton = new HorizontalLayout();
    hlButton.setSpacing(true);
    hlButton.setMargin(true);
    form.addComponent(hlButton);

    btnSearch = new Button(BundleUtils.getLanguage("lbl.search"), FontAwesome.SEARCH);
    hlButton.addComponent(btnSearch);

    btnExportExcel = new Button(BundleUtils.getLanguage("lbl.exportExcel"), FontAwesome.FILE_EXCEL_O);
    hlButton.addComponent(btnExportExcel);

    btnExportXML = new Button(BundleUtils.getLanguage("lbl.exportXML"), FontAwesome.FILE_CODE_O);
    hlButton.addComponent(btnExportXML);

    btnCancel = new Button(BundleUtils.getLanguage("lbl.cancel"), FontAwesome.BAN);
    hlButton.addComponent(btnCancel);

}

From source file:com.dungnv.streetfood.view.RestaurantView.java

private void init() {
    header = new VerticalLayout();
    header.addStyleName("viewheader");
    header.setSpacing(true);//  w w w. j  a  v a 2  s. c  om
    header.setId("hehehe");

    titleLabel = new Label(BundleUtils.getLanguage("menu.RESTAURANT"));
    titleLabel.setId(TITLE_ID);
    titleLabel.setWidth("100%");
    titleLabel.addStyleName(ValoTheme.LABEL_BOLD);
    header.addComponent(titleLabel);

    btnAdd = new Button();
    btnAdd.setCaption(FontAwesome.PLUS_CIRCLE.getLabel().setSize3x().getCssHtml());
    btnAdd.setCaptionAsHtml(true);
    btnAdd.addStyleName("float-button");
    //        add.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    //        add.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    //        add.addStyleName(ValoTheme.BUTTON_LARGE);
    header.addComponent(btnAdd);

    HorizontalLayout item = new HorizontalLayout();

    //        item.setSpacing(true);
    item.setWidth("100%");
    header.addComponent(item);

    txtSearch = new TextField();
    txtSearch.setImmediate(true);
    txtSearch.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.TIMEOUT);
    txtSearch.setIcon(FontAwesome.SEARCH);
    txtSearch.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    txtSearch.setInputPrompt(BundleUtils.getLanguage("lbl.restaurant.name.input"));
    txtSearch.setWidth("100%");

    item.addComponent(txtSearch);
    item.setComponentAlignment(txtSearch, Alignment.TOP_RIGHT);

    lbAdvanced = new Button();
    lbAdvanced.setCaption(BundleUtils.getLanguage("lbl.search.advanced"));
    lbAdvanced.addStyleName(ValoTheme.BUTTON_LINK);
    lbAdvanced.addStyleName(ValoTheme.BUTTON_LARGE);
    item.addComponent(lbAdvanced);
    item.setComponentAlignment(lbAdvanced, Alignment.BOTTOM_LEFT);

    uiSearchPaged = new CommonSearchPagedUI(1) {
        @Override
        public void cbChanged() {
            this.getCbPaged().addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent event) {
                    if (event.getProperty().getValue() != null) {
                        onSearch(false);
                    }
                }
            });
            this.getCbRecordPerPage().addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent event) {
                    if (event.getProperty().getValue() != null) {
                        onSearch(true);
                    }

                }
            });
        }
    };

    header.addComponent(uiSearchPaged);

    searchLayout = new VerticalLayout();
    //        searchLayout.setSpacing(true);
    searchLayout.setSizeFull();
    header.addComponent(searchLayout);

    searchDetail = new RestaurantSearchDetail(this);
}

From source file:com.dungnv.streetfood.view.SlideShowSearchDetail.java

private void init() {
    layout = new VerticalLayout();
    layout.setSpacing(true);/*from   w w w  .  java 2s  .c  o  m*/
    layout.setMargin(true);

    form = new FormLayout();
    form.addStyleName("light");
    //                form.addStyleName("outlined");
    form.setSizeFull();
    form.setMargin(true);
    form.setSpacing(true);
    layout.addComponent(form);

    tfName = new TextField(BundleUtils.getLanguage("lbl.category.name"));
    tfName.setWidth(80.0f, Unit.PERCENTAGE);
    form.addComponent(tfName);

    tfDescription = new TextField(BundleUtils.getLanguage("lbl.slideShow.description"));
    tfDescription.setWidth(80.0f, Unit.PERCENTAGE);
    form.addComponent(tfDescription);

    HorizontalLayout hlButton = new HorizontalLayout();
    hlButton.setSpacing(true);
    hlButton.setMargin(true);
    form.addComponent(hlButton);

    btnSearch = new Button(BundleUtils.getLanguage("lbl.search"), FontAwesome.SEARCH);
    hlButton.addComponent(btnSearch);

    btnCancel = new Button(BundleUtils.getLanguage("lbl.cancel"), FontAwesome.BAN);
    hlButton.addComponent(btnCancel);

}

From source file:com.dungnv.streetfood.view.SlideShowView.java

private void init() {
    header = new VerticalLayout();
    header.addStyleName("viewheader");
    header.setSpacing(true);/*from   w  ww .  ja  v  a2 s .  c  om*/
    header.setId("hehehe");

    titleLabel = new Label(BundleUtils.getLanguage("menu.RESTAURANT"));
    titleLabel.setId(TITLE_ID);
    titleLabel.setWidth("100%");
    titleLabel.addStyleName(ValoTheme.LABEL_BOLD);
    header.addComponent(titleLabel);

    btnAdd = new Button();
    btnAdd.setCaption(FontAwesome.PLUS_CIRCLE.getLabel().setSize3x().getCssHtml());
    btnAdd.setCaptionAsHtml(true);
    btnAdd.addStyleName("float-button");
    //        add.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    //        add.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    //        add.addStyleName(ValoTheme.BUTTON_LARGE);
    header.addComponent(btnAdd);

    HorizontalLayout item = new HorizontalLayout();

    //        item.setSpacing(true);
    item.setWidth("100%");
    header.addComponent(item);

    txtSearch = new TextField();
    txtSearch.setImmediate(true);
    txtSearch.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.TIMEOUT);
    txtSearch.setIcon(FontAwesome.SEARCH);
    txtSearch.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    txtSearch.setInputPrompt(BundleUtils.getLanguage("lbl.slideShow.name.input"));
    txtSearch.setWidth("100%");

    item.addComponent(txtSearch);
    item.setComponentAlignment(txtSearch, Alignment.TOP_RIGHT);

    lbAdvanced = new Button();
    lbAdvanced.setCaption(BundleUtils.getLanguage("lbl.search.advanced"));
    lbAdvanced.addStyleName(ValoTheme.BUTTON_LINK);
    lbAdvanced.addStyleName(ValoTheme.BUTTON_LARGE);
    item.addComponent(lbAdvanced);
    item.setComponentAlignment(lbAdvanced, Alignment.BOTTOM_LEFT);

    uiSearchPaged = new CommonSearchPagedUI(1) {
        @Override
        public void cbChanged() {
            this.getCbPaged().addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent event) {
                    if (event.getProperty().getValue() != null) {
                        onSearch(false);
                    }
                }
            });
            this.getCbRecordPerPage().addValueChangeListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent event) {
                    if (event.getProperty().getValue() != null) {
                        onSearch(true);
                    }

                }
            });
        }
    };

    header.addComponent(uiSearchPaged);

    searchLayout = new VerticalLayout();
    //        searchLayout.setSpacing(true);
    searchLayout.setSizeFull();
    header.addComponent(searchLayout);

    searchDetail = new SlideShowSearchDetail(this);
}

From source file:com.ejt.vaadin.loginform.DefaultHorizontalLoginForm.java

License:Apache License

@Override
protected Component createContent(TextField userNameField, PasswordField passwordField, Button loginButton) {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);//from   w  ww .j  a va2s  .co m
    layout.setMargin(true);

    layout.addComponent(userNameField);
    layout.addComponent(passwordField);
    layout.addComponent(loginButton);
    layout.setComponentAlignment(loginButton, Alignment.BOTTOM_LEFT);
    return layout;
}

From source file:com.esofthead.mycollab.community.ui.chart.PieChartWrapper.java

License:Open Source License

@Override
protected final ComponentContainer createLegendBox() {
    final CustomLayout boxWrapper = CustomLayoutExt.createLayout("legendBox");
    final CssLayout mainLayout = new CssLayout();

    mainLayout.setSizeUndefined();//from w  w w . j  a  v  a2  s .c om
    final List keys = pieDataSet.getKeys();

    for (int i = 0; i < keys.size(); i++) {
        final HorizontalLayout layout = new HorizontalLayout();
        layout.setMargin(new MarginInfo(false, false, false, true));
        layout.addStyleName("inline-block");
        final Comparable key = (Comparable) keys.get(i);
        final String color = "<div style = \" width:8px;height:8px;border-radius:5px;background: #"
                + GenericChartWrapper.CHART_COLOR_STR[i % GenericChartWrapper.CHART_COLOR_STR.length] + "\" />";
        final Label lblCircle = new Label(color);
        lblCircle.setContentMode(ContentMode.HTML);

        String btnCaption;
        if (enumKeyCls == null) {
            btnCaption = String.format("%s(%d)", key, pieDataSet.getValue(key).intValue());
        } else {
            btnCaption = String.format("%s(%d)", AppContext.getMessage(enumKeyCls, key.toString()),
                    pieDataSet.getValue(key).intValue());
        }
        final Button btnLink = new Button(btnCaption, new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                PieChartWrapper.this.onClickedDescription(key.toString());
            }
        });
        btnLink.addStyleName("link");
        layout.addComponent(lblCircle);
        layout.setComponentAlignment(lblCircle, Alignment.MIDDLE_CENTER);
        layout.addComponent(btnLink);
        layout.setComponentAlignment(btnLink, Alignment.MIDDLE_CENTER);
        layout.setSizeUndefined();
        mainLayout.addComponent(layout);
    }
    boxWrapper.setWidth("100%");
    boxWrapper.addComponent(mainLayout, "legendBoxContent");
    return boxWrapper;
}

From source file:com.esofthead.mycollab.mobile.module.crm.ui.NotesList.java

License:Open Source License

private void initUI() {
    noteList = new BeanList<NoteService, NoteSearchCriteria, SimpleNote>(noteService,
            NoteRowDisplayHandler.class);
    noteList.setDisplayEmptyListText(false);
    noteList.setStyleName("noteList");

    noteListContainer = new VerticalLayout();
    this.setContent(noteListContainer);
    displayNotes();/*w  w w .j  a va 2  s. com*/

    HorizontalLayout commentBox = new HorizontalLayout();
    commentBox.setSizeFull();
    commentBox.setStyleName("comment-box");
    commentBox.setSpacing(true);
    commentBox.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    final TextArea noteInput = new TextArea();
    noteInput.setInputPrompt(AppContext.getMessage(GenericI18Enum.M_NOTE_INPUT_PROMPT));
    noteInput.setSizeFull();
    commentBox.addComponent(noteInput);
    commentBox.setExpandRatio(noteInput, 1.0f);

    Button postBtn = new Button(AppContext.getMessage(GenericI18Enum.M_BUTTON_SEND));
    postBtn.setStyleName("submit-btn");
    postBtn.setWidthUndefined();
    postBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = -5095455325725786794L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            final Note note = new Note();
            note.setCreateduser(AppContext.getUsername());
            note.setNote(noteInput.getValue());
            note.setSaccountid(AppContext.getAccountId());
            note.setSubject("");
            note.setType(type);
            note.setTypeid(typeid);
            note.setCreatedtime(new GregorianCalendar().getTime());
            note.setLastupdatedtime(new GregorianCalendar().getTime());
            noteService.saveWithSession(note, AppContext.getUsername());

            // Save Relay Email -- having time must refact to
            // Aop
            // ------------------------------------------------------
            RelayEmailNotification relayNotification = new RelayEmailNotification();
            relayNotification.setChangeby(AppContext.getUsername());
            relayNotification.setChangecomment(noteInput.getValue());
            relayNotification.setSaccountid(AppContext.getAccountId());
            relayNotification.setType(type);
            relayNotification.setAction(MonitorTypeConstants.ADD_COMMENT_ACTION);
            relayNotification.setTypeid("" + typeid);
            if (type.equals(CrmTypeConstants.ACCOUNT)) {
                relayNotification.setEmailhandlerbean(AccountRelayEmailNotificationAction.class.getName());
            } else if (type.equals(CrmTypeConstants.CONTACT)) {
                relayNotification.setEmailhandlerbean(ContactRelayEmailNotificationAction.class.getName());
            } else if (type.equals(CrmTypeConstants.CAMPAIGN)) {
                relayNotification.setEmailhandlerbean(CampaignRelayEmailNotificationAction.class.getName());
            } else if (type.equals(CrmTypeConstants.LEAD)) {
                relayNotification.setEmailhandlerbean(LeadRelayEmailNotificationAction.class.getName());
            } else if (type.equals(CrmTypeConstants.OPPORTUNITY)) {
                relayNotification.setEmailhandlerbean(OpportunityRelayEmailNotificationAction.class.getName());
            } else if (type.equals(CrmTypeConstants.CASE)) {
                relayNotification.setEmailhandlerbean(CaseRelayEmailNotificationAction.class.getName());
            } else if (type.equals(CrmTypeConstants.TASK)) {
                relayNotification.setEmailhandlerbean(TaskRelayEmailNotificationAction.class.getName());
            } else if (type.equals(CrmTypeConstants.MEETING)) {
                relayNotification.setEmailhandlerbean(MeetingRelayEmailNotificationAction.class.getName());
            } else if (type.equals(CrmTypeConstants.CALL)) {
                relayNotification.setEmailhandlerbean(CallRelayEmailNotificationAction.class.getName());
            }
            RelayEmailNotificationService relayEmailNotificationService = ApplicationContextUtil
                    .getSpringBean(RelayEmailNotificationService.class);
            relayEmailNotificationService.saveWithSession(relayNotification, AppContext.getUsername());
            noteInput.setValue("");
            displayNotes();
        }
    });
    commentBox.addComponent(postBtn);

    this.setToolbar(commentBox);

}