Example usage for org.apache.wicket.ajax.markup.html.navigation.paging AjaxPagingNavigator AjaxPagingNavigator

List of usage examples for org.apache.wicket.ajax.markup.html.navigation.paging AjaxPagingNavigator AjaxPagingNavigator

Introduction

In this page you can find the example usage for org.apache.wicket.ajax.markup.html.navigation.paging AjaxPagingNavigator AjaxPagingNavigator.

Prototype

public AjaxPagingNavigator(final String id, final IPageable pageable) 

Source Link

Document

Constructor.

Usage

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

License:Open Source License

protected WebMarkupContainer initialiseSearchResults() {
    SearchResultListPanel searchResultListPanel = new SearchResultListPanel("resultListPanel", cpModel,
            arkCrudContainerVO, feedBackPanel);

    // Data providor to paginate resultList
    customFieldProvider = new ArkDataProvider2<CustomField, CustomField>() {
        private static final long serialVersionUID = 1L;

        public int size() {
            return (int) iArkCommonService.getCustomFieldCount(criteriaModel.getObject());
        }//from www.  ja v a2 s.  c  om

        public Iterator<CustomField> iterator(int first, int count) {
            List<CustomField> listCustomFields = new ArrayList<CustomField>();
            if (isActionPermitted()) {
                listCustomFields = iArkCommonService.searchPageableCustomFields(criteriaModel.getObject(),
                        first, count);
            }
            return listCustomFields.iterator();
        }
    };
    // Set the criteria for the data provider
    customFieldProvider.setCriteriaModel(new PropertyModel<CustomField>(cpModel, "customField"));

    dataView = searchResultListPanel.buildDataView(customFieldProvider);
    dataView.setItemsPerPage(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(arkCrudContainerVO.getSearchResultPanelContainer());
        }
    };
    searchResultListPanel.add(pageNavigator);
    searchResultListPanel.add(dataView);
    arkCrudContainerVO.getSearchResultPanelContainer().add(searchResultListPanel);
    return arkCrudContainerVO.getSearchResultPanelContainer();
}

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

License:Open Source License

protected WebMarkupContainer initialiseSearchResults() {
    SearchResultListPanel searchResultListPanel = new SearchResultListPanel("resultListPanel", cpModel,
            arkCrudContainerVO, feedBackPanel);
    // Data providor to paginate resultList
    customFieldCategoryProvider = new ArkDataProvider2<CustomFieldCategory, CustomFieldCategory>() {
        private static final long serialVersionUID = 1L;

        public int size() {
            if (criteriaModel.getObject().getArkFunction().getName()
                    .equalsIgnoreCase(Constants.FUNCTION_KEY_VALUE_DATA_DICTIONARY)) {
                criteriaModel.getObject().setArkFunction(
                        iArkCommonService.getArkFunctionByName(Constants.FUNCTION_KEY_VALUE_PHENO_COLLECTION));
                return (int) iArkCommonService.getCustomFieldCategoryCount(criteriaModel.getObject());//todo safe int conversion
            } else {
                return (int) iArkCommonService.getCustomFieldCategoryCount(criteriaModel.getObject());//todo safe int conversion
            }/*from  w w w  .j  a  va  2  s  .c o  m*/
        }

        public Iterator<CustomFieldCategory> iterator(int first, int count) {
            List<CustomFieldCategory> listCustomFieldCategories = new ArrayList<CustomFieldCategory>();

            if (isActionPermitted()) {
                //if(criteriaModel.getObject().getArkFunction().getName().equalsIgnoreCase(Constants.FUNCTION_KEY_VALUE_DATA_DICTIONARY)){
                //listCustomFields = iArkCommonService.searchPageableCustomFieldsForPheno(criteriaModel.getObject(), first, count);
                //}
                //else{
                listCustomFieldCategories = iArkCommonService
                        .searchPageableCustomFieldCategories(criteriaModel.getObject(), first, count);
                //}

            }
            return CustomFieldCategoryOrderingHelper.getInstance()
                    .orderHierarchicalyCustomFieldCategories(listCustomFieldCategories).iterator();
            //return orderHierarchicalyCustomFieldCategories(listCustomFieldCategories).iterator();
        }
    };
    // Set the criteria for the data provider
    customFieldCategoryProvider
            .setCriteriaModel(new PropertyModel<CustomFieldCategory>(cpModel, "customFieldCategory"));
    dataView = searchResultListPanel.buildDataView(customFieldCategoryProvider);
    dataView.setItemsPerPage(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(arkCrudContainerVO.getSearchResultPanelContainer());
        }
    };
    searchResultListPanel.add(pageNavigator);
    searchResultListPanel.add(dataView);
    arkCrudContainerVO.getSearchResultPanelContainer().add(searchResultListPanel);
    return arkCrudContainerVO.getSearchResultPanelContainer();
}

