Example usage for com.vaadin.ui PopupView PopupView

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

Introduction

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

Prototype

public PopupView(final String small, final Component large) 

Source Link

Document

A simple way to create a PopupPanel.

Usage

From source file:ac.uk.icl.dell.vaadin.glycanbuilder.VaadinGlycanCanvas.java

License:Open Source License

private void updateLinkageToolBar() {
    if (linkagePanel == null) {
        return;/*from  ww w .  ja v  a2  s. c  o m*/
    } else {
        final Residue current = theCanvas.getCurrentResidue();

        if (field_anomeric_state != null) {
            field_anomeric_state.removeListener(defaultListener);
            field_anomeric_state.removeListener(defaultListener);
            field_anomeric_carbon.removeListener(defaultListener);
            field_linkage_position.removeListener(defaultListener);
            field_chirality.removeListener(defaultListener);
            field_ring_size.removeListener(defaultListener);
            field_second_child_position.removeListener(defaultListener);
            field_second_parent_position.removeListener(defaultListener);
        }

        linkagePanel.removeAllComponents();
        popupLayout2 = new HorizontalLayout();
        linkage_two_panel = new PopupView("2nd Linkage", popupLayout2);

        popupLayout2.addStyleName("2nd_linkage_panel");
        linkage_two_panel.setEnabled(false);

        field_anomeric_state = new OptionGroup("Anomeric state", Arrays.asList(new String[] { "?", "a", "b" }));
        field_anomeric_state.setStyleName("linkage_component_select");
        field_anomeric_state.setEnabled(false);

        field_anomeric_carbon = new OptionGroup("Anomeric carbon",
                Arrays.asList(new String[] { "?", "1", "2", "3" }));
        field_anomeric_carbon.setEnabled(false);

        field_linkage_position = new OptionGroup("Linkage position",
                Arrays.asList(new String[] { "?", "1", "2", "3", "4", "5", "6", "7", "8", "9" }));
        field_linkage_position.setMultiSelect(true);
        field_linkage_position.setEnabled(false);

        field_chirality = new OptionGroup("Chirality", Arrays.asList(new String[] { "?", "D", "L" }));
        field_chirality.setMultiSelect(false);
        field_chirality.setEnabled(false);

        field_ring_size = new OptionGroup("Ring", Arrays.asList(new String[] { "?", "p", "f", "o" }));
        field_ring_size.setMultiSelect(false);
        field_ring_size.setEnabled(false);

        field_second_bond = new CheckBox("");
        field_second_bond.setEnabled(false);
        field_second_bond.addStyleName("glycanbuilder-2nd-cov-checkbox");

        field_second_bond.setValue(false);
        field_second_bond.setImmediate(true); //forces a value change event to be fired immediately

        field_second_child_position = new OptionGroup("Linkage Position",
                Arrays.asList(new String[] { "?", "1", "2", "3" }));
        field_second_child_position.setMultiSelect(false);
        field_second_child_position.setEnabled(false);

        field_second_parent_position = new OptionGroup("Linkage Position",
                Arrays.asList(new String[] { "?", "1", "2", "3", "4", "5", "6", "7", "8", "9" }));
        field_second_parent_position.setMultiSelect(true);
        field_second_parent_position.setEnabled(false);

        if (current != null && (!current.isSpecial() || current.isCleavage() || current.isStartRepetition())) {
            //linkagePanel.setVisible(true);

            Linkage parent_link = current.getParentLinkage();

            if (parent_link != null) {
                field_linkage_position.removeAllItems();
                List<String> positions = theCanvas.createPositions(parent_link.getParentResidue());
                for (String position : positions) {
                    field_linkage_position.addItem(position);
                }

                field_second_parent_position.removeAllItems();
                for (String position : positions) {
                    field_second_parent_position.addItem(position);
                }
            }

            boolean can_have_parent_linkage = (parent_link != null && parent_link.getParentResidue() != null
                    && (parent_link.getParentResidue().isSaccharide()
                            || parent_link.getParentResidue().isBracket()
                            || parent_link.getParentResidue().isRepetition()
                            || parent_link.getParentResidue().isRingFragment()));

            field_linkage_position.setEnabled(can_have_parent_linkage);
            field_anomeric_state.setEnabled(current.isSaccharide());
            field_anomeric_carbon.setEnabled(current.isSaccharide());
            field_chirality.setEnabled(current.isSaccharide());
            field_ring_size.setEnabled(current.isSaccharide());
            field_second_bond.setEnabled(can_have_parent_linkage);

            linkage_two_panel.setEnabled(can_have_parent_linkage && parent_link.hasMultipleBonds());

            field_second_parent_position.setEnabled(can_have_parent_linkage && parent_link.hasMultipleBonds());
            field_second_child_position.setEnabled(can_have_parent_linkage && parent_link.hasMultipleBonds());

            if (parent_link != null) {
                field_linkage_position.setValue(
                        Arrays.asList(theCanvas.toStrings(parent_link.glycosidicBond().getParentPositions())));
            } else {
                field_linkage_position.setValue(null);
            }

            field_anomeric_state.setValue("" + current.getAnomericState());
            field_anomeric_carbon.setValue("" + current.getAnomericCarbon());
            field_chirality.setValue("" + current.getChirality());
            field_ring_size.setValue("" + current.getRingSize());
            if (parent_link != null) {
                field_second_bond.setValue(parent_link.hasMultipleBonds());
                field_second_parent_position.setValue(
                        Arrays.asList(theCanvas.toStrings(parent_link.getBonds().get(0).getParentPositions())));
                field_second_child_position.setValue("" + parent_link.getBonds().get(0).getChildPosition());
            } else {
                field_second_parent_position.setValue(null);
                field_second_child_position.setValue("?");
            }

            forceLinkagePopRepaint();
        } else {
            //linkagePanel.setVisible(false);

            field_linkage_position.setEnabled(false);
            field_anomeric_state.setEnabled(false);
            field_anomeric_carbon.setEnabled(false);
            field_chirality.setEnabled(false);
            field_ring_size.setEnabled(false);
            field_second_bond.setEnabled(false);
            field_second_parent_position.setEnabled(false);
            field_second_child_position.setEnabled(false);

            field_linkage_position.setValue(null);
            field_anomeric_state.setValue("?");
            field_anomeric_carbon.setValue("");
            field_chirality.setValue("?");
            field_ring_size.setValue("?");
            field_second_parent_position.setValue(null);
            field_second_child_position.setValue("?");

            forceLinkagePopRepaint();
        }
    }
}

