Example usage for com.vaadin.ui HorizontalLayout setSizeUndefined

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

Introduction

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

Prototype

@Override
    public void setSizeUndefined() 

Source Link

Usage

From source file:org.vaadin.addons.sitekit.viewlet.administrator.group.GroupsFlowlet.java

License:Apache License

@Override
public void initialize() {
    final List<FieldDescriptor> fieldDescriptors = SiteFields.getFieldDescriptors(Group.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    container = new EntityContainer<Group>(entityManager, true, false, false, Group.class, 1000,
            new String[] { "name" }, new boolean[] { true }, "groupId");

    ContainerUtil.addContainerProperties(container, fieldDescriptors);

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();//  w ww .j  a  v a2  s . c  o m
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setSizeUndefined();
    gridLayout.addComponent(buttonLayout, 0, 0);

    final Table table = new FormattingTable();
    grid = new Grid(table, container);
    grid.setFields(fieldDescriptors);
    grid.setFilters(filterDefinitions);

    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    gridLayout.addComponent(grid, 0, 1);

    final Button addButton = getSite().getButton("add");
    buttonLayout.addComponent(addButton);
    addButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Group group = new Group();
            group.setCreated(new Date());
            group.setModified(group.getCreated());
            group.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final GroupFlowlet groupView = getFlow().forward(GroupFlowlet.class);
            groupView.edit(group, true);
        }
    });

    final Button editButton = getSite().getButton("edit");
    buttonLayout.addComponent(editButton);
    editButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Group entity = container.getEntity(grid.getSelectedItemId());
            final GroupFlowlet groupView = getFlow().forward(GroupFlowlet.class);
            groupView.edit(entity, false);
        }
    });

    final Button removeButton = getSite().getButton("remove");
    buttonLayout.addComponent(removeButton);
    removeButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Group entity = container.getEntity(grid.getSelectedItemId());
            final List<User> users = UserDao.getGroupMembers(entityManager,
                    (Company) getSite().getSiteContext().getObject(Company.class), entity);

            for (final User user : users) {
                UserDao.removeGroupMember(entityManager, entity, user);
            }

            final List<Privilege> privileges = UserDao.getGroupPrivileges(entityManager, entity);
            for (final Privilege privilege : privileges) {
                UserDao.removeGroupPrivilege(entityManager, entity, privilege.getKey(), privilege.getDataId());
            }

            container.removeItem(grid.getSelectedItemId());
            container.commit();
        }
    });

    final Company company = getSite().getSiteContext().getObject(Company.class);
    container.removeDefaultFilters();
    container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId()));
    grid.refresh();
}

From source file:org.vaadin.addons.sitekit.viewlet.administrator.user.UsersFlowlet.java

License:Apache License

