Example usage for com.vaadin.ui Button setIcon

List of usage examples for com.vaadin.ui Button setIcon

Introduction

In this page you can find the example usage for com.vaadin.ui Button setIcon.

Prototype

@Override
public void setIcon(Resource icon) 

Source Link

Document

Sets the component's icon.

Usage

From source file:com.esofthead.mycollab.module.crm.view.opportunity.OpportunitySearchPanel.java

License:Open Source License

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

    final Label searchtitle = new CrmViewHeader(CrmTypeConstants.OPPORTUNITY,
            AppContext.getMessage(OpportunityI18nEnum.VIEW_LIST_TITLE));
    searchtitle.setStyleName(UIConstants.HEADER_TEXT);
    layout.with(searchtitle).expand(searchtitle).withAlign(searchtitle, Alignment.MIDDLE_LEFT);

    final Button createAccountBtn = new Button(
            AppContext.getMessage(OpportunityI18nEnum.BUTTON_NEW_OPPORTUNITY), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override//from  w  w  w.j  a  v  a2 s  .co m
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance()
                            .post(new OpportunityEvent.GotoAdd(OpportunitySearchPanel.this, null));
                }
            });
    createAccountBtn.setIcon(FontAwesome.PLUS);
    createAccountBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createAccountBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_OPPORTUNITY));
    layout.with(createAccountBtn).withAlign(createAccountBtn, Alignment.MIDDLE_RIGHT);

    return layout;
}

From source file:com.esofthead.mycollab.module.crm.view.opportunity.OpportunitySimpleSearchPanel.java

License:Open Source License

private void createBasicSearchLayout() {
    layoutSearchPane = new GridLayout(3, 3);
    layoutSearchPane.setSpacing(true);/*from w ww . j a v  a2s  .c  om*/

    final ValueComboBox group = new ValueComboBox(false, "Name", "Account Name", "Sales Stage",
            AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE));
    group.select("Name");
    group.setImmediate(true);
    group.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            removeComponents();
            String searchType = (String) group.getValue();
            if (searchType.equals("Name")) {
                addTextFieldSearch();
            } else if (searchType.equals("Account Name")) {
                addTextFieldSearch();
            } else if (searchType.equals("Sales Stage")) {
                addTextFieldSearch();
            } else if (searchType.equals(AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE))) {
                addUserListSelectField();
            }
        }
    });

    layoutSearchPane.addComponent(group, 1, 0);
    layoutSearchPane.setComponentAlignment(group, Alignment.MIDDLE_CENTER);
    addTextFieldSearch();

    Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH));
    searchBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    searchBtn.setIcon(FontAwesome.SEARCH);
    searchBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            searchCriteria = new OpportunitySearchCriteria();
            searchCriteria.setSaccountid(new NumberSearchField(SearchField.AND, AppContext.getAccountId()));

            String searchType = (String) group.getValue();
            if (StringUtils.isNotBlank(searchType)) {

                if (textValueField != null) {
                    String strSearch = textValueField.getValue();
                    if (StringUtils.isNotBlank(strSearch)) {

                        if (searchType.equals("Name")) {
                            searchCriteria
                                    .setOpportunityName(new StringSearchField(SearchField.AND, strSearch));
                        }
                    }
                }

                if (userBox != null) {
                    String user = (String) userBox.getValue();
                    if (StringUtils.isNotBlank(user)) {
                        searchCriteria.setAssignUsers(
                                new SetSearchField<String>(SearchField.AND, new String[] { user }));
                    }
                }
            }

            OpportunitySimpleSearchPanel.this.notifySearchHandler(searchCriteria);
        }
    });
    layoutSearchPane.addComponent(searchBtn, 2, 0);
    layoutSearchPane.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER);
    this.setCompositionRoot(layoutSearchPane);
}

From source file:com.esofthead.mycollab.module.file.view.components.ResourcesDisplayComponent.java

