Example usage for com.vaadin.server FontAwesome PLUS

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

Introduction

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

Prototype

FontAwesome PLUS

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

Click Source Link

Usage

From source file:com.esofthead.mycollab.module.project.view.task.TaskKanbanviewImpl.java

License:Open Source License

public TaskKanbanviewImpl() {
    this.setSizeFull();
    this.withSpacing(true).withMargin(new MarginInfo(false, true, true, true));
    searchPanel = new TaskSearchPanel();
    MHorizontalLayout groupWrapLayout = new MHorizontalLayout();
    groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    searchPanel.addHeaderRight(groupWrapLayout);

    Button addNewColumnBtn = new Button("New column", new Button.ClickListener() {
        @Override//from   w ww  .  j a  va 2  s  .  c  o  m
        public void buttonClick(Button.ClickEvent clickEvent) {
            UI.getCurrent()
                    .addWindow(new AddNewColumnWindow(TaskKanbanviewImpl.this, ProjectTypeConstants.TASK));
        }
    });
    addNewColumnBtn.setIcon(FontAwesome.PLUS);
    addNewColumnBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS));
    addNewColumnBtn.setStyleName(UIConstants.BUTTON_ACTION);
    groupWrapLayout.addComponent(addNewColumnBtn);

    Button deleteColumBtn = new Button("Delete columns", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent()
                    .addWindow(new DeleteColumnWindow(TaskKanbanviewImpl.this, ProjectTypeConstants.TASK));
        }
    });
    deleteColumBtn.setIcon(FontAwesome.TRASH_O);
    deleteColumBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS));
    deleteColumBtn.setStyleName(UIConstants.BUTTON_DANGER);

    Button advanceDisplayBtn = new Button("List", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new TaskEvent.GotoDashboard(TaskKanbanviewImpl.this, null));
        }
    });
    advanceDisplayBtn.setWidth("100px");
    advanceDisplayBtn.setIcon(FontAwesome.SITEMAP);
    advanceDisplayBtn.setDescription("Advance View");

    Button kanbanBtn = new Button("Kanban");
    kanbanBtn.setWidth("100px");
    kanbanBtn.setDescription("Kanban View");
    kanbanBtn.setIcon(FontAwesome.TH);

    ToggleButtonGroup viewButtons = new ToggleButtonGroup();
    viewButtons.addButton(advanceDisplayBtn);
    viewButtons.addButton(kanbanBtn);
    viewButtons.setDefaultButton(kanbanBtn);
    groupWrapLayout.addComponent(viewButtons);

    kanbanLayout = new DDHorizontalLayout();
    kanbanLayout.setHeight("100%");
    kanbanLayout.addStyleName("kanban-layout");
    kanbanLayout.setSpacing(true);
    kanbanLayout.setMargin(new MarginInfo(true, false, true, false));
    kanbanLayout.setComponentHorizontalDropRatio(0.3f);
    kanbanLayout.setDragMode(LayoutDragMode.CLONE_OTHER);

    //      Enable dropping components
    kanbanLayout.setDropHandler(new DropHandler() {
        @Override
        public void drop(DragAndDropEvent event) {
            LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();

            DDHorizontalLayout.HorizontalLayoutTargetDetails details = (DDHorizontalLayout.HorizontalLayoutTargetDetails) event
                    .getTargetDetails();
            Component dragComponent = transferable.getComponent();
            if (dragComponent instanceof KanbanBlock) {
                KanbanBlock kanbanItem = (KanbanBlock) dragComponent;
                int newIndex = details.getOverIndex();
                if (details.getDropLocation() == HorizontalDropLocation.RIGHT) {
                    kanbanLayout.addComponent(kanbanItem);
                } else if (newIndex == -1) {
                    kanbanLayout.addComponent(kanbanItem, 0);
                } else {
                    kanbanLayout.addComponent(kanbanItem, newIndex);
                }

                //Update options index for this project
                List<Map<String, Integer>> indexMap = new ArrayList<>();
                for (int i = 0; i < kanbanLayout.getComponentCount(); i++) {
                    KanbanBlock blockItem = (KanbanBlock) kanbanLayout.getComponent(i);
                    Map<String, Integer> map = new HashedMap(2);
                    map.put("id", blockItem.optionVal.getId());
                    map.put("index", i);
                    indexMap.add(map);
                }
                if (indexMap.size() > 0) {
                    optionValService.massUpdateOptionIndexes(indexMap, AppContext.getAccountId());
                }
            }
        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return new Not(VerticalLocationIs.MIDDLE);
        }
    });
    this.setWidth("100%");
    this.with(searchPanel, kanbanLayout).expand(kanbanLayout);
}

