List of usage examples for org.apache.wicket MarkupContainer setVisible
public final Component setVisible(final boolean visible)
From source file:com.asptt.plongee.resa.wicket.page.admin.palanque.PalanqueForm.java
@SuppressWarnings("serial") public PalanqueForm(String id, NavigationOriginePage originePage, final Palanque palanqueUpdate, Date dateMin, Date dateMax, final FeedbackPanel feedback) { super(id);//from ww w.j a va2 s. co m feedback.setOutputMarkupId(true); dateMini = dateMin; dateMaxi = dateMax; origPage = originePage; //Rcupration de la fiche de securite dans la session fs = ResaSession.get().getFicheSecurite(); //init de la palanque if (null == palanqueUpdate) { this.palanque = new Palanque(); this.palanque.setDatePlongee(fs.getDatePlongee()); this.palanque.setNumero(fs.getNbPalanques() + 1); } else { this.palanque = palanqueUpdate; //methode pour initialiser les ChoiceRenderPlongeur de la palanque initPalanque(palanqueUpdate); } //initialisation des plongeurs inscrire pour ne pas allez la chercher chaque fois // listPlongeursAInscrireForpalanque = ResaSession.get().getPlongeeService().initListPlongeursAInscrire(fs); listPlongeursAInscrireForpalanque = ResaSession.get().getListPlongeursAInscrire(); //sauvegarde de la palanque en cas d'annulation de modification //TODO - se servir de l'implementation de la methode clone final Palanque palanqueSAV = new Palanque(palanque); //sauvegarde des plongeursAInscrire en cas d'annulation de modification final List<ChoiceRenderPlongeur> plongeursAInscrireSAV = new ArrayList<ChoiceRenderPlongeur>(); if (null != ResaSession.get().getListPlongeursAInscrire()) { plongeursAInscrireSAV.addAll(ResaSession.get().getListPlongeursAInscrire()); } final CompoundPropertyModel<Palanque> modelPalanque = new CompoundPropertyModel<Palanque>(palanque); setModel(modelPalanque); add(new Label("messageNumPalanque", new StringResourceModel( CatalogueMessages.SAISIE_PALANQUE_MSG_NUM_PALANQUE, this, new Model<Palanque>(palanque)))); // Ajout de la checkbox Bapteme AjaxCheckBox checkBox = new AjaxCheckBox("bapteme", new PropertyModel(modelPalanque, "isBapteme")) { @Override protected void onUpdate(AjaxRequestTarget target) { // getIsBapteme = this.getModelObject(); // logger.info("value of getIsBapteme = "+this.getModelObject().toString()); // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }; add(checkBox); //----------------------Le Choix des plongeurs ------------------------ final IModel<ChoiceRenderPlongeur> ddcModel = new PropertyModel<ChoiceRenderPlongeur>(this, "selectedPlongeur"); final DropDownChoice ddc = new DropDownChoice<ChoiceRenderPlongeur>("listPlongeurs", // new PropertyModel(this, "selectedPlongeur"), ddcModel, listPlongeursAInscrireForpalanque, new PlongeurChoiceRenderer("value", "key")) { @Override protected boolean wantOnSelectionChangedNotifications() { return true; } @Override protected void onSelectionChanged(ChoiceRenderPlongeur newSelection) { setSelectedPlongeur(ddcModel.getObject()); } }; ddc.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); ddc.setOutputMarkupId(true); add(ddc); //--------------GUIGE----------------------- final Label labelGuide = new Label("nomGuide", new PropertyModel(modelPalanque, "nomCompletGuide")); labelGuide.setOutputMarkupId(true); add(labelGuide); add(new IndicatingAjaxLink("valideGuide") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedback); if (getGuide() != null) { //on a dja un guide de saisi, donc erreur et on fait rien error("Le guide dj t saisi : " + getGuide().getValue() + " Impossible d'en saisir un autre"); } else if (null == getSelectedPlongeur()) { error("Vous devez d'abord slectionner un plongeur"); } else { setGuide(getSelectedPlongeur()); suppEntreeListPlongeursAInscrire(getGuide()); setSelectedPlongeur(null); target.addComponent(labelGuide); target.addComponent(ddc); } } }); final MarkupContainer containAptGuide = new WebMarkupContainer("containGuide"); Label labelAptGuide = new Label("labelAptGuide", Model.of(new String("aptitude"))); labelAptGuide.setOutputMarkupId(true); containAptGuide.add(labelAptGuide); TextField<String> valueAptPlongeur = new TextField<String>("aptitudePlongeur"); valueAptPlongeur.setOutputMarkupId(true); containAptGuide.add(valueAptPlongeur); containAptGuide.add(new AjaxButton("validAptGuide") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { Palanque pp = (Palanque) form.getModelObject(); if (null != pp.getAptitudePlongeur()) { ChoiceRenderPlongeur oldGuide = getSelectedPlongeur(); Adherent adh = ResaSession.get().getAdherentService() .rechercherAdherentParIdentifiantTous(getGuide().getKey()); String key = adh.getNumeroLicense(); String value = adh.getNom() + " " + adh.getPrenom() + " " + pp.getAptitudePlongeur(); ChoiceRenderPlongeur newGuide = new ChoiceRenderPlongeur(key, value); //on met le plongeur modifi comme guide setGuide(newGuide); //On supprime "ancien" et "nouveau" plongeur des plongeurs inscrire listPlongeursAInscrireForpalanque.remove(oldGuide); listPlongeursAInscrireForpalanque.remove(newGuide); //On redonne le choix dans la selection du plongeur setSelectedPlongeur(null); // on remet aptitudePlongeur null pour la prochaine fois pp.setAptitudePlongeur(null); } containAptGuide.setVisible(!containAptGuide.isVisible()); target.addComponent(labelGuide); target.addComponent(containAptGuide); target.addComponent(ddc); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.addComponent(feedback); } }); containAptGuide.setVisible(false); containAptGuide.setOutputMarkupId(true); containAptGuide.setOutputMarkupPlaceholderTag(true); add(containAptGuide); add(new IndicatingAjaxLink("modifierGuide") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedback); if (getGuide() == null) { error("Le guide n'est pas saisi "); } else { containAptGuide.setVisible(!containAptGuide.isVisible()); target.addComponent(labelGuide); target.addComponent(containAptGuide); target.addComponent(ddc); } } }); add(new IndicatingAjaxLink("annulerGuide") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedback); if (getGuide() == null) { error("Le guide n'est pas saisi "); } else { addEntreeListPlongeursAInscrire(getGuide()); setGuide(null); setSelectedPlongeur(null); target.addComponent(labelGuide); target.addComponent(ddc); } } }); //--------------PLONGEUR1----------------------- final Label labelPlongeur1 = new Label("nomPlongeur1", new PropertyModel(modelPalanque, "nomCompletPlongeur1")); labelPlongeur1.setOutputMarkupId(true); add(labelPlongeur1); add(new IndicatingAjaxLink("validePlongeur1") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedback); if (getPlongeur1() != null) { //on a dja un Plongeur1 de saisi, donc erreur et on fait rien error("Le Plongeur1 dj t saisi : " + getPlongeur1().getValue() + " Impossible d'en saisir un autre"); } else if (null == getSelectedPlongeur()) { error("Vous devez d'abord slectionner un plongeur"); } else { setPlongeur1(getSelectedPlongeur()); suppEntreeListPlongeursAInscrire(getPlongeur1()); setSelectedPlongeur(null); target.addComponent(labelPlongeur1); target.addComponent(ddc); } } }); final MarkupContainer containAptPlongeur1 = new WebMarkupContainer("containPlongeur1"); Label labelAptPlongeur1 = new Label("labelAptPlongeur1", Model.of(new String("aptitude"))); labelAptPlongeur1.setOutputMarkupId(true); containAptPlongeur1.add(labelAptPlongeur1); TextField<String> valueAptPlongeur1 = new TextField<String>("aptitudePlongeur"); valueAptPlongeur1.setOutputMarkupId(true); containAptPlongeur1.add(valueAptPlongeur1); containAptPlongeur1.add(new AjaxButton("validAptPlongeur1") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { Palanque pp = (Palanque) form.getModelObject(); if (null != pp.getAptitudePlongeur()) { ChoiceRenderPlongeur oldPlongeur1 = getSelectedPlongeur(); Adherent adh = ResaSession.get().getAdherentService() .rechercherAdherentParIdentifiantTous(getPlongeur1().getKey()); String key = adh.getNumeroLicense(); String value = adh.getNom() + " " + adh.getPrenom() + " " + pp.getAptitudePlongeur(); ChoiceRenderPlongeur newPlongeur1 = new ChoiceRenderPlongeur(key, value); //on met le plongeur modifi setPlongeur1(newPlongeur1); //On supprime "ancien" et "nouveau" plongeur des plongeurs inscrire listPlongeursAInscrireForpalanque.remove(oldPlongeur1); listPlongeursAInscrireForpalanque.remove(newPlongeur1); //On redonne le choix dans la selection du plongeur setSelectedPlongeur(null); // on remet aptitudePlongeur null pour la prochaine fois pp.setAptitudePlongeur(null); } containAptPlongeur1.setVisible(!containAptPlongeur1.isVisible()); target.addComponent(labelPlongeur1); target.addComponent(containAptPlongeur1); target.addComponent(ddc); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.addComponent(feedback); } }); containAptPlongeur1.setVisible(false); containAptPlongeur1.setOutputMarkupId(true); containAptPlongeur1.setOutputMarkupPlaceholderTag(true); add(containAptPlongeur1); add(new IndicatingAjaxLink("modifierPlongeur1") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedback); if (getPlongeur1() == null) { error("Le plongeur1 n'est pas saisi "); } else { containAptPlongeur1.setVisible(!containAptPlongeur1.isVisible()); target.addComponent(labelPlongeur1); target.addComponent(containAptPlongeur1); target.addComponent(ddc); } } }); add(new IndicatingAjaxLink("annulerPlongeur1") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedback); if (getPlongeur1() == null) { error("Le Plongeur1 n'est pas saisi "); } else { addEntreeListPlongeursAInscrire(getPlongeur1()); setPlongeur1(null); setSelectedPlongeur(null); target.addComponent(labelPlongeur1); target.addComponent(ddc); } } }); //--------------PLONGEUR2----------------------- final Label labelPlongeur2 = new Label("nomPlongeur2", new PropertyModel(modelPalanque, "nomCompletPlongeur2")); labelPlongeur2.setOutputMarkupId(true); add(labelPlongeur2); add(new IndicatingAjaxLink("validePlongeur2") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedback); if (getPlongeur2() != null) { //on a dja un Plongeur2 de saisi, donc erreur et on fait rien error("Le Plongeur2 dj t saisi : " + getPlongeur2().getValue() + " Impossible d'en saisir un autre"); } else if (null == getSelectedPlongeur()) { error("Vous devez d'abord slectionner un plongeur"); } else { setPlongeur2(getSelectedPlongeur()); suppEntreeListPlongeursAInscrire(getPlongeur2()); setSelectedPlongeur(null); target.addComponent(labelPlongeur2); target.addComponent(ddc); } } }); final MarkupContainer containAptPlongeur2 = new WebMarkupContainer("containPlongeur2"); Label labelAptPlongeur2 = new Label("labelAptPlongeur2", Model.of(new String("aptitude"))); labelAptPlongeur2.setOutputMarkupId(true); containAptPlongeur2.add(labelAptPlongeur2); TextField<String> valueAptPlongeur2 = new TextField<String>("aptitudePlongeur"); valueAptPlongeur2.setOutputMarkupId(true); containAptPlongeur2.add(valueAptPlongeur2); containAptPlongeur2.add(new AjaxButton("validAptPlongeur2") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { Palanque pp = (Palanque) form.getModelObject(); if (null != pp.getAptitudePlongeur()) { ChoiceRenderPlongeur oldPlongeur2 = getSelectedPlongeur(); Adherent adh = ResaSession.get().getAdherentService() .rechercherAdherentParIdentifiantTous(getPlongeur2().getKey()); String key = adh.getNumeroLicense(); String value = adh.getNom() + " " + adh.getPrenom() + " " + pp.getAptitudePlongeur(); ChoiceRenderPlongeur newPlongeur2 = new ChoiceRenderPlongeur(key, value); //on met le plongeur modifi setPlongeur2(newPlongeur2); //On supprime "ancien" et "nouveau" plongeur des plongeurs inscrire listPlongeursAInscrireForpalanque.remove(oldPlongeur2); listPlongeursAInscrireForpalanque.remove(newPlongeur2); //On redonne le choix dans la selection du plongeur setSelectedPlongeur(null); // on remet aptitudePlongeur null pour la prochaine fois pp.setAptitudePlongeur(null); } containAptPlongeur2.setVisible(!containAptPlongeur2.isVisible()); target.addComponent(labelPlongeur2); target.addComponent(containAptPlongeur2); target.addComponent(ddc); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.addComponent(feedback); } }); containAptPlongeur2.setVisible(false); containAptPlongeur2.setOutputMarkupId(true); containAptPlongeur2.setOutputMarkupPlaceholderTag(true); add(containAptPlongeur2); add(new IndicatingAjaxLink("modifierPlongeur2") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedback); if (getPlongeur2() == null) { error("Le plongeur2 n'est pas saisi "); } else { containAptPlongeur2.setVisible(!containAptPlongeur2.isVisible()); target.addComponent(labelPlongeur2); target.addComponent(containAptPlongeur2); target.addComponent(ddc); } } }); add(new IndicatingAjaxLink("annulerPlongeur2") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedback); if (getPlongeur2() == null) { error("Le Plongeur2 n'est pas saisi "); } else { addEntreeListPlongeursAInscrire(getPlongeur2()); setPlongeur2(null); setSelectedPlongeur(null); target.addComponent(labelPlongeur2); target.addComponent(ddc); } } }); //--------------PLONGEUR3----------------------- final Label labelPlongeur3 = new Label("nomPlongeur3", new PropertyModel(modelPalanque, "nomCompletPlongeur3")); labelPlongeur3.setOutputMarkupId(true); add(labelPlongeur3); add(new IndicatingAjaxLink("validePlongeur3") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedback); if (getPlongeur3() != null) { //on a dja un Plongeur3 de saisi, donc erreur et on fait rien error("Le Plongeur3 dj t saisi : " + getPlongeur3().getValue() + " Impossible d'en saisir un autre"); } else if (null == getSelectedPlongeur()) { error("Vous devez d'abord slectionner un plongeur"); } else { setPlongeur3(getSelectedPlongeur()); suppEntreeListPlongeursAInscrire(getPlongeur3()); setSelectedPlongeur(null); target.addComponent(labelPlongeur3); target.addComponent(ddc); } } }); final MarkupContainer containAptPlongeur3 = new WebMarkupContainer("containPlongeur3"); Label labelAptPlongeur3 = new Label("labelAptPlongeur3", Model.of(new String("aptitude"))); labelAptPlongeur3.setOutputMarkupId(true); containAptPlongeur3.add(labelAptPlongeur3); TextField<String> valueAptPlongeur3 = new TextField<String>("aptitudePlongeur"); valueAptPlongeur3.setOutputMarkupId(true); containAptPlongeur3.add(valueAptPlongeur3); containAptPlongeur3.add(new AjaxButton("validAptPlongeur3") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { Palanque pp = (Palanque) form.getModelObject(); if (null != pp.getAptitudePlongeur()) { ChoiceRenderPlongeur oldPlongeur3 = getSelectedPlongeur(); Adherent adh = ResaSession.get().getAdherentService() .rechercherAdherentParIdentifiantTous(getPlongeur3().getKey()); String key = adh.getNumeroLicense(); String value = adh.getNom() + " " + adh.getPrenom() + " " + pp.getAptitudePlongeur(); ChoiceRenderPlongeur newPlongeur3 = new ChoiceRenderPlongeur(key, value); //on met le plongeur modifi setPlongeur3(newPlongeur3); //On supprime "ancien" et "nouveau" plongeur des plongeurs inscrire listPlongeursAInscrireForpalanque.remove(oldPlongeur3); listPlongeursAInscrireForpalanque.remove(newPlongeur3); //On redonne le choix dans la selection du plongeur setSelectedPlongeur(null); // on remet aptitudePlongeur null pour la prochaine fois pp.setAptitudePlongeur(null); } containAptPlongeur3.setVisible(!containAptPlongeur3.isVisible()); target.addComponent(labelPlongeur3); target.addComponent(containAptPlongeur3); target.addComponent(ddc); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.addComponent(feedback); } }); containAptPlongeur3.setVisible(false); containAptPlongeur3.setOutputMarkupId(true); containAptPlongeur3.setOutputMarkupPlaceholderTag(true); add(containAptPlongeur3); add(new IndicatingAjaxLink("modifierPlongeur3") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedback); if (getPlongeur3() == null) { error("Le plongeur3 n'est pas saisi "); } else { containAptPlongeur3.setVisible(!containAptPlongeur3.isVisible()); target.addComponent(labelPlongeur3); target.addComponent(containAptPlongeur3); target.addComponent(ddc); } } }); add(new IndicatingAjaxLink("annulerPlongeur3") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedback); if (getPlongeur3() == null) { error("Le Plongeur3 n'est pas saisi "); } else { addEntreeListPlongeursAInscrire(getPlongeur3()); setPlongeur3(null); setSelectedPlongeur(null); target.addComponent(labelPlongeur3); target.addComponent(ddc); } } }); //--------------PLONGEUR4----------------------- final Label labelPlongeur4 = new Label("nomPlongeur4", new PropertyModel(modelPalanque, "nomCompletPlongeur4")); labelPlongeur4.setOutputMarkupId(true); add(labelPlongeur4); add(new IndicatingAjaxLink("validePlongeur4") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedback); if (getPlongeur4() != null) { //on a dja un Plongeur4 de saisi, donc erreur et on fait rien error("Le Plongeur4 dj t saisi : " + getPlongeur4().getValue() + " Impossible d'en saisir un autre"); } else if (null == getSelectedPlongeur()) { error("Vous devez d'abord slectionner un plongeur"); } else { setPlongeur4(getSelectedPlongeur()); suppEntreeListPlongeursAInscrire(getPlongeur4()); setSelectedPlongeur(null); target.addComponent(labelPlongeur4); target.addComponent(ddc); } } }); final MarkupContainer containAptPlongeur4 = new WebMarkupContainer("containPlongeur4"); Label labelAptPlongeur4 = new Label("labelAptPlongeur4", Model.of(new String("aptitude"))); labelAptPlongeur4.setOutputMarkupId(true); containAptPlongeur4.add(labelAptPlongeur4); TextField<String> valueAptPlongeur4 = new TextField<String>("aptitudePlongeur"); valueAptPlongeur4.setOutputMarkupId(true); containAptPlongeur4.add(valueAptPlongeur4); containAptPlongeur4.add(new AjaxButton("validAptPlongeur4") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { Palanque pp = (Palanque) form.getModelObject(); if (null != pp.getAptitudePlongeur()) { ChoiceRenderPlongeur oldPlongeur4 = getSelectedPlongeur(); Adherent adh = ResaSession.get().getAdherentService() .rechercherAdherentParIdentifiantTous(getPlongeur4().getKey()); String key = adh.getNumeroLicense(); String value = adh.getNom() + " " + adh.getPrenom() + " " + pp.getAptitudePlongeur(); ChoiceRenderPlongeur newPlongeur4 = new ChoiceRenderPlongeur(key, value); //on met le plongeur modifi comme guide setPlongeur4(newPlongeur4); //On supprime "ancien" et "nouveau" plongeur des plongeurs inscrire listPlongeursAInscrireForpalanque.remove(oldPlongeur4); listPlongeursAInscrireForpalanque.remove(newPlongeur4); //On redonne le choix dans la selection du plongeur setSelectedPlongeur(null); // on remet aptitudePlongeur null pour la prochaine fois pp.setAptitudePlongeur(null); } containAptPlongeur4.setVisible(!containAptPlongeur4.isVisible()); target.addComponent(labelPlongeur4); target.addComponent(containAptPlongeur4); target.addComponent(ddc); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.addComponent(feedback); } }); containAptPlongeur4.setVisible(false); containAptPlongeur4.setOutputMarkupId(true); containAptPlongeur4.setOutputMarkupPlaceholderTag(true); add(containAptPlongeur4); add(new IndicatingAjaxLink("modifierPlongeur4") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedback); if (getPlongeur4() == null) { error("Le plongeur4 n'est pas saisi "); } else { containAptPlongeur4.setVisible(!containAptPlongeur4.isVisible()); target.addComponent(labelPlongeur4); target.addComponent(containAptPlongeur4); target.addComponent(ddc); } } }); add(new IndicatingAjaxLink("annulerPlongeur4") { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(feedback); if (getPlongeur4() == null) { error("Le Plongeur4 n'est pas saisi "); } else { addEntreeListPlongeursAInscrire(getPlongeur4()); setPlongeur4(null); setSelectedPlongeur(null); target.addComponent(labelPlongeur4); target.addComponent(ddc); } } }); //-----------------Profondeur Maxi-------------------------- TextField pMaxPrevu = new TextField<Integer>("profondeurMaxPrevue", Integer.class); pMaxPrevu.add(new MaximumValidator<Integer>(60)); pMaxPrevu.add(new MinimumValidator<Integer>(0)); add(pMaxPrevu); TextField pMaxRea = new TextField<Integer>("profondeurMaxRea", Integer.class); pMaxRea.add(new MaximumValidator<Integer>(60)); pMaxRea.add(new MinimumValidator<Integer>(0)); add(pMaxRea); //-----------------Dure de la plonge-------------------------- TextField dureePrevu = new TextField<Integer>("dureeTotalePrevue", Integer.class); add(dureePrevu); TextField dureeRea = new TextField<Integer>("dureeTotaleRea", Integer.class); add(dureeRea); //-----------------Paliers-------------------------- TextField palier3 = new TextField<Integer>("palier3m", Integer.class); palier3.add(new MinimumValidator<Integer>(0)); add(palier3); TextField palier6 = new TextField<Integer>("palier6m", Integer.class); palier6.add(new MinimumValidator<Integer>(0)); add(palier6); TextField palier9 = new TextField<Integer>("palier9m", Integer.class); palier9.add(new MinimumValidator<Integer>(0)); add(palier9); TextField palierP = new TextField<Integer>("palierProfond", Integer.class); palierP.add(new MinimumValidator<Integer>(0)); add(palierP); //-----------------Heure de sortie TextField heureSortie = new TextField<Integer>("hhSortie", Integer.class); heureSortie.add(new MaximumValidator<Integer>(24)); heureSortie.add(new MinimumValidator<Integer>(0)); add(heureSortie); TextField minuteSortie = new TextField<Integer>("mnSortie", Integer.class); minuteSortie.add(new MaximumValidator<Integer>(60)); minuteSortie.add(new MinimumValidator<Integer>(0)); add(minuteSortie); //------------------- Validation de la palanquee AjaxButton b_validerPalanque = new AjaxButton("validerPalanque") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { Palanque palanqueForm = (Palanque) form.getModelObject(); boolean formatAptitude = true; if (palanqueForm.getListPlongeursPalanque().size() > 0) { for (ChoiceRenderPlongeur crp : palanqueForm.getListPlongeursPalanque()) { if (crp.getValue().contains("/")) { formatAptitude = false; } else { error("Vrifier les aptitudes des plongeurs"); } } } if (formatAptitude) { if (palanqueForm.getListPlongeursPalanque().size() > 0) { //init de l'heure de sortie avec les champs palanqueForm.setHeureSortie(palanqueForm.getHhSortie(), palanqueForm.getMnSortie()); //suppression des plongeurs de la palanque dans les plongeurs inscrire suppPlongeursAInscrire(palanqueForm.getListPlongeursPalanque()); fs.getPalanques().remove(palanque); fs.getPalanques().add(palanqueForm); if (palanqueForm.getIsBapteme()) { // c'est un Bapteme on remet le guide dans la liste des plongeurs inscrire // pour pouvoir le re-inscrire sur une autre palanque if (!listPlongeursAInscrireForpalanque.contains(getGuide())) { listPlongeursAInscrireForpalanque.add(getGuide()); } } //mise jour des plongeurs inscrire en session ResaSession.get().setListPlongeursAInscrire(listPlongeursAInscrireForpalanque); //Retour sur la feuille de saisie pour d'autres palanques eventuelles setResponsePage(new SaisieFicheSecurite(origPage, dateMini, dateMaxi)); } else { error("Cette palanque ne contient aucun plongeur !"); } } } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.addComponent(feedback); } }; b_validerPalanque.setOutputMarkupId(true); add(b_validerPalanque); // bouton retour saisie Fiche de securite en reprennant les sauvegardes add(new Link("cancel") { @Override public void onClick() { for (Palanque ps : fs.getPalanques()) { if (ps.getNumero() == palanqueSAV.getNumero()) { fs.getPalanques().set(fs.getPalanques().indexOf(ps), palanqueSAV); break; } } ResaSession.get().setListPlongeursAInscrire(plongeursAInscrireSAV); setResponsePage(new SaisieFicheSecurite(origPage, dateMini, dateMaxi)); } }); }
From source file:com.gitblit.wicket.panels.LogPanel.java
License:Apache License
public LogPanel(String wicketId, final String repositoryName, final String objectId, Repository r, int limit, int pageOffset, boolean showRemoteRefs) { super(wicketId); boolean pageResults = limit <= 0; int itemsPerPage = app().settings().getInteger(Keys.web.itemsPerPage, 50); if (itemsPerPage <= 1) { itemsPerPage = 50;/*ww w . j a v a2s.c om*/ } final Map<ObjectId, List<RefModel>> allRefs = JGitUtils.getAllRefs(r, showRemoteRefs); List<RevCommit> commits; if (pageResults) { // Paging result set commits = JGitUtils.getRevLog(r, objectId, pageOffset * itemsPerPage, itemsPerPage); } else { // Fixed size result set commits = JGitUtils.getRevLog(r, objectId, 0, limit); } // inaccurate way to determine if there are more commits. // works unless commits.size() represents the exact end. hasMore = commits.size() >= itemsPerPage; final String baseUrl = WicketUtils.getGitblitURL(getRequest()); final boolean showGraph = app().settings().getBoolean(Keys.web.showBranchGraph, true); MarkupContainer graph = new WebMarkupContainer("graph"); add(graph); if (!showGraph || commits.isEmpty()) { // not showing or nothing to show graph.setVisible(false); } else { // set the rowspan on the graph row and +1 for the graph row itself graph.add(new AttributeModifier("rowspan", "" + (commits.size() + 1))); graph.add(new ExternalImage("image", BranchGraphServlet.asLink(baseUrl, repositoryName, commits.get(0).name(), commits.size()))); } // header if (pageResults) { // shortlog page add(new Label("header", objectId)); } else { // summary page // show shortlog page link add(new LinkPanel("header", "title", objectId, LogPage.class, WicketUtils.newRepositoryParameter(repositoryName))); } final int hashLen = app().settings().getInteger(Keys.web.shortCommitIdLength, 6); ListDataProvider<RevCommit> dp = new ListDataProvider<RevCommit>(commits); DataView<RevCommit> logView = new DataView<RevCommit>("commit", dp) { private static final long serialVersionUID = 1L; int counter; @Override public void populateItem(final Item<RevCommit> item) { final RevCommit entry = item.getModelObject(); final Date date = JGitUtils.getAuthorDate(entry); final boolean isMerge = entry.getParentCount() > 1; item.add(WicketUtils.createDateLabel("commitDate", date, getTimeZone(), getTimeUtils())); // author search link String author = entry.getAuthorIdent().getName(); LinkPanel authorLink = new LinkPanel("commitAuthor", "list", author, GitSearchPage.class, WicketUtils.newSearchParameter(repositoryName, null, author, Constants.SearchType.AUTHOR)); setPersonSearchTooltip(authorLink, author, Constants.SearchType.AUTHOR); item.add(authorLink); // merge icon if (isMerge) { item.add(WicketUtils.newImage("commitIcon", "commit_merge_16x16.png")); } else { item.add(WicketUtils.newBlankImage("commitIcon")); } // short message String shortMessage = entry.getShortMessage(); String trimmedMessage = shortMessage; if (allRefs.containsKey(entry.getId())) { trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG_REFS); } else { trimmedMessage = StringUtils.trimString(shortMessage, Constants.LEN_SHORTLOG); } LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject" + (isMerge ? " merge" : ""), trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())); if (!shortMessage.equals(trimmedMessage)) { WicketUtils.setHtmlTooltip(shortlog, shortMessage); } item.add(shortlog); item.add(new RefsPanel("commitRefs", repositoryName, entry, allRefs)); // commit hash link LinkPanel commitHash = new LinkPanel("hashLink", null, entry.getName().substring(0, hashLen), CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())); WicketUtils.setCssClass(commitHash, "shortsha1"); WicketUtils.setHtmlTooltip(commitHash, entry.getName()); item.add(commitHash); item.add(new BookmarkablePageLink<Void>("diff", CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())) .setEnabled(entry.getParentCount() > 0)); item.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()))); String clazz = counter % 2 == 0 ? "light commit" : "dark commit"; WicketUtils.setCssClass(item, clazz); counter++; } }; add(logView); // determine to show pager, more, or neither if (limit <= 0) { // no display limit add(new Label("moreLogs", "").setVisible(false)); } else { if (pageResults) { // paging add(new Label("moreLogs", "").setVisible(false)); } else { // more if (commits.size() == limit) { // show more add(new LinkPanel("moreLogs", "link", new StringResourceModel("gb.moreLogs", this, null), LogPage.class, WicketUtils.newRepositoryParameter(repositoryName))); } else { // no more add(new Label("moreLogs", "").setVisible(false)); } } } }
From source file:gr.abiss.calipso.wicket.DashboardRowPanel.java
License:Open Source License
public DashboardRowPanel(String id, IBreadCrumbModel breadCrumbModel, final UserSpaceRole userSpaceRole, final Counts counts, final boolean useCurrentSpace) { super(id, breadCrumbModel); setOutputMarkupId(true);/*from w w w . ja va2 s . c o m*/ CalipsoService calipso = getCalipso(); // needed for links like (space, assets) // TODO: holds last space final Space space = userSpaceRole.getSpaceRole().getSpace(); final User user = userSpaceRole.getUser(); //setCurrentSpace(space); boolean canViewItems = UserUtils.canViewItems(user, space); // no need to set manually the space, because it has reference MarkupContainer spaceLink = canViewItems ? new BreadCrumbLink("spaceName", getBreadCrumbModel()) { private static final long serialVersionUID = 1L; @Override protected IBreadCrumbParticipant getParticipant(String componentId) { return new SingleSpacePanel(componentId, getBreadCrumbModel(), new ItemSearch(space, getPrincipal(), this, DashboardRowPanel.this.getCalipso())); } } : (MarkupContainer) new WebMarkupContainer("spaceName").setRenderBodyOnly(true); Label spaceNameLabel = new Label("spaceNameLabel", localize(space.getNameTranslationResourceKey()));//space name if (space.getDescription() != null) { spaceNameLabel.add(new SimpleAttributeModifier("title", space.getDescription()));//space description } spaceLink.add(spaceNameLabel); //if in single space, don't render name if (useCurrentSpace) { spaceLink.setVisible(false); } add(spaceLink); if (userSpaceRole.isAbleToCreateNewItem()) { add(new BreadCrumbLink("new", getBreadCrumbModel()) { private static final long serialVersionUID = 1L; protected IBreadCrumbParticipant getParticipant(String componentId) { // need to added manually because the item doesn't have space reference setCurrentSpace(space); return new ItemFormPanel(componentId, getBreadCrumbModel()); } }); } else { add(new Label("new").setVisible(false)); } //TODO: For future use add(new Link("sla") { private static final long serialVersionUID = 1L; public void onClick() { setCurrentSpace(space); setResponsePage(SLAsPage.class); } }.setVisible(false)); if (UserUtils.canViewSpaceAssets(user, space, calipso)) { add(new BreadCrumbLink("asset", getBreadCrumbModel()) { private static final long serialVersionUID = 1L; protected IBreadCrumbParticipant getParticipant(String componentId) { // on click current space is the this panel space setCurrentSpace(space); return new AssetSpacePanel(componentId, getBreadCrumbModel()); } }.setVisible(user.isGlobalAdmin() || user.isSpaceAdmin(space))); } else { add(new Label("asset").setVisible(false)); } if (canViewItems) { add(new BreadCrumbLink("search", getBreadCrumbModel()) { private static final long serialVersionUID = 1L; protected IBreadCrumbParticipant getParticipant(String componentId) { setCurrentSpace(space); return new ItemSearchFormPanel(componentId, getBreadCrumbModel()); } }); } else { add(new Label("search").setVisible(false)); } add(new IndicatingAjaxLink("link") { public void onClick(AjaxRequestTarget target) { //mark expanded in DashboardPanel IBreadCrumbParticipant activePanel = getBreadCrumbModel().getActive(); if (activePanel instanceof DashboardPanel) { ((DashboardPanel) activePanel).markRowExpanded(userSpaceRole); } Counts tempCounts = counts; // avoid hitting the database again if re-expanding if (!tempCounts.isDetailed()) { tempCounts = getCalipso().loadCountsForUserSpace(user, space); } DashboardRowExpandedPanel dashboardRow = new DashboardRowExpandedPanel("dashboardRow", getBreadCrumbModel(), userSpaceRole, tempCounts, useCurrentSpace); dashboardRow.setOddLine(isOddLine); DashboardRowPanel.this.replaceWith(dashboardRow); target.addComponent(dashboardRow); } }.setVisible(canViewItems)); if (canViewItems) { WebMarkupContainer loggedByMeContainer; WebMarkupContainer assignedToMeContainer; WebMarkupContainer unassignedContainer; if (useCurrentSpace) {//if a space is selected loggedByMeContainer = new IndicatingAjaxLink("loggedByMe") { public void onClick(AjaxRequestTarget target) { setCurrentSpace(space); ItemSearch itemSearch = new ItemSearch(space, getPrincipal(), this, DashboardRowPanel.this.getCalipso()); itemSearch.setLoggedBy(user); setCurrentItemSearch(itemSearch); SingleSpacePanel singleSpacePanel = (SingleSpacePanel) getBreadCrumbModel().getActive(); singleSpacePanel.refreshItemListPanel(target); } }; assignedToMeContainer = new IndicatingAjaxLink("assignedToMe") { public void onClick(AjaxRequestTarget target) { ItemSearch itemSearch = new ItemSearch(space, getPrincipal(), this, DashboardRowPanel.this.getCalipso()); itemSearch.setAssignedTo(user); setCurrentItemSearch(itemSearch); SingleSpacePanel singleSpacePanel = (SingleSpacePanel) getBreadCrumbModel().getActive(); singleSpacePanel.refreshItemListPanel(target); } }; unassignedContainer = new IndicatingAjaxLink("unassigned") { public void onClick(AjaxRequestTarget target) { ItemSearch itemSearch = new ItemSearch(space, getPrincipal(), this, DashboardRowPanel.this.getCalipso()); itemSearch.setUnassigned(); setCurrentItemSearch(itemSearch); SingleSpacePanel singleSpacePanel = (SingleSpacePanel) getBreadCrumbModel().getActive(); singleSpacePanel.refreshItemListPanel(target); } }; } else {//if no space is selected. i.e. for dashboard loggedByMeContainer = new BreadCrumbLink("loggedByMe", getBreadCrumbModel()) { private static final long serialVersionUID = 1L; protected IBreadCrumbParticipant getParticipant(String componentId) { ItemSearch itemSearch = new ItemSearch(space, getPrincipal(), this, DashboardRowPanel.this.getCalipso()); itemSearch.setLoggedBy(user); setCurrentItemSearch(itemSearch); return new SingleSpacePanel(componentId, getBreadCrumbModel(), itemSearch); //return new ItemListPanel(componentId, getBreadCrumbModel()); } }; assignedToMeContainer = new BreadCrumbLink("assignedToMe", getBreadCrumbModel()) { private static final long serialVersionUID = 1L; protected IBreadCrumbParticipant getParticipant(String componentId) { ItemSearch itemSearch = new ItemSearch(space, getPrincipal(), this, DashboardRowPanel.this.getCalipso()); itemSearch.setAssignedTo(user); setCurrentItemSearch(itemSearch); return new SingleSpacePanel(componentId, getBreadCrumbModel(), itemSearch); //return new ItemListPanel(componentId, getBreadCrumbModel()); } }; unassignedContainer = new BreadCrumbLink("unassigned", getBreadCrumbModel()) { private static final long serialVersionUID = 1L; protected IBreadCrumbParticipant getParticipant(String componentId) { ItemSearch itemSearch = new ItemSearch(space, getPrincipal(), this, DashboardRowPanel.this.getCalipso()); itemSearch.setUnassigned(); setCurrentItemSearch(itemSearch); return new SingleSpacePanel(componentId, getBreadCrumbModel(), itemSearch); } }; } //get Total Long total = new Long(counts.getTotal()); //add the numbers loggedByMeContainer .add(new DashboardNumbers("loggedByMeNumbers", new Long(counts.getLoggedByMe()), total)); assignedToMeContainer .add(new DashboardNumbers("assignedToMeNumbers", new Long(counts.getAssignedToMe()), total)); unassignedContainer .add(new DashboardNumbers("unassignedNumbers", new Long(counts.getUnassigned()), total)); //add the containers add(loggedByMeContainer); add(assignedToMeContainer); add(unassignedContainer); } else { add(new WebMarkupContainer("loggedByMe").setVisible(false)); add(new WebMarkupContainer("assignedToMe").setVisible(false)); add(new WebMarkupContainer("unassigned").setVisible(false)); } WebMarkupContainer totalContainer; if (useCurrentSpace) {//if a space is selected totalContainer = new IndicatingAjaxLink("total") { public void onClick(AjaxRequestTarget target) { ItemSearch itemSearch = new ItemSearch(space, getPrincipal(), this, DashboardRowPanel.this.getCalipso()); setCurrentItemSearch(itemSearch); SingleSpacePanel singleSpacePanel = (SingleSpacePanel) getBreadCrumbModel().getActive(); singleSpacePanel.refreshItemListPanel(target); } }; } else {//if no space is selected. i.e. for dashboard totalContainer = new BreadCrumbLink("total", getBreadCrumbModel()) { private static final long serialVersionUID = 1L; protected IBreadCrumbParticipant getParticipant(String componentId) { ItemSearch itemSearch = new ItemSearch(space, getPrincipal(), this, DashboardRowPanel.this.getCalipso()); setCurrentItemSearch(itemSearch); return new SingleSpacePanel(componentId, getBreadCrumbModel(), itemSearch); //return new ItemListPanel(componentId, getBreadCrumbModel()); } }; } totalContainer.add(new Label("total", new PropertyModel(counts, "total"))); add(totalContainer.setRenderBodyOnly(user.isAnonymous())); }
From source file:hsa.awp.usergui.NavigationLoginPanel.java
License:Open Source License
public NavigationLoginPanel(String id) { super(id);/*from w ww .j av a 2s . c o m*/ SingleUser singleUser = SingleUser.getInstance(); singleUser.setName(""); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (auth != null) { singleUser = controller.getUserById(auth.getName()); } Form<Object> loginForm = new Form<Object>("loginForm"); add(loginForm); MarkupContainer loggedInContainer = new WebMarkupContainer("loggedIn"); loggedInContainer.add(new Label("loginName", singleUser.getName())); add(loggedInContainer); if (auth == null) { loggedInContainer.setVisible(false); loginForm.setVisible(true); } else { loggedInContainer.setVisible(true); loginForm.setVisible(false); } }
From source file:nl.mpi.lamus.web.pages.SelectWorkspacePage.java
License:Open Source License
/** * Create Form that will show a list of Workspaces to be opened by a * specific user/*from ww w .j ava 2 s.c om*/ * * @param id * @return created form */ private Form createNodeIdForm(String id) { boolean showPanel = true; Workspace defaultSelectedWs = null; List<Workspace> myWSList = new ArrayList<>(workspaceService.listUserWorkspaces(currentUserId)); if (!myWSList.isEmpty()) { defaultSelectedWs = myWSList.iterator().next(); } else { showPanel = false; } IModel<Workspace> workspaceModel; if (!showPanel) { workspaceModel = null; } else { workspaceModel = workspaceModelProvider.getWorkspaceModel(defaultSelectedWs.getWorkspaceID()); } ListChoice<Workspace> listWorkspaces = new ListChoice<>("workspaceSelection", workspaceModel, myWSList, new ChoiceRenderer<Workspace>("workspaceSelectionDisplayString")); listWorkspaces.setMaxRows(5); listWorkspaces.setNullValid(false); listWorkspaces.setRequired(true); final Form<Workspace> openWsForm = new Form<>(id, workspaceModel); Button submitButton = new AjaxButton("openWorkspace") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { target.add(getFeedbackPanel()); try { if (form.getModelObject() != null) { Workspace openSelectedWorkspace = workspaceService.openWorkspace(currentUserId, ((Workspace) form.getModelObject()).getWorkspaceID()); setResponsePage(pagesProvider.getWorkspacePage(openSelectedWorkspace)); } } catch (WorkspaceNotFoundException | WorkspaceAccessException | IOException ex) { Session.get().error(ex.getMessage()); } } }; openWsForm.add(submitButton); openWsForm.add(listWorkspaces); // Put details/submit form in container for refresh through AJAX final MarkupContainer formContainer = new WebMarkupContainer("formContainer"); formContainer.add(openWsForm); if (!showPanel) { formContainer.setVisible(false); Session.get().info(getLocalizer().getString("select_workspace_no_open_workspaces", this)); } // Add container to page add(formContainer); return openWsForm; }
From source file:org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.IsisBlobOrClobPanelAbstract.java
License:Apache License
private void updateRegularFormComponents(final InputFieldVisibility visibility) { MarkupContainer formComponent = (MarkupContainer) getComponentForRegular(); formComponent.get(ID_SCALAR_VALUE).setVisible(visibility == InputFieldVisibility.VISIBLE); fileNameLabel = updateFileNameLabel(ID_FILE_NAME, formComponent); updateClearLink(visibility);//from ww w . ja v a2 s . c o m // the visibility of download link is intentionally 'backwards'; // if in edit mode then do NOT show final MarkupContainer downloadLink = updateDownloadLink(ID_SCALAR_IF_REGULAR_DOWNLOAD, formComponent); if (downloadLink != null) { downloadLink.setVisible(visibility == InputFieldVisibility.NOT_VISIBLE); } // ditto any image if (wicketImage != null) { wicketImage.setVisible(visibility == InputFieldVisibility.NOT_VISIBLE); } }
From source file:org.artifactory.webapp.wicket.page.home.addon.AddonsInfoPanel.java
License:Open Source License
/** * Main constructor/*from ww w .java 2s . c o m*/ * * @param id ID to assign to panel * @param installedAddons Name list of installed addons * @param noEnabledAddons True if no addons are enabled */ public AddonsInfoPanel(String id, List<AddonInfo> installedAddons, boolean noEnabledAddons) { super(id); add(new CssClass("addons-table")); final boolean currentLicenseValid = addonsManager.isLicenseInstalled(); MarkupContainer addonTable = new WebMarkupContainer("addonTable"); boolean noAddons = installedAddons.isEmpty(); boolean admin = authorizationService.isAdmin(); addonTable.setVisible(!noAddons); addonTable.setOutputMarkupId(true); Component listView = new ListView<AddonInfo>("addonItem", installedAddons) { @Override protected void populateItem(ListItem<AddonInfo> item) { AddonInfo addonInfo = item.getModelObject(); item.add(new ExternalLink("name", getAddonUrl(addonInfo.getAddonName()), addonInfo.getAddonDisplayName())); item.add(new Label("image", "").add(new CssClass("addon-" + addonInfo.getAddonName()))); String stateString = getAddonStatus(addonInfo.getAddonState()); item.add(new Label("status", stateString)); if (item.getIndex() % 2 == 0) { item.add(new CssClass("even")); } } }; addonTable.add(listView); add(addonTable); add(new Label("addonsDisabled", "No addons available") .setVisible(currentLicenseValid && !noAddons && noEnabledAddons)); add(new Label("noAddons", "No add-ons currently installed.").setVisible(noAddons)); String licenseRequiredMessage = addonsWebManager .getLicenseRequiredMessage(WicketUtils.absoluteMountPathForPage(LicensePage.class)); Label noLicenseKeyLabel = new Label("noLicenseKey", licenseRequiredMessage); noLicenseKeyLabel.setVisible(admin && !currentLicenseValid && !noAddons && noEnabledAddons); noLicenseKeyLabel.setEscapeModelStrings(false); add(noLicenseKeyLabel); }
From source file:org.bosik.diacomp.web.frontend.wicket.components.menu.Menu.java
License:Open Source License
@Override protected void onInitialize() { super.onInitialize(); add(new BookmarkablePageLink<Void>("linkAbout", AboutPage.class)); RepeatingView menu = new RepeatingView("menuItem"); add(menu);//from w ww .ja va2 s .c om for (final MenuItem menuItem : getModelObject().getItems()) { BookmarkablePageLink<Void> link = new BookmarkablePageLink<Void>("Link", menuItem.getResponsePage()); link.add(new Label("Text", menuItem.getCaption())); WebMarkupContainer itemPlace = new WebMarkupContainer(menu.newChildId()); menu.add(itemPlace); itemPlace.add(link); final String current = menuItem.getResponsePage().getName(); final String selected = getModelObject().getSelected().getName(); if (current.equals(selected)) { itemPlace.add(new AttributeModifier("class", "active")); } else { //link.add(new AttributeAppender("class", " menu_option")); } } String userName = getModelObject().getUserName(); MarkupContainer loginInfo = new WebMarkupContainer("infoLogin"); add(loginInfo.setVisible(!"".equals(userName))); // TODO loginInfo.add(new ExternalLink("linkLogout", "j_spring_security_logout")); loginInfo.add(new Label("infoLoginUserName", userName)); }
From source file:org.hippoecm.frontend.editor.plugins.field.NodeFieldPlugin.java
License:Apache License
@Override protected void populateEditItem(Item item, final JcrNodeModel model) { Fragment fragment = new TransparentFragment("fragment", "edit-fragment", this); final int index = item.getIndex(); WebMarkupContainer controls = new WebMarkupContainer("controls"); controls.setVisible(canRemoveItem() || canReorderItems()); fragment.add(controls);/*from w ww. java 2s . c o m*/ MarkupContainer remove = new AjaxLink("remove") { @Override public void onClick(AjaxRequestTarget target) { onRemoveItem(model, target); } }; if (!canRemoveItem()) { remove.setVisible(false); } final HippoIcon removeIcon = HippoIcon.fromSprite("remove-icon", Icon.TIMES); remove.add(removeIcon); controls.add(remove); MarkupContainer upLink = new AjaxLink("up") { @Override public void onClick(AjaxRequestTarget target) { onMoveItemUp(model, target); } }; if (!canReorderItems()) { upLink.setVisible(false); } if (index == 0) { upLink.setEnabled(false); } final HippoIcon upIcon = HippoIcon.fromSprite("up-icon", Icon.ARROW_UP); upLink.add(upIcon); controls.add(upLink); MarkupContainer downLink = new AjaxLink("down") { @Override public void onClick(AjaxRequestTarget target) { IFieldDescriptor field = getFieldHelper().getField(); if (field != null) { String name = field.getPath(); JcrNodeModel parent = model.getParentModel(); if (parent != null) { JcrNodeModel nextModel = new JcrNodeModel( parent.getItemModel().getPath() + "/" + name + "[" + (index + 2) + "]"); onMoveItemUp(nextModel, target); } } } }; if (!canReorderItems()) { downLink.setVisible(false); } boolean isLast = (index == provider.size() - 1); downLink.setEnabled(!isLast); final HippoIcon downIcon = HippoIcon.fromSprite("down-icon", Icon.ARROW_DOWN); downLink.add(downIcon); controls.add(downLink); item.add(fragment); }
From source file:org.hippoecm.frontend.editor.plugins.field.PropertyFieldPlugin.java
License:Apache License
@Override protected void populateEditItem(Item item, final JcrPropertyValueModel model) { Fragment fragment = new TransparentFragment("fragment", "edit-fragment", this); WebMarkupContainer controls = new WebMarkupContainer("controls"); controls.setVisible(canRemoveItem() || canReorderItems()); fragment.add(controls);//from ww w . j av a 2 s .c om MarkupContainer remove = new AjaxLink("remove") { @Override public void onClick(AjaxRequestTarget target) { onRemoveItem(model, target); hasChangedPropValueOrder = true; } }; if (!canRemoveItem()) { remove.setVisible(false); } final HippoIcon removeIcon = HippoIcon.fromSprite("remove-icon", Icon.TIMES); remove.add(removeIcon); controls.add(remove); MarkupContainer upLink = new AjaxLink("up") { @Override public void onClick(AjaxRequestTarget target) { onMoveItemUp(model, target); hasChangedPropValueOrder = true; } }; boolean isFirst = (model.getIndex() == 0); if (!canReorderItems()) { upLink.setVisible(false); } upLink.setEnabled(!isFirst); final HippoIcon upIcon = HippoIcon.fromSprite("up-icon", Icon.ARROW_UP); upLink.add(upIcon); controls.add(upLink); MarkupContainer downLink = new AjaxLink("down") { @Override public void onClick(AjaxRequestTarget target) { JcrPropertyValueModel nextModel = new JcrPropertyValueModel(model.getIndex() + 1, model.getJcrPropertymodel()); onMoveItemUp(nextModel, target); hasChangedPropValueOrder = true; } }; boolean isLast = (model.getIndex() == provider.size() - 1); if (!canReorderItems()) { downLink.setVisible(false); } downLink.setEnabled(!isLast); final HippoIcon downIcon = HippoIcon.fromSprite("down-icon", Icon.ARROW_DOWN); downLink.add(downIcon); controls.add(downLink); item.add(fragment); }