List of usage examples for org.apache.wicket.markup.html.image ContextImage ContextImage
public ContextImage(String id, String contextRelativePath)
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 .co m*/ 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.StudyHelper.java
License:Open Source License
public void setStudyLogoImage(final Study study, String id, WebMarkupContainer studyLogoImageContainer) { // Set the study logo if (study != null && study.getStudyLogoBlob() != null) { final java.sql.Blob studyLogoBlob = study.getStudyLogoBlob(); if (studyLogoBlob != null) { BlobImageResource blobImageResource = new BlobImageResource() { private static final long serialVersionUID = 1L; @Override/* www . ja va 2 s . c o m*/ protected Blob getBlob() { return studyLogoBlob; } }; Image studyLogoImage = new Image(id, blobImageResource); studyLogoImageContainer.addOrReplace(studyLogoImage); } } else { noStudyLogoImage = new ContextImage("study.studyLogoImage", new Model<String>("images/no_study_logo.gif")); studyLogoImageContainer.addOrReplace(noStudyLogoImage); } }
From source file:au.org.theark.lims.web.component.biospecimen.form.BiospecimenListForm.java
License:Open Source License
/** * /*from www .j av a2s .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.biotransaction.BioTransactionListPanel.java
License:Open Source License
/** * /* w w w .ja v a2s . 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
/** * /* 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().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.biospecimen.form.BiospecimenListForm.java
License:Open Source License
/** * //from w w w. ja va 2s. 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.phenodatadictionary.SearchResultListPanel.java
License:Open Source License
public DataView<PhenoDataSetField> buildDataView( ArkDataProvider2<PhenoDataSetField, PhenoDataSetField> subjectProvider) { DataView<PhenoDataSetField> phonoFieldDataView = new DataView<PhenoDataSetField>("phenoDataSetFieldLst", subjectProvider) {/*from w w w. ja v a 2 s . c o m*/ @Override protected void populateItem(final Item<PhenoDataSetField> item) { PhenoDataSetField field = item.getModelObject(); if (field.getId() != null) { // Add the id component here item.add(new Label(Constants.PHENODATASET_ID, field.getId().toString())); } else { item.add(new Label(Constants.PHENODATASET_ID, "")); } // Component Name Link item.add(buildLinkWMC(item)); // Field Type if (field.getFieldType() != null) { item.add(new Label(Constants.PHENODATASET_FIELD_TYPE, field.getFieldType().getName())); } else { item.add(new Label(Constants.PHENODATASET_FIELD_TYPE, "")); } // Field Label if (field.getFieldLabel() != null) { item.add(new Label(Constants.PHENODATASET_FIELD_LABEL, field.getFieldLabel())); } else { item.add(new Label(Constants.PHENODATASET_FIELD_LABEL, "")); } if (field.getDefaultValue() != null) { item.add(new Label(Constants.PHENODATASET_DEFAULT_VALUE, field.getDefaultValue())); } else { item.add(new Label(Constants.PHENODATASET_DEFAULT_VALUE, "")); } if (field.getMissingValue() != null) { item.add(new Label(Constants.PHENODATASET_MISSING_VALUE, field.getMissingValue())); } else { item.add(new Label(Constants.PHENODATASET_MISSING_VALUE, "")); } if (field.getRequired() != null && field.getRequired() == true) { item.add(new ContextImage(Constants.PHENODATASET_REQUIRED, new Model<String>("images/icons/tick.png"))); } else { item.add(new ContextImage(Constants.PHENODATASET_REQUIRED, new Model<String>("images/icons/cross.png"))); } /* For the alternative stripes */ item.add(new AttributeModifier("class", new AbstractReadOnlyModel() { @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; addToolbars(phonoFieldDataView); return phonoFieldDataView; }
From source file:au.org.theark.study.web.component.address.SearchResultListPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public PageableListView<Address> buildPageableListView(IModel iModel) { PageableListView<Address> pageableListView = new PageableListView<Address>(Constants.ADDRESS_LIST, iModel, iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) { private static final long serialVersionUID = 1L; @Override// ww w . j ava2s. c o m protected void populateItem(final ListItem<Address> item) { Address address = item.getModelObject(); item.add(buildLink(address)); if (address.getCity() != null) { item.add(new Label("city", address.getCity())); } else { item.add(new Label("city", "")); } if (address.getState() != null && address.getState().getName() != null) { item.add(new Label("state.name", address.getState().getName()));//TODO things like this might almost need to be constants } else { item.add(new Label("state.name", (address.getOtherState() != null && !address.getOtherState().isEmpty()) ? ("other: " + address.getOtherState()) : "not defined")); } if (address.getPostCode() != null) { item.add(new Label("postCode", address.getPostCode())); } else { item.add(new Label("postCode", "")); } if (address.getCountry() != null && address.getCountry().getName() != null) { item.add(new Label("country.name", address.getCountry().getName())); } else { item.add(new Label("country.name", "")); } if (address.getAddressType() != null && address.getAddressType().getName() != null) { item.add(new Label("addressType.name", address.getAddressType().getName())); } else { item.add(new Label("addressType.name", "")); } if (address.getDateReceived() != null) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat( au.org.theark.core.Constants.DD_MM_YYYY); String dateReceived = ""; dateReceived = simpleDateFormat.format(address.getDateReceived()); item.add(new Label("address.dateReceived", dateReceived)); } else { item.add(new Label("address.dateReceived", "")); } if (address.getPreferredMailingAddress() != null && address.getPreferredMailingAddress() == true) { item.add(new ContextImage("address.preferredMailingAddress", new Model<String>("images/icons/tick.png"))); } else { item.add(new Label("address.preferredMailingAddress", "")); } item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return pageableListView; }
From source file:au.org.theark.study.web.component.contact.AddressListPanel.java
License:Open Source License
/** * Build the data view for display and navigate purposes. * /* www .ja va 2s. c om*/ * @param addressProvider * @return */ private DataView<Address> buildDataView(ArkDataProvider<Address, IStudyService> addressProvider) { DataView<Address> adressListDataView = new DataView<Address>("addressList", addressProvider) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final Item<Address> item) { Address address = item.getModelObject(); item.add(buildLink(address)); if (address.getCity() != null) { item.add(new Label("city", address.getCity())); } else { item.add(new Label("city", "")); } if (address.getState() != null && address.getState().getName() != null) { item.add(new Label("state.name", address.getState().getName()));// TODO things like this might almost need to be constants } else { item.add(new Label("state.name", (address.getOtherState() != null && !address.getOtherState().isEmpty()) ? ("other: " + address.getOtherState()) : "not defined")); } if (address.getPostCode() != null) { item.add(new Label("postCode", address.getPostCode())); } else { item.add(new Label("postCode", "")); } if (address.getCountry() != null && address.getCountry().getName() != null) { item.add(new Label("country.name", address.getCountry().getName())); } else { item.add(new Label("country.name", "")); } if (address.getAddressType() != null && address.getAddressType().getName() != null) { item.add(new Label("addressType.name", address.getAddressType().getName())); } else { item.add(new Label("addressType.name", "")); } if (address.getDateReceived() != null) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat( au.org.theark.core.Constants.DD_MM_YYYY); String dateReceived = ""; dateReceived = simpleDateFormat.format(address.getDateReceived()); item.add(new Label("address.dateReceived", dateReceived)); } else { item.add(new Label("address.dateReceived", "")); } if (address.getPreferredMailingAddress() != null && address.getPreferredMailingAddress() == true) { item.add(new ContextImage("address.preferredMailingAddress", new Model<String>("images/icons/tick.png"))); } else { item.add(new Label("address.preferredMailingAddress", "")); } item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return adressListDataView; }
From source file:au.org.theark.study.web.component.contact.AddressListPanel.java
License:Open Source License
/** * Build the data view for export purposes with subject id. * //from w w w .j a v a 2 s .c o m * @param addressProvider * @return */ private DataView<AddressSubjectVO> buildDataViewWithSubjectStudyID( ArkDataProvider<AddressSubjectVO, IStudyService> addressProvider) { DataView<AddressSubjectVO> addressListDataView = new DataView<AddressSubjectVO>("addressList", addressProvider) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final Item<AddressSubjectVO> item) { AddressSubjectVO addressSubjectVO = item.getModelObject(); // item.add(buildLink(address)); if (addressSubjectVO.getSubjectUID() != null) { item.add(new Label("subjectUID", addressSubjectVO.getSubjectUID())); } else { item.add(new Label("subjectUID", "")); } if (addressSubjectVO.getStreetAddress() != null) { item.add(new Label("streetAddress", addressSubjectVO.getStreetAddress())); } else { item.add(new Label("streetAddress", "")); } if (addressSubjectVO.getCity() != null) { item.add(new Label("city", addressSubjectVO.getCity())); } else { item.add(new Label("city", "")); } if (addressSubjectVO.getState() != null && addressSubjectVO.getState().getName() != null) { item.add(new Label("state.name", addressSubjectVO.getState().getName()));// TODO things like this might almost need to be constants } else { item.add(new Label("state.name", (addressSubjectVO.getOtherState() != null && !addressSubjectVO.getOtherState().isEmpty()) ? ("other: " + addressSubjectVO.getOtherState()) : "not defined")); } if (addressSubjectVO.getPostCode() != null) { item.add(new Label("postCode", addressSubjectVO.getPostCode())); } else { item.add(new Label("postCode", "")); } if (addressSubjectVO.getCountry() != null && addressSubjectVO.getCountry().getName() != null) { item.add(new Label("country.name", addressSubjectVO.getCountry().getName())); } else { item.add(new Label("country.name", "")); } if (addressSubjectVO.getAddressType() != null && addressSubjectVO.getAddressType().getName() != null) { item.add(new Label("addressType.name", addressSubjectVO.getAddressType().getName())); } else { item.add(new Label("addressType.name", "")); } if (addressSubjectVO.getDateReceived() != null) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat( au.org.theark.core.Constants.DD_MM_YYYY); String dateReceived = ""; dateReceived = simpleDateFormat.format(addressSubjectVO.getDateReceived()); item.add(new Label("address.dateReceived", dateReceived)); } else { item.add(new Label("address.dateReceived", "")); } if (addressSubjectVO.getPreferredMailingAddress() != null && addressSubjectVO.getPreferredMailingAddress() == true) { item.add(new ContextImage("address.preferredMailingAddress", new Model<String>("images/icons/tick.png"))); } else { item.add(new Label("address.preferredMailingAddress", "")); } item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return addressListDataView; }