Example usage for com.vaadin.server FontAwesome BAN

List of usage examples for com.vaadin.server FontAwesome BAN

Introduction

In this page you can find the example usage for com.vaadin.server FontAwesome BAN.

Prototype

FontAwesome BAN

To view the source code for com.vaadin.server FontAwesome BAN.

Click Source Link

Usage

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

private void init() {
    layout = new VerticalLayout();
    layout.setSpacing(true);/*from  w  w w . jav  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);

    tfTitle = new TextField(BundleUtils.getLanguage("lbl.article.title"));
    tfTitle.setWidth(80.0f, Unit.PERCENTAGE);
    form.addComponent(tfTitle);

    tfShortContent = new TextField(BundleUtils.getLanguage("lbl.article.shortContent"));
    tfShortContent.setWidth(80.0f, Unit.PERCENTAGE);
    form.addComponent(tfShortContent);

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

    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);

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

}

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

private void init() {
    layout = new VerticalLayout();
    layout.setSpacing(true);// ww  w.  jav a2  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.category.name"));
    tfName.setWidth(80.0f, Unit.PERCENTAGE);
    form.addComponent(tfName);

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

    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);

    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.DishSearchDetail.java

private void init() {
    layout = new VerticalLayout();
    layout.setSpacing(true);/*from   w  ww .  j ava2 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.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.RestaurantSearchDetail.java

private void init() {
    layout = new VerticalLayout();
    layout.setSpacing(true);/*w  w w  . ja va 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.SlideShowSearchDetail.java

private void init() {
    layout = new VerticalLayout();
    layout.setSpacing(true);//from  ww  w. j  ava 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.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:org.jumpmind.vaadin.ui.common.NotifyDialog.java

License:Open Source License

public NotifyDialog(String caption, String text, final Throwable ex, Type type) {
    super(caption);
    setWidth(400, Unit.PIXELS);/* www .  j av  a2 s .  c  o  m*/
    setHeight(300, Unit.PIXELS);

    final HorizontalLayout messageArea = new HorizontalLayout();
    messageArea.addStyleName("v-scrollable");
    messageArea.setMargin(true);
    messageArea.setSpacing(true);
    messageArea.setSizeFull();

    text = isNotBlank(text) ? text : (ex != null ? ex.getMessage() : "");
    if (type == Type.ERROR_MESSAGE) {
        setIcon(FontAwesome.BAN);
    }

    final String message = text;

    final Label textLabel = new Label(message, ContentMode.HTML);
    messageArea.addComponent(textLabel);
    messageArea.setExpandRatio(textLabel, 1);

    content.addComponent(messageArea);
    content.setExpandRatio(messageArea, 1);

    final Button detailsButton = new Button("Details");
    detailsButton.setVisible(ex != null);
    detailsButton.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            detailsMode = !detailsMode;
            if (detailsMode) {
                String msg = "<pre>" + ExceptionUtils.getStackTrace(ex).trim() + "</pre>";
                msg = msg.replace("\t", "    ");
                textLabel.setValue(msg);
                detailsButton.setCaption("Message");
                messageArea.setMargin(new MarginInfo(false, false, false, true));
                setHeight(600, Unit.PIXELS);
                setWidth(1000, Unit.PIXELS);
                setPosition(getPositionX() - 300, getPositionY() - 150);
            } else {
                textLabel.setValue(message);
                detailsButton.setCaption("Details");
                messageArea.setMargin(true);
                setWidth(400, Unit.PIXELS);
                setHeight(300, Unit.PIXELS);
                setPosition(getPositionX() + 300, getPositionY() + 150);
            }
        }
    });

    content.addComponent(buildButtonFooter(detailsButton, buildCloseButton()));

}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.SqlRunner.java

License:Open Source License

