Example usage for com.vaadin.ui HorizontalLayout HorizontalLayout

List of usage examples for com.vaadin.ui HorizontalLayout HorizontalLayout

Introduction

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

Prototype

public HorizontalLayout() 

Source Link

Document

Constructs an empty HorizontalLayout.

Usage

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

License:Apache License

public Tabsheets() {
    setMargin(true);/* w w w  .j  a va2s  .c o  m*/

    Label h1 = new Label("Tabs");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout wrap = new HorizontalLayout();
    wrap.setSpacing(true);
    wrap.addStyleName("wrapping");
    addComponent(wrap);

    final CheckBox closable = new CheckBox("Closable");
    closable.setImmediate(true);
    wrap.addComponent(closable);

    final CheckBox overflow = new CheckBox("Overflow");
    overflow.setImmediate(true);
    wrap.addComponent(overflow);

    final CheckBox caption = new CheckBox("Captions", true);
    caption.setImmediate(true);
    wrap.addComponent(caption);

    final CheckBox icon = new CheckBox("Icons");
    icon.setImmediate(true);
    wrap.addComponent(icon);

    final CheckBox disable = new CheckBox("Disable tabs");
    disable.setImmediate(true);
    wrap.addComponent(disable);

    Label h3 = new Label("Additional Styles");
    h3.addStyleName("h3");
    addComponent(h3);

    wrap = new HorizontalLayout();
    wrap.setSpacing(true);
    wrap.addStyleName("wrapping");
    wrap.setMargin(new MarginInfo(false, false, true, false));
    addComponent(wrap);

    final CheckBox framed = new CheckBox("Framed", true);
    framed.setImmediate(true);
    wrap.addComponent(framed);

    final CheckBox centered = new CheckBox("Centered tabs");
    centered.setImmediate(true);
    wrap.addComponent(centered);

    final CheckBox rightAlign = new CheckBox("Right-aligned tabs");
    rightAlign.setImmediate(true);
    wrap.addComponent(rightAlign);

    final CheckBox equal = new CheckBox("Equal-width tabs");
    equal.setImmediate(true);
    wrap.addComponent(equal);

    final CheckBox padded = new CheckBox("Padded tabbar");
    padded.setImmediate(true);
    wrap.addComponent(padded);

    final CheckBox compact = new CheckBox("Compact");
    compact.setImmediate(true);
    wrap.addComponent(compact);

    final CheckBox iconsOnTop = new CheckBox("Icons on top");
    iconsOnTop.setImmediate(true);
    wrap.addComponent(iconsOnTop);

    final CheckBox selectedOnly = new CheckBox("Selected tab closable");
    selectedOnly.setImmediate(true);
    wrap.addComponent(selectedOnly);

    ValueChangeListener update = new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            String style = framed.getValue() ? "framed " : "";
            style += centered.getValue() ? " centered-tabs" : "";
            style += rightAlign.getValue() ? " right-aligned-tabs" : "";
            style += equal.getValue() ? " equal-width-tabs" : "";
            style += padded.getValue() ? " padded-tabbar" : "";
            style += compact.getValue() ? " compact-tabbar" : "";
            style += iconsOnTop.getValue() ? " icons-on-top" : "";
            style += selectedOnly.getValue() ? " only-selected-closable" : "";

            if (tabs != null) {
                removeComponent(tabs);
            }
            tabs = getTabSheet(caption.getValue(), style.trim(), closable.getValue(), overflow.getValue(),
                    icon.getValue(), disable.getValue());
            addComponent(tabs);
        }
    };
    closable.addValueChangeListener(update);
    overflow.addValueChangeListener(update);
    caption.addValueChangeListener(update);
    icon.addValueChangeListener(update);
    disable.addValueChangeListener(update);
    framed.addValueChangeListener(update);
    centered.addValueChangeListener(update);
    rightAlign.addValueChangeListener(update);
    equal.addValueChangeListener(update);
    padded.addValueChangeListener(update);
    compact.addValueChangeListener(update);
    iconsOnTop.addValueChangeListener(update);
    selectedOnly.addValueChangeListener(update);

    // Generate initial view
    icon.setValue(true);
}

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

License:Apache License

