Example usage for com.vaadin.ui GridLayout setComponentAlignment

List of usage examples for com.vaadin.ui GridLayout setComponentAlignment

Introduction

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

Prototype

@Override
    public void setComponentAlignment(Component childComponent, Alignment alignment) 

Source Link

Usage

From source file:dhbw.clippinggorilla.userinterface.windows.NewSourceWindow.java

public Component getFooter(Runnable cancelRunnable, Runnable nextRunnable, Component... extraComponents) {
    Label placeholder = new Label();
    Button cancel = new Button(Language.get(Word.CANCEL), VaadinIcons.CLOSE);
    cancel.addClickListener(ce -> cancelRunnable.run());
    Button next = new Button(Language.get(Word.NEXT), VaadinIcons.ARROW_RIGHT);
    next.addClickListener(ce -> nextRunnable.run());
    GridLayout footer = new GridLayout(3 + extraComponents.length, 1);
    footer.setSpacing(true);/*  w  ww .ja  v a  2 s  .  com*/
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth(100.0f, Sizeable.Unit.PERCENTAGE);
    footer.setSizeUndefined();
    footer.setWidth("100%");
    for (Component extraComponent : extraComponents) {
        footer.addComponent(extraComponent);
        footer.setComponentAlignment(extraComponent, Alignment.MIDDLE_CENTER);
    }
    footer.addComponents(placeholder, cancel, next);
    footer.setColumnExpandRatio(footer.getColumns() - 1 - 2, 1);//ExpandRatio(placeholder, 1);
    footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(next, Alignment.MIDDLE_CENTER);
    return footer;
}

From source file:dhbw.clippinggorilla.userinterface.windows.RegisterWindow.java

