Example usage for com.vaadin.ui VerticalLayout setExpandRatio

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

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout 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:com.selzlein.lojavirtual.vaadin.popup.TodoDelegation.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    LspsUI ui = (LspsUI) getUI();//from   w  ww .j  av  a 2  s  .co m
    setCaption(ui.getMessage("todo.delegationTitle"));

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

    Label help = new Label(ui.getMessage("todo.delegationHelp"));
    help.setStyleName("form-help");
    layout.addComponent(help);

    Collection<Person> allUsers = new ArrayList<Person>(
            personService.findPersons(new PersonCriteria()).getData());
    Set<Person> substitutes = ui.getUser().getPerson().getDirectSubstitutes();
    Set<String> substitutesIds = new HashSet<String>();
    for (Person p : substitutes) {
        substitutesIds.add(p.getId());
    }

    delegates = new OptionGroup(ui.getMessage("todo.delegates"));
    delegates.setMultiSelect(true);
    delegates.addStyleName("ui-spacing");
    delegates.setRequired(true);
    delegates.setSizeFull();
    for (Person p : allUsers) {
        delegates.addItem(p.getId());
        delegates.setItemCaption(p.getId(), p.getFullName());
    }
    delegates.setValue(substitutesIds);
    layout.addComponent(delegates);
    layout.setExpandRatio(delegates, 1);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    layout.addComponent(buttons);

    @SuppressWarnings("serial")
    Button delegateButton = new Button(ui.getMessage("action.delegate"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            delegate();
        }
    });
    buttons.addComponent(delegateButton);

    @SuppressWarnings("serial")
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
}

From source file:com.skysql.manager.ManagerUI.java

License:Open Source License

/**
 * Inits the layout./*from  w  w  w. jav a 2s.  co m*/
 */
private void initLayout() {

    VerticalLayout main = new VerticalLayout();
    main.setMargin(new MarginInfo(false, true, false, true));
    main.setSpacing(true);
    main.setSizeFull();

    setContent(main);

    VaadinSession session = getSession();

    AnimatorProxy proxy = new AnimatorProxy();
    main.addComponent(proxy);
    session.setAttribute(AnimatorProxy.class, proxy);

    VerticalLayout topMiddleLayout = new VerticalLayout();
    main.addComponent(topMiddleLayout);
    session.setAttribute(VerticalLayout.class, topMiddleLayout);

    TopPanel topPanel = new TopPanel();
    topMiddleLayout.addComponent(topPanel);
    session.setAttribute(TopPanel.class, topPanel);

    overviewPanel = new OverviewPanel();
    topMiddleLayout.addComponent(overviewPanel);
    session.setAttribute(OverviewPanel.class, overviewPanel);

    tabbedPanel = new TabbedPanel(session);
    main.addComponent(tabbedPanel.getTabSheet());
    main.setExpandRatio(tabbedPanel.getTabSheet(), 1f);
    session.setAttribute(TabbedPanel.class, tabbedPanel);

    overviewPanel.refresh();

}

From source file:com.skysql.manager.ui.CalendarDialog.java

License:Open Source License

/**
 * Inits the layout content.//from  w w w . j  a v a  2 s .  co  m
 */
private void initLayoutContent() {
    initNavigationButtons();
    initAddNewEventButton();
    initHideWeekEndButton();
    //initAllScheduleButton();

    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth("100%");
    hl.setSpacing(true);
    hl.setMargin(new MarginInfo(false, false, true, false));
    hl.addComponent(prevButton);
    hl.addComponent(captionLabel);
    hl.addComponent(monthButton);
    hl.addComponent(weekButton);
    hl.addComponent(nextButton);
    hl.setComponentAlignment(prevButton, Alignment.MIDDLE_LEFT);
    hl.setComponentAlignment(captionLabel, Alignment.MIDDLE_CENTER);
    hl.setComponentAlignment(monthButton, Alignment.MIDDLE_CENTER);
    hl.setComponentAlignment(weekButton, Alignment.MIDDLE_CENTER);
    hl.setComponentAlignment(nextButton, Alignment.MIDDLE_RIGHT);

    monthButton.setVisible(viewMode == Mode.WEEK);
    weekButton.setVisible(viewMode == Mode.DAY);

    HorizontalLayout controlPanel = new HorizontalLayout();
    controlPanel.setSpacing(true);
    controlPanel.setMargin(new MarginInfo(false, false, true, false));
    controlPanel.setWidth("100%");
    //controlPanel.addComponent(localeSelect);
    //controlPanel.setComponentAlignment(localeSelect, Alignment.MIDDLE_LEFT);
    controlPanel.addComponent(timeZoneSelect);
    controlPanel.setComponentAlignment(timeZoneSelect, Alignment.MIDDLE_LEFT);
    //controlPanel.addComponent(formatSelect);
    //controlPanel.setComponentAlignment(formatSelect, Alignment.MIDDLE_LEFT);
    controlPanel.addComponent(addNewEvent);
    controlPanel.setComponentAlignment(addNewEvent, Alignment.BOTTOM_LEFT);
    controlPanel.addComponent(hideWeekendsButton);
    controlPanel.setComponentAlignment(hideWeekendsButton, Alignment.BOTTOM_LEFT);
    //controlPanel.addComponent(allScheduleButton);
    //controlPanel.setComponentAlignment(allScheduleButton, Alignment.MIDDLE_LEFT);

    VerticalLayout layout = (VerticalLayout) dialogWindow.getContent();
    layout.addComponent(controlPanel);
    layout.addComponent(hl);
    layout.addComponent(calendarComponent);
    layout.setExpandRatio(calendarComponent, 1);
}

