List of usage examples for org.apache.wicket.markup.html WebMarkupContainer WebMarkupContainer
public WebMarkupContainer(final String id, IModel<?> model)
From source file:au.org.theark.admin.web.component.rolePolicy.SearchResultsPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public DataView<ArkRoleModuleFunctionVO> buildDataView( ArkDataProvider<ArkRoleModuleFunctionVO, IAdminService> dataProvider) { DataView<ArkRoleModuleFunctionVO> dataView = new DataView<ArkRoleModuleFunctionVO>( "arkRoleModuleFunctionVoList", dataProvider) { private static final long serialVersionUID = -7977497161071264676L; @Override/*from w w w .j a va 2 s .c om*/ protected void populateItem(final Item<ArkRoleModuleFunctionVO> item) { final ArkRoleModuleFunctionVO arkRoleModuleFunctionVo = item.getModelObject(); item.setOutputMarkupId(true); item.setOutputMarkupPlaceholderTag(true); WebMarkupContainer rowEditWMC = new WebMarkupContainer("rowEditWMC", item.getModel()); AjaxButton listEditButton = new AjaxButton("listEditButton", new StringResourceModel(au.org.theark.core.Constants.EDIT, this, null)) { private static final long serialVersionUID = 197521505680635043L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { item.setEnabled(true); item.get("arkCreatePermissionImg").setVisible(false); item.get("arkReadPermissionImg").setVisible(false); item.get("arkUpdatePermissionImg").setVisible(false); item.get("arkDeletePermissionImg").setVisible(false); item.addOrReplace(new CheckBox("arkCreatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkCreatePermission")) .setEnabled(true)); item.addOrReplace(new CheckBox("arkReadPermission", new PropertyModel(arkRoleModuleFunctionVo, "arkReadPermission")).setEnabled(true)); item.addOrReplace(new CheckBox("arkUpdatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkUpdatePermission")) .setEnabled(true)); item.addOrReplace(new CheckBox("arkDeletePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkDeletePermission")) .setEnabled(true)); item.get("rowSaveWMC").setVisible(true); target.add(item); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { log.error("onError called when listEditButton pressed"); } }; listEditButton.setDefaultFormProcessing(false); rowEditWMC.add(listEditButton); item.add(rowEditWMC); if (arkRoleModuleFunctionVo.getArkRole() != null) { item.add(new Label("arkRole", arkRoleModuleFunctionVo.getArkRole().getName())); } else { item.add(new Label("arkRole", "")); } if (arkRoleModuleFunctionVo.getArkModule() != null) { item.add(new Label("arkModule", arkRoleModuleFunctionVo.getArkModule().getName())); } else { item.add(new Label("arkModule", "")); } if (arkRoleModuleFunctionVo.getArkFunction() != null) { item.add(new Label("arkFunction", arkRoleModuleFunctionVo.getArkFunction().getName())); } else { item.add(new Label("arkFunction", "")); } if (arkRoleModuleFunctionVo.getArkCreatePermission()) { item.addOrReplace( new ContextImage("arkCreatePermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace(new ContextImage("arkCreatePermissionImg", new Model<String>("images/icons/cross.png"))); } if (arkRoleModuleFunctionVo.getArkReadPermission()) { item.addOrReplace( new ContextImage("arkReadPermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace( new ContextImage("arkReadPermissionImg", new Model<String>("images/icons/cross.png"))); } if (arkRoleModuleFunctionVo.getArkUpdatePermission()) { item.addOrReplace( new ContextImage("arkUpdatePermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace(new ContextImage("arkUpdatePermissionImg", new Model<String>("images/icons/cross.png"))); } if (arkRoleModuleFunctionVo.getArkDeletePermission()) { item.addOrReplace( new ContextImage("arkDeletePermissionImg", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace(new ContextImage("arkDeletePermissionImg", new Model<String>("images/icons/cross.png"))); } item.addOrReplace(new CheckBox("arkCreatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkCreatePermission")).setVisible(false)); item.addOrReplace(new CheckBox("arkReadPermission", new PropertyModel(arkRoleModuleFunctionVo, "arkReadPermission")).setVisible(false)); item.addOrReplace(new CheckBox("arkUpdatePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkUpdatePermission")).setVisible(false)); item.addOrReplace(new CheckBox("arkDeletePermission", new PropertyModel(arkRoleModuleFunctionVo, "arkDeletePermission")).setVisible(false)); WebMarkupContainer rowSaveWMC = new WebMarkupContainer("rowSaveWMC", item.getModel()); AjaxButton listSaveButton = new AjaxButton("listSaveButton", new StringResourceModel(au.org.theark.core.Constants.SAVE, this, null)) { private static final long serialVersionUID = -7382768898426488999L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { onSave(target, arkRoleModuleFunctionVo); target.add(SearchResultsPanel.this); target.add(feedbackPanel); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { log.error("onError called when listSaveButton pressed"); } }; rowSaveWMC.add(listSaveButton); rowSaveWMC.setVisible(false); item.add(rowSaveWMC); item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1938679383897533820L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return dataView; }
From source file:au.org.theark.core.web.component.customfield.SearchResultListPanel.java
License:Open Source License
private WebMarkupContainer buildLinkWMC(final Item<CustomField> item) { WebMarkupContainer customfieldLinkWMC = new WebMarkupContainer("customfieldLinkWMC", item.getModel()); ArkBusyAjaxLink link = new ArkBusyAjaxLink(Constants.CUSTOMFIELD_NAME) { @Override/*from ww w . java 2s .c o m*/ public void onClick(AjaxRequestTarget target) { // Sets the selected object into the model CustomField cf = (CustomField) (getParent().getDefaultModelObject()); CompoundPropertyModel<CustomFieldVO> newModel = new CompoundPropertyModel<CustomFieldVO>( new CustomFieldVO()); newModel.getObject().setCustomField(cf); newModel.getObject().setUseCustomFieldDisplay(cpModel.getObject().isUseCustomFieldDisplay()); DetailPanel detailPanel = new DetailPanel("detailPanel", feedbackPanel, newModel, arkCrudContainerVO); arkCrudContainerVO.getDetailPanelContainer().addOrReplace(detailPanel); ArkCRUDHelper.preProcessDetailPanelOnSearchResults(target, arkCrudContainerVO); //Added on 2016-05-26 to stop showing the previous feed back message when deleting or updating in the form. //This will clear the feedback message. Session.get().cleanupFeedbackMessages(); target.add(feedbackPanel); } }; // Add the label for the link CustomField field = item.getModelObject(); Label nameLinkLabel = new Label("nameLbl", field.getName()); link.add(nameLinkLabel); customfieldLinkWMC.add(link); return customfieldLinkWMC; }
From source file:au.org.theark.core.web.component.customfieldcategory.SearchResultListPanel.java
License:Open Source License
private WebMarkupContainer buildLinkWMC(final Item<CustomFieldCategory> item) { WebMarkupContainer customfieldCategoryLinkWMC = new WebMarkupContainer("customfieldCategoryLinkWMC", item.getModel());/*w w w .j a v a2 s .com*/ ArkBusyAjaxLink link = new ArkBusyAjaxLink(Constants.CUSTOMFIELDCATEGORY_NAME) { @Override public void onClick(AjaxRequestTarget target) { // Sets the selected object into the model CustomFieldCategory cf = (CustomFieldCategory) (getParent().getDefaultModelObject()); CompoundPropertyModel<CustomFieldCategoryVO> newModel = new CompoundPropertyModel<CustomFieldCategoryVO>( new CustomFieldCategoryVO()); newModel.getObject().setCustomFieldCategory(cf); //newModel.getObject().setUseCustomFieldCategoryDisplay(cpModel.getObject().isUseCustomFieldCategoryDisplay()); DetailPanel detailPanel = new DetailPanel("detailPanel", feedbackPanel, newModel, arkCrudContainerVO); arkCrudContainerVO.getDetailPanelContainer().addOrReplace(detailPanel); ArkCRUDHelper.preProcessDetailPanelOnSearchResults(target, arkCrudContainerVO); //Added on 2016-05-26 to stop showing the previous feed back message when deleting or updating in the form. //This will clear the feedback message. Session.get().cleanupFeedbackMessages(); target.add(feedbackPanel); } }; // Add the label for the link CustomFieldCategory category = item.getModelObject(); //Label nameLinkLabel = new Label("nameLbl", category.getName()); Label nameLinkLabel = new Label("nameLbl", CustomFieldCategoryOrderingHelper.getInstance() .preTextDecider(category).concat(category.getName())); link.add(nameLinkLabel); customfieldCategoryLinkWMC.add(link); return customfieldCategoryLinkWMC; }
From source file:au.org.theark.lims.web.component.biospecimen.form.BiospecimenListForm.java
License:Open Source License
/** * /* www . ja v a2s .c o 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.biotransaction.BioTransactionListPanel.java
License:Open Source License
/** * // www . j a v a 2s . c o m * @param iModel * @return the pageableListView of BioCollection */ public DataView<BioTransaction> buildDataView(ArkDataProvider2<LimsVO, BioTransaction> bioTransactionProvider) { final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(au.org.theark.core.Constants.DD_MM_YYYY); DataView<BioTransaction> bioTransactionDataView = new DataView<BioTransaction>("bioTransactionList", bioTransactionProvider) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final Item<BioTransaction> item) { item.setOutputMarkupId(true); // DO NOT store the item.getModelObject! Checking it is ok... final BioTransaction bioTransaction = item.getModelObject(); WebMarkupContainer rowDetailsWMC = new WebMarkupContainer("rowDetailsWMC", item.getModel()); AjaxConfirmLink<BioTransaction> rowDeleteLink = new AjaxConfirmLink<BioTransaction>("rowDeleteLink", new StringResourceModel("bioTransaction.confirmDelete", this, item.getModel()), item.getModel()) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { BioTransaction bioTransaction = getModelObject(); iLimsService.deleteBioTransaction(bioTransaction); // update biospecimen (qty avail) Double qtyAvail = iLimsService.getQuantityAvailable(cpModel.getObject().getBiospecimen()); cpModel.getObject().getBiospecimen().setQuantity(qtyAvail); try { iLimsService.updateBiospecimen(cpModel.getObject()); } catch (ArkSystemException e) { this.error(e.getMessage()); } this.info("Successfully removed the transaction"); target.add(feedbackPanel); target.add(dataViewListWMC); // repaint the list target.add(dataViewListWMC.getParent().getParent()); // repaint the parent form } }; rowDetailsWMC.add(rowDeleteLink); // if ((bioTransaction.getStatus() != null) && (bioTransaction.getStatus().getName().equalsIgnoreCase(Constants.BIOTRANSACTION_STATUS_INITIAL_QUANTITY))) { // // do not allow the initial quantity to be deleted // rowDetailsWMC.setVisible(false); // } idLbl = new Label("bioTransaction.id", bioTransaction.getId().toString()); String dateOfTransaction = ""; if (bioTransaction.getTransactionDate() != null) { dateOfTransaction = simpleDateFormat.format(bioTransaction.getTransactionDate()); } transactionDateLbl = new Label("bioTransaction.transactionDate", dateOfTransaction); if (bioTransaction.getQuantity() == null) { quantityLbl = new Label("bioTransaction.quantity", "0"); } else { quantityLbl = new Label("bioTransaction.quantity", bioTransaction.getQuantity().toString()); } if (bioTransaction.getBiospecimen().getUnit() == null) { unitsLbl = new Label("bioTransaction.biospecimen.unit.name", ""); } else { unitsLbl = new Label("bioTransaction.biospecimen.unit.name", bioTransaction.getBiospecimen().getUnit().getName()); } reasonLbl = new Label("bioTransaction.reason", bioTransaction.getReason()); recorderLbl = new Label("bioTransaction.recorder", bioTransaction.getRecorder()); if (bioTransaction.getStatus() == null) { statusLbl = new Label("bioTransaction.status.name", ""); } else { statusLbl = new Label("bioTransaction.status.name", bioTransaction.getStatus().getName()); } if (bioTransaction.getAccessRequest() == null) { requestLbl = new Label("bioTransaction.accessRequest.id", ""); } else { requestLbl = new Label("bioTransaction.accessRequest.id", bioTransaction.getAccessRequest().getId().toString()); } item.add(idLbl); item.add(transactionDateLbl); if (bioTransaction.getQuantity() > 0) { quantityImage = new ContextImage("bioTransaction.quantityImage", new Model<String>("images/icons/arrow_up.png")); } else { quantityImage = new ContextImage("bioTransaction.quantityImage", new Model<String>("images/icons/arrow_down_red.png")); } item.add(quantityImage); item.add(quantityLbl); item.add(unitsLbl); item.add(reasonLbl); item.add(recorderLbl); item.add(statusLbl); item.add(requestLbl); item.add(rowDetailsWMC); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; return bioTransactionDataView; }
From source file:au.org.theark.lims.web.component.global.biospecimen.form.BiospecimenListForm.java
License:Open Source License
/** * /*from w w w .j a v a 2 s .c om*/ * @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().setBioCollection(biospecimenFromDB.getBioCollection()); 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.subjectlims.lims.biocollection.form.BioCollectionListForm.java
License:Open Source License
/** * /* w w w . ja v a 2 s . c om*/ * @param iModel * @return the pageableListView of BioCollection */ public DataView<BioCollection> buildDataView( ArkDataProvider<BioCollection, ILimsService> bioCollectionProvider) { DataView<BioCollection> bioCollectionDataView = new DataView<BioCollection>("collectionList", bioCollectionProvider) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final Item<BioCollection> item) { item.setOutputMarkupId(true); // DO NOT store the item.getModelObject! Checking it is ok... final BioCollection bioCollection = 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) { BioCollection bc = (BioCollection) (getParent().getDefaultModelObject()); CompoundPropertyModel<LimsVO> newModel = new CompoundPropertyModel<LimsVO>(new LimsVO()); newModel.getObject().getBioCollection().setId(bc.getId()); showModalWindow(target, newModel); } }; SimpleDateFormat simpleDateFormat = new SimpleDateFormat(au.org.theark.core.Constants.DD_MM_YYYY); idLblFld = new Label("bioCollection.id", String.valueOf(bioCollection.getId())); biocollectionLblFld = new Label("bioCollection.biocollectionUid", bioCollection.getBiocollectionUid()); nameLblFld = new Label("bioCollection.name", bioCollection.getName()); listDetailsLink.add(biocollectionLblFld); rowDetailsWMC.add(listDetailsLink); if (bioCollection.getCollectionDate() != null) { collectionDateLblFld = new Label("bioCollection.collectionDate", simpleDateFormat.format(bioCollection.getCollectionDate())); } else { collectionDateLblFld = new Label("bioCollection.collectionDate", ""); } if (bioCollection.getSurgeryDate() != null) { new Label("bioCollection.surgeryDate", simpleDateFormat.format(bioCollection.getSurgeryDate())); } else { new Label("bioCollection.surgeryDate", ""); } commentsLblFld = new Label("bioCollection.comments", bioCollection.getComments()); item.add(idLblFld); item.add(rowDetailsWMC); item.add(nameLblFld); item.add(collectionDateLblFld); item.add(commentsLblFld); 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 bioCollectionDataView; }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biospecimen.form.BiospecimenListForm.java
License:Open Source License
/** * // www . j a v a2s. c o 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()); newModel.getObject().setBiospecimen(biospecimenFromDB); newModel.getObject().setBioCollection(biospecimenFromDB.getBioCollection()); 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()); sampleTypeLblFld = new Label("biospecimen.sampleType.name", biospecimen.getSampleType().getName()); collectionLblFld = new Label("biospecimen.bioCollection.biocollectionUid", biospecimen.getBioCollection().getBiocollectionUid()); commentsLblFld = new Label("biospecimen.comments", biospecimen.getComments()); 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); newModel.getObject().setTreeModel(cpModel.getObject().getTreeModel()); 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(sampleTypeLblFld); item.add(collectionLblFld); //item.add(commentsLblFld); 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() { SecurityManager securityManager = ThreadContext.getSecurityManager(); Subject currentUser = SecurityUtils.getSubject(); boolean canCreate = ArkPermissionHelper.hasNewPermission(securityManager, currentUser); boolean validQuantity = (item.getModelObject().getQuantity() != null && item.getModelObject().getQuantity() > 0); return (canCreate && validQuantity); }; }.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).setOutputMarkupPlaceholderTag(true)); 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.phenotypic.web.component.phenodatacategory.SearchResultListPanel.java
License:Open Source License
private WebMarkupContainer buildLinkWMC(final Item<PhenoDataSetCategory> item) { WebMarkupContainer phenoDatasetCategoryLinkWMC = new WebMarkupContainer("phenoDataSetCategoryLinkWMC", item.getModel());/*from w w w .j a v a 2s.co m*/ ArkBusyAjaxLink link = new ArkBusyAjaxLink(Constants.PHENODATASETCATEGORY_NAME) { @Override public void onClick(AjaxRequestTarget target) { // Sets the selected object into the model PhenoDataSetCategory cf = (PhenoDataSetCategory) (getParent().getDefaultModelObject()); CompoundPropertyModel<PhenoDataSetCategoryVO> newModel = new CompoundPropertyModel<PhenoDataSetCategoryVO>( new PhenoDataSetCategoryVO()); newModel.getObject().setPhenoDataSetCategory(cf); //newModel.getObject().setUseCustomFieldCategoryDisplay(cpModel.getObject().isUseCustomFieldCategoryDisplay()); DetailPanel detailPanel = new DetailPanel("detailPanel", feedbackPanel, newModel, arkCrudContainerVO); arkCrudContainerVO.getDetailPanelContainer().addOrReplace(detailPanel); ArkCRUDHelper.preProcessDetailPanelOnSearchResults(target, arkCrudContainerVO); } }; // Add the label for the link PhenoDataSetCategory category = item.getModelObject(); Label nameLinkLabel = new Label("nameLbl", category.getName()); //Label nameLinkLabel = new Label("nameLbl",PhenoDataSetCategoryOrderingHelper.getInstance().preTextDecider(category).concat(category.getName())); link.add(nameLinkLabel); phenoDatasetCategoryLinkWMC.add(link); return phenoDatasetCategoryLinkWMC; }
From source file:au.org.theark.phenotypic.web.component.phenodatadictionary.SearchResultListPanel.java
License:Open Source License
private WebMarkupContainer buildLinkWMC(final Item<PhenoDataSetField> item) { WebMarkupContainer phenoDataSetfieldLinkWMC = new WebMarkupContainer("phenoDataSetfieldLinkWMC", item.getModel());/* w w w .j a v a 2 s .c om*/ ArkBusyAjaxLink link = new ArkBusyAjaxLink(Constants.PHENODATASET_NAME) { @Override public void onClick(AjaxRequestTarget target) { // Sets the selected object into the model PhenoDataSetField phenoField = (PhenoDataSetField) (getParent().getDefaultModelObject()); CompoundPropertyModel<PhenoDataSetFieldVO> newModel = new CompoundPropertyModel<PhenoDataSetFieldVO>( new PhenoDataSetFieldVO()); newModel.getObject().setPhenoDataSetField(phenoField); //newModel.getObject().setUsePhenoDataSetFieldDisplay(cpModel.getObject().isUsePhenoDataSetFieldDisplay()); DetailPanel detailPanel = new DetailPanel("detailPanel", feedbackPanel, newModel, arkCrudContainerVO); //unitTypeDropDownOn,subjectCustomField); arkCrudContainerVO.getDetailPanelContainer().addOrReplace(detailPanel); ArkCRUDHelper.preProcessDetailPanelOnSearchResults(target, arkCrudContainerVO); } }; // Add the label for the link PhenoDataSetField field = item.getModelObject(); Label nameLinkLabel = new Label("nameLbl", field.getName()); link.add(nameLinkLabel); phenoDataSetfieldLinkWMC.add(link); return phenoDataSetfieldLinkWMC; }