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:eu.uqasar.web.pages.admin.users.UserEditPage.java

License:Apache License

private DataView<TeamMembership> getTeamListing() {
    return new DataView<TeamMembership>("teams", provider = new TeamProvider(user)) {
        @Override/*from   w  w  w  .j  a v a2 s  .c  o m*/
        protected void populateItem(Item<TeamMembership> item) {
            final TeamMembership team = item.getModelObject();
            Check<TeamMembership> check = newDeleteCheck(item);
            List<Role> roles = new ArrayList<>(Arrays.asList(Role.teamAssignableRoles()));
            item.add(check);
            DropDownChoice<Role> roleSelector = new DropDownChoice<>("td.role",
                    new PropertyModel<Role>(team, "role"), roles);
            roleSelector.setNullValid(false);
            item.add(roleSelector);
            BookmarkablePageLink<TeamEditPage> editTeamLink = new BookmarkablePageLink<>("link.edit.team",
                    TeamEditPage.class, new PageParameters().add("id", team.getTeam().getId()));
            editTeamLink.add(new Label("td.teamname", new PropertyModel<>(team.getTeam(), "name")));
            item.add(editTeamLink);
            item.setOutputMarkupId(true);
        }
    };
}

From source file:eu.uqasar.web.pages.tree.projects.panels.ProjectViewPanel.java

License:Apache License