License:Open Source License

public ResourcesDisplayComponent(final String rootPath, final Folder rootFolder) {
    this.setSpacing(true);
    this.baseFolder = rootFolder;
    this.rootPath = rootPath;
    externalResourceService = ApplicationContextUtil.getSpringBean(ExternalResourceService.class);
    externalDriveService = ApplicationContextUtil.getSpringBean(ExternalDriveService.class);
    resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);

    VerticalLayout mainBodyLayout = new VerticalLayout();
    mainBodyLayout.setSpacing(true);/*from  w w w  .  j a v  a2s. c o m*/
    mainBodyLayout.addStyleName("box-no-border-left");

    // file breadcrum ---------------------
    HorizontalLayout breadcrumbContainer = new HorizontalLayout();
    breadcrumbContainer.setMargin(false);
    fileBreadCrumb = new FileBreadcrumb(rootPath);
    breadcrumbContainer.addComponent(fileBreadCrumb);
    mainBodyLayout.addComponent(breadcrumbContainer);

    // Construct controllGroupBtn
    controllGroupBtn = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true));

    final Button selectAllBtn = new Button();
    selectAllBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    selectAllBtn.setIcon(FontAwesome.SQUARE_O);
    selectAllBtn.setData(false);
    selectAllBtn.setImmediate(true);
    selectAllBtn.setDescription("Select all");

    selectAllBtn.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (!(Boolean) selectAllBtn.getData()) {
                selectAllBtn.setIcon(FontAwesome.CHECK_SQUARE_O);
                selectAllBtn.setData(true);
                resourcesContainer.setAllValues(true);
            } else {
                selectAllBtn.setData(false);
                selectAllBtn.setIcon(FontAwesome.SQUARE_O);
                resourcesContainer.setAllValues(false);
            }
        }
    });
    controllGroupBtn.with(selectAllBtn).withAlign(selectAllBtn, Alignment.MIDDLE_LEFT);

    Button goUpBtn = new Button("Up");
    goUpBtn.setIcon(FontAwesome.ARROW_UP);

    goUpBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            Folder parentFolder;
            if (baseFolder instanceof ExternalFolder) {
                if (baseFolder.getPath().equals("/")) {
                    parentFolder = baseFolder;
                } else {
                    parentFolder = externalResourceService.getParentResourceFolder(
                            ((ExternalFolder) baseFolder).getExternalDrive(), baseFolder.getPath());
                }
            } else if (!baseFolder.getPath().equals(rootPath)) {
                parentFolder = resourceService.getParentFolder(baseFolder.getPath());
            } else {
                parentFolder = baseFolder;
            }

            resourcesContainer.constructBody(parentFolder);
            baseFolder = parentFolder;
            fileBreadCrumb.gotoFolder(baseFolder);
        }
    });
    goUpBtn.setDescription("Back to parent folder");
    goUpBtn.setStyleName(UIConstants.THEME_BROWN_LINK);
    goUpBtn.setDescription("Go up");

    controllGroupBtn.with(goUpBtn).withAlign(goUpBtn, Alignment.MIDDLE_LEFT);

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

                @Override
                public void buttonClick(ClickEvent event) {
                    AddNewFolderWindow addnewFolderWindow = new AddNewFolderWindow();
                    UI.getCurrent().addWindow(addnewFolderWindow);
                }
            });
    createBtn.setIcon(FontAwesome.PLUS);
    createBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    createBtn.setDescription("Create new folder");
    createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(createBtn);

    Button uploadBtn = new Button("Upload", new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            MultiUploadContentWindow multiUploadWindow = new MultiUploadContentWindow();
            UI.getCurrent().addWindow(multiUploadWindow);
        }
    });
    uploadBtn.setIcon(FontAwesome.UPLOAD);
    uploadBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    uploadBtn.setDescription("Upload");

    uploadBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(uploadBtn);

    Button downloadBtn = new Button("Download");

    LazyStreamSource streamSource = new LazyStreamSource() {
        private static final long serialVersionUID = 1L;

        @Override
        protected StreamSource buildStreamSource() {
            Collection<Resource> selectedResources = getSelectedResources();
            return StreamDownloadResourceUtil.getStreamSourceSupportExtDrive(selectedResources);
        }

        @Override
        public String getFilename() {
            Collection<Resource> selectedResources = getSelectedResources();
            return StreamDownloadResourceUtil.getDownloadFileName(selectedResources);
        }
    };
    OnDemandFileDownloader downloaderExt = new OnDemandFileDownloader(streamSource);
    downloaderExt.extend(downloadBtn);

    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    downloadBtn.setDescription("Download");
    downloadBtn.setEnabled(AppContext.canRead(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(downloadBtn);

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

        @Override
        public void buttonClick(ClickEvent event) {
            Collection<Resource> selectedResources = getSelectedResources();
            if (CollectionUtils.isNotEmpty(selectedResources)) {
                MoveResourceWindow moveResourceWindow = new MoveResourceWindow(selectedResources);
                UI.getCurrent().addWindow(moveResourceWindow);
            } else {
                NotificationUtil.showWarningNotification("Please select at least one item to move");
            }
        }
    });
    moveToBtn.setIcon(FontAwesome.ARROWS);
    moveToBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    moveToBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    moveToBtn.setDescription("Move to");
    navButton.addButton(moveToBtn);

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

                @Override
                public void buttonClick(ClickEvent event) {
                    Collection<Resource> selectedResources = getSelectedResources();
                    if (CollectionUtils.isEmpty(selectedResources)) {
                        NotificationUtil.showWarningNotification("Please select at least one item to delete");
                    } else {
                        deleteResourceAction();
                    }
                }
            });
    deleteBtn.setIcon(FontAwesome.TRASH_O);
    deleteBtn.addStyleName(UIConstants.THEME_RED_LINK);
    deleteBtn.setDescription("Delete resource");
    deleteBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));

    navButton.addButton(deleteBtn);
    controllGroupBtn.addComponent(navButton);

    mainBodyLayout.addComponent(controllGroupBtn);

    resourcesContainer = new ResourcesContainer(baseFolder);

    mainBodyLayout.addComponent(resourcesContainer);
    this.addComponent(mainBodyLayout);
}

