Example usage for com.vaadin.ui HorizontalLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:fr.amapj.view.engine.basicform.BasicFormListPart.java

License:Open Source License

private void buildMainArea() {

    createColumn();/*from w  w w . j  a  v  a  2 s . com*/

    // Create a persistent person container
    listPartContainer = new BeanItemContainer(getClazz());
    onPopupClose();

    // Add a nested property to a many-to-one property
    for (ColumnInfo colInfo : colInfos) {
        if (colInfo.isNested()) {
            listPartContainer.addNestedContainerProperty(colInfo.propertyId);
        }
    }

    // Set up sorting if the natural order is not appropriate
    listPartContainer.sort(orderByInfo, new boolean[] { true, true });

    // Bind it to a component
    beanTable = createTable(listPartContainer);

    // Gestion de la liste des colonnes visibles
    List<String> colNames = new ArrayList<String>();
    for (ColumnInfo colInfo : colInfos) {
        colNames.add(colInfo.propertyId);
    }
    beanTable.setVisibleColumns(colNames.toArray());

    // Gestion des titres de colonnes
    for (ColumnInfo colInfo : colInfos) {
        beanTable.setColumnHeader(colInfo.propertyId, colInfo.title);
    }

    beanTable.setSelectable(true);
    beanTable.setImmediate(true);

    // Activation au desactivation des boutons delete et edit
    beanTable.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            setModificationsEnabled(event.getProperty().getValue() != null);
        }

        private void setModificationsEnabled(boolean b) {
            Long id = IdentifiableUtil.getIdOfSelectedItem(beanTable);
            if ((id != null) && (b == true) && (isAccessAllowed(id) == false)) {
                b = false;
            }

            deleteButton.setEnabled(b);
            editButton.setEnabled(b);
            enableSpecificButton(b);
        }
    });

    beanTable.setSizeFull();

    beanTable.addItemClickListener(new ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
                beanTable.select(event.getItemId());
            }
        }
    });

    HorizontalLayout toolbar = new HorizontalLayout();

    Label title = new Label(getListPartTitle());
    title.setSizeUndefined();
    title.addStyleName("stdlistpart-text-title");

    newButton = new Button("Ajouter");
    newButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            handleAjouter();
        }
    });
    newButton.addStyleName(ChameleonTheme.BUTTON_BIG);

    deleteButton = new Button("Supprimer");
    deleteButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            handleSupprimer();

        }
    });
    deleteButton.setEnabled(false);
    deleteButton.addStyleName(ChameleonTheme.BUTTON_BIG);

    editButton = new Button("Editer");
    editButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            handleEditer();

        }
    });
    editButton.setEnabled(false);
    editButton.addStyleName(ChameleonTheme.BUTTON_BIG);

    searchField = new TextField();
    searchField.setInputPrompt(getListPartInputPrompt());
    searchField.addTextChangeListener(new TextChangeListener() {

        @Override
        public void textChange(TextChangeEvent event) {
            textFilter = event.getText();
            updateFilters();
        }
    });
    searchField.addStyleName(ChameleonTheme.TEXTFIELD_BIG);
    searchField.setWidth("50%");

    toolbar.addComponent(newButton);
    toolbar.addComponent(deleteButton);
    toolbar.addComponent(editButton);
    addSpecificButton(toolbar);
    toolbar.addComponent(searchField);
    toolbar.setWidth("100%");
    toolbar.setExpandRatio(searchField, 1);
    toolbar.setComponentAlignment(searchField, Alignment.TOP_RIGHT);

    setMargin(true);
    setSpacing(true);

    addComponent(title);
    addComponent(toolbar);
    Component c = getExtraComponent();
    if (c != null) {
        addComponent(c);
    }

    addComponent(beanTable);
    setExpandRatio(beanTable, 1);
    setSizeFull();

}

From source file:fr.amapj.view.engine.grid.currencyvector.PopupCurrencyVector.java

License:Open Source License

