List of usage examples for com.vaadin.ui Label setContentMode
public void setContentMode(ContentMode contentMode)
From source file:com.jain.addon.action.confirm.ConfirmWindow.java
License:Apache License
@JNIComponentInit public void init() { setModal(true);/* w w w . j a v a 2s. c om*/ setWidth("25%"); VerticalLayout layout = new VerticalLayout(); setContent(layout); layout.setWidth("100%"); layout.setMargin(true); layout.setSpacing(true); layout.setStyleName(JNStyleConstants.J_ALTERNATE_VIEW); JNConfirm confirm = action.getConfirm(); HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSpacing(true); hLayout.setWidth("100%"); findNAddIcon(confirm, hLayout); Label label = new Label(confirm.message()); label.setContentMode(confirm.mode()); hLayout.addComponent(label); hLayout.setExpandRatio(label, 2); layout.addComponent(hLayout); layout.setComponentAlignment(hLayout, Alignment.MIDDLE_CENTER); ActionMenuBar<ConfirmWindow> menuBar = new ActionMenuBar<ConfirmWindow>(null, this); layout.addComponent(menuBar); layout.setExpandRatio(menuBar, 2); layout.setComponentAlignment(menuBar, Alignment.MIDDLE_CENTER); }
From source file:com.klwork.explorer.ui.business.social.DiscussPopupWindow.java
License:Apache License
public VerticalLayout initMainLayout(final SocialUserWeibo userWeibo) { return new VerticalLayout() { {//from w ww. j a v a2 s .c om setSizeFull(); setSpacing(true); setMargin(new MarginInfo(true, true, false, true)); Label descriptionField = new Label(); descriptionField.addStyleName("wb_text"); descriptionField.setContentMode(ContentMode.HTML); descriptionField.setValue( "@" + userWeibo.getUserScreenName() + ":" + mainPage.textTranslate(userWeibo.getText())); addComponent(descriptionField); addComponent(new HorizontalLayout() {// ?,? { setWidth("100%"); // Label inputFontField = initInputFontField(); addComponent(inputFontField); // setExpandRatio(image, 1.0f); setComponentAlignment(inputFontField, Alignment.MIDDLE_RIGHT); setExpandRatio(inputFontField, 0.2f); } }); // ? weiboContentTA = new TextArea(""); weiboContentTA.setWidth("100%"); weiboContentTA.setColumns(25); weiboContentTA.focus(); addComponent(weiboContentTA); scheduleEventFieldGroup.bind(weiboContentTA, "content"); // ? addComponent(new HorizontalLayout() { { setSpacing(true); // setSizeFull(); // setMargin(true); CheckBox simuField = CommonFieldHandler.createCheckBox(""); simuField.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -7104996493482558021L; @Override public void valueChange(ValueChangeEvent event) { Object value = event.getProperty().getValue(); } }); addComponent(simuField); // setExpandRatio(image, 1.0f); setComponentAlignment(simuField, Alignment.MIDDLE_LEFT); Label commentLable = new Label(); commentLable.setContentMode(ContentMode.HTML); commentLable.setValue("????"); addComponent(commentLable); // setExpandRatio(image, 1.0f); setComponentAlignment(commentLable, Alignment.MIDDLE_LEFT); Image image = initFaceComponet();// addComponent(image); } }); // HorizontalLayout buttonLayout = new HorizontalLayout() { { setSpacing(true); setSizeFull(); // setMargin(true); Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK)); addComponent(okButton); setComponentAlignment(okButton, Alignment.TOP_RIGHT); okButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { BinderHandler.commit(scheduleEventFieldGroup); int ret = socialService.discussWeibo(weiboForwardSend); if (ret == 1) { Notification.show("??", Notification.Type.HUMANIZED_MESSAGE); } close(); } }); setExpandRatio(okButton, 1.0f); Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL)); addComponent(cancleButton); setComponentAlignment(cancleButton, Alignment.TOP_RIGHT); cancleButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { close(); } }); } }; addComponent(buttonLayout); setExpandRatio(buttonLayout, 1f); } }; }
From source file:com.klwork.explorer.ui.business.social.SaveToNotePopupWindow.java
License:Apache License
public VerticalLayout initMainLayout(final SocialUserWeibo userWeibo) { return new VerticalLayout() { {//from w w w . ja va 2s . co m setSizeFull(); setSpacing(true); setMargin(new MarginInfo(true, true, false, true)); Label descriptionField = new Label(); descriptionField.addStyleName("wb_text"); descriptionField.setContentMode(ContentMode.HTML); descriptionField.setValue(""); addComponent(descriptionField); // ? weiboContentTA = new TextArea(""); weiboContentTA.setWidth("100%"); weiboContentTA.setColumns(25); weiboContentTA.focus(); addComponent(weiboContentTA); scheduleEventFieldGroup.bind(weiboContentTA, "content"); if (hasOrginWeibo) {// weiboContentTA.setValue("//@" + userWeibo.getUserScreenName() + ": " + userWeibo.getText()); } else { weiboContentTA.setValue(userWeibo.getText()); //+ mainPage.textTranslate(userWeibo.getText())); } //, addComponent(new VerticalLayout() { { setSpacing(true); TextField titleField = CommonFieldHandler.createTextField(""); scheduleEventFieldGroup.bind(titleField, "title"); //??? if (userWeibo.getText() != null && userWeibo.getText().length() > 10) { titleField.setValue(userWeibo.getText().substring(0, 10)); } addComponent(titleField); // setSizeFull(); // setMargin(true); SocialUserAccount noteAccount = socialUserAccountService .findSocialUserByType(socialUserAccount.getOwnUser(), DictDef.dictInt("evernote")); if (noteAccount != null) { noteEntity.setUserAccountId(noteAccount.getId()); } Map<String, String> map = socialEvernoteService.queryNotebook(noteAccount); ComboBox noteMap = CommonFieldHandler.createComBox("", map, ""); addComponent(noteMap); setComponentAlignment(noteMap, Alignment.MIDDLE_LEFT); } }); // HorizontalLayout buttonLayout = new HorizontalLayout() { { setSpacing(true); setSizeFull(); // setMargin(true); Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK)); addComponent(okButton); setComponentAlignment(okButton, Alignment.TOP_RIGHT); okButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { BinderHandler.commit(scheduleEventFieldGroup); //? int ret = socialEvernoteService.saveWeiboToNotes(noteEntity); if (ret == 1) { Notification.show("??", Notification.Type.HUMANIZED_MESSAGE); } else { Notification.show("??!", Notification.Type.HUMANIZED_MESSAGE); } close(); } }); setExpandRatio(okButton, 1.0f); Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL)); addComponent(cancleButton); setComponentAlignment(cancleButton, Alignment.TOP_RIGHT); cancleButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { close(); } }); } }; addComponent(buttonLayout); setExpandRatio(buttonLayout, 1f); } }; }
From source file:com.klwork.explorer.ui.business.social.TransmitPopupWindow.java
License:Apache License
public TransmitPopupWindow(final SocialUserWeibo userWeibo, final AbstractWeiboDisplayPage mainPage) { super(mainPage.getSocialType()); this.socialUserWeiboService = ViewToolManager.getBean("socialUserWeiboService"); this.socialService = AbstractSocialService.querySocialClass(mainPage.getSocialType()); this.i18nManager = ViewToolManager.getI18nManager(); weiboForwardSend.setWeibId(userWeibo.getWeiboId()); weiboForwardSend.setUserAccountId(userWeibo.getUserAccountId()); this.userWeibo = userWeibo; if (userWeibo.getRetweetedId() != null) { orginWeibo = socialUserWeiboService.findSocialUserWeiboById(userWeibo.getRetweetedId()); hasOrginWeibo = true;//from ww w . j a va 2 s .c o m weiboForwardSend.setWeibId(orginWeibo.getId()); } scheduleEventFieldGroup.setBuffered(true); if (currentBeanItem != null) { scheduleEventFieldGroup.setItemDataSource(currentBeanItem); } mainLayout = new VerticalLayout() { { setSizeFull(); setSpacing(true); setMargin(new MarginInfo(true, true, false, true)); Label descriptionField = new Label(); descriptionField.addStyleName("wb_text"); descriptionField.setContentMode(ContentMode.HTML); descriptionField.setValue( "@" + userWeibo.getUserScreenName() + ":" + mainPage.textTranslate(userWeibo.getText())); if (hasOrginWeibo) { descriptionField.setValue("@" + orginWeibo.getUserScreenName() + ":" + mainPage.textTranslate(orginWeibo.getText())); } addComponent(descriptionField); addComponent(new HorizontalLayout() {// ?,? { // setSizeFull(); // setSpacing(true); setWidth("100%"); // setSpacing(true); // setMargin(true); /*Image image = initFaceComponet(); addComponent(image); setExpandRatio(image, 1.2f); setComponentAlignment(image, Alignment.MIDDLE_LEFT);*/ // Label inputFontField = initInputFontField(); addComponent(inputFontField); // setExpandRatio(image, 1.0f); setComponentAlignment(inputFontField, Alignment.MIDDLE_RIGHT); setExpandRatio(inputFontField, 0.2f); } }); // ? weiboContentTA.setWidth("100%"); weiboContentTA.setColumns(25); weiboContentTA.focus(); addComponent(weiboContentTA); scheduleEventFieldGroup.bind(weiboContentTA, "content"); if (hasOrginWeibo) {// weiboContentTA.setValue("//@" + userWeibo.getUserScreenName() + ": " + userWeibo.getText()); } // ? addComponent(new HorizontalLayout() { { setSpacing(true); // setSizeFull(); // setMargin(true); CheckBox simuField = CommonFieldHandler.createCheckBox(""); simuField.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -7104996493482558021L; @Override public void valueChange(ValueChangeEvent event) { Object value = event.getProperty().getValue(); } }); addComponent(simuField); // setExpandRatio(image, 1.0f); setComponentAlignment(simuField, Alignment.MIDDLE_LEFT); Label commentLable = new Label(); commentLable.setContentMode(ContentMode.HTML); commentLable.setValue("? " + "" + userWeibo.getUserScreenName()); addComponent(commentLable); // setExpandRatio(image, 1.0f); setComponentAlignment(commentLable, Alignment.MIDDLE_LEFT); Image image = initFaceComponet();// addComponent(image); } }); if (hasOrginWeibo) { // ? addComponent(new HorizontalLayout() { { // setSizeFull(); setSpacing(true); // setMargin(true); CheckBox simuOriginalField = CommonFieldHandler.createCheckBox(""); simuOriginalField.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -7104996493482558021L; @Override public void valueChange(ValueChangeEvent event) { Object value = event.getProperty().getValue(); } }); addComponent(simuOriginalField); // setExpandRatio(image, 1.0f); setComponentAlignment(simuOriginalField, Alignment.MIDDLE_LEFT); Label commentLable = new Label(); commentLable.setContentMode(ContentMode.HTML); commentLable .setValue("? " + "" + orginWeibo.getUserScreenName()); addComponent(commentLable); // setExpandRatio(image, 1.0f); setComponentAlignment(commentLable, Alignment.MIDDLE_LEFT); } }); } // HorizontalLayout buttonLayout = new HorizontalLayout() { { setSpacing(true); setSizeFull(); // setMargin(true); Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK)); addComponent(okButton); setComponentAlignment(okButton, Alignment.TOP_RIGHT); okButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { BinderHandler.commit(scheduleEventFieldGroup); int ret = socialService.forwardWeibo(weiboForwardSend); if (ret == 1) { Notification.show("??", Notification.Type.HUMANIZED_MESSAGE); } close(); } }); setExpandRatio(okButton, 1.0f); Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL)); addComponent(cancleButton); setComponentAlignment(cancleButton, Alignment.TOP_RIGHT); cancleButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { // handleFormSubmit(); close(); } }); } }; addComponent(buttonLayout); setExpandRatio(buttonLayout, 1f); } }; setContent(mainLayout); setMainLayout(mainLayout); setWeiboContentTextArea(weiboContentTA); }
From source file:com.klwork.explorer.ui.custom.ToolBar.java
License:Apache License
public ToolBar() { entryMap = new HashMap<String, ToolbarEntry>(); actionButtons = new ArrayList<Button>(); additionalComponents = new ArrayList<Component>(); setWidth("100%"); setHeight(36, UNITS_PIXELS);// w ww. jav a2 s . com addStyleName(ExplorerLayout.STYLE_TOOLBAR); setSpacing(true); setMargin(ViewToolManager.currentCommMargin()); // Add label to fill excess space Label spacer = new Label(); spacer.setContentMode(Label.CONTENT_XHTML); spacer.setValue(" "); addComponent(spacer); setExpandRatio(spacer, 1.0f); }
From source file:com.klwork.explorer.ui.mainlayout.MainLayout.java
License:Apache License
protected void initFooter() { footer = new CssLayout(); footer.setWidth(100, Unit.PERCENTAGE); footer.addStyleName(ExplorerLayout.STYLE_MAIN_FOOTER); addComponent(footer);/*from w w w. ja v a2 s .co m*/ Label footerLabel = new Label(); footerLabel.setContentMode(ContentMode.HTML); footerLabel.setValue(i18nManager.getMessage(Messages.FOOTER_MESSAGE)); footerLabel.setWidth(100, Unit.PERCENTAGE); footer.addComponent(footerLabel); }
From source file:com.klwork.explorer.ui.task.HistoricTaskDetailPanel.java
License:Apache License
protected void initHeader() { GridLayout taskDetails = new GridLayout(5, 2); taskDetails.setWidth(100, UNITS_PERCENTAGE); taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK); taskDetails.setSpacing(true);//w w w.j a v a 2 s . c o m taskDetails.setMargin(new MarginInfo(false, false, true, false)); // Add image Embedded image = new Embedded(null, Images.TASK_50); taskDetails.addComponent(image, 0, 0, 0, 1); // Add task name Label nameLabel = new Label(historicTask.getName()); nameLabel.addStyleName(Reindeer.LABEL_H2); taskDetails.addComponent(nameLabel, 1, 0, 4, 0); // Add due date PrettyTimeLabel dueDateLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_DUEDATE_SHORT), historicTask.getDueDate(), i18nManager.getMessage(Messages.TASK_DUEDATE_UNKNOWN), false); dueDateLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_DUEDATE); taskDetails.addComponent(dueDateLabel, 1, 1); // Add priority Integer lowMedHighPriority = convertPriority(historicTask.getPriority()); Label priorityLabel = new Label(); switch (lowMedHighPriority) { case 1: priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_LOW)); priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_LOW); break; case 2: priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_MEDIUM)); priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_MEDIUM); break; case 3: default: priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_HIGH)); priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_HIGH); } taskDetails.addComponent(priorityLabel, 2, 1); // Add create date PrettyTimeLabel createLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_CREATED_SHORT), historicTask.getStartTime(), "", true); createLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_CREATE_TIME); taskDetails.addComponent(createLabel, 3, 1); // Add label to fill excess space Label spacer = new Label(); spacer.setContentMode(Label.CONTENT_XHTML); spacer.setValue(" "); spacer.setSizeUndefined(); taskDetails.addComponent(spacer); taskDetails.setColumnExpandRatio(1, 1.0f); taskDetails.setColumnExpandRatio(2, 1.0f); taskDetails.setColumnExpandRatio(3, 1.0f); taskDetails.setColumnExpandRatio(4, 1.0f); centralLayout.addComponent(taskDetails); }
From source file:com.lizardtech.expresszip.vaadin.FindLayersViewComponent.java
License:Apache License
public FindLayersViewComponent() { treeTable = new ExpressZipTreeTable(); popupTable = new ExpressZipTreeTable(); configureTable(treeTable);/*from w w w .ja va 2 s . co m*/ popupSelectionListener = new Property.ValueChangeListener() { private static final long serialVersionUID = 625365970493526725L; @Override public void valueChange(ValueChangeEvent event) { // the current popup selection Set<ExpressZipLayer> popupSelection = (Set<ExpressZipLayer>) event.getProperty().getValue(); // get the tree's current selection HashSet<ExpressZipLayer> treeSelection = new HashSet<ExpressZipLayer>( (Set<ExpressZipLayer>) treeTable.getValue()); // remove all items in common with popup treeSelection.removeAll(popupTable.getItemIds()); // set the treeTable selection to the union Set<ExpressZipLayer> unionSelection = new HashSet<ExpressZipLayer>(); unionSelection.addAll(popupSelection); unionSelection.addAll(treeSelection); treeTable.setValue(unionSelection); } }; popupTable.addListener(popupSelectionListener); treeTable.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 6236114836521221107L; @Override public void valueChange(ValueChangeEvent event) { Set<ExpressZipLayer> highlightedLayers = (Set<ExpressZipLayer>) event.getProperty().getValue(); for (FindLayersViewListener listener : listeners) { listener.layerHighlightedEvent(highlightedLayers); } // reset selection of popup table popupTable.removeListener(popupSelectionListener); // intersection of treeTable's selection and popupTable items Set<ExpressZipLayer> popupSelection = new HashSet<ExpressZipLayer>(); popupSelection.addAll(highlightedLayers); popupSelection.retainAll(popupTable.getItemIds()); popupTable.setValue(popupSelection); popupTable.addListener(popupSelectionListener); } }); configureTable(popupTable); filter = new Filter(this); filterButtonListener = new FilterListeners(); axisSelectedListener = new AxisSelected(); listeners = new ArrayList<FindLayersViewListener>(); btnNext = new ExpressZipButton("Next", Style.STEP); btnBack = new ExpressZipButton("Back", Style.STEP); btnAddFilter = new ExpressZipButton("Add Filter", Style.ACTION); btnAddFilter.addStyleName("filter-flow"); hshFilterButtons = new HashMap<Button, FilterObject>(); cssLayers = new CssLayout(); basemapSelector = new ComboBox(); basemapSelector.setWidth(100.0f, UNITS_PERCENTAGE); basemapSelector.setTextInputAllowed(false); basemapSelector.setImmediate(true); basemapSelector.setNullSelectionAllowed(false); basemapSelector.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -7358667131762099215L; @Override public void valueChange(ValueChangeEvent event) { ProjectedLayer l = (ProjectedLayer) basemapSelector.getValue(); boolean enableCheckbox = false; if (l instanceof WebMapServiceLayer) { for (ExpressZipLayer local : mapModel.getLocalBaseLayers()) { if (l.toString().equals(local.getName())) { enableCheckbox = true; break; } } } includeBasemap.setEnabled(enableCheckbox); if (!enableCheckbox) { includeBasemap.setValue(false); } if (mapModel.getBaseLayerTerms(l) != null && !mapModel.getBaseLayerTermsAccepted(l)) { final Window modal = new Window("Terms of Use"); modal.setModal(true); modal.setClosable(false); modal.setResizable(false); modal.getContent().setSizeUndefined(); // trick to size around content Button bOK = new ExpressZipButton("OK", Style.ACTION, new ClickListener() { private static final long serialVersionUID = -2872178665349848542L; @Override public void buttonClick(ClickEvent event) { ProjectedLayer l = (ProjectedLayer) basemapSelector.getValue(); mapModel.setBaseLayerTermsAccepted(l); for (FindLayersViewListener listener : listeners) listener.baseMapChanged(l); ((ExpressZipWindow) getApplication().getMainWindow()).removeWindow(modal); } }); Button bCancel = new ExpressZipButton("Cancel", Style.ACTION, new ClickListener() { private static final long serialVersionUID = -3044064554876422836L; @Override public void buttonClick(ClickEvent event) { basemapSelector.select(mapModel.getBaseLayers().get(0)); ((ExpressZipWindow) getApplication().getMainWindow()).removeWindow(modal); } }); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(bOK); buttons.addComponent(bCancel); Label termsText = new Label(mapModel.getBaseLayerTerms(l)); termsText.setContentMode(Label.CONTENT_XHTML); VerticalLayout vlay = new VerticalLayout(); vlay.addComponent(termsText); vlay.addComponent(buttons); vlay.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT); vlay.setWidth(400, UNITS_PIXELS); modal.getContent().addComponent(vlay); ((ExpressZipWindow) getApplication().getMainWindow()).addWindow(modal); } else { for (FindLayersViewListener listener : listeners) listener.baseMapChanged(l); } } }); includeBasemap = new CheckBox(); includeBasemap.setDescription("Include this basemap in the exported image."); includeBasemap.setWidth(64f, UNITS_PIXELS); HorizontalLayout basemapLayout = new HorizontalLayout(); basemapLayout.setWidth(100f, UNITS_PERCENTAGE); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSizeFull(); setSizeFull(); Label step = new Label("Step 1: Select Layers"); step.addStyleName("step"); layout.addComponent(step); layout.addComponent(treeTable); layout.setSpacing(true); treeTable.setSizeFull(); layout.setExpandRatio(treeTable, 1f); layout.addComponent(new Panel(BASEMAP, basemapLayout)); basemapLayout.addComponent(basemapSelector); basemapLayout.setExpandRatio(basemapSelector, 1f); basemapLayout.addComponent(includeBasemap); layout.addComponent(cssLayers); cssLayers.addComponent(btnAddFilter); HorizontalLayout backSubmitLayout = new HorizontalLayout(); backSubmitLayout.setWidth("100%"); backSubmitLayout.addComponent(btnBack); backSubmitLayout.addComponent(btnNext); backSubmitLayout.setComponentAlignment(btnBack, Alignment.BOTTOM_LEFT); backSubmitLayout.setComponentAlignment(btnNext, Alignment.BOTTOM_RIGHT); VerticalLayout navLayout = new VerticalLayout(); navLayout.addComponent(backSubmitLayout); navLayout.setSpacing(true); ThemeResource banner = new ThemeResource("img/ProgressBar1.png"); navLayout.addComponent(new Embedded(null, banner)); layout.addComponent(navLayout); layout.setComponentAlignment(navLayout, Alignment.BOTTOM_CENTER); btnNext.addListener(this); btnNext.setEnabled(false); btnBack.setEnabled(false); // always disabled btnAddFilter.addListener(this); layout.addStyleName("findlayers"); setCompositionRoot(layout); }
From source file:com.mycollab.module.file.view.components.FileDownloadWindow.java
License:Open Source License
private void constructBody() { final MVerticalLayout layout = new MVerticalLayout().withFullWidth(); CssLayout iconWrapper = new CssLayout(); final ELabel iconEmbed = ELabel.fontIcon(FileAssetsUtil.getFileIconResource(content.getName())); iconEmbed.addStyleName("icon-48px"); iconWrapper.addComponent(iconEmbed); layout.with(iconWrapper).withAlign(iconWrapper, Alignment.MIDDLE_CENTER); final GridFormLayoutHelper inforLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 4); if (content.getDescription() != null) { final Label descLbl = new Label(); if (!content.getDescription().equals("")) { descLbl.setData(content.getDescription()); } else {/*from www . j a v a2s . c o m*/ descLbl.setValue(" "); descLbl.setContentMode(ContentMode.HTML); } inforLayout.addComponent(descLbl, "Description", 0, 0); } UserService userService = AppContextUtil.getSpringBean(UserService.class); SimpleUser user = userService.findUserByUserNameInAccount(content.getCreatedUser(), AppContext.getAccountId()); if (user == null) { inforLayout.addComponent(new UserLink(AppContext.getUsername(), AppContext.getUserAvatarId(), AppContext.getUserDisplayName()), "Created by", 0, 1); } else { inforLayout.addComponent(new UserLink(user.getUsername(), user.getAvatarid(), user.getDisplayName()), "Created by", 0, 1); } final Label size = new Label(FileUtils.getVolumeDisplay(content.getSize())); inforLayout.addComponent(size, "Size", 0, 2); ELabel dateCreate = new ELabel().prettyDateTime(content.getCreated().getTime()); inforLayout.addComponent(dateCreate, "Created date", 0, 3); layout.addComponent(inforLayout.getLayout()); final MHorizontalLayout buttonControls = new MHorizontalLayout() .withMargin(new MarginInfo(true, false, true, false)); final Button downloadBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD)); List<Resource> resources = new ArrayList<>(); resources.add(content); StreamResource downloadResource = StreamDownloadResourceUtil.getStreamResourceSupportExtDrive(resources); FileDownloader fileDownloader = new FileDownloader(downloadResource); fileDownloader.extend(downloadBtn); downloadBtn.setIcon(FontAwesome.DOWNLOAD); downloadBtn.addStyleName(UIConstants.BUTTON_ACTION); final Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { close(); } }); cancelBtn.addStyleName(UIConstants.BUTTON_OPTION); buttonControls.with(cancelBtn, downloadBtn).alignAll(Alignment.TOP_RIGHT); layout.with(buttonControls).withAlign(buttonControls, Alignment.TOP_RIGHT); this.setContent(layout); }
From source file:com.mycollab.module.file.view.FileDownloadWindow.java
License:Open Source License
private void constructBody() { final MVerticalLayout layout = new MVerticalLayout().withFullWidth(); CssLayout iconWrapper = new CssLayout(); final ELabel iconEmbed = ELabel.fontIcon(FileAssetsUtil.getFileIconResource(content.getName())); iconEmbed.addStyleName("icon-48px"); iconWrapper.addComponent(iconEmbed); layout.with(iconWrapper).withAlign(iconWrapper, Alignment.MIDDLE_CENTER); final GridFormLayoutHelper inforLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 4); if (content.getDescription() != null) { final Label descLbl = new Label(); if (!content.getDescription().equals("")) { descLbl.setData(content.getDescription()); } else {/*from ww w . ja v a2 s .c o m*/ descLbl.setValue(" "); descLbl.setContentMode(ContentMode.HTML); } inforLayout.addComponent(descLbl, UserUIContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0, 0); } UserService userService = AppContextUtil.getSpringBean(UserService.class); SimpleUser user = userService.findUserByUserNameInAccount(content.getCreatedUser(), MyCollabUI.getAccountId()); if (user == null) { inforLayout.addComponent( new UserLink(UserUIContext.getUsername(), UserUIContext.getUserAvatarId(), UserUIContext.getUserDisplayName()), UserUIContext.getMessage(GenericI18Enum.OPT_CREATED_BY), 0, 1); } else { inforLayout.addComponent(new UserLink(user.getUsername(), user.getAvatarid(), user.getDisplayName()), UserUIContext.getMessage(GenericI18Enum.OPT_CREATED_BY), 0, 1); } final Label size = new Label(FileUtils.getVolumeDisplay(content.getSize())); inforLayout.addComponent(size, UserUIContext.getMessage(FileI18nEnum.OPT_SIZE), 0, 2); ELabel dateCreate = new ELabel().prettyDateTime(content.getCreated().getTime()); inforLayout.addComponent(dateCreate, UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME), 0, 3); layout.addComponent(inforLayout.getLayout()); MButton downloadBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD)) .withIcon(FontAwesome.DOWNLOAD).withStyleName(WebThemes.BUTTON_ACTION); List<Resource> resources = new ArrayList<>(); resources.add(content); StreamResource downloadResource = StreamDownloadResourceUtil.getStreamResourceSupportExtDrive(resources); FileDownloader fileDownloader = new FileDownloader(downloadResource); fileDownloader.extend(downloadBtn); MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL), clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION); final MHorizontalLayout buttonControls = new MHorizontalLayout(cancelBtn, downloadBtn); layout.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT); this.setContent(layout); }