public TextFields() {
    setMargin(true);/*from  w  ww  .j  a v  a 2  s.  c  o m*/

    Label h1 = new Label("Text Fields");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    TextField tf = new TextField("Normal");
    tf.setInputPrompt("First name");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("Custom color");
    tf.setInputPrompt("Email");
    tf.addStyleName("color1");
    row.addComponent(tf);

    tf = new TextField("User Color");
    tf.setInputPrompt("Gender");
    tf.addStyleName("color2");
    row.addComponent(tf);

    tf = new TextField("Themed");
    tf.setInputPrompt("Age");
    tf.addStyleName("color3");
    row.addComponent(tf);

    tf = new TextField("Error");
    tf.setValue("Somethings wrong");
    tf.setComponentError(new UserError("Fix it, now!"));
    row.addComponent(tf);

    tf = new TextField("Error, borderless");
    tf.setValue("Somethings wrong");
    tf.setComponentError(new UserError("Fix it, now!"));
    tf.addStyleName("borderless");
    row.addComponent(tf);

    tf = new TextField("Read-only");
    tf.setInputPrompt("Nationality");
    tf.setValue("Finnish");
    tf.setReadOnly(true);
    row.addComponent(tf);

    tf = new TextField("Small");
    tf.setValue("Field value");
    tf.addStyleName("small");
    row.addComponent(tf);

    tf = new TextField("Large");
    tf.setValue("Field value");
    tf.addStyleName("large");
    tf.setIcon(testIcon.get(true));
    row.addComponent(tf);

    tf = new TextField("Icon inside");
    tf.setInputPrompt("Ooh, an icon");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("Large, Icon inside");
    tf.setInputPrompt("Ooh, an icon");
    tf.addStyleName("large");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("Small, Icon inside");
    tf.setInputPrompt("Ooh, an icon");
    tf.addStyleName("small");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("16px supported by default");
    tf.setInputPrompt("Image icon");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get(true, 16));
    row.addComponent(tf);

    tf = new TextField();
    tf.setValue("Font, no caption");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField();
    tf.setValue("Image, no caption");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get(true, 16));
    row.addComponent(tf);

    CssLayout group = new CssLayout();
    group.addStyleName("v-component-group");
    row.addComponent(group);

    tf = new TextField();
    tf.setInputPrompt("Grouped with a button");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get());
    tf.setWidth("260px");
    group.addComponent(tf);

    Button button = new Button("Do It");
    // button.addStyleName("primary");
    group.addComponent(button);

    tf = new TextField("Borderless");
    tf.setInputPrompt("Write here");
    tf.addStyleName("inline-icon");
    tf.addStyleName("borderless");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("Right-aligned");
    tf.setValue("1,234");
    tf.addStyleName("align-right");
    row.addComponent(tf);

    tf = new TextField("Centered");
    tf.setInputPrompt("Guess what?");
    tf.addStyleName("align-center");
    row.addComponent(tf);

    PasswordField pwf = new PasswordField("Password");
    pwf.setInputPrompt("Secret words");
    pwf.addStyleName("inline-icon");
    pwf.setIcon(FontAwesome.LOCK);
    row.addComponent(pwf);

    pwf = new PasswordField("Password, right-aligned");
    pwf.setInputPrompt("Secret words");
    pwf.addStyleName("inline-icon");
    pwf.addStyleName("align-right");
    pwf.setIcon(FontAwesome.LOCK);
    row.addComponent(pwf);

    pwf = new PasswordField("Password, centered");
    pwf.setInputPrompt("Secret words");
    pwf.addStyleName("inline-icon");
    pwf.addStyleName("align-center");
    pwf.setIcon(FontAwesome.LOCK);
    row.addComponent(pwf);

    tf = new TextField("Tiny");
    tf.setValue("Field value");
    tf.addStyleName("tiny");
    row.addComponent(tf);

    tf = new TextField("Huge");
    tf.setValue("Field value");
    tf.addStyleName("huge");
    row.addComponent(tf);

    h1 = new Label("Text Areas");
    h1.addStyleName("h1");
    addComponent(h1);

    row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    TextArea ta = new TextArea("Normal");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Inline icon");
    ta.setInputPrompt("Inline icon not really working");
    ta.addStyleName("inline-icon");
    ta.setIcon(testIcon.get());
    row.addComponent(ta);

    ta = new TextArea("Custom color");
    ta.addStyleName("color1");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Custom color, read-only");
    ta.addStyleName("color2");
    ta.setValue("Field value, spanning multiple lines of text");
    ta.setReadOnly(true);
    row.addComponent(ta);

    ta = new TextArea("Custom color");
    ta.addStyleName("color3");
    ta.setValue("Field value, spanning multiple lines of text");
    row.addComponent(ta);

    ta = new TextArea("Small");
    ta.addStyleName("small");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Large");
    ta.addStyleName("large");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Borderless");
    ta.addStyleName("borderless");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Right-aligned");
    ta.addStyleName("align-right");
    ta.setValue("Field value, spanning multiple lines of text");
    row.addComponent(ta);

    ta = new TextArea("Centered");
    ta.addStyleName("align-center");
    ta.setValue("Field value, spanning multiple lines of text");
    row.addComponent(ta);

    ta = new TextArea("Tiny");
    ta.addStyleName("tiny");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Huge");
    ta.addStyleName("huge");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    RichTextArea rta = new RichTextArea();
    rta.setValue("<b>Some</b> <i>rich</i> content");
    row.addComponent(rta);

    rta = new RichTextArea("Read-only");
    rta.setValue("<b>Some</b> <i>rich</i> content");
    rta.setReadOnly(true);
    row.addComponent(rta);
}

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

