Example usage for com.vaadin.ui Button Button

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

Introduction

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

Prototype

public Button() 

Source Link

Document

Creates a new push button.

Usage

From source file:com.esofthead.mycollab.mobile.module.project.view.milestone.MilestoneReadViewImpl.java

License:Open Source License

@Override
protected ComponentContainer createBottomPanel() {
    HorizontalLayout toolbarLayout = new HorizontalLayout();
    toolbarLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    toolbarLayout.setSpacing(true);//ww w.j a va  2 s.c om

    Button relatedBugs = new Button();
    relatedBugs.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.PROJECT_BUG
            + "\"></span><div class=\"screen-reader-text\">"
            + AppContext.getMessage(ProjectCommonI18nEnum.VIEW_BUG) + "</div>");
    relatedBugs.setHtmlContentAllowed(true);
    relatedBugs.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 2113811477874305745L;

        @Override
        public void buttonClick(ClickEvent arg0) {
            EventBusFactory.getInstance().post(new ShellEvent.PushView(this, getRelatedBugs()));
        }
    });
    toolbarLayout.addComponent(relatedBugs);

    Button relatedTasks = new Button();
    relatedTasks.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.PROJECT_TASK
            + "\"></span><div class=\"screen-reader-text\">"
            + AppContext.getMessage(ProjectCommonI18nEnum.VIEW_TASK) + "</div>");
    relatedTasks.setHtmlContentAllowed(true);
    relatedTasks.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -9171495386840452500L;

        @Override
        public void buttonClick(ClickEvent arg0) {
            EventBusFactory.getInstance().post(new ShellEvent.PushView(this, getRelatedTasks()));
        }
    });
    toolbarLayout.addComponent(relatedTasks);

    relatedComments = new Button();
    relatedComments.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.PROJECT_MESSAGE
            + "\"></span><div class=\"screen-reader-text\">"
            + AppContext.getMessage(ProjectCommonI18nEnum.TAB_COMMENT) + "</div>");
    relatedComments.setHtmlContentAllowed(true);
    relatedComments.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 2206489649468573076L;

        @Override
        public void buttonClick(ClickEvent arg0) {
            EventBusFactory.getInstance().post(new ShellEvent.PushView(this, associateComments));
        }
    });
    toolbarLayout.addComponent(relatedComments);

    return toolbarLayout;
}

From source file:com.esofthead.mycollab.mobile.module.project.view.settings.ProjectMemberListViewImpl.java

License:Open Source License

@Override
protected Component createRightComponent() {
    Button inviteMemberBtn = new Button();
    inviteMemberBtn.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 3817727548038589396L;

        @Override//  w  w  w  . j av  a  2 s  .c  om
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoInviteMembers(this, null));
        }
    });
    inviteMemberBtn.setStyleName("add-btn");
    return inviteMemberBtn;
}

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

License:Open Source License

@Override
protected ComponentContainer createBottomPanel() {
    HorizontalLayout toolbarLayout = new HorizontalLayout();
    toolbarLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    toolbarLayout.setSpacing(true);/* w w w  .  j av a2 s .c  o m*/

    relatedComments = new Button();
    relatedComments.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.PROJECT_MESSAGE
            + "\"></span><div class=\"screen-reader-text\">"
            + AppContext.getMessage(ProjectCommonI18nEnum.TAB_COMMENT) + "</div>");
    relatedComments.setHtmlContentAllowed(true);
    relatedComments.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 2276465280812964681L;

        @Override
        public void buttonClick(ClickEvent arg0) {
            EventBusFactory.getInstance().post(new ShellEvent.PushView(this, associateComments));
        }
    });
    toolbarLayout.addComponent(relatedComments);

    return toolbarLayout;
}

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

License:Open Source License

@Override
protected ComponentContainer createBottomPanel() {
    HorizontalLayout toolbarLayout = new HorizontalLayout();
    toolbarLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    toolbarLayout.setSpacing(true);//from w w w. ja  va 2  s .  c  o m

    relatedComments = new Button();
    relatedComments.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.PROJECT_MESSAGE
            + "\"></span><div class=\"screen-reader-text\">"
            + AppContext.getMessage(ProjectCommonI18nEnum.TAB_COMMENT) + "</div>");
    relatedComments.setHtmlContentAllowed(true);
    relatedComments.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = 4889821151518627676L;

        @Override
        public void buttonClick(ClickEvent arg0) {
            EventBusFactory.getInstance().post(new ShellEvent.PushView(this, associateComments));
        }
    });
    toolbarLayout.addComponent(relatedComments);

    return toolbarLayout;
}