public ProjectViewPanel(String id, final IModel<Project> model) {
    super(id, model);

    project = model.getObject();//from ww  w . j av  a2s  .  c  o  m
    QualityStatus qs = project.getQualityStatus();

    add(new Label("name", new PropertyModel<>(model, "name")));

    Label iconLabel = new Label("icon");
    iconLabel.add(new CssClassNameAppender(project.getIconType().cssClassName()));
    iconLabel.add(new AttributeAppender("class", new Model(qs.getCssClassName()), " "));
    add(iconLabel);

    // TODO only show if authorized to edit
    BookmarkablePageLink<ProjectEditPage> editLink = new BookmarkablePageLink<>("link.edit",
            ProjectEditPage.class, BaseTreePage.forProject(project));
    add(editLink);

    // add quality status and value
    WebMarkupContainer qualityStatus = new WebMarkupContainer("quality.status");
    qualityStatus.add(new CssClassNameAppender(qs.getCssClassName()));
    Label qualityValue = null;
    // Round the value to the nearest integer if possible
    if (project.getValue() == null || project.getValue().isNaN() || project.getValue().isInfinite()) {
        qualityValue = new Label("quality.value", Model.of(project.getValue()));
    } else {
        qualityValue = new Label("quality.value", Model.of(Math.round(project.getValue())));
    }
    qualityValue.add(new CssClassNameAppender(qs.getCssClassName()));
    qualityStatus.add(qualityValue);
    add(qualityStatus);

    add(new Label("nodeKey", new PropertyModel<>(model, "nodeKey")));
    SimpleDateFormat df = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.MEDIUM,
            Session.get().getLocale());
    PatternDateConverter pdc = new PatternDateConverter(df.toPattern(), true);
    add(new DateLabel("startDate", new PropertyModel<Date>(model, "startDate"), pdc));
    add(new DateLabel("endDate", new PropertyModel<Date>(model, "endDate"), pdc));

    // QModel WMC
    qmodelWebMarkUp = new WebMarkupContainer("qmodelWebMarkUp");
    add(qmodelWebMarkUp.add(newLabelWithWMC("qmodel", new PropertyModel<Collection<QModel>>(model, "qmodel"),
            qmodelWebMarkUp)));
    // Product WMC
    productWebMarkUp = new WebMarkupContainer("productWebMarkUp");
    add(productWebMarkUp.add(newLabelWithWMC("product",
            new PropertyModel<Collection<Product>>(model, "product"), productWebMarkUp)));
    // Process WMC
    processWebMarkUp = new WebMarkupContainer("processWebMarkUp");
    add(processWebMarkUp.add(newLabelWithWMC("process",
            new PropertyModel<Collection<Process>>(model, "process"), processWebMarkUp)));

    add(new Label("lastUpdated", new PropertyModel<Date>(model, "lastUpdated")));

    // Threshold indicator
    add(new ThresholdIndicator<>("thresholdIndicator", model));

    add(new Label("formulaAverage", new PropertyModel<>(model, "formulaAverage")));
    add(new Label("lcStage.current", new PropertyModel<LifeCycleStage>(model, "lifeCycleStage"))
            .setRenderBodyOnly(true));

    // Save snapshot button and Modal
    add(saveSnapButton());
    add(saveSnapshotModal = newSaveSnapshotModal());
    add(recoverSnapButton());
    add(recoverSnapshotModal = newRecoverSnapshotModal());

    // Description WMC
    descriptionWebMarkUp = new WebMarkupContainer("descriptionWebMarkUp");
    add(descriptionWebMarkUp
            .add(newLabelWithWMC("description", new PropertyModel<Collection<String>>(model, "description"),
                    descriptionWebMarkUp).setEscapeModelStrings(false)));

    StringResourceModel projectProgressText = new StringResourceModel("progress.status.title", null,
            project.getElapsedDays(), project.getDurationInDays(), project.getDateProgressInPercent(),
            project.getRemainingDays());
    ProgressBar progress = new ProgressBar("progress.bar", Model.of(project.getDateProgressInPercent()));
    add(progress);
    progress.add(new AttributeModifier("title", projectProgressText));

    add(new Label("progress.text", projectProgressText));

    // check for Team tag.
    Label teamLabel;
    List<User> users = getUsersOfAllTeamsPerProject(project);
    if (users.size() == 0) {
        teamLabel = new Label("teamLabelId", "Team:") {
            /**
             * 
             */
            private static final long serialVersionUID = 1L;

            @Override
            public boolean isVisible() {
                return false;
            }
        };
    } else {
        teamLabel = new Label("teamLabelId", "Team:");
    }
    add(teamLabel);
    add(new DataView<User>("users", new ListDataProvider<>(users)) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(Item<User> item) {
            item.add(new LinkableUserBadge("userPanel", item.getModel()).setRenderBodyOnly(true));
        }
    });

    // metadata
    wmcProgLan = new WebMarkupContainer("wmcProgLan");
    wmcItTool = new WebMarkupContainer("wmcItTool");
    wmcScmTool = new WebMarkupContainer("wmcScmTool");
    wmcSaTool = new WebMarkupContainer("wmcSaTool");
    wmcTmTool = new WebMarkupContainer("wmcTmTool");
    wmcCiTool = new WebMarkupContainer("wmcCiTool");
    wmcCtype = new WebMarkupContainer("wmcCtype");
    wmcPtype = new WebMarkupContainer("wmcPtype");
    wmcSwType = new WebMarkupContainer("wmcSwType");
    wmcSwLicense = new WebMarkupContainer("wmcSwLicense");
    wmcTopic = new WebMarkupContainer("wmcTopic");
    wmcSwDevMeth = new WebMarkupContainer("wmcSwDevMeth");

    add(wmcProgLan.add(newLabelWithWMC("progLan",
            new PropertyModel<Collection<ProgrammingLanguage>>(model, "programmingLanguages"), wmcProgLan)),
            wmcItTool.add(newLabelWithWMC("itTool",
                    new PropertyModel<Collection<IssueTrackingTool>>(model, "issueTrackingTools"), wmcItTool)),
            wmcScmTool
                    .add(newLabelWithWMC("scmTool",
                            new PropertyModel<Collection<SourceCodeManagementTool>>(model,
                                    "sourceCodeManagementTools"),
                            wmcScmTool)),
            wmcSaTool.add(newLabelWithWMC("saTool",
                    new PropertyModel<Collection<StaticAnalysisTool>>(model, "staticAnalysisTools"),
                    wmcSaTool)),
            wmcTmTool.add(newLabelWithWMC("tmTool",
                    new PropertyModel<Collection<TestManagementTool>>(model, "testManagementTools"),
                    wmcTmTool)),
            wmcCiTool.add(newLabelWithWMC("ciTool",
                    new PropertyModel<Collection<ContinuousIntegrationTool>>(model,
                            "continuousIntegrationTools"),
                    wmcCiTool)),
            wmcCtype.add(newLabelWithWMC("customerType",
                    new PropertyModel<Collection<CustomerType>>(model, "customerTypes"), wmcCtype)),
            wmcPtype.add(newLabelWithWMC("projectType",
                    new PropertyModel<Collection<ProjectType>>(model, "projectTypes"), wmcPtype)),
            wmcSwType.add(newLabelWithWMC("softwareType",
                    new PropertyModel<Collection<SoftwareType>>(model, "softwareTypes"), wmcSwType)),
            wmcSwLicense.add(newLabelWithWMC("softwareLicense",
                    new PropertyModel<Collection<SoftwareLicense>>(model, "softwareLicenses"), wmcSwLicense)),
            wmcTopic.add(
                    newLabelWithWMC("topic", new PropertyModel<Collection<Topic>>(model, "topics"), wmcTopic)),
            wmcSwDevMeth.add(newLabelWithWMC("softwareDevelopmentMethodology",
                    new PropertyModel<Collection<SoftwareDevelopmentMethodology>>(model,
                            "softwareDevelopmentMethodologies"),
                    wmcSwDevMeth)));

    // check for metadata tag.
    Label metaDataLabel;
    if (model.getObject().getProgrammingLanguages().size() == 0
            && model.getObject().getIssueTrackingTools().size() == 0
            && model.getObject().getSourceCodeManagementTools().size() == 0
            && model.getObject().getStaticAnalysisTools().size() == 0
            && model.getObject().getTestManagementTools().size() == 0
            && model.getObject().getContinuousIntegrationTools().size() == 0
            && model.getObject().getCustomerTypes().size() == 0
            && model.getObject().getProjectTypes().size() == 0
            && model.getObject().getSoftwareTypes().size() == 0
            && model.getObject().getSoftwareLicenses().size() == 0 && model.getObject().getTopics().size() == 0
            && model.getObject().getSoftwareDevelopmentMethodologies().size() == 0) {

        metaDataLabel = new Label("metadataId", "Metadata:") {
            /**
             * 
             */
            private static final long serialVersionUID = 1L;

            @Override
            public boolean isVisible() {
                return false;
            }
        };
    } else {
        metaDataLabel = new Label("metadataId", "Metadata:");
    }
    add(metaDataLabel);

    // Historical data panel with the last 10 values
    // TODO: Panelize this!!
    RepeatingView listOfHistValues = new RepeatingView("listOfHistValues");
    List<HistoricValuesProject> historicValues = historicalDataService
            .getAllHistValuesForProject(project.getId(), 0, 10);
    add(new Label("noOfRegisters", historicalDataService.countHistValuesForProject(project.getId())));
    add(new BookmarkablePageLink<HistoricProjectPage>("historical", HistoricProjectPage.class,
            BaseTreePage.forProject(project)));

    for (HistoricValuesProject value : historicValues) {
        listOfHistValues.add(new Label(listOfHistValues.newChildId(),
                value.getValue() + " / " + value.getDate().toString()));
    }

    add(listOfHistValues);

    // add quality trend chart
    add(new BaseTrendChartPanel<>("trend", model));

}

