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.esofthead.mycollab.module.crm.view.opportunity.OpportunityListNoItemView.java

License:Open Source License

public OpportunityListNoItemView() {

    VerticalLayout layout = new VerticalLayout();
    layout.addStyleName("case-noitem");
    layout.setWidth("800px");
    layout.setSpacing(true);//from  www. j  av a  2  s  .c om
    layout.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    layout.setMargin(true);

    Image image = new Image(null, MyCollabResource.newResource("icons/48/crm/opportunity.png"));
    layout.addComponent(image);

    Label title = new Label(AppContext.getMessage(OpportunityI18nEnum.VIEW_NO_ITEM_TITLE));
    title.addStyleName("h2");
    title.setWidthUndefined();
    layout.addComponent(title);

    Label body = new Label(AppContext.getMessage(OpportunityI18nEnum.VIEW_NO_ITEM_HINT));
    body.setWidthUndefined();
    layout.addComponent(body);

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

                @Override
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new OpportunityEvent.GotoAdd(this, null));
                }
            });

    HorizontalLayout links = new HorizontalLayout();

    links.addComponent(btCreateContact);
    btCreateContact.addStyleName(UIConstants.THEME_GREEN_LINK);

    /*
     * Label or = new Label("Or"); or.setStyleName("h2");
     * links.addComponent(or);
     * 
     * Button btImportContact = new Button("Import Leads", new
     * Button.ClickListener() { private static final long serialVersionUID =
     * 1L;
     * 
     * @Override public void buttonClick(ClickEvent arg0) {
     * UI.getCurrent().addWindow(new CaseImportWindow()); } });
     * 
     * btImportContact.addStyleName(UIConstants.THEME_GRAY_LINK);
     * 
     * 
     * links.addComponent(btImportContact);
     */
    links.setSpacing(true);

    layout.addComponent(links);
    this.addComponent(layout);
    this.setComponentAlignment(layout, Alignment.TOP_CENTER);
}

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

License:Open Source License

