Example usage for com.vaadin.ui VerticalLayout removeAllComponents

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

Introduction

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

Prototype

@Override
public void removeAllComponents() 

Source Link

Document

Removes all components from the container.

Usage

From source file:com.hack23.cia.web.impl.ui.application.views.user.document.pagemode.SearchDocumentPageModContentFactoryImpl.java

License:Apache License

@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override//from www.  j  a v  a 2s  .c o m
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout panelContent = createPanelContent();

    final String pageId = getPageId(parameters);

    getMenuItemFactory().createMainPageMenuBar(menuBar);

    final VerticalLayout searchLayout = new VerticalLayout();
    searchLayout.setSizeFull();
    panelContent.addComponent(searchLayout);

    final VerticalLayout searchresultLayout = new VerticalLayout();
    searchresultLayout.setSizeFull();

    final Panel formPanel = new Panel();
    formPanel.setSizeFull();

    searchresultLayout.addComponent(formPanel);

    final FormLayout formContent = new FormLayout();
    formPanel.setContent(formContent);

    panelContent.addComponent(searchresultLayout);

    final SearchDocumentRequest searchRequest = new SearchDocumentRequest();
    searchRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
    searchRequest.setMaxResults(MAX_RESULT_SIZE);
    searchRequest.setSearchExpression("");
    final SearchDocumentResponseHandler handler = new SearchDocumentResponseHandler() {

        /** The Constant serialVersionUID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void handle(final SearchDocumentResponse response) {
            searchresultLayout.removeAllComponents();

            final BeanItemContainer<DocumentElement> documentActivityDataDataDataSource = new BeanItemContainer<>(
                    DocumentElement.class, response.getResultElement());

            getGridFactory().createBasicBeanItemGrid(searchresultLayout, documentActivityDataDataDataSource,
                    "Document",
                    new String[] { "rm", "createdDate", "madePublicDate", "documentType", "subType", "title",
                            "subTitle", "status" },
                    new String[] { "label", "id", "hit", "relatedId", "org", "tempLabel", "numberValue",
                            "systemDate", "kallId", "documentFormat", "documentUrlText", "documentUrlHtml",
                            "documentStatusUrlXml", "committeeReportUrlXml" },
                    null, null, null);

        }
    };
    final ClickListener searchListener = new SearchDocumentClickListener(searchRequest, getApplicationManager(),
            handler);
    getFormFactory().addRequestInputFormFields(formContent, new BeanItem<>(searchRequest),
            SearchDocumentRequest.class, Arrays.asList(new String[] { "searchExpression" }), "Search",
            searchListener);

    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENT_VIEW, ApplicationEventGroup.USER, NAME,
            parameters, pageId);

    return panelContent;

}

From source file:com.haulmont.cuba.web.WebWindowManager.java

License:Apache License

protected Layout createNewTabLayout(final Window window, final boolean multipleOpen,
        WindowBreadCrumbs breadCrumbs, Component... additionalComponents) {
    Layout layout = new CssLayout();
    layout.setPrimaryStyleName("c-app-window-wrap");
    layout.setSizeFull();/*w w w  .  ja v  a 2  s.c  o  m*/

    layout.addComponent(breadCrumbs);
    if (additionalComponents != null) {
        for (final Component c : additionalComponents) {
            layout.addComponent(c);
        }
    }

    final Component component = WebComponentsHelper.getComposition(window);
    component.setSizeFull();
    layout.addComponent(component);

    WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window));

    if (workArea.getMode() == Mode.TABBED) {
        layout.addStyleName("c-app-tabbed-window");
        TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();

        String tabId;
        Integer hashCode = getWindowHashCode(window);
        ComponentContainer tab = null;
        if (hashCode != null) {
            tab = findTab(hashCode);
        }
        if (tab != null && !multipleOpen) {
            tabSheet.replaceComponent(tab, layout);
            tabSheet.removeComponent(tab);
            tabs.put(layout, breadCrumbs);
            tabId = tabSheet.getTab(layout);
        } else {
            tabs.put(layout, breadCrumbs);

            tabId = "tab_" + uuidSource.createUuid();

            tabSheet.addTab(layout, tabId);

            if (ui.isTestMode()) {
                String id = "tab_" + window.getId();

                tabSheet.setTabTestId(tabId, ui.getTestIdManager().getTestId(id));
                tabSheet.setTabCubaId(tabId, id);
            }
        }
        String windowContentSwitchMode = window.getContentSwitchMode().name();
        ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(windowContentSwitchMode);
        tabSheet.setContentSwitchMode(tabId, contentSwitchMode);

        String formattedCaption = formatTabCaption(window.getCaption(), window.getDescription());
        tabSheet.setTabCaption(tabId, formattedCaption);
        String formattedDescription = formatTabDescription(window.getCaption(), window.getDescription());
        if (!Objects.equals(formattedCaption, formattedDescription)) {
            tabSheet.setTabDescription(tabId, formattedDescription);
        } else {
            tabSheet.setTabDescription(tabId, null);
        }

        tabSheet.setTabIcon(tabId, WebComponentsHelper.getIcon(window.getIcon()));
        tabSheet.setTabClosable(tabId, true);
        tabSheet.setTabCloseHandler(layout, (targetTabSheet, tabContent) -> {
            //noinspection SuspiciousMethodCalls
            WindowBreadCrumbs breadCrumbs1 = tabs.get(tabContent);

            if (!canWindowBeClosed(breadCrumbs1.getCurrentWindow())) {
                return;
            }

            Runnable closeTask = new TabCloseTask(breadCrumbs1);
            closeTask.run();

            // it is needed to force redraw tabsheet if it has a lot of tabs and part of them are hidden
            targetTabSheet.markAsDirty();
        });
        tabSheet.setSelectedTab(layout);
    } else {
        tabs.put(layout, breadCrumbs);
        layout.addStyleName("c-app-single-window");

        VerticalLayout mainLayout = workArea.getSingleWindowContainer();
        mainLayout.removeAllComponents();
        mainLayout.addComponent(layout);
    }

    return layout;
}

