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

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

Introduction

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

Prototype

protected DataView(String id, IDataProvider<T> dataProvider) 

Source Link

Usage

From source file:au.org.theark.admin.web.component.function.SearchResultsPanel.java

License:Open Source License

@SuppressWarnings("unchecked")
public DataView<ArkFunction> buildDataView(ArkDataProvider<ArkFunction, IAdminService> dataProvider) {
    DataView<ArkFunction> dataView = new DataView<ArkFunction>("arkFunctionList", dataProvider) {

        private static final long serialVersionUID = 2981419595326128410L;

        @Override/* www  .  j av a 2s.c  o m*/
        protected void populateItem(final Item<ArkFunction> item) {
            ArkFunction arkFunction = item.getModelObject();

            item.add(new Label("arkFunction.id", arkFunction.getId().toString()));
            item.add(buildLink(arkFunction));

            if (arkFunction.getDescription() != null) {
                // the ID here must match the ones in mark-up
                item.add(new Label("arkFunction.description", arkFunction.getDescription()));
            } else {
                item.add(new Label("arkFunction.description", ""));
            }

            if (arkFunction.getArkFunctionType() != null) {
                // the ID here must match the ones in mark-up
                item.add(new Label("arkFunction.arkFunctionType", arkFunction.getArkFunctionType().getName()));
            } else {
                item.add(new Label("arkFunction.arkFunctionType", ""));
            }

            item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 5761909841047153853L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));
        }
    };
    return dataView;
}

From source file:au.org.theark.admin.web.component.module.SearchResultsPanel.java

License:Open Source License

@SuppressWarnings("unchecked")
public DataView<ArkModule> buildDataView(ArkDataProvider<ArkModule, IAdminService> dataProvider) {
    DataView<ArkModule> dataView = new DataView<ArkModule>("arkModuleList", dataProvider) {

        private static final long serialVersionUID = 2981419595326128410L;

        @Override//from  ww  w. j  ava2  s  . c  om
        protected void populateItem(final Item<ArkModule> item) {
            ArkModule arkModule = item.getModelObject();

            item.add(new Label("arkModule.id", arkModule.getId().toString()));

            item.add(buildLink(arkModule));

            if (arkModule.getDescription() != null) {
                // the ID here must match the ones in mark-up
                item.add(new Label("arkModule.description", arkModule.getDescription()));
            } else {
                item.add(new Label("arkModule.description", ""));
            }

            item.add(new Label("arkModule.enabled", arkModule.getEnabled() ? "Enabled" : "Disabled"));

            item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 5761909841047153853L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));
        }
    };
    return dataView;
}

From source file:au.org.theark.admin.web.component.modulefunction.SearchResultsPanel.java

License:Open Source License

@SuppressWarnings("unchecked")
public DataView<ArkModuleFunction> buildDataView(
        ArkDataProvider<ArkModuleFunction, IAdminService> dataProvider) {
    DataView<ArkModuleFunction> dataView = new DataView<ArkModuleFunction>("arkModuleFunctionList",
            dataProvider) {/*w  ww  . ja v  a2s.c om*/

        private static final long serialVersionUID = 2981419595326128410L;

        @Override
        protected void populateItem(final Item<ArkModuleFunction> item) {
            ArkModuleFunction arkModuleFunction = item.getModelObject();

            item.add(new Label("arkModuleFunction.id", arkModuleFunction.getId().toString()));

            item.add(buildLink(arkModuleFunction));

            if (arkModuleFunction.getArkFunction() != null) {
                item.add(new Label("arkModuleFunction.arkFunction",
                        arkModuleFunction.getArkFunction().getName()));
            } else {
                item.add(new Label("arkModuleFunction.arkFunction", ""));
            }

            if (arkModuleFunction.getFunctionSequence() != null) {
                item.add(new Label("arkModuleFunction.functionSequence",
                        arkModuleFunction.getFunctionSequence().toString()));
            } else {
                item.add(new Label("arkModuleFunction.functionSequence", ""));
            }

            item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 5761909841047153853L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));
        }
    };
    return dataView;
}

From source file:au.org.theark.admin.web.component.modulerole.SearchResultsPanel.java

License:Open Source License

@SuppressWarnings("unchecked")
public DataView<ArkModuleRole> buildDataView(ArkDataProvider<ArkModuleRole, IAdminService> dataProvider) {
    DataView<ArkModuleRole> dataView = new DataView<ArkModuleRole>("arkModuleRoleList", dataProvider) {

        private static final long serialVersionUID = 1L;

        @Override/*from   ww  w .j av a  2  s .c o m*/
        protected void populateItem(final Item<ArkModuleRole> item) {
            ArkModuleRole arkModuleRole = item.getModelObject();

            item.add(new Label("arkModuleRole.id", arkModuleRole.getId().toString()));

            item.add(buildLink(arkModuleRole));

            if (arkModuleRole.getArkRole() != null) {
                item.add(new Label("arkModuleRole.arkRole", arkModuleRole.getArkRole().getName()));
            } else {
                item.add(new Label("arkModuleRole.arkRole", ""));
            }

            item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 5761909841047153853L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));
        }
    };
    return dataView;
}