protected void createContent(VerticalLayout mainLayout) {
    setType(PopupType.CENTERFIT);/* w  w w  . ja  v  a2 s  .c  om*/
    loadParam();

    if (param.messageSpecifique != null) {
        Label messageSpeLabel = new Label(param.messageSpecifique);
        messageSpeLabel.addStyleName("popup-currency-vector-message");
        mainLayout.addComponent(messageSpeLabel);
    }

    if (param.messageSpecifique2 != null) {
        Label messageSpeLabel = new Label(param.messageSpecifique2, ContentMode.HTML);
        messageSpeLabel.addStyleName("popup-currency-vector-message");
        mainLayout.addComponent(messageSpeLabel);
    }

    if (param.messageSpecifique3 != null) {
        Label messageSpeLabel = new Label(param.messageSpecifique3, ContentMode.HTML);
        messageSpeLabel.addStyleName("popup-currency-vector-message");
        mainLayout.addComponent(messageSpeLabel);
    }

    if (param.avoirInitial != 0) {
        // Footer 1 avec le montant total des paiements
        HorizontalLayout footer1 = new HorizontalLayout();
        footer1.setWidth("350px");
        fillFooter(footer1, "Avoir initial", param.avoirInitial);

        // Footer 2 pour avoir un espace
        HorizontalLayout footer2 = new HorizontalLayout();
        footer2.setWidth("200px");
        footer2.setHeight("20px");

        mainLayout.addComponent(footer1);
        mainLayout.addComponent(footer2);
    }

    // Construction des headers
    for (GridHeaderLine line : param.headerLines) {
        constructHeaderLine(mainLayout, line);
    }

    // Construction de la table de saisie
    table = new Table();
    table.addStyleName("no-vertical-lines");
    table.addStyleName("no-horizontal-lines");
    table.addStyleName("no-stripes");

    table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);

    // Colonne de gauche contenant un libell
    table.addContainerProperty(new Integer(-1), Label.class, null);
    table.setColumnWidth(new Integer(-1), param.largeurCol);

    // colonne de droite correspondant  la saisie des quantites
    Class clzz;
    if (param.readOnly) {
        clzz = Label.class;
    } else {
        clzz = TextField.class;
    }
    table.addContainerProperty(new Integer(0), clzz, null);
    table.setColumnWidth(new Integer(0), param.largeurCol);

    // Convertion du vecteur en un tableau
    boolean[][] excluded = new boolean[param.excluded.length][1];
    for (int i = 0; i < param.excluded.length; i++) {
        excluded[i][0] = param.excluded[i];
    }

    if (param.readOnly == false) {
        shortCutManager = new ShortCutManager(param.nbLig, 1, excluded);
        shortCutManager.addShorcut(this.getWindow());
    }

    // Creation de toutes les cellules pour la saisie
    for (int i = 0; i < param.nbLig; i++) {
        addRow(i);
    }

    if (param.readOnly) {
        table.setEditable(false);
    } else {
        table.setEditable(true);
    }
    table.setSelectable(true);
    table.setSortEnabled(false);
    table.setPageLength(getPageLength());

    // Footer 0 pour avoir un espace
    HorizontalLayout footer0 = new HorizontalLayout();
    footer0.setWidth("200px");
    footer0.setHeight("20px");

    // Construction globale
    mainLayout.addComponent(table);
    mainLayout.addComponent(footer0);

    if ((param.readOnly == true) || (param.computeLastLine == false)) {
        // Footer 1 avec le montant total des paiements
        HorizontalLayout footer1 = new HorizontalLayout();
        footer1.setWidth("350px");
        montantTotalPaiement = fillFooter(footer1, "Montant total paiements", getMontantTotalPaiement());

        // Footer 2 pour avoir un espace
        HorizontalLayout footer2 = new HorizontalLayout();
        footer2.setWidth("200px");
        footer2.setHeight("20px");

        // Footer 3 avec le prix total du contrat
        HorizontalLayout footer3 = new HorizontalLayout();
        footer3.setWidth("350px");
        fillFooter(footer3, "Montant total d", param.montantCible);

        mainLayout.addComponent(footer1);
        mainLayout.addComponent(footer2);
        mainLayout.addComponent(footer3);
    } else {
        // Footer 1 avec le prix total
        HorizontalLayout footer1 = new HorizontalLayout();
        footer1.setWidth("350px");
        fillFooter(footer1, "Montant total  rgler", param.montantCible);
        mainLayout.addComponent(footer1);
    }
}

From source file:fr.amapj.view.engine.grid.currencyvector.PopupCurrencyVector.java

License:Open Source License

private void constructHeaderLine(VerticalLayout mainLayout, GridHeaderLine line) {
    HorizontalLayout header1 = new HorizontalLayout();
    header1.setWidth(getLargeurTotal());
    if (line.height != -1) {
        header1.setHeight(line.height + "px");
    }//from w  w w  .  j  a v  a 2 s .c o m

    for (String str : line.cells) {
        Label dateLabel = new Label(str);
        if (line.styleName != null) {
            dateLabel.addStyleName(line.styleName);
        }
        header1.addComponent(dateLabel);
        dateLabel.setSizeFull();
        header1.setExpandRatio(dateLabel, 1.0f);
    }
    mainLayout.addComponent(header1);
}