From source file:com.jiangyifen.ec2.ui.mgr.system.tabsheet.SystemLicence.java

/**
 * added by chb 20140520//from   w ww  .  j  ava 2  s  .  co  m
 * @return
 */
private VerticalLayout updateLicenseComponent() {
    VerticalLayout licenseUpdateLayout = new VerticalLayout();
    final VerticalLayout textAreaPlaceHolder = new VerticalLayout();
    final HorizontalLayout buttonPlaceHolder = new HorizontalLayout();
    buttonPlaceHolder.setSpacing(true);

    //
    final Button updateButton = new Button("License");
    updateButton.setData("show");

    //
    final Button cancelButton = new Button("?");

    //
    final TextArea licenseTextArea = new TextArea();
    licenseTextArea.setColumns(30);
    licenseTextArea.setRows(5);
    licenseTextArea.setWordwrap(true);
    licenseTextArea.setInputPrompt("??");

    //Layout
    buttonPlaceHolder.addComponent(updateButton);
    licenseUpdateLayout.addComponent(textAreaPlaceHolder);
    licenseUpdateLayout.addComponent(buttonPlaceHolder);

    //
    cancelButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            textAreaPlaceHolder.removeAllComponents();
            buttonPlaceHolder.removeComponent(cancelButton);
            updateButton.setData("show");
            updateButton.setCaption("License");
        }
    });

    updateButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (((String) event.getButton().getData()).equals("show")) {
                textAreaPlaceHolder.removeAllComponents();
                textAreaPlaceHolder.addComponent(licenseTextArea);
                buttonPlaceHolder.addComponent(cancelButton);
                event.getButton().setData("updateAndHide");
                event.getButton().setCaption("??");
            } else if (((String) event.getButton().getData()).equals("updateAndHide")) {
                StringReader stringReader = new StringReader(
                        StringUtils.trimToEmpty((String) licenseTextArea.getValue()));
                Properties props = new Properties();
                try {
                    props.load(stringReader);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                stringReader.close();
                //               Boolean isValidvalidateLicense(licenseTextArea.getValue());
                String license_date = props.getProperty(LicenseManager.LICENSE_DATE);
                String license_count = props.getProperty(LicenseManager.LICENSE_COUNT);
                String license_localmd5 = props.getProperty(LicenseManager.LICENSE_LOCALMD5);
                //
                Boolean isMatch = regexMatchCheck(license_date, license_count, license_localmd5);
                if (isMatch) {

                    Map<String, String> licenseMap = new HashMap<String, String>();
                    //??
                    //                  String license_count = (String)props.get(LicenseManager.LICENSE_COUNT);
                    license_count = license_count == null ? "" : license_count;
                    licenseMap.put(LicenseManager.LICENSE_COUNT, license_count);

                    //?
                    //                  String license_date = (String)props.get(LicenseManager.LICENSE_DATE);
                    license_date = license_date == null ? "" : license_date;
                    licenseMap.put(LicenseManager.LICENSE_DATE, license_date);

                    //???
                    //                  String license_localmd5 = (String)props.get(LicenseManager.LICENSE_LOCALMD5);
                    license_localmd5 = license_localmd5 == null ? "" : license_localmd5;
                    licenseMap.put(LicenseManager.LICENSE_LOCALMD5, license_localmd5);

                    //?License
                    Map<String, String> resultMap = LicenseManager.licenseValidate(licenseMap);

                    String validateResult = resultMap.get(LicenseManager.LICENSE_VALIDATE_RESULT);
                    if (LicenseManager.LICENSE_VALID.equals(validateResult)) {
                        //continue
                    } else {
                        NotificationUtil.showWarningNotification(SystemLicence.this,
                                "License ?License");
                        return;
                    }

                    try {
                        URL resourceurl = SystemLicence.class.getResource(LicenseManager.LICENSE_FILE);
                        //System.err.println("chb: SystemLicense"+resourceurl.getPath());
                        OutputStream fos = new FileOutputStream(resourceurl.getPath());
                        props.store(fos, "license");
                    } catch (Exception e) {
                        e.printStackTrace();
                        NotificationUtil.showWarningNotification(SystemLicence.this, "License ");
                        return;
                    }
                    textAreaPlaceHolder.removeAllComponents();
                    buttonPlaceHolder.removeComponent(cancelButton);
                    updateButton.setData("show");
                    updateButton.setCaption("License");
                    LicenseManager.loadLicenseFile(LicenseManager.LICENSE_FILE.substring(1));
                    //                  LicenseManager.loadLicenseFile(licenseFilename)
                    refreshLicenseInfo();
                    NotificationUtil.showWarningNotification(SystemLicence.this,
                            "License ?,?");
                } else {
                    NotificationUtil.showWarningNotification(SystemLicence.this,
                            "License ??");
                }
            }
        }

        /**
         * license ?
         * @param license_date
         * @param license_count
         * @param license_localmd5
         * @return
         */
        private Boolean regexMatchCheck(String license_date, String license_count, String license_localmd5) {
            if (StringUtils.isEmpty(license_date) || StringUtils.isEmpty(license_count)
                    || StringUtils.isEmpty(license_localmd5)) {
                return false;
            }
            String date_regex = "^\\d{4}-\\d{2}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2}$"; //?
            String count_regex = "^\\d+$"; //?
            String md5_32_regex = "^\\w{32}$"; //?
            return license_localmd5.matches(md5_32_regex) && license_date.matches(date_regex)
                    && license_count.matches(count_regex);
        }
    });

    return licenseUpdateLayout;
}