From source file:com.esofthead.mycollab.module.project.ui.components.CommentRowDisplayHandler.java

License:Open Source License

@Override
public Component generateRow(final SimpleComment comment, int rowIndex) {
    final MHorizontalLayout layout = new MHorizontalLayout()
            .withMargin(new MarginInfo(true, false, true, false)).withWidth("100%").withStyleName("message");

    ProjectMemberBlock memberBlock = new ProjectMemberBlock(comment.getCreateduser(),
            comment.getOwnerAvatarId(), comment.getOwnerFullName());
    layout.addComponent(memberBlock);/*from ww  w  . j a  va 2 s  .com*/

    CssLayout rowLayout = new CssLayout();
    rowLayout.setStyleName("message-container");
    rowLayout.setWidth("100%");

    MHorizontalLayout messageHeader = new MHorizontalLayout()
            .withMargin(new MarginInfo(true, true, false, true)).withWidth("100%")
            .withStyleName("message-header");
    messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    ELabel timePostLbl = new ELabel(AppContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT,
            comment.getOwnerFullName(), AppContext.formatPrettyTime(comment.getCreatedtime())),
            ContentMode.HTML).withDescription(AppContext.formatDateTime(comment.getCreatedtime()));

    timePostLbl.setSizeUndefined();
    timePostLbl.setStyleName("time-post");
    messageHeader.with(timePostLbl).expand(timePostLbl);

    // Message delete button
    Button msgDeleteBtn = new Button();
    msgDeleteBtn.setIcon(FontAwesome.TRASH_O);
    msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY);
    messageHeader.addComponent(msgDeleteBtn);

    if (hasDeletePermission(comment)) {
        msgDeleteBtn.setVisible(true);
        msgDeleteBtn.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                ConfirmDialogExt.show(UI.getCurrent(),
                        AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                                SiteConfiguration.getSiteName()),
                        AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                        AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                        AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                            private static final long serialVersionUID = 1L;

                            @Override
                            public void onClose(ConfirmDialog dialog) {
                                if (dialog.isConfirmed()) {
                                    CommentService commentService = ApplicationContextUtil
                                            .getSpringBean(CommentService.class);
                                    commentService.removeWithSession(comment.getId(), AppContext.getUsername(),
                                            AppContext.getAccountId());
                                    CommentRowDisplayHandler.this.owner.removeRow(layout);
                                }
                            }
                        });
            }
        });
    } else {
        msgDeleteBtn.setVisible(false);
    }

    rowLayout.addComponent(messageHeader);

    Label messageContent = new SafeHtmlLabel(comment.getComment());
    messageContent.setStyleName("message-body");
    rowLayout.addComponent(messageContent);

    List<Content> attachments = comment.getAttachments();
    if (!CollectionUtils.isEmpty(attachments)) {
        MVerticalLayout messageFooter = new MVerticalLayout().withSpacing(false).withWidth("100%")
                .withStyleName("message-footer");
        AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments);
        attachmentDisplay.setWidth("100%");
        messageFooter.with(attachmentDisplay).withAlign(attachmentDisplay, Alignment.MIDDLE_RIGHT);
        rowLayout.addComponent(messageFooter);
    }

    layout.with(rowLayout).expand(rowLayout);
    return layout;
}