@Override
public void initialize() {
    final List<FieldDescriptor> fieldDescriptors = SiteFields.getFieldDescriptors(User.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    container = new EntityContainer<User>(entityManager, true, false, false, User.class, 1000,
            new String[] { "lastName", "firstName" }, new boolean[] { true, true }, "userId");

    ContainerUtil.addContainerProperties(container, fieldDescriptors);

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();/*from w ww .j a va 2 s  .  c om*/
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setSizeUndefined();
    gridLayout.addComponent(buttonLayout, 0, 0);

    final Table table = new FormattingTable();
    grid = new Grid(table, container);
    grid.setFields(fieldDescriptors);
    grid.setFilters(filterDefinitions);

    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    table.setColumnCollapsed("passwordHash", true);
    table.setColumnCollapsed("openIdIdentifier", true);
    gridLayout.addComponent(grid, 0, 1);

    final Button addButton = getSite().getButton("add");
    buttonLayout.addComponent(addButton);
    addButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final User user = new User();
            user.setCreated(new Date());
            user.setModified(user.getCreated());
            user.setOwner((Company) getSite().getSiteContext().getObject(Company.class));

            final UserFlowlet userView = getFlow().getFlowlet(UserFlowlet.class);
            userView.edit(user, true);
            getFlow().forward(UserFlowlet.class);
        }
    });

    final Button editButton = getSite().getButton("edit");
    buttonLayout.addComponent(editButton);
    editButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final User entity = container.getEntity(grid.getSelectedItemId());
            final UserFlowlet userView = getFlow().getFlowlet(UserFlowlet.class);
            userView.edit(entity, false);
            getFlow().forward(UserFlowlet.class);
        }
    });

    final Button removeButton = getSite().getButton("remove");
    buttonLayout.addComponent(removeButton);
    removeButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final User entity = container.getEntity(grid.getSelectedItemId());

            final List<Group> groups = UserDao.getUserGroups(entityManager,
                    (Company) getSite().getSiteContext().getObject(Company.class), entity);

            for (final Group group : groups) {
                UserDao.removeGroupMember(entityManager, group, entity);
            }

            final List<Privilege> privileges = UserDao.getUserPrivileges(entityManager, entity);
            for (final Privilege privilege : privileges) {
                UserDao.removeUserPrivilege(entityManager, entity, privilege.getKey(), privilege.getDataId());
            }

            container.removeItem(grid.getSelectedItemId());
            container.commit();
        }
    });

    final Button lockButton = getSite().getButton("lock");
    lockButton.setImmediate(true);
    buttonLayout.addComponent(lockButton);
    lockButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final User user = container.getEntity(grid.getSelectedItemId());
            user.setLockedOut(true);
            UserDao.updateUser(entityManager, entityManager.merge(user));
            container.refresh();
        }
    });

    final Button unlockButton = getSite().getButton("unlock");
    unlockButton.setImmediate(true);
    buttonLayout.addComponent(unlockButton);
    unlockButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final User user = container.getEntity(grid.getSelectedItemId());
            user.setLockedOut(false);
            user.setFailedLoginCount(0);
            UserDao.updateUser(entityManager, entityManager.merge(user));
            container.refresh();
        }
    });

    final Company company = getSite().getSiteContext().getObject(Company.class);
    container.removeDefaultFilters();
    container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId()));
    grid.refresh();
}

From source file:org.vaadin.peholmst.samples.dddwebinar.ui.admin.LicenseTypeMapField.java

License:Open Source License

@Override
protected Component initContent() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeUndefined();
    layout.setSpacing(true);/*w  ww. ja va2s  . c  o m*/

    selectable = new Grid(selectableContainer);
    selectable.setWidth("300px");
    selectable.setHeight("200px");

    layout.addComponent(selectable);

    VerticalLayout buttons = new VerticalLayout();
    buttons.setSpacing(true);

    add = new Button("Add", this::add);

    buttons.addComponent(add);

    remove = new Button("Remove", this::remove);
    buttons.addComponent(remove);

    layout.addComponent(buttons);

    selected = new Grid(selectedContainer);
    selected.setWidth("330px");
    selected.setHeight("200px");
    selected.getColumn("name").setEditable(false);
    selected.setEditorEnabled(true);
    selected.setEditorBuffered(false);
    layout.addComponent(selected);

    return layout;
}

From source file:rs.pupin.jpo.esta_ld.EndpointWindow.java

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

    // add endpoint field
    Label lbl = new Label("Endpoint:");
    lbl.setSizeUndefined();/*from ww w .j  a va2 s .  c  om*/
    settingsLayout.addComponent(lbl, 0, 0, 0, 0);
    settingsLayout.setComponentAlignment(lbl, Alignment.MIDDLE_LEFT);
    endpointInput = new TextField();
    endpointInput.setValue(state.endpoint);
    endpointInput.setWidth("100%");
    settingsLayout.addComponent(endpointInput, 1, 0, 1, 0);
    settingsLayout.setComponentAlignment(endpointInput, Alignment.MIDDLE_RIGHT);

    // add blank row
    lbl = new Label("");
    lbl.setHeight("30px");
    settingsLayout.addComponent(lbl, 0, 1, 1, 1);

    // add buttons
    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    hl.setSizeUndefined();
    btnOK = new Button("OK");
    btnCancel = new Button("Cancel");
    hl.addComponent(btnOK);
    hl.addComponent(btnCancel);
    settingsLayout.addComponent(hl, 1, 2);
    settingsLayout.setComponentAlignment(hl, Alignment.MIDDLE_RIGHT);

    createListeners();
    center();
}

