Example usage for com.vaadin.ui HorizontalLayout HorizontalLayout

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

Introduction

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

Prototype

public HorizontalLayout() 

Source Link

Document

Constructs an empty HorizontalLayout.

Usage

From source file:br.com.anteros.mobileserver.app.form.TableForm.java

License:Apache License

private void createGrids() {
    layoutFields = new VerticalLayout();
    layoutFields.setImmediate(false);//from w  ww  . j a  v  a2 s  . co  m
    layoutFields.setWidth("100.0%");
    layoutFields.setHeight("100.0%");
    layoutFields.setMargin(false);

    gridFields = new Table();
    gridFields.setWidth("100.0%");
    gridFields.setHeight("100.0%");
    gridFields.setContainerDataSource(getFieldsDataSource());
    gridFields.setColumnHeaders(
            new String[] { "Id", "Nome campo", "Descrio", "Nome campo SQL", "Tipo de Campo", "" });
    gridFields.setSizeFull();
    gridFields.addListener(new Property.ValueChangeListener() {

        public void valueChange(ValueChangeEvent event) {
            enableActions();
        }
    });

    gridFields.setColumnExpandRatio("NAME", 1);
    gridFields.setColumnWidth("ID", 70);
    gridFields.setColumnWidth("NAME", 300);
    gridFields.setColumnWidth("DESCRIPTION", 400);
    gridFields.setColumnWidth("SQL_FIELD_NAME", 200);
    gridFields.setColumnWidth("FIELD_TYPE", 200);
    gridFields.setColumnWidth(MobileServerData.PROPERTY_DATA, 1);
    gridFields.setSelectable(true);
    gridFields.setImmediate(true);

    layoutFields.addComponent(gridFields);
    layoutFields.setExpandRatio(gridFields, 1.0f);

    buttonsFields = new HorizontalLayout();
    buttonsFields.setImmediate(false);
    buttonsFields.setWidth("100.0%");
    buttonsFields.setHeight("30px");
    buttonsFields.setMargin(false);
    buttonsFields.setSpacing(true);

    btnAddField = new Button();
    btnAddField.setCaption("Adicionar");
    btnAddField.setImmediate(false);
    btnAddField.setWidth("-1px");
    btnAddField.setHeight("-1px");
    btnAddField.setIcon(new ThemeResource("icons/16/fieldAdd.png"));
    btnAddField.addListener(this);
    buttonsFields.addComponent(btnAddField);
    buttonsFields.setComponentAlignment(btnAddField, new Alignment(33));

    btnRemoveField = new Button();
    btnRemoveField.setCaption("Remover");
    btnRemoveField.setImmediate(false);
    btnRemoveField.setWidth("-1px");
    btnRemoveField.setHeight("-1px");
    btnRemoveField.setIcon(new ThemeResource("icons/16/fieldRemove.png"));
    btnRemoveField.addListener(this);
    buttonsFields.addComponent(btnRemoveField);
    buttonsFields.setComponentAlignment(btnRemoveField, new Alignment(33));

    btnEditField = new Button();
    btnEditField.setCaption("Editar");
    btnEditField.setImmediate(false);
    btnEditField.setWidth("-1px");
    btnEditField.setHeight("-1px");
    btnEditField.setIcon(new ThemeResource("icons/16/fieldEdit.png"));
    btnEditField.addListener(this);
    buttonsFields.addComponent(btnEditField);
    buttonsFields.setComponentAlignment(btnEditField, new Alignment(33));
    buttonsFields.setExpandRatio(btnEditField, 1);

    layoutParameters = new VerticalLayout();
    layoutParameters.setImmediate(false);
    layoutParameters.setWidth("100.0%");
    layoutParameters.setHeight("100.0%");
    layoutParameters.setMargin(false);

    gridParameters = new Table();
    gridParameters.setWidth("100.0%");
    gridParameters.setHeight("100.0%");
    gridParameters.setContainerDataSource(getParametersDataSource());
    gridParameters.setColumnHeaders(new String[] { "Id", "Nome Parmetro", "Descrio",
            "Tipo Dado Parmetro", "Tipo de Parmetro", "" });
    gridParameters.setSizeFull();
    gridParameters.setSelectable(true);
    gridParameters.setImmediate(true);

    gridParameters.setColumnExpandRatio("NAME", 1);
    gridParameters.setColumnWidth("ID", 70);
    gridParameters.setColumnWidth("NAME", 300);
    gridParameters.setColumnWidth("DESCRIPTION", 400);
    gridParameters.setColumnWidth("PARAMETER_DATA_TYPE", 200);
    gridParameters.setColumnWidth("PARAMETER_TYPE", 200);
    gridParameters.setColumnWidth(MobileServerData.PROPERTY_DATA, 0);
    gridParameters.addListener(new Property.ValueChangeListener() {

        public void valueChange(ValueChangeEvent event) {
            enableActions();
        }
    });
    layoutParameters.addComponent(gridParameters);
    layoutParameters.setExpandRatio(gridParameters, 1.0f);

    buttonsParameters = new HorizontalLayout();
    buttonsParameters.setImmediate(false);
    buttonsParameters.setWidth("100.0%");
    buttonsParameters.setHeight("30px");
    buttonsParameters.setMargin(false);
    buttonsParameters.setSpacing(true);

    btnAddParameter = new Button();
    btnAddParameter.setCaption("Adicionar");
    btnAddParameter.setImmediate(false);
    btnAddParameter.setWidth("-1px");
    btnAddParameter.setHeight("-1px");
    btnAddParameter.setIcon(new ThemeResource("icons/16/parameterAdd.png"));
    btnAddParameter.addListener(this);
    buttonsParameters.addComponent(btnAddParameter);
    buttonsParameters.setComponentAlignment(btnAddParameter, new Alignment(33));

    btnRemoveParameter = new Button();
    btnRemoveParameter.setCaption("Remover");
    btnRemoveParameter.setImmediate(false);
    btnRemoveParameter.setWidth("-1px");
    btnRemoveParameter.setHeight("-1px");
    btnRemoveParameter.setIcon(new ThemeResource("icons/16/parameterRemove.png"));
    btnRemoveParameter.addListener(this);
    buttonsParameters.addComponent(btnRemoveParameter);
    buttonsParameters.setComponentAlignment(btnRemoveParameter, new Alignment(33));

    btnEditParameter = new Button();
    btnEditParameter.setCaption("Editar");
    btnEditParameter.setImmediate(false);
    btnEditParameter.setWidth("-1px");
    btnEditParameter.setHeight("-1px");
    btnEditParameter.setIcon(new ThemeResource("icons/16/parameterEdit.png"));
    btnEditParameter.addListener(this);
    buttonsParameters.addComponent(btnEditParameter);
    buttonsParameters.setComponentAlignment(btnEditParameter, new Alignment(33));
    buttonsParameters.setExpandRatio(btnEditParameter, 1);

}