private void constructBody() {
    MVerticalLayout contentLayout = new MVerticalLayout().withSpacing(true).withMargin(true);
    this.setContent(contentLayout);

    final HorizontalLayout resourceContainer = new HorizontalLayout();
    resourceContainer.setSizeFull();/*  w  ww  .j av  a  2 s .c  o  m*/

    this.folderTree = new TreeTable();
    this.folderTree.setMultiSelect(false);
    this.folderTree.setSelectable(true);
    this.folderTree.setImmediate(true);
    this.folderTree.addContainerProperty("Name", String.class, "");
    this.folderTree.addContainerProperty("Date Modified", String.class, "");
    this.folderTree.setColumnWidth("Date Modified", UIConstants.TABLE_DATE_TIME_WIDTH);
    this.folderTree.setColumnExpandRatio("Name", 1.0f);
    this.folderTree.setWidth("100%");

    resourceContainer.addComponent(this.folderTree);

    this.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 (rootPath.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);

                    AbstractResourceMovingWindow.this.folderTree
                            .addItem(
                                    new Object[] { externalMapFolder.getName(),
                                            AppContext
                                                    .formatDateTime(externalMapFolder.getCreated().getTime()) },
                                    externalMapFolder);

                    AbstractResourceMovingWindow.this.folderTree.setItemIcon(externalMapFolder,
                            MyCollabResource.newResource("icons/16/ecm/dropbox.png"));
                    AbstractResourceMovingWindow.this.folderTree.setItemCaption(externalMapFolder,
                            externalMapFolder.getName());
                    AbstractResourceMovingWindow.this.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);
                    Date dateTime = ((ExternalFolder) subFolder).getExternalDrive().getCreatedtime();

                    AbstractResourceMovingWindow.this.folderTree.addItem(
                            new Object[] { subFolder.getName(), AppContext.formatDateTime(dateTime) },
                            subFolder);

                    AbstractResourceMovingWindow.this.folderTree.setItemIcon(subFolder,
                            MyCollabResource.newResource("icons/16/ecm/dropbox_subfolder.png"));
                    AbstractResourceMovingWindow.this.folderTree.setItemCaption(subFolder, subFolder.getName());
                    AbstractResourceMovingWindow.this.folderTree.setParent(subFolder, expandFolder);
                }
            } else {
                final List<Folder> subFolders = AbstractResourceMovingWindow.this.resourceService
                        .getSubFolders(expandFolder.getPath());

                AbstractResourceMovingWindow.this.folderTree.setItemIcon(expandFolder,
                        MyCollabResource.newResource("icons/16/ecm/folder_open.png"));

                if (subFolders != null) {
                    for (final Folder subFolder : subFolders) {
                        expandFolder.addChild(subFolder);
                        AbstractResourceMovingWindow.this.folderTree.addItem(
                                new Object[] { subFolder.getName(),
                                        AppContext.formatDateTime(subFolder.getCreated().getTime()) },
                                subFolder);

                        AbstractResourceMovingWindow.this.folderTree.setItemIcon(subFolder,
                                MyCollabResource.newResource("icons/16/ecm/folder_close.png"));
                        AbstractResourceMovingWindow.this.folderTree.setItemCaption(subFolder,
                                subFolder.getName());
                        AbstractResourceMovingWindow.this.folderTree.setParent(subFolder, expandFolder);
                    }
                }
            }
        }
    });

    this.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) {
                if (collapseFolder.getPath().equals("/"))
                    AbstractResourceMovingWindow.this.folderTree.setItemIcon(collapseFolder,
                            MyCollabResource.newResource("icons/16/ecm/dropbox.png"));
                else
                    AbstractResourceMovingWindow.this.folderTree.setItemIcon(collapseFolder,
                            MyCollabResource.newResource("icons/16/ecm/dropbox_subfolder.png"));
            } else {
                AbstractResourceMovingWindow.this.folderTree.setItemIcon(collapseFolder,
                        MyCollabResource.newResource("icons/16/ecm/folder_close.png"));
            }
            for (Folder folder : collapseFolder.getChilds()) {
                recursiveRemoveSubItem(folder);
            }
        }

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

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

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

    contentLayout.addComponent(resourceContainer);
    displayFiles();

    HorizontalLayout controlGroupBtnLayout = new HorizontalLayout();
    controlGroupBtnLayout.setSpacing(true);

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

        @Override
        public void buttonClick(ClickEvent event) {
            if (resourceEditting != null) {
                try {
                    resourceMover.moveResource(resourceEditting, baseFolder, AppContext.getUsername(),
                            AppContext.getAccountId());

                    displayAfterMoveSuccess(AbstractResourceMovingWindow.this.baseFolder, false);
                } finally {
                    AbstractResourceMovingWindow.this.close();
                }
            } else if (!CollectionUtils.isEmpty(lstResEditting)) {
                boolean checkingFail = false;
                for (Resource res : lstResEditting) {
                    try {
                        resourceMover.moveResource(res, baseFolder, AppContext.getUsername(),
                                AppContext.getAccountId());
                    } catch (Exception e) {
                        checkingFail = true;
                    }
                }
                AbstractResourceMovingWindow.this.close();
                displayAfterMoveSuccess(AbstractResourceMovingWindow.this.baseFolder, checkingFail);
            }
        }

    });
    moveBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    controlGroupBtnLayout.addComponent(moveBtn);
    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            AbstractResourceMovingWindow.this.close();
        }
    });
    cancelBtn.addStyleName(UIConstants.THEME_GRAY_LINK);
    controlGroupBtnLayout.addComponent(cancelBtn);

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

From source file:com.esofthead.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.  j ava2  s  . c  o  m*/
        public void buttonClick(ClickEvent event) {
            FileSearchCriteria criteria = new FileSearchCriteria();
            criteria.setBaseFolder(rootFolderPath);
            criteria.setRootFolder(rootFolderPath);
            notifySearchHandler(criteria);
        }
    }));
    this.setHeight(25, Unit.PIXELS);

    this.select(0);
    Button documentBtnLink = generateBreadcrumbLink("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("link");
    this.addLink(documentBtnLink);
    this.setLinkEnabled(true, 1);
}

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