From source file:fr.amapj.view.engine.grid.integergrid.PopupIntegerGrid.java

License:Open Source License

protected void createContent(VerticalLayout mainLayout) {
    setType(PopupType.CENTERFIT);//from   ww  w  . j  a  v a 2 s .c  om
    loadParam();
    param.initialize();

    if (param.messageSpecifique != null) {
        Label messageSpeLabel = new Label(param.messageSpecifique);
        messageSpeLabel.addStyleName("popup-integer-grid-message");
        mainLayout.addComponent(messageSpeLabel);
    }

    // Construction des headers
    for (GridHeaderLine line : param.headerLines) {
        constructHeaderLine(mainLayout, line);
    }

    // Construction de la table de saisie
    table = new Table();
    table.addStyleName("no-vertical-lines");
    table.addStyleName("no-horizontal-lines");
    table.addStyleName("no-stripes");

    table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);

    // Colonne de gauche contenant un libell
    table.addContainerProperty(new Integer(-1), Label.class, null);
    table.setColumnWidth(new Integer(-1), param.leftPartLineLargeur);

    // Les autres colonnes correspondant  la saisie des quantites
    for (int i = 0; i < param.nbCol; i++) {
        Class clzz;
        if (param.readOnly) {
            clzz = Label.class;
        } else {
            clzz = TextField.class;
        }
        table.addContainerProperty(new Integer(i), clzz, null);
        table.setColumnWidth(new Integer(i), param.largeurCol);
    }

    //
    if (param.readOnly == false) {
        shortCutManager = new ShortCutManager(param.nbLig, param.nbCol, param.excluded);
        shortCutManager.addShorcut(this.getWindow());
    }

    // Creation de toutes les cellules pour la saisie
    for (int i = 0; i < param.nbLig; i++) {
        addRow(i);
    }

    if (param.readOnly) {
        table.setEditable(false);
    } else {
        table.setEditable(true);
    }
    table.setSelectable(true);
    table.setSortEnabled(false);
    table.setPageLength(getPageLength());

    // Footer 0 pour avoir un espace
    HorizontalLayout footer0 = new HorizontalLayout();
    footer0.setWidth("200px");
    footer0.setHeight("20px");

    // Footer 1 avec le prix total
    HorizontalLayout footer1 = new HorizontalLayout();

    Label dateLabel = new Label(param.libPrixTotal);
    dateLabel.addStyleName("libprix");
    footer1.addComponent(dateLabel);

    prixTotal = new Label("");
    displayMontantTotal();
    prixTotal.addStyleName("prix");
    prixTotal.setWidth("100px");
    footer1.addComponent(prixTotal);

    // Construction globale
    mainLayout.addComponent(table);
    mainLayout.addComponent(footer0);
    mainLayout.addComponent(footer1);

    // Message spcifique en bas de popup
    if (param.messageSpecifiqueBottom != null) {
        labelMessageSpecifiqueBottom = new Label(param.messageSpecifiqueBottom);
        labelMessageSpecifiqueBottom.addStyleName("popup-integer-grid-message");
        mainLayout.addComponent(labelMessageSpecifiqueBottom);
    }

}

From source file:fr.amapj.view.engine.listpart.StandardListPart.java

License:Open Source License

private void buildMainArea() {
    // Lecture dans la base de donnes
    mcInfos = new BeanItemContainer<T>(beanClazz);

    // Bind it to a component
    cdesTable = createTable(mcInfos);/*  w ww.j ava 2s . com*/

    drawTable();

    cdesTable.setSelectable(true);
    cdesTable.setMultiSelect(multiSelect);
    cdesTable.setImmediate(true);

    // Activation ou desactivation des boutons delete et edit
    cdesTable.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            if (multiSelect) {
                Set s = (Set) event.getProperty().getValue();
                buttonBarEditMode(s.size() > 0);
            } else {
                buttonBarEditMode(event.getProperty().getValue() != null);
            }
        }
    });

    cdesTable.setSizeFull();

    cdesTable.addItemClickListener(new ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
                cdesTable.select(event.getItemId());
            }
        }
    });

    HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.addStyleName("buttonbar");

    Label title2 = new Label(getTitle());
    title2.setSizeUndefined();
    title2.addStyleName("title");

    drawButton();

    for (ButtonHandler handler : buttons) {
        toolbar.addComponent(handler.button);
    }

    if (searchField != null) {
        toolbar.addComponent(searchField);
        toolbar.setWidth("100%");
        toolbar.setExpandRatio(searchField, 1);
        toolbar.setComponentAlignment(searchField, Alignment.TOP_RIGHT);
    }

    addComponent(title2);
    addSelectorComponent();
    addComponent(toolbar);
    addExtraComponent();
    addComponent(cdesTable);
    setExpandRatio(cdesTable, 1);

    refreshTable();

}