License:Apache License

CssLayout buildMenu() {
    // Add items// ww w.  j a  v  a  2 s.c  o  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.cerebro.gorgone.landingpage.LandingPage.java

public LandingPage() {
    logger.info("Creazione della Landing Page");
    // Contenitore principale
    HorizontalLayout root = new HorizontalLayout();
    root.setId("landingPage_root");
    root.setMargin(true);/* w w  w  .  j  av a2  s  . com*/
    // Componente di registrazione
    signIn = new SignIn();
    signIn.resetField();
    // Componente di login
    login = new Login();

    root.addComponents(signIn, login);
    this.addComponents(root);
}

From source file:com.cerebro.gorgone.landingpage.SignInWindow.java

private Component setFirstStep() {
    VerticalLayout firstStep = new VerticalLayout();
    firstStep.setMargin(true);//from  w  w  w  .ja  v  a  2 s  .c  om
    // Body
    HorizontalLayout body = new HorizontalLayout();
    FormLayout datiIniziali = new FormLayout();
    TextField nomePG = new TextField("Nome del Personaggio");
    nomePG.setRequired(true);
    TextField cognomePG = new TextField("Cognome del Personaggio");
    cognomePG.setRequired(true);
    OptionGroup sessoPG = new OptionGroup("Sesso del Personaggio");
    sessoPG.setRequired(true);
    sessoPG.addItems("Maschio", "Femmina");
    ComboBox razzaPG = new ComboBox("Razza");
    razzaPG.setRequired(true);
    Slider age = new Slider("Et");
    age.setImmediate(true);
    age.setWidth("200px");
    age.setVisible(false);
    HorizontalLayout ageDescription = new HorizontalLayout();
    ageDescription.setHeight("250px");
    Label ageText = new Label("Valore dell'et: ");
    Label ageValue = new Label(age.getValue().toString());
    Label periodoVita = new Label("");
    ageDescription.addComponents(ageText, ageValue, periodoVita);
    age.addValueChangeListener((Property.ValueChangeEvent event) -> {
        System.out.println("Valore: " + age.getValue().toString());
        ageValue.setValue(age.getValue().toString());
        Double value = (100 * (age.getValue()) / (age.getMax()));
        if (value < 14) {
            periodoVita.setValue("Bambino");
        } else if (value > 14 && value < 24) {
            periodoVita.setValue("Adolescenza");
        } else if (value > 24 && value < 73) {
            periodoVita.setValue("Et adulta");
        } else if (value > 73) {
            periodoVita.setValue("Et anziana");
        }
    });
    ageDescription.addComponents(ageText, ageValue, periodoVita);
    ageDescription.setVisible(false);
    datiIniziali.addComponents(nomePG, cognomePG, sessoPG, razzaPG, age, ageDescription);
    Panel descrizioneRazza = new Panel();
    CssLayout descrizioneRazzaContent = new CssLayout();
    descrizioneRazza.setWidth("400px");
    descrizioneRazza.setHeight("500px");
    descrizioneRazza.setContent(descrizioneRazzaContent);
    //  Dettagli di popolazione e comportamento ComboBox
    TableQuery tq_races = new TableQuery(DatabaseTables.RACES_TABLE, connPool);
    tq_races.setVersionColumn(DatabaseTables.RACES_VERSION);
    SQLContainer container_races = null;
    try {
        container_races = new SQLContainer(tq_races);
    } catch (Exception ex) {
        logger.error(ex.getMessage());
    }
    razzaPG.setContainerDataSource(container_races);
    razzaPG.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
    razzaPG.setItemCaptionPropertyId(DatabaseTables.RACES_NAME);
    razzaPG.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (razzaPG.getValue() != null) {
                logger.info("Razza selezionata: " + razzaPG.getValue());
                age.setVisible(true);
                ageDescription.setVisible(true);
                descrizioneRazzaContent.removeAllComponents();
                Item item = razzaPG.getContainerDataSource().getItem(razzaPG.getValue());
                race = (String) item.getItemProperty(DatabaseTables.RACES_NAME).getValue();
                Label nameRace = new Label(race);
                FileResource imageSrc = new FileResource(
                        new File(MyUI.basePath + item.getItemProperty(DatabaseTables.RACES_IMAGE).getValue()));
                Image imageRace = new Image(null, imageSrc);
                imageRace.setWidth("200px");
                Label descriptionRace = new Label(
                        (String) item.getItemProperty(DatabaseTables.RACES_DESCRIPTION).getValue(),
                        ContentMode.HTML);
                min_age = (int) item.getItemProperty(DatabaseTables.RACES_MIN_AGE).getValue();
                max_age = (int) item.getItemProperty(DatabaseTables.RACES_MAX_AGE).getValue();
                age.setMin(min_age);
                age.setMax(max_age);
                strenght = (int) item.getItemProperty(DatabaseTables.RACES_STRENGHT).getValue();
                resistance = (int) item.getItemProperty(DatabaseTables.RACES_RESISTANCE).getValue();
                agility = (int) item.getItemProperty(DatabaseTables.RACES_AGILITY).getValue();
                intelligence = (int) item.getItemProperty(DatabaseTables.RACES_INTELLIGENCE).getValue();
                wisdom = (int) item.getItemProperty(DatabaseTables.RACES_WISDOM).getValue();
                charm = (int) item.getItemProperty(DatabaseTables.RACES_CHARM).getValue();
                Label min_ageL = new Label("Et minima: " + min_age);
                Label max_ageL = new Label("Et masima " + max_age);
                //                Panel levels = new Panel();
                //                VerticalLayout levelsContent = new VerticalLayout();
                //                levels.setContent(levelsContent);
                //                Label strenghtL = new Label("Forza: " + strenght);
                //                levelsContent.addComponents(strenghtL);

                String levelTable = "<table><tr><td>Forza</td><td>Resistenza</td><td>Agilit</td><td>Intelligenza</td>"
                        + "<td>Saggezza</td><td>Carisma</td></tr><tr>" + "<td>" + strenght + "</td>" + "<td>"
                        + resistance + "</td>" + "<td>" + agility + "</td>" + "<td>" + intelligence + "</td>"
                        + "<td>" + wisdom + "</td>" + "<td>" + charm + "</td>" + "</tr></table>";
                Label levels = new Label(levelTable, ContentMode.HTML);

                descrizioneRazzaContent.addComponents(nameRace, imageRace, descriptionRace, min_ageL, max_ageL,
                        levels);
            }
        }
    });

    body.addComponents(datiIniziali, descrizioneRazza);
    CssLayout footer = new CssLayout();
    Button next = new Button("Avanti ->");
    next.addClickListener((Button.ClickEvent event) -> {
        user.setNomePG(nomePG.getValue());
        user.setCognomePG(cognomePG.getValue());
        user.setSessoPG(sessoPG.getValue().toString());
        user.setRazzaPG(race);
        user.setEtaPG(age.getValue().toString());
        user.setForzaPG(strenght);
        user.setResistenzaPG(resistance);
        user.setAgilitaPG(agility);
        user.setIntelligenzaPG(intelligence);
        user.setSaggezzaPG(wisdom);
        user.setCarismaPG(charm);
        this.setContent(setSecondStep());
    });
    footer.addComponents(next, createCancelButton());
    firstStep.addComponents(setHeader("2/4"), body, footer);
    return firstStep;
}

