Example usage for com.vaadin.ui Button addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:com.mycollab.module.crm.view.activity.ActivitySearchPanel.java

License:Open Source License

@Override
protected Component buildExtraControls() {
    final SplitButton splitBtn = new SplitButton();
    splitBtn.setSizeUndefined();//  w  w w  . j  a v  a 2  s  . c  o m
    splitBtn.setEnabled(UserUIContext.canWrite(RolePermissionCollections.CRM_CALL)
            || UserUIContext.canWrite(RolePermissionCollections.CRM_MEETING));
    splitBtn.addStyleName(WebThemes.BUTTON_ACTION);
    splitBtn.setIcon(FontAwesome.PLUS);
    splitBtn.setCaption(UserUIContext.getMessage(TaskI18nEnum.NEW));
    splitBtn.addClickListener(
            event -> EventBusFactory.getInstance().post(new ActivityEvent.TaskAdd(this, null)));

    OptionPopupContent btnControlsLayout = new OptionPopupContent();
    splitBtn.setContent(btnControlsLayout);

    Button createMeetingBtn = new Button(UserUIContext.getMessage(MeetingI18nEnum.NEW), clickEvent -> {
        splitBtn.setPopupVisible(false);
        EventBusFactory.getInstance().post(new ActivityEvent.MeetingAdd(this, null));
    });
    btnControlsLayout.addOption(createMeetingBtn);
    createMeetingBtn.setEnabled(UserUIContext.canWrite(RolePermissionCollections.CRM_MEETING));
    final Button createCallBtn = new Button(UserUIContext.getMessage(CallI18nEnum.NEW), clickEvent -> {
        splitBtn.setPopupVisible(false);
        EventBusFactory.getInstance().post(new ActivityEvent.CallAdd(this, null));
    });
    createCallBtn.setEnabled(UserUIContext.canWrite(RolePermissionCollections.CRM_CALL));
    btnControlsLayout.addOption(createCallBtn);

    ButtonGroup viewSwitcher = new ButtonGroup();

    Button calendarViewBtn = new Button("Calendar",
            clickEvent -> EventBusFactory.getInstance().post(new ActivityEvent.GotoCalendar(this, null)));
    calendarViewBtn.addStyleName(WebThemes.BUTTON_ACTION);
    viewSwitcher.addButton(calendarViewBtn);

    Button activityListBtn = new Button("Activities");
    activityListBtn.setStyleName("selected");
    activityListBtn.addStyleName(WebThemes.BUTTON_ACTION);
    viewSwitcher.addButton(activityListBtn);

    return new MHorizontalLayout(splitBtn, viewSwitcher);
}

From source file:com.mycollab.module.file.view.components.AbstractResourceMovingWindow.java

License:Open Source License

