Example usage for com.vaadin.server FontAwesome SHARE_ALT

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

Introduction

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

Prototype

FontAwesome SHARE_ALT

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

Click Source Link

Usage

From source file:annis.gui.CitationLinkGenerator.java

License:Apache License

@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
    Button btLink = new Button();
    btLink.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    btLink.setIcon(FontAwesome.SHARE_ALT);
    btLink.setDescription("Share query reference link");
    btLink.addClickListener(this);

    if (itemId instanceof DisplayedResultQuery) {
        btLink.addClickListener(new LinkClickListener((DisplayedResultQuery) itemId));
    } else if (itemId instanceof Query) {
        final CitationProvider citationProvider = new CitationProviderForQuery((Query) itemId);
        btLink.addClickListener(new LinkClickListener(citationProvider));
    } else if (itemId instanceof CitationProvider) {
        final CitationProvider citationProvider = (CitationProvider) itemId;
        btLink.addClickListener(new LinkClickListener(citationProvider));
    }/*from  www  . j a  va  2s  . com*/

    return btLink;
}

From source file:annis.gui.paging.PagingComponent.java

License:Apache License

public PagingComponent(int count, int pageSize) {
    if (pageSize <= 0) {
        pageSize = 1;//from   w w  w.  ja va 2s.c  o  m
    }
    if (count < 0) {
        count = 0;
    }
    currentPage = 1;
    this.count = new AtomicInteger(pageSize);
    this.pageSize = pageSize;

    setWidth("100%");
    setHeight("-1px");

    addStyleName("toolbar");

    callbacks = new HashSet<>();

    layout = new HorizontalLayout();
    layout.setSpacing(true);
    layout.setMargin(new MarginInfo(false, true, false, true));

    setContent(layout);
    addStyleName(ChameleonTheme.PANEL_LIGHT);

    lblInfo = new Label();
    lblInfo.setContentMode(ContentMode.HTML);
    lblInfo.addStyleName("right-aligned-text");

    btShareQuery = new Button(FontAwesome.SHARE_ALT);
    btShareQuery.setDescription("Share query reference link");
    btShareQuery.addStyleName(ValoTheme.BUTTON_BORDERLESS);

    layout.setWidth("100%");
    layout.setHeight("-1px");

    btFirst = new Button();
    btFirst.setIcon(FIRST);
    btFirst.setDescription("jump to first page");
    btFirst.addClickListener((Button.ClickListener) this);
    btFirst.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY);
    btFirst.addStyleName(ChameleonTheme.BUTTON_SMALL);
    btFirst.setDisableOnClick(true);

    btLast = new Button();
    btLast.setIcon(LAST);
    btLast.setDescription("jump to last page");
    btLast.addClickListener((Button.ClickListener) this);
    btLast.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY);
    btLast.addStyleName(ChameleonTheme.BUTTON_SMALL);
    btLast.setDisableOnClick(true);

    btNext = new Button();
    btNext.setIcon(RIGHT_ARROW);
    btNext.setDescription("jump to next page");
    btNext.addClickListener((Button.ClickListener) this);
    btNext.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY);
    btNext.addStyleName(ChameleonTheme.BUTTON_SMALL);
    btNext.setDisableOnClick(true);

    btPrevious = new Button();
    btPrevious.setIcon(LEFT_ARROW);
    btPrevious.setDescription("jump to previous page");
    btPrevious.addClickListener((Button.ClickListener) this);
    btPrevious.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY);
    btPrevious.addStyleName(ChameleonTheme.BUTTON_SMALL);
    btPrevious.setDisableOnClick(true);

    txtPage = new TextField();
    txtPage.setDescription("current page");
    txtPage.setHeight("-1px");
    txtPage.setWidth(5.f, UNITS_EM);
    Validator pageValidator = new PageValidator("must be an integer greater than zero");
    txtPage.addValidator(pageValidator);
    addActionHandler(new EnterHandler(txtPage));

    lblMaxPages = new Label();
    lblMaxPages.setDescription("maximal pages");
    lblMaxPages.setSizeUndefined();

    lblStatus = new Label();
    lblStatus.setSizeUndefined();

    layout.addComponent(btFirst);
    layout.addComponent(btPrevious);
    layout.addComponent(txtPage);
    layout.addComponent(lblMaxPages);
    layout.addComponent(btNext);
    layout.addComponent(btLast);
    layout.addComponent(lblStatus);
    layout.addComponent(lblInfo);
    layout.addComponent(btShareQuery);

    layout.setComponentAlignment(btFirst, Alignment.MIDDLE_LEFT);
    layout.setComponentAlignment(btPrevious, Alignment.MIDDLE_LEFT);
    layout.setComponentAlignment(lblStatus, Alignment.MIDDLE_LEFT);
    layout.setComponentAlignment(lblMaxPages, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(txtPage, Alignment.MIDDLE_RIGHT);
    layout.setComponentAlignment(btNext, Alignment.MIDDLE_RIGHT);
    layout.setComponentAlignment(btLast, Alignment.MIDDLE_RIGHT);

    layout.setExpandRatio(lblStatus, 1.0f);
    layout.setComponentAlignment(lblInfo, Alignment.MIDDLE_RIGHT);
    layout.setExpandRatio(lblInfo, 10.0f);

    update(false);
}