From source file:au.org.theark.disease.web.component.affection.form.DetailForm.java

License:Open Source License

@SuppressWarnings("unchecked")
public void initialiseDetailForm() {

    initDiseaseDDC();/* www. j  a v a  2 s  . com*/
    initAffectionStatusDDC();

    detachableModel = new LoadableDetachableModel<List<Position>>() {

        @Override
        protected List<Position> load() {
            List<Position> positions = iArkDiseaseService
                    .getPositions(containerForm.getModelObject().getAffection());
            return positions;
        }
    };

    positionListEditor = new ListView<Position>("positionListEditor", detachableModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<Position> item) {
            final Position position = item.getModelObject();
            if (position != null) {
                position_storage.put(item.getIndex(), position);
            }

            List<Gene> availableGenes = new ArrayList<Gene>();
            if (containerForm.getModelObject().getAffection().getDisease() != null
                    && containerForm.getModelObject().getAffection().getDisease().getGenes() != null) {
                availableGenes = new ArrayList<Gene>(
                        containerForm.getModelObject().getAffection().getDisease().getGenes());
            }
            final DropDownChoice<Gene> geneDDC = new DropDownChoice<Gene>("affection.disease.genes",
                    new Model<Gene>(position.getGene()), availableGenes,
                    new ChoiceRenderer<Gene>("name", "id"));
            geneDDC.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                private static final long serialVersionUID = 1L;

                protected void onUpdate(AjaxRequestTarget target) {
                    Gene selectedGene = iArkDiseaseService.getGeneByID(Long.parseLong(geneDDC.getValue()));
                    positionDDC.setChoices(new ArrayList<Position>(selectedGene.getPositions()));
                    target.add(positionDDC);
                }
            });

            geneDDC.setOutputMarkupId(true);
            item.add(geneDDC);

            List<Position> availablePositions = new ArrayList<Position>();
            if (geneDDC.getModelObject() != null) {
                availablePositions = new ArrayList<Position>(geneDDC.getModelObject().getPositions());
            }
            LoadableDetachableModel<Position> positionModel = new LoadableDetachableModel<Position>(position) {

                @Override
                protected Position load() {
                    return position;
                }
            };
            if (position != null) {
                positionModel.setObject(position);
            }
            positionDDC = new DropDownChoice<Position>("affection.positions", positionModel, availablePositions,
                    new ChoiceRenderer<Position>("name", "id")) {
                @Override
                protected void onBeforeRender() {
                    if (geneDDC.getModelObject() != null && geneDDC.getModelObject().getId() != null
                            && !geneDDC.getModelObject().getPositions().isEmpty()) {
                        this.setChoices(new ArrayList<Position>(geneDDC.getModelObject().getPositions()));
                    }
                    if (this.getModelObject().getName() != null) {
                        position_storage.put(item.getIndex(), this.getModelObject());
                    }
                    super.onBeforeRender();
                }
            };
            positionDDC.setOutputMarkupId(true);
            positionDDC.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                private static final long serialVersionUID = 1L;

                protected void onUpdate(AjaxRequestTarget target) {
                    Position selectedPosition = positionDDC.getModelObject();
                    if (selectedPosition.getName() != null) {
                        position_storage.put(item.getIndex(), selectedPosition);
                    }
                }
            });
            item.add(positionDDC);

            item.add(new AjaxDeleteButton(Constants.DELETE, new Model<String>("Are you sure?"),
                    new Model<String>("Delete")) {

                private static final long serialVersionUID = 1L;

                protected void onDeleteConfirmed(AjaxRequestTarget target, Form<?> form) {
                    try {
                        //need to remove save containerform post position removal
                        position_storage.remove(item.getIndex());
                        positionListEditor.getModelObject().remove(position);
                        containerForm.getModelObject().setAffection(iArkDiseaseService
                                .getAffectionByID(containerForm.getModelObject().getAffection().getId()));

                        save(containerForm, target);
                        target.add(dataViewPanel);
                        deleteCompleted("Row '" + position.getName() + "' deleted successfully.", true);
                    } catch (Exception e) {
                        e.printStackTrace();
                        target.add(form);
                        deleteCompleted("Error deleting row '" + position.getName()
                                + "'. Row has data associated with it.", false);
                    }
                }

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    onDeleteConfirmed(target, form);
                    target.add(form);
                    target.add(feedBackPanel);
                }
            });

            item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() {
                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD;
                }
            }));
        }
    };

    positionListEditor.setOutputMarkupId(true);

    newPositionBtn = new AjaxEditorButton(Constants.NEW) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(form);
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            positionListEditor.getModelObject().add(new Position());
            target.add(form);
        }
    }.setDefaultFormProcessing(false);

    arkCrudContainerVO.getDetailPanelFormContainer().add(newPositionBtn);

    PropertyModel<Date> recordDateModel = new PropertyModel<Date>(containerForm.getModel(),
            "affection.recordDate");
    recordDateTxtFld = new DateTextField("recordDate", recordDateModel) {
        @Override
        protected void onBeforeRender() {
            this.setModel(new PropertyModel<Date>(containerForm.getModel(), "affection.recordDate"));
            super.onBeforeRender();
        }
    };
    ArkDatePicker recordDatePicker = new ArkDatePicker();
    recordDatePicker.bind(recordDateTxtFld);
    recordDateTxtFld.add(recordDatePicker);

    AffectionCustomDataVO affectionCustomDataVO = new AffectionCustomDataVO();
    affectionCustomDataVO.setCustomFieldDataList(new ArrayList<AffectionCustomFieldData>(
            cpModel.getObject().getAffection().getAffectionCustomFieldDataSets()));

    final CompoundPropertyModel<AffectionCustomDataVO> affectionCustomDataModel = new CompoundPropertyModel<AffectionCustomDataVO>(
            affectionCustomDataVO);
    dataViewPanel = new AffectionCustomDataDataViewPanel("dataViewPanel", affectionCustomDataModel)
            .initialisePanel(
                    iArkCommonService.getUserConfig(Constants.CONFIG_CUSTOM_FIELDS_PER_PAGE).getIntValue());
    customFieldForm = new AbstractCustomDataEditorForm<AffectionCustomDataVO>("customFieldForm",
            affectionCustomDataModel, feedBackPanel) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onEditSave(AjaxRequestTarget target, Form<?> form) {
            for (AffectionCustomFieldData acfd : this.cpModel.getObject().getCustomFieldDataList()) {
                iArkDiseaseService.save(acfd);
            }
        }

        @Override
        public void onBeforeRender() {
            if (!isNew()) {
                this.setModelObject(new AffectionCustomDataVO(iArkDiseaseService
                        .getAffectionCustomFieldData(containerForm.getModelObject().getAffection())));
            }
            this.buttonsPanelWMC.setVisible(false);
            super.onBeforeRender();
        }
    }.initialiseForm();

    pageNavigator = new AjaxPagingNavigator("navigator", dataViewPanel.getDataView()) {
        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(customFieldForm.getDataViewWMC());
            target.add(this);
        }
    };
    pageNavigator.setOutputMarkupId(true);
    customFieldForm.getDataViewWMC().add(dataViewPanel);
    arkCrudContainerVO.getDetailPanelFormContainer().add(pageNavigator);
    attachValidators();
    addDetailFormComponents();

    deleteButton.setVisible(false);
}