From source file:com.esofthead.mycollab.module.project.view.UserDashboardViewImpl.java

License:Open Source License

@Override
protected void displayView() {
    this.removeAllComponents();

    this.withMargin(false).withWidth("100%");

    final CssLayout headerWrapper = new CssLayout();
    headerWrapper.setWidth("100%");
    headerWrapper.setStyleName("projectfeed-hdr-wrapper");

    final MHorizontalLayout header = new MHorizontalLayout().withMargin(false).withWidth("100%");
    header.addStyleName("projectfeed-hdr");

    Button avatar = UserAvatarControlFactory.createUserAvatarEmbeddedButton(AppContext.getUserAvatarId(), 64);
    avatar.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override/*  www  .  j  a  va  2 s  . com*/
        public void buttonClick(final ClickEvent event) {
            String userFullLinkStr = AccountLinkGenerator.generatePreviewFullUserLink(AppContext.getSiteUrl(),
                    AppContext.getUsername());
            getUI().getPage().open(userFullLinkStr, null);
        }
    });

    header.addComponent(avatar);

    final MVerticalLayout headerContent = new MVerticalLayout()
            .withMargin(new MarginInfo(false, false, false, true));
    headerContent.addStyleName("projectfeed-hdr-content");

    final Label headerLabel = new Label(AppContext.getSession().getDisplayName());
    headerLabel.setStyleName(Reindeer.LABEL_H1);

    final MHorizontalLayout headerContentTop = new MHorizontalLayout()
            .withMargin(new MarginInfo(false, false, true, false));
    headerContentTop.with(headerLabel).withAlign(headerLabel, Alignment.TOP_LEFT);

    if (AppContext.canBeYes(RolePermissionCollections.CREATE_NEW_PROJECT)) {
        final Button createProjectBtn = new Button(
                AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_NEW_PROJECT), new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final Button.ClickEvent event) {
                        final ProjectAddWindow projectNewWindow = new ProjectAddWindow();
                        UI.getCurrent().addWindow(projectNewWindow);
                    }
                });
        createProjectBtn.setIcon(FontAwesome.PLUS);
        createProjectBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        headerContentTop.addComponent(createProjectBtn);
        headerContentTop.setComponentAlignment(createProjectBtn, Alignment.MIDDLE_LEFT);
    }

    followingTicketsLink = new LabelLink(AppContext.getMessage(FollowerI18nEnum.OPT_MY_FOLLOWING_TICKETS, 0),
            AppContext.getSiteUrl() + "#project/following");

    followingTicketsLink.setIconLink(FontAwesome.EYE);

    LabelLink timeTrackingLink = new LabelLink(AppContext.getMessage(TimeTrackingI18nEnum.TIME_RECORD_HEADER),
            AppContext.getSiteUrl() + "#project/timetracking");
    timeTrackingLink.setIconLink(ProjectAssetsManager.getAsset(ProjectTypeConstants.TIME));

    final MHorizontalLayout headerContentBottom = new MHorizontalLayout().withMargin(false)
            .with(followingTicketsLink, timeTrackingLink);

    headerContent.with(headerContentTop, headerContentBottom);

    header.with(headerContent).expand(headerContent);
    headerWrapper.addComponent(header);

    this.addComponent(headerWrapper);

    final MHorizontalLayout layout = new MHorizontalLayout()
            .withMargin(new MarginInfo(false, false, true, false)).withWidth("100%");

    ActivityStreamComponent activityStreamComponent = new ActivityStreamComponent();
    final MVerticalLayout leftPanel = new MVerticalLayout().withSpacing(false)
            .withMargin(new MarginInfo(false, true, false, false)).withWidth("100%")
            .with(activityStreamComponent);

    final MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false).withWidth("565px");
    MyProjectListComponent myProjectListComponent = new MyProjectListComponent();
    TaskStatusComponent taskStatusComponent = new TaskStatusComponent();
    rightPanel.with(myProjectListComponent, taskStatusComponent);

    layout.with(leftPanel, rightPanel).expand(leftPanel);

    final CssLayout contentWrapper = new CssLayout();
    contentWrapper.setWidth("100%");
    contentWrapper.addStyleName("content-wrapper");
    this.addComponent(contentWrapper);
    contentWrapper.addComponent(layout);

    final ProjectService prjService = ApplicationContextUtil.getSpringBean(ProjectService.class);
    prjKeys = prjService.getProjectKeysUserInvolved(AppContext.getUsername(), AppContext.getAccountId());
    if (CollectionUtils.isNotEmpty(prjKeys)) {
        activityStreamComponent.showFeeds(prjKeys);
        myProjectListComponent.displayDefaultProjectsList();
        displayFollowingTicketsCount();
    }

    taskStatusComponent.showProjectTasksByStatus(prjKeys);

}