From source file:annis.gui.resultview.SingleResultPanel.java

License:Apache License

public SingleResultPanel(final SDocument result, Match match, long resultNumber,
        ResolverProvider resolverProvider, PluginSystem ps, AnnisUI ui, Set<String> visibleTokenAnnos,
        String segmentationName, QueryController controller, InstanceConfig instanceConfig,
        DisplayedResultQuery query) {/*from  w w  w .  ja va 2 s .c  o  m*/
    this.ps = ps;
    this.ui = ui;
    this.result = result;
    this.segmentationName = segmentationName;
    this.queryController = controller;
    this.resultNumber = resultNumber;
    this.resolverProvider = resolverProvider;
    this.visibleTokenAnnos = visibleTokenAnnos;
    this.instanceConfig = instanceConfig;
    this.query = query;
    this.match = match;

    calculateHelperVariables();

    setWidth("100%");
    setHeight("-1px");

    if (query != null && query.getSelectedMatches().contains(resultNumber)) {
        addStyleName("selected-match");
    }

    infoBar = new HorizontalLayout();
    infoBar.addStyleName("info-bar");
    infoBar.setWidth("100%");
    infoBar.setHeight("-1px");

    Label lblNumber = new Label("" + (resultNumber + 1));
    infoBar.addComponent(lblNumber);
    lblNumber.setSizeUndefined();

    btInfo = new Button();
    btInfo.setStyleName(ValoTheme.BUTTON_BORDERLESS);
    btInfo.setIcon(ICON_RESOURCE);
    btInfo.setDescription("Show metadata");
    btInfo.addClickListener((Button.ClickListener) this);
    infoBar.addComponent(btInfo);

    btLink = new Button();
    btLink.setStyleName(ValoTheme.BUTTON_BORDERLESS);
    btLink.setIcon(FontAwesome.SHARE_ALT);
    btLink.setDescription("Share match reference");
    btLink.setDisableOnClick(true);
    btLink.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            showShareSingleMatchGenerator();
        }
    });
    infoBar.addComponent(btLink);

    /**
     * Extract the top level corpus name and the document name of this single
     * result.
     */
    path = CommonHelper.getCorpusPath(result.getGraph(), result);
    Collections.reverse(path);
    corpusName = path.get(0);
    documentName = path.get(path.size() - 1);

    MinMax minMax = getIds(result.getDocumentGraph());

    // build label
    StringBuilder sb = new StringBuilder("Path: ");
    sb.append(StringUtils.join(path, " > "));
    sb.append(" (" + minMax.segName + " ").append(minMax.min);
    sb.append(" - ").append(minMax.max).append(")");

    Label lblPath = new Label(sb.toString());
    lblPath.addStyleName("path-label");

    lblPath.setWidth("100%");
    lblPath.setHeight("-1px");
    infoBar.addComponent(lblPath);
    infoBar.setExpandRatio(lblPath, 1.0f);
    infoBar.setSpacing(false);

    this.visualizerState = new HashMap<>();

    // init context combox
    lftCtxCombo = new ComboBox();
    rghtCtxCombo = new ComboBox();

    lftCtxCombo.setWidth(50, Unit.PIXELS);
    rghtCtxCombo.setWidth(50, Unit.PIXELS);

    lftCtxCombo.setNullSelectionAllowed(false);
    rghtCtxCombo.setNullSelectionAllowed(false);

    lftCtxCombo.addStyleName(ValoTheme.COMBOBOX_SMALL);
    rghtCtxCombo.addStyleName(ValoTheme.COMBOBOX_SMALL);

    IndexedContainer lftCtxContainer = new IndexedContainer();
    IndexedContainer rghtCtxContainer = new IndexedContainer();

    // and a property for sorting
    lftCtxContainer.addContainerProperty("number", Integer.class, 0);
    rghtCtxContainer.addContainerProperty("number", Integer.class, 0);

    for (int i = 0; i < 30; i += 5) {
        lftCtxContainer.addItem(i).getItemProperty("number").setValue(i);
        rghtCtxContainer.addItem(i).getItemProperty("number").setValue(i);
    }

    int lftContextIdx = query == null ? 0 : query.getLeftContext();
    lftCtxContainer.addItemAt(lftContextIdx, lftContextIdx);
    lftCtxContainer.sort(new Object[] { "number" }, new boolean[] { true });

    int rghtCtxIdx = query == null ? 0 : query.getRightContext();
    rghtCtxContainer.addItem(rghtCtxIdx);

    rghtCtxContainer.sort(new Object[] { "number" }, new boolean[] { true });

    lftCtxCombo.setContainerDataSource(lftCtxContainer);
    rghtCtxCombo.setContainerDataSource(rghtCtxContainer);

    lftCtxCombo.select(lftContextIdx);
    rghtCtxCombo.select(rghtCtxIdx);

    lftCtxCombo.setNewItemsAllowed(true);
    rghtCtxCombo.setNewItemsAllowed(true);

    lftCtxCombo.setImmediate(true);
    rghtCtxCombo.setImmediate(true);

    lftCtxCombo.setNewItemHandler(new AddNewItemHandler(lftCtxCombo));
    rghtCtxCombo.setNewItemHandler(new AddNewItemHandler(rghtCtxCombo));

    lftCtxCombo.addValueChangeListener(new ContextChangeListener(resultNumber, true));
    rghtCtxCombo.addValueChangeListener(new ContextChangeListener(resultNumber, false));

    Label leftCtxLabel = new Label("left context: ");
    Label rightCtxLabel = new Label("right context: ");

    leftCtxLabel.setWidth("-1px");
    rightCtxLabel.setWidth("-1px");

    HorizontalLayout ctxLayout = new HorizontalLayout();
    ctxLayout.setSpacing(true);
    ctxLayout.addComponents(leftCtxLabel, lftCtxCombo, rightCtxLabel, rghtCtxCombo);
    infoBar.addComponent(ctxLayout);

    addComponent(infoBar);
    initVisualizer();
}

