Example usage for org.apache.wicket.markup.html.basic Label setDefaultModelObject

List of usage examples for org.apache.wicket.markup.html.basic Label setDefaultModelObject

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.basic Label setDefaultModelObject.

Prototype

@SuppressWarnings("unchecked")
public final Component setDefaultModelObject(final Object object) 

Source Link

Document

Sets the backing model object.

Usage

From source file:au.org.theark.study.web.component.managestudy.form.SearchForm.java

License:Open Source License

@SuppressWarnings("unchecked")
protected void onNew(AjaxRequestTarget target) {
    containerForm.setModelObject(new StudyModelVO());
    Collection<ArkModule> availableArkModules = new ArrayList<ArkModule>();
    availableArkModules = iArkCommonService.getEntityList(ArkModule.class);
    // Hide Admin and Reporting modules from "Available" view
    availableArkModules.remove(iArkCommonService.getArkModuleByName(ModuleConstants.ARK_MODULE_ADMIN));
    //availableArkModules.remove(iArkCommonService.getArkModuleByName(ModuleConstants.ARK_MODULE_REPORTING));

    containerForm.getModelObject().setAvailableArkModules(availableArkModules);// ArkModule from database not LDAP.

    Collection<ArkModule> selectedArkModules = new ArrayList<ArkModule>();
    selectedArkModules.add(iArkCommonService.getArkModuleByName(ModuleConstants.ARK_MODULE_STUDY));
    selectedArkModules.add(iArkCommonService.getArkModuleByName(ModuleConstants.ARK_MODULE_SUBJECT));
    containerForm.getModelObject().setSelectedArkModules(selectedArkModules);

    // Hide Summary details on new
    studyCrudContainerVO.getSummaryContainer().setVisible(false);
    target.add(studyCrudContainerVO.getSummaryContainer());

    // Show upload item for new Study
    studyCrudContainerVO.getStudyLogoMarkup().setVisible(true);
    studyCrudContainerVO.getStudyLogoUploadContainer().setVisible(true);

    StudyHelper studyHelper = new StudyHelper();
    studyHelper.setStudyLogo(containerForm.getModelObject().getStudy(), target,
            studyCrudContainerVO.getStudyNameMarkup(), studyCrudContainerVO.getStudyLogoMarkup());

    target.add(studyCrudContainerVO.getStudyLogoMarkup());
    target.add(studyCrudContainerVO.getStudyLogoUploadContainer());

    // Clear context items
    ContextHelper contextHelper = new ContextHelper();
    contextHelper.resetContextLabel(target, studyCrudContainerVO.getArkContextMarkup());
    studyNameTxtFld.setEnabled(true);//from w  ww .j  a  v  a  2  s  .c om

    // Default boolean selections
    containerForm.getModelObject().getStudy().setAutoGenerateSubjectUid(false);
    containerForm.getModelObject().getStudy().setAutoConsent(false);

    // TODO: Suggest moving some of this "onNew" code into DetailPanel/DetailForm's onBeforeRender(..)
    // Disable SubjectUID pattern fields by default for New study
    WebMarkupContainer wmc = (WebMarkupContainer) studyCrudContainerVO.getDetailPanelContainer();
    DetailPanel detailsPanel = (DetailPanel) wmc.get("detailPanel");
    DetailForm detailForm = (DetailForm) detailsPanel.get("detailForm");
    WebMarkupContainer autoSubjectUidcontainer = detailForm.getAutoSubjectUidContainer();
    WebMarkupContainer autoBiocollectionContainer = detailForm.getAutoBiocollectionUidContainer();
    WebMarkupContainer autoBiospecimenContainer = detailForm.getAutoBiospecimenUidContainer();
    WebMarkupContainer subjectUidcontainer = detailForm.getSubjectUidContainer();

    // Example auto-generated SubjectUID to "AAA-0000000001" on new
    containerForm.getModelObject().setSubjectUidExample(Constants.SUBJECTUID_EXAMPLE);
    Label subjectUidExampleLbl = detailForm.getSubjectUidExampleLbl();
    subjectUidExampleLbl.setDefaultModelObject(containerForm.getModelObject().getSubjectUidExample());
    target.add(subjectUidExampleLbl);

    autoSubjectUidcontainer.setEnabled(true);
    autoBiocollectionContainer.setEnabled(true);
    autoBiospecimenContainer.setEnabled(true);
    subjectUidcontainer.setEnabled(false);
    target.add(subjectUidcontainer);

    preProcessDetailPanel(target);
}

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