From source file:rs.pupin.jpo.validation.gui.ValidationSettingsWindow.java

@Override
public void attach() {
    // add endpoint field
    Label lbl = new Label("Endpoint:");
    lbl.setSizeUndefined();/*from  www . jav  a2 s  . c  om*/
    settingsLayout.addComponent(lbl, 0, 0, 0, 0);
    settingsLayout.setComponentAlignment(lbl, Alignment.MIDDLE_LEFT);
    endpointInput = new TextField();
    endpointInput.setValue(state.endpoint);
    endpointInput.setWidth("100%");
    settingsLayout.addComponent(endpointInput, 1, 0, 1, 0);

    // add graph field
    lbl = new Label("Graph:");
    lbl.setSizeUndefined();
    settingsLayout.addComponent(lbl, 0, 1, 0, 1);
    settingsLayout.setComponentAlignment(lbl, Alignment.MIDDLE_LEFT);
    graphInput = new TextField();
    graphInput.setValue(state.graph);
    graphInput.setWidth("100%");
    settingsLayout.addComponent(graphInput, 1, 1, 1, 1);

    lbl = new Label("");
    lbl.setHeight("30px");
    settingsLayout.addComponent(lbl, 0, 2, 1, 2);

    // add basic authentication check box
    authCheckBox = new CheckBox("Use basic authentication");
    authCheckBox.setSizeUndefined();
    settingsLayout.addComponent(authCheckBox, 0, 3, 1, 3);
    settingsLayout.setComponentAlignment(authCheckBox, Alignment.MIDDLE_LEFT);

    // add username field
    lbl = new Label("Username:");
    lbl.setSizeUndefined();
    settingsLayout.addComponent(lbl, 0, 4);
    settingsLayout.setComponentAlignment(lbl, Alignment.MIDDLE_LEFT);
    usernameInput = new TextField();
    usernameInput.setWidth("100%");
    usernameInput.setEnabled(false);
    settingsLayout.addComponent(usernameInput, 1, 4);
    settingsLayout.setComponentAlignment(usernameInput, Alignment.MIDDLE_LEFT);

    // add password field
    lbl = new Label("Password:");
    lbl.setSizeUndefined();
    settingsLayout.addComponent(lbl, 0, 5);
    settingsLayout.setComponentAlignment(lbl, Alignment.MIDDLE_LEFT);
    passwordInput = new PasswordField();
    passwordInput.setWidth("100%");
    passwordInput.setEnabled(false);
    settingsLayout.addComponent(passwordInput, 1, 5);

    lbl = new Label("");
    lbl.setHeight("30px");
    settingsLayout.addComponent(lbl, 0, 6, 1, 6);

    // add OntoWiki check box
    owCheckBox = new CheckBox("Use OntoWiki instance");
    owCheckBox.setSizeUndefined();
    if (state.owUrl != null)
        owCheckBox.setValue(true);
    else
        owCheckBox.setValue(false);
    settingsLayout.addComponent(owCheckBox, 0, 7, 1, 7);
    settingsLayout.setComponentAlignment(owCheckBox, Alignment.MIDDLE_LEFT);

    // add OntoWiki field
    lbl = new Label("OntoWiki URL:");
    lbl.setSizeUndefined();
    settingsLayout.addComponent(lbl, 0, 8);
    settingsLayout.setComponentAlignment(lbl, Alignment.MIDDLE_LEFT);
    owInput = new TextField();
    owInput.setWidth("100%");
    if (state.owUrl != null) {
        owInput.setEnabled(true);
        owInput.setValue(state.owUrl);
    } else
        owInput.setEnabled(false);
    settingsLayout.addComponent(owInput, 1, 8);
    settingsLayout.setComponentAlignment(owInput, Alignment.MIDDLE_LEFT);

    lbl = new Label("");
    lbl.setHeight("30px");
    settingsLayout.addComponent(lbl, 0, 9, 1, 9);

    // add buttons
    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    hl.setSizeUndefined();
    btnOK = new Button("OK");
    btnCancel = new Button("Cancel");
    hl.addComponent(btnOK);
    hl.addComponent(btnCancel);
    settingsLayout.addComponent(hl, 1, 10);
    settingsLayout.setComponentAlignment(hl, Alignment.MIDDLE_RIGHT);

    createListeners();
    center();
}

