public VerticalTabsheet(boolean isLeft) { CssLayout contentLayout = new CssLayout(); new Restrain(contentLayout).setMinHeight("100%"); navigatorWrapper = new CssLayout(); navigatorWrapper.setStyleName("navigator-wrap"); navigatorContainer = new VerticalLayout(); navigatorWrapper.addComponent(navigatorContainer); contentWrapper = new VerticalLayout(); contentWrapper.setStyleName("container-wrap"); contentWrapper.setWidth("100%"); tabContainer = new CssLayout(); tabContainer.setWidth("100%"); contentWrapper.addComponent(tabContainer); if (isLeft) { contentLayout.addComponent(navigatorWrapper); contentLayout.addComponent(contentWrapper); } else { contentLayout.addComponent(contentWrapper); contentLayout.addComponent(navigatorWrapper); } this.setCompositionRoot(contentLayout); this.setStyleName(TABSHEET_STYLENAME); }
private Layout getLayout(String caption, Class<? extends Layout> layoutClass, String width) { Layout l; if (layoutClass == VerticalLayout.class) { if (verticalLayout == null) { verticalLayout = new VerticalLayout(); verticalLayout.setStyleName("borders"); } l = verticalLayout; } else if (layoutClass == HorizontalLayout.class) { if (horizontalLayout == null) { horizontalLayout = new HorizontalLayout(); horizontalLayout.setStyleName("borders"); } l = horizontalLayout; } else if (layoutClass == GridLayout.class) { if (gridLayout == null) { gridLayout = new GridLayout(); gridLayout.setStyleName("borders"); } l = gridLayout; } else if (layoutClass == CssLayout.class) { if (cssLayout == null) { cssLayout = new CssLayout(); cssLayout.setStyleName("borders"); } l = cssLayout; } else if (layoutClass == FormLayout.class) { if (formLayout == null) { formLayout = new FormLayout(); formLayout.setStyleName("borders"); } l = formLayout; } else { return null; } l.setCaption(caption); if (width.equals("auto")) { width = null; } l.setWidth(width); // addComponent(l); return l; }
public void setSearchCriteria(final S criteria) { this.searchCriteria = criteria; final JFreeChart chart = createChart(); final JFreeChartWrapper chartWrapper = new JFreeChartWrapper(chart); removeAllComponents(); final CssLayout borderWrap = new CssLayout(); borderWrap.addComponent(chartWrapper); borderWrap.setStyleName("chart-wrapper"); borderWrap.setHeight(height + "px"); borderWrap.setWidth(width + "px"); chartWrapper.setHeight(height + "px"); chartWrapper.setWidth(width + "px"); chartWrapper.setGraphHeight(height); chartWrapper.setGraphWidth(width); this.addComponent(borderWrap); // this.setComponentAlignment(chartWrapper, Alignment.MIDDLE_CENTER); final Component legendBox = createLegendBox(); legendBox.setWidth(width + "px"); this.addComponent(legendBox); this.setComponentAlignment(legendBox, Alignment.MIDDLE_CENTER); }
public Depot( final Label titleLbl, final ComponentContainer headerElement, final ComponentContainer component, final String headerWidth, final String headerLeftWidth) { this.setStyleName("depotComp"); this.setMargin(new MarginInfo(true, false, false, false)); this.header = new HorizontalLayout(); this.header.setStyleName("depotHeader"); this.header.setWidth(headerWidth); this.bodyContent = component; if (headerElement != null) { this.headerContent = headerElement; } else { this.headerContent = new HorizontalLayout(); ((HorizontalLayout) this.headerContent).setSpacing(true); ((HorizontalLayout) this.headerContent).setMargin(true); ((HorizontalLayout) this.headerContent).setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); this.headerContent.setVisible(false); } this.headerContent.setStyleName("header-elements"); this.headerContent.setWidth(Sizeable.SIZE_UNDEFINED, Sizeable.Unit.PIXELS); // this.headerContent.setHeight("100%"); this.headerContent.setSizeUndefined(); this.addComponent(this.header); final VerticalLayout headerLeft = new VerticalLayout(); this.headerLbl = titleLbl; this.headerLbl.setStyleName("h2"); this.headerLbl.setWidth("100%"); headerLeft.addComponent(this.headerLbl); headerLeft.setStyleName("depot-title"); headerLeft.addLayoutClickListener( new LayoutClickListener() { private static final long serialVersionUID = 1L; @Override public void layoutClick(final LayoutClickEvent event) { Depot.this.isOpenned = !Depot.this.isOpenned; if (Depot.this.isOpenned) { Depot.this.bodyContent.setVisible(true); Depot.this.removeStyleName("collapsed"); } else { Depot.this.bodyContent.setVisible(false); Depot.this.addStyleName("collapsed"); } } }); final CssLayout headerWrapper = new CssLayout(); headerWrapper.addComponent(headerLeft); headerWrapper.setStyleName("header-wrapper"); headerWrapper.setWidth(headerLeftWidth); this.header.addComponent(headerWrapper); this.header.setComponentAlignment(headerWrapper, Alignment.MIDDLE_LEFT); this.header.addComponent(this.headerContent); this.header.setComponentAlignment(this.headerContent, Alignment.TOP_RIGHT); this.header.setExpandRatio(headerWrapper, 1.0f); final CustomComponent customComp = new CustomComponent(this.bodyContent); customComp.setWidth("100%"); this.bodyContent.addStyleName("depotContent"); this.addComponent(customComp); this.setComponentAlignment(customComp, Alignment.TOP_CENTER); }
public void setContainerStyleName(String styleName) { tabContainer.setStyleName(styleName); }
@Override public Component generateBlock(final SimpleOpportunity opportunity, int blockIndex) { CssLayout beanBlock = new CssLayout(); beanBlock.addStyleName("bean-block"); beanBlock.setWidth("350px"); VerticalLayout blockContent = new VerticalLayout(); MHorizontalLayout blockTop = new MHorizontalLayout().withWidth("100%"); CssLayout iconWrap = new CssLayout(); iconWrap.setStyleName("icon-wrap"); FontIconLabel opportunityIcon = new FontIconLabel(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY)); iconWrap.addComponent(opportunityIcon); blockTop.addComponent(iconWrap); VerticalLayout opportunityInfo = new VerticalLayout(); opportunityInfo.setSpacing(true); MButton btnDelete = new MButton(FontAwesome.TRASH_O); btnDelete.addClickListener( new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { ConfirmDialogExt.show( UI.getCurrent(), AppContext.getMessage( GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { ContactService contactService = ApplicationContextUtil.getSpringBean(ContactService.class); ContactOpportunity associateOpportunity = new ContactOpportunity(); associateOpportunity.setContactid(contact.getId()); associateOpportunity.setOpportunityid(opportunity.getId()); contactService.removeContactOpportunityRelationship( associateOpportunity, AppContext.getAccountId()); ContactOpportunityListComp.this.refresh(); } } }); } }); btnDelete.addStyleName(UIConstants.BUTTON_ICON_ONLY); blockContent.addComponent(btnDelete); blockContent.setComponentAlignment(btnDelete, Alignment.TOP_RIGHT); Label opportunityName = new Label( String.format( "Name: <a href='%s%s'>%s</a>", SiteConfiguration.getSiteUrl(AppContext.getUser().getSubdomain()), CrmLinkGenerator.generateCrmItemLink( CrmTypeConstants.OPPORTUNITY, opportunity.getId()), opportunity.getOpportunityname()), ContentMode.HTML); opportunityInfo.addComponent(opportunityName); Label opportunityAmount = new Label("Amount: " + (opportunity.getAmount() != null ? opportunity.getAmount() : "")); if (opportunity.getCurrency() != null && opportunity.getAmount() != null) { opportunityAmount.setValue( opportunityAmount.getValue() + opportunity.getCurrency().getSymbol()); } opportunityInfo.addComponent(opportunityAmount); Label opportunitySaleStage = new Label( "Sale Stage: " + (opportunity.getSalesstage() != null ? opportunity.getSalesstage() : "")); opportunityInfo.addComponent(opportunitySaleStage); ELabel opportunityExpectedCloseDate = new ELabel( "Expected Closed Date: " + AppContext.formatPrettyTime(opportunity.getExpectedcloseddate())) .withDescription(AppContext.formatDate(opportunity.getExpectedcloseddate())); opportunityInfo.addComponent(opportunityExpectedCloseDate); blockTop.with(opportunityInfo).expand(opportunityInfo); blockContent.addComponent(blockTop); blockContent.setWidth("100%"); beanBlock.addComponent(blockContent); return beanBlock; }
@Override public Component generateRow(final SimpleComment comment, int rowIndex) { final MHorizontalLayout layout = new MHorizontalLayout() .withMargin(new MarginInfo(true, true, true, false)) .withWidth("100%") .withStyleName("message"); UserBlock memberBlock = new UserBlock( comment.getCreateduser(), comment.getOwnerAvatarId(), comment.getOwnerFullName()); layout.addComponent(memberBlock); CssLayout rowLayout = new CssLayout(); rowLayout.setStyleName("message-container"); rowLayout.setWidth("100%"); MHorizontalLayout messageHeader = new MHorizontalLayout() .withMargin(new MarginInfo(true, true, false, true)) .withWidth("100%") .withStyleName("message-header"); messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); ELabel timePostLbl = new ELabel( AppContext.getMessage( GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(), AppContext.formatPrettyTime(comment.getCreatedtime())), ContentMode.HTML) .withDescription(AppContext.formatDateTime(comment.getCreatedtime())); timePostLbl.setSizeUndefined(); timePostLbl.setStyleName("time-post"); messageHeader.with(timePostLbl).expand(timePostLbl); // Message delete button Button msgDeleteBtn = new Button(); msgDeleteBtn.setIcon(FontAwesome.TRASH_O); msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY); messageHeader.addComponent(msgDeleteBtn); if (hasDeletePermission(comment)) { msgDeleteBtn.setVisible(true); msgDeleteBtn.addClickListener( new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { ConfirmDialogExt.show( UI.getCurrent(), AppContext.getMessage( GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { CommentService commentService = ApplicationContextUtil.getSpringBean(CommentService.class); commentService.removeWithSession( comment, AppContext.getUsername(), AppContext.getAccountId()); owner.removeRow(layout); } } }); } }); } else { msgDeleteBtn.setVisible(false); } rowLayout.addComponent(messageHeader); Label messageContent = new SafeHtmlLabel(comment.getComment()); messageContent.setStyleName("message-body"); rowLayout.addComponent(messageContent); List<Content> attachments = comment.getAttachments(); if (!CollectionUtils.isEmpty(attachments)) { MVerticalLayout messageFooter = new MVerticalLayout() .withSpacing(false) .withWidth("100%") .withStyleName("message-footer"); AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments); attachmentDisplay.setWidth("100%"); messageFooter.with(attachmentDisplay).withAlign(attachmentDisplay, Alignment.MIDDLE_RIGHT); rowLayout.addComponent(messageFooter); } layout.with(rowLayout).expand(rowLayout); return layout; }
private void initUI() { GridLayout mainLayout = new GridLayout(1, 5); mainLayout.setWidth("100%"); mainLayout.setMargin(true); mainLayout.setSpacing(true); CssLayout inputPanel = new CssLayout(); inputPanel.setWidth("100%"); inputPanel.setStyleName("mail-panel"); inputLayout = new GridLayout(3, 4); inputLayout.setSpacing(true); inputLayout.setWidth("100%"); inputLayout.setColumnExpandRatio(0, 1.0f); inputPanel.addComponent(inputLayout); mainLayout.addComponent(inputPanel); tokenFieldMailTo = new EmailTokenField(); inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0); if (lstMail != null) { for (String mail : lstMail) { if (StringUtils.isNotBlank(mail)) { if (mail.indexOf("<") > -1) { String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">")); if (strMail != null && !strMail.equalsIgnoreCase("null")) {} } else { } } } } final TextField subject = new TextField(); subject.setRequired(true); subject.setWidth("100%"); subjectField = createTextFieldMail("Subject:", subject); inputLayout.addComponent(subjectField, 0, 1); initButtonLinkCcBcc(); ccField = createTextFieldMail("Cc:", tokenFieldMailCc); bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc); final RichTextArea noteArea = new RichTextArea(); noteArea.setWidth("100%"); noteArea.setHeight("200px"); mainLayout.addComponent(noteArea, 0, 1); mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setWidth("100%"); final AttachmentPanel attachments = new AttachmentPanel(); attachments.setWidth("500px"); MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments); uploadExt.addComponent(attachments); controlsLayout.addComponent(uploadExt); controlsLayout.setExpandRatio(uploadExt, 1.0f); controlsLayout.setSpacing(true); Button cancelBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { MailFormWindow.this.close(); } }); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); controlsLayout.addComponent(cancelBtn); controlsLayout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT); Button sendBtn = new Button( "Send", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (tokenFieldMailTo.getListRecipient().size() <= 0 || subject.getValue().equals("")) { NotificationUtil.showErrorNotification( "To Email field and Subject field must be not empty! Please fulfil them before sending email."); return; } if (AppContext.getUser().getEmail() != null && AppContext.getUser().getEmail().length() > 0) { ExtMailService systemMailService = ApplicationContextUtil.getSpringBean(ExtMailService.class); List<File> listFile = attachments.files(); List<EmailAttachementSource> emailAttachmentSource = null; if (listFile != null && listFile.size() > 0) { emailAttachmentSource = new ArrayList<>(); for (File file : listFile) { emailAttachmentSource.add(new FileEmailAttachmentSource(file)); } } systemMailService.sendHTMLMail( AppContext.getUser().getEmail(), AppContext.getUser().getDisplayName(), tokenFieldMailTo.getListRecipient(), tokenFieldMailCc.getListRecipient(), tokenFieldMailBcc.getListRecipient(), subject.getValue().toString(), noteArea.getValue().toString(), emailAttachmentSource); MailFormWindow.this.close(); } else { NotificationUtil.showErrorNotification( "Your email is empty value, please fulfil it before sending email!"); } } }); sendBtn.setIcon(FontAwesome.SEND); sendBtn.setStyleName(UIConstants.BUTTON_ACTION); controlsLayout.addComponent(sendBtn); controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT); mainLayout.addComponent(controlsLayout, 0, 2); this.setContent(mainLayout); }
@Override public Component generateRow(final SimpleMessage message, final int rowIndex) { final HorizontalLayout messageLayout = new HorizontalLayout(); messageLayout.setStyleName("message"); messageLayout.setSpacing(true); if (message.getIsstick() != null && message.getIsstick()) { messageLayout.addStyleName("important-message"); } messageLayout.setWidth("100%"); VerticalLayout userBlock = new VerticalLayout(); userBlock.setDefaultComponentAlignment(Alignment.TOP_CENTER); userBlock.setWidth("80px"); userBlock.setSpacing(true); userBlock.addComponent( UserAvatarControlFactory.createUserAvatarButtonLink( message.getPostedUserAvatarId(), message.getFullPostedUserName())); Label userName = new Label(message.getFullPostedUserName()); userName.setStyleName("user-name"); userBlock.addComponent(userName); messageLayout.addComponent(userBlock); final CssLayout rowLayout = new CssLayout(); rowLayout.setStyleName("message-container"); rowLayout.setWidth("100%"); final Button title = new Button( message.getTitle(), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { EventBus.getInstance() .fireEvent( new MessageEvent.GotoRead(MessageListViewImpl.this, message.getId())); } }); title.setWidth("550px"); title.setStyleName("link"); title.addStyleName(UIConstants.WORD_WRAP); final HorizontalLayout messageHeader = new HorizontalLayout(); messageHeader.setStyleName("message-header"); messageHeader.setMargin(new MarginInfo(true, true, false, true)); final VerticalLayout leftHeader = new VerticalLayout(); title.addStyleName("message-title"); leftHeader.addComponent(title); final HorizontalLayout rightHeader = new HorizontalLayout(); rightHeader.setSpacing(true); final Label timePostLbl = new Label(DateTimeUtils.getStringDateFromNow(message.getPosteddate())); timePostLbl.setSizeUndefined(); timePostLbl.setStyleName("time-post"); final HorizontalLayout notification = new HorizontalLayout(); notification.setStyleName("notification"); notification.setSizeUndefined(); notification.setSpacing(true); if (message.getCommentsCount() > 0) { final HorizontalLayout commentNotification = new HorizontalLayout(); final Label commentCountLbl = new Label(Integer.toString(message.getCommentsCount())); commentCountLbl.setStyleName("comment-count"); commentCountLbl.setSizeUndefined(); commentNotification.addComponent(commentCountLbl); final Image commentIcon = new Image(null, MyCollabResource.newResource("icons/16/project/message.png")); commentNotification.addComponent(commentIcon); notification.addComponent(commentNotification); } ResourceService attachmentService = ApplicationContextUtil.getSpringBean(ResourceService.class); List<Content> attachments = attachmentService.getContents( AttachmentUtils.getProjectEntityAttachmentPath( AppContext.getAccountId(), message.getProjectid(), AttachmentType.PROJECT_MESSAGE, message.getId())); if (attachments != null && !attachments.isEmpty()) { final HorizontalLayout attachmentNotification = new HorizontalLayout(); final Label attachmentCountLbl = new Label(Integer.toString(attachments.size())); attachmentCountLbl.setStyleName("attachment-count"); attachmentCountLbl.setSizeUndefined(); attachmentNotification.addComponent(attachmentCountLbl); final Image attachmentIcon = new Image(null, MyCollabResource.newResource("icons/16/attachment.png")); attachmentNotification.addComponent(attachmentIcon); notification.addComponent(attachmentNotification); } Button deleteBtn = new Button( "", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialogExt.show( UI.getCurrent(), LocalizationHelper.getMessage( GenericI18Enum.DELETE_DIALOG_TITLE, SiteConfiguration.getSiteName()), LocalizationHelper.getMessage( GenericI18Enum.CONFIRM_DELETE_RECORD_DIALOG_MESSAGE), LocalizationHelper.getMessage(GenericI18Enum.BUTTON_YES_LABEL), LocalizationHelper.getMessage(GenericI18Enum.BUTTON_NO_LABEL), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(final ConfirmDialog dialog) { if (dialog.isConfirmed()) { final MessageService messageService = ApplicationContextUtil.getSpringBean(MessageService.class); messageService.removeWithSession( message.getId(), AppContext.getUsername(), AppContext.getAccountId()); MessageListViewImpl.this.tableItem.setSearchCriteria(searchCriteria); } } }); } }); deleteBtn.setIcon(MyCollabResource.newResource("icons/12/project/icon_x.png")); deleteBtn.addStyleName("link"); deleteBtn.setEnabled( CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.MESSAGES)); rightHeader.addComponent(timePostLbl); rightHeader.addComponent(deleteBtn); rightHeader.setExpandRatio(timePostLbl, 1.0f); messageHeader.addComponent(leftHeader); messageHeader.setExpandRatio(leftHeader, 1.0f); messageHeader.addComponent(rightHeader); messageHeader.setWidth("100%"); rowLayout.addComponent(messageHeader); final Label messageContent = new Label(StringUtils.formatExtraLink(message.getMessage()), ContentMode.HTML); messageContent.setStyleName("message-body"); rowLayout.addComponent(messageContent); if (notification.getComponentCount() > 0) { VerticalLayout messageFooter = new VerticalLayout(); messageFooter.setWidth("100%"); messageFooter.setStyleName("message-footer"); messageFooter.addComponent(notification); messageFooter.setMargin(true); messageFooter.setComponentAlignment(notification, Alignment.MIDDLE_RIGHT); rowLayout.addComponent(messageFooter); } messageLayout.addComponent(rowLayout); messageLayout.setExpandRatio(rowLayout, 1.0f); return messageLayout; }