From source file:au.org.theark.admin.web.component.role.SearchResultsPanel.java

License:Open Source License

@SuppressWarnings("unchecked")
public DataView<ArkRole> buildDataView(ArkDataProvider<ArkRole, IAdminService> dataProvider) {
    DataView<ArkRole> dataView = new DataView<ArkRole>("arkRoleList", dataProvider) {

        private static final long serialVersionUID = 2981419595326128410L;

        @Override//from w  w w.j a  va2  s. c om
        protected void populateItem(final Item<ArkRole> item) {
            ArkRole arkRole = item.getModelObject();

            item.add(new Label("arkRole.id", arkRole.getId().toString()));

            item.add(buildLink(arkRole));

            if (arkRole.getDescription() != null) {
                // the ID here must match the ones in mark-up
                item.add(new Label("arkRole.description", arkRole.getDescription()));
            } else {
                item.add(new Label("arkRole.description", ""));
            }

            item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 5761909841047153853L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));
        }
    };
    return dataView;
}

From source file:au.org.theark.admin.web.component.rolePolicy.SearchResultsPanel.java

License:Open Source License

@SuppressWarnings("unchecked")
public DataView<ArkRoleModuleFunctionVO> buildDataView(
        ArkDataProvider<ArkRoleModuleFunctionVO, IAdminService> dataProvider) {
    DataView<ArkRoleModuleFunctionVO> dataView = new DataView<ArkRoleModuleFunctionVO>(
            "arkRoleModuleFunctionVoList", dataProvider) {

        private static final long serialVersionUID = -7977497161071264676L;

        @Override//from   w  w w.  j  ava2  s. c  o  m
        protected void populateItem(final Item<ArkRoleModuleFunctionVO> item) {

            final ArkRoleModuleFunctionVO arkRoleModuleFunctionVo = item.getModelObject();
            item.setOutputMarkupId(true);
            item.setOutputMarkupPlaceholderTag(true);

            WebMarkupContainer rowEditWMC = new WebMarkupContainer("rowEditWMC", item.getModel());
            AjaxButton listEditButton = new AjaxButton("listEditButton",
                    new StringResourceModel(au.org.theark.core.Constants.EDIT, this, null)) {
                private static final long serialVersionUID = 197521505680635043L;

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    item.setEnabled(true);
                    item.get("arkCreatePermissionImg").setVisible(false);
                    item.get("arkReadPermissionImg").setVisible(false);
                    item.get("arkUpdatePermissionImg").setVisible(false);
                    item.get("arkDeletePermissionImg").setVisible(false);
                    item.addOrReplace(new CheckBox("arkCreatePermission",
                            new PropertyModel(arkRoleModuleFunctionVo, "arkCreatePermission"))
                                    .setEnabled(true));
                    item.addOrReplace(new CheckBox("arkReadPermission",
                            new PropertyModel(arkRoleModuleFunctionVo, "arkReadPermission")).setEnabled(true));
                    item.addOrReplace(new CheckBox("arkUpdatePermission",
                            new PropertyModel(arkRoleModuleFunctionVo, "arkUpdatePermission"))
                                    .setEnabled(true));
                    item.addOrReplace(new CheckBox("arkDeletePermission",
                            new PropertyModel(arkRoleModuleFunctionVo, "arkDeletePermission"))
                                    .setEnabled(true));
                    item.get("rowSaveWMC").setVisible(true);
                    target.add(item);
                }

                @Override
                protected void onError(AjaxRequestTarget target, Form<?> form) {
                    log.error("onError called when listEditButton pressed");
                }
            };
            listEditButton.setDefaultFormProcessing(false);
            rowEditWMC.add(listEditButton);
            item.add(rowEditWMC);

            if (arkRoleModuleFunctionVo.getArkRole() != null) {
                item.add(new Label("arkRole", arkRoleModuleFunctionVo.getArkRole().getName()));
            } else {
                item.add(new Label("arkRole", ""));
            }

            if (arkRoleModuleFunctionVo.getArkModule() != null) {
                item.add(new Label("arkModule", arkRoleModuleFunctionVo.getArkModule().getName()));
            } else {
                item.add(new Label("arkModule", ""));
            }

            if (arkRoleModuleFunctionVo.getArkFunction() != null) {
                item.add(new Label("arkFunction", arkRoleModuleFunctionVo.getArkFunction().getName()));
            } else {
                item.add(new Label("arkFunction", ""));
            }

            if (arkRoleModuleFunctionVo.getArkCreatePermission()) {
                item.addOrReplace(
                        new ContextImage("arkCreatePermissionImg", new Model<String>("images/icons/tick.png")));
            } else {
                item.addOrReplace(new ContextImage("arkCreatePermissionImg",
                        new Model<String>("images/icons/cross.png")));
            }

            if (arkRoleModuleFunctionVo.getArkReadPermission()) {
                item.addOrReplace(
                        new ContextImage("arkReadPermissionImg", new Model<String>("images/icons/tick.png")));
            } else {
                item.addOrReplace(
                        new ContextImage("arkReadPermissionImg", new Model<String>("images/icons/cross.png")));
            }

            if (arkRoleModuleFunctionVo.getArkUpdatePermission()) {
                item.addOrReplace(
                        new ContextImage("arkUpdatePermissionImg", new Model<String>("images/icons/tick.png")));
            } else {
                item.addOrReplace(new ContextImage("arkUpdatePermissionImg",
                        new Model<String>("images/icons/cross.png")));
            }

            if (arkRoleModuleFunctionVo.getArkDeletePermission()) {
                item.addOrReplace(
                        new ContextImage("arkDeletePermissionImg", new Model<String>("images/icons/tick.png")));
            } else {
                item.addOrReplace(new ContextImage("arkDeletePermissionImg",
                        new Model<String>("images/icons/cross.png")));
            }

            item.addOrReplace(new CheckBox("arkCreatePermission",
                    new PropertyModel(arkRoleModuleFunctionVo, "arkCreatePermission")).setVisible(false));
            item.addOrReplace(new CheckBox("arkReadPermission",
                    new PropertyModel(arkRoleModuleFunctionVo, "arkReadPermission")).setVisible(false));
            item.addOrReplace(new CheckBox("arkUpdatePermission",
                    new PropertyModel(arkRoleModuleFunctionVo, "arkUpdatePermission")).setVisible(false));
            item.addOrReplace(new CheckBox("arkDeletePermission",
                    new PropertyModel(arkRoleModuleFunctionVo, "arkDeletePermission")).setVisible(false));

            WebMarkupContainer rowSaveWMC = new WebMarkupContainer("rowSaveWMC", item.getModel());
            AjaxButton listSaveButton = new AjaxButton("listSaveButton",
                    new StringResourceModel(au.org.theark.core.Constants.SAVE, this, null)) {
                private static final long serialVersionUID = -7382768898426488999L;

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    onSave(target, arkRoleModuleFunctionVo);
                    target.add(SearchResultsPanel.this);
                    target.add(feedbackPanel);
                }

                @Override
                protected void onError(AjaxRequestTarget target, Form<?> form) {
                    log.error("onError called when listSaveButton pressed");
                }
            };
            rowSaveWMC.add(listSaveButton);
            rowSaveWMC.setVisible(false);
            item.add(rowSaveWMC);

            item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1938679383897533820L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));
        }
    };
    return dataView;
}

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

