Example usage for org.apache.wicket.ajax.markup.html AjaxLink add

List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink add

Introduction

In this page you can find the example usage for org.apache.wicket.ajax.markup.html AjaxLink add.

Prototype

public MarkupContainer add(final Component... children) 

Source Link

Document

Adds the child component(s) to this container.

Usage

From source file:au.org.theark.report.web.component.viewReport.ReportSelectPanel.java

License:Open Source License

@SuppressWarnings({ "unchecked" })
private AjaxLink buildLink(final ReportTemplate reportTemplate) {

    AjaxLink link = new AjaxLink("reportTemplate.link") {

        private static final long serialVersionUID = 1L;

        @Override//w ww .ja  va  2  s  .  c o m
        public void onClick(AjaxRequestTarget target) {
            // Perform security check upon selection of the report
            Subject subject = SecurityUtils.getSubject();
            boolean securityCheckOk = false;
            try {
                String userRole = iArkCommonService.getUserRole(subject.getPrincipal().toString(),
                        reportTemplate.getFunction(), reportTemplate.getModule(),
                        reportSelectCPM.getObject().getStudy());
                if (userRole.length() > 0) {
                    securityCheckOk = true;
                }
            } catch (EntityNotFoundException e) {
                // TODO I don't like this kind of code - if there isn't a record, we should just return NULL.
                // Only if it really is an error to not have a record, then we should throw an exception.
            }

            if (securityCheckOk == false) {
                this.error(
                        "You do not have enough privileges to access this report.  If you believe this is incorrect, then please contact your administrator.");
            } else if (reportTemplate.getName().equals(Constants.STUDY_SUMMARY_REPORT_NAME)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    StudySummaryReportContainer selectedReportPanel = new StudySummaryReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.STUDY_LEVEL_CONSENT_REPORT_NAME)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    StudyLevelConsentReportContainer selectedReportPanel = new StudyLevelConsentReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.STUDY_COMP_CONSENT_REPORT_NAME)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    ConsentDetailsReportContainer selectedReportPanel = new ConsentDetailsReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.PHENO_FIELD_DETAILS_REPORT_NAME)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    PhenoFieldDetailsReportContainer selectedReportPanel = new PhenoFieldDetailsReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.STUDY_USER_ROLE_PERMISSIONS)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    StudyUserRolePermissionsReportContainer selectedReportPanel = new StudyUserRolePermissionsReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.WORK_RESEARCHER_COST_REPORT_NAME)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    WorkResearcherCostReportContainer selectedReportPanel = new WorkResearcherCostReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.WORK_RESEARCHER_DETAIL_COST_REPORT_NAME)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    WorkResearcherDetailCostReportContainer selectedReportPanel = new WorkResearcherDetailCostReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.WORK_STUDY_DETAIL_COST_REPORT_NAME)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    StudyCostReportContainer selectedReportPanel = new StudyCostReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.LIMS_BIOSPECIMEN_SUMMARY_REPORT_NAME)) {
                BiospecimenSummaryReportContainer selectedReportPanel = new BiospecimenSummaryReportContainer(
                        "selectedReportContainerPanel");
                selectedReportPanel.setOutputMarkupId(true);
                // Replace the old selectedReportPanel with this new one
                reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                target.add(reportContainerVO.getSelectedReportContainerWMC());
                this.info(reportTemplate.getName() + " template selected.");

            } else if (reportTemplate.getName().equals(Constants.LIMS_BIOSPECIMEN_DETAIL_REPORT_NAME)) {
                BiospecimenDetailsReportContainer selectedReportPanel = new BiospecimenDetailsReportContainer(
                        "selectedReportContainerPanel");
                selectedReportPanel.setOutputMarkupId(true);
                // Replace the old selectedReportPanel with this new one
                reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                target.add(reportContainerVO.getSelectedReportContainerWMC());
                this.info(reportTemplate.getName() + " template selected.");

            } else {
                this.error("System error: " + reportTemplate.getName()
                        + " has no implementation or has been deprecated.");
            }
            target.add(reportContainerVO.getFeedbackPanel());
        }
    };

    // Add the label for the link
    Label nameLinkLabel = new Label("reportTemplate.name", reportTemplate.getName());
    link.add(nameLinkLabel);
    return link;

}