From source file:fiftyfive.wicket.css.IterationCssBehaviorTestPage.java

License:Apache License

public IterationCssBehaviorTestPage() {
    List<String> list = Arrays.asList("1", "2", "3", "4", "5", "6");
    ListView<String> listView = new ListView<String>("listView", list) {
        @Override//from w  ww .ja v  a  2  s  . c  o  m
        protected void populateItem(ListItem<String> it) {
            it.add(new IterationCssBehavior("odd", "even", "first", "last", "iteration"));
        }
    };
    listView.setViewSize(5);
    add(listView);

    DataView<String> dataView = new DataView<String>("dataView", new ListDataProvider<String>(list)) {
        @Override
        protected void populateItem(Item<String> it) {
            it.add(new IterationCssBehavior("odd", "even", "first", "last", "iteration"));
        }
    };
    dataView.setItemsPerPage(5);
    add(dataView);

    add(newLoop("loop0", 0));
    add(newLoop("loop1", 1));
    add(newLoop("loop2", 2));
}

From source file:fiftyfive.wicket.data.DtoDataProviderTestPage.java

License:Apache License

public DtoDataProviderTestPage() {
    super();/*from w  ww  . j a  v a 2s  .co  m*/

    this.provider = new BeanResultProvider();
    DataView<Bean> dataView = new DataView<Bean>("beans", this.provider) {
        protected void populateItem(Item<Bean> item) {
            item.add(label("label", item.getModel()));
        }
    };
    this.provider.setPageableView(dataView);
    dataView.setItemsPerPage(10);
    add(dataView);

    add(new PagingNavigator("paging", dataView));
}

