Example usage for com.vaadin.ui Panel setContent

List of usage examples for com.vaadin.ui Panel setContent

Introduction

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

Prototype

@Override
public void setContent(Component content) 

Source Link

Document

Sets the content of this container.

Usage

From source file:cz.zcu.pia.social.network.frontend.components.posts.ComponentPost.java

/**
 * Adds click listeners to the buttons/*from   www .  jav a 2s  .co  m*/
 */
private void addClickListeners() {
    this.likes.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Post post = componentPostService.updateLikeRating(postId);
            numberOfLikes = post.getLikeCount();
            numberOfDisagrees = post.getHateCount();
            updateHateLike();

        }
    });
    this.disagrees.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Post post = componentPostService.updateDisagreeRating(postId);

            numberOfLikes = post.getLikeCount();
            numberOfDisagrees = post.getHateCount();
            updateHateLike();
        }
    });
    this.tags.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window subWindow = new Window(msgs.getMessage("post.tags"));

            subWindow.setModal(true);
            subWindow.center();
            subWindow.setWidth(400, Unit.PIXELS);
            subWindow.setHeight(110, Unit.PIXELS);
            subWindow.setResizable(false);
            Panel panel = new Panel();

            panel.setSizeFull();
            HorizontalLayout tagsWrapper = new HorizontalLayout();
            tagsWrapper.setStyleName("margin-left-big");
            panel.setContent(tagsWrapper);
            tagsWrapper.setSpacing(true);
            tagsWrapper.setMargin(true);
            tagsWrapper.setSizeUndefined();

            for (Tag t : postService.getPostTags(postId)) {
                CustomLayout tag = new CustomLayout("tag");
                Button tagLabel = new Button(t.getTagName());
                tag.addComponent(tagLabel, "button");

                tagsWrapper.addComponent(tag);
            }

            subWindow.setContent(panel);
            UI.getCurrent().addWindow(subWindow);
        }
    });
    this.comments.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window subWindow = new Window(msgs.getMessage("post.comments"));

            subWindow.setModal(true);
            subWindow.center();
            subWindow.setWidth(400, Unit.PIXELS);
            subWindow.setHeight(600, Unit.PIXELS);
            subWindow.setResizable(true);

            ComponentPostComments componentPostComments = applicationContext
                    .getBean(ComponentPostComments.class, postId);
            subWindow.setContent(componentPostComments);
            UI.getCurrent().addWindow(subWindow);
        }
    });
    this.name.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window subWindow = new Window(msgs.getMessage("header.profile") + "- " + name.getCaption());

            subWindow.setModal(true);
            subWindow.center();
            subWindow.setWidth(400, Unit.PIXELS);
            subWindow.setHeight(350, Unit.PIXELS);
            subWindow.setResizable(true);

            Users user = postService.getPostById(postId).getUser();
            ComponentProfilePost profilePost = applicationContext.getBean(ComponentProfilePost.class, user);

            subWindow.setContent(profilePost);
            UI.getCurrent().addWindow(subWindow);
        }
    });
}

From source file:de.escidoc.admintool.view.context.ContextAddView.java

License:Open Source License

private void addAdminDescriptorField() {
    adminDescriptorAccordion = new Accordion();
    adminDescriptorAccordion.setWidth(ViewConstants.FIELD_WIDTH);
    adminDescriptorAccordion.setSizeFull();

    final Panel accordionPanel = new Panel();
    accordionPanel.setContent(adminDescriptorAccordion);
    accordionPanel.setSizeFull();//from   w w w. ja va 2  s  .c  o m
    accordionPanel.setWidth(ViewConstants.FIELD_WIDTH);

    final Button addButton = new Button(ViewConstants.ADD_LABEL);
    final Button editButton = new Button(ViewConstants.EDIT_LABEL);
    final Button delButton = new Button(ViewConstants.REMOVE_LABEL);

    addButton.setStyleName("small");
    editButton.setStyleName("small");
    delButton.setStyleName("small");

    addButton.addListener(new NewAdminDescriptorListener(mainWindow, adminDescriptorAccordion));
    editButton.addListener(new EditAdminDescriptorListener(mainWindow, adminDescriptorAccordion));
    delButton.addListener(new RemoveAdminDescriptorListener(adminDescriptorAccordion));

    panel.addComponent(LayoutHelper.create("Admin Descriptors", accordionPanel, LABEL_WIDTH + 2, 300, false,
            new Button[] { addButton, editButton, delButton }));
}

From source file:de.escidoc.admintool.view.context.ContextEditForm.java

License:Open Source License