From source file:au.org.theark.study.web.component.global.subject.SearchResultListPanel.java

License:Open Source License

private AjaxLink buildLink(Item<SubjectVO> item, final AbstractDetailModalWindow modalWindow,
        final List<RelationshipVo> relatives, final FeedbackPanel feedbackPanel) {

    AjaxLink link = null;
    final SubjectVO subject = item.getModelObject();
    if ("Male".equalsIgnoreCase(subject.getLinkSubjectStudy().getPerson().getGenderType().getName())) {
        subject.setParentType("Father");
    } else {/*from  w w w  .  j  a va2s .  com*/
        subject.setParentType("Mother");
    }

    if (isConsiderParentAge(subject)) {
        link = new AjaxConfirmLink(Constants.SUBJECT_UID,
                new StringResourceModel("pedigree.parent.dob.warning", this, item.getModel()),
                item.getModel()) {
            @Override
            public void onClick(AjaxRequestTarget target) {
                processParentSelection(subject, modalWindow, relatives, feedbackPanel, target);
            }
        };
    } else {
        link = new ArkBusyAjaxLink(Constants.SUBJECT_UID) {
            @Override
            public void onClick(AjaxRequestTarget target) {
                processParentSelection(subject, modalWindow, relatives, feedbackPanel, target);
            }
        };
    }
    Label nameLinkLabel = new Label(Constants.SUBJECT_KEY_LBL, subject.getLinkSubjectStudy().getSubjectUID());
    link.add(nameLinkLabel);
    return link;
}

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

License:Open Source License

private AjaxLink buildLink(final ArkUserVO arkUserVo, final WebMarkupContainer searchResultsContainer) {

    AjaxLink link = new AjaxLink("userName") {

        private static final long serialVersionUID = 1L;

        @Override//w  ww  . jav  a 2 s .  c  o m
        public void onClick(AjaxRequestTarget target) {
            try {
                // Fetch the user and related details from backend
                Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession()
                        .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID);
                Study study = iArkCommonService.getStudy(sessionStudyId);

                ArkUserVO arkUserVOFromBackend = iUserService.lookupArkUser(arkUserVo.getUserName(), study);
                if (!arkUserVOFromBackend.isArkUserPresentInDatabase()) {
                    containerForm
                            .info(new StringResourceModel("user.not.linked.to.study", this, null).getString());
                    target.add(feedbackPanel);
                    arkUserVOFromBackend.setChangePassword(true);
                    arkUserVOFromBackend.getArkUserEntity().setLdapUserName(arkUserVo.getUserName());
                    arkUserVOFromBackend.setStudy(new Study());
                    prePopulateForNewUser(arkUserVOFromBackend);
                } else {
                    arkUserVOFromBackend.setStudy(study);
                    prePopulateArkUserRoleList(arkUserVOFromBackend);
                }

                containerForm.getModelObject().setArkUserRoleList(arkUserVOFromBackend.getArkUserRoleList());

                containerForm.setModelObject(arkUserVOFromBackend);

                // This triggers the call to populateItem() of the ListView
                ListView listView = (ListView) arkCrudContainerVO.getWmcForarkUserAccountPanel()
                        .get("arkUserRoleList");
                if (listView != null) {
                    listView.removeAll();
                }

                arkCrudContainerVO.getWmcForarkUserAccountPanel().setVisible(true);
                ArkCRUDHelper.preProcessDetailPanelOnSearchResults(target, arkCrudContainerVO);
                target.add(feedbackPanel);
                // Set the MODE here.Since the User Details are from LDAP we don't have a entity that we can use to check for a mode
                containerForm.getModelObject().setMode(Constants.MODE_EDIT);

                // Available/assigned child studies
                List<Study> availableChildStudies = new ArrayList<Study>(0);
                List<Study> selectedChildStudies = new ArrayList<Study>(0);

                if (study.getParentStudy() != null && study.getParentStudy() == study) {
                    availableChildStudies = iStudyService.getChildStudyListOfParent(study);

                    // Only assign selected child studies if/when user actually assigned study in context
                    if (arkUserVOFromBackend.getStudy().getId() != null) {
                        selectedChildStudies = iArkCommonService
                                .getAssignedChildStudyListForUser(arkUserVOFromBackend);
                    }
                }

                containerForm.getModelObject().setAvailableChildStudies(availableChildStudies);
                containerForm.getModelObject().setSelectedChildStudies(selectedChildStudies);
            } catch (ArkSystemException e) {
                containerForm.error(new StringResourceModel("ark.system.error", this, null).getString());
                target.add(feedbackPanel);
            }
        }
    };
    // Add the label for the link
    Label userNameLinkLabel = new Label("userNameLink", arkUserVo.getUserName());
    link.add(userNameLinkLabel);
    return link;
}

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

