Example usage for com.vaadin.ui Label getValue

List of usage examples for com.vaadin.ui Label getValue

Introduction

In this page you can find the example usage for com.vaadin.ui Label getValue.

Prototype

public String getValue() 

Source Link

Document

Gets the text shown in the label.

Usage

From source file:annis.visualizers.htmlvis.HTMLVis.java

License:Apache License

@Override
public Panel createComponent(VisualizerInput vi, VisualizationToggle vt) {
    Panel scrollPanel = new Panel();
    scrollPanel.setSizeFull();//from w  w  w .  j av a 2  s  .c o m
    Label lblResult = new Label("ERROR", ContentMode.HTML);
    lblResult.setSizeUndefined();

    List<String> corpusPath = CommonHelper.getCorpusPath(vi.getDocument().getGraph(), vi.getDocument());
    String corpusName = corpusPath.get(corpusPath.size() - 1);
    corpusName = urlPathEscape.escape(corpusName);

    String wrapperClassName = "annis-wrapped-htmlvis-" + corpusName.replaceAll("[^0-9A-Za-z-]", "_");

    scrollPanel.addStyleName(wrapperClassName);

    String visConfigName = vi.getMappings().getProperty("config");
    String hitMarkConfig = vi.getMappings().getProperty("hitmark", "true");
    hitMark = Boolean.parseBoolean(hitMarkConfig);
    mc = vi.getMarkedAndCovered();

    VisualizationDefinition[] definitions = parseDefinitions(corpusName, vi.getMappings());

    if (definitions != null) {

        lblResult.setValue(createHTML(vi.getSResult().getDocumentGraph(), definitions));

        String labelClass = vi.getMappings().getProperty("class", "htmlvis");
        lblResult.addStyleName(labelClass);

        InputStream inStreamCSSRaw = null;
        if (visConfigName == null) {
            inStreamCSSRaw = HTMLVis.class.getResourceAsStream("htmlvis.css");
        } else {
            WebResource resBinary = Helper.getAnnisWebResource().path("query/corpora/").path(corpusName)
                    .path(corpusName).path("binary").path(visConfigName + ".css");

            ClientResponse response = resBinary.get(ClientResponse.class);
            if (response.getStatus() == ClientResponse.Status.OK.getStatusCode()) {
                inStreamCSSRaw = response.getEntityInputStream();
            }
        }
        if (inStreamCSSRaw != null) {
            try (InputStream inStreamCSS = inStreamCSSRaw) {
                String cssContent = IOUtils.toString(inStreamCSS);
                UI currentUI = UI.getCurrent();
                if (currentUI instanceof AnnisBaseUI) {
                    // do not add identical CSS files
                    ((AnnisBaseUI) currentUI).injectUniqueCSS(cssContent, wrapperClassName);
                }
            } catch (IOException ex) {
                log.error("Could not parse the HTML visualizer CSS file", ex);
                Notification.show("Could not parse the HTML visualizer CSS file", ex.getMessage(),
                        Notification.Type.ERROR_MESSAGE);
            }
        }

    }

    if (vi.getMappings().containsKey("debug")) {
        TextArea txtDebug = new TextArea();
        txtDebug.setValue(lblResult.getValue());
        txtDebug.setReadOnly(true);
        txtDebug.setWidth("100%");
        Label sep = new Label("<hr/>", ContentMode.HTML);
        VerticalLayout layout = new VerticalLayout(txtDebug, sep, lblResult);
        layout.setSizeUndefined();
        scrollPanel.setContent(layout);
    } else {
        scrollPanel.setContent(lblResult);
    }

    return scrollPanel;
}

From source file:com.cavisson.gui.dashboard.components.controls.ValoThemeUI.java

License:Apache License