From source file:fr.amapj.view.engine.menu.MenuPart.java

License:Open Source License

private CssLayout buildMenu(CssLayout menu, CssLayout menuItemsLayout, List<MenuDescription> allMenus,
        Navigator navigator, AmapUI ui) {

    final HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName("valo-menu-title");
    menu.addComponent(top);/*  ww  w. ja  va2 s  . c  o m*/

    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);

    String nomAmap = new ParametresService().getParametres().nomAmap;
    Label title = new Label("<h2>" + nomAmap + "</h2>", ContentMode.HTML);
    title.setSizeUndefined();
    top.addComponent(title);
    top.setExpandRatio(title, 1);

    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");

    SessionParameters p = SessionManager.getSessionParameters();
    MenuItem settingsItem = settings.addItem(p.userPrenom + " " + p.userNom, null, null);
    settingsItem.addItem("Se dconnecter", new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            new PasswordManager().disconnect();
            ui.buildLoginView(null, null, null);
        }
    });

    menu.addComponent(settings);

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

    boolean first = true;
    String firstEntry = null;
    Button firstButton = null;

    for (MenuDescription menuDescription : allMenus) {
        final String view = menuDescription.getMenuName().name().toLowerCase();
        final String titleView = menuDescription.getMenuName().getTitle();

        if (menuDescription.getCategorie() != null) {
            Label l = new Label(menuDescription.getCategorie(), ContentMode.HTML);
            l.setPrimaryStyleName("valo-menu-subtitle");
            l.addStyleName("h4");
            l.setSizeUndefined();
            menuItemsLayout.addComponent(l);
        }

        final Button b = new Button(titleView, new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                setSelected(event.getButton(), menuItemsLayout);
                navigator.navigateTo("/" + view);
            }
        });

        b.setId("amapj.menu." + view);
        b.setHtmlContentAllowed(true);
        b.setPrimaryStyleName("valo-menu-item");
        b.setIcon(menuDescription.getMenuName().getFont());
        menuItemsLayout.addComponent(b);

        viewNameToMenuButton.put("/" + view, b);

        if (first) {
            first = false;
            firstButton = b;
            firstEntry = view;
        }
    }

    // Gestion de l'url
    String f = Page.getCurrent().getUriFragment();
    if (f != null && f.startsWith("!")) {
        f = f.substring(1);
    }
    if (f == null || f.equals("") || f.equals("/")) {
        navigateWithProtect(navigator, "/" + firstEntry);
        setSelected(firstButton, menuItemsLayout);
    } else {
        navigateWithProtect(navigator, f);
        setSelected(viewNameToMenuButton.get(f), menuItemsLayout);
    }

    return menu;
}

From source file:fr.amapj.view.engine.popup.copypopup.CopyPopup.java

License:Open Source License

protected void createContent(VerticalLayout contentLayout) {
    // Calcul du texte a afficher
    String str = contentSupplier.get();

    // Construction de la zone d'affichage du texte
    HorizontalLayout hlTexte = new HorizontalLayout();
    hlTexte.setMargin(true);/*from  w  ww . j ava 2s  . c o m*/
    hlTexte.setSpacing(true);
    hlTexte.setWidth("100%");

    TextArea listeMails = new TextArea("");
    listeMails.setValue(str);
    listeMails.setReadOnly(true);
    listeMails.selectAll();
    listeMails.setWidth("80%");
    listeMails.setHeight(5, Unit.CM);

    hlTexte.addComponent(listeMails);
    hlTexte.setExpandRatio(listeMails, 1);
    hlTexte.setComponentAlignment(listeMails, Alignment.MIDDLE_CENTER);

    contentLayout.addComponent(hlTexte);

}

From source file:fr.amapj.view.engine.popup.errorpopup.ErrorPopup.java

License:Open Source License