public RegisterWindow() {
    setModal(true);/*from w  w w.  ja v  a 2  s.  c  o  m*/
    setResizable(false);
    setDraggable(false);
    setCaption(Language.get(Word.REGISTER));
    addCloseShortcut(KeyCode.ENTER, null);

    Button save = new Button(Language.get(Word.REGISTER));

    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.setMargin(false);
    windowLayout.setSizeUndefined();

    FormLayout forms = new FormLayout();
    forms.setMargin(true);
    forms.setSizeUndefined();

    TextField firstName = new TextField(Language.get(Word.FIRST_NAME));
    firstName.focus();
    firstName.setMaxLength(20);
    firstName.addValueChangeListener(event -> {
        String firstNameError = UserUtils.checkName(event.getValue());
        if (!firstNameError.isEmpty()) {
            firstName.setComponentError(new UserError(firstNameError, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(firstNameError);
            save.setEnabled(setError(firstName, true));
        } else {
            firstName.setComponentError(null);
            boolean enabled = setError(firstName, false);
            save.setEnabled(enabled);
        }
    });
    forms.addComponent(firstName);

    TextField lastName = new TextField(Language.get(Word.LAST_NAME));
    lastName.setMaxLength(20);
    lastName.addValueChangeListener(event -> {
        String lastNameError = UserUtils.checkName(event.getValue());
        if (!lastNameError.isEmpty()) {
            lastName.setComponentError(new UserError(lastNameError, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(lastNameError);
            save.setEnabled(setError(lastName, true));
        } else {
            lastName.setComponentError(null);
            save.setEnabled(setError(lastName, false));
        }
    });
    forms.addComponent(lastName);

    TextField userName = new TextField(Language.get(Word.USERNAME));
    userName.setMaxLength(20);
    userName.addValueChangeListener(event -> {
        String userNameError = UserUtils.checkUsername(event.getValue());
        if (!userNameError.isEmpty()) {
            userName.setComponentError(new UserError(userNameError, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(userNameError);
            save.setEnabled(setError(userName, true));
        } else {
            userName.setComponentError(null);
            save.setEnabled(setError(userName, false));

        }
    });
    forms.addComponent(userName);

    TextField email1 = new TextField(Language.get(Word.EMAIL));
    email1.setMaxLength(256);
    email1.addValueChangeListener(event -> {
        String email1Error = UserUtils.checkEmail(event.getValue().toLowerCase());
        if (!email1Error.isEmpty()) {
            email1.setComponentError(new UserError(email1Error, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(email1Error);
            save.setEnabled(setError(email1, true));
        } else {
            email1.setComponentError(null);
            save.setEnabled(setError(email1, false));
        }
    });
    forms.addComponent(email1);

    TextField email2 = new TextField(Language.get(Word.EMAIL_AGAIN));
    email2.setMaxLength(256);
    email2.addValueChangeListener(event -> {
        String email2Error = UserUtils.checkEmail(event.getValue().toLowerCase())
                + UserUtils.checkSecondEmail(email1.getValue().toLowerCase(), event.getValue().toLowerCase());
        if (!email2Error.isEmpty()) {
            email2.setComponentError(new UserError(email2Error, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(email2Error);
            save.setEnabled(setError(email2, true));
        } else {
            email2.setComponentError(null);
            save.setEnabled(setError(email2, false));
        }
    });
    forms.addComponent(email2);

    ProgressBar strength = new ProgressBar();

    PasswordField password1 = new PasswordField(Language.get(Word.PASSWORD));
    password1.setMaxLength(51);
    password1.addValueChangeListener(event -> {
        String password1Error = UserUtils.checkPassword(event.getValue());
        strength.setValue(UserUtils.calculatePasswordStrength(event.getValue()));
        if (!password1Error.isEmpty()) {
            password1.setComponentError(new UserError(password1Error, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(password1Error);
            save.setEnabled(setError(password1, true));
        } else {
            password1.setComponentError(null);
            save.setEnabled(setError(password1, false));
        }

    });
    forms.addComponent(password1);

    strength.setWidth("184px");
    strength.setHeight("1px");
    forms.addComponent(strength);

    PasswordField password2 = new PasswordField(Language.get(Word.PASSWORD_AGAIN));
    password2.setMaxLength(51);
    password2.addValueChangeListener(event -> {
        String password2Error = UserUtils.checkPassword(event.getValue())
                + UserUtils.checkSecondPassword(password1.getValue(), event.getValue());
        if (!password2Error.isEmpty()) {
            password2.setComponentError(new UserError(password2Error, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(password2Error);
            save.setEnabled(setError(password2, true));
        } else {
            password2.setComponentError(null);
            save.setEnabled(setError(password2, false));
        }
    });
    forms.addComponent(password2);

    GridLayout footer = new GridLayout(3, 1);
    footer.setSpacing(true);
    footer.setSizeUndefined();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth(100.0f, Unit.PERCENTAGE);

    Label placeholder = new Label();

    Button cancel = new Button(Language.get(Word.CANCEL));
    cancel.setIcon(VaadinIcons.CLOSE);
    cancel.addClickListener(ce -> {
        close();
    });
    cancel.setClickShortcut(KeyCode.ESCAPE, null);

    save.setEnabled(false);
    save.setIcon(VaadinIcons.CHECK);
    save.addStyleName(ValoTheme.BUTTON_PRIMARY);
    save.addClickListener(ce -> {
        try {
            User user = UserUtils.registerUser(userName.getValue(), password1.getValue(), password2.getValue(),
                    email1.getValue().toLowerCase(), email2.getValue().toLowerCase(), firstName.getValue(),
                    lastName.getValue());
            UserUtils.setCurrentUser(user);
            close();
            UI.getCurrent().addWindow(ActivateWindow.get());
        } catch (UserCreationException ex) {
            Log.error("Registration failed", ex);
            VaadinUtils.errorNotification(Language.get(Word.REG_FAILED));
        }
    });
    save.setClickShortcut(KeyCode.ENTER, null);

    footer.addComponents(placeholder, cancel, save);
    footer.setColumnExpandRatio(0, 1);//ExpandRatio(placeholder, 1);
    footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(save, Alignment.MIDDLE_CENTER);

    windowLayout.addComponent(forms);
    windowLayout.addComponent(footer);

    setContent(windowLayout);
}

From source file:dhbw.ka.mwi.businesshorizon2.ui.scenarioscreen.ScenarioScreenViewImpl.java

License:Open Source License

/**
 * Die Methode fuegt der View ein Szenario hinzu. Sie baut hierzu saemtliche
 * notwendigen GUI-Elemente und entsprechenden Listener hinzu.
 * //from  ww  w .j  a v a2  s  .  c o m
 * Auf ein GridLayout umgestellt.
 * 
 * @author Julius Hacker, Tobias Lindner
 * @param rateReturnEquity Standardwert fuer die Renditeforderung Eigenkapital
 * @param rateReturnCapitalStock Standardwert fuer die Renditeforderung Fremdkapital
 * @param businessTax Standardwert fuer die Gewerbesteuer
 * @param corporateAndSolitaryTax Standardwert fuer die Koerperschaftssteuer mit Solidaritaetszuschlag.
 */

@Override
public void addScenario(String rateReturnEquity, String rateReturnCapitalStock, String corporateAndSolitaryTax,
        String businessTax, String personalTaxRate, boolean isIncludeInCalculation, final int number) {
    HashMap<String, AbstractComponent> scenarioComponents = new HashMap<String, AbstractComponent>();

    Property.ValueChangeListener changeListener = new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            presenter.updateScenario(number);
            logger.debug("TextChange ausgeloest");
            logger.debug("ChangeListener " + System.identityHashCode(this));
            presenter.isValid();
        }
    };

    final GridLayout gl = new GridLayout(3, 7);
    gl.addStyleName("gridLayoutScenarios");
    gl.setSizeFull();
    gl.setColumnExpandRatio(0, 2);
    gl.setColumnExpandRatio(1, 1);
    gl.setColumnExpandRatio(2, 1);

    final Label scenarioName = new Label("<strong>Szenario " + number + "</strong>");
    scenarioName.setContentMode(Label.CONTENT_XHTML);
    scenarioComponents.put("label", scenarioName);

    logger.debug("SzenarioName: " + scenarioName);
    gl.addComponent(scenarioName, 0, 0);

    //EK Rendite
    final Label textEigenkapital = new Label("Renditeforderung Eigenkapital: ");
    textEigenkapital.setSizeFull();

    final TextField tfEigenkapital = new TextField();

    if (!"0.0".equals(rateReturnEquity)) {
        tfEigenkapital.setValue(rateReturnEquity);
    }

    tfEigenkapital.setImmediate(true);
    tfEigenkapital.addStyleName("scenario");
    tfEigenkapital.addListener(changeListener);

    gl.addComponent(textEigenkapital, 0, 1);
    gl.addComponent(tfEigenkapital, 1, 1);

    scenarioComponents.put("rateReturnEquity", tfEigenkapital);

    // Fremdkapital      
    final Label textFremdkapitel = new Label("Renditeforderung FK: ");

    final TextField tfFremdkapital = new TextField();

    if (!"0.0".equals(rateReturnCapitalStock)) {
        tfFremdkapital.setValue(rateReturnCapitalStock);
    }

    tfFremdkapital.setImmediate(true);
    tfFremdkapital.addStyleName("scenario");
    tfFremdkapital.addListener(changeListener);

    gl.addComponent(textFremdkapitel, 0, 2);
    gl.addComponent(tfFremdkapital, 1, 2);

    scenarioComponents.put("rateReturnCapitalStock", tfFremdkapital);

    //Gewerbesteuer
    final Label textGewerbesteuer = new Label("Gewerbesteuer:");
    final TextField tfGewerbesteuer = new TextField();

    if (!"0.0".equals(businessTax)) {
        tfGewerbesteuer.setValue(businessTax);
    }

    tfGewerbesteuer.setImmediate(true);
    tfGewerbesteuer.addStyleName("scenario");
    tfGewerbesteuer.addListener(changeListener);

    gl.addComponent(textGewerbesteuer, 0, 3);
    gl.addComponent(tfGewerbesteuer, 1, 3);

    scenarioComponents.put("businessTax", tfGewerbesteuer);

    //Krperschaftssteuer
    final Label textKoerperschaftssteuer = new Label("Krperschaftssteuer mit Solidarittszuschlag: ");

    final TextField tfKoerperschaftssteuer = new TextField();

    if (!"0.0".equals(corporateAndSolitaryTax)) {
        tfKoerperschaftssteuer.setValue(corporateAndSolitaryTax);
    }

    tfKoerperschaftssteuer.setImmediate(true);
    tfKoerperschaftssteuer.addStyleName("scenario");
    tfKoerperschaftssteuer.addListener(changeListener);

    gl.addComponent(textKoerperschaftssteuer, 0, 4);
    gl.addComponent(tfKoerperschaftssteuer, 1, 4);

    scenarioComponents.put("corporateAndSolitaryTax", tfKoerperschaftssteuer);

    // Persnlicher Steuersatz
    final Label textPersonalTaxRate = new Label("pers\u00F6nlicher Steuersatz: ");
    final TextField tfPersonalTaxRate = new TextField();
    if (!"0.0".equals(personalTaxRate)) {
        tfPersonalTaxRate.setValue(personalTaxRate);
    }
    tfPersonalTaxRate.setImmediate(true);
    tfPersonalTaxRate.addStyleName("scenario");
    tfPersonalTaxRate.addListener(changeListener);

    gl.addComponent(textPersonalTaxRate, 0, 5);
    gl.addComponent(tfPersonalTaxRate, 1, 5);

    scenarioComponents.put("personalTaxRate", tfPersonalTaxRate);

    deleteIcon = new Embedded(null,
            new ThemeResource("./images/icons/newIcons/1418766003_editor_trash_delete_recycle_bin_-128.png"));
    deleteIcon.setHeight(60, UNITS_PIXELS);
    deleteIcon.addStyleName("deleteScenario");

    deleteIcon.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void click(ClickEvent event) {
            presenter.removeScenario(number);
        }

    });

    gl.addComponent(deleteIcon, 2, 0, 2, 6);
    gl.setComponentAlignment(deleteIcon, Alignment.MIDDLE_CENTER);

    final Label gap = new Label();
    gap.setHeight(20, UNITS_PIXELS);

    gl.addComponent(gap, 0, 6);

    scenarioComponents.put("scenario", gl);

    this.scenarios.add(scenarioComponents);
    this.vlScenarios.addComponent(gl);

    //Button bei 3 Scenarios deaktivieren
    if (number == 3) {
        deactivateAddScenario();
    }
}

From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java

License:Open Source License

void handleShowActiveUsersPerServer(MenuBar mbar) {
    Object[][] oa = Mmowgli2UI.getGlobals().getSessionCountByServer();

    Window svrCountWin = new Window("Display Active Users Per Server");
    svrCountWin.setModal(true);/*from w  w w. j  a v a 2 s.  com*/
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("99%");
    svrCountWin.setContent(layout);

    GridLayout gl = new GridLayout(2, Math.max(1, oa.length));
    gl.setSpacing(true);
    gl.addStyleName("m-greyborder");
    for (Object[] row : oa) {
        Label lab = new Label();
        lab.setSizeUndefined();
        lab.setValue(row[0].toString());
        gl.addComponent(lab);
        gl.setComponentAlignment(lab, Alignment.MIDDLE_RIGHT);

        gl.addComponent(new Label(row[1].toString()));
    }
    layout.addComponent(gl);
    layout.setComponentAlignment(gl, Alignment.MIDDLE_CENTER);

    svrCountWin.setWidth("250px");
    UI.getCurrent().addWindow(svrCountWin);
    svrCountWin.center();
}

From source file:edu.nps.moves.mmowgli.export.BaseExporter.java

License:Open Source License

protected void getMetaStringOrCancel(final MetaListener lis, String title, final Map<String, String> params) {
    final Window dialog = new Window(title);
    final TextField[] parameterFields;

    dialog.setModal(true);/*  www  .  java  2  s .  c o  m*/

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();
    dialog.setContent(layout);

    final TextArea ta = new TextArea();
    ta.setWidth("100%");
    ta.setInputPrompt("Type a description of this data, or the game which generated this data (optional)");

    ta.setImmediate(true);
    layout.addComponent(ta);

    Set<String> keySet = params.keySet();
    parameterFields = new TextField[keySet.size()];
    int i = 0;
    GridLayout pGL = new GridLayout();
    pGL.addStyleName("m-greyborder");
    pGL.setColumns(2);
    Label hdr = new HtmlLabel("<b>Parameters</b>");
    hdr.addStyleName("m-textaligncenter");
    pGL.addComponent(hdr, 0, 0, 1, 0); // top row
    pGL.setComponentAlignment(hdr, Alignment.MIDDLE_CENTER);
    pGL.setSpacing(false);
    for (String key : keySet) {
        pGL.addComponent(new HtmlLabel("&nbsp;" + key + "&nbsp;&nbsp;"));
        pGL.addComponent(parameterFields[i] = new TextField());
        parameterFields[i++].setValue(params.get(key));
    }
    if (i > 0) {
        layout.addComponent(pGL);
        layout.setComponentAlignment(pGL, Alignment.TOP_CENTER);
    }

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    @SuppressWarnings("serial")
    Button cancelButt = new Button("Cancel", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            dialog.close();
            lis.continueOrCancel(null);
        }
    });

    @SuppressWarnings("serial")
    Button exportButt = new Button("Export", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            dialog.close();

            Set<String> keySet = params.keySet();
            int i = 0;
            for (String key : keySet)
                params.put(key, parameterFields[i++].getValue().toString());

            lis.continueOrCancel(ta.getValue().toString());
        }
    });
    hl.addComponent(cancelButt);
    hl.addComponent(exportButt);
    hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT);
    hl.setExpandRatio(cancelButt, 1.0f);

    // The components added to the window are actually added to the window's
    // layout; you can use either. Alignments are set using the layout
    layout.addComponent(hl);
    dialog.setWidth("385px");
    dialog.setHeight("310px");
    hl.setWidth("100%");
    ta.setWidth("100%");
    ta.setHeight("100%");
    layout.setExpandRatio(ta, 1.0f);

    UI.getCurrent().addWindow(dialog);
}

From source file:edu.nps.moves.mmowgliMobile.ui.UserRenderer2.java

License:Open Source License

public void addRow(GridLayout lay, String label, String value) {
    Label lbl;//from www . j  a  v  a  2s . c o m
    lay.addComponent(lbl = new Label(label));
    lbl.setStyleName("light-text");
    lbl.setSizeUndefined();
    lay.setComponentAlignment(lbl, Alignment.TOP_RIGHT);

    lay.addComponent(new HtmlLabel(value));
}

From source file:fr.amapj.view.views.permanence.mespermanences.grille.InscriptionPopupRoleDifferent.java

License:Open Source License

/**
 * Permet de dessiner le tableau //  w w  w.  j a  va  2 s. c  om
 */
public void drawTab(Tab tab) {
    GridLayout gl = new GridLayout(4, 1 + tab.lines.size());
    gl.setWidth("800px");
    gl.setSpacing(false);

    contentLayout.addComponent(gl);

    // Construction du titre   
    Label l = new Label(tab.titre);
    l.addStyleName(tab.styleTitre);
    l.setWidth("100%");
    gl.addComponent(l, 0, 0, 3, 0);

    List<TabLine> lines = tab.lines;
    for (int i = 0; i < lines.size(); i++) {
        TabLine line = lines.get(i);

        int height = computeHeight(line);
        // La taille minimale est de 36 pixels, pour les boutons inscrire / desincrire
        height = Math.max(height, 36);

        Label l1 = new Label(line.col1);
        l1.addStyleName(line.styleCol1);
        l1.setWidth("100%");
        l1.setHeight(height + "px");
        gl.addComponent(l1, 0, i + 1);

        Label l2 = new Label(line.col2);
        l2.addStyleName(line.styleCol2);
        l2.setWidth("100%");
        l2.setHeight(height + "px");
        gl.addComponent(l2, 1, i + 1);

        Label l3 = new Label(line.col3);
        l3.addStyleName(line.styleCol3);
        l3.setWidth("100%");
        l3.setHeight(height + "px");
        gl.addComponent(l3, 2, i + 1);

        if (line.col4 != null) {
            Button b = new Button(line.col4);
            b.addStyleName(line.styleCol4);
            b.addClickListener(e -> handleButton(line.role));
            b.setWidth("100%");
            gl.addComponent(b, 3, i + 1);
            gl.setComponentAlignment(b, Alignment.MIDDLE_CENTER);
        } else {
            Label l4 = new Label("");
            l4.addStyleName(line.styleCol4);
            l4.setWidth("100%");
            l4.setHeight(height + "px");
            gl.addComponent(l4, 3, i + 1);
        }
    }
}

From source file:fr.amapj.view.views.permanence.mespermanences.grille.InscriptionPopupToutAutorise.java

License:Open Source License

/**
 * Permet de dessiner le tableau /*ww  w. j  a v  a  2 s . c o  m*/
 */
public void drawTab(Tab tab) {
    GridLayout gl = new GridLayout(3, 1 + tab.lines.size());
    gl.setWidth("600px");
    gl.setSpacing(false);

    contentLayout.addComponent(gl);

    // Construction du titre   
    Label l = new Label(tab.titre);
    l.addStyleName(tab.styleTitre);
    l.setWidth("100%");
    gl.addComponent(l, 0, 0, 2, 0);

    List<TabLine> lines = tab.lines;
    for (int i = 0; i < lines.size(); i++) {
        TabLine line = lines.get(i);

        int height = computeHeight(line);
        // La taille minimale est de 36 pixels, pour les boutons inscrire / desincrire
        height = Math.max(height, 36);

        Label l1 = new Label(line.col1);
        l1.addStyleName(line.styleCol1);
        l1.setWidth("100%");
        l1.setHeight(height + "px");
        gl.addComponent(l1, 0, i + 1);

        Label l2 = new Label(line.col2);
        l2.addStyleName(line.styleCol2);
        l2.setWidth("100%");
        l2.setHeight(height + "px");
        gl.addComponent(l2, 1, i + 1);

        if (line.col3 != null) {
            Button b = new Button(line.col3);
            b.addStyleName(line.styleCol3);
            b.addClickListener(e -> handleButton(line.cell));
            b.setWidth("100%");
            gl.addComponent(b, 2, i + 1);
            gl.setComponentAlignment(b, Alignment.MIDDLE_CENTER);
        } else {
            Label l3 = new Label("");
            l3.addStyleName(line.styleCol3);
            l3.setWidth("100%");
            l3.setHeight(height + "px");
            gl.addComponent(l3, 2, i + 1);
        }
    }
}

From source file:fr.univlorraine.mondossierweb.views.windows.FiltreInscritsMobileWindow.java

License:Apache License

/**
 * Cre une fentre/*  ww w . ja v a 2s  .c  o m*/
 */
public FiltreInscritsMobileWindow() {
    setWidth("95%");
    setModal(true);
    setResizable(false);
    setClosable(true);

    setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale()));
    setStyleName("v-popover-blank");

    typeFavori = MdwTouchkitUI.getCurrent().getTypeObjListInscrits();

    GridLayout layout = new GridLayout(1, 2);
    layout.setWidth("100%");
    layout.setSpacing(true);
    layout.setMargin(true);
    setContent(layout);

    //Si on affiche la liste des inscrits  un ELP
    //on doit affiche l'tape d'appartenance et ventuellement les groupes
    //Affichage d'une liste droulante contenant la liste des annes
    if (typeIsElp()) {

        //GESTION DES ETAPES
        List<VersionEtape> letapes = MdwTouchkitUI.getCurrent().getListeEtapesInscrits();
        if (letapes != null && letapes.size() > 0) {

            Label etapeLabel = new Label(applicationContext.getMessage(NAME + ".etape", null, getLocale()));
            layout.addComponent(etapeLabel);
            layout.setComponentAlignment(etapeLabel, Alignment.BOTTOM_LEFT);
            listeEtapes = new NativeSelect();
            listeEtapes.setNullSelectionAllowed(false);
            listeEtapes.setRequired(false);
            listeEtapes.setWidth("100%");
            listeEtapes.addItem(TOUTES_LES_ETAPES_LABEL);
            listeEtapes.setItemCaption(TOUTES_LES_ETAPES_LABEL, TOUTES_LES_ETAPES_LABEL);
            for (VersionEtape etape : letapes) {
                String idEtape = etape.getId().getCod_etp() + "/" + etape.getId().getCod_vrs_vet();
                listeEtapes.addItem(idEtape);
                listeEtapes.setItemCaption(idEtape, "[" + idEtape + "] " + etape.getLib_web_vet());
            }

            if (MdwTouchkitUI.getCurrent().getEtapeInscrits() != null) {
                listeEtapes.setValue(MdwTouchkitUI.getCurrent().getEtapeInscrits());
            } else {

                listeEtapes.setValue(TOUTES_LES_ETAPES_LABEL);
            }
            //Gestion de l'vnement sur le changement d'tape
            listeEtapes.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(ValueChangeEvent event) {
                    vetSelectionnee = (String) event.getProperty().getValue();
                    if (vetSelectionnee.equals(TOUTES_LES_ETAPES_LABEL)) {
                        vetSelectionnee = null;
                    }
                    MdwTouchkitUI.getCurrent().setEtapeInscrits(vetSelectionnee);
                    //faire le changement
                    groupeSelectionne = ((listeGroupes != null && listeGroupes.getValue() != null)
                            ? (String) listeGroupes.getValue()
                            : null);
                    if (groupeSelectionne != null && groupeSelectionne.equals(TOUS_LES_GROUPES_LABEL)) {
                        groupeSelectionne = null;
                    }

                    //update de l'affichage
                    //initListe();

                }
            });
            layout.addComponent(listeEtapes);

        }

        //GESTION DES GROUPES
        List<ElpDeCollection> lgroupes = MdwTouchkitUI.getCurrent().getListeGroupesInscrits();
        if (lgroupes != null && lgroupes.size() > 0) {

            // Label "GROUPE"
            HorizontalLayout gLayout = new HorizontalLayout();
            gLayout.setSizeFull();
            Label groupeLabel = new Label(applicationContext.getMessage(NAME + ".groupe", null, getLocale()));
            gLayout.addComponent(groupeLabel);
            gLayout.setComponentAlignment(groupeLabel, Alignment.MIDDLE_LEFT);
            layout.addComponent(gLayout);

            //Liste droulante pour choisir le groupe
            listeGroupes = new NativeSelect();
            listeGroupes.setNullSelectionAllowed(false);
            listeGroupes.setRequired(false);
            listeGroupes.setWidth("100%");
            listeGroupes.addItem(TOUS_LES_GROUPES_LABEL);
            listeGroupes.setItemCaption(TOUS_LES_GROUPES_LABEL, TOUS_LES_GROUPES_LABEL);
            for (ElpDeCollection edc : lgroupes) {
                for (CollectionDeGroupes cdg : edc.getListeCollection()) {
                    for (Groupe groupe : cdg.getListeGroupes()) {
                        listeGroupes.addItem(groupe.getCleGroupe());
                        listeGroupes.setItemCaption(groupe.getCleGroupe(), groupe.getLibGroupe());

                    }
                }
            }
            //On pr-remplie le groupe choisi si on en a dj choisi un
            if (MdwTouchkitUI.getCurrent().getGroupeInscrits() != null) {
                listeGroupes.setValue(MdwTouchkitUI.getCurrent().getGroupeInscrits());
            } else {
                listeGroupes.setValue(TOUS_LES_GROUPES_LABEL);
            }

            //Gestion de l'vnement sur le changement de groupe
            listeGroupes.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(ValueChangeEvent event) {
                    groupeSelectionne = (String) event.getProperty().getValue();
                    if (groupeSelectionne.equals(TOUS_LES_GROUPES_LABEL)) {
                        groupeSelectionne = null;
                    }
                    MdwTouchkitUI.getCurrent().setGroupeInscrits(groupeSelectionne);
                    //faire le changement
                    vetSelectionnee = ((listeEtapes != null && listeEtapes.getValue() != null)
                            ? (String) listeEtapes.getValue()
                            : null);
                    if (vetSelectionnee != null && vetSelectionnee.equals(TOUTES_LES_ETAPES_LABEL)) {
                        vetSelectionnee = null;
                    }

                }
            });

            layout.addComponent(listeGroupes);

        }
    }

    // Bouton "Filtrer"
    HorizontalLayout bLayout = new HorizontalLayout();
    bLayout.setSizeFull();
    Button closeButton = new Button(applicationContext.getMessage(NAME + ".filtrerBtn", null, getLocale()));
    closeButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
    closeButton.addStyleName("v-popover-button");
    demandeFiltrage = false;
    closeButton.addClickListener(e -> {
        //retourner vetSelectionnee et groupeSelectionne;
        demandeFiltrage = true;
        close();
    });
    bLayout.addComponent(closeButton);
    bLayout.setComponentAlignment(closeButton, Alignment.MIDDLE_CENTER);
    layout.addComponent(bLayout);

}

