Example usage for com.vaadin.ui Layout removeAllComponents

List of usage examples for com.vaadin.ui Layout removeAllComponents

Introduction

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

Prototype

public void removeAllComponents();

Source Link

Document

Removes all components from this container.

Usage

From source file:ch.bfh.due1.srs.views.ReservationView.java

License:Open Source License

public ReservationView(Navigator navigator, RoomController roomController,
        ReservationController reservationController) {
    this.roomController = roomController;
    this.reservationController = reservationController;
    // setSizeFull();
    addComponent(this.tabsheet);
    // Button button = new Button("Go to Room List View", new
    // Button.ClickListener() {
    // @Override//from  www.j av  a 2s  .c  om
    // public void buttonClick(ClickEvent event) {
    // navigator.navigateTo(RoomListView.VIEWNAME);
    // }
    // });
    // addComponent(button);
    // setComponentAlignment(button, Alignment.MIDDLE_CENTER);
    this.tabsheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() {
        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            // Find the tab sheet
            TabSheet tabsheet = event.getTabSheet();

            // Find the tab (it's a layout)
            Layout tab = (Layout) tabsheet.getSelectedTab();

            // Get the tab caption from the tab object
            String roomName = tabsheet.getTab(tab).getCaption();

            // Fill the tab content
            tab.removeAllComponents();
            // Create table for selected room
            table = createTimeSlotTable(roomName);
            tab.addComponent(table);
        }
    });

}

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

private void refreshProfiles(Group g, Layout layoutProfiles) {
    layoutProfiles.removeAllComponents();
    GroupUtils.getAllInterestProfiles(g, UserUtils.getCurrent()).forEach((p, enabled) -> {
        HorizontalLayout layoutProfile = new HorizontalLayout();
        layoutProfile.setWidth("100%");

        CheckBox checkBoxEnabled = new CheckBox();
        checkBoxEnabled.setValue(enabled);
        checkBoxEnabled.addValueChangeListener(v -> {
            GroupInterestProfileUtils.changeEnabled(p, UserUtils.getCurrent(), v.getValue());
            refreshAll(g);/*w w w.ja  va  2 s .c o m*/
        });

        long subscribers = p.getEnabledUsers().values().stream().filter(v -> v).count();
        Label labelProfileInfo = new Label();
        Language.setCustom(Word.SUBSCRIBERS, s -> {
            String info = p.getName() + " (" + subscribers + " ";
            info += subscribers == 1 ? Language.get(Word.SUBSCRIBER) + ")"
                    : Language.get(Word.SUBSCRIBERS) + ")";
            labelProfileInfo.setValue(info);
        });

        boolean isAdmin = g.getUsers().getOrDefault(UserUtils.getCurrent(), false);

        Button buttonOpen = new Button(VaadinIcons.EXTERNAL_LINK);
        buttonOpen.addClickListener(ce -> {
            UI.getCurrent().addWindow(GroupProfileWindow.show(p, isAdmin, () -> {
            }));
        });

        if (isAdmin) {
            Button buttonRemove = new Button(VaadinIcons.MINUS);
            buttonRemove.addStyleName(ValoTheme.BUTTON_DANGER);
            buttonRemove.addClickListener(ce -> {
                ConfirmationDialog.show(
                        Language.get(Word.REALLY_DELETE_PROFILE).replace("[PROFILE]", p.getName()), () -> {
                            GroupInterestProfileUtils.delete(p);
                            refreshAll(g);
                        });
            });

            layoutProfile.addComponents(checkBoxEnabled, labelProfileInfo, buttonOpen, buttonRemove);
        } else {
            layoutProfile.addComponents(checkBoxEnabled, labelProfileInfo, buttonOpen);
        }

        layoutProfile.setExpandRatio(labelProfileInfo, 5);
        layoutProfile.setComponentAlignment(checkBoxEnabled, Alignment.MIDDLE_CENTER);
        layoutProfile.setComponentAlignment(labelProfileInfo, Alignment.MIDDLE_LEFT);

        layoutProfiles.addComponent(layoutProfile);
    });
}

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