License:Open Source License

private AjaxLink<Study> buildLink(final Study study, final WebMarkupContainer searchResultsContainer) {
    ArkBusyAjaxLink<Study> link = new ArkBusyAjaxLink<Study>("studyName") {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("unchecked")
        @Override//w  ww .j  a va 2 s.c om
        public void onClick(AjaxRequestTarget target) {
            Subject currentUser = SecurityUtils.getSubject();

            // Place the selected study in session context for the user
            SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID,
                    study.getId());
            SecurityUtils.getSubject().getSession()
                    .removeAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID);
            SecurityUtils.getSubject().getSession().removeAttribute(au.org.theark.core.Constants.PERSON_TYPE);
            // Clear out any Subject UID placed in session via LIMS
            SecurityUtils.getSubject().getSession().removeAttribute(au.org.theark.core.Constants.SUBJECTUID);

            // Force clearing of Cache to re-load roles for the user for the study
            arkLdapRealm.clearCachedAuthorizationInfo(currentUser.getPrincipals());
            aafRealm.clearCachedAuthorizationInfo(currentUser.getPrincipals());

            Study searchStudy = iArkCommonService.getStudy(study.getId());
            /**************
             * this is code which must not be commented out...was to be utilized to deal with data from WAGER ... 
            //TODO ASAP Dont leave this nasty hack here
            iArkCommonService.convertLimsBiospecimenCustomDataValuesToKeysForThisStudy(searchStudy);~~~
            //TODO ASAP Dont leave this nasty hack here
            iArkCommonService.convertLimsBiocollectionCustomDataValuesToKeysForThisStudy(searchStudy);~~~
            ************/

            Study parentStudy = searchStudy.getParentStudy();

            // Check if the study has been linked to a Main Study and if so get a reference to the main study.
            // studyContainerForm.getModelObject().setLinkedToStudy(linkedToStudy)

            studyContainerForm.getModelObject().setStudy(searchStudy);
            studyContainerForm.getModelObject()
                    .setSubjectUidExample(iArkCommonService.getSubjectUidExample(searchStudy));

            WebMarkupContainer wmc = (WebMarkupContainer) studyCrudContainerVO.getDetailPanelContainer();
            DetailPanel detailsPanel = (DetailPanel) wmc.get("detailPanel");
            DetailForm detailForm = (DetailForm) detailsPanel.get("detailForm");

            // All SubjectUID generator fields grouped within a container(s)
            WebMarkupContainer autoSubjectUidcontainer = detailForm.getAutoSubjectUidContainer();
            WebMarkupContainer autoBiocollectionUidcontainer = detailForm.getAutoBiocollectionUidContainer();
            WebMarkupContainer autoBiospecimenUidcontainer = detailForm.getAutoBiospecimenUidContainer();
            WebMarkupContainer subjectUidcontainer = detailForm.getSubjectUidContainer();

            // Disable all SubjectUID generation fields if subjects exist or is a child study
            if (iArkCommonService.studyHasSubjects(searchStudy) || parentStudy != null) {
                autoSubjectUidcontainer.setEnabled(false);
                subjectUidcontainer.setEnabled(false);
            } else {
                autoSubjectUidcontainer.setEnabled(true);
                if (studyContainerForm.getModelObject().getStudy().getAutoGenerateSubjectUid()) {
                    subjectUidcontainer.setEnabled(true);
                } else {
                    subjectUidcontainer.setEnabled(false);
                }
            }

            // Enable bioSpecimenUidContainer if there are no biospecimens created as yet
            WebMarkupContainer biospecimenUidContainer = detailForm.getBiospecimenUidContainer();
            if (iArkCommonService.studyHasBiospecimen(studyContainerForm.getModelObject().getStudy())) {
                biospecimenUidContainer.setEnabled(false);
                autoBiospecimenUidcontainer.setEnabled(false);
            } else {
                biospecimenUidContainer.setEnabled(parentStudy == null);
                autoBiospecimenUidcontainer.setEnabled(parentStudy == null);
            }

            WebMarkupContainer bioCollectionUidContainer = detailForm.getBioCollectionUidContainer();
            if (iArkCommonService.studyHasBioCollection(studyContainerForm.getModelObject().getStudy())) {
                bioCollectionUidContainer.setEnabled(false);
                autoBiocollectionUidcontainer.setEnabled(false);
            } else {
                bioCollectionUidContainer.setEnabled(parentStudy == null);
                autoBiocollectionUidcontainer.setEnabled(parentStudy == null);
            }

            // Get the Source Modules from database
            Collection<ArkModule> availableArkModules = iArkCommonService.getEntityList(ArkModule.class);
            // Hide Admin and Reporting modules from "Available" view
            availableArkModules.remove(iArkCommonService.getArkModuleByName(ModuleConstants.ARK_MODULE_ADMIN));
            //availableArkModules.remove(iArkCommonService.getArkModuleByName(ModuleConstants.ARK_MODULE_REPORTING));

            // Get the Modules for the Study from database
            Collection<ArkModule> arkModulesLinkedToStudy = iArkCommonService
                    .getArkModulesLinkedWithStudy(searchStudy);

            studyContainerForm.getModelObject().setAvailableArkModules(availableArkModules);
            studyContainerForm.getModelObject().setSelectedArkModules(arkModulesLinkedToStudy);

            // Store module names linked to study in session
            for (Iterator iterator = arkModulesLinkedToStudy.iterator(); iterator.hasNext();) {
                ArkModule arkModule = (ArkModule) iterator.next();
                SecurityUtils.getSubject().getSession().setAttribute(arkModule.getName(), arkModule.getName());
            }
            studyCrudContainerVO.getSummaryContainer().setVisible(true);

            // Set Study Logo
            studyHelper = new StudyHelper();
            studyHelper.setStudyLogo(searchStudy, target, studyCrudContainerVO.getStudyNameMarkup(),
                    studyCrudContainerVO.getStudyLogoMarkup());

            // Set Context items
            ContextHelper contextHelper = new ContextHelper();
            contextHelper.resetContextLabel(target, studyCrudContainerVO.getArkContextMarkup());
            contextHelper.setStudyContextLabel(target, searchStudy.getName(),
                    studyCrudContainerVO.getArkContextMarkup());

            target.add(studyCrudContainerVO.getSummaryContainer());
            ArkCRUDHelper.preProcessDetailPanelOnSearchResults(target, studyCrudContainerVO);

            // Example auto-generated SubjectUID
            Label subjectUidExampleLbl = detailForm.getSubjectUidExampleLbl();

            // Get the Biospecimen UID Pattern if present for the given study
            BiospecimenUidTemplate biospecimentUidTemplate = null;
            // Get the BioCollection UID pattern if present
            BioCollectionUidTemplate bioCollectionUidTemplate = null;

            if (parentStudy == null || searchStudy == parentStudy) {
                subjectUidExampleLbl.setDefaultModelObject(iArkCommonService.getSubjectUidExample(searchStudy));
                biospecimentUidTemplate = iArkCommonService.getBiospecimenUidTemplate(searchStudy);
                bioCollectionUidTemplate = iArkCommonService.getBioCollectionUidTemplate(searchStudy);
            } else {
                // Disable parent study drop down
                detailForm.getLinkedToStudyDDContainer().setEnabled(false);
                subjectUidExampleLbl.setDefaultModelObject(iArkCommonService.getSubjectUidExample(parentStudy));
                biospecimentUidTemplate = iArkCommonService.getBiospecimenUidTemplate(parentStudy);
                bioCollectionUidTemplate = iArkCommonService.getBioCollectionUidTemplate(parentStudy);
            }

            if (biospecimentUidTemplate != null) {
                studyContainerForm.getModelObject().setBiospecimenUidTemplate(biospecimentUidTemplate);
            }

            if (bioCollectionUidTemplate != null) {
                studyContainerForm.getModelObject().setBioCollectionUidTemplate(bioCollectionUidTemplate);
            }
            target.add(subjectUidExampleLbl);

            boolean isChildStudy = (parentStudy != null && parentStudy != searchStudy);
            detailForm.getSubjectFileUploadContainer().setVisible(isChildStudy);
            detailForm.getSubjectFileUploadContainer().setEnabled(isChildStudy);

            long totalSubjects = iArkCommonService.getCountOfSubjects(searchStudy);
            long totalSubjectsOfParent = iArkCommonService.getCountOfSubjects(searchStudy.getParentStudy());

            studyContainerForm.getModelObject().setTotalSubjects(totalSubjects);
            studyContainerForm.getModelObject().setTotalSubjectsOfParent(totalSubjectsOfParent);

            // Refresh base container form to remove any feedBack messages
            target.add(autoSubjectUidcontainer);
            target.add(subjectUidcontainer);
            target.add(autoBiocollectionUidcontainer);
            target.add(bioCollectionUidContainer);
            target.add(autoBiospecimenUidcontainer);
            target.add(biospecimenUidContainer);
            target.add(studyContainerForm);
            target.add(moduleTabbedPanel);
        }
    };

    // Add the label for the link
    Label studyNameLinkLabel = new Label("studyNameLink", study.getName());
    link.add(studyNameLinkLabel);
    return link;
}

