Example usage for org.apache.wicket.ajax AjaxRequestTarget add

List of usage examples for org.apache.wicket.ajax AjaxRequestTarget add

Introduction

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

Prototype

void add(Component... components);

Source Link

Document

Adds components to the list of components to be rendered.

Usage

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

License:Open Source License

public void initialiseForm() {
    add(buildListEditor());//from   w  w  w  .j av  a  2  s  .  c  o m
    add(new AjaxEditorButton(Constants.NEW) {
        private static final long serialVersionUID = 1L;

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

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            BatchBiospecimenVO item = new BatchBiospecimenVO();
            item.setBiospecimen(new Biospecimen());
            item.getBiospecimen().setLinkSubjectStudy(cpModel.getObject().getLinkSubjectStudy());
            item.getBiospecimen().setStudy(cpModel.getObject().getStudy());
            listEditor.addItem(item);
            target.add(form);
        }
    }.setDefaultFormProcessing(false));

    add(new AjaxButton(Constants.SAVE) {
        private static final long serialVersionUID = 1L;

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

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

    add(new AjaxButton(Constants.SAVEANDCLOSE) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            if (onSave(target)) {
                target.add(feedbackPanel);
                modalWindow.close(target);
            }
        }

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

    add(new AjaxButton(Constants.CANCEL) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            modalWindow.close(target);
        }

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

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

License:Open Source License

/**
 * /*from  w  w  w .j  av  a2  s  .c o m*/
 * @return the listEditor of BatchBiospecimen(s)
 */
public AbstractListEditor<BatchBiospecimenVO> buildListEditor() {
    listEditor = new AbstractListEditor<BatchBiospecimenVO>("batchBiospecimenList",
            new PropertyModel(this, "batchBiospecimenList")) {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("serial")
        @Override
        protected void onPopulateItem(final ListItem<BatchBiospecimenVO> item) {
            item.setOutputMarkupId(true);
            item.getModelObject().getBiospecimen()
                    .setLinkSubjectStudy(cpModel.getObject().getLinkSubjectStudy());
            item.getModelObject().getBiospecimen()
                    .setStudy(cpModel.getObject().getLinkSubjectStudy().getStudy());

            numberToCreateTxtFld = new TextField<Number>("numberToCreate",
                    new PropertyModel(item.getModelObject(), "numberToCreate"));

            initBioCollectionDdc(item);
            initSampleTypeDdc(item);

            sampleDateTxtFld = new DateTextField("biospecimen.sampleDate",
                    new PropertyModel(item.getModelObject(), "biospecimen.sampleDate"),
                    au.org.theark.core.Constants.DD_MM_YYYY);
            ArkDatePicker sampleDatePicker = new ArkDatePicker();
            sampleDatePicker.bind(sampleDateTxtFld);
            sampleDateTxtFld.add(sampleDatePicker);

            quantityTxtFld = new TextField<Double>("biospecimen.quantity",
                    new PropertyModel(item.getModelObject(), "biospecimen.quantity")) {
                private static final long serialVersionUID = 1L;

                @Override
                public <C> IConverter<C> getConverter(Class<C> type) {
                    DoubleConverter doubleConverter = new DoubleConverter();
                    NumberFormat numberFormat = NumberFormat.getInstance();
                    numberFormat.setMinimumFractionDigits(1);
                    doubleConverter.setNumberFormat(getLocale(), numberFormat);
                    return (IConverter<C>) doubleConverter;
                }
            };
            initUnitDdc(item);
            initTreatmentTypeDdc(item);
            concentrationTxtFld = new TextField<Number>("biospecimen.concentration",
                    new PropertyModel(item.getModelObject(), "biospecimen.concentration"));

            // Added onchange events to ensure model updated when any change made
            item.add(numberToCreateTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(bioCollectionDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(sampleTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(sampleDateTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(quantityTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(unitDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(treatmentTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(concentrationTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));

            // Copy button allows entire row details to be copied
            item.add(new AjaxEditorButton(Constants.COPY) {
                private static final long serialVersionUID = 1L;

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

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    BatchBiospecimenVO batchBiospecimenVo = new BatchBiospecimenVO();
                    try {
                        batchBiospecimenVo.setNumberToCreate(item.getModelObject().getNumberToCreate());
                        PropertyUtils.copyProperties(batchBiospecimenVo.getBiospecimen(),
                                item.getModelObject().getBiospecimen());
                        listEditor.addItem(batchBiospecimenVo);
                        target.add(form);
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    } catch (InvocationTargetException e) {
                        e.printStackTrace();
                    } catch (NoSuchMethodException e) {
                        e.printStackTrace();
                    }
                }
            }.setDefaultFormProcessing(false));

            item.add(new AjaxEditorButton(Constants.DELETE) {
                private static final long serialVersionUID = 1L;

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

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    listEditor.removeItem(item);
                    target.add(form);
                }
            }.setDefaultFormProcessing(false).setVisible(item.getIndex() > 0));

            item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD;
                }
            }));
        }

    };
    return listEditor;
}

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

License:Open Source License

public void initialiseForm() {
    add(buildListEditor());//ww  w .j a v  a  2 s  .co m
    add(new AjaxEditorButton(Constants.NEW) {
        private static final long serialVersionUID = 1L;

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

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            BatchBiospecimenVO item = new BatchBiospecimenVO();
            item.setBiospecimen(new Biospecimen());
            item.getBiospecimen().setLinkSubjectStudy(cpModel.getObject().getLinkSubjectStudy());
            item.getBiospecimen().setStudy(cpModel.getObject().getStudy());
            listEditor.addItem(item);
            target.add(form);
        }
    }.setDefaultFormProcessing(false));

    // Hidden save button to prevent resaving of created biospecimens 
    add(new AjaxButton(Constants.SAVE) {
        private static final long serialVersionUID = 1L;

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

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

    add(new AjaxButton(Constants.SAVEANDCLOSE) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            if (onSave(target)) {
                target.add(feedbackPanel);
                modalWindow.close(target);
            }

        }

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

    add(new AjaxButton(Constants.CANCEL) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            modalWindow.close(target);
        }

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

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

License:Open Source License

/**
 * /*from   w w w  .  j av a 2s. com*/
 * @return the listEditor of BatchBiospecimen(s)
 */
public AbstractListEditor<BatchBiospecimenVO> buildListEditor() {
    listEditor = new AbstractListEditor<BatchBiospecimenVO>("batchBiospecimenList",
            new PropertyModel(this, "batchBiospecimenList")) {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("serial")
        @Override
        protected void onPopulateItem(final ListItem<BatchBiospecimenVO> item) {
            item.setOutputMarkupId(true);
            item.getModelObject().getBiospecimen()
                    .setLinkSubjectStudy(cpModel.getObject().getLinkSubjectStudy());
            item.getModelObject().getBiospecimen()
                    .setStudy(cpModel.getObject().getLinkSubjectStudy().getStudy());

            biospecimenUidTxtFld = new TextField<String>("biospecimen.biospecimenUid",
                    new PropertyModel(item.getModelObject(), "biospecimen.biospecimenUid"));

            initBioCollectionDdc(item);
            initSampleTypeDdc(item);

            sampleDateTxtFld = new DateTextField("biospecimen.sampleDate",
                    new PropertyModel(item.getModelObject(), "biospecimen.sampleDate"),
                    au.org.theark.core.Constants.DD_MM_YYYY);
            ArkDatePicker sampleDatePicker = new ArkDatePicker();
            sampleDatePicker.bind(sampleDateTxtFld);
            sampleDateTxtFld.add(sampleDatePicker);

            quantityTxtFld = new TextField<Double>("biospecimen.quantity",
                    new PropertyModel(item.getModelObject(), "biospecimen.quantity")) {
                private static final long serialVersionUID = 1L;

                @Override
                public <C> IConverter<C> getConverter(Class<C> type) {
                    DoubleConverter doubleConverter = new DoubleConverter();
                    NumberFormat numberFormat = NumberFormat.getInstance();
                    numberFormat.setMinimumFractionDigits(1);
                    doubleConverter.setNumberFormat(getLocale(), numberFormat);
                    return (IConverter<C>) doubleConverter;
                }
            };
            initUnitDdc(item);
            initTreatmentTypeDdc(item);

            concentrationTxtFld = new TextField<Number>("biospecimen.concentration",
                    new PropertyModel(item.getModelObject(), "biospecimen.concentration"));

            // Added onchange events to ensure model updated when any change made
            item.add(biospecimenUidTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    // Check BiospecimenUID is unique
                    String biospecimenUid = (getComponent().getDefaultModelObject().toString() != null
                            ? getComponent().getDefaultModelObject().toString()
                            : new String());
                    Biospecimen biospecimen = iLimsService.getBiospecimenByUid(biospecimenUid,
                            item.getModelObject().getBiospecimen().getStudy());
                    if (biospecimen != null && biospecimen.getId() != null) {
                        ManualBatchCreateBiospecimenForm.this
                                .error("Biospecimen UID must be unique. Please try again.");
                        target.focusComponent(getComponent());
                    }
                    target.add(feedbackPanel);
                }
            }));

            item.add(bioCollectionDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(sampleTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(sampleDateTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(quantityTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(unitDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(treatmentTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));
            item.add(concentrationTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            }));

            // Copy button allows entire row details to be copied
            item.add(new AjaxEditorButton(Constants.COPY) {
                private static final long serialVersionUID = 1L;

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

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    BatchBiospecimenVO batchBiospecimenVo = new BatchBiospecimenVO();
                    try {
                        PropertyUtils.copyProperties(batchBiospecimenVo.getBiospecimen(),
                                item.getModelObject().getBiospecimen());
                        batchBiospecimenVo.getBiospecimen().setBiospecimenUid(new String());
                        listEditor.addItem(batchBiospecimenVo);
                        target.add(form);
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    } catch (InvocationTargetException e) {
                        e.printStackTrace();
                    } catch (NoSuchMethodException e) {
                        e.printStackTrace();
                    }
                }
            }.setDefaultFormProcessing(false));

            item.add(new AjaxEditorButton(Constants.DELETE) {
                private static final long serialVersionUID = 1L;

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

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    listEditor.removeItem(item);
                    target.add(form);
                }
            }.setDefaultFormProcessing(false).setVisible(item.getIndex() > 0));

            item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD;
                }
            }));
        }

    };
    return listEditor;
}

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

