Example usage for com.vaadin.ui HorizontalLayout setExpandRatio

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

Introduction

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

Prototype

public void setExpandRatio(Component component, float ratio) 

Source Link

Document

This method is used to control how excess space in layout is distributed among components.

Usage

From source file:jp.primecloud.auto.ui.ServiceDescDetail.java

License:Open Source License

public ServiceDescDetail() {
    addStyleName(Reindeer.PANEL_LIGHT);//from   w w w. j ava 2  s.co m
    setHeight("100%");

    HorizontalLayout hlPanels = new HorizontalLayout();
    hlPanels.setWidth("100%");
    hlPanels.setHeight("100%");
    hlPanels.setMargin(true);
    hlPanels.setSpacing(true);
    hlPanels.addStyleName("service-desc-detail");
    setContent(hlPanels);

    left.setWidth("250px");
    right.setWidth("100%");
    right.setHeight("100%");

    VerticalLayout layLeft = new VerticalLayout();
    layLeft.setMargin(false);
    layLeft.setSpacing(false);
    layLeft.setWidth("250px");
    layLeft.setHeight("100%");
    layLeft.addComponent(left);
    layLeft.setExpandRatio(left, 1.0f);

    hlPanels.addComponent(layLeft);
    hlPanels.addComponent(right);

    hlPanels.setExpandRatio(right, 100);

}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminAuthView.java

License:Open Source License

