List of usage examples for com.vaadin.ui HorizontalLayout setWidth
@Override public void setWidth(String width)
From source file:com.dungnv.streetfood.view.RestaurantView.java
private void init() { header = new VerticalLayout(); header.addStyleName("viewheader"); header.setSpacing(true);/*from w w w .jav a 2s .c om*/ header.setId("hehehe"); titleLabel = new Label(BundleUtils.getLanguage("menu.RESTAURANT")); titleLabel.setId(TITLE_ID); titleLabel.setWidth("100%"); titleLabel.addStyleName(ValoTheme.LABEL_BOLD); header.addComponent(titleLabel); btnAdd = new Button(); btnAdd.setCaption(FontAwesome.PLUS_CIRCLE.getLabel().setSize3x().getCssHtml()); btnAdd.setCaptionAsHtml(true); btnAdd.addStyleName("float-button"); // add.addStyleName(ValoTheme.BUTTON_BORDERLESS); // add.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // add.addStyleName(ValoTheme.BUTTON_LARGE); header.addComponent(btnAdd); HorizontalLayout item = new HorizontalLayout(); // item.setSpacing(true); item.setWidth("100%"); header.addComponent(item); txtSearch = new TextField(); txtSearch.setImmediate(true); txtSearch.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.TIMEOUT); txtSearch.setIcon(FontAwesome.SEARCH); txtSearch.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); txtSearch.setInputPrompt(BundleUtils.getLanguage("lbl.restaurant.name.input")); txtSearch.setWidth("100%"); item.addComponent(txtSearch); item.setComponentAlignment(txtSearch, Alignment.TOP_RIGHT); lbAdvanced = new Button(); lbAdvanced.setCaption(BundleUtils.getLanguage("lbl.search.advanced")); lbAdvanced.addStyleName(ValoTheme.BUTTON_LINK); lbAdvanced.addStyleName(ValoTheme.BUTTON_LARGE); item.addComponent(lbAdvanced); item.setComponentAlignment(lbAdvanced, Alignment.BOTTOM_LEFT); uiSearchPaged = new CommonSearchPagedUI(1) { @Override public void cbChanged() { this.getCbPaged().addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { onSearch(false); } } }); this.getCbRecordPerPage().addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { onSearch(true); } } }); } }; header.addComponent(uiSearchPaged); searchLayout = new VerticalLayout(); // searchLayout.setSpacing(true); searchLayout.setSizeFull(); header.addComponent(searchLayout); searchDetail = new RestaurantSearchDetail(this); }
From source file:com.dungnv.streetfood.view.SlideShowView.java
private void init() { header = new VerticalLayout(); header.addStyleName("viewheader"); header.setSpacing(true);/*from www . java 2s . c o m*/ header.setId("hehehe"); titleLabel = new Label(BundleUtils.getLanguage("menu.RESTAURANT")); titleLabel.setId(TITLE_ID); titleLabel.setWidth("100%"); titleLabel.addStyleName(ValoTheme.LABEL_BOLD); header.addComponent(titleLabel); btnAdd = new Button(); btnAdd.setCaption(FontAwesome.PLUS_CIRCLE.getLabel().setSize3x().getCssHtml()); btnAdd.setCaptionAsHtml(true); btnAdd.addStyleName("float-button"); // add.addStyleName(ValoTheme.BUTTON_BORDERLESS); // add.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // add.addStyleName(ValoTheme.BUTTON_LARGE); header.addComponent(btnAdd); HorizontalLayout item = new HorizontalLayout(); // item.setSpacing(true); item.setWidth("100%"); header.addComponent(item); txtSearch = new TextField(); txtSearch.setImmediate(true); txtSearch.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.TIMEOUT); txtSearch.setIcon(FontAwesome.SEARCH); txtSearch.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); txtSearch.setInputPrompt(BundleUtils.getLanguage("lbl.slideShow.name.input")); txtSearch.setWidth("100%"); item.addComponent(txtSearch); item.setComponentAlignment(txtSearch, Alignment.TOP_RIGHT); lbAdvanced = new Button(); lbAdvanced.setCaption(BundleUtils.getLanguage("lbl.search.advanced")); lbAdvanced.addStyleName(ValoTheme.BUTTON_LINK); lbAdvanced.addStyleName(ValoTheme.BUTTON_LARGE); item.addComponent(lbAdvanced); item.setComponentAlignment(lbAdvanced, Alignment.BOTTOM_LEFT); uiSearchPaged = new CommonSearchPagedUI(1) { @Override public void cbChanged() { this.getCbPaged().addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { onSearch(false); } } }); this.getCbRecordPerPage().addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (event.getProperty().getValue() != null) { onSearch(true); } } }); } }; header.addComponent(uiSearchPaged); searchLayout = new VerticalLayout(); // searchLayout.setSpacing(true); searchLayout.setSizeFull(); header.addComponent(searchLayout); searchDetail = new SlideShowSearchDetail(this); }
From source file:com.emuanalytics.vaadin.enhancedjavascript.BasicTestUI.java
License:Apache License
@Override public Component getTestComponent() { // The sample component under test sampleComponent = new SampleEnhancedComponent(); sampleComponent.setId("sample-component"); Component componentWrapper = createComponentContainer(sampleComponent); Component testPanel = createTestPanel(); HorizontalLayout layout = new HorizontalLayout(componentWrapper, testPanel); layout.setWidth("100%"); layout.setHeight("100%"); layout.setMargin(true);/*from w w w . jav a 2s . c o m*/ layout.setExpandRatio(componentWrapper, 1); sampleComponent.addClickListener(value -> { lastEventField.setValue("Click (value=" + value + ")"); }); sampleComponent.addVariableChangeListener(value -> { lastVariableChangeField.setValue("inputValue Changed (value=" + value.toString() + ")"); }); return layout; }
From source file:com.esofthead.mycollab.mobile.module.project.ui.ProjectCommentInput.java
License:Open Source License
private Component createAttachmentRow(String fileName) { final HorizontalLayout uploadSucceedLayout = new HorizontalLayout(); uploadSucceedLayout.setWidth("100%"); Label uploadResult = new Label(fileName); uploadResult.setWidth("100%"); uploadSucceedLayout.addComponent(uploadResult); uploadSucceedLayout.setExpandRatio(uploadResult, 1.0f); Button removeAttachment = new Button( "<span aria-hidden=\"true\" data-icon=\"" + IconConstants.DELETE + "\"></span>", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override/*from w w w.ja v a 2s. c o m*/ public void buttonClick(ClickEvent event) { statusWrapper.removeComponent(uploadSucceedLayout); } }); removeAttachment.setHtmlContentAllowed(true); removeAttachment.setStyleName("link"); uploadSucceedLayout.addComponent(removeAttachment); uploadSucceedLayout.setStyleName("upload-succeed-layout"); uploadSucceedLayout.setSpacing(true); return uploadSucceedLayout; }
From source file:com.esofthead.mycollab.mobile.module.project.ui.TimeLogComp.java
License:Open Source License
public void displayTime(final V bean) { this.removeAllComponents(); HorizontalLayout header = new HorizontalLayout(); header.setSpacing(true);//from ww w .j a v a 2s .c o m header.setStyleName("info-hdr"); header.addStyleName("timelog-comp-hdr"); header.setWidth("100%"); Label dateInfoHeader = new Label(AppContext.getMessage(TimeTrackingI18nEnum.SUB_INFO_TIME)); dateInfoHeader.setWidthUndefined(); header.addComponent(dateInfoHeader); header.setExpandRatio(dateInfoHeader, 1.0f); 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) { showEditTimeView(bean); } }); editBtn.setStyleName("link"); editBtn.setHtmlContentAllowed(true); header.addComponent(editBtn); header.setComponentAlignment(editBtn, Alignment.BOTTOM_LEFT); } this.addComponent(header); GridFormLayoutHelper layout = new GridFormLayoutHelper(1, 3, "100%", "150px", Alignment.TOP_RIGHT); layout.getLayout().setWidth("100%"); layout.getLayout().setMargin(false); double billableHours = getTotalBillableHours(bean); double nonBillableHours = getTotalNonBillableHours(bean); double remainHours = getRemainedHours(bean); layout.addComponent(new Label(billableHours + ""), AppContext.getMessage(TimeTrackingI18nEnum.M_FORM_BILLABLE_HOURS), 0, 0); layout.addComponent(new Label(nonBillableHours + ""), AppContext.getMessage(TimeTrackingI18nEnum.M_FORM_NON_BILLABLE_HOURS), 0, 1); layout.addComponent(new Label(remainHours + ""), AppContext.getMessage(TimeTrackingI18nEnum.M_FORM_REMAIN_HOURS), 0, 2); this.addComponent(layout.getLayout()); }
From source file:com.esofthead.mycollab.mobile.module.project.view.message.MessageAttachmentField.java
License:Open Source License
@Override protected void constructUI() { content = new VerticalLayout(); content.setStyleName("attachment-field"); rowWrap = new VerticalLayout(); rowWrap.setWidth("100%"); rowWrap.setStyleName("attachment-row-wrap"); HorizontalLayout compHeader = new HorizontalLayout(); compHeader.setWidth("100%"); compHeader.setStyleName("attachment-field-header"); Label headerLbl = new Label(AppContext.getMessage(GenericI18Enum.M_FORM_ATTACHMENT)); headerLbl.setStyleName("field-caption"); compHeader.addComponent(headerLbl);//from ww w. j a v a 2 s .c om compHeader.setExpandRatio(headerLbl, 1.0f); compHeader.addComponent(attachmentBtn); content.addComponent(compHeader); content.addComponent(rowWrap); }
From source file:com.esofthead.mycollab.mobile.module.project.view.message.MessageReadViewImpl.java
License:Open Source License
@Override public void previewItem(SimpleMessage message) { this.bean = message; mainLayout.removeAllComponents();/*w w w . java 2 s . c o m*/ HorizontalLayout messageBlock = new HorizontalLayout(); messageBlock.setStyleName("message-block"); Image userAvatarImg = UserAvatarControlFactory .createUserAvatarEmbeddedComponent(message.getPostedUserAvatarId(), 32); userAvatarImg.setStyleName("user-avatar"); messageBlock.addComponent(userAvatarImg); CssLayout rightCol = new CssLayout(); rightCol.setWidth("100%"); HorizontalLayout metadataRow = new HorizontalLayout(); metadataRow.setWidth("100%"); metadataRow.setStyleName("metadata-row"); Label userNameLbl = new Label(message.getFullPostedUserName()); userNameLbl.setStyleName("user-name"); metadataRow.addComponent(userNameLbl); metadataRow.setExpandRatio(userNameLbl, 1.0f); Label messageTimePost = new Label( DateTimeUtils.getPrettyDateValue(message.getPosteddate(), AppContext.getUserLocale())); messageTimePost.setStyleName("time-post"); messageTimePost.setWidthUndefined(); metadataRow.addComponent(messageTimePost); rightCol.addComponent(metadataRow); HorizontalLayout titleRow = new HorizontalLayout(); titleRow.setWidth("100%"); titleRow.setStyleName("title-row"); Label messageTitle = new Label(message.getTitle()); messageTitle.setStyleName("message-title"); titleRow.addComponent(messageTitle); titleRow.setExpandRatio(messageTitle, 1.0f); if (message.getCommentsCount() > 0) { Label msgCommentCount = new Label(String.valueOf(message.getCommentsCount())); msgCommentCount.setStyleName("comment-count"); msgCommentCount.setWidthUndefined(); titleRow.addComponent(msgCommentCount); titleRow.addStyleName("has-comment"); titleRow.setComponentAlignment(messageTitle, Alignment.MIDDLE_LEFT); } rightCol.addComponent(titleRow); Label messageContent = new Label( StringUtils.trim(StringUtils.trimHtmlTags(message.getMessage()), 150, true)); messageContent.setStyleName("message-content"); rightCol.addComponent(messageContent); 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()) { CssLayout attachmentPanel = new CssLayout(); attachmentPanel.setStyleName("attachment-panel"); attachmentPanel.setWidth("100%"); for (Content attachment : attachments) { attachmentPanel.addComponent(MobileAttachmentUtils.renderAttachmentRow(attachment)); } rightCol.addComponent(attachmentPanel); } messageBlock.addComponent(rightCol); messageBlock.setExpandRatio(rightCol, 1.0f); messageBlock.setWidth("100%"); mainLayout.addComponent(messageBlock); MessageCommentListDisplay commentDisplay = new MessageCommentListDisplay(CommentType.PRJ_MESSAGE, CurrentProjectVariables.getProjectId(), true, true, MessageRelayEmailNotificationAction.class); commentDisplay.loadComments("" + message.getId()); this.setToolbar(commentDisplay.getCommentBox()); mainLayout.addComponent(commentDisplay); }
From source file:com.esofthead.mycollab.mobile.ui.ConfirmDialog.java
License:Open Source License
private void constructUI(final String message, final String okCaption, final String cancelCaption) { VerticalLayout layout = new VerticalLayout(); layout.setWidth("100%"); layout.setHeightUndefined();//w ww . jav a2 s. co m layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); VerticalLayout messageWrapper = new VerticalLayout(); messageWrapper.setStyleName("message-wrapper"); messageWrapper.setWidth("100%"); messageWrapper.setMargin(true); final Label messageDisplay = new Label(message); messageDisplay.setWidth("100%"); messageWrapper.addComponent(messageDisplay); layout.addComponent(messageWrapper); HorizontalLayout controlBtn = new HorizontalLayout(); controlBtn.setWidth("100%"); final Button okBtn = new Button(okCaption); okBtn.setWidth("100%"); okBtn.setHeight("35px"); final Button cancelBtn = new Button(cancelCaption); cancelBtn.setWidth("100%"); cancelBtn.setHeight("35px"); Button.ClickListener listener = new Button.ClickListener() { private static final long serialVersionUID = -8306231710367659086L; @Override public void buttonClick(ClickEvent event) { ConfirmDialog.this.setConfirmed(event.getButton() == okBtn); if (ConfirmDialog.this.getListener() != null) { ConfirmDialog.this.getListener().onClose(ConfirmDialog.this); } ConfirmDialog.this.close(); } }; okBtn.addClickListener(listener); cancelBtn.addClickListener(listener); controlBtn.addComponent(cancelBtn); controlBtn.addComponent(okBtn); layout.addComponent(controlBtn); this.setContent(layout); }
From source file:com.esofthead.mycollab.mobile.ui.GridFormLayoutHelper.java
License:Open Source License
public Component addComponent(final Component field, final String caption, final int columns, final int rows, final int colspan, final String width, final Alignment alignment) { if (caption != null) { final Label l = new Label(caption); final HorizontalLayout captionWrapper = new HorizontalLayout(); captionWrapper.addComponent(l);/*from w ww . j a v a2s. c o m*/ captionWrapper.setComponentAlignment(l, alignment); captionWrapper.setStyleName("gridform-caption"); captionWrapper.setMargin(true); captionWrapper.setWidth(this.defaultCaptionWidth); if (columns == 0) { captionWrapper.addStyleName("first-col"); } if (rows == 0) { captionWrapper.addStyleName("first-row"); } if ((rows + 1) % 2 == 0) captionWrapper.addStyleName("even-row"); this.layout.addComponent(captionWrapper, 2 * columns, rows); captionWrapper.setHeight("100%"); } final HorizontalLayout fieldWrapper = new HorizontalLayout(); fieldWrapper.setStyleName("gridform-field"); fieldWrapper.setMargin(true); fieldWrapper.addComponent(field); if (!(field instanceof Button)) field.setCaption(null); field.setWidth(width); fieldWrapper.setWidth("100%"); if (rows == 0) { fieldWrapper.addStyleName("first-row"); } if ((rows + 1) % 2 == 0) { fieldWrapper.addStyleName("even-row"); } this.layout.addComponent(fieldWrapper, 2 * columns + 1, rows, 2 * (columns + colspan - 1) + 1, rows); this.layout.setColumnExpandRatio(2 * columns + 1, 1.0f); return field; }
From source file:com.esofthead.mycollab.mobile.ui.GridFormLayoutHelper.java
License:Open Source License
public Component addComponent(final Component field, final String caption, final int columns, final int rows, final String width, final Alignment alignment) { if (caption != null) { final Label l = new Label(caption); // l.setHeight("100%"); final HorizontalLayout captionWrapper = new HorizontalLayout(); captionWrapper.addComponent(l);/*from w w w .ja v a 2 s.c o m*/ captionWrapper.setComponentAlignment(l, alignment); captionWrapper.setWidth(this.defaultCaptionWidth); captionWrapper.setHeight("100%"); captionWrapper.setStyleName("gridform-caption"); captionWrapper.setMargin(true); if (columns == 0) { captionWrapper.addStyleName("first-col"); } if (rows == 0) { captionWrapper.addStyleName("first-row"); } this.layout.addComponent(captionWrapper, 2 * columns, rows); } final HorizontalLayout fieldWrapper = new HorizontalLayout(); fieldWrapper.setStyleName("gridform-field"); if (!(field instanceof Button)) field.setCaption(null); fieldWrapper.addComponent(field); field.setWidth(width); fieldWrapper.setWidth("100%"); fieldWrapper.setMargin(true); if (rows == 0) { fieldWrapper.addStyleName("first-row"); } this.layout.addComponent(fieldWrapper, 2 * columns + 1, rows); this.layout.setColumnExpandRatio(2 * columns + 1, 1.0f); return field; }