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.logviewer.ui.dialog.FilterLog.java

License:Open Source License

private com.vaadin.ui.Component buildContetDialog() {
    final TextField txtFilter = new TextField() {
        {//from   ww  w  . java  2 s.c  o m
            setWidth(100, Unit.PERCENTAGE);
        }
    };

    table = new Table("");

    table.addStyleName("small compact");
    table.setSizeFull();
    table.setImmediate(true);
    table.setSelectable(true);
    table.setEditable(false);
    table.addContainerProperty("Filter", String.class, null);
    loadTable();

    VerticalLayout panelContent = new VerticalLayout();
    panelContent.setSpacing(true);
    panelContent.setMargin(true);
    panelContent.setSizeFull();
    panelContent.setId("panel-content");
    panelContent.addComponent(new HorizontalLayout() {
        {
            addComponent(txtFilter);
            addComponent(new Button("Add", new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent clickEvent) {
                    filters.add(txtFilter.getValue());
                    loadTable();
                }
            }));
            setExpandRatio(txtFilter, 1f);
            setWidth(100, Unit.PERCENTAGE);
        }
    });
    panelContent.addComponent(table);
    panelContent.setExpandRatio(table, 1.0f);

    return panelContent;
}

From source file:com.lst.deploymentautomation.vaadin.core.AppFormConnector.java

License:Open Source License

@Override
public void setContent(Component content) {
    if (content == null) {
        //rendering failed; show a sad face to show how sorry we are
        VerticalLayout layout = new VerticalLayout();
        Label fail = new Label(":-(");
        fail.addStyleName("screen-failed-to-render");
        layout.addComponent(fail);/*from  w w  w  . j a  v a 2s  .  c om*/
        layout.setExpandRatio(fail, 1);
        layout.setComponentAlignment(fail, Alignment.MIDDLE_LEFT);
        layout.setSizeFull();

        view.setContent(layout);

    } else {
        //if the component has either natural or absolute size, wrap it
        //in a scrollable panel with full size and nice margin
        if (content.getHeightUnits() != Unit.PERCENTAGE) {
            final Panel panel = new Panel();
            panel.addStyleName("l-border-none");
            panel.setContent(content);
            panel.setSizeFull();
            content = panel;
        }

        view.setContent(content);
    }
}

From source file:com.lst.deploymentautomation.vaadin.page.TodoListView.java

License:Open Source License