private void addAdminDescriptor() {
    adminDescriptorAccordion = new Accordion();
    adminDescriptorAccordion.setWidth(ViewConstants.FIELD_WIDTH);
    adminDescriptorAccordion.setSizeFull();

    final Panel accordionPanel = new Panel();
    accordionPanel.setContent(adminDescriptorAccordion);
    accordionPanel.setSizeFull();// w  w  w  .j a v a  2 s.c o m
    accordionPanel.setWidth(ViewConstants.FIELD_WIDTH);

    addAdminDescButton.setStyleName(AppConstants.SMALL_BUTTON);
    editAdminDescButton.setStyleName(AppConstants.SMALL_BUTTON);
    delAdminDescButton.setStyleName(AppConstants.SMALL_BUTTON);

    addAdminDescButton.addListener(new NewAdminDescriptorListener(mainWindow, adminDescriptorAccordion));
    editAdminDescButton.addListener(new EditAdminDescriptorListener(mainWindow, adminDescriptorAccordion));
    delAdminDescButton.addListener(new RemoveAdminDescriptorListener(adminDescriptorAccordion));

    form.addComponent(LayoutHelper.create("Admin Descriptors", accordionPanel, LABEL_WIDTH, 300, false,
            new Button[] { addAdminDescButton, editAdminDescButton, delAdminDescButton }));
}

From source file:de.gedoplan.webclients.vaadin.VaadinDemoUi.java

public Panel createFooter() {
    Panel footer = new Panel();
    footer.setStyleName(ValoTheme.PANEL_WELL);
    footer.setHeight(75, Unit.PIXELS);//from   ww w  .  j  a  v  a  2 s  .co m
    Label footerText = new Label(" 2016 gedoplan.de");
    footerText.setSizeUndefined();
    VerticalLayout footerLayout = new VerticalLayout();
    footerLayout.setSizeFull();
    footerLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    footerLayout.addComponent(footerText);
    footer.setContent(footerLayout);
    return footer;
}

From source file:de.gedoplan.webclients.vaadin.views.CustomerDetailView.java