@Override
public void run() {
    TypedProperties properties = settings.getProperties();
    boolean resultsAsText = properties.is(SQL_EXPLORER_RESULT_AS_TEXT);
    int maxResultsSize = properties.getInt(SQL_EXPLORER_MAX_RESULTS);
    String delimiter = properties.get(SQL_EXPLORER_DELIMITER);
    boolean ignoreWhenRunAsScript = properties.is(SQL_EXPLORER_IGNORE_ERRORS_WHEN_RUNNING_SCRIPTS);

    List<Component> resultComponents = new ArrayList<Component>();
    FontAwesome icon = FontAwesome.CHECK_CIRCLE;
    rowsUpdated = false;//  w w w  . j a v a  2 s .c  o  m
    boolean committed = false;
    boolean autoCommitBefore = true;
    try {
        DataSource dataSource = db.getPlatform().getDataSource();
        JdbcSqlTemplate sqlTemplate = (JdbcSqlTemplate) db.getPlatform().getSqlTemplate();
        stmt = null;
        StringBuilder results = new StringBuilder();
        try {
            if (connection == null) {
                connection = dataSource.getConnection();
                connection.setAutoCommit(autoCommit);
            }

            autoCommitBefore = connection.getAutoCommit();
            if (connection.getTransactionIsolation() != sqlTemplate.getIsolationLevel()) {
                connection.setTransactionIsolation(sqlTemplate.getIsolationLevel());
            }
            if (sqlTemplate.isRequiresAutoCommitFalseToSetFetchSize()) {
                connection.setAutoCommit(false);
            }

            SqlScriptReader sqlReader = null;
            try {
                sqlReader = new SqlScriptReader(new StringReader(sqlText));
                sqlReader.setDelimiter(delimiter);
                String sql = sqlReader.readSqlStatement();
                while (sql != null) {
                    JdbcSqlTemplate.close(stmt);
                    if (db.getPlatform().getName().equals("voltdb")) {
                        stmt = connection.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE,
                                ResultSet.CONCUR_READ_ONLY);
                    } else {
                        stmt = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY,
                                ResultSet.CONCUR_READ_ONLY);
                    }

                    String lowercaseSql = sql.trim().toLowerCase();
                    if (!lowercaseSql.startsWith("delete") && !lowercaseSql.startsWith("update")
                            && !lowercaseSql.startsWith("insert")) {
                        if (db.getPlatform().getName().equals(DatabaseNamesConstants.MYSQL)) {
                            stmt.setFetchSize(Integer.MIN_VALUE);
                        } else {
                            stmt.setFetchSize(maxResultsSize < 100 ? maxResultsSize : 100);
                        }
                    }

                    if (logAtDebug) {
                        log.debug("[" + db.getName() + "] Executing: {}", sql.trim());

                    } else {
                        log.info("[" + db.getName() + "] Executing: {}", sql.trim());
                    }
                    if (sql.replaceAll("\\s", "").equalsIgnoreCase(COMMIT_COMMAND)) {
                        committed = true;
                    } else {
                        committed = false;
                    }

                    boolean hasResults = false;
                    try {
                        hasResults = stmt.execute();
                    } catch (SQLException e) {
                        if (runAsScript && ignoreWhenRunAsScript) {
                            results.append(sql);
                            results.append("\n");
                            results.append(buildErrorMessage(e));
                            results.append("\n");
                            results.append("\n");
                        } else {
                            throw e;
                        }
                    }
                    int updateCount = stmt.getUpdateCount();
                    while (hasResults || updateCount != -1) {
                        ResultSet rs = null;
                        try {
                            if (hasResults) {
                                rs = stmt.getResultSet();
                                if (!runAsScript) {
                                    if (!resultsAsText) {
                                        resultComponents.add(new TabularResultLayout(explorer, db, sql, rs,
                                                listener, user, settings, queryPanel, showSqlOnResults,
                                                isInQueryGeneralResults));
                                    } else {
                                        resultComponents.add(putResultsInArea(stmt, maxResultsSize));
                                    }
                                } else {
                                    int rowsRetrieved = 0;
                                    while (rs.next()) {
                                        rowsRetrieved++;
                                    }
                                    results.append(sql);
                                    results.append("\n");
                                    results.append("Rows Retrieved: ");
                                    results.append(rowsRetrieved);
                                    results.append("\n");
                                    results.append("\n");
                                }
                            } else {
                                rowsUpdated = updateCount > 0 ? true : false;
                                if (!runAsScript) {
                                    resultComponents.add(wrapTextInComponent(
                                            String.format("%d rows affected", updateCount)));
                                } else {
                                    results.append(sql);
                                    results.append("\n");
                                    results.append("Rows Affected: ");
                                    results.append(updateCount);
                                    results.append("\n");
                                    results.append("\n");
                                }
                            }
                            hasResults = stmt.getMoreResults();
                            updateCount = stmt.getUpdateCount();
                        } finally {
                            JdbcSqlTemplate.close(rs);
                        }
                    }

                    sql = sqlReader.readSqlStatement();

                }

            } finally {
                IOUtils.closeQuietly(sqlReader);
            }

        } catch (Throwable ex) {
            if (isCanceled) {
                String canceledMessage = "Canceled successfully.\n\n" + sqlText;
                resultComponents.add(wrapTextInComponent(canceledMessage));
            } else {
                icon = FontAwesome.BAN;
                resultComponents.add(wrapTextInComponent(buildErrorMessage(ex), "marked"));
            }
        } finally {
            if (autoCommitBefore) {
                try {
                    connection.commit();
                    connection.setAutoCommit(autoCommitBefore);
                } catch (SQLException e) {
                }
            }
            JdbcSqlTemplate.close(stmt);
            if (autoCommit || (!autoCommit && !rowsUpdated && createdConnection)) {
                JdbcSqlTemplate.close(connection);
                connection = null;
            }

        }

        if (resultComponents.size() == 0 && StringUtils.isNotBlank(results.toString())) {
            resultComponents
                    .add(wrapTextInComponent(results.toString(), icon == FontAwesome.BAN ? "marked" : null));
        }

    } finally {
        endTime = new Date();
        if (listener != null) {
            listener.finished(icon, resultComponents, endTime.getTime() - startTime.getTime(),
                    !autoCommit && rowsUpdated, committed);
        } else if (!autoCommit) {
            rollback(connection);
        }

    }
}