From source file:com.esofthead.mycollab.module.project.ui.components.ProjectCommentInput.java

License:Open Source License

ProjectCommentInput(final ReloadableComponent component, final CommentType typeVal,
        final Integer extraTypeIdVal, final boolean cancelButtonEnable, final boolean isSendingEmailRelay,
        final Class<? extends SendingRelayEmailNotificationAction> emailHandler) {
    super();/*from ww w.j  a  v  a  2  s . com*/
    this.withWidth("100%").withStyleName("message");

    final SimpleUser currentUser = AppContext.getSession();
    MVerticalLayout userBlock = new MVerticalLayout().withMargin(false).withWidth("80px");
    userBlock.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    ClickListener gotoUser = new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            EventBusFactory.getInstance()
                    .post(new ProjectMemberEvent.GotoRead(this, currentUser.getUsername()));
        }
    };

    Button userAvatarBtn = UserAvatarControlFactory.createUserAvatarButtonLink(currentUser.getAvatarid(),
            currentUser.getDisplayName());
    userAvatarBtn.addClickListener(gotoUser);
    userBlock.addComponent(userAvatarBtn);
    Button userName = new Button(currentUser.getDisplayName());
    userName.setStyleName("user-name");
    userName.addStyleName("link");
    userName.addStyleName(UIConstants.WORD_WRAP);
    userName.addClickListener(gotoUser);
    userBlock.addComponent(userName);

    this.addComponent(userBlock);
    MVerticalLayout textAreaWrap = new MVerticalLayout().withWidth("100%").withStyleName("message-container");
    this.addComponent(textAreaWrap);
    this.setExpandRatio(textAreaWrap, 1.0f);

    type = typeVal;
    extraTypeId = extraTypeIdVal;

    commentArea = new RichTextArea();
    commentArea.setWidth("100%");
    commentArea.setHeight("200px");

    final AttachmentPanel attachments = new AttachmentPanel();

    final MHorizontalLayout controlsLayout = new MHorizontalLayout().withSpacing(true).withMargin(false)
            .withWidth("100%");

    final MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments);
    uploadExt.addComponent(attachments);
    controlsLayout.with(uploadExt).withAlign(uploadExt, Alignment.TOP_LEFT).expand(uploadExt);

    final Label emptySpace = new Label();
    controlsLayout.addComponent(emptySpace);
    controlsLayout.setExpandRatio(emptySpace, 1.0f);

    if (cancelButtonEnable) {
        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) {
                        component.cancel();
                    }
                });
        cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
        controlsLayout.addComponent(cancelBtn);
        controlsLayout.setComponentAlignment(cancelBtn, Alignment.TOP_RIGHT);
    }

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

                @Override
                public void buttonClick(final Button.ClickEvent event) {
                    final Comment comment = new Comment();
                    comment.setComment(Jsoup.clean(commentArea.getValue(), Whitelist.relaxed()));
                    comment.setCreatedtime(new GregorianCalendar().getTime());
                    comment.setCreateduser(AppContext.getUsername());
                    comment.setSaccountid(AppContext.getAccountId());
                    comment.setType(type.toString());
                    comment.setTypeid("" + typeId);
                    comment.setExtratypeid(extraTypeId);

                    final CommentService commentService = ApplicationContextUtil
                            .getSpringBean(CommentService.class);
                    int commentId = commentService.saveWithSession(comment, AppContext.getUsername(),
                            isSendingEmailRelay, emailHandler);

                    String attachmentPath = AttachmentUtils.getProjectEntityCommentAttachmentPath(typeVal,
                            AppContext.getAccountId(), CurrentProjectVariables.getProjectId(), typeId,
                            commentId);

                    if (!"".equals(attachmentPath)) {
                        attachments.saveContentsToRepo(attachmentPath);
                    }

                    // save success, clear comment area and load list
                    // comments again
                    commentArea.setValue("");
                    attachments.removeAllAttachmentsDisplay();
                    component.reload();
                }
            });
    newCommentBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    newCommentBtn.setIcon(FontAwesome.SEND);
    controlsLayout.with(newCommentBtn).withAlign(newCommentBtn, Alignment.TOP_RIGHT);

    textAreaWrap.addComponent(commentArea);
    textAreaWrap.addComponent(controlsLayout);
}

