List of usage examples for com.vaadin.ui CssLayout addComponent
@Override public void addComponent(Component c)
From source file:com.m4gik.views.component.LicenseScreen.java
/** * Method builds license layout with texts. * //from w w w . ja v a 2 s . c om * @return The VerticalLayout with texts. * * @see com.m4gik.views.component.ViewScreen#build() */ @Override public Layout build() { VerticalLayout layout = new VerticalLayout(); layout.setSizeFull(); layout.setCaption("Welcome"); Panel welcome = new Panel("License"); welcome.setSizeFull(); welcome.addStyleName(Runo.PANEL_LIGHT); layout.addComponent(welcome); layout.setExpandRatio(welcome, 1); CssLayout margin = new CssLayout(); // margin.setMargin(true); margin.setWidth("100%"); welcome.setContent(margin); Label title = new Label("Music player"); title.addStyleName(Runo.LABEL_H1); // margin.addComponent(title); HorizontalLayout texts = new HorizontalLayout(); texts.setSpacing(true); texts.setWidth("100%"); margin.addComponent(texts); addText(texts, "<h3>Everything You Need Is Here</h3>" + "<p>Everything you see inside this application...</p>", null); addText(texts, "<h3>Everything You Need Is Here</h3>" + "<p>Everything you see inside this application...</p>", null); addText(texts, "<h3>Everything You Need Is Here</h3>" + "<p>Everything you see inside this application...</p>", null); layout.addComponent(new Label("<hr />", Label.CONTENT_XHTML)); return layout; }
From source file:com.mcparland.john.vaadin_mvn_arch.samples.authentication.LoginScreen.java
License:Apache License
private Component buildLoginForm() { FormLayout loginForm = new FormLayout(); loginForm.addStyleName("login-form"); loginForm.setSizeUndefined();/*from ww w.j av a 2 s . com*/ loginForm.setMargin(false); loginForm.addComponent(username = new TextField("Username", "admin")); username.setWidth(15, Unit.EM); loginForm.addComponent(password = new PasswordField("Password")); password.setWidth(15, Unit.EM); password.setDescription("Write anything"); CssLayout buttons = new CssLayout(); buttons.setStyleName("buttons"); loginForm.addComponent(buttons); buttons.addComponent(login = new Button("Login")); login.setDisableOnClick(true); login.addClickListener(new Button.ClickListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { try { login(); } finally { login.setEnabled(true); } } }); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addStyleName(ValoTheme.BUTTON_FRIENDLY); buttons.addComponent(forgotPassword = new Button("Forgot password?")); forgotPassword.addClickListener(new Button.ClickListener() { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { showNotification(new Notification("Hint: Try anything")); } }); forgotPassword.addStyleName(ValoTheme.BUTTON_LINK); return loginForm; }
From source file:com.mcparland.john.vaadin_mvn_arch.samples.authentication.LoginScreen.java
License:Apache License
private CssLayout buildLoginInformation() { CssLayout loginInformation = new CssLayout(); loginInformation.setStyleName("login-information"); Label loginInfoText = new Label("<h1>Login Information</h1>" + "Log in as "admin" to have full access. Log in with any other username to have read-only access. For all users, any password is fine", ContentMode.HTML);//from ww w . j a v a 2s .c o m loginInformation.addComponent(loginInfoText); return loginInformation; }
From source file:com.mycollab.mobile.module.project.view.message.MessageReadViewImpl.java
License:Open Source License
private void displayItem() { mainLayout.removeAllComponents();//from w w w. j a v a2s .com MHorizontalLayout messageBlock = new MHorizontalLayout().withSpacing(false).withFullWidth() .withStyleName("message-block"); Image userAvatarImg = UserAvatarControlFactory .createUserAvatarEmbeddedComponent(bean.getPostedUserAvatarId(), 32); userAvatarImg.addStyleName(UIConstants.CIRCLE_BOX); messageBlock.addComponent(userAvatarImg); CssLayout rightCol = new CssLayout(); rightCol.setWidth("100%"); MHorizontalLayout metadataRow = new MHorizontalLayout().withFullWidth(); ELabel userNameLbl = new ELabel(bean.getFullPostedUserName()).withStyleName(UIConstants.META_INFO); userNameLbl.addStyleName(UIConstants.TEXT_ELLIPSIS); CssLayout userNameWrap = new CssLayout(userNameLbl); ELabel messageTimePost = new ELabel().prettyDateTime(bean.getPosteddate()) .withStyleName(UIConstants.META_INFO).withWidthUndefined(); metadataRow.with(userNameWrap, messageTimePost).withAlign(messageTimePost, Alignment.TOP_RIGHT) .expand(userNameWrap); rightCol.addComponent(metadataRow); CssLayout titleRow = new CssLayout(); titleRow.setWidth("100%"); titleRow.setStyleName("title-row"); Label messageTitle = new Label(bean.getTitle()); messageTitle.setStyleName("message-title"); titleRow.addComponent(messageTitle); rightCol.addComponent(titleRow); Label messageContent = new Label(StringUtils.trimHtmlTags(bean.getMessage())); rightCol.addComponent(messageContent); ResourceService attachmentService = AppContextUtil.getSpringBean(ResourceService.class); List<Content> attachments = attachmentService.getContents(AttachmentUtils.getProjectEntityAttachmentPath( MyCollabUI.getAccountId(), bean.getProjectid(), ProjectTypeConstants.MESSAGE, "" + bean.getId())); if (CollectionUtils.isNotEmpty(attachments)) { CssLayout attachmentPanel = new CssLayout(); attachmentPanel.setStyleName("attachment-panel"); attachmentPanel.setWidth("100%"); for (Content attachment : attachments) { attachmentPanel.addComponent(MobileAttachmentUtils.renderAttachmentRow(attachment)); } rightCol.addComponent(attachmentPanel); } messageBlock.with(rightCol).expand(rightCol); mainLayout.addComponent(messageBlock); Label commentTitleLbl = new Label(); Component section = FormSectionBuilder.build(FontAwesome.COMMENT, commentTitleLbl); MessageCommentListDisplay commentDisplay = new MessageCommentListDisplay(ProjectTypeConstants.MESSAGE, bean.getId() + "", bean.getProjectid(), true); int numComments = commentDisplay.getNumComments(); commentTitleLbl.setValue(UserUIContext.getMessage(GenericI18Enum.OPT_COMMENTS_VALUE, numComments)); mainLayout.addComponent(section); mainLayout.addComponent(commentDisplay); this.setToolbar(commentDisplay.getCommentBox()); }
From source file:com.mycollab.mobile.module.user.view.LoginViewImpl.java
License:Open Source License
private void initUI() { MVerticalLayout contentLayout = new MVerticalLayout().withStyleName("content-wrapper").withFullWidth(); contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER); Image mainLogo = new Image(null, AccountAssetsResolver.createLogoResource(MyCollabUI.getBillingAccount().getLogopath(), 150)); contentLayout.addComponent(mainLogo); CssLayout welcomeTextWrapper = new CssLayout(); ELabel welcomeText = new ELabel( LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.BUTTON_LOG_IN)) .withStyleName("h1"); welcomeTextWrapper.addComponent(welcomeText); contentLayout.addComponent(welcomeText); final EmailField emailField = new EmailField(); new Dom(emailField).setAttribute("placeholder", LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), GenericI18Enum.FORM_EMAIL)); emailField.setWidth("100%"); contentLayout.addComponent(emailField); final PasswordField pwdField = new PasswordField(); pwdField.setWidth("100%"); new Dom(pwdField).setAttribute("placeholder", LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.FORM_PASSWORD)); contentLayout.addComponent(pwdField); final CheckBox rememberPassword = new CheckBox( LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.OPT_REMEMBER_PASSWORD), true);//from w ww. ja va 2 s.c om rememberPassword.setWidth("100%"); contentLayout.addComponent(rememberPassword); MButton signInBtn = new MButton( LocalizationHelper.getMessage(MyCollabUI.getDefaultLocale(), ShellI18nEnum.BUTTON_LOG_IN), clickEvent -> { try { LoginViewImpl.this.fireEvent(new ViewEvent<>(LoginViewImpl.this, new UserEvent.PlainLogin( emailField.getValue(), pwdField.getValue(), rememberPassword.getValue()))); } catch (Exception e) { throw new MyCollabException(e); } }).withStyleName(MobileUIConstants.BUTTON_ACTION); contentLayout.addComponent(signInBtn); this.addComponent(contentLayout); }
From source file:com.mycollab.mobile.ui.AbstractPreviewItemComp.java
License:Open Source License
public void previewItem(final B item) { this.beanItem = item; CssLayout content = new CssLayout(); content.addComponent(new MHorizontalLayout(ELabel.h2(initFormHeader())).withMargin(true) .withStyleName("border-bottom").withFullWidth()); content.addComponent(previewForm);// ww w .ja va2 s . c o m ComponentContainer buttonControls = createButtonControls(); if (buttonControls instanceof VerticalLayout) { NavigationBarQuickMenu editBtn = new NavigationBarQuickMenu(); editBtn.setContent(buttonControls); this.setRightComponent(editBtn); } else if (buttonControls instanceof HorizontalLayout) { if (StringUtils.isNotBlank(getType()) && !SiteConfiguration.isCommunityEdition()) { favoriteBtn = new MButton("", clickEvent -> toggleFavorite()).withIcon(FontAwesome.HEART) .withStyleName(UIConstants.CIRCLE_BOX); ((HorizontalLayout) buttonControls).addComponent(favoriteBtn, 0); } this.setRightComponent(buttonControls); } else { throw new MyCollabException("Not support controls " + buttonControls); } if (favoriteBtn != null) { if (isFavorite()) { favoriteBtn.addStyleName("favorite-btn-selected"); } else { favoriteBtn.addStyleName("favorite-btn"); } } initRelatedComponents(); ComponentContainer toolbarContent = createBottomPanel(); if (toolbarContent != null) { content.addComponent(toolbarContent); } this.setContent(content); previewForm.setFormLayoutFactory(initFormLayoutFactory()); previewForm.setBeanFormFieldFactory(initBeanFormFieldFactory()); }
From source file:com.mycollab.mobile.ui.AttachmentPreviewView.java
License:Open Source License
public AttachmentPreviewView() { CssLayout imgWrap = new CssLayout(); imgWrap.setStyleName("image-wrap"); imgWrap.setSizeFull();/*from w ww . jav a2 s.co m*/ this.setStyleName("attachment-preview-view"); this.setSizeFull(); this.addComponent(imgWrap, "top: 0px left: 0px; z-index: 0;"); backBtn = new NavigationButton(UserUIContext.getMessage(GenericI18Enum.M_BUTTON_BACK)); backBtn.setStyleName("back-btn"); this.addComponent(backBtn, "top: 15px; left: 15px; z-index: 1;"); previewImage = new Image(); imgWrap.addComponent(previewImage); }
From source file:com.mycollab.mobile.ui.MobileAttachmentUtils.java
License:Open Source License
public static Component renderAttachmentRow(final Content attachment) { String docName = attachment.getPath(); int lastIndex = docName.lastIndexOf("/"); MHorizontalLayout attachmentRow = new MHorizontalLayout().withSpacing(false).withFullWidth() .withStyleName("attachment-row"); attachmentRow.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); CssLayout thumbnailWrap = new CssLayout(); thumbnailWrap.setWidth("25px"); thumbnailWrap.setStyleName("thumbnail-wrap"); Component thumbnail;/*from w w w . j a v a 2s. c om*/ if (StringUtils.isNotBlank(attachment.getThumbnail())) { thumbnail = new Image(null, VaadinResourceFactory.getResource(attachment.getThumbnail())); } else { thumbnail = new ELabel(FileAssetsUtil.getFileIconResource(attachment.getName()).getHtml(), ContentMode.HTML); } thumbnail.setWidth("100%"); thumbnailWrap.addComponent(thumbnail); attachmentRow.addComponent(thumbnailWrap); if (lastIndex != -1) { docName = docName.substring(lastIndex + 1, docName.length()); } if (MimeTypesUtil.isImageType(docName)) { MButton b = new MButton(attachment.getTitle(), clickEvent -> { AttachmentPreviewView previewView = new AttachmentPreviewView( VaadinResourceFactory.getResource(attachment.getPath())); EventBusFactory.getInstance().post(new ShellEvent.PushView(attachment, previewView)); }).withStyleName(UIConstants.TEXT_ELLIPSIS); b.setWidth("100%"); attachmentRow.with(b).expand(b); } else { Label l = new Label(attachment.getTitle()); l.setWidth("100%"); attachmentRow.addComponent(l); attachmentRow.setExpandRatio(l, 1.0f); } return attachmentRow; }
From source file:com.mycollab.mobile.ui.MobileAttachmentUtils.java
License:Open Source License
public static Component renderAttachmentFieldRow(final Content attachment, Button.ClickListener additionalListener) { String docName = attachment.getPath(); int lastIndex = docName.lastIndexOf("/"); if (lastIndex != -1) { docName = docName.substring(lastIndex + 1, docName.length()); }/* ww w. ja v a 2 s .c om*/ final MHorizontalLayout attachmentLayout = new MHorizontalLayout().withStyleName("attachment-row") .withFullWidth(); attachmentLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); CssLayout thumbnailWrap = new CssLayout(); thumbnailWrap.setWidth("25px"); thumbnailWrap.setStyleName("thumbnail-wrap"); Component thumbnail; if (StringUtils.isNotBlank(attachment.getThumbnail())) { thumbnail = new Image(null, VaadinResourceFactory.getResource(attachment.getThumbnail())); } else { thumbnail = ELabel.fontIcon(FileAssetsUtil.getFileIconResource(attachment.getName())); } thumbnail.setWidth("100%"); thumbnailWrap.addComponent(thumbnail); attachmentLayout.addComponent(thumbnailWrap); ELabel attachmentLink = new ELabel(docName).withStyleName(UIConstants.META_INFO, UIConstants.TEXT_ELLIPSIS); attachmentLayout.with(attachmentLink).expand(attachmentLink); MButton removeAttachment = new MButton("", clickEvent -> { ConfirmDialog.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.CONFIRM_DELETE_ATTACHMENT), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), dialog -> { if (dialog.isConfirmed()) { ResourceService attachmentService = AppContextUtil.getSpringBean(ResourceService.class); attachmentService.removeResource(attachment.getPath(), UserUIContext.getUsername(), true, MyCollabUI.getAccountId()); ((ComponentContainer) attachmentLayout.getParent()).removeComponent(attachmentLayout); } }); }).withIcon(FontAwesome.TRASH_O).withStyleName(MobileUIConstants.BUTTON_LINK); if (additionalListener != null) { removeAttachment.addClickListener(additionalListener); } removeAttachment.setHtmlContentAllowed(true); attachmentLayout.addComponent(removeAttachment); return attachmentLayout; }
From source file:com.mycollab.module.crm.ui.components.CommentRowDisplayHandler.java
License:Open Source License
@Override public Component generateRow(IBeanList<SimpleComment> host, final SimpleComment comment, int rowIndex) { final MHorizontalLayout layout = new MHorizontalLayout().withMargin(new MarginInfo(true, true, true, false)) .withFullWidth();//w w w. j a v a 2 s.c om UserBlock memberBlock = new UserBlock(comment.getCreateduser(), comment.getOwnerAvatarId(), comment.getOwnerFullName()); layout.addComponent(memberBlock); CssLayout rowLayout = new CssLayout(); rowLayout.setStyleName(WebThemes.MESSAGE_CONTAINER); rowLayout.setWidth("100%"); MHorizontalLayout messageHeader = new MHorizontalLayout() .withMargin(new MarginInfo(true, true, false, true)).withFullWidth(); messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); ELabel timePostLbl = new ELabel(UserUIContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(), UserUIContext.formatPrettyTime(comment.getCreatedtime())), ContentMode.HTML).withDescription(UserUIContext.formatDateTime(comment.getCreatedtime())); timePostLbl.setSizeUndefined(); timePostLbl.setStyleName(UIConstants.META_INFO); messageHeader.with(timePostLbl).expand(timePostLbl); // Message delete button if (hasDeletePermission(comment)) { MButton msgDeleteBtn = new MButton("", clickEvent -> { ConfirmDialogExt.show(UI.getCurrent(), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()), UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), UserUIContext.getMessage(GenericI18Enum.BUTTON_YES), UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> { if (confirmDialog.isConfirmed()) { CommentService commentService = AppContextUtil.getSpringBean(CommentService.class); commentService.removeWithSession(comment, UserUIContext.getUsername(), MyCollabUI.getAccountId()); ((BeanList) host).removeRow(layout); } }); }).withIcon(FontAwesome.TRASH_O).withStyleName(WebThemes.BUTTON_ICON_ONLY); messageHeader.addComponent(msgDeleteBtn); } 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().withSpacing(false).withFullWidth(); AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments); messageFooter.with(attachmentDisplay).withAlign(attachmentDisplay, Alignment.MIDDLE_RIGHT); rowLayout.addComponent(messageFooter); } layout.with(rowLayout).expand(rowLayout); return layout; }