License:Open Source License

public void initialisePanel() {
    final BiospecimenListPanel panelToRepaint = this;
    AbstractDetailModalWindow modalWindow = new AbstractDetailModalWindow("detailModalWindow") {
        private static final long serialVersionUID = 1L;

        @Override//w ww. j a  v  a 2  s  .c  o  m
        protected void onCloseModalWindow(AjaxRequestTarget target) {
            target.add(panelToRepaint);
        }
    };
    listDetailForm = new BiospecimenListForm("biospecimenListForm", feedbackPanel, modalWindow, cpModel,
            arkContextMarkup, studyNameMarkup, studyLogoMarkup);
    listDetailForm.initialiseForm();
    add(listDetailForm);
}

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

License:Open Source License

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

        private static final long serialVersionUID = 1L;

        public int size() {
            return (int) iLimsService.getBiospecimenCount(criteriaModel.getObject());
        }//from   ww  w  .j a v a 2  s.c  o  m

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

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

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

        private static final long serialVersionUID = 1L;

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

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

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

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

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

License:Open Source License

/**
 * //from w  w  w  . j  av  a 2s .  co  m
 * @param iModel
 * @return the pageableListView of BioCollection
 */
public DataView<Biospecimen> buildDataView(ArkDataProvider2<LimsVO, Biospecimen> biospecimenProvider) {

    DataView<Biospecimen> biospecimenDataView = new DataView<Biospecimen>("biospecimenList",
            biospecimenProvider) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<Biospecimen> item) {
            item.setOutputMarkupId(true);
            // DO NOT store the item.getModelObject! Checking it is ok...
            final Biospecimen biospecimen = item.getModelObject();

            WebMarkupContainer rowDetailsWMC = new WebMarkupContainer("rowDetailsWMC", item.getModel());
            ArkBusyAjaxLink listDetailsLink = new ArkBusyAjaxLink("listDetailsLink") {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    CompoundPropertyModel<LimsVO> newModel = new CompoundPropertyModel<LimsVO>(new LimsVO());
                    try {
                        Biospecimen biospecimenFromDB = iLimsService.getBiospecimen(biospecimen.getId());
                        Study study = iArkCommonService.getStudy(biospecimenFromDB.getStudy().getId());
                        LinkSubjectStudy linkSubjectStudy = iArkCommonService.getSubjectByUID(
                                biospecimenFromDB.getLinkSubjectStudy().getSubjectUID(), study);
                        biospecimenFromDB.setStudy(study);
                        biospecimenFromDB.setLinkSubjectStudy(linkSubjectStudy);

                        setContextItems(target, linkSubjectStudy);

                        newModel.getObject().setLinkSubjectStudy(linkSubjectStudy);
                        newModel.getObject().setBiospecimen(biospecimenFromDB);
                        newModel.getObject().setTreeModel(cpModel.getObject().getTreeModel());
                        showModalWindow(target, newModel);
                    } catch (EntityNotFoundException e) {
                        log.error(e.getMessage());
                    }
                }

            };

            idLblFld = new Label("biospecimen.id", String.valueOf(biospecimen.getId()));

            nameLblFld = new Label("biospecimen.biospecimenUid", biospecimen.getBiospecimenUid());
            listDetailsLink.add(nameLblFld);
            rowDetailsWMC.add(listDetailsLink);

            studyLblFld = new Label("biospecimen.study.name", biospecimen.getStudy().getName());
            subjectUidLblFld = new Label("biospecimen.linkSubjectStudy.subjectUid",
                    biospecimen.getLinkSubjectStudy().getSubjectUID());
            sampleTypeLblFld = new Label("biospecimen.sampleType.name", biospecimen.getSampleType().getName());
            collectionLblFld = new Label("biospecimen.bioCollection.biocollectionUid",
                    biospecimen.getBioCollection().getBiocollectionUid());

            biospecimen.setQuantity(iLimsService.getQuantityAvailable(biospecimen));
            if (biospecimen.getQuantity() == null) {
                quantityLblFld = new Label("biospecimen.quantity", "0");
            } else {
                quantityLblFld = new Label("biospecimen.quantity", biospecimen.getQuantity().toString());
            }
            if (biospecimen.getUnit() == null) {
                unitsLblFld = new Label("biospecimen.unit", "");
            } else {
                unitsLblFld = new Label("biospecimen.unit", biospecimen.getUnit().getName());
            }

            try {
                locationLbl = new Label("biospecimen.location", "view");
                locationLink = new ArkBusyAjaxLink("biospecimen.location.link") {

                    /**
                     * 
                     */
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        CompoundPropertyModel<LimsVO> newModel = new CompoundPropertyModel<LimsVO>(
                                new LimsVO());
                        newModel.getObject().getBiospecimen().setId(biospecimen.getId());
                        BiospecimenLocationVO biospecimenLocationVo;
                        try {
                            biospecimenLocationVo = iInventoryService.getBiospecimenLocation(biospecimen);
                            newModel.getObject().setBiospecimenLocationVO(biospecimenLocationVo);
                            BioLocationPanel bioLocationPanel = new BioLocationPanel("content", newModel) {
                                /**
                                 * 
                                 */
                                private static final long serialVersionUID = 1L;

                                @Override
                                public void refreshParentPanel(AjaxRequestTarget target) {
                                }
                            };
                            bioLocationPanel.getUnallocateButton().setVisible(false);
                            bioLocationPanel.add(new AttributeModifier("class", "detailsPanelBorder"));
                            // Set the modalWindow title and content
                            modalWindow.setTitle("Biospecimen Location Detail");
                            modalWindow.setContent(bioLocationPanel);
                            modalWindow.show(target);
                        } catch (ArkSystemException e) {
                            log.error(e.getMessage());
                        }
                    }
                };

                locationLink.add(locationLbl);

                BiospecimenLocationVO biospecimenLocationVo = iInventoryService
                        .getBiospecimenLocation(biospecimen);
                if (!biospecimenLocationVo.getIsAllocated()) {
                    locationLink.setVisible(false);
                }
            } catch (ArkSystemException e) {
                log.error(e.getMessage());
            }

            item.add(idLblFld);
            item.add(rowDetailsWMC);
            item.add(studyLblFld);
            item.add(subjectUidLblFld);
            item.add(sampleTypeLblFld);
            item.add(collectionLblFld);
            item.add(quantityLblFld);
            item.add(unitsLblFld);
            item.add(locationLink);

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

            item.add(new AjaxButton("batchAliquot") {

                /**
                 * 
                 */
                private static final long serialVersionUID = 1L;

                @Override
                public boolean isEnabled() {
                    return ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.NEW);
                }

                protected void onSubmit(AjaxRequestTarget target,
                        org.apache.wicket.markup.html.form.Form<?> form) {
                    onBatchAliquot(target, item.getModel());
                    target.add(feedbackPanel);
                };

                protected void onError(AjaxRequestTarget target,
                        org.apache.wicket.markup.html.form.Form<?> form) {
                    target.add(feedbackPanel);
                };

                public boolean isVisible() {
                    return (item.getModelObject().getQuantity() != null
                            && item.getModelObject().getQuantity() > 0);
                };

            }.setDefaultFormProcessing(false));

            item.add(new AjaxButton("allocateUnallocate") {
                private static final long serialVersionUID = 1L;

                @Override
                public boolean isEnabled() {
                    return ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.EDIT);
                }

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

                    BiospecimenLocationVO biospecimenLocationVo = null;
                    try {
                        biospecimenLocationVo = iInventoryService.getBiospecimenLocation(biospecimen);
                    } catch (ArkSystemException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    if (biospecimenLocationVo.getIsAllocated()) {
                        //unallocate
                        InvCell invCell = iInventoryService.getInvCellByBiospecimen(biospecimen);
                        invCell.setBiospecimen(null);
                        invCell.setStatus("Empty");
                        iInventoryService.updateInvCell(invCell);

                        try {
                            cpModel.getObject()
                                    .setBiospecimenLocationVO(iInventoryService.getInvCellLocation(invCell));
                            cpModel.getObject().getBiospecimenLocationVO().setIsAllocated(false);
                            cpModel.getObject().setInvCell(invCell);
                        } catch (ArkSystemException e) {
                        }
                    } else {
                        //cpModel.getObject().setBiospecimen(biospecimen);
                        CompoundPropertyModel<LimsVO> cpm = new CompoundPropertyModel<LimsVO>(new LimsVO());
                        cpm.getObject().setBiospecimen(biospecimen);
                        modalContentPanel = new BioModalAllocateDetailPanel("content", modalWindow, cpm);

                        // Set the modalWindow title and content
                        modalWindow.setTitle("Biospecimen Allocation");
                        modalWindow.setContent(modalContentPanel);
                        modalWindow.setWidthUnit("%");
                        modalWindow.setInitialWidth(70);
                        modalWindow.show(target);
                        //cpModel.getObject().setBiospecimen(new Biospecimen());
                        modalWindow.repaintComponent(BiospecimenListForm.this);

                    }
                    target.add(BiospecimenListForm.this);
                }

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

            }.setDefaultFormProcessing(false));

            item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD;
                }
            }));
        }

    };

    return biospecimenDataView;
}

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