License:Open Source License

private AjaxLink buildLink(Item<SubjectVO> item, final AbstractDetailModalWindow modalWindow,
        final List<RelationshipVo> relatives, final FeedbackPanel feedbackPanel) {

    AjaxLink link = null;
    final SubjectVO subject = item.getModelObject();
    if ("Male".equalsIgnoreCase(subject.getLinkSubjectStudy().getPerson().getGenderType().getName())) {
        subject.setParentType("Father");
    } else {/*  w  w  w  .jav a  2  s  .  c o m*/
        subject.setParentType("Mother");
    }

    Boolean inbreedAllowed = (Boolean) SecurityUtils.getSubject().getSession()
            .getAttribute(Constants.INBREED_ALLOWED);

    if (BooleanUtils.isTrue(inbreedAllowed)) {
        final String result = getCircularRelationships(subject, relatives);
        item.getModelObject().setMessage(result);
        if (isConsiderParentAge(subject) && result != null) {
            link = new AjaxConfirmLink(Constants.SUBJECT_UID,
                    new StringResourceModel("pedigree.parent.dob.circular.warning", this, item.getModel()),
                    item.getModel()) {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    processParentSelection(subject, modalWindow, relatives, feedbackPanel, target);
                }
            };
        } else if (isConsiderParentAge(subject)) {
            link = new AjaxConfirmLink(Constants.SUBJECT_UID,
                    new StringResourceModel("pedigree.parent.dob.warning", this, item.getModel()),
                    item.getModel()) {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    processParentSelection(subject, modalWindow, relatives, feedbackPanel, target);
                }
            };
        } else if (result != null) {
            link = new AjaxConfirmLink(Constants.SUBJECT_UID,
                    new StringResourceModel("pedigree.parent.circular.warning", this, item.getModel()),
                    item.getModel()) {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    processParentSelection(subject, modalWindow, relatives, feedbackPanel, target);
                }
            };
        } else {
            link = new ArkBusyAjaxLink(Constants.SUBJECT_UID) {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    processParentSelection(subject, modalWindow, relatives, feedbackPanel, target);
                }
            };
        }

    } else {
        if (isConsiderParentAge(subject)) {
            link = new AjaxConfirmLink(Constants.SUBJECT_UID,
                    new StringResourceModel("pedigree.parent.dob.warning", this, item.getModel()),
                    item.getModel()) {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    processParentSelection(subject, modalWindow, relatives, feedbackPanel, target);
                }
            };
        } else {
            link = new ArkBusyAjaxLink(Constants.SUBJECT_UID) {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    processParentSelection(subject, modalWindow, relatives, feedbackPanel, target);
                }
            };
        }
    }
    Label nameLinkLabel = new Label(Constants.SUBJECT_KEY_LBL, subject.getLinkSubjectStudy().getSubjectUID());
    link.add(nameLinkLabel);
    return link;
}

From source file:ca.travelagency.traveler.SelectPanel.java

License:Apache License

public SelectPanel(String id, final IModel<Traveler> model, final Form<InvoiceTraveler> travelerForm,
        final ModalWindow modalWindow) {
    super(id);//from   w  w  w .  j ava  2  s .  c o  m

    AjaxLink<Void> link = new AjaxLink<Void>(LINK) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            travelerForm.getModelObject().copy(model.getObject());
            target.add(travelerForm);
            modalWindow.close(target);
            target.appendJavaScript(JSUtils.INITIALIZE);
        }
    };
    link.add(new Label(LABEL, Model.of(model.getObject().getName())));
    add(link);
}

From source file:ch.bd.qv.quiz.panels.LangPanel.java

