List of usage examples for com.vaadin.ui Alignment MIDDLE_CENTER
Alignment MIDDLE_CENTER
To view the source code for com.vaadin.ui Alignment MIDDLE_CENTER.
Click Source Link
From source file:de.uni_tuebingen.qbic.qbicmainportlet.MultiscaleComponent.java
License:Open Source License
void buildEmptyComments() { // add comments VerticalLayout addComment = new VerticalLayout(); addComment.setMargin(true);//from w w w . j av a 2 s. c o m addComment.setWidth(100, Unit.PERCENTAGE); final TextArea comments = new TextArea(); comments.setInputPrompt("Write your comment here..."); comments.setWidth(100, Unit.PERCENTAGE); comments.setRows(2); Button commentsOk = new Button("Add Comment"); commentsOk.addStyleName(ValoTheme.BUTTON_FRIENDLY); commentsOk.addClickListener(new ClickListener() { /** * */ private static final long serialVersionUID = -5369241494545155677L; public void buttonClick(ClickEvent event) { if ("".equals(comments.getValue())) return; String newComment = comments.getValue(); // reset comments comments.setValue(""); // use some date format Date dNow = new Date(); SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); Note note = new Note(); note.setComment(newComment); note.setUsername(controller.getUser()); note.setTime(ft.format(dNow)); // show it now // pastcomments.getContainerDataSource().addItem(note); notes.add(note); // TODO write back Label commentsLabel = new Label(translateComments(notes), ContentMode.HTML); commentsPanel.setContent(commentsLabel); // write back to openbis if (!controller.addNote(note)) { Notification.show("Could not add comment to sample. How did you do that?"); } } }); HorizontalLayout inputPrompt = new HorizontalLayout(); inputPrompt.addComponent(comments); inputPrompt.addComponent(commentsOk); inputPrompt.setWidth(50, Unit.PERCENTAGE); inputPrompt.setComponentAlignment(commentsOk, Alignment.TOP_RIGHT); inputPrompt.setExpandRatio(comments, 1.0f); // addComment.addComponent(comments); // addComment.addComponent(commentsOk); addComment.addComponent(commentsPanel); addComment.addComponent(inputPrompt); // addComment.setComponentAlignment(comments, Alignment.TOP_CENTER); // addComment.setComponentAlignment(commentsOk, Alignment.MIDDLE_CENTER); addComment.setComponentAlignment(commentsPanel, Alignment.TOP_CENTER); addComment.setComponentAlignment(inputPrompt, Alignment.MIDDLE_CENTER); mainlayout.addComponent(addComment); // mainlayout.addComponent(pastcomments); Label commentsLabel = new Label("No comments added so far.", ContentMode.HTML); commentsPanel.setContent(commentsLabel); // mainlayout.addComponent(commentsPanel); // mainlayout.setComponentAlignment(commentsPanel, // Alignment.TOP_CENTER); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientStatusComponent.java
License:Open Source License
public void updateUI(final ProjectBean currentBean) { BeanItemContainer<ExperimentStatusBean> experimentstatusBeans = datahandler .computeIvacPatientStatus(currentBean); int finishedExperiments = 0; status.removeAllComponents();//ww w. j a v a 2s .c o m status.setWidth(100.0f, Unit.PERCENTAGE); // Generate button caption column final GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(experimentstatusBeans); gpc.addGeneratedProperty("started", new PropertyValueGenerator<String>() { @Override public Class<String> getType() { return String.class; } @Override public String getValue(Item item, Object itemId, Object propertyId) { String status = null; if ((double) item.getItemProperty("status").getValue() > 0.0) { status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.CHECK.getFontFamily() + ";color:" + "#2dd085" + "\">&#x" + Integer.toHexString(FontAwesome.CHECK.getCodepoint()) + ";</span>"; } else { status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.TIMES.getFontFamily() + ";color:" + "#f54993" + "\">&#x" + Integer.toHexString(FontAwesome.TIMES.getCodepoint()) + ";</span>"; } return status.toString(); } }); gpc.removeContainerProperty("identifier"); experiments.setContainerDataSource(gpc); // experiments.setHeaderVisible(false); // experiments.setHeightMode(HeightMode.ROW); experiments.setHeightByRows(gpc.size()); experiments.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS); experiments.getColumn("status").setRenderer(new ProgressBarRenderer()); // experiments.setColumnOrder("started", "code", "description", "status", "download", // "runWorkflow"); experiments.setColumnOrder("started", "code", "description", "status", "workflow"); experiments.getColumn("workflow").setRenderer(new ButtonRenderer(new RendererClickListener() { @Override public void click(RendererClickEvent event) { ExperimentStatusBean esb = (ExperimentStatusBean) event.getItemId(); TabSheet parent = (TabSheet) getParent(); PatientView pv = (PatientView) parent.getParent().getParent(); WorkflowComponent wp = pv.getWorkflowComponent(); // TODO WATCH OUT NUMBER OF WORKFLOW TAB IS HARDCODED AT THE MOMENT, NO BETTER SOLUTION // FOUND SO FAR, e.g. get Tab by Name ? // TODO idea get description of item to navigate to the correct workflow ?! if (esb.getDescription().equals("Barcode Generation")) { ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(currentBean.getId()); //TODO navigate to barcode dragon rawwwr // message.add(BarcodeView.navigateToLabel); // state.notifyObservers(message); } else if (esb.getDescription().equals("Variant Annotation")) { /* * ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType"); * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&"); * sb.append("experiment="); sb.append("Q_WF_NGS_VARIANT_ANNOTATION"); * message.add(sb.toString()); message.add(WorkflowView.navigateToLabel); * state.notifyObservers(message); */ Map<String, String> args = new HashMap<String, String>(); args.put("id", currentBean.getId()); args.put("type", "workflowExperimentType"); args.put("experiment", "Q_WF_NGS_VARIANT_ANNOTATION"); parent.setSelectedTab(9); wp.update(args); } else if (esb.getDescription().equals("Epitope Prediction")) { /* * ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType"); * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&"); * sb.append("experiment="); sb.append("Q_WF_NGS_EPITOPE_PREDICTION"); * message.add(sb.toString()); message.add(WorkflowView.navigateToLabel); * state.notifyObservers(message); */ Map<String, String> args = new HashMap<String, String>(); args.put("id", currentBean.getId()); args.put("type", "workflowExperimentType"); args.put("experiment", "Q_WF_NGS_EPITOPE_PREDICTION"); parent.setSelectedTab(9); wp.update(args); } else if (esb.getDescription().equals("HLA Typing")) { /* * ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); * StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType"); * sb.append("&"); sb.append("id="); sb.append(currentBean.getId()); sb.append("&"); * sb.append("experiment="); sb.append("Q_WF_NGS_HLATYPING"); message.add(sb.toString()); * message.add(WorkflowView.navigateToLabel); state.notifyObservers(message); */ Map<String, String> args = new HashMap<String, String>(); args.put("id", currentBean.getId()); args.put("type", "workflowExperimentType"); args.put("experiment", "Q_WF_NGS_HLATYPING"); parent.setSelectedTab(9); wp.update(args); } else { Notification notif = new Notification("Workflow not (yet) available.", Type.TRAY_NOTIFICATION); // Customize it notif.setDelayMsec(60000); notif.setPosition(Position.MIDDLE_CENTER); // Show it in the page notif.show(Page.getCurrent()); } } })); experiments.getColumn("started").setRenderer(new HtmlRenderer()); ProgressBar progressBar = new ProgressBar(); progressBar.setCaption("Overall Progress"); progressBar.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS); progressBar.setStyleName("patientprogress"); status.addComponent(progressBar); status.addComponent(experiments); status.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER); status.setComponentAlignment(experiments, Alignment.MIDDLE_CENTER); /** * Defined Experiments for iVac - Barcodes available -> done with project creation (done) - * Sequencing done (Status Q_NGS_MEASUREMENT) - Variants annotated (Status * Q_NGS_VARIANT_CALLING) - HLA Typing done (STATUS Q_NGS_WF_HLA_TYPING) - Epitope Prediction * done (STATUS Q_WF_NGS_EPITOPE_PREDICTION) */ for (Iterator i = experimentstatusBeans.getItemIds().iterator(); i.hasNext();) { ExperimentStatusBean statusBean = (ExperimentStatusBean) i.next(); finishedExperiments += statusBean.getStatus(); // statusBean.setDownload("Download"); statusBean.setWorkflow("Run"); } progressBar.setValue((float) finishedExperiments / experimentstatusBeans.size()); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientView.java
License:Open Source License
void updateContentMemberSection() { membersSection.removeAllComponents(); Component memberComponent = getMembersComponent(); membersSection.addComponent(new Label( "The following people are members of this project. If you would like to contact them, click on their name.", Label.CONTENT_PREFORMATTED)); membersSection.addComponent(memberComponent); membersSection.setComponentAlignment(memberComponent, Alignment.MIDDLE_CENTER); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientView.java
License:Open Source License
void updateProjectStatus() { BeanItemContainer<ExperimentStatusBean> experimentstatusBeans = datahandler .computeIvacPatientStatus(currentBean); int finishedExperiments = 0; status.removeAllComponents();/*from ww w. ja v a 2 s .co m*/ status.setWidth(100.0f, Unit.PERCENTAGE); // Generate button caption column final GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(experimentstatusBeans); gpc.addGeneratedProperty("started", new PropertyValueGenerator<String>() { @Override public Class<String> getType() { return String.class; } @Override public String getValue(Item item, Object itemId, Object propertyId) { String status = null; if ((double) item.getItemProperty("status").getValue() > 0.0) { status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.CHECK.getFontFamily() + ";color:" + "#2dd085" + "\">&#x" + Integer.toHexString(FontAwesome.CHECK.getCodepoint()) + ";</span>"; } else { status = "<span class=\"v-icon\" style=\"font-family: " + FontAwesome.TIMES.getFontFamily() + ";color:" + "#f54993" + "\">&#x" + Integer.toHexString(FontAwesome.TIMES.getCodepoint()) + ";</span>"; } return status.toString(); } }); gpc.removeContainerProperty("identifier"); experiments.setContainerDataSource(gpc); // experiments.setHeaderVisible(false); experiments.setHeightMode(HeightMode.ROW); experiments.setHeightByRows(gpc.size()); experiments.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS); experiments.getColumn("status").setRenderer(new ProgressBarRenderer()); experiments.setColumnOrder("started", "code", "description", "status", "download", "runWorkflow"); ButtonRenderer downloadRenderer = new ButtonRenderer(new RendererClickListener() { @Override public void click(RendererClickEvent event) { ExperimentStatusBean esb = (ExperimentStatusBean) event.getItemId(); if (esb.getDescription().equals("Barcode Generation")) { new Notification("Download of Barcodes not available.", "<br/>Please create barcodes by clicking 'Run'.", Type.WARNING_MESSAGE, true) .show(Page.getCurrent()); } else if (esb.getIdentifier() == null || esb.getIdentifier().isEmpty()) { new Notification("No data available for download.", "<br/>Please do the analysis by clicking 'Run' first.", Type.WARNING_MESSAGE, true) .show(Page.getCurrent()); } else { ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); StringBuilder sb = new StringBuilder("type="); sb.append("experiment"); sb.append("&"); sb.append("id="); // sb.append(currentBean.getId()); sb.append(esb.getIdentifier()); message.add(sb.toString()); message.add(DatasetView.navigateToLabel); state.notifyObservers(message); } } }); experiments.getColumn("download").setRenderer(downloadRenderer); experiments.getColumn("runWorkflow").setRenderer(new ButtonRenderer(new RendererClickListener() { @Override public void click(RendererClickEvent event) { ExperimentStatusBean esb = (ExperimentStatusBean) event.getItemId(); // TODO idea get description of item to navigate to the correct workflow ?! if (esb.getDescription().equals("Barcode Generation")) { ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(currentBean.getId()); // TODO link to barcode dragon // message.add(BarcodeView.navigateToLabel); // state.notifyObservers(message); } else { ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); StringBuilder sb = new StringBuilder("type="); sb.append("workflowExperimentType"); sb.append("&"); sb.append("id="); sb.append("Q_WF_MS_PEPTIDEID"); sb.append("&"); sb.append("project="); sb.append(currentBean.getId()); message.add(sb.toString()); message.add(WorkflowView.navigateToLabel); state.notifyObservers(message); } } })); experiments.getColumn("started").setRenderer(new HtmlRenderer()); ProgressBar progressBar = new ProgressBar(); progressBar.setCaption("Overall Progress"); progressBar.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.6f, Unit.PIXELS); progressBar.setStyleName("patientprogress"); status.addComponent(progressBar); status.addComponent(experiments); status.setComponentAlignment(progressBar, Alignment.MIDDLE_CENTER); status.setComponentAlignment(experiments, Alignment.MIDDLE_CENTER); /** * Defined Experiments for iVac - Barcodes available -> done with project creation (done) - * Sequencing done (Status Q_NGS_MEASUREMENT) - Variants annotated (Status * Q_NGS_VARIANT_CALLING) - HLA Typing done (STATUS Q_NGS_WF_HLA_TYPING) - Epitope Prediction * done (STATUS Q_WF_NGS_EPITOPE_PREDICTION) */ for (Iterator i = experimentstatusBeans.getItemIds().iterator(); i.hasNext();) { ExperimentStatusBean statusBean = (ExperimentStatusBean) i.next(); // HorizontalLayout experimentStatusRow = new HorizontalLayout(); // experimentStatusRow.setSpacing(true); finishedExperiments += statusBean.getStatus(); // statusBean.setDownload("Download"); statusBean.setWorkflow("Run"); /* * if ((Integer) pairs.getValue() == 0) { Label statusLabel = new Label(pairs.getKey() + ": " * + FontAwesome.TIMES.getHtml(), ContentMode.HTML); statusLabel.addStyleName("redicon"); * experimentStatusRow.addComponent(statusLabel); * statusContent.addComponent(experimentStatusRow); } * * else { * * Label statusLabel = new Label(pairs.getKey() + ": " + FontAwesome.CHECK.getHtml(), * ContentMode.HTML); statusLabel.addStyleName("greenicon"); * experimentStatusRow.addComponent(statusLabel); * statusContent.addComponent(experimentStatusRow); * * finishedExperiments += (Integer) pairs.getValue(); } * experimentStatusRow.addComponent(runWorkflow); * * } */ } progressBar.setValue((float) finishedExperiments / experimentstatusBeans.size()); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientView.java
License:Open Source License
public void loadGraph() { // LOGGER.debug(String.valueOf(graphSectionContent.getComponentCount() == 0)); if (graphSectionContent.getComponentCount() > 0) LOGGER.debug(String.valueOf(graphSectionContent.getComponent(0) instanceof Image)); if (graphSectionContent.getComponentCount() == 0 || !(graphSectionContent.getComponent(0) instanceof Image)) { ProgressBar progress = new ProgressBar(); progress.setIndeterminate(true); Label info = new Label( "Computing the project graph can take several seconds on big projects. Please be patient."); info.setStyleName(ValoTheme.LABEL_SUCCESS); graphSectionContent.removeAllComponents(); // graphSectionContent.addComponent(info); graphSectionContent.addComponent(progress); // graphSectionContent.setComponentAlignment(info, Alignment.MIDDLE_CENTER); graphSectionContent.setComponentAlignment(progress, Alignment.MIDDLE_CENTER); Worker worker = new Worker(getCurrent()); worker.start();//www . j a v a 2s . c o m UI.getCurrent().setPollInterval(500); } }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientView.java
License:Open Source License
void updateContentGraph() { Resource resource = getGraphResourceAndParseNewGraph(); if (resource != null) { graphSectionContent.removeAllComponents(); Image graphImage = new Image("", resource); graphSectionContent.addComponent(graphImage); graphSectionContent.setComponentAlignment(graphImage, Alignment.MIDDLE_CENTER); } else {/*from w w w . j a v a 2s . co m*/ Label error = new Label("Project Graph can not be computed at that time for this project"); error.setStyleName(ValoTheme.LABEL_FAILURE); graphSectionContent.removeAllComponents(); graphSectionContent.addComponent(error); graphSectionContent.setComponentAlignment(error, Alignment.MIDDLE_CENTER); LOGGER.error(String.format("%s: %s", error.getValue(), currentBean.getId())); } }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ProjectView.java
License:Open Source License
/** * //from ww w. java 2 s . c o m */ public void loadGraph() { if (graphSectionContent.getComponentCount() == 0 || !(graphSectionContent.getComponent(0) instanceof Image)) { ProgressBar progress = new ProgressBar(); progress.setIndeterminate(true); Label info = new Label( "Computing the project graph can take several seconds on big projects. Please be patient."); info.setStyleName(ValoTheme.LABEL_SUCCESS); graphSectionContent.removeAllComponents(); graphSectionContent.addComponent(progress); graphSectionContent.setComponentAlignment(progress, Alignment.MIDDLE_CENTER); Worker worker = new Worker(getCurrent()); worker.start(); UI.getCurrent().setPollInterval(500); } }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ProjectView.java
License:Open Source License
/** * //w ww . j av a 2 s . c o m */ void updateContentGraph() { Resource resource = getGraphResourceAndParseNewGraph(); if (resource != null) { graphSectionContent.removeAllComponents(); Image graphImage = new Image("", resource); graphSectionContent.addComponent(graphImage); graphSectionContent.setComponentAlignment(graphImage, Alignment.MIDDLE_CENTER); } else { Label error = new Label("Project Graph can not be computed at that time for this project"); error.setStyleName(ValoTheme.LABEL_FAILURE); graphSectionContent.removeAllComponents(); graphSectionContent.addComponent(error); graphSectionContent.setComponentAlignment(error, Alignment.MIDDLE_CENTER); LOGGER.error(String.format("%s: %s", error.getValue(), currentBean.getId())); } }
From source file:dhbw.clippinggorilla.userinterface.views.ArchiveView.java
public Component createClippingRow(Article a) { Image imageNewsImage = new Image(); String url = a.getUrlToImage(); if (url == null || url.isEmpty()) { url = a.getSourceAsSource().getLogo().toExternalForm(); }/*from ww w . j a v a2 s . com*/ imageNewsImage.setSource(new ExternalResource(url)); imageNewsImage.addStyleName("articleimage"); VerticalLayout layoutNewsImage = new VerticalLayout(imageNewsImage); layoutNewsImage.setMargin(false); layoutNewsImage.setSpacing(false); layoutNewsImage.setWidth("200px"); layoutNewsImage.setHeight("150px"); layoutNewsImage.setComponentAlignment(imageNewsImage, Alignment.MIDDLE_CENTER); Label labelHeadLine = new Label(a.getTitle(), ContentMode.HTML); labelHeadLine.addStyleName(ValoTheme.LABEL_H2); labelHeadLine.addStyleName(ValoTheme.LABEL_NO_MARGIN); labelHeadLine.setWidth("100%"); Label labelDescription = new Label(a.getDescription(), ContentMode.HTML); labelDescription.setWidth("100%"); Image imageSource = new Image(); Source s = a.getSourceAsSource(); URL logo; if (s != null) { logo = s.getLogo(); } else { Log.error("Source is null: " + a.getSource()); return new Label("INTERNAL ERROR"); } if (logo != null) { imageSource.setSource(new ExternalResource(logo)); } else { Log.error("Sourcelogo is null: " + s.getName()); } imageSource.setHeight("30px"); Label labelSource = new Label(a.getSourceAsSource().getName()); labelSource.addStyleName(ValoTheme.LABEL_SMALL); LocalDateTime time = a.getPublishedAtAsLocalDateTime(); DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG); formatter.withZone(ZoneId.of("Europe/Berlin")); Label labelDate = new Label(time.format(formatter)); labelDate.addStyleName(ValoTheme.LABEL_SMALL); Label labelAuthor = new Label(); labelAuthor.addStyleName(ValoTheme.LABEL_SMALL); labelAuthor.setWidth("100%"); if (a.getAuthor() != null && !a.getAuthor().isEmpty()) { labelAuthor.setValue(a.getAuthor()); } Button openWebsite = new Button(VaadinIcons.EXTERNAL_LINK); openWebsite.addClickListener(e -> UI.getCurrent().getPage().open(a.getUrl(), "_blank", false)); HorizontalLayout layoutArticleOptions = new HorizontalLayout(); layoutArticleOptions.setWidth("100%"); layoutArticleOptions.addComponents(imageSource, labelSource, labelDate, labelAuthor, openWebsite); layoutArticleOptions.setComponentAlignment(imageSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelDate, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelAuthor, Alignment.MIDDLE_LEFT); layoutArticleOptions.setComponentAlignment(openWebsite, Alignment.MIDDLE_CENTER); layoutArticleOptions.setExpandRatio(labelAuthor, 5); VerticalLayout layoutNewsText = new VerticalLayout(labelHeadLine, labelDescription, layoutArticleOptions); layoutNewsText.setMargin(false); layoutNewsText.setWidth("100%"); HorizontalLayout layoutClipping = new HorizontalLayout(); layoutClipping.setWidth("100%"); layoutClipping.setMargin(true); layoutClipping.addComponents(layoutNewsImage, layoutNewsText); layoutClipping.setComponentAlignment(layoutNewsImage, Alignment.MIDDLE_CENTER); layoutClipping.setExpandRatio(layoutNewsText, 5); layoutClipping.addStyleName(ValoTheme.LAYOUT_CARD); layoutClipping.addStyleName("tags"); return layoutClipping; }
From source file:dhbw.clippinggorilla.userinterface.views.ClippingView.java
public Component createClippingRow(Article a) { Image imageNewsImage = new Image(); String url = a.getUrlToImage(); if (url == null || url.isEmpty()) { url = a.getSourceAsSource().getLogo().toExternalForm(); }/* w w w. ja v a2 s . co m*/ imageNewsImage.setSource(new ExternalResource(url)); imageNewsImage.addStyleName("articleimage"); VerticalLayout layoutNewsImage = new VerticalLayout(imageNewsImage); layoutNewsImage.setMargin(false); layoutNewsImage.setSpacing(false); layoutNewsImage.setWidth("200px"); layoutNewsImage.setHeight("150px"); layoutNewsImage.setComponentAlignment(imageNewsImage, Alignment.MIDDLE_CENTER); Label labelHeadLine = new Label(a.getTitle(), ContentMode.HTML); labelHeadLine.addStyleName(ValoTheme.LABEL_H2); labelHeadLine.addStyleName(ValoTheme.LABEL_NO_MARGIN); labelHeadLine.setWidth("100%"); Label labelDescription = new Label(a.getDescription(), ContentMode.HTML); labelDescription.setWidth("100%"); Image imageSource = new Image(); Source s = a.getSourceAsSource(); URL logo = null; if (s != null) { logo = s.getLogo(); } else { Log.error("Source is null: " + a.getSource()); return new Label("INTERNAL ERROR"); } if (logo != null) { imageSource.setSource(new ExternalResource(logo)); } else { Log.error("Sourcelogo is null: " + s.getName()); } imageSource.setHeight("30px"); Label labelSource = new Label(a.getSourceAsSource().getName()); labelSource.addStyleName(ValoTheme.LABEL_SMALL); LocalDateTime time = a.getPublishedAtAsLocalDateTime(); DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG); formatter.withZone(ZoneId.of("Europe/Berlin")); Label labelDate = new Label(time.format(formatter)); labelDate.addStyleName(ValoTheme.LABEL_SMALL); Label labelAuthor = new Label(); labelAuthor.addStyleName(ValoTheme.LABEL_SMALL); labelAuthor.setWidth("100%"); if (a.getAuthor() != null && !a.getAuthor().isEmpty()) { labelAuthor.setValue(a.getAuthor()); } Button openWebsite = new Button(VaadinIcons.EXTERNAL_LINK); openWebsite.addClickListener(e -> UI.getCurrent().getPage().open(a.getUrl(), "_blank", false)); HorizontalLayout layoutArticleOptions = new HorizontalLayout(); layoutArticleOptions.setWidth("100%"); layoutArticleOptions.addComponents(imageSource, labelSource, labelDate, labelAuthor, openWebsite); layoutArticleOptions.setComponentAlignment(imageSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelSource, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelDate, Alignment.MIDDLE_CENTER); layoutArticleOptions.setComponentAlignment(labelAuthor, Alignment.MIDDLE_LEFT); layoutArticleOptions.setComponentAlignment(openWebsite, Alignment.MIDDLE_CENTER); layoutArticleOptions.setExpandRatio(labelAuthor, 5); VerticalLayout layoutNewsText = new VerticalLayout(labelHeadLine, labelDescription, layoutArticleOptions); layoutNewsText.setMargin(false); layoutNewsText.setWidth("100%"); HorizontalLayout layoutClipping = new HorizontalLayout(); layoutClipping.setWidth("100%"); layoutClipping.setMargin(true); layoutClipping.addComponents(layoutNewsImage, layoutNewsText); layoutClipping.setComponentAlignment(layoutNewsImage, Alignment.MIDDLE_CENTER); layoutClipping.setExpandRatio(layoutNewsText, 5); layoutClipping.addStyleName(ValoTheme.LAYOUT_CARD); layoutClipping.addStyleName("tags"); return layoutClipping; }