From source file:com.cerebro.gorgone.landingpage.SignInWindow.java

private Component setSecondStep() {
    VerticalLayout secondStep = new VerticalLayout();
    HorizontalLayout body = new HorizontalLayout();
    Panel sx = new Panel();
    VerticalLayout sxContent = new VerticalLayout();
    sx.setContent(sxContent);/* w ww. j ava2s .  c  om*/
    Label welcome = null;
    if (user.getSessoPG().equals("Maschio")) {
        welcome = new Label("Benvenuto: " + user.getNomePG() + "!");
    } else if (user.getSessoPG().equals("Femmina")) {
        welcome = new Label("Benvenuta: " + user.getNomePG() + "!");
    }
    ComboBox carrieraPG = new ComboBox("Scegli la tua carriera:");
    carrieraPG.isRequired();
    Panel careerDescription = new Panel();
    CssLayout careerDescrContent = new CssLayout();
    careerDescription.setContent(careerDescrContent);
    sxContent.addComponents(welcome, carrieraPG, careerDescription);

    //  Dettagli di popolazione e comportamento ComboBox
    TableQuery tq_career = new TableQuery(DatabaseTables.CAREER_TABLE, connPool);
    tq_career.setVersionColumn(DatabaseTables.CAREER_VERSION);
    SQLContainer container_career = null;
    try {
        container_career = new SQLContainer(tq_career);
    } catch (Exception ex) {
        logger.error(ex.getMessage());
    }
    carrieraPG.setContainerDataSource(container_career);
    carrieraPG.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
    carrieraPG.setItemCaptionPropertyId(DatabaseTables.CAREER_NAME);
    carrieraPG.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (carrieraPG.getValue() != null) {
                logger.info("Carriera: " + carrieraPG.getValue().toString());
                careerDescrContent.removeAllComponents();
                Item item = (Item) carrieraPG.getContainerDataSource().getItem(carrieraPG.getValue());
                career = (String) item.getItemProperty(DatabaseTables.CAREER_NAME).getValue();
                Label careerName = new Label(career);
                FileResource imageSrc = new FileResource(
                        new File(MyUI.basePath + item.getItemProperty(DatabaseTables.CAREER_IMAGE).getValue()));
                Image imageCareer = new Image(null, imageSrc);
                imageCareer.setWidth("200px");
                Label careerDescription = new Label(item.getItemProperty(DatabaseTables.CAREER_DESCRIPTION),
                        ContentMode.HTML);
                strenght_car = (int) item.getItemProperty(DatabaseTables.CAREER_STRENGTH).getValue();
                resistance_car = (int) item.getItemProperty(DatabaseTables.CAREER_RESISTANCE).getValue();
                agility_car = (int) item.getItemProperty(DatabaseTables.CAREER_AGILITY).getValue();
                intelligence_car = (int) item.getItemProperty(DatabaseTables.CAREER_INTELLIGENCE).getValue();
                wisdom_car = (int) item.getItemProperty(DatabaseTables.CAREER_WISDOM).getValue();
                charm_car = (int) item.getItemProperty(DatabaseTables.CAREER_CHARM).getValue();
                String modsTable = "<table><tr><td>Forza</td><td>Resistenza</td><td>Agilit</td><td>Intelligenza</td>"
                        + "<td>Saggezza</td><td>Carisma</td></tr><tr>" + "<td>" + strenght_car + "</td>"
                        + "<td>" + resistance_car + "</td>" + "<td>" + agility_car + "</td>" + "<td>"
                        + intelligence_car + "</td>" + "<td>" + wisdom_car + "</td>" + "<td>" + charm_car
                        + "</td>" + "</tr></table>";
                Label mods = new Label(modsTable, ContentMode.HTML);
                careerDescrContent.addComponents(careerName, imageCareer, careerDescription, mods);
            }

        }

    });

    Panel dx = new Panel();
    VerticalLayout dxContent = new VerticalLayout();
    dx.setContent(dxContent);
    ComboBox orientamentoPG = new ComboBox("Scegli il tuo orientamento:");
    orientamentoPG.isRequired();
    Panel orientamentoDescription = new Panel();
    CssLayout orientamentoDescrContent = new CssLayout();
    orientamentoDescription.setContent(orientamentoDescrContent);
    dxContent.addComponents(orientamentoPG, orientamentoDescription);
    //  Dettagli di popolazione e comportamento ComboBox
    TableQuery tq_orientamento = new TableQuery(DatabaseTables.MORALCODE_TABLE, connPool);
    tq_orientamento.setVersionColumn(DatabaseTables.MORALCODE_VERSION);
    SQLContainer container_orientamento = null;
    try {
        container_orientamento = new SQLContainer(tq_orientamento);
    } catch (Exception ex) {
        logger.error(ex.getMessage());
    }
    orientamentoPG.setContainerDataSource(container_orientamento);
    orientamentoPG.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
    orientamentoPG.setItemCaptionPropertyId(DatabaseTables.MORALCODE_TENDENCY);
    orientamentoPG.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (orientamentoPG.getValue() != null) {
                logger.info("Orientamento: " + orientamentoPG.getValue().toString());
                orientamentoDescrContent.removeAllComponents();
                Item item = (Item) orientamentoPG.getContainerDataSource().getItem(orientamentoPG.getValue());
                moralCode = (String) item.getItemProperty(DatabaseTables.MORALCODE_TENDENCY).getValue();
                Label orientamentoName = new Label(moralCode);
                FileResource imageSrc = new FileResource(new File(
                        MyUI.basePath + item.getItemProperty(DatabaseTables.MORALCODE_IMAGE).getValue()));
                Image imageTendency = new Image(null, imageSrc);
                imageTendency.setWidth("200px");
                Label orientamentoDescription = new Label(
                        item.getItemProperty(DatabaseTables.MORALCODE_DESCRIPTION), ContentMode.HTML);

                orientamentoDescrContent.addComponents(orientamentoName, imageTendency,
                        orientamentoDescription);
            }

        }

    });

    body.addComponents(sx, dx);
    CssLayout footer = new CssLayout();
    Button next = new Button("Avanti ->");
    next.addClickListener((Button.ClickEvent event) -> {
        user.setCarrieraPG(career);
        // Gestire modificatori
        user.setForzaPG(user.getForzaPG() + strenght_car);
        user.setResistenzaPG(user.getResistenzaPG() + resistance_car);
        user.setAgilitaPG(user.getAgilitaPG() + agility_car);
        user.setIntelligenzaPG(user.getIntelligenzaPG() + intelligence_car);
        user.setSaggezzaPG(user.getSaggezzaPG() + wisdom_car);
        user.setCarismaPG(user.getCarismaPG() + charm_car);
        user.setOrientamentoPG(moralCode);
        this.setContent(setThirdStep());
    });
    footer.addComponents(next, createCancelButton());
    secondStep.addComponents(setHeader("3/4"), body, footer);
    return secondStep;
}

