Example usage for com.vaadin.ui GridLayout setSpacing

List of usage examples for com.vaadin.ui GridLayout setSpacing

Introduction

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

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

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  www .j a va2  s .co  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);
    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.addons.sitekit.viewlet.user.AccountFlowlet.java

License:Apache License

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

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();
    filterDefinitions.add(new FilterDescriptor("companyName", "companyName", "Company Name", new TextField(),
            101, "=", String.class, ""));
    filterDefinitions.add(new FilterDescriptor("lastName", "lastName", "Last Name", new TextField(), 101, "=",
            String.class, ""));

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    entityContainer = new EntityContainer<Customer>(entityManager, true, false, false, Customer.class, 1000,
            new String[] { "companyName", "lastName" }, new boolean[] { false, false }, "customerId");

    for (final FieldDescriptor fieldDefinition : fieldDefinitions) {
        entityContainer.addContainerProperty(fieldDefinition.getId(), fieldDefinition.getValueType(),
                fieldDefinition.getDefaultValue(), fieldDefinition.isReadOnly(), fieldDefinition.isSortable());
    }/*from   w  w w  . j a v  a 2  s . c  om*/

    final GridLayout gridLayout = new GridLayout(1, 6);
    gridLayout.setRowExpandRatio(0, 0.0f);
    gridLayout.setRowExpandRatio(1, 0.0f);
    gridLayout.setRowExpandRatio(2, 0.0f);
    gridLayout.setRowExpandRatio(3, 0.0f);
    gridLayout.setRowExpandRatio(4, 0.0f);
    gridLayout.setRowExpandRatio(5, 1.0f);

    gridLayout.setSizeFull();
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(4, 1f);
    setViewContent(gridLayout);

    final HorizontalLayout userAccountTitle = new HorizontalLayout();
    userAccountTitle.setMargin(new MarginInfo(false, false, false, false));
    userAccountTitle.setSpacing(true);
    final Embedded userAccountTitleIcon = new Embedded(null, getSite().getIcon("view-icon-user"));
    userAccountTitleIcon.setWidth(32, UNITS_PIXELS);
    userAccountTitleIcon.setHeight(32, UNITS_PIXELS);
    userAccountTitle.addComponent(userAccountTitleIcon);
    final Label userAccountTitleLabel = new Label("<h2>User Account</h2>", Label.CONTENT_XHTML);
    userAccountTitle.addComponent(userAccountTitleLabel);
    gridLayout.addComponent(userAccountTitle, 0, 0);

    final HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setMargin(new MarginInfo(true, false, false, false));
    titleLayout.setSpacing(true);
    final Embedded titleIcon = new Embedded(null, getSite().getIcon("view-icon-customer"));
    titleIcon.setWidth(32, UNITS_PIXELS);
    titleIcon.setHeight(32, UNITS_PIXELS);
    titleLayout.addComponent(titleIcon);
    final Label titleLabel = new Label("<h2>Customer Accounts</h2>", Label.CONTENT_XHTML);
    titleLayout.addComponent(titleLabel);
    gridLayout.addComponent(titleLayout, 0, 3);

    final Table table = new Table();
    table.setPageLength(10);
    entityGrid = new Grid(table, entityContainer);
    entityGrid.setFields(fieldDefinitions);
    entityGrid.setFilters(filterDefinitions);
    //entityGrid.setFixedWhereCriteria("e.owner.companyId=:companyId");

    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    table.setColumnCollapsed("company", true);
    gridLayout.addComponent(entityGrid, 0, 5);

    final Button editUserButton = new Button("Edit User Account");
    editUserButton.setIcon(getSite().getIcon("button-icon-edit"));
    gridLayout.addComponent(editUserButton, 0, 2);
    editUserButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final User entity = ((SecurityProviderSessionImpl) getSite().getSecurityProvider())
                    .getUserFromSession();
            final UserAccountFlowlet customerView = getFlow().getFlowlet(UserAccountFlowlet.class);
            customerView.edit(entity, false);
            getFlow().forward(UserAccountFlowlet.class);
        }
    });

    final Company company = getSite().getSiteContext().getObject(Company.class);
    if (company.isOpenIdLogin()) {
        final Panel openIdPanel = new Panel();
        openIdPanel.setStyleName(Reindeer.PANEL_LIGHT);
        openIdPanel.setCaption("Choose OpenID Provider:");
        gridLayout.addComponent(openIdPanel, 0, 1);
        final HorizontalLayout openIdLayout = new HorizontalLayout();
        openIdPanel.setContent(openIdLayout);
        openIdLayout.setMargin(new MarginInfo(false, false, true, false));
        openIdLayout.setSpacing(true);
        final String returnViewName = "openidlink";
        final Map<String, String> urlIconMap = OpenIdUtil.getOpenIdProviderUrlIconMap();
        for (final String url : urlIconMap.keySet()) {
            openIdLayout.addComponent(OpenIdUtil.getLoginButton(url, urlIconMap.get(url), returnViewName));
        }
    }

    final HorizontalLayout customerButtonsLayout = new HorizontalLayout();
    gridLayout.addComponent(customerButtonsLayout, 0, 4);
    customerButtonsLayout.setMargin(false);
    customerButtonsLayout.setSpacing(true);

    final Button editCustomerDetailsButton = new Button("Edit Customer Details");
    customerButtonsLayout.addComponent(editCustomerDetailsButton);
    editCustomerDetailsButton.setEnabled(false);
    editCustomerDetailsButton.setIcon(getSite().getIcon("button-icon-edit"));
    editCustomerDetailsButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final CustomerFlowlet customerView = getFlow().forward(CustomerFlowlet.class);
            customerView.edit(entity, false);
        }
    });

    final Button editCustomerMembersButton = new Button("Edit Customer Members");
    customerButtonsLayout.addComponent(editCustomerMembersButton);
    editCustomerMembersButton.setEnabled(false);
    editCustomerMembersButton.setIcon(getSite().getIcon("button-icon-edit"));
    editCustomerMembersButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final GroupFlowlet view = getFlow().forward(GroupFlowlet.class);
            view.edit(entity.getMemberGroup(), false);
        }
    });

    final Button editCustomerAdminsButton = new Button("Edit Customer Admins");
    customerButtonsLayout.addComponent(editCustomerAdminsButton);
    editCustomerAdminsButton.setEnabled(false);
    editCustomerAdminsButton.setIcon(getSite().getIcon("button-icon-edit"));
    editCustomerAdminsButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final GroupFlowlet view = getFlow().forward(GroupFlowlet.class);
            view.edit(entity.getAdminGroup(), false);
        }
    });

    table.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(final Property.ValueChangeEvent event) {
            editCustomerDetailsButton.setEnabled(table.getValue() != null);
            editCustomerMembersButton.setEnabled(table.getValue() != null);
            editCustomerAdminsButton.setEnabled(table.getValue() != null);
        }
    });

}

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

