List of usage examples for org.apache.wicket.markup.html.basic Label setVisible
public final Component setVisible(final boolean visible)
From source file:au.org.theark.lims.web.component.inventory.panel.box.display.GridBoxPanel.java
License:Open Source License
/** * Creates the header of the table for the represented InvBox in question * @param invBox/*from www . j a v a 2 s .co m*/ * @return */ @SuppressWarnings({ "unchecked" }) private Loop createHeadings(final InvBox invBox) { String colRowNoType = ""; if (invBox.getId() != null) { colRowNoType = invBox.getColnotype().getName(); } else { // handle for null invBox (eg when backend list of cells corrupted) return new Loop("heading", 1) { private static final long serialVersionUID = 1L; @Override protected void populateItem(LoopItem item) { Label colLabel = new Label("cellHead", ""); item.add(colLabel.setVisible(false)); } @Override public boolean isVisible() { return false; } }; } final String colNoType = colRowNoType; // Outer Loop instance, using a PropertyModel to bind the Loop iteration to invBox "noofcol" value return new Loop("heading", new PropertyModel(invBox, "noofcol")) { private static final long serialVersionUID = -7027878243061138904L; public void populateItem(LoopItem item) { final int col = item.getIndex(); IModel<String> colModel = new Model() { private static final long serialVersionUID = 1144128566137457199L; @Override public Serializable getObject() { String label = new String(); if (colNoType.equalsIgnoreCase("ALPHABET")) { char character = (char) (col + 65); label = new Character(character).toString(); } else { label = new Integer(col + 1).toString(); } return label; } }; // Create the col number/label Label colLabel = new Label("cellHead", colModel); item.add(colLabel); } }; }
From source file:au.org.theark.study.web.component.address.form.DetailForm.java
License:Open Source License
@Override protected void onSave(Form<AddressVO> containerForm, AjaxRequestTarget target) { Long personSessionId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID); StringBuffer feedBackMessageStr = new StringBuffer(); // Get the person and set it on the AddressVO. try {//from w w w .j av a 2 s . co m Person person = iStudyService.getPerson(personSessionId); List<State> statesForThisCountry = iArkCommonService .getStates(containerForm.getModelObject().getAddress().getCountry()); if (statesForThisCountry.isEmpty()) { containerForm.getModelObject().getAddress().setState(null); } else { containerForm.getModelObject().getAddress().setOtherState(null); } // otherStateInvalidError.setVisible(false); WebMarkupContainer wmcStateSelector = (WebMarkupContainer) arkCrudContainerVO .getDetailPanelFormContainer().get(Constants.STATE_SELECTOR_WMC); Label otherStateInvalidError = (Label) wmcStateSelector.get("address.otherStateInvalidError"); otherStateInvalidError.setVisible(false); containerForm.getModelObject().getAddress().setPerson(person); if (containerForm.getModelObject().getAddress().getId() == null) { if (containerForm.getModelObject().getAddress().getPreferredMailingAddress()) { // Update any other preferredMailingAddresses to false iStudyService.setPreferredMailingAdressToFalse(person); } iStudyService.create(containerForm.getModelObject().getAddress()); feedBackMessageStr.append("Address was successfully added and linked to Subject: "); } else { if (containerForm.getModelObject().getAddress().getPreferredMailingAddress()) { // Update any other preferredMailingAddresses to false iStudyService.setPreferredMailingAdressToFalse(person); } iStudyService.update(containerForm.getModelObject().getAddress()); feedBackMessageStr.append("Address was successfully updated and linked to Subject: "); } if (person.getFirstName() != null && person.getLastName() != null) { feedBackMessageStr.append(person.getFirstName() + " " + person.getLastName()); } else { Long studyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = iArkCommonService.getStudy(studyId); String uid = iArkCommonService.getSubject(person.getId(), study).getSubjectUID(); feedBackMessageStr.append(uid); } this.info(feedBackMessageStr.toString()); processErrors(target); onSavePostProcess(target); // Invoke backend to persist the AddressVO } catch (EntityNotFoundException e) { this.error("The Specified subject is not available any more in the system. Please re-do the operation"); } catch (ArkSystemException e) { this.error("A system error has occured, Pleas contact support."); } }
From source file:au.org.theark.study.web.component.address.form.SearchForm.java
License:Open Source License
public void updateDetailFormPrerender(Address address) { // Ensure we update the CountyStateChoices in DetailsForm // like what happens via DetailForm's updateStateChoices(..) List<State> stateList = iArkCommonService.getStates(address.getCountry()); WebMarkupContainer wmcStateSelector = (WebMarkupContainer) arkCrudContainerVO.getDetailPanelFormContainer() .get(Constants.STATE_SELECTOR_WMC); DropDownChoice<State> detailStateSelector = (DropDownChoice<State>) wmcStateSelector.get("address.state"); Label otherStateInvalidError = (Label) wmcStateSelector.get("address.otherStateInvalidError"); TextField<String> otherState = (TextField<String>) wmcStateSelector.get("address.otherState"); if (stateList != null && stateList.size() > 0) { detailStateSelector.getChoices().clear(); detailStateSelector.setChoices(stateList); detailStateSelector.setVisible(true); otherState.setVisible(false);/*from www.j ava 2 s . c o m*/ //ARK-748 //Ignore the new Address objects from state validation and hide the other state validation label if (getModelObject().getAddress().getId() != null && otherState.getModelObject() != null && !otherState.getModelObject().isEmpty()) { //alert the user otherStateInvalidError = new Label("address.otherStateInvalidError", "Previously uploaded value " + otherState.getModelObject() + " was invalid."); otherStateInvalidError.add(new Behavior() { /** * */ private static final long serialVersionUID = 7964297415151363039L; @Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); tag.put("class", "fieldErrorMessage");//or something like ("style"; "color-red") } }); wmcStateSelector.addOrReplace(otherStateInvalidError); } else { otherStateInvalidError.setVisible(false); } } else { // hide it detailStateSelector.setVisible(false); otherState.setVisible(true); otherStateInvalidError.setVisible(false); } }
From source file:au.org.theark.study.web.component.contact.ContactContainerPanel.java
License:Open Source License
/** * /* w w w . j a v a 2 s .co m*/ * @param address */ private void updateDetailFormPrerender(Address address) { // Ensure we update the CountyStateChoices in DetailsForm // like what happens via DetailForm's updateStateChoices(..) List<State> stateList = iArkCommonService.getStates(address.getCountry()); WebMarkupContainer wmcStateSelector = (WebMarkupContainer) arkCrudContainerVO.getDetailPanelFormContainer() .get(Constants.STATE_SELECTOR_WMC); DropDownChoice<State> detailStateSelector = (DropDownChoice<State>) wmcStateSelector .get("addressVo.address.state"); Label otherStateInvalidError = (Label) wmcStateSelector.get("addressVo.address.otherStateInvalidError"); TextField<String> otherState = (TextField<String>) wmcStateSelector.get("addressVo.address.otherState"); if (stateList != null && stateList.size() > 0) { detailStateSelector.getChoices().clear(); detailStateSelector.setChoices(stateList); detailStateSelector.setVisible(true); otherState.setVisible(false); //ARK-748 //Ignore the new Address objects from state validation and hide the other state validation label if (cpModel.getObject().getAddressVo().getAddress().getId() != null && otherState.getModelObject() != null && !otherState.getModelObject().isEmpty()) { //alert the user otherStateInvalidError = new Label("addressVo.address.otherStateInvalidError", "Previously uploaded value " + otherState.getModelObject() + " was invalid."); otherStateInvalidError.add(new Behavior() { /** * */ private static final long serialVersionUID = 7964297415151363039L; @Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); tag.put("class", "fieldErrorMessage");//or something like ("style"; "color-red") } }); wmcStateSelector.addOrReplace(otherStateInvalidError); } else { otherStateInvalidError.setVisible(false); } } else { // hide it detailStateSelector.setVisible(false); otherState.setVisible(true); otherStateInvalidError.setVisible(false); } }
From source file:au.org.theark.study.web.component.contact.form.AddressDetailForm.java
License:Open Source License
@Override protected void onSave(Form<ContactVO> containerForm, AjaxRequestTarget target) { Long personSessionId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID); StringBuffer feedBackMessageStr = new StringBuffer(); // Get the person and set it on the AddressVO. try {/*w w w.j a v a 2 s. c om*/ Person person = iStudyService.getPerson(personSessionId); List<State> statesForThisCountry = iArkCommonService .getStates(containerForm.getModelObject().getAddressVo().getAddress().getCountry()); if (statesForThisCountry.isEmpty()) { containerForm.getModelObject().getAddressVo().getAddress().setState(null); } else { containerForm.getModelObject().getAddressVo().getAddress().setOtherState(null); } // otherStateInvalidError.setVisible(false); WebMarkupContainer wmcStateSelector = (WebMarkupContainer) arkCrudContainerVO .getDetailPanelFormContainer().get(Constants.STATE_SELECTOR_WMC); Label otherStateInvalidError = (Label) wmcStateSelector.get("addressVo.address.otherStateInvalidError"); otherStateInvalidError.setVisible(false); containerForm.getModelObject().getAddressVo().getAddress().setPerson(person); if (containerForm.getModelObject().getAddressVo().getAddress().getId() == null) { if (containerForm.getModelObject().getAddressVo().getAddress().getPreferredMailingAddress()) { // Update any other preferredMailingAddresses to false iStudyService.setPreferredMailingAdressToFalse(person); } iStudyService.create(containerForm.getModelObject().getAddressVo().getAddress()); feedBackMessageStr.append("Address was successfully added and linked to Subject: "); } else { if (containerForm.getModelObject().getAddressVo().getAddress().getPreferredMailingAddress()) { // Update any other preferredMailingAddresses to false iStudyService.setPreferredMailingAdressToFalse(person); } iStudyService.update(containerForm.getModelObject().getAddressVo().getAddress()); feedBackMessageStr.append("Address was successfully updated and linked to Subject: "); } if (person.getFirstName() != null && person.getLastName() != null) { feedBackMessageStr.append(person.getFirstName() + " " + person.getLastName()); } else { Long studyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = iArkCommonService.getStudy(studyId); String uid = iArkCommonService.getSubject(person.getId(), study).getSubjectUID(); feedBackMessageStr.append(uid); } this.info(feedBackMessageStr.toString()); processErrors(target); onSavePostProcess(target); // Invoke backend to persist the AddressVO } catch (EntityNotFoundException e) { this.error("The Specified subject is not available any more in the system. Please re-do the operation"); } catch (ArkSystemException e) { this.error("A system error has occured, Pleas contact support."); } }
From source file:au.org.theark.study.web.component.managestudy.SearchResultListPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public PageableListView<Study> buildPageableListView(IModel iModel, final WebMarkupContainer searchResultsContainer) { PageableListView<Study> studyPageableListView = new PageableListView<Study>("studyList", iModel, iArkCommonService.getUserConfig(Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) { private static final long serialVersionUID = 1L; @Override//from w w w . j av a 2 s . c o m protected void populateItem(final ListItem<Study> item) { Study study = item.getModelObject(); if (study.getId() != null) { item.add(new Label("id", study.getId().toString())); } else { item.add(new Label("id", "")); } childStudiesExist = (study.getParentStudy() != null); // Add "+" indicator if study has a parent (but handle for actual parent) Label childStudyLabel = new Label("childStudyIndicator", "+"); childStudyLabel.setVisible(childStudiesExist && (study != study.getParentStudy())); childStudyNote.setVisible(childStudiesExist); item.add(childStudyLabel); item.add(buildLink(study, searchResultsContainer)); if (study.getContactPerson() != null) { item.add(new Label("contact", study.getContactPerson()));// the ID here must match the ones in mark-up } else { item.add(new Label("contact", ""));// the ID here must match the ones in mark-up } SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.DD_MM_YYYY); String dateOfApplication = ""; if (study.getDateOfApplication() != null) { dateOfApplication = simpleDateFormat.format(study.getDateOfApplication()); item.add(new Label("dateOfApplication", dateOfApplication)); } else { item.add(new Label("dateOfApplication", dateOfApplication)); } 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 studyPageableListView; }
From source file:ch.tkuhn.nanobrowser.AgentItem.java
License:Open Source License
public AgentItem(String id, AgentElement a, int guiItemStyle) { super(id);/*from w ww . ja va 2 s. com*/ PageParameters params = new PageParameters(); params.add("uri", a.getURI()); BookmarkablePageLink<WebPage> link = new BookmarkablePageLink<WebPage>("agentlink", AgentPage.class, params); add(link); WebMarkupContainer icon = new WebMarkupContainer("icon"); if (a.isBot()) { icon.add(new AttributeModifier("src", new Model<String>("icons/bot.svg"))); } link.add(icon); Label nameLabel = new Label("agent", a.getName()); nameLabel.setVisible(guiItemStyle != ThingElement.TINY_GUI_ITEM); link.add(nameLabel); }
From source file:ch.tkuhn.nanobrowser.NanopubItem.java
License:Open Source License
public NanopubItem(String id, NanopubElement n, int guiItemStyle) { super(id);/* w ww .j av a2s . c o m*/ PageParameters params = new PageParameters(); params.add("uri", n.getURI()); BookmarkablePageLink<WebPage> link = new BookmarkablePageLink<WebPage>("nanopublink", NanopubPage.class, params); add(link); WebMarkupContainer icon = new WebMarkupContainer("icon"); if (n.isValid()) { icon.add(new AttributeModifier("src", new Model<String>("icons/nanopubv.svg"))); } link.add(icon); String date = n.getCreateDateString(); Label dateLabel; if (date == null) { dateLabel = new Label("nanopubdate", ""); } else { dateLabel = new Label("nanopubdate", n.getCreateDateString()); } dateLabel.setVisible(guiItemStyle == ThingElement.LONG_GUI_ITEM); add(dateLabel); Label nameLabel = new Label("nanopubname", " " + n.getShortName() + " "); nameLabel.setVisible(guiItemStyle != ThingElement.TINY_GUI_ITEM); link.add(nameLabel); }
From source file:ch.tkuhn.nanobrowser.PaperItem.java
License:Open Source License
public PaperItem(String id, PaperElement p, int guiItemStyle) { super(id);/*from www . ja va 2s. co m*/ PageParameters params = new PageParameters(); params.add("uri", p.getURI()); BookmarkablePageLink<WebPage> link = new BookmarkablePageLink<WebPage>("doilink", PaperPage.class, params); add(link); Label nameLabel = new Label("doi", p.getDoiString()); nameLabel.setVisible(guiItemStyle != ThingElement.TINY_GUI_ITEM); link.add(nameLabel); }
From source file:ch.tkuhn.nanobrowser.SentenceItem.java
License:Open Source License
public SentenceItem(String id, SentenceElement s, int guiItemStyle) { super(id);/*from w w w . j av a 2s.co m*/ PageParameters params = new PageParameters(); params.add("uri", s.getURI()); BookmarkablePageLink<WebPage> link = new BookmarkablePageLink<WebPage>("sentencelink", SentencePage.class, params); add(link); Label nameLabel = new Label("sentence", s.getSentenceText()); nameLabel.setVisible(guiItemStyle != ThingElement.TINY_GUI_ITEM); link.add(nameLabel); }