From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.RoleSearchPanel.java

License:Open Source License

private HorizontalLayout createSearchTopPanel() {
    final MHorizontalLayout layout = new MHorizontalLayout().withStyleName(UIConstants.HEADER_VIEW)
            .withWidth("100%").withSpacing(true).withMargin(new MarginInfo(true, false, true, false));
    layout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    final Label searchtitle = new Label(
            FontAwesome.USERS.getHtml() + " " + AppContext.getMessage(RoleI18nEnum.VIEW_LIST_TITLE),
            ContentMode.HTML);/*from ww w  .ja  v  a2 s  . co m*/
    searchtitle.setStyleName(UIConstants.HEADER_TEXT);
    layout.addComponent(searchtitle);
    layout.setExpandRatio(searchtitle, 1.0f);

    final Button createBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CREATE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final Button.ClickEvent event) {
                    EventBusFactory.getInstance().post(new RoleEvent.GotoAdd(this, null));
                }
            });
    createBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createBtn.setIcon(FontAwesome.PLUS);
    createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.ACCOUNT_ROLE));

    layout.with(createBtn).withAlign(createBtn, Alignment.MIDDLE_RIGHT);

    return layout;
}

From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.UserListViewImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*w ww .  j a v a  2 s. com*/
public void setSearchCriteria(UserSearchCriteria searchCriteria) {
    UserService userService = ApplicationContextUtil.getSpringBean(UserService.class);
    List<SimpleUser> userAccountList = userService
            .findPagableListByCriteria(new SearchRequest<>(searchCriteria, 0, Integer.MAX_VALUE));

    this.removeAllComponents();
    this.setSpacing(true);
    HorizontalLayout header = new HorizontalLayout();
    header.setStyleName(UIConstants.HEADER_VIEW);
    header.setWidth("100%");
    header.setMargin(new MarginInfo(true, false, true, false));
    Button createBtn = new Button("Invite user", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new UserEvent.GotoAdd(this, null));
        }
    });
    createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.ACCOUNT_USER));
    createBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createBtn.setIcon(FontAwesome.PLUS);

    header.addComponent(createBtn);
    header.setComponentAlignment(createBtn, Alignment.MIDDLE_RIGHT);
    this.addComponent(header);

    CssLayout contentLayout = new CssLayout();
    contentLayout.setWidth("100%");
    for (SimpleUser userAccount : userAccountList) {
        contentLayout.addComponent(generateMemberBlock(userAccount));
    }
    this.addComponent(contentLayout);
}

From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.UserSearchPanel.java

License:Open Source License

private HorizontalLayout createSearchTopPanel() {
    final MHorizontalLayout layout = new MHorizontalLayout().withWidth("100%").withSpacing(true)
            .withMargin(true);//from  w ww. ja v  a2  s.c  o  m

    final Label searchtitle = new Label("Users");
    searchtitle.setStyleName(Reindeer.LABEL_H2);
    layout.addComponent(searchtitle);
    layout.setComponentAlignment(searchtitle, Alignment.MIDDLE_LEFT);

    final Button createBtn = new Button("Invite", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new UserEvent.GotoAdd(this, null));
        }
    });
    createBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createBtn.setIcon(FontAwesome.PLUS);
    createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.ACCOUNT_USER));

    layout.with(createBtn).withAlign(createBtn, Alignment.MIDDLE_RIGHT);

    return layout;
}

From source file:com.esofthead.mycollab.module.user.ui.components.PreviewFormControlsGenerator.java

License:Open Source License