From source file:ru.codeinside.adm.ui.employee.CertificateBlock.java

License:Mozilla Public License

public CertificateBlock(UserItem userItem) {
    this.x509 = userItem.getX509();
    Component root = new HorizontalLayout();
    if (x509 != null) {
        X509Certificate x509Certificate = X509.decode(x509);
        if (x509Certificate != null) {
            HorizontalLayout h = new HorizontalLayout();
            h.setSpacing(true);/*w  ww.  ja v a 2s .c o  m*/
            h.setMargin(true);
            h.setSizeUndefined();

            NameParts subjectParts = X509.getSubjectParts(x509Certificate);

            Label certLabel = new Label(subjectParts.getShortName());
            h.addComponent(certLabel);
            h.setComponentAlignment(certLabel, Alignment.MIDDLE_CENTER);

            Button remove = new Button("? ?  ?");
            remove.setStyleName(Reindeer.BUTTON_SMALL);
            h.addComponent(remove);
            h.setComponentAlignment(remove, Alignment.MIDDLE_CENTER);

            remove.addListener((Button.ClickListener) new CertificateCleaner(remove, certLabel));

            Panel panel = new Panel();
            panel.setCaption("? ?:");
            panel.setContent(h);
            panel.setSizeUndefined();
            root = panel;
        } else {
            certificateWasRemoved = true;
        }
    }
    setCompositionRoot(root);
    setSizeUndefined();
}

From source file:xyz.iipster.ui.ChangePasswordComponent.java

License:Apache License

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

    setModal(true);/*from  ww  w  . j  a v a 2  s  .co m*/
    setClosable(false);
    setResizable(false);

    setCaption(i18N.get("iipster.changePassword.title"));

    oldPasswordField.setCaption(i18N.get("iipster.changePassword.oldPassword.label"));
    newPasswordField1.setCaption(i18N.get("iipster.changePassword.newPassword1.label"));
    newPasswordField2.setCaption(i18N.get("iipster.changePassword.newPassword2.label"));

    VerticalLayout vl = new VerticalLayout();
    vl.setSizeUndefined();
    vl.setMargin(true);

    if (currentPassword != null) {
        // currentPassowrd is not null, that means we are on login screen and the password is expired
        Label expiredLabel = new Label(i18N.get("iipster.changePassword.expired.text"));
        vl.addComponent(expiredLabel);
    }

    FormLayout fl = new FormLayout();
    fl.setSizeUndefined();
    fl.addComponents(oldPasswordField, newPasswordField1, newPasswordField2);
    vl.addComponent(fl);
    vl.setExpandRatio(fl, 1F);

    okButton.setCaption(i18N.get("iipster.ok"));
    okButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    okButton.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    okButton.addClickListener(e -> {
        try {
            ibmiService.changePassword(
                    securityUtils.getAuthentication() == null ? userName
                            : securityUtils.getAuthentication().getPrincipal().toString(),
                    oldPasswordField.getValue(), newPasswordField1.getValue());
            close();
            eventBus.post(new PasswordChangedEvent(newPasswordField1.getValue()));
        } catch (BadCredentialsException e1) {
            Notification.show(i18N.get("iipster.changePassword.oldPassword.error"),
                    Notification.Type.WARNING_MESSAGE);
            oldPasswordField.focus();
        } catch (IOException e1) {
            Notification.show("Error while changing password", Notification.Type.ERROR_MESSAGE);
        } catch (NewPasswordInvalidException e1) {
            Notification.show(i18N.get(e1.getMessageId()), Notification.Type.WARNING_MESSAGE);
            newPasswordField1.focus();
        }
    });

    cancelButton.setCaption(i18N.get("iipster.cancel"));
    cancelButton.setClickShortcut(ShortcutAction.KeyCode.F12);
    cancelButton.addClickListener(e -> {
        close();
    });

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSizeUndefined();
    hl.setSpacing(true);
    hl.addComponents(okButton, cancelButton);

    vl.addComponent(hl);
    vl.setComponentAlignment(hl, Alignment.MIDDLE_CENTER);

    setContent(vl);

    if (currentPassword == null) {
        // currentPassword is null so we are not forced to change password during login
        oldPasswordField.setValue("");
        oldPasswordField.setEnabled(true);

        oldPasswordField.focus();
    } else {
        oldPasswordField.setValue(currentPassword);
        oldPasswordField.setEnabled(false);

        newPasswordField1.focus();
    }

    newPasswordField1.setValue("");
    newPasswordField2.setValue("");
}