License:Open Source License

private void constructBody() {
    final MVerticalLayout layout = new MVerticalLayout();
    final Embedded iconEmbed = new Embedded();
    iconEmbed.setSource(MyCollabResource.newResource("icons/page_white.png"));
    layout.with(iconEmbed).withAlign(iconEmbed, Alignment.MIDDLE_CENTER);

    final GridFormLayoutHelper info = new GridFormLayoutHelper(1, 4, "100%", "80px", Alignment.TOP_LEFT);
    info.getLayout().setWidth("100%");
    info.getLayout().setMargin(new MarginInfo(false, true, false, true));
    info.getLayout().setSpacing(false);//w  ww .  j  a v a 2s  .co  m

    if (this.content.getDescription() != null) {
        final Label desvalue = new Label();
        if (!this.content.getDescription().equals("")) {
            desvalue.setData(this.content.getDescription());
        } else {
            desvalue.setValue("&nbsp;");
            desvalue.setContentMode(ContentMode.HTML);
        }
        info.addComponent(desvalue, "Description", 0, 0);
    }
    final Label author = new Label(this.content.getCreatedBy());
    info.addComponent(author, "Created by", 0, 1);

    final Label size = new Label(ResourceUtils.getVolumeDisplay(this.content.getSize()));
    info.addComponent(size, "Size", 0, 2);

    final Label dateCreate = new Label(AppContext.formatDate(this.content.getCreated().getTime()));
    info.addComponent(dateCreate, "Date created", 0, 3);

    layout.addComponent(info.getLayout());

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

    final Button downloadBtn = new Button("Download");
    List<Resource> resources = new ArrayList<Resource>();
    resources.add(content);

    StreamResource downloadResource = StreamDownloadResourceUtil.getStreamResourceSupportExtDrive(resources);

    FileDownloader fileDownloader = new FileDownloader(downloadResource);
    fileDownloader.extend(downloadBtn);

    downloadBtn.addStyleName(UIConstants.THEME_GREEN_LINK);

    buttonControls.with(downloadBtn).withAlign(downloadBtn, Alignment.MIDDLE_CENTER);

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

                @Override
                public void buttonClick(final ClickEvent event) {
                    FileDownloadWindow.this.close();
                }
            });
    cancelBtn.addStyleName(UIConstants.THEME_GRAY_LINK);
    buttonControls.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER);
    layout.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_CENTER);
    this.setContent(layout);
}

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);/* w  w w.j a va 2s.c om*/
    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.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   w  w w. j a  v  a  2 s . co m*/
    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.ProjectFollowersComp.java

License:Open Source License

