List of usage examples for com.vaadin.ui Label setValue
public void setValue(String value)
From source file:com.esofthead.mycollab.vaadin.ui.form.field.DefaultViewField.java
License:Open Source License
@Override protected Component initContent() { final Label label = new Label(); label.setWidth("100%"); label.setContentMode(contentMode);/* w w w .j av a2 s. c om*/ if (StringUtils.isNotBlank(value)) { label.setValue(value); } else { label.setValue(""); } return label; }
From source file:com.esofthead.mycollab.vaadin.ui.form.field.I18nFormViewField.java
License:Open Source License
@Override protected Component initContent() { final Label label = new Label(); label.setWidth("100%"); label.setContentMode(ContentMode.TEXT); if (org.apache.commons.lang3.StringUtils.isNotBlank(key)) { try {//from w w w .ja v a 2s . c o m String value = AppContext.getMessage(enumClass, key); label.setValue(value); } catch (Exception e) { label.setValue(""); } } else { label.setValue(""); } return label; }
From source file:com.esofthead.mycollab.vaadin.ui.form.field.PrettyDateTimeViewField.java
License:Open Source License
@Override protected Component initContent() { final Label l = new Label(); l.setWidth("100%"); if (date == null) { l.setValue(" "); l.setContentMode(ContentMode.HTML); } else {//from w w w . j a v a 2 s . c o m l.setValue(AppContext.formatPrettyTime(date)); l.setDescription(AppContext.formatDateTime(date)); } return l; }
From source file:com.esofthead.mycollab.vaadin.ui.form.field.PrettyDateViewField.java
License:Open Source License
@Override protected Component initContent() { final Label l = new Label(); l.setWidth("100%"); if (date == null) { l.setValue(" "); l.setContentMode(ContentMode.HTML); } else {//from www. ja v a 2 s . c o m l.setValue(AppContext.formatPrettyTime(date)); l.setDescription(AppContext.formatDate(date)); } return l; }
From source file:com.esofthead.mycollab.vaadin.ui.form.field.RoundNumerField.java
License:Open Source License
@Override protected Component initContent() { final Label label = new Label(); label.setWidth("100%"); if (value != null) { double d = value.doubleValue(); d = Math.round(d * 100);/*from w w w. j a v a 2s.c o m*/ d = d / 100; label.setValue(d + ""); } else { label.setValue(""); } return label; }
From source file:com.esspl.datagen.util.DataGenEventHandler.java
License:Open Source License
public void onChangeDataType(ValueChangeEvent event, Select select) { log.debug("DataGenEventHandler - onChangeDataType() method start"); int rowId = (Integer) select.getData(); DataGenApplication tdg = (DataGenApplication) select.getApplication(); Item item = tdg.listing.getItem(rowId); Select formatSel = (Select) item.getItemProperty("Format").getValue(); formatSel.removeAllItems();/*from w w w. jav a2 s.com*/ formatSel.setEnabled(true); Label exampleSel = (Label) item.getItemProperty("Examples").getValue(); exampleSel.setValue("NA"); HorizontalLayout addBar = (HorizontalLayout) item.getItemProperty("Additional Data").getValue(); addBar.removeAllComponents(); addBar.setMargin(false); addBar.addComponent(new Label("NA")); if (event.getProperty().getValue() == null) { formatSel.setValue(null); formatSel.setEnabled(false); return; } if (event.getProperty().getValue().equals("Name")) { for (String f : DataGenConstant.NAME_FORMATS) { formatSel.addItem(f); } formatSel.setNullSelectionAllowed(false); formatSel.setValue("First_Name Last_Name"); } else if (event.getProperty().getValue().equals("Date")) { for (String f : DataGenConstant.DATE_FORMATS) { formatSel.addItem(f); } formatSel.setNullSelectionAllowed(false); formatSel.setValue("dd/MM/yyyy"); } else if (event.getProperty().getValue().equals("Phone/Fax")) { for (String f : DataGenConstant.PHONE_FORMATS) { formatSel.addItem(f); } formatSel.setNullSelectionAllowed(false); formatSel.setValue("India"); } else if (event.getProperty().getValue().equals("Postal/Zip")) { for (String f : DataGenConstant.ZIP_FORMATS) { formatSel.addItem(f); } formatSel.setNullSelectionAllowed(false); formatSel.setValue("India"); } else if (event.getProperty().getValue().equals("State/Provience/County")) { for (String f : DataGenConstant.STATE_FORMATS) { formatSel.addItem(f); } formatSel.setNullSelectionAllowed(false); formatSel.setValue("Full"); } else if (event.getProperty().getValue().equals("Random Text")) { exampleSel.setValue(df.getRandomText(6)); addTextFields(addBar, "Min Length", "Max Length"); } else if (event.getProperty().getValue().equals("Fixed Text")) { exampleSel.setValue(df.getRandomWord()); addChkTextField(addBar, "Text", "Is Number"); } else if (event.getProperty().getValue().equals("Number Range")) { exampleSel.setValue(df.getNumberBetween(10, 1000)); addTextFields(addBar, "Start Number", "End Number"); } else if (event.getProperty().getValue().equals("Alphanumeric")) { exampleSel.setValue("SD0358"); addTextFields(addBar, "Starting Text", "Total Length"); } else if (event.getProperty().getValue().equals("Title")) {//Examples start exampleSel.setValue(df.getPrefix()); } else if (event.getProperty().getValue().equals("Email")) { exampleSel.setValue(df.getEmailAddress()); } else if (event.getProperty().getValue().equals("Street Address")) { exampleSel.setValue(df.getStreetName()); } else if (event.getProperty().getValue().equals("City")) { exampleSel.setValue(df.getCity()); } else if (event.getProperty().getValue().equals("Country")) { exampleSel.setValue(df.getCountry()); } else if (event.getProperty().getValue().equals("Incremental Number")) { exampleSel.setValue("1, 2, 3, 4, 5.."); addSingleTextField(addBar, "Starting From"); } else if (event.getProperty().getValue().equals("Marital Status")) { exampleSel.setValue(df.getStatus()); } else if (event.getProperty().getValue().equals("Department Name")) { exampleSel.setValue(df.getBusinessType()); } else if (event.getProperty().getValue().equals("Company Name")) { exampleSel.setValue(df.getCompanyName()); } else if (event.getProperty().getValue().equals("Boolean Flag")) { exampleSel.setValue(df.getBooleanFlag()); } else if (event.getProperty().getValue().equals("Passport Number")) { exampleSel.setValue(df.getPassportNumber()); } //If there are no formats to show, then disable it if (formatSel.getItemIds().size() == 0) { formatSel.setEnabled(false); } log.debug("DataGenEventHandler - onChangeDataType() method end"); }
From source file:com.esspl.datagen.util.DataGenEventHandler.java
License:Open Source License
public void onChangeFormat(ValueChangeEvent event, Select select) { log.debug("DataGenEventHandler - onChangeFormat() method start"); int rowId = (Integer) select.getData(); DataGenApplication tdg = (DataGenApplication) select.getApplication(); Item item = tdg.listing.getItem(rowId); Label exampleSel = (Label) item.getItemProperty("Examples").getValue(); Select dataSel = (Select) item.getItemProperty("Data Type").getValue(); HorizontalLayout addBar = (HorizontalLayout) item.getItemProperty("Additional Data").getValue(); addBar.setMargin(false);//from w w w .j a v a2 s .co m if (event.getProperty().getValue() == null) { exampleSel.setValue("NA"); return; } //Name examples if (event.getProperty().getValue().equals("First_Name Last_Name")) { exampleSel.setValue(df.getName("First_Name Last_Name")); } else if (event.getProperty().getValue().equals("First_Name")) { exampleSel.setValue(df.getName("First_Name")); } else if (event.getProperty().getValue().equals("Last_Name")) { exampleSel.setValue(df.getName("Last_Name")); } else if (event.getProperty().getValue().equals("Sur_Name Last_Name")) { exampleSel.setValue(df.getName("Sur_Name Last_Name")); } else if (event.getProperty().getValue().equals("Sur_Name First_Name")) { exampleSel.setValue(df.getName("Sur_Name First_Name")); } else if (event.getProperty().getValue().equals("Sur_Name First_Name Last_Name")) { exampleSel.setValue(df.getName("Sur_Name First_Name Last_Name")); } else if (event.getProperty().getValue().equals("MM/dd/yyyy")) {//Date Examples start exampleSel.setValue(df.getDate("MM/dd/yyyy", "", "")); addDateFields(select, addBar); } else if (event.getProperty().getValue().equals("dd/MM/yyyy")) { exampleSel.setValue(df.getDate("dd/MM/yyyy", "", "")); addDateFields(select, addBar); } else if (event.getProperty().getValue().equals("yyyy-MM-dd")) { exampleSel.setValue(df.getDate("yyyy-MM-dd", "", "")); addDateFields(select, addBar); } else if (event.getProperty().getValue().equals("MMM dd, yyyy")) { exampleSel.setValue(df.getDate("MMM dd, yyyy", "", "")); addDateFields(select, addBar); } else if (event.getProperty().getValue().equals("dd MMM, yy")) { exampleSel.setValue(df.getDate("dd MMM, yy", "", "")); addDateFields(select, addBar); } else if (event.getProperty().getValue().equals("yyyy-MM-dd HH:mm:ss")) { exampleSel.setValue(df.getDate("yyyy-MM-dd HH:mm:ss", "", "")); addDateFields(select, addBar); } else if (event.getProperty().getValue().equals("MM/dd/yyyy HH:mm:ss")) { exampleSel.setValue(df.getDate("MM/dd/yyyy HH:mm:ss", "", "")); addDateFields(select, addBar); } else if (event.getProperty().getValue().equals("MM.dd.yyyy")) { exampleSel.setValue(df.getDate("MM.dd.yyyy", "", "")); addDateFields(select, addBar); } else if (event.getProperty().getValue().equals("dd.MM.yyyy")) { exampleSel.setValue(df.getDate("dd.MM.yyyy", "", "")); addDateFields(select, addBar); } else if (event.getProperty().getValue().equals("India") && dataSel.getValue().equals("Phone/Fax")) {//Phone Examples start exampleSel.setValue(df.getPhoneNumber("India")); } else if (event.getProperty().getValue().equals("USA/Canada") && dataSel.getValue().equals("Phone/Fax")) { exampleSel.setValue(df.getPhoneNumber("USA/Canada")); } else if (event.getProperty().getValue().equals("UK") && dataSel.getValue().equals("Phone/Fax")) { exampleSel.setValue(df.getPhoneNumber("UK")); } else if (event.getProperty().getValue().equals("India") && dataSel.getValue().equals("Postal/Zip")) {//Zip Examples start exampleSel.setValue(df.getZipCode("India")); } else if (event.getProperty().getValue().equals("Canada") && dataSel.getValue().equals("Postal/Zip")) { exampleSel.setValue(df.getZipCode("Canada")); } else if (event.getProperty().getValue().equals("USA") && dataSel.getValue().equals("Postal/Zip")) { exampleSel.setValue(df.getZipCode("USA")); } else if (event.getProperty().getValue().equals("Full")) {//State Examples start exampleSel.setValue(df.getState("Full")); } else if (event.getProperty().getValue().equals("Sort")) { exampleSel.setValue(df.getState("Sort")); } log.debug("DataGenEventHandler - onChangeFormat() method end"); }
From source file:com.etest.connection.ShowErrorNotification.java
public static void error(String error) { Label label = new Label(); label.setWidth("400px"); label.setValue(error); label.setContentMode(ContentMode.HTML); Notification.show(label.getValue(), Notification.Type.ERROR_MESSAGE); }
From source file:com.etest.pdfgenerator.TQCoveragePDF.java
public TQCoveragePDF(int tqCoverageId) { this.tqCoverageId = tqCoverageId; Document document = null;//ww w . j a va 2 s . c o m try { document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter.getInstance(document, outputStream); document.open(); Font header1 = FontFactory.getFont("Times-Roman", 14, Font.BOLD); Font header2 = FontFactory.getFont("Times-Roman", 12, Font.BOLD); Font content = FontFactory.getFont("Times-Roman", 10); Image img = null; try { img = Image.getInstance("C:\\eTest-images\\SUCN_seal.png"); img.scaleToFit(60, 60); img.setAbsolutePosition(100, 720); } catch (BadElementException | IOException ex) { Logger.getLogger(TQCoveragePDF.class.getName()).log(Level.SEVERE, null, ex); } document.add(img); Paragraph title = new Paragraph(); title.setAlignment(Element.ALIGN_CENTER); title.add(new Phrase("COLLEGE OF NURSING", header2)); document.add(title); Paragraph school = new Paragraph(); school.setAlignment(Element.ALIGN_CENTER); school.add(new Phrase("Siliman University", header2)); document.add(school); Paragraph location = new Paragraph(); location.setSpacingAfter(10f); location.setAlignment(Element.ALIGN_CENTER); location.add(new Phrase("Dumaguete City", header2)); document.add(location); Paragraph examTitle = new Paragraph(); examTitle.setSpacingAfter(20f); examTitle.setAlignment(Element.ALIGN_CENTER); examTitle .add(new Phrase( cs.getCurriculumById(tq.getTQCoverageById(getTQCoverageId()).getCurriculumId()) .getSubject() + " " + tq.getTQCoverageById(getTQCoverageId()).getExamTitle(), header2)); document.add(examTitle); Paragraph instruction = new Paragraph(); instruction.setSpacingAfter(5f); instruction.setAlignment(Element.ALIGN_LEFT); instruction.add( new Phrase("INSTRUCTIONS: Read the cases carefully. Choose the letter of the correct answer. " + "Use an answer sheet and follow instruction for its use.", content)); document.add(instruction); int itemNo = 1; Map<Integer, Map<Integer, Integer>> tqCoverage = tq.getTQCoverage(getTQCoverageId()); for (Map.Entry<Integer, Map<Integer, Integer>> tqCases : tqCoverage.entrySet()) { Integer tqCaseId = tqCases.getKey(); Label caseTopic = new Label(); caseTopic.setValue(ccs.getCellCaseById(tqCaseId).getCaseTopic()); caseTopic.setContentMode(ContentMode.HTML); document.add(new Paragraph(caseTopic.getValue().replaceAll("(?i)<p.*?>.*?</p>", ""), content)); Map<Integer, Integer> value = tqCases.getValue(); for (Map.Entry<Integer, Integer> itemIds : value.entrySet()) { Integer itemId = itemIds.getKey(); Integer itemKeyId = itemIds.getValue(); List<String> keyList = k.getAllItemKey(itemId); if (keyList.isEmpty()) { ShowErrorNotification.error( "No Item Key was found for STEM: \n" + cis.getCellItemById(itemId).getItem()); return; } Label stem = new Label(); // stem.setValue(itemNo+". "+cis.getCellItemById(itemId).getItem().replace("{key}", keyList.get(0))); stem.setValue(itemNo + ". " + cis.getCellItemById(itemId).getItem().replace("{key}", k.getItemKeyById(itemKeyId))); stem.setContentMode(ContentMode.HTML); document.add(new Paragraph(stem.getValue(), content)); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); table.setSpacingBefore(10f); table.setSpacingAfter(10f); //Set Column widths float[] columnWidths = { 1f, 1f }; table.setWidths(columnWidths); PdfPCell cell1 = new PdfPCell( new Paragraph("A) " + cis.getCellItemById(itemId).getOptionA(), content)); // cell1.setBorderColor(BaseColor.BLUE); cell1.setBorder(0); cell1.setPaddingLeft(10); cell1.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell1.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell2 = new PdfPCell( new Paragraph("C) " + cis.getCellItemById(itemId).getOptionC(), content)); // cell2.setBorderColor(BaseColor.GREEN); cell2.setBorder(0); cell2.setPaddingLeft(10); cell2.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell3 = new PdfPCell( new Paragraph("B) " + cis.getCellItemById(itemId).getOptionB(), content)); // cell3.setBorderColor(BaseColor.RED); cell3.setBorder(0); cell3.setPaddingLeft(10); cell3.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell3.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell4 = new PdfPCell( new Paragraph("D) " + cis.getCellItemById(itemId).getOptionD(), content)); // cell4.setBorderColor(BaseColor.RED); cell4.setBorder(0); cell4.setPaddingLeft(10); cell4.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell4.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); table.addCell(cell4); document.add(table); itemNo++; } } document.newPage(); Paragraph ticketNo = new Paragraph(); ticketNo.setSpacingAfter(30f); ticketNo.setAlignment(Element.ALIGN_LEFT); ticketNo.add(new Phrase("TQ Ticket #: " + tq.getTqCoverageTicketNo(getTQCoverageId()), content)); document.add(ticketNo); document.add(new Paragraph("Answer Key: ")); itemNo = 1; List<TQAnswerKey> answerKey = tq.getTQCoverageAnswerKey(getTQCoverageId()); for (TQAnswerKey t : answerKey) { document.add(new Paragraph( t.getItemNo() + ": " + cis.getOptionAnswer(t.getCellItemId()).get(t.getAnswer()))); } } catch (DocumentException ex) { Logger.getLogger(TQCoveragePDF.class.getName()).log(Level.SEVERE, null, ex); } finally { if (document != null) { document.close(); } } }
From source file:com.etest.view.notification.ViewCaseNotificationWindow.java
VerticalLayout buildForms() { VerticalLayout v = new VerticalLayout(); v.setWidth("700px"); v.setMargin(true);/*from ww w. ja v a 2 s .c om*/ v.setSpacing(true); Label cellCase = new Label(); cellCase.setValue("<b>Case</b>: " + ccs.getCellCaseById(getCellCaseId()).getCaseTopic()); cellCase.setContentMode(ContentMode.HTML); v.addComponent(cellCase); Label cellItem = new Label(); cellItem.setContentMode(ContentMode.HTML); Button approvalBtn = new Button(); approvalBtn.setCaption("Approve CASE"); approvalBtn.setWidthUndefined(); approvalBtn.addStyleName(ValoTheme.BUTTON_TINY); approvalBtn.addStyleName(ValoTheme.BUTTON_PRIMARY); approvalBtn.addClickListener(buttonClickListener); if (ccs.getCellCaseById(getCellCaseId()).getApprovalStatus() == 0) { approvalBtn.setVisible(true); } else { approvalBtn.setVisible(false); } v.addComponent(approvalBtn); HorizontalLayout h1 = new HorizontalLayout(); h1.setWidth("100%"); approvalItemBtn.setVisible(false); approvalItemBtn.setWidthUndefined(); approvalItemBtn.addStyleName(ValoTheme.BUTTON_TINY); approvalItemBtn.addStyleName(ValoTheme.BUTTON_PRIMARY); if (getCellItemId() != 0) { approvalBtn.setCaption("Approve ITEM"); CellItem ci = cis.getCellItemById(getCellItemId()); keyList = k.getAllItemKey(getCellItemId()); keyIndexSize = keyList.size(); if (keyList.isEmpty()) { ShowErrorNotification.error("No Item Key was found for STEM: \n" + ci.getItem()); return null; } stem = ci.getItem().replace("{key}", "<u>" + keyList.get(getKeyIndex()) + "</u>"); cellItem.setValue("<b>STEM</b>: " + getStem()); OptionGroup options = new OptionGroup(); options.addItems(cis.getCellItemById(getCellItemId()).getOptionA(), cis.getCellItemById(getCellItemId()).getOptionB(), cis.getCellItemById(getCellItemId()).getOptionC(), cis.getCellItemById(getCellItemId()).getOptionD()); h1.addComponent(options); h1.setComponentAlignment(options, Alignment.MIDDLE_CENTER); if (cis.getCellItemById(getCellItemId()).getCellItemStatus() == 0) { approvalItemBtn.setVisible(true); } else { approvalItemBtn.setVisible(false); } approvalItemBtn.addClickListener(buttonClickListener); approvalItemBtn.setVisible(true); } v.addComponent(approvalBtn); v.addComponent(cellItem); v.addComponent(h1); v.addComponent(approvalItemBtn); Label separator = new Label("<HR>"); separator.setContentMode(ContentMode.HTML); v.addComponent(separator); return v; }