private void constructBody() {
    MVerticalLayout contentLayout = new MVerticalLayout();
    new Restrain(contentLayout).setMaxHeight("600px");
    this.setContent(contentLayout);

    folderTree = new Tree();
    folderTree.setMultiSelect(false);/*from ww w.  j av a2s  .c  om*/
    folderTree.setSelectable(true);
    folderTree.setImmediate(true);
    folderTree.setSizeFull();

    folderTree.addExpandListener(new Tree.ExpandListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void nodeExpand(final ExpandEvent event) {
            final Folder expandFolder = (Folder) event.getItemId();
            // load externalResource if currentExpandFolder is rootFolder
            if (baseFolder.getPath().equals(expandFolder.getPath())) {
                List<ExternalDrive> externalDrives = externalDriveService
                        .getExternalDrivesOfUser(AppContext.getUsername());
                for (ExternalDrive externalDrive : externalDrives) {
                    ExternalFolder externalMapFolder = new ExternalFolder("/");
                    externalMapFolder.setStorageName(externalDrive.getStoragename());
                    externalMapFolder.setExternalDrive(externalDrive);
                    externalMapFolder.setName(externalDrive.getFoldername());

                    Calendar cal = GregorianCalendar.getInstance();
                    cal.setTime(externalDrive.getCreatedtime());

                    externalMapFolder.setCreated(cal);
                    expandFolder.addChild(externalMapFolder);
                    folderTree.addItem(externalMapFolder);
                    folderTree.setItemIcon(externalMapFolder, FontAwesome.DROPBOX);
                    folderTree.setItemCaption(externalMapFolder, externalMapFolder.getName());
                    folderTree.setParent(externalMapFolder, expandFolder);
                }
            }
            if (expandFolder instanceof ExternalFolder) {
                List<ExternalFolder> subFolders = externalResourceService.getSubFolders(
                        ((ExternalFolder) expandFolder).getExternalDrive(), expandFolder.getPath());
                for (final Folder subFolder : subFolders) {
                    expandFolder.addChild(subFolder);
                    folderTree.addItem(subFolder);
                    folderTree.setItemIcon(subFolder, FontAwesome.DROPBOX);
                    folderTree.setItemCaption(subFolder, subFolder.getName());
                    folderTree.setParent(subFolder, expandFolder);
                }
            } else {
                final List<Folder> subFolders = resourceService.getSubFolders(expandFolder.getPath());
                folderTree.setItemIcon(expandFolder, FontAwesome.FOLDER_OPEN);

                if (subFolders != null) {
                    for (final Folder subFolder : subFolders) {
                        String subFolderName = subFolder.getName();
                        if (!subFolderName.startsWith(".")) {
                            expandFolder.addChild(subFolder);
                            folderTree.addItem(subFolder);
                            folderTree.setItemIcon(subFolder, FontAwesome.FOLDER);
                            folderTree.setItemCaption(subFolder, subFolderName);
                            folderTree.setParent(subFolder, expandFolder);
                        }
                    }
                }
            }
        }
    });

    folderTree.addCollapseListener(new Tree.CollapseListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void nodeCollapse(final CollapseEvent event) {
            final Folder collapseFolder = (Folder) event.getItemId();
            if (collapseFolder instanceof ExternalFolder) {
                folderTree.setItemIcon(collapseFolder, FontAwesome.DROPBOX);
            } else {
                folderTree.setItemIcon(collapseFolder, FontAwesome.FOLDER);
            }
            for (Folder folder : collapseFolder.getChilds()) {
                recursiveRemoveSubItem(folder);
            }
        }

        private void recursiveRemoveSubItem(Folder collapseFolder) {
            List<Folder> childFolders = collapseFolder.getChilds();
            if (childFolders.size() > 0) {
                for (Folder subFolder : childFolders) {
                    recursiveRemoveSubItem(subFolder);
                }
                folderTree.removeItem(collapseFolder);
            } else {
                folderTree.removeItem(collapseFolder);
            }
        }
    });

    folderTree.addItemClickListener(new ItemClickEvent.ItemClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void itemClick(final ItemClickEvent event) {
            baseFolder = (Folder) event.getItemId();
        }
    });

    CssLayout treeWrapper = new CssLayout(folderTree);
    treeWrapper.setSizeFull();
    contentLayout.addComponent(treeWrapper);
    displayFiles();

    MHorizontalLayout controlGroupBtnLayout = new MHorizontalLayout();

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

        @Override
        public void buttonClick(ClickEvent event) {
            if (!CollectionUtils.isEmpty(movedResources)) {
                boolean checkingFail = false;
                for (Resource res : movedResources) {
                    try {
                        resourceMover.moveResource(res, baseFolder, AppContext.getUsername(),
                                AppContext.getAccountId());
                    } catch (Exception e) {
                        checkingFail = true;
                        LOG.error("Error", e);
                    }
                }
                close();
                displayAfterMoveSuccess(baseFolder, checkingFail);
            }
        }

    });
    moveBtn.setIcon(FontAwesome.ARROWS);
    moveBtn.addStyleName(UIConstants.BUTTON_ACTION);

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

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    cancelBtn.addStyleName(UIConstants.BUTTON_OPTION);
    controlGroupBtnLayout.with(cancelBtn, moveBtn);

    contentLayout.with(controlGroupBtnLayout).withAlign(controlGroupBtnLayout, Alignment.MIDDLE_RIGHT);
}

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

License:Open Source License

void initBreadcrumb() {
    // home Btn ----------------
    this.addLink(new Button(null, new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override//from w  w  w .ja v a  2  s .co m
        public void buttonClick(ClickEvent event) {
            FileSearchCriteria criteria = new FileSearchCriteria();
            criteria.setBaseFolder(rootFolderPath);
            criteria.setRootFolder(rootFolderPath);
            notifySearchHandler(criteria);
        }
    }));

    this.select(0);
    Button documentBtnLink = generateBreadcrumbLink(AppContext.getMessage(FileI18nEnum.OPT_MY_DOCUMENTS),
            new ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    FileSearchCriteria criteria = new FileSearchCriteria();
                    criteria.setBaseFolder(rootFolderPath);
                    criteria.setRootFolder(rootFolderPath);
                    notifySearchHandler(criteria);
                }
            });
    documentBtnLink.addStyleName(UIConstants.BUTTON_LINK);
    this.addLink(documentBtnLink);
    this.setLinkEnabled(true, 1);
}

From source file:com.mycollab.module.file.view.components.FileDownloadWindow.java

License:Open Source License