From source file:com.dungnv.streetfood.ui.DishItemUI.java

private void buildAction() {

    if ("1".equals(item.getDishStatus())) {
        lbTitle.addStyleName("lb-status-active");
    } else {/*from  w w  w .j a  va  2 s . c o m*/
        lbTitle.addStyleName("lb-status-inActive");
    }

    String info = !StringUtils.isNullOrEmpty(item.getId())
            ? "<b>" + com.kbdunn.vaadin.addons.fontawesome.FontAwesome.BARCODE.getHtml() + " " + item.getId()
                    + "</b>"
            : "<b>" + com.kbdunn.vaadin.addons.fontawesome.FontAwesome.BARCODE.getHtml() + " --</b>";

    info += !StringUtils.isNullOrEmpty(item.getRating())
            ? "&nbsp|" + FontAwesome.STAR_O.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getRating()
            : "&nbsp|" + FontAwesome.STAR_O.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";

    info += !StringUtils.isNullOrEmpty(item.getViewCount())
            ? "&nbsp|" + FontAwesome.EYE.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getViewCount()
            : "&nbsp|" + FontAwesome.EYE.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";

    info += !StringUtils.isNullOrEmpty(item.getCommentCount())
            ? "&nbsp|" + FontAwesome.COMMENTS.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getCommentCount()
            : "&nbsp|" + FontAwesome.COMMENTS.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";

    info += !StringUtils.isNullOrEmpty(item.getShareCount())
            ? "&nbsp|" + FontAwesome.SHARE_ALT.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getShareCount()
            : "&nbsp|" + FontAwesome.SHARE_ALT.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";

    if (!StringUtils.isNullOrEmpty(info)) {
        lbInfo.setCaption(info);
    }

    btnEdit.addClickListener((Button.ClickEvent event) -> {
        if (item != null) {
            DishInsert dishInsert = new DishInsert(item//
            , event.getButton().findAncestor(DishView.class)//
            , Constants.ACTION.UPDATE);
            dishInsert.setWidth("80%");
            dishInsert.setHeight("90%");
            dishInsert.setModal(true);
            FWUtils.reloadWindow(dishInsert);
            UI.getCurrent().addWindow(dishInsert);
        }
    });

    btnLink.addClickListener((Button.ClickEvent event) -> {
        if (item != null) {
            DishLink dishLink = new DishLink(item);
            dishLink.setWidth("80%");
            dishLink.setHeight("75%");
            dishLink.setModal(true);
            FWUtils.reloadWindow(dishLink);
            UI.getCurrent().addWindow(dishLink);
        }
    });

    btnDelete.addClickListener((Button.ClickEvent event) -> {
        ConfirmDialog.show(UI.getCurrent(), BundleUtils.getLanguage("lbl.confirm")//
        , BundleUtils.getLanguage("message.category.delete.confirm")//
        , BundleUtils.getLanguage("lbl.yes")//
        , BundleUtils.getLanguage("lbl.no")//
        , (ConfirmDialog cd) -> {
            if (cd.isConfirmed()) {
                UserDTO user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());
                ResultDTO result = ClientServiceImpl.getInstance().deleteDish(user.getUsername()//
                , getLocale().getLanguage(), getLocale().getCountry(), null, Long.valueOf(itemId));
                if (result != null && Constants.SUCCESS.equals(result.getMessage())) {
                    mainView.onSearch(Boolean.TRUE);
                    UI.getCurrent().removeWindow(event.getButton().findAncestor(Window.class));
                } else {
                    Notification.show(
                            result == null || result.getKey() == null ? Constants.FAIL : result.getKey(),
                            Notification.Type.ERROR_MESSAGE);
                }
            }
        });
    });

}