From source file:com.francetelecom.clara.cloud.presentation.designer.services.cfjavaprocessing.LogicalCfJavaProcessingServicePanel.java

License:Apache License

private void setDefaultIconAndCleanFeedBack(WebMarkupContainer image, Label feedback) {
    image.add(new AttributeModifier("style", new Model<String>(
            "background-image:url(\"../../../../../images/designer/cloudfoundry-icon.png\"); background-repeat:no-repeat; background-position:5px 5px")));
    if (feedback != null) {
        feedback.setDefaultModelObject("");
    }//w ww.jav a  2s .c  o  m
}

From source file:com.francetelecom.clara.cloud.presentation.designer.services.cfjavaprocessing.LogicalCfJavaProcessingServicePanel.java

License:Apache License

private void setCustomIconAndUpdateFeedBack(WebMarkupContainer image, TextField<String> iconUrl,
        Label feedback) {
    image.add(new AttributeModifier("style", new Model<String>("background-image:url(\""
            + iconUrl.getModelObject().toString()
            + "\"); background-repeat:no-repeat; background-position:5px 5px; background-size:32px 32px;")));
    if (feedback != null) {
        feedback.setDefaultModelObject("");
    }//w w w.  ja  va 2  s  . c o m
}

From source file:com.francetelecom.clara.cloud.presentation.designer.services.jeeprocessing.LogicalJeeProcessingServicePanel.java