@SuppressWarnings("serial")
private void createView() {
    final LspsUI ui = (LspsUI) getUI();

    setTitle(ui.getMessage(TITLE));//  ww w  .  j  a  va 2 s  . c om

    VerticalLayout layout = new VerticalLayout();
    setContent(layout);

    table = new Table();
    table.setSizeFull();
    table.setSelectable(true);
    table.setMultiSelectMode(MultiSelectMode.SIMPLE);
    table.setSortEnabled(false);
    table.setColumnReorderingAllowed(true);
    table.setColumnCollapsingAllowed(true);

    table.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            final Object sel = event.getProperty().getValue();
            if (sel instanceof Set) {
                selection = (Set<Long>) sel;
            } else if (sel instanceof Long) {
                selection = Collections.singleton((Long) sel);
            } else {
                selection = Collections.emptySet();
            }

            //enable todo actions only if the sel is non-empty
            actionBtn.setEnabled(selection.size() > 0);
        }
    });
    table.addItemClickListener(new ItemClickListener() {

        @Override
        public void itemClick(ItemClickEvent event) {
            if (table.isMultiSelect()) {
                return; //don't do anything if in selection mode
            }
            if (event.getButton() != MouseButton.LEFT || event.isDoubleClick()) {
                return; //ignore right-clicks
            }

            final Item item = event.getItem();
            final Long todoId = (Long) item.getItemProperty("id").getValue();
            try {
                ((LspsUI) getUI()).openTodo(todoId);
            } catch (Exception e) {
                Utils.log(e, "could not open to-do " + todoId, log);
                final LspsUI ui = (LspsUI) getUI();
                ui.showErrorMessage("app.unknownErrorOccurred", e); //todo.openFailed?
            }
        }
    });

    table.setContainerDataSource(container);

    Object[] defaultColumns = new Object[] { "title", "notes", "priority", "authorization", "modelInstanceId",
            "issuedDate" };
    //load table settings
    String settings = ui.getUser().getSettingString(SETTINGS_KEY, null);
    if (settings == null) {
        table.setVisibleColumns(defaultColumns);
        originalSettings = getColumnSettings();
    } else {
        originalSettings = settings;
        try {
            applyTableSettings(settings);
        } catch (Exception e) {
            table.setVisibleColumns(defaultColumns);
            Utils.log(e, "could not load todo list settings", log);
        }
    }

    table.setColumnHeader("title", ui.getMessage("todo.title"));
    table.setColumnHeader("notes", ui.getMessage("todo.notes"));
    table.setColumnHeader("priority", ui.getMessage("todo.priority"));
    table.setColumnHeader("authorization", ui.getMessage("todo.authorizationShort"));
    table.setColumnHeader("modelInstanceId", ui.getMessage("todo.process"));
    table.setColumnHeader("issuedDate", ui.getMessage("todo.issued"));

    table.setColumnAlignment("modelInstanceId", Table.Align.CENTER);
    table.setColumnExpandRatio("title", 2);
    table.setColumnExpandRatio("notes", 1);

    //localize todo titles
    table.addGeneratedColumn("title", new ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            @SuppressWarnings("unchecked")
            BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId);
            return ui.localizeEngineText(item.getBean().getTitle());
        }
    });

    //show icons for authorization
    table.addGeneratedColumn("authorization", new ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            @SuppressWarnings("unchecked")
            BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId);
            String icon;
            String text;
            switch (item.getBean().getAuthorization()) {
            case INITIAL_PERFORMER:
                icon = "auth_performer.gif";
                text = ui.getMessage("todo.authorizationPerformer");
                break;
            case DELEGATE:
                icon = "auth_delegate.gif";
                text = ui.getMessage("todo.authorizationDelegate");
                break;
            case SUBSTITUTE:
                icon = "auth_substitute.gif";
                text = ui.getMessage("todo.authorizationSubstitute");
                break;
            case NOT_PERMITTED:
            default:
                icon = "auth_unknown.gif";
                text = ui.getMessage("todo.authorizationUnknown");
                break;
            }
            Embedded authIcon = new Embedded(null, new ThemeResource("../icons/" + icon));
            authIcon.setDescription(text);

            if (item.getBean().getAllocatedTo() != null) {
                HorizontalLayout layout = new HorizontalLayout();
                layout.setSpacing(true);

                layout.addComponent(authIcon);

                Embedded lockedIcon = new Embedded(null, new ThemeResource("../icons/lock.gif"));
                lockedIcon.setDescription(
                        ui.getMessage("todo.lockedBy", item.getBean().getAllocatedToFullName()));
                layout.addComponent(lockedIcon);
                return layout;
            } else {
                return authIcon;
            }
        }
    });

    //format date
    final SimpleDateFormat df = new SimpleDateFormat(ui.getMessage("app.dateTimeFormat"));
    table.addGeneratedColumn("issuedDate", new ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            @SuppressWarnings("unchecked")
            BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId);
            return df.format(item.getBean().getIssuedDate());
        }
    });

    layout.addComponent(table);
    layout.setExpandRatio(table, 1);
}

From source file:com.lst.deploymentautomation.vaadin.page.TodoView.java

License:Open Source License

@Override
protected void setContent(Component content) {
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();/*from  w w w .  ja  v a2s . co  m*/
    layout.addComponent(annotations);
    layout.addComponent(content);
    layout.setExpandRatio(content, 1);
    super.setContent(layout);
}

From source file:com.lst.deploymentautomation.vaadin.popup.TodoAnnotation.java