License:Open Source License

public DataView<CustomField> buildDataView(ArkDataProvider2<CustomField, CustomField> subjectProvider) {

    DataView<CustomField> customFieldDataView = new DataView<CustomField>("customFieldList", subjectProvider) {

        @Override/*from  w  w  w.j  a va 2  s.  co  m*/
        protected void populateItem(final Item<CustomField> item) {
            CustomField field = item.getModelObject();

            if (field.getId() != null) {
                // Add the id component here
                item.add(new Label(Constants.CUSTOMFIELD_ID, field.getId().toString()));
            } else {
                item.add(new Label(Constants.CUSTOMFIELD_ID, ""));
            }

            // Component Name Link
            item.add(buildLinkWMC(item));
            // Field Type
            if (field.getFieldType() != null) {
                item.add(new Label(Constants.CUSTOMFIELD_FIELD_TYPE, field.getFieldType().getName()));
            } else {
                item.add(new Label(Constants.CUSTOMFIELD_FIELD_TYPE, ""));
            }
            // Field Label
            if (field.getFieldLabel() != null) {
                item.add(new Label(Constants.CUSTOMFIELD_FIELD_LABEL, field.getFieldLabel()));
            } else {
                item.add(new Label(Constants.CUSTOMFIELD_FIELD_LABEL, ""));
            }
            // custom field type
            if (field.getCustomFieldType() != null) {
                item.add(new Label(Constants.CUSTOMFIELD_CUSTOME_FIELD_TYPE,
                        field.getCustomFieldType().getName()));
            } else {
                item.add(new Label(Constants.CUSTOMFIELD_CUSTOME_FIELD_TYPE, ""));
            }
            //custom file category
            if (field.getCustomFieldCategory() != null) {
                item.add(new Label(Constants.CUSTOMFIELD_CATEGORY, field.getCustomFieldCategory().getName()));
            } else {
                item.add(new Label(Constants.CUSTOMFIELD_CATEGORY, ""));
            }
            //custom file category order number
            if (field.getCustomFieldCategory() != null
                    && field.getCustomFieldCategory().getOrderNumber() != null) {
                item.add(new Label(Constants.CUSTOMFIELD_CATEGORY_ORDERNUMBER,
                        field.getCustomFieldCategory().getOrderNumber().toString()));
            } else {
                item.add(new Label(Constants.CUSTOMFIELD_CATEGORY_ORDERNUMBER, ""));
            }
            /* For the alternative stripes */
            item.add(new AttributeModifier("class", new AbstractReadOnlyModel() {
                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));

        }
    };

    addToolbars(customFieldDataView);

    return customFieldDataView;
}

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

License:Open Source License

public DataView<CustomFieldCategory> buildDataView(
        ArkDataProvider2<CustomFieldCategory, CustomFieldCategory> subjectProvider) {

    DataView<CustomFieldCategory> customFieldCategoryDataView = new DataView<CustomFieldCategory>(
            "customFieldCategoryList", subjectProvider) {
        @Override//from  w ww.ja va  2s  .c  o  m
        protected void populateItem(final Item<CustomFieldCategory> item) {
            CustomFieldCategory category = item.getModelObject();
            //id
            if (category.getId() != null) {
                item.add(new Label(Constants.CUSTOMFIELDCATEGORY_ID, category.getId().toString()));
            } else {
                item.add(new Label(Constants.CUSTOMFIELDCATEGORY_ID, ""));
            }
            // Component Name Link
            item.add(buildLinkWMC(item));

            //Custom Field Name
            if (category.getCustomFieldType() != null) {
                item.add(new Label(Constants.FIELDVO_CUSTOMFIELDCATEGORY_CUSTOM_FIELD_TYPE_NAME,
                        category.getCustomFieldType().getName()));
            } else {
                item.add(new Label(Constants.FIELDVO_CUSTOMFIELDCATEGORY_CUSTOM_FIELD_TYPE_NAME, ""));
            }

            // Description
            if (category.getDescription() != null) {
                item.add(new Label(Constants.CUSTOMFIELDCATEGORY_DESCRIPTION, category.getDescription()));
            } else {
                item.add(new Label(Constants.CUSTOMFIELDCATEGORY_DESCRIPTION, ""));
            }
            //Parent Category
            if (category.getParentCategory() != null) {
                item.add(new Label(Constants.FIELDVO_CUSTOMFIELDCATEGORY_PARENTCATEGORY_NAME,
                        category.getParentCategory().getName()));
            } else {
                item.add(new Label(Constants.FIELDVO_CUSTOMFIELDCATEGORY_PARENTCATEGORY_NAME, ""));
            }

            //Order Number
            if (category.getOrderNumber() != null) {
                item.add(new Label(Constants.CUSTOMFIELDCATEGORY_ORDERNUMBER,
                        category.getOrderNumber().toString()));
            } else {
                item.add(new Label(Constants.CUSTOMFIELDCATEGORY_ORDERNUMBER, ""));
            }

            /* For the alternative stripes */
            item.add(new AttributeModifier("class", new AbstractReadOnlyModel() {
                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? "even" : "odd";
                }
            }));

        }
    };

    addToolbars(customFieldCategoryDataView);

    return customFieldCategoryDataView;
}

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

License:Open Source License

public DataView<DiseaseVO> buildDataView(ArkDataProvider<DiseaseVO, IArkDiseaseService> diseaseProvider) {

    DataView<DiseaseVO> studyCompDataView = new DataView<DiseaseVO>("diseaseList", diseaseProvider) {

        @Override//from w w w . j a  va  2 s .  c o  m
        protected void populateItem(final Item<DiseaseVO> item) {
            Disease disease = item.getModelObject().getDisease();
            item.add(new Label("disease.id", disease.getId().toString()));
            item.add(buildLink(item.getModelObject()));

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

From source file:au.org.theark.disease.web.component.gene.SearchResultListPanel.java

License:Open Source License

public DataView<GeneVO> buildDataView(ArkDataProvider<GeneVO, IArkDiseaseService> diseaseProvider) {

    DataView<GeneVO> studyCompDataView = new DataView<GeneVO>("diseaseList", diseaseProvider) {

        @Override/*from ww w  .  j a  v a 2 s.  co m*/
        protected void populateItem(final Item<GeneVO> item) {
            Gene gene = item.getModelObject().getGene();

            item.add(new Label("gene.id", gene.getId().toString()));

            item.add(buildLink(item.getModelObject()));

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