From source file:com.dungnv.streetfood.ui.RestaurantItemUI.java

private void buildAction() {

    if ("1".equals(item.getRestaurantStatus())) {
        lbTitle.addStyleName("lb-status-active");
    } else {// w  w  w  .j a  va2  s.  c o  m
        lbTitle.addStyleName("lb-status-inActive");
    }

    String info = !StringUtils.isNullOrEmpty(item.getId())
            ? "<b>" + com.kbdunn.vaadin.addons.fontawesome.FontAwesome.BARCODE.getHtml() + " " + item.getId()
                    + "</b>"
            : "<b>" + com.kbdunn.vaadin.addons.fontawesome.FontAwesome.BARCODE.getHtml() + " --</b>";

    info += !StringUtils.isNullOrEmpty(item.getRating())
            ? "&nbsp|" + FontAwesome.STAR_O.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getRating()
            : "&nbsp|" + FontAwesome.STAR_O.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";

    info += !StringUtils.isNullOrEmpty(item.getViewCount())
            ? "&nbsp|" + FontAwesome.EYE.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getViewCount()
            : "&nbsp|" + FontAwesome.EYE.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";

    info += !StringUtils.isNullOrEmpty(item.getCommentCount())
            ? "&nbsp|" + FontAwesome.COMMENTS.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getCommentCount()
            : "&nbsp|" + FontAwesome.COMMENTS.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";

    info += !StringUtils.isNullOrEmpty(item.getShareCount())
            ? "&nbsp|" + FontAwesome.SHARE_ALT.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getShareCount()
            : "&nbsp|" + FontAwesome.SHARE_ALT.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--";
    //        
    //        info += !StringUtils.isNullOrEmpty(item.getOperatingTimeStart())
    //                ? "&nbsp|" + FontAwesome.CLOCK_O.getHtml() + "&nbsp&nbsp:&nbsp&nbsp" + item.getOperatingTimeStart() + " / "
    //                : "&nbsp|" + FontAwesome.CLOCK_O.getHtml() + "&nbsp&nbsp:&nbsp&nbsp--:--" + " / ";
    //        
    //        info += !StringUtils.isNullOrEmpty(item.getOperatingTimeEnd())
    //                ?  item.getOperatingTimeEnd() : "--:--" ;

    if (!StringUtils.isNullOrEmpty(info)) {
        lbInfo.setCaption(info);
    }

    btnEdit.addClickListener((Button.ClickEvent event) -> {
        if (item != null) {
            RestaurantInsert restaurantInsert = new RestaurantInsert(item//
            , event.getButton().findAncestor(RestaurantView.class)//
            , Constants.ACTION.UPDATE);
            restaurantInsert.setWidth("80%");
            restaurantInsert.setHeight("90%");
            restaurantInsert.setModal(true);
            FWUtils.reloadWindow(restaurantInsert);
            UI.getCurrent().addWindow(restaurantInsert);
        }
    });

    btnLink.addClickListener((Button.ClickEvent event) -> {
        if (item != null) {
            RestaurantLink restaurantLink = new RestaurantLink(item);
            restaurantLink.setWidth("80%");
            restaurantLink.setHeight("75%");
            restaurantLink.setModal(true);
            FWUtils.reloadWindow(restaurantLink);
            UI.getCurrent().addWindow(restaurantLink);
        }
    });

    btnDelete.addClickListener((Button.ClickEvent event) -> {
        ConfirmDialog.show(UI.getCurrent(), BundleUtils.getLanguage("lbl.confirm")//
        , BundleUtils.getLanguage("message.category.delete.confirm")//
        , BundleUtils.getLanguage("lbl.yes")//
        , BundleUtils.getLanguage("lbl.no")//
        , (ConfirmDialog cd) -> {
            if (cd.isConfirmed()) {
                UserDTO user = (UserDTO) VaadinSession.getCurrent().getAttribute(UserDTO.class.getName());
                ResultDTO result = ClientServiceImpl.getInstance().deleteRestaurant(user.getUsername()//
                , getLocale().getLanguage(), getLocale().getCountry(), null, Long.valueOf(itemId));
                if (result != null && Constants.SUCCESS.equals(result.getMessage())) {
                    mainView.onSearch(Boolean.TRUE);
                    UI.getCurrent().removeWindow(event.getButton().findAncestor(Window.class));
                } else {
                    Notification.show(
                            result == null || result.getKey() == null ? Constants.FAIL : result.getKey(),
                            Notification.Type.ERROR_MESSAGE);
                }
            }
        });
    });

}