From source file:com.skysql.manager.ui.ErrorDialog.java

License:Open Source License

/**
 * Instantiates a new error dialog./*  ww  w.  j  av  a  2  s . com*/
 *
 * @param e the exception
 * @param humanizedError the humanized error
 */
public ErrorDialog(Exception e, String humanizedError) {

    if (e != null) {
        ManagerUI.error(e.getMessage());
    }

    dialogWindow = new ModalWindow("An Error has occurred", "775px");
    dialogWindow.setHeight("340px");
    dialogWindow.addCloseListener(this);
    UI current = UI.getCurrent();
    if (current.getContent() == null) {
        current.setContent(new ErrorView(Notification.Type.ERROR_MESSAGE, null));
    }
    current.addWindow(dialogWindow);

    HorizontalLayout wrapper = new HorizontalLayout();
    wrapper.setSizeFull();
    wrapper.setMargin(true);

    VerticalLayout iconLayout = new VerticalLayout();
    iconLayout.setWidth("100px");
    wrapper.addComponent(iconLayout);
    Embedded image = new Embedded(null, new ThemeResource("img/error.png"));
    iconLayout.addComponent(image);

    VerticalLayout textLayout = new VerticalLayout();
    textLayout.setHeight("100%");
    textLayout.setSpacing(true);
    wrapper.addComponent(textLayout);
    wrapper.setExpandRatio(textLayout, 1.0f);

    if (humanizedError != null || e != null) {
        String error = (humanizedError != null) ? humanizedError : e.toString();
        ManagerUI.error(error);
        Label label = new Label(error, ContentMode.HTML);
        label.addStyleName("warning");
        textLayout.addComponent(label);
        textLayout.setComponentAlignment(label, Alignment.TOP_CENTER);
    }

    if (e != null) {
        TextArea stackTrace = new TextArea("Error Log");
        stackTrace.setSizeFull();
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        stackTrace.setValue(sw.toString());
        textLayout.addComponent(stackTrace);
        textLayout.setComponentAlignment(stackTrace, Alignment.TOP_LEFT);
        textLayout.setExpandRatio(stackTrace, 1.0f);
    }

    HorizontalLayout buttonsBar = new HorizontalLayout();
    buttonsBar.setStyleName("buttonsBar");
    buttonsBar.setSizeFull();
    buttonsBar.setSpacing(true);
    buttonsBar.setMargin(true);
    buttonsBar.setHeight("49px");

    Label filler = new Label();
    buttonsBar.addComponent(filler);
    buttonsBar.setExpandRatio(filler, 1.0f);

    Button cancelButton = new Button("Close");
    buttonsBar.addComponent(cancelButton);
    buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            dialogWindow.close();
            //UI.getCurrent().close();
        }
    });

    Button okButton = new Button("Send Error");
    okButton.setEnabled(false);
    okButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            dialogWindow.close();
        }
    });
    buttonsBar.addComponent(okButton);
    buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);

    VerticalLayout windowLayout = (VerticalLayout) dialogWindow.getContent();
    windowLayout.setHeight("100%");
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);
    windowLayout.addComponent(wrapper);
    windowLayout.setExpandRatio(wrapper, 1.0f);
    windowLayout.addComponent(buttonsBar);

}

From source file:com.squadd.views.ChatView.java