From source file:au.org.theark.lims.web.component.biocollectioncustomdata.BioCollectionCustomDataEditorPanel.java

License:Open Source License

public BioCollectionCustomDataEditorPanel initialisePanel() {

    dataViewPanel = new BioCollectionCustomDataDataViewPanel("dataViewPanel", cpModel).initialisePanel(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    customDataEditorForm = new CustomDataEditorForm("customDataEditorForm", cpModel, feedbackPanel)
            .initialiseForm();//  w  w  w  . j av a 2s  . c  o  m
    AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataViewPanel.getDataView()) {
        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(customDataEditorForm.getDataViewWMC());
            target.add(this);
        }
    };
    pageNavigator.setOutputMarkupId(true);
    customDataEditorForm.getDataViewWMC().add(dataViewPanel);
    this.add(customDataEditorForm);
    this.add(pageNavigator);

    return this;
}

From source file:au.org.theark.lims.web.component.biospecimen.form.BiospecimenListForm.java

License:Open Source License

private void initialiseDataView() {
    dataViewListWMC = new WebMarkupContainer("dataViewListWMC");
    dataViewListWMC.setOutputMarkupId(true);
    // Data provider to paginate resultList
    biospecimenProvider = new ArkDataProvider2<LimsVO, Biospecimen>() {

        private static final long serialVersionUID = 1L;

        public int size() {
            return (int) iLimsService.getBiospecimenCount(criteriaModel.getObject());
        }// w w  w  .ja  va  2s  .  c  om

        public Iterator<Biospecimen> iterator(int first, int count) {
            List<Biospecimen> biospecimenList = new ArrayList<Biospecimen>();
            if (ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.SEARCH)) {
                biospecimenList = iLimsService.searchPageableBiospecimens(criteriaModel.getObject(), first,
                        count);
            }
            return biospecimenList.iterator();
        }
    };
    // Set the criteria into the data provider's model
    biospecimenProvider.setCriteriaModel(cpModel);

    dataView = buildDataView(biospecimenProvider);
    dataView.setItemsPerPage(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(dataViewListWMC);
        }
    };
    dataViewListWMC.add(pageNavigator);
    dataViewListWMC.add(dataView);

    List<IColumn<Biospecimen>> columns = new ArrayList<IColumn<Biospecimen>>();
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("BiospecimenUID"), "biospecimenUid"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Study"), "study.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("SubjectUID"), "linkSubjectStudy.subjectUID"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("ParentUID"), "parentUid"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Collection"), "bioCollection.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Sample Type"), "sampleType.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Quantity"), "quantity"));

    DataTable table = new DataTable("datatable", columns, dataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("BiospecimenUID");
    headers.add("Study");
    headers.add("SubjectUID");
    headers.add("ParentUID");
    headers.add("Collection");
    headers.add("Sample Type");
    headers.add("Quantity");

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

From source file:au.org.theark.lims.web.component.biospecimencustomdata.BiospecimenCustomDataEditorPanel.java

License:Open Source License

public BiospecimenCustomDataEditorPanel initialisePanel() {

    dataViewPanel = new BiospecimenCustomDataDataViewPanel("dataViewPanel", cpModel).initialisePanel(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    customDataEditorForm = new CustomDataEditorForm("customDataEditorForm", cpModel, feedbackPanel)
            .initialiseForm();/*from   ww w.  j a va 2 s  .  c o  m*/
    AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataViewPanel.getDataView()) {
        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(customDataEditorForm.getDataViewWMC());
            target.add(this);
        }
    };
    pageNavigator.setOutputMarkupId(true);
    customDataEditorForm.getDataViewWMC().add(dataViewPanel);
    this.add(customDataEditorForm);
    this.add(pageNavigator);

    return this;
}