From source file:com.cerebro.provevaadin.ChatOffGame.java

public ChatOffGame() {
    Panel messagesPanel = new Panel();
    messagesPanel.setSizeFull();/* w w  w . j  ava 2 s. co m*/
    messagesPanel.setContent(messages);
    this.addComponent(messagesPanel);
    this.setExpandRatio(messagesPanel, 1.0f);

    HorizontalLayout sendBar = new HorizontalLayout();
    sendBar.setWidth("100%");
    final TextField input = new TextField();
    input.setWidth("100%");
    sendBar.addComponent(input);
    sendBar.setExpandRatio(input, 1.0f);

    Button send = new Button("Send");
    send.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    send.addClickListener((Button.ClickEvent event) -> {
        BroadcasterOffGame.broadcast(input.getValue(), FROM);
        input.setValue("");
    });
    sendBar.addComponent(send);
    this.addComponent(sendBar);

    BroadcasterOffGame.register(this);
}

From source file:com.cerebro.provevaadin.ChatOnGame.java

public ChatOnGame(User user) {
    if (user.getUltimoLuogoPG() != null) {
        logger.info("Luogo: " + user.getUltimoLuogoPG());
    } else {/*  w w  w  .  jav  a  2 s.  c o  m*/
        logger.info("Nessun luogo selezionato");
    }
    Panel messagesPanel = new Panel();
    messagesPanel.setSizeFull();
    messagesPanel.setContent(messages);
    this.addComponent(messagesPanel);
    this.setExpandRatio(messagesPanel, 1.0f);

    HorizontalLayout sendBar = new HorizontalLayout();
    sendBar.setWidth("100%");
    final TextField input = new TextField();
    input.setWidth("100%");
    sendBar.addComponent(input);
    sendBar.setExpandRatio(input, 1.0f);

    Button send = new Button("Send");
    send.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    send.addClickListener((Button.ClickEvent event) -> {
        logger.info("Invio del messaggio al server");
        BroadcasterOnGame.broadcast(input.getValue(), FROM);
        input.setValue("");
    });
    sendBar.addComponent(send);
    this.addComponent(sendBar);

    BroadcasterOnGame.register(this);
}