From source file:gov.va.ehtac.appsonfhir.ui.FHIRChart.java

public FHIRChart() {
    session = ((HealthElementsTouchKitUI) UI.getCurrent()).getSessionAttributes();
    setCaption("TriCare Portal");
    //final VerticalComponentGroup vert = new VerticalComponentGroup();
    GridLayout layout = new GridLayout(3, 2);
    layout.setMargin(true);//from w  w w .  j  av a  2s .c  o m
    layout.setWidth("80%");
    layout.setHeight("100%");

    Panel problemListPanel = getProblemList();
    Panel medicationPanel = getMedications();
    Panel encountersPanel = getEncounters();
    Panel allergiesPanel = getAllergies();
    Panel testsPanel = getTests();
    Panel carePanel = getCarePlan();

    layout.addComponent(problemListPanel, 0, 0);
    layout.setComponentAlignment(problemListPanel, Alignment.TOP_LEFT);
    layout.addComponent(medicationPanel, 1, 0);
    layout.setComponentAlignment(medicationPanel, Alignment.TOP_LEFT);
    layout.addComponent(encountersPanel, 2, 0);
    layout.setComponentAlignment(encountersPanel, Alignment.TOP_LEFT);
    layout.addComponent(allergiesPanel, 0, 1);
    layout.setComponentAlignment(allergiesPanel, Alignment.TOP_LEFT);
    layout.addComponent(testsPanel, 1, 1);
    layout.setComponentAlignment(testsPanel, Alignment.TOP_LEFT);
    layout.addComponent(carePanel, 2, 1);
    layout.setComponentAlignment(carePanel, Alignment.TOP_LEFT);

    //vert.addComponent(layout);

    setContent(new CssLayout(layout));

}