private void buildLayout() {

    VerticalLayout chatAndFooter = new VerticalLayout();
    chatAndFooter.setHeight("90%");
    VerticalLayout contacts = new VerticalLayout();
    contacts.setSizeFull();//from ww  w  .ja  v  a 2s .  co m
    contactsPanel.setHeight("800px");
    contactsPanel.setWidth("300px");
    contactsPanel.setContent(contactsLayout);
    contacts.addComponent(contactsPanel);
    contacts.setHeight("90%");

    TextField idTo = new TextField("idTo");
    idTo.setWidth("200px");
    Button setIdTo = new Button("set");
    setIdTo.setWidth("100px");
    HorizontalLayout setUserToId = new HorizontalLayout();

    Button.ClickListener st = new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (!idTo.getValue().equals("")) {
                UserInfoBean newUserTo = new UserInfoBean();
                newUserTo.setId(Integer.parseInt(idTo.getValue()));
                newUserTo.setName("id" + idTo.getValue());
                control.setUserTo(newUserTo);
                if (footer.isVisible() == false) {
                    footer.setVisible(true);
                }
                UserInfoFace look = new UserInfoFace(newUserTo, control, footer);
                Panel panel = look.getUserPanel();

                boolean exists = false;
                for (int i = 0; i < contactsLayout.getComponentCount(); i++) {
                    if (contactsLayout.getComponent(i).getClass() == Panel.class) {
                        Panel pan = (Panel) contactsLayout.getComponent(i);
                        if ((!(pan.getId() == null)) && pan.getId().equals(idTo.getValue())) {
                            exists = true;
                        }
                    }
                }
                if (exists == false) {
                    contactsLayout.addComponent(panel);
                }
                control.clearChat();
                control.updateChatLog(10);
            }
            idTo.clear();
        }
    };

    setIdTo.addClickListener(st);
    setUserToId.addComponents(idTo, setIdTo);
    setUserToId.setComponentAlignment(setIdTo, Alignment.BOTTOM_CENTER);
    contacts.addComponent(setUserToId);
    mainLayout.addComponents(contacts);
    footer.setVisible(false);/////////
    chatAndFooter.addComponents(chatPanel, footer);
    chatLayout = new VerticalLayout();
    chatPanel.setHeight("750px");
    chatPanel.setWidth("900px");
    chatPanel.setContent(chatLayout);
    chatInput = new TextField();
    chatInput.setWidthUndefined();
    footer.addComponent(chatInput);
    chatInput.focus();
    send.setWidth("120px");
    footer.addComponent(send);
    clear.setWidth("120px");
    footer.addComponent(clear);
    update.setWidth("120px");
    footer.addComponent(update);
    footer.setHeight("50px");
    footer.setWidth("900px");
    chatInput.setWidth("100%");
    footer.setExpandRatio(chatInput, 1f);
    chatAndFooter.setExpandRatio(chatPanel, 1f);
    mainLayout.addComponents(chatAndFooter);
    mainLayout.setExpandRatio(chatAndFooter, 1f);
    control.loadFriends();
}

From source file:com.tapas.evidence.fe.main.MainPresenter.java

License:Apache License

@Override
public void bind() {
    final VerticalLayout mainLayout = this.view.getMainLayout();
    final HorizontalSplitPanel layoutPanel = this.view.getSplitLayout();
    mainLayout.setExpandRatio(layoutPanel, 1.0f);
    layoutPanel.setSplitPosition(25, HorizontalSplitPanel.UNITS_PERCENTAGE);

    componentLocation();/*from w  w  w.j  a  va2  s .c  om*/
}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentComplaintsPanel.java

private void openComplaintWindow(Complaint complaint) {

    WebBrowser webBrowser = Page.getCurrent().getWebBrowser();

    Window window = new Window("Registro de Queja");
    window.setModal(true);/* w ww. ja  v  a2  s.  co  m*/
    if (webBrowser.getScreenWidth() < 1024) {
        window.setSizeFull();
    } else {
        window.setHeight(90.0f, Unit.PERCENTAGE);
        window.setWidth(90.0f, Unit.PERCENTAGE);
    }

    //        TextField nameField = new TextField();
    //        nameField.setInputPrompt("Introduzca el ttulo de la queja");
    //        nameField.setWidth("100%");
    TextArea notesArea = new TextArea();
    notesArea.setInputPrompt("Introduzca el contenido de la queja");
    notesArea.setSizeFull();
    //        CheckBox doneField = new CheckBox("Atendido");

    HorizontalLayout horizontal = new HorizontalLayout();
    horizontal.setSpacing(true);
    horizontal.addComponent(createDeleteButton(window));
    horizontal.addComponent(createOkButton(window));

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.setMargin(true);
    layout.addComponent(complaintType);
    layout.addComponent(notesArea);
    //        layout.addComponent(doneField);
    layout.addComponent(horizontal);
    layout.setComponentAlignment(horizontal, Alignment.MIDDLE_RIGHT);
    layout.setExpandRatio(complaintType, 1);
    layout.setExpandRatio(notesArea, 8);
    //        layout.setExpandRatio(doneField, 1);
    layout.setExpandRatio(horizontal, 1);

    BeanItem beanItem = new BeanItem<>(complaint);
    fieldGroup = new BeanFieldGroup<>(Complaint.class);
    fieldGroup.setItemDataSource(beanItem);
    fieldGroup.bind(complaintType, "complaintType");
    fieldGroup.bind(notesArea, "notes");
    //        fieldGroup.bind(doneField, "done");

    window.setContent(layout);
    getUI().addWindow(window);

    //        Window windowComplaint = new Window(complaintView);
    //        WidgetActions actions = new WidgetActions(){
    //
    //            @Override
    //            public void saveAction() {
    //                refreshBind();
    //                windowComplaint.close();
    //            }
    //
    //            @Override
    //            public void deleteAction() {
    //                appointment.getComplaints().remove(complaint);
    //                refreshBind();
    //                windowComplaint.close();
    //            }
    //            
    //        };
    //        complaintView.bind(complaint);
    //        complaintView.setActions(actions);
    //        getUI().addWindow(windowComplaint);
}

