Example usage for com.vaadin.ui GridLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

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

License:Apache License

/**
 * Cre une fentre/*from ww w.  j a  v  a2  s . com*/
 */
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);//  w w  w  .  j  a v  a  2  s  . 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));

}

From source file:gov.va.ehtac.myappsonfhir.ui.FitnessWellness.java

private GridLayout getChartLayout() {
    getChartData(-6);//from  ww  w  . jav  a2 s .c  o  m
    Button b1 = new Button("See More");
    Button b2 = new Button("See More");
    Button b3 = new Button("See More");
    Button b4 = new Button("See More");

    b1.setImmediate(true);
    b2.setImmediate(true);
    b3.setImmediate(true);
    b4.setImmediate(true);

    b1.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            dRequest = "raw";
            refresh();
        }
    });

    b2.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            dRequest = "raw";
            refresh();
        }
    });

    b3.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            dRequest = "raw";
            refresh();
        }
    });

    b4.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            dRequest = "raw";
            refresh();
        }
    });

    GridLayout grid = new GridLayout(2, 2);
    grid.setMargin(true);
    grid.setWidth("100%");

    Panel p1 = new Panel("Heart Rate Activity");
    p1.setHeight("100px");
    VerticalComponentGroup v = new VerticalComponentGroup();
    //v.addComponent(hChart.getChart());
    v.addComponent(hChart.getChart());
    v.addComponent(b1);
    grid.addComponent(v, 0, 0);

    Panel p2 = new Panel("Distance - Miles");
    p2.setHeight("100px");
    VerticalComponentGroup v2 = new VerticalComponentGroup();
    //v2.addComponent(dChart.getChart());
    v2.addComponent(dChart.getChart(results));
    v2.addComponent(b2);
    grid.addComponent(v2, 1, 0);

    Panel p3 = new Panel("Calories Burned");
    p3.setHeight("100px");
    VerticalComponentGroup v3 = new VerticalComponentGroup();
    //v3.addComponent(cChart.getChart());
    v3.addComponent(cChart.getChart(results));
    v3.addComponent(b3);
    grid.addComponent(v3, 0, 1);

    Panel p4 = new Panel("Steps Taken");
    p4.setHeight("100px");
    VerticalComponentGroup v4 = new VerticalComponentGroup();
    //v4.addComponent(sChart.getChart());
    v4.addComponent(sChart.getChart(results));
    v4.addComponent(b4);
    grid.addComponent(v4, 1, 1);
    return grid;
}

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

License:Open Source License

GridLayout getPreviewLayout(String caption) {
    GridLayout grid = new GridLayout(3, 1) {
        @Override/*from   w w w.jav  a  2 s. co m*/
        public void addComponent(Component c) {
            super.addComponent(c);
            setComponentAlignment(c, "center middle");
            if (c.getStyleName() != "") {
                ((AbstractComponent) c).setDescription(
                        c.getClass().getSimpleName() + ".addStyleName(\"" + c.getStyleName() + "\")");
            } else {
                ((AbstractComponent) c).setDescription("new " + c.getClass().getSimpleName() + "()");
            }
        }
    };
    grid.setWidth("100%");
    grid.setSpacing(true);
    grid.setMargin(true);
    grid.setCaption(caption);
    grid.setStyleName("preview-grid");
    return grid;
}

From source file:org.abstractform.vaadin.VaadinFormToolkit.java

License:Apache License

private AbstractComponentContainer buildSubForm(SubForm subForm, Map<String, AbstractComponent> mapComponents,
        List<String> fieldIdList, Map<String, Object> extraObjects) {
    //panel.setCaption(formEditor.getName());
    GridLayout layout = new GridLayout(subForm.getColumns(), subForm.getRows());
    layout.setWidth("100%");
    layout.setSpacing(true);/*from w w  w.  j  a  va2  s. c  om*/
    for (int row = 0; row < subForm.getRows(); row++) {
        for (int column = 0; column < subForm.getColumns(); column++) {
            Component component = subForm.getField(row, column);
            if (component == null) {
                layout.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));
            } else if (component instanceof Field) {
                Field editor = (Field) component;
                if (editor != null) {
                    layout.addComponent(buildField(editor, mapComponents, fieldIdList, extraObjects));
                }
            } else {
                buildComponent(component, mapComponents, fieldIdList, extraObjects);
            }
        }
    }
    return layout;
}

From source file:org.accelerators.activiti.admin.ui.GroupTab.java

License:Open Source License

