r55 - in trunk: tutti-persistence/src/main/java/fr/ifremer/tutti/persistence tutti-persistence/src/main/resources/META-INF/services tutti-persistence/src/main/xmi tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence tutti-service/src/main/java/fr/ifremer/tutti/service tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation tutti-ui-swing/src/
Author: tchemit Date: 2012-12-13 02:57:28 +0100 (Thu, 13 Dec 2012) New Revision: 55 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/55 Log: continue batch screens Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIModel.java Removed: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIModel.java Modified: trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java trunk/tutti-persistence/src/main/resources/META-INF/services/fr.ifremer.tutti.persistence.entities.IdAware trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiScreen.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchRowModel.java trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2012-12-13 01:57:28 UTC (rev 55) @@ -24,16 +24,15 @@ * #L% */ -import fr.ifremer.tutti.persistence.entities.data.AccidentelBatch; +import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; +import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.MacroDechetBatch; -import fr.ifremer.tutti.persistence.entities.data.PlanctonBatch; +import fr.ifremer.tutti.persistence.entities.data.MacroWasteBatch; +import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch; import fr.ifremer.tutti.persistence.entities.data.Program; -import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; -import fr.ifremer.tutti.persistence.entities.referential.Strata; import fr.ifremer.tutti.persistence.entities.referential.BeaufortScale; import fr.ifremer.tutti.persistence.entities.referential.Country; import fr.ifremer.tutti.persistence.entities.referential.Gear; @@ -41,6 +40,7 @@ import fr.ifremer.tutti.persistence.entities.referential.SeaState; import fr.ifremer.tutti.persistence.entities.referential.Sex; import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.persistence.entities.referential.Strata; import fr.ifremer.tutti.persistence.entities.referential.Vessel; import fr.ifremer.tutti.persistence.entities.referential.WeightCategory; import fr.ifremer.tutti.persistence.entities.referential.Zone; @@ -162,39 +162,48 @@ BenthosBatch saveBenthosBatch(BenthosBatch bean); + void deleteBenthosBatch(String id); + //------------------------------------------------------------------------// //-- Plancton Batch methods --// //------------------------------------------------------------------------// - List<PlanctonBatch> getAllPlanctonBatch(String fishingOperationId); + List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId); - PlanctonBatch getPlanctonBatch(String id); + PlanktonBatch getPlanktonBatch(String id); - PlanctonBatch createPlanctonBatch(PlanctonBatch bean); + PlanktonBatch createPlanktonBatch(PlanktonBatch bean); - PlanctonBatch savePlanctonBatch(PlanctonBatch bean); + PlanktonBatch savePlanktonBatch(PlanktonBatch bean); + void deletePlanktonBatch(String id); + //------------------------------------------------------------------------// //-- Macrodechet Batch methods --// //------------------------------------------------------------------------// - List<MacroDechetBatch> getAllMacroDechetBatch(String fishingOperationId); + List<MacroWasteBatch> getAllMacroWasteBatch(String fishingOperationId); - MacroDechetBatch getMacroDechetBatch(String id); + MacroWasteBatch getMacroWasteBatch(String id); - MacroDechetBatch createMacroDechetBatch(MacroDechetBatch bean); + MacroWasteBatch createMacroWasteBatch(MacroWasteBatch bean); - MacroDechetBatch saveMacroDechetBatch(MacroDechetBatch bean); + MacroWasteBatch saveMacroWasteBatch(MacroWasteBatch bean); + void deleteMacroWasteBatch(String id); + //------------------------------------------------------------------------// //-- Accidentel Batch methods --// //------------------------------------------------------------------------// - List<AccidentelBatch> getAllAccidentelBatch(String fishingOperationId); + List<AccidentalBatch> getAllAccidentalBatch(String fishingOperationId); - AccidentelBatch getAccidentelBatch(String id); + AccidentalBatch getAccidentalBatch(String id); - AccidentelBatch createAccidentelBatch(AccidentelBatch bean); + AccidentalBatch createAccidentalBatch(AccidentalBatch bean); - AccidentelBatch saveAccidentelBatch(AccidentelBatch bean); + AccidentalBatch saveAccidentalBatch(AccidentalBatch bean); + + void deleteAccidentalBatch(String id); + } Modified: trunk/tutti-persistence/src/main/resources/META-INF/services/fr.ifremer.tutti.persistence.entities.IdAware =================================================================== --- trunk/tutti-persistence/src/main/resources/META-INF/services/fr.ifremer.tutti.persistence.entities.IdAware 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-persistence/src/main/resources/META-INF/services/fr.ifremer.tutti.persistence.entities.IdAware 2012-12-13 01:57:28 UTC (rev 55) @@ -1,8 +1,8 @@ -fr.ifremer.tutti.persistence.entities.data.AccidentelBatch +fr.ifremer.tutti.persistence.entities.data.AccidentalBatch fr.ifremer.tutti.persistence.entities.data.BenthosBatch fr.ifremer.tutti.persistence.entities.data.FishingOperation -fr.ifremer.tutti.persistence.entities.data.MacroDechetBatch -fr.ifremer.tutti.persistence.entities.data.PlanctonBatch +fr.ifremer.tutti.persistence.entities.data.MacroWasteBatch +fr.ifremer.tutti.persistence.entities.data.PlanktonBatch fr.ifremer.tutti.persistence.entities.data.Program fr.ifremer.tutti.persistence.entities.data.Cruise fr.ifremer.tutti.persistence.entities.data.SpeciesBatch Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo =================================================================== (Binary files differ) Modified: trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java =================================================================== --- trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java 2012-12-13 01:57:28 UTC (rev 55) @@ -35,13 +35,13 @@ import fr.ifremer.tutti.persistence.entities.AbstractTuttiEntity; import fr.ifremer.tutti.persistence.entities.IdAware; import fr.ifremer.tutti.persistence.entities.TuttiEntities; -import fr.ifremer.tutti.persistence.entities.data.AccidentelBatch; +import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.FishingOperationAware; -import fr.ifremer.tutti.persistence.entities.data.MacroDechetBatch; -import fr.ifremer.tutti.persistence.entities.data.PlanctonBatch; +import fr.ifremer.tutti.persistence.entities.data.MacroWasteBatch; +import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch; import fr.ifremer.tutti.persistence.entities.data.Program; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; @@ -239,7 +239,7 @@ } //------------------------------------------------------------------------// - //-- Program methods --// + //-- Program methods --// //------------------------------------------------------------------------// @Override @@ -267,7 +267,7 @@ } //------------------------------------------------------------------------// - //-- Cruise methods --// + //-- Cruise methods --// //------------------------------------------------------------------------// @Override @@ -300,7 +300,7 @@ } //------------------------------------------------------------------------// - //-- FishingOperation methods --// + //-- FishingOperation methods --// //------------------------------------------------------------------------// @Override @@ -421,93 +421,113 @@ return result; } + @Override + public void deleteBenthosBatch(String id) { + remove(BenthosBatch.class, id); + } + //------------------------------------------------------------------------// //-- Plancton Batch methods --// //------------------------------------------------------------------------// @Override - public List<PlanctonBatch> getAllPlanctonBatch(String fishingOperationId) { - List<PlanctonBatch> result = getAllTraitFilterBatches( - PlanctonBatch.class, fishingOperationId); + public List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId) { + List<PlanktonBatch> result = getAllTraitFilterBatches( + PlanktonBatch.class, fishingOperationId); return result; } @Override - public PlanctonBatch getPlanctonBatch(String id) { - PlanctonBatch result = getBean(PlanctonBatch.class, id); + public PlanktonBatch getPlanktonBatch(String id) { + PlanktonBatch result = getBean(PlanktonBatch.class, id); return result; } @Override - public PlanctonBatch createPlanctonBatch(PlanctonBatch bean) { - PlanctonBatch result = create(PlanctonBatch.class, bean); + public PlanktonBatch createPlanktonBatch(PlanktonBatch bean) { + PlanktonBatch result = create(PlanktonBatch.class, bean); return result; } @Override - public PlanctonBatch savePlanctonBatch(PlanctonBatch bean) { - PlanctonBatch result = save(PlanctonBatch.class, bean); + public PlanktonBatch savePlanktonBatch(PlanktonBatch bean) { + PlanktonBatch result = save(PlanktonBatch.class, bean); return result; } + @Override + public void deletePlanktonBatch(String id) { + remove(PlanktonBatch.class, id); + } + //------------------------------------------------------------------------// - //-- Macrodechet Batch methods --// + //-- Macrodechet Batch methods --// //------------------------------------------------------------------------// @Override - public List<MacroDechetBatch> getAllMacroDechetBatch(String fishingOperationId) { - List<MacroDechetBatch> result = getAllTraitFilterBatches( - MacroDechetBatch.class, fishingOperationId); + public List<MacroWasteBatch> getAllMacroWasteBatch(String fishingOperationId) { + List<MacroWasteBatch> result = getAllTraitFilterBatches( + MacroWasteBatch.class, fishingOperationId); return result; } @Override - public MacroDechetBatch getMacroDechetBatch(String id) { - MacroDechetBatch result = getBean(MacroDechetBatch.class, id); + public MacroWasteBatch getMacroWasteBatch(String id) { + MacroWasteBatch result = getBean(MacroWasteBatch.class, id); return result; } @Override - public MacroDechetBatch createMacroDechetBatch(MacroDechetBatch bean) { - MacroDechetBatch result = create(MacroDechetBatch.class, bean); + public MacroWasteBatch createMacroWasteBatch(MacroWasteBatch bean) { + MacroWasteBatch result = create(MacroWasteBatch.class, bean); return result; } @Override - public MacroDechetBatch saveMacroDechetBatch(MacroDechetBatch bean) { - MacroDechetBatch result = save(MacroDechetBatch.class, bean); + public MacroWasteBatch saveMacroWasteBatch(MacroWasteBatch bean) { + MacroWasteBatch result = save(MacroWasteBatch.class, bean); return result; } + @Override + public void deleteMacroWasteBatch(String id) { + remove(MacroWasteBatch.class, id); + } + //------------------------------------------------------------------------// //-- Accidentel Batch methods --// //------------------------------------------------------------------------// @Override - public List<AccidentelBatch> getAllAccidentelBatch(String fishingOperationId) { - List<AccidentelBatch> result = getAllTraitFilterBatches( - AccidentelBatch.class, fishingOperationId); + public List<AccidentalBatch> getAllAccidentalBatch(String fishingOperationId) { + List<AccidentalBatch> result = getAllTraitFilterBatches( + AccidentalBatch.class, fishingOperationId); return result; } @Override - public AccidentelBatch getAccidentelBatch(String id) { - AccidentelBatch result = getBean(AccidentelBatch.class, id); + public AccidentalBatch getAccidentalBatch(String id) { + AccidentalBatch result = getBean(AccidentalBatch.class, id); return result; } @Override - public AccidentelBatch createAccidentelBatch(AccidentelBatch bean) { - AccidentelBatch result = create(AccidentelBatch.class, bean); + public AccidentalBatch createAccidentalBatch(AccidentalBatch bean) { + AccidentalBatch result = create(AccidentalBatch.class, bean); return result; } @Override - public AccidentelBatch saveAccidentelBatch(AccidentelBatch bean) { - AccidentelBatch result = save(AccidentelBatch.class, bean); + public AccidentalBatch saveAccidentalBatch(AccidentalBatch bean) { + AccidentalBatch result = save(AccidentalBatch.class, bean); return result; } + @Override + public void deleteAccidentalBatch(String id) { + remove(AccidentalBatch.class, id); + } + //------------------------------------------------------------------------// //-- Internal methods --// //------------------------------------------------------------------------// Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2012-12-13 01:57:28 UTC (rev 55) @@ -26,12 +26,12 @@ import com.google.common.base.Preconditions; import fr.ifremer.tutti.persistence.TuttiPersistence; -import fr.ifremer.tutti.persistence.entities.data.AccidentelBatch; +import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.MacroDechetBatch; -import fr.ifremer.tutti.persistence.entities.data.PlanctonBatch; +import fr.ifremer.tutti.persistence.entities.data.MacroWasteBatch; +import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch; import fr.ifremer.tutti.persistence.entities.data.Program; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; @@ -357,90 +357,114 @@ return driver.saveBenthosBatch(bean); } + @Override + public void deleteBenthosBatch(String id) { + checkDriverExists(); + driver.deleteBenthosBatch(id); + } + //------------------------------------------------------------------------// //-- Plancton Batch methods --// //------------------------------------------------------------------------// @Override - public List<PlanctonBatch> getAllPlanctonBatch(String fishingOperationId) { + public List<PlanktonBatch> getAllPlanktonBatch(String fishingOperationId) { checkDriverExists(); - return driver.getAllPlanctonBatch(fishingOperationId); + return driver.getAllPlanktonBatch(fishingOperationId); } @Override - public PlanctonBatch getPlanctonBatch(String id) { + public PlanktonBatch getPlanktonBatch(String id) { checkDriverExists(); - return driver.getPlanctonBatch(id); + return driver.getPlanktonBatch(id); } @Override - public PlanctonBatch createPlanctonBatch(PlanctonBatch bean) { + public PlanktonBatch createPlanktonBatch(PlanktonBatch bean) { checkDriverExists(); - return driver.createPlanctonBatch(bean); + return driver.createPlanktonBatch(bean); } @Override - public PlanctonBatch savePlanctonBatch(PlanctonBatch bean) { + public PlanktonBatch savePlanktonBatch(PlanktonBatch bean) { checkDriverExists(); - return driver.savePlanctonBatch(bean); + return driver.savePlanktonBatch(bean); } + @Override + public void deletePlanktonBatch(String id) { + checkDriverExists(); + driver.deletePlanktonBatch(id); + } + //------------------------------------------------------------------------// //-- Macrodechet Batch methods --// //------------------------------------------------------------------------// @Override - public List<MacroDechetBatch> getAllMacroDechetBatch(String fishingOperationId) { + public List<MacroWasteBatch> getAllMacroWasteBatch(String fishingOperationId) { checkDriverExists(); - return driver.getAllMacroDechetBatch(fishingOperationId); + return driver.getAllMacroWasteBatch(fishingOperationId); } @Override - public MacroDechetBatch getMacroDechetBatch(String id) { + public MacroWasteBatch getMacroWasteBatch(String id) { checkDriverExists(); - return driver.getMacroDechetBatch(id); + return driver.getMacroWasteBatch(id); } @Override - public MacroDechetBatch createMacroDechetBatch(MacroDechetBatch bean) { + public MacroWasteBatch createMacroWasteBatch(MacroWasteBatch bean) { checkDriverExists(); - return driver.createMacroDechetBatch(bean); + return driver.createMacroWasteBatch(bean); } @Override - public MacroDechetBatch saveMacroDechetBatch(MacroDechetBatch bean) { + public MacroWasteBatch saveMacroWasteBatch(MacroWasteBatch bean) { checkDriverExists(); - return driver.saveMacroDechetBatch(bean); + return driver.saveMacroWasteBatch(bean); } + @Override + public void deleteMacroWasteBatch(String id) { + checkDriverExists(); + driver.deleteMacroWasteBatch(id); + } + //------------------------------------------------------------------------// //-- Accidentel Batch methods --// //------------------------------------------------------------------------// @Override - public List<AccidentelBatch> getAllAccidentelBatch(String fishingOperationId) { + public List<AccidentalBatch> getAllAccidentalBatch(String fishingOperationId) { checkDriverExists(); - return driver.getAllAccidentelBatch(fishingOperationId); + return driver.getAllAccidentalBatch(fishingOperationId); } @Override - public AccidentelBatch getAccidentelBatch(String id) { + public AccidentalBatch getAccidentalBatch(String id) { checkDriverExists(); - return driver.getAccidentelBatch(id); + return driver.getAccidentalBatch(id); } @Override - public AccidentelBatch createAccidentelBatch(AccidentelBatch bean) { + public AccidentalBatch createAccidentalBatch(AccidentalBatch bean) { checkDriverExists(); - return driver.createAccidentelBatch(bean); + return driver.createAccidentalBatch(bean); } @Override - public AccidentelBatch saveAccidentelBatch(AccidentelBatch bean) { + public AccidentalBatch saveAccidentalBatch(AccidentalBatch bean) { checkDriverExists(); - return driver.saveAccidentelBatch(bean); + return driver.saveAccidentalBatch(bean); } + @Override + public void deleteAccidentalBatch(String id) { + checkDriverExists(); + driver.deleteAccidentalBatch(id); + } + //------------------------------------------------------------------------// //-- Internal methods --// //------------------------------------------------------------------------// Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css 2012-12-13 01:57:28 UTC (rev 55) @@ -73,7 +73,7 @@ text: "tutti.action.fillCatches"; toolTipText: "tutti.action.fillCatches.tip"; mnemonic: C; - enabled: {model.getScreen() != TuttiScreen.FILL_FISHING_OPERATION && model.isCruiseContextFilled()}; + enabled: {model.getScreen() != TuttiScreen.EDIT_FISHING_OPERATION && model.isCruiseContextFilled()}; /*actionIcon: "catches";*/ } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUIHandler.java 2012-12-13 01:57:28 UTC (rev 55) @@ -24,16 +24,16 @@ * #L% */ +import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.Program; -import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.config.TuttiServiceConfigOption; import fr.ifremer.tutti.ui.swing.config.TuttiConfig; import fr.ifremer.tutti.ui.swing.config.TuttiConfigOption; import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUI; -import fr.ifremer.tutti.ui.swing.content.program.EditProgramUI; import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUI; import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; +import fr.ifremer.tutti.ui.swing.content.program.EditProgramUI; import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import jaxx.runtime.SwingUtil; import jaxx.runtime.swing.AboutPanel; @@ -114,7 +114,7 @@ if (context.isCruiseContextFilled()) { // direct fill catches screen - screen = TuttiScreen.FILL_FISHING_OPERATION; + screen = TuttiScreen.EDIT_FISHING_OPERATION; } else { // go to select cruise screen @@ -234,7 +234,7 @@ } public void showFillCatches() { - context.setScreen(TuttiScreen.FILL_FISHING_OPERATION); + context.setScreen(TuttiScreen.EDIT_FISHING_OPERATION); } public void showImportScreen() { @@ -355,9 +355,9 @@ screenUI = new EditCruiseUI(context); break; - case FILL_FISHING_OPERATION: + case EDIT_FISHING_OPERATION: - screenTitle = _("tutti.title.fill.catches"); + screenTitle = _("tutti.title.edit.operations", getSelectedCruiseTitle()); screenUI = new FishingOperationsUI(context); break; } @@ -397,7 +397,7 @@ protected void closeCurrentBody() { if (currentBody != null) { - TuttiUI<?,?> body = (TuttiUI<?,?>) currentBody; + TuttiUI<?, ?> body = (TuttiUI<?, ?>) currentBody; body.getHandler().onCloseUI(); context.getSwingSession().save(); @@ -430,7 +430,16 @@ } protected void changeTitle() { + + String title = getSelectedCruiseTitle(); + + ui.setTitle("Tutti - v " + getConfig().getVersion() + " [ " + title + " ]"); + } + + protected String getSelectedCruiseTitle() { + String surveyId = context.getProgramId(); + String title; if (surveyId == null) { @@ -465,8 +474,7 @@ title += _("tutti.title.selectedCruise", cruise.getName()); } } - - ui.setTitle("Tutti - v " + getConfig().getVersion() + " [ " + title + " ]"); + return title; } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiScreen.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiScreen.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiScreen.java 2012-12-13 01:57:28 UTC (rev 55) @@ -65,5 +65,5 @@ * * @since 0.1 */ - FILL_FISHING_OPERATION + EDIT_FISHING_OPERATION } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2012-12-13 01:57:28 UTC (rev 55) @@ -175,7 +175,7 @@ public void showFishingOperations() { - context.setScreen(TuttiScreen.FILL_FISHING_OPERATION); + context.setScreen(TuttiScreen.EDIT_FISHING_OPERATION); } public void showSelectedProgram() { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationTabUI.jaxx 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationTabUI.jaxx 2012-12-13 01:57:28 UTC (rev 55) @@ -84,10 +84,10 @@ <field name='saisisseur' component='saisisseurList'/> </BeanValidator> - <JPanel id='traitPane' constraints='BorderLayout.CENTER' + <JPanel id='fishingOperationPane' constraints='BorderLayout.CENTER' layout='{new BorderLayout()}'> - <JTabbedPane id='traitTabPane' constraints='BorderLayout.CENTER'> + <JTabbedPane id='fishingOperationTabPane' constraints='BorderLayout.CENTER'> <tab id='traitGeneralTab' title='tutti.label.tab.fishingOperation.general'> <Table fill='both' id='generalForm'> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationTabUIHandler.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationTabUIHandler.java 2012-12-13 01:57:28 UTC (rev 55) @@ -28,7 +28,6 @@ import fr.ifremer.tutti.persistence.entities.referential.Person; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; -import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -72,7 +71,7 @@ model.addPropertyChangeListener(FishingOperationTabUIModel.PROPERTY_EMPTY, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { - JPanel form = ui.getTraitPane(); + JPanel form = ui.getFishingOperationPane(); JLabel noContentPane = ui.getNoTraitPane(); Boolean empty = (Boolean) evt.getNewValue(); @@ -153,9 +152,6 @@ // update model empty property model.setEmpty(empty); - // reload bean in validator (? really mandatory?) -// ui.getValidator().reloadBean(); - // if new fishingOperation can already cancel his creation model.setModify(!empty && model.isCreate()); } @@ -192,13 +188,13 @@ } // keep selected tab (to resotre it after save) - int selectedIndex = ui.getTraitTabPane().getSelectedIndex(); + int selectedIndex = ui.getFishingOperationTabPane().getSelectedIndex(); // persist current fishingOperation parentUi.getHandler().saveFishingOperation(toSave); // reselect current tab - ui.getTraitTabPane().setSelectedIndex(selectedIndex); + ui.getFishingOperationTabPane().setSelectedIndex(selectedIndex); getModel().setModify(false); } @@ -219,10 +215,6 @@ getModel().setGearShootingStartLongitude(Float.valueOf(text)); } -// public void setGearShootingStartTime(String text) { -// getModel().setGearShootingStartTime(Integer.valueOf(text)); -// } - public void setGearShootingEndLatitude(String text) { getModel().setGearShootingEndLatitude(Float.valueOf(text)); } @@ -230,8 +222,4 @@ public void setGearShootingEndLongitude(String text) { getModel().setGearShootingEndLongitude(Float.valueOf(text)); } - -// public void setGearShootingEndTime(String text) { -// getModel().setGearShootingEndTime(Integer.valueOf(text)); -// } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css 2012-12-13 01:57:28 UTC (rev 55) @@ -46,7 +46,7 @@ enabled: {model.getSelectedFishingOperation() != null}; } -#planctonTab { +#planktonTab { enabled: {model.getSelectedFishingOperation() != null}; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2012-12-13 01:57:28 UTC (rev 55) @@ -28,11 +28,11 @@ fr.ifremer.tutti.persistence.entities.data.FishingOperation fr.ifremer.tutti.ui.swing.TuttiUIContext - fr.ifremer.tutti.ui.swing.content.operation.accidental.AccidentelTabUI - fr.ifremer.tutti.ui.swing.content.operation.benthos.BenthosTabUI - fr.ifremer.tutti.ui.swing.content.operation.macrowaste.MacroDechetTabUI - fr.ifremer.tutti.ui.swing.content.operation.plankton.PlanctonTabUI - fr.ifremer.tutti.ui.swing.content.operation.species.SpeciesTabUI + fr.ifremer.tutti.ui.swing.content.operation.accidental.AccidentalBatchUI + fr.ifremer.tutti.ui.swing.content.operation.benthos.BenthosBatchUI + fr.ifremer.tutti.ui.swing.content.operation.macrowaste.MacroWasteBatchUI + fr.ifremer.tutti.ui.swing.content.operation.plankton.PlanktonBatchUI + fr.ifremer.tutti.ui.swing.content.operation.species.SpeciesBatchUI jaxx.runtime.swing.editor.bean.BeanComboBox @@ -73,23 +73,23 @@ </Table> <JTabbedPane id='tabPane' constraints='BorderLayout.CENTER'> - <tab id='traitTab' title='tutti.label.tab.fishingOperation'> + <tab id='fishingOperationTab' title='tutti.label.tab.fishingOperation'> <FishingOperationTabUI id='fishingOperationTabContent' constructorParams='this'/> </tab> <tab id='speciesTab' title='tutti.label.tab.species'> - <SpeciesTabUI id='speciesTabContent' constructorParams='this'/> + <SpeciesBatchUI id='speciesTabContent' constructorParams='this'/> </tab> <tab id='benthosTab' title='tutti.label.tab.benthos'> - <BenthosTabUI id='benthosTabContent' constructorParams='this'/> + <BenthosBatchUI id='benthosTabContent' constructorParams='this'/> </tab> - <tab id='planctonTab' title='tutti.label.tab.plancton'> - <PlanctonTabUI id='planctonTabContent' constructorParams='this'/> + <tab id='planktonTab' title='tutti.label.tab.plancton'> + <PlanktonBatchUI id='planktonTabContent' constructorParams='this'/> </tab> <tab id='macroDechetTab' title='tutti.label.tab.macroDechet'> - <MacroDechetTabUI id='macroDechetTabContent' constructorParams='this'/> + <MacroWasteBatchUI id='macroDechetTabContent' constructorParams='this'/> </tab> <tab id='accidentelTab' title='tutti.label.tab.accidentel'> - <AccidentelTabUI id='accidentelTabContent' constructorParams='this'/> + <AccidentalBatchUI id='accidentelTabContent' constructorParams='this'/> </tab> <tab id='observationIndividuelTab' title='tutti.label.tab.observationIndividuel'> <JLabel text='tutti.to.be.done' horizontalAlignment='{JLabel.CENTER}'/> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2012-12-13 01:57:28 UTC (rev 55) @@ -127,7 +127,7 @@ // ui will be saved so we do not want to keep selected tab indexes ui.getTabPane().setSelectedIndex(0); - ui.getFishingOperationTabContent().getTraitTabPane().setSelectedIndex(0); + ui.getFishingOperationTabContent().getFishingOperationTabPane().setSelectedIndex(0); // when quitting ui, let's de-select fishingOperation (will save any changes) selectFishingOperation(null); @@ -167,13 +167,13 @@ ui.getTabPane().setSelectedIndex(0); // back to general tab of fishingOperation tabs - ui.getFishingOperationTabContent().getTraitTabPane().setSelectedIndex(0); + ui.getFishingOperationTabContent().getFishingOperationTabPane().setSelectedIndex(0); // propagate fishingOperation to his tabs ui.getFishingOperationTabContent().selectFishingOperation(fishingOperation); ui.getSpeciesTabContent().selectFishingOperation(fishingOperation); ui.getBenthosTabContent().selectFishingOperation(fishingOperation); - ui.getPlanctonTabContent().selectFishingOperation(fishingOperation); + ui.getPlanktonTabContent().selectFishingOperation(fishingOperation); ui.getMacroDechetTabContent().selectFishingOperation(fishingOperation); ui.getAccidentelTabContent().selectFishingOperation(fishingOperation); Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchRowModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchRowModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,116 @@ +package fr.ifremer.tutti.ui.swing.content.operation.accidental; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +/** + * Define a benthos batch row. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class AccidentalBatchRowModel extends AbstractTuttiBeanUIModel<AccidentalBatch, AccidentalBatchRowModel> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_SPECIES = "species"; + + public static final String PROPERTY_WEIGHT = "weight"; + + public static final String PROPERTY_COMMENT = "comment"; + + /** + * Species observed. + * + * @since 0.2 + */ + protected Species species; + + /** + * Observed weight. + * + * @since 0.2 + */ + protected Float weight; + + /** + * Comment on this catches. + * + * @since 0.2 + */ + protected String comment; + + protected static final Binder<AccidentalBatch, AccidentalBatchRowModel> fromBeanBinder = + BinderFactory.newBinder(AccidentalBatch.class, + AccidentalBatchRowModel.class); + + protected static final Binder<AccidentalBatchRowModel, AccidentalBatch> toBeanBinder = + BinderFactory.newBinder(AccidentalBatchRowModel.class, + AccidentalBatch.class); + + public AccidentalBatchRowModel() { + super(AccidentalBatch.class, fromBeanBinder, toBeanBinder); + } + + public AccidentalBatchRowModel(AccidentalBatch aBatch) { + this(); + fromBean(aBatch); + } + + public Species getSpecies() { + return species; + } + + public void setSpecies(Species species) { + Object oldValue = getSpecies(); + this.species = species; + firePropertyChange(PROPERTY_SPECIES, oldValue, species); + } + + public Float getWeight() { + return weight; + } + + public void setWeight(Float weight) { + Object oldValue = getWeight(); + this.weight = weight; + firePropertyChange(PROPERTY_WEIGHT, oldValue, weight); + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + Object oldValue = getComment(); + this.comment = comment; + firePropertyChange(PROPERTY_COMMENT, oldValue, comment); + } +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchRowModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchTableModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchTableModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,119 @@ +package fr.ifremer.tutti.ui.swing.content.operation.accidental; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.ui.swing.content.operation.benthos.BenthosBatchRowModel; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; + +import javax.swing.table.TableColumnModel; + +import static org.nuiton.i18n.I18n.n_; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class AccidentalBatchTableModel extends AbstractTuttiTableModel<AccidentalBatchRowModel> { + + private static final long serialVersionUID = 1L; + + public static final ColumnIdentifier<AccidentalBatchRowModel> SPECIES_BY_CODE = ColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_SPECIES, + n_("tutti.table.benthos.batch.header.speciesByCode"), + n_("tutti.table.benthos.batch.header.speciesByCode")); + + public static final ColumnIdentifier<AccidentalBatchRowModel> SPECIES_BY_GENUS_CODE = ColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_SPECIES, + n_("tutti.table.benthos.batch.header.speciesByGenusCode"), + n_("tutti.table.benthos.batch.header.speciesByGenusCode")); + + public static final ColumnIdentifier<AccidentalBatchRowModel> WEIGHT = ColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_WEIGHT, + n_("tutti.table.benthos.batch.header.weight"), + n_("tutti.table.benthos.batch.header.weight")); + + public static final ColumnIdentifier<AccidentalBatchRowModel> COMMENT = ColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_COMMENT, + n_("tutti.table.benthos.batch.header.comment"), + n_("tutti.table.benthos.batch.header.comment")); + + public static final ColumnIdentifier<AccidentalBatchRowModel> FILE = ColumnIdentifier.newId( + null, + n_("tutti.table.benthos.batch.header.file"), + n_("tutti.table.benthos.batch.header.file")); + + + public AccidentalBatchTableModel(TableColumnModel columnModel) { + super(columnModel); + + setNoneEditableCols( + FILE + ); + } + + @Override + protected AccidentalBatchRowModel createNewRow() { + AccidentalBatchRowModel result = new AccidentalBatchRowModel(); + + // by default empty row is not valid + result.setValid(false); + return result; + } + + @Override + public void setValueAt(Object aValue, + int rowIndex, + int columnIndex, + ColumnIdentifier<AccidentalBatchRowModel> propertyName, + AccidentalBatchRowModel entry) { + super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry); + + if (propertyName == SPECIES_BY_CODE) { + + // update also other columns + fireTableCellUpdated(rowIndex, + SPECIES_BY_GENUS_CODE); + + } else if (propertyName == SPECIES_BY_GENUS_CODE) { + + // update also other columns + fireTableCellUpdated(rowIndex, + SPECIES_BY_CODE); + } + } + + @Override + protected boolean isCellEditable(int rowIndex, + int columnIndex, + ColumnIdentifier<AccidentalBatchRowModel> propertyName) { + + boolean result = super.isCellEditable(rowIndex, + columnIndex, + propertyName); + + return result; + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchTableModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.css (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.css 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,37 @@ +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +NumberEditor { + autoPopup: {handler.getConfig().isAutoPopupNumberEditor()}; + showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; + bean: {model}; + showReset: true; +} + +#table { + selectionMode: {ListSelectionModel.SINGLE_SELECTION}; + selectionBackground: {null}; + selectionForeground: {Color.BLACK}; + sortable: false; +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.jaxx (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.jaxx 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,67 @@ +<!-- + #%L + Tutti :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 Ifremer + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JPanel id='homePanel' layout='{new BorderLayout()}' + implements='fr.ifremer.tutti.ui.swing.TuttiUI<AccidentalBatchUIModel, AccidentalBatchUIHandler>'> + + <import> + fr.ifremer.tutti.persistence.entities.data.FishingOperation + + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI + + jaxx.runtime.swing.editor.NumberEditor + + org.jdesktop.swingx.JXTable + + javax.swing.ListSelectionModel + + java.awt.Color + + static org.nuiton.i18n.I18n._ + </import> + + <script><![CDATA[ + +public AccidentalBatchUI(FishingOperationsUI parentUI) { + AccidentalBatchUIHandler handler = new AccidentalBatchUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); } + +protected void $afterCompleteSetup() { handler.afterInitUI(); } + ]]></script> + + <AccidentalBatchUIHandler id='handler' + initializer='getContextValue(AccidentalBatchUIHandler.class)'/> + + <AccidentalBatchUIModel id='model' + initializer='getContextValue(AccidentalBatchUIModel.class)'/> + + <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> + <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event);'/> + </JScrollPane> + +</JPanel> \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIHandler.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIHandler.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,464 @@ +package fr.ifremer.tutti.ui.swing.content.operation.accidental; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.DecoratorService; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.TuttiUI; +import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; +import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; +import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; +import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener; +import jaxx.runtime.SwingUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.ComponentAdapter; +import org.jdesktop.swingx.decorator.HighlightPredicate; +import org.jdesktop.swingx.decorator.Highlighter; +import org.jdesktop.swingx.table.DefaultTableColumnModelExt; +import org.nuiton.util.decorator.Decorator; + +import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableColumnModel; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.FocusEvent; +import java.util.List; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class AccidentalBatchUIHandler extends AbstractTuttiTableUIHandler<AccidentalBatchRowModel, AccidentalBatchUIModel> { + + /** Logger. */ + private static final Log log = LogFactory.getLog(AccidentalBatchUIHandler.class); + + /** + * UI. + * + * @since 0.2 + */ + private final AccidentalBatchUI ui; + + /** + * Persistence service. + * + * @since 0.2 + */ + private final PersistenceService persistenceService; + + /** + * To monitor changes on the fishing operation. + * + * @since 0.2 + */ + private final TuttiBeanMonitor<AccidentalBatchUIModel> fishingOperationMonitor; + + public AccidentalBatchUIHandler(FishingOperationsUI parentUi, AccidentalBatchUI ui) { + super(parentUi.getHandler().getContext(), + AccidentalBatchRowModel.PROPERTY_SPECIES, + AccidentalBatchRowModel.PROPERTY_WEIGHT, + AccidentalBatchRowModel.PROPERTY_COMMENT); + this.ui = ui; + this.persistenceService = context.getService(PersistenceService.class); + this.fishingOperationMonitor = new TuttiBeanMonitor<AccidentalBatchUIModel>(); + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiTableUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + protected AccidentalBatchUIModel getModel() { + return ui.getModel(); + } + + @Override + protected AccidentalBatchTableModel getTableModel() { + return (AccidentalBatchTableModel) getTable().getModel(); + } + + @Override + protected JXTable getTable() { + return ui.getTable(); + } + + @Override + protected TableColumnModel createTableColumnModel() { + + DefaultTableColumnModelExt columnModel = + new DefaultTableColumnModelExt(); + + List<Species> allSpecies = persistenceService.getAllSpecies(); + + { + // Species (by code) column + + Decorator<Species> decorator = getDecorator( + Species.class, DecoratorService.SPECIES_BY_CODE); + + addComboDataColumnToModel(columnModel, + AccidentalBatchTableModel.SPECIES_BY_CODE, + decorator, allSpecies); + } + + { + // Species (by genusCode) column + + Decorator<Species> decorator = getDecorator( + Species.class, DecoratorService.SPECIES_BY_GENUS); + + addComboDataColumnToModel(columnModel, + AccidentalBatchTableModel.SPECIES_BY_GENUS_CODE, + decorator, allSpecies); + + } + + { // Weight column + + addFloatColumnToModel(columnModel, + AccidentalBatchTableModel.WEIGHT, + TuttiUI.DECIMAL3_PATTERN); + } + + { // Comment column + + addColumnToModel(columnModel, + AccidentalBatchTableModel.COMMENT); + } + + { // File column + + addColumnToModel(columnModel, + AccidentalBatchTableModel.FILE); + } + return columnModel; + } + + @Override + protected void onRowModified(AccidentalBatchRowModel row, + String propertyName, + Object oldValue, + Object newValue) { + + boolean wasValid = row.isValid(); + + boolean valid = isRowValid(row); + + if (log.isInfoEnabled()) { + log.info("Was valid / Is valid: " + wasValid + " / " + valid); + } + row.setValid(valid); + } + + @Override + protected void onRowValidStateChanged(AccidentalBatchRowModel row, + Boolean oldValue, + Boolean newValue) { + int rowIndex = getTableModel().getRowIndex(row); + + if (rowIndex > -1) { + getTableModel().fireTableRowsUpdated(rowIndex, rowIndex); + } + } + + @Override + protected void onRowModifyStateChanged(AccidentalBatchRowModel row, + Boolean oldValue, + Boolean newValue) { + } + + @Override + protected void onModelRowsChanged(List<AccidentalBatchRowModel> rows) { + super.onModelRowsChanged(rows); + + // set valid flag + for (AccidentalBatchRowModel row : rows) { + boolean valid = isRowValid(row); + row.setValid(valid); + } + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public void beforeInitUI() { + + if (log.isInfoEnabled()) { + log.info("beforeInit: " + ui); + } + + AccidentalBatchUIModel model = new AccidentalBatchUIModel(); + ui.setContextValue(model); + + fishingOperationMonitor.setBean(model); + } + + @Override + public void afterInitUI() { + + if (log.isInfoEnabled()) { + log.info("afterInit: " + ui); + } + + initUI(ui); + + JXTable table = getTable(); + + // create table column model + TableColumnModel columnModel = createTableColumnModel(); + + // create table model + AccidentalBatchTableModel tableModel = + new AccidentalBatchTableModel(columnModel); + + table.setModel(tableModel); + table.setColumnModel(columnModel); + installTableKeyListener(columnModel, table); + + table.getTableHeader().setReorderingAllowed(false); + + + Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY); + + table.addHighlighter(readOnlyHighlighter); + Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { + + boolean result = false; + if (adapter.isEditable()) { + int rowIndex = adapter.convertRowIndexToModel(adapter.row); + AccidentalBatchRowModel row = getTableModel().getEntry(rowIndex); + result = !row.isValid(); + } + return result; + } + }), Color.RED); + table.addHighlighter(validHighlighter); + + // when model datas change let's propagate it table model + listenRowsFromModel(); + + // save when row chaged and was modified + ListSelectionListener listener = new TableRowModificationListener<AccidentalBatchRowModel>( + getTableModel(), getRowMonitor()) { + @Override + protected void saveSelectedRow() { + saveSelectedRowIfRequired(); + } + }; + table.getSelectionModel().addListSelectionListener(listener); + + // always scroll to selected row + SwingUtil.scrollToTableSelection(getTable()); + } + + @Override + public void onCloseUI() { + if (log.isInfoEnabled()) { + log.info("closing: " + ui); + } + } + + //------------------------------------------------------------------------// + //-- Public methods --// + //------------------------------------------------------------------------// + + public void saveSelectedRowIfRequired(FocusEvent event) { + + Component oppositeComponent = event.getOppositeComponent(); + + JXTable parentContainer = null; + + if (oppositeComponent != null) { + + // check out if still on table + parentContainer = SwingUtil.getParentContainer( + oppositeComponent, JXTable.class); + } + + if (parentContainer == null) { + + // out of the table can save + if (getModel().getFishingOperation() != null) { + saveSelectedRowIfRequired(); + } + } + } + + public void selectFishingOperation(FishingOperation bean) { + + JXTable table = getTable(); + + if (table.isEditing()) { + + // make sure to stop editor + table.editingCanceled(null); + } + + if (fishingOperationMonitor.wasModified()) { + + // previous fishingOperation was modified, let's save it + AccidentalBatchUIModel beanToSave = fishingOperationMonitor.getBean(); + + FishingOperation fishingOperation = beanToSave.toBean(); + + if (log.isInfoEnabled()) { + log.info("FishingOperation " + fishingOperation.getId() + + " was modified, will save it."); + } + + persistenceService.saveFishingOperation(fishingOperation); + } + + // make sure selection is empty (will remove bean from monitor) + table.clearSelection(); + + boolean empty = bean == null; + + AccidentalBatchUIModel model = getModel(); + + List<AccidentalBatchRowModel> rows; + + if (empty) { + rows = null; + bean = new FishingOperation(); + model.setFishingOperation(null); + } else { + + if (log.isInfoEnabled()) { + log.info("Get species batch for fishingOperation: " + bean.getId()); + } + rows = Lists.newArrayList(); + + if (!TuttiEntities.isNew(bean)) { + List<AccidentalBatch> catches = + persistenceService.getAllAccidentalBatch(bean.getId()); + for (AccidentalBatch aBatch : catches) { + AccidentalBatchRowModel entry = + new AccidentalBatchRowModel(aBatch); + rows.add(entry); + } + } + model.setFishingOperation(bean); + } + + model.fromBean(bean); + model.setRows(rows); + + fishingOperationMonitor.clearModified(); + } + + public void cancel() { + + if (log.isInfoEnabled()) { + log.info("Cancel edition"); + } + } + + public void save() { + if (log.isInfoEnabled()) { + log.info("Will save"); + } + } + + //------------------------------------------------------------------------// + //-- Internal methods --// + //------------------------------------------------------------------------// + + protected boolean isRowValid(AccidentalBatchRowModel row) { + boolean result = row.getSpecies() != null && row.getWeight() != null; + return result; + } + + protected void saveSelectedRowIfRequired() { + + TuttiBeanMonitor<AccidentalBatchRowModel> rowMonitor = getRowMonitor(); + + AccidentalBatchRowModel bean = rowMonitor.getBean(); + if (bean != null) { + + if (bean.isValid()) { + // there is a valid bean attached to the monitor + + if (rowMonitor.wasModified()) { + + // monitored bean was modified, save it + if (log.isInfoEnabled()) { + log.info("Row " + bean + " was modified, will save it"); + } + + saveRow(bean); + + // clear modified flag on the monitor + rowMonitor.clearModified(); + } + } else { + + // row is not valid can not save it + + AccidentalBatch catchBean = bean.toBean(); + + if (!TuttiEntities.isNew(catchBean)) { + + // remove this + persistenceService.deleteAccidentalBatch(catchBean.getId()); + } + } + } + } + + protected void saveRow(AccidentalBatchRowModel row) { + + AccidentalBatch catchBean = row.toBean(); + + FishingOperation fishingOperation = getModel().getFishingOperation(); + catchBean.setFishingOperation(fishingOperation); + if (log.isInfoEnabled()) { + log.info("Selected fishingOperation: " + fishingOperation.getId()); + } + + if (TuttiEntities.isNew(catchBean)) { + + catchBean = persistenceService.createAccidentalBatch(catchBean); + row.setId(catchBean.getId()); + } else { + persistenceService.saveAccidentalBatch(catchBean); + } + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,73 @@ +package fr.ifremer.tutti.ui.swing.content.operation.accidental; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderModelBuilder; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class AccidentalBatchUIModel extends AbstractTuttiTableUIModel<FishingOperation, AccidentalBatchRowModel, AccidentalBatchUIModel> { + + private static final long serialVersionUID = 1L; + + /** + * Editing fishing operation. + * + * @since 0.2 + */ + protected FishingOperation fishingOperation; + + + protected static final Binder<FishingOperation, AccidentalBatchUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, AccidentalBatchUIModel.class) + .addProperty(FishingOperation.PROPERTY_ID, PROPERTY_ID) + .toBinder(); + + protected static final Binder<AccidentalBatchUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(AccidentalBatchUIModel.class, FishingOperation.class) + .toBinder(); + + + public AccidentalBatchUIModel() { + super(FishingOperation.class, fromBeanBinder, toBeanBinder); + } + + public FishingOperation getFishingOperation() { + return fishingOperation; + } + + public void setFishingOperation(FishingOperation fishingOperation) { + this.fishingOperation = fishingOperation; + } + + + @Override + protected FishingOperation newEntity() { + return fishingOperation; + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentalBatchUIModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.css 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.css 2012-12-13 01:57:28 UTC (rev 55) @@ -1,59 +0,0 @@ -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -NumberEditor { - autoPopup: {handler.getConfig().isAutoPopupNumberEditor()}; - showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; - bean: {model}; - showReset: true; -} - -#totalWeightLabel { - text: "tutti.label.captureAccidentel.totalWeight"; - labelFor: {totalWeightField}; -} - -#totalWeightField { - property: "totalWeight"; - model: {model.getTotalWeight()}; - useFloat: false; - numberPattern: {INT_6_DIGITS_PATTERN}; -} - -#sampleTotalWeightLabel { - text: "tutti.label.captureAccidentel.sampleTotalWeight"; - labelFor: {totalWeightField}; -} - -#sampleTotalWeightField { - property: "sampleTotalWeight"; - model: {model.getSampleTotalWeight()}; - useFloat: false; - numberPattern: {INT_6_DIGITS_PATTERN}; -} - -#table { - model: {getContextValue(TableModel.class)}; - columnModel: {getContextValue(TableColumnModel.class)}; -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.jaxx 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.jaxx 2012-12-13 01:57:28 UTC (rev 55) @@ -1,98 +0,0 @@ -<!-- - #%L - Tutti :: UI - $Id$ - $HeadURL$ - %% - Copyright (C) 2012 Ifremer - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> -<JPanel id='homePanel' layout='{new BorderLayout()}' - implements='fr.ifremer.tutti.ui.swing.TuttiUI<AccidentelTabUIModel, AccidentelTabUIHandler>'> - - <import> - fr.ifremer.tutti.persistence.entities.data.FishingOperation - - fr.ifremer.tutti.ui.swing.TuttiUIContext - fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI - - jaxx.runtime.swing.editor.NumberEditor - - jaxx.runtime.validator.swing.SwingValidatorUtil - jaxx.runtime.validator.swing.SwingValidatorMessageTableModel - - javax.swing.table.TableModel - javax.swing.table.TableColumnModel - - static org.nuiton.i18n.I18n._ - </import> - - <script><![CDATA[ - -public AccidentelTabUI(FishingOperationsUI parentUI) { - AccidentelTabUIHandler handler = new AccidentelTabUIHandler(parentUI, this); - setContextValue(handler); - handler.beforeInitUI(); -} - -public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); } - -protected void $afterCompleteSetup() { handler.afterInitUI(); } - ]]></script> - - <AccidentelTabUIHandler id='handler' - initializer='getContextValue(AccidentelTabUIHandler.class)'/> - - <AccidentelTabUIModel id='model' - initializer='getContextValue(AccidentelTabUIModel.class)'/> - - <SwingValidatorMessageTableModel id='errorTableModel'/> - - <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' - uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> - <field name='totalWeight' component='totalWeightField'/> - <field name='sampleTotalWeight' component='sampleTotalWeightField'/> - </BeanValidator> - - <Table id='form' fill='both' constraints='BorderLayout.NORTH'> - - <!-- Poids total --> - <row> - <cell anchor='west'> - <JLabel id='totalWeightLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='totalWeightField' constructorParams='this'/> - </cell> - </row> - - <!-- Poids total échantillonné --> - <row> - <cell> - <JLabel id='sampleTotalWeightLabel'/> - </cell> - <cell> - <NumberEditor id='sampleTotalWeightField' constructorParams='this'/> - </cell> - </row> - </Table> - - <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> - <JTable id='table'/> - </JScrollPane> - -</JPanel> \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIHandler.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIHandler.java 2012-12-13 01:57:28 UTC (rev 55) @@ -1,182 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.accidental; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.data.AccidentelBatch; -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; -import fr.ifremer.tutti.persistence.entities.referential.Species; -import fr.ifremer.tutti.service.PersistenceService; -import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; -import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; -import jaxx.runtime.SwingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.JComboBox; -import javax.swing.JTable; -import javax.swing.table.DefaultTableColumnModel; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.List; - -import static org.nuiton.i18n.I18n._; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class AccidentelTabUIHandler extends AbstractTuttiUIHandler<AccidentelTabUIModel> { - - /** Logger. */ - private static final Log log = LogFactory.getLog(AccidentelTabUIHandler.class); - - private final AccidentelTabUI ui; - - private final FishingOperationsUI parentUi; - - private final PersistenceService persistenceService; - - public AccidentelTabUIHandler(FishingOperationsUI parentUi, AccidentelTabUI ui) { - super(parentUi.getHandler().getContext()); - this.ui = ui; - this.parentUi = parentUi; - this.persistenceService = context.getService(PersistenceService.class); - } - - @Override - public void beforeInitUI() { - - AccidentelTabUIModel model = new AccidentelTabUIModel(); - ui.setContextValue(model); - - JTable tb = new JTable(); - - TableCellEditor defaultEditor = tb.getDefaultEditor(String.class); - TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class); - - // prepare the table column model - TableColumnModel columnModel = new DefaultTableColumnModel(); - - TableColumn col; - - // species (by code) column - - col = new TableColumn(0); - - JComboBox speciesEditor = new JComboBox(); - List<Species> allSpecies = persistenceService.getAllSpecies(); - SwingUtil.fillComboBox(speciesEditor, allSpecies, null); -// col.setCellEditor(); -// col.setCellRenderer(newTableCellRender(Species.class)); - col.setHeaderValue(_("tutti.table.captureAccidentel.header.speciesByCode")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("speciesByCode"); - columnModel.addColumn(col); - - // Poids observé - col = new TableColumn(1); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.captureAccidentel.header.weight")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("weight"); - columnModel.addColumn(col); - - // Nombre observé - col = new TableColumn(2); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.captureAccidentel.header.number")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("computedNumber"); - columnModel.addColumn(col); - - ui.setContextValue(columnModel); - - final AccidentelTableModel tableModel = new AccidentelTableModel(columnModel); - ui.setContextValue(tableModel); - - model.addPropertyChangeListener(AccidentelTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - tableModel.setData((List<SpeciesBatch>) evt.getNewValue()); - } - }); - - } - - @Override - public void afterInitUI() { - AccidentelTabUIModel model = ui.getModel(); - - initUI(ui); - } - - @Override - public void onCloseUI() { - } - - @Override - protected AccidentelTabUIModel getModel() { - return ui.getModel(); - } - - public void selectFishingOperation(FishingOperation bean) { - - boolean empty = bean == null; - - AccidentelTabUIModel model = ui.getModel(); - - List<AccidentelBatch> catches; - - if (empty) { - catches = null; - bean = new FishingOperation(); - } else { - catches = persistenceService.getAllAccidentelBatch(bean.getId()); - } - - model.fromBean(bean); - model.setCatches(catches); - } - - public void cancel() { - - if (log.isInfoEnabled()) { - log.info("Cancel edition"); - } - } - - public void save() { - if (log.isInfoEnabled()) { - log.info("Will save"); - } - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIModel.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -1,95 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.accidental; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.data.AccidentelBatch; -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import org.jdesktop.beans.AbstractSerializableBean; -import org.nuiton.util.beans.BinderFactory; - -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class AccidentelTabUIModel extends AbstractSerializableBean { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; - - public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight"; - - public static final String PROPERTY_CATCHES = "catches"; - - protected Float totalWeight; - - protected Float sampleTotalWeight; - - protected List<AccidentelBatch> catches; - - public Float getTotalWeight() { - return totalWeight; - } - - public void setTotalWeight(Float totalWeight) { - Object oldValue = getTotalWeight(); - this.totalWeight = totalWeight; - firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); - } - - public Float getSampleTotalWeight() { - return sampleTotalWeight; - } - - public void setSampleTotalWeight(Float sampleTotalWeight) { - Object oldValue = getSampleTotalWeight(); - this.sampleTotalWeight = sampleTotalWeight; - firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight); - } - - public List<AccidentelBatch> getCatches() { - return catches; - } - - public void setCatches(List<AccidentelBatch> catches) { - Object oldValue = getCatches(); - this.catches = catches; - firePropertyChange(PROPERTY_CATCHES, oldValue, catches); - } - - public void fromBean(FishingOperation bean) { - BinderFactory.newBinder(FishingOperation.class, - AccidentelTabUIModel.class).copy(bean, this); - } - - public FishingOperation toBean() { - FishingOperation result = new FishingOperation(); - BinderFactory.newBinder(AccidentelTabUIModel.class, - FishingOperation.class).copy(this, result); - return result; - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTableModel.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTableModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -1,78 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.accidental; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.common.collect.Lists; -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; - -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableColumnModel; -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class AccidentelTableModel extends AbstractTableModel { - - private static final long serialVersionUID = 1L; - - protected List<SpeciesBatch> data; - - protected final TableColumnModel columnModel; - - public AccidentelTableModel(TableColumnModel columnModel) { - this.columnModel = columnModel; - } - - public void setData(List<SpeciesBatch> data) { - if (data == null) { - data = Lists.newArrayList(); - data.add(new SpeciesBatch()); - } - this.data = data; - fireTableDataChanged(); - } - - @Override - public int getRowCount() { - return data == null ? 0 : data.size(); - } - - @Override - public int getColumnCount() { - return columnModel.getColumnCount(); - } - - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - return null; - } - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return true; - } -} \ No newline at end of file Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchRowModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchRowModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,173 @@ +package fr.ifremer.tutti.ui.swing.content.operation.benthos; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +/** + * Define a benthos batch row. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<BenthosBatch, BenthosBatchRowModel> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_SPECIES = "species"; + + public static final String PROPERTY_SPECIES_TO_CONFIRM = "speciesToConfirm"; + + public static final String PROPERTY_WEIGHT = "weight"; + + public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight"; + + public static final String PROPERTY_SAMPLING_RATIO = "samplingRatio"; + + public static final String PROPERTY_COMMENT = "comment"; + + /** + * Species observed. + * + * @since 0.2 + */ + protected Species species; + + /** + * Is the species need to be confirmed?. + * + * @since 0.2 + */ + protected boolean speciesToConfirm; + + /** + * Observed weight. + * + * @since 0.2 + */ + protected Float weight; + + /** + * Sample weight. + * + * @since 0.2 + */ + protected Float sampleWeight; + + /** + * Sampling ratio. + * + * @since 0.2 + */ + protected Float samplingRatio; + + /** + * Comment on this catches. + * + * @since 0.2 + */ + protected String comment; + + protected static final Binder<BenthosBatch, BenthosBatchRowModel> fromBeanBinder = + BinderFactory.newBinder(BenthosBatch.class, + BenthosBatchRowModel.class); + + protected static final Binder<BenthosBatchRowModel, BenthosBatch> toBeanBinder = + BinderFactory.newBinder(BenthosBatchRowModel.class, + BenthosBatch.class); + + public BenthosBatchRowModel() { + super(BenthosBatch.class, fromBeanBinder, toBeanBinder); + } + + public BenthosBatchRowModel(BenthosBatch aBatch) { + this(); + fromBean(aBatch); + } + + public Species getSpecies() { + return species; + } + + public void setSpecies(Species species) { + Object oldValue = getSpecies(); + this.species = species; + firePropertyChange(PROPERTY_SPECIES, oldValue, species); + } + + public Boolean getSpeciesToConfirm() { + return speciesToConfirm; + } + + public void setSpeciesToConfirm(Boolean speciesToConfirm) { + Object oldValue = getSpeciesToConfirm(); + this.speciesToConfirm = speciesToConfirm; + firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm); + } + + public Float getWeight() { + return weight; + } + + public void setWeight(Float weight) { + Object oldValue = getWeight(); + this.weight = weight; + firePropertyChange(PROPERTY_WEIGHT, oldValue, weight); + } + + public Float getSampleWeight() { + return sampleWeight; + } + + public void setSampleWeight(Float sampleWeight) { + Object oldValue = getSampleWeight(); + this.sampleWeight = sampleWeight; + firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight); + } + + public Float getSamplingRatio() { + return samplingRatio; + } + + public void setSamplingRatio(Float samplingRatio) { + Object oldValue = getSamplingRatio(); + this.samplingRatio = samplingRatio; + firePropertyChange(PROPERTY_SAMPLING_RATIO, oldValue, samplingRatio); + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + Object oldValue = getComment(); + this.comment = comment; + firePropertyChange(PROPERTY_COMMENT, oldValue, comment); + } +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchRowModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchTableModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchTableModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,147 @@ +package fr.ifremer.tutti.ui.swing.content.operation.benthos; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; + +import javax.swing.table.TableColumnModel; +import java.util.Set; + +import static org.nuiton.i18n.I18n.n_; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class BenthosBatchTableModel extends AbstractTuttiTableModel<BenthosBatchRowModel> { + + private static final long serialVersionUID = 1L; + + public static final ColumnIdentifier<BenthosBatchRowModel> SPECIES_TO_CONFIRM = ColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM, + n_("tutti.table.benthos.batch.header.toConfirm"), + n_("tutti.table.benthos.batch.header.toConfirm")); + + public static final ColumnIdentifier<BenthosBatchRowModel> SPECIES_BY_CODE = ColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_SPECIES, + n_("tutti.table.benthos.batch.header.speciesByCode"), + n_("tutti.table.benthos.batch.header.speciesByCode")); + + public static final ColumnIdentifier<BenthosBatchRowModel> SPECIES_BY_GENUS_CODE = ColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_SPECIES, + n_("tutti.table.benthos.batch.header.speciesByGenusCode"), + n_("tutti.table.benthos.batch.header.speciesByGenusCode")); + + public static final ColumnIdentifier<BenthosBatchRowModel> WEIGHT = ColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_WEIGHT, + n_("tutti.table.benthos.batch.header.weight"), + n_("tutti.table.benthos.batch.header.weight")); + + public static final ColumnIdentifier<BenthosBatchRowModel> SAMPLE_WEIGHT = ColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT, + n_("tutti.table.benthos.batch.header.sampleWeight"), + n_("tutti.table.benthos.batch.header.sampleWeight")); + + public static final ColumnIdentifier<BenthosBatchRowModel> SAMPLING_RATIO = ColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_SAMPLING_RATIO, + n_("tutti.table.benthos.batch.header.elevationRate"), + n_("tutti.table.benthos.batch.header.elevationRate")); + + public static final ColumnIdentifier<BenthosBatchRowModel> COMMENT = ColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_COMMENT, + n_("tutti.table.benthos.batch.header.comment"), + n_("tutti.table.benthos.batch.header.comment")); + + public static final ColumnIdentifier<BenthosBatchRowModel> FILE = ColumnIdentifier.newId( + null, + n_("tutti.table.benthos.batch.header.file"), + n_("tutti.table.benthos.batch.header.file")); + + + public BenthosBatchTableModel(TableColumnModel columnModel) { + super(columnModel); + + setNoneEditableCols( + SAMPLE_WEIGHT, + SAMPLING_RATIO, + FILE + ); + } + + @Override + protected BenthosBatchRowModel createNewRow() { + BenthosBatchRowModel result = new BenthosBatchRowModel(); + + // by default empty row is not valid + result.setValid(false); + return result; + } + + @Override + public void setValueAt(Object aValue, + int rowIndex, + int columnIndex, + ColumnIdentifier<BenthosBatchRowModel> propertyName, + BenthosBatchRowModel entry) { + super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry); + + if (propertyName == SPECIES_BY_CODE) { + + // update also other columns + fireTableCellUpdated(rowIndex, + SPECIES_BY_GENUS_CODE); + + } else if (propertyName == SPECIES_BY_GENUS_CODE) { + + // update also other columns + fireTableCellUpdated(rowIndex, + SPECIES_BY_CODE); + } + } + + public void updateSamplingRatio(Set<BenthosBatchRowModel> rows) { + for (BenthosBatchRowModel row : rows) { + int rowIndex = getRows().indexOf(row); + fireTableCellUpdated(rowIndex, + SAMPLE_WEIGHT, + SAMPLING_RATIO); + } + + + } + + @Override + protected boolean isCellEditable(int rowIndex, + int columnIndex, + ColumnIdentifier<BenthosBatchRowModel> propertyName) { + + boolean result = super.isCellEditable(rowIndex, + columnIndex, + propertyName); + + return result; + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchTableModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.css (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.css 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,61 @@ +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +NumberEditor { + autoPopup: {handler.getConfig().isAutoPopupNumberEditor()}; + showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; + bean: {model}; + showReset: true; +} + +#totalWeightLabel { + text: "tutti.label.benthos.totalWeight"; + labelFor: {totalWeightField}; +} + +#totalWeightField { + property: "totalWeight"; + model: {model.getTotalWeight()}; + useFloat: false; + numberPattern: {INT_6_DIGITS_PATTERN}; +} + +#sampleTotalWeightLabel { + text: "tutti.label.benthos.sampleTotalWeight"; + labelFor: {totalWeightField}; +} + +#sampleTotalWeightField { + property: "sampleTotalWeight"; + model: {model.getSampleTotalWeight()}; + useFloat: false; + numberPattern: {INT_6_DIGITS_PATTERN}; +} + +#table { + selectionMode: {ListSelectionModel.SINGLE_SELECTION}; + selectionBackground: {null}; + selectionForeground: {Color.BLACK}; + sortable: false; +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.jaxx (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.jaxx 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,101 @@ +<!-- + #%L + Tutti :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 Ifremer + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JPanel id='homePanel' layout='{new BorderLayout()}' + implements='fr.ifremer.tutti.ui.swing.TuttiUI<BenthosBatchUIModel, BenthosBatchUIHandler>'> + + <import> + fr.ifremer.tutti.persistence.entities.data.FishingOperation + + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI + + jaxx.runtime.swing.editor.NumberEditor + + jaxx.runtime.validator.swing.SwingValidatorUtil + jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + + org.jdesktop.swingx.JXTable + + javax.swing.ListSelectionModel + + java.awt.Color + + static org.nuiton.i18n.I18n._ + </import> + + <script><![CDATA[ + +public BenthosBatchUI(FishingOperationsUI parentUI) { + BenthosBatchUIHandler handler = new BenthosBatchUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); } + +protected void $afterCompleteSetup() { handler.afterInitUI(); } + ]]></script> + + <BenthosBatchUIHandler id='handler' + initializer='getContextValue(BenthosBatchUIHandler.class)'/> + + <BenthosBatchUIModel id='model' + initializer='getContextValue(BenthosBatchUIModel.class)'/> + + <SwingValidatorMessageTableModel id='errorTableModel'/> + + <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' + uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> + <field name='totalWeight' component='totalWeightField'/> + <field name='sampleTotalWeight' component='sampleTotalWeightField'/> + </BeanValidator> + + <Table id='form' fill='both' constraints='BorderLayout.NORTH'> + + <!-- Poids total --> + <row> + <cell anchor='west'> + <JLabel id='totalWeightLabel'/> + </cell> + <cell weightx='1.0'> + <NumberEditor id='totalWeightField' constructorParams='this'/> + </cell> + </row> + + <!-- Poids total échantillonné --> + <row> + <cell> + <JLabel id='sampleTotalWeightLabel'/> + </cell> + <cell> + <NumberEditor id='sampleTotalWeightField' constructorParams='this'/> + </cell> + </row> + </Table> + + <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> + <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event);'/> + </JScrollPane> + +</JPanel> Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIHandler.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIHandler.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,496 @@ +package fr.ifremer.tutti.ui.swing.content.operation.benthos; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.DecoratorService; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.TuttiUI; +import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; +import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; +import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; +import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener; +import jaxx.runtime.SwingUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.ComponentAdapter; +import org.jdesktop.swingx.decorator.HighlightPredicate; +import org.jdesktop.swingx.decorator.Highlighter; +import org.jdesktop.swingx.table.DefaultTableColumnModelExt; +import org.nuiton.util.decorator.Decorator; + +import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableColumnModel; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.FocusEvent; +import java.util.List; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class BenthosBatchUIHandler extends AbstractTuttiTableUIHandler<BenthosBatchRowModel, BenthosBatchUIModel> { + + /** Logger. */ + private static final Log log = LogFactory.getLog(BenthosBatchUIHandler.class); + + /** + * UI. + * + * @since 0.2 + */ + private final BenthosBatchUI ui; + + /** + * Persistence service. + * + * @since 0.2 + */ + private final PersistenceService persistenceService; + + /** + * To monitor changes on the fishing operation. + * + * @since 0.2 + */ + private final TuttiBeanMonitor<BenthosBatchUIModel> fishingOperationMonitor; + + public BenthosBatchUIHandler(FishingOperationsUI parentUi, BenthosBatchUI ui) { + super(parentUi.getHandler().getContext(), + BenthosBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM, + BenthosBatchRowModel.PROPERTY_SPECIES, + BenthosBatchRowModel.PROPERTY_WEIGHT, + BenthosBatchRowModel.PROPERTY_COMMENT); + this.ui = ui; + this.persistenceService = context.getService(PersistenceService.class); + this.fishingOperationMonitor = new TuttiBeanMonitor<BenthosBatchUIModel>( + BenthosBatchUIModel.PROPERTY_TOTAL_WEIGHT, + BenthosBatchUIModel.PROPERTY_SAMPLE_TOTAL_WEIGHT + ); + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiTableUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + protected BenthosBatchUIModel getModel() { + return ui.getModel(); + } + + @Override + protected BenthosBatchTableModel getTableModel() { + return (BenthosBatchTableModel) getTable().getModel(); + } + + @Override + protected JXTable getTable() { + return ui.getTable(); + } + + @Override + protected String[] getRowPropertiesToIgnore() { + return new String[]{ + BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT, + BenthosBatchRowModel.PROPERTY_SAMPLING_RATIO + }; + } + + @Override + protected TableColumnModel createTableColumnModel() { + + DefaultTableColumnModelExt columnModel = + new DefaultTableColumnModelExt(); + + { + // Species to confirm column + + addBooleanColumnToModel(columnModel, + BenthosBatchTableModel.SPECIES_TO_CONFIRM, + getTable()); + } + + List<Species> allSpecies = persistenceService.getAllSpecies(); + + { + // Species (by code) column + + Decorator<Species> decorator = getDecorator( + Species.class, DecoratorService.SPECIES_BY_CODE); + + addComboDataColumnToModel(columnModel, + BenthosBatchTableModel.SPECIES_BY_CODE, + decorator, allSpecies); + } + + { + // Species (by genusCode) column + + Decorator<Species> decorator = getDecorator( + Species.class, DecoratorService.SPECIES_BY_GENUS); + + addComboDataColumnToModel(columnModel, + BenthosBatchTableModel.SPECIES_BY_GENUS_CODE, + decorator, allSpecies); + + } + + { // Weight column + + addFloatColumnToModel(columnModel, + BenthosBatchTableModel.WEIGHT, + TuttiUI.DECIMAL3_PATTERN); + } + + { // Sample weight column + + addColumnToModel(columnModel, + BenthosBatchTableModel.SAMPLE_WEIGHT); + } + + { // SamplingRatio column + + addColumnToModel(columnModel, + BenthosBatchTableModel.SAMPLING_RATIO); + } + + { // Comment column + + addColumnToModel(columnModel, + BenthosBatchTableModel.COMMENT); + } + + { // File column + + addColumnToModel(columnModel, + BenthosBatchTableModel.FILE); + } + return columnModel; + } + + @Override + protected void onRowModified(BenthosBatchRowModel row, + String propertyName, + Object oldValue, + Object newValue) { + + boolean wasValid = row.isValid(); + + boolean valid = isRowValid(row); + + if (log.isInfoEnabled()) { + log.info("Was valid / Is valid: " + wasValid + " / " + valid); + } + row.setValid(valid); + } + + @Override + protected void onRowValidStateChanged(BenthosBatchRowModel row, + Boolean oldValue, + Boolean newValue) { + int rowIndex = getTableModel().getRowIndex(row); + + if (rowIndex > -1) { + getTableModel().fireTableRowsUpdated(rowIndex, rowIndex); + } + } + + @Override + protected void onRowModifyStateChanged(BenthosBatchRowModel row, + Boolean oldValue, + Boolean newValue) { + } + + @Override + protected void onModelRowsChanged(List<BenthosBatchRowModel> rows) { + super.onModelRowsChanged(rows); + + // set valid flag + for (BenthosBatchRowModel row : rows) { + boolean valid = isRowValid(row); + row.setValid(valid); + } + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public void beforeInitUI() { + + if (log.isInfoEnabled()) { + log.info("beforeInit: " + ui); + } + + BenthosBatchUIModel model = new BenthosBatchUIModel(); + ui.setContextValue(model); + + fishingOperationMonitor.setBean(model); + } + + @Override + public void afterInitUI() { + + if (log.isInfoEnabled()) { + log.info("afterInit: " + ui); + } + + initUI(ui); + + JXTable table = getTable(); + + // create table column model + TableColumnModel columnModel = createTableColumnModel(); + + // create table model + BenthosBatchTableModel tableModel = + new BenthosBatchTableModel(columnModel); + + table.setModel(tableModel); + table.setColumnModel(columnModel); + installTableKeyListener(columnModel, table); + + table.getTableHeader().setReorderingAllowed(false); + + + Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY); + + table.addHighlighter(readOnlyHighlighter); + Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { + + boolean result = false; + if (adapter.isEditable()) { + int rowIndex = adapter.convertRowIndexToModel(adapter.row); + BenthosBatchRowModel row = getTableModel().getEntry(rowIndex); + result = !row.isValid(); + } + return result; + } + }), Color.RED); + table.addHighlighter(validHighlighter); + + // when model datas change let's propagate it table model + listenRowsFromModel(); + + // save when row chaged and was modified + ListSelectionListener listener = new TableRowModificationListener<BenthosBatchRowModel>( + getTableModel(), getRowMonitor()) { + @Override + protected void saveSelectedRow() { + saveSelectedRowIfRequired(); + } + }; + table.getSelectionModel().addListSelectionListener(listener); + + // always scroll to selected row + SwingUtil.scrollToTableSelection(getTable()); + } + + @Override + public void onCloseUI() { + if (log.isInfoEnabled()) { + log.info("closing: " + ui); + } + } + + //------------------------------------------------------------------------// + //-- Public methods --// + //------------------------------------------------------------------------// + + public void saveSelectedRowIfRequired(FocusEvent event) { + + Component oppositeComponent = event.getOppositeComponent(); + + JXTable parentContainer = null; + + if (oppositeComponent != null) { + + // check out if still on table + parentContainer = SwingUtil.getParentContainer( + oppositeComponent, JXTable.class); + } + + if (parentContainer == null) { + + // out of the table can save + if (getModel().getFishingOperation() != null) { + saveSelectedRowIfRequired(); + } + } + } + + public void selectFishingOperation(FishingOperation bean) { + + JXTable table = getTable(); + + if (table.isEditing()) { + + // make sure to stop editor + table.editingCanceled(null); + } + + if (fishingOperationMonitor.wasModified()) { + + // previous fishingOperation was modified, let's save it + BenthosBatchUIModel beanToSave = fishingOperationMonitor.getBean(); + + FishingOperation fishingOperation = beanToSave.toBean(); + + if (log.isInfoEnabled()) { + log.info("FishingOperation " + fishingOperation.getId() + + " was modified, will save it."); + } + + persistenceService.saveFishingOperation(fishingOperation); + } + + // make sure selection is empty (will remove bean from monitor) + table.clearSelection(); + + boolean empty = bean == null; + + BenthosBatchUIModel model = getModel(); + + List<BenthosBatchRowModel> rows; + + if (empty) { + rows = null; + bean = new FishingOperation(); + model.setFishingOperation(null); + } else { + + if (log.isInfoEnabled()) { + log.info("Get species batch for fishingOperation: " + bean.getId()); + } + rows = Lists.newArrayList(); + + if (!TuttiEntities.isNew(bean)) { + List<BenthosBatch> catches = + persistenceService.getAllBenthosBatch(bean.getId()); + for (BenthosBatch aBatch : catches) { + BenthosBatchRowModel entry = + new BenthosBatchRowModel(aBatch); + rows.add(entry); + } + } + model.setFishingOperation(bean); + } + + model.fromBean(bean); + model.setRows(rows); + + fishingOperationMonitor.clearModified(); + } + + public void cancel() { + + if (log.isInfoEnabled()) { + log.info("Cancel edition"); + } + } + + public void save() { + if (log.isInfoEnabled()) { + log.info("Will save"); + } + } + + //------------------------------------------------------------------------// + //-- Internal methods --// + //------------------------------------------------------------------------// + + protected boolean isRowValid(BenthosBatchRowModel row) { + boolean result = row.getSpecies() != null && row.getWeight() != null; + return result; + } + + protected void saveSelectedRowIfRequired() { + + TuttiBeanMonitor<BenthosBatchRowModel> rowMonitor = getRowMonitor(); + + BenthosBatchRowModel bean = rowMonitor.getBean(); + if (bean != null) { + + if (bean.isValid()) { + // there is a valid bean attached to the monitor + + if (rowMonitor.wasModified()) { + + // monitored bean was modified, save it + if (log.isInfoEnabled()) { + log.info("Row " + bean + " was modified, will save it"); + } + + saveRow(bean); + + // clear modified flag on the monitor + rowMonitor.clearModified(); + } + } else { + + // row is not valid can not save it + + BenthosBatch catchBean = bean.toBean(); + + if (!TuttiEntities.isNew(catchBean)) { + + // remove this + persistenceService.deleteBenthosBatch(catchBean.getId()); + } + } + } + } + + protected void saveRow(BenthosBatchRowModel row) { + + BenthosBatch catchBean = row.toBean(); + + FishingOperation fishingOperation = getModel().getFishingOperation(); + catchBean.setFishingOperation(fishingOperation); + if (log.isInfoEnabled()) { + log.info("Selected fishingOperation: " + fishingOperation.getId()); + } + + if (TuttiEntities.isNew(catchBean)) { + + catchBean = persistenceService.createBenthosBatch(catchBean); + row.setId(catchBean.getId()); + } else { + persistenceService.saveBenthosBatch(catchBean); + } + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,113 @@ +package fr.ifremer.tutti.ui.swing.content.operation.benthos; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderModelBuilder; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class BenthosBatchUIModel extends AbstractTuttiTableUIModel<FishingOperation, BenthosBatchRowModel, BenthosBatchUIModel> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; + + public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight"; + + /** + * Editing fishing operation. + * + * @since 0.2 + */ + protected FishingOperation fishingOperation; + + /** + * Total Weight filled in screen. + * + * @since 0.2 + */ + protected Float totalWeight; + + /** + * Total Sample Weight filled in screen. + * + * @since 0.2 + */ + protected Float sampleTotalWeight; + + protected static final Binder<FishingOperation, BenthosBatchUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, BenthosBatchUIModel.class) + .addProperty(FishingOperation.PROPERTY_BENTHOS_TOTAL_WEIGHT, PROPERTY_TOTAL_WEIGHT) + .addProperty(FishingOperation.PROPERTY_BENTHOS_SAMPLE_TOTAL_WEIGHT, PROPERTY_SAMPLE_TOTAL_WEIGHT) + .addProperty(FishingOperation.PROPERTY_ID, PROPERTY_ID) + .toBinder(); + + protected static final Binder<BenthosBatchUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(BenthosBatchUIModel.class, FishingOperation.class) + .addProperty(PROPERTY_TOTAL_WEIGHT, FishingOperation.PROPERTY_BENTHOS_TOTAL_WEIGHT) + .addProperty(PROPERTY_SAMPLE_TOTAL_WEIGHT, FishingOperation.PROPERTY_BENTHOS_SAMPLE_TOTAL_WEIGHT) + .toBinder(); + + + public BenthosBatchUIModel() { + super(FishingOperation.class, fromBeanBinder, toBeanBinder); + } + + public FishingOperation getFishingOperation() { + return fishingOperation; + } + + public void setFishingOperation(FishingOperation fishingOperation) { + this.fishingOperation = fishingOperation; + } + + public Float getTotalWeight() { + return totalWeight; + } + + public void setTotalWeight(Float totalWeight) { + Object oldValue = getTotalWeight(); + this.totalWeight = totalWeight; + firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); + } + + public Float getSampleTotalWeight() { + return sampleTotalWeight; + } + + public void setSampleTotalWeight(Float sampleTotalWeight) { + Object oldValue = getSampleTotalWeight(); + this.sampleTotalWeight = sampleTotalWeight; + firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight); + } + + @Override + protected FishingOperation newEntity() { + return fishingOperation; + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosBatchUIModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.css 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.css 2012-12-13 01:57:28 UTC (rev 55) @@ -1,59 +0,0 @@ -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -NumberEditor { - autoPopup:{handler.getConfig().isAutoPopupNumberEditor()}; - showPopupButton:{handler.getConfig().isShowNumberEditorButton()}; - bean:{model}; - showReset:true; -} - -#totalWeightLabel { - text:"tutti.label.benthos.totalWeight"; - labelFor:{totalWeightField}; -} - -#totalWeightField { - property:"totalWeight"; - model:{model.getTotalWeight()}; - useFloat:false; - numberPattern:{INT_6_DIGITS_PATTERN}; -} - -#sampleTotalWeightLabel { - text:"tutti.label.benthos.sampleTotalWeight"; - labelFor:{totalWeightField}; -} - -#sampleTotalWeightField { - property:"sampleTotalWeight"; - model:{model.getSampleTotalWeight()}; - useFloat:false; - numberPattern:{INT_6_DIGITS_PATTERN}; -} - -#table { - model:{getContextValue(TableModel.class)}; - columnModel:{getContextValue(TableColumnModel.class)}; -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.jaxx 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.jaxx 2012-12-13 01:57:28 UTC (rev 55) @@ -1,98 +0,0 @@ -<!-- - #%L - Tutti :: UI - $Id$ - $HeadURL$ - %% - Copyright (C) 2012 Ifremer - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> -<JPanel id='homePanel' layout='{new BorderLayout()}' - implements='fr.ifremer.tutti.ui.swing.TuttiUI<BenthosTabUIModel, BenthosTabUIHandler>'> - - <import> - fr.ifremer.tutti.persistence.entities.data.FishingOperation - - fr.ifremer.tutti.ui.swing.TuttiUIContext - fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI - - jaxx.runtime.swing.editor.NumberEditor - - jaxx.runtime.validator.swing.SwingValidatorUtil - jaxx.runtime.validator.swing.SwingValidatorMessageTableModel - - javax.swing.table.TableModel - javax.swing.table.TableColumnModel - - static org.nuiton.i18n.I18n._ - </import> - - <script><![CDATA[ - -public BenthosTabUI(FishingOperationsUI parentUI) { - BenthosTabUIHandler handler = new BenthosTabUIHandler(parentUI, this); - setContextValue(handler); - handler.beforeInitUI(); -} - -public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); } - -protected void $afterCompleteSetup() { handler.afterInitUI(); } - ]]></script> - - <BenthosTabUIHandler id='handler' - initializer='getContextValue(BenthosTabUIHandler.class)'/> - - <BenthosTabUIModel id='model' - initializer='getContextValue(BenthosTabUIModel.class)'/> - - <SwingValidatorMessageTableModel id='errorTableModel'/> - - <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' - uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> - <field name='totalWeight' component='totalWeightField'/> - <field name='sampleTotalWeight' component='sampleTotalWeightField'/> - </BeanValidator> - - <Table id='form' fill='both' constraints='BorderLayout.NORTH'> - - <!-- Poids total --> - <row> - <cell anchor='west'> - <JLabel id='totalWeightLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='totalWeightField' constructorParams='this'/> - </cell> - </row> - - <!-- Poids total échantillonné --> - <row> - <cell> - <JLabel id='sampleTotalWeightLabel'/> - </cell> - <cell> - <NumberEditor id='sampleTotalWeightField' constructorParams='this'/> - </cell> - </row> - </Table> - - <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> - <JTable id='table'/> - </JScrollPane> - -</JPanel> Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIHandler.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIHandler.java 2012-12-13 01:57:28 UTC (rev 55) @@ -1,182 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.benthos; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; -import fr.ifremer.tutti.persistence.entities.referential.Species; -import fr.ifremer.tutti.service.PersistenceService; -import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; -import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; -import jaxx.runtime.SwingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.JComboBox; -import javax.swing.JTable; -import javax.swing.table.DefaultTableColumnModel; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.List; - -import static org.nuiton.i18n.I18n._; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.1 - */ -public class BenthosTabUIHandler extends AbstractTuttiUIHandler<BenthosTabUIModel> { - - /** Logger. */ - private static final Log log = LogFactory.getLog(BenthosTabUIHandler.class); - - private final BenthosTabUI ui; - - private final FishingOperationsUI parentUi; - - private final PersistenceService persistenceService; - - public BenthosTabUIHandler(FishingOperationsUI parentUi, BenthosTabUI ui) { - super(parentUi.getHandler().getContext()); - this.ui = ui; - this.parentUi = parentUi; - this.persistenceService = context.getService(PersistenceService.class); - } - - @Override - public void beforeInitUI() { - - BenthosTabUIModel model = new BenthosTabUIModel(); - ui.setContextValue(model); - - JTable tb = new JTable(); - - TableCellEditor defaultEditor = tb.getDefaultEditor(String.class); - TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class); - - // prepare the table column model - TableColumnModel columnModel = new DefaultTableColumnModel(); - - TableColumn col; - - // species (by code) column - - col = new TableColumn(0); - - JComboBox speciesEditor = new JComboBox(); - List<Species> allSpecies = persistenceService.getAllSpecies(); - SwingUtil.fillComboBox(speciesEditor, allSpecies, null); -// col.setCellEditor(); -// col.setCellRenderer(newTableCellRender(Species.class)); - col.setHeaderValue(_("tutti.table.benthos.header.speciesByCode")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("speciesByCode"); - columnModel.addColumn(col); - - // Poids observé - col = new TableColumn(1); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.benthos.header.weight")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("weight"); - columnModel.addColumn(col); - - // Nombre observé - col = new TableColumn(2); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.benthos.header.number")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("computedNumber"); - columnModel.addColumn(col); - - ui.setContextValue(columnModel); - - final BenthosTableModel tableModel = new BenthosTableModel(columnModel); - ui.setContextValue(tableModel); - - model.addPropertyChangeListener(BenthosTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - tableModel.setData((List<SpeciesBatch>) evt.getNewValue()); - } - }); - - } - - @Override - public void afterInitUI() { - BenthosTabUIModel model = ui.getModel(); - - initUI(ui); - } - - @Override - public void onCloseUI() { - } - - @Override - protected BenthosTabUIModel getModel() { - return ui.getModel(); - } - - public void selectFishingOperation(FishingOperation bean) { - - boolean empty = bean == null; - - BenthosTabUIModel model = ui.getModel(); - - List<BenthosBatch> catches; - - if (empty) { - catches = null; - bean = new FishingOperation(); - } else { - catches = persistenceService.getAllBenthosBatch(bean.getId()); - } - - model.fromBean(bean); - model.setCatches(catches); - } - - public void cancel() { - - if (log.isInfoEnabled()) { - log.info("Cancel edition"); - } - } - - public void save() { - if (log.isInfoEnabled()) { - log.info("Will save"); - } - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIModel.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -1,95 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.benthos; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import org.jdesktop.beans.AbstractSerializableBean; -import org.nuiton.util.beans.BinderFactory; - -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.1 - */ -public class BenthosTabUIModel extends AbstractSerializableBean { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; - - public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight"; - - public static final String PROPERTY_CATCHES = "catches"; - - protected Float totalWeight; - - protected Float sampleTotalWeight; - - protected List<BenthosBatch> catches; - - public Float getTotalWeight() { - return totalWeight; - } - - public void setTotalWeight(Float totalWeight) { - Object oldValue = getTotalWeight(); - this.totalWeight = totalWeight; - firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); - } - - public Float getSampleTotalWeight() { - return sampleTotalWeight; - } - - public void setSampleTotalWeight(Float sampleTotalWeight) { - Object oldValue = getSampleTotalWeight(); - this.sampleTotalWeight = sampleTotalWeight; - firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight); - } - - public List<BenthosBatch> getCatches() { - return catches; - } - - public void setCatches(List<BenthosBatch> catches) { - Object oldValue = getCatches(); - this.catches = catches; - firePropertyChange(PROPERTY_CATCHES, oldValue, catches); - } - - public void fromBean(FishingOperation bean) { - BinderFactory.newBinder(FishingOperation.class, - BenthosTabUIModel.class).copy(bean, this); - } - - public FishingOperation toBean() { - FishingOperation result = new FishingOperation(); - BinderFactory.newBinder(BenthosTabUIModel.class, - FishingOperation.class).copy(this, result); - return result; - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTableModel.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTableModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -1,78 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.benthos; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.common.collect.Lists; -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; - -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableColumnModel; -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.1 - */ -public class BenthosTableModel extends AbstractTableModel { - - private static final long serialVersionUID = 1L; - - protected List<SpeciesBatch> data; - - protected final TableColumnModel columnModel; - - public BenthosTableModel(TableColumnModel columnModel) { - this.columnModel = columnModel; - } - - public void setData(List<SpeciesBatch> data) { - if (data == null) { - data = Lists.newArrayList(); - data.add(new SpeciesBatch()); - } - this.data = data; - fireTableDataChanged(); - } - - @Override - public int getRowCount() { - return data == null ? 0 : data.size(); - } - - @Override - public int getColumnCount() { - return columnModel.getColumnCount(); - } - - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - return null; - } - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return true; - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.css 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.css 2012-12-13 01:57:28 UTC (rev 55) @@ -1,59 +0,0 @@ -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -NumberEditor { - autoPopup:{handler.getConfig().isAutoPopupNumberEditor()}; - showPopupButton:{handler.getConfig().isShowNumberEditorButton()}; - bean:{model}; - showReset:true; -} - -#totalWeightLabel { - text:"tutti.label.macroDechet.totalWeight"; - labelFor:{totalWeightField}; -} - -#totalWeightField { - property:"totalWeight"; - model:{model.getTotalWeight()}; - useFloat:false; - numberPattern:{INT_6_DIGITS_PATTERN}; -} - -#sampleTotalWeightLabel { - text:"tutti.label.macroDechet.sampleTotalWeight"; - labelFor:{totalWeightField}; -} - -#sampleTotalWeightField { - property:"sampleTotalWeight"; - model:{model.getSampleTotalWeight()}; - useFloat:false; - numberPattern:{INT_6_DIGITS_PATTERN}; -} - -#table { - model:{getContextValue(TableModel.class)}; - columnModel:{getContextValue(TableColumnModel.class)}; -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.jaxx 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.jaxx 2012-12-13 01:57:28 UTC (rev 55) @@ -1,98 +0,0 @@ -<!-- - #%L - Tutti :: UI - $Id$ - $HeadURL$ - %% - Copyright (C) 2012 Ifremer - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> -<JPanel id='homePanel' layout='{new BorderLayout()}' - implements='fr.ifremer.tutti.ui.swing.TuttiUI<MacroDechetTabUIModel, MacroDechetTabUIHandler>'> - - <import> - fr.ifremer.tutti.persistence.entities.data.FishingOperation - - fr.ifremer.tutti.ui.swing.TuttiUIContext - fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI - - jaxx.runtime.swing.editor.NumberEditor - - jaxx.runtime.validator.swing.SwingValidatorUtil - jaxx.runtime.validator.swing.SwingValidatorMessageTableModel - - javax.swing.table.TableModel - javax.swing.table.TableColumnModel - - static org.nuiton.i18n.I18n._ - </import> - - <script><![CDATA[ - -public MacroDechetTabUI(FishingOperationsUI parentUI) { - MacroDechetTabUIHandler handler = new MacroDechetTabUIHandler(parentUI, this); - setContextValue(handler); - handler.beforeInitUI(); -} - -public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); } - -protected void $afterCompleteSetup() { handler.afterInitUI(); } - ]]></script> - - <MacroDechetTabUIHandler id='handler' - initializer='getContextValue(MacroDechetTabUIHandler.class)'/> - - <MacroDechetTabUIModel id='model' - initializer='getContextValue(MacroDechetTabUIModel.class)'/> - - <SwingValidatorMessageTableModel id='errorTableModel'/> - - <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' - uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> - <field name='totalWeight' component='totalWeightField'/> - <field name='sampleTotalWeight' component='sampleTotalWeightField'/> - </BeanValidator> - - <Table id='form' fill='both' constraints='BorderLayout.NORTH'> - - <!-- Poids total --> - <row> - <cell anchor='west'> - <JLabel id='totalWeightLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='totalWeightField' constructorParams='this'/> - </cell> - </row> - - <!-- Poids total échantillonné --> - <row> - <cell> - <JLabel id='sampleTotalWeightLabel'/> - </cell> - <cell> - <NumberEditor id='sampleTotalWeightField' constructorParams='this'/> - </cell> - </row> - </Table> - - <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> - <JTable id='table'/> - </JScrollPane> - -</JPanel> \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIHandler.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIHandler.java 2012-12-13 01:57:28 UTC (rev 55) @@ -1,182 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.macrowaste; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.MacroDechetBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; -import fr.ifremer.tutti.persistence.entities.referential.Species; -import fr.ifremer.tutti.service.PersistenceService; -import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; -import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; -import jaxx.runtime.SwingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.JComboBox; -import javax.swing.JTable; -import javax.swing.table.DefaultTableColumnModel; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.List; - -import static org.nuiton.i18n.I18n._; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class MacroDechetTabUIHandler extends AbstractTuttiUIHandler<MacroDechetTabUIModel> { - - /** Logger. */ - private static final Log log = LogFactory.getLog(MacroDechetTabUIHandler.class); - - private final MacroDechetTabUI ui; - - private final FishingOperationsUI parentUi; - - private final PersistenceService persistenceService; - - public MacroDechetTabUIHandler(FishingOperationsUI parentUi, MacroDechetTabUI ui) { - super(parentUi.getHandler().getContext()); - this.ui = ui; - this.parentUi = parentUi; - this.persistenceService = context.getService(PersistenceService.class); - } - - @Override - public void beforeInitUI() { - - MacroDechetTabUIModel model = new MacroDechetTabUIModel(); - ui.setContextValue(model); - - JTable tb = new JTable(); - - TableCellEditor defaultEditor = tb.getDefaultEditor(String.class); - TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class); - - // prepare the table column model - TableColumnModel columnModel = new DefaultTableColumnModel(); - - TableColumn col; - - // species (by code) column - - col = new TableColumn(0); - - JComboBox speciesEditor = new JComboBox(); - List<Species> allSpecies = persistenceService.getAllSpecies(); - SwingUtil.fillComboBox(speciesEditor, allSpecies, null); -// col.setCellEditor(); -// col.setCellRenderer(newTableCellRender(Species.class)); - col.setHeaderValue(_("tutti.table.macroDechet.header.speciesByCode")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("speciesByCode"); - columnModel.addColumn(col); - - // Poids observé - col = new TableColumn(1); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.macroDechet.header.weight")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("weight"); - columnModel.addColumn(col); - - // Nombre observé - col = new TableColumn(2); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.macroDechet.header.number")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("computedNumber"); - columnModel.addColumn(col); - - ui.setContextValue(columnModel); - - final MacroDechetTableModel tableModel = new MacroDechetTableModel(columnModel); - ui.setContextValue(tableModel); - - model.addPropertyChangeListener(MacroDechetTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - tableModel.setData((List<SpeciesBatch>) evt.getNewValue()); - } - }); - - } - - @Override - public void afterInitUI() { - MacroDechetTabUIModel model = ui.getModel(); - - initUI(ui); - } - - @Override - public void onCloseUI() { - } - - @Override - protected MacroDechetTabUIModel getModel() { - return ui.getModel(); - } - - public void selectFishingOperation(FishingOperation bean) { - - boolean empty = bean == null; - - MacroDechetTabUIModel model = ui.getModel(); - - List<MacroDechetBatch> catches; - - if (empty) { - catches = null; - bean = new FishingOperation(); - } else { - catches = persistenceService.getAllMacroDechetBatch(bean.getId()); - } - - model.fromBean(bean); - model.setCatches(catches); - } - - public void cancel() { - - if (log.isInfoEnabled()) { - log.info("Cancel edition"); - } - } - - public void save() { - if (log.isInfoEnabled()) { - log.info("Will save"); - } - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIModel.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -1,95 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.macrowaste; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.MacroDechetBatch; -import org.jdesktop.beans.AbstractSerializableBean; -import org.nuiton.util.beans.BinderFactory; - -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class MacroDechetTabUIModel extends AbstractSerializableBean { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; - - public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight"; - - public static final String PROPERTY_CATCHES = "catches"; - - protected Float totalWeight; - - protected Float sampleTotalWeight; - - protected List<MacroDechetBatch> catches; - - public Float getTotalWeight() { - return totalWeight; - } - - public void setTotalWeight(Float totalWeight) { - Object oldValue = getTotalWeight(); - this.totalWeight = totalWeight; - firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); - } - - public Float getSampleTotalWeight() { - return sampleTotalWeight; - } - - public void setSampleTotalWeight(Float sampleTotalWeight) { - Object oldValue = getSampleTotalWeight(); - this.sampleTotalWeight = sampleTotalWeight; - firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight); - } - - public List<MacroDechetBatch> getCatches() { - return catches; - } - - public void setCatches(List<MacroDechetBatch> catches) { - Object oldValue = getCatches(); - this.catches = catches; - firePropertyChange(PROPERTY_CATCHES, oldValue, catches); - } - - public void fromBean(FishingOperation bean) { - BinderFactory.newBinder(FishingOperation.class, - MacroDechetTabUIModel.class).copy(bean, this); - } - - public FishingOperation toBean() { - FishingOperation result = new FishingOperation(); - BinderFactory.newBinder(MacroDechetTabUIModel.class, - FishingOperation.class).copy(this, result); - return result; - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTableModel.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTableModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -1,78 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.macrowaste; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.common.collect.Lists; -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; - -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableColumnModel; -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class MacroDechetTableModel extends AbstractTableModel { - - private static final long serialVersionUID = 1L; - - protected List<SpeciesBatch> data; - - protected final TableColumnModel columnModel; - - public MacroDechetTableModel(TableColumnModel columnModel) { - this.columnModel = columnModel; - } - - public void setData(List<SpeciesBatch> data) { - if (data == null) { - data = Lists.newArrayList(); - data.add(new SpeciesBatch()); - } - this.data = data; - fireTableDataChanged(); - } - - @Override - public int getRowCount() { - return data == null ? 0 : data.size(); - } - - @Override - public int getColumnCount() { - return columnModel.getColumnCount(); - } - - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - return null; - } - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return true; - } -} \ No newline at end of file Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchRowModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchRowModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,116 @@ +package fr.ifremer.tutti.ui.swing.content.operation.macrowaste; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.MacroWasteBatch; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +/** + * Define a benthos batch row. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class MacroWasteBatchRowModel extends AbstractTuttiBeanUIModel<MacroWasteBatch, MacroWasteBatchRowModel> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_SPECIES = "species"; + + public static final String PROPERTY_WEIGHT = "weight"; + + public static final String PROPERTY_COMMENT = "comment"; + + /** + * Species observed. + * + * @since 0.2 + */ + protected Species species; + + /** + * Observed weight. + * + * @since 0.2 + */ + protected Float weight; + + /** + * Comment on this catches. + * + * @since 0.2 + */ + protected String comment; + + protected static final Binder<MacroWasteBatch, MacroWasteBatchRowModel> fromBeanBinder = + BinderFactory.newBinder(MacroWasteBatch.class, + MacroWasteBatchRowModel.class); + + protected static final Binder<MacroWasteBatchRowModel, MacroWasteBatch> toBeanBinder = + BinderFactory.newBinder(MacroWasteBatchRowModel.class, + MacroWasteBatch.class); + + public MacroWasteBatchRowModel() { + super(MacroWasteBatch.class, fromBeanBinder, toBeanBinder); + } + + public MacroWasteBatchRowModel(MacroWasteBatch aBatch) { + this(); + fromBean(aBatch); + } + + public Species getSpecies() { + return species; + } + + public void setSpecies(Species species) { + Object oldValue = getSpecies(); + this.species = species; + firePropertyChange(PROPERTY_SPECIES, oldValue, species); + } + + public Float getWeight() { + return weight; + } + + public void setWeight(Float weight) { + Object oldValue = getWeight(); + this.weight = weight; + firePropertyChange(PROPERTY_WEIGHT, oldValue, weight); + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + Object oldValue = getComment(); + this.comment = comment; + firePropertyChange(PROPERTY_COMMENT, oldValue, comment); + } +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchRowModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchTableModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchTableModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,104 @@ +package fr.ifremer.tutti.ui.swing.content.operation.macrowaste; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; + +import javax.swing.table.TableColumnModel; + +import static org.nuiton.i18n.I18n.n_; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class MacroWasteBatchTableModel extends AbstractTuttiTableModel<MacroWasteBatchRowModel> { + + private static final long serialVersionUID = 1L; + + public static final ColumnIdentifier<MacroWasteBatchRowModel> SPECIES_BY_CODE = ColumnIdentifier.newId( + MacroWasteBatchRowModel.PROPERTY_SPECIES, + n_("tutti.table.macrowaste.batch.header.speciesByCode"), + n_("tutti.table.macrowaste.batch.header.speciesByCode")); + + public static final ColumnIdentifier<MacroWasteBatchRowModel> SPECIES_BY_GENUS_CODE = ColumnIdentifier.newId( + MacroWasteBatchRowModel.PROPERTY_SPECIES, + n_("tutti.table.macrowaste.batch.header.speciesByGenusCode"), + n_("tutti.table.macrowaste.batch.header.speciesByGenusCode")); + + public static final ColumnIdentifier<MacroWasteBatchRowModel> WEIGHT = ColumnIdentifier.newId( + MacroWasteBatchRowModel.PROPERTY_WEIGHT, + n_("tutti.table.macrowaste.batch.header.weight"), + n_("tutti.table.macrowaste.batch.header.weight")); + + public static final ColumnIdentifier<MacroWasteBatchRowModel> COMMENT = ColumnIdentifier.newId( + MacroWasteBatchRowModel.PROPERTY_COMMENT, + n_("tutti.table.macrowaste.batch.header.comment"), + n_("tutti.table.macrowaste.batch.header.comment")); + + public static final ColumnIdentifier<MacroWasteBatchRowModel> FILE = ColumnIdentifier.newId( + null, + n_("tutti.table.macrowaste.batch.header.file"), + n_("tutti.table.macrowaste.batch.header.file")); + + + public MacroWasteBatchTableModel(TableColumnModel columnModel) { + super(columnModel); + + setNoneEditableCols(FILE); + } + + @Override + protected MacroWasteBatchRowModel createNewRow() { + MacroWasteBatchRowModel result = new MacroWasteBatchRowModel(); + + // by default empty row is not valid + result.setValid(false); + return result; + } + + @Override + public void setValueAt(Object aValue, + int rowIndex, + int columnIndex, + ColumnIdentifier<MacroWasteBatchRowModel> propertyName, + MacroWasteBatchRowModel entry) { + super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry); + + if (propertyName == SPECIES_BY_CODE) { + + // update also other columns + fireTableCellUpdated(rowIndex, + SPECIES_BY_GENUS_CODE); + + } else if (propertyName == SPECIES_BY_GENUS_CODE) { + + // update also other columns + fireTableCellUpdated(rowIndex, + SPECIES_BY_CODE); + } + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchTableModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.css (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.css 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,49 @@ +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +NumberEditor { + autoPopup: {handler.getConfig().isAutoPopupNumberEditor()}; + showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; + bean: {model}; + showReset: true; +} + +#totalWeightLabel { + text: "tutti.label.macroWaste.totalWeight"; + labelFor: {totalWeightField}; +} + +#totalWeightField { + property: "totalWeight"; + model: {model.getTotalWeight()}; + useFloat: false; + numberPattern: {INT_6_DIGITS_PATTERN}; +} + +#table { + selectionMode: {ListSelectionModel.SINGLE_SELECTION}; + selectionBackground: {null}; + selectionForeground: {Color.BLACK}; + sortable: false; +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.jaxx (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.jaxx 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,90 @@ +<!-- + #%L + Tutti :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 Ifremer + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JPanel id='homePanel' layout='{new BorderLayout()}' + implements='fr.ifremer.tutti.ui.swing.TuttiUI<MacroWasteBatchUIModel, MacroWasteBatchUIHandler>'> + + <import> + fr.ifremer.tutti.persistence.entities.data.FishingOperation + + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI + + jaxx.runtime.swing.editor.NumberEditor + + jaxx.runtime.validator.swing.SwingValidatorUtil + jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + + org.jdesktop.swingx.JXTable + + javax.swing.ListSelectionModel + + java.awt.Color + + static org.nuiton.i18n.I18n._ + </import> + + <script><![CDATA[ + +public MacroWasteBatchUI(FishingOperationsUI parentUI) { + MacroWasteBatchUIHandler handler = new MacroWasteBatchUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); } + +protected void $afterCompleteSetup() { handler.afterInitUI(); } + ]]></script> + + <MacroWasteBatchUIHandler id='handler' + initializer='getContextValue(MacroWasteBatchUIHandler.class)'/> + + <MacroWasteBatchUIModel id='model' + initializer='getContextValue(MacroWasteBatchUIModel.class)'/> + + <SwingValidatorMessageTableModel id='errorTableModel'/> + + <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' + uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> + <field name='totalWeight' component='totalWeightField'/> + </BeanValidator> + + <Table id='form' fill='both' constraints='BorderLayout.NORTH'> + + <!-- Poids total --> + <row> + <cell anchor='west'> + <JLabel id='totalWeightLabel'/> + </cell> + <cell weightx='1.0'> + <NumberEditor id='totalWeightField' constructorParams='this'/> + </cell> + </row> + </Table> + + <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> + <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event);'/> + </JScrollPane> + +</JPanel> \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIHandler.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIHandler.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,467 @@ +package fr.ifremer.tutti.ui.swing.content.operation.macrowaste; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.MacroWasteBatch; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.DecoratorService; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.TuttiUI; +import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; +import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; +import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; +import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener; +import jaxx.runtime.SwingUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.ComponentAdapter; +import org.jdesktop.swingx.decorator.HighlightPredicate; +import org.jdesktop.swingx.decorator.Highlighter; +import org.jdesktop.swingx.table.DefaultTableColumnModelExt; +import org.nuiton.util.decorator.Decorator; + +import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableColumnModel; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.FocusEvent; +import java.util.List; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class MacroWasteBatchUIHandler extends AbstractTuttiTableUIHandler<MacroWasteBatchRowModel, MacroWasteBatchUIModel> { + + /** Logger. */ + private static final Log log = LogFactory.getLog(MacroWasteBatchUIHandler.class); + + /** + * UI. + * + * @since 0.2 + */ + private final MacroWasteBatchUI ui; + + /** + * Persistence service. + * + * @since 0.2 + */ + private final PersistenceService persistenceService; + + /** + * To monitor changes on the fishing operation. + * + * @since 0.2 + */ + private final TuttiBeanMonitor<MacroWasteBatchUIModel> fishingOperationMonitor; + + + public MacroWasteBatchUIHandler(FishingOperationsUI parentUi, MacroWasteBatchUI ui) { + super(parentUi.getHandler().getContext(), + MacroWasteBatchRowModel.PROPERTY_SPECIES, + MacroWasteBatchRowModel.PROPERTY_WEIGHT, + MacroWasteBatchRowModel.PROPERTY_COMMENT); + this.ui = ui; + this.persistenceService = context.getService(PersistenceService.class); + this.fishingOperationMonitor = new TuttiBeanMonitor<MacroWasteBatchUIModel>( + MacroWasteBatchUIModel.PROPERTY_TOTAL_WEIGHT + ); + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiTableUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + protected MacroWasteBatchUIModel getModel() { + return ui.getModel(); + } + + @Override + protected MacroWasteBatchTableModel getTableModel() { + return (MacroWasteBatchTableModel) getTable().getModel(); + } + + @Override + protected JXTable getTable() { + return ui.getTable(); + } + + @Override + protected TableColumnModel createTableColumnModel() { + + DefaultTableColumnModelExt columnModel = + new DefaultTableColumnModelExt(); + + List<Species> allSpecies = persistenceService.getAllSpecies(); + + { + // Species (by code) column + + Decorator<Species> decorator = getDecorator( + Species.class, DecoratorService.SPECIES_BY_CODE); + + addComboDataColumnToModel(columnModel, + MacroWasteBatchTableModel.SPECIES_BY_CODE, + decorator, allSpecies); + } + + { + // Species (by genusCode) column + + Decorator<Species> decorator = getDecorator( + Species.class, DecoratorService.SPECIES_BY_GENUS); + + addComboDataColumnToModel(columnModel, + MacroWasteBatchTableModel.SPECIES_BY_GENUS_CODE, + decorator, allSpecies); + + } + + { // Weight column + + addFloatColumnToModel(columnModel, + MacroWasteBatchTableModel.WEIGHT, + TuttiUI.DECIMAL3_PATTERN); + } + + { // Comment column + + addColumnToModel(columnModel, + MacroWasteBatchTableModel.COMMENT); + } + + { // File column + + addColumnToModel(columnModel, + MacroWasteBatchTableModel.FILE); + } + return columnModel; + } + + @Override + protected void onRowModified(MacroWasteBatchRowModel row, + String propertyName, + Object oldValue, + Object newValue) { + + boolean wasValid = row.isValid(); + + boolean valid = isRowValid(row); + + if (log.isInfoEnabled()) { + log.info("Was valid / Is valid: " + wasValid + " / " + valid); + } + row.setValid(valid); + } + + @Override + protected void onRowValidStateChanged(MacroWasteBatchRowModel row, + Boolean oldValue, + Boolean newValue) { + int rowIndex = getTableModel().getRowIndex(row); + + if (rowIndex > -1) { + getTableModel().fireTableRowsUpdated(rowIndex, rowIndex); + } + } + + @Override + protected void onRowModifyStateChanged(MacroWasteBatchRowModel row, + Boolean oldValue, + Boolean newValue) { + } + + @Override + protected void onModelRowsChanged(List<MacroWasteBatchRowModel> rows) { + super.onModelRowsChanged(rows); + + // set valid flag + for (MacroWasteBatchRowModel row : rows) { + boolean valid = isRowValid(row); + row.setValid(valid); + } + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public void beforeInitUI() { + + if (log.isInfoEnabled()) { + log.info("beforeInit: " + ui); + } + + MacroWasteBatchUIModel model = new MacroWasteBatchUIModel(); + ui.setContextValue(model); + + fishingOperationMonitor.setBean(model); + } + + @Override + public void afterInitUI() { + + if (log.isInfoEnabled()) { + log.info("afterInit: " + ui); + } + + initUI(ui); + + JXTable table = getTable(); + + // create table column model + TableColumnModel columnModel = createTableColumnModel(); + + // create table model + MacroWasteBatchTableModel tableModel = + new MacroWasteBatchTableModel(columnModel); + + table.setModel(tableModel); + table.setColumnModel(columnModel); + installTableKeyListener(columnModel, table); + + table.getTableHeader().setReorderingAllowed(false); + + + Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY); + + table.addHighlighter(readOnlyHighlighter); + Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { + + boolean result = false; + if (adapter.isEditable()) { + int rowIndex = adapter.convertRowIndexToModel(adapter.row); + MacroWasteBatchRowModel row = getTableModel().getEntry(rowIndex); + result = !row.isValid(); + } + return result; + } + }), Color.RED); + table.addHighlighter(validHighlighter); + + // when model datas change let's propagate it table model + listenRowsFromModel(); + + // save when row chaged and was modified + ListSelectionListener listener = new TableRowModificationListener<MacroWasteBatchRowModel>( + getTableModel(), getRowMonitor()) { + @Override + protected void saveSelectedRow() { + saveSelectedRowIfRequired(); + } + }; + table.getSelectionModel().addListSelectionListener(listener); + + // always scroll to selected row + SwingUtil.scrollToTableSelection(getTable()); + } + + @Override + public void onCloseUI() { + if (log.isInfoEnabled()) { + log.info("closing: " + ui); + } + } + + //------------------------------------------------------------------------// + //-- Public methods --// + //------------------------------------------------------------------------// + + public void saveSelectedRowIfRequired(FocusEvent event) { + + Component oppositeComponent = event.getOppositeComponent(); + + JXTable parentContainer = null; + + if (oppositeComponent != null) { + + // check out if still on table + parentContainer = SwingUtil.getParentContainer( + oppositeComponent, JXTable.class); + } + + if (parentContainer == null) { + + // out of the table can save + if (getModel().getFishingOperation() != null) { + saveSelectedRowIfRequired(); + } + } + } + + public void selectFishingOperation(FishingOperation bean) { + + JXTable table = getTable(); + + if (table.isEditing()) { + + // make sure to stop editor + table.editingCanceled(null); + } + + if (fishingOperationMonitor.wasModified()) { + + // previous fishingOperation was modified, let's save it + MacroWasteBatchUIModel beanToSave = fishingOperationMonitor.getBean(); + + FishingOperation fishingOperation = beanToSave.toBean(); + + if (log.isInfoEnabled()) { + log.info("FishingOperation " + fishingOperation.getId() + + " was modified, will save it."); + } + + persistenceService.saveFishingOperation(fishingOperation); + } + + // make sure selection is empty (will remove bean from monitor) + table.clearSelection(); + + boolean empty = bean == null; + + MacroWasteBatchUIModel model = getModel(); + + List<MacroWasteBatchRowModel> rows; + + if (empty) { + rows = null; + bean = new FishingOperation(); + model.setFishingOperation(null); + } else { + + if (log.isInfoEnabled()) { + log.info("Get species batch for fishingOperation: " + bean.getId()); + } + rows = Lists.newArrayList(); + + if (!TuttiEntities.isNew(bean)) { + List<MacroWasteBatch> catches = + persistenceService.getAllMacroWasteBatch(bean.getId()); + for (MacroWasteBatch aBatch : catches) { + MacroWasteBatchRowModel entry = + new MacroWasteBatchRowModel(aBatch); + rows.add(entry); + } + } + model.setFishingOperation(bean); + } + + model.fromBean(bean); + model.setRows(rows); + + fishingOperationMonitor.clearModified(); + } + + public void cancel() { + + if (log.isInfoEnabled()) { + log.info("Cancel edition"); + } + } + + public void save() { + if (log.isInfoEnabled()) { + log.info("Will save"); + } + } + + //------------------------------------------------------------------------// + //-- Internal methods --// + //------------------------------------------------------------------------// + + protected boolean isRowValid(MacroWasteBatchRowModel row) { + boolean result = row.getSpecies() != null && row.getWeight() != null; + return result; + } + + protected void saveSelectedRowIfRequired() { + + TuttiBeanMonitor<MacroWasteBatchRowModel> rowMonitor = getRowMonitor(); + + MacroWasteBatchRowModel bean = rowMonitor.getBean(); + if (bean != null) { + + if (bean.isValid()) { + // there is a valid bean attached to the monitor + + if (rowMonitor.wasModified()) { + + // monitored bean was modified, save it + if (log.isInfoEnabled()) { + log.info("Row " + bean + " was modified, will save it"); + } + + saveRow(bean); + + // clear modified flag on the monitor + rowMonitor.clearModified(); + } + } else { + + // row is not valid can not save it + + MacroWasteBatch catchBean = bean.toBean(); + + if (!TuttiEntities.isNew(catchBean)) { + + // remove this + persistenceService.deleteMacroWasteBatch(catchBean.getId()); + } + } + } + } + + protected void saveRow(MacroWasteBatchRowModel row) { + + MacroWasteBatch catchBean = row.toBean(); + + FishingOperation fishingOperation = getModel().getFishingOperation(); + catchBean.setFishingOperation(fishingOperation); + if (log.isInfoEnabled()) { + log.info("Selected fishingOperation: " + fishingOperation.getId()); + } + + if (TuttiEntities.isNew(catchBean)) { + + catchBean = persistenceService.createMacroWasteBatch(catchBean); + row.setId(catchBean.getId()); + } else { + persistenceService.saveMacroWasteBatch(catchBean); + } + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,94 @@ +package fr.ifremer.tutti.ui.swing.content.operation.macrowaste; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderModelBuilder; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class MacroWasteBatchUIModel extends AbstractTuttiTableUIModel<FishingOperation, MacroWasteBatchRowModel, MacroWasteBatchUIModel> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; + + /** + * Editing fishing operation. + * + * @since 0.2 + */ + protected FishingOperation fishingOperation; + + /** + * Total Weight filled in screen. + * + * @since 0.2 + */ + protected Float totalWeight; + + + protected static final Binder<FishingOperation, MacroWasteBatchUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, MacroWasteBatchUIModel.class) + .addProperty(FishingOperation.PROPERTY_MACRO_WASTE_TOTAL_WEIGHT, PROPERTY_TOTAL_WEIGHT) + .addProperty(FishingOperation.PROPERTY_ID, PROPERTY_ID) + .toBinder(); + + protected static final Binder<MacroWasteBatchUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(MacroWasteBatchUIModel.class, FishingOperation.class) + .addProperty(PROPERTY_TOTAL_WEIGHT, FishingOperation.PROPERTY_MACRO_WASTE_TOTAL_WEIGHT) + .toBinder(); + + + public MacroWasteBatchUIModel() { + super(FishingOperation.class, fromBeanBinder, toBeanBinder); + } + + public FishingOperation getFishingOperation() { + return fishingOperation; + } + + public void setFishingOperation(FishingOperation fishingOperation) { + this.fishingOperation = fishingOperation; + } + + + public Float getTotalWeight() { + return totalWeight; + } + + public void setTotalWeight(Float totalWeight) { + Object oldValue = getTotalWeight(); + this.totalWeight = totalWeight; + firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); + } + + @Override + protected FishingOperation newEntity() { + return fishingOperation; + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroWasteBatchUIModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.css 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.css 2012-12-13 01:57:28 UTC (rev 55) @@ -1,59 +0,0 @@ -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -NumberEditor { - autoPopup:{handler.getConfig().isAutoPopupNumberEditor()}; - showPopupButton:{handler.getConfig().isShowNumberEditorButton()}; - bean:{model}; - showReset:true; -} - -#totalWeightLabel { - text:"tutti.label.plancton.totalWeight"; - labelFor:{totalWeightField}; -} - -#totalWeightField { - property:"totalWeight"; - model:{model.getTotalWeight()}; - useFloat:false; - numberPattern:{INT_6_DIGITS_PATTERN}; -} - -#sampleTotalWeightLabel { - text:"tutti.label.plancton.sampleTotalWeight"; - labelFor:{totalWeightField}; -} - -#sampleTotalWeightField { - property:"sampleTotalWeight"; - model:{model.getSampleTotalWeight()}; - useFloat:false; - numberPattern:{INT_6_DIGITS_PATTERN}; -} - -#table { - model:{getContextValue(TableModel.class)}; - columnModel:{getContextValue(TableColumnModel.class)}; -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.jaxx 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.jaxx 2012-12-13 01:57:28 UTC (rev 55) @@ -1,98 +0,0 @@ -<!-- - #%L - Tutti :: UI - $Id$ - $HeadURL$ - %% - Copyright (C) 2012 Ifremer - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> -<JPanel id='homePanel' layout='{new BorderLayout()}' - implements='fr.ifremer.tutti.ui.swing.TuttiUI<PlanctonTabUIModel, PlanctonTabUIHandler>'> - - <import> - fr.ifremer.tutti.persistence.entities.data.FishingOperation - - fr.ifremer.tutti.ui.swing.TuttiUIContext - fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI - - jaxx.runtime.swing.editor.NumberEditor - - jaxx.runtime.validator.swing.SwingValidatorUtil - jaxx.runtime.validator.swing.SwingValidatorMessageTableModel - - javax.swing.table.TableModel - javax.swing.table.TableColumnModel - - static org.nuiton.i18n.I18n._ - </import> - - <script><![CDATA[ - -public PlanctonTabUI(FishingOperationsUI parentUI) { - PlanctonTabUIHandler handler = new PlanctonTabUIHandler(parentUI, this); - setContextValue(handler); - handler.beforeInitUI(); -} - -public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); } - -protected void $afterCompleteSetup() { handler.afterInitUI(); } - ]]></script> - - <PlanctonTabUIHandler id='handler' - initializer='getContextValue(PlanctonTabUIHandler.class)'/> - - <PlanctonTabUIModel id='model' - initializer='getContextValue(PlanctonTabUIModel.class)'/> - - <SwingValidatorMessageTableModel id='errorTableModel'/> - - <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' - uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> - <field name='totalWeight' component='totalWeightField'/> - <field name='sampleTotalWeight' component='sampleTotalWeightField'/> - </BeanValidator> - - <Table id='form' fill='both' constraints='BorderLayout.NORTH'> - - <!-- Poids total --> - <row> - <cell anchor='west'> - <JLabel id='totalWeightLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='totalWeightField' constructorParams='this'/> - </cell> - </row> - - <!-- Poids total échantillonné --> - <row> - <cell> - <JLabel id='sampleTotalWeightLabel'/> - </cell> - <cell> - <NumberEditor id='sampleTotalWeightField' constructorParams='this'/> - </cell> - </row> - </Table> - - <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> - <JTable id='table'/> - </JScrollPane> - -</JPanel> \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIHandler.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIHandler.java 2012-12-13 01:57:28 UTC (rev 55) @@ -1,182 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.plankton; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.PlanctonBatch; -import fr.ifremer.tutti.persistence.entities.referential.Species; -import fr.ifremer.tutti.service.PersistenceService; -import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; -import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; -import jaxx.runtime.SwingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.JComboBox; -import javax.swing.JTable; -import javax.swing.table.DefaultTableColumnModel; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.List; - -import static org.nuiton.i18n.I18n._; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class PlanctonTabUIHandler extends AbstractTuttiUIHandler<PlanctonTabUIModel> { - - /** Logger. */ - private static final Log log = LogFactory.getLog(PlanctonTabUIHandler.class); - - private final PlanctonTabUI ui; - - private final FishingOperationsUI parentUi; - - private final PersistenceService persistenceService; - - public PlanctonTabUIHandler(FishingOperationsUI parentUi, PlanctonTabUI ui) { - super(parentUi.getHandler().getContext()); - this.ui = ui; - this.parentUi = parentUi; - this.persistenceService = context.getService(PersistenceService.class); - } - - @Override - public void beforeInitUI() { - - PlanctonTabUIModel model = new PlanctonTabUIModel(); - ui.setContextValue(model); - - JTable tb = new JTable(); - - TableCellEditor defaultEditor = tb.getDefaultEditor(String.class); - TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class); - - // prepare the table column model - TableColumnModel columnModel = new DefaultTableColumnModel(); - - TableColumn col; - - // species (by code) column - - col = new TableColumn(0); - - JComboBox speciesEditor = new JComboBox(); - List<Species> allSpecies = persistenceService.getAllSpecies(); - SwingUtil.fillComboBox(speciesEditor, allSpecies, null); -// col.setCellEditor(); -// col.setCellRenderer(newTableCellRender(Species.class)); - col.setHeaderValue(_("tutti.table.plancton.header.speciesByCode")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("speciesByCode"); - columnModel.addColumn(col); - - // Poids observé - col = new TableColumn(1); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.plancton.header.weight")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("weight"); - columnModel.addColumn(col); - - // Nombre observé - col = new TableColumn(2); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.plancton.header.number")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("computedNumber"); - columnModel.addColumn(col); - - ui.setContextValue(columnModel); - - final PlanctonTableModel tableModel = new PlanctonTableModel(columnModel); - ui.setContextValue(tableModel); - - model.addPropertyChangeListener(PlanctonTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - tableModel.setData((List<SpeciesBatch>) evt.getNewValue()); - } - }); - - } - - @Override - public void afterInitUI() { - PlanctonTabUIModel model = ui.getModel(); - - initUI(ui); - } - - @Override - public void onCloseUI() { - } - - @Override - protected PlanctonTabUIModel getModel() { - return ui.getModel(); - } - - public void selectFishingOperation(FishingOperation bean) { - - boolean empty = bean == null; - - PlanctonTabUIModel model = ui.getModel(); - - List<PlanctonBatch> catches; - - if (empty) { - catches = null; - bean = new FishingOperation(); - } else { - catches = persistenceService.getAllPlanctonBatch(bean.getId()); - } - - model.fromBean(bean); - model.setCatches(catches); - } - - public void cancel() { - - if (log.isInfoEnabled()) { - log.info("Cancel edition"); - } - } - - public void save() { - if (log.isInfoEnabled()) { - log.info("Will save"); - } - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIModel.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -1,95 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.plankton; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.PlanctonBatch; -import org.jdesktop.beans.AbstractSerializableBean; -import org.nuiton.util.beans.BinderFactory; - -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class PlanctonTabUIModel extends AbstractSerializableBean { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; - - public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight"; - - public static final String PROPERTY_CATCHES = "catches"; - - protected Float totalWeight; - - protected Float sampleTotalWeight; - - protected List<PlanctonBatch> catches; - - public Float getTotalWeight() { - return totalWeight; - } - - public void setTotalWeight(Float totalWeight) { - Object oldValue = getTotalWeight(); - this.totalWeight = totalWeight; - firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); - } - - public Float getSampleTotalWeight() { - return sampleTotalWeight; - } - - public void setSampleTotalWeight(Float sampleTotalWeight) { - Object oldValue = getSampleTotalWeight(); - this.sampleTotalWeight = sampleTotalWeight; - firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight); - } - - public List<PlanctonBatch> getCatches() { - return catches; - } - - public void setCatches(List<PlanctonBatch> catches) { - Object oldValue = getCatches(); - this.catches = catches; - firePropertyChange(PROPERTY_CATCHES, oldValue, catches); - } - - public void fromBean(FishingOperation bean) { - BinderFactory.newBinder(FishingOperation.class, - PlanctonTabUIModel.class).copy(bean, this); - } - - public FishingOperation toBean() { - FishingOperation result = new FishingOperation(); - BinderFactory.newBinder(PlanctonTabUIModel.class, - FishingOperation.class).copy(this, result); - return result; - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTableModel.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTableModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -1,78 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.plankton; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.common.collect.Lists; -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; - -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableColumnModel; -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class PlanctonTableModel extends AbstractTableModel { - - private static final long serialVersionUID = 1L; - - protected List<SpeciesBatch> data; - - protected final TableColumnModel columnModel; - - public PlanctonTableModel(TableColumnModel columnModel) { - this.columnModel = columnModel; - } - - public void setData(List<SpeciesBatch> data) { - if (data == null) { - data = Lists.newArrayList(); - data.add(new SpeciesBatch()); - } - this.data = data; - fireTableDataChanged(); - } - - @Override - public int getRowCount() { - return data == null ? 0 : data.size(); - } - - @Override - public int getColumnCount() { - return columnModel.getColumnCount(); - } - - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - return null; - } - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return true; - } -} \ No newline at end of file Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchRowModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchRowModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,173 @@ +package fr.ifremer.tutti.ui.swing.content.operation.plankton; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +/** + * Define a benthos batch row. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class PlanktonBatchRowModel extends AbstractTuttiBeanUIModel<PlanktonBatch, PlanktonBatchRowModel> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_SPECIES = "species"; + + public static final String PROPERTY_SPECIES_TO_CONFIRM = "speciesToConfirm"; + + public static final String PROPERTY_WEIGHT = "weight"; + + public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight"; + + public static final String PROPERTY_SAMPLING_RATIO = "samplingRatio"; + + public static final String PROPERTY_COMMENT = "comment"; + + /** + * Species observed. + * + * @since 0.2 + */ + protected Species species; + + /** + * Is the species need to be confirmed?. + * + * @since 0.2 + */ + protected boolean speciesToConfirm; + + /** + * Observed weight. + * + * @since 0.2 + */ + protected Float weight; + + /** + * Sample weight. + * + * @since 0.2 + */ + protected Float sampleWeight; + + /** + * Sampling ratio. + * + * @since 0.2 + */ + protected Float samplingRatio; + + /** + * Comment on this catches. + * + * @since 0.2 + */ + protected String comment; + + protected static final Binder<PlanktonBatch, PlanktonBatchRowModel> fromBeanBinder = + BinderFactory.newBinder(PlanktonBatch.class, + PlanktonBatchRowModel.class); + + protected static final Binder<PlanktonBatchRowModel, PlanktonBatch> toBeanBinder = + BinderFactory.newBinder(PlanktonBatchRowModel.class, + PlanktonBatch.class); + + public PlanktonBatchRowModel() { + super(PlanktonBatch.class, fromBeanBinder, toBeanBinder); + } + + public PlanktonBatchRowModel(PlanktonBatch aBatch) { + this(); + fromBean(aBatch); + } + + public Species getSpecies() { + return species; + } + + public void setSpecies(Species species) { + Object oldValue = getSpecies(); + this.species = species; + firePropertyChange(PROPERTY_SPECIES, oldValue, species); + } + + public Boolean getSpeciesToConfirm() { + return speciesToConfirm; + } + + public void setSpeciesToConfirm(Boolean speciesToConfirm) { + Object oldValue = getSpeciesToConfirm(); + this.speciesToConfirm = speciesToConfirm; + firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm); + } + + public Float getWeight() { + return weight; + } + + public void setWeight(Float weight) { + Object oldValue = getWeight(); + this.weight = weight; + firePropertyChange(PROPERTY_WEIGHT, oldValue, weight); + } + + public Float getSampleWeight() { + return sampleWeight; + } + + public void setSampleWeight(Float sampleWeight) { + Object oldValue = getSampleWeight(); + this.sampleWeight = sampleWeight; + firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight); + } + + public Float getSamplingRatio() { + return samplingRatio; + } + + public void setSamplingRatio(Float samplingRatio) { + Object oldValue = getSamplingRatio(); + this.samplingRatio = samplingRatio; + firePropertyChange(PROPERTY_SAMPLING_RATIO, oldValue, samplingRatio); + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + Object oldValue = getComment(); + this.comment = comment; + firePropertyChange(PROPERTY_COMMENT, oldValue, comment); + } +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchRowModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchTableModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchTableModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,124 @@ +package fr.ifremer.tutti.ui.swing.content.operation.plankton; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; + +import javax.swing.table.TableColumnModel; + +import static org.nuiton.i18n.I18n.n_; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class PlanktonBatchTableModel extends AbstractTuttiTableModel<PlanktonBatchRowModel> { + + private static final long serialVersionUID = 1L; + + public static final ColumnIdentifier<PlanktonBatchRowModel> SPECIES_TO_CONFIRM = ColumnIdentifier.newId( + PlanktonBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM, + n_("tutti.table.plankton.batch.header.toConfirm"), + n_("tutti.table.plankton.batch.header.toConfirm")); + + public static final ColumnIdentifier<PlanktonBatchRowModel> SPECIES_BY_CODE = ColumnIdentifier.newId( + PlanktonBatchRowModel.PROPERTY_SPECIES, + n_("tutti.table.plankton.batch.header.speciesByCode"), + n_("tutti.table.plankton.batch.header.speciesByCode")); + + public static final ColumnIdentifier<PlanktonBatchRowModel> SPECIES_BY_GENUS_CODE = ColumnIdentifier.newId( + PlanktonBatchRowModel.PROPERTY_SPECIES, + n_("tutti.table.plankton.batch.header.speciesByGenusCode"), + n_("tutti.table.plankton.batch.header.speciesByGenusCode")); + + public static final ColumnIdentifier<PlanktonBatchRowModel> WEIGHT = ColumnIdentifier.newId( + PlanktonBatchRowModel.PROPERTY_WEIGHT, + n_("tutti.table.plankton.batch.header.weight"), + n_("tutti.table.plankton.batch.header.weight")); + + public static final ColumnIdentifier<PlanktonBatchRowModel> SAMPLE_WEIGHT = ColumnIdentifier.newId( + PlanktonBatchRowModel.PROPERTY_SAMPLE_WEIGHT, + n_("tutti.table.plankton.batch.header.sampleWeight"), + n_("tutti.table.plankton.batch.header.sampleWeight")); + + public static final ColumnIdentifier<PlanktonBatchRowModel> SAMPLING_RATIO = ColumnIdentifier.newId( + PlanktonBatchRowModel.PROPERTY_SAMPLING_RATIO, + n_("tutti.table.plankton.batch.header.elevationRate"), + n_("tutti.table.plankton.batch.header.elevationRate")); + + public static final ColumnIdentifier<PlanktonBatchRowModel> COMMENT = ColumnIdentifier.newId( + PlanktonBatchRowModel.PROPERTY_COMMENT, + n_("tutti.table.plankton.batch.header.comment"), + n_("tutti.table.plankton.batch.header.comment")); + + public static final ColumnIdentifier<PlanktonBatchRowModel> FILE = ColumnIdentifier.newId( + null, + n_("tutti.table.plankton.batch.header.file"), + n_("tutti.table.plankton.batch.header.file")); + + + public PlanktonBatchTableModel(TableColumnModel columnModel) { + super(columnModel); + + setNoneEditableCols( + SAMPLE_WEIGHT, + SAMPLING_RATIO, + FILE + ); + } + + @Override + protected PlanktonBatchRowModel createNewRow() { + PlanktonBatchRowModel result = new PlanktonBatchRowModel(); + + // by default empty row is not valid + result.setValid(false); + return result; + } + + @Override + public void setValueAt(Object aValue, + int rowIndex, + int columnIndex, + ColumnIdentifier<PlanktonBatchRowModel> propertyName, + PlanktonBatchRowModel entry) { + super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry); + + if (propertyName == SPECIES_BY_CODE) { + + // update also other columns + fireTableCellUpdated(rowIndex, + SPECIES_BY_GENUS_CODE); + + } else if (propertyName == SPECIES_BY_GENUS_CODE) { + + // update also other columns + fireTableCellUpdated(rowIndex, + SPECIES_BY_CODE); + } + } + +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchTableModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.css (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.css 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,61 @@ +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +NumberEditor { + autoPopup: {handler.getConfig().isAutoPopupNumberEditor()}; + showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; + bean: {model}; + showReset: true; +} + +#totalWeightLabel { + text: "tutti.label.plankton.totalWeight"; + labelFor: {totalWeightField}; +} + +#totalWeightField { + property: "totalWeight"; + model: {model.getTotalWeight()}; + useFloat: false; + numberPattern: {INT_6_DIGITS_PATTERN}; +} + +#sampleTotalWeightLabel { + text: "tutti.label.plankton.sampleTotalWeight"; + labelFor: {totalWeightField}; +} + +#sampleTotalWeightField { + property: "sampleTotalWeight"; + model: {model.getSampleTotalWeight()}; + useFloat: false; + numberPattern: {INT_6_DIGITS_PATTERN}; +} + +#table { + selectionMode: {ListSelectionModel.SINGLE_SELECTION}; + selectionBackground: {null}; + selectionForeground: {Color.BLACK}; + sortable: false; +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.jaxx (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.jaxx 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,101 @@ +<!-- + #%L + Tutti :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 Ifremer + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JPanel id='homePanel' layout='{new BorderLayout()}' + implements='fr.ifremer.tutti.ui.swing.TuttiUI<PlanktonBatchUIModel, PlanktonBatchUIHandler>'> + + <import> + fr.ifremer.tutti.persistence.entities.data.FishingOperation + + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI + + jaxx.runtime.swing.editor.NumberEditor + + jaxx.runtime.validator.swing.SwingValidatorUtil + jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + + org.jdesktop.swingx.JXTable + + javax.swing.ListSelectionModel + + java.awt.Color + + static org.nuiton.i18n.I18n._ + </import> + + <script><![CDATA[ + +public PlanktonBatchUI(FishingOperationsUI parentUI) { + PlanktonBatchUIHandler handler = new PlanktonBatchUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); } + +protected void $afterCompleteSetup() { handler.afterInitUI(); } + ]]></script> + + <PlanktonBatchUIHandler id='handler' + initializer='getContextValue(PlanktonBatchUIHandler.class)'/> + + <PlanktonBatchUIModel id='model' + initializer='getContextValue(PlanktonBatchUIModel.class)'/> + + <SwingValidatorMessageTableModel id='errorTableModel'/> + + <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' + uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> + <field name='totalWeight' component='totalWeightField'/> + <field name='sampleTotalWeight' component='sampleTotalWeightField'/> + </BeanValidator> + + <Table id='form' fill='both' constraints='BorderLayout.NORTH'> + + <!-- Poids total --> + <row> + <cell anchor='west'> + <JLabel id='totalWeightLabel'/> + </cell> + <cell weightx='1.0'> + <NumberEditor id='totalWeightField' constructorParams='this'/> + </cell> + </row> + + <!-- Poids total échantillonné --> + <row> + <cell> + <JLabel id='sampleTotalWeightLabel'/> + </cell> + <cell> + <NumberEditor id='sampleTotalWeightField' constructorParams='this'/> + </cell> + </row> + </Table> + + <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> + <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event);'/> + </JScrollPane> + +</JPanel> \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIHandler.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIHandler.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,496 @@ +package fr.ifremer.tutti.ui.swing.content.operation.plankton; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.DecoratorService; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.TuttiUI; +import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; +import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; +import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; +import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener; +import jaxx.runtime.SwingUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.ComponentAdapter; +import org.jdesktop.swingx.decorator.HighlightPredicate; +import org.jdesktop.swingx.decorator.Highlighter; +import org.jdesktop.swingx.table.DefaultTableColumnModelExt; +import org.nuiton.util.decorator.Decorator; + +import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableColumnModel; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.FocusEvent; +import java.util.List; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class PlanktonBatchUIHandler extends AbstractTuttiTableUIHandler<PlanktonBatchRowModel, PlanktonBatchUIModel> { + + /** Logger. */ + private static final Log log = LogFactory.getLog(PlanktonBatchUIHandler.class); + + /** + * UI. + * + * @since 0.2 + */ + private final PlanktonBatchUI ui; + + /** + * Persistence service. + * + * @since 0.2 + */ + private final PersistenceService persistenceService; + + /** + * To monitor changes on the fishing operation. + * + * @since 0.2 + */ + private final TuttiBeanMonitor<PlanktonBatchUIModel> fishingOperationMonitor; + + public PlanktonBatchUIHandler(FishingOperationsUI parentUi, PlanktonBatchUI ui) { + super(parentUi.getHandler().getContext(), + PlanktonBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM, + PlanktonBatchRowModel.PROPERTY_SPECIES, + PlanktonBatchRowModel.PROPERTY_WEIGHT, + PlanktonBatchRowModel.PROPERTY_COMMENT); + this.ui = ui; + this.persistenceService = context.getService(PersistenceService.class); + this.fishingOperationMonitor = new TuttiBeanMonitor<PlanktonBatchUIModel>( + PlanktonBatchUIModel.PROPERTY_TOTAL_WEIGHT, + PlanktonBatchUIModel.PROPERTY_SAMPLE_TOTAL_WEIGHT + ); + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiTableUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + protected PlanktonBatchUIModel getModel() { + return ui.getModel(); + } + + @Override + protected PlanktonBatchTableModel getTableModel() { + return (PlanktonBatchTableModel) getTable().getModel(); + } + + @Override + protected JXTable getTable() { + return ui.getTable(); + } + + @Override + protected String[] getRowPropertiesToIgnore() { + return new String[]{ + PlanktonBatchRowModel.PROPERTY_SAMPLE_WEIGHT, + PlanktonBatchRowModel.PROPERTY_SAMPLING_RATIO + }; + } + + @Override + protected TableColumnModel createTableColumnModel() { + + DefaultTableColumnModelExt columnModel = + new DefaultTableColumnModelExt(); + + { + // Species to confirm column + + addBooleanColumnToModel(columnModel, + PlanktonBatchTableModel.SPECIES_TO_CONFIRM, + getTable()); + } + + List<Species> allSpecies = persistenceService.getAllSpecies(); + + { + // Species (by code) column + + Decorator<Species> decorator = getDecorator( + Species.class, DecoratorService.SPECIES_BY_CODE); + + addComboDataColumnToModel(columnModel, + PlanktonBatchTableModel.SPECIES_BY_CODE, + decorator, allSpecies); + } + + { + // Species (by genusCode) column + + Decorator<Species> decorator = getDecorator( + Species.class, DecoratorService.SPECIES_BY_GENUS); + + addComboDataColumnToModel(columnModel, + PlanktonBatchTableModel.SPECIES_BY_GENUS_CODE, + decorator, allSpecies); + + } + + { // Weight column + + addFloatColumnToModel(columnModel, + PlanktonBatchTableModel.WEIGHT, + TuttiUI.DECIMAL3_PATTERN); + } + + { // Sample weight column + + addColumnToModel(columnModel, + PlanktonBatchTableModel.SAMPLE_WEIGHT); + } + + { // SamplingRatio column + + addColumnToModel(columnModel, + PlanktonBatchTableModel.SAMPLING_RATIO); + } + + { // Comment column + + addColumnToModel(columnModel, + PlanktonBatchTableModel.COMMENT); + } + + { // File column + + addColumnToModel(columnModel, + PlanktonBatchTableModel.FILE); + } + return columnModel; + } + + @Override + protected void onRowModified(PlanktonBatchRowModel row, + String propertyName, + Object oldValue, + Object newValue) { + + boolean wasValid = row.isValid(); + + boolean valid = isRowValid(row); + + if (log.isInfoEnabled()) { + log.info("Was valid / Is valid: " + wasValid + " / " + valid); + } + row.setValid(valid); + } + + @Override + protected void onRowValidStateChanged(PlanktonBatchRowModel row, + Boolean oldValue, + Boolean newValue) { + int rowIndex = getTableModel().getRowIndex(row); + + if (rowIndex > -1) { + getTableModel().fireTableRowsUpdated(rowIndex, rowIndex); + } + } + + @Override + protected void onRowModifyStateChanged(PlanktonBatchRowModel row, + Boolean oldValue, + Boolean newValue) { + } + + @Override + protected void onModelRowsChanged(List<PlanktonBatchRowModel> rows) { + super.onModelRowsChanged(rows); + + // set valid flag + for (PlanktonBatchRowModel row : rows) { + boolean valid = isRowValid(row); + row.setValid(valid); + } + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public void beforeInitUI() { + + if (log.isInfoEnabled()) { + log.info("beforeInit: " + ui); + } + + PlanktonBatchUIModel model = new PlanktonBatchUIModel(); + ui.setContextValue(model); + + fishingOperationMonitor.setBean(model); + } + + @Override + public void afterInitUI() { + + if (log.isInfoEnabled()) { + log.info("afterInit: " + ui); + } + + initUI(ui); + + JXTable table = getTable(); + + // create table column model + TableColumnModel columnModel = createTableColumnModel(); + + // create table model + PlanktonBatchTableModel tableModel = + new PlanktonBatchTableModel(columnModel); + + table.setModel(tableModel); + table.setColumnModel(columnModel); + installTableKeyListener(columnModel, table); + + table.getTableHeader().setReorderingAllowed(false); + + + Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY); + + table.addHighlighter(readOnlyHighlighter); + Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { + + boolean result = false; + if (adapter.isEditable()) { + int rowIndex = adapter.convertRowIndexToModel(adapter.row); + PlanktonBatchRowModel row = getTableModel().getEntry(rowIndex); + result = !row.isValid(); + } + return result; + } + }), Color.RED); + table.addHighlighter(validHighlighter); + + // when model datas change let's propagate it table model + listenRowsFromModel(); + + // save when row chaged and was modified + ListSelectionListener listener = new TableRowModificationListener<PlanktonBatchRowModel>( + getTableModel(), getRowMonitor()) { + @Override + protected void saveSelectedRow() { + saveSelectedRowIfRequired(); + } + }; + table.getSelectionModel().addListSelectionListener(listener); + + // always scroll to selected row + SwingUtil.scrollToTableSelection(getTable()); + } + + @Override + public void onCloseUI() { + if (log.isInfoEnabled()) { + log.info("closing: " + ui); + } + } + + //------------------------------------------------------------------------// + //-- Public methods --// + //------------------------------------------------------------------------// + + public void saveSelectedRowIfRequired(FocusEvent event) { + + Component oppositeComponent = event.getOppositeComponent(); + + JXTable parentContainer = null; + + if (oppositeComponent != null) { + + // check out if still on table + parentContainer = SwingUtil.getParentContainer( + oppositeComponent, JXTable.class); + } + + if (parentContainer == null) { + + // out of the table can save + if (getModel().getFishingOperation() != null) { + saveSelectedRowIfRequired(); + } + } + } + + public void selectFishingOperation(FishingOperation bean) { + + JXTable table = getTable(); + + if (table.isEditing()) { + + // make sure to stop editor + table.editingCanceled(null); + } + + if (fishingOperationMonitor.wasModified()) { + + // previous fishingOperation was modified, let's save it + PlanktonBatchUIModel beanToSave = fishingOperationMonitor.getBean(); + + FishingOperation fishingOperation = beanToSave.toBean(); + + if (log.isInfoEnabled()) { + log.info("FishingOperation " + fishingOperation.getId() + + " was modified, will save it."); + } + + persistenceService.saveFishingOperation(fishingOperation); + } + + // make sure selection is empty (will remove bean from monitor) + table.clearSelection(); + + boolean empty = bean == null; + + PlanktonBatchUIModel model = getModel(); + + List<PlanktonBatchRowModel> rows; + + if (empty) { + rows = null; + bean = new FishingOperation(); + model.setFishingOperation(null); + } else { + + if (log.isInfoEnabled()) { + log.info("Get species batch for fishingOperation: " + bean.getId()); + } + rows = Lists.newArrayList(); + + if (!TuttiEntities.isNew(bean)) { + List<PlanktonBatch> catches = + persistenceService.getAllPlanktonBatch(bean.getId()); + for (PlanktonBatch aBatch : catches) { + PlanktonBatchRowModel entry = + new PlanktonBatchRowModel(aBatch); + rows.add(entry); + } + } + model.setFishingOperation(bean); + } + + model.fromBean(bean); + model.setRows(rows); + + fishingOperationMonitor.clearModified(); + } + + public void cancel() { + + if (log.isInfoEnabled()) { + log.info("Cancel edition"); + } + } + + public void save() { + if (log.isInfoEnabled()) { + log.info("Will save"); + } + } + + //------------------------------------------------------------------------// + //-- Internal methods --// + //------------------------------------------------------------------------// + + protected boolean isRowValid(PlanktonBatchRowModel row) { + boolean result = row.getSpecies() != null && row.getWeight() != null; + return result; + } + + protected void saveSelectedRowIfRequired() { + + TuttiBeanMonitor<PlanktonBatchRowModel> rowMonitor = getRowMonitor(); + + PlanktonBatchRowModel bean = rowMonitor.getBean(); + if (bean != null) { + + if (bean.isValid()) { + // there is a valid bean attached to the monitor + + if (rowMonitor.wasModified()) { + + // monitored bean was modified, save it + if (log.isInfoEnabled()) { + log.info("Row " + bean + " was modified, will save it"); + } + + saveRow(bean); + + // clear modified flag on the monitor + rowMonitor.clearModified(); + } + } else { + + // row is not valid can not save it + + PlanktonBatch catchBean = bean.toBean(); + + if (!TuttiEntities.isNew(catchBean)) { + + // remove this + persistenceService.deletePlanktonBatch(catchBean.getId()); + } + } + } + } + + protected void saveRow(PlanktonBatchRowModel row) { + + PlanktonBatch catchBean = row.toBean(); + + FishingOperation fishingOperation = getModel().getFishingOperation(); + catchBean.setFishingOperation(fishingOperation); + if (log.isInfoEnabled()) { + log.info("Selected fishingOperation: " + fishingOperation.getId()); + } + + if (TuttiEntities.isNew(catchBean)) { + + catchBean = persistenceService.createPlanktonBatch(catchBean); + row.setId(catchBean.getId()); + } else { + persistenceService.savePlanktonBatch(catchBean); + } + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,113 @@ +package fr.ifremer.tutti.ui.swing.content.operation.plankton; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderModelBuilder; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class PlanktonBatchUIModel extends AbstractTuttiTableUIModel<FishingOperation, PlanktonBatchRowModel, PlanktonBatchUIModel> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; + + public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight"; + + /** + * Editing fishing operation. + * + * @since 0.2 + */ + protected FishingOperation fishingOperation; + + /** + * Total Weight filled in screen. + * + * @since 0.2 + */ + protected Float totalWeight; + + /** + * Total Sample Weight filled in screen. + * + * @since 0.2 + */ + protected Float sampleTotalWeight; + + protected static final Binder<FishingOperation, PlanktonBatchUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, PlanktonBatchUIModel.class) + .addProperty(FishingOperation.PROPERTY_PLANKTON_TOTAL_WEIGHT, PROPERTY_TOTAL_WEIGHT) + .addProperty(FishingOperation.PROPERTY_PLANKTON_SAMPLE_TOTAL_WEIGHT, PROPERTY_SAMPLE_TOTAL_WEIGHT) + .addProperty(FishingOperation.PROPERTY_ID, PROPERTY_ID) + .toBinder(); + + protected static final Binder<PlanktonBatchUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(PlanktonBatchUIModel.class, FishingOperation.class) + .addProperty(PROPERTY_TOTAL_WEIGHT, FishingOperation.PROPERTY_PLANKTON_TOTAL_WEIGHT) + .addProperty(PROPERTY_SAMPLE_TOTAL_WEIGHT, FishingOperation.PROPERTY_PLANKTON_SAMPLE_TOTAL_WEIGHT) + .toBinder(); + + + public PlanktonBatchUIModel() { + super(FishingOperation.class, fromBeanBinder, toBeanBinder); + } + + public FishingOperation getFishingOperation() { + return fishingOperation; + } + + public void setFishingOperation(FishingOperation fishingOperation) { + this.fishingOperation = fishingOperation; + } + + public Float getTotalWeight() { + return totalWeight; + } + + public void setTotalWeight(Float totalWeight) { + Object oldValue = getTotalWeight(); + this.totalWeight = totalWeight; + firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); + } + + public Float getSampleTotalWeight() { + return sampleTotalWeight; + } + + public void setSampleTotalWeight(Float sampleTotalWeight) { + Object oldValue = getSampleTotalWeight(); + this.sampleTotalWeight = sampleTotalWeight; + firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight); + } + + @Override + protected FishingOperation newEntity() { + return fishingOperation; + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanktonBatchUIModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchRowModel.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchRowModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -155,7 +155,7 @@ protected Float sampleWeight; /** - * Elevation ratio. + * Sampling ratio. * * @since 0.2 */ Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.css (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.css 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,83 @@ +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +NumberEditor { + autoPopup: {handler.getConfig().isAutoPopupNumberEditor()}; + showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; + bean: {model}; + showReset: true; +} + +#totalWeightLabel { + text: "tutti.label.species.totalWeight"; + labelFor: {totalWeightField}; +} + +#totalWeightField { + property: "totalWeight"; + model: {model.getTotalWeight()}; + useFloat: false; + numberPattern: {INT_6_DIGITS_PATTERN}; +} + +#totalVracWeightLabel { + text: "tutti.label.species.totalVracWeight"; + labelFor: {totalVracWeightField}; +} + +#totalVracWeightField { + property: "totalVracWeight"; + model: {model.getTotalVracWeight()}; + useFloat: false; + numberPattern: {INT_6_DIGITS_PATTERN}; +} + +#sampleVracWeightLabel { + text: "tutti.label.species.sampleVracWeight"; + labelFor: {sampleVracWeightField}; +} + +#sampleVracWeightField { + property: "sampleVracWeight"; + model: {model.getSampleVracWeight()}; + useFloat: false; + numberPattern: {INT_6_DIGITS_PATTERN}; +} + +#totalHorsVracWeightLabel { + text: "tutti.label.species.totalHorsVracWeight"; + labelFor: {totalHorsVracWeightField}; +} + +#totalHorsVracWeightField { + text: {getStringValue(model.getTotalHorsVracWeight())}; + editable: false; +} + +#table { + selectionMode: {ListSelectionModel.SINGLE_SELECTION}; + selectionBackground: {null}; + selectionForeground: {Color.BLACK}; + sortable: false; +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,119 @@ +<!-- + #%L + Tutti :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 Ifremer + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<JPanel id='homePanel' layout='{new BorderLayout()}' + implements='fr.ifremer.tutti.ui.swing.TuttiUI<SpeciesBatchUIModel, SpeciesBatchUIHandler>'> + + <import> + fr.ifremer.tutti.persistence.entities.data.FishingOperation + + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI + fr.ifremer.tutti.ui.swing.content.operation.species.SpeciesFrequencyUI + + org.jdesktop.swingx.JXTable + + jaxx.runtime.swing.editor.NumberEditor + + jaxx.runtime.validator.swing.SwingValidatorUtil + jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + + javax.swing.ListSelectionModel + + java.awt.Color + + static org.nuiton.i18n.I18n._ + static jaxx.runtime.SwingUtil.getStringValue + </import> + + <script><![CDATA[ + +public SpeciesBatchUI(FishingOperationsUI parentUI) { + SpeciesBatchUIHandler handler = new SpeciesBatchUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); } + +protected void $afterCompleteSetup() { handler.afterInitUI(); } + ]]></script> + + <SpeciesBatchUIHandler id='handler' + initializer='getContextValue(SpeciesBatchUIHandler.class)'/> + + <SpeciesBatchUIModel id='model' + initializer='getContextValue(SpeciesBatchUIModel.class)'/> + + <SwingValidatorMessageTableModel id='errorTableModel'/> + + <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' + uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> + <field name='totalWeight' component='totalWeightField'/> + <field name='totalVracWeight' component='totalVracWeightField'/> + <field name='sampleVracWeight' component='sampleVracWeightField'/> + <field name='totalHorsVracWeight' component='totalHorsVracWeightField'/> + </BeanValidator> + + <SpeciesFrequencyUI id='frequencyUI' constructorParams='handler.getContext()'/> + + <Table id='form' fill='both' constraints='BorderLayout.NORTH'> + + <!-- Poids total / Poids total vrac --> + <row> + <cell anchor='west'> + <JLabel id='totalWeightLabel'/> + </cell> + <cell weightx='1.0'> + <NumberEditor id='totalWeightField' constructorParams='this'/> + </cell> + <cell anchor='west'> + <JLabel id='totalVracWeightLabel'/> + </cell> + <cell weightx='1.0'> + <NumberEditor id='totalVracWeightField' constructorParams='this'/> + </cell> + </row> + + <!-- Poids échantillonné vrac / Poids total hors vrac --> + <row> + <cell> + <JLabel id='sampleVracWeightLabel'/> + </cell> + <cell> + <NumberEditor id='sampleVracWeightField' constructorParams='this'/> + </cell> + <cell> + <JLabel id='totalHorsVracWeightLabel'/> + </cell> + <cell> + <JTextField id='totalHorsVracWeightField'/> + </cell> + </row> + </Table> + + <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> + <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event);'/> + </JScrollPane> + +</JPanel> Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java (from rev 54, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,756 @@ +package fr.ifremer.tutti.ui.swing.content.operation.species; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; +import fr.ifremer.tutti.persistence.entities.data.VracHorsVracEnum; +import fr.ifremer.tutti.persistence.entities.referential.Sex; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.persistence.entities.referential.WeightCategory; +import fr.ifremer.tutti.service.DecoratorService; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.TuttiUI; +import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; +import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; +import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; +import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener; +import jaxx.runtime.SwingUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.ComponentAdapter; +import org.jdesktop.swingx.decorator.HighlightPredicate; +import org.jdesktop.swingx.decorator.Highlighter; +import org.jdesktop.swingx.table.DefaultTableColumnModelExt; +import org.nuiton.util.decorator.Decorator; + +import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableColumnModel; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.FocusEvent; +import java.util.List; +import java.util.Set; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class SpeciesBatchUIHandler extends AbstractTuttiTableUIHandler<SpeciesBatchRowModel, SpeciesBatchUIModel> { + + /** Logger. */ + private static final Log log = LogFactory.getLog(SpeciesBatchUIHandler.class); + + public static final Set<String> RECOMPUTE_TOTAL_WEIGHT = Sets.newHashSet( + SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC, + SpeciesBatchRowModel.PROPERTY_WEIGHT + ); + + public static final Set<String> SAMPLING_PROPERTIES = Sets.newHashSet( + SpeciesBatchRowModel.PROPERTY_SPECIES, + SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC, + SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY, + SpeciesBatchRowModel.PROPERTY_SEX, + SpeciesBatchRowModel.PROPERTY_MATURITY, + SpeciesBatchRowModel.PROPERTY_AGE + ); + + /** + * UI. + * + * @since 0.2 + */ + private final SpeciesBatchUI ui; + + /** + * Persistence service. + * + * @since 0.2 + */ + private final PersistenceService persistenceService; + + /** + * To monitor changes on the fishing operation. + * + * @since 0.2 + */ + private final TuttiBeanMonitor<SpeciesBatchUIModel> fishingOperationMonitor; + + public SpeciesBatchUIHandler(FishingOperationsUI parentUi, SpeciesBatchUI ui) { + super(parentUi.getHandler().getContext(), + SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM, + SpeciesBatchRowModel.PROPERTY_SPECIES, + SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC, + SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY, + SpeciesBatchRowModel.PROPERTY_SEX, + SpeciesBatchRowModel.PROPERTY_MATURITY, + SpeciesBatchRowModel.PROPERTY_AGE, + SpeciesBatchRowModel.PROPERTY_WEIGHT, + SpeciesBatchRowModel.PROPERTY_COMMENT, + SpeciesBatchRowModel.PROPERTY_FREQUENCY); + this.ui = ui; + this.persistenceService = context.getService(PersistenceService.class); + this.fishingOperationMonitor = new TuttiBeanMonitor<SpeciesBatchUIModel>( + SpeciesBatchUIModel.PROPERTY_SAMPLE_VRAC_WEIGHT, + SpeciesBatchUIModel.PROPERTY_TOTAL_HORS_VRAC_WEIGHT, + SpeciesBatchUIModel.PROPERTY_TOTAL_VRAC_WEIGHT, + SpeciesBatchUIModel.PROPERTY_TOTAL_WEIGHT + ); + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiTableUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + protected SpeciesBatchUIModel getModel() { + return ui.getModel(); + } + + @Override + protected SpeciesBatchTableModel getTableModel() { + return (SpeciesBatchTableModel) getTable().getModel(); + } + + @Override + protected JXTable getTable() { + return ui.getTable(); + } + + @Override + protected void onModelRowsChanged(List<SpeciesBatchRowModel> rows) { + super.onModelRowsChanged(rows); + + // build the new sampling tree from the new rows to edit + getModel().getSamplingTreeModel().populate(rows); + } + + @Override + protected String[] getRowPropertiesToIgnore() { + return new String[]{ + SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT, + SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO, + SpeciesBatchRowModel.PROPERTY_FREQUENCY + }; + } + + @Override + protected TableColumnModel createTableColumnModel() { + + List<String> samplingOrder = getModel().getSamplingOrder(); + + DefaultTableColumnModelExt columnModel = + new DefaultTableColumnModelExt(); + + { + // Species to confirm column + + addBooleanColumnToModel(columnModel, + SpeciesBatchTableModel.SPECIES_TO_CONFIRM, + getTable()); + } + + List<Species> allSpecies = persistenceService.getAllSpecies(); + + { + // Species (by code) column + + Decorator<Species> decorator = getDecorator( + Species.class, DecoratorService.SPECIES_BY_CODE); + + addComboDataColumnToModel(columnModel, + SpeciesBatchTableModel.SPECIES_BY_CODE, + decorator, allSpecies); + } + + { + // Species (by genusCode) column + + Decorator<Species> decorator = getDecorator( + Species.class, DecoratorService.SPECIES_BY_GENUS); + + addComboDataColumnToModel(columnModel, + SpeciesBatchTableModel.SPECIES_BY_GENUS_CODE, + decorator, allSpecies); + + } + + if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC)) { + + // Vrac / Hors vrac column + + addComboEnumColumnToModel(columnModel, + SpeciesBatchTableModel.VRAC_HORS_VRAC, + VracHorsVracEnum.values()); + } + + if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY)) { + + // WeightCategory column + + Decorator<WeightCategory> decorator = + getDecorator(WeightCategory.class, + DecoratorService.BY_NAME); + + List<WeightCategory> data = + persistenceService.getAllWeightCategory(); + + addComboDataColumnToModel(columnModel, + SpeciesBatchTableModel.WEIGHT_CATEGORY, + decorator, data); + } + + if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_SEX)) { + + // Sex column + + Decorator<Sex> decorator = + getDecorator(Sex.class, DecoratorService.BY_NAME); + + List<Sex> data = persistenceService.getAllSex(); + + addComboDataColumnToModel(columnModel, + SpeciesBatchTableModel.SEX, + decorator, data); + } + + if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_MATURITY)) { + + // Maturity column + + addFloatColumnToModel(columnModel, + SpeciesBatchTableModel.MATURITY, + TuttiUI.DECIMAL3_PATTERN); + } + + if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_AGE)) { + + // Age column + + addFloatColumnToModel(columnModel, + SpeciesBatchTableModel.AGE, + TuttiUI.DECIMAL3_PATTERN); + } + + { // Weight column + + addFloatColumnToModel(columnModel, + SpeciesBatchTableModel.WEIGHT, + TuttiUI.DECIMAL3_PATTERN); + } + + { // Computed weight column (from frequencies) + + addColumnToModel(columnModel, + FrequencyCellComponent.newEditor(ui.getFrequencyUI()), + FrequencyCellComponent.newRender(), + SpeciesBatchTableModel.COMPUTED_WEIGHT); + } + + { // Computed number column (from frequencies) + + addColumnToModel(columnModel, + FrequencyCellComponent.newEditor(ui.getFrequencyUI()), + FrequencyCellComponent.newRender(), + SpeciesBatchTableModel.COMPUTED_NUMBER); + } + + { // Sample weight column + + addColumnToModel(columnModel, + SpeciesBatchTableModel.SAMPLE_WEIGHT); + } + + { // SamplingRatio column + + addColumnToModel(columnModel, + SpeciesBatchTableModel.SAMPLING_RATIO); + } + + { // Comment column + + addColumnToModel(columnModel, + SpeciesBatchTableModel.COMMENT); + } + + { // File column + + addColumnToModel(columnModel, + SpeciesBatchTableModel.FILE); + } + return columnModel; + } + + @Override + protected void onRowModified(SpeciesBatchRowModel row, + String propertyName, + Object oldValue, + Object newValue) { + + if (RECOMPUTE_TOTAL_WEIGHT.contains(propertyName)) { + + // Need to recompute totalHorsVracWeight + recomputeTotalHorsVrac(); + } + + SpeciesBatchUIModel model = getModel(); + + SpeciesBatchTreeModel samplingTreeModel = model.getSamplingTreeModel(); + + if (SAMPLING_PROPERTIES.contains(propertyName)) { + + // Need to rebuilt this row sampling tree path (and then recompute + // old super - samplingRatio and new super - samplingRatio) + + // old node of the previous sampling def for this row + // and remove it from any cache + SpeciesBatchTreeNode oldNode = samplingTreeModel.removeNodeFromCache(row); + + boolean rowWasValid = row.isValid(); + if (oldNode != null && rowWasValid) { + + // remove this row from his super sampling + recomputeSuperSamplingRatio(samplingTreeModel, oldNode); + } + + // get new sampling node + SpeciesBatchTreeNode newNode = samplingTreeModel.getSamplingNode(row); + + // check this row is valid + boolean rowValid = samplingTreeModel.isValid(row, newNode); + + // push this state back to the row + row.setValid(rowValid); + + if (rowValid) { + + // can add it to his super-sampling + recomputeSuperSamplingRatio(samplingTreeModel, newNode); + } else { + + if (rowWasValid) { + + row.setSampleWeight(null); + row.setSamplingRatio(null); + + getTableModel().updateSamplingRatio(Sets.newHashSet(row)); + } + } + } + + if (SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) { + + // Need to recompute the super - samplingRatio + + SpeciesBatchTreeNode node = samplingTreeModel.getSamplingNode(row); + + boolean rowWasValid = row.isValid(); + + // check this row is valid + boolean rowValid = samplingTreeModel.isValid(row, node); + + // push this state back to the row + row.setValid(rowValid); + + if (rowValid) { + recomputeSuperSamplingRatio(samplingTreeModel, node); + } else { + if (rowWasValid) { + + // must remove this row from his super-sampling + recomputeSuperSamplingRatio(samplingTreeModel, node); + + row.setSampleWeight(null); + row.setSamplingRatio(null); + + getTableModel().updateSamplingRatio(Sets.newHashSet(row)); + } + } + } + } + + @Override + protected void onRowValidStateChanged(SpeciesBatchRowModel row, + Boolean oldValue, + Boolean newValue) { + int rowIndex = getTableModel().getRowIndex(row); + + if (rowIndex > -1) { + getTableModel().fireTableRowsUpdated(rowIndex, rowIndex); + } + } + + @Override + protected void onRowModifyStateChanged(SpeciesBatchRowModel row, + Boolean oldValue, + Boolean newValue) { + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public void beforeInitUI() { + + if (log.isInfoEnabled()) { + log.info("beforeInit: " + ui); + } + + SpeciesBatchUIModel model = new SpeciesBatchUIModel(); + ui.setContextValue(model); + + fishingOperationMonitor.setBean(model); + } + + @Override + public void afterInitUI() { + + if (log.isInfoEnabled()) { + log.info("afterInit: " + ui); + } + + initUI(ui); + + //TODO Will come from protocol + List<String> samplingOrder = Lists.newArrayList( + SpeciesBatchRowModel.PROPERTY_SPECIES, + SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC, + SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY, + SpeciesBatchRowModel.PROPERTY_SEX + ); + + getModel().setSamplingOrder(samplingOrder); + + JXTable table = getTable(); + + // create table column model + TableColumnModel columnModel = createTableColumnModel(); + + // create table model + SpeciesBatchTableModel tableModel = + new SpeciesBatchTableModel(columnModel); + + table.setModel(tableModel); + table.setColumnModel(columnModel); + installTableKeyListener(columnModel, table); + + table.getTableHeader().setReorderingAllowed(false); + + + Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY); + + table.addHighlighter(readOnlyHighlighter); + Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( + new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { + + boolean result = false; + if (adapter.isEditable()) { + int rowIndex = adapter.convertRowIndexToModel(adapter.row); + SpeciesBatchRowModel row = getTableModel().getEntry(rowIndex); + result = !row.isValid(); + } + return result; + } + }), Color.RED); + table.addHighlighter(validHighlighter); + + // when model datas change let's propagate it table model + listenRowsFromModel(); + + // save when row chaged and was modified + ListSelectionListener listener = new TableRowModificationListener<SpeciesBatchRowModel>( + getTableModel(), getRowMonitor()) { + @Override + protected void saveSelectedRow() { + saveSelectedRowIfRequired(); + } + }; + table.getSelectionModel().addListSelectionListener(listener); + + // always scroll to selected row + SwingUtil.scrollToTableSelection(getTable()); + } + + @Override + public void onCloseUI() { + if (log.isInfoEnabled()) { + log.info("closing: " + ui); + } + } + + //------------------------------------------------------------------------// + //-- Public methods --// + //------------------------------------------------------------------------// + + public void saveSelectedRowIfRequired(FocusEvent event) { + + Component oppositeComponent = event.getOppositeComponent(); + + JXTable parentContainer = null; + + if (oppositeComponent != null) { + + // check out if still on table + parentContainer = SwingUtil.getParentContainer( + oppositeComponent, JXTable.class); + } + + if (parentContainer == null) { + + // out of the table can save + if (getModel().getFishingOperation() != null) { + saveSelectedRowIfRequired(); + } + } + } + + public void selectFishingOperation(FishingOperation bean) { + + JXTable table = ui.getTable(); + + if (table.isEditing()) { + + // make sure to stop editor + table.editingCanceled(null); + } + + if (fishingOperationMonitor.wasModified()) { + + // previous fishingOperation was modified, let's save it + SpeciesBatchUIModel beanToSave = fishingOperationMonitor.getBean(); + + FishingOperation fishingOperation = beanToSave.toBean(); + + if (log.isInfoEnabled()) { + log.info("FishingOperation " + fishingOperation.getId() + + " was modified, will save it."); + } + + persistenceService.saveFishingOperation(fishingOperation); + } + + // make sure selection is empty (will remove bean from monitor) + table.clearSelection(); + + boolean empty = bean == null; + + SpeciesBatchUIModel model = getModel(); + + List<SpeciesBatchRowModel> rows; + + if (empty) { + rows = null; + bean = new FishingOperation(); + model.setFishingOperation(null); + } else { + + if (log.isInfoEnabled()) { + log.info("Get species batch for fishingOperation: " + bean.getId()); + } + rows = Lists.newArrayList(); + + if (!TuttiEntities.isNew(bean)) { + List<SpeciesBatch> catches = + persistenceService.getAllSpeciesBatch(bean.getId()); + for (SpeciesBatch aBatch : catches) { + List<SpeciesBatchFrequency> frequencies = + persistenceService.getAllSpeciesBatchFrequency(aBatch.getId()); + SpeciesBatchRowModel entry = + new SpeciesBatchRowModel(aBatch, frequencies); + rows.add(entry); + } + } + model.setFishingOperation(bean); + } + + model.fromBean(bean); + model.setRows(rows); + + fishingOperationMonitor.clearModified(); + } + + //------------------------------------------------------------------------// + //-- Internal methods --// + //------------------------------------------------------------------------// + + protected void recomputeSuperSamplingRatio(SpeciesBatchTreeModel samplingTreeModel, + SpeciesBatchTreeNode node) { + + SpeciesBatchTreeNode superSamplingNode = node.getParent(); + + Preconditions.checkNotNull(superSamplingNode, + "Super sampling node can't be null"); + + SpeciesBatchTreeModel.SamplingContext samplingContext = + samplingTreeModel.createSamplingContext(superSamplingNode); + + float samplingTotalWeight = samplingContext.getTotalWeight(); + Float superSamplingTotalWeight; + SpeciesBatchRowModel superSamplingRow = + samplingContext.getSuperSamplingRow(); + if (superSamplingRow == null) { + + // Use directly the batch total weight (means no super-sampling) + + superSamplingTotalWeight = getModel().getTotalWeight(); + } else { + superSamplingTotalWeight = superSamplingRow.getWeight(); + } + + if (log.isInfoEnabled()) { + log.info("Super sampling total weight: " + + superSamplingTotalWeight); + } + + Float samplingRatio = null; + if (superSamplingTotalWeight != null) { + samplingRatio = samplingTotalWeight / superSamplingTotalWeight; + } + + if (log.isInfoEnabled()) { + log.info("Sampling ratio: " + samplingRatio); + } + + samplingContext.applyNewSampleValues(samplingTotalWeight, + samplingRatio); + + getTableModel().updateSamplingRatio(samplingContext.getSamplingRows()); + } + + + protected void recomputeTotalHorsVrac() { + + // recompute total hors vrac + Float totalHorsVrac = 0f; + Float totalVrac = 0f; + + for (SpeciesBatchRowModel batch : getModel().getRows()) { + VracHorsVracEnum vracHorsVrac = batch.getVracHorsVrac(); + if (vracHorsVrac == null) { + + // can't sum anything + } else if (vracHorsVrac == VracHorsVracEnum.HORS_VRAC) { + Float weight = batch.getWeight(); + if (weight != null) { + totalHorsVrac += weight; + } + } else if (vracHorsVrac == VracHorsVracEnum.VRAC) { + Float weight = batch.getWeight(); + if (weight != null) { + totalVrac += weight; + } + } + } + if (log.isInfoEnabled()) { + log.info("New total vrac / hors vrac: " + + totalVrac + " / " + totalHorsVrac); + } + getModel().setTotalHorsVracWeight(totalHorsVrac); + //TODO Should we also set the total vrac weight ? +// getModel().setTotalVracWeight(totalVrac); + } + + protected void saveSelectedRowIfRequired() { + + TuttiBeanMonitor<SpeciesBatchRowModel> rowMonitor = getRowMonitor(); + + SpeciesBatchRowModel bean = rowMonitor.getBean(); + if (bean != null) { + + if (bean.isValid()) { + // there is a valid bean attached to the monitor + + if (rowMonitor.wasModified()) { + + // monitored bean was modified, save it + if (log.isInfoEnabled()) { + log.info("Row " + bean + " was modified, will save it"); + } + + saveRow(bean); + + // clear modified flag on the monitor + rowMonitor.clearModified(); + } + } else { + + // row is not valid can not save it + + SpeciesBatch catchBean = bean.toBean(); + + if (!TuttiEntities.isNew(catchBean)) { + + // remove this + persistenceService.deleteSpeciesBatch(catchBean.getId()); + } + } + } + } + + protected void saveRow(SpeciesBatchRowModel row) { + + SpeciesBatch catchBean = row.toBean(); + + FishingOperation fishingOperation = getModel().getFishingOperation(); + catchBean.setFishingOperation(fishingOperation); + if (log.isInfoEnabled()) { + log.info("Selected fishingOperation: " + fishingOperation.getId()); + } + + if (TuttiEntities.isNew(catchBean)) { + + catchBean = persistenceService.createSpeciesBatch(catchBean); + row.setId(catchBean.getId()); + } else { + persistenceService.saveSpeciesBatch(catchBean); + } + + List<SpeciesFrequencyRowModel> frequencyRows = row.getFrequency(); + + List<SpeciesBatchFrequency> frequency = + SpeciesFrequencyRowModel.toBeans(frequencyRows, catchBean); + + if (log.isInfoEnabled()) { + log.info("Will save " + frequency.size() + " frequencies."); + } + frequency = persistenceService.saveSpeciesBatchFrequency( + catchBean.getId(), frequency); + + // push it back to row model + frequencyRows = SpeciesFrequencyRowModel.fromBeans(frequency); + row.setFrequency(frequencyRows); + } +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIModel.java (from rev 48, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -0,0 +1,184 @@ +package fr.ifremer.tutti.ui.swing.content.operation.species; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderModelBuilder; + +import java.util.List; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class SpeciesBatchUIModel extends AbstractTuttiTableUIModel<FishingOperation, SpeciesBatchRowModel, SpeciesBatchUIModel> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; + + public static final String PROPERTY_TOTAL_VRAC_WEIGHT = "totalVracWeight"; + + public static final String PROPERTY_SAMPLE_VRAC_WEIGHT = "sampleVracWeight"; + + public static final String PROPERTY_TOTAL_HORS_VRAC_WEIGHT = "totalHorsVracWeight"; + + /** + * Editing fishing operation. + * + * @since 0.2 + */ + protected FishingOperation fishingOperation; + + /** + * Total Weight filled in screen. + * + * @since 0.2 + */ + protected Float totalWeight; + + /** + * Total vrac Weight filled in screen. + * + * @since 0.2 + */ + protected Float totalVracWeight; + + /** + * Total sample vrac Weight filled in screen. + * + * @since 0.2 + */ + protected Float sampleVracWeight; + + /** + * Total hors vrac Weight computed by hros vrac rows. + * + * @since 0.2 + */ + protected Float totalHorsVracWeight; + + /** + * Sampling order (sets by protocol). + * + * @since 0.2 + */ + protected List<String> samplingOrder; + + /** + * Tree of sampling for batch rows. + * + * @since 0.2 + */ + protected final SpeciesBatchTreeModel samplingTreeModel; + + protected static final Binder<FishingOperation, SpeciesBatchUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, SpeciesBatchUIModel.class) + .addProperty(FishingOperation.PROPERTY_SPECIES_TOTAL_WEIGHT, PROPERTY_TOTAL_WEIGHT) + .addProperty(FishingOperation.PROPERTY_SPECIES_TOTAL_HORS_VRAC_WEIGHT, PROPERTY_TOTAL_HORS_VRAC_WEIGHT) + .addProperty(FishingOperation.PROPERTY_SPECIES_TOTAL_VRAC_WEIGHT, PROPERTY_TOTAL_VRAC_WEIGHT) + .addProperty(FishingOperation.PROPERTY_SPECIES_SAMPLE_VRAC_WEIGHT, PROPERTY_SAMPLE_VRAC_WEIGHT) + .addProperty(FishingOperation.PROPERTY_ID, PROPERTY_ID) + .toBinder(); + + protected static final Binder<SpeciesBatchUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(SpeciesBatchUIModel.class, FishingOperation.class) + .addProperty(PROPERTY_TOTAL_WEIGHT, FishingOperation.PROPERTY_SPECIES_TOTAL_WEIGHT) + .addProperty(PROPERTY_TOTAL_HORS_VRAC_WEIGHT, FishingOperation.PROPERTY_SPECIES_TOTAL_HORS_VRAC_WEIGHT) + .addProperty(PROPERTY_TOTAL_VRAC_WEIGHT, FishingOperation.PROPERTY_SPECIES_TOTAL_VRAC_WEIGHT) + .addProperty(PROPERTY_SAMPLE_VRAC_WEIGHT, FishingOperation.PROPERTY_SPECIES_SAMPLE_VRAC_WEIGHT) + .toBinder(); + + public SpeciesBatchUIModel() { + super(FishingOperation.class, fromBeanBinder, toBeanBinder); + this.samplingTreeModel = new SpeciesBatchTreeModel(); + } + + public FishingOperation getFishingOperation() { + return fishingOperation; + } + + public void setFishingOperation(FishingOperation fishingOperation) { + this.fishingOperation = fishingOperation; + } + + public SpeciesBatchTreeModel getSamplingTreeModel() { + return samplingTreeModel; + } + + public Float getTotalWeight() { + return totalWeight; + } + + public void setTotalWeight(Float totalWeight) { + Object oldValue = getTotalWeight(); + this.totalWeight = totalWeight; + firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); + } + + public Float getTotalVracWeight() { + return totalVracWeight; + } + + public void setTotalVracWeight(Float totalVracWeight) { + Object oldValue = getTotalVracWeight(); + this.totalVracWeight = totalVracWeight; + firePropertyChange(PROPERTY_TOTAL_VRAC_WEIGHT, oldValue, totalVracWeight); + } + + public Float getSampleVracWeight() { + return sampleVracWeight; + } + + public void setSampleVracWeight(Float sampleVracWeight) { + Object oldValue = getSampleVracWeight(); + this.sampleVracWeight = sampleVracWeight; + firePropertyChange(PROPERTY_SAMPLE_VRAC_WEIGHT, oldValue, sampleVracWeight); + } + + public Float getTotalHorsVracWeight() { + return totalHorsVracWeight; + } + + public void setTotalHorsVracWeight(Float totalHorsVracWeight) { + Object oldValue = getTotalHorsVracWeight(); + this.totalHorsVracWeight = totalHorsVracWeight; + firePropertyChange(PROPERTY_TOTAL_HORS_VRAC_WEIGHT, oldValue, totalHorsVracWeight); + } + + public List<String> getSamplingOrder() { + return samplingOrder; + } + + public void setSamplingOrder(List<String> samplingOrder) { + this.samplingOrder = samplingOrder; + samplingTreeModel.setSamplingOrder(samplingOrder.toArray(new String[samplingOrder.size()])); + } + + @Override + protected FishingOperation newEntity() { + return fishingOperation; + } +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesBatchUIModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.css 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.css 2012-12-13 01:57:28 UTC (rev 55) @@ -1,83 +0,0 @@ -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -NumberEditor { - autoPopup: {handler.getConfig().isAutoPopupNumberEditor()}; - showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; - bean: {model}; - showReset: true; -} - -#totalWeightLabel { - text: "tutti.label.species.totalWeight"; - labelFor: {totalWeightField}; -} - -#totalWeightField { - property: "totalWeight"; - model: {model.getTotalWeight()}; - useFloat: false; - numberPattern: {INT_6_DIGITS_PATTERN}; -} - -#totalVracWeightLabel { - text: "tutti.label.species.totalVracWeight"; - labelFor: {totalVracWeightField}; -} - -#totalVracWeightField { - property: "totalVracWeight"; - model: {model.getTotalVracWeight()}; - useFloat: false; - numberPattern: {INT_6_DIGITS_PATTERN}; -} - -#sampleVracWeightLabel { - text: "tutti.label.species.sampleVracWeight"; - labelFor: {sampleVracWeightField}; -} - -#sampleVracWeightField { - property: "sampleVracWeight"; - model: {model.getSampleVracWeight()}; - useFloat: false; - numberPattern: {INT_6_DIGITS_PATTERN}; -} - -#totalHorsVracWeightLabel { - text: "tutti.label.species.totalHorsVracWeight"; - labelFor: {totalHorsVracWeightField}; -} - -#totalHorsVracWeightField { - text: {getStringValue(model.getTotalHorsVracWeight())}; - editable: false; -} - -#table { - selectionMode: {ListSelectionModel.SINGLE_SELECTION}; - selectionBackground: {null}; - selectionForeground: {Color.BLACK}; - sortable: false; -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.jaxx 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUI.jaxx 2012-12-13 01:57:28 UTC (rev 55) @@ -1,119 +0,0 @@ -<!-- - #%L - Tutti :: UI - $Id$ - $HeadURL$ - %% - Copyright (C) 2012 Ifremer - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> -<JPanel id='homePanel' layout='{new BorderLayout()}' - implements='fr.ifremer.tutti.ui.swing.TuttiUI<SpeciesTabUIModel, SpeciesTabUIHandler>'> - - <import> - fr.ifremer.tutti.persistence.entities.data.FishingOperation - - fr.ifremer.tutti.ui.swing.TuttiUIContext - fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI - fr.ifremer.tutti.ui.swing.content.operation.species.SpeciesFrequencyUI - - org.jdesktop.swingx.JXTable - - jaxx.runtime.swing.editor.NumberEditor - - jaxx.runtime.validator.swing.SwingValidatorUtil - jaxx.runtime.validator.swing.SwingValidatorMessageTableModel - - javax.swing.ListSelectionModel - - java.awt.Color - - static org.nuiton.i18n.I18n._ - static jaxx.runtime.SwingUtil.getStringValue - </import> - - <script><![CDATA[ - -public SpeciesTabUI(FishingOperationsUI parentUI) { - SpeciesTabUIHandler handler = new SpeciesTabUIHandler(parentUI, this); - setContextValue(handler); - handler.beforeInitUI(); -} - -public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); } - -protected void $afterCompleteSetup() { handler.afterInitUI(); } - ]]></script> - - <SpeciesTabUIHandler id='handler' - initializer='getContextValue(SpeciesTabUIHandler.class)'/> - - <SpeciesTabUIModel id='model' - initializer='getContextValue(SpeciesTabUIModel.class)'/> - - <SwingValidatorMessageTableModel id='errorTableModel'/> - - <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' - uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> - <field name='totalWeight' component='totalWeightField'/> - <field name='totalVracWeight' component='totalVracWeightField'/> - <field name='sampleVracWeight' component='sampleVracWeightField'/> - <field name='totalHorsVracWeight' component='totalHorsVracWeightField'/> - </BeanValidator> - - <SpeciesFrequencyUI id='frequencyUI' constructorParams='handler.getContext()'/> - - <Table id='form' fill='both' constraints='BorderLayout.NORTH'> - - <!-- Poids total / Poids total vrac --> - <row> - <cell anchor='west'> - <JLabel id='totalWeightLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='totalWeightField' constructorParams='this'/> - </cell> - <cell anchor='west'> - <JLabel id='totalVracWeightLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='totalVracWeightField' constructorParams='this'/> - </cell> - </row> - - <!-- Poids échantillonné vrac / Poids total hors vrac --> - <row> - <cell> - <JLabel id='sampleVracWeightLabel'/> - </cell> - <cell> - <NumberEditor id='sampleVracWeightField' constructorParams='this'/> - </cell> - <cell> - <JLabel id='totalHorsVracWeightLabel'/> - </cell> - <cell> - <JTextField id='totalHorsVracWeightField'/> - </cell> - </row> - </Table> - - <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> - <JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event);'/> - </JScrollPane> - -</JPanel> Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java 2012-12-13 01:57:28 UTC (rev 55) @@ -1,762 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.species; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; -import fr.ifremer.tutti.persistence.entities.TuttiEntities; -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; -import fr.ifremer.tutti.persistence.entities.data.VracHorsVracEnum; -import fr.ifremer.tutti.persistence.entities.referential.Sex; -import fr.ifremer.tutti.persistence.entities.referential.Species; -import fr.ifremer.tutti.persistence.entities.referential.WeightCategory; -import fr.ifremer.tutti.service.DecoratorService; -import fr.ifremer.tutti.service.PersistenceService; -import fr.ifremer.tutti.ui.swing.TuttiUI; -import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; -import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; -import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; -import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; -import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener; -import jaxx.runtime.SwingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.JXTable; -import org.jdesktop.swingx.decorator.ComponentAdapter; -import org.jdesktop.swingx.decorator.HighlightPredicate; -import org.jdesktop.swingx.decorator.Highlighter; -import org.jdesktop.swingx.table.DefaultTableColumnModelExt; -import org.nuiton.util.beans.BeanMonitor; -import org.nuiton.util.decorator.Decorator; - -import javax.swing.event.ListSelectionListener; -import javax.swing.table.TableColumnModel; -import java.awt.Color; -import java.awt.Component; -import java.awt.event.FocusEvent; -import java.util.List; -import java.util.Set; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.1 - */ -public class SpeciesTabUIHandler extends AbstractTuttiTableUIHandler<SpeciesBatchRowModel, SpeciesTabUIModel> { - - /** Logger. */ - private static final Log log = LogFactory.getLog(SpeciesTabUIHandler.class); - - public static final Set<String> RECOMPUTE_TOTAL_WEIGHT = Sets.newHashSet( - SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC, - SpeciesBatchRowModel.PROPERTY_WEIGHT - ); - - public static final Set<String> SAMPLING_PROPERTIES = Sets.newHashSet( - SpeciesBatchRowModel.PROPERTY_SPECIES, - SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC, - SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY, - SpeciesBatchRowModel.PROPERTY_SEX, - SpeciesBatchRowModel.PROPERTY_MATURITY, - SpeciesBatchRowModel.PROPERTY_AGE - ); - - /** - * UI. - * - * @since 0.2 - */ - private final SpeciesTabUI ui; - - /** - * Persistence service. - * - * @since 0.2 - */ - private final PersistenceService persistenceService; - - /** - * To monitor changes on the fishing operation. - * - * @since 0.2 - */ - private final BeanMonitor fishingOperationMonitor; - - public SpeciesTabUIHandler(FishingOperationsUI parentUi, SpeciesTabUI ui) { - super(parentUi.getHandler().getContext(), - SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM, - SpeciesBatchRowModel.PROPERTY_SPECIES, - SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC, - SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY, - SpeciesBatchRowModel.PROPERTY_SEX, - SpeciesBatchRowModel.PROPERTY_MATURITY, - SpeciesBatchRowModel.PROPERTY_AGE, - SpeciesBatchRowModel.PROPERTY_WEIGHT, -// SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT, -// SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO, - SpeciesBatchRowModel.PROPERTY_COMMENT, - SpeciesBatchRowModel.PROPERTY_FREQUENCY); - this.ui = ui; - this.persistenceService = context.getService(PersistenceService.class); - this.fishingOperationMonitor = new BeanMonitor( - SpeciesTabUIModel.PROPERTY_SAMPLE_VRAC_WEIGHT, - SpeciesTabUIModel.PROPERTY_TOTAL_HORS_VRAC_WEIGHT, - SpeciesTabUIModel.PROPERTY_TOTAL_VRAC_WEIGHT, - SpeciesTabUIModel.PROPERTY_TOTAL_WEIGHT - ); - } - - //------------------------------------------------------------------------// - //-- AbstractTuttiTableUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - protected SpeciesTabUIModel getModel() { - return ui.getModel(); - } - - @Override - protected SpeciesBatchTableModel getTableModel() { - return (SpeciesBatchTableModel) getTable().getModel(); - } - - @Override - protected JXTable getTable() { - return ui.getTable(); - } - - @Override - protected void onModelRowsChanged(List<SpeciesBatchRowModel> rows) { - super.onModelRowsChanged(rows); - - // build the new sampling tree from the new rows to edit - getModel().getSamplingTreeModel().populate(rows); - } - - @Override - protected String[] getRowPropertiesToIgnore() { - return new String[]{ - SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT, - SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO, - SpeciesBatchRowModel.PROPERTY_FREQUENCY - }; - } - - @Override - protected TableColumnModel createTableColumnModel() { - - List<String> samplingOrder = getModel().getSamplingOrder(); - - DefaultTableColumnModelExt columnModel = - new DefaultTableColumnModelExt(); - - { - // Species to confirm column - - addBooleanColumnToModel(columnModel, - SpeciesBatchTableModel.SPECIES_TO_CONFIRM, - getTable()); - } - - List<Species> allSpecies = persistenceService.getAllSpecies(); - - { - // Species (by code) column - - Decorator<Species> decorator = getDecorator( - Species.class, DecoratorService.SPECIES_BY_CODE); - - addComboDataColumnToModel(columnModel, - SpeciesBatchTableModel.SPECIES_BY_CODE, - decorator, allSpecies); - } - - { - // Species (by genusCode) column - - Decorator<Species> decorator = getDecorator( - Species.class, DecoratorService.SPECIES_BY_GENUS); - - addComboDataColumnToModel(columnModel, - SpeciesBatchTableModel.SPECIES_BY_GENUS_CODE, - decorator, allSpecies); - - } - - if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC)) { - - // Vrac / Hors vrac column - - addComboEnumColumnToModel(columnModel, - SpeciesBatchTableModel.VRAC_HORS_VRAC, - VracHorsVracEnum.values()); - } - - if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY)) { - - // WeightCategory column - - Decorator<WeightCategory> decorator = - getDecorator(WeightCategory.class, - DecoratorService.BY_NAME); - - List<WeightCategory> data = - persistenceService.getAllWeightCategory(); - - addComboDataColumnToModel(columnModel, - SpeciesBatchTableModel.WEIGHT_CATEGORY, - decorator, data); - } - - if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_SEX)) { - - // Sex column - - Decorator<Sex> decorator = - getDecorator(Sex.class, DecoratorService.BY_NAME); - - List<Sex> data = persistenceService.getAllSex(); - - addComboDataColumnToModel(columnModel, - SpeciesBatchTableModel.SEX, - decorator, data); - } - - if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_MATURITY)) { - - // Maturity column - - addFloatColumnToModel(columnModel, - SpeciesBatchTableModel.MATURITY, - TuttiUI.DECIMAL3_PATTERN); - } - - if (samplingOrder.contains(SpeciesBatchRowModel.PROPERTY_AGE)) { - - // Age column - - addFloatColumnToModel(columnModel, - SpeciesBatchTableModel.AGE, - TuttiUI.DECIMAL3_PATTERN); - } - - { // Weight column - - addFloatColumnToModel(columnModel, - SpeciesBatchTableModel.WEIGHT, - TuttiUI.DECIMAL3_PATTERN); - } - - { // Computed weight column (from frequencies) - - addColumnToModel(columnModel, - FrequencyCellComponent.newEditor(ui.getFrequencyUI()), - FrequencyCellComponent.newRender(), - SpeciesBatchTableModel.COMPUTED_WEIGHT); - } - - { // Computed number column (from frequencies) - - addColumnToModel(columnModel, - FrequencyCellComponent.newEditor(ui.getFrequencyUI()), - FrequencyCellComponent.newRender(), - SpeciesBatchTableModel.COMPUTED_NUMBER); - } - - { // Sample weight column - - addColumnToModel(columnModel, - SpeciesBatchTableModel.SAMPLE_WEIGHT); - } - - { // SamplingRatio column - - addColumnToModel(columnModel, - SpeciesBatchTableModel.SAMPLING_RATIO); - } - - { // Comment column - - addColumnToModel(columnModel, - SpeciesBatchTableModel.COMMENT); - } - - { // File column - - addColumnToModel(columnModel, - SpeciesBatchTableModel.FILE); - } - return columnModel; - } - - @Override - protected void onRowModified(SpeciesBatchRowModel row, - String propertyName, - Object oldValue, - Object newValue) { - - if (RECOMPUTE_TOTAL_WEIGHT.contains(propertyName)) { - - // Need to recompute totalHorsVracWeight - recomputeTotalHorsVrac(); - } - - SpeciesTabUIModel model = getModel(); - - SpeciesBatchTreeModel samplingTreeModel = model.getSamplingTreeModel(); - - if (SAMPLING_PROPERTIES.contains(propertyName)) { - - // Need to rebuilt this row sampling tree path (and then recompute - // old super - samplingRatio and new super - samplingRatio) - - // old node of the previous sampling def for this row - // and remove it from any cache - SpeciesBatchTreeNode oldNode = samplingTreeModel.removeNodeFromCache(row); - - boolean rowWasValid = row.isValid(); - if (oldNode != null && rowWasValid) { - - // remove this row from his super sampling - recomputeSuperSamplingRatio(samplingTreeModel, oldNode); - } - - // get new sampling node - SpeciesBatchTreeNode newNode = samplingTreeModel.getSamplingNode(row); - - // check this row is valid - boolean rowValid = samplingTreeModel.isValid(row, newNode); - - // push this state back to the row - row.setValid(rowValid); - - if (rowValid) { - - // can add it to his super-sampling - recomputeSuperSamplingRatio(samplingTreeModel, newNode); - } else { - - if (rowWasValid) { - - row.setSampleWeight(null); - row.setSamplingRatio(null); - - getTableModel().updateSamplingRatio(Sets.newHashSet(row)); - } - } - } - - if (SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) { - - // Need to recompute the super - samplingRatio - - SpeciesBatchTreeNode node = samplingTreeModel.getSamplingNode(row); - - boolean rowWasValid = row.isValid(); - - // check this row is valid - boolean rowValid = samplingTreeModel.isValid(row, node); - - // push this state back to the row - row.setValid(rowValid); - - if (rowValid) { - recomputeSuperSamplingRatio(samplingTreeModel, node); - } else { - if (rowWasValid) { - - // must remove this row from his super-sampling - recomputeSuperSamplingRatio(samplingTreeModel, node); - - row.setSampleWeight(null); - row.setSamplingRatio(null); - - getTableModel().updateSamplingRatio(Sets.newHashSet(row)); - } - } - } - } - - @Override - protected void onRowValidStateChanged(SpeciesBatchRowModel row, - Boolean oldValue, - Boolean newValue) { - int rowIndex = getTableModel().getRowIndex(row); - - if (rowIndex > -1) { - getTableModel().fireTableRowsUpdated(rowIndex, rowIndex); - } - } - - @Override - protected void onRowModifyStateChanged(SpeciesBatchRowModel row, - Boolean oldValue, - Boolean newValue) { - } - - //------------------------------------------------------------------------// - //-- AbstractTuttiUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - public void beforeInitUI() { - - if (log.isInfoEnabled()) { - log.info("beforeInit: " + ui); - } - - SpeciesTabUIModel model = new SpeciesTabUIModel(); - ui.setContextValue(model); - - fishingOperationMonitor.setBean(model); - } - - @Override - public void afterInitUI() { - - if (log.isInfoEnabled()) { - log.info("afterInit: " + ui); - } - - initUI(ui); - - //TODO Will come from protocol - List<String> samplingOrder = Lists.newArrayList( - SpeciesBatchRowModel.PROPERTY_SPECIES, - SpeciesBatchRowModel.PROPERTY_VRAC_HORS_VRAC, - SpeciesBatchRowModel.PROPERTY_WEIGHT_CATEGORY, - SpeciesBatchRowModel.PROPERTY_SEX - ); - - getModel().setSamplingOrder(samplingOrder); - - JXTable table = getTable(); - - // create table column model - TableColumnModel columnModel = createTableColumnModel(); - - // create table model - SpeciesBatchTableModel tableModel = - new SpeciesBatchTableModel(columnModel); - - table.setModel(tableModel); - table.setColumnModel(columnModel); - installTableKeyListener(columnModel, table); - - table.getTableHeader().setReorderingAllowed(false); - - - Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY); - - table.addHighlighter(readOnlyHighlighter); - Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter( - new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - - boolean result = false; - if (adapter.isEditable()) { - int rowIndex = adapter.convertRowIndexToModel(adapter.row); - SpeciesBatchRowModel row = getTableModel().getEntry(rowIndex); - result = !row.isValid(); - } - return result; - } - }), Color.RED); - table.addHighlighter(validHighlighter); - - // when model datas change let's propagate it table model - listenRowsFromModel(); - - // save when row chaged and was modified - ListSelectionListener listener = new TableRowModificationListener<SpeciesBatchRowModel>( - getTableModel(), getRowMonitor()) { - @Override - protected void saveSelectedRow() { - saveSelectedRowIfRequired(); - } - }; - table.getSelectionModel().addListSelectionListener(listener); - - // always scroll to selected row - SwingUtil.scrollToTableSelection(getTable()); - } - - @Override - public void onCloseUI() { - if (log.isInfoEnabled()) { - log.info("closing: " + ui); - } - } - - //------------------------------------------------------------------------// - //-- Public methods --// - //------------------------------------------------------------------------// - - public void saveSelectedRowIfRequired(FocusEvent event) { - - Component oppositeComponent = event.getOppositeComponent(); - - JXTable parentContainer = null; - - if (oppositeComponent != null) { - - // check out if still on table - parentContainer = SwingUtil.getParentContainer( - oppositeComponent, JXTable.class); - } - - if (parentContainer == null) { - - // out of the table can save - if (getModel().getFishingOperation()!=null) { - saveSelectedRowIfRequired(); - } - } - } - - public void selectFishingOperation(FishingOperation bean) { - - JXTable table = ui.getTable(); - - if (table.isEditing()) { - - // make sure to stop editor - table.editingCanceled(null); - } - - if (fishingOperationMonitor.wasModified()) { - - // previous fishingOperation was modified, let's save it - SpeciesTabUIModel traitMonitorBean = - (SpeciesTabUIModel) fishingOperationMonitor.getBean(); - - FishingOperation fishingOperation = traitMonitorBean.toBean(); - - if (log.isInfoEnabled()) { - log.info("FishingOperation " + fishingOperation.getId() + - " was modified, will save it."); - } - - persistenceService.saveFishingOperation(fishingOperation); - } - - // make sure selection is empty (will remove bean from monitor) - table.clearSelection(); - - boolean empty = bean == null; - - SpeciesTabUIModel model = getModel(); - - List<SpeciesBatchRowModel> rows; - - if (empty) { - rows = null; - bean = new FishingOperation(); - model.setFishingOperation(null); - } else { - - if (log.isInfoEnabled()) { - log.info("Get species batch for fishingOperation: " + bean.getId()); - } - rows = Lists.newArrayList(); - - if (!TuttiEntities.isNew(bean)) { - List<SpeciesBatch> catches = - persistenceService.getAllSpeciesBatch(bean.getId()); - for (SpeciesBatch aBatch : catches) { - List<SpeciesBatchFrequency> frequencies = - persistenceService.getAllSpeciesBatchFrequency(aBatch.getId()); - SpeciesBatchRowModel entry = - new SpeciesBatchRowModel(aBatch, frequencies); - rows.add(entry); - } - } - model.setFishingOperation(bean); - } - - model.fromBean(bean); - model.setRows(rows); - - fishingOperationMonitor.clearModified(); - } - - //------------------------------------------------------------------------// - //-- Internal methods --// - //------------------------------------------------------------------------// - - protected void recomputeSuperSamplingRatio(SpeciesBatchTreeModel samplingTreeModel, - SpeciesBatchTreeNode node) { - - SpeciesBatchTreeNode superSamplingNode = node.getParent(); - - Preconditions.checkNotNull(superSamplingNode, - "Super sampling node can't be null"); - - SpeciesBatchTreeModel.SamplingContext samplingContext = - samplingTreeModel.createSamplingContext(superSamplingNode); - - float samplingTotalWeight = samplingContext.getTotalWeight(); - Float superSamplingTotalWeight; - SpeciesBatchRowModel superSamplingRow = - samplingContext.getSuperSamplingRow(); - if (superSamplingRow == null) { - - // Use directly the batch total weight (means no super-sampling) - - superSamplingTotalWeight = getModel().getTotalWeight(); - } else { - superSamplingTotalWeight = superSamplingRow.getWeight(); - } - - if (log.isInfoEnabled()) { - log.info("Super sampling total weight: " + - superSamplingTotalWeight); - } - - Float samplingRatio = null; - if (superSamplingTotalWeight != null) { - samplingRatio = samplingTotalWeight / superSamplingTotalWeight; - } - - if (log.isInfoEnabled()) { - log.info("Sampling ratio: " + samplingRatio); - } - - samplingContext.applyNewSampleValues(samplingTotalWeight, - samplingRatio); - - getTableModel().updateSamplingRatio(samplingContext.getSamplingRows()); - } - - - protected void recomputeTotalHorsVrac() { - - // recompute total hors vrac - Float totalHorsVrac = 0f; - Float totalVrac = 0f; - - for (SpeciesBatchRowModel batch : getModel().getRows()) { - VracHorsVracEnum vracHorsVrac = batch.getVracHorsVrac(); - if (vracHorsVrac == null) { - - // can't sum anything - } else if (vracHorsVrac == VracHorsVracEnum.HORS_VRAC) { - Float weight = batch.getWeight(); - if (weight != null) { - totalHorsVrac += weight; - } - } else if (vracHorsVrac == VracHorsVracEnum.VRAC) { - Float weight = batch.getWeight(); - if (weight != null) { - totalVrac += weight; - } - } - } - if (log.isInfoEnabled()) { - log.info("New total vrac / hors vrac: " + - totalVrac + " / " + totalHorsVrac); - } - getModel().setTotalHorsVracWeight(totalHorsVrac); - //TODO Should we also set the total vrac weight ? -// getModel().setTotalVracWeight(totalVrac); - } - - protected void saveSelectedRowIfRequired() { - - TuttiBeanMonitor<SpeciesBatchRowModel> rowMonitor = getRowMonitor(); - - SpeciesBatchRowModel bean = rowMonitor.getBean(); - if (bean != null) { - - if (bean.isValid()) { - // there is a valid bean attached to the monitor - - if (rowMonitor.wasModified()) { - - // monitored bean was modified, save it - if (log.isInfoEnabled()) { - log.info("Row " + bean + " was modified, will save it"); - } - - saveRow(bean); - - // clear modified flag on the monitor - rowMonitor.clearModified(); - } - } else { - - // row is not valid can not save it - - SpeciesBatch catchBean = bean.toBean(); - - FishingOperation fishingOperation = getModel().getFishingOperation(); - - if (!TuttiEntities.isNew(catchBean)) { - - // remove this - persistenceService.deleteSpeciesBatch(catchBean.getId()); - } - } - } - } - - protected void saveRow(SpeciesBatchRowModel row) { - - SpeciesBatch catchBean = row.toBean(); - - FishingOperation fishingOperation = getModel().getFishingOperation(); - catchBean.setFishingOperation(fishingOperation); - if (log.isInfoEnabled()) { - log.info("Selected fishingOperation: " + fishingOperation.getId()); - } - - if (TuttiEntities.isNew(catchBean)) { - - catchBean = persistenceService.createSpeciesBatch(catchBean); - row.setId(catchBean.getId()); - } else { - persistenceService.saveSpeciesBatch(catchBean); - } - - List<SpeciesFrequencyRowModel> frequencyRows = row.getFrequency(); - - List<SpeciesBatchFrequency> frequency = - SpeciesFrequencyRowModel.toBeans(frequencyRows, catchBean); - - if (log.isInfoEnabled()) { - log.info("Will save " + frequency.size() + " frequencies."); - } - frequency = persistenceService.saveSpeciesBatchFrequency( - catchBean.getId(), frequency); - - // push it back to row model - frequencyRows = SpeciesFrequencyRowModel.fromBeans(frequency); - row.setFrequency(frequencyRows); - } -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIModel.java 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIModel.java 2012-12-13 01:57:28 UTC (rev 55) @@ -1,184 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.species; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; -import org.nuiton.util.beans.Binder; -import org.nuiton.util.beans.BinderModelBuilder; - -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.1 - */ -public class SpeciesTabUIModel extends AbstractTuttiTableUIModel<FishingOperation, SpeciesBatchRowModel, SpeciesTabUIModel> { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; - - public static final String PROPERTY_TOTAL_VRAC_WEIGHT = "totalVracWeight"; - - public static final String PROPERTY_SAMPLE_VRAC_WEIGHT = "sampleVracWeight"; - - public static final String PROPERTY_TOTAL_HORS_VRAC_WEIGHT = "totalHorsVracWeight"; - - /** - * Editing fishing operation. - * - * @since 0.2 - */ - protected FishingOperation fishingOperation; - - /** - * Total Weight filled in screen. - * - * @since 0.2 - */ - protected Float totalWeight; - - /** - * Total vrac Weight filled in screen. - * - * @since 0.2 - */ - protected Float totalVracWeight; - - /** - * Total sample vrac Weight filled in screen. - * - * @since 0.2 - */ - protected Float sampleVracWeight; - - /** - * Total hors vrac Weight computed by hros vrac rows. - * - * @since 0.2 - */ - protected Float totalHorsVracWeight; - - /** - * Sampling order (sets by protocol). - * - * @since 0.2 - */ - protected List<String> samplingOrder; - - /** - * Tree of sampling for batch rows. - * - * @since 0.2 - */ - protected final SpeciesBatchTreeModel samplingTreeModel; - - protected static final Binder<FishingOperation, SpeciesTabUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, SpeciesTabUIModel.class) - .addProperty("speciesTotalWeight", PROPERTY_TOTAL_WEIGHT) - .addProperty("speciesTotalHorsVracWeight", PROPERTY_TOTAL_HORS_VRAC_WEIGHT) - .addProperty("speciesTotalVracWeight", PROPERTY_TOTAL_VRAC_WEIGHT) - .addProperty("speciesSampleVracWeight", PROPERTY_SAMPLE_VRAC_WEIGHT) - .addProperty("id", PROPERTY_ID) - .toBinder(); - - protected static final Binder<SpeciesTabUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(SpeciesTabUIModel.class, FishingOperation.class) - .addProperty(PROPERTY_TOTAL_WEIGHT, "speciesTotalWeight") - .addProperty(PROPERTY_TOTAL_HORS_VRAC_WEIGHT, "speciesTotalHorsVracWeight") - .addProperty(PROPERTY_TOTAL_VRAC_WEIGHT, "speciesTotalVracWeight") - .addProperty(PROPERTY_SAMPLE_VRAC_WEIGHT, "speciesSampleVracWeight") - .toBinder(); - - public SpeciesTabUIModel() { - super(FishingOperation.class, fromBeanBinder, toBeanBinder); - this.samplingTreeModel = new SpeciesBatchTreeModel(); - } - - public FishingOperation getFishingOperation() { - return fishingOperation; - } - - public void setFishingOperation(FishingOperation fishingOperation) { - this.fishingOperation = fishingOperation; - } - - public SpeciesBatchTreeModel getSamplingTreeModel() { - return samplingTreeModel; - } - - public Float getTotalWeight() { - return totalWeight; - } - - public void setTotalWeight(Float totalWeight) { - Object oldValue = getTotalWeight(); - this.totalWeight = totalWeight; - firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); - } - - public Float getTotalVracWeight() { - return totalVracWeight; - } - - public void setTotalVracWeight(Float totalVracWeight) { - Object oldValue = getTotalVracWeight(); - this.totalVracWeight = totalVracWeight; - firePropertyChange(PROPERTY_TOTAL_VRAC_WEIGHT, oldValue, totalVracWeight); - } - - public Float getSampleVracWeight() { - return sampleVracWeight; - } - - public void setSampleVracWeight(Float sampleVracWeight) { - Object oldValue = getSampleVracWeight(); - this.sampleVracWeight = sampleVracWeight; - firePropertyChange(PROPERTY_SAMPLE_VRAC_WEIGHT, oldValue, sampleVracWeight); - } - - public Float getTotalHorsVracWeight() { - return totalHorsVracWeight; - } - - public void setTotalHorsVracWeight(Float totalHorsVracWeight) { - Object oldValue = getTotalHorsVracWeight(); - this.totalHorsVracWeight = totalHorsVracWeight; - firePropertyChange(PROPERTY_TOTAL_HORS_VRAC_WEIGHT, oldValue, totalHorsVracWeight); - } - - public List<String> getSamplingOrder() { - return samplingOrder; - } - - public void setSamplingOrder(List<String> samplingOrder) { - this.samplingOrder = samplingOrder; - samplingTreeModel.setSamplingOrder(samplingOrder.toArray(new String[samplingOrder.size()])); - } - - @Override - protected FishingOperation newEntity() { - return fishingOperation; - } -} Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-12 22:50:50 UTC (rev 54) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-13 01:57:28 UTC (rev 55) @@ -43,8 +43,6 @@ tutti.config.ui.showNumberEditorButton=Afficher le pavé numérique de saisie tutti.label.benthos.sampleTotalWeight=Poids total échantillonné tutti.label.benthos.totalWeight=Poids total -tutti.label.captureAccidentel.sampleTotalWeight=Poids total échantillonné -tutti.label.captureAccidentel.totalWeight=Poids total tutti.label.comment=Commentaire tutti.label.cruise=Campagne tutti.label.cruise.beginDate=Date de début @@ -68,25 +66,18 @@ tutti.label.fishingOperation.gearDate=Date tutti.label.fishingOperation.gearLatitude=Latitude tutti.label.fishingOperation.gearLongitude=Longitude -tutti.label.fishingOperation.gearShootingDate=Date tutti.label.fishingOperation.gearShootingEnd=Fin de traine tutti.label.fishingOperation.gearShootingEndBottomSalinity=Salinité de fond fin de traine tutti.label.fishingOperation.gearShootingEndBottomTemperature=Température de fond fin de traine tutti.label.fishingOperation.gearShootingEndDepth=Profondeur fin de traine tutti.label.fishingOperation.gearShootingEndSurfaceSalinity=Salinité de surface fin de traine tutti.label.fishingOperation.gearShootingEndSurfaceTemperature=Temperature de surface fin de traine -tutti.label.fishingOperation.gearShootingLatitude=Latitude -tutti.label.fishingOperation.gearShootingLongitude=Longitude tutti.label.fishingOperation.gearShootingStart=Début de traine tutti.label.fishingOperation.gearShootingStartBottomSalinity=Salinité de fond début de traine tutti.label.fishingOperation.gearShootingStartBottomTemperature=Température de fond début de traine tutti.label.fishingOperation.gearShootingStartDepth=Profondeur début de traine -tutti.label.fishingOperation.gearShootingStartLatitude=Latitude début de traine -tutti.label.fishingOperation.gearShootingStartLongitude=Longitude début de traine tutti.label.fishingOperation.gearShootingStartSurfaceSalinity=Salinité de surface début de traine tutti.label.fishingOperation.gearShootingStartSurfaceTemperature=Temperature de surface début de traine -tutti.label.fishingOperation.gearShootingStartTime=Début de traine -tutti.label.fishingOperation.gearShootingTime=Heure tutti.label.fishingOperation.gearTime=Heure tutti.label.fishingOperation.geometrieMesuree=Géométrie mesurée tutti.label.fishingOperation.localite=Localité @@ -102,7 +93,6 @@ tutti.label.fishingOperation.windDirection=Direction du vent tutti.label.frequencyConfiguration.maxStep=Classe max tutti.label.frequencyConfiguration.minStep=Classe min -tutti.label.frequencyConfiguration.mode=Mode de saisie tutti.label.frequencyConfiguration.mode.autoGen=Génération des classes tutti.label.frequencyConfiguration.mode.autoGen.tip=Mode où toutes les classes de taille sont générées tutti.label.frequencyConfiguration.mode.rafale=Mode "rafale" @@ -115,13 +105,11 @@ tutti.label.list.gear=Engin(s) tutti.label.list.headOfMission=Chef(s) de mission tutti.label.list.headOfSortRoom=Reponsable(s) de salle de tri -tutti.label.list.saisisseur=Nom des saisisseurs tutti.label.list.vessel=Navire(s) -tutti.label.macroDechet.sampleTotalWeight=Poids total échantillonné -tutti.label.macroDechet.totalWeight=Poids total +tutti.label.macroWaste.totalWeight=Poids total tutti.label.no.fishingOperation.selected=< Aucun trait sélectionné > -tutti.label.plancton.sampleTotalWeight=Poids total échantillonné -tutti.label.plancton.totalWeight=Poids total +tutti.label.plankton.sampleTotalWeight=Poids total échantillonné +tutti.label.plankton.totalWeight=Poids total tutti.label.program=Série de campagne tutti.label.program.name=Nom tutti.label.program.zone=Zone @@ -155,26 +143,35 @@ tutti.menu.synchronisationImport.tip=Effectuer des imports tutti.menu.synchronisations=Synchronisation tutti.menu.synchronisations.tip=Import/Export -tutti.table.benthos.header.number=Nombre observé -tutti.table.benthos.header.speciesByCode=Espèce -tutti.table.benthos.header.weight=Poids observé -tutti.table.captureAccidentel.header.number=Nombre observé -tutti.table.captureAccidentel.header.speciesByCode=Espèce -tutti.table.captureAccidentel.header.weight=Poids observé -tutti.table.macroDechet.header.number=Nombre observé -tutti.table.macroDechet.header.speciesByCode=Espèce -tutti.table.macroDechet.header.weight=Poids observé -tutti.table.plancton.header.number=Nombre observé -tutti.table.plancton.header.speciesByCode=Espèce -tutti.table.plancton.header.weight=Poids observé +tutti.table.benthos.batch.header.comment=Commentaire +tutti.table.benthos.batch.header.elevationRate=Fraction d'élévation +tutti.table.benthos.batch.header.file=Pièces jointes +tutti.table.benthos.batch.header.sampleWeight=Poids échantillonné +tutti.table.benthos.batch.header.speciesByCode=Espèce +tutti.table.benthos.batch.header.speciesByGenusCode=Espèce +tutti.table.benthos.batch.header.toConfirm=A Confirmer +tutti.table.benthos.batch.header.weight=Poids +tutti.table.macrowaste.batch.header.comment=Commentaire +tutti.table.macrowaste.batch.header.file=Pièces jointes +tutti.table.macrowaste.batch.header.speciesByCode=Espèce +tutti.table.macrowaste.batch.header.speciesByGenusCode=Espèce +tutti.table.macrowaste.batch.header.weight=Poids +tutti.table.plankton.batch.header.comment=Commentaire +tutti.table.plankton.batch.header.elevationRate=Fraction d'élévation +tutti.table.plankton.batch.header.file=Pièces jointes +tutti.table.plankton.batch.header.sampleWeight=Poids échantillonné +tutti.table.plankton.batch.header.speciesByCode=Espèce +tutti.table.plankton.batch.header.speciesByGenusCode=Espèce +tutti.table.plankton.batch.header.toConfirm=A Confirmer +tutti.table.plankton.batch.header.weight=Poids tutti.table.species.batch.header.age=Age tutti.table.species.batch.header.comment=Commentaire tutti.table.species.batch.header.computedNumber=Nombre calculé tutti.table.species.batch.header.computedWeight=Poids calculé -tutti.table.species.batch.header.elevationRate=Fraction d'él +tutti.table.species.batch.header.elevationRate=Fraction d'élévation tutti.table.species.batch.header.file=Pièces jointes tutti.table.species.batch.header.maturity=Maturité -tutti.table.species.batch.header.sampleWeight=Poids échan +tutti.table.species.batch.header.sampleWeight=Poids échantillonné tutti.table.species.batch.header.sex=Sexe tutti.table.species.batch.header.speciesByCode=Espèce tutti.table.species.batch.header.speciesByGenusCode=Espèce @@ -191,8 +188,8 @@ tutti.title.create.cruise=Créer une nouvelle campagne tutti.title.create.program=Créer une nouvelle série de campagne tutti.title.edit.cruise=Editer une campagne existante +tutti.title.edit.operations=Saisie des opérations de pêches (%s) tutti.title.edit.program=Editer une série de campagne existante -tutti.title.fill.catches=Saisie des captures tutti.title.frequency=Saisie des mensurations tutti.title.home=Sélection de la campagne tutti.title.noSelectedCruise=Pas de campagne sélectionné
participants (1)
-
tchemit@users.forge.codelutin.com