Example usage for com.vaadin.ui VerticalLayout setSizeUndefined

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

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout setSizeUndefined.

Prototype

@Override
    public void setSizeUndefined() 

Source Link

Usage

From source file:org.lucidj.vaadinui.Login.java

License:Apache License

@Override // LoginForm
protected Component createContent(TextField userNameField, PasswordField passwordField, Button loginButton) {
    // Save the predefined components
    this.userNameField = userNameField;
    this.passwordField = passwordField;
    this.loginButton = loginButton;

    // Make LoginForm container full-screen
    setSizeFull();//w  w  w .j  ava 2  s  .c o m

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();
    layout.addStyleName("login-wallpaper");

    final VerticalLayout loginPanel = new VerticalLayout();
    loginPanel.setSizeUndefined();
    loginPanel.setMargin(true);
    loginPanel.setSpacing(true);
    Responsive.makeResponsive(loginPanel);
    loginPanel.addStyleName("card");

    //--------
    // HEADER
    //--------

    final HorizontalLayout labels = new HorizontalLayout();
    labels.setWidth("100%");

    final Label title = new Label("<h3><strong>LucidJ</strong> Console</h3>", ContentMode.HTML);
    labels.addComponent(title);
    labels.setExpandRatio(title, 1);

    loginPanel.addComponent(labels);

    //--------
    // FIELDS
    //--------

    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.addStyleName("fields");

    userNameField.setImmediate(true);
    userNameField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER);
    final ShortcutListener username_enter_listener = new ShortcutListener("Next field (Tab)",
            ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object o, Object o1) {
            passwordField.setValue("");
            passwordField.focus();
        }
    };
    userNameField.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(FieldEvents.TextChangeEvent textChangeEvent) {
            show_default_message();

            int new_username_length = textChangeEvent.getText().length();

            // Check for autofill
            if (userNameField.isEmpty() && new_username_length > 1 && !userNameField_filling) {
                // This is autofill
                userNameField.removeShortcutListener(username_enter_listener);
                userNameField.setCursorPosition(new_username_length);
                userNameField.setSelectionRange(0, new_username_length);
            } else {
                userNameField_filling = true;
                passwordField.setValue("");
                userNameField.addShortcutListener(username_enter_listener);
            }
        }
    });
    userNameField.addFocusListener(new FieldEvents.FocusListener() {
        @Override
        public void focus(FieldEvents.FocusEvent focusEvent) {
            // Cursor on username, Enter jump to password
            loginButton.removeClickShortcut();
            userNameField.addShortcutListener(username_enter_listener);
        }
    });
    userNameField.addBlurListener(new FieldEvents.BlurListener() {
        @Override
        public void blur(FieldEvents.BlurEvent blurEvent) {
            // Cursor on password or elsewhere, enter submits
            userNameField.removeShortcutListener(username_enter_listener);
            loginButton.setClickShortcut(ShortcutAction.KeyCode.ENTER);
        }
    });

    passwordField.setImmediate(true);
    passwordField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER);
    passwordField.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(FieldEvents.TextChangeEvent textChangeEvent) {
            show_default_message();
        }
    });

    loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    loginButton.setDisableOnClick(true);

    fields.addComponents(userNameField, passwordField, loginButton);
    fields.setComponentAlignment(loginButton, Alignment.BOTTOM_LEFT);

    loginPanel.addComponent(fields);

    //--------
    // FOOTER
    //--------

    loginPanel.addComponent(new CheckBox("Remember me", true));

    loginPanel.addComponent(message_label);
    show_default_message();

    layout.addComponent(loginPanel);
    layout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
    return (layout);
}

From source file:org.lunifera.examples.ecview.model.ui.PersonUI.java

License:Apache License