License:Apache License

@Override
public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout layout = new GridLayout(1, 3);
    layout.setSizeFull();/*from   w  w  w  .  j  a v  a 2 s  .  c  o m*/
    layout.setMargin(false);
    layout.setSpacing(true);
    layout.setRowExpandRatio(1, 1f);
    layout.setColumnExpandRatio(1, 1f);
    setViewContent(layout);

    editor = new ValidatingEditor(SiteFields.getFieldDescriptors(User.class));
    editor.setCaption("User");
    editor.addListener((ValidatingEditorStateListener) this);
    editor.setWidth("380px");
    layout.addComponent(editor, 0, 1);

    final HorizontalLayout editorButtonLayout = new HorizontalLayout();
    editorButtonLayout.setSpacing(true);
    layout.addComponent(editorButtonLayout, 0, 2);

    saveButton = new Button("Save");
    saveButton.setImmediate(true);
    editorButtonLayout.addComponent(saveButton);
    saveButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            editor.commit();
            entityManager.getTransaction().begin();
            try {

                if (user.getPasswordHash() != null) {
                    final int hashSize = 64;
                    if (user.getPasswordHash().length() != hashSize) {
                        final byte[] passwordAndSaltBytes = (user.getEmailAddress() + ":"
                                + user.getPasswordHash()).getBytes(Charset.forName("UTF-8"));
                        try {
                            final MessageDigest md = MessageDigest.getInstance("SHA-256");
                            final byte[] passwordAndSaltDigest = md.digest(passwordAndSaltBytes);
                            user.setPasswordHash(StringUtil.toHexString(passwordAndSaltDigest));
                        } catch (NoSuchAlgorithmException e) {
                            e.printStackTrace();
                        }
                    }
                }
                // UserLogic.updateUser(user,
                // UserDao.getGroupMembers(entityManager, user));
                user = entityManager.merge(user);
                entityManager.persist(user);
                entityManager.getTransaction().commit();
                editor.setItem(new BeanItem<User>(user), false);
                entityManager.detach(user);
            } catch (final Throwable t) {
                if (entityManager.getTransaction().isActive()) {
                    entityManager.getTransaction().rollback();
                }
                throw new RuntimeException("Failed to save entity: " + user, t);
            }
        }
    });

    discardButton = new Button("Discard");
    discardButton.setImmediate(true);
    editorButtonLayout.addComponent(discardButton);
    discardButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            editor.discard();
        }
    });

}

From source file:org.vaadin.johannesh.jfokus2012.touchkit.view.ShowContactView.java

License:Open Source License