From source file:com.esofthead.mycollab.mobile.module.user.ui.UserPanel.java

License:Open Source License

public UserPanel() {
    super();// w  ww  .j av  a2s .  c o m
    setStyleName("user-info-panel");
    setSpacing(true);
    setMargin(true);
    setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    setHeightUndefined();

    userAvatar = new Image();
    userAvatar.setWidth("24px");
    userAvatar.setHeight("24px");

    userName = new Button();
    userName.setWidth("100%");
    userName.setStyleName("user-btn");

    setUserInfo();

    addComponent(userAvatar);
    addComponent(userName);
    setExpandRatio(userName, 1.0f);

    // add listener to listen the change avatar or user information to
    // update panel display info
    EventBusFactory.getInstance().register(new ApplicationEventListener<SessionEvent.UserProfileChangeEvent>() {
        private static final long serialVersionUID = 1L;

        @Subscribe
        @Override
        public void handle(UserProfileChangeEvent event) {
            setUserInfo();
        }
    });

}

From source file:com.esofthead.mycollab.module.crm.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");

    UserBlock memberBlock = new UserBlock(comment.getCreateduser(), comment.getOwnerAvatarId(),
            comment.getOwnerFullName());
    layout.addComponent(memberBlock);/*w  w  w  .  ja v  a2 s. c om*/

    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(Button.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.crm.ui.components.CrmActivityComponent.java

License:Open Source License

private Component buildCommentBlock(final SimpleComment comment) {
    final MHorizontalLayout layout = new MHorizontalLayout()
            .withMargin(new MarginInfo(true, false, true, false)).withFullWidth().withStyleName("message");

    ProjectMemberBlock memberBlock = new ProjectMemberBlock(comment.getCreateduser(),
            comment.getOwnerAvatarId(), comment.getOwnerFullName());
    layout.addComponent(memberBlock);/*  ww w.  j  av a 2s .  c  o  m*/

    MVerticalLayout rowLayout = new MVerticalLayout().withFullWidth().withStyleName("message-container");

    MHorizontalLayout messageHeader = new MHorizontalLayout().withFullWidth();
    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.setStyleName(UIConstants.META_INFO);

    if (hasDeletePermission(comment)) {
        Button msgDeleteBtn = new Button();
        msgDeleteBtn.setIcon(FontAwesome.TRASH_O);
        msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY);
        msgDeleteBtn.setVisible(true);
        msgDeleteBtn.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(Button.ClickEvent event) {
                ConfirmDialogExt.show(UI.getCurrent(),
                        AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.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 = AppContextUtil
                                            .getSpringBean(CommentService.class);
                                    commentService.removeWithSession(comment, AppContext.getUsername(),
                                            AppContext.getAccountId());
                                    activityBox.removeComponent(layout);
                                }
                            }
                        });
            }
        });
        messageHeader.with(timePostLbl, msgDeleteBtn).expand(timePostLbl);
    } else {
        messageHeader.with(timePostLbl).expand(timePostLbl);
    }

    rowLayout.addComponent(messageHeader);

    Label messageContent = new SafeHtmlLabel(comment.getComment());
    rowLayout.addComponent(messageContent);

    List<Content> attachments = comment.getAttachments();
    if (!CollectionUtils.isEmpty(attachments)) {
        MVerticalLayout messageFooter = new MVerticalLayout().withMargin(false).withSpacing(false)
                .withFullWidth();
        AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments);
        attachmentDisplay.setWidth("100%");
        messageFooter.with(attachmentDisplay);
        rowLayout.addComponent(messageFooter);
    }

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