@SuppressWarnings("restriction")
@Override//from  ww w  .j a v a 2  s  .  c o m
protected void init(VaadinRequest request) {

    VerticalLayout spanningLayout = new VerticalLayout();
    spanningLayout.setSizeFull();
    setContent(spanningLayout);

    dtoService = DtoServiceAccess.getService(PersonDto.class);
    VerticalLayout layout = new VerticalLayout();
    spanningLayout.addComponent(layout);
    layout.setSizeUndefined();
    layout.setWidth("100%");

    HorizontalLayout buttonBar = new HorizontalLayout();
    layout.addComponent(buttonBar);
    buttonBar.setMargin(true);
    buttonBar.setSpacing(true);
    NativeButton setupDB = new NativeButton("Setup DB");
    setupDB.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Activator.INSTANCE.setupDB();
        }
    });
    buttonBar.addComponent(setupDB);

    YView yView = findViewModel("org.lunifera.examples.ecview.model.jpa.services.PersonView");
    if (yView == null) {
        Notification.show("PersonView could not be found!", Type.ERROR_MESSAGE);
        return;
    }

    // render the Vaadin UI
    VaadinRenderer renderer = new VaadinRenderer();
    try {
        viewContext = renderer.render(layout, yView, null);
    } catch (ContextException e) {
        e.printStackTrace();
    }

    II18nService service = viewContext.getService(II18nService.ID);
    for (YExposedAction action : yView.getExposedActions()) {
        Button temp = new Button();
        buttonBar.addComponent(temp);
        temp.setCaption(service.getValue(action.getLabelI18nKey(), getLocale()));
        temp.setIcon(new ThemeResource(action.getIcon()));
        if (action.getId().equals("org.lunifera.actions.load")) {
            reloadAction = temp;
            reloadAction.setEnabled(false);
            temp.addClickListener(new LoadHandler());
        } else if (action.getId().equals("org.lunifera.actions.save")) {
            saveAction = temp;
            saveAction.setEnabled(false);
            temp.addClickListener(new SaveHandler());
        } else if (action.getId().equals("org.lunifera.actions.delete")) {
            deleteAction = temp;
            deleteAction.setEnabled(false);
            temp.addClickListener(new DeleteHandler());
        } else if (action.getId().equals("org.lunifera.actions.find")) {
            searchAction = temp;
            temp.addClickListener(new SearchHandler());
        }
    }
}

From source file:org.ripla.web.demo.widgets.views.InputWidgetsView.java

License:Open Source License

public InputWidgetsView() {
    super();/*from w w w  .  ja  v a  2s  .  c o  m*/

    final IMessages lMessages = Activator.getMessages();
    final VerticalLayout lLayout = initLayout(lMessages, "widgets.title.page.input"); //$NON-NLS-1$

    final HorizontalLayout lColumns = new HorizontalLayout();
    lColumns.setSpacing(true);
    lLayout.addComponent(lColumns);

    final VerticalLayout lCol1 = new VerticalLayout();
    lCol1.setSizeUndefined();
    lColumns.addComponent(lCol1);
    final VerticalLayout lCol2 = new VerticalLayout();
    lCol2.setSizeUndefined();
    lColumns.addComponent(lCol2);
    final VerticalLayout lCol3 = new VerticalLayout();
    lCol3.setSizeUndefined();
    lColumns.addComponent(lCol3);
    lColumns.setExpandRatio(lCol3, 1);

    // classic input fields
    lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.input.normal"))); //$NON-NLS-1$
    final TextField lTextField = new TextField();
    lTextField.setColumns(WIDTH_FIELD);
    lCol1.addComponent(lTextField);

    lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.input.prompt"))); //$NON-NLS-1$
    final TextField lTextField2 = new TextField();
    lTextField2.setInputPrompt(lMessages.getMessage("widgets.input.input.prompt")); //$NON-NLS-1$
    lTextField2.setColumns(WIDTH_FIELD);
    lCol1.addComponent(lTextField2);

    lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.input.password"))); //$NON-NLS-1$
    final PasswordField lPassword = new PasswordField();
    lPassword.setColumns(WIDTH_FIELD);
    lCol1.addComponent(lPassword);

    lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.date"))); //$NON-NLS-1$
    final PopupDateField lDate1 = new PopupDateField(lMessages.getMessage("widgets.input.popup.date")); //$NON-NLS-1$
    lDate1.setResolution(Resolution.DAY);
    lDate1.setDateFormat("dd. MMMM yyyy"); //$NON-NLS-1$
    lDate1.setWidth(160, Unit.PIXELS);
    lDate1.setValue(new java.util.Date());
    lCol1.addComponent(lDate1);

    // text areas
    lCol2.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.text.area"))); //$NON-NLS-1$
    final TextArea lArea = new TextArea();
    lArea.setColumns(WIDTH_AREA);
    lArea.setRows(7);
    lCol2.addComponent(lArea);

    lCol2.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.rich.text"))); //$NON-NLS-1$
    final RichTextArea lRichText = new RichTextArea();
    lRichText.setWidth(WIDTH_AREA, Unit.EM);
    lRichText.setHeight(15, Unit.EM);
    lCol2.addComponent(lRichText);

    // text input with filter
    final CountryContainer lCountries = new CountryContainer();
    lCol3.addComponent(getSubtitle(lMessages.getMessage("widgets.input.subtitle.input.filter"))); //$NON-NLS-1$
    final TextField lFilter = new TextField();
    lFilter.setTextChangeEventMode(TextChangeEventMode.LAZY);
    lFilter.setTextChangeTimeout(200);
    lFilter.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(final TextChangeEvent inEvent) {
            lCountries.removeAllContainerFilters();
            lCountries.addContainerFilter(
                    new SimpleStringFilter(CountryContainer.PROPERTY_NAME, inEvent.getText(), true, true));
        }
    });
    lFilter.setWidth(FILTER_WIDTH, Unit.PIXELS);

    final Table lTable = new Table(null, lCountries);
    lTable.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
    lTable.setWidth(FILTER_WIDTH, Unit.PIXELS);
    lTable.setPageLength(18);

    lCol3.addComponent(lFilter);
    lCol3.addComponent(lTable);
}