License:Open Source License

private void onBatchAliquot(AjaxRequestTarget target, IModel<Biospecimen> iModel) {
    IModel model = new Model<BatchBiospecimenAliquotsVO>(new BatchBiospecimenAliquotsVO(iModel.getObject()));
    // handles for auto-gen biospecimenUid or manual entry
    modalContentPanel = new BatchAliquotBiospecimenPanel("content", feedbackPanel, model, modalWindow);

    // Set the modalWindow title and content
    modalWindow.setTitle("Batch Aliquot Biospecimens");
    modalWindow.setContent(modalContentPanel);
    modalWindow.show(target);/*from w w w  .j a  va 2s  .c  o m*/
    // refresh the feedback messages
    target.add(feedbackPanel);
}

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

License:Open Source License

@Override
protected void onSearch(AjaxRequestTarget target) {
    // Refresh the FB panel if there was an old message from previous search result
    target.add(feedbackPanel);

    long count = iLimsService.getBiospecimenCount(cpmModel.getObject());
    if (count == 0L) {
        this.info("There are no Biospecimens with the specified criteria.");
        target.add(feedbackPanel);/*from w  ww . ja  v  a  2  s.  c  o m*/
    }

    target.add(arkCrudContainerVO.getSearchResultPanelContainer());
}

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

License:Open Source License

public BiospecimenCustomDataEditorPanel initialisePanel() {

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

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

    return this;
}