From source file:guru.mmp.application.web.template.pages.CodeAdministrationPage.java

License:Apache License

/**
 * Constructs a new <code>CodeAdministrationPage</code>.
 *
 * @param previousPage     the previous page
 * @param codeCategoryId   the Universally Unique Identifier (UUID) used to uniquely identify the
 *                         code category the codes are associated with
 * @param codeCategoryName the name of the code category
 *///from  w  w w .j  ava  2s .  c o  m
CodeAdministrationPage(PageReference previousPage, UUID codeCategoryId, String codeCategoryName) {
    super("Codes", codeCategoryName);

    try {
        /*
         * The table container, which allows the table and its associated navigator to be updated
         * using AJAX.
         */
        WebMarkupContainer tableContainer = new WebMarkupContainer("tableContainer");
        tableContainer.setOutputMarkupId(true);
        add(tableContainer);

        // The dialog used to confirm the removal of a code
        RemoveDialog removeDialog = new RemoveDialog(tableContainer);
        add(removeDialog);

        // The "addLink" link
        Link<Void> addLink = new Link<Void>("addLink") {
            private static final long serialVersionUID = 1000000;

            @Override
            public void onClick() {
                AddCodePage page = new AddCodePage(getPageReference(), codeCategoryId);

                setResponsePage(page);
            }
        };
        tableContainer.add(addLink);

        // The "backLink" link
        Link<Void> backLink = new Link<Void>("backLink") {
            private static final long serialVersionUID = 1000000;

            @Override
            public void onClick() {
                setResponsePage(previousPage.getPage());
            }
        };
        tableContainer.add(backLink);

        // The code data view
        CodeDataProvider dataProvider = new CodeDataProvider(codeCategoryId);

        DataView<Code> dataView = new DataView<Code>("code", dataProvider) {
            private static final long serialVersionUID = 1000000;

            @Override
            protected void populateItem(Item<Code> item) {
                Code code = item.getModelObject();

                String name = StringUtil.truncate(code.getName(), 25);
                String value = StringUtil.truncate(code.getValue(), 30);

                item.add(new Label("name", Model.of(name)));
                item.add(new Label("value", Model.of(value)));

                // The "updateLink" link
                Link<Void> updateLink = new Link<Void>("updateLink") {
                    private static final long serialVersionUID = 1000000;

                    @Override
                    public void onClick() {
                        UpdateCodePage page = new UpdateCodePage(getPageReference(), item.getModel());

                        setResponsePage(page);
                    }
                };
                item.add(updateLink);

                // The "removeLink" link
                AjaxLink<Void> removeLink = new AjaxLink<Void>("removeLink") {
                    private static final long serialVersionUID = 1000000;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        removeDialog.show(target, item.getModel());
                    }
                };
                item.add(removeLink);
            }
        };
        dataView.setItemsPerPage(10);
        dataView.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
        tableContainer.add(dataView);

        tableContainer.add(new PagingNavigator("navigator", dataView));
    } catch (Throwable e) {
        throw new WebApplicationException("Failed to initialise the CodeAdministrationPage", e);
    }
}

From source file:guru.mmp.application.web.template.pages.CodeCategoryAdministrationPage.java

License:Apache License

/**
 * Constructs a new <code>CodeCategoryAdministrationPage</code>.
 *///w  ww. ja  v a2 s  .  c o  m