From source file:ac.uk.icl.dell.vaadin.glycanbuilder.VaadinGlycanCanvas.java

License:Open Source License

public void forceLinkagePopRepaint() {
    registerLinkageListeners();//ww w .  jav a  2  s  .  c  o m

    WeeLayout toolBar = new WeeLayout(Direction.HORIZONTAL);
    toolBar.setWidth("100%");

    HorizontalLayout popupLayout = new HorizontalLayout();
    linkage_one_panel = new PopupView("1st Linkage", popupLayout);
    if (field_linkage_position.isEnabled() || field_anomeric_carbon.isEnabled()
            || field_anomeric_state.isEnabled() || field_chirality.isEnabled() || field_ring_size.isEnabled()) {
        linkage_one_panel.setEnabled(true);
    } else {
        linkage_one_panel.setEnabled(false);
    }

    popupLayout.addStyleName("1st_linkage_panel");

    popupLayout.addComponent(field_anomeric_state);
    popupLayout.addComponent(field_anomeric_carbon);
    popupLayout.addComponent(field_linkage_position);
    popupLayout.addComponent(field_chirality);
    popupLayout.addComponent(field_ring_size);

    //      boolean enabled=linkage_two_panel.isEnabled();
    //      linkage_two_panel = new PopupButton("2nd Linkage");
    //      linkage_two_panel.setEnabled(enabled);
    //      linkage_two_panel.setComponent(popupLayout2);

    //      linkage_one_panel.addStyleName(BaseTheme.BUTTON_LINK);
    //      linkage_two_panel.addStyleName("link");

    linkage_two_panel.addStyleName("igg-glycan-builder-linkage-toolbar-panel-item");
    linkage_one_panel.addStyleName("igg-glycan-builder-linkage-toolbar-panel-item");
    field_second_bond.addStyleName("igg-glycan-builder-linkage-toolbar-panel-item");

    toolBar.addComponent(linkage_one_panel);

    popupLayout2.addComponent(field_second_child_position);
    popupLayout2.addComponent(field_second_parent_position);

    toolBar.addComponent(field_second_bond);

    toolBar.addComponent(linkage_two_panel);

    linkagePanel.removeAllComponents();
    linkagePanel.setContent(toolBar);

    linkagePanel.requestRepaintAll();
}