From source file:com.esofthead.mycollab.vaadin.ui.EditFormControlsGenerator.java

License:Open Source License

public HorizontalLayout createButtonControls(final boolean isSaveBtnVisible,
        final boolean isSaveAndNewBtnVisible, final boolean isCancelBtnVisible) {
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);//from   w  ww  .j  a  va 2  s  . c o  m
    layout.setSizeUndefined();
    layout.setStyleName("addNewControl");

    if (isSaveBtnVisible) {
        final Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        if (EditFormControlsGenerator.this.editForm.validateForm()) {
                            EditFormControlsGenerator.this.editForm.fireSaveForm();
                        }
                    }
                });
        saveBtn.setIcon(FontAwesome.SAVE);
        saveBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        layout.addComponent(saveBtn);
        layout.setComponentAlignment(saveBtn, Alignment.MIDDLE_CENTER);
    }

    if (isSaveAndNewBtnVisible) {
        final Button saveAndNewBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE_NEW),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        if (EditFormControlsGenerator.this.editForm.validateForm()) {
                            EditFormControlsGenerator.this.editForm.fireSaveAndNewForm();
                        }
                    }
                });
        saveAndNewBtn.setIcon(FontAwesome.SHARE_ALT);
        saveAndNewBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        layout.addComponent(saveAndNewBtn);
        layout.setComponentAlignment(saveAndNewBtn, Alignment.MIDDLE_CENTER);
    }

    if (isCancelBtnVisible) {
        final Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        EditFormControlsGenerator.this.editForm.fireCancelForm();
                    }
                });
        cancelBtn.setIcon(FontAwesome.MINUS);
        cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
        layout.addComponent(cancelBtn);
        layout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_CENTER);
    }

    return layout;
}

From source file:com.esofthead.mycollab.vaadin.web.ui.EditFormControlsGenerator.java

License:Open Source License