public CodeCategoryAdministrationPage() {
    super("Code Categories");

    try {
        /*
         * The table container, which allows the table and its associated navigator to be updated
         * using AJAX.
         */
        WebMarkupContainer tableContainer = new WebMarkupContainer("tableContainer");
        tableContainer.setOutputMarkupId(true);
        add(tableContainer);

        // The dialog used to confirm the removal of a code category
        RemoveDialog removeDialog = new RemoveDialog(tableContainer);
        add(removeDialog);

        // The "addLink" used to add a new code category
        Link<Void> addLink = new Link<Void>("addLink") {
            private static final long serialVersionUID = 1000000;

            @Override
            public void onClick() {
                setResponsePage(new AddCodeCategoryPage(getPageReference()));
            }
        };
        tableContainer.add(addLink);

        // The code category data view
        CodeCategoryDataProvider dataProvider = new CodeCategoryDataProvider(false);

        DataView<CodeCategory> dataView = new DataView<CodeCategory>("codeCategory", dataProvider) {
            private static final long serialVersionUID = 1000000;

            @Override
            protected void populateItem(Item<CodeCategory> item) {
                item.add(new Label("name", new PropertyModel<String>(item.getModel(), "name")));
                item.add(new Label("categoryType",
                        new PropertyModel<String>(item.getModel(), "categoryType.name")));

                // The "updateLink" link
                Link<Void> updateLink = new Link<Void>("updateLink") {
                    private static final long serialVersionUID = 1000000;

                    @Override
                    public void onClick() {
                        UpdateCodeCategoryPage page = new UpdateCodeCategoryPage(getPageReference(),
                                item.getModel());

                        setResponsePage(page);
                    }
                };
                item.add(updateLink);

                // The "removeLink" link
                AjaxLink<Void> removeLink = new AjaxLink<Void>("removeLink") {
                    private static final long serialVersionUID = 1000000;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        removeDialog.show(target, item.getModel());
                    }
                };
                item.add(removeLink);

                // The "codeAdministrationLink" link
                Link<Void> codeAdministrationLink = new Link<Void>("codeAdministrationLink") {
                    private static final long serialVersionUID = 1000000;

                    @Override
                    public boolean isVisible() {
                        return item.getModelObject().getCategoryType() == CodeCategoryType.LOCAL_STANDARD;
                    }

                    @Override
                    public void onClick() {
                        CodeCategory codeCategory = item.getModelObject();

                        UUID codeCategoryId = codeCategory.getId();
                        String codeCategoryName = codeCategory.getName();

                        setResponsePage(new CodeAdministrationPage(getPageReference(), codeCategoryId,
                                codeCategoryName));
                    }
                };

                item.add(codeAdministrationLink);
            }
        };
        dataView.setItemsPerPage(10);
        dataView.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
        tableContainer.add(dataView);

        tableContainer.add(new PagingNavigator("navigator", dataView));
    } catch (Throwable e) {
        throw new WebApplicationException("Failed to initialise the CodeCategoryAdministrationPage", e);
    }
}

From source file:guru.mmp.application.web.template.pages.ConfigurationAdministrationPage.java

License:Apache License

/**
 * Constructs a new <code>ConfigurationAdministrationPage</code>.
 *///from  ww  w.  jav  a2s.  co  m
public ConfigurationAdministrationPage() {
    super("Configuration");

    try {
        /*
         * The table container, which allows the table and its associated navigator to be updated
         * using AJAX.
         */
        WebMarkupContainer tableContainer = new WebMarkupContainer("tableContainer");
        tableContainer.setOutputMarkupId(true);
        add(tableContainer);

        // The dialog used to confirm the removal of a configuration value
        RemoveDialog removeDialog = new RemoveDialog(tableContainer);
        add(removeDialog);

        // The "addLink" used to add a new configuration value
        Link<Void> addLink = new Link<Void>("addLink") {
            private static final long serialVersionUID = 1000000;

            @Override
            public void onClick() {
                setResponsePage(new AddConfigurationValuePage(getPageReference()));
            }
        };
        tableContainer.add(addLink);

        FilteredConfigurationValueDataProvider dataProvider = new FilteredConfigurationValueDataProvider();

        // The "filterForm" form
        Form<Void> filterForm = new Form<>("filterForm");
        filterForm.setMarkupId("filterForm");
        filterForm.setOutputMarkupId(true);

        // The "filter" field
        TextField<String> filterField = new TextField<>("filter", new PropertyModel<>(dataProvider, "filter"));
        filterForm.add(filterField);

        // The "filterButton" button
        Button filterButton = new Button("filterButton") {
            private static final long serialVersionUID = 1000000;

            @Override
            public void onSubmit() {
            }
        };
        filterButton.setDefaultFormProcessing(true);
        filterForm.add(filterButton);

        // The "resetButton" button
        Button resetButton = new Button("resetButton") {
            private static final long serialVersionUID = 1000000;

            @Override
            public void onSubmit() {
                dataProvider.setFilter("");
            }
        };
        filterForm.add(resetButton);

        tableContainer.add(filterForm);

        // The configuration value data view
        DataView<ConfigurationValue> dataView = new DataView<ConfigurationValue>("configurationValue",
                dataProvider) {
            private static final long serialVersionUID = 1000000;

            @Override
            protected void populateItem(Item<ConfigurationValue> item) {
                item.add(new Label("key", new PropertyModel<String>(item.getModel(), "key")));
                item.add(new Label("value", new PropertyModel<String>(item.getModel(), "value")));

                // The "updateLink" link
                Link<Void> updateLink = new Link<Void>("updateLink") {
                    private static final long serialVersionUID = 1000000;

                    @Override
                    public void onClick() {
                        UpdateConfigurationValuePage page = new UpdateConfigurationValuePage(getPageReference(),
                                item.getModel());

                        setResponsePage(page);
                    }
                };
                item.add(updateLink);

                // The "removeLink" link
                AjaxLink<Void> removeLink = new AjaxLink<Void>("removeLink") {
                    private static final long serialVersionUID = 1000000;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        ConfigurationValue configuration = item.getModelObject();

                        if (configuration != null) {
                            removeDialog.show(target, configuration);
                        } else {
                            target.add(tableContainer);
                        }
                    }
                };
                item.add(removeLink);
            }
        };
        dataView.setItemsPerPage(10);
        dataView.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
        tableContainer.add(dataView);

        tableContainer.add(new PagingNavigator("navigator", dataView));
    } catch (Throwable e) {
        throw new WebApplicationException("Failed to initialise the ConfigurationAdministrationPage", e);
    }
}