From source file:annis.gui.admin.PopupTwinColumnSelect.java

License:Apache License

public PopupTwinColumnSelect() {

    txtValue = createTextField();/*w  w  w . j  a  v a  2s .c  om*/
    txtValue.setConverter(new CommaSeperatedStringConverterSet());
    txtValue.setWidth("100%");
    txtValue.setPropertyDataSource(PopupTwinColumnSelect.this);

    selector = new TwinColSelect();
    selector.setConverter(new TreeSetConverter());
    selector.setNewItemsAllowed(false);
    selector.setLeftColumnCaption("Available");
    selector.setRightColumnCaption("Selected");
    selector.setContainerDataSource(selectableContainer);
    selector.setWidth("44em");
    selector.setPropertyDataSource(PopupTwinColumnSelect.this);

    PopupView popup = new PopupView("Select", selector);

    layout = new HorizontalLayout(popup, txtValue);
    layout.setExpandRatio(popup, 0.0f);
    layout.setExpandRatio(txtValue, 1.0f);
    layout.setWidth("100%");
    layout.setSpacing(true);

    addValueChangeListener(new UpdateContainerListener());
}

From source file:com.liferay.mail.vaadin.MessageToolbar.java

License:Open Source License

protected void selectMoveTarget() {

    // Ensure a mail is selected
    List<Message> message = mainMailView.getSelectedMessages();
    if (message.isEmpty()) {
        Controller.get().showInfo(Lang.get("no-messages-selected"));
        return;//from w  w w.  j a v  a 2  s  . com
    }

    Account account;
    try {
        account = MessageUtil.getAccountForMessage(message.get(0));
    } catch (Exception e) {
        Controller.get().showError(Lang.get("unable-to-move-messages"), e);
        return;
    }

    VerticalLayout panelLayout = new VerticalLayout();
    panelLayout.setMargin(false, true, true, false);
    panelLayout.setSizeUndefined();

    Panel p = new Panel(panelLayout);
    p.setSizeUndefined();

    final PopupView popupView = new PopupView("", p);

    FolderTree destinationTree = new FolderTree(new FolderChangeListener() {

        public void selectedFolderChanged(Folder folder) {

            if (folder != null) {
                popupView.setPopupVisible(false);
                Controller controller = Controller.get();
                try {
                    MessageUtil.moveMessagesTo(mainMailView.getSelectedMessages(), folder);

                    controller.showInfo(Lang.get("messages-have-been-moved"));
                } catch (MailException me) {
                    if (me.getType() == MailException.FOLDER_INVALID_DESTINATION) {
                        controller.showError(Lang.get("cannot-move-messages-to-this-folder"));
                    }
                } catch (PortalException e) {
                    controller.showError(Lang.get("unable-to-move-messages"), e);
                } catch (SystemException e) {
                    controller.showError(Lang.get("unable-to-move-messages"), e);
                }

            }
        }
    }, null);

    p.addComponent(destinationTree);

    popupView.setPopupVisible(true);
    popupView.addListener(new PopupVisibilityListener() {

        public void popupVisibilityChange(PopupVisibilityEvent event) {

            // Remove popupview from layout when it has been closed
            if (!event.isPopupVisible()) {
                removeComponent(event.getPopupView());

            }
        }
    });

    // Set tree properties
    List<Account> accounts = new ArrayList<Account>();
    accounts.add(account);
    final FolderContainer folderContainer = new FolderContainer(accounts);

    destinationTree.setContainerDataSource(folderContainer);
    destinationTree.expandItemsRecursively(destinationTree.rootItemIds().iterator().next());

    addComponent(popupView, moveToIndex);

}

From source file:com.mycollab.module.crm.ui.components.CrmFollowersComp.java

License:Open Source License