public void init() {
    Double discount = customerService.calculateCustomerDiscount(customer.getCustomerID()).getDiscount();
    Label name = new Label(new PropertyFormatter(form.getProperty(Customer_.companyName)) {
        @Override/* ww w .j  a va 2  s . c  o m*/
        public String format(Object value) {
            return value + " (" + customer.getCustomerID() + ")";
        }

        @Override
        public Object parse(String formattedValue) throws Exception {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    name.setStyleName(ValoTheme.LABEL_BOLD);
    Label rabattLabel = new Label(Messages.customer_discount.value());
    rabattLabel.setStyleName(ValoTheme.LABEL_BOLD);
    rabattLabel.setSizeUndefined();
    Label rabatt = new Label(new DecimalFormat("#0.00").format(discount) + "%");
    rabatt.setSizeUndefined();
    rabatt.addStyleName(ValoTheme.LABEL_COLORED);
    rabatt.addStyleName(ValoTheme.LABEL_BOLD);
    HorizontalLayout headline = new HorizontalLayout(name, rabattLabel, rabatt);
    headline.setComponentAlignment(rabatt, Alignment.TOP_RIGHT);
    headline.setExpandRatio(name, 1);
    headline.setWidth(100, Unit.PERCENTAGE);
    headline.setSpacing(true);
    headline.setStyleName(ValoTheme.LAYOUT_WELL);
    headline.setMargin(new MMarginInfo(false, true));
    Panel panel = new Panel();
    panel.setContent(form);
    setMargin(true);
    setSpacing(true);
    addComponents(headline, panel);
}

From source file:de.metas.ui.web.vaadin.window.components.AWindowTab.java

License:Open Source License

public AWindowTab(final TabModel tabModel) {
    super();//  w  w w  . ja va 2 s. c om
    this.tabModel = tabModel;
    setSizeFull();
    setCaption(tabModel.getName());

    toolbar = new ATabToolbar(tabModel.getToolbarModel());
    addComponent(toolbar);

    {
        formLayout = new AWindowTabFormLayout(tabModel.getWindowContext(), tabModel.getDescriptor());
        formLayout.setRow(tabModel.getCurrentRow());

        final Panel formLayoutContainer = new Panel();
        formLayoutContainer.setHeight("400px");
        formLayoutContainer.setContent(formLayout);
        addComponent(formLayoutContainer);
    }

    // final AWindowTabGridLayout gridLayout = new AWindowTabGridLayout(tabModel.getWindowContext(), tabModel.getRowsContainer());
    // addComponent(gridLayout);
}

From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.ui.Popup.java

License:Apache License

private void init() {
    this.setModal(true);
    this.setHeight(325, Unit.PIXELS);
    this.setWidth(500, Unit.PIXELS);

    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//from  w  ww  .java  2 s.  c  om
    layout.setSpacing(true);
    layout.setMargin(true);
    setContent(layout);

    Panel panel = new Panel();
    panel.setHeight(100, Unit.PERCENTAGE);
    panel.addStyleName(Runo.PANEL_LIGHT);
    layout.addComponent(panel);
    layout.setExpandRatio(panel, 1);

    messageLabel = new Label();
    panel.setContent(messageLabel);

    Button close = new Button("Beenden", new Button.ClickListener() {
        private static final long serialVersionUID = -8385641161488292715L;

        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(Popup.this);
        }
    });

    layout.addComponent(close);
    layout.setComponentAlignment(close, Alignment.BOTTOM_RIGHT);
}

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

private Component getProfiles(Group g) {
    VerticalLayout layoutRootProfiles = new VerticalLayout();
    layoutRootProfiles.setMargin(false);
    layoutRootProfiles.setWidth("100%");
    Panel panelProfiles = new Panel(Language.get(Word.PROFILES));
    Language.setCustom(Word.PROFILES, s -> panelProfiles.setCaption(s));
    panelProfiles.setWidth("100%");
    panelProfiles.setHeight("200px");

    VerticalLayout layoutProfiles = new VerticalLayout();
    mapLayoutProfiles.put(g, layoutProfiles);
    layoutProfiles.setWidth("100%");

    refreshProfiles(g, layoutProfiles);//  w ww  .j  av  a2s. c  o m

    panelProfiles.setContent(layoutProfiles);
    layoutRootProfiles.addComponent(panelProfiles);

    if (GroupUtils.isAdmin(g, UserUtils.getCurrent())) {
        CssLayout addProfileGroup = new CssLayout();
        addProfileGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
        addProfileGroup.setWidth("100%");

        TextField textFieldAddProfile = new TextField();
        Language.setCustom(Word.PROFILE_NAME, s -> textFieldAddProfile.setPlaceholder(s));
        textFieldAddProfile.setMaxLength(255);
        textFieldAddProfile.setWidth("35%");
        addProfileGroup.addComponent(textFieldAddProfile);

        Button buttonAddProfile = new Button();
        buttonAddProfile.setIcon(VaadinIcons.PLUS);
        buttonAddProfile.addStyleName(ValoTheme.BUTTON_PRIMARY);
        buttonAddProfile.setWidth("15%");
        buttonAddProfile.addClickListener(e -> {
            try {
                String name = textFieldAddProfile.getValue();
                textFieldAddProfile.clear();
                Runnable onClose = () -> refreshAll(g);
                UI.getCurrent().addWindow(GroupProfileWindow.create(g, name, true, onClose));
            } catch (UserNotFoundException ex) {
                VaadinUtils.errorNotification(Language.get(Word.USER_NOT_FOUND));
            }
        });
        addProfileGroup.addComponent(buttonAddProfile);

        layoutRootProfiles.addComponent(addProfileGroup);
    }
    return layoutRootProfiles;
}

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

private Component getMembers(Group g) {
    VerticalLayout layoutRootMembers = new VerticalLayout();
    layoutRootMembers.setMargin(false);/*from  w  ww  .  ja v  a 2 s .  com*/
    layoutRootMembers.setWidth("100%");
    Panel panelMembers = new Panel(Language.get(Word.MEMBERS));
    Language.setCustom(Word.MEMBERS, s -> panelMembers.setCaption(s));
    panelMembers.setWidth("100%");
    panelMembers.setHeight("200px");

    VerticalLayout layoutMembers = new VerticalLayout();
    mapLayoutMembers.put(g, layoutMembers);
    layoutMembers.setWidth("100%");

    refreshMembers(g, layoutMembers);

    panelMembers.setContent(layoutMembers);
    layoutRootMembers.addComponent(panelMembers);

    if (GroupUtils.isAdmin(g, UserUtils.getCurrent())) {
        CssLayout addUserGroup = new CssLayout();
        addUserGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
        addUserGroup.setWidth("100%");

        TextField textFieldaddUser = new TextField();
        Language.setCustom(Word.USERNAME, s -> textFieldaddUser.setPlaceholder(s));
        textFieldaddUser.setMaxLength(255);
        textFieldaddUser.setWidth("70%");
        addUserGroup.addComponent(textFieldaddUser);

        Button buttonAddUser = new Button();
        buttonAddUser.setIcon(VaadinIcons.PLUS);
        buttonAddUser.addStyleName(ValoTheme.BUTTON_PRIMARY);
        buttonAddUser.setWidth("30%");
        buttonAddUser.addClickListener(e -> {
            try {
                User u = UserUtils.getUser(textFieldaddUser.getValue());
                textFieldaddUser.clear();
                GroupUtils.addUser(g, u);
                refreshAll(g);
            } catch (UserNotFoundException ex) {
                VaadinUtils.errorNotification(Language.get(Word.USER_NOT_FOUND));
            }
        });
        addUserGroup.addComponent(buttonAddUser);

        layoutRootMembers.addComponent(addUserGroup);
    }

    return layoutRootMembers;
}

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());
                });//  w ww . j  a va2s .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;
}