private void buildLayout() {
    layout = new CssLayout();
    layout.addStyleName("show-contact-view");
    layout.setWidth("100%");

    VerticalComponentGroup infoGroup = new VerticalComponentGroup("");
    infoGroup.setWidth("100%");

    Component label;/*  ww w .j  a  v  a2  s.  c o  m*/
    Property p;

    p = item.getItemProperty(ContactUtils.PROPERTY_COMPANY);
    label = new Label(new ContactUtils.CompanyPropertyFormatter(p));
    label.setCaption(ContactUtils.formatFieldCaption(ContactUtils.PROPERTY_COMPANY));
    infoGroup.addComponent(label);

    p = item.getItemProperty(ContactUtils.PROPERTY_MOBILE);
    label = new Label(p);
    label.setCaption(ContactUtils.formatFieldCaption(ContactUtils.PROPERTY_MOBILE));
    infoGroup.addComponent(label);

    p = item.getItemProperty(ContactUtils.PROPERTY_EMAIL);
    label = new Label(p);
    label.setCaption(ContactUtils.formatFieldCaption(ContactUtils.PROPERTY_EMAIL));
    infoGroup.addComponent(label);

    Embedded picture = new Embedded("", new ThemeResource("icon/picture.png"));
    picture.setWidth("57px");
    picture.setHeight("57px");

    Label firstName = new Label(item.getItemProperty(ContactUtils.PROPERTY_FIRST_NAME));
    firstName.addStyleName("strong-name");

    Label lastName = new Label(item.getItemProperty(ContactUtils.PROPERTY_LAST_NAME));
    lastName.addStyleName("strong-name");

    GridLayout nameLayout = new GridLayout(2, 2);
    nameLayout.setWidth("100%");
    nameLayout.setSpacing(true);
    nameLayout.setMargin(true, true, false, true);
    nameLayout.setColumnExpandRatio(1, 1.0f);
    nameLayout.addComponent(picture, 0, 0, 0, 1);
    nameLayout.addComponent(firstName, 1, 0);
    nameLayout.addComponent(lastName, 1, 1);
    nameLayout.setComponentAlignment(firstName, Alignment.MIDDLE_LEFT);
    nameLayout.setComponentAlignment(lastName, Alignment.MIDDLE_LEFT);

    final Favourite favourite = new Favourite();
    favourite.setImmediate(true);
    favourite.setReadOnly(true);
    favourite.setIcon(new ThemeResource("icon/favourite.png"));
    favourite.setPropertyDataSource(item.getItemProperty(ContactUtils.PROPERTY_FAVOURITE));

    layout.addComponent(nameLayout);
    layout.addComponent(favourite);
    layout.addComponent(infoGroup);

    Button editButton = new Button("Edit");
    editButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            getNavigationManager().navigateTo(new EditContactView(item));
        }
    });
    setRightComponent(editButton);
    setContent(layout);
}

From source file:org.vaadin.spinkit.demo.DemoUI.java

License:Apache License

private Component spinnersContainer(String primaryStyleName) {
    int types = SpinnerType.values().length;
    GridLayout spinners = new GridLayout(4, (types / 4 + types % 4));
    spinners.setSizeFull();/*from   w ww. ja v  a 2  s  .c o  m*/
    spinners.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    spinners.setSpacing(true);
    spinners.setWidth(100, Unit.PERCENTAGE);
    StringToEnumConverter converter = new StringToEnumConverter();
    for (SpinnerType type : SpinnerType.values()) {
        Spinner spinner = new Spinner(type);
        spinner.setCaption(converter.convertToPresentation(type, String.class, getLocale()));
        if (primaryStyleName != null) {
            spinner.setPrimaryStyleName(primaryStyleName);
        }
        spinners.addComponent(spinner);
    }
    return spinners;
}

From source file:org.vaadin.spinkit.demo.DemoUI.java

License:Apache License

private Component spinnerSizesContainer() {
    int types = SpinnerSize.values().length;
    GridLayout spinners = new GridLayout(4, (types / 4 + types % 4));
    spinners.setSizeFull();//ww w . jav  a 2  s.  c om
    spinners.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    spinners.setSpacing(true);

    ComboBox selector = new ComboBox("Select spinner type", Arrays.asList(SpinnerType.values()));
    selector.setNullSelectionAllowed(false);
    selector.setPageLength(0);
    selector.setValue(SpinnerType.ROTATING_PLANE);
    selector.addValueChangeListener(e -> {
        for (Component c : spinners) {
            if (c instanceof Spinner) {
                ((Spinner) c).setType((SpinnerType) selector.getValue());
            }
        }
    });

    StringToEnumConverter converter = new StringToEnumConverter();
    for (SpinnerSize size : SpinnerSize.values()) {
        Spinner spinner = new Spinner(SpinnerType.ROTATING_PLANE);
        spinner.setSize(size);
        spinner.setCaption(converter.convertToPresentation(size, String.class, getLocale()));
        spinners.addComponent(spinner);
    }

    VerticalLayout l = new VerticalLayout();
    l.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    l.setSizeFull();
    l.setMargin(false);
    l.setSpacing(true);
    l.addComponents(selector, spinners);
    l.setExpandRatio(spinners, 1);
    return l;
}

From source file:probe.com.view.body.QuantCompareDataLayout.java