From source file:com.esofthead.mycollab.module.project.ui.components.TimeLogEditWindow.java

License:Open Source License

private void initUI() {
    this.setWidth("900px");

    headerPanel = new MHorizontalLayout().withWidth("100%");
    content.addComponent(headerPanel);//from ww  w  .  jav  a2 s .  co  m
    constructSpentTimeEntryPanel();
    constructRemainTimeEntryPanel();

    this.tableItem = new DefaultPagedBeanTable<>(
            ApplicationContextUtil.getSpringBean(ItemTimeLoggingService.class), SimpleItemTimeLogging.class,
            Arrays.asList(TimeTableFieldDef.logUser, TimeTableFieldDef.logForDate, TimeTableFieldDef.logValue,
                    TimeTableFieldDef.billable,
                    new TableViewField(null, "id", UIConstants.TABLE_CONTROL_WIDTH)));

    this.tableItem.addGeneratedColumn("logUserFullName", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(final Table source, final Object itemId,
                final Object columnId) {
            final SimpleItemTimeLogging timeLoggingItem = TimeLogEditWindow.this.tableItem
                    .getBeanByIndex(itemId);

            return new ProjectUserLink(timeLoggingItem.getLoguser(), timeLoggingItem.getLogUserAvatarId(),
                    timeLoggingItem.getLogUserFullName());

        }
    });

    this.tableItem.addGeneratedColumn("logforday", new ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(final Table source, final Object itemId,
                final Object columnId) {
            final SimpleItemTimeLogging monitorItem = TimeLogEditWindow.this.tableItem.getBeanByIndex(itemId);
            final Label l = new Label();
            l.setValue(AppContext.formatDate(monitorItem.getLogforday()));
            return l;
        }
    });

    this.tableItem.addGeneratedColumn("logvalue", new ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(final Table source, final Object itemId,
                final Object columnId) {
            final SimpleItemTimeLogging itemTimeLogging = TimeLogEditWindow.this.tableItem
                    .getBeanByIndex(itemId);
            final Label l = new Label();
            l.setValue(itemTimeLogging.getLogvalue() + "");
            return l;
        }
    });

    this.tableItem.addGeneratedColumn("isbillable", new ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleItemTimeLogging monitorItem = tableItem.getBeanByIndex(itemId);
            FontIconLabel icon;
            if (monitorItem.getIsbillable()) {
                icon = new FontIconLabel(FontAwesome.CHECK);
            } else {
                icon = new FontIconLabel(FontAwesome.TIMES);
            }
            icon.setStyleName(UIConstants.BUTTON_ICON_ONLY);
            return icon;
        }
    });

    this.tableItem.addGeneratedColumn("id", new ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(final Table source, final Object itemId,
                final Object columnId) {
            final SimpleItemTimeLogging itemTimeLogging = TimeLogEditWindow.this.tableItem
                    .getBeanByIndex(itemId);
            final Button deleteBtn = new Button(null, new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    TimeLogEditWindow.this.itemTimeLoggingService.removeWithSession(itemTimeLogging.getId(),
                            AppContext.getUsername(), AppContext.getAccountId());
                    TimeLogEditWindow.this.loadTimeValue();
                }
            });
            deleteBtn.setIcon(FontAwesome.TRASH_O);
            deleteBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);
            itemTimeLogging.setExtraData(deleteBtn);

            deleteBtn.setEnabled(CurrentProjectVariables.isAdmin()
                    || AppContext.getUsername().equals(itemTimeLogging.getLoguser()));
            return deleteBtn;
        }
    });

    this.tableItem.setWidth("100%");
    content.addComponent(tableItem);
}

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