License:Apache License

public LangPanel(String id) {
    super(id);//from  w  w  w .  j  a va2  s  .  c o m
    LOGGER.debug("lang received on panel: " + Joiner.on(":").join(supportedLocales.iterator()));
    add(new ListView<Locale>("list", supportedLocales) {
        @Override
        protected void populateItem(final ListItem<Locale> item) {

            AjaxLink<Void> langLink = new AjaxLink<Void>("lang") {
                @Override
                public void onClick(AjaxRequestTarget target) {
                    getSession().setLocale(item.getModelObject());
                    BasePanel bp = findParent(BasePanel.class);
                    bp.driveNavigation();
                    target.add(bp);
                }
            };
            langLink.add(new Label("label", new LoadableDetachableModel<String>() {
                @Override
                protected String load() {
                    LOGGER.debug("item: " + item.getModelObject());
                    return item.getModelObject().getLanguage().toUpperCase();
                }
            }));
            item.add(langLink);
        }
    });

}

From source file:ch.difty.scipamato.common.web.component.table.column.LinkIconPanel.java

License:Apache License

private AjaxLink<Void> makeLink() {
    AjaxLink<Void> link = new AjaxLink<Void>(ID_LINK) {
        private static final long serialVersionUID = 1L;

        @Override/* w w  w . j a  v a2s .c om*/
        public void onClick(AjaxRequestTarget target) {
            onClickPerformed(target);
        }
    };
    link.add(makeImage(ID_IMAGE));
    link.setOutputMarkupId(true);
    return link;
}

From source file:com.axway.ats.testexplorer.pages.reports.compare.ComparePage.java

License:Apache License

private ListView<PluginParameters> getCustomRunsCompareButtons() {

    // Add buttons that will create some reports about the selected runs
    List<PluginParameters> pluginParameters = TestExplorerPluginsRepo.getInstance()
            .getPluginParameters(PluginConfigurationParser.PLUGIN_TYPE.COMPARE_RUNS_REPORT);
    // add plugin buttons, clicking a button forwards to the plugin web page 
    ListView<PluginParameters> reportButtons = new ListView<PluginParameters>("runs_compare_plugin_buttons",
            pluginParameters) {//from   w w  w .  j  av a 2 s.c om

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<PluginParameters> item) {

            final PluginParameters pluginParameters = item.getModelObject();

            AjaxLink<String> aReportButton = new AjaxLink<String>("runs_compare_plugin_button") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {

                    StringBuilder sb = new StringBuilder();
                    Map<Run, Model<Boolean>> runs = getTESession().getCompareContainer().getRuns();
                    for (Run r : runs.keySet()) {
                        if (runs.get(r).getObject()) {
                            sb.append(String.valueOf(r.runId));
                            sb.append("_");
                        }
                    }
                    if (sb.length() > 0) {

                        PageParameters parameters = new PageParameters();
                        parameters.add("runIds", sb.substring(0, sb.length() - 1));
                        //pass database name
                        parameters.add("dbname", ((TestExplorerSession) Session.get()).getDbName());
                        setResponsePage(pluginParameters.getPluginClass(), parameters);
                    }
                }
            };
            aReportButton.add(new Label("button_name", pluginParameters.getButtonName()));
            item.add(aReportButton);
        }
    };
    return reportButtons;
}

From source file:com.axway.ats.testexplorer.pages.reports.compare.ComparePage.java

License:Apache License