License:Open Source License

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

    LspsUI ui = (LspsUI) getUI();//from w  w w. j a v a  2 s.  c  o m
    setCaption(ui.getMessage("todo.annotationTitle"));

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

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

    priorityField = new TextField(ui.getMessage("todo.priority"), priority);
    //TODO forbid negative priorities
    priorityField.setConverter(Integer.class);
    priorityField.setConversionError(ui.getMessage("app.invalidValueMessage"));
    priorityField.setNullRepresentation("");
    priorityField.setNullSettingAllowed(true);
    layout.addComponent(priorityField);

    TextArea notesField = new TextArea(ui.getMessage("todo.notes"), notes);
    notesField.setMaxLength(1024);
    notesField.setNullRepresentation("");
    priorityField.setNullSettingAllowed(true);
    notesField.setSizeFull();
    layout.addComponent(notesField);
    layout.setExpandRatio(notesField, 1);

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

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

        @Override
        public void buttonClick(ClickEvent event) {
            annotate();
        }
    });
    buttons.addComponent(submitButton);

    @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.lst.deploymentautomation.vaadin.popup.TodoDelegation.java

License:Open Source License

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

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

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();
    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.lst.deploymentautomation.vaadin.popup.TodoEscalation.java

License:Open Source License

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

    LspsUI ui = (LspsUI) getUI();//from   ww w  . j a  va  2 s .  c  om
    setCaption(ui.getMessage("todo.escalationTitle"));

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

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

    reason = new TextArea(ui.getMessage("todo.escalationReason"));
    reason.setMaxLength(1024);
    reason.setRequired(true);
    reason.setSizeFull();
    layout.addComponent(reason);
    layout.setExpandRatio(reason, 1);

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

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

        @Override
        public void buttonClick(ClickEvent event) {
            escalate();
        }
    });
    buttons.addComponent(submitButton);

    @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.lst.deploymentautomation.vaadin.popup.TodoRejection.java

License:Open Source License

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

    LspsUI ui = (LspsUI) getUI();// w  w  w  . j a va 2  s .co  m
    setCaption(ui.getMessage("todo.rejectionTitle"));

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

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

    reason = new TextArea(ui.getMessage("todo.rejectionReason"));
    reason.setMaxLength(1024);
    reason.setRequired(true);
    reason.setSizeFull();
    layout.addComponent(reason);
    layout.setExpandRatio(reason, 1);

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

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

        @Override
        public void buttonClick(ClickEvent event) {
            reject();
        }
    });
    buttons.addComponent(rejectButton);

    @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.m4gik.views.component.LicenseScreen.java

/**
 * Method builds license layout with texts.
 * //from  www. ja  v  a  2  s  . co  m
 * @return The VerticalLayout with texts.
 * 
 * @see com.m4gik.views.component.ViewScreen#build()
 */
@Override
public Layout build() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.setCaption("Welcome");

    Panel welcome = new Panel("License");
    welcome.setSizeFull();
    welcome.addStyleName(Runo.PANEL_LIGHT);
    layout.addComponent(welcome);
    layout.setExpandRatio(welcome, 1);

    CssLayout margin = new CssLayout();
    // margin.setMargin(true);
    margin.setWidth("100%");
    welcome.setContent(margin);

    Label title = new Label("Music player");
    title.addStyleName(Runo.LABEL_H1);
    // margin.addComponent(title);

    HorizontalLayout texts = new HorizontalLayout();
    texts.setSpacing(true);
    texts.setWidth("100%");
    margin.addComponent(texts);

    addText(texts,
            "<h3>Everything You Need Is Here</h3>" + "<p>Everything you see inside this application...</p>",
            null);
    addText(texts,
            "<h3>Everything You Need Is Here</h3>" + "<p>Everything you see inside this application...</p>",
            null);
    addText(texts,
            "<h3>Everything You Need Is Here</h3>" + "<p>Everything you see inside this application...</p>",
            null);

    layout.addComponent(new Label("<hr />", Label.CONTENT_XHTML));

    return layout;
}

From source file:com.m4gik.views.MainView.java

/**
 * @param root// ww  w .ja v a 2 s  .c  om
 */
private void addSplitPanel(VerticalLayout root) {
    final HorizontalSplitPanel split = new HorizontalSplitPanel();
    split.setStyleName(Runo.SPLITPANEL_REDUCED);
    split.setSplitPosition(1, Sizeable.Unit.PIXELS);
    split.setLocked(true);
    root.addComponent(split);
    root.setExpandRatio(split, 1);

    addPanelLeft(split);
    addPanelRight(split);
}