private VerticalLayout initProteinsDataCapture(int width) {
    VerticalLayout proteinsDataCapturingMainLayout = new VerticalLayout();
    proteinsDataCapturingMainLayout.setSpacing(true);
    proteinsDataCapturingMainLayout.setMargin(true);
    String containerWidth = ((width * 2) + 10) + "px";
    proteinsDataCapturingMainLayout.setWidth(containerWidth);
    proteinsDataCapturingMainLayout.setSpacing(true);

    Label titleLabel = new Label("2. Insert UniProt Proteins Accessions");
    titleLabel.setContentMode(ContentMode.HTML);
    titleLabel.setStyleName("normalheader");
    titleLabel.setHeight("20px");
    proteinsDataCapturingMainLayout.addComponent(titleLabel);
    proteinsDataCapturingMainLayout.setComponentAlignment(titleLabel, Alignment.TOP_LEFT);

    GridLayout insertProteinsLayout = new GridLayout(3, 3);
    proteinsDataCapturingMainLayout.addComponent(insertProteinsLayout);
    insertProteinsLayout.setSpacing(true);
    insertProteinsLayout.setMargin(new MarginInfo(false, false, false, false));
    insertProteinsLayout.setWidth(containerWidth);

    HorizontalLayout hlo1 = new HorizontalLayout();
    hlo1.setWidth("100%");
    hlo1.setMargin(new MarginInfo(false, true, false, false));
    Label highLabel = new Label("<font color='#cc0000'>&nbsp;High</font>");
    highLabel.setWidth("40px");
    highLabel.setContentMode(ContentMode.HTML);
    hlo1.addComponent(highLabel);/* ww w. ja v  a  2  s .  c  o  m*/

    HorizontalLayout hlo2 = new HorizontalLayout();
    hlo2.setWidth("100%");
    hlo2.setMargin(new MarginInfo(false, true, false, false));
    Label stableLabel = new Label("<font color='#018df4'>&nbsp;Stable</font>");
    stableLabel.setWidth("50px");
    stableLabel.setContentMode(ContentMode.HTML);
    hlo2.addComponent(stableLabel);

    HorizontalLayout hlo3 = new HorizontalLayout();
    hlo3.setWidth("100%");
    hlo3.setMargin(new MarginInfo(false, true, false, false));
    Label lowLabel = new Label("<font color='#009900'>&nbsp;Low</font>");
    lowLabel.setWidth("40px");
    lowLabel.setContentMode(ContentMode.HTML);
    hlo3.addComponent(lowLabel);
    insertProteinsLayout.addComponent(hlo1, 0, 0);
    insertProteinsLayout.setComponentAlignment(hlo1, Alignment.MIDDLE_CENTER);
    insertProteinsLayout.addComponent(hlo2, 1, 0);
    insertProteinsLayout.setComponentAlignment(hlo2, Alignment.MIDDLE_CENTER);
    insertProteinsLayout.addComponent(hlo3, 2, 0);
    insertProteinsLayout.setComponentAlignment(hlo3, Alignment.MIDDLE_CENTER);

    highTextArea.setWidth("100%");
    highTextArea.setHeight("200px");
    insertProteinsLayout.addComponent(highTextArea, 0, 1);
    insertProteinsLayout.setComponentAlignment(highTextArea, Alignment.MIDDLE_CENTER);

    stableTextArea.setWidth("100%");
    stableTextArea.setHeight("200px");
    insertProteinsLayout.addComponent(stableTextArea, 1, 1);
    insertProteinsLayout.setComponentAlignment(stableTextArea, Alignment.MIDDLE_CENTER);

    lowTextArea.setWidth("100%");
    lowTextArea.setHeight("200px");
    insertProteinsLayout.addComponent(lowTextArea, 2, 1);
    insertProteinsLayout.setComponentAlignment(lowTextArea, Alignment.MIDDLE_CENTER);

    VerticalLayout clear1 = new VerticalLayout();
    hlo1.addComponent(clear1);
    clear1.setDescription("Clear field");
    clear1.setStyleName("clearfieldbtn");
    clear1.setWidth("20px");
    clear1.setHeight("20px");
    //        insertProteinsLayout.addComponent(clear1, 0, 2);
    hlo1.setComponentAlignment(clear1, Alignment.MIDDLE_RIGHT);
    clear1.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            highTextArea.clear();
        }
    });

    VerticalLayout clear2 = new VerticalLayout();
    hlo2.addComponent(clear2);
    clear2.setDescription("Clear field");
    clear2.setStyleName("clearfieldbtn");
    clear2.setWidth("20px");
    clear2.setHeight("20px");

    clear2.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            stableTextArea.clear();
        }
    });

    hlo2.setComponentAlignment(clear2, Alignment.MIDDLE_RIGHT);
    VerticalLayout clear3 = new VerticalLayout();
    hlo3.addComponent(clear3);
    clear3.setDescription("Clear field");
    clear3.setStyleName("clearfieldbtn");
    clear3.setWidth("20px");
    clear3.setHeight("20px");

    clear3.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            lowTextArea.clear();
        }
    });
    hlo3.setComponentAlignment(clear3, Alignment.MIDDLE_RIGHT);
    Label errorLabel = new Label();
    proteinsDataCapturingMainLayout.addComponent(errorLabel);
    HorizontalLayout btnsLayout = new HorizontalLayout();
    btnsLayout.setSpacing(true);
    btnsLayout.setMargin(new MarginInfo(true, false, false, false));

    proteinsDataCapturingMainLayout.addComponent(btnsLayout);
    proteinsDataCapturingMainLayout.setComponentAlignment(btnsLayout, Alignment.MIDDLE_RIGHT);

    Button sampleBtn = new Button("Sample");
    sampleBtn.setStyleName(Reindeer.BUTTON_SMALL);
    btnsLayout.addComponent(sampleBtn);
    sampleBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            reset();
            highTextArea.setValue(highAcc);
            lowTextArea.setValue(lowAcc);
            stableTextArea.setValue(stableAcc);
            diseaseGroupsListA.select("Group A");
            diseaseGroupsListB.select("Group B");
            compareBtn.focus();
        }
    });

    Button resetBtn = new Button("Reset");
    resetBtn.setStyleName(Reindeer.BUTTON_SMALL);
    btnsLayout.addComponent(resetBtn);
    resetBtn.setId("resetBtn");
    resetBtn.addClickListener(this);

    compareBtn = new Button("Compare");
    compareBtn.setStyleName(Reindeer.BUTTON_SMALL);
    btnsLayout.addComponent(compareBtn);
    compareBtn.setId("compareBtn");
    compareBtn.addClickListener(this);

    //        highTextArea.setValue(highAcc);
    //        lowTextArea.setValue(lowAcc);
    //        stableTextArea.setValue(stableAcc);

    return proteinsDataCapturingMainLayout;
}