License:Open Source License

private void initHeader() {
    final Label title = new ProjectViewHeader(ProjectTypeConstants.BUG,
            AppContext.getMessage(BugI18nEnum.VIEW_BUG_DASHBOARD_TITLE));
    header.with(title).withAlign(title, Alignment.MIDDLE_LEFT).expand(title);

    final Button createBugBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_NEW_BUG),
            new Button.ClickListener() {
                @Override//  w  ww .  j a  va  2  s  .  c om
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new BugEvent.GotoAdd(this, null));
                }
            });
    createBugBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS));
    createBugBtn.setIcon(FontAwesome.PLUS);
    final SplitButton controlsBtn = new SplitButton(createBugBtn);
    controlsBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    controlsBtn.setWidthUndefined();

    final VerticalLayout btnControlsLayout = new VerticalLayout();
    final Button createComponentBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_NEW_COMPONENT),
            new Button.ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    controlsBtn.setPopupVisible(false);
                    EventBusFactory.getInstance().post(new BugComponentEvent.GotoAdd(this, null));
                }
            });
    createComponentBtn.setStyleName("link");
    createComponentBtn
            .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.COMPONENTS));
    btnControlsLayout.addComponent(createComponentBtn);

    final Button createVersionBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_NEW_VERSION),
            new Button.ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    controlsBtn.setPopupVisible(false);
                    EventBusFactory.getInstance().post(new BugVersionEvent.GotoAdd(this, null));
                }
            });
    createVersionBtn.setStyleName("link");
    createVersionBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.VERSIONS));
    btnControlsLayout.addComponent(createVersionBtn);

    controlsBtn.setContent(btnControlsLayout);
    header.addComponent(controlsBtn);
}

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

License:Open Source License