From source file:org.opencms.ui.sitemap.CmsSitemapTreeController.java

License:Open Source License

/**
 * Creates a sitemap tree node widget from a tree node bean.<p>
 *
 * @param entry the tree node bean//w  w  w . ja v  a  2 s.  c  om
 * @return the tree node widget
 */
public CmsSitemapTreeNode createNode(final CmsSitemapTreeNodeData entry) {

    final CmsSitemapTreeNode node = new CmsSitemapTreeNode();

    node.addLayoutClickListener(new LayoutClickListener() {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("synthetic-access")
        public void layoutClick(LayoutClickEvent event) {

            Component currentComponent = event.getClickedComponent();
            if (currentComponent != null) {
                boolean linked = false;
                do {
                    currentComponent = currentComponent.getParent();
                    if ((currentComponent != null)
                            && "linked".equals(((AbstractComponent) currentComponent).getData())) {
                        linked = true;
                    }
                    if (event.getClickedComponent() instanceof CmsResourceIcon) {
                        if (currentComponent == node) {
                            openTargetPage((CmsSitemapTreeNodeData) (node.getData()), linked);
                        } else if (currentComponent instanceof CmsSitemapTreeNode) {
                            break;
                        }
                    }
                } while (currentComponent != null);
            }

        }

    });
    String icon = CmsResourceIcon.getSitemapResourceIcon(A_CmsUI.getCmsObject(), entry.getResource(),
            IconMode.localeCompare);
    CmsResourceInfo info = new CmsResourceInfo(entry.getClientEntry().getTitle(),
            entry.getClientEntry().getSitePath(), icon);
    info = CmsResourceInfo.createSitemapResourceInfo(entry.getResource(),
            OpenCms.getSiteManager().getSiteForRootPath(m_localeContext.getRoot().getRootPath()));
    info.getResourceIcon().addStyleName(OpenCmsTheme.POINTER);
    info.getResourceIcon()
            .setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_OPEN_PAGE_0));

    if (entry.getClientEntry().isHiddenNavigationEntry()) {
        info.addStyleName(OpenCmsTheme.RESOURCE_INFO_WEAK);
    }
    final MenuBar menu = new MenuBar();
    boolean noTranslation = false;
    noTranslation = entry.isMarkedNoTranslation(m_localeContext.getComparisonLocale());

    final MenuItem main = menu.addItem("", null);
    main.setIcon(FontOpenCms.CONTEXT_MENU);
    CssLayout rightSide = new CssLayout();
    info.setButtonWidget(rightSide);
    rightSide.addComponent(menu);
    main.setCommand(new Command() {

        /** Serial version id. */
        private static final long serialVersionUID = 1L;

        public void menuSelected(MenuItem selectedItem) {

            List<I_CmsSimpleContextMenuEntry<MenuContext>> entries = Arrays.asList(

                    new EntryOpen(), new EntryExplorer(), new EntryProperties(), new EntryLink(),
                    new EntryUnlink(), new EntryMark(), new EntryRemoveMark(), new EntryCopy(),
                    new EntryInfo());

            MenuContext context = new MenuContext(entry, node);
            m_menu.setEntries(entries, context);
            m_menu.open(menu);

        }

    });

    menu.addStyleName("borderless o-toolbar-button o-resourceinfo-toolbar");
    if (entry.isLinked()) {
        CmsSite site = OpenCms.getSiteManager().getSiteForRootPath(m_localeContext.getRoot().getRootPath());
        CmsResourceInfo linkedInfo = CmsResourceInfo
                .createSitemapResourceInfo(readSitemapEntryFolderIfPossible(entry.getLinkedResource()), site);
        linkedInfo.addStyleName(OpenCmsTheme.RESOURCE_INFO_DIRECTLINK);
        rightSide.addComponent(linkedInfo, 0);
        linkedInfo.setWidth(RHS_WIDTH + "px");
        node.setContent(info);
        linkedInfo.setData("linked"); // Data used by click handler to distinguish clicked resource icons
        linkedInfo.getResourceIcon()
                .setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_OPEN_PAGE_0));
        linkedInfo.getResourceIcon().addStyleName(OpenCmsTheme.POINTER);
    } else {
        if (noTranslation) {
            CmsResourceInfo noTranslationInfo = new CmsResourceInfo();
            String topMessage = CmsVaadinUtils.getMessageText(Messages.GUI_LOCALECOMPARE_NO_TRANSLATION_TOP_0);
            String bottomMessage = CmsVaadinUtils
                    .getMessageText(Messages.GUI_LOCALECOMPARE_NO_TRANSLATION_BOTTOM_0);
            noTranslationInfo.getTopLine().setValue(topMessage);
            noTranslationInfo.getBottomLine().setValue(bottomMessage);
            noTranslationInfo.getResourceIcon().setValue("<span class=\"" + OpenCmsTheme.RESOURCE_ICON + " "
                    + OpenCmsTheme.NO_TRANSLATION_ICON + "\">" + FontAwesome.BAN.getHtml() + "</span>");
            noTranslationInfo.addStyleName(OpenCmsTheme.RESOURCE_INFO_DIRECTLINK);
            noTranslationInfo.setWidth(RHS_WIDTH + "px");
            rightSide.addComponent(noTranslationInfo, 0);
        }
        node.setContent(info);
    }

    if (entry.hasNoChildren()) {
        node.setOpen(true);
        node.setOpenerVisible(false);
    }
    node.setData(entry);
    return node;

}