public AdminAuthView() {

    setSizeFull();//from  ww  w.  ja  v  a 2  s.  c  o  m

    VerticalLayout header = new VerticalLayout();
    header.setSizeFull();

    HorizontalLayout content = new HorizontalLayout();
    content.setSizeFull();

    addComponents(header, content);
    setExpandRatio(header, 1);
    setExpandRatio(content, 6);

    welcomeText.setValue("<h1>Welcome to the iCrash Administrator console!</h1>");
    welcomeText.setContentMode(ContentMode.HTML);
    welcomeText.setSizeUndefined();
    header.addComponent(welcomeText);
    header.setComponentAlignment(welcomeText, Alignment.MIDDLE_CENTER);

    Panel controlPanel = new Panel("Administrator control panel");
    controlPanel.setSizeUndefined();

    Panel addCoordPanel = new Panel("Create a new coordinator");
    addCoordPanel.setSizeUndefined();

    Panel messagesPanel = new Panel("Administrator messages");
    messagesPanel.setWidth("580px");

    Table adminMessagesTable = new Table();

    adminMessagesTable.setContainerDataSource(actAdmin.getMessagesDataSource());

    adminMessagesTable.setColumnWidth("inputEvent", 180);
    adminMessagesTable.setSizeFull();

    VerticalLayout controlLayout = new VerticalLayout(controlPanel);
    controlLayout.setSizeFull();
    controlLayout.setMargin(false);
    controlLayout.setComponentAlignment(controlPanel, Alignment.TOP_CENTER);

    VerticalLayout coordOperationsLayout = new VerticalLayout(addCoordPanel);
    coordOperationsLayout.setSizeFull();
    coordOperationsLayout.setMargin(false);
    coordOperationsLayout.setComponentAlignment(addCoordPanel, Alignment.TOP_CENTER);

    /******************************************/
    coordOperationsLayout.setVisible(true); // main layout in the middle
    addCoordPanel.setVisible(false); // ...which contains the panel "Create a new coordinator"
    /******************************************/

    HorizontalLayout messagesExternalLayout = new HorizontalLayout(messagesPanel);
    VerticalLayout messagesInternalLayout = new VerticalLayout(adminMessagesTable);

    messagesExternalLayout.setSizeFull();
    messagesExternalLayout.setMargin(false);
    messagesExternalLayout.setComponentAlignment(messagesPanel, Alignment.TOP_CENTER);

    messagesInternalLayout.setMargin(false);
    messagesInternalLayout.setSizeFull();
    messagesInternalLayout.setComponentAlignment(adminMessagesTable, Alignment.TOP_CENTER);

    messagesPanel.setContent(messagesInternalLayout);

    TextField idCoordAdd = new TextField();
    TextField loginCoord = new TextField();
    PasswordField pwdCoord = new PasswordField();

    Label idCaptionAdd = new Label("ID");
    Label loginCaption = new Label("Login");
    Label pwdCaption = new Label("Password");

    idCaptionAdd.setSizeUndefined();
    idCoordAdd.setSizeUndefined();

    loginCaption.setSizeUndefined();
    loginCoord.setSizeUndefined();

    pwdCaption.setSizeUndefined();
    pwdCoord.setSizeUndefined();

    Button validateNewCoord = new Button("Validate");
    validateNewCoord.setClickShortcut(KeyCode.ENTER);
    validateNewCoord.setStyleName(ValoTheme.BUTTON_PRIMARY);

    GridLayout addCoordinatorLayout = new GridLayout(2, 4);
    addCoordinatorLayout.setSpacing(true);
    addCoordinatorLayout.setMargin(true);
    addCoordinatorLayout.setSizeFull();

    addCoordinatorLayout.addComponents(idCaptionAdd, idCoordAdd, loginCaption, loginCoord, pwdCaption,
            pwdCoord);

    addCoordinatorLayout.addComponent(validateNewCoord, 1, 3);

    addCoordinatorLayout.setComponentAlignment(idCaptionAdd, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(idCoordAdd, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(loginCaption, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(loginCoord, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(pwdCaption, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(pwdCoord, Alignment.MIDDLE_LEFT);

    addCoordPanel.setContent(addCoordinatorLayout);

    content.addComponents(controlLayout, coordOperationsLayout, messagesExternalLayout);
    content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER);
    content.setComponentAlignment(controlLayout, Alignment.TOP_CENTER);
    content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER);

    content.setExpandRatio(controlLayout, 20);
    content.setExpandRatio(coordOperationsLayout, 10);
    content.setExpandRatio(messagesExternalLayout, 28);

    Button addCoordinator = new Button("Add coordinator");
    Button deleteCoordinator = new Button("Delete coordinator");

    addCoordinator.addStyleName(ValoTheme.BUTTON_HUGE);
    deleteCoordinator.addStyleName(ValoTheme.BUTTON_HUGE);
    logoutBtn.addStyleName(ValoTheme.BUTTON_HUGE);

    VerticalLayout buttons = new VerticalLayout();

    buttons.setMargin(true);
    buttons.setSpacing(true);
    buttons.setSizeFull();

    buttons.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    controlPanel.setContent(buttons);

    buttons.addComponents(addCoordinator, deleteCoordinator, logoutBtn);

    /******* DELETE COORDINATOR PANEL BEGIN *********/
    Label idCaptionDel = new Label("ID");
    TextField idCoordDel = new TextField();

    Panel delCoordPanel = new Panel("Delete a coordinator");

    coordOperationsLayout.addComponent(delCoordPanel);
    delCoordPanel.setVisible(false);

    coordOperationsLayout.setComponentAlignment(delCoordPanel, Alignment.TOP_CENTER);
    delCoordPanel.setSizeUndefined();

    GridLayout delCoordinatorLayout = new GridLayout(2, 2);
    delCoordinatorLayout.setSpacing(true);
    delCoordinatorLayout.setMargin(true);
    delCoordinatorLayout.setSizeFull();

    Button deleteCoordBtn = new Button("Delete");
    deleteCoordBtn.setClickShortcut(KeyCode.ENTER);
    deleteCoordBtn.setStyleName(ValoTheme.BUTTON_PRIMARY);

    delCoordinatorLayout.addComponents(idCaptionDel, idCoordDel);

    delCoordinatorLayout.addComponent(deleteCoordBtn, 1, 1);

    delCoordinatorLayout.setComponentAlignment(idCaptionDel, Alignment.MIDDLE_LEFT);
    delCoordinatorLayout.setComponentAlignment(idCoordDel, Alignment.MIDDLE_LEFT);

    delCoordPanel.setContent(delCoordinatorLayout);
    /******* DELETE COORDINATOR PANEL END *********/

    /************************************************* MAIN BUTTONS LOGIC BEGIN *************************************************/

    addCoordinator.addClickListener(event -> {
        if (!addCoordPanel.isVisible()) {
            delCoordPanel.setVisible(false);
            addCoordPanel.setVisible(true);
            idCoordAdd.focus();
        } else
            addCoordPanel.setVisible(false);
    });

    deleteCoordinator.addClickListener(event -> {
        if (!delCoordPanel.isVisible()) {
            addCoordPanel.setVisible(false);
            delCoordPanel.setVisible(true);
            idCoordDel.focus();
        } else
            delCoordPanel.setVisible(false);
    });

    /************************************************* MAIN BUTTONS LOGIC END *************************************************/

    /************************************************* ADD COORDINATOR FORM LOGIC BEGIN *************************************************/
    validateNewCoord.addClickListener(event -> {

        String currentURL = Page.getCurrent().getLocation().toString();
        int strIndexCreator = currentURL.lastIndexOf(AdministratorLauncher.adminPageName);
        String iCrashURL = currentURL.substring(0, strIndexCreator);
        String googleShebang = "#!";
        String coordURL = iCrashURL + CoordinatorServlet.coordinatorsName + googleShebang;

        try {
            sys.oeAddCoordinator(new DtCoordinatorID(new PtString(idCoordAdd.getValue())),
                    new DtLogin(new PtString(loginCoord.getValue())),
                    new DtPassword(new PtString(pwdCoord.getValue())));

            // open new browser tab with the newly created coordinator console...
            // "_blank" instructs the browser to open a new tab instead of a new window...
            // unhappily not all browsers interpret it correctly,
            // some versions of some browsers might still open a new window instead (notably Firefox)!
            Page.getCurrent().open(coordURL + idCoordAdd.getValue(), "_blank");

        } catch (Exception e) {
            e.printStackTrace();
        }

        idCoordAdd.setValue("");
        loginCoord.setValue("");
        pwdCoord.setValue("");

        idCoordAdd.focus();
    });
    /************************************************* ADD COORDINATOR FORM LOGIC END *************************************************/
    /************************************************* DELETE COORDINATOR FORM LOGIC BEGIN *************************************************/
    deleteCoordBtn.addClickListener(event -> {
        IcrashSystem sys = IcrashSystem.getInstance();

        try {
            sys.oeDeleteCoordinator(new DtCoordinatorID(new PtString(idCoordDel.getValue())));
        } catch (Exception e) {
            e.printStackTrace();
        }

        idCoordDel.setValue("");
        idCoordDel.focus();
    });
    /************************************************* DELETE COORDINATOR FORM LOGIC END *************************************************/
}

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

License:Apache License

CssLayout buildMenu() {
    // Add items/*from ww w .  j  a v  a 2s  .c  o  m*/
    menuItems.put("MessageView", "First Message");
    menuItems.put("MessageView1", "Second Message");
    /*
    menuItems.put("labels", "Labels");
    menuItems.put("buttons-and-links", "Buttons & Links");
    menuItems.put("textfields", "Text Fields");
    menuItems.put("datefields", "Date Fields");
    menuItems.put("comboboxes", "Combo Boxes");
    menuItems.put("selects", "Selects");
    menuItems.put("checkboxes", "Check Boxes & Option Groups");
    menuItems.put("sliders", "Sliders & Progress Bars");
    menuItems.put("colorpickers", "Color Pickers");
    menuItems.put("menubars", "Menu Bars");
    menuItems.put("trees", "Trees");
    menuItems.put("tables", "Tables");
    menuItems.put("dragging", "Drag and Drop");
    menuItems.put("panels", "Panels");
    menuItems.put("splitpanels", "Split Panels");
    menuItems.put("tabs", "Tabs");
    menuItems.put("accordions", "Accordions");
    menuItems.put("popupviews", "Popup Views");
    // menuItems.put("calendar", "Calendar");
    menuItems.put("forms", "Forms");
    */
    final HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName("valo-menu-title");
    menu.addComponent(top);
    menu.addComponent(createThemeSelect());

    final Button showMenu = new Button("Menu", new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            if (menu.getStyleName().contains("valo-menu-visible")) {
                menu.removeStyleName("valo-menu-visible");
            } else {
                menu.addStyleName("valo-menu-visible");
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName("valo-menu-toggle");
    showMenu.setIcon(FontAwesome.LIST);
    menu.addComponent(showMenu);

    final Label title = new Label("<h3>Vaadin <strong>Valo Theme</strong></h3>", ContentMode.HTML);
    title.setSizeUndefined();
    top.addComponent(title);
    top.setExpandRatio(title, 1);

    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");
    /*
    final StringGenerator sg = new StringGenerator();
    final MenuItem settingsItem = settings.addItem(sg.nextString(true)
        + " " + sg.nextString(true) + sg.nextString(false),
        new ThemeResource("../tests-valo/img/profile-pic-300px.jpg"),
        null);
            
    settingsItem.addItem("Edit Profile", null);
    settingsItem.addItem("Preferences", null);
    settingsItem.addSeparator();
    settingsItem.addItem("Sign Out", null);
                */
    menu.addComponent(settings);

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

    Label label = null;
    int count = -1;
    for (final Entry<String, String> item : menuItems.entrySet()) {
        if (item.getKey().equals("labels")) {
            label = new Label("Components", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        if (item.getKey().equals("panels")) {
            label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");
            count = 0;
            label = new Label("Containers", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        if (item.getKey().equals("forms")) {
            label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");
            count = 0;
            label = new Label("Other", ContentMode.HTML);
            label.setPrimaryStyleName("valo-menu-subtitle");
            label.addStyleName("h4");
            label.setSizeUndefined();
            menuItemsLayout.addComponent(label);
        }
        final Button b = new Button(item.getValue(), new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                navigator.navigateTo(item.getKey());
            }
        });
        if (count == 2) {
            b.setCaption(b.getCaption() + " <span class=\"valo-menu-badge\">123</span>");
        }
        b.setHtmlContentAllowed(true);
        b.setPrimaryStyleName("valo-menu-item");
        //            b.setIcon(testIcon.get());
        menuItemsLayout.addComponent(b);
        count++;
    }
    if (label != null)
        label.setValue(label.getValue() + " <span class=\"valo-menu-badge\">" + count + "</span>");

    return menu;
}

From source file:me.uni.emuseo.view.menu.MenuView.java

License:Open Source License

private CssLayout buildMenu() {
    // Add items/*w ww  .j a  v  a 2 s.  c  o  m*/
    if (authManager.isAuthorizedTo(Permissions.MENU_USERS_VIEW)) {
        menuItems.put(Permissions.MENU_USERS_VIEW, "Uytkownicy");
    }
    if (authManager.isAuthorizedTo(Permissions.MENU_EXHIBIT_VIEW)) {
        menuItems.put(Permissions.MENU_EXHIBIT_VIEW, "Katalog eksponatw");
    }
    if (authManager.isAuthorizedTo(Permissions.MENU_CATEGORIES_VIEW)) {
        menuItems.put(Permissions.MENU_CATEGORIES_VIEW, "Kategorie");
    }
    if (authManager.isAuthorizedTo(Permissions.MENU_RESOURCES_VIEW)) {
        menuItems.put(Permissions.MENU_RESOURCES_VIEW, "Zasoby");
    }

    final HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName("valo-menu-title");
    menu.addComponent(top);
    final Button showMenu = new Button("Menu", new ClickListener() {
        private static final long serialVersionUID = -719702284721453362L;

        @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>e<strong>Museo</strong></h3>", ContentMode.HTML);
    title.setSizeUndefined();
    top.addComponent(title);
    top.setExpandRatio(title, 1);
    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");

    settingsItem = settings.addItem("Jan Kowalski", defaultIcon, null);
    if (authManager.isAuthorizedTo(Permissions.MENU_MY_ACCOUNT_VIEW)) {
        settingsItem.addItem("Moje konto", new MenuBar.Command() {
            private static final long serialVersionUID = 7015035735144235104L;

            @Override
            public void menuSelected(MenuItem selectedItem) {
                navigator.navigateTo(Permissions.MENU_MY_ACCOUNT_VIEW);
            }

        });
    }
    if (authManager.isAuthorizedTo(Permissions.MENU_SETTINGS_VIEW)) {
        settingsItem.addItem("Ustawienia", new MenuBar.Command() {
            private static final long serialVersionUID = 7015035735144235105L;

            @Override
            public void menuSelected(MenuItem selectedItem) {
                navigator.navigateTo(Permissions.MENU_SETTINGS_VIEW);
            }

        });
    }
    settingsItem.addSeparator();
    settingsItem.addItem("Wyloguj", new MenuBar.Command() {
        private static final long serialVersionUID = 1333473616079310225L;

        @Override
        public void menuSelected(MenuItem selectedItem) {
            final AuthManager authManager = EMuseoUtil.getAppContext().getBean(AuthManager.class);
            authManager.logout();
        }
    });
    menu.addComponent(settings);
    menuItemsLayout.setPrimaryStyleName("valo-menuitems");
    menu.addComponent(menuItemsLayout);

    for (final Entry<String, String> item : menuItems.entrySet()) {
        FontIcon icon = null;
        if (item.getKey().equals(Permissions.MENU_USERS_VIEW)) {
            icon = FontAwesome.USERS;
        } else if (item.getKey().endsWith(Permissions.MENU_EXHIBIT_VIEW)) {
            icon = FontAwesome.UNIVERSITY;
        } else if (item.getKey().endsWith(Permissions.MENU_CATEGORIES_VIEW)) {
            icon = FontAwesome.ARCHIVE;
        } else if (item.getKey().endsWith(Permissions.MENU_RESOURCES_VIEW)) {
            icon = FontAwesome.IMAGE;
        }
        final Button b = new Button(item.getValue(), new ClickListener() {
            private static final long serialVersionUID = -7089398070311521853L;

            @Override
            public void buttonClick(final ClickEvent event) {
                navigator.navigateTo(item.getKey());
            }
        });
        b.setHtmlContentAllowed(true);
        b.setPrimaryStyleName("valo-menu-item");
        if (icon != null) {
            b.setIcon(icon);
        }
        menuItemsLayout.addComponent(b);
    }
    return menu;
}

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

License:Open Source License

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

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

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

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

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

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

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

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

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

    return layout;
}

From source file:my.vaadin.app.MyUI.java

@Override
protected void init(VaadinRequest vaadinRequest) {
    final VerticalLayout layout = new VerticalLayout();

    filterText.setPlaceholder("filter by name...");
    filterText.addValueChangeListener(e -> updateList());
    filterText.setValueChangeMode(ValueChangeMode.LAZY);

    Button clearFilterTextBtn = new Button(FontAwesome.TIMES);
    clearFilterTextBtn.setDescription("Clear the current filter");
    clearFilterTextBtn.addClickListener(e -> filterText.clear());

    CssLayout filtering = new CssLayout();
    filtering.addComponents(filterText, clearFilterTextBtn);
    filtering.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);

    Button addCustomerBtn = new Button("Add new customer");
    addCustomerBtn.addClickListener(e -> {
        grid.asSingleSelect().clear();//from  w  w  w  . j  a  va2  s .  c  o  m
        form.setCustomer(new Customer());
    });

    HorizontalLayout toolbar = new HorizontalLayout(filtering, addCustomerBtn);

    grid.setColumns("firstName", "lastName", "email");

    HorizontalLayout main = new HorizontalLayout(grid, form);
    main.setSizeFull();
    grid.setSizeFull();
    main.setExpandRatio(grid, 1);

    layout.addComponents(toolbar, main);

    // fetch list of Customers from service and assign it to Grid
    updateList();

    setContent(layout);

    form.setVisible(false);

    grid.asSingleSelect().addValueChangeListener(event -> {
        if (event.getValue() == null) {
            form.setVisible(false);
        } else {
            form.setCustomer(event.getValue());
        }
    });
}

From source file:net.anthavio.vinbudin.vui.ChatUI.java

License:Open Source License

@Logged
@Override/*from ww w.  ja  v a  2  s .c  om*/
protected void init(VaadinRequest request) {

    fieldMessage.setMaxLength(100);
    fieldMessage.setEnabled(false);
    fieldMessage.setWidth("100%");
    fieldMessage.addTextChangeListener(event -> {
        String text = event.getText();
        buttonSend.setEnabled(text != null && text.length() > 2);
    });

    buttonSend.setEnabled(false);
    buttonSend.setClickShortcut(KeyCode.ENTER);
    buttonSend.addStyleName(ValoTheme.BUTTON_PRIMARY);

    buttonSend.addClickListener(event -> {
        ChatMessage message = new ChatMessage(getMe(), fieldMessage.getValue());
        service.addMessage(message);
        fieldMessage.setValue("");
        buttonSend.setEnabled(false);
    });

    buttonCancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);
    buttonCancel.addClickListener(event -> {
        fieldMessage.setValue("");
        buttonSend.setEnabled(false);
    });

    buttonClear.setEnabled(false);
    buttonClear.addClickListener(event -> {
        ConfirmDialog.show(this, "Please Confirm:", "Delete all messages?", "Yes", "Nope",
                new ConfirmDialog.Listener() {
                    public void onClose(ConfirmDialog dialog) {
                        if (dialog.isConfirmed()) {
                            service.clearMessages();
                            ChatMessage message = new ChatMessage(getMe(), "Cleared discussion...");
                            service.addMessage(message);
                        }
                    }
                });
    });

    menubar.setWidth("100%");
    miLogin = menubar.addItem("Login", null);
    for (OAuthProvider p : OAuthProvider.values()) {
        miLogin.addItem(p.name(), loginCommand);
    }
    miLogout = menubar.addItem("Replace Me", null);
    miLogout.addItem("Logout", (selectedItem) -> {
        //Say good bye...
        ChatMessage message = new ChatMessage(getMe(), "Logged out...");
        service.addMessage(message);

        setMe(null);
        setUiStateByLogin();
    });

    HorizontalLayout lSending = new HorizontalLayout(fieldMessage, buttonSend, buttonCancel, buttonClear);
    lSending.setWidth("100%");
    lSending.setSpacing(true);
    lSending.setExpandRatio(fieldMessage, 1);

    labelBoard.setSizeFull();

    VerticalLayout layout = new VerticalLayout(menubar, lSending, labelBoard);
    layout.setSpacing(true);
    layout.setMargin(true);
    setContent(layout);
    setSizeFull();

    setUiStateByLogin();
    refreshMessageBoard();
    fieldMessage.focus();
    registry.attach(this, new ChatMessageListener() {

        @Override
        public void onEvent(ChatMessage message) {
            onChatMessage(message);
        }
    });
}

From source file:net.javaforge.netty.vaadin.AddressbookUI.java

License:Apache License

private void initLayout() {

    /* Root of the user interface component tree is set */
    HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
    setContent(splitPanel);/*from ww w  .j  a v a 2  s. co  m*/

    /* Build the component tree */
    VerticalLayout leftLayout = new VerticalLayout();
    splitPanel.addComponent(leftLayout);
    splitPanel.addComponent(editorLayout);
    leftLayout.addComponent(contactList);
    HorizontalLayout bottomLeftLayout = new HorizontalLayout();
    leftLayout.addComponent(bottomLeftLayout);
    bottomLeftLayout.addComponent(searchField);
    bottomLeftLayout.addComponent(addNewContactButton);

    /* Set the contents in the left of the split panel to use all the space */
    leftLayout.setSizeFull();

    /*
       * On the left side, expand the size of the contactList so that it uses
     * all the space left after from bottomLeftLayout
     */
    leftLayout.setExpandRatio(contactList, 1);
    contactList.setSizeFull();

    /*
     * In the bottomLeftLayout, searchField takes all the width there is
     * after adding addNewContactButton. The height of the layout is defined
     * by the tallest component.
     */
    bottomLeftLayout.setWidth("100%");
    searchField.setWidth("100%");
    bottomLeftLayout.setExpandRatio(searchField, 1);

    /* Put a little margin around the fields in the right side editor */
    editorLayout.setMargin(true);
    editorLayout.setVisible(false);
}

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

License:Open Source License

private HorizontalLayout createHeader() {
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth("100%");
    layout.setMargin(true);//from w  w  w.jav a  2  s  .c o  m
    layout.setSpacing(true);
    final Label title = new Label("Activiti + Vaadin - A Match Made in Heaven");
    title.addStyleName(Reindeer.LABEL_H1);
    layout.addComponent(title);
    layout.setExpandRatio(title, 1.0f);

    Label currentUser = new Label();
    currentUser.setSizeUndefined();
    layout.addComponent(currentUser);
    layout.setComponentAlignment(currentUser, Alignment.MIDDLE_RIGHT);

    Button logout = new Button("Logout");
    logout.addStyleName(Reindeer.BUTTON_SMALL);
    // logout.addListener(createLogoutButtonListener());
    layout.addComponent(logout);
    layout.setComponentAlignment(logout, Alignment.MIDDLE_RIGHT);

    return layout;
}

From source file:nl.kpmg.lcm.ui.view.administration.AuthorizedLcmPanel.java

License:Apache License

public AuthorizedLcmPanel(RestClientService restClientService) {
    this.restClientService = restClientService;

    HorizontalLayout menubar = initMenubar(restClientService);

    HorizontalLayout dataLayout = initDataLayout();

    VerticalLayout rootVerticalLayout = new VerticalLayout();
    rootVerticalLayout.addComponent(menubar);
    rootVerticalLayout.addComponent(dataLayout);
    rootVerticalLayout.setHeight("100%");

    HorizontalLayout root = new HorizontalLayout();
    root.addComponent(rootVerticalLayout);
    root.setSpacing(true);/* w ww . j  av a  2 s . co  m*/
    root.setMargin(true);
    root.setWidth("100%");
    root.setHeight("100%");
    root.setExpandRatio(rootVerticalLayout, 1f);

    setCompositionRoot(root);
}