Example usage for com.vaadin.ui Label addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:life.qbic.components.OfferGeneratorTab.java

License:Open Source License

/**
 * creates the tab to generate the offers with the respective packages
 * @return vaadin component holding the offer generator
 *//*w  w w. j  a  v a2 s  .  com*/
static Component createOfferGeneratorTab() {

    Database db = qOfferManager.getDb();
    TabSheet managerTabs = qOfferManager.getManagerTabs();

    ComboBox selectedProjectComboBox = new ComboBox("Select Project");
    selectedProjectComboBox.setInputPrompt("No project selected!");
    selectedProjectComboBox.setDescription("Please select a project before its too late! :P");
    selectedProjectComboBox.addItems(db.getProjects());
    selectedProjectComboBox.setWidth("300px");

    Button completeButton = new Button("Complete");
    completeButton.setDescription("Click here to finalize the offer and save it into the DB!");
    completeButton.setIcon(FontAwesome.CHECK_CIRCLE);
    completeButton.setEnabled(false);

    // get the package ids and names as a bean container
    final BeanItemContainer<String> packageIdsAndNamesContainer = new BeanItemContainer<>(String.class);
    packageIdsAndNamesContainer.addAll(db.getPackageIdsAndNames());

    TwinColSelect selectPackagesTwinColSelect = new TwinColSelect();
    selectPackagesTwinColSelect.setContainerDataSource(packageIdsAndNamesContainer);
    selectPackagesTwinColSelect.setLeftColumnCaption("Available packages");
    selectPackagesTwinColSelect.setRightColumnCaption("Selected packages");
    selectPackagesTwinColSelect.setSizeFull();

    // text field which functions as a filter for the left side of the twin column select
    TextField twinColSelectFilter = new TextField();
    twinColSelectFilter.setCaption("Filter available packages");
    twinColSelectFilter.addTextChangeListener((FieldEvents.TextChangeListener) event -> {
        packageIdsAndNamesContainer.removeAllContainerFilters();
        packageIdsAndNamesContainer.addContainerFilter(new Container.Filter() {

            @Override
            public boolean passesFilter(Object itemId, Item item) throws UnsupportedOperationException {
                return ((String) itemId).toLowerCase().contains(event.getText().toLowerCase())
                        || ((Collection) selectPackagesTwinColSelect.getValue()).contains(itemId);
            }

            @Override
            public boolean appliesToProperty(Object propertyId) {
                return true;
            }
        });
    });

    VerticalLayout right = new VerticalLayout();
    right.setSpacing(true);
    right.setMargin(true);

    VerticalLayout addPackLayout = new VerticalLayout();
    addPackLayout.setMargin(true);
    addPackLayout.setSpacing(true);

    Panel packageDescriptionPanel = new Panel("Package Details");
    packageDescriptionPanel.setContent(right);

    @SuppressWarnings("deprecation")
    Label packageDetailsLabel = new Label("Package details will appear here!", Label.CONTENT_XHTML);
    packageDetailsLabel.addStyleName(ValoTheme.LABEL_BOLD);
    right.addComponent(packageDetailsLabel);

    addListeners(db, managerTabs, selectedProjectComboBox, completeButton, addPackLayout,
            selectPackagesTwinColSelect, packageDescriptionPanel, packageDetailsLabel, twinColSelectFilter);

    addPackLayout.addComponent(selectedProjectComboBox);

    return addPackLayout;
}

From source file:lv.polarisit.demosidemenu.ValoThemeUI.java

License:Apache License