From source file:org.ripla.web.demo.widgets.views.SelectionWidgetsView.java

License:Open Source License

public SelectionWidgetsView(final CountryContainer inCountries) {
    super();/*from   w w w . j ava 2 s .com*/

    final IMessages lMessages = Activator.getMessages();
    final VerticalLayout lLayout = initLayout(lMessages, "widgets.title.page.select"); //$NON-NLS-1$

    final HorizontalLayout lColumns = new HorizontalLayout();
    lColumns.setSpacing(true);
    lLayout.addComponent(lColumns);

    final VerticalLayout lCol1 = new VerticalLayout();
    lCol1.setSizeUndefined();
    lColumns.addComponent(lCol1);
    final VerticalLayout lCol2 = new VerticalLayout();
    lCol2.setSizeUndefined();
    lColumns.addComponent(lCol2);
    final VerticalLayout lCol3 = new VerticalLayout();
    lCol3.setSizeUndefined();
    lColumns.addComponent(lCol3);
    lColumns.setExpandRatio(lCol3, 1);

    lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.selection.subtitle.list"))); //$NON-NLS-1$
    final ListSelect lList1 = new ListSelect(null, inCountries);
    lList1.setItemCaptionMode(ItemCaptionMode.ID);
    lList1.setRows(10);
    lList1.setMultiSelect(true);
    lList1.setNullSelectionAllowed(false);
    lList1.select(inCountries.getIdByIndex(0));
    lList1.setImmediate(true);
    lList1.addValueChangeListener(new Listener());
    lCol1.addComponent(lList1);

    lCol1.addComponent(getSubtitle(lMessages.getMessage("widgets.selection.subtitle.combox"))); //$NON-NLS-1$
    final ComboBox lCombo = new ComboBox(null, inCountries);
    lCombo.setInputPrompt(lMessages.getMessage("widgets.selection.combox.prompt")); //$NON-NLS-1$
    lCombo.setNullSelectionAllowed(false);
    lCombo.setFilteringMode(FilteringMode.STARTSWITH);
    lCombo.setImmediate(true);
    lCombo.addValueChangeListener(new Listener());
    lCol1.addComponent(lCombo);

    lCol2.addComponent(getSubtitle(lMessages.getMessage("widgets.selection.subtitle.options.single"))); //$NON-NLS-1$
    List<String> lCountries = getRandomSubset(inCountries, OPTION_SIZE, System.currentTimeMillis());
    final OptionGroup lOptions1 = new OptionGroup(null, lCountries);
    lOptions1.setNullSelectionAllowed(false);
    lOptions1.select(lCountries.get(0));
    lOptions1.setImmediate(true);
    lOptions1.addValueChangeListener(new Listener());
    lCol2.addComponent(lOptions1);

    lCol2.addComponent(getSubtitle(lMessages.getMessage("widgets.selection.subtitle.options.multiple"))); //$NON-NLS-1$
    lCountries = getRandomSubset(inCountries, OPTION_SIZE, System.currentTimeMillis() + 2000);
    final OptionGroup lOptions2 = new OptionGroup(null, lCountries);
    lOptions2.setNullSelectionAllowed(false);
    lOptions2.setMultiSelect(true);
    lOptions2.select(lCountries.get(0));
    lOptions2.setImmediate(true);
    lOptions2.addValueChangeListener(new Listener());
    lCol2.addComponent(lOptions2);

    lCol3.addComponent(getSubtitle(lMessages.getMessage("widgets.selection.subtitle.twin"))); //$NON-NLS-1$
    final TwinColSelect lCountrySelect = new TwinColSelect();
    lCountrySelect.setContainerDataSource(inCountries);
    lCountrySelect.setRows(OPTION_SIZE);
    lCountrySelect.setNullSelectionAllowed(true);
    lCountrySelect.setMultiSelect(true);
    lCountrySelect.setWidth(400, Unit.PIXELS);
    lCol3.addComponent(lCountrySelect);
}

From source file:org.sensorhub.ui.DefaultModulePanelBuilder.java

License:Mozilla Public License

@Override
public Component buildPanel(MyBeanItem<ModuleConfig> beanItem, IModule<?> module,
        IModuleConfigFormBuilder formBuilder) {
    // create panel with module name
    String moduleType = formBuilder.getTitle(beanItem.getBean());
    Panel panel = new Panel(moduleType);

    // add generated form
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeUndefined();
    layout.setWidth(100.0f, Unit.PERCENTAGE);
    layout.setMargin(true);/* w  ww .  j  a  v  a  2s .  co m*/

    Component form = formBuilder.buildForm(new FieldGroup(beanItem));
    layout.addComponent(form);

    panel.setContent(layout);
    return panel;
}