From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.PopupRecombineDiseaseGroups.java

private void initPopupLayout() {

    int h = 0;//(default_DiseaseCat_DiseaseGroupMap.size() * 33) + 300;
    for (Map<String, String> m : default_DiseaseCat_DiseaseGroupMap.values()) {
        if (h < m.size()) {
            h = m.size();/*from  w  w  w  .j av  a 2s.c  om*/
        }
    }
    h = (h * 26) + 200;
    int w = 700;
    if (Page.getCurrent().getBrowserWindowHeight() - 280 < h) {
        h = Page.getCurrent().getBrowserWindowHeight() - 280;
    }
    if (Page.getCurrent().getBrowserWindowWidth() < w) {
        w = Page.getCurrent().getBrowserWindowWidth();
    }

    popupWindow.setWidth(w + "px");
    popupWindow.setHeight(h + "px");

    popupBodyLayout.setWidth((w - 50) + "px");

    Set<String> diseaseSet = Quant_Central_Manager.getDiseaseCategorySet();

    diseaseTypeSelectionList.setDescription("Select disease category");

    for (String disease : diseaseSet) {
        diseaseTypeSelectionList.addItem(disease);
        diseaseTypeSelectionList.setItemCaption(disease, (disease));

    }

    HorizontalLayout diseaseCategorySelectLayout = new HorizontalLayout();
    diseaseCategorySelectLayout.setWidthUndefined();
    diseaseCategorySelectLayout.setHeight("50px");
    diseaseCategorySelectLayout.setSpacing(true);
    diseaseCategorySelectLayout.setMargin(true);

    popupBodyLayout.addComponent(diseaseCategorySelectLayout);
    popupBodyLayout.setComponentAlignment(diseaseCategorySelectLayout, Alignment.TOP_LEFT);

    Label title = new Label("Disease Category");
    title.setStyleName(Reindeer.LABEL_SMALL);
    diseaseCategorySelectLayout.addComponent(title);

    diseaseCategorySelectLayout.setComponentAlignment(title, Alignment.BOTTOM_CENTER);
    diseaseTypeSelectionList.setWidth("200px");
    diseaseTypeSelectionList.setNullSelectionAllowed(false);
    diseaseTypeSelectionList.setValue("All");
    diseaseTypeSelectionList.setImmediate(true);
    diseaseCategorySelectLayout.addComponent(diseaseTypeSelectionList);
    diseaseCategorySelectLayout.setComponentAlignment(diseaseTypeSelectionList, Alignment.TOP_LEFT);
    diseaseTypeSelectionList.setStyleName("diseaseselectionlist");
    diseaseTypeSelectionList.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            boolean showAll = false;
            String value = event.getProperty().getValue().toString();
            if (value.equalsIgnoreCase("All")) {
                showAll = true;
            }
            for (String dName : diseaseGroupsGridLayoutMap.keySet()) {
                if (dName.equalsIgnoreCase(value) || showAll) {
                    diseaseGroupsGridLayoutMap.get(dName).setVisible(true);
                } else {
                    diseaseGroupsGridLayoutMap.get(dName).setVisible(false);
                }
            }

        }
    });

    VerticalLayout diseaseGroupsNamesContainer = new VerticalLayout();
    diseaseGroupsNamesContainer.setWidth("100%");
    diseaseGroupsNamesContainer.setHeightUndefined();
    popupBodyLayout.addComponent(diseaseGroupsNamesContainer);
    diseaseGroupsNamesContainer.setStyleName(Reindeer.LAYOUT_WHITE);
    GridLayout diseaseNamesHeader = new GridLayout(2, 1);
    diseaseNamesHeader.setWidth("100%");
    diseaseNamesHeader.setHeightUndefined();
    diseaseNamesHeader.setSpacing(true);
    diseaseNamesHeader.setMargin(new MarginInfo(true, false, true, false));
    diseaseGroupsNamesContainer.addComponent(diseaseNamesHeader);
    Label col1Label = new Label("Group Name");
    diseaseNamesHeader.addComponent(col1Label, 0, 0);
    col1Label.setStyleName(Reindeer.LABEL_SMALL);

    Label col2Label = new Label("Suggested Name");
    diseaseNamesHeader.addComponent(col2Label, 1, 0);
    col2Label.setStyleName(Reindeer.LABEL_SMALL);

    Panel diseaseGroupsNamesFrame = new Panel();
    diseaseGroupsNamesFrame.setWidth("100%");
    diseaseGroupsNamesFrame.setHeight((h - 200) + "px");
    diseaseGroupsNamesContainer.addComponent(diseaseGroupsNamesFrame);
    diseaseGroupsNamesFrame.setStyleName(Reindeer.PANEL_LIGHT);

    VerticalLayout diseaseNamesUpdateContainerLayout = new VerticalLayout();
    for (String diseaseCategory : diseaseSet) {
        if (diseaseCategory.equalsIgnoreCase("All")) {
            continue;
        }

        HorizontalLayout diseaseNamesUpdateContainer = initDiseaseNamesUpdateContainer(diseaseCategory);
        diseaseNamesUpdateContainerLayout.addComponent(diseaseNamesUpdateContainer);
        diseaseGroupsGridLayoutMap.put(diseaseCategory, diseaseNamesUpdateContainer);
    }
    diseaseGroupsNamesFrame.setContent(diseaseNamesUpdateContainerLayout);

    HorizontalLayout btnLayout = new HorizontalLayout();
    btnLayout.setMargin(true);
    btnLayout.setSpacing(true);

    Button resetFiltersBtn = new Button("Reset");
    resetFiltersBtn.setPrimaryStyleName("resetbtn");
    btnLayout.addComponent(resetFiltersBtn);
    resetFiltersBtn.setWidth("50px");
    resetFiltersBtn.setHeight("24px");

    resetFiltersBtn.setDescription("Reset group names to default");
    resetFiltersBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            resetToDefault();
        }
    });
    Button resetToOriginalBtn = new Button("Publications Names");
    resetToOriginalBtn.setPrimaryStyleName("resetbtn");
    btnLayout.addComponent(resetToOriginalBtn);
    resetToOriginalBtn.setWidth("150px");
    resetToOriginalBtn.setHeight("24px");

    resetToOriginalBtn.setDescription("Reset group names to original publication names");
    resetToOriginalBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            resetToPublicationsNames();
        }
    });

    Button applyFilters = new Button("Update");
    applyFilters.setDescription("Update disease groups with the selected names");
    applyFilters.setPrimaryStyleName("resetbtn");
    applyFilters.setWidth("50px");
    applyFilters.setHeight("24px");

    btnLayout.addComponent(applyFilters);
    applyFilters.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            updateGroups();

        }
    });

    popupBodyLayout.addComponent(btnLayout);
    popupBodyLayout.setComponentAlignment(btnLayout, Alignment.MIDDLE_RIGHT);
    resetToDefault();

}