public void refreshMembers(Group g, Layout layoutMembers) {
    layoutMembers.removeAllComponents();
    Map<User, Boolean> allMembers = GroupUtils.getAllMembers(g);
    boolean isAdmin = GroupUtils.isAdmin(g, UserUtils.getCurrent());
    if (!isAdmin) {
        if (allMembers.size() < 2) {
            buttonLeave.setVisible(false);
        } else {// ww  w  .  j a va 2s.c o m
            buttonLeave.setVisible(true);
        }
    } else {
        if (allMembers.entrySet().stream().map(e -> e.getValue()).filter(b -> b == true).count() > 1) {
            buttonLeave.setVisible(true);
        } else {
            buttonLeave.setVisible(false);
        }
    }
    allMembers.forEach((u, admin) -> {
        HorizontalLayout layoutMember = new HorizontalLayout();
        layoutMember.setWidth("100%");

        VaadinIcons iconRole = admin ? VaadinIcons.KEY : VaadinIcons.USER;
        Label labelMemberName = new Label(iconRole.getHtml() + " " + u.getUsername(), ContentMode.HTML);
        //labelMemberName.setWidth("50%");

        layoutMember.addComponents(labelMemberName);
        layoutMember.setComponentAlignment(labelMemberName, Alignment.MIDDLE_LEFT);
        layoutMember.setExpandRatio(labelMemberName, 5);
        if (isAdmin) {
            if (g.getUsers().size() > 1) {
                Button buttonChangeRole = new Button(admin ? VaadinIcons.ARROW_DOWN : VaadinIcons.ARROW_UP);
                buttonChangeRole.addClickListener(ce -> {
                    if (g.getUsers().get(u)) {//Downgrade
                        long amountAdmins = g.getUsers().entrySet().stream().filter(e -> e.getValue()).count();
                        if (amountAdmins > 1) {
                            if (UserUtils.getCurrent() == u) {
                                ConfirmationDialog.show(Language.get(Word.REALLY_DEADMIN_YOURSELF), () -> {
                                    GroupUtils.makeNormalMember(g, u);
                                    refreshAll(g);
                                });
                            } else {
                                GroupUtils.makeNormalMember(g, u);
                                refreshAll(g);
                            }
                        } else {
                            VaadinUtils.errorNotification(Language.get(Word.NOT_ENOUGH_ADMINS_IN_GROUP));
                            buttonLeave.setVisible(false);
                        }
                    } else {//Upgrade
                        GroupUtils.makeAdmin(g, u);
                        refreshAll(g);
                    }
                });
                layoutMember.addComponent(buttonChangeRole);

                if (g.getUsers().values().stream().filter(v -> v).count() > 1 || !GroupUtils.isAdmin(g, u)) {
                    Button buttonRemoveUser = new Button(VaadinIcons.MINUS);
                    buttonRemoveUser.addStyleName(ValoTheme.BUTTON_DANGER);
                    buttonRemoveUser.addClickListener(ce -> {
                        ConfirmationDialog.show(
                                Language.get(Word.REALLY_REMOVE_USER_FROM_GROUP)
                                        .replace("[USER]", u.getUsername()).replace("[GROUP]", g.getName()),
                                () -> {
                                    GroupUtils.removeUser(g, u);
                                    refreshAll(g);
                                });
                    });
                    layoutMember.addComponents(buttonRemoveUser);
                }
            }
        }
        layoutMembers.addComponent(layoutMember);
    });
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.ValidationManagerUI.java

License:Apache License

public void setTabContent(Tab target, Component content, String permission) {
    Component c = target.getComponent();
    if (c != null && c instanceof Layout) {
        Layout l = (Layout) c;
        l.removeAllComponents();
        if (content != null) {
            l.addComponent(content);//from   ww  w . ja v a2  s .  c om
        }
    } else {
        LOG.log(Level.SEVERE, "Invalid target: {0}", target);
    }
    if (permission != null && !permission.isEmpty()) {
        //Hide tab based on permissions
        boolean viewable = checkRight(permission);
        if (viewable != target.isVisible()) {
            target.setVisible(viewable);
        }
    }
    tabSheet.setSelectedTab(target);
}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.FeedInfoBox.java

License:Open Source License

private void renderContentPanel(Layout layout, Project project, String userId,
        HashMap<String, SourceDetails> sourceFilter) {
    layout.removeAllComponents();
    renderSourceFilters(layout, project, userId, sourceFilter);
    renderSubscribeLink(layout, project);
    renderTimelineContent(layout, project, userId, sourceFilter);
}