CssLayout buildMenu() {
    // Add items/*from   w w  w .ja  va2s  .  c om*/
    menuItems.put("MessageView", "First Message");
    menuItems.put("MessageView1", "Second Message");
    /*
    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++;
    }
    if (label != null)
        label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");

    return menu;
}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

private void initView() {
    setCompositionRoot(root);//w w w . j  a  v a 2 s . co m
    root.setSizeFull();
    root.setSplitPosition(15);
    root.setStyleName("small previews");

    previewArea.setWidth("100%");
    previewTabs = new VerticalLayout();
    previewTabs.setSizeFull();
    previewTabs.setHeight(null);

    compoundTabs = new VerticalLayout();
    compoundTabs.setSizeFull();
    compoundTabs.setHeight(null);

    bennuStylesTabs = new VerticalLayout();
    bennuStylesTabs.setSizeFull();
    bennuStylesTabs.setHeight(null);

    VerticalLayout menu = new VerticalLayout();
    menu.setSizeFull();
    menu.setStyleName("sidebar-menu");

    Button syncThemes = new Button("Sync Themes", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            syncThemes();
        }
    });
    menu.addComponent(syncThemes);
    menu.addComponent(new Label("Single Components"));
    menu.addComponent(previewTabs);
    menu.addComponent(new Label("Compound Styles"));
    menu.addComponent(compoundTabs);

    menu.addComponent(new Label("Bennu Styles"));
    menu.addComponent(bennuStylesTabs);

    root.setFirstComponent(menu);

    CssLayout toolbar = new CssLayout();
    toolbar.setWidth("100%");
    toolbar.setStyleName("toolbar");
    toolbar.addComponent(editorToggle);

    final Window downloadWindow = new Window("Download Theme");
    GridLayout l = new GridLayout(3, 2);
    l.setSizeUndefined();
    l.setMargin(true);
    l.setSpacing(true);
    downloadWindow.setContent(l);
    downloadWindow.setModal(true);
    downloadWindow.setResizable(false);
    downloadWindow.setCloseShortcut(KeyCode.ESCAPE, null);
    downloadWindow.addStyleName("opaque");
    Label caption = new Label("Theme Name");
    l.addComponent(caption);
    l.setComponentAlignment(caption, Alignment.MIDDLE_CENTER);
    final TextField name = new TextField();
    name.setValue("my-chameleon");
    name.addValidator(new RegexpValidator("[a-zA-Z0-9\\-_\\.]+", "Only alpha-numeric characters allowed"));
    name.setRequired(true);
    name.setRequiredError("Please give a name for the theme");
    downloadWindow.addComponent(name);
    Label info = new Label(
            "This is the name you will use to set the theme in your application code, i.e. <code>setTheme(\"my-cameleon\")</code>.",
            Label.CONTENT_XHTML);
    info.addStyleName("tiny");
    info.setWidth("200px");
    l.addComponent(info, 1, 1, 2, 1);

    Button download = new Button(null, new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            getApplication().getMainWindow().addWindow(downloadWindow);
            name.focus();
        }
    });
    download.setDescription("Donwload the current theme");
    download.setIcon(new ThemeResource("download.png"));
    download.setStyleName("icon-only");
    toolbar.addComponent(download);

    menu.addComponent(toolbar);
    menu.setExpandRatio(toolbar, 1);
    menu.setComponentAlignment(toolbar, Alignment.BOTTOM_CENTER);

}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

private Layout getSotisFrontPage() {
    GridSystemLayout layout = new GridSystemLayout(12);
    Label title = new Label(
            "O <strong>SOTIS</strong>  o Repositrio Institucional do Instituto Superior Tcnico.",
            Label.CONTENT_XHTML);
    title.addStyleName(BennuTheme.LABEL_BIG);
    layout.setCell("title", 12, title);

    Label description = new Label(
            "Aqui poder encontrar artigos publicados em <a href=\"\">Revistas</a>, <a href=\"\">Conferncias</a>, <a href=\"\">Livros</a>, <a href=\"\">Manuais</a> e <a href=\"\">Outros</a>, categorizados por <a href=\"\">Unidades de Investigao</a> e <a href=\"\">Unidades Acadmicas</a>.",
            Label.CONTENT_XHTML);
    description.addStyleName(BennuTheme.LABEL_BIG);
    layout.setCell("description", 12, description);

    VerticalLayout searchPanel = new VerticalLayout();
    layout.setCell("search", 2, 8, 2, searchPanel);
    searchPanel.addStyleName("big");
    searchPanel.addStyleName("inset");
    searchPanel.setMargin(true);/*  w  w  w . ja v  a  2 s . c  o  m*/
    searchPanel.setSpacing(true);
    HorizontalLayout searchForm = new HorizontalLayout();
    searchPanel.addComponent(searchForm);
    searchForm.setSpacing(true);
    searchForm.setWidth("100%");

    TextField searchText = new TextField();
    searchForm.addComponent(searchText);
    searchText.setInputPrompt("Introduza o termo a pesquisar");
    searchText.setWidth("100%");

    Button searchSubmit = new Button("Pesquisar");
    searchForm.addComponent(searchSubmit);
    searchSubmit.addStyleName(BennuTheme.BUTTON_DEFAULT);
    searchForm.setExpandRatio(searchText, 1f);

    Link advanced = new Link("advanced search", null);
    searchPanel.addComponent(advanced);

    Panel browseByType = new Panel("Publicaes por Tipo");
    browseByType.addStyleName(BennuTheme.PANEL_LIGHT);
    layout.setCell("type", 4, browseByType);

    Panel browseByDept = new Panel("Publicaes por Departamento");
    browseByDept.addStyleName(BennuTheme.PANEL_LIGHT);
    layout.setCell("dept", 4, browseByDept);

    Panel contacts = new Panel("Contactos");
    contacts.addStyleName(BennuTheme.PANEL_LIGHT);
    layout.setCell("contacts", 4, contacts);

    return layout;
}

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   ww w  . ja va2 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(\"&lt;h1&gt;Top Level Header&lt;/h1&gt;\", 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(\"&lt;h2&gt;Second Header&lt;/h2&gt;\", 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(\"&lt;h3&gt;Subtitle&lt;/h3&gt;\", 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:my.vaadin.profile.Forms.java

public Forms() {
    setSpacing(true);//  w  ww  .j  a  v a 2  s. c  o  m
    setMargin(true);

    Label title = new Label("Signup Form");
    title.addStyleName("h1");
    addComponent(title);

    final FormLayout form = new FormLayout();
    form.setMargin(false);
    form.setWidth("900px");
    form.addStyleName("light");
    addComponent(form);

    Label section = new Label("Personal Info");
    section.addStyleName("h2");
    section.addStyleName("colored");
    form.addComponent(section);
    //StringGenerator sg = new StringGenerator();

    TextField zID = new TextField("zID");
    zID.setValue("z123456");
    zID.setRequired(true);
    form.addComponent(zID);

    TextField name = new TextField("Name");
    name.setValue("loreum");
    //name.setWidth("50%");
    form.addComponent(name);

    PasswordField pw = new PasswordField("Set Password");
    pw.setRequired(true);
    form.addComponent(pw);

    DateField birthday = new DateField("Birthday");
    birthday.setDateFormat("dd-MM-yyyy");
    birthday.setValue(new java.util.Date());
    form.addComponent(birthday);

    OptionGroup gender = new OptionGroup("Gender");
    gender.addItem("Male");
    gender.addItem("Female");
    //sex.select("Male");
    gender.addStyleName("horizontal");
    form.addComponent(gender);

    section = new Label("Class Info");
    section.addStyleName("h2");
    section.addStyleName("colored");
    form.addComponent(section);

    TextField classID = new TextField("Class ID");
    classID.setValue("INFS2605");
    classID.setRequired(true);
    //classID.setWidth("50%");
    form.addComponent(classID);

    TextField groupID = new TextField("Group ID");
    groupID.setValue("1");
    //groupID.setWidth("50%");
    groupID.setRequired(true);
    form.addComponent(groupID);

    Button confirm = new Button("Confirm");
    confirm.addStyleName("primary");
    form.addComponent(confirm);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, false, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    form.addComponent(footer);
    footer.addComponent(confirm);

}

From source file:my.vaadin.profile.MainLayout.java

public MainLayout() {

    Label header = new Label("Student");
    header.addStyleName("colored");
    header.addStyleName("h2");
    //header.addStyleName("alignRight");
    header.setSizeUndefined();/*from w  w  w  .j ava  2  s .  co m*/

    Button signOut = new Button("Sign-Out");
    signOut.setSizeUndefined();
    signOut.addStyleName("small");

    Label menu = new Label("Menu");
    menu.addStyleName("colored");
    menu.addStyleName("h2");

    upperSection.setSizeFull();

    innerUpperSection.addComponent(header);
    innerUpperSection.addComponent(signOut);
    innerUpperSection.setExpandRatio(signOut, 1);
    innerUpperSection.setSpacing(true);
    innerUpperSection.setComponentAlignment(signOut, Alignment.MIDDLE_RIGHT);

    upperSection.addComponent(innerUpperSection);
    upperSection.setMargin(new MarginInfo(false, true, false, false));
    upperSection.setComponentAlignment(innerUpperSection, Alignment.TOP_RIGHT);
    upperSection.addStyleName("borderBottom");

    menuTitle.addComponent(menu);
    menuLayout.addComponent(menuTitle);
    menuLayout.setWidth("100%");
    menuLayout.setComponentAlignment(menuTitle, Alignment.MIDDLE_CENTER);
    //menuLayout.addStyleName("whiteStuff");
    //        menuLayout.setExpandRatio(, 1);

    //contentLayout.addComponent();

    lowerSection.addComponent(menuLayout);
    lowerSection.addComponent(contentLayout);

    addComponent(upperSection);
    addComponent(lowerSection);

    upperSection.setHeight(4, UNITS_EM);

    //showBorders();
    setSizeFull();
    lowerSection.setSizeFull();
    //menuLayout.setSizeFull();
    contentLayout.setSizeFull();

    setExpandRatio(lowerSection, 1);

    lowerSection.setSplitPosition(15);

    Button lolol = new Button("hi");
    menuLayout.addComponent(lolol);
    lolol.setWidth("100%");
    lolol.setStyleName("borderless");

}

From source file:net.antoinecomte.regex.RegExTesterApplication.java

License:Apache License

private void showResult(String regexValue, String textValue) {
    Matcher matcher;//from w w w  .ja va 2s  .  c  om
    try {
        result.setVisible(!"".equals(regexValue));
        Label match = new Label("no match");
        match.addStyleName("h3 color");
        result.removeAllComponents();
        result.addComponent(match);
        matcher = Pattern.compile(regexValue).matcher(textValue);
        if (matcher.matches()) {
            if (matcher.groupCount() > 0)
                for (int i = 1; i <= matcher.groupCount(); i++) {
                    Label g = new Label("group " + i + " = " + matcher.group(i));
                    g.addStyleName("h3 color");
                    g.setSizeUndefined();
                    result.addComponent(g);
                }
            match.setValue("match");
        }
        matcher.reset();
        if (matcher.find()) {
            Label findresult = new Label("find=true, start = " + matcher.start() + " end = " + matcher.end());
            findresult.addStyleName("h3 color");
            result.addComponent(findresult);
        }
        Label javaString = new Label("java string : \"" + StringEscapeUtils.escapeJava(regexValue) + "\"");
        javaString.addStyleName("small color");
        result.addComponent(javaString);
    } catch (Exception e) {
        result.removeAllComponents();
        Label error = new Label(e.getMessage());
        error.addStyleName("error");
        result.addComponent(error);
    }
}

From source file:net.sf.gazpachoquest.questionnaires.views.QuestionnaireView.java

License:Open Source License

public void update(QuestionnairePageDTO page) {
    questionsLayout.removeAllComponents();

    List<SectionDTO> sections = page.getSections();

    for (SectionDTO sectionDTO : sections) {
        if (sectionInfoVisible && page.isSectionInfoAvailable()) {
            final Label sectionTile = new Label(sectionDTO.getLanguageSettings().getTitle());
            sectionTile.addStyleName(Reindeer.LABEL_H2);
            questionsLayout.addComponent(sectionTile);
        }/*from   ww w . j  av  a2  s  .  c  o m*/
        List<QuestionDTO> questions = sectionDTO.getQuestions();
        for (QuestionDTO questionDTO : questions) {
            QuestionComponent questionComponent;
            try {
                questionComponent = QuestionFactory.build(questionnaireId, questionDTO);
                questionsLayout.addComponent(questionComponent);
            } catch (NotSupportedException e) {
                logger.warn(e.getMessage());
            }
        }

    }

    HorizontalLayout buttonsLayout = new HorizontalLayout();

    if (page.getMetadata().isNotFirst()) {
        previousButton.addClickListener(this);
        buttonsLayout.addComponent(previousButton);
    }

    if (page.getMetadata().isNotLast()) {
        nextButton.addClickListener(this);
        buttonsLayout.addComponent(nextButton);
    }
    questionsLayout.addComponent(buttonsLayout);
}

From source file:net.sf.gazpachoquest.questionnaires.views.QuestionnaireView.java

License:Open Source License

@Override
public void enter(ViewChangeEvent event) {
    logger.debug("Entering {} view ", QuestionnaireView.NAME);
    addStyleName(Reindeer.LAYOUT_BLUE);//from   www  . j  av a2  s  .  c om
    addStyleName("questionnaires");

    WebBrowser webBrowser = Page.getCurrent().getWebBrowser();
    Integer screenWidth = webBrowser.getScreenWidth();
    Integer heightWidth = webBrowser.getScreenHeight();

    logger.debug("Browser screen settings  {} x {}", screenWidth, heightWidth);

    if (heightWidth <= 480) {
        renderingMode = RenderingMode.QUESTION_BY_QUESTION;
    }

    // centralLayout.addStyleName("questionnaires");
    // new Responsive(centralLayout);

    RespondentAccount respondent = (RespondentAccount) VaadinServletService.getCurrentServletRequest()
            .getUserPrincipal();
    if (respondent.hasPreferredLanguage()) {
        preferredLanguage = Language.fromString(respondent.getPreferredLanguage());
    } else {
        preferredLanguage = Language.fromLocale(webBrowser.getLocale());
    }
    questionnaireId = respondent.getGrantedquestionnaireIds().iterator().next();
    logger.debug("Trying to fetch questionnair identified with id  = {} ", questionnaireId);
    QuestionnaireDefinitionDTO definition = questionnaireResource.getDefinition(questionnaireId);
    sectionInfoVisible = definition.isSectionInfoVisible();
    QuestionnairePageDTO page = questionnaireResource.getPage(questionnaireId, renderingMode, preferredLanguage,
            NavigationAction.ENTERING);

    logger.debug("Displaying page {}/{} with {} questions", page.getMetadata().getNumber(),
            page.getMetadata().getCount(), page.getQuestions().size());
    questionsLayout = new VerticalLayout();
    update(page);

    Label questionnaireTitle = new Label(definition.getLanguageSettings().getTitle());
    questionnaireTitle.addStyleName(Reindeer.LABEL_H1);

    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();
    mainLayout.setMargin(true);
    mainLayout.addComponent(questionnaireTitle);
    mainLayout.addComponent(questionsLayout);
    // Add the responsive capabilities to the components

    Panel centralLayout = new Panel();
    centralLayout.setContent(mainLayout);
    centralLayout.setSizeFull();
    centralLayout.getContent().setSizeUndefined();

    Responsive.makeResponsive(questionnaireTitle);
    setCompositionRoot(centralLayout);
    setSizeFull();
}