List of usage examples for org.apache.wicket.ajax AjaxRequestTarget add
void add(Component... components);
From source file:au.org.theark.lims.web.component.bioupload.form.SearchForm.java
License:Open Source License
@Override protected void onNew(AjaxRequestTarget target) { // NB: Should not be possible to get here (GUI should be using Wizard for new) // Due to ARK-108 :: No longer reset the VO onNew(..) UploadVO UploadVO = getModelObject(); UploadVO.setMode(au.org.theark.core.Constants.MODE_NEW); UploadVO.getUpload().setId(null); // must ensure Id is blank onNew setModelObject(UploadVO);// ww w . jav a 2s. c o m arkCrudContainerVO.getSearchResultPanelContainer().setVisible(false); arkCrudContainerVO.getSearchPanelContainer().setVisible(false); // Explicitly Show Wizard panel arkCrudContainerVO.getWizardPanelContainer().setVisible(true); arkCrudContainerVO.getWizardPanelContainer().setEnabled(true); target.add(arkCrudContainerVO.getSearchResultPanelContainer()); target.add(arkCrudContainerVO.getSearchPanelContainer()); target.add(arkCrudContainerVO.getDetailPanelFormContainer()); target.add(arkCrudContainerVO.getWizardPanelContainer()); }
From source file:au.org.theark.lims.web.component.global.biospecimen.form.BiospecimenListForm.java
License:Open Source License
private void initialiseDataView() { Subject currentUser = SecurityUtils.getSubject(); ArkUser arkUser;/*from w w w. j av a 2s. c o m*/ try { arkUser = iArkCommonService.getArkUser(currentUser.getPrincipal().toString()); ArkUserVO arkUserVo = new ArkUserVO(); arkUserVo.setArkUserEntity(arkUser); studyListForUser = iArkCommonService.getStudyListForUser(arkUserVo); //getParentAndChildStudies(sessionStudyId); } catch (EntityNotFoundException e) { e.printStackTrace(); } 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()); } 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()); final IModel<String> amountModel = new Model<String>(Integer.toString(biospecimenProvider.size())); dataViewListWMC.add(new Label("total", amountModel) { private static final long serialVersionUID = 1L; protected void onBeforeRender() { amountModel.setObject(Integer.toString(biospecimenProvider.size())); super.onBeforeRender(); }; }); 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.global.biospecimen.form.BiospecimenListForm.java
License:Open Source License
/** * /* w w w .j ava2s . 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.inventory.form.AbstractInventoryDetailForm.java
License:Open Source License
/** * Initialise the form, with the general edit/save/cancel/delete buttons * //w ww. j a v a2s . c o m */ protected void initialiseForm() { cancelButton = new AjaxButton(Constants.CANCEL) { private static final long serialVersionUID = 1684005199059571017L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { detailContainer.setVisible(false); target.add(detailContainer); processErrors(target); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } }; saveButton = new ArkBusyAjaxButton(Constants.SAVE) { private static final long serialVersionUID = -423605230448635419L; @Override public boolean isVisible() { return ArkPermissionHelper.isActionPermitted(Constants.SAVE); } public void onSubmit(AjaxRequestTarget target, Form<?> form) { onSave(containerForm, target); target.add(detailFormContainer); target.add(containerPanel); } @SuppressWarnings("unchecked") public void onError(AjaxRequestTarget target, Form<?> form) { boolean setFocusError = false; WebMarkupContainer wmc = (WebMarkupContainer) form.get("detailFormContainer"); for (Iterator iterator = wmc.iterator(); iterator.hasNext();) { Component component = (Component) iterator.next(); if (component instanceof FormComponent) { FormComponent formComponent = (FormComponent) component; if (!formComponent.isValid()) { if (!setFocusError) { // Place focus on field in error (for the first field in error) target.focusComponent(formComponent); setFocusError = true; } } } } processErrors(target); } }; deleteButton = new AjaxDeleteButton(Constants.DELETE, new StringResourceModel("confirmDelete", this, null), new StringResourceModel(Constants.DELETE, this, null)) { private static final long serialVersionUID = 4005032637149080009L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { onDeleteConfirmed(target); target.add(feedbackPanel); detailContainer.setVisible(false); target.add(detailContainer); // remove node DefaultTreeModel treeModel = (DefaultTreeModel) tree.getDefaultModelObject(); for (Object selectedNode : tree.getTreeState().getSelectedNodes()) { treeModel.removeNodeFromParent((MutableTreeNode) selectedNode); } tree.updateTree(target); } @Override public boolean isVisible() { return (ArkPermissionHelper.isActionPermitted(Constants.DELETE) && !isNew()); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } @Override public boolean isEnabled() { return canDelete(); } }; //editButton.setDefaultFormProcessing(false); cancelButton.setDefaultFormProcessing(false); /* Defines a edit mode */ editButtonContainer = new WebMarkupContainer("editButtonContainer"); editButtonContainer.setOutputMarkupPlaceholderTag(true); editButtonContainer.setVisible(isNew()); // Initialise in read only detailFormContainer = new WebMarkupContainer("detailFormContainer"); detailFormContainer.setOutputMarkupPlaceholderTag(true); detailFormContainer.setEnabled(isNew()); addComponentsToForm(); }
From source file:au.org.theark.lims.web.component.inventory.form.AbstractInventoryDetailForm.java
License:Open Source License
/** * A helper method that will allow the toggle of panels and buttons. This method can be invoked by sub-classes as part of the onSave() * implementation.Once the user has pressed Save either to create a new entity or update, invoking this method will place the new/edited record * panel in View/Read only mode.// w ww . j a va 2 s.co m * * @param target */ protected void onSavePostProcess(AjaxRequestTarget target) { detailFormContainer.setEnabled(true); editButtonContainer.setVisible(true); target.add(detailFormContainer); target.add(editButtonContainer); // trigger redraw of corresponding node if (node != null) { tree.treeNodesChanged(new TreeModelEvent(this, new TreePath(node.getParent()), new int[] { 0 }, new TreeNode[] { node })); } tree.updateTree(target); }
From source file:au.org.theark.lims.web.component.inventory.form.AbstractInventoryDetailForm.java
License:Open Source License
/** * Refresh/repaint the detailPanel/* w ww .j ava 2 s . com*/ * * @param target * @param detailPanel */ public void refreshDetailPanel(AjaxRequestTarget target, Panel detailPanel) { detailContainer.addOrReplace(detailPanel); detailContainer.setVisible(true); target.add(feedbackPanel); target.add(detailContainer); target.add(detailPanel); }
From source file:au.org.theark.lims.web.component.inventory.form.BoxAllocationDetailForm.java
License:Open Source License
@Override protected void onSave(Form<LimsVO> containerForm, AjaxRequestTarget target) { if (containerForm.getModelObject().getInvBox().getAvailable() == 0) { this.error("This box has no available locations"); } else {/*from w w w . j a v a 2 s . co m*/ String biospecimenUid = containerForm.getModelObject().getBiospecimen().getBiospecimenUid(); if (biospecimenUid != null && !biospecimenUid.isEmpty()) { Long studyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = null; //Inventory can be loaded without selecting a study if (studyId != null) { study = iArkCommonService.getStudy(studyId); } Biospecimen biospecimen = iLimsService.getBiospecimenByUid(biospecimenUid, study); if (biospecimen != null && biospecimen.getId() != null) { InvCell invCell = iInventoryService.getInvCellByBiospecimen(biospecimen); if (invCell.getBiospecimen() != null) { try { BiospecimenLocationVO biospecimenLocationVO = iInventoryService .getBiospecimenLocation(biospecimen); StringBuilder location = new StringBuilder(); location.append("The Biospecimen: "); location.append(biospecimenUid); location.append(" is already allocated at "); location.append("Box: "); location.append(biospecimenLocationVO.getBoxName()); location.append(" "); location.append("Row: "); location.append(biospecimenLocationVO.getRowLabel()); location.append(", "); location.append("Column: "); location.append(biospecimenLocationVO.getColLabel()); this.error(location.toString()); } catch (ArkSystemException e) { log.error(e.getMessage()); } } else { invCell = iInventoryService .getNextAvailableInvCell(containerForm.getModelObject().getInvBox()); containerForm.getModelObject().setBiospecimen(biospecimen); invCell.setBiospecimen(containerForm.getModelObject().getBiospecimen()); // TODO: use Reference CellStatus invCell.setStatus("Not Empty"); containerForm.getModelObject().setInvCell(invCell); iInventoryService.updateInvCell(invCell); try { iLimsService.updateBiospecimen(containerForm.getModelObject()); } catch (ArkSystemException e1) { this.error(e1.getMessage()); } // Refresh the gridpanel gridBoxPanel = new GridBoxPanel("gridBoxPanel", containerForm.getModelObject(), modalWindow, false); BoxAllocationDetailForm.this.getParent().addOrReplace(gridBoxPanel); target.add(gridBoxPanel); try { BiospecimenLocationVO biospecimenLocationVO = iInventoryService .getBiospecimenLocation(biospecimen); StringBuilder location = new StringBuilder(); location.append("The Biospecimen: "); location.append(biospecimenUid); location.append(" allocated to "); location.append("Row: "); location.append(biospecimenLocationVO.getRowLabel()); location.append(", "); location.append("Column: "); location.append(biospecimenLocationVO.getColLabel()); this.info(location.toString()); } catch (ArkSystemException e) { log.error(e.getMessage()); } // Refresh text box model reference containerForm.getModelObject().setBiospecimen(new Biospecimen()); } } else { this.error("Biospecimen:" + biospecimenUid + " does not exist in the system. Please check and try again"); } } else { this.error("Scan or manually enter the Biospecimen UID to allocate to the next available position"); } } // refresh feedback target.add(feedbackPanel); }
From source file:au.org.theark.lims.web.component.inventory.form.BoxAllocationDetailForm.java
License:Open Source License
protected void onCancel(AjaxRequestTarget target) { LimsVO limsVo = new LimsVO(); containerForm.setModelObject(limsVo); target.add(feedbackPanel); }
From source file:au.org.theark.lims.web.component.inventory.form.BoxAllocationDetailForm.java
License:Open Source License
@Override protected void processErrors(AjaxRequestTarget target) { target.add(feedbackPanel); }
From source file:au.org.theark.lims.web.component.inventory.form.BoxAllocationDetailForm.java
License:Open Source License
protected void onDeleteConfirmed(AjaxRequestTarget target) { iInventoryService.deleteInvBox(containerForm.getModelObject()); this.info("Box " + containerForm.getModelObject().getInvBox().getName() + " was deleted successfully"); log.info("Box " + containerForm.getModelObject().getInvBox().getName() + " was deleted successfully"); // Display delete confirmation message target.add(feedbackPanel); // Move focus back to Search form LimsVO limsVo = new LimsVO(); containerForm.setModelObject(limsVo); }