From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.PopupRecombineDiseaseGroups.java

private HorizontalLayout initDiseaseNamesUpdateContainer(String diseaseCategory) {
    GridLayout diseaseNamesUpdateContainer = new GridLayout(2,
            (default_DiseaseCat_DiseaseGroupMap.get(diseaseCategory).size() * 2));
    diseaseNamesUpdateContainer.setWidth("100%");
    diseaseNamesUpdateContainer.setHeightUndefined();
    diseaseNamesUpdateContainer.setSpacing(false);
    diseaseNamesUpdateContainer.setMargin(new MarginInfo(false, false, false, false));

    int widthCalc = 0;
    int row = 0;/*  w w w  . j a  v  a  2 s .  c o  m*/
    int col = 0;
    Map<String, ComboBox> diseaseGroupNameToListMap = new LinkedHashMap<String, ComboBox>();
    for (String diseaseGroupName : default_DiseaseCat_DiseaseGroupMap.get(diseaseCategory).keySet()) {
        //            if(!diseaseGroupName.contains(diseaseCategory))
        //                continue;
        diseaseNamesUpdateContainer.addComponent(generateLabel(diseaseGroupName, diseaseCategory), col, row);
        ComboBox list = generateLabelList(diseaseCategory);
        diseaseNamesUpdateContainer.addComponent(list, col + 1, row);
        diseaseGroupNameToListMap.put(diseaseGroupName, list);

        col = 0;
        row++;

        VerticalLayout spacer1 = new VerticalLayout();
        spacer1.setHeight("2px");
        spacer1.setWidth("300px");
        spacer1.setStyleName(Reindeer.LAYOUT_WHITE);
        diseaseNamesUpdateContainer.addComponent(spacer1, col, row);
        VerticalLayout spacer2 = new VerticalLayout();
        spacer2.setHeight("2px");
        spacer2.setWidth("300px");
        spacer2.setStyleName(Reindeer.LAYOUT_WHITE);//"lightgraylayout");
        diseaseNamesUpdateContainer.addComponent(spacer2, col + 1, row);

        col = 0;
        row++;
        widthCalc += 26;

    }
    diseaseGroupsSelectionListMap.put(diseaseCategory, diseaseGroupNameToListMap);

    //        widthCalc-=26;
    VerticalLayout diseaseLabelContainer = new VerticalLayout();

    Label label = new Label("<center><font  color='#ffffff'>" + diseaseCategory + "</font></center>");
    label.setContentMode(ContentMode.HTML);
    diseaseLabelContainer.setHeight(widthCalc + "px");
    diseaseLabelContainer.setWidth("20px");
    VerticalLayout rotateContainer = new VerticalLayout();

    rotateContainer.setWidth(widthCalc + "px");
    rotateContainer.setHeight("20px");
    diseaseLabelContainer.addComponent(rotateContainer);

    rotateContainer.setStyleName(
            "row_" + diseaseStyleMap.get(diseaseCategory.replace(" ", "_").replace("'", "-") + ("_Disease")));
    rotateContainer.addComponent(label);
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);
    layout.addComponent(diseaseLabelContainer);
    layout.addComponent(diseaseNamesUpdateContainer);

    return layout;
}