public HorizontalLayout createButtonControls(int buttonEnableFlags, String permissionItem) {
    optionBtn = new PopupButton();
    optionBtn.addStyleName(UIConstants.BOX);
    optionBtn.setIcon(FontAwesome.ELLIPSIS_H);

    if (permissionItem != null) {
        boolean canWrite = AppContext.canWrite(permissionItem);
        boolean canAccess = AppContext.canAccess(permissionItem);
        boolean canRead = AppContext.canRead(permissionItem);

        if ((buttonEnableFlags & ADD_BTN_PRESENTED) == ADD_BTN_PRESENTED) {
            Button addBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ADD),
                    new Button.ClickListener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void buttonClick(final ClickEvent event) {
                            optionBtn.setPopupVisible(false);
                            T item = previewForm.getBean();
                            previewForm.fireAddForm(item);
                        }//  w ww  .j  a  v  a 2 s .  c om
                    });
            addBtn.setIcon(FontAwesome.PLUS);
            addBtn.setStyleName(UIConstants.BUTTON_ACTION);
            addBtn.setEnabled(canWrite);
            editButtons.addComponent(addBtn);
        }

        if ((buttonEnableFlags & EDIT_BTN_PRESENTED) == EDIT_BTN_PRESENTED) {
            Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT),
                    new Button.ClickListener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void buttonClick(final ClickEvent event) {
                            optionBtn.setPopupVisible(false);
                            T item = previewForm.getBean();
                            previewForm.fireEditForm(item);
                        }
                    });
            editBtn.setIcon(FontAwesome.EDIT);
            editBtn.setStyleName(UIConstants.BUTTON_ACTION);
            editBtn.setEnabled(canWrite);
            editButtons.addComponent(editBtn);
        }

        if ((buttonEnableFlags & DELETE_BTN_PRESENTED) == DELETE_BTN_PRESENTED) {
            Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE),
                    new Button.ClickListener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void buttonClick(final ClickEvent event) {
                            T item = previewForm.getBean();
                            previewForm.fireDeleteForm(item);
                        }
                    });
            deleteBtn.setIcon(FontAwesome.TRASH_O);
            deleteBtn.setStyleName(UIConstants.BUTTON_DANGER);
            deleteBtn.setEnabled(canAccess);
            editButtons.addComponent(deleteBtn);
        }

        layout.with(editButtons);

        if ((buttonEnableFlags & NAVIGATOR_BTN_PRESENTED) == NAVIGATOR_BTN_PRESENTED) {
            ButtonGroup navigationBtns = new ButtonGroup();
            Button previousItem = new Button(null, new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    T item = previewForm.getBean();
                    previewForm.fireGotoPrevious(item);
                }
            });
            previousItem.setIcon(FontAwesome.CHEVRON_LEFT);
            previousItem.setStyleName(UIConstants.BUTTON_ACTION);
            previousItem.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_PREVIOUS_ITEM));
            previousItem.setEnabled(canRead);
            navigationBtns.addButton(previousItem);

            Button nextItemBtn = new Button(null, new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    T item = previewForm.getBean();
                    previewForm.fireGotoNextItem(item);
                }
            });
            nextItemBtn.setIcon(FontAwesome.CHEVRON_RIGHT);
            nextItemBtn.setStyleName(UIConstants.BUTTON_ACTION);
            nextItemBtn.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_NEXT_ITEM));
            nextItemBtn.setEnabled(canRead);
            navigationBtns.addButton(nextItemBtn);
            layout.with(navigationBtns);
        }

        if ((buttonEnableFlags & CLONE_BTN_PRESENTED) == CLONE_BTN_PRESENTED) {
            Button cloneBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLONE),
                    new Button.ClickListener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void buttonClick(final ClickEvent event) {
                            optionBtn.setPopupVisible(false);
                            T item = previewForm.getBean();
                            previewForm.fireCloneForm(item);
                        }
                    });
            cloneBtn.setIcon(FontAwesome.ROAD);
            cloneBtn.setEnabled(canWrite);
            popupButtonsControl.addOption(cloneBtn);
        }

        if (popupButtonsControl.getComponentCount() > 0) {
            optionBtn.setContent(popupButtonsControl);
            layout.with(optionBtn);
        }
    }
    return layout;
}

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

License:Open Source License