From source file:guru.mmp.application.web.template.pages.GroupAdministrationPage.java

License:Apache License

/**
 * Constructs a new <code>GroupAdministrationPage</code>.
 *//*from   w w  w . j a va2 s.  c  o  m*/
public GroupAdministrationPage() {
    super("Groups");

    try {
        /*
         * Retrieve the list of user directories for the organisation the currently logged on user
         * is associated with and default to the first user directory.
         */
        List<UserDirectory> userDirectories = getUserDirectories();

        userDirectory = userDirectories.get(0);

        /*
         * The table container, which allows the table and its associated navigator to be updated
         * using AJAX.
         */
        WebMarkupContainer tableContainer = new WebMarkupContainer("tableContainer");
        tableContainer.setOutputMarkupId(true);
        add(tableContainer);

        // The dialog used to confirm the removal of a group
        RemoveDialog removeDialog = new RemoveDialog(tableContainer);
        add(removeDialog);

        // The "addLink" link
        Link<Void> addLink = new Link<Void>("addLink") {
            private static final long serialVersionUID = 1000000;

            @Override
            public void onClick() {
                AddGroupPage page = new AddGroupPage(getPageReference(), userDirectory.getId());

                setResponsePage(page);
            }
        };
        tableContainer.add(addLink);

        GroupDataProvider dataProvider = new GroupDataProvider(userDirectory.getId());

        // The "userDirectoryDropdownMenu" dropdown button
        DropdownMenu<UserDirectory> userDirectoryDropdownMenu = new DropdownMenu<UserDirectory>(
                "userDirectoryDropdownMenu", new PropertyModel<>(this, "userDirectory"), userDirectories,
                "fa fa-users") {
            @Override
            protected String getDisplayValue(UserDirectory menuItem) {
                return menuItem.getName();
            }

            @Override
            protected void onMenuItemSelected(AjaxRequestTarget target, UserDirectory menuItem) {
                dataProvider.setUserDirectoryId(userDirectory.getId());

                if (target != null) {
                    target.add(tableContainer);
                }
            }
        };
        userDirectoryDropdownMenu.setVisible(userDirectories.size() > 1);
        tableContainer.add(userDirectoryDropdownMenu);

        // The group data view
        DataView<Group> dataView = new DataView<Group>("group", dataProvider) {
            private static final long serialVersionUID = 1000000;

            @Override
            protected void populateItem(Item<Group> item) {
                item.add(new Label("groupName", new PropertyModel<String>(item.getModel(), "groupName")));
                item.add(new Label("description", new PropertyModel<String>(item.getModel(), "description")));

                // The "updateLink" link
                Link<Void> updateLink = new Link<Void>("updateLink") {
                    private static final long serialVersionUID = 1000000;

                    @Override
                    public void onClick() {
                        UpdateGroupPage page = new UpdateGroupPage(getPageReference(), item.getModel());

                        setResponsePage(page);
                    }
                };
                item.add(updateLink);

                // The "removeLink" link
                AjaxLink<Void> removeLink = new AjaxLink<Void>("removeLink") {
                    private static final long serialVersionUID = 1000000;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        Group group = item.getModelObject();

                        if (group != null) {
                            removeDialog.show(target, group);
                        } else {
                            target.add(tableContainer);
                        }
                    }
                };
                item.add(removeLink);
            }
        };
        dataView.setItemsPerPage(10);
        dataView.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
        tableContainer.add(dataView);

        tableContainer.add(new PagingNavigator("navigator", dataView));
    } catch (Throwable e) {
        throw new WebApplicationException("Failed to initialise the GroupAdministrationPage", e);
    }
}