private void constructBody() {
    final MVerticalLayout layout = new MVerticalLayout().withFullWidth();
    CssLayout iconWrapper = new CssLayout();
    final ELabel iconEmbed = ELabel.fontIcon(FileAssetsUtil.getFileIconResource(content.getName()));
    iconEmbed.addStyleName("icon-48px");
    iconWrapper.addComponent(iconEmbed);
    layout.with(iconWrapper).withAlign(iconWrapper, Alignment.MIDDLE_CENTER);

    final GridFormLayoutHelper inforLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 4);

    if (content.getDescription() != null) {
        final Label descLbl = new Label();
        if (!content.getDescription().equals("")) {
            descLbl.setData(content.getDescription());
        } else {//  ww w  .  j ava2 s  .co m
            descLbl.setValue("&nbsp;");
            descLbl.setContentMode(ContentMode.HTML);
        }
        inforLayout.addComponent(descLbl, "Description", 0, 0);
    }

    UserService userService = AppContextUtil.getSpringBean(UserService.class);
    SimpleUser user = userService.findUserByUserNameInAccount(content.getCreatedUser(),
            AppContext.getAccountId());
    if (user == null) {
        inforLayout.addComponent(new UserLink(AppContext.getUsername(), AppContext.getUserAvatarId(),
                AppContext.getUserDisplayName()), "Created by", 0, 1);
    } else {
        inforLayout.addComponent(new UserLink(user.getUsername(), user.getAvatarid(), user.getDisplayName()),
                "Created by", 0, 1);
    }

    final Label size = new Label(FileUtils.getVolumeDisplay(content.getSize()));
    inforLayout.addComponent(size, "Size", 0, 2);

    ELabel dateCreate = new ELabel().prettyDateTime(content.getCreated().getTime());
    inforLayout.addComponent(dateCreate, "Created date", 0, 3);

    layout.addComponent(inforLayout.getLayout());

    final MHorizontalLayout buttonControls = new MHorizontalLayout()
            .withMargin(new MarginInfo(true, false, true, false));

    final Button downloadBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD));
    List<Resource> resources = new ArrayList<>();
    resources.add(content);

    StreamResource downloadResource = StreamDownloadResourceUtil.getStreamResourceSupportExtDrive(resources);

    FileDownloader fileDownloader = new FileDownloader(downloadResource);
    fileDownloader.extend(downloadBtn);
    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.addStyleName(UIConstants.BUTTON_ACTION);

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

                @Override
                public void buttonClick(ClickEvent event) {
                    close();
                }
            });
    cancelBtn.addStyleName(UIConstants.BUTTON_OPTION);
    buttonControls.with(cancelBtn, downloadBtn).alignAll(Alignment.TOP_RIGHT);
    layout.with(buttonControls).withAlign(buttonControls, Alignment.TOP_RIGHT);
    this.setContent(layout);
}

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

License:Open Source License

void initBreadcrumb() {
    // home Btn ----------------
    this.addLink(new Button(null, clickEvent -> {
        FileSearchCriteria criteria = new FileSearchCriteria();
        criteria.setBaseFolder(rootFolderPath);
        criteria.setRootFolder(rootFolderPath);
        notifySearchHandler(criteria);/* ww w  . j  ava 2  s  .c  o m*/
    }));

    this.select(0);
    Button documentBtnLink = generateBreadcrumbLink(UserUIContext.getMessage(FileI18nEnum.OPT_MY_DOCUMENTS),
            clickEvent -> {
                FileSearchCriteria criteria = new FileSearchCriteria();
                criteria.setBaseFolder(rootFolderPath);
                criteria.setRootFolder(rootFolderPath);
                notifySearchHandler(criteria);
            });
    documentBtnLink.addStyleName(WebThemes.BUTTON_LINK);
    this.addLink(documentBtnLink);
    this.setLinkEnabled(true, 1);
}

From source file:com.mycollab.module.project.view.milestone.ToggleGenericTaskSummaryField.java

License:Open Source License

ToggleGenericTaskSummaryField(final ProjectGenericTask genericTask) {
    this.genericTask = genericTask;
    this.setWidth("100%");
    titleLinkLbl = ELabel.html(buildGenericTaskLink())
            .withStyleName(ValoTheme.LABEL_NO_MARGIN, UIConstants.LABEL_WORD_WRAP).withWidthUndefined();
    this.addComponent(titleLinkLbl);
    if ((genericTask.isTask() && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS))
            || (genericTask.isBug() && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS))
            || (genericTask.isRisk()/*from w  ww. jav  a 2s  .  c o m*/
                    && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.RISKS))) {
        this.addStyleName("editable-field");
        buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false);
        Button instantEditBtn = new Button(null, new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent clickEvent) {
                if (isRead) {
                    removeComponent(titleLinkLbl);
                    removeComponent(buttonControls);
                    final TextField editField = new TextField();
                    editField.setValue(genericTask.getName());
                    editField.setWidth("100%");
                    editField.focus();
                    addComponent(editField);
                    removeStyleName("editable-field");
                    editField.addValueChangeListener(new Property.ValueChangeListener() {
                        @Override
                        public void valueChange(Property.ValueChangeEvent event) {
                            updateFieldValue(editField);
                        }
                    });
                    editField.addBlurListener(new FieldEvents.BlurListener() {
                        @Override
                        public void blur(FieldEvents.BlurEvent event) {
                            updateFieldValue(editField);
                        }
                    });
                    isRead = !isRead;
                }
            }
        });
        instantEditBtn.setDescription("Edit task name");
        instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
        instantEditBtn.setIcon(FontAwesome.EDIT);
        buttonControls.with(instantEditBtn);

        this.addComponent(buttonControls);
    }
}