public BuildCriterionComponent(Param[] paramFields, Class<S> type, String searchCategory) {
    this.setSpacing(true);
    this.paramFields = paramFields;
    this.type = type;
    this.searchCategory = searchCategory;

    MHorizontalLayout headerBox = new MHorizontalLayout().withSpacing(true)
            .withMargin(new MarginInfo(true, false, true, true));
    headerBox.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    this.addComponent(headerBox);

    Label filterLbl = new Label("&nbsp; Saved Filter: ", ContentMode.HTML);
    headerBox.with(filterLbl).withAlign(filterLbl, Alignment.MIDDLE_LEFT);

    filterBox = new MHorizontalLayout().withSpacing(true);
    headerBox.with(filterBox).withAlign(filterBox, Alignment.MIDDLE_LEFT);

    buildFilterBox(null);/*from   ww  w .  j av  a 2 s  .c  o m*/

    this.searchContainer = new MVerticalLayout().withSpacing(true).withMargin(false);
    this.searchContainer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    controlsBtn = new MHorizontalLayout().withSpacing(true).withMargin(true);

    Button addCriteriaBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ADD_CRITERIA),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    CriteriaSelectionLayout newCriteriaBar = new CriteriaSelectionLayout(
                            searchContainer.getComponentCount() + 1);
                    searchContainer.addComponent(newCriteriaBar);
                }
            });
    addCriteriaBtn.setStyleName(UIConstants.THEME_BROWN_LINK);
    addCriteriaBtn.setIcon(FontAwesome.PLUS);

    controlsBtn.with(addCriteriaBtn);

    this.with(searchContainer, controlsBtn);
}

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

License:Open Source License

private void buildFilterBox(String queryname) {
    filterBox.removeAllComponents();//from  w  w w .j av a 2  s  .  co  m

    filterComboBox = new SavedSearchResultComboBox();
    filterComboBox.setWidth("125px");
    filterBox.addComponent(filterComboBox);

    Button saveSearchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_NEW_FILTER),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    buildSaveFilterBox();
                }
            });
    saveSearchBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    saveSearchBtn.setIcon(FontAwesome.PLUS);
    filterBox.addComponent(saveSearchBtn);
}

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

License:Open Source License