public void displayFollowers(final V bean) {
    this.bean = bean;
    try {// w  ww.j ava 2s. c  om
        typeId = (Integer) PropertyUtils.getProperty(bean, "id");
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        LOG.error("Error", e);
        return;
    }
    this.removeAllComponents();

    MHorizontalLayout header = new MHorizontalLayout().withStyleName("info-hdr");
    header.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    Label followerHeader = new Label(
            FontAwesome.EYE.getHtml() + " " + UserUIContext.getMessage(FollowerI18nEnum.OPT_SUB_INFO_WATCHERS),
            ContentMode.HTML);
    header.addComponent(followerHeader);

    if (hasEditPermission()) {
        final PopupView addPopupView = new PopupView(UserUIContext.getMessage(GenericI18Enum.ACTION_MODIFY),
                new MVerticalLayout());
        addPopupView.addPopupVisibilityListener(popupVisibilityEvent -> {
            PopupView.Content content = addPopupView.getContent();
            if (popupVisibilityEvent.isPopupVisible()) {
                MVerticalLayout popupComponent = (MVerticalLayout) content.getPopupComponent();
                popupComponent.removeAllComponents();
                popupComponent.with(new ELabel(UserUIContext.getMessage(FollowerI18nEnum.OPT_SUB_INFO_WATCHERS))
                        .withStyleName(ValoTheme.LABEL_H3), new ModifyWatcherPopup());
            } else {
                MVerticalLayout popupComponent = (MVerticalLayout) content.getPopupComponent();
                ModifyWatcherPopup popup = (ModifyWatcherPopup) popupComponent.getComponent(1);
                List<MonitorItem> unsavedItems = popup.getUnsavedItems();
                monitorItemService.saveMonitorItems(unsavedItems);
                loadWatchers();
            }
        });
        header.addComponent(addPopupView);
    }
    header.addComponent(ELabel.fontIcon(FontAwesome.QUESTION_CIRCLE).withStyleName(WebThemes.INLINE_HELP)
            .withDescription(UserUIContext.getMessage(FollowerI18nEnum.FOLLOWER_EXPLAIN_HELP)));

    this.addComponent(header);
    watcherLayout = new MCssLayout().withFullWidth().withStyleName(WebThemes.FLEX_DISPLAY);
    this.addComponent(watcherLayout);
    loadWatchers();
}

From source file:com.mycollab.module.project.ui.components.ProjectFollowersComp.java

License:Open Source License

public void displayFollowers(final V bean) {
    this.bean = bean;
    try {//  w w  w.  j a  v  a2s . c  o m
        typeId = (Integer) PropertyUtils.getProperty(bean, "id");
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        LOG.error("Error", e);
        return;
    }
    this.removeAllComponents();

    MHorizontalLayout header = new MHorizontalLayout().withStyleName("info-hdr");
    header.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    Label followerHeader = new Label(
            FontAwesome.EYE.getHtml() + " " + UserUIContext.getMessage(FollowerI18nEnum.OPT_SUB_INFO_WATCHERS),
            ContentMode.HTML);
    header.addComponent(followerHeader);

    if (hasEditPermission()) {
        final PopupView addPopupView = new PopupView(UserUIContext.getMessage(GenericI18Enum.ACTION_MODIFY),
                new MVerticalLayout());
        addPopupView.addPopupVisibilityListener(popupVisibilityEvent -> {
            PopupView.Content content = addPopupView.getContent();
            if (popupVisibilityEvent.isPopupVisible()) {
                MVerticalLayout popupComponent = (MVerticalLayout) content.getPopupComponent();
                popupComponent.removeAllComponents();
                popupComponent.with(new ELabel(UserUIContext.getMessage(FollowerI18nEnum.OPT_SUB_INFO_WATCHERS))
                        .withStyleName(ValoTheme.LABEL_H3), new ModifyWatcherPopup());
            } else {
                MVerticalLayout popupComponent = (MVerticalLayout) content.getPopupComponent();
                ModifyWatcherPopup popup = (ModifyWatcherPopup) popupComponent.getComponent(1);
                List<MonitorItem> unsavedItems = popup.getUnsavedItems();
                monitorItemService.saveMonitorItems(unsavedItems);
                loadWatchers();
            }
        });
        header.addComponent(addPopupView);
    }
    header.addComponent(ELabel.fontIcon(FontAwesome.QUESTION_CIRCLE).withStyleName(WebThemes.INLINE_HELP)
            .withDescription(UserUIContext.getMessage(FollowerI18nEnum.FOLLOWER_EXPLAIN_HELP)));

    this.addComponent(header);

    watcherLayout = new MCssLayout().withFullWidth().withStyleName(WebThemes.FLEX_DISPLAY);
    this.addComponent(watcherLayout);
    loadWatchers();
}