public void displayFollowers(final V bean) {
    this.bean = bean;
    this.removeAllComponents();
    this.withSpacing(true).withMargin(new MarginInfo(false, false, false, true));

    MHorizontalLayout header = new MHorizontalLayout().withSpacing(true);
    Label followerHeader = new Label(
            FontAwesome.EYE.getHtml() + " " + AppContext.getMessage(FollowerI18nEnum.OPT_SUB_INFO_WATCHERS),
            ContentMode.HTML);/*  w w w  . j av  a2 s. c o m*/
    followerHeader.setStyleName("info-hdr");
    header.addComponent(followerHeader);

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

                    @Override
                    public void buttonClick(ClickEvent event) {
                        showEditWatchersWindow(bean);

                    }
                });
        editBtn.setStyleName("link");
        editBtn.addStyleName("info-hdr");
        header.addComponent(editBtn);
    }

    this.addComponent(header);
    Label sep = new Label("/");
    sep.setStyleName("info-hdr");
    header.addComponent(sep);

    currentUserFollow = isUserWatching(bean);

    final Button toogleWatching = new Button("");
    toogleWatching.setStyleName("link");
    toogleWatching.addStyleName("info-hdr");
    toogleWatching.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (currentUserFollow) {
                unfollowItem(AppContext.getUsername(), bean);
                currentUserFollow = false;
                toogleWatching.setCaption(AppContext.getMessage(FollowerI18nEnum.BUTTON_FOLLOW));
            } else {
                followItem(AppContext.getUsername(), bean);
                toogleWatching.setCaption(AppContext.getMessage(FollowerI18nEnum.BUTTON_UNFOLLOW));
                currentUserFollow = true;
            }

            updateTotalFollowers(bean);
        }
    });
    header.addComponent(toogleWatching);

    if (currentUserFollow) {
        toogleWatching.setCaption(AppContext.getMessage(FollowerI18nEnum.BUTTON_UNFOLLOW));
    } else {
        toogleWatching.setCaption(AppContext.getMessage(FollowerI18nEnum.BUTTON_FOLLOW));
    }

    MVerticalLayout layout = new MVerticalLayout().withWidth("100%").withSpacing(true)
            .withMargin(new MarginInfo(false, false, false, true));
    this.addComponent(layout);

    int totalFollowers = getTotalFollowers(bean);
    followersBtn = new Button(AppContext.getMessage(FollowerI18nEnum.OPT_NUM_FOLLOWERS, totalFollowers),
            new ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    if (hasReadPermission()) {
                        showEditWatchersWindow(bean);
                    }

                }
            });
    followersBtn.setStyleName("link");
    layout.addComponent(followersBtn);
}

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

License:Open Source License

public ProjectListNoItemView() {
    MVerticalLayout layout = new MVerticalLayout();
    layout.addStyleName("case-noitem");
    layout.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    Label image = new Label(viewIcon().getHtml(), ContentMode.HTML);
    image.setSizeUndefined();/*w ww  .  j a  v a 2 s .  co m*/
    layout.with(image).withAlign(image, Alignment.TOP_CENTER);

    Label title = new Label(viewTitle());
    title.addStyleName("h2");
    title.setSizeUndefined();
    layout.with(title).withAlign(title, Alignment.TOP_CENTER);

    Label body = new Label(viewHint());
    body.setWidthUndefined();
    layout.addComponent(body);

    Button createBugBtn = new Button(actionMessage(), actionListener());
    createBugBtn.setEnabled(hasPermission());

    MHorizontalLayout links = new MHorizontalLayout();

    links.addComponent(createBugBtn);
    createBugBtn.addStyleName(UIConstants.THEME_GREEN_LINK);

    layout.addComponent(links);
    this.addComponent(layout);
    this.setComponentAlignment(layout, Alignment.TOP_CENTER);
}

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

License:Open Source License

public void displayTime(final V bean) {
    this.removeAllComponents();
    this.withSpacing(true).withMargin(new MarginInfo(false, false, false, true));

    HorizontalLayout header = new MHorizontalLayout().withSpacing(true).withMargin(false);

    Label dateInfoHeader = new Label(
            FontAwesome.CLOCK_O.getHtml() + " " + AppContext.getMessage(TimeTrackingI18nEnum.SUB_INFO_TIME),
            ContentMode.HTML);//from  w ww  .  j a  va 2  s  . co m
    dateInfoHeader.setStyleName("info-hdr");
    header.addComponent(dateInfoHeader);

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

                    @Override
                    public void buttonClick(ClickEvent event) {
                        showEditTimeWindow(bean);

                    }
                });
        editBtn.setStyleName("link");
        editBtn.addStyleName("info-hdr");
        header.addComponent(editBtn);
    }

    this.addComponent(header);

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

    double billableHours = getTotalBillableHours(bean);
    double nonBillableHours = getTotalNonBillableHours(bean);
    double remainHours = getRemainedHours(bean);
    layout.addComponent(new Label(
            String.format(AppContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS), billableHours)));
    layout.addComponent(new Label(String
            .format(AppContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS), nonBillableHours)));
    layout.addComponent(new Label(
            String.format(AppContext.getMessage(TimeTrackingI18nEnum.OPT_REMAIN_HOURS), remainHours)));
    this.addComponent(layout);
}

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);// w w  w  .j a v a 2  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);
}