List of usage examples for com.vaadin.ui Label setDescription
public void setDescription(String description)
From source file:module.pandabox.presentation.PandaBox.java
License:Open Source License
private Layout getLabelPreviews() { Layout grid = getPreviewLayout("Labels"); Label label = new Label("<h4>Paragraph Header</h4>Plain text, lorem ipsum dolor sit amet consectetur amit.", Label.CONTENT_XHTML); label.setWidth("200px"); grid.addComponent(label);//from w w w . j a v a2 s . c o m label = new Label("Big plain text, lorem ipsum dolor sit amet consectetur amit."); label.setWidth("200px"); label.setStyleName("big"); grid.addComponent(label); label = new Label("Small plain text, lorem ipsum dolor sit amet consectetur amit."); label.setWidth("200px"); label.setStyleName("small"); grid.addComponent(label); label = new Label("Tiny plain text, lorem ipsum dolor sit amet consectetur amit."); label.setWidth("200px"); label.setStyleName("tiny"); grid.addComponent(label); label = new Label("<h1>Top Level Header</h1>", Label.CONTENT_XHTML); label.setSizeUndefined(); grid.addComponent(label); label.setDescription( "Label.addStyleName(\"h1\");<br>or<br>new Label(\"<h1>Top Level Header</h1>\", Label.CONTENT_XHTML);"); label = new Label("<h2>Second Header</h2>", Label.CONTENT_XHTML); label.setSizeUndefined(); grid.addComponent(label); label.setDescription( "Label.addStyleName(\"h2\");<br>or<br>new Label(\"<h2>Second Header</h2>\", Label.CONTENT_XHTML);"); label = new Label("<h3>Subtitle</h3>", Label.CONTENT_XHTML); label.setSizeUndefined(); grid.addComponent(label); label.setDescription( "Label.addStyleName(\"h3\");<br>or<br>new Label(\"<h3>Subtitle</h3>\", Label.CONTENT_XHTML);"); label = new Label("<h4>Paragraph Header</h4>Plain text, lorem ipsum dolor sit amet consectetur amit.", Label.CONTENT_XHTML); label.setWidth("200px"); label.setStyleName("color"); grid.addComponent(label); label = new Label("Big plain text, lorem ipsum dolor sit amet consectetur amit."); label.setWidth("200px"); label.setStyleName("big color"); grid.addComponent(label); label = new Label("Small plain text, lorem ipsum dolor sit amet consectetur amit."); label.setWidth("200px"); label.setStyleName("small color"); grid.addComponent(label); label = new Label("Tiny plain text, lorem ipsum dolor sit amet consectetur amit."); label.setWidth("200px"); label.setStyleName("tiny color"); grid.addComponent(label); label = new Label("Top Level Header"); label.setSizeUndefined(); label.setStyleName("h1 color"); grid.addComponent(label); label = new Label("Second Header"); label.setSizeUndefined(); label.setStyleName("h2 color"); grid.addComponent(label); label = new Label("Subtitle"); label.setSizeUndefined(); label.setStyleName("h3 color"); grid.addComponent(label); label = new Label("Warning text, lorem ipsum dolor sit."); label.setStyleName("warning"); grid.addComponent(label); label = new Label("Error text, lorem ipsum dolor."); label.setStyleName("error"); grid.addComponent(label); label = new Label("Big warning text"); label.setStyleName("big warning"); grid.addComponent(label); label = new Label("Big error text"); label.setStyleName("big error"); grid.addComponent(label); label = new Label("Loading text..."); label.setStyleName("h3 loading"); grid.addComponent(label); label = new Label("1"); label.setSizeUndefined(); label.addStyleName("numeral"); label.addStyleName("green"); grid.addComponent(label); label = new Label("2"); label.setSizeUndefined(); label.addStyleName("numeral"); label.addStyleName("yellow"); grid.addComponent(label); label = new Label("3"); label.setSizeUndefined(); label.addStyleName("numeral"); label.addStyleName("blue"); grid.addComponent(label); label = new Label("1"); label.setSizeUndefined(); label.addStyleName("numeral"); label.addStyleName("green"); label.addStyleName("big"); grid.addComponent(label); label = new Label("2"); label.setSizeUndefined(); label.addStyleName("numeral"); label.addStyleName("yellow"); label.addStyleName("big"); grid.addComponent(label); label = new Label("3"); label.setSizeUndefined(); label.addStyleName("numeral"); label.addStyleName("blue"); label.addStyleName("big"); grid.addComponent(label); return grid; }
From source file:nl.amc.biolab.nsg.display.component.ProcessingStatusForm.java
License:Open Source License
private VerticalLayout makeSubmissionStatusLayout(List<SubmissionIO> submissionIOinputs, final Processing processing, final VaadinTestApplication app) { StringBuffer statusValue = new StringBuffer(); VerticalLayout statusLayout = new VerticalLayout(); statusLayout.setWidth("100%"); final Submission submission = submissionIOinputs.get(0).getSubmission(); // There is at least one input! //get status information String submissionStatus = submission.getLastStatus().getValue(); logger.info("Status is " + submissionStatus); Date lastUpdateDate = processing.getDate(); final Iterator<Status> iterator = submission.getStatuses().iterator(); Status st = null;/*from ww w .java2 s .c o m*/ while (iterator.hasNext()) { st = iterator.next(); } if (st != null) { lastUpdateDate = st.getTimestamp(); } String submissionUpdateDate = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(lastUpdateDate); // when the status is last updated nl.amc.biolab.datamodel.objects.Error error = null; List<nl.amc.biolab.datamodel.objects.Error> errors = submissionIOinputs.get(0).getSubmission().getErrors(); if (submissionIOinputs.get(0).getSubmission().getErrors() != null && submissionIOinputs.get(0).getSubmission().getErrors().size() > 0) { error = errors.get(errors.size() - 1); } if (error != null) { logger.info("Error message is " + error.getMessage()); } statusValue.append(getStatus(submissionStatus, error, userDataService.isNSGAdmin())).append("\n"); logger.info(statusValue); createSubmissionButtons(app, submissionIOinputs.get(0), error); Label status = new Label(statusValue.toString(), Label.CONTENT_XHTML); status.setDescription("Last updated on " + submissionUpdateDate); status.setWidth("80%"); String aborted = "Aborted"; if (aborted.equals(submissionStatus)) { statusLayout.addComponent(status); statusLayout.addComponent(remarksButton); } else { statusLayout.addComponent(status); } return statusLayout; }
From source file:org.agocontrol.site.viewlet.dashboard.BuildingControlPanel.java
License:Apache License
/** * Default constructor./*from ww w .j av a2 s. c o m*/ */ public BuildingControlPanel() { site = ((AgoControlSiteUI) UI.getCurrent()).getSite(); siteContext = site.getSiteContext(); entityManager = siteContext.getObject(EntityManager.class); layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); layout.setSizeFull(); layout.setStyleName(Reindeer.LAYOUT_WHITE); final Label title = new Label("Control Panel"); title.setIcon(getSite().getIcon("inventory")); title.setStyleName(Reindeer.LABEL_H2); layout.addComponent(title); layout.setExpandRatio(title, 0); elementLayout = new VerticalLayout(); elementLayout.setSpacing(true); elementLayout.setMargin(false); layout.addComponent(elementLayout); layout.setExpandRatio(elementLayout, 1); roomIcon = site.getIcon("room"); deviceIcon = site.getIcon("device"); temperatureIcon = site.getIcon("temperature"); brightnessIcon = site.getIcon("brightness"); humidityIcon = site.getIcon("humidity"); eventIcon = site.getIcon("event"); setCompositionRoot(layout); // the Refresher polls automatically final Refresher refresher = new Refresher(); refresher.setRefreshInterval(200); refresher.addListener(new Refresher.RefreshListener() { @Override public void refresh(final Refresher refresher) { while (!recordsQueue.isEmpty()) { final List<Record> records = recordsQueue.remove(); if (records.size() > 0) { final Record record = records.get(0); final RecordSet recordSet = record.getRecordSet(); final Element element = recordSet.getElement(); final GridLayout recordsLayout = recordsLayouts.get(element.getElementId()); if (recordsLayout == null) { continue; } final int columnIndex = recordSet.getType().ordinal(); final int rowIndex = 0; if (recordsLayout.getComponent(columnIndex, rowIndex) != null) { continue; } final VerticalLayout recordLayout = new VerticalLayout(); recordLayout.setSpacing(true); final Resource recordIcon; switch (recordSet.getType()) { case TEMPERATURE: recordIcon = temperatureIcon; break; case BRIGHTNESS: recordIcon = brightnessIcon; break; case HUMIDITY: recordIcon = humidityIcon; break; default: recordIcon = eventIcon; break; } final Embedded embedded = new Embedded(null, recordIcon); recordLayout.addComponent(embedded); recordLayout.setExpandRatio(embedded, 0.1f); embedded.setWidth(32, Unit.PIXELS); embedded.setHeight(32, Unit.PIXELS); final Label label = new Label(); recordLayout.addComponent(label); recordLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT); final String recordUnit = recordSet.getUnit(); final String displayUnit = DisplayValueConversionUtil.getDisplayUnit(recordSet.getType(), recordUnit); final double displayValue = DisplayValueConversionUtil.convertValue(recordSet.getType(), recordUnit, displayUnit, record.getValue()); final String displayValueString = DisplayValueConversionUtil.formatDouble(displayValue); label.setValue(displayValueString + " " + displayUnit); label.setDescription(record.getCreated().toString()); recordsLayout.addComponent(recordLayout, columnIndex, rowIndex); } } } }); addExtension(refresher); }
From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadConfirmationWindow.java
License:Open Source License
/** * Warning icon is displayed, if an artifact exists with same provided file * name. Error icon is displayed, if file name entered is duplicate. * * @param warningIconLabel//www . j a va 2s .c o m * warning/error label * @param fileName * provided file name * @param itemId * item id of the current row */ private void setWarningIcon(final Label warningIconLabel, final String fileName, final Object itemId) { final Item item = uploadDetailsTable.getItem(itemId); if (StringUtils.hasText(fileName)) { final String fileNameTrimmed = StringUtils.trimWhitespace(fileName); final Long baseSwId = (Long) item.getItemProperty(BASE_SOFTWARE_ID).getValue(); final Optional<Artifact> artifact = artifactManagement.getByFilenameAndSoftwareModule(fileNameTrimmed, baseSwId); if (artifact.isPresent()) { warningIconLabel.setVisible(true); if (isErrorIcon(warningIconLabel)) { warningIconLabel.removeStyleName(SPUIStyleDefinitions.ERROR_LABEL); redErrorLabelCount--; } warningIconLabel.setDescription(i18n.getMessage(ALREADY_EXISTS_MSG)); if (checkForDuplicate(fileNameTrimmed, itemId, baseSwId)) { warningIconLabel.setDescription(i18n.getMessage("message.duplicate.filename")); warningIconLabel.addStyleName(SPUIStyleDefinitions.ERROR_LABEL); redErrorLabelCount++; } } else { warningIconLabel.setVisible(false); if (warningIconLabel.getStyleName().contains(SPUIStyleDefinitions.ERROR_LABEL)) { warningIconLabel.removeStyleName(SPUIStyleDefinitions.ERROR_LABEL); warningIconLabel.setDescription(i18n.getMessage(ALREADY_EXISTS_MSG)); redErrorLabelCount--; } } } }
From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadConfirmationWindow.java
License:Open Source License
/** * If warning was displayed prior and not displayed currently ,the update * other warning labels accordingly.//from w w w. j a v a2 s. co m * * @param itemId * id of row which is deleted/whose file name modified. * @param oldSwId * software module id * @param oldFileName * file name before modification */ private void modifyIconOfSameSwId(final Object itemId, final Long oldSwId, final String oldFileName) { for (final Object rowId : tableContainer.getItemIds()) { final Item newItem = tableContainer.getItem(rowId); final Long newBaseSwId = (Long) newItem.getItemProperty(BASE_SOFTWARE_ID).getValue(); final String newFileName = (String) newItem.getItemProperty(FILE_NAME).getValue(); if (!rowId.equals(itemId) && newBaseSwId.equals(oldSwId) && newFileName.equals(oldFileName)) { final HorizontalLayout layout = (HorizontalLayout) newItem.getItemProperty(FILE_NAME_LAYOUT) .getValue(); final Label warningLabel = (Label) layout.getComponent(1); if (warningLabel.isVisible()) { warningLabel.removeStyleName(SPUIStyleDefinitions.ERROR_LABEL); warningLabel.setDescription(i18n.getMessage(ALREADY_EXISTS_MSG)); newItem.getItemProperty(WARNING_ICON).setValue(warningLabel); redErrorLabelCount--; break; } } } }
From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadConfirmationWindow.java
License:Open Source License
private void newFileNameIsDuplicate(final Object itemId, final Long currentSwId, final String currentChangedText) { for (final Object rowId : tableContainer.getItemIds()) { final Item currentItem = tableContainer.getItem(itemId); final Item newItem = tableContainer.getItem(rowId); final Long newBaseSwId = (Long) newItem.getItemProperty(BASE_SOFTWARE_ID).getValue(); final String fileName = (String) newItem.getItemProperty(FILE_NAME).getValue(); if (!rowId.equals(itemId) && newBaseSwId.equals(currentSwId) && fileName.equals(currentChangedText)) { final HorizontalLayout layout = (HorizontalLayout) currentItem.getItemProperty(FILE_NAME_LAYOUT) .getValue();//from w w w . j a v a 2s . co m final Label iconLabel = (Label) layout.getComponent(1); if (!iconLabel.getStyleName().contains(SPUIStyleDefinitions.ERROR_LABEL)) { iconLabel.setVisible(true); iconLabel.setDescription(i18n.getMessage("message.duplicate.filename")); iconLabel.addStyleName(SPUIStyleDefinitions.ERROR_LABEL); redErrorLabelCount++; } break; } } }
From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadConfirmationWindow.java
License:Open Source License
private void hideErrorIcon(final Label warningLabel, final int errorLabelCount, final int duplicateCount, final Label errorLabel, final String oldFileName, final Long currentSwId) { if (warningLabel == null && (errorLabelCount > 1 || (duplicateCount == 1 && errorLabelCount == 1))) { final Optional<Artifact> artifactList = artifactManagement.getByFilenameAndSoftwareModule(oldFileName, currentSwId);/*from w w w . j a v a 2 s . c om*/ if (errorLabel == null) { return; } errorLabel.removeStyleName(SPUIStyleDefinitions.ERROR_LABEL); errorLabel.setDescription(i18n.getMessage(ALREADY_EXISTS_MSG)); if (!artifactList.isPresent()) { errorLabel.setVisible(false); } redErrorLabelCount--; } }
From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadResultWindow.java
License:Open Source License
private void populateUploadResultTable() { setTableContainer();/*from w ww . j a v a2s . c om*/ Label statusLabel; Label reasonLabel; for (final UploadStatus uploadResult : uploadResultList) { final Item newItem = tabelContainer .addItem(uploadResult.getBaseSwModuleName() + "/" + uploadResult.getFileName()); newItem.getItemProperty(FILE_NAME) .setValue(HawkbitCommonUtil.getFormatedLabel(uploadResult.getFileName())); newItem.getItemProperty(BASE_SW_MODULE) .setValue(HawkbitCommonUtil.getFormatedLabel(uploadResult.getBaseSwModuleName())); if (uploadResult.getUploadResult().equals(SPUILabelDefinitions.SUCCESS)) { statusLabel = new Label(HawkbitCommonUtil.getFormatedLabel(i18n.getMessage("upload.success"))); statusLabel.addStyleName("validation-success"); newItem.getItemProperty(UPLOAD_RESULT).setValue(statusLabel); } else { statusLabel = new Label(HawkbitCommonUtil.getFormatedLabel(i18n.getMessage("upload.failed"))); statusLabel.addStyleName("validation-failed"); newItem.getItemProperty(UPLOAD_RESULT).setValue(statusLabel); } reasonLabel = HawkbitCommonUtil.getFormatedLabel(uploadResult.getReason()); reasonLabel.setDescription(uploadResult.getReason()); final String idStr = UIComponentIdProvider.UPLOAD_ERROR_REASON + uploadResult.getBaseSwModuleName() + "/" + uploadResult.getFileName(); reasonLabel.setId(idStr); newItem.getItemProperty(REASON).setValue(reasonLabel); } }
From source file:org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsTable.java
License:Open Source License
private VerticalLayout createSoftModuleLayout(final SoftwareModuleType swModType, final DistributionSet distributionSet, final Set<SoftwareModule> alreadyAssignedSwModules) { final VerticalLayout verticalLayout = new VerticalLayout(); for (final SoftwareModule sw : alreadyAssignedSwModules) { if (swModType.getKey().equals(sw.getType().getKey())) { final HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSizeFull(); final Label softwareModule = HawkbitCommonUtil.getFormatedLabel(""); final Button reassignSoftModule = SPUIComponentProvider.getButton(sw.getName(), "", "", "", true, FontAwesome.TIMES, SPUIButtonStyleNoBorder.class); reassignSoftModule//from w ww .ja v a 2 s. c om .addClickListener(event -> unassignSW(event, distributionSet, alreadyAssignedSwModules)); final String softwareModNameVersion = HawkbitCommonUtil.getFormattedNameVersion(sw.getName(), sw.getVersion()); softwareModule.setValue(softwareModNameVersion); softwareModule.setDescription(softwareModNameVersion); softwareModule.setId(sw.getName() + "-label"); horizontalLayout.addComponent(softwareModule); horizontalLayout.setExpandRatio(softwareModule, 1F); if (isUnassignSoftModAllowed && permissionChecker.hasUpdateRepositoryPermission() && !isTargetAssigned && (isSoftModAvaiableForSoftType(alreadyAssignedSwModules, swModType))) { horizontalLayout.addComponent(reassignSoftModule); } verticalLayout.addComponent(horizontalLayout); } } return verticalLayout; }
From source file:org.eclipse.hawkbit.ui.components.SPUIComponentProvider.java
License:Open Source License
private static Label createUsernameLabel(final String label, final String username) { String loadAndFormatUsername = ""; if (!StringUtils.isEmpty(username)) { loadAndFormatUsername = UserDetailsFormatter.loadAndFormatUsername(username); }/*w w w . jav a 2s . c om*/ final Label nameValueLabel = new Label(getBoldHTMLText(label) + loadAndFormatUsername, ContentMode.HTML); nameValueLabel.setSizeFull(); nameValueLabel.addStyleName(SPUIDefinitions.TEXT_STYLE); nameValueLabel.addStyleName("label-style"); nameValueLabel.setDescription(loadAndFormatUsername); return nameValueLabel; }