Example usage for org.apache.wicket.markup.repeater.data DataView getDataProvider

List of usage examples for org.apache.wicket.markup.repeater.data DataView getDataProvider

Introduction

In this page you can find the example usage for org.apache.wicket.markup.repeater.data DataView getDataProvider.

Prototype

public IDataProvider<T> getDataProvider() 

Source Link

Usage

From source file:au.org.theark.core.web.component.customfield.SearchResultListPanel.java

License:Open Source License

private void addToolbars(DataView<CustomField> customFieldDataView) {
    List<IColumn<CustomField>> columns = new ArrayList<IColumn<CustomField>>();
    columns.add(new ExportableTextColumn<CustomField>(Model.of("name"), "name"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("fieldType"), "fieldType.name"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("description"), "description"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("fieldLabel"), "fieldLabel"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("unitType"), "unitType.name"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("encodedValues"), "encodedValues"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("minValue"), "minValue"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("maxValue"), "maxValue"));
    columns.add(new ExportableTextColumn<CustomField>(Model.of("missingValue"), "missingValue"));

    DataTable table = new DataTable("datatable", columns, customFieldDataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("FIELD_NAME");
    headers.add("FIELD_TYPE");
    headers.add("DESCRIPTION");
    headers.add("QUESTION");
    headers.add("UNITS");
    headers.add("ENCODED_VALUES");
    headers.add("MINIMUM_VALUE");
    headers.add("MAXIMUM_VALUE");
    headers.add("MISSING_VALUE");

    String filename = "data_dictionary";
    RepeatingView toolbars = new RepeatingView("toolbars");
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    add(toolbars);// w  w  w.  j av  a2  s . co m
}

From source file:au.org.theark.core.web.component.customfieldcategory.SearchResultListPanel.java

License:Open Source License

private void addToolbars(DataView<CustomFieldCategory> customFieldCategoryDataView) {
    List<IColumn<CustomFieldCategory>> columns = new ArrayList<IColumn<CustomFieldCategory>>();
    columns.add(new ExportableTextColumn<CustomFieldCategory>(Model.of("name"), "name"));
    columns.add(/*w w w.j av  a2 s.c  om*/
            new ExportableTextColumn<CustomFieldCategory>(Model.of("customFieldType"), "customFieldType.name"));
    columns.add(new ExportableTextColumn<CustomFieldCategory>(Model.of("description"), "description"));
    columns.add(
            new ExportableTextColumn<CustomFieldCategory>(Model.of("parentCategory"), "parentCategory.name"));
    columns.add(new ExportableTextColumn<CustomFieldCategory>(Model.of("orderNumber"), "orderNumber"));

    DataTable table = new DataTable("datatable", columns, customFieldCategoryDataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("FIELD_NAME");
    headers.add("CUSTOM_FIELD_TYPE");
    headers.add("DESCRIPTION");
    headers.add("PARENT_CATEGORY");
    headers.add("ORDER_NUMBER");

    String filename = "data_dictionary";
    RepeatingView toolbars = new RepeatingView("toolbars");
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    add(toolbars);
}

From source file:au.org.theark.phenotypic.web.component.phenodatacategory.SearchResultListPanel.java

License:Open Source License

private void addToolbars(DataView<PhenoDataSetCategory> phenoDataSetCategoryDataView) {
    List<IColumn<PhenoDataSetCategory>> columns = new ArrayList<IColumn<PhenoDataSetCategory>>();
    columns.add(new ExportableTextColumn<PhenoDataSetCategory>(Model.of("name"), "name"));
    columns.add(new ExportableTextColumn<PhenoDataSetCategory>(Model.of("description"), "description"));
    columns.add(/*from   w w  w.j  a va 2 s .  c o  m*/
            new ExportableTextColumn<PhenoDataSetCategory>(Model.of("parentCategory"), "parentCategory.name"));
    columns.add(new ExportableTextColumn<PhenoDataSetCategory>(Model.of("orderNumber"), "orderNumber"));

    DataTable table = new DataTable("datatable", columns, phenoDataSetCategoryDataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    List<String> headers = new ArrayList<String>(0);
    headers.add("FIELD_NAME");
    headers.add("DESCRIPTION");
    String filename = "pheno_dataset_category";
    RepeatingView toolbars = new RepeatingView("toolbars");
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    add(toolbars);
}

From source file:au.org.theark.phenotypic.web.component.phenodatadictionary.SearchResultListPanel.java

License:Open Source License

private void addToolbars(DataView<PhenoDataSetField> phenoDataSetFieldDataView) {
    List<IColumn<PhenoDataSetField>> columns = new ArrayList<IColumn<PhenoDataSetField>>();
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("name"), "name"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("fieldType"), "fieldType.name"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("description"), "description"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("fieldLabel"), "fieldLabel"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("unitTypeInText"), "unitTypeInText"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("encodedValues"), "encodedValues"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("minValue"), "minValue"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("maxValue"), "maxValue"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("missingValue"), "missingValue"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("defaultValue"), "defaultValue"));
    columns.add(new ExportableTextColumn<PhenoDataSetField>(Model.of("required"), "required"));

    DataTable table = new DataTable("datatable", columns, phenoDataSetFieldDataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("FIELD_NAME");
    headers.add("FIELD_TYPE");
    headers.add("DESCRIPTION");
    headers.add("QUESTION");
    headers.add("UNITS");
    headers.add("ENCODED_VALUES");
    headers.add("MINIMUM_VALUE");
    headers.add("MAXIMUM_VALUE");
    headers.add("MISSING_VALUE");
    headers.add("DEFAULT_VALUE");
    headers.add("REQUIRED");

    String filename = "pheno_dataset_dictionary";
    RepeatingView toolbars = new RepeatingView("toolbars");
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    add(toolbars);/*from  w  w w  . j av  a2s  .co  m*/
}

From source file:com.doculibre.constellio.wicket.components.sort.DataViewOrderByLink.java

License:Open Source License

/**
 * @param id/* w w w .ja  va  2 s. c om*/
 * @param property
 * @param stateLocator
 * @param cssProvider
 */
public DataViewOrderByLink(String id, String property, DataView dataView, ICssProvider cssProvider) {
    super(id, property, (ISortStateLocator) dataView.getDataProvider(), cssProvider);
    this.dataView = dataView;
}

From source file:com.doculibre.constellio.wicket.components.sort.DataViewOrderByLink.java

License:Open Source License

/**
 * @param id/*from  w w  w.  jav a2s . c  o  m*/
 * @param property
 * @param stateLocator
 */
public DataViewOrderByLink(String id, String property, DataView dataView) {
    super(id, property, (ISortStateLocator) dataView.getDataProvider());
    this.dataView = dataView;
}

From source file:com.doculibre.constellio.wicket.paging.ConstellioPagingNavigator.java

License:Open Source License

@Override
protected Link newPagingNavigationIncrementLink(String id, final IPageable pageable, final int increment) {
    DataView dataView = (DataView) pageable;
    SimpleSearch simpleSearch;//from ww w.j  a v a2s .c  o  m
    if (dataView.getDataProvider() instanceof FacetsDataProvider) {
        FacetsDataProvider dataProvider = (FacetsDataProvider) dataView.getDataProvider();
        simpleSearch = dataProvider.getSimpleSearch();
    } else {
        SearchResultsDataProvider dataProvider = (SearchResultsDataProvider) dataView.getDataProvider();
        simpleSearch = dataProvider.getSimpleSearch();
    }
    SimpleSearch clone = simpleSearch.clone();
    int page = clone.getPage();
    int newPage = page + increment;
    clone.setPage(newPage);

    PageFactoryPlugin pageFactoryPlugin = PluginFactory.getPlugin(PageFactoryPlugin.class);
    return new BookmarkablePageLink(id, pageFactoryPlugin.getSearchResultsPage(),
            SearchResultsPage.getParameters(clone)) {
        public boolean isEnabled() {
            return super.isEnabled() && ConstellioPagingNavigator.this.isEnabled()
                    && ConstellioPagingNavigator.this.isEnableAllowed();
        }

        /**
         * Returns true if the page link links to the given page.
         * 
         * @param page
         *            ignored
         * @return True if this link links to the given page
         * @see org.apache.wicket.markup.html.link.PageLink#linksTo(org.apache.wicket.Page)
         */
        public boolean linksTo(final Page page) {
            pageable.getCurrentPage();
            return ((increment < 0) && isFirst()) || ((increment > 0) && isLast());
        }

        /**
         * @return True if it is referring to the first page of the underlying PageableListView.
         */
        public boolean isFirst() {
            return pageable.getCurrentPage() <= 0;
        }

        /**
         * @return True if it is referring to the last page of the underlying PageableListView.
         */
        public boolean isLast() {
            return pageable.getCurrentPage() >= (pageable.getPageCount() - 1);
        }

        @Override
        public boolean isVisible() {
            return super.isVisible() && isEnabled();
        }
    }.setAutoEnable(true);
}

From source file:com.doculibre.constellio.wicket.paging.ConstellioPagingNavigator.java

License:Open Source License

@Override
protected Link newPagingNavigationLink(String id, final IPageable pageable, final int pageNumber) {
    DataView dataView = (DataView) pageable;
    SimpleSearch simpleSearch;/*ww  w .  java 2  s.c o m*/
    if (dataView.getDataProvider() instanceof FacetsDataProvider) {
        FacetsDataProvider dataProvider = (FacetsDataProvider) dataView.getDataProvider();
        simpleSearch = dataProvider.getSimpleSearch();
    } else {
        SearchResultsDataProvider dataProvider = (SearchResultsDataProvider) dataView.getDataProvider();
        simpleSearch = dataProvider.getSimpleSearch();
    }
    SimpleSearch clone = simpleSearch.clone();
    if (pageNumber == -1) {
        clone.setPage(pageable.getPageCount() - 1);
    } else {
        clone.setPage(pageNumber);
    }

    PageFactoryPlugin pageFactoryPlugin = PluginFactory.getPlugin(PageFactoryPlugin.class);
    return new BookmarkablePageLink(id, pageFactoryPlugin.getSearchResultsPage(),
            SearchResultsPage.getParameters(clone)) {
        public boolean isEnabled() {
            boolean enabled = super.isEnabled() && ConstellioPagingNavigator.this.isEnabled()
                    && ConstellioPagingNavigator.this.isEnableAllowed();
            if (enabled) {
                int currentPage = pageable.getCurrentPage();
                if (!"first".equals(getId()) && !"last".equals(getId()) && currentPage == pageNumber) {
                    enabled = false;
                }
            }
            return enabled;
        }

        @Override
        public boolean isVisible() {
            boolean visible = super.isVisible();
            if (visible) {
                int currentPage = pageable.getCurrentPage();
                int pageCount = pageable.getPageCount();
                if ("first".equals(getId()) && currentPage == 0) {
                    visible = false;
                } else if ("last".equals(getId()) && currentPage == (pageCount - 1)) {
                    visible = false;
                }
            }
            return visible;
        }
    };
}

From source file:com.marc.lastweek.web.pages.classifiedadslisting.ClassifiedAdsListPanel.java

License:Open Source License

public ClassifiedAdsListPanel(String id, final FilterParameters filterParameters) {
    super(id);/*from   w  w  w .  j av a2 s  .  c  o m*/

    WebMarkupContainer classifiedListBox = new WebMarkupContainer("classifiedListBox");
    DataView classifiedList = new DataView("classifiedAdsList",
            new FilterCalssifiedAdsProvider(filterParameters), RESULTS_PER_PAGE) {
        private static final long serialVersionUID = 8440379131631972878L;

        @Override
        protected void populateItem(Item item) {
            ClassifiedAd classifiedAd = (ClassifiedAd) item.getModelObject();

            PageParameters linkParameters = new PageParameters();
            linkParameters.put(PageParametersNaming.PARAM_NAME_CLASSIFIED_AD_ID, classifiedAd.getId());
            Link classifiedAdLink = (new BookmarkablePageLink("classifiedAdLink", ClassifiedAdDetailPage.class,
                    linkParameters));
            classifiedAdLink.add(new Label("classifiedAdTitle", ViewUtils.labelizer(classifiedAd.getTitle())));
            item.add(classifiedAdLink);

            item.add(new Label("classifiedAdPublicationDate",
                    ViewUtils.labelizer(classifiedAd.getPublicationDate())));

            Label description = new Label("classifiedAdDescription",
                    ViewUtils.getDigest(classifiedAd.getDescription()));
            description.setEscapeModelStrings(false);
            item.add(description);
            item.add(new Label("classifiedAdPrice", ViewUtils.labelizer(classifiedAd.getPrice())));

            if (item.getIndex() % 2 == 1) {
                item.add(new SimpleAttributeModifier("class", "classified-ad-summary-alt"));
            }
        }
    };
    classifiedListBox.add(classifiedList);
    classifiedListBox.setOutputMarkupId(true);
    this.add(classifiedListBox);

    VerticalFancyPaginator paginationLinks = new VerticalFancyPaginator("paginationLinks", classifiedList);
    this.add(paginationLinks);

    // No results
    WebMarkupContainer noResultsDiv = new WebMarkupContainer("noResults");
    this.add(noResultsDiv);

    if (classifiedList.getDataProvider().size() != 0) {
        noResultsDiv.setVisible(false);
    } else {
        paginationLinks.setVisible(false);
    }

}

From source file:com.socialsite.course.CoursesPanel.java

License:Open Source License

/**
 * // w  ww .  ja v a  2s  . c  o  m
 * @param id
 * @param modelId
 * @param dataProvider
 */
public CoursesPanel(final String id, final IDataProvider<Course> dataProvider) {
    super(id);
    final DataView<Course> courseView = new DataView<Course>("courses", dataProvider, 9) {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<Course> item) {
            final Course course = item.getModelObject();
            CourseLink courseImageLink;
            item.add(courseImageLink = new CourseLink("imagelink", item.getModel()));
            courseImageLink.add(new ImagePanel("coursethumb", course.getId(), ImageType.COURSE,
                    course.getLastModified(), true));

            // course link
            CourseLink courseLink;
            item.add(courseLink = new CourseLink("name", item.getModel()));
            courseLink.add(new Label("coursename", course.getName()));
        }
    };
    add(courseView);
    add(new ShowAllLink("showall", courseView.getDataProvider().size(), UserCoursesPage.class));
}