public BugKanbanViewImpl() {
    this.setSizeFull();
    this.withSpacing(true).withMargin(new MarginInfo(false, true, true, true));

    searchPanel = new BugSearchPanel();
    MHorizontalLayout groupWrapLayout = new MHorizontalLayout();
    groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    searchPanel.addHeaderRight(groupWrapLayout);

    Button advanceDisplayBtn = new Button("List", new Button.ClickListener() {
        @Override/*from   w ww.j  a  v  a  2  s .c o m*/
        public void buttonClick(Button.ClickEvent clickEvent) {
            EventBusFactory.getInstance().post(new BugEvent.GotoList(BugKanbanViewImpl.this, null));
        }
    });
    advanceDisplayBtn.setWidth("100px");
    advanceDisplayBtn.setIcon(FontAwesome.SITEMAP);
    advanceDisplayBtn.setDescription("Detail");

    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.withDefaultButton(kanbanBtn);
    groupWrapLayout.addComponent(viewButtons);

    kanbanLayout = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false))
            .withFullHeight();
    kanbanLayout.addStyleName("kanban-layout");
    this.with(searchPanel, kanbanLayout).expand(kanbanLayout);
}

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

License:Open Source License

private ComponentContainer constructTableActionControls() {
    final MHorizontalLayout layout = new MHorizontalLayout().withWidth("100%");

    final Label lbEmpty = new Label("");
    layout.with(lbEmpty).expand(lbEmpty);

    MHorizontalLayout buttonControls = new MHorizontalLayout();
    layout.addComponent(buttonControls);

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

        @Override//from   w w  w  .j av  a2s.  c om
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().addWindow(new BugListCustomizeWindow(BugListView.VIEW_DEF_ID, tableItem));

        }
    });
    customizeViewBtn.setIcon(FontAwesome.COG);
    customizeViewBtn.setDescription("Layout Options");
    customizeViewBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
    buttonControls.addComponent(customizeViewBtn);

    PopupButton exportButtonControl = new PopupButton();
    exportButtonControl.addStyleName(UIConstants.THEME_GRAY_LINK);
    exportButtonControl.setIcon(FontAwesome.EXTERNAL_LINK);
    exportButtonControl.setDescription(AppContext.getMessage(FileI18nEnum.EXPORT_FILE));

    VerticalLayout popupButtonsControl = new VerticalLayout();
    exportButtonControl.setContent(popupButtonsControl);

    Button exportPdfBtn = new Button(AppContext.getMessage(FileI18nEnum.PDF));

    StreamWrapperFileDownloader fileDownloader = new StreamWrapperFileDownloader(new StreamResourceFactory() {

        @Override
        public StreamResource getStreamResource() {
            String title = "Bugs of Project " + ((CurrentProjectVariables.getProject() != null
                    && CurrentProjectVariables.getProject().getName() != null)
                            ? CurrentProjectVariables.getProject().getName()
                            : "");
            BugSearchCriteria searchCriteria = new BugSearchCriteria();
            searchCriteria.setProjectId(
                    new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProject().getId()));

            return new StreamResource(new SimpleGridExportItemsStreamResource.AllItems<>(title,
                    new RpParameterBuilder(tableItem.getDisplayColumns()), ReportExportType.PDF,
                    ApplicationContextUtil.getSpringBean(BugService.class), searchCriteria, SimpleBug.class),
                    "export.pdf");
        }

    });
    fileDownloader.extend(exportPdfBtn);
    exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O);
    exportPdfBtn.setStyleName("link");
    popupButtonsControl.addComponent(exportPdfBtn);

    Button exportExcelBtn = new Button(AppContext.getMessage(FileI18nEnum.EXCEL));
    StreamWrapperFileDownloader excelDownloader = new StreamWrapperFileDownloader(new StreamResourceFactory() {

        @Override
        public StreamResource getStreamResource() {
            String title = "Bugs of Project " + ((CurrentProjectVariables.getProject() != null
                    && CurrentProjectVariables.getProject().getName() != null)
                            ? CurrentProjectVariables.getProject().getName()
                            : "");
            BugSearchCriteria searchCriteria = new BugSearchCriteria();
            searchCriteria.setProjectId(
                    new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProject().getId()));

            return new StreamResource(new SimpleGridExportItemsStreamResource.AllItems<>(title,
                    new RpParameterBuilder(tableItem.getDisplayColumns()), ReportExportType.EXCEL,
                    ApplicationContextUtil.getSpringBean(BugService.class), searchCriteria, SimpleBug.class),
                    "export.xlsx");
        }
    });
    excelDownloader.extend(exportExcelBtn);
    exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O);
    exportExcelBtn.setStyleName("link");
    popupButtonsControl.addComponent(exportExcelBtn);

    Button exportCsvBtn = new Button(AppContext.getMessage(FileI18nEnum.CSV));

    StreamWrapperFileDownloader csvFileDownloader = new StreamWrapperFileDownloader(
            new StreamResourceFactory() {

                @Override
                public StreamResource getStreamResource() {
                    String title = "Bugs of Project " + ((CurrentProjectVariables.getProject() != null
                            && CurrentProjectVariables.getProject().getName() != null)
                                    ? CurrentProjectVariables.getProject().getName()
                                    : "");
                    BugSearchCriteria searchCriteria = new BugSearchCriteria();
                    searchCriteria.setProjectId(new NumberSearchField(SearchField.AND,
                            CurrentProjectVariables.getProject().getId()));

                    return new StreamResource(new SimpleGridExportItemsStreamResource.AllItems<>(title,
                            new RpParameterBuilder(tableItem.getDisplayColumns()), ReportExportType.CSV,
                            ApplicationContextUtil.getSpringBean(BugService.class), searchCriteria,
                            SimpleBug.class), "export.csv");
                }
            });
    csvFileDownloader.extend(exportCsvBtn);

    exportCsvBtn.setIcon(FontAwesome.FILE_TEXT_O);
    exportCsvBtn.setStyleName("link");
    popupButtonsControl.addComponent(exportCsvBtn);

    buttonControls.addComponent(exportButtonControl);
    return layout;
}

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

