Author: tchemit Date: 2013-04-04 10:17:58 +0200 (Thu, 04 Apr 2013) New Revision: 730 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/730 Log: continue model imporvment Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-04-04 08:17:26 UTC (rev 729) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-04-04 08:17:58 UTC (rev 730) @@ -123,14 +123,14 @@ public static final String PROPERTY_SAMPLE_CATEGORY = "sampleCategory"; /** - * Species. + * Delegate edit object. * - * @since 0.3 + * @since 1.3 */ - protected Species species; + protected final SpeciesBatch editObject = TuttiBeanFactory.newSpeciesBatch(); /** - * Is catch is vrac or horsVrac?. + * Sorted - Unsroted category (can not be null). * * @since 0.2 */ @@ -167,7 +167,7 @@ /** * Sample category of this batch. * <p/> - * This is one of the sample category befined above, used to know if the + * This is one of the sample category defined above, used to know if the * table row which sample category affects this row exactly. * * @since 0.3 @@ -175,13 +175,6 @@ private SampleCategory<?> sampleCategory; /** - * Is the species need to be confirmed?. - * - * @since 0.2 - */ - protected boolean speciesToConfirm; - - /** * Observed weight. * * @since 0.2 @@ -198,13 +191,6 @@ new TuttiComputedOrNotData<Integer>(); /** - * Comment. - * - * @since 0.2 - */ - protected String comment; - - /** * Attachments (should never be null). * * @since 0.2 @@ -219,14 +205,6 @@ protected List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList(); /** - * Parent of this batch (can be null if batch is root). - * - * @see #isBatchRoot() - * @since 0.3 - */ - protected SpeciesBatchRowModel parentBatch; - - /** * List of child batches (can be null or empty if batch is a leaf). * * @see #isBatchLeaf() @@ -274,6 +252,197 @@ } //------------------------------------------------------------------------// + //-- SpeciesBatch --// + //------------------------------------------------------------------------// + + @Override + public Species getSpecies() { + return editObject.getSpecies(); + } + + @Override + public void setSpecies(Species species) { + Object oldCategory = getSpecies(); + editObject.setSpecies(species); + firePropertyChange(PROPERTY_SPECIES, oldCategory, species); + } + + @Override + public String getComment() { + return editObject.getComment(); + } + + @Override + public void setComment(String comment) { + Object oldValue = getComment(); + editObject.setComment(comment); + firePropertyChange(PROPERTY_COMMENT, oldValue, comment); + } + + @Override + public boolean isSpeciesToConfirm() { + return editObject.isSpeciesToConfirm(); + } + + @Override + public void setSpeciesToConfirm(boolean speciesToConfirm) { + Object oldValue = isSpeciesToConfirm(); + editObject.setSpeciesToConfirm(speciesToConfirm); + firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm); + } + + @Override + public Integer getComputedNumber() { + return computedOrNotNumber.getComputedData(); + } + + @Override + public void setComputedNumber(Integer computedNumber) { + computedOrNotNumber.setComputedData(computedNumber); + } + + @Override + public Float getComputedWeight() { + return computedOrNotWeight.getComputedData(); + } + + @Override + public void setComputedWeight(Float computedWeight) { + computedOrNotWeight.setComputedData(computedWeight); + } + + @Override + public FishingOperation getFishingOperation() { + return editObject.getFishingOperation(); + } + + @Override + public void setFishingOperation(FishingOperation fishingOperation) { + editObject.setFishingOperation(fishingOperation); + } + + @Override + public SpeciesBatchRowModel getParentBatch() { + return (SpeciesBatchRowModel) editObject.getParentBatch(); + } + + @Override + public void setParentBatch(SpeciesBatch parentBatch) { + Object oldValue = getParentBatch(); + editObject.setParentBatch(parentBatch); + firePropertyChange(PROPERTY_PARENT_BATCH, oldValue, parentBatch); + firePropertyChange(PROPERTY_BATCH_ROOT, null, isBatchRoot()); + } + + @Override + public Float getWeight() { + return computedOrNotWeight.getData(); + } + + @Override + public void setWeight(Float weight) { + this.computedOrNotWeight.setData(weight); + } + + @Override + public SampleCategoryEnum getSampleCategoryType() { + return null; + } + + @Override + public void setSampleCategoryType(SampleCategoryEnum sampleCategoryType) { + } + + @Override + public Serializable getSampleCategoryValue() { + return null; + } + + @Override + public void setSampleCategoryValue(Serializable sampleCategoryValue) { + } + + @Override + public Float getSampleCategoryWeight() { + return null; + } + + @Override + public void setSampleCategoryWeight(Float sampleCategoryWeight) { + } + + @Override + public Integer getNumber() { + return computedOrNotNumber.getData(); + } + + @Override + public void setNumber(Integer number) { + computedOrNotNumber.setData(number); + } + + @Override + public Float getSampleCategoryComputedWeight() { + return null; + } + + @Override + public void setSampleCategoryComputedWeight(Float sampleCategoryComputedWeight) { + } + + @Override + public SpeciesBatch getChildBatchs(int index) { + return null; + } + + @Override + public boolean isChildBatchsEmpty() { + return false; + } + + @Override + public int sizeChildBatchs() { + return 0; + } + + @Override + public void addChildBatchs(SpeciesBatch childBatchs) { + } + + @Override + public void addAllChildBatchs(Collection<SpeciesBatch> childBatchs) { + } + + @Override + public boolean removeChildBatchs(SpeciesBatch childBatchs) { + return false; + } + + @Override + public boolean removeAllChildBatchs(Collection<SpeciesBatch> childBatchs) { + return false; + } + + @Override + public boolean containsChildBatchs(SpeciesBatch childBatchs) { + return false; + } + + @Override + public boolean containsAllChildBatchs(Collection<SpeciesBatch> childBatchs) { + return false; + } + + @Override + public List<SpeciesBatch> getChildBatchs() { + return null; + } + + @Override + public void setChildBatchs(List<SpeciesBatch> childBatchs) { + } + + //------------------------------------------------------------------------// //-- Sample category --// //------------------------------------------------------------------------// @@ -330,20 +499,6 @@ } //------------------------------------------------------------------------// - //-- Species category --// - //------------------------------------------------------------------------// - - public Species getSpecies() { - return species; - } - - public void setSpecies(Species species) { - Object oldCategory = getSpecies(); - this.species = species; - firePropertyChange(PROPERTY_SPECIES, oldCategory, species); - } - - //------------------------------------------------------------------------// //-- SortedUnsorted category --// //------------------------------------------------------------------------// @@ -564,61 +719,6 @@ } //------------------------------------------------------------------------// - //-- Navigation properties --// - //------------------------------------------------------------------------// - - @Override - public SpeciesBatchRowModel getParentBatch() { - return parentBatch; - } - - @Override - public void setParentBatch(SpeciesBatch parentBatch) { - } - - public void setParentBatch(SpeciesBatchRowModel parentBatch) { - Object oldValue = getParentBatch(); - this.parentBatch = parentBatch; - firePropertyChange(PROPERTY_PARENT_BATCH, oldValue, parentBatch); - firePropertyChange(PROPERTY_BATCH_ROOT, null, isBatchRoot()); - } - - public List<SpeciesBatchRowModel> getChildBatch() { - return childBatch; - } - - public void setChildBatch(List<SpeciesBatchRowModel> childBatch) { - this.childBatch = childBatch; - // force to propagate child changes - firePropertyChange(PROPERTY_CHILD_BATCH, null, childBatch); - firePropertyChange(PROPERTY_BATCH_LEAF, null, isBatchLeaf()); - } - - public boolean isBatchLeaf() { - return CollectionUtils.isEmpty(childBatch); - } - - public boolean isBatchRoot() { - return parentBatch == null; - } - - //------------------------------------------------------------------------// - //-- CommentAware --// - //------------------------------------------------------------------------// - - @Override - public String getComment() { - return comment; - } - - @Override - public void setComment(String comment) { - Object oldValue = getComment(); - this.comment = comment; - firePropertyChange(PROPERTY_COMMENT, oldValue, comment); - } - - //------------------------------------------------------------------------// //-- AttachmentModelAware --// //------------------------------------------------------------------------// @@ -665,134 +765,25 @@ //-- Other properties --// //------------------------------------------------------------------------// - @Override - public boolean isSpeciesToConfirm() { - return speciesToConfirm; + public List<SpeciesBatchRowModel> getChildBatch() { + return childBatch; } - public void setSpeciesToConfirm(boolean speciesToConfirm) { - Object oldValue = isSpeciesToConfirm(); - this.speciesToConfirm = speciesToConfirm; - firePropertyChange(PROPERTY_SPECIES_TO_CONFIRM, oldValue, speciesToConfirm); + public void setChildBatch(List<SpeciesBatchRowModel> childBatch) { + this.childBatch = childBatch; + // force to propagate child changes + firePropertyChange(PROPERTY_CHILD_BATCH, null, childBatch); + firePropertyChange(PROPERTY_BATCH_LEAF, null, isBatchLeaf()); } - @Override - public FishingOperation getFishingOperation() { - return null; + public boolean isBatchLeaf() { + return CollectionUtils.isEmpty(childBatch); } - @Override - public void setFishingOperation(FishingOperation fishingOperation) { + public boolean isBatchRoot() { + return getParentBatch() == null; } - @Override - public Float getWeight() { - return computedOrNotWeight.getData(); - } - - @Override - public void setWeight(Float weight) { - this.computedOrNotWeight.setData(weight); - } - - @Override - public SampleCategoryEnum getSampleCategoryType() { - return null; - } - - @Override - public void setSampleCategoryType(SampleCategoryEnum sampleCategoryType) { - } - - @Override - public Serializable getSampleCategoryValue() { - return null; - } - - @Override - public void setSampleCategoryValue(Serializable sampleCategoryValue) { - } - - @Override - public Float getSampleCategoryWeight() { - return null; - } - - @Override - public void setSampleCategoryWeight(Float sampleCategoryWeight) { - } - - @Override - public Integer getNumber() { - return computedOrNotNumber.getData(); - } - - @Override - public void setNumber(Integer number) { - computedOrNotNumber.setData(number); - } - - @Override - public Float getSampleCategoryComputedWeight() { - return null; - } - - @Override - public void setSampleCategoryComputedWeight(Float sampleCategoryComputedWeight) { - } - - @Override - public SpeciesBatch getChildBatchs(int index) { - return null; - } - - @Override - public boolean isChildBatchsEmpty() { - return false; - } - - @Override - public int sizeChildBatchs() { - return 0; - } - - @Override - public void addChildBatchs(SpeciesBatch childBatchs) { - } - - @Override - public void addAllChildBatchs(Collection<SpeciesBatch> childBatchs) { - } - - @Override - public boolean removeChildBatchs(SpeciesBatch childBatchs) { - return false; - } - - @Override - public boolean removeAllChildBatchs(Collection<SpeciesBatch> childBatchs) { - return false; - } - - @Override - public boolean containsChildBatchs(SpeciesBatch childBatchs) { - return false; - } - - @Override - public boolean containsAllChildBatchs(Collection<SpeciesBatch> childBatchs) { - return false; - } - - @Override - public List<SpeciesBatch> getChildBatchs() { - return null; - } - - @Override - public void setChildBatchs(List<SpeciesBatch> childBatchs) { - } - public List<SpeciesFrequencyRowModel> getFrequency() { return frequency; } @@ -803,26 +794,6 @@ firePropertyChange(PROPERTY_FREQUENCY, null, frequency); } - @Override - public Integer getComputedNumber() { - return computedOrNotNumber.getComputedData(); - } - - @Override - public void setComputedNumber(Integer computedNumber) { - computedOrNotNumber.setComputedData(computedNumber); - } - - @Override - public Float getComputedWeight() { - return computedOrNotWeight.getComputedData(); - } - - @Override - public void setComputedWeight(Float computedWeight) { - computedOrNotWeight.setComputedData(computedWeight); - } - public TuttiComputedOrNotData<Integer> getComputedOrNotNumber() { return computedOrNotNumber; }