public GroupTab(AdminApp application) {

    // Set application reference
    this.app = application;

    // Set tab name
    setCaption(app.getMessage(Messages.Groups));

    // Add main layout
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);//ww w  .j av a2s . c o  m
    layout.setSpacing(true);
    layout.setSizeFull();

    // Add toolbar layout
    GridLayout toolbar = new GridLayout(2, 1);
    toolbar.setWidth("100%");
    layout.addComponent(toolbar);

    // Add create button
    create = new Button(app.getMessage(Messages.Create), (ClickListener) this);
    create.setDescription(app.getMessage(Messages.CreateGroup));
    create.setIcon(new ThemeResource("../runo/icons/16/ok.png"));
    toolbar.addComponent(create, 0, 0);
    toolbar.setComponentAlignment(create, Alignment.TOP_LEFT);

    // Add refresh button
    refresh = new Button(app.getMessage(Messages.Refresh), (ClickListener) this);
    refresh.setDescription(app.getMessage(Messages.RefreshTable));
    refresh.setIcon(new ThemeResource("../runo/icons/16/reload.png"));
    toolbar.addComponent(refresh, 1, 0);
    toolbar.setComponentAlignment(refresh, Alignment.TOP_RIGHT);

    // Add table
    table = new GroupTable(app);
    table.setSizeFull();
    layout.addComponent(table);

    // Set table to expand
    layout.setExpandRatio(table, 1.0f);

    // Root
    setCompositionRoot(layout);
}

From source file:org.accelerators.activiti.admin.ui.LoginView.java

License:Open Source License

@SuppressWarnings("serial")
public LoginView(AdminApp application) {

    // Set application reference
    this.app = application;

    // Init window caption
    app.getMainWindow().setCaption(app.getMessage(Messages.Title));

    // Set layout to full size
    setSizeFull();/*from  w  w  w .  j a v a2 s.c  o m*/

    // Set style
    this.setStyleName("login-background");

    // Add header bar
    final HorizontalLayout header = new HorizontalLayout();
    header.setHeight("50px");
    header.setWidth("100%");
    addComponent(header);
    setComponentAlignment(header, Alignment.MIDDLE_CENTER);

    // Setup grid
    GridLayout loginGrid = new GridLayout(1, 2);
    loginGrid.setWidth("250px");
    addComponent(loginGrid);
    setComponentAlignment(loginGrid, Alignment.MIDDLE_CENTER);

    // Add title to header
    GridLayout logoGrid = new GridLayout(1, 1);
    loginGrid.addComponent(logoGrid, 0, 0);
    loginGrid.setComponentAlignment(logoGrid, Alignment.MIDDLE_CENTER);

    Embedded logoImage = new Embedded(null, new ThemeResource("img/login-logo.png"));
    logoImage.setType(Embedded.TYPE_IMAGE);
    logoImage.addStyleName("login-image");
    logoGrid.addComponent(logoImage, 0, 0);
    logoGrid.setComponentAlignment(logoImage, Alignment.MIDDLE_CENTER);

    // Add field and button layout
    VerticalLayout buttonLayout = new VerticalLayout();
    buttonLayout.setSizeFull();
    buttonLayout.setSpacing(true);
    buttonLayout.setMargin(false);
    buttonLayout.setStyleName("login-form");
    loginGrid.addComponent(buttonLayout, 0, 1);
    loginGrid.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER);

    // Add username field
    username = new TextField(app.getMessage(Messages.Username));
    username.setWidth("100%");
    buttonLayout.addComponent(username);

    // Add password field
    password = new PasswordField(app.getMessage(Messages.Password));
    password.setWidth("100%");
    buttonLayout.addComponent(password);

    // Add Login button
    buttonLayout.addComponent(login);
    buttonLayout.setComponentAlignment(login, Alignment.BOTTOM_RIGHT);

    // Set focus to this component
    username.focus();

    // Add shortcut to login button
    login.setClickShortcut(KeyCode.ENTER);

    login.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            try {

                // Athenticate the user
                authenticate((String) username.getValue(), (String) password.getValue());

                // Switch to the main view
                app.getViewManager().switchScreen(MainView.class.getName(), new MainView(app));

            } catch (Exception e) {
                getWindow().showNotification(e.toString());
            }
        }
    });

    HorizontalLayout footer = new HorizontalLayout();
    footer.setHeight("50px");
    footer.setWidth("100%");
    addComponent(footer);

}

From source file:org.accelerators.activiti.admin.ui.MainView.java

License:Open Source License