From source file:com.mycollab.module.crm.view.SalesDashboardView.java

License:Open Source License

void displayReport() {
    final String reportName = this.reportDashboard[this.currentReportIndex];

    final VerticalLayout bodyContent = (VerticalLayout) this.bodyContent;
    bodyContent.removeAllComponents();
    bodyContent.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    if ("OpportunitySalesStage".equals(reportName)) {
        this.setTitle(UserUIContext.getMessage(OpportunityI18nEnum.OPT_SALES_STAGE));
        OpportunitySalesStageDashboard salesStageDashboard = new OpportunitySalesStageDashboard();
        bodyContent.addComponent(salesStageDashboard);

        final OpportunitySearchCriteria criteria = new OpportunitySearchCriteria();
        criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
        salesStageDashboard.displayChart(criteria);
    } else if ("OpportunityLeadSource".equals(reportName)) {
        this.setTitle(UserUIContext.getMessage(OpportunityI18nEnum.OPT_LEAD_SOURCES));
        OpportunityLeadSourceDashboard leadSourceDashboard = new OpportunityLeadSourceDashboard();
        bodyContent.addComponent(leadSourceDashboard);

        final OpportunitySearchCriteria criteria = new OpportunitySearchCriteria();
        criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
        leadSourceDashboard.displayChart(criteria);
    }//from   ww  w.j  a v  a  2s  .c o m
}