From source file:com.mycollab.module.project.view.ProjectBreadcrumb.java

License:Open Source License

private void addLink(Button button) {
    button.addStyleName(WebThemes.BUTTON_LINK);
    with(new ELabel("/"), button);
}

From source file:com.mycollab.module.project.view.ProjectBreadcrumb.java

License:Open Source License

private void addEnabledLink(Button button) {
    button.addStyleName(WebThemes.BUTTON_LINK);
    with(new ELabel("/"), button);
}

From source file:com.mycollab.module.project.view.settings.component.InviteUserTokenField.java

License:Open Source License

private Component generateToken(final String email) {
    final Button btn = new Button(email, FontAwesome.TIMES);
    btn.addClickListener(clickEvent -> {
        InviteUserTokenField.this.removeComponent(btn);
        inviteEmails.remove(email);/*from w w  w.j a  va2  s  .c om*/
    });
    btn.addStyleName("token-field");
    return btn;
}

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

License:Open Source License

private void queryAndDisplayTasks() {
    wrapBody.removeAllComponents();// w  ww.  ja v a 2s  . co m

    if (GROUP_DUE_DATE.equals(groupByState)) {
        baseCriteria.setOrderFields(
                Collections.singletonList(new SearchCriteria.OrderField("deadline", sortDirection)));
        taskGroupOrderComponent = new DueDateOrderComponent();
    } else if (GROUP_START_DATE.equals(groupByState)) {
        baseCriteria.setOrderFields(
                Collections.singletonList(new SearchCriteria.OrderField("startdate", sortDirection)));
        taskGroupOrderComponent = new StartDateOrderComponent();
    } else if (PLAIN_LIST.equals(groupByState)) {
        baseCriteria.setOrderFields(
                Collections.singletonList(new SearchCriteria.OrderField("lastupdatedtime", sortDirection)));
        taskGroupOrderComponent = new SimpleListOrderComponent();
    } else if (GROUP_CREATED_DATE.equals(groupByState)) {
        baseCriteria.setOrderFields(
                Collections.singletonList(new SearchCriteria.OrderField("createdtime", sortDirection)));
        taskGroupOrderComponent = new CreatedDateOrderComponent();
    } else if (GROUP_USER.equals(groupByState)) {
        baseCriteria.setOrderFields(
                Collections.singletonList(new SearchCriteria.OrderField("createdtime", sortDirection)));
        taskGroupOrderComponent = new UserOrderComponent();
    } else {
        throw new MyCollabException("Do not support group view by " + groupByState);
    }
    wrapBody.addComponent(taskGroupOrderComponent);
    final ProjectTaskService projectTaskService = AppContextUtil.getSpringBean(ProjectTaskService.class);
    int totalTasks = projectTaskService.getTotalCount(baseCriteria);
    taskSearchPanel.setTotalCountNumber(totalTasks);
    currentPage = 0;
    int pages = totalTasks / 20;
    if (currentPage < pages) {
        Button moreBtn = new Button(AppContext.getMessage(GenericI18Enum.ACTION_MORE), clickEvent -> {
            int newTotalTasks = projectTaskService.getTotalCount(baseCriteria);
            int newNumPages = newTotalTasks / 20;
            currentPage++;
            List<SimpleTask> otherTasks = projectTaskService
                    .findPagableListByCriteria(new BasicSearchRequest<>(baseCriteria, currentPage + 1, 20));
            taskGroupOrderComponent.insertTasks(otherTasks);
            if (currentPage >= newNumPages) {
                wrapBody.removeComponent(wrapBody.getComponent(1));
            }
        });
        moreBtn.addStyleName(UIConstants.BUTTON_ACTION);
        wrapBody.addComponent(moreBtn);
    }
    List<SimpleTask> tasks = projectTaskService
            .findPagableListByCriteria(new BasicSearchRequest<>(baseCriteria, currentPage + 1, 20));
    taskGroupOrderComponent.insertTasks(tasks);
}