public HorizontalLayout createButtonControls(int buttonEnableFlags, final String permissionItem) {

    Button optionParentBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_OPTION),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override//from ww  w  .  j a v  a2s.  c  o  m
                public void buttonClick(ClickEvent event) {
                    optionBtn.setPopupVisible(true);
                }
            });

    optionBtn = new SplitButton(optionParentBtn);
    optionBtn.setWidthUndefined();
    optionBtn.addStyleName(UIConstants.THEME_GRAY_LINK);

    if ((buttonEnableFlags & ADD_BTN_PRESENTED) == ADD_BTN_PRESENTED) {
        addBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ADD), new Button.ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                optionBtn.setPopupVisible(false);
                final T item = previewForm.getBean();
                previewForm.fireAddForm(item);
            }
        });
        addBtn.setIcon(FontAwesome.PLUS);
        addBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        editButtons.addComponent(addBtn);
        editButtons.setComponentAlignment(addBtn, Alignment.MIDDLE_CENTER);
    }

    if ((buttonEnableFlags & EDIT_BTN_PRESENTED) == EDIT_BTN_PRESENTED) {
        editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                optionBtn.setPopupVisible(false);
                final T item = previewForm.getBean();
                previewForm.fireEditForm(item);
            }
        });
        editBtn.setIcon(FontAwesome.EDIT);
        editBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        editButtons.addComponent(editBtn);
        editButtons.setComponentAlignment(editBtn, Alignment.MIDDLE_CENTER);
    }

    if ((buttonEnableFlags & DELETE_BTN_PRESENTED) == DELETE_BTN_PRESENTED) {
        deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE), new Button.ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                final T item = previewForm.getBean();
                previewForm.fireDeleteForm(item);
            }
        });
        deleteBtn.setIcon(FontAwesome.TRASH_O);
        deleteBtn.setStyleName(UIConstants.THEME_RED_LINK);
        editButtons.addComponent(deleteBtn);
        editButtons.setComponentAlignment(deleteBtn, Alignment.MIDDLE_CENTER);
    }

    if ((buttonEnableFlags & ASSIGN_BTN_PRESENTED) == ASSIGN_BTN_PRESENTED) {
        assignBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ASSIGN), new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                final T item = previewForm.getBean();
                previewForm.fireAssignForm(item);
            }
        });
        assignBtn.setIcon(FontAwesome.SHARE_SQUARE_O);
        assignBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        editButtons.addComponent(assignBtn, 0);

    }

    if ((buttonEnableFlags & CLONE_BTN_PRESENTED) == CLONE_BTN_PRESENTED) {
        cloneBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLONE), new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                optionBtn.setPopupVisible(false);
                final T item = previewForm.getBean();
                previewForm.fireCloneForm(item);
            }
        });
        cloneBtn.setIcon(FontAwesome.ROAD);
        cloneBtn.setStyleName("link");
        popupButtonsControl.addComponent(cloneBtn);
    }

    if (popupButtonsControl.getComponentCount() > 0) {
        optionBtn.setContent(popupButtonsControl);
        editButtons.addComponent(optionBtn);
        editButtons.setComponentAlignment(optionBtn, Alignment.MIDDLE_CENTER);
    }

    layout.addComponent(editButtons);
    layout.setComponentAlignment(editButtons, Alignment.MIDDLE_CENTER);
    layout.setExpandRatio(editButtons, 1.0f);

    if ((buttonEnableFlags & NAVIGATOR_BTN_PRESENTED) == NAVIGATOR_BTN_PRESENTED) {
        ButtonGroup navigationBtns = new ButtonGroup();
        navigationBtns.setStyleName("navigation-btns");
        Button previousItem = new Button("<", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                final T item = previewForm.getBean();
                previewForm.fireGotoPrevious(item);
            }
        });

        previousItem.setStyleName(UIConstants.THEME_GREEN_LINK);
        previousItem.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_PREVIOUS_ITEM));
        navigationBtns.addButton(previousItem);

        Button nextItemBtn = new Button(">", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                final T item = previewForm.getBean();
                previewForm.fireGotoNextItem(item);
            }
        });

        nextItemBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        nextItemBtn.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_NEXT_ITEM));

        navigationBtns.addButton(nextItemBtn);
        layout.addComponent(navigationBtns);
        layout.setComponentAlignment(navigationBtns, Alignment.MIDDLE_RIGHT);
    }

    if (permissionItem != null) {
        final boolean canWrite = CurrentProjectVariables.canWrite(permissionItem);
        final boolean canAccess = CurrentProjectVariables.canAccess(permissionItem);

        if (assignBtn != null) {
            assignBtn.setEnabled(canWrite);
        }

        if (addBtn != null) {
            addBtn.setEnabled(canWrite);
        }

        if (editBtn != null) {
            editBtn.setEnabled(canWrite);
        }

        if (cloneBtn != null) {
            cloneBtn.setEnabled(canWrite);
        }

        if (deleteBtn != null) {
            deleteBtn.setEnabled(canAccess);
        }
    }
    return layout;
}

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

License:Open Source License

public BuildCriterionComponent(GenericSearchPanel.SearchLayout<S> searchLayout, Param[] paramFields,
        Class<S> type, String searchCategory) {
    this.hostSearchLayout = searchLayout;
    this.paramFields = paramFields;
    this.type = type;
    this.searchCategory = searchCategory;

    MHorizontalLayout headerBox = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, true));
    headerBox.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    addComponent(headerBox);//  w ww  . java2 s  .  co m

    Label filterLbl = new Label(AppContext.getMessage(GenericI18Enum.OPT_SAVED_FILTER));
    headerBox.with(filterLbl).withAlign(filterLbl, Alignment.TOP_LEFT);

    filterBox = new MHorizontalLayout();
    headerBox.with(filterBox).withAlign(filterBox, Alignment.TOP_LEFT);

    buildFilterBox(null);

    searchContainer = new MVerticalLayout().withMargin(false);
    searchContainer.setDefaultComponentAlignment(Alignment.TOP_LEFT);

    MHorizontalLayout controlsBtn = new MHorizontalLayout().withMargin(true);

    Button addCriteriaBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ADD_CRITERIA),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    CriteriaSelectionLayout newCriteriaBar = new CriteriaSelectionLayout(
                            searchContainer.getComponentCount() + 1);
                    searchContainer.addComponent(newCriteriaBar);
                }
            });
    addCriteriaBtn.setStyleName(UIConstants.BUTTON_ACTION);
    addCriteriaBtn.setIcon(FontAwesome.PLUS);

    controlsBtn.with(addCriteriaBtn);

    this.with(searchContainer, controlsBtn);
}