From source file:com.terralcode.gestion.frontend.view.window.CustomerFinderDialogWindow.java

private void buildLayout() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();//from w w  w. ja  v  a 2s  . com

    searchText = new TextField();
    searchText.setInputPrompt("Introduzca una cadena de bsqueda");
    searchText.addTextChangeListener(new FieldEvents.TextChangeListener() {

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            String search = event.getText();
            if (search.length() > 3) {
                findCustomer(search);
            }
        }
    });
    searchText.setWidth("100%");
    vlayout.addComponent(searchText);

    resultsTable = new Table();
    resultsTable.setContainerDataSource(containerCustomers);
    resultsTable.setVisibleColumns(new Object[] { "code", "name", "customerStatus", "customerType" });
    resultsTable.setSelectable(true);
    resultsTable.setNullSelectionAllowed(false);
    resultsTable.addItemClickListener(new ItemClickEvent.ItemClickListener() {

        @Override
        public void itemClick(ItemClickEvent event) {
            selectedCustomer = (CustomerCRM) event.getItemId();
            okButton.setEnabled(selectedCustomer != null);
        }
    });
    resultsTable.setSizeFull();
    vlayout.addComponent(resultsTable);
    vlayout.setExpandRatio(resultsTable, 1);

    setBody(vlayout);
    setFooterButtons(DialogButton.OK, DialogButton.CANCEL);
}

From source file:com.vaadHL.window.base.BaseWindow.java

License:Apache License

/**
 * Creates the content of the window but does not set (display). The content
 * consists of three vertically placed areas: the upper, middle and bottom
 * area. Create content but don't bind data.
 * /*w  w w  . j a v a 2s  .c  o  m*/
 * @return The just created content of the window.
 */
public Component getCompositeContent() {
    VerticalLayout content = new VerticalLayout();
    Component c;
    c = makeUpperArea();
    if (c != null)
        content.addComponent(c);
    c = makeMiddleArea();
    if (c != null) {
        c.setSizeFull();
        content.addComponent(c);
        content.setExpandRatio(c, 1);
    }
    c = makeBottomArea();
    if (c != null) {
        VerticalLayout v = new VerticalLayout();
        v.addComponent(c);
        v.setComponentAlignment(c, Alignment.BOTTOM_CENTER);
        /*
         * Label gap = new Label(); gap.setHeight("5px");
         * v.addComponent(gap);
         */
        content.addComponent(v);
        content.setComponentAlignment(v, Alignment.BOTTOM_CENTER);
    }
    content.setSpacing(true);
    return (content);
}

From source file:com.wft.ui.welcome.WFTWelcomeWindow.java

License:Apache License

public void afterPropertiesSet() throws Exception {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();/* w  w w.  jav  a 2  s .com*/
    setContent(layout);

    VerticalLayout leftLayout = new VerticalLayout();
    leftLayout.setSizeFull();
    layout.addComponent(leftLayout);
    layout.setExpandRatio(leftLayout, 1);

    VerticalLayout middleLayout = new VerticalLayout();
    middleLayout.setSizeFull();
    layout.addComponent(middleLayout);
    layout.setExpandRatio(middleLayout, 3);

    VerticalLayout rightLayout = new VerticalLayout();
    rightLayout.setSizeFull();
    layout.addComponent(rightLayout);
    layout.setExpandRatio(rightLayout, 1);

    leftLayout.addComponent(wftWelcomeProfilePanel);
    leftLayout.setExpandRatio(wftWelcomeProfilePanel, 1);

    leftLayout.addComponent(wftWelcomeTournamentsPanel);
    leftLayout.setExpandRatio(wftWelcomeTournamentsPanel, 1);

    leftLayout.addComponent(wftWelcomeCalendarPanel);
    leftLayout.setExpandRatio(wftWelcomeCalendarPanel, 1);

    middleLayout.addComponent(wftWelcomeMainPanel);

    rightLayout.addComponent(wftWelcomeMessagesPanel);
    rightLayout.setExpandRatio(wftWelcomeMessagesPanel, 1);

    rightLayout.addComponent(wftWelcomeChatPanel);
    rightLayout.setExpandRatio(wftWelcomeChatPanel, 1);

    setImmediate(true);
}