CssLayout buildMenu() {
    // Add items/*from w w w.  j a va 2  s . co m*/
    menuItems.put("common", "Common UI Elements");
    menuItems.put("labels", "Labels");
    menuItems.put("buttons-and-links", "Buttons & Links");
    menuItems.put("textfields", "Text Fields");
    menuItems.put("datefields", "Date Fields");
    menuItems.put("comboboxes", "Combo Boxes");
    menuItems.put("selects", "Selects");
    menuItems.put("checkboxes", "Check Boxes & Option Groups");
    menuItems.put("sliders", "Sliders & Progress Bars");
    menuItems.put("colorpickers", "Color Pickers");
    menuItems.put("menubars", "Menu Bars");
    menuItems.put("trees", "Trees");
    menuItems.put("tables", "Tables");
    menuItems.put("dragging", "Drag and Drop");
    menuItems.put("panels", "Panels");
    menuItems.put("splitpanels", "Split Panels");
    menuItems.put("tabs", "Tabs");
    menuItems.put("accordions", "Accordions");
    menuItems.put("popupviews", "Popup Views");
    // menuItems.put("calendar", "Calendar");
    menuItems.put("forms", "Forms");

    final HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName("valo-menu-title");
    menu.addComponent(top);
    menu.addComponent(createThemeSelect());

    final Button showMenu = new Button("Menu", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            if (menu.getStyleName().contains("valo-menu-visible")) {
                menu.removeStyleName("valo-menu-visible");
            } else {
                menu.addStyleName("valo-menu-visible");
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName("valo-menu-toggle");
    showMenu.setIcon(FontAwesome.LIST);
    menu.addComponent(showMenu);

    final Label title = new Label("<h3>Vaadin <strong>Valo Theme</strong></h3>", ContentMode.HTML);
    title.setSizeUndefined();
    top.addComponent(title);
    top.setExpandRatio(title, 1);

    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");
    final StringGenerator sg = new StringGenerator();
    final MenuItem settingsItem = settings.addItem(
            sg.nextString(true) + " " + sg.nextString(true) + sg.nextString(false),
            new ThemeResource("../tests-valo/img/profile-pic-300px.jpg"), null);
    settingsItem.addItem("Edit Profile", null);
    settingsItem.addItem("Preferences", null);
    settingsItem.addSeparator();
    settingsItem.addItem("Sign Out", null);
    menu.addComponent(settings);

    menuItemsLayout.setPrimaryStyleName("valo-menuitems");
    menu.addComponent(menuItemsLayout);

    Label label = null;
    int count = -1;
    for (final Entry<String, String> item : menuItems.entrySet()) {
        if (item.getKey().equals("labels")) {
            label = new Label("Components", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        if (item.getKey().equals("panels")) {
            label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");
            count = 0;
            label = new Label("Containers", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        if (item.getKey().equals("forms")) {
            label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");
            count = 0;
            label = new Label("Other", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        final Button b = new Button(item.getValue(), new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                navigator.navigateTo(item.getKey());
            }
        });
        if (count == 2) {
            b.setCaption(b.getCaption() + " <span class=\"valo-menu-badge\">123</span>");
        }
        b.setHtmlContentAllowed(true);
        b.setPrimaryStyleName("valo-menu-item");
        b.setIcon(testIcon.get());
        menuItemsLayout.addComponent(b);
        count++;
    }
    label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");

    return menu;
}

From source file:com.etest.connection.ShowErrorNotification.java

public static void error(String error) {
    Label label = new Label();
    label.setWidth("400px");
    label.setValue(error);// ww  w .j av  a 2 s  . c o  m
    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  .  ja va2s . 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.utilities.CommonUtilities.java

public static int convertStringToInt(String str) {
    int val = 0;
    try {//from   w w w  .jav a 2  s  .co m
        if (str != null || !str.isEmpty()) {
            val = Integer.parseInt(str);
        }
    } catch (Exception e) {
        Label label = new Label("cant convert input to String \n" + e.toString());
        ShowErrorNotification.error(label.getValue());
        e.getMessage();
    }

    return val;
}

From source file:com.etest.utilities.CommonUtilities.java

public static boolean isNumeric(String str) {
    try {/*  w w w. jav  a  2  s .  co m*/
        Integer.parseInt(str);
        return true;
    } catch (Exception e) {
        Label label = new Label("Enter a Numeric Format \n" + e.toString());
        ShowErrorNotification.error(label.getValue());
        return false;
    }
}

From source file:com.etest.utilities.CommonUtilities.java

public static boolean isValueInteger(Object object) {
    try {//from ww w .j ava  2  s  .  c o  m
        Integer.parseInt(object.toString());
        return true;
    } catch (Exception e) {
        Label label = new Label("Enter an Integer Value \n" + e.toString());
        ShowErrorNotification.error(label.getValue());
        return false;
    }
}

From source file:com.example.sudoku.UndoListener.java

@Override
public void buttonClick(ClickEvent event) {
    if (!stack.empty()) {
        Undo undo = stack.pop();//  w w w  .  j a  va 2  s.c  o m
        Label label = new Label();
        label = undo.getLabel();
        System.out.println("The label is " + label.getValue());
        Property property = label.getPropertyDataSource();
        property.setValue(undo.getOldValue());
        System.out.println("The old value in Undo is " + property.getValue());
        System.out.println("The old value in UndoListener is " + undo.getOldValue());

        label.setPropertyDataSource(property);
    } else
        Notification.show("Nothing to undo", Type.WARNING_MESSAGE);
}

From source file:com.haulmont.cuba.web.LoginWindow.java

License:Apache License

protected HorizontalLayout createTitleLayout() {
    HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setStyleName("cuba-login-title");
    titleLayout.setSpacing(true);/*from w ww  . j a  va2s .co  m*/

    Image logoImage = getLogoImage();
    if (logoImage != null) {
        logoImage.setStyleName("cuba-login-icon");
        titleLayout.addComponent(logoImage);
        titleLayout.setComponentAlignment(logoImage, Alignment.MIDDLE_LEFT);
    }

    String welcomeMsg = messages.getMainMessage("loginWindow.welcomeLabel", resolvedLocale);
    Label label = new Label(welcomeMsg.replace("\n", "<br/>"));
    label.setContentMode(ContentMode.HTML);
    label.setWidthUndefined();
    label.setStyleName("cuba-login-caption");

    if (!StringUtils.isBlank(label.getValue())) {
        titleLayout.addComponent(label);
        titleLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
    }
    return titleLayout;
}

From source file:com.jain.addon.i18N.handlers.I18NLableHandler.java

License:Apache License

public I18NLableHandler(final Label component) {
    super(component.getValue());
    provider = ((I18NUI) component.getUI()).getI18nProvider();
}