License:Apache License

private void setDefaultIconAndCleanFeedBack(WebMarkupContainer image, Label feedback) {
    image.add(new AttributeModifier("style", new Model<String>(
            "background-image:url(\"../../../../../images/designer/jee-processing-icon.png\"); background-repeat:no-repeat; background-position:5px 5px")));
    if (feedback != null) {
        feedback.setDefaultModelObject("");
    }/* www  . j  a va 2s .  c  om*/
}

From source file:com.francetelecom.clara.cloud.presentation.designer.services.nodeprocessing.LogicalNodeProcessingServicePanel.java

License:Apache License

protected void setDefaultIconAndCleanFeedBack(WebMarkupContainer image, Label feedback) {
    image.add(new AttributeModifier("style", new Model<String>(
            "background-image:url(\"../../../../../images/designer/jee-processing-icon.png\"); background-repeat:no-repeat; background-position:5px 5px")));
    if (feedback != null) {
        feedback.setDefaultModelObject("");
    }/* w w  w  . j a  va 2s  . com*/
}

From source file:com.francetelecom.clara.cloud.presentation.designer.services.nodeprocessing.LogicalNodeProcessingServicePanel.java

License:Apache License

protected void setCustomIconAndUpdateFeedBack(WebMarkupContainer image, TextField<String> iconUrl,
        Label feedback) {
    image.add(new AttributeModifier("style", new Model<String>("background-image:url(\""
            + iconUrl.getModelObject().toString()
            + "\"); background-repeat:no-repeat; background-position:5px 5px; background-size:32px 32px;")));
    if (feedback != null) {
        feedback.setDefaultModelObject("");
    }//from   w  ww .  ja  v  a2s . c  o m
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.articles.ArticlesPage.java

License:Apache License

private void updatePageTitleAndView(final Label pageTitle, final WebMarkupContainer internalContainer,
        final WebMarkupContainer linkedInContainer, final Model<Boolean> internalModel,
        final Model<Boolean> linkedInModel, AjaxRequestTarget target) {

    // get show configuration from form
    Boolean showInternalArticles = internalModel.getObject();
    Boolean showLinkedInArticles = linkedInModel.getObject();

    // update visibility with data from form
    internalContainer.setVisible(showInternalArticles);
    linkedInContainer.setVisible(showLinkedInArticles);

    // change date for updated visibility configuration
    if (showLinkedInArticles && showInternalArticles) {
        pageTitle.setDefaultModelObject(ResourceUtils.getString("pageTitle.allArticles"));
    } else if (!showLinkedInArticles && !showInternalArticles) {
        pageTitle.setDefaultModelObject(ResourceUtils.getString("pageTitle.noArticles"));
    } else if (showLinkedInArticles) {
        pageTitle.setDefaultModelObject(ResourceUtils.getString("pageTitle.linkedInArticles"));
    } else {//from www  .  ja v  a2  s .com
        pageTitle.setDefaultModelObject(ResourceUtils.getString("pageTitle.internalArticles"));
    }

    // ajax refresh
    target.add(pageTitle, internalContainer, linkedInContainer);
}

From source file:eu.esdihumboldt.hale.server.status.war.components.memory.MemoryPanel.java

License:Open Source License

/**
 * Default constructor/*from  w w w.  jav  a 2s.  c  o m*/
 * 
 * @param id the component ID
 */
public MemoryPanel(String id) {
    super(id);

    // calculate start values
    long curMax = Runtime.getRuntime().maxMemory() / 1024 / 1024;
    long curTotal = Runtime.getRuntime().totalMemory() / 1024 / 1024;
    long curUsed = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024;

    // create labels that show the current memory situation (they will be
    // updated via Ajax)
    final Label maxLabel = new Label("max_memory_label", String.valueOf(curMax));
    final Label totalLabel = new Label("total_memory_label", String.valueOf(curTotal));
    final Label usedLabel = new Label("used_memory_label", String.valueOf(curUsed));
    maxLabel.setOutputMarkupId(true);
    totalLabel.setOutputMarkupId(true);
    usedLabel.setOutputMarkupId(true);

    // create a container that redraws itself every second
    WebMarkupContainer redrawContainer = new WebMarkupContainer("redraw_container");
    redrawContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(1)) {

        private static final long serialVersionUID = -5579424950201876034L;

        /**
         * These arrays store the memory values of the last 61 seconds (one
         * second more, because the chart goes from 0 to 60)
         */
        private final long[] maxMemory = new long[61];
        private final long[] totalMemory = new long[61];
        private final long[] usedMemory = new long[61];

        /**
         * Shifts all values in the given array to the right and sets the
         * first entry to the given value
         * 
         * @param arr the array to shift
         * @param val the new value to insert at position 0
         */
        private void updateArray(long[] arr, long val) {
            System.arraycopy(arr, 0, arr, 1, arr.length - 1);
            arr[0] = val;
        }

        /**
         * Creates a string that can be used as plotting data for the memory
         * chart
         * 
         * @param arr the array that contains the memory values of the last
         *            61 seconds
         * @return the plot data string
         */
        private String makePlot(long[] arr) {
            StringBuffer result = new StringBuffer();
            for (int i = 0; i < arr.length; ++i) {
                if (arr[i] != 0) {
                    if (result.length() > 0) {
                        result.append(",");
                    }
                    result.append("[" + i + "," + arr[i] + "]");
                }
            }
            return result.toString();
        }

        /**
         * Gets the maximum value from an array
         * 
         * @param arr the array
         * @return the maximum value in <code>arr</code>
         */
        private long getMax(long[] arr) {
            long result = 0;
            for (int i = 0; i < arr.length; ++i) {
                if (arr[i] > result) {
                    result = arr[i];
                }
            }
            return result;
        }

        @Override
        protected void onPostProcessTarget(final AjaxRequestTarget target) {
            // get current memory situation
            long curMax = Runtime.getRuntime().maxMemory() / 1024 / 1024;
            long curTotal = Runtime.getRuntime().totalMemory() / 1024 / 1024;
            long curUsed = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024
                    / 1024;

            // update plot data of last 61 seconds
            updateArray(totalMemory, curTotal);
            updateArray(usedMemory, curUsed);

            // create plot data string
            String total = makePlot(totalMemory);
            String free = makePlot(usedMemory);

            // calculate the maximum for the chart's y axis (+ 50 MB)
            long ymax = getMax(totalMemory) + 50;

            // reset labels
            maxLabel.setDefaultModelObject(String.valueOf(curMax));
            totalLabel.setDefaultModelObject(String.valueOf(curTotal));
            usedLabel.setDefaultModelObject(String.valueOf(curUsed));
            target.add(maxLabel);
            target.add(totalLabel);
            target.add(usedLabel);

            // redraw chart
            target.appendJavaScript("chart_plot.axes.xaxis.max = " + (maxMemory.length - 1) + ";"
                    + "chart_plot.axes.yaxis.max = " + ymax + ";" + "chart_plot.series[0].data = [" + total
                    + "];" + "chart_plot.series[1].data = [" + free + "];" + "chart_plot.replot();");
        }
    });
    redrawContainer.add(maxLabel);
    redrawContainer.add(totalLabel);
    redrawContainer.add(usedLabel);
    add(redrawContainer);

    // add a button that performs garbage collection
    AjaxFallbackLink<Object> performGC = new AjaxFallbackLink<Object>("perform-gc") {

        private static final long serialVersionUID = -1411055574233411598L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            System.gc();
        }
    };
    redrawContainer.add(performGC);
}