From source file:br.com.anteros.mobileserver.app.form.TableForm.java

License:Apache License

private void createButtons() {
    buttons = new HorizontalLayout();
    buttons.setSpacing(true);// www. j  ava 2 s .  c  o  m
    buttons.setWidth("100%");

    buttons.addComponent(buttonsFields);
    buttons.setExpandRatio(buttonsFields, 1);

    btnOk = new Button("Ok", this);
    btnOk.addStyleName("default");
    btnOk.setIcon(new ThemeResource("icons/16/ok.png"));
    btnOk.addListener(this);
    buttons.addComponent(btnOk);
    buttons.setComponentAlignment(btnOk, Alignment.MIDDLE_RIGHT);

    btnCancel = new Button("Cancela", this);
    btnCancel.setIcon(new ThemeResource("icons/16/cancel.png"));
    btnCancel.addListener(this);
    buttons.addComponent(btnCancel);
    buttons.setComponentAlignment(btnCancel, Alignment.MIDDLE_RIGHT);
    buttons.setMargin(true, false, true, false);
}

From source file:br.com.anteros.mobileserver.app.form.UserLoginForm.java

License:Apache License

private HorizontalLayout buildHorizontalLayout_1() {
    horizontalLayout = new HorizontalLayout();
    horizontalLayout.setImmediate(false);
    horizontalLayout.setWidth("100.0%");
    horizontalLayout.setHeight("100.0%");
    horizontalLayout.setMargin(false);/*from   www.  j  a  va  2s . c om*/

    image = new Embedded();
    image.setImmediate(false);
    image.setWidth("64px");
    image.setHeight("64px");
    image.setSource(new ThemeResource("img/login.png"));
    image.setType(1);
    image.setMimeType("image/png");
    horizontalLayout.addComponent(image);
    horizontalLayout.setComponentAlignment(image, new Alignment(33));

    absoluteLayout = buildAbsoluteLayout();
    horizontalLayout.addComponent(absoluteLayout);
    horizontalLayout.setExpandRatio(absoluteLayout, 1.0f);

    return horizontalLayout;
}