From source file:xyz.iipster.ui.DefaultIbmiLoginComponent.java

License:Apache License

@Override
public void attach() {
    super.attach();
    final FormLayout fl = new FormLayout();
    fl.setSizeUndefined();// w w w  .j  a  va2s .  co  m

    userNameTF.setCaption(i18N.get("iipster.login.username.label"));
    //        userNameTF.setRequired(true);
    userNameTF.addStyleName("upper-case");
    userNameTF.setMaxLength(10);
    passwordPF.setCaption(i18N.get("iipster.login.password.label"));
    //        passwordPF.setRequired(true);

    fl.addComponent(userNameTF);
    fl.addComponent(passwordPF);

    final VerticalLayout vl = new VerticalLayout();
    vl.setSizeUndefined();
    vl.addComponent(fl);
    vl.setExpandRatio(fl, 1F);
    vl.setComponentAlignment(fl, Alignment.MIDDLE_CENTER);

    final HorizontalLayout hl = new HorizontalLayout();
    hl.setSizeUndefined();

    loginButton.setCaption(i18N.get("iipster.login.loginButton.label"));
    loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    loginButton.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    loginButton.addClickListener(event -> {
        if (userNameTF.isEmpty()) {
            Notification.show(i18N.get("iipster.login.username.missing"), Notification.Type.WARNING_MESSAGE);
            userNameTF.focus();
            return;
        }
        if (passwordPF.isEmpty()) {
            Notification.show(i18N.get("iipster.login.password.missing"), Notification.Type.WARNING_MESSAGE);
            passwordPF.focus();
            return;
        }

        try {
            Authentication auth = securityUtils.login(userNameTF.getValue(), passwordPF.getValue());
            eventBus.post(new LoginEvent(auth.getPrincipal().toString()));
        } catch (BadCredentialsException e) {
            Notification.show(i18N.get("iipster.login.bad.credential"), Notification.Type.WARNING_MESSAGE);
        } catch (DisabledException e) {
            Notification.show(i18N.get("iipster.login.disabled"), Notification.Type.WARNING_MESSAGE);
        } catch (CredentialsExpiredException e) {
            changePasswordComponent.setUserName(userNameTF.getValue());
            changePasswordComponent.setCurrentPassword(passwordPF.getValue());
            UI.getCurrent().addWindow(changePasswordComponent);
        } catch (Exception e) {
            Notification.show(i18N.get("iipster.login.error"), Notification.Type.WARNING_MESSAGE);
        }
    });
    hl.addComponent(loginButton);
    vl.addComponent(hl);
    vl.setComponentAlignment(hl, Alignment.MIDDLE_CENTER);
    vl.setSizeUndefined();

    vl.setMargin(true);
    final Panel panel = new Panel(i18N.get("iipster.login.panel.title"), vl);
    panel.setSizeUndefined();

    rootLayout.addComponent(panel);
    rootLayout.setSizeFull();
    rootLayout.setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
    setCompositionRoot(rootLayout);
    setSizeFull();
}