From source file:au.org.theark.lims.web.component.biotransaction.BioTransactionListPanel.java

License:Open Source License

private void initialiseDataView() {
    dataViewListWMC = new WebMarkupContainer("dataViewListWMC");
    dataViewListWMC.setOutputMarkupId(true);
    // Data provider to paginate resultList
    bioTransactionProvider = new ArkDataProvider2<LimsVO, BioTransaction>() {

        private static final long serialVersionUID = 1L;

        public int size() {
            return (int) iLimsService.getBioTransactionCount(criteriaModel.getObject().getBioTransaction());
        }//from w  w  w  . j av  a  2  s  . c o m

        public Iterator<BioTransaction> iterator(int first, int count) {
            List<BioTransaction> biospecimenList = new ArrayList<BioTransaction>();
            if (ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.SEARCH)) {
                biospecimenList = iLimsService.searchPageableBioTransactions(
                        criteriaModel.getObject().getBioTransaction(), first, count);
            }
            return biospecimenList.iterator();
        }
    };
    // Set the criteria into the data provider's model
    bioTransactionProvider.setCriteriaModel(cpModel);

    dataView = buildDataView(bioTransactionProvider);
    dataView.setItemsPerPage(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(dataViewListWMC);
        }
    };
    dataViewListWMC.add(pageNavigator);
    dataViewListWMC.add(dataView);
    add(dataViewListWMC);

}