private ListView<PluginParameters> getCustomTestcasesCompareButtons() {

    // Add buttons that will create some reports about the selected testcases
    List<PluginParameters> pluginParameters = TestExplorerPluginsRepo.getInstance()
            .getPluginParameters(PluginConfigurationParser.PLUGIN_TYPE.COMPARE_TESTCASES_REPORT);
    // add plugin buttons, clicking a button forwards to the plugin web page 
    ListView<PluginParameters> reportButtons = new ListView<PluginParameters>(
            "testcases_compare_plugin_buttons", pluginParameters) {

        private static final long serialVersionUID = 1L;

        @Override/*from  w  ww.  j a va  2s  .c  om*/
        protected void populateItem(final ListItem<PluginParameters> item) {

            final PluginParameters pluginParameters = item.getModelObject();

            AjaxLink<String> aReportButton = new AjaxLink<String>("testcases_compare_plugin_button") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {

                    StringBuilder sb = new StringBuilder();
                    Map<Testcase, Model<Boolean>> testcases = getTESession().getCompareContainer()
                            .getTestcases();
                    for (Testcase t : testcases.keySet()) {
                        if (testcases.get(t).getObject()) {
                            sb.append(String.valueOf(t.testcaseId));
                            sb.append("_");
                        }
                    }
                    if (sb.length() > 0) {

                        PageParameters parameters = new PageParameters();
                        parameters.add("testcaseIds", sb.substring(0, sb.length() - 1));
                        setResponsePage(pluginParameters.getPluginClass(), parameters);
                    }
                }
            };
            aReportButton.add(new Label("button_name", pluginParameters.getButtonName()));
            item.add(aReportButton);
        }
    };
    return reportButtons;
}

From source file:com.axway.ats.testexplorer.pages.reports.testcase.SelectTestcaseReportPage.java

License:Apache License

public SelectTestcaseReportPage(PageParameters parameters) {

    super(parameters);

    testcaseId = TestExplorerUtils.extractPageParameter(parameters, "testcaseId");

    WebMarkupContainer mainContainer = new WebMarkupContainer("mainContainer");
    add(mainContainer);/*from  w ww.  j a  v  a2s.  c om*/

    PageNavigation navigation;
    try {
        navigation = ((TestExplorerSession) Session.get()).getDbReadConnection()
                .getNavigationForTestcase(testcaseId, getTESession().getTimeOffset());
    } catch (DatabaseAccessException e) {
        error("Could not read info about testcase with id " + testcaseId + "; CAUSE: " + e.getMessage());

        mainContainer.setVisible(false);
        return;
    }

    // Add fields describing the selected testcase
    TextField<String> runNameTextField = new TextField<String>("run_name",
            new Model<String>(navigation.getRunName()));
    runNameTextField.setEnabled(false);
    mainContainer.add(runNameTextField);

    TextField<String> runIdTextField = new TextField<String>("run_id",
            new Model<String>(navigation.getRunId()));
    runIdTextField.setEnabled(false);
    mainContainer.add(runIdTextField);

    TextField<String> suiteNameTextField = new TextField<String>("suite_name",
            new Model<String>(navigation.getSuiteName()));
    suiteNameTextField.setEnabled(false);
    mainContainer.add(suiteNameTextField);

    TextField<String> scenarioNameTextField = new TextField<String>("scenario_name",
            new Model<String>(navigation.getScenarioName()));
    scenarioNameTextField.setEnabled(false);
    mainContainer.add(scenarioNameTextField);

    TextField<String> testcaseNameTextField = new TextField<String>("testcase_name",
            new Model<String>(navigation.getTestcaseName()));
    testcaseNameTextField.setEnabled(false);
    mainContainer.add(testcaseNameTextField);

    TextField<String> testcaseIdTextField = new TextField<String>("testcase_id", new Model<String>(testcaseId));
    testcaseIdTextField.setEnabled(false);
    mainContainer.add(testcaseIdTextField);

    // Add buttons that will create some reports about the selected testcase
    List<PluginParameters> pluginParameters = TestExplorerPluginsRepo.getInstance()
            .getPluginParameters(PluginConfigurationParser.PLUGIN_TYPE.SINGLE_TESTCASE_REPORT);

    // add plugin buttons, clicking a button forwards to the plugin web page 
    ListView<PluginParameters> reportButtons = new ListView<PluginParameters>("report_buttons",
            pluginParameters) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<PluginParameters> item) {

            final PluginParameters pluginParameters = item.getModelObject();

            AjaxLink<String> aReportButton = new AjaxLink<String>("report_button") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {

                    if (!StringUtils.isNullOrEmpty(testcaseId)) {

                        PageParameters parameters = new PageParameters();
                        parameters.add("testcaseId", String.valueOf(testcaseId));

                        setResponsePage(pluginParameters.getPluginClass(), parameters);
                    }
                }
            };
            aReportButton.add(new Label("button_name", pluginParameters.getButtonName()));
            item.add(aReportButton);
        }
    };
    mainContainer.add(reportButtons);
}