Author: echatellier Date: 2013-02-06 18:22:48 +0100 (Wed, 06 Feb 2013) New Revision: 85 Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/85 Log: Improve provenance edition Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html 2013-02-06 17:20:39 UTC (rev 84) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.html 2013-02-06 17:22:48 UTC (rev 85) @@ -154,16 +154,16 @@ <input type="text" class="tiny" id="Molecule.provenance.presence" wicket:id="Molecule.provenance.presence" /> </td> <td> - todo lot + <span id="Molecule.provenance.lot.ref" wicket:id="Molecule.provenance.lot.ref" /> </td> <td> - todo genre + <span id="Molecule.provenance.genre" wicket:id="Molecule.provenance.genre" /> </td> <td> - todo espece + <span id="Molecule.provenance.espece" wicket:id="Molecule.provenance.espece" /> </td> <td> - todo campagne + <span id="Molecule.provenance.campagne" wicket:id="Molecule.provenance.campagne" /> </td> <td> <input wicket:id="Molecule.provenance.Add" type="submit" wicket:message="value:Add" /> Modified: trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java =================================================================== --- trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java 2013-02-06 17:20:39 UTC (rev 84) +++ trunk/cantharella.web/src/main/java/nc/ird/cantharella/web/pages/domain/molecule/ManageMoleculePage.java 2013-02-06 17:22:48 UTC (rev 85) @@ -49,22 +49,20 @@ import nc.ird.cantharella.web.utils.behaviors.JSConfirmationBehavior; import nc.ird.cantharella.web.utils.behaviors.MoleculeEditorBehavior; import nc.ird.cantharella.web.utils.behaviors.MoleculeViewBehavior; -import nc.ird.cantharella.web.utils.behaviors.ReplaceEmptyLabelBehavior; import nc.ird.cantharella.web.utils.forms.AutoCompleteTextFieldString; +import nc.ird.cantharella.web.utils.forms.AutoCompleteTextFieldString.ComparisonMode; import nc.ird.cantharella.web.utils.forms.SubmittableButton; import nc.ird.cantharella.web.utils.forms.SubmittableButtonEvents; -import nc.ird.cantharella.web.utils.forms.AutoCompleteTextFieldString.ComparisonMode; import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel; import nc.ird.cantharella.web.utils.models.DisplayDecimalPropertyModel.DecimalDisplFormat; import nc.ird.cantharella.web.utils.panels.PropertyLabelLinkProduitPanel; import nc.ird.cantharella.web.utils.security.AuthRole; import nc.ird.cantharella.web.utils.security.AuthRoles; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.apache.wicket.AttributeModifier; import org.apache.wicket.MarkupContainer; import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton; import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; import org.apache.wicket.markup.html.WebMarkupContainer; @@ -79,10 +77,13 @@ import org.apache.wicket.markup.html.link.Link; import org.apache.wicket.markup.html.list.ListItem; import org.apache.wicket.markup.html.list.ListView; +import org.apache.wicket.model.AbstractPropertyModel; import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; import org.apache.wicket.model.PropertyModel; import org.apache.wicket.spring.injection.annot.SpringBean; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Manage molecule page. @@ -378,17 +379,28 @@ }); item.add(new Label("Molecule.provenance.List.presence", new DisplayDecimalPropertyModel( - provenanceModel, "pourcentage", DecimalDisplFormat.SMALL, getLocale()))) - .add(new ReplaceEmptyLabelBehavior()); - item.add(new Label("Molecule.provenance.List.lot.ref", new PropertyModel<String>(provenanceModel, - "pourcentage")).add(new ReplaceEmptyLabelBehavior())); - item.add(new Label("Molecule.provenance.List.genre", new PropertyModel<String>(provenanceModel, - "pourcentage")).add(new ReplaceEmptyLabelBehavior())); - item.add(new Label("Molecule.provenance.List.espece", new PropertyModel<String>(provenanceModel, - "pourcentage")).add(new ReplaceEmptyLabelBehavior())); - item.add(new Label("Molecule.provenance.List.campagne", new PropertyModel<String>(provenanceModel, - "pourcentage")).add(new ReplaceEmptyLabelBehavior())); + provenanceModel, "pourcentage", DecimalDisplFormat.SMALL, getLocale()))); + if (provenance.getProduit() instanceof Fraction) { + item.add(new Label("Molecule.provenance.List.lot.ref", new PropertyModel<String>(provenanceModel, + "produit.purification.lotSource.ref"))); + item.add(new Label("Molecule.provenance.List.genre", new PropertyModel<String>(provenanceModel, + "produit.purification.lotSource.specimenRef.genre"))); + item.add(new Label("Molecule.provenance.List.espece", new PropertyModel<String>(provenanceModel, + "produit.purification.lotSource.specimenRef.espece"))); + item.add(new Label("Molecule.provenance.List.campagne", new PropertyModel<String>(provenanceModel, + "produit.purification.lotSource.campagne.nom"))); + } else { + item.add(new Label("Molecule.provenance.List.lot.ref", new PropertyModel<String>(provenanceModel, + "produit.extraction.lot.ref"))); + item.add(new Label("Molecule.provenance.List.genre", new PropertyModel<String>(provenanceModel, + "produit.extraction.lot.specimenRef.genre"))); + item.add(new Label("Molecule.provenance.List.espece", new PropertyModel<String>(provenanceModel, + "produit.extraction.lot.specimenRef.espece"))); + item.add(new Label("Molecule.provenance.List.campagne", new PropertyModel<String>(provenanceModel, + "produit.extraction.lot.campagne.nom"))); + } + // Action : suppression d'un résultat de test Button deleteButton = new AjaxFallbackButton("Molecule.provenance.List.Delete", formView) { @Override @@ -432,7 +444,65 @@ presenceInput.setOutputMarkupId(true); presenceInput.setOutputMarkupPlaceholderTag(true); provenanceTable.add(presenceInput); + + final Label lotRefLabel = new Label("Molecule.provenance.lot.ref", new AbstractPropertyModel<String>(newProvenanceModel) { + @Override + protected String propertyExpression() { + if (newProvenanceModel.getObject().getProduit() instanceof Fraction) { + return "produit.purification.lotSource.ref"; + } else { + return "produit.extraction.lot.ref"; + } + } + }); + lotRefLabel.setOutputMarkupId(true); + provenanceTable.add(lotRefLabel); + + final Label genreLabel = new Label("Molecule.provenance.genre", new AbstractPropertyModel<String>(newProvenanceModel) { + @Override + protected String propertyExpression() { + if (newProvenanceModel.getObject().getProduit() instanceof Fraction) { + return "produit.purification.lotSource.specimenRef.genre"; + } else { + return "produit.extraction.lot.specimenRef.genre"; + } + } + }); + genreLabel.setOutputMarkupId(true); + provenanceTable.add(genreLabel); + final Label especeLabel = new Label("Molecule.provenance.espece", new AbstractPropertyModel<String>(newProvenanceModel) { + @Override + protected String propertyExpression() { + if (newProvenanceModel.getObject().getProduit() instanceof Fraction) { + return "produit.purification.lotSource.specimenRef.espece"; + } else { + return "produit.extraction.lot.specimenRef.espece"; + } + } + }); + especeLabel.setOutputMarkupId(true); + provenanceTable.add(especeLabel); + + final Label campagneLabel = new Label("Molecule.provenance.campagne", new AbstractPropertyModel<String>(newProvenanceModel) { + @Override + protected String propertyExpression() { + if (newProvenanceModel.getObject().getProduit() instanceof Fraction) { + return "produit.purification.lotSource.campagne.nom"; + } else { + return "produit.extraction.lot.campagne.nom"; + } + } + }); + campagneLabel.setOutputMarkupId(true); + provenanceTable.add(campagneLabel); + + produitChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { + protected void onUpdate(AjaxRequestTarget target) { + target.add(lotRefLabel, genreLabel, especeLabel, campagneLabel); + } + }); + // Bouton AJAX pour ajouter un résultat de test addProvenanceButton = new AjaxFallbackButton("Molecule.provenance.Add", formView) { @Override