From source file:probe.com.view.body.quantdatasetsoverview.quantproteinstabsheet.studies.PeptidesComparisonsSequenceLayout.java

/**
 *
 * @param cp//from  w ww . ja  v  a2s . c  o m
 * @param width
 * @param Quant_Central_Manager
 */
public PeptidesComparisonsSequenceLayout(QuantCentralManager Quant_Central_Manager,
        final DiseaseGroupsComparisonsProteinLayout cp, int width) {
    this.studiesMap = new LinkedHashMap<String, StudyInfoData>();
    this.setColumns(4);
    this.setRows(3);
    this.setWidthUndefined();
    this.setSpacing(true);
    this.setMargin(new MarginInfo(true, false, false, false));
    comparisonTitle = new Label();
    comparisonTitle.setContentMode(ContentMode.HTML);
    comparisonTitle.setStyleName("custChartLabelHeader");
    comparisonTitle.setWidth((width - 55) + "px");
    this.addComponent(comparisonTitle, 1, 0);
    this.setComponentAlignment(comparisonTitle, Alignment.TOP_LEFT);

    closeBtn = new VerticalLayout();
    closeBtn.setWidth("20px");
    closeBtn.setHeight("20px");
    closeBtn.setStyleName("closebtn");
    this.addComponent(closeBtn, 2, 0);
    this.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT);
    //end of toplayout
    //init comparison study layout

    GridLayout proteinSequenceComparisonsContainer = new GridLayout(2,
            cp.getComparison().getDatasetIndexes().length);
    proteinSequenceComparisonsContainer.setWidthUndefined();
    proteinSequenceComparisonsContainer.setHeightUndefined();
    proteinSequenceComparisonsContainer.setStyleName(Reindeer.LAYOUT_WHITE);
    proteinSequenceComparisonsContainer.setSpacing(true);
    proteinSequenceComparisonsContainer.setMargin(new MarginInfo(true, false, false, false));
    this.addComponent(proteinSequenceComparisonsContainer, 1, 1);
    coverageWidth = (width - 100 - 180);

    Map<Integer, Set<QuantPeptide>> dsQuantPepMap = new HashMap<Integer, Set<QuantPeptide>>();
    for (QuantPeptide quantPep : cp.getQuantPeptidesList()) {
        if (!dsQuantPepMap.containsKey(quantPep.getDsKey())) {
            Set<QuantPeptide> subList = new HashSet<QuantPeptide>();
            dsQuantPepMap.put(quantPep.getDsKey(), subList);
        }
        Set<QuantPeptide> subList = dsQuantPepMap.get(quantPep.getDsKey());
        subList.add(quantPep);
        dsQuantPepMap.put(quantPep.getDsKey(), subList);
    }

    int numb = 0;

    int panelWidth = Page.getCurrent().getBrowserWindowWidth() - 100;
    String groupCompTitle = cp.getComparison().getComparisonHeader();
    String updatedHeader = groupCompTitle.split(" / ")[0].split("\n")[0] + " / "
            + groupCompTitle.split(" / ")[1].split("\n")[0];//+ " ( " + groupCompTitle.split(" / ")[1].split("\n")[1] + " )";
    ;
    final StudyInformationPopupComponent studyInformationPopupPanel = new StudyInformationPopupComponent(
            panelWidth, cp.getProtName(), cp.getUrl(), cp.getComparison().getComparisonFullName());
    studyInformationPopupPanel.setVisible(false);

    LayoutEvents.LayoutClickListener studyListener = new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            Integer dsId;
            if (event.getComponent() instanceof AbsoluteLayout) {
                dsId = (Integer) ((AbsoluteLayout) event.getComponent()).getData();
            } else {
                dsId = (Integer) ((VerticalLayout) event.getComponent()).getData();
            }
            studyInformationPopupPanel.updateContent(dsToStudyLayoutMap.get(dsId));
        }
    };
    TreeSet<QuantProtein> orderSet = new TreeSet<QuantProtein>(cp.getDsQuantProteinsMap().values());
    for (QuantProtein quantProtein : orderSet) {
        StudyInfoData exportData = new StudyInfoData();
        exportData.setCoverageWidth(coverageWidth);
        Label studyTitle = new Label();//"Study " + (numb + 1));
        studyTitle.setStyleName("peptideslayoutlabel");
        studyTitle.setHeightUndefined();
        studyTitle.setWidth("200px");

        Label iconTitle = new Label("#Patients ("
                + (quantProtein.getPatientsGroupIINumber() + quantProtein.getPatientsGroupINumber()) + ")");
        exportData.setSubTitle(iconTitle.getValue());

        iconTitle.setStyleName("peptideslayoutlabel");
        iconTitle.setHeightUndefined();
        if (quantProtein.getStringPValue().equalsIgnoreCase("Not Significant")
                || quantProtein.getStringFCValue().equalsIgnoreCase("Not regulated")) {
            iconTitle.setStyleName("notregicon");
            exportData.setTrend(0);
        } else if (quantProtein.getStringFCValue().equalsIgnoreCase("Decreased")) {
            iconTitle.setStyleName("downarricon");
            exportData.setTrend(-1);
        } else {
            exportData.setTrend(1);
            iconTitle.setStyleName("uparricon");
        }

        iconTitle.setDescription(cp.getProteinAccssionNumber() + " : #Patients ("
                + (quantProtein.getPatientsGroupIINumber() + quantProtein.getPatientsGroupINumber()) + ")  "
                + quantProtein.getStringFCValue() + " " + quantProtein.getStringPValue() + "");

        VerticalLayout labelContainer = new VerticalLayout();
        labelContainer.addComponent(studyTitle);
        labelContainer.addComponent(iconTitle);

        proteinSequenceComparisonsContainer.addComponent(labelContainer, 0, numb);
        proteinSequenceComparisonsContainer.setComponentAlignment(labelContainer, Alignment.TOP_CENTER);

        Map<Integer, ComparisonDetailsBean> patientGroupsNumToDsIdMap = new HashMap<Integer, ComparisonDetailsBean>();
        ComparisonDetailsBean pGr = new ComparisonDetailsBean();
        patientGroupsNumToDsIdMap
                .put((quantProtein.getPatientsGroupIINumber() + quantProtein.getPatientsGroupINumber()), pGr);
        QuantDatasetObject ds;

        ds = Quant_Central_Manager.getFullQuantDatasetMap().get(quantProtein.getDsKey());

        StudyPopupLayout study = new StudyPopupLayout(panelWidth, quantProtein, ds,
                cp.getProteinAccssionNumber(), cp.getUrl(), cp.getProtName(),
                Quant_Central_Manager.getDiseaseHashedColorMap());
        Set<QuantDatasetObject> qdsSet = new HashSet<QuantDatasetObject>();
        qdsSet.add(ds);
        study.setInformationData(qdsSet, cp);
        dsToStudyLayoutMap.put(ds.getDsKey(), study);

        labelContainer.addLayoutClickListener(studyListener);
        labelContainer.setData(ds.getDsKey());
        studyTitle.setValue("[" + (numb + 1) + "] " + ds.getAuthor());
        exportData.setTitle(ds.getAuthor());

        if (dsQuantPepMap.get(quantProtein.getDsKey()) == null) {
            Label noPeptidesInfoLabel = new Label("No Peptide Information Available ");
            noPeptidesInfoLabel.setHeightUndefined();
            noPeptidesInfoLabel.setStyleName("peptideslayoutlabel");
            VerticalLayout labelValueContainer = new VerticalLayout();
            labelValueContainer.addComponent(noPeptidesInfoLabel);
            labelValueContainer.addLayoutClickListener(studyListener);
            labelValueContainer.setData(ds.getDsKey());

            proteinSequenceComparisonsContainer.addComponent(labelValueContainer, 1, numb);
            proteinSequenceComparisonsContainer.setComponentAlignment(labelValueContainer,
                    Alignment.TOP_CENTER);
            numb++;
            studiesMap.put((numb + 1) + ds.getAuthor(), exportData);
            continue;
        }

        String key = "_-_" + quantProtein.getDsKey() + "_-_" + cp.getProteinAccssionNumber() + "_-_";
        PeptidesInformationOverviewLayout peptideInfoLayout = new PeptidesInformationOverviewLayout(
                cp.getSequence(), dsQuantPepMap.get(quantProtein.getDsKey()), coverageWidth, true,
                studyListener, ds.getDsKey());
        exportData.setPeptidesInfoList(peptideInfoLayout.getStackedPeptides());
        exportData.setLevelsNumber(peptideInfoLayout.getLevel());
        hasPTM = peptideInfoLayout.isHasPTM();
        peptidesInfoLayoutDSIndexMap.put(key, peptideInfoLayout);
        proteinSequenceComparisonsContainer.addComponent(peptideInfoLayout, 1, numb);
        numb++;
        studiesMap.put((numb + 1) + ds.getAuthor(), exportData);

    }

    String rgbColor = Quant_Central_Manager
            .getDiseaseHashedColor(groupCompTitle.split(" / ")[1].split("\n")[1]);
    comparisonTitle.setValue("<font color='" + rgbColor + "' style='font-weight: bold;'>" + updatedHeader
            + " (#Datasets " + numb + "/" + cp.getComparison().getDatasetIndexes().length + ")</font>");
    comparisonTitle.setDescription(cp.getComparison().getComparisonFullName());
    VerticalLayout bottomSpacer = new VerticalLayout();
    bottomSpacer.setWidth((width - 100) + "px");
    bottomSpacer.setHeight("10px");
    bottomSpacer.setStyleName("dottedline");
    this.addComponent(bottomSpacer, 1, 2);

}