From source file:au.org.theark.lims.web.component.global.biospecimen.form.BiospecimenListForm.java

License:Open Source License

private void initialiseDataView() {

    Subject currentUser = SecurityUtils.getSubject();
    ArkUser arkUser;/*from  w  w  w  . j  av  a2 s. c o m*/
    try {
        arkUser = iArkCommonService.getArkUser(currentUser.getPrincipal().toString());
        ArkUserVO arkUserVo = new ArkUserVO();
        arkUserVo.setArkUserEntity(arkUser);
        studyListForUser = iArkCommonService.getStudyListForUser(arkUserVo); //getParentAndChildStudies(sessionStudyId);
    } catch (EntityNotFoundException e) {
        e.printStackTrace();
    }

    dataViewListWMC = new WebMarkupContainer("dataViewListWMC");
    dataViewListWMC.setOutputMarkupId(true);
    // Data provider to paginate resultList
    biospecimenProvider = new ArkDataProvider2<LimsVO, Biospecimen>() {

        private static final long serialVersionUID = 1L;

        public int size() {
            return (int) iLimsService.getBiospecimenCount(criteriaModel.getObject());
        }

        public Iterator<Biospecimen> iterator(int first, int count) {
            List<Biospecimen> biospecimenList = new ArrayList<Biospecimen>();
            if (ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.SEARCH)) {
                biospecimenList = iLimsService.searchPageableBiospecimens(criteriaModel.getObject(), first,
                        count);
            }
            return biospecimenList.iterator();
        }
    };
    // Set the criteria into the data provider's model
    biospecimenProvider.setCriteriaModel(cpModel);

    dataView = buildDataView(biospecimenProvider);
    dataView.setItemsPerPage(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    final IModel<String> amountModel = new Model<String>(Integer.toString(biospecimenProvider.size()));
    dataViewListWMC.add(new Label("total", amountModel) {
        private static final long serialVersionUID = 1L;

        protected void onBeforeRender() {
            amountModel.setObject(Integer.toString(biospecimenProvider.size()));
            super.onBeforeRender();
        };
    });

    AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(dataViewListWMC);
        }
    };
    dataViewListWMC.add(pageNavigator);
    dataViewListWMC.add(dataView);

    List<IColumn<Biospecimen>> columns = new ArrayList<IColumn<Biospecimen>>();
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("BiospecimenUID"), "biospecimenUid"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Study"), "study.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("SubjectUID"), "linkSubjectStudy.subjectUID"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("ParentUID"), "parentUid"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Collection"), "bioCollection.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Sample Type"), "sampleType.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Quantity"), "quantity"));

    DataTable table = new DataTable("datatable", columns, dataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("BiospecimenUID");
    headers.add("Study");
    headers.add("SubjectUID");
    headers.add("ParentUID");
    headers.add("Collection");
    headers.add("Sample Type");
    headers.add("Quantity");

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

From source file:au.org.theark.lims.web.component.subjectlims.lims.biocollection.form.BioCollectionListForm.java

License:Open Source License

private void initialiseDataView() {
    dataViewListWMC = new WebMarkupContainer("dataViewListWMC");
    dataViewListWMC.setOutputMarkupId(true);
    // Data provider to paginate resultList
    bioColectionProvider = new ArkDataProvider<BioCollection, ILimsService>(iLimsService) {

        private static final long serialVersionUID = 1L;

        public int size() {
            return (int) service.getBioCollectionCount(model.getObject());
        }//from ww w .  j a  va  2  s .  c  o  m

        public Iterator<BioCollection> iterator(int first, int count) {
            List<BioCollection> listCollection = new ArrayList<BioCollection>();
            if (ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.SEARCH)) {
                listCollection = service.searchPageableBioCollections(model.getObject(), first, count);
            }
            return listCollection.iterator();
        }
    };
    // Set the criteria into the data provider's model
    bioColectionProvider.setModel(new LoadableDetachableModel<BioCollection>() {

        private static final long serialVersionUID = 1L;

        @Override
        protected BioCollection load() {
            return cpModel.getObject().getBioCollection();
        }
    });

    dataView = buildDataView(bioColectionProvider);
    dataView.setItemsPerPage(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(dataViewListWMC);
        }
    };
    dataViewListWMC.add(pageNavigator);
    dataViewListWMC.add(dataView);
    add(dataViewListWMC);

}