From source file:br.com.anteros.mobileserver.util.UserMessages.java

License:Apache License

public Window confirm(String title, String message, String okTitle, String cancelTitle,
        Button.ClickListener listener) {

    if (title == null) {
        title = CONFIRM_OK_TITLE;/*w w  w. j av  a 2  s.  c om*/
    }
    if (cancelTitle == null) {
        cancelTitle = CONFIRM_CANCEL_TITLE;
    }
    if (okTitle == null) {
        okTitle = CONFIRM_OK_TITLE;
    }

    final Window confirm = new Window(title);
    this.confirm = confirm;
    win.addWindow(confirm);

    confirm.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1971800928047045825L;

        public void windowClose(CloseEvent ce) {
            Object data = ce.getWindow().getData();
            if (data != null) {
                try {
                } catch (Exception exception) {
                    error("Unhandled Exception", exception);
                }
            }
        }
    });

    int chrW = 5;
    int chrH = 15;
    int txtWidth = Math.max(250, Math.min(350, message.length() * chrW));
    int btnHeight = 25;
    int vmargin = 100;
    int hmargin = 40;

    int txtHeight = 2 * chrH * (message.length() * chrW) / txtWidth;

    confirm.setWidth((txtWidth + hmargin) + "px");
    confirm.setHeight((vmargin + txtHeight + btnHeight) + "px");
    confirm.getContent().setSizeFull();

    confirm.center();
    confirm.setModal(true);

    Label text = new Label(message);
    text.setWidth("100%");
    text.setHeight("100%");

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setHeight(btnHeight + 5 + "px");
    buttons.setWidth("100%");
    buttons.setSpacing(true);
    buttons.setMargin(false);

    Button cancel = new Button(cancelTitle, listener);
    cancel.setIcon(new ThemeResource("icons/16/no.png"));
    cancel.setData(USER_CONFIRM_CANCEL);
    cancel.setClickShortcut(KeyCode.ESCAPE);
    Button ok = new Button(okTitle, listener);
    ok.setIcon(new ThemeResource("icons/16/yes.png"));
    ok.setData(USER_CONFIRM_OK);
    ok.setClickShortcut(KeyCode.ENTER);
    buttons.addComponent(ok);
    buttons.setExpandRatio(ok, 1);
    buttons.setComponentAlignment(ok, Alignment.MIDDLE_RIGHT);

    buttons.addComponent(cancel);
    buttons.setComponentAlignment(cancel, Alignment.MIDDLE_RIGHT);

    confirm.addComponent(text);
    confirm.addComponent(buttons);
    ((VerticalLayout) confirm.getContent()).setExpandRatio(text, 1f);
    confirm.setResizable(false);
    return confirm;
}

From source file:br.gov.frameworkdemoiselle.vaadin.ui.CrudForm.java

License:Open Source License

protected void createButtons() {
    buttonSave = new Button(this.bundle.getString("button.save"));
    buttonClear = new Button(this.bundle.getString("button.clear"));
    buttonDelete = new Button(this.bundle.getString("button.delete"));

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);/*from w  ww  . j a  v  a 2 s .  co m*/
    buttons.addComponent(getButtonSave());
    buttons.addComponent(getButtonDelete());
    buttons.addComponent(buttonClear);
    getFooter().addComponent(buttons);

    getButtonSave().addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                commit();
            } catch (InvalidValueException exception) {
                beanManager.fireEvent(getBean(), new AnnotationLiteral<ProcessInvalidValue>() {
                });
                getWindow().showNotification(exception.getMessage(), Notification.TYPE_WARNING_MESSAGE);
                return;
            }
            beanManager.fireEvent(getBean(), new AnnotationLiteral<ProcessSave>() {
            });
        }

    });

    buttonClear.addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            CrudForm.this.discard();
            beanManager.fireEvent(getBean(), new AnnotationLiteral<ProcessClear>() {
            });
        }

    });

    getButtonDelete().addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            beanManager.fireEvent(getBean(), new AnnotationLiteral<ProcessDelete>() {
            });
        }

    });
}