From source file:guru.mmp.application.web.template.pages.JobAdministrationPage.java

License:Apache License

/**
 * Constructs a new <code>JobAdministrationPage</code>.
 *//* ww w .  j a va 2  s. com*/
public JobAdministrationPage() {
    super("Scheduler");

    try {
        /*
         * The table container, which allows the table and its associated navigator to be updated
         * using AJAX.
         */
        WebMarkupContainer tableContainer = new WebMarkupContainer("tableContainer");
        tableContainer.setOutputMarkupId(true);
        add(tableContainer);

        // The dialog used to confirm the removal of a job
        RemoveDialog removeDialog = new RemoveDialog(tableContainer);
        add(removeDialog);

        // The "addLink" used to add a new job
        Link<Void> addLink = new Link<Void>("addLink") {
            private static final long serialVersionUID = 1000000;

            @Override
            public void onClick() {
                AddJobPage page = new AddJobPage(getPageReference());

                setResponsePage(page);
            }
        };
        tableContainer.add(addLink);

        FilteredJobDataProvider dataProvider = new FilteredJobDataProvider();

        // The "filterForm" form
        Form<Void> filterForm = new Form<>("filterForm");
        filterForm.setMarkupId("filterForm");
        filterForm.setOutputMarkupId(true);

        // The "filter" field
        TextField<String> filterField = new TextField<>("filter", new PropertyModel<>(dataProvider, "filter"));
        filterForm.add(filterField);

        // The "filterButton" button
        Button filterButton = new Button("filterButton") {
            private static final long serialVersionUID = 1000000;

            @Override
            public void onSubmit() {
            }
        };
        filterButton.setDefaultFormProcessing(true);
        filterForm.add(filterButton);

        // The "resetButton" button
        Button resetButton = new Button("resetButton") {
            private static final long serialVersionUID = 1000000;

            @Override
            public void onSubmit() {
                dataProvider.setFilter("");
            }
        };
        filterForm.add(resetButton);

        tableContainer.add(filterForm);

        // The job data view
        DataView<Job> dataView = new DataView<Job>("job", dataProvider) {
            private static final long serialVersionUID = 1000000;

            @Override
            protected void populateItem(Item<Job> item) {
                item.add(new Label("name", new PropertyModel<String>(item.getModel(), "name")));
                item.add(new Label("jobClass", new PropertyModel<String>(item.getModel(), "jobClass")));
                item.add(DateLabel.forDatePattern("nextExecution",
                        new PropertyModel<>(item.getModel(), "nextExecution"), "YYYY-MM-dd hh:mm a"));

                // The "parametersLink" link
                Link<Void> parametersLink = new Link<Void>("parametersLink") {
                    private static final long serialVersionUID = 1000000;

                    @Override
                    public void onClick() {
                        //            Job job = item.getModelObject();

                        //            JobParametersPage page = new JobParametersPage(getPageReference(), job.getId());
                        //
                        //            setResponsePage(page);
                    }
                };
                item.add(parametersLink);

                // The "updateLink" link
                Link<Void> updateLink = new Link<Void>("updateLink") {
                    private static final long serialVersionUID = 1000000;

                    @Override
                    public void onClick() {
                        UpdateJobPage page = new UpdateJobPage(getPageReference(), item.getModel());

                        setResponsePage(page);
                    }
                };
                item.add(updateLink);

                // The "removeLink" link
                AjaxLink<Void> removeLink = new AjaxLink<Void>("removeLink") {
                    private static final long serialVersionUID = 1000000;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        Job job = item.getModelObject();

                        if (job != null) {
                            removeDialog.show(target, job);
                        } else {
                            target.add(tableContainer);
                        }
                    }
                };
                item.add(removeLink);
            }
        };
        dataView.setItemsPerPage(10);
        dataView.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
        tableContainer.add(dataView);

        tableContainer.add(new PagingNavigator("navigator", dataView));
    } catch (Throwable e) {
        throw new WebApplicationException("Failed to initialise the JobAdministrationPage", e);
    }
}