License:Open Source License

@Override
protected ComponentContainer createButtonControls() {
    ProjectPreviewFormControlsGenerator<SimpleBug> bugPreviewFormControls = new ProjectPreviewFormControlsGenerator<>(
            previewForm);//from w ww  .  j  av a  2  s.c  o  m
    MButton linkBtn = new MButton("Link", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            UI.getCurrent().addWindow(new LinkIssueWindow(beanItem));
        }
    }).withIcon(FontAwesome.LINK);
    linkBtn.addStyleName("black");
    bugPreviewFormControls.addOptionButton(linkBtn);

    final HorizontalLayout topPanel = bugPreviewFormControls.createButtonControls(
            ProjectPreviewFormControlsGenerator.ADD_BTN_PRESENTED
                    | ProjectPreviewFormControlsGenerator.DELETE_BTN_PRESENTED
                    | ProjectPreviewFormControlsGenerator.EDIT_BTN_PRESENTED
                    | ProjectPreviewFormControlsGenerator.CLONE_BTN_PRESENTED,
            ProjectRolePermissionCollections.BUGS);

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

                @Override
                public void buttonClick(final ClickEvent event) {
                    UI.getCurrent().addWindow(new AssignBugWindow(BugReadViewImpl.this, beanItem));
                }
            });
    assignBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS));
    assignBtn.setIcon(FontAwesome.SHARE);

    assignBtn.setStyleName(UIConstants.THEME_GREEN_LINK);

    this.bugWorkflowControl = new HorizontalLayout();
    this.bugWorkflowControl.setMargin(false);
    this.bugWorkflowControl.addStyleName("workflow-controls");

    bugPreviewFormControls.insertToControlBlock(bugWorkflowControl);
    bugPreviewFormControls.insertToControlBlock(assignBtn);
    topPanel.setSizeUndefined();

    return topPanel;
}