public MainView(AdminApp application) {

    // Set application
    this.app = application;

    // Setup main layout
    setStyleName(Reindeer.LAYOUT_WHITE);
    setMargin(false);/* w w  w.  j  a  v  a  2 s. c  o  m*/
    setSpacing(false);
    setSizeFull();

    // Add header
    GridLayout header = new GridLayout(2, 1);
    header.setWidth("100%");
    header.setHeight("34px");
    addComponent(header);

    // Add header styles
    header.addStyleName(Consts.HEADER);
    header.addStyleName("header");
    header.setSpacing(true);

    // Add title to header
    GridLayout logoGrid = new GridLayout(1, 1);
    header.addComponent(logoGrid, 0, 0);
    header.setComponentAlignment(logoGrid, Alignment.MIDDLE_LEFT);

    Embedded logoImage = new Embedded(null, new ThemeResource("img/header-logo.png"));
    logoImage.setType(Embedded.TYPE_IMAGE);
    logoImage.addStyleName("header-image");
    logoGrid.addComponent(logoImage, 0, 0);
    logoGrid.setComponentAlignment(logoImage, Alignment.MIDDLE_CENTER);

    // Add logout button to header
    GridLayout logoutGrid = new GridLayout(2, 1);
    Label userLabel = new Label("Signed in as: " + app.getUser().toString());
    userLabel.addStyleName("user");
    logout.setStyleName(Reindeer.BUTTON_LINK);
    logout.addStyleName("logout");
    logoutGrid.addComponent(userLabel, 0, 0);
    logoutGrid.addComponent(logout, 1, 0);
    header.addComponent(logoutGrid, 1, 0);
    header.setComponentAlignment(logoutGrid, Alignment.TOP_RIGHT);

    // Create tab sheet
    TabSheet tabs = new TabSheet();
    tabs.setSizeFull();

    // Add tab styles
    tabs.addStyleName(Reindeer.TABSHEET_BORDERLESS);
    tabs.addStyleName(Reindeer.LAYOUT_WHITE);

    // Add task view tab
    tabs.addTab(new UserTab(app));
    tabs.addTab(new GroupTab(app));

    // Add tab sheet to layout
    addComponent(tabs);
    setExpandRatio(tabs, 1.0F);

    // Add footer text
    Label footerText = new Label(app.getMessage(Messages.Footer));
    footerText.setSizeUndefined();
    footerText.setStyleName(Reindeer.LABEL_SMALL);
    addComponent(footerText);
    setComponentAlignment(footerText, Alignment.BOTTOM_CENTER);

}

From source file:org.accelerators.activiti.admin.ui.UserTab.java

License:Open Source License

public UserTab(AdminApp application) {

    // Set application reference
    this.app = application;

    // Set tab name
    setCaption(app.getMessage(Messages.Users));

    // Add main layout
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/*from w ww.  j  ava 2 s .c  o  m*/
    layout.setSpacing(true);
    layout.setSizeFull();

    // Add toolbar layout
    GridLayout toolbar = new GridLayout(2, 1);
    toolbar.setWidth("100%");
    layout.addComponent(toolbar);

    // Add create button
    create = new Button(app.getMessage(Messages.Create), (ClickListener) this);
    create.setDescription(app.getMessage(Messages.CreateUser));
    create.setIcon(new ThemeResource("../runo/icons/16/ok.png"));
    toolbar.addComponent(create, 0, 0);
    toolbar.setComponentAlignment(create, Alignment.TOP_LEFT);

    // Add refresh button
    refresh = new Button(app.getMessage(Messages.Refresh), (ClickListener) this);
    refresh.setDescription(app.getMessage(Messages.RefreshTable));
    refresh.setIcon(new ThemeResource("../runo/icons/16/reload.png"));
    toolbar.addComponent(refresh, 1, 0);
    toolbar.setComponentAlignment(refresh, Alignment.TOP_RIGHT);

    // Add table
    table = new UserTable(app);
    table.setSizeFull();
    layout.addComponent(table);

    // Set table to expand
    layout.setExpandRatio(table, 1.0f);

    // Root
    setCompositionRoot(layout);
}

From source file:org.apache.ace.webui.vaadin.component.ConfirmationDialog.java

License:Apache License

/**
 * Adds all components to this dialog./*  w ww .  ja  v  a  2  s  . co m*/
 * 
 * @param message
 *            the optional message to display, can be <code>null</code>;
 * @param buttonNames
 *            the names of the buttons to add, never <code>null</code> or empty.
 */
protected void addComponents(String message, String defaultButton, String... buttonNames) {
    if (message != null) {
        addComponent(new Label(message));
    }

    GridLayout gl = new GridLayout(buttonNames.length + 1, 1);
    gl.setSpacing(true);
    gl.setWidth("100%");

    gl.addComponent(new Label(" "));
    gl.setColumnExpandRatio(0, 1.0f);

    for (String buttonName : buttonNames) {
        Button button = new Button(buttonName, this);
        button.setData(buttonName);
        if (defaultButton != null && defaultButton.equals(buttonName)) {
            button.setStyleName(Reindeer.BUTTON_DEFAULT);
            button.setClickShortcut(KeyCode.ENTER);
            // Request focus in this window...
            button.focus();
        }
        gl.addComponent(button);
    }

    addComponent(gl);
}