List of usage examples for com.vaadin.ui CssLayout setStyleName
@Override public void setStyleName(String style)
From source file:com.hivesys.dashboard.view.search.TextualView.java
public void UpdateSearchPane(String searchString) { css.removeAllComponents();/*from w w w .j a v a2 s. c om*/ SearchResponse response = ElasticSearchContext.getInstance().searchSimpleQuery(searchString); logResponse(response); SearchHits results = response.getHits(); Label labelResultSummary = new Label("About " + results.getHits().length + " results found <br><br>", ContentMode.HTML); css.addComponent(labelResultSummary); for (SearchHit hit : results) { CssLayout cssResult = new CssLayout(); cssResult.setStyleName("search-result"); try { String filename = DocumentDB.getInstance().getDocumentNameFromHash(hit.getId()); String boxviewID = DocumentDB.getInstance().getBoxViewIDFromHash(hit.getId()); String highlight = ""; HighlightField objhighlight = hit.highlightFields().get("file"); if (objhighlight != null) { for (Text fgmt : objhighlight.getFragments()) { highlight += fgmt.string() + "<br>"; } } Button lblfileName = new Button(filename); lblfileName.addClickListener((Button.ClickEvent event) -> { if (boxviewID != null) { String url = BoxViewDocuments.getInstance().getViewURL(boxviewID); if (url != null || !url.equals("")) { url = BoxViewDocuments.getInstance().getViewURL(boxviewID); BrowserFrame bframe = new BrowserFrame(filename, new ExternalResource(url)); VerticalLayout vlayout = new VerticalLayout(bframe); final Window w = new Window(); w.setSizeFull(); w.setModal(true); w.setWindowMode(WindowMode.MAXIMIZED); w.setContent(vlayout); vlayout.setSizeFull(); vlayout.setMargin(true); w.setResizable(false); w.setDraggable(false); UI.getCurrent().addWindow(w); bframe.setSizeFull(); return; } Notification.show("Preview not available for this document!"); } }); lblfileName.setPrimaryStyleName("filename"); Label lblHighlight = new Label(highlight, ContentMode.HTML); lblHighlight.setStyleName("highlight"); cssResult.addComponent(lblfileName); cssResult.addComponent(lblHighlight); css.addComponent(cssResult); css.addComponent(new Label("<br>", ContentMode.HTML)); } catch (SQLException ex) { } } }
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 w ww. j a va 2 s . co m*/ 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 w w w .ja v a 2 s . 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();/*www. j a v a2s . c o m*/ 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.shell.view.MainView.java
License:Open Source License
public MainView() { super();//from w ww . j a v a 2 s .c o m this.setSizeFull(); MVerticalLayout contentLayout = new MVerticalLayout().withStyleName("content-wrapper").withFullWidth(); contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER); Image mainLogo = new Image(null, new ThemeResource("icons/logo_m.png")); contentLayout.addComponent(mainLogo); Label introText = new Label( "MyCollab helps you do all your office jobs on the computers, phones and tablets you use"); introText.setStyleName("intro-text"); contentLayout.addComponent(introText); CssLayout welcomeTextWrapper = new CssLayout(); welcomeTextWrapper.setStyleName("welcometext-wrapper"); welcomeTextWrapper.setWidth("100%"); welcomeTextWrapper.setHeight("15px"); contentLayout.addComponent(welcomeTextWrapper); Button crmButton = new Button(UserUIContext.getMessage(GenericI18Enum.MODULE_CRM), clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null))); crmButton.addStyleName(MobileUIConstants.BUTTON_ACTION); crmButton.setWidth("100%"); contentLayout.addComponent(crmButton); Button pmButton = new Button(UserUIContext.getMessage(GenericI18Enum.MODULE_PROJECT), clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null))); pmButton.setWidth("100%"); pmButton.addStyleName(MobileUIConstants.BUTTON_ACTION); contentLayout.addComponent(pmButton); this.addComponent(contentLayout); }
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 . ja v a 2 s . c o 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;/*w ww . j a v a 2 s .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()); }/*from w w w. j a va 2 s .c o m*/ 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();/*www . j a v a 2 s. c o m*/ 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; }
From source file:com.mycollab.module.crm.view.account.AccountCaseListComp.java
License:Open Source License
@Override protected Component generateTopControls() { MHorizontalLayout controlsBtnWrap = new MHorizontalLayout().withFullWidth(); MHorizontalLayout notesWrap = new MHorizontalLayout().withFullWidth(); Label noteLbl = new Label(UserUIContext.getMessage(GenericI18Enum.OPT_NOTE)); noteLbl.setSizeUndefined();/*from w w w. j a v a 2s . c om*/ noteLbl.setStyleName("list-note-lbl"); notesWrap.addComponent(noteLbl); CssLayout noteBlock = new CssLayout(); noteBlock.setWidth("100%"); noteBlock.setStyleName("list-note-block"); for (CaseStatus status : CrmDataTypeFactory.getCasesStatusList()) { ELabel note = new ELabel(UserUIContext.getMessage(status)) .withStyleName("note-label", colorsMap.get(status.name())).withWidthUndefined(); noteBlock.addComponent(note); } notesWrap.with(noteBlock).expand(noteBlock); controlsBtnWrap.addComponent(notesWrap); if (UserUIContext.canWrite(RolePermissionCollections.CRM_CASE)) { MButton createBtn = new MButton(UserUIContext.getMessage(CaseI18nEnum.NEW), clickEvent -> fireNewRelatedItem("")).withIcon(FontAwesome.PLUS) .withStyleName(WebThemes.BUTTON_ACTION); controlsBtnWrap.with(createBtn).withAlign(createBtn, Alignment.TOP_RIGHT); } return controlsBtnWrap; }