public HorizontalLayout createButtonControls(boolean isSaveBtnVisible, boolean isSaveAndNewBtnVisible,
        boolean isCancelBtnVisible) {
    MHorizontalLayout layout = new MHorizontalLayout().withStyleName("addNewControl");
    layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    layout.setSizeUndefined();//  w  ww .  j av a 2  s  .  c  om

    if (isSaveBtnVisible) {
        final Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        if (editForm.validateForm()) {
                            editForm.fireSaveForm();
                        }
                    }
                });
        saveBtn.setIcon(FontAwesome.SAVE);
        saveBtn.setStyleName(UIConstants.BUTTON_ACTION);
        layout.addComponent(saveBtn);
    }

    if (isSaveAndNewBtnVisible) {
        Button saveAndNewBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE_NEW),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        if (editForm.validateForm()) {
                            editForm.fireSaveAndNewForm();
                        }
                    }
                });
        saveAndNewBtn.setIcon(FontAwesome.SHARE_ALT);
        saveAndNewBtn.setStyleName(UIConstants.BUTTON_ACTION);
        layout.addComponent(saveAndNewBtn);
    }

    if (isCancelBtnVisible) {
        Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        editForm.fireCancelForm();
                    }
                });
        cancelBtn.setIcon(FontAwesome.MINUS);
        cancelBtn.setStyleName(UIConstants.BUTTON_OPTION);
        layout.addComponent(cancelBtn);
    }

    return layout;
}

From source file:com.esofthead.mycollab.vaadin.web.ui.utils.FormControlsGenerator.java

License:Open Source License

public static final <T> ComponentContainer generateEditFormControls(final AdvancedEditBeanForm<T> editForm,
        boolean isSaveBtnVisible, boolean isSaveAndNewBtnVisible, boolean isCancelBtnVisible) {
    MHorizontalLayout layout = new MHorizontalLayout();

    if (isCancelBtnVisible) {
        Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override/*from   w ww.j  av  a 2  s . c o  m*/
                    public void buttonClick(final Button.ClickEvent event) {
                        editForm.fireCancelForm();
                    }
                });
        cancelBtn.setIcon(FontAwesome.MINUS);
        cancelBtn.setStyleName(UIConstants.BUTTON_OPTION);
        layout.addComponent(cancelBtn);
    }

    if (isSaveAndNewBtnVisible) {
        Button saveAndNewBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE_NEW),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final Button.ClickEvent event) {
                        if (editForm.validateForm()) {
                            editForm.fireSaveAndNewForm();
                        }
                    }
                });
        saveAndNewBtn.setIcon(FontAwesome.SHARE_ALT);
        saveAndNewBtn.setStyleName(UIConstants.BUTTON_ACTION);
        layout.addComponent(saveAndNewBtn);
    }

    if (isSaveBtnVisible) {
        final Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final Button.ClickEvent event) {
                        if (editForm.validateForm()) {
                            editForm.fireSaveForm();
                        }
                    }
                });
        saveBtn.setIcon(FontAwesome.SAVE);
        saveBtn.setStyleName(UIConstants.BUTTON_ACTION);
        layout.addComponent(saveBtn);
    }

    return layout;
}

From source file:com.mycollab.vaadin.web.ui.utils.FormControlsGenerator.java

License:Open Source License

public static <T> ComponentContainer generateEditFormControls(final AdvancedEditBeanForm<T> editForm,
        boolean isSaveBtnVisible, boolean isSaveAndNewBtnVisible, boolean isCancelBtnVisible) {
    MHorizontalLayout layout = new MHorizontalLayout();

    if (isCancelBtnVisible) {
        MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
                clickEvent -> editForm.fireCancelForm()).withStyleName(WebThemes.BUTTON_OPTION);
        layout.addComponent(cancelBtn);/*w w  w .  j av  a 2s  .  com*/
    }

    if (isSaveAndNewBtnVisible) {
        MButton saveAndNewBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE_NEW),
                clickEvent -> {
                    if (editForm.validateForm()) {
                        editForm.fireSaveAndNewForm();
                    }
                }).withIcon(FontAwesome.SHARE_ALT).withStyleName(WebThemes.BUTTON_ACTION);
        layout.addComponent(saveAndNewBtn);
    }

    if (isSaveBtnVisible) {
        final MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE),
                clickEvent -> {
                    if (editForm.validateForm()) {
                        editForm.fireSaveForm();
                    }
                }).withIcon(FontAwesome.SAVE).withStyleName(WebThemes.BUTTON_ACTION);
        layout.addComponent(saveBtn);
    }

    return layout;
}