From source file:com.cerebro.provevaadin.Secure.java

public Secure() {

    HorizontalLayout top = new HorizontalLayout();
    this.addComponent(top);
    top.addComponent(new Label("Area sicura"));

    VerticalLayout content = new VerticalLayout();
    this.addComponent(content);

    Navigator nav = new Navigator(UI.getCurrent(), content);
    nav.setErrorView(new ErrorView());
    nav.addView("", new HomeView());
    nav.navigateTo("");

    Button logout = new Button("Logout");
    logout.addClickListener((Button.ClickEvent event) -> {
        System.out.println("Esco dalla sessione");
        SecurityUtils.getSubject().logout();
        UI.getCurrent().getSession().close();
        UI.getCurrent().getPage().setLocation("");
    });/*w ww  .j  a  va2  s.  c om*/
    top.addComponent(logout);
}

From source file:com.cerebro.provevaadin.SignIn.java

private VerticalLayout setFirstStep() {
    VerticalLayout firstStep = new VerticalLayout();
    CssLayout header = new CssLayout();
    Label title = new Label("Benvenuto " + u.getNomeUtente() + "!");
    Label istructions = new Label("Crea il tuo personaggio");
    Label step = new Label("1/*");
    header.addComponents(title, istructions, step);
    HorizontalLayout body = new HorizontalLayout();
    FormLayout datiIniziali = new FormLayout();
    TextField nomePG = new TextField("Nome del Personaggio");
    TextField cognomePG = new TextField("Cognome del Personaggio");
    OptionGroup sessoPG = new OptionGroup("Sesso del Personaggio");
    sessoPG.addItems("Maschio", "Femmina");
    ComboBox razzaPG = new ComboBox("Razza");
    datiIniziali.addComponents(nomePG, cognomePG, sessoPG, razzaPG);
    HorizontalLayout descrizioneRazza = new HorizontalLayout();
    descrizioneRazza.setWidth(datiIniziali.getWidth(), datiIniziali.getWidthUnits());
    //        Dettagli di popolazione e comportamento ComboBox
    razzaPG.addItem("Essere umano");
    body.addComponents(datiIniziali, descrizioneRazza);
    CssLayout footer = new CssLayout();
    Button next = new Button("Avanti ->");
    next.addClickListener((Button.ClickEvent event) -> {
        u.setNomePG(nomePG.getValue());//from   w w  w  . j  ava  2s. c  o m
        u.setCognomePG(cognomePG.getValue());
        u.setSessoPG(sessoPG.getValue().toString());
        u.setRazzaPG(razzaPG.getValue().toString());
        this.setContent(setSecondStep());
    });
    footer.addComponents(next, createCancelButton());

    firstStep.addComponents(header, body, footer);
    return firstStep;
}