From source file:com.mymita.vaadlets.VaadletsBuilder.java

License:Apache License

private com.vaadin.ui.Component createComponent(final com.mymita.vaadlets.core.Component vaadletComponent)
        throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    if (vaadletComponent instanceof com.mymita.vaadlets.addon.CodeMirror) {
        // TODO build tag handler to adapt custom tags
        final com.mymita.vaadlets.addon.CodeMirror cm = (com.mymita.vaadlets.addon.CodeMirror) vaadletComponent;
        final Class<?> codeMirrorComponentClass = Class.forName("org.vaadin.codemirror.CodeMirror");
        try {/*from   www . ja  v a2s  .  c  om*/
            final Constructor<?> constructor = codeMirrorComponentClass.getDeclaredConstructor(String.class);
            final CodeMirror result = (CodeMirror) constructor.newInstance(cm.getCaption());
            result.setCodeStyle(VaadinUtils.codeMirrorCodeStyleOf(cm.getCodeStyle()));
            result.setShowLineNumbers(cm.isShowLineNumbers());
            return result;
        } catch (NoSuchMethodException | SecurityException | IllegalArgumentException
                | InvocationTargetException e) {
            throw new IllegalArgumentException(
                    format("Can't create vaadin component for vaadlets component '%s'", vaadletComponent), e);
        }
    }
    String vaadinComponentClassName = null;
    if (vaadletComponent instanceof com.mymita.vaadlets.ui.PopupView) {
        // TODO build tag handler to adapt custom tags
        final com.mymita.vaadlets.ui.PopupView popupView = (com.mymita.vaadlets.ui.PopupView) vaadletComponent;
        final String small = popupView.getSmall();
        final com.mymita.vaadlets.core.Component large = ((JAXBElement<com.mymita.vaadlets.core.Component>) popupView
                .getLarge().getContent().get(0)).getValue();
        LOG.debug(format("Create vaadin component '%s' with small '%s' and large '%s'",
                vaadinComponentClassName, small, large));
        return new PopupView(small, createVaadinComponentWithChildren(large));
    }
    vaadinComponentClassName = "com.vaadin.ui." + vaadletComponent.getClass().getSimpleName();
    LOG.debug(format("Create vaadin component '%s'", vaadinComponentClassName));
    return (com.vaadin.ui.Component) Class.forName(vaadinComponentClassName).newInstance();
}

From source file:de.escidoc.admintool.view.admintask.filter.FilterResourceView.java

License:Open Source License

private void addFilterQueryTexField() {
    rawFilterTextArea.setWidth(800, UNITS_PIXELS);

    final Label popUpContent = new Label(ViewConstants.FILTER_EXAMPLE_TOOLTIP_TEXT, Label.CONTENT_XHTML);
    popUpContent.setWidth(400, UNITS_PIXELS);
    final PopupView popup = new PopupView(ViewConstants.TIP, popUpContent);
    filterLayout.addComponent(popup);//from w  w w  .j a  v  a2  s  .c  om
    filterLayout.addComponent(rawFilterTextArea);
}

From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java