From source file:org.sensorhub.ui.SensorPanelBuilder.java

License:Mozilla Public License

@Override
public Component buildPanel(MyBeanItem<ModuleConfig> beanItem, IModule<?> module,
        IModuleConfigFormBuilder formBuilder) {
    ModuleConfig moduleConfig = beanItem.getBean();

    // create panel with module name
    String moduleName = beanItem.getBean().name + " (" + beanItem.getBean().moduleClass + ")";
    Panel panel = new Panel(moduleName);

    // add generated form
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeUndefined();
    layout.setMargin(true);/*from  ww  w  . jav  a 2 s .c  om*/

    Component form = formBuilder.buildForm(new FieldGroup(beanItem));
    layout.addComponent(form);

    // only if module is loaded and started
    if (module != null && module.isEnabled()) {

    }

    panel.setContent(layout);
    return panel;
}

From source file:org.test.chartjs.ChartJSIntegrationView.java

License:Apache License

public ChartJSIntegrationView() {
    this.setSizeUndefined();
    VerticalLayout vl = new VerticalLayout();
    vl.setSizeUndefined();
    //      vl.setWidth("500px");
    //      vl.setHeight("500px");
    this.setContent(vl);
    vl.setId("myPanel");
    chartJSExtension = new ChartJSExtension();
    chartJSExtension.extend(this);

}

From source file:org.vaadin.spring.samples.security.shared.LoginUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    getPage().setTitle("Vaadin Shared Security Demo Login");

    FormLayout loginForm = new FormLayout();
    loginForm.setSizeUndefined();// w  w w .j  a  va  2  s  . c o m

    userName = new TextField("Username");
    passwordField = new PasswordField("Password");
    rememberMe = new CheckBox("Remember me");
    login = new Button("Login");
    loginForm.addComponent(userName);
    loginForm.addComponent(passwordField);
    loginForm.addComponent(rememberMe);
    loginForm.addComponent(login);
    login.addStyleName(ValoTheme.BUTTON_PRIMARY);
    login.setDisableOnClick(true);
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            login();
        }
    });

    VerticalLayout loginLayout = new VerticalLayout();
    loginLayout.setSpacing(true);
    loginLayout.setSizeUndefined();

    if (request.getParameter("logout") != null) {
        loggedOutLabel = new Label("You have been logged out!");
        loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS);
        loggedOutLabel.setSizeUndefined();
        loginLayout.addComponent(loggedOutLabel);
        loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER);
    }

    loginLayout.addComponent(loginFailedLabel = new Label());
    loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER);
    loginFailedLabel.setSizeUndefined();
    loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE);
    loginFailedLabel.setVisible(false);

    loginLayout.addComponent(loginForm);
    loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER);

    VerticalLayout rootLayout = new VerticalLayout(loginLayout);
    rootLayout.setSizeFull();
    rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER);
    setContent(rootLayout);
    setSizeFull();
}

From source file:org.vaadin.spring.samples.security.ui.login.views.LoginView.java

License:Apache License

private Component buildLoginForm() {
    final VerticalLayout loginPanel = new VerticalLayout();
    loginPanel.setSizeUndefined();
    loginPanel.setSpacing(true);//from   ww  w.jav  a 2s. c  o  m
    Responsive.makeResponsive(loginPanel);
    loginPanel.addStyleName("login-panel");

    loginPanel.addComponent(buildLabels());
    loginPanel.addComponent(buildFields());
    loginPanel.addComponent(rememberMe);
    return loginPanel;
}

From source file:pl.exsio.frameset.vaadin.ui.support.component.data.common.DataComponent.java

License:Open Source License

private Layout buildForm(final I item, final C container, final Window formWindow, final int mode) {
    F form = this.instantiateForm(item, container, formWindow, mode);
    this.formatForm(form);
    VerticalLayout mainLayout = new VerticalLayout();
    Layout formLayout = this.decorateForm(form, item, mode);
    formLayout.setSizeUndefined();/*from ww  w  .  ja v a 2 s .c  o  m*/
    formLayout.setStyleName("frameset-dc-window-form-wrapper");
    if (formLayout instanceof MarginHandler) {
        ((MarginHandler) formLayout).setMargin(new MarginInfo(false, true, false, true));
    }
    Layout controls = this.decorateFormControls(
            this.createFormControls(item, form, container, formWindow, mode), item, form, container, formWindow,
            mode);
    mainLayout.addComponent(formLayout);
    mainLayout.addComponent(controls);
    mainLayout.setExpandRatio(formLayout, 10);
    mainLayout.setExpandRatio(controls, 1);
    mainLayout.setSizeUndefined();
    return mainLayout;

}