From source file:jdave.webdriver.testapplication.WebDriverTestPage.java

License:Apache License

public WebDriverTestPage() {
    final Label label = new Label("testLabel", new Model<String>("test label"));
    label.setOutputMarkupId(true);//from   w  ww  . j ava 2 s .co m
    add(label);
    add(new AjaxFallbackLink<Void>("testLink") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            label.setDefaultModelObject("link clicked");
            target.addComponent(label);
        }
    });
    add(new AjaxFallbackLink<Void>("testLink2") {
        @Override
        public void onClick(AjaxRequestTarget target) {
        }
    });
    TextField<String> textField = new TextField<String>("testTextField", new Model<String>());
    add(textField);
    textField.add(new OnChangeAjaxBehavior() {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            label.setDefaultModelObject(getDefaultModelObject());
            target.addComponent(label);
        }
    });
    add(new AjaxCheckBox("testCheckBox", new Model<Boolean>(false)) {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            label.setDefaultModelObject("checkbox clicked");
            target.addComponent(label);
        }
    });

    add(TestDropDownChoice.getDropDownChoice());
    Link<Void> openLink = new Link<Void>("openChildPageLink") {
        @Override
        public void onClick() {
            setResponsePage(new ChildPage());
        }
    };
    final PopupSettings popupSettings = new PopupSettings(PopupSettings.SCROLLBARS).setWidth(1045)
            .setHeight(900).setWindowName("childPage");
    openLink.setPopupSettings(popupSettings);
    add(openLink);
}