From source file:com.esofthead.mycollab.module.crm.view.account.AccountCaseListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    HorizontalLayout controlsBtnWrap = new HorizontalLayout();
    controlsBtnWrap.setWidth("100%");

    HorizontalLayout notesWrap = new HorizontalLayout();
    notesWrap.setWidth("100%");
    notesWrap.setSpacing(true);/* w w  w.ja  v  a 2  s  . co  m*/
    Label noteLbl = new Label("Note: ");
    noteLbl.setSizeUndefined();
    noteLbl.setStyleName("list-note-lbl");
    notesWrap.addComponent(noteLbl);

    CssLayout noteBlock = new CssLayout();
    noteBlock.setWidth("100%");
    noteBlock.setStyleName("list-note-block");
    for (int i = 0; i < CrmDataTypeFactory.getCasesStatusList().length; i++) {
        Label note = new Label(CrmDataTypeFactory.getCasesStatusList()[i]);
        note.setStyleName("note-label");
        note.addStyleName(colorsMap.get(CrmDataTypeFactory.getCasesStatusList()[i]));
        note.setSizeUndefined();

        noteBlock.addComponent(note);
    }
    notesWrap.addComponent(noteBlock);
    notesWrap.setExpandRatio(noteBlock, 1.0f);

    controlsBtnWrap.addComponent(notesWrap);

    controlsBtnWrap.setWidth("100%");
    final Button createBtn = new Button();
    createBtn.setSizeUndefined();
    createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CASE));
    createBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    createBtn.setCaption(AppContext.getMessage(CaseI18nEnum.BUTTON_NEW_CASE));
    createBtn.setIcon(FontAwesome.PLUS);
    createBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = -8725970955325733072L;

        @Override
        public void buttonClick(final Button.ClickEvent event) {
            fireNewRelatedItem("");
        }
    });

    controlsBtnWrap.addComponent(createBtn);
    controlsBtnWrap.setComponentAlignment(createBtn, Alignment.MIDDLE_RIGHT);
    return controlsBtnWrap;
}

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

License:Open Source License

private void displayMyCollabFolder(final Folder folder) {
    String folderPath = folder.getPath();
    if (!folderPath.startsWith(rootFolderPath)) {
        throw new MyCollabException("Invalid path " + rootFolderPath + "---" + folderPath);
    }//from   ww w  .ja  v a  2  s.c o  m

    String remainPath = folderPath.substring(rootFolderPath.length());
    if (remainPath.startsWith("/")) {
        remainPath = remainPath.substring(1);
    }

    StringBuffer curPath = new StringBuffer("");
    String[] path = remainPath.split("/");
    for (int i = 0; i < path.length; i++) {
        String pathName = path[i];
        curPath.append(pathName);

        final Button btn = new Button();
        btn.setCaption(StringUtils.trim(pathName, 25, true));
        btn.setDescription(pathName);
        final String currentResourcePath = curPath.toString();
        btn.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                FileSearchCriteria criteria = new FileSearchCriteria();
                criteria.setBaseFolder(rootFolderPath + "/" + currentResourcePath);
                criteria.setRootFolder(rootFolderPath);
                notifySearchHandler(criteria);
            }
        });

        this.select(i + 1);
        this.addLink(btn);
        this.setLinkEnabled(true, i + 1);

        if (i < path.length - 1) {
            curPath.append("/");
        }
    }
}

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

License:Open Source License

private void displayExternalFolder(final ExternalFolder folder) {
    String folderPath = folder.getPath();

    final StringBuffer curPath = new StringBuffer("");
    String[] path = folderPath.split("/");
    if (path.length == 0) {
        final Button btn = new Button();
        btn.setCaption(StringUtils.trim(folder.getExternalDrive().getFoldername(), 25, true));
        this.addLink(btn);
        this.select(2);
        return;//from w ww  . ja  v a2s.co m
    }

    for (int i = 0; i < path.length; i++) {
        String pathName = path[i];

        if (i == 0) {
            pathName = folder.getExternalDrive().getFoldername();
            curPath.append("/");
        } else {
            curPath.append(pathName);
        }

        final Button btn = new Button();
        btn.setCaption(StringUtils.trim(pathName, 25, true));
        btn.setDescription(pathName);

        final String currentFolderPath = curPath.toString();

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

            @Override
            public void buttonClick(ClickEvent event) {
                FileSearchCriteria criteria = new FileSearchCriteria();
                criteria.setBaseFolder(currentFolderPath);

                criteria.setRootFolder("/");
                criteria.setStorageName(StorageNames.DROPBOX);
                criteria.setExternalDrive(folder.getExternalDrive());
                notifySearchHandler(criteria);
            }
        });

        this.select(i + 1);
        this.addLink(btn);
        this.setLinkEnabled(true, i + 1);

        if (i < path.length - 1) {
            curPath.append("/");
        }
    }
}