From source file:br.gov.sp.saovicente.MyVaadinApplication.java

License:Apache License

@Override
public void init() {

    final Window mainWindow = new Window("Sampleinvientchart2 Application");
    mainWindow.setSizeFull();//from w ww .ja va  2  s  .c  om
    setMainWindow(mainWindow);

    mgberr = new MessageBox(getMainWindow(), "My message ERRO...", MessageBox.Icon.ERROR, "Hello World!",
            new MessageBox.ButtonConfig(ButtonType.OK, "Ok"));

    mgbinf = new MessageBox(getMainWindow(), "My message INFO...", MessageBox.Icon.INFO, "Hello World!",
            new MessageBox.ButtonConfig(ButtonType.OK, "Ok"));

    mgbquest = new MessageBox(getMainWindow(), "My message QUESTION...", MessageBox.Icon.QUESTION,
            "Hello World!", new MessageBox.ButtonConfig(ButtonType.YES, "YES"),
            new MessageBox.ButtonConfig(ButtonType.NO, "NO"));

    mgbnone = new MessageBox(getMainWindow(), "My message NONE...", MessageBox.Icon.QUESTION, "Hello World!",
            new MessageBox.ButtonConfig(ButtonType.OK, "Ok"));

    mgbwarn = new MessageBox(getMainWindow(), "My message WARN...", MessageBox.Icon.WARN, "Hello World!",
            new MessageBox.ButtonConfig(ButtonType.OK, "Ok"));

    infomacao = new Button("Informao");

    infomacao.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            mgbinf.show(new MessageBox.EventListener() {

                public void buttonClicked(ButtonType buttonType) {
                }
            });
        }
    });

    erro = new Button("Erro");

    erro.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            mgberr.show(new MessageBox.EventListener() {

                public void buttonClicked(ButtonType buttonType) {
                    System.out.println("Este boto foi pressionado: " + buttonType);
                }
            });
        }
    });

    none = new Button("None");

    none.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            mgbnone.show(new MessageBox.EventListener() {

                public void buttonClicked(ButtonType buttonType) {
                    System.out.println("Este boto foi pressionado: " + buttonType);
                }
            });
        }
    });

    question = new Button("Question");

    question.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            mgbquest.show(new MessageBox.EventListener() {

                public void buttonClicked(ButtonType buttonType) {
                    if (buttonType.toString().equals("YES")) {
                        mainWindow.open(new ExternalResource("http://10.171.0.9:8080/bic/"));
                        System.out.println("Este boto foi pressionado: " + buttonType);
                    } else if (buttonType.toString().equals("NO")) {
                        mainWindow.open(new ExternalResource("http://localhost:8080/modelo/"));
                    }
                }
            });
        }
    });

    warn = new Button("Warn");

    warn.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            mgbwarn.show(new MessageBox.EventListener() {

                public void buttonClicked(ButtonType buttonType) {
                    System.out.println("Este boto foi pressionado: " + buttonType);
                }
            });
        }
    });

    HorizontalLayout botao = new HorizontalLayout();
    botao.setSpacing(true);
    botao.addComponent(erro);
    botao.addComponent(warn);
    botao.addComponent(none);
    botao.addComponent(infomacao);
    botao.addComponent(question);

    // CustomDateField df = new CustomDateField();
    //df.setbTwelveHourClock(false);
    // df.setbTwelveHourClock(true);
    // mainWindow.addComponent(df);
    //mainWindow.addComponent(new WidgetSetTest());

    mainWindow.addComponent(botao);

}