protected void createContent(VerticalLayout contentLayout) {
    setColorStyle(ColorStyle.RED);/*from  ww  w .ja  v a  2 s .c o m*/

    // Message logg 
    SessionParameters p = SessionManager.getSessionParameters();
    String debugMessage = null;
    if (p != null) {
        debugMessage = p.userNom + " " + p.userPrenom + " a rencontr une erreur :" + message;
        p.incNbError();
    } else {
        debugMessage = "Pas d'utilisateur encore logg. Erreur :" + message;
    }
    logger.info(debugMessage, throwable);

    String constraintInfo = getConstraintInfo(throwable);
    if (constraintInfo != null) {
        logger.info("Constraint Information:" + constraintInfo);
    }

    // Message utilisateur
    String msg = "Dsol, une erreur est survenue.<br/>";
    if (message != null) {
        msg = msg + "Information supplmentaire:<br/>" + message + "<br/>";
    }
    if (constraintInfo != null) {
        msg = msg + "<br/>" + constraintInfo + "<br/>";
    }

    msg = msg + "Veuillez cliquer sur OK pour continuer<br/>";

    // Construction de la zone de texte
    HorizontalLayout hlTexte = new HorizontalLayout();
    hlTexte.setMargin(true);
    hlTexte.setSpacing(true);
    hlTexte.setWidth("100%");

    Label textArea = new Label(msg, ContentMode.HTML);
    textArea.setStyleName(ChameleonTheme.TEXTFIELD_BIG);
    textArea.setWidth("80%");

    hlTexte.addComponent(textArea);
    hlTexte.setExpandRatio(textArea, 1);
    hlTexte.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER);

    contentLayout.addComponent(hlTexte);
}

From source file:fr.amapj.view.engine.popup.suppressionpopup.SuppressionPopup.java

License:Open Source License

protected void createContent(VerticalLayout contentLayout) {

    setWidth(40, 450);//from w ww.  j a va 2  s.co  m

    // Construction de la zone de texte
    HorizontalLayout hlTexte = new HorizontalLayout();
    hlTexte.setMargin(true);
    hlTexte.setSpacing(true);
    hlTexte.setWidth("100%");

    Label textArea = new Label(message);
    textArea.setStyleName(ChameleonTheme.TEXTFIELD_BIG);
    textArea.setWidth("80%");

    hlTexte.addComponent(textArea);
    hlTexte.setExpandRatio(textArea, 1);
    hlTexte.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER);

    contentLayout.addComponent(hlTexte);

    if (secured) {
        hlTexte = new HorizontalLayout();
        hlTexte.setMargin(true);
        hlTexte.setSpacing(true);
        hlTexte.setWidth("100%");

        textArea = new Label(
                "Veuillez confirmer en saississant le mot SUPPRIMER dans le champ de saisie ci dessous");
        textArea.setStyleName(ChameleonTheme.TEXTFIELD_BIG);
        textArea.setWidth("80%");

        hlTexte.addComponent(textArea);
        hlTexte.setExpandRatio(textArea, 1);
        hlTexte.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER);

        contentLayout.addComponent(hlTexte);

        hlTexte = new HorizontalLayout();
        hlTexte.setMargin(true);
        hlTexte.setSpacing(true);
        hlTexte.setWidth("100%");

        TextField textField = new TextField();
        textField.setStyleName(ChameleonTheme.TEXTFIELD_BIG);
        textField.setWidth("80%");
        textField.setImmediate(true);
        textField.setBuffered(false);

        hlTexte.addComponent(textField);
        hlTexte.setExpandRatio(textField, 1);
        hlTexte.setComponentAlignment(textField, Alignment.MIDDLE_CENTER);

        textField.addTextChangeListener(new TextChangeListener() {
            @Override
            public void textChange(TextChangeEvent event) {
                if (event.getText().equals("SUPPRIMER")) {
                    okButton.setEnabled(true);
                } else {
                    okButton.setEnabled(false);
                }
            }
        });

        contentLayout.addComponent(hlTexte);
    }

}

From source file:fr.amapj.view.views.appinstance.PopupCopyAllMail.java

License:Open Source License

protected void createContent(VerticalLayout contentLayout) {

    // Construction de la zone d'affichage des mails
    HorizontalLayout hlTexte = new HorizontalLayout();
    hlTexte.setMargin(true);/*from  ww w. java2 s .  c o m*/
    hlTexte.setSpacing(true);
    hlTexte.setWidth("100%");

    TextArea listeMails = new TextArea("");
    listeMails.setValue(mails);
    listeMails.setReadOnly(true);
    listeMails.selectAll();
    listeMails.setWidth("80%");
    listeMails.setHeight(5, Unit.CM);

    hlTexte.addComponent(listeMails);
    hlTexte.setExpandRatio(listeMails, 1);
    hlTexte.setComponentAlignment(listeMails, Alignment.MIDDLE_CENTER);

    contentLayout.addComponent(hlTexte);

}