From source file:guru.mmp.application.web.template.pages.OrganisationAdministrationPage.java

License:Apache License

/**
 * Constructs a new <code>OrganisationAdministrationPage</code>.
 *//* www .  jav a2s  .  c  o m*/
public OrganisationAdministrationPage() {
    super("Organisations");

    try {
        /*
         * The table container, which allows the table and its associated navigator to be updated
         * using AJAX.
         */
        WebMarkupContainer tableContainer = new WebMarkupContainer("tableContainer");
        tableContainer.setOutputMarkupId(true);
        add(tableContainer);

        // The dialog used to confirm the removal of an organisation
        RemoveDialog removeDialog = new RemoveDialog(tableContainer);
        add(removeDialog);

        // The "addLink" used to add a new organisation
        Link<Void> addLink = new Link<Void>("addLink") {
            private static final long serialVersionUID = 1000000;

            @Override
            public void onClick() {
                setResponsePage(new AddOrganisationPage(getPageReference()));
            }
        };
        tableContainer.add(addLink);

        FilteredOrganisationDataProvider dataProvider = new FilteredOrganisationDataProvider();

        // The "filterForm" form
        Form<Void> filterForm = new Form<>("filterForm");
        filterForm.setMarkupId("filterForm");
        filterForm.setOutputMarkupId(true);

        // The "filter" field
        TextField<String> filterField = new TextField<>("filter", new PropertyModel<>(dataProvider, "filter"));
        filterForm.add(filterField);

        // The "filterButton" button
        Button filterButton = new Button("filterButton") {
            private static final long serialVersionUID = 1000000;

            @Override
            public void onSubmit() {
            }
        };
        filterButton.setDefaultFormProcessing(true);
        filterForm.add(filterButton);

        // The "resetButton" button
        Button resetButton = new Button("resetButton") {
            private static final long serialVersionUID = 1000000;

            @Override
            public void onSubmit() {
                dataProvider.setFilter("");
            }
        };
        filterForm.add(resetButton);

        tableContainer.add(filterForm);

        // The organisation data view
        DataView<Organisation> dataView = new DataView<Organisation>("organisation", dataProvider) {
            private static final long serialVersionUID = 1000000;

            @Override
            protected void populateItem(Item<Organisation> item) {
                item.add(new Label("id", new PropertyModel<String>(item.getModel(), "id")));
                item.add(new Label("name", new PropertyModel<String>(item.getModel(), "name")));

                // The "updateLink" link
                Link<Void> updateLink = new Link<Void>("updateLink") {
                    private static final long serialVersionUID = 1000000;

                    @Override
                    public void onClick() {
                        UpdateOrganisationPage page = new UpdateOrganisationPage(getPageReference(),
                                item.getModel());

                        setResponsePage(page);
                    }
                };
                item.add(updateLink);

                // The "removeLink" link
                AjaxLink<Void> removeLink = new AjaxLink<Void>("removeLink") {
                    private static final long serialVersionUID = 1000000;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        Organisation organisation = item.getModelObject();

                        if (organisation != null) {
                            removeDialog.show(target, organisation);
                        } else {
                            target.add(tableContainer);
                        }
                    }
                };
                item.add(removeLink);
            }
        };
        dataView.setItemsPerPage(10);
        dataView.setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance());
        tableContainer.add(dataView);

        tableContainer.add(new PagingNavigator("navigator", dataView));
    } catch (Throwable e) {
        throw new WebApplicationException("Failed to initialise the OrganisationAdministrationPage", e);
    }
}