From source file:com.mycompany.filmupo.Graficos.java

/**
 * Metodo de inicializacion de la clase//from w  w w .  ja v  a2  s  .  c  o  m
 *
 * @param vaadinRequest VaadinRequest
 */
@Override
protected void init(VaadinRequest vaadinRequest) {
    try {

        HorizontalLayout v2h2 = new HorizontalLayout();
        v2h2.setMargin(true);

        final VerticalLayout v2h1 = new VerticalLayout();
        v2h1.setMargin(true);

        final VerticalSplitPanel v2 = new VerticalSplitPanel();
        v2.addComponent(v2h2);
        v2.addComponent(v2h1);
        v2.setSplitPosition(22, Unit.PERCENTAGE);
        v2.setLocked(true);

        VerticalLayout v1 = new VerticalLayout();
        v1.setMargin(true);

        HorizontalSplitPanel layout = new HorizontalSplitPanel();
        layout.addComponent(v1);
        layout.addComponent(v2);
        layout.setSplitPosition(28, Unit.PERCENTAGE);

        setContent(layout);

        //Creamos los 3 links de navegacion de la aplicacion y loa aadimos al layout declarado al principio del codigo
        Link pri = new Link("Principal", new ExternalResource("/Principal"));
        Link est = new Link("Graficos", new ExternalResource("/Graficos"));
        Link adm = new Link("Administracin", new ExternalResource("/Admin"));
        v2h2.addComponent(pri);
        v2h2.addComponent(new Label(" / "));
        v2h2.addComponent(est);
        v2h2.addComponent(new Label(" / "));
        v2h2.addComponent(adm);

        final DAO dao = new DAO();
        dao.abrirConexion();

        final List<Pelicula> listaPeliculas = dao.consultarPeliculas();
        final List<Director> listaDirectores = dao.consultarDirectores();
        final List<Actor> listaActores = dao.consultarActores();

        //Creamos un unico arbol que contiene el acceso a las 4 graficas que hemos creado:
        //  - Peliculas segun su duracion
        //  - Peliculas segun su genero
        //  - Numero de peliculas segun actor
        //  - Numero de peliculas segun director
        Tree tree = new Tree("");
        String a = "Estadisticas";
        tree.addItem(a);
        String aa = "Peliculas segn su duracin";
        tree.addItem(aa);
        tree.setParent(aa, a);
        tree.setChildrenAllowed(aa, false);
        String ab = "Peliculas segn su gnero";
        tree.addItem(ab);
        tree.setParent(ab, a);
        tree.setChildrenAllowed(ab, false);
        String ac = "Numero de peliculas segn actor";
        tree.addItem(ac);
        tree.setParent(ac, a);
        tree.setChildrenAllowed(ac, false);
        String ad = "Numero de peliculas segn director";
        tree.addItem(ad);
        tree.setParent(ad, a);
        tree.setChildrenAllowed(ad, false);

        tree.setSelectable(true);
        tree.addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                v2h1.removeAllComponents();
                //Grafica de las peliculas segun su duracion
                if (event.getProperty().getValue().toString().contains("duracin")) {
                    Chart chart = new Chart(ChartType.PIE);
                    Configuration conf = chart.getConfiguration();
                    conf.setTitle("Peliculas");
                    conf.setSubTitle("Segn su duracin en minutos");

                    PlotOptionsPie options = new PlotOptionsPie();
                    options.setInnerSize(0);
                    options.setSize("75%");
                    options.setCenter("50%", "50%");
                    conf.setPlotOptions(options);

                    DataSeries series = new DataSeries();
                    for (Pelicula p : listaPeliculas) {
                        series.add(new DataSeriesItem(p.getTitulo(), p.getDuracion()));
                    }
                    conf.addSeries(series);
                    v2h1.addComponent(chart);
                    //Grafica de las peliculas segun su genero
                } else if (event.getProperty().getValue().toString().contains("gnero")) {
                    Chart chart = new Chart(ChartType.COLUMN);
                    chart.setWidth("400px");
                    chart.setHeight("300px");
                    Configuration conf = chart.getConfiguration();
                    conf.setTitle("Peliculas");
                    conf.setSubTitle("Agrupadas segn su gnero");

                    PlotOptionsLine plotOptions = new PlotOptionsLine();
                    plotOptions.setMarker(new Marker(false));
                    conf.setPlotOptions(plotOptions);

                    ListSeries series = new ListSeries("Numero de peliculas");
                    int i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0;
                    try {
                        dao.abrirConexion();
                        i1 = dao.numGeneros("Accin");
                        i2 = dao.numGeneros("Ciencia Ficcin");
                        i3 = dao.numGeneros("Drama");
                        i4 = dao.numGeneros("Romance");
                        i5 = dao.numGeneros("Novela de Suspense");
                    } catch (IllegalAccessException ex) {
                        Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (SQLException ex) {
                        Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (InstantiationException ex) {
                        Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    series.addData(i1);
                    series.addData(i2);
                    series.addData(i3);
                    series.addData(i4);
                    series.addData(i5);

                    conf.addSeries(series);

                    XAxis xaxis = new XAxis();
                    xaxis.setTitle("Gnero");
                    xaxis.setCategories("Accin", "Ciencia Ficcin", "Drama", "Romance",
                            "Novela de suspense");
                    conf.addxAxis(xaxis);

                    YAxis yayis = new YAxis();
                    yayis.setTitle("Nmero de peliculas");
                    conf.addyAxis(yayis);

                    v2h1.addComponent(chart);

                    //Grafica de las peliculas segun actor
                } else if (event.getProperty().getValue().toString().contains("actor")) {
                    Chart chart = new Chart(ChartType.PIE);
                    Configuration conf = chart.getConfiguration();
                    conf.setTitle("Actores");
                    conf.setSubTitle("Nmero de peliculas que tienen");

                    PlotOptionsPie options = new PlotOptionsPie();
                    options.setInnerSize(0);
                    options.setSize("75%");
                    options.setCenter("50%", "50%");
                    conf.setPlotOptions(options);

                    DataSeries series = new DataSeries();
                    for (Actor a : listaActores) {
                        int i = 0;
                        try {
                            dao.abrirConexion();
                            i = dao.numPeliculasA(a.getIdActor());
                        } catch (InstantiationException ex) {
                            Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (IllegalAccessException ex) {
                            Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (SQLException ex) {
                            Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        series.add(new DataSeriesItem(a.getNombreCompleto(), i));
                    }
                    conf.addSeries(series);

                    v2h1.addComponent(chart);

                    //Grafica del numero de peliculas segun director
                } else if (event.getProperty().getValue().toString().contains("director")) {
                    Chart chart = new Chart(ChartType.PIE);
                    Configuration conf = chart.getConfiguration();
                    conf.setTitle("Directores");
                    conf.setSubTitle("Nmero de peliculas que tienen");

                    PlotOptionsPie options = new PlotOptionsPie();
                    options.setInnerSize(0);
                    options.setSize("75%");
                    options.setCenter("50%", "50%");
                    conf.setPlotOptions(options);

                    DataSeries series = new DataSeries();
                    for (Director d : listaDirectores) {
                        int i = 0;
                        try {
                            dao.abrirConexion();
                            i = dao.numPeliculasD(d.getIdDirector());
                        } catch (InstantiationException ex) {
                            Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (IllegalAccessException ex) {
                            Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (SQLException ex) {
                            Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        series.add(new DataSeriesItem(d.getNombreCompleto(), i));
                    }
                    conf.addSeries(series);

                    v2h1.addComponent(chart);
                }
            }
        });

        v1.addComponent(tree);

        dao.cerrarConexion();
    } catch (SQLException ex) {
        Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.rdonasco.security.application.views.ApplicationListPanelView.java

License:Apache License

@Override
public void initWidget() throws WidgetInitalizeException {
    getAddButton().setCaption(I18NResource.localize("Add new"));
    getAddButton().setDescription(I18NResource.localize("Add new application"));
    getAddButton().setIcon(new ThemeResource(SecurityDefaultTheme.ICON_16x16_ADD));
    getAddButton().setWidth(100, UNITS_PERCENTAGE);
    getAddButton().addStyleName(SecurityDefaultTheme.CSS_SMALL);
    getRefreshButton().setCaption(I18NResource.localize("Refresh"));
    getRefreshButton().setIcon(new ThemeResource(SecurityDefaultTheme.ICON_16x16_REFRESH));
    getRefreshButton().addStyleName(SecurityDefaultTheme.CSS_SMALL);
    VerticalLayout content = ((VerticalLayout) getContent());
    content.setMargin(true);//ww w.  j  a  v a 2s  .  c  om
    content.setHeight(600, UNITS_PIXELS);
    content.removeAllComponents();
    if (null != getDataViewListTable()) {
        getDataViewListTable().setSizeFull();
        HorizontalLayout buttonLayout = new HorizontalLayout();
        buttonLayout.setSpacing(true);
        buttonLayout.setWidth(100F, UNITS_PERCENTAGE);
        buttonLayout.addComponent(getAddButton());
        buttonLayout.addComponent(getRefreshButton());
        buttonLayout.setExpandRatio(getAddButton(), 1);
        content.addComponent(buttonLayout);
        content.addComponent(getDataViewListTable());
        content.setExpandRatio(getDataViewListTable(), 1);
        content.setSpacing(true);
    }
}

From source file:com.rdonasco.security.group.views.GroupListPanelView.java

License:Apache License

@Override
public void initWidget() throws WidgetInitalizeException {
    setCaption(I18NResource.localize("Groups"));
    setStyleName(SecurityDefaultTheme.CSS_PANEL_BUBBLE);
    VerticalLayout content = (VerticalLayout) getContent();
    content.setMargin(true);//  w  w w . j  a  v  a2s .c  o  m
    content.setHeight(600, UNITS_PIXELS);
    content.removeAllComponents();
    getGroupListTable().setSizeFull();
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth(100F, UNITS_PERCENTAGE);
    buttonLayout.addComponent(getAddGroupButton());
    buttonLayout.addComponent(getRefreshButton());
    buttonLayout.setExpandRatio(getAddGroupButton(), 1);
    content.addComponent(buttonLayout);

    content.addComponent(getGroupListTable());
    content.setExpandRatio(getGroupListTable(), 1);
    content.setSpacing(true);

}

From source file:com.rdonasco.security.role.views.RoleListPanelView.java

License:Apache License

@Override
public void initWidget() throws WidgetInitalizeException {
    setCaption(I18NResource.localize("Roles"));
    setStyleName(SecurityDefaultTheme.CSS_PANEL_BUBBLE);
    VerticalLayout content = (VerticalLayout) getContent();
    content.setMargin(true);/* w  w  w. ja v a2 s.c  o  m*/
    content.setHeight(600, UNITS_PIXELS);
    content.removeAllComponents();
    getRoleListTable().setSizeFull();
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setWidth(100F, UNITS_PERCENTAGE);
    buttonLayout.addComponent(addRoleButton);
    buttonLayout.addComponent(refreshButton);
    buttonLayout.setExpandRatio(addRoleButton, 1);
    content.addComponent(buttonLayout);
    content.addComponent(getRoleListTable());
    content.setExpandRatio(getRoleListTable(), 1);
    content.setSpacing(true);
}

From source file:com.rdonasco.security.user.views.UserListPanelView.java

License:Apache License

@Override
public void initWidget() throws WidgetInitalizeException {
    getAddUserButton().setCaption(I18NResource.localize("Add new user"));
    getAddUserButton().setIcon(new ThemeResource(SecurityDefaultTheme.ICON_16x16_ADD));
    getAddUserButton().setWidth(100, UNITS_PERCENTAGE);
    getAddUserButton().addStyleName(SecurityDefaultTheme.CSS_SMALL);
    getRefreshButton().setCaption("Refresh");
    getRefreshButton().setIcon(new ThemeResource(SecurityDefaultTheme.ICON_16x16_REFRESH));
    getRefreshButton().addStyleName(SecurityDefaultTheme.CSS_SMALL);
    VerticalLayout content = ((VerticalLayout) getContent());
    content.setMargin(true);/*w ww.j  a  va  2 s . c  o  m*/
    content.setHeight(600, UNITS_PIXELS);
    content.removeAllComponents();
    if (null != getDataViewListTable()) {
        getDataViewListTable().setSizeFull();
        HorizontalLayout buttonLayout = new HorizontalLayout();
        buttonLayout.setSpacing(true);
        buttonLayout.setWidth(100F, UNITS_PERCENTAGE);
        buttonLayout.addComponent(getAddUserButton());
        buttonLayout.addComponent(getRefreshButton());
        buttonLayout.setExpandRatio(getAddUserButton(), 1);
        content.addComponent(buttonLayout);
        content.addComponent(getDataViewListTable());
        content.setExpandRatio(getDataViewListTable(), 1);
        content.setSpacing(true);
    }
}

From source file:com.snowy.UsersList.java

public UsersList(data d) {
    this.d = d;/*from  w ww  . j  a v a  2s .c o  m*/
    c.addContainerProperty("id", Integer.class, "");
    retrieveActiveUsers();
    //this.addItem("Chase");
    //this.addItem("Cole");

    //ll.addComponent(ll);
    //PopupView pop = new PopupView(null,ll);
    //pop.s
    //pop.addPopupVisibilityListener(e->{
    //   ll.addComponent(hl);
    //});

    //TODO add the select listener
    ls.addValueChangeListener(e -> {
        if (e.getProperty().getValue() != null) {
            Window w = new Window("Confirm Challenge");
            int id = Integer.parseInt(c.getItem(e.getProperty().getValue().toString()).getItemProperty("id")
                    .getValue().toString());
            String Username = e.getProperty().getValue().toString();
            //Logger.getLogger(UsersList.class.getName()).info(Username);
            //Logger.getLogger(UsersList.class.getName()).info(id+"");
            VerticalLayout ll = new VerticalLayout();
            VerticalLayout bb = new VerticalLayout();
            HorizontalLayout hl = new HorizontalLayout();
            Label la = new Label("Send challenge to " + Username + "?");
            bb.addComponent(la);
            ll.addComponent(bb);

            ll.setSizeUndefined();
            bb.setComponentAlignment(la, Alignment.MIDDLE_CENTER);

            ll.addComponent(hl);
            ll.setSpacing(true);
            ll.setMargin(new MarginInfo(true, true, false, true));
            hl.setMargin(new MarginInfo(false, true, true, true));
            hl.setSpacing(true);
            Button cancle = new Button("Cancel", b -> {
                w.close();
            });
            Button send = new Button("Send", c -> {
                if (d.sendChallenge(id)) {
                    ll.removeAllComponents();
                    ll.addComponent(new Label("Challenge Sent Succesfully!"));
                    ll.addComponent(new Button("Close", dd -> {
                        w.close();
                    }));
                    w.setCaption("Success");
                    ll.setSpacing(true);
                    ll.setMargin(true);
                } else {
                    ll.removeAllComponents();
                    ll.addComponent(new Label("Challenge Dend Failed"));
                    ll.addComponent(new Button("Close", dd -> {
                        w.close();
                    }));
                    w.setCaption("Failure");
                    ll.setSpacing(true);
                    ll.setMargin(true);
                }
            });
            hl.addComponents(cancle, send);
            //      this.addComponent(pop);
            //    ll.addComponent(la);
            //   pop.setPopupVisible(true);
            //w.setPosition(null, null);
            w.center();
            w.setModal(true);
            w.setClosable(false);
            w.setResizable(false);
            w.setContent(ll);
            this.getUI().addWindow(w);

        }
    });

    this.setSizeFull();
    this.addStyleName("mine");
    this.addComponent(ls);
    ls.setContainerDataSource(c);
    //ls.setContainerDataSource((Container) hm.keySet());
    ls.setSizeFull();
    ls.setImmediate(true);

}