From source file:au.org.theark.lims.web.component.subjectlims.lims.biospecimen.form.BiospecimenListForm.java

License:Open Source License

private void initialiseDataView() {
    dataViewListWMC = new WebMarkupContainer("dataViewListWMC");
    dataViewListWMC.setOutputMarkupId(true);
    // Data provider to paginate resultList
    biospecimenProvider = new ArkDataProvider2<LimsVO, Biospecimen>() {

        private static final long serialVersionUID = 1L;

        public int size() {
            return (int) iLimsService.getBiospecimenCount(criteriaModel.getObject());
        }//from   www .  j a  v  a 2 s  .  com

        public Iterator<Biospecimen> iterator(int first, int count) {
            List<Biospecimen> biospecimenList = new ArrayList<Biospecimen>();
            if (ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.SEARCH)) {
                biospecimenList = iLimsService.searchPageableBiospecimens(criteriaModel.getObject(), first,
                        count);
            }
            return biospecimenList.iterator();
        }
    };
    // Set the criteria into the data provider's model
    biospecimenProvider.setCriteriaModel(cpModel);

    dataView = buildDataView(biospecimenProvider);
    dataView.setItemsPerPage(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(dataViewListWMC);
        }
    };

    dataViewListWMC.add(pageNavigator);
    dataViewListWMC.add(dataView);

    List<IColumn<Biospecimen>> columns = new ArrayList<IColumn<Biospecimen>>();
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("BiospecimenUID"), "biospecimenUid"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Study"), "study.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("SubjectUID"), "linkSubjectStudy.subjectUID"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("ParentUID"), "ParentUid"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Collection"), "bioCollection.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Sample Type"), "sampleType.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Quantity"), "quantity"));

    DataTable table = new DataTable("datatable", columns, dataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("BiospecimenUID");
    headers.add("Study");
    headers.add("SubjectUID");
    headers.add("ParentUID");
    headers.add("Collection");
    headers.add("Sample Type");
    headers.add("Quantity");

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

    add(dataViewListWMC);
}