From source file:by.bigvova.MainUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    EventBus.register(this);
    getPage().setTitle("FoodNote");
    UI.getCurrent().setLocale(Locale.forLanguageTag("ru-RU"));
    // Let's register a custom error handler to make the 'access denied' messages a bit friendlier.
    setErrorHandler(new DefaultErrorHandler() {
        @Override//from   ww  w  .  ja v a2  s.c  o  m
        public void error(com.vaadin.server.ErrorEvent event) {
            if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) {
                Notification.show("Sorry, you don't have access to do that.");
            } else {
                super.error(event);
            }
        }
    });
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();

    // By adding a security item filter, only views that are accessible to the user will show up in the side bar.
    sideBar.setItemFilter(new VaadinSecurityItemFilter(vaadinSecurity));
    sideBar.setHeader(new CssLayout() {
        {
            Label header = new Label("<span>Food</span>Note", ContentMode.HTML);
            header.setWidth(100, Unit.PERCENTAGE);
            header.setHeightUndefined();
            addComponent(header);
            addComponent(buildUserMenu());
        }
    });
    sideBar.getHeader().setStyleName("branding");
    layout.addComponent(sideBar);

    CssLayout viewContainer = new CssLayout();
    viewContainer.setSizeFull();
    layout.addComponent(viewContainer);
    layout.setExpandRatio(viewContainer, 1f);

    Navigator navigator = new Navigator(this, viewContainer);
    // Without an AccessDeniedView, the view provider would act like the restricted views did not exist at all.
    springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class);
    navigator.addProvider(springViewProvider);
    navigator.setErrorView(ErrorView.class);
    navigator.navigateTo(navigator.getState());

    setContent(layout); // Call this here because the Navigator must have been configured before the Side Bar can be attached to a UI.
}

From source file:by.bigvova.ui.LoginUI.java

License:Apache License

private Component buildFields() {
    final VerticalLayout layout = new VerticalLayout();
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);//from w w  w .  jav a  2 s.  c  om
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.setIcon(FontAwesome.USER);
    username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final PasswordField password = new PasswordField("Password");
    password.setIcon(FontAwesome.LOCK);
    password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final Button signin = new Button("Sign In");
    signin.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signin.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    signin.focus();

    final CheckBox checkBox = new CheckBox("Remember me", true);

    signin.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            login(username.getValue(), password.getValue(), checkBox.getValue());
        }
    });

    fields.addComponents(username, password, signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    layout.setSpacing(true);
    layout.addComponent(fields);
    layout.addComponent(checkBox);
    return layout;
}

From source file:by.bigvova.views.UserView.UserView.java

License:Apache License

@Autowired
public UserView(MealController userMealController) {
    footerButtons = new HorizontalLayout();
    mainGrid = new MainGrid(userMealController, footerButtons);
}

From source file:cb_server.SettingsWindow.java

License:Open Source License

private void addSaveCancelButtons() {
    HorizontalLayout hl = new HorizontalLayout();
    final Button btnSave = new Button(Translation.Get("save".hashCode()));
    final Button btnCancel = new Button(Translation.Get("cancel".hashCode()));

    hl.addComponent(btnSave);//  w w w  . ja  va 2  s.c  o m
    hl.addComponent(btnCancel);

    btnCancel.addClickListener(new ClickListener() {

        private static final long serialVersionUID = -4799987364890297976L;

        @Override
        public void buttonClick(ClickEvent event) {
            Config.settings.LoadFromLastValue();
            SettingsWindow.this.close();
        }
    });

    btnSave.addClickListener(new ClickListener() {

        private static final long serialVersionUID = -878673538684730570L;

        @Override
        public void buttonClick(ClickEvent event) {
            String lang = (String) langSpinner.getValue();

            for (Lang tmp : Translation.GetLangs(SettingsClass.LanguagePath.getValue())) {
                if (lang.equals(tmp.Name)) {
                    CB_UI_Base_Settings.Sel_LanguagePath.setValue(tmp.Path);
                    try {
                        Translation.LoadTranslation(tmp.Path);
                    } catch (Exception e) {
                        try {
                            Translation.LoadTranslation(CB_UI_Base_Settings.Sel_LanguagePath.getDefaultValue());
                        } catch (IOException e1) {
                            e1.printStackTrace();
                        }
                    }
                    break;
                }

            }

            Config.settings.WriteToDB();
            Config.settings.SaveToLastValue();

            SettingsWindow.this.close();
        }
    });

    content.addComponent(hl);
}