public VerticalLayout createTab(InterestProfile profile) {
    VerticalLayout profileSettingsLayout = new VerticalLayout();
    GridLayout tabContent = new GridLayout(3, 3);

    TextField textFieldName = new TextField();
    Language.set(Word.NAME, textFieldName);
    textFieldName.setWidth("100%");
    textFieldName.setValue(profile.getName());
    textFieldName.setMaxLength(255);//from  www . java 2 s. co m
    CheckBox checkBoxEnabled = new CheckBox();
    checkBoxEnabled.setValue(profile.isEnabled());
    Language.setCustom(Word.ENABLED, s -> checkBoxEnabled.setCaption(s));

    Button buttonDelete = new Button();
    Language.set(Word.DELETE, buttonDelete);
    buttonDelete.setIcon(VaadinIcons.TRASH);
    buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER);
    buttonDelete.addClickListener(ce -> {
        InterestProfileUtils.delete(profile);
        accordion.removeTab(accordion.getTab(profileSettingsLayout));
    });

    Button buttonSave = new Button();
    Language.set(Word.SAVE, buttonSave);
    buttonSave.setIcon(VaadinIcons.CHECK);
    buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonSave.addClickListener(ce -> {
        InterestProfileUtils.changeName(profile, textFieldName.getValue());
        accordion.getTab(profileSettingsLayout).setCaption(textFieldName.getValue());
        InterestProfileUtils.changeEnabled(profile, checkBoxEnabled.getValue());
        InterestProfileUtils.changeSources(profile, profile.getSources());
        InterestProfileUtils.changeCategories(profile, profile.getCategories());
        InterestProfileUtils.changeAllTags(profile, profile.getTags());
        VaadinUtils.infoNotification(Language.get(Word.SUCCESSFULLY_SAVED));
    });
    buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);

    Label placeholder = new Label();
    Label placeholder2 = new Label();
    placeholder2.setWidth("100%");

    Label labelHelp = new Label(Language.get(Word.HELP_TEXT), ContentMode.HTML);
    Language.setCustom(Word.HELP_TEXT, s -> labelHelp.setValue(s));
    labelHelp.setWidth("500px");
    PopupView popupHelp = new PopupView(null, labelHelp);

    Button buttonHelp = new Button(Language.get(Word.HELP), VaadinIcons.QUESTION);
    buttonHelp.addClickListener(ce -> {
        popupHelp.setPopupVisible(true);
    });

    GridLayout footer = new GridLayout(5, 1);
    footer.setSpacing(true);
    footer.setSizeUndefined();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth("100%");
    footer.addStyleName("menubar");
    footer.addComponents(buttonHelp, popupHelp, placeholder, buttonDelete, buttonSave);
    footer.setColumnExpandRatio(2, 5);
    footer.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER);

    tabContent.addComponents(textFieldName, checkBoxEnabled, placeholder2);
    tabContent.addComponent(getSources(profile), 0, 1, 1, 1);
    tabContent.addComponent(getCategories(profile), 2, 1);
    tabContent.addComponent(getTags(profile), 0, 2, 2, 2);
    tabContent.setWidth("100%");
    tabContent.setSpacing(true);
    tabContent.setMargin(true);
    tabContent.addStyleName("profiles");
    tabContent.setComponentAlignment(textFieldName, Alignment.MIDDLE_LEFT);
    tabContent.setComponentAlignment(checkBoxEnabled, Alignment.MIDDLE_CENTER);
    profileSettingsLayout.addComponents(tabContent, footer);
    profileSettingsLayout.setMargin(false);
    profileSettingsLayout.setSpacing(false);
    profileSettingsLayout.setWidth("100%");
    return profileSettingsLayout;
}

From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java

public Component getSources(InterestProfile profile) {
    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.setWidth("100%");
    VerticalLayout sourcesLayout = new VerticalLayout();
    sourcesLayout.setWidth("100%");
    Panel sourcesPanel = new Panel(sourcesLayout);

    List<CheckBox> checkBoxes = new ArrayList<>();
    HashMap<String, GridLayout> sourceLayouts = new HashMap<>();
    profile.getSources().entrySet().stream()
            .sorted((e1, e2) -> e1.getKey().getName().compareToIgnoreCase(e2.getKey().getName())).forEach(e -> {
                Source source = e.getKey();
                boolean enabled = e.getValue();
                GridLayout sourceLayout = new GridLayout(5, 1);
                sourceLayout.setSizeFull();

                CheckBox sourceSelected = new CheckBox();
                sourceSelected.setValue(enabled);
                sourceSelected.addStyleName(ValoTheme.CHECKBOX_LARGE);
                sourceSelected.addValueChangeListener(v -> profile.getSources().replace(source, v.getValue()));
                checkBoxes.add(sourceSelected);

                Image sourceLogo = new Image();
                sourceLogo.addStyleName("logosmall");
                sourceLogo.setSource(new ExternalResource(source.getLogo()));
                sourceLogo.addClickListener(c -> {
                    sourceSelected.setValue(!sourceSelected.getValue());
                    profile.getSources().replace(source, sourceSelected.getValue());
                });/*from  w ww  .  j  av a 2s.c  o  m*/
                VerticalLayout layoutLogo = new VerticalLayout(sourceLogo);
                layoutLogo.setWidth("150px");
                layoutLogo.setHeight("50px");
                layoutLogo.setMargin(false);
                layoutLogo.setSpacing(false);
                layoutLogo.setComponentAlignment(sourceLogo, Alignment.MIDDLE_LEFT);

                Label labelHeadLine = new Label(
                        source.getCategory().getIcon().getHtml() + "  " + source.getName(), ContentMode.HTML);
                labelHeadLine.addStyleName(ValoTheme.LABEL_H3);

                Label labelDescription = new Label(source.getDescription(), ContentMode.HTML);
                labelDescription.setWidth("300px");
                PopupView popup = new PopupView(null, labelDescription);

                Button buttonDescription = new Button(VaadinIcons.INFO_CIRCLE_O);
                buttonDescription.addClickListener(ce -> {
                    popup.setPopupVisible(true);
                });

                sourceLayout.addComponents(sourceSelected, layoutLogo, labelHeadLine, popup, buttonDescription);
                sourceLayout.setComponentAlignment(sourceSelected, Alignment.MIDDLE_CENTER);
                sourceLayout.setComponentAlignment(layoutLogo, Alignment.MIDDLE_CENTER);
                sourceLayout.setColumnExpandRatio(2, 5);
                sourceLayout.setSpacing(true);

                sourceLayouts.put(source.getName().toLowerCase().replaceAll(" ", "").replaceAll("-", "")
                        .replaceAll("_", ""), sourceLayout);
                sourcesLayout.addComponent(sourceLayout);
            });

    sourcesPanel.setContent(sourcesLayout);
    sourcesPanel.setHeight("100%");
    sourcesPanel.setCaption(Language.get(Word.SOURCES));
    Language.setCustom(Word.SOURCES, s -> sourcesPanel.setCaption(s));
    windowLayout.addComponent(sourcesPanel);
    windowLayout.setExpandRatio(sourcesPanel, 1);
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);

    CheckBox checkBoxSelectAll = new CheckBox();
    Language.setCustom(Word.SELECT_ALL, s -> checkBoxSelectAll.setCaption(s));
    checkBoxSelectAll.setWidth("100%");
    checkBoxSelectAll.addValueChangeListener(e -> {
        profile.getSources().replaceAll((c, enabled) -> checkBoxSelectAll.getValue());
        checkBoxes.forEach(c -> c.setValue(checkBoxSelectAll.getValue()));
    });

    TextField textFieldSearch = new TextField();
    Language.setCustom(Word.SEARCH, s -> textFieldSearch.setPlaceholder(s));
    textFieldSearch.setWidth("100%");
    textFieldSearch.setMaxLength(255);
    textFieldSearch.setPlaceholder(Language.get(Word.SEARCH));
    textFieldSearch.addValueChangeListener(searchValue -> {
        sourceLayouts.forEach((sourceName, sourceLayout) -> {
            if (!sourceName.contains(searchValue.getValue().toLowerCase().replaceAll(" ", "")
                    .replaceAll("-", "").replaceAll("_", ""))) {
                sourcesLayout.removeComponent(sourceLayout);
            } else {
                sourcesLayout.addComponent(sourceLayout);
            }
        });
    });

    Label placeholder = new Label();
    placeholder.setWidth("100%");

    GridLayout footer = new GridLayout(3, 1);
    footer.setSpacing(true);
    footer.setMargin(new MarginInfo(true, false, false, false));
    footer.addStyleName("menubar");
    footer.setWidth("100%");
    footer.addComponents(checkBoxSelectAll, textFieldSearch, placeholder);
    footer.setComponentAlignment(checkBoxSelectAll, Alignment.MIDDLE_LEFT);
    footer.setComponentAlignment(textFieldSearch, Alignment.MIDDLE_CENTER);

    windowLayout.addComponent(footer);
    windowLayout.setHeight("350px");
    return windowLayout;
}