r114 - in trunk: tutti-persistence/src/main/xmi tutti-service/src/main/java/fr/ifremer/tutti/service tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton tutti-ui-swing/src/main/java/fr/
Author: tchemit Date: 2012-12-28 09:34:01 +0100 (Fri, 28 Dec 2012) New Revision: 114 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/114 Log: refs #1805: [Onglet Poisson] Assistance ?\195?\160 la saisie des lots de poissons Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryEditor.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryRenderer.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/TableViewMode.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java Removed: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/FrequencyCellComponent.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIModel.java Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java 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/SpeciesBatchTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTreeModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyRowModelTest.java Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo =================================================================== (Binary files differ) Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2012-12-28 08:34:01 UTC (rev 114) @@ -104,6 +104,14 @@ registerMultiJXPathDecorator(Species.class, SPECIES_BY_GENUS, "${genusSpecies}$s", SEPARATOR, " - "); registerMultiJXPathDecorator(SpeciesProtocol.class, "${speciesId}", SEPARATOR, " - "); registerMultiJXPathDecorator(Attachment.class, "${name}$s", SEPARATOR, " - "); + registerDecorator(new Decorator<Float>(Float.class) { + private static final long serialVersionUID = 1L; + + @Override + public String toString(Object bean) { + return bean == null ? "" : String.valueOf(bean); + } + }); } }; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2012-12-28 08:34:01 UTC (rev 114) @@ -43,6 +43,7 @@ import org.jdesktop.swingx.table.DefaultTableColumnModelExt; import org.nuiton.util.decorator.Decorator; +import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; import java.util.List; @@ -99,7 +100,7 @@ } @Override - protected TableColumnModel createTableColumnModel() { + protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) { DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt(); @@ -327,7 +328,7 @@ JXTable table = getTable(); // create table column model - TableColumnModel columnModel = createTableColumnModel(); + TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class)); // create table model AccidentalBatchTableModel tableModel = Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2012-12-28 08:34:01 UTC (rev 114) @@ -49,10 +49,10 @@ public static final String PROPERTY_WEIGHT = "weight"; + public static final String PROPERTY_NUMBER = "number"; + public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight"; - public static final String PROPERTY_SAMPLING_RATIO = "samplingRatio"; - public static final String PROPERTY_COMMENT = "comment"; public static final String PROPERTY_ATTACHMENTS = "attachments"; @@ -79,19 +79,20 @@ protected Float weight; /** - * Sample weight. + * Observed number. * - * @since 0.2 + * @since 0.3 */ - protected Float sampleWeight; + protected Integer number; /** - * Sampling ratio. + * Sample weight. * * @since 0.2 */ - protected Float samplingRatio; + protected Float sampleWeight; + /** * Comment on this catches. * @@ -163,14 +164,14 @@ firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight); } - public Float getSamplingRatio() { - return samplingRatio; + public Integer getNumber() { + return number; } - public void setSamplingRatio(Float samplingRatio) { - Object oldValue = getSamplingRatio(); - this.samplingRatio = samplingRatio; - firePropertyChange(PROPERTY_SAMPLING_RATIO, oldValue, samplingRatio); + public void setNumber(Integer number) { + Object oldValue = getNumber(); + this.number = number; + firePropertyChange(PROPERTY_NUMBER, oldValue, number); } public String getComment() { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2012-12-28 08:34:01 UTC (rev 114) @@ -56,16 +56,17 @@ n_("tutti.table.benthos.batch.header.weight"), n_("tutti.table.benthos.batch.header.weight")); + public static final ColumnIdentifier<BenthosBatchRowModel> NUMBER = ColumnIdentifier.newId( + BenthosBatchRowModel.PROPERTY_NUMBER, + n_("tutti.table.benthos.batch.header.number"), + n_("tutti.table.benthos.batch.header.number")); + + 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.samplingRatio"), - n_("tutti.table.benthos.batch.header.samplingRatio")); - public static final ColumnIdentifier<BenthosBatchRowModel> COMMENT = ColumnIdentifier.newId( BenthosBatchRowModel.PROPERTY_COMMENT, n_("tutti.table.benthos.batch.header.comment"), @@ -83,8 +84,6 @@ public BenthosBatchTableModel(TableColumnModel columnModel) { super(columnModel); - - setNoneEditableCols(SAMPLE_WEIGHT, SAMPLING_RATIO); } @Override @@ -107,37 +106,12 @@ if (propertyName == SPECIES_BY_CODE) { // update also other columns - fireTableCellUpdated(rowIndex, - SPECIES_BY_GENUS_CODE); + fireTableCellUpdated(rowIndex, SPECIES_BY_GENUS_CODE); } else if (propertyName == SPECIES_BY_GENUS_CODE) { // update also other columns - fireTableCellUpdated(rowIndex, - SPECIES_BY_CODE); + 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 Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2012-12-28 08:34:01 UTC (rev 114) @@ -120,7 +120,7 @@ <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> <JXTable id='table' - onFocusLost='handler.saveSelectedRowIfRequired(event);'/> + onFocusLost='handler.saveSelectedRowIfRequired(event)'/> </JScrollPane> </JPanel> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2012-12-28 08:34:01 UTC (rev 114) @@ -43,6 +43,7 @@ import org.jdesktop.swingx.table.DefaultTableColumnModelExt; import org.nuiton.util.decorator.Decorator; +import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; import java.util.List; @@ -71,6 +72,8 @@ BenthosBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM, BenthosBatchRowModel.PROPERTY_SPECIES, BenthosBatchRowModel.PROPERTY_WEIGHT, + BenthosBatchRowModel.PROPERTY_NUMBER, + BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT, BenthosBatchRowModel.PROPERTY_COMMENT); this.ui = ui; @@ -100,16 +103,16 @@ return getModel().getFishingOperation(); } - @Override - protected String[] getRowPropertiesToIgnore() { - return new String[]{ - BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT, - BenthosBatchRowModel.PROPERTY_SAMPLING_RATIO - }; - } +// @Override +// protected String[] getRowPropertiesToIgnore() { +// return new String[]{ +// BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT, +// BenthosBatchRowModel.PROPERTY_SAMPLING_RATIO +// }; +// } @Override - protected TableColumnModel createTableColumnModel() { + protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) { DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt(); @@ -146,16 +149,18 @@ TuttiUI.DECIMAL3_PATTERN); } - { // Sample weight column + { // Number column - addColumnToModel(columnModel, - BenthosBatchTableModel.SAMPLE_WEIGHT); + addIntegerColumnToModel(columnModel, + BenthosBatchTableModel.NUMBER, + TuttiUI.INT_3_DIGITS_PATTERN); } - { // SamplingRatio column + { // Sample weight column - addColumnToModel(columnModel, - BenthosBatchTableModel.SAMPLING_RATIO); + addFloatColumnToModel(columnModel, + BenthosBatchTableModel.SAMPLE_WEIGHT, + TuttiUI.DECIMAL3_PATTERN); } { // Comment column @@ -359,7 +364,7 @@ JXTable table = getTable(); // create table column model - TableColumnModel columnModel = createTableColumnModel(); + TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class)); // create table model BenthosBatchTableModel tableModel = Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java 2012-12-28 08:34:01 UTC (rev 114) @@ -42,6 +42,7 @@ import org.jdesktop.swingx.table.DefaultTableColumnModelExt; import org.nuiton.util.decorator.Decorator; +import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; import java.util.List; @@ -99,7 +100,7 @@ } @Override - protected TableColumnModel createTableColumnModel() { + protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) { DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt(); @@ -333,7 +334,7 @@ JXTable table = getTable(); // create table column model - TableColumnModel columnModel = createTableColumnModel(); + TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class)); // create table model MacroWasteBatchTableModel tableModel = Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java 2012-12-28 08:34:01 UTC (rev 114) @@ -51,8 +51,6 @@ public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight"; - public static final String PROPERTY_SAMPLING_RATIO = "samplingRatio"; - public static final String PROPERTY_COMMENT = "comment"; public static final String PROPERTY_ATTACHMENTS = "attachments"; @@ -86,13 +84,6 @@ protected Float sampleWeight; /** - * Sampling ratio. - * - * @since 0.2 - */ - protected Float samplingRatio; - - /** * Comment on this catches. * * @since 0.2 @@ -163,16 +154,6 @@ 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; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java 2012-12-28 08:34:01 UTC (rev 114) @@ -64,11 +64,6 @@ 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"), @@ -81,8 +76,6 @@ public PlanktonBatchTableModel(TableColumnModel columnModel) { super(columnModel); - - setNoneEditableCols(SAMPLE_WEIGHT, SAMPLING_RATIO); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java 2012-12-28 08:34:01 UTC (rev 114) @@ -43,6 +43,7 @@ import org.jdesktop.swingx.table.DefaultTableColumnModelExt; import org.nuiton.util.decorator.Decorator; +import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; import java.util.List; @@ -98,24 +99,23 @@ return getModel().getFishingOperation(); } - @Override - protected String[] getRowPropertiesToIgnore() { - return new String[]{ - PlanktonBatchRowModel.PROPERTY_SAMPLE_WEIGHT, - PlanktonBatchRowModel.PROPERTY_SAMPLING_RATIO - }; - } +// @Override +// protected String[] getRowPropertiesToIgnore() { +// return new String[]{ +// PlanktonBatchRowModel.PROPERTY_SAMPLE_WEIGHT, +// PlanktonBatchRowModel.PROPERTY_SAMPLING_RATIO +// }; +// } @Override - protected TableColumnModel createTableColumnModel() { + protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) { DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt(); List<Species> allSpecies = persistenceService.getAllSpecies(); - { - // Species (by code) column + { // Species (by code) column Decorator<Species> decorator = getDecorator( Species.class, DecoratorService.SPECIES_BY_CODE); @@ -125,8 +125,7 @@ decorator, allSpecies); } - { - // Species (by genusCode) column + { // Species (by genusCode) column Decorator<Species> decorator = getDecorator( Species.class, DecoratorService.SPECIES_BY_GENUS); @@ -150,12 +149,6 @@ PlanktonBatchTableModel.SAMPLE_WEIGHT); } - { // SamplingRatio column - - addColumnToModel(columnModel, - PlanktonBatchTableModel.SAMPLING_RATIO); - } - { // Comment column addColumnToModel(columnModel, @@ -174,8 +167,7 @@ PlanktonBatchTableModel.ATTACHMENTS); } - { - // Species to confirm column + { // Species to confirm column addBooleanColumnToModel(columnModel, PlanktonBatchTableModel.SPECIES_TO_CONFIRM, @@ -356,7 +348,7 @@ JXTable table = getTable(); // create table column model - TableColumnModel columnModel = createTableColumnModel(); + TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class)); // create table model PlanktonBatchTableModel tableModel = Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/FrequencyCellComponent.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/FrequencyCellComponent.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/FrequencyCellComponent.java 2012-12-28 08:34:01 UTC (rev 114) @@ -1,257 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.catches.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 fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; -import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; -import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; -import jaxx.runtime.SwingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.AbstractCellEditor; -import javax.swing.JButton; -import javax.swing.JTable; -import javax.swing.border.LineBorder; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; -import java.awt.Color; -import java.awt.Component; -import java.awt.Frame; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -import static org.nuiton.i18n.I18n._; - -/** - * Component to render and edit frequency stuff from batch table. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class FrequencyCellComponent extends JButton { - - private static final long serialVersionUID = 1L; - - public static final String ROW_INDEX = "rowIndex"; - - /** Logger. */ - private static final Log log = - LogFactory.getLog(FrequencyCellComponent.class); - - public FrequencyCellComponent() { - setContentAreaFilled(false); - setOpaque(false); - setIcon(SwingUtil.createActionIcon("show-frequency")); - } - - public static TableCellRenderer newRender() { - return new FrequencyCellRenderer(); - } - - public static TableCellEditor newEditor(SpeciesFrequencyUI ui) { - return new FrequencyCellEditor(ui); - } - - public static class FrequencyCellEditor extends AbstractCellEditor implements TableCellEditor { - - private static final long serialVersionUID = 1L; - - protected final FrequencyCellComponent component; - - protected final SpeciesFrequencyUI ui; - - protected Frame frame; - - protected JTable table; - - protected SpeciesBatchTableModel tableModel; - - protected ColumnIdentifier<SpeciesBatchRowModel> columnIdentifier; - - protected SpeciesBatchRowModel editRow; - - protected Integer rowIndex; - - protected Integer columnIndex; - - public FrequencyCellEditor(SpeciesFrequencyUI ui) { - this.ui = ui; - component = new FrequencyCellComponent(); - component.setBorder(new LineBorder(Color.BLACK)); - component.addKeyListener(new KeyAdapter() { - @Override - public void keyReleased(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_ENTER || - e.getKeyCode() == KeyEvent.VK_SPACE) { - e.consume(); - startEdit(); - } - } - }); - - component.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - e.consume(); - startEdit(); - } - }); - } - - protected void startEdit() { - - Preconditions.checkNotNull(tableModel, "No table model assigned."); - - // open frequency dialog - - Preconditions.checkNotNull(editRow, "No editRow found."); - - if (log.isInfoEnabled()) { - log.info("Will edit frequencies for row: " + rowIndex); - } - - if (frame == null) { - frame = SwingUtil.getParentContainer(ui, Frame.class); - } - - ui.editBatch(editRow); - - // open frequency dialog - TuttiUIUtil.openInDialog( - ui, frame, _("tutti.title.frequency"), true, null); - - // at close, synch back frequencies - - editRow.updateTotalFromFrequencies(); - - int r = rowIndex; - int c = columnIndex; - - // stop edition - stopCellEditing(); - - // reselect this cell - AbstractSelectTableAction.doSelectCell(table, r, c); - table.requestFocus(); - } - - @Override - public Component getTableCellEditorComponent(JTable table, - Object value, - boolean isSelected, - int row, - int column) { - if (tableModel == null) { - tableModel = (SpeciesBatchTableModel) table.getModel(); - this.table = table; - columnIdentifier = tableModel.getPropertyName(column); - } - String text; - if (value == null) { - text = " - "; - } else { - text = String.valueOf(value); - } - component.setText(text); - - rowIndex = row; - columnIndex = column; - - editRow = tableModel.getEntry(row); - - return component; - } - - @Override - public Object getCellEditorValue() { - - Preconditions.checkNotNull(editRow, "No editRow found in editor."); - - Object result; - if (columnIdentifier == SpeciesBatchTableModel.COMPUTED_NUMBER) { - result = editRow.getComputedNumber(); - } else { - result = editRow.getComputedWeight(); - } - if (log.isInfoEnabled()) { - log.info("editor value (" + columnIdentifier + "): " + result); - } - - return result; - } - - @Override - public boolean stopCellEditing() { - boolean b = super.stopCellEditing(); - if (b) { - rowIndex = null; - editRow = null; - columnIndex = null; - } - return b; - } - - @Override - public void cancelCellEditing() { - super.cancelCellEditing(); - rowIndex = null; - columnIndex = null; - editRow = null; - } - } - - public static class FrequencyCellRenderer implements TableCellRenderer { - - protected final FrequencyCellComponent component; - - public FrequencyCellRenderer() { - component = new FrequencyCellComponent(); - } - - @Override - public Component getTableCellRendererComponent(JTable table, - Object value, - boolean isSelected, - boolean hasFocus, - int row, - int column) { - - String text; - if (value == null) { - text = " - "; - } else { - text = String.valueOf(value); - } - boolean editable = table.isCellEditable(row, column); - component.setEnabled(editable); - component.setText(text); - return component; - } - } -} Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java 2012-12-28 08:34:01 UTC (rev 114) @@ -0,0 +1,68 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.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 java.io.Serializable; + +/** + * Represents a sample category value in the species batch table. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class SampleCategory<C extends Serializable> implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * Sample category value. + * + * @since 0.3 + */ + protected C categoryValue; + + /** + * Sample category weight. + * + * @since 0.3 + */ + protected Float categoryWeight; + + public C getCategoryValue() { + return categoryValue; + } + + public void setCategoryValue(C categoryValue) { + this.categoryValue = categoryValue; + } + + public Float getCategoryWeight() { + return categoryWeight; + } + + public void setCategoryWeight(Float categoryWeight) { + this.categoryWeight = categoryWeight; + } +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java 2012-12-28 08:34:01 UTC (rev 114) @@ -0,0 +1,48 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.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 org.nuiton.util.decorator.Decorator; + +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import java.io.Serializable; + +/** + * To render and edit a {@link SampleCategory}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class SampleCategoryComponent { + + public static <C extends Serializable> TableCellRenderer newRender(TableCellRenderer renderer, Decorator<C> decorator) { + return new SampleCategoryRenderer<C>(renderer, decorator); + } + + public static <C extends Serializable> TableCellEditor newEditor(Decorator<C> decorator) { + return new SampleCategoryEditor<C>(decorator); + } +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryEditor.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryEditor.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryEditor.java 2012-12-28 08:34:01 UTC (rev 114) @@ -0,0 +1,167 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.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 jaxx.runtime.swing.editor.NumberEditor; +import org.nuiton.util.decorator.Decorator; + +import javax.swing.AbstractCellEditor; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; +import javax.swing.event.AncestorEvent; +import javax.swing.event.AncestorListener; +import javax.swing.table.TableCellEditor; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.io.Serializable; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since TODO + */ +public class SampleCategoryEditor<C extends Serializable> extends AbstractCellEditor + implements TableCellEditor, FocusListener, AncestorListener { + + private static final long serialVersionUID = 1L; + + protected final NumberEditor numberEditor; + + protected final JPanel editor; + + protected final JLabel editorLabel; + + protected final Decorator<C> categoryDecorator; + + public SampleCategoryEditor(Decorator<C> categoryDecorator) { + this.categoryDecorator = categoryDecorator; + numberEditor = new NumberEditor(); + numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT); + numberEditor.getTextField().setBorder(null); + numberEditor.getTextField().addFocusListener(this); + numberEditor.getTextField().addAncestorListener(this); + numberEditor.setModelType(Float.class); + numberEditor.setUseSign(false); + numberEditor.init(); + + editor = new JPanel(new BorderLayout()); + editor.add(BorderLayout.WEST, editorLabel = new JLabel()); + editor.add(BorderLayout.CENTER, numberEditor); + } + + @Override + public Component getTableCellEditorComponent(JTable table, + Object value, + boolean isSelected, + int row, + int column) { + + SampleCategory<C> sampleCategory = (SampleCategory<C>) value; + + C categoryValue = sampleCategory == null ? null : sampleCategory.getCategoryValue(); + Float number = sampleCategory == null ? null : sampleCategory.getCategoryWeight(); + + numberEditor.setModel(number); + + // Check nullity and set the text that will be selected with the current value + if (number == null) { + numberEditor.setModelText(""); + } else { + numberEditor.setModelText(String.valueOf(number)); + } + + String label = sampleCategory == null ? "-" : + categoryDecorator.toString(categoryValue); + + editorLabel.setText(label); + return editor; + } + + @Override + public Float getCellEditorValue() { + return (Float) numberEditor.getModel(); + } + + @Override + public void focusGained(FocusEvent e) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + numberEditor.getTextField().requestFocus(); + numberEditor.getTextField().selectAll(); + } + }); + } + + @Override + public void focusLost(FocusEvent e) { + } + + @Override + public void ancestorAdded(AncestorEvent event) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + numberEditor.getTextField().requestFocus(); + numberEditor.getTextField().selectAll(); + } + }); + } + + @Override + public void ancestorRemoved(AncestorEvent event) { + } + + @Override + public void ancestorMoved(AncestorEvent event) { + } + + @Override + public boolean stopCellEditing() { + boolean result = super.stopCellEditing(); + // Reset previous data to avoid keeping it on other cell edition + if (result) { + resetEditor(); + } + return result; + } + + @Override + public void cancelCellEditing() { + resetEditor(); + super.cancelCellEditing(); + } + + protected void resetEditor() { + numberEditor.setModel(null); + // Use empty string, otherwise there is a NPE in NumberEditorHandler + numberEditor.setModelText(""); + editorLabel.setText("-"); + } +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryEditor.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryRenderer.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryRenderer.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryRenderer.java 2012-12-28 08:34:01 UTC (rev 114) @@ -0,0 +1,82 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.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 org.nuiton.util.decorator.Decorator; + +import javax.swing.JTable; +import javax.swing.table.TableCellRenderer; +import java.awt.Component; +import java.io.Serializable; + +/** + * To render a {@link SampleCategory} in a table cell. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class SampleCategoryRenderer<C extends Serializable> implements TableCellRenderer { + + protected final TableCellRenderer delegate; + + protected final Decorator<C> categoryDecorator; + + public SampleCategoryRenderer(TableCellRenderer delegate, + Decorator<C> categoryDecorator) { + this.delegate = delegate; + this.categoryDecorator = categoryDecorator; + } + + @Override + public Component getTableCellRendererComponent(JTable table, + Object value, + boolean isSelected, + boolean hasFocus, + int row, + int column) { + SampleCategory<C> sampleCategory = (SampleCategory<C>) value; + + String text = null; + if (sampleCategory != null) { + C categoryValue = sampleCategory.getCategoryValue(); + Float number = sampleCategory.getCategoryWeight(); + + text = categoryDecorator.toString(categoryValue) + " / "; + + if (number == null) { + text = "-"; + } else { + text += number; + } + } + + return delegate.getTableCellRendererComponent(table, + text, + isSelected, + hasFocus, + row, + column); + } +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryRenderer.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/catches/species/SpeciesBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2012-12-28 08:34:01 UTC (rev 114) @@ -31,6 +31,7 @@ import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel; import org.apache.commons.collections.CollectionUtils; import org.nuiton.util.beans.Binder; import org.nuiton.util.beans.BinderFactory; @@ -52,22 +53,40 @@ public static final String PROPERTY_SPECIES_TO_CONFIRM = "speciesToConfirm"; + public static final String PROPERTY_SORTED_UNSORTED_SAMPLE_CATEGORY = "sortedUnsortedSampleCategory"; + public static final String PROPERTY_SORTED_UNSORTED_CATEGORY = "sortedUnsortedCategory"; + public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT = "sortedUnsortedCategoryWeight"; + + public static final String PROPERTY_SIZE_SAMPLE_CATEGORY = "sizeSampleCategory"; + public static final String PROPERTY_SIZE_CATEGORY = "sizeCategory"; + public static final String PROPERTY_SIZE_CATEGORY_WEIGHT = "sizeCategoryWeight"; + + public static final String PROPERTY_SEX_SAMPLE_CATEGORY = "sexSampleCategory"; + public static final String PROPERTY_SEX_CATEGORY = "sexCategory"; + public static final String PROPERTY_SEX_CATEGORY_WEIGHT = "sexCategoryWeight"; + + public static final String PROPERTY_MATURITY_SAMPLE_CATEGORY = "maturitySampleCategory"; + public static final String PROPERTY_MATURITY_CATEGORY = "maturityCategory"; - public static final String PROPERTY_AGE = "age"; + public static final String PROPERTY_MATURITY_CATEGORY_WEIGHT = "maturityCategoryWeight"; + public static final String PROPERTY_AGE_SAMPLE_CATEGORY = "ageSampleCategory"; + + public static final String PROPERTY_AGE_CATEGORY = "ageCategory"; + + public static final String PROPERTY_AGE_CATEGORY_WEIGHT = "ageCategoryWeight"; + public static final String PROPERTY_WEIGHT = "weight"; - public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight"; + public static final String PROPERTY_NUMBER = "number"; - public static final String PROPERTY_SAMPLING_RATIO = "samplingRatio"; - public static final String PROPERTY_COMMENT = "comment"; public static final String PROPERTY_FREQUENCY = "frequency"; @@ -97,35 +116,35 @@ * * @since 0.2 */ - protected CaracteristicQualitativeValue sortedUnsortedCategory; + protected final SampleCategory<CaracteristicQualitativeValue> sortedUnsortedSampleCategory = new SampleCategory<CaracteristicQualitativeValue>(); /** * Weight category (can be null). * * @since 0.2 */ - protected CaracteristicQualitativeValue sizeCategory; + protected final SampleCategory<CaracteristicQualitativeValue> sizeSampleCategory = new SampleCategory<CaracteristicQualitativeValue>(); /** * Sex (can be null). * * @since 0.2 */ - protected CaracteristicQualitativeValue sexCategory; + protected final SampleCategory<CaracteristicQualitativeValue> sexSampleCategory = new SampleCategory<CaracteristicQualitativeValue>(); /** * Maturity (can be null). * * @since 0.2 */ - protected CaracteristicQualitativeValue maturityCategory; + protected final SampleCategory<CaracteristicQualitativeValue> maturitySampleCategory = new SampleCategory<CaracteristicQualitativeValue>(); /** * Age (can be null). * * @since 0.2 */ - protected Float age; + protected final SampleCategory<Float> ageSampleCategory = new SampleCategory<Float>(); /** * Observed weight. @@ -135,6 +154,13 @@ protected Float weight; /** + * Observed number. + * + * @since 0.3 + */ + protected Integer number; + + /** * Total computed weight (from frequencies). * * @since 0.2 @@ -149,20 +175,6 @@ protected Float computedNumber; /** - * Sample weight. - * - * @since 0.2 - */ - protected Float sampleWeight; - - /** - * Sampling ratio. - * - * @since 0.2 - */ - protected Float samplingRatio; - - /** * Comment on this catches. * * @since 0.2 @@ -253,55 +265,105 @@ } public CaracteristicQualitativeValue getSortedUnsortedCategory() { - return sortedUnsortedCategory; + return sortedUnsortedSampleCategory.getCategoryValue(); } public void setSortedUnsortedCategory(CaracteristicQualitativeValue sortedUnsortedCategory) { Object oldValue = getSortedUnsortedCategory(); - this.sortedUnsortedCategory = sortedUnsortedCategory; + sortedUnsortedSampleCategory.setCategoryValue(sortedUnsortedCategory); firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY, oldValue, sortedUnsortedCategory); } + public Float getSortedUnsortedCategoryWeight() { + return sortedUnsortedSampleCategory.getCategoryWeight(); + } + + public void setSortedUnsortedCategoryWeight(Float sortedUnsortedCategoryWeight) { + Object oldValue = getSortedUnsortedCategoryWeight(); + sortedUnsortedSampleCategory.setCategoryWeight(sortedUnsortedCategoryWeight); + firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, oldValue, sortedUnsortedCategoryWeight); + } + public CaracteristicQualitativeValue getSizeCategory() { - return sizeCategory; + return sizeSampleCategory.getCategoryValue(); } public void setSizeCategory(CaracteristicQualitativeValue sizeCategory) { Object oldValue = getSizeCategory(); - this.sizeCategory = sizeCategory; + this.sizeSampleCategory.setCategoryValue(sizeCategory); firePropertyChange(PROPERTY_SIZE_CATEGORY, oldValue, sizeCategory); } + public Float getSizeCategoryWeight() { + return sizeSampleCategory.getCategoryWeight(); + } + + public void setSizeCategoryWeight(Float sizeCategoryWeight) { + Object oldValue = getSizeCategoryWeight(); + this.sizeSampleCategory.setCategoryWeight(sizeCategoryWeight); + firePropertyChange(PROPERTY_SIZE_CATEGORY_WEIGHT, oldValue, sizeCategoryWeight); + } + public CaracteristicQualitativeValue getSexCategory() { - return sexCategory; + return sexSampleCategory.getCategoryValue(); } public void setSexCategory(CaracteristicQualitativeValue sexCategory) { Object oldValue = getSexCategory(); - this.sexCategory = sexCategory; + this.sexSampleCategory.setCategoryValue(sexCategory); firePropertyChange(PROPERTY_SEX_CATEGORY, oldValue, sexCategory); } + public Float getSexCategoryWeight() { + return sexSampleCategory.getCategoryWeight(); + } + + public void setSexCategoryWeight(Float sexCategoryWeight) { + Object oldValue = getSexCategoryWeight(); + this.sexSampleCategory.setCategoryWeight(sexCategoryWeight); + firePropertyChange(PROPERTY_SEX_CATEGORY_WEIGHT, oldValue, sexCategoryWeight); + } + public CaracteristicQualitativeValue getMaturityCategory() { - return maturityCategory; + return maturitySampleCategory.getCategoryValue(); } public void setMaturityCategory(CaracteristicQualitativeValue maturityCategory) { Object oldValue = getMaturityCategory(); - this.maturityCategory = maturityCategory; + this.maturitySampleCategory.setCategoryValue(maturityCategory); firePropertyChange(PROPERTY_MATURITY_CATEGORY, oldValue, maturityCategory); } - public Float getAge() { - return age; + public Float getMaturityCategoryWeight() { + return maturitySampleCategory.getCategoryWeight(); } - public void setAge(Float age) { - Object oldValue = getAge(); - this.age = age; - firePropertyChange(PROPERTY_AGE, oldValue, age); + public void setMaturityCategoryWeight(Float maturityCategoryWeight) { + Object oldValue = getMaturityCategoryWeight(); + this.maturitySampleCategory.setCategoryWeight(maturityCategoryWeight); + firePropertyChange(PROPERTY_MATURITY_CATEGORY_WEIGHT, oldValue, maturityCategoryWeight); } + public Float getAgeCategory() { + return ageSampleCategory.getCategoryValue(); + } + + public void setAgeCategory(Float ageCategory) { + Object oldValue = getAgeCategory(); + ageSampleCategory.setCategoryValue(ageCategory); + firePropertyChange(PROPERTY_AGE_CATEGORY, oldValue, ageCategory); + } + + public Float getAgeCategoryWeight() { + return ageSampleCategory.getCategoryWeight(); + } + + public void setAgeCategoryWeight(Float ageCategoryWeight) { + Object oldValue = getAgeCategoryWeight(); + ageSampleCategory.setCategoryWeight(ageCategoryWeight); + firePropertyChange(PROPERTY_AGE_CATEGORY_WEIGHT, oldValue, ageCategoryWeight); + } + public Float getWeight() { return weight; } @@ -312,26 +374,16 @@ firePropertyChange(PROPERTY_WEIGHT, oldValue, weight); } - public Float getSampleWeight() { - return sampleWeight; + public Integer getNumber() { + return number; } - public void setSampleWeight(Float sampleWeight) { - Object oldValue = getSampleWeight(); - this.sampleWeight = sampleWeight; - firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight); + public void setNumber(Integer number) { + Object oldValue = getNumber(); + this.number = number; + firePropertyChange(PROPERTY_NUMBER, oldValue, number); } - 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; } @@ -384,7 +436,27 @@ computedNumber); } - public int getRowCount() { - return frequency == null ? 0 : frequency.size(); + public SampleCategory<CaracteristicQualitativeValue> getSortedUnsortedSampleCategory() { + return sortedUnsortedSampleCategory; } + + public SampleCategory<CaracteristicQualitativeValue> getSizeSampleCategory() { + return sizeSampleCategory; + } + + public SampleCategory<CaracteristicQualitativeValue> getSexSampleCategory() { + return sexSampleCategory; + } + + public SampleCategory<CaracteristicQualitativeValue> getMaturitySampleCategory() { + return maturitySampleCategory; + } + + public SampleCategory<Float> getAgeSampleCategory() { + return ageSampleCategory; + } + + // public int getRowCount() { +// return frequency == null ? 0 : frequency.size(); +// } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2012-12-28 08:34:01 UTC (rev 114) @@ -52,29 +52,29 @@ n_("tutti.table.species.batch.header.speciesByGenusCode")); public static final ColumnIdentifier<SpeciesBatchRowModel> SORTED_UNSORTED_CATEGORY = ColumnIdentifier.newId( - SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY, + SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_SAMPLE_CATEGORY, n_("tutti.table.species.batch.header.sortedUnsortedCategory"), n_("tutti.table.species.batch.header.sortedUnsortedCategory")); public static final ColumnIdentifier<SpeciesBatchRowModel> SIZE_CATEGORY = ColumnIdentifier.newId( - SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY, + SpeciesBatchRowModel.PROPERTY_SIZE_SAMPLE_CATEGORY, n_("tutti.table.species.batch.header.sizeCategory"), n_("tutti.table.species.batch.header.sizeCategory")); public static final ColumnIdentifier<SpeciesBatchRowModel> SEX_CATEGORY = ColumnIdentifier.newId( - SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY, + SpeciesBatchRowModel.PROPERTY_SEX_SAMPLE_CATEGORY, n_("tutti.table.species.batch.header.sexCategory"), n_("tutti.table.species.batch.header.sexCategory")); public static final ColumnIdentifier<SpeciesBatchRowModel> MATURITY_CATEGORY = ColumnIdentifier.newId( - SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY, + SpeciesBatchRowModel.PROPERTY_MATURITY_SAMPLE_CATEGORY, n_("tutti.table.species.batch.header.maturityCategory"), n_("tutti.table.species.batch.header.maturityCategory")); - public static final ColumnIdentifier<SpeciesBatchRowModel> AGE = ColumnIdentifier.newId( - SpeciesBatchRowModel.PROPERTY_AGE, - n_("tutti.table.species.batch.header.age"), - n_("tutti.table.species.batch.header.age")); + public static final ColumnIdentifier<SpeciesBatchRowModel> AGE_CATEGORY = ColumnIdentifier.newId( + SpeciesBatchRowModel.PROPERTY_AGE_SAMPLE_CATEGORY, + n_("tutti.table.species.batch.header.ageCategory"), + n_("tutti.table.species.batch.header.ageCategory")); public static final ColumnIdentifier<SpeciesBatchRowModel> WEIGHT = ColumnIdentifier.newId( SpeciesBatchRowModel.PROPERTY_WEIGHT, @@ -91,16 +91,11 @@ n_("tutti.table.species.batch.header.computedNumber"), n_("tutti.table.species.batch.header.computedNumber")); - public static final ColumnIdentifier<SpeciesBatchRowModel> SAMPLE_WEIGHT = ColumnIdentifier.newId( - SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT, - n_("tutti.table.species.batch.header.sampleWeight"), - n_("tutti.table.species.batch.header.sampleWeight")); + public static final ColumnIdentifier<SpeciesBatchRowModel> NUMBER = ColumnIdentifier.newId( + SpeciesBatchRowModel.PROPERTY_NUMBER, + n_("tutti.table.species.batch.header.number"), + n_("tutti.table.species.batch.header.number")); - public static final ColumnIdentifier<SpeciesBatchRowModel> SAMPLING_RATIO = ColumnIdentifier.newId( - SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO, - n_("tutti.table.species.batch.header.elevationRate"), - n_("tutti.table.species.batch.header.elevationRate")); - public static final ColumnIdentifier<SpeciesBatchRowModel> COMMENT = ColumnIdentifier.newId( SpeciesBatchRowModel.PROPERTY_COMMENT, n_("tutti.table.species.batch.header.comment"), @@ -118,13 +113,23 @@ protected final Set<ColumnIdentifier<SpeciesBatchRowModel>> noneEditableColIfNoSpecies; + protected final Set<ColumnIdentifier<SpeciesBatchRowModel>> sampleCols; + public SpeciesBatchTableModel(TableColumnModel columnModel) { super(columnModel); - setNoneEditableCols(SAMPLE_WEIGHT, SAMPLING_RATIO); + setNoneEditableCols(); +// setNoneEditableCols(SAMPLE_WEIGHT, SAMPLING_RATIO); noneEditableColIfNoSpecies = Sets.newHashSet(); noneEditableColIfNoSpecies.add(COMPUTED_NUMBER); noneEditableColIfNoSpecies.add(COMPUTED_WEIGHT); + + sampleCols = Sets.newHashSet(); + sampleCols.add(SORTED_UNSORTED_CATEGORY); + sampleCols.add(SIZE_CATEGORY); + sampleCols.add(SEX_CATEGORY); + sampleCols.add(MATURITY_CATEGORY); + sampleCols.add(AGE_CATEGORY); } @Override @@ -172,12 +177,10 @@ } public void updateSamplingRatio(Set<SpeciesBatchRowModel> rows) { - for (SpeciesBatchRowModel row : rows) { - int rowIndex = getRows().indexOf(row); - fireTableCellUpdated(rowIndex, SAMPLE_WEIGHT, SAMPLING_RATIO); - } - - +// for (SpeciesBatchRowModel row : rows) { +// int rowIndex = getRows().indexOf(row); +// fireTableCellUpdated(rowIndex, SAMPLE_WEIGHT, SAMPLING_RATIO); +// } } @Override @@ -195,6 +198,12 @@ // must have filled a species to edit this column SpeciesBatchRowModel entry = getEntry(rowIndex); result = entry.getSpecies() != null; + } else if (sampleCols.contains(propertyName)) { + + // can only edit if a category value is setted + SpeciesBatchRowModel entry = getEntry(rowIndex); + SampleCategory<?> value = (SampleCategory<?>) propertyName.getValue(entry); + result = value.getCategoryValue() != null; } } return result; Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTreeModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTreeModel.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTreeModel.java 2012-12-28 08:34:01 UTC (rev 114) @@ -27,16 +27,12 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; -import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import org.apache.commons.collections.CollectionUtils; import java.io.Serializable; import java.util.Collection; -import java.util.List; import java.util.Map; -import java.util.Set; /** * @author tchemit <chemit@codelutin.com> @@ -81,22 +77,22 @@ nodeToRow = HashMultimap.create(); } - public void populate(List<SpeciesBatchRowModel> rows) { +// public void populate(List<SpeciesBatchRowModel> rows) { +// +// clear(); +// +// for (SpeciesBatchRowModel row : rows) { +// +// SpeciesBatchTreeNode node = getSamplingNode(row); +// +// // check if row is valid +// boolean rowIsValid = isValid(row, node); +// +// // set it in row +// row.setValid(rowIsValid); +// } +// } - clear(); - - for (SpeciesBatchRowModel row : rows) { - - SpeciesBatchTreeNode node = getSamplingNode(row); - - // check if row is valid - boolean rowIsValid = isValid(row, node); - - // set it in row - row.setValid(rowIsValid); - } - } - public String[] getSamplingOrder() { return samplingOrder; } @@ -185,42 +181,42 @@ return result; } - public SamplingContext createSamplingContext(SpeciesBatchTreeNode rootNode) { +// public SamplingContext createSamplingContext(SpeciesBatchTreeNode rootNode) { +// +// Set<SpeciesBatchRowModel> childRows = Sets.newHashSet(); +// +// SpeciesBatchRowModel superSamplingRow = getNodeToRow(rootNode); +// +// float totalWeight = 0f; +// for (int i = 0, nbChildren = rootNode.getChildCount(); i < nbChildren; i++) { +// SpeciesBatchTreeNode node = rootNode.getChildAt(i); +// +// SpeciesBatchRowModel row = getNodeToRow(node); +// if (row != null) { +// CaracteristicQualitativeValue sortedUnsortedCategory = +// row.getSortedUnsortedCategory(); +// if (sortedUnsortedCategory != null && +// "unsorted".equals(sortedUnsortedCategory.getName())) { +// +// // never take account of a such child +// +// } else { +// +// childRows.add(row); +// Float weight = row.getWeight(); +// if (weight != null) { +// totalWeight += weight; +// } +// } +// } +// } +// SamplingContext result = new SamplingContext(rootNode, +// superSamplingRow, +// childRows, +// totalWeight); +// return result; +// } - Set<SpeciesBatchRowModel> childRows = Sets.newHashSet(); - - SpeciesBatchRowModel superSamplingRow = getNodeToRow(rootNode); - - float totalWeight = 0f; - for (int i = 0, nbChildren = rootNode.getChildCount(); i < nbChildren; i++) { - SpeciesBatchTreeNode node = rootNode.getChildAt(i); - - SpeciesBatchRowModel row = getNodeToRow(node); - if (row != null) { - CaracteristicQualitativeValue sortedUnsortedCategory = - row.getSortedUnsortedCategory(); - if (sortedUnsortedCategory != null && - "unsorted".equals(sortedUnsortedCategory.getName())) { - - // never take account of a such child - - } else { - - childRows.add(row); - Float weight = row.getWeight(); - if (weight != null) { - totalWeight += weight; - } - } - } - } - SamplingContext result = new SamplingContext(rootNode, - superSamplingRow, - childRows, - totalWeight); - return result; - } - public SpeciesBatchRowModel getNodeToRow(SpeciesBatchTreeNode node) { Collection<SpeciesBatchRowModel> rows = nodeToRow.get(node); @@ -249,49 +245,49 @@ return result; } - public static class SamplingContext { - - private final SpeciesBatchTreeNode rootNode; - - private final SpeciesBatchRowModel superSamplingRow; - - private final Set<SpeciesBatchRowModel> samplingRows; - - private final float totalWeight; - - public SamplingContext(SpeciesBatchTreeNode rootNode, - SpeciesBatchRowModel superSamplingRow, - Set<SpeciesBatchRowModel> samplingRows, - float totalWeight) { - this.rootNode = rootNode; - this.superSamplingRow = superSamplingRow; - this.samplingRows = samplingRows; - this.totalWeight = totalWeight; - } - - public SpeciesBatchTreeNode getRootNode() { - return rootNode; - } - - public SpeciesBatchRowModel getSuperSamplingRow() { - return superSamplingRow; - } - - public Set<SpeciesBatchRowModel> getSamplingRows() { - return samplingRows; - } - - public float getTotalWeight() { - return totalWeight; - } - - public void applyNewSampleValues(float samplingWeight, - Float samplingRatio) { - - for (SpeciesBatchRowModel row : samplingRows) { - row.setSampleWeight(samplingWeight); - row.setSamplingRatio(samplingRatio); - } - } - } +// public static class SamplingContext { +// +// private final SpeciesBatchTreeNode rootNode; +// +// private final SpeciesBatchRowModel superSamplingRow; +// +// private final Set<SpeciesBatchRowModel> samplingRows; +// +// private final float totalWeight; +// +// public SamplingContext(SpeciesBatchTreeNode rootNode, +// SpeciesBatchRowModel superSamplingRow, +// Set<SpeciesBatchRowModel> samplingRows, +// float totalWeight) { +// this.rootNode = rootNode; +// this.superSamplingRow = superSamplingRow; +// this.samplingRows = samplingRows; +// this.totalWeight = totalWeight; +// } +// +// public SpeciesBatchTreeNode getRootNode() { +// return rootNode; +// } +// +// public SpeciesBatchRowModel getSuperSamplingRow() { +// return superSamplingRow; +// } +// +// public Set<SpeciesBatchRowModel> getSamplingRows() { +// return samplingRows; +// } +// +// public float getTotalWeight() { +// return totalWeight; +// } +// +// public void applyNewSampleValues(float samplingWeight, +// Float samplingRatio) { +// +// for (SpeciesBatchRowModel row : samplingRows) { +// row.setSampleWeight(samplingWeight); +// row.setSamplingRatio(samplingRatio); +// } +// } +// } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2012-12-28 08:34:01 UTC (rev 114) @@ -28,6 +28,7 @@ fr.ifremer.tutti.ui.swing.TuttiUI fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyUI fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI fr.ifremer.tutti.ui.swing.util.editor.AttachmentEditorUI Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2012-12-28 08:34:01 UTC (rev 114) @@ -40,6 +40,8 @@ import fr.ifremer.tutti.ui.swing.TuttiUI; import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.FrequencyCellComponent; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent; import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent; @@ -49,6 +51,7 @@ import org.jdesktop.swingx.table.DefaultTableColumnModelExt; import org.nuiton.util.decorator.Decorator; +import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; import java.util.List; import java.util.Set; @@ -75,7 +78,7 @@ SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY, SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY, SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY, - SpeciesBatchRowModel.PROPERTY_AGE); + SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY); /** * UI. @@ -90,11 +93,17 @@ SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM, SpeciesBatchRowModel.PROPERTY_SPECIES, SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY, + SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY, + SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT, SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY, + SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT, SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY, - SpeciesBatchRowModel.PROPERTY_AGE, + SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT, + SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY, + SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT, SpeciesBatchRowModel.PROPERTY_WEIGHT, + SpeciesBatchRowModel.PROPERTY_NUMBER, SpeciesBatchRowModel.PROPERTY_COMMENT, SpeciesBatchRowModel.PROPERTY_ATTACHMENTS, SpeciesBatchRowModel.PROPERTY_FREQUENCY); @@ -129,19 +138,23 @@ protected void onModelRowsChanged(List<SpeciesBatchRowModel> rows) { super.onModelRowsChanged(rows); + for (SpeciesBatchRowModel row : rows) { + boolean rowValid = row.getSpecies() != null; + row.setValid(rowValid); + } // build the new sampling tree from the new rows to edit - getModel().getSamplingTreeModel().populate(rows); +// getModel().getSamplingTreeModel().populate(rows); } - @Override - protected String[] getRowPropertiesToIgnore() { - return new String[]{ - SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT, - SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO}; - } +// @Override +// protected String[] getRowPropertiesToIgnore() { +// return new String[]{ +// SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT, +// SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO}; +// } @Override - protected TableColumnModel createTableColumnModel() { + protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) { DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt(); @@ -151,8 +164,7 @@ List<Species> allSpecies = persistenceService.getAllSpecies(); - { - // Species (by code) column + { // Species (by code) column Decorator<Species> decorator = getDecorator( Species.class, DecoratorService.SPECIES_BY_CODE); @@ -162,8 +174,7 @@ decorator, allSpecies); } - { - // Species (by genusCode) column + { // Species (by genusCode) column Decorator<Species> decorator = getDecorator( Species.class, DecoratorService.SPECIES_BY_GENUS); @@ -173,59 +184,88 @@ decorator, allSpecies); } - { + { // SortedUnsortedCategory column - // SortedUnsortedCategory column + addColumnToModel(columnModel, + SampleCategoryComponent.newEditor(caracteristicDecorator), + SampleCategoryComponent.newRender(defaultRenderer, caracteristicDecorator), + SpeciesBatchTableModel.SORTED_UNSORTED_CATEGORY); - Caracteristic data = - persistenceService.getSortedUnsortedCaracteristic(); - - addComboDataColumnToModel(columnModel, - SpeciesBatchTableModel.SORTED_UNSORTED_CATEGORY, - caracteristicDecorator, - data.getQualitativeValue()); +// Caracteristic data = +// persistenceService.getSortedUnsortedCaracteristic(); +// +// addComboDataColumnToModel(columnModel, +// SpeciesBatchTableModel.SORTED_UNSORTED_CATEGORY, +// caracteristicDecorator, +// data.getQualitativeValue()); } { // SizeCategory column - Caracteristic data = - persistenceService.getSizeCategoryCaracteristic(); + addColumnToModel(columnModel, + SampleCategoryComponent.newEditor(caracteristicDecorator), + SampleCategoryComponent.newRender(defaultRenderer, caracteristicDecorator), + SpeciesBatchTableModel.SIZE_CATEGORY); - addComboDataColumnToModel(columnModel, - SpeciesBatchTableModel.SIZE_CATEGORY, - caracteristicDecorator, - data.getQualitativeValue()); +// Caracteristic data = +// persistenceService.getSizeCategoryCaracteristic(); +// +// addComboDataColumnToModel(columnModel, +// SpeciesBatchTableModel.SIZE_CATEGORY, +// caracteristicDecorator, +// data.getQualitativeValue()); } { // SexCategory column - Caracteristic data = persistenceService.getSexCaracteristic(); + addColumnToModel(columnModel, + SampleCategoryComponent.newEditor(caracteristicDecorator), + SampleCategoryComponent.newRender(defaultRenderer, caracteristicDecorator), + SpeciesBatchTableModel.SEX_CATEGORY); - addComboDataColumnToModel(columnModel, - SpeciesBatchTableModel.SEX_CATEGORY, - caracteristicDecorator, - data.getQualitativeValue()); +// Caracteristic data = persistenceService.getSexCaracteristic(); +// +// addComboDataColumnToModel(columnModel, +// SpeciesBatchTableModel.SEX_CATEGORY, +// caracteristicDecorator, +// data.getQualitativeValue()); } { // MaturityCategory column - Caracteristic data = - persistenceService.getMaturityCaracteristic(); + addColumnToModel(columnModel, + SampleCategoryComponent.newEditor(caracteristicDecorator), + SampleCategoryComponent.newRender(defaultRenderer, caracteristicDecorator), + SpeciesBatchTableModel.MATURITY_CATEGORY); - - addComboDataColumnToModel(columnModel, - SpeciesBatchTableModel.MATURITY_CATEGORY, - caracteristicDecorator, - data.getQualitativeValue()); +// Caracteristic data = +// persistenceService.getMaturityCaracteristic(); +// +// +// addComboDataColumnToModel(columnModel, +// SpeciesBatchTableModel.MATURITY_CATEGORY, +// caracteristicDecorator, +// data.getQualitativeValue()); } - { + { // AgeCategory column - // Age column + Decorator<Float> floatDecorator = new Decorator<Float>(Float.class) { + private static final long serialVersionUID = 1L; - addFloatColumnToModel(columnModel, - SpeciesBatchTableModel.AGE, - TuttiUI.DECIMAL3_PATTERN); + @Override + public String toString(Object bean) { + return String.valueOf(bean); + } + }; + addColumnToModel(columnModel, + SampleCategoryComponent.newEditor(floatDecorator), + SampleCategoryComponent.newRender(defaultRenderer, floatDecorator), + SpeciesBatchTableModel.AGE_CATEGORY); + +// addFloatColumnToModel(columnModel, +// SpeciesBatchTableModel.AGE_CATEGORY, +// TuttiUI.DECIMAL3_PATTERN); } { // Weight column @@ -251,18 +291,6 @@ SpeciesBatchTableModel.COMPUTED_NUMBER); } - { // Sample weight column - - addColumnToModel(columnModel, - SpeciesBatchTableModel.SAMPLE_WEIGHT); - } - - { // SamplingRatio column - - addColumnToModel(columnModel, - SpeciesBatchTableModel.SAMPLING_RATIO); - } - { // Comment column addColumnToModel(columnModel, @@ -305,80 +333,87 @@ recomputeTotalHorsVrac(); } - SpeciesBatchUIModel model = getModel(); + if (SpeciesBatchRowModel.PROPERTY_SPECIES.equals(propertyName)) { - 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 + // species has changed, recompute valid property + boolean rowValid = newValue != null; 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)); - } - } - } +// 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 @@ -449,7 +484,7 @@ SpeciesBatchTreeModel samplingTreeModel = model.getSamplingTreeModel(); SpeciesBatchTreeNode node = samplingTreeModel.getSamplingNode(row); boolean rowValid = samplingTreeModel.isValid(row, node); - return rowValid; + return row.isValid(); } @Override @@ -492,17 +527,6 @@ @Override public void selectFishingOperation(FishingOperation bean) { -// JXTable table = ui.getTable(); -// -// if (table.isEditing()) { -// -// // make sure to stop editor -// table.editingCanceled(null); -// } -// -// // make sure selection is empty (will remove bean from monitor) -// table.clearSelection(); - boolean empty = bean == null; SpeciesBatchUIModel model = getModel(); @@ -576,7 +600,7 @@ SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY, SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY, SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY, - SpeciesBatchRowModel.PROPERTY_AGE + SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY ); getModel().setSamplingOrder(samplingOrder); @@ -584,7 +608,7 @@ JXTable table = getTable(); // create table column model - TableColumnModel columnModel = createTableColumnModel(); + TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class)); // create table model SpeciesBatchTableModel tableModel = @@ -611,50 +635,50 @@ //-- Internal methods --// //------------------------------------------------------------------------// - protected void recomputeSuperSamplingRatio(SpeciesBatchTreeModel samplingTreeModel, - SpeciesBatchTreeNode node) { +// 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().getSpeciesTotalWeight(); +// } 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()); +// } - 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().getSpeciesTotalWeight(); - } 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 Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2012-12-28 08:34:01 UTC (rev 114) @@ -37,6 +37,10 @@ private static final long serialVersionUID = 1L; + + public static final String PROPERTY_TABLE_VIEW_MODE = "tableViewMode"; + + /** * Sampling order (sets by protocol). * @@ -45,6 +49,13 @@ protected List<String> samplingOrder; /** + * What to show in the table. + * + * @since 0.3 + */ + protected TableViewMode tableViewMode; + + /** * Tree of sampling for batch rows. * * @since 0.2 @@ -105,4 +116,13 @@ samplingTreeModel.setSamplingOrder(samplingOrder.toArray(new String[samplingOrder.size()])); } + public TableViewMode getTableViewMode() { + return tableViewMode; + } + + public void setTableViewMode(TableViewMode tableViewMode) { + Object oldValue = getTableViewMode(); + this.tableViewMode = tableViewMode; + firePropertyChange(PROPERTY_TABLE_VIEW_MODE, oldValue, tableViewMode); + } } Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyRowModel.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyRowModel.java 2012-12-28 08:34:01 UTC (rev 114) @@ -1,191 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.catches.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.collect.Lists; -import com.google.common.collect.Ordering; -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; -import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; -import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel; -import org.nuiton.util.beans.Binder; -import org.nuiton.util.beans.BinderFactory; - -import java.util.List; - -/** - * Represents a batch frequency row. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBatchFrequency, SpeciesFrequencyRowModel> implements Comparable<SpeciesFrequencyRowModel> { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_LENGTH_STEP = "lengthStep"; - - public static final String PROPERTY_NUMBER = "number"; - - public static final String PROPERTY_WEIGHT = "weight"; - - public static final String PROPERTY_COMPUTED_WEIGHT = "computedWeight"; - - - public static final String PROPERTY_LENGHT_STEP_CARACTERISTIC = "lengthStepCaracteristic"; - - - /** - * Length step. - * - * @since 0.2 - */ - protected Float lengthStep; - - /** - * Count of fishes for this lengthStep. - * - * @since 0.2 - */ - protected Integer number; - - /** - * Weight of fishes observed. - * - * @since 0.2 - */ - protected Float weight; - - /** - * Computed weight from number + relation taille-poids. - * - * @since 0.2 - */ - protected Float computedWeight; - - /** - * Length step caracteristic. - * - * @since 0.3 - */ - protected Caracteristic lengthStepCaracteristic; - - protected static final Binder<SpeciesBatchFrequency, SpeciesFrequencyRowModel> fromBeanBinder = - BinderFactory.newBinder(SpeciesBatchFrequency.class, - SpeciesFrequencyRowModel.class); - - protected static final Binder<SpeciesFrequencyRowModel, SpeciesBatchFrequency> toBeanBinder = - BinderFactory.newBinder(SpeciesFrequencyRowModel.class, - SpeciesBatchFrequency.class); - - private static final Ordering<Float> ordering = Ordering.natural().nullsFirst(); - - public static List<SpeciesFrequencyRowModel> fromBeans(List<SpeciesBatchFrequency> frequency) { - List<SpeciesFrequencyRowModel> result = Lists.newArrayList(); - for (SpeciesBatchFrequency b : frequency) { - SpeciesFrequencyRowModel model = new SpeciesFrequencyRowModel(); - fromBeanBinder.copy(b, model); - result.add(model); - } - return result; - } - - public static List<SpeciesBatchFrequency> toBeans(List<SpeciesFrequencyRowModel> frequency, SpeciesBatch batch) { - List<SpeciesBatchFrequency> result = Lists.newArrayList(); - for (SpeciesFrequencyRowModel b : frequency) { - SpeciesBatchFrequency model = new SpeciesBatchFrequency(); - toBeanBinder.copy(b, model); - model.setBatch(batch); - result.add(model); - } - return result; - } - - public SpeciesFrequencyRowModel() { - super(SpeciesBatchFrequency.class, fromBeanBinder, toBeanBinder); - } - - public Float getLengthStep() { - return lengthStep; - } - - public void setLengthStep(Float lengthStep) { - Object oldValue = getLengthStep(); - this.lengthStep = lengthStep; - firePropertyChange(PROPERTY_LENGTH_STEP, oldValue, lengthStep); - } - - public Integer getNumber() { - return number; - } - - public void setNumber(Integer number) { - Object oldValue = getNumber(); - this.number = number; - firePropertyChange(PROPERTY_NUMBER, oldValue, number); - } - - public Float getWeight() { - return weight; - } - - public void setWeight(Float weight) { - Object oldValue = getWeight(); - this.weight = weight; - firePropertyChange(PROPERTY_WEIGHT, oldValue, weight); - } - - public Float getComputedWeight() { - return computedWeight; - } - - public void setComputedWeight(Float computedWeight) { - Object oldValue = getComputedWeight(); - this.computedWeight = computedWeight; - firePropertyChange(PROPERTY_COMPUTED_WEIGHT, oldValue, computedWeight); - } - - public Caracteristic getLengthStepCaracteristic() { - return lengthStepCaracteristic; - } - - public void setLengthStepCaracteristic(Caracteristic lengthStepCaracteristic) { - Object oldValue = getLengthStepCaracteristic(); - this.lengthStepCaracteristic = lengthStepCaracteristic; - firePropertyChange(PROPERTY_LENGHT_STEP_CARACTERISTIC, oldValue, lengthStepCaracteristic); - } - - //TODO Use validator - @Override - public boolean isValid() { - return lengthStep != null && number != null && lengthStepCaracteristic != null; - } - - @Override - public int compareTo(SpeciesFrequencyRowModel o) { - int result = ordering.compare(lengthStep, o.lengthStep); - return result; - } -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyTableModel.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyTableModel.java 2012-12-28 08:34:01 UTC (rev 114) @@ -1,148 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.catches.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.Maps; -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.List; -import java.util.Map; - -import static org.nuiton.i18n.I18n.n_; - -/** - * Model of the species frequency table. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class SpeciesFrequencyTableModel extends AbstractTuttiTableModel<SpeciesFrequencyRowModel> { - - private static final long serialVersionUID = 1L; - - public static final ColumnIdentifier<SpeciesFrequencyRowModel> LENGTH_STEP = ColumnIdentifier.newId( - SpeciesFrequencyRowModel.PROPERTY_LENGTH_STEP, - n_("tutti.table.species.frequency.header.lengthStep"), - n_("tutti.table.species.frequency.header.lengthStep")); - - public static final ColumnIdentifier<SpeciesFrequencyRowModel> NUMBER = ColumnIdentifier.newId( - SpeciesFrequencyRowModel.PROPERTY_NUMBER, - n_("tutti.table.species.frequency.header.number"), - n_("tutti.table.species.frequency.header.number")); - - public static final ColumnIdentifier<SpeciesFrequencyRowModel> WEIGHT = ColumnIdentifier.newId( - SpeciesFrequencyRowModel.PROPERTY_WEIGHT, - n_("tutti.table.species.frequency.header.weight"), - n_("tutti.table.species.frequency.header.weight")); - - public static final ColumnIdentifier<SpeciesFrequencyRowModel> COMPUTED_WEIGHT = ColumnIdentifier.newId( - SpeciesFrequencyRowModel.PROPERTY_COMPUTED_WEIGHT, - n_("tutti.table.species.frequency.header.computedWeight"), - n_("tutti.table.species.frequency.header.computedWeight")); - - private final SpeciesFrequencyUIModel uiModel; - - private final Map<Float, SpeciesFrequencyRowModel> rowCache; - - public SpeciesFrequencyTableModel(TableColumnModel columnModel, - SpeciesFrequencyUIModel uiModel) { - super(columnModel); - this.uiModel = uiModel; - this.rowCache = Maps.newTreeMap(); - setNoneEditableCols(COMPUTED_WEIGHT); - } - - @Override - protected SpeciesFrequencyRowModel createNewRow() { - Float defaultStep = null; - - int rowCount = getRowCount(); - if (rowCount > 0) { - - SpeciesFrequencyRowModel rowModel = getEntry(rowCount - 1); - Float lengthStep = rowModel.getLengthStep(); - if (lengthStep != null) { - defaultStep = uiModel.getLengthStep( - lengthStep + uiModel.getStep()); - } - } - SpeciesFrequencyRowModel result = new SpeciesFrequencyRowModel(); - result.setLengthStep(defaultStep); - result.setValid(false); - return result; - } - - @Override - public void setValueAt(Object aValue, - int rowIndex, - int columnIndex, - ColumnIdentifier<SpeciesFrequencyRowModel> propertyName, - SpeciesFrequencyRowModel entry) { - super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry); - // TODO Rebuild the computedWeight if possible... - } - - public Map<Float, SpeciesFrequencyRowModel> getRowCache() { - return rowCache; - } - - @Override - protected void onRowsChanged(List<SpeciesFrequencyRowModel> data) { - - // rebuild row cache - rowCache.clear(); - - for (SpeciesFrequencyRowModel row : data) { - Float lengthStep = row.getLengthStep(); - if (lengthStep != null) { - rowCache.put(lengthStep, row); - } - } - } - - @Override - protected void onRowAdded(int rowIndex, SpeciesFrequencyRowModel newValue) { - - Preconditions.checkNotNull(newValue, "can't add a null row"); - - newValue.setLengthStepCaracteristic(uiModel.getLengthStepCaracteristic()); - - // add new row to cache - Float lengthStep = newValue.getLengthStep(); - - Preconditions.checkNotNull(lengthStep, - "can't add a null lengthStep row"); - - float roundLenghtValue = uiModel.getLengthStep(lengthStep); - - if (!rowCache.containsKey(roundLenghtValue)) { - - rowCache.put(roundLenghtValue, newValue); - } - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.css 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.css 2012-12-28 08:34:01 UTC (rev 114) @@ -1,160 +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% - */ - -BeanComboBox { - showReset: true; - i18nPrefix: "tutti.property."; - bean: {model}; -} - -NumberEditor { - autoPopup: {handler.getConfig().isAutoPopupNumberEditor()}; - showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; -} - -#stepLabel { - text: "tutti.label.frequencyConfiguration.step"; - labelFor: {stepField}; -} - -#stepField { - property: "step"; - model: {model.getStep()}; - useFloat: true; - numberPattern: {DECIMAL1_PATTERN}; - bean: {model}; -} - -#lenghtStepCaracteristicLabel { - text: "tutti.label.frequencyConfiguration.lengthStepCaracteristic"; - labelFor: {lenghtStepCaracteristicComboBox}; -} - -#lenghtStepCaracteristicComboBox { - property: "lengthStepCaracteristic"; - selectedItem: {model.getLengthStepCaracteristic()}; -} - -#minStepLabel { - text: "tutti.label.frequencyConfiguration.minStep"; - labelFor: {minStepField}; -} - -#minStepField { - property: "minStep"; - model: {model.getMinStep()}; - useFloat: true; - showReset: true; - numberPattern: {DECIMAL1_PATTERN}; - bean: {model}; -} - -#maxStepLabel { - text: "tutti.label.frequencyConfiguration.maxStep"; - labelFor: {maxStepField}; -} - -#maxStepField { - property: "maxStep"; - model: {model.getMaxStep()}; - useFloat: true; - showReset: true; - numberPattern: {DECIMAL1_PATTERN}; - bean: {model}; -} - -#rafaleStepLabel { - text: "tutti.label.frequencyConfiguration.rafaleStep"; - labelFor: {rafaleStepField}; -} - -#rafaleStepField { - modelType: {Float.class}; - useFloat: true; - showReset: true; - numberPattern: {DECIMAL1_PATTERN}; -} - -#generateButton { - actionIcon: "generate"; - text: "tutti.action.generate"; - enabled: {model.isCanGenerate()}; -} - -#configurationPanel { - border: {new TitledBorder(null, _("tutti.legend.frequencyConfiguration"))}; -} - -#modeConfigurationLayout { - selected: {String.valueOf(mode.getSelectedValue())}; -} - -#modeConfigurationPanel { - layout: {modeConfigurationLayout}; -} - -#simpleModeButton { - text: "tutti.label.frequencyConfiguration.mode.simple"; - toolTipText: "tutti.label.frequencyConfiguration.mode.simple.tip"; - value: "simpleMode"; - selected: {model.isSimpleMode()}; - buttonGroup: "mode"; -} - -#simpleModeLabel { - text: "tutti.label.frequencyConfiguration.no.configuration"; - horizontalAlignment: {JLabel.CENTER}; - enabled: false; -} - -#autoGenModeButton { - text: "tutti.label.frequencyConfiguration.mode.autoGen"; - toolTipText: "tutti.label.frequencyConfiguration.mode.autoGen.tip"; - value: "autoGenMode"; - selected: {model.isAutoGenMode()}; - buttonGroup: "mode"; -} - -#rafaleModeButton { - text: "tutti.label.frequencyConfiguration.mode.rafale"; - toolTipText: "tutti.label.frequencyConfiguration.mode.rafale.tip"; - value: "rafaleMode"; - selected: {model.isRafaleMode()}; - buttonGroup: "mode"; -} - -#closeButton { - actionIcon: "close"; - text: "tutti.action.close"; - mnemonic: F; - enabled: {model.getRows().size() == 0 || model.getLengthStepCaracteristic() != null}; -} - -#table { - selectionMode: {ListSelectionModel.SINGLE_SELECTION}; - selectionBackground: {null}; - selectionForeground: {Color.BLACK}; - sortable: false; - enabled: {model.getLengthStepCaracteristic() != null} -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.jaxx 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.jaxx 2012-12-28 08:34:01 UTC (rev 114) @@ -1,182 +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<SpeciesFrequencyUIModel, SpeciesFrequencyUIHandler>'> - - <import> - fr.ifremer.tutti.persistence.entities.referential.Caracteristic - - fr.ifremer.tutti.ui.swing.TuttiUIContext - fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel - - jaxx.runtime.swing.CardLayout2Ext - jaxx.runtime.swing.editor.bean.BeanComboBox - jaxx.runtime.swing.editor.NumberEditor - - org.jdesktop.swingx.JXTable - - javax.swing.ListSelectionModel - javax.swing.SwingConstants - - java.awt.Color - java.awt.Dimension - - static org.nuiton.i18n.I18n._ - static jaxx.runtime.SwingUtil.getStringValue - </import> - - <script><![CDATA[ - - public SpeciesFrequencyUI(SpeciesBatchUI parentUI) { - JAXXUtil.initContext(this, parentUI); - SpeciesFrequencyUIHandler handler = new SpeciesFrequencyUIHandler(parentUI.getHandler().getContext(), this); - setContextValue(handler); - handler.beforeInitUI(); - } - - public void editBatch(SpeciesBatchRowModel row) { - handler.editBatch(row); - } - - protected void $afterCompleteSetup() { - handler.afterInitUI(); - } - ]]></script> - - <SpeciesFrequencyUIHandler id='handler' - initializer='getContextValue(SpeciesFrequencyUIHandler.class)'/> - - <SpeciesFrequencyUIModel id='model' - initializer='getContextValue(SpeciesFrequencyUIModel.class)'/> - - <CardLayout2Ext id='modeConfigurationLayout' - constructorParams='this, "modeConfigurationPanel"'/> - - <JPanel id='configurationPanel' layout='{new BorderLayout()}' - constraints='BorderLayout.NORTH'> - - <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.CENTER'> - <VBox id='modePanel' constraints='BorderLayout.WEST' - verticalAlignment='{SwingConstants.CENTER}'> - <JRadioButton id='simpleModeButton' - onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE)'/> - <JRadioButton id='autoGenModeButton' - onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.AUTO_GEN)'/> - <JRadioButton id='rafaleModeButton' - onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.RAFALE)'/> - </VBox> - - <JPanel id='modeConfigurationPanel' constraints='BorderLayout.CENTER'> - <JPanel id='simpleModePanel' constraints='"simpleMode"' - layout='{new BorderLayout()}'> - <JLabel id='simpleModeLabel' constraints='BorderLayout.CENTER'/> - </JPanel> - <JPanel id='autoGenModePanel' constraints='"autoGenMode"'> - <Table fill='both' constraints='BorderLayout.SOUTH'> - <!-- Min step--> - <row> - <cell anchor='west'> - <JLabel id='minStepLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='minStepField' constructorParams='this'/> - </cell> - </row> - <!-- Max step--> - <row> - <cell anchor='west'> - <JLabel id='maxStepLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='maxStepField' constructorParams='this'/> - </cell> - </row> - <!-- Actions --> - <row> - <cell columns='2'> - <JPanel layout='{new GridLayout(1, 0)}'> - <JButton id='generateButton' - onActionPerformed='handler.generateLengthSteps()'/> - </JPanel> - </cell> - </row> - </Table> - </JPanel> - <JPanel id='rafaleModePanel' constraints='"rafaleMode"'> - <Table fill='both' constraints='BorderLayout.SOUTH'> - <!-- Rafale step--> - <row> - <cell weightx='1.0'> - <JLabel id='rafaleStepLabel'/> - </cell> - </row> - <row> - <cell weightx='1.0'> - <NumberEditor id='rafaleStepField' constructorParams='this'/> - </cell> - </row> - </Table> - </JPanel> - </JPanel> - </JPanel> - <Table fill='both' constraints='BorderLayout.SOUTH'> - <row> - <cell columns='2'> - <JSeparator/> - </cell> - </row> - <!-- length step caracteristic --> - <row> - <cell anchor='west'> - <JLabel id='lenghtStepCaracteristicLabel'/> - </cell> - <cell weightx='1.0'> - <BeanComboBox id='lenghtStepCaracteristicComboBox' - constructorParams='this' - genericType='Caracteristic'/> - </cell> - </row> - <!-- Step --> - <row> - <cell anchor='west'> - <JLabel id='stepLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='stepField' constructorParams='this'/> - </cell> - </row> - </Table> - </JPanel> - - <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> - <JXTable id='table'/> - </JScrollPane> - - <!-- actions --> - <JPanel id='actionPanel' layout='{new GridLayout(1, 0)}' - constraints='BorderLayout.SOUTH'> - <JButton id='closeButton' onActionPerformed='handler.close()'/> - </JPanel> - -</JPanel> \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIHandler.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIHandler.java 2012-12-28 08:34:01 UTC (rev 114) @@ -1,414 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.catches.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.ezware.oxbow.swingbits.util.Preconditions; -import com.google.common.collect.Lists; -import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; -import fr.ifremer.tutti.ui.swing.TuttiUI; -import fr.ifremer.tutti.ui.swing.TuttiUIContext; -import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; -import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; -import jaxx.runtime.SwingUtil; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.JXTable; -import org.jdesktop.swingx.decorator.HighlightPredicate; -import org.jdesktop.swingx.table.DefaultTableColumnModelExt; - -import javax.swing.JDialog; -import javax.swing.table.TableColumnModel; -import java.awt.Color; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<SpeciesFrequencyRowModel, SpeciesFrequencyUIModel> { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(SpeciesFrequencyUIHandler.class); - - private final SpeciesFrequencyUI ui; - - public SpeciesFrequencyUIHandler(TuttiUIContext context, - SpeciesFrequencyUI ui) { - super(context, - SpeciesFrequencyRowModel.PROPERTY_LENGTH_STEP, - SpeciesFrequencyRowModel.PROPERTY_NUMBER, - SpeciesFrequencyRowModel.PROPERTY_WEIGHT, - SpeciesFrequencyRowModel.PROPERTY_COMPUTED_WEIGHT); - this.ui = ui; - } - - //------------------------------------------------------------------------// - //-- AbstractTuttiTableUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - protected SpeciesFrequencyUIModel getModel() { - return ui.getModel(); - } - - @Override - protected SpeciesFrequencyTableModel getTableModel() { - return (SpeciesFrequencyTableModel) getTable().getModel(); - } - - @Override - protected JXTable getTable() { - return ui.getTable(); - } - - @Override - protected TableColumnModel createTableColumnModel() { - - DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt(); - - { // LengthStep - - addFloatColumnToModel(columnModel, - SpeciesFrequencyTableModel.LENGTH_STEP, - TuttiUI.DECIMAL1_PATTERN); - } - - { // Number - - addIntegerColumnToModel(columnModel, - SpeciesFrequencyTableModel.NUMBER, - TuttiUI.INT_6_DIGITS_PATTERN); - } - - { // Weight - - addFloatColumnToModel(columnModel, - SpeciesFrequencyTableModel.WEIGHT, - TuttiUI.DECIMAL3_PATTERN); - } - - { // ComputedWeight - - addFloatColumnToModel(columnModel, - SpeciesFrequencyTableModel.COMPUTED_WEIGHT, - TuttiUI.DECIMAL3_PATTERN); - } - return columnModel; - } - - @Override - protected void onRowModified(SpeciesFrequencyRowModel row, - String propertyName, - Object oldValue, - Object newValue) { - if (SpeciesFrequencyRowModel.PROPERTY_NUMBER.equals(propertyName)) { - - // Need to recompute the computedWeight - computeComputedWeight(row); - } - } - - @Override - protected void onRowValidStateChanged(SpeciesFrequencyRowModel row, - Boolean oldValue, - Boolean newValue) { - } - - @Override - protected void onRowModifyStateChanged(SpeciesFrequencyRowModel row, - Boolean oldValue, - Boolean newValue) { - } - - //------------------------------------------------------------------------// - //-- AbstractTuttiUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - public void beforeInitUI() { - - SpeciesFrequencyUIModel model = new SpeciesFrequencyUIModel(); - - ui.setContextValue(model); - } - - @Override - public void afterInitUI() { - - initUI(ui); - - List<Caracteristic> lengthStepCaracterics = - ui.getContextValue( - List.class, - SpeciesBatchUIHandler.SPECIES_FREQUENCY_LENGHTS); - Preconditions.checkNotNull(lengthStepCaracterics); - - SpeciesFrequencyUIModel model = getModel(); - - //TODO Use protocol to have lengthStepCaracteristic to use (if any protocol) - initBeanComboBox(ui.getLenghtStepCaracteristicComboBox(), - lengthStepCaracterics, - model.getLengthStepCaracteristic()); - - JXTable table = getTable(); - - // create table column model - TableColumnModel columnModel = createTableColumnModel(); - - // create table model - SpeciesFrequencyTableModel tableModel = - new SpeciesFrequencyTableModel(columnModel, model); - - table.setModel(tableModel); - table.setColumnModel(columnModel); - - installTableKeyListener(columnModel, table); - - table.getTableHeader().setReorderingAllowed(false); - - table.addHighlighter(TuttiUIUtil.newBackgroundColorHighlighter( - HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY)); - - // when model datas change let's propagate it table model - listenRowsFromModel(); - - //TODO Should it come from PROTOCOL or config ? - model.setStep(.5f); - - model.setMinStep(10f); - model.setMaxStep(20f); - - //TODO Configure this ? - model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE); - - // always scroll to selected row - SwingUtil.scrollToTableSelection(getTable()); - - ui.getRafaleStepField().getTextField().addKeyListener(new KeyAdapter() { - - @Override - public void keyReleased(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_ENTER) { - e.consume(); - Float step = (Float) ui.getRafaleStepField().getModel(); - - applyRafaleStep(step); - } - } - }); - - // when lengthStepCaracteristic changed, let's updates all row with the new value - model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_LENGHT_STEP_CARACTERISTIC, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - Caracteristic newValue = (Caracteristic) evt.getNewValue(); - for (SpeciesFrequencyRowModel rowModel : getModel().getRows()) { - rowModel.setLengthStepCaracteristic(newValue); - } - } - }); - } - - @Override - public void onCloseUI() { - } - - //------------------------------------------------------------------------// - //-- Public methods --// - //------------------------------------------------------------------------// - - public void generateLengthSteps() { - - SpeciesFrequencyUIModel model = getModel(); - - Map<Float, SpeciesFrequencyRowModel> rowsByStep = - getTableModel().getRowCache(); - - Float minStep = model.getLengthStep(model.getMinStep()); - Float maxStep = model.getLengthStep(model.getMaxStep()); - - for (float i = minStep, step = model.getStep(); i <= maxStep; i += step) { - if (!rowsByStep.containsKey(i)) { - - // add it - SpeciesFrequencyRowModel newRow = new SpeciesFrequencyRowModel(); - newRow.setLengthStep(i); - rowsByStep.put(i, newRow); - } - } - - List<SpeciesFrequencyRowModel> rows = - Lists.newArrayList(rowsByStep.values()); - - model.setRows(rows); - } - - public void applyRafaleStep(Float step) { - - if (log.isInfoEnabled()) { - log.info("Will apply rafale step: " + step); - } - SpeciesFrequencyUIModel model = getModel(); - SpeciesFrequencyTableModel tableModel = getTableModel(); - - Map<Float, SpeciesFrequencyRowModel> rowsByStep = tableModel.getRowCache(); - - float aroundLengthStep = model.getLengthStep(step); - - SpeciesFrequencyRowModel row = rowsByStep.get(aroundLengthStep); - - int rowIndex; - - if (row != null) { - - // increments current row - Integer number = row.getNumber(); - row.setNumber((number == null ? 0 : number) + 1); - rowIndex = tableModel.updateRow(row); - - } else { - - // create a new row - row = new SpeciesFrequencyRowModel(); - row.setLengthStep(aroundLengthStep); - row.setNumber(1); - - // get new index - List<Float> steps = Lists.newArrayList(rowsByStep.keySet()); - steps.add(aroundLengthStep); - - Collections.sort(steps); - - rowIndex = steps.indexOf(aroundLengthStep); - - tableModel.addNewRow(rowIndex, row); - } - - getTable().scrollRowToVisible(rowIndex); - } - - public void editBatch(SpeciesBatchRowModel row) { - - List<SpeciesFrequencyRowModel> frequency = null; - - Caracteristic lengthStepCaracteristic = null; - if (row != null) { - frequency = row.getFrequency(); - } - - - List<SpeciesFrequencyRowModel> editFrequency; - if (CollectionUtils.isEmpty(frequency)) { - - // new list - editFrequency = Lists.newArrayList(); - } else { - - editFrequency = Lists.newArrayList(frequency); - lengthStepCaracteristic = frequency.get(0).getLengthStepCaracteristic(); - } - - if (log.isInfoEnabled()) { - log.info("Will edit batch row: " + row + " with " + - editFrequency.size() + " frequency"); - } - - SpeciesFrequencyUIModel model = getModel(); - - model.setRows(editFrequency); - - if (lengthStepCaracteristic == null) { - - // no lengthStep caracteristic to apply make sure it is not setted. - if (log.isInfoEnabled()) { - log.info("No lengthStepCaracteristic to set."); - } - model.setLengthStepCaracteristic(null); - } else { - - // apply existing lengthStepCaracteristic - - if (log.isInfoEnabled()) { - log.info("Use lengthStepCaracteristic: " + - lengthStepCaracteristic.getName()); - } - model.setLengthStepCaracteristic(lengthStepCaracteristic); - } - - // keep batch (will be used to push back editing entry) - model.setBatch(row); - } - - public void close() { - - if (log.isInfoEnabled()) { - log.info("Will close UI " + ui); - } - - SpeciesFrequencyUIModel model = getModel(); - - // transfer rows to editor - List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList(); - for (SpeciesFrequencyRowModel row : model.getRows()) { - if (row.isValid()) { - - // can keep this row - frequency.add(row); - } - } - - if (log.isInfoEnabled()) { - log.info("Push back " + frequency.size() + - " frequency to batch " + model.getBatch()); - } - - // push back to batch - model.getBatch().setFrequency(frequency); - - ui.editBatch(null); - - SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false); - } - - //------------------------------------------------------------------------// - //-- Internal methods --// - //------------------------------------------------------------------------// - - protected void computeComputedWeight(SpeciesFrequencyRowModel row) { - - if (log.isInfoEnabled()) { - log.info("Will recompute computed weight for frequency: " + row); - } - } - -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIModel.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIModel.java 2012-12-28 08:34:01 UTC (rev 114) @@ -1,194 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.catches.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.referential.Caracteristic; -import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBatchRowModel, SpeciesFrequencyRowModel, SpeciesFrequencyUIModel> { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_CONFIGURATION_MODE = "configurationMode"; - - public static final String PROPERTY_STEP = "step"; - - private static final String PROPERTY_MIN_STEP = "minStep"; - - private static final String PROPERTY_MAX_STEP = "maxStep"; - - public static final String PROPERTY_CAN_GENERATE = "canGenerate"; - - public static final String PROPERTY_SIMPLE_MODE = "simpleMode"; - - public static final String PROPERTY_AUTO_GEN_MODE = "autoGenMode"; - - public static final String PROPERTY_RAFALE_MODE = "rafaleMode"; - - public static final String PROPERTY_LENGHT_STEP_CARACTERISTIC = "lengthStepCaracteristic"; - - public static enum ConfigurationMode { - SIMPLE, - AUTO_GEN, - RAFALE - } - - /** - * Fill mode. - * - * @since 0.2 - */ - protected ConfigurationMode configurationMode; - - /** - * Batch that contains frequencies. - * - * @since 0.2 - */ - protected SpeciesBatchRowModel batch; - - /** - * Default step to increment length step. - * - * @since 0.2 - */ - protected float step; - - /** - * Min step to auto generate length steps. - * - * @since 0.2 - */ - protected Float minStep; - - /** - * Max step to auto generate length steps. - * - * @since 0.2 - */ - protected Float maxStep; - - /** - * Length step caracteristic. - * - * @since 0.3 - */ - protected Caracteristic lengthStepCaracteristic; - - public SpeciesFrequencyUIModel() { - super(SpeciesBatchRowModel.class, null, null); - } - - public ConfigurationMode getConfigurationMode() { - return configurationMode; - } - - public void setConfigurationMode(ConfigurationMode configurationMode) { - Object oldValue = getConfigurationMode(); - this.configurationMode = configurationMode; - firePropertyChange(PROPERTY_CONFIGURATION_MODE, oldValue, configurationMode); - firePropertyChange(PROPERTY_SIMPLE_MODE, null, isSimpleMode()); - firePropertyChange(PROPERTY_AUTO_GEN_MODE, null, isAutoGenMode()); - firePropertyChange(PROPERTY_RAFALE_MODE, null, isRafaleMode()); - } - - public float getStep() { - return step; - } - - public void setStep(float step) { - Object oldValue = getStep(); - this.step = step; - firePropertyChange(PROPERTY_STEP, oldValue, step); - } - - public Caracteristic getLengthStepCaracteristic() { - return lengthStepCaracteristic; - } - - public void setLengthStepCaracteristic(Caracteristic lengthStepCaracteristic) { - Object oldValue = getLengthStepCaracteristic(); - this.lengthStepCaracteristic = lengthStepCaracteristic; - firePropertyChange(PROPERTY_LENGHT_STEP_CARACTERISTIC, oldValue, lengthStepCaracteristic); - } - - public Float getMinStep() { - return minStep; - } - - public void setMinStep(Float minStep) { - Object oldValue = getMinStep(); - this.minStep = minStep; - firePropertyChange(PROPERTY_MIN_STEP, oldValue, minStep); - firePropertyChange(PROPERTY_CAN_GENERATE, null, isCanGenerate()); - } - - public Float getMaxStep() { - return maxStep; - } - - public void setMaxStep(Float maxStep) { - Object oldValue = getMaxStep(); - this.maxStep = maxStep; - firePropertyChange(PROPERTY_MAX_STEP, oldValue, maxStep); - firePropertyChange(PROPERTY_CAN_GENERATE, null, isCanGenerate()); - } - - public boolean isSimpleMode() { - return ConfigurationMode.SIMPLE == configurationMode; - } - - public boolean isAutoGenMode() { - return ConfigurationMode.AUTO_GEN == configurationMode; - } - - public boolean isRafaleMode() { - return ConfigurationMode.RAFALE == configurationMode; - } - - public boolean isCanGenerate() { - return minStep != null && maxStep != null && maxStep > minStep; - } - - public SpeciesBatchRowModel getBatch() { - return batch; - } - - public void setBatch(SpeciesBatchRowModel batch) { - this.batch = batch; - } - - public float getLengthStep(float lengthStep) { - int intValue = (int) (lengthStep * 10); - int intStep = (int) (step * 10); - int correctIntStep = intValue - (intValue % intStep); - float result = correctIntStep / 10f; - return result; - } -} \ No newline at end of file Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/TableViewMode.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/TableViewMode.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/TableViewMode.java 2012-12-28 08:34:01 UTC (rev 114) @@ -0,0 +1,52 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.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% + */ + +/** + * What to show in the species table? + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public enum TableViewMode { + /** + * Show all nodes of sampling. + * + * @since 0.3 + */ + ALL, + /** + * Show only leaves of sampling. + * + * @since 0.3 + */ + LEAF, + /** + * Show onlyroot nodes of sampling. + * + * @since 0.3 + */ + ROOT +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/TableViewMode.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/catches/species/frequency/FrequencyCellComponent.java (from rev 108, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/FrequencyCellComponent.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2012-12-28 08:34:01 UTC (rev 114) @@ -0,0 +1,259 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency; + +/* + * #%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 fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel; +import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; +import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; +import jaxx.runtime.SwingUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.AbstractCellEditor; +import javax.swing.JButton; +import javax.swing.JTable; +import javax.swing.border.LineBorder; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import java.awt.Color; +import java.awt.Component; +import java.awt.Frame; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import static org.nuiton.i18n.I18n._; + +/** + * Component to render and edit frequency stuff from batch table. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class FrequencyCellComponent extends JButton { + + private static final long serialVersionUID = 1L; + + public static final String ROW_INDEX = "rowIndex"; + + /** Logger. */ + private static final Log log = + LogFactory.getLog(FrequencyCellComponent.class); + + public FrequencyCellComponent() { + setContentAreaFilled(false); + setOpaque(false); + setIcon(SwingUtil.createActionIcon("show-frequency")); + } + + public static TableCellRenderer newRender() { + return new FrequencyCellRenderer(); + } + + public static TableCellEditor newEditor(SpeciesFrequencyUI ui) { + return new FrequencyCellEditor(ui); + } + + public static class FrequencyCellEditor extends AbstractCellEditor implements TableCellEditor { + + private static final long serialVersionUID = 1L; + + protected final FrequencyCellComponent component; + + protected final SpeciesFrequencyUI ui; + + protected Frame frame; + + protected JTable table; + + protected SpeciesBatchTableModel tableModel; + + protected ColumnIdentifier<SpeciesBatchRowModel> columnIdentifier; + + protected SpeciesBatchRowModel editRow; + + protected Integer rowIndex; + + protected Integer columnIndex; + + public FrequencyCellEditor(SpeciesFrequencyUI ui) { + this.ui = ui; + component = new FrequencyCellComponent(); + component.setBorder(new LineBorder(Color.BLACK)); + component.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER || + e.getKeyCode() == KeyEvent.VK_SPACE) { + e.consume(); + startEdit(); + } + } + }); + + component.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + e.consume(); + startEdit(); + } + }); + } + + protected void startEdit() { + + Preconditions.checkNotNull(tableModel, "No table model assigned."); + + // open frequency dialog + + Preconditions.checkNotNull(editRow, "No editRow found."); + + if (log.isInfoEnabled()) { + log.info("Will edit frequencies for row: " + rowIndex); + } + + if (frame == null) { + frame = SwingUtil.getParentContainer(ui, Frame.class); + } + + ui.editBatch(editRow); + + // open frequency dialog + TuttiUIUtil.openInDialog( + ui, frame, _("tutti.title.frequency"), true, null); + + // at close, synch back frequencies + + editRow.updateTotalFromFrequencies(); + + int r = rowIndex; + int c = columnIndex; + + // stop edition + stopCellEditing(); + + // reselect this cell + AbstractSelectTableAction.doSelectCell(table, r, c); + table.requestFocus(); + } + + @Override + public Component getTableCellEditorComponent(JTable table, + Object value, + boolean isSelected, + int row, + int column) { + if (tableModel == null) { + tableModel = (SpeciesBatchTableModel) table.getModel(); + this.table = table; + columnIdentifier = tableModel.getPropertyName(column); + } + String text; + if (value == null) { + text = " - "; + } else { + text = String.valueOf(value); + } + component.setText(text); + + rowIndex = row; + columnIndex = column; + + editRow = tableModel.getEntry(row); + + return component; + } + + @Override + public Object getCellEditorValue() { + + Preconditions.checkNotNull(editRow, "No editRow found in editor."); + + Object result; + if (columnIdentifier == SpeciesBatchTableModel.COMPUTED_NUMBER) { + result = editRow.getComputedNumber(); + } else { + result = editRow.getComputedWeight(); + } + if (log.isInfoEnabled()) { + log.info("editor value (" + columnIdentifier + "): " + result); + } + + return result; + } + + @Override + public boolean stopCellEditing() { + boolean b = super.stopCellEditing(); + if (b) { + rowIndex = null; + editRow = null; + columnIndex = null; + } + return b; + } + + @Override + public void cancelCellEditing() { + super.cancelCellEditing(); + rowIndex = null; + columnIndex = null; + editRow = null; + } + } + + public static class FrequencyCellRenderer implements TableCellRenderer { + + protected final FrequencyCellComponent component; + + public FrequencyCellRenderer() { + component = new FrequencyCellComponent(); + } + + @Override + public Component getTableCellRendererComponent(JTable table, + Object value, + boolean isSelected, + boolean hasFocus, + int row, + int column) { + + String text; + if (value == null) { + text = " - "; + } else { + text = String.valueOf(value); + } + boolean editable = table.isCellEditable(row, column); + component.setEnabled(editable); + component.setText(text); + return component; + } + } +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.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/catches/species/frequency/SpeciesFrequencyRowModel.java (from rev 109, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyRowModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java 2012-12-28 08:34:01 UTC (rev 114) @@ -0,0 +1,191 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency; + +/* + * #%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 com.google.common.collect.Ordering; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; +import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; +import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +import java.util.List; + +/** + * Represents a batch frequency row. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBatchFrequency, SpeciesFrequencyRowModel> implements Comparable<SpeciesFrequencyRowModel> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_LENGTH_STEP = "lengthStep"; + + public static final String PROPERTY_NUMBER = "number"; + + public static final String PROPERTY_WEIGHT = "weight"; + + public static final String PROPERTY_COMPUTED_WEIGHT = "computedWeight"; + + + public static final String PROPERTY_LENGHT_STEP_CARACTERISTIC = "lengthStepCaracteristic"; + + + /** + * Length step. + * + * @since 0.2 + */ + protected Float lengthStep; + + /** + * Count of fishes for this lengthStep. + * + * @since 0.2 + */ + protected Integer number; + + /** + * Weight of fishes observed. + * + * @since 0.2 + */ + protected Float weight; + + /** + * Computed weight from number + relation taille-poids. + * + * @since 0.2 + */ + protected Float computedWeight; + + /** + * Length step caracteristic. + * + * @since 0.3 + */ + protected Caracteristic lengthStepCaracteristic; + + protected static final Binder<SpeciesBatchFrequency, SpeciesFrequencyRowModel> fromBeanBinder = + BinderFactory.newBinder(SpeciesBatchFrequency.class, + SpeciesFrequencyRowModel.class); + + protected static final Binder<SpeciesFrequencyRowModel, SpeciesBatchFrequency> toBeanBinder = + BinderFactory.newBinder(SpeciesFrequencyRowModel.class, + SpeciesBatchFrequency.class); + + private static final Ordering<Float> ordering = Ordering.natural().nullsFirst(); + + public static List<SpeciesFrequencyRowModel> fromBeans(List<SpeciesBatchFrequency> frequency) { + List<SpeciesFrequencyRowModel> result = Lists.newArrayList(); + for (SpeciesBatchFrequency b : frequency) { + SpeciesFrequencyRowModel model = new SpeciesFrequencyRowModel(); + fromBeanBinder.copy(b, model); + result.add(model); + } + return result; + } + + public static List<SpeciesBatchFrequency> toBeans(List<SpeciesFrequencyRowModel> frequency, SpeciesBatch batch) { + List<SpeciesBatchFrequency> result = Lists.newArrayList(); + for (SpeciesFrequencyRowModel b : frequency) { + SpeciesBatchFrequency model = new SpeciesBatchFrequency(); + toBeanBinder.copy(b, model); + model.setBatch(batch); + result.add(model); + } + return result; + } + + public SpeciesFrequencyRowModel() { + super(SpeciesBatchFrequency.class, fromBeanBinder, toBeanBinder); + } + + public Float getLengthStep() { + return lengthStep; + } + + public void setLengthStep(Float lengthStep) { + Object oldValue = getLengthStep(); + this.lengthStep = lengthStep; + firePropertyChange(PROPERTY_LENGTH_STEP, oldValue, lengthStep); + } + + public Integer getNumber() { + return number; + } + + public void setNumber(Integer number) { + Object oldValue = getNumber(); + this.number = number; + firePropertyChange(PROPERTY_NUMBER, oldValue, number); + } + + public Float getWeight() { + return weight; + } + + public void setWeight(Float weight) { + Object oldValue = getWeight(); + this.weight = weight; + firePropertyChange(PROPERTY_WEIGHT, oldValue, weight); + } + + public Float getComputedWeight() { + return computedWeight; + } + + public void setComputedWeight(Float computedWeight) { + Object oldValue = getComputedWeight(); + this.computedWeight = computedWeight; + firePropertyChange(PROPERTY_COMPUTED_WEIGHT, oldValue, computedWeight); + } + + public Caracteristic getLengthStepCaracteristic() { + return lengthStepCaracteristic; + } + + public void setLengthStepCaracteristic(Caracteristic lengthStepCaracteristic) { + Object oldValue = getLengthStepCaracteristic(); + this.lengthStepCaracteristic = lengthStepCaracteristic; + firePropertyChange(PROPERTY_LENGHT_STEP_CARACTERISTIC, oldValue, lengthStepCaracteristic); + } + + //TODO Use validator + @Override + public boolean isValid() { + return lengthStep != null && number != null && lengthStepCaracteristic != null; + } + + @Override + public int compareTo(SpeciesFrequencyRowModel o) { + int result = ordering.compare(lengthStep, o.lengthStep); + return result; + } +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.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/catches/species/frequency/SpeciesFrequencyTableModel.java (from rev 109, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java 2012-12-28 08:34:01 UTC (rev 114) @@ -0,0 +1,148 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency; + +/* + * #%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.Maps; +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.List; +import java.util.Map; + +import static org.nuiton.i18n.I18n.n_; + +/** + * Model of the species frequency table. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class SpeciesFrequencyTableModel extends AbstractTuttiTableModel<SpeciesFrequencyRowModel> { + + private static final long serialVersionUID = 1L; + + public static final ColumnIdentifier<SpeciesFrequencyRowModel> LENGTH_STEP = ColumnIdentifier.newId( + SpeciesFrequencyRowModel.PROPERTY_LENGTH_STEP, + n_("tutti.table.species.frequency.header.lengthStep"), + n_("tutti.table.species.frequency.header.lengthStep")); + + public static final ColumnIdentifier<SpeciesFrequencyRowModel> NUMBER = ColumnIdentifier.newId( + SpeciesFrequencyRowModel.PROPERTY_NUMBER, + n_("tutti.table.species.frequency.header.number"), + n_("tutti.table.species.frequency.header.number")); + + public static final ColumnIdentifier<SpeciesFrequencyRowModel> WEIGHT = ColumnIdentifier.newId( + SpeciesFrequencyRowModel.PROPERTY_WEIGHT, + n_("tutti.table.species.frequency.header.weight"), + n_("tutti.table.species.frequency.header.weight")); + + public static final ColumnIdentifier<SpeciesFrequencyRowModel> COMPUTED_WEIGHT = ColumnIdentifier.newId( + SpeciesFrequencyRowModel.PROPERTY_COMPUTED_WEIGHT, + n_("tutti.table.species.frequency.header.computedWeight"), + n_("tutti.table.species.frequency.header.computedWeight")); + + private final SpeciesFrequencyUIModel uiModel; + + private final Map<Float, SpeciesFrequencyRowModel> rowCache; + + public SpeciesFrequencyTableModel(TableColumnModel columnModel, + SpeciesFrequencyUIModel uiModel) { + super(columnModel); + this.uiModel = uiModel; + this.rowCache = Maps.newTreeMap(); + setNoneEditableCols(COMPUTED_WEIGHT); + } + + @Override + protected SpeciesFrequencyRowModel createNewRow() { + Float defaultStep = null; + + int rowCount = getRowCount(); + if (rowCount > 0) { + + SpeciesFrequencyRowModel rowModel = getEntry(rowCount - 1); + Float lengthStep = rowModel.getLengthStep(); + if (lengthStep != null) { + defaultStep = uiModel.getLengthStep( + lengthStep + uiModel.getStep()); + } + } + SpeciesFrequencyRowModel result = new SpeciesFrequencyRowModel(); + result.setLengthStep(defaultStep); + result.setValid(false); + return result; + } + + @Override + public void setValueAt(Object aValue, + int rowIndex, + int columnIndex, + ColumnIdentifier<SpeciesFrequencyRowModel> propertyName, + SpeciesFrequencyRowModel entry) { + super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry); + // TODO Rebuild the computedWeight if possible... + } + + public Map<Float, SpeciesFrequencyRowModel> getRowCache() { + return rowCache; + } + + @Override + protected void onRowsChanged(List<SpeciesFrequencyRowModel> data) { + + // rebuild row cache + rowCache.clear(); + + for (SpeciesFrequencyRowModel row : data) { + Float lengthStep = row.getLengthStep(); + if (lengthStep != null) { + rowCache.put(lengthStep, row); + } + } + } + + @Override + protected void onRowAdded(int rowIndex, SpeciesFrequencyRowModel newValue) { + + Preconditions.checkNotNull(newValue, "can't add a null row"); + + newValue.setLengthStepCaracteristic(uiModel.getLengthStepCaracteristic()); + + // add new row to cache + Float lengthStep = newValue.getLengthStep(); + + Preconditions.checkNotNull(lengthStep, + "can't add a null lengthStep row"); + + float roundLenghtValue = uiModel.getLengthStep(lengthStep); + + if (!rowCache.containsKey(roundLenghtValue)) { + + rowCache.put(roundLenghtValue, newValue); + } + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.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/catches/species/frequency/SpeciesFrequencyUI.css (from rev 109, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2012-12-28 08:34:01 UTC (rev 114) @@ -0,0 +1,160 @@ +/* + * #%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% + */ + +BeanComboBox { + showReset: true; + i18nPrefix: "tutti.property."; + bean: {model}; +} + +NumberEditor { + autoPopup: {handler.getConfig().isAutoPopupNumberEditor()}; + showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; +} + +#stepLabel { + text: "tutti.label.frequencyConfiguration.step"; + labelFor: {stepField}; +} + +#stepField { + property: "step"; + model: {model.getStep()}; + useFloat: true; + numberPattern: {DECIMAL1_PATTERN}; + bean: {model}; +} + +#lenghtStepCaracteristicLabel { + text: "tutti.label.frequencyConfiguration.lengthStepCaracteristic"; + labelFor: {lenghtStepCaracteristicComboBox}; +} + +#lenghtStepCaracteristicComboBox { + property: "lengthStepCaracteristic"; + selectedItem: {model.getLengthStepCaracteristic()}; +} + +#minStepLabel { + text: "tutti.label.frequencyConfiguration.minStep"; + labelFor: {minStepField}; +} + +#minStepField { + property: "minStep"; + model: {model.getMinStep()}; + useFloat: true; + showReset: true; + numberPattern: {DECIMAL1_PATTERN}; + bean: {model}; +} + +#maxStepLabel { + text: "tutti.label.frequencyConfiguration.maxStep"; + labelFor: {maxStepField}; +} + +#maxStepField { + property: "maxStep"; + model: {model.getMaxStep()}; + useFloat: true; + showReset: true; + numberPattern: {DECIMAL1_PATTERN}; + bean: {model}; +} + +#rafaleStepLabel { + text: "tutti.label.frequencyConfiguration.rafaleStep"; + labelFor: {rafaleStepField}; +} + +#rafaleStepField { + modelType: {Float.class}; + useFloat: true; + showReset: true; + numberPattern: {DECIMAL1_PATTERN}; +} + +#generateButton { + actionIcon: "generate"; + text: "tutti.action.generate"; + enabled: {model.isCanGenerate()}; +} + +#configurationPanel { + border: {new TitledBorder(null, _("tutti.legend.frequencyConfiguration"))}; +} + +#modeConfigurationLayout { + selected: {String.valueOf(mode.getSelectedValue())}; +} + +#modeConfigurationPanel { + layout: {modeConfigurationLayout}; +} + +#simpleModeButton { + text: "tutti.label.frequencyConfiguration.mode.simple"; + toolTipText: "tutti.label.frequencyConfiguration.mode.simple.tip"; + value: "simpleMode"; + selected: {model.isSimpleMode()}; + buttonGroup: "mode"; +} + +#simpleModeLabel { + text: "tutti.label.frequencyConfiguration.no.configuration"; + horizontalAlignment: {JLabel.CENTER}; + enabled: false; +} + +#autoGenModeButton { + text: "tutti.label.frequencyConfiguration.mode.autoGen"; + toolTipText: "tutti.label.frequencyConfiguration.mode.autoGen.tip"; + value: "autoGenMode"; + selected: {model.isAutoGenMode()}; + buttonGroup: "mode"; +} + +#rafaleModeButton { + text: "tutti.label.frequencyConfiguration.mode.rafale"; + toolTipText: "tutti.label.frequencyConfiguration.mode.rafale.tip"; + value: "rafaleMode"; + selected: {model.isRafaleMode()}; + buttonGroup: "mode"; +} + +#closeButton { + actionIcon: "close"; + text: "tutti.action.close"; + mnemonic: F; + enabled: {model.getRows().size() == 0 || model.getLengthStepCaracteristic() != null}; +} + +#table { + selectionMode: {ListSelectionModel.SINGLE_SELECTION}; + selectionBackground: {null}; + selectionForeground: {Color.BLACK}; + sortable: false; + enabled: {model.getLengthStepCaracteristic() != null} +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.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/catches/species/frequency/SpeciesFrequencyUI.jaxx (from rev 108, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx 2012-12-28 08:34:01 UTC (rev 114) @@ -0,0 +1,183 @@ +<!-- + #%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<SpeciesFrequencyUIModel, SpeciesFrequencyUIHandler>'> + + <import> + fr.ifremer.tutti.persistence.entities.referential.Caracteristic + + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel + fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI + + jaxx.runtime.swing.CardLayout2Ext + jaxx.runtime.swing.editor.bean.BeanComboBox + jaxx.runtime.swing.editor.NumberEditor + + org.jdesktop.swingx.JXTable + + javax.swing.ListSelectionModel + javax.swing.SwingConstants + + java.awt.Color + java.awt.Dimension + + static org.nuiton.i18n.I18n._ + static jaxx.runtime.SwingUtil.getStringValue + </import> + + <script><![CDATA[ + + public SpeciesFrequencyUI(SpeciesBatchUI parentUI) { + JAXXUtil.initContext(this, parentUI); + SpeciesFrequencyUIHandler handler = new SpeciesFrequencyUIHandler(parentUI.getHandler().getContext(), this); + setContextValue(handler); + handler.beforeInitUI(); + } + + public void editBatch(SpeciesBatchRowModel row) { + handler.editBatch(row); + } + + protected void $afterCompleteSetup() { + handler.afterInitUI(); + } + ]]></script> + + <SpeciesFrequencyUIHandler id='handler' + initializer='getContextValue(SpeciesFrequencyUIHandler.class)'/> + + <SpeciesFrequencyUIModel id='model' + initializer='getContextValue(SpeciesFrequencyUIModel.class)'/> + + <CardLayout2Ext id='modeConfigurationLayout' + constructorParams='this, "modeConfigurationPanel"'/> + + <JPanel id='configurationPanel' layout='{new BorderLayout()}' + constraints='BorderLayout.NORTH'> + + <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.CENTER'> + <VBox id='modePanel' constraints='BorderLayout.WEST' + verticalAlignment='{SwingConstants.CENTER}'> + <JRadioButton id='simpleModeButton' + onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE)'/> + <JRadioButton id='autoGenModeButton' + onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.AUTO_GEN)'/> + <JRadioButton id='rafaleModeButton' + onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.RAFALE)'/> + </VBox> + + <JPanel id='modeConfigurationPanel' constraints='BorderLayout.CENTER'> + <JPanel id='simpleModePanel' constraints='"simpleMode"' + layout='{new BorderLayout()}'> + <JLabel id='simpleModeLabel' constraints='BorderLayout.CENTER'/> + </JPanel> + <JPanel id='autoGenModePanel' constraints='"autoGenMode"'> + <Table fill='both' constraints='BorderLayout.SOUTH'> + <!-- Min step--> + <row> + <cell anchor='west'> + <JLabel id='minStepLabel'/> + </cell> + <cell weightx='1.0'> + <NumberEditor id='minStepField' constructorParams='this'/> + </cell> + </row> + <!-- Max step--> + <row> + <cell anchor='west'> + <JLabel id='maxStepLabel'/> + </cell> + <cell weightx='1.0'> + <NumberEditor id='maxStepField' constructorParams='this'/> + </cell> + </row> + <!-- Actions --> + <row> + <cell columns='2'> + <JPanel layout='{new GridLayout(1, 0)}'> + <JButton id='generateButton' + onActionPerformed='handler.generateLengthSteps()'/> + </JPanel> + </cell> + </row> + </Table> + </JPanel> + <JPanel id='rafaleModePanel' constraints='"rafaleMode"'> + <Table fill='both' constraints='BorderLayout.SOUTH'> + <!-- Rafale step--> + <row> + <cell weightx='1.0'> + <JLabel id='rafaleStepLabel'/> + </cell> + </row> + <row> + <cell weightx='1.0'> + <NumberEditor id='rafaleStepField' constructorParams='this'/> + </cell> + </row> + </Table> + </JPanel> + </JPanel> + </JPanel> + <Table fill='both' constraints='BorderLayout.SOUTH'> + <row> + <cell columns='2'> + <JSeparator/> + </cell> + </row> + <!-- length step caracteristic --> + <row> + <cell anchor='west'> + <JLabel id='lenghtStepCaracteristicLabel'/> + </cell> + <cell weightx='1.0'> + <BeanComboBox id='lenghtStepCaracteristicComboBox' + constructorParams='this' + genericType='Caracteristic'/> + </cell> + </row> + <!-- Step --> + <row> + <cell anchor='west'> + <JLabel id='stepLabel'/> + </cell> + <cell weightx='1.0'> + <NumberEditor id='stepField' constructorParams='this'/> + </cell> + </row> + </Table> + </JPanel> + + <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> + <JXTable id='table'/> + </JScrollPane> + + <!-- actions --> + <JPanel id='actionPanel' layout='{new GridLayout(1, 0)}' + constraints='BorderLayout.SOUTH'> + <JButton id='closeButton' onActionPerformed='handler.close()'/> + </JPanel> + +</JPanel> \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.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/catches/species/frequency/SpeciesFrequencyUIHandler.java (from rev 109, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2012-12-28 08:34:01 UTC (rev 114) @@ -0,0 +1,417 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency; + +/* + * #%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.ezware.oxbow.swingbits.util.Preconditions; +import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; +import fr.ifremer.tutti.ui.swing.TuttiUI; +import fr.ifremer.tutti.ui.swing.TuttiUIContext; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler; +import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; +import jaxx.runtime.SwingUtil; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.HighlightPredicate; +import org.jdesktop.swingx.table.DefaultTableColumnModelExt; + +import javax.swing.JDialog; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumnModel; +import java.awt.Color; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<SpeciesFrequencyRowModel, SpeciesFrequencyUIModel> { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(SpeciesFrequencyUIHandler.class); + + private final SpeciesFrequencyUI ui; + + public SpeciesFrequencyUIHandler(TuttiUIContext context, + SpeciesFrequencyUI ui) { + super(context, + SpeciesFrequencyRowModel.PROPERTY_LENGTH_STEP, + SpeciesFrequencyRowModel.PROPERTY_NUMBER, + SpeciesFrequencyRowModel.PROPERTY_WEIGHT, + SpeciesFrequencyRowModel.PROPERTY_COMPUTED_WEIGHT); + this.ui = ui; + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiTableUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + protected SpeciesFrequencyUIModel getModel() { + return ui.getModel(); + } + + @Override + protected SpeciesFrequencyTableModel getTableModel() { + return (SpeciesFrequencyTableModel) getTable().getModel(); + } + + @Override + protected JXTable getTable() { + return ui.getTable(); + } + + @Override + protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) { + + DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt(); + + { // LengthStep + + addFloatColumnToModel(columnModel, + SpeciesFrequencyTableModel.LENGTH_STEP, + TuttiUI.DECIMAL1_PATTERN); + } + + { // Number + + addIntegerColumnToModel(columnModel, + SpeciesFrequencyTableModel.NUMBER, + TuttiUI.INT_6_DIGITS_PATTERN); + } + + { // Weight + + addFloatColumnToModel(columnModel, + SpeciesFrequencyTableModel.WEIGHT, + TuttiUI.DECIMAL3_PATTERN); + } + + { // ComputedWeight + + addFloatColumnToModel(columnModel, + SpeciesFrequencyTableModel.COMPUTED_WEIGHT, + TuttiUI.DECIMAL3_PATTERN); + } + return columnModel; + } + + @Override + protected void onRowModified(SpeciesFrequencyRowModel row, + String propertyName, + Object oldValue, + Object newValue) { + if (SpeciesFrequencyRowModel.PROPERTY_NUMBER.equals(propertyName)) { + + // Need to recompute the computedWeight + computeComputedWeight(row); + } + } + + @Override + protected void onRowValidStateChanged(SpeciesFrequencyRowModel row, + Boolean oldValue, + Boolean newValue) { + } + + @Override + protected void onRowModifyStateChanged(SpeciesFrequencyRowModel row, + Boolean oldValue, + Boolean newValue) { + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public void beforeInitUI() { + + SpeciesFrequencyUIModel model = new SpeciesFrequencyUIModel(); + + ui.setContextValue(model); + } + + @Override + public void afterInitUI() { + + initUI(ui); + + List<Caracteristic> lengthStepCaracterics = + ui.getContextValue( + List.class, + SpeciesBatchUIHandler.SPECIES_FREQUENCY_LENGHTS); + Preconditions.checkNotNull(lengthStepCaracterics); + + SpeciesFrequencyUIModel model = getModel(); + + //TODO Use protocol to have lengthStepCaracteristic to use (if any protocol) + initBeanComboBox(ui.getLenghtStepCaracteristicComboBox(), + lengthStepCaracterics, + model.getLengthStepCaracteristic()); + + JXTable table = getTable(); + + // create table column model + TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class)); + + // create table model + SpeciesFrequencyTableModel tableModel = + new SpeciesFrequencyTableModel(columnModel, model); + + table.setModel(tableModel); + table.setColumnModel(columnModel); + + installTableKeyListener(columnModel, table); + + table.getTableHeader().setReorderingAllowed(false); + + table.addHighlighter(TuttiUIUtil.newBackgroundColorHighlighter( + HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY)); + + // when model datas change let's propagate it table model + listenRowsFromModel(); + + //TODO Should it come from PROTOCOL or config ? + model.setStep(.5f); + + model.setMinStep(10f); + model.setMaxStep(20f); + + //TODO Configure this ? + model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE); + + // always scroll to selected row + SwingUtil.scrollToTableSelection(getTable()); + + ui.getRafaleStepField().getTextField().addKeyListener(new KeyAdapter() { + + @Override + public void keyReleased(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + e.consume(); + Float step = (Float) ui.getRafaleStepField().getModel(); + + applyRafaleStep(step); + } + } + }); + + // when lengthStepCaracteristic changed, let's updates all row with the new value + model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_LENGHT_STEP_CARACTERISTIC, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Caracteristic newValue = (Caracteristic) evt.getNewValue(); + for (SpeciesFrequencyRowModel rowModel : getModel().getRows()) { + rowModel.setLengthStepCaracteristic(newValue); + } + } + }); + } + + @Override + public void onCloseUI() { + } + + //------------------------------------------------------------------------// + //-- Public methods --// + //------------------------------------------------------------------------// + + public void generateLengthSteps() { + + SpeciesFrequencyUIModel model = getModel(); + + Map<Float, SpeciesFrequencyRowModel> rowsByStep = + getTableModel().getRowCache(); + + Float minStep = model.getLengthStep(model.getMinStep()); + Float maxStep = model.getLengthStep(model.getMaxStep()); + + for (float i = minStep, step = model.getStep(); i <= maxStep; i += step) { + if (!rowsByStep.containsKey(i)) { + + // add it + SpeciesFrequencyRowModel newRow = new SpeciesFrequencyRowModel(); + newRow.setLengthStep(i); + rowsByStep.put(i, newRow); + } + } + + List<SpeciesFrequencyRowModel> rows = + Lists.newArrayList(rowsByStep.values()); + + model.setRows(rows); + } + + public void applyRafaleStep(Float step) { + + if (log.isInfoEnabled()) { + log.info("Will apply rafale step: " + step); + } + SpeciesFrequencyUIModel model = getModel(); + SpeciesFrequencyTableModel tableModel = getTableModel(); + + Map<Float, SpeciesFrequencyRowModel> rowsByStep = tableModel.getRowCache(); + + float aroundLengthStep = model.getLengthStep(step); + + SpeciesFrequencyRowModel row = rowsByStep.get(aroundLengthStep); + + int rowIndex; + + if (row != null) { + + // increments current row + Integer number = row.getNumber(); + row.setNumber((number == null ? 0 : number) + 1); + rowIndex = tableModel.updateRow(row); + + } else { + + // create a new row + row = new SpeciesFrequencyRowModel(); + row.setLengthStep(aroundLengthStep); + row.setNumber(1); + + // get new index + List<Float> steps = Lists.newArrayList(rowsByStep.keySet()); + steps.add(aroundLengthStep); + + Collections.sort(steps); + + rowIndex = steps.indexOf(aroundLengthStep); + + tableModel.addNewRow(rowIndex, row); + } + + getTable().scrollRowToVisible(rowIndex); + } + + public void editBatch(SpeciesBatchRowModel row) { + + List<SpeciesFrequencyRowModel> frequency = null; + + Caracteristic lengthStepCaracteristic = null; + if (row != null) { + frequency = row.getFrequency(); + } + + + List<SpeciesFrequencyRowModel> editFrequency; + if (CollectionUtils.isEmpty(frequency)) { + + // new list + editFrequency = Lists.newArrayList(); + } else { + + editFrequency = Lists.newArrayList(frequency); + lengthStepCaracteristic = frequency.get(0).getLengthStepCaracteristic(); + } + + if (log.isInfoEnabled()) { + log.info("Will edit batch row: " + row + " with " + + editFrequency.size() + " frequency"); + } + + SpeciesFrequencyUIModel model = getModel(); + + model.setRows(editFrequency); + + if (lengthStepCaracteristic == null) { + + // no lengthStep caracteristic to apply make sure it is not setted. + if (log.isInfoEnabled()) { + log.info("No lengthStepCaracteristic to set."); + } + model.setLengthStepCaracteristic(null); + } else { + + // apply existing lengthStepCaracteristic + + if (log.isInfoEnabled()) { + log.info("Use lengthStepCaracteristic: " + + lengthStepCaracteristic.getName()); + } + model.setLengthStepCaracteristic(lengthStepCaracteristic); + } + + // keep batch (will be used to push back editing entry) + model.setBatch(row); + } + + public void close() { + + if (log.isInfoEnabled()) { + log.info("Will close UI " + ui); + } + + SpeciesFrequencyUIModel model = getModel(); + + // transfer rows to editor + List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList(); + for (SpeciesFrequencyRowModel row : model.getRows()) { + if (row.isValid()) { + + // can keep this row + frequency.add(row); + } + } + + if (log.isInfoEnabled()) { + log.info("Push back " + frequency.size() + + " frequency to batch " + model.getBatch()); + } + + // push back to batch + model.getBatch().setFrequency(frequency); + + ui.editBatch(null); + + SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false); + } + + //------------------------------------------------------------------------// + //-- Internal methods --// + //------------------------------------------------------------------------// + + protected void computeComputedWeight(SpeciesFrequencyRowModel row) { + + if (log.isInfoEnabled()) { + log.info("Will recompute computed weight for frequency: " + row); + } + } + +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.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/catches/species/frequency/SpeciesFrequencyUIModel.java (from rev 109, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java 2012-12-28 08:34:01 UTC (rev 114) @@ -0,0 +1,195 @@ +package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency; + +/* + * #%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.referential.Caracteristic; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBatchRowModel, SpeciesFrequencyRowModel, SpeciesFrequencyUIModel> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_CONFIGURATION_MODE = "configurationMode"; + + public static final String PROPERTY_STEP = "step"; + + private static final String PROPERTY_MIN_STEP = "minStep"; + + private static final String PROPERTY_MAX_STEP = "maxStep"; + + public static final String PROPERTY_CAN_GENERATE = "canGenerate"; + + public static final String PROPERTY_SIMPLE_MODE = "simpleMode"; + + public static final String PROPERTY_AUTO_GEN_MODE = "autoGenMode"; + + public static final String PROPERTY_RAFALE_MODE = "rafaleMode"; + + public static final String PROPERTY_LENGHT_STEP_CARACTERISTIC = "lengthStepCaracteristic"; + + public static enum ConfigurationMode { + SIMPLE, + AUTO_GEN, + RAFALE + } + + /** + * Fill mode. + * + * @since 0.2 + */ + protected ConfigurationMode configurationMode; + + /** + * Batch that contains frequencies. + * + * @since 0.2 + */ + protected SpeciesBatchRowModel batch; + + /** + * Default step to increment length step. + * + * @since 0.2 + */ + protected float step; + + /** + * Min step to auto generate length steps. + * + * @since 0.2 + */ + protected Float minStep; + + /** + * Max step to auto generate length steps. + * + * @since 0.2 + */ + protected Float maxStep; + + /** + * Length step caracteristic. + * + * @since 0.3 + */ + protected Caracteristic lengthStepCaracteristic; + + public SpeciesFrequencyUIModel() { + super(SpeciesBatchRowModel.class, null, null); + } + + public ConfigurationMode getConfigurationMode() { + return configurationMode; + } + + public void setConfigurationMode(ConfigurationMode configurationMode) { + Object oldValue = getConfigurationMode(); + this.configurationMode = configurationMode; + firePropertyChange(PROPERTY_CONFIGURATION_MODE, oldValue, configurationMode); + firePropertyChange(PROPERTY_SIMPLE_MODE, null, isSimpleMode()); + firePropertyChange(PROPERTY_AUTO_GEN_MODE, null, isAutoGenMode()); + firePropertyChange(PROPERTY_RAFALE_MODE, null, isRafaleMode()); + } + + public float getStep() { + return step; + } + + public void setStep(float step) { + Object oldValue = getStep(); + this.step = step; + firePropertyChange(PROPERTY_STEP, oldValue, step); + } + + public Caracteristic getLengthStepCaracteristic() { + return lengthStepCaracteristic; + } + + public void setLengthStepCaracteristic(Caracteristic lengthStepCaracteristic) { + Object oldValue = getLengthStepCaracteristic(); + this.lengthStepCaracteristic = lengthStepCaracteristic; + firePropertyChange(PROPERTY_LENGHT_STEP_CARACTERISTIC, oldValue, lengthStepCaracteristic); + } + + public Float getMinStep() { + return minStep; + } + + public void setMinStep(Float minStep) { + Object oldValue = getMinStep(); + this.minStep = minStep; + firePropertyChange(PROPERTY_MIN_STEP, oldValue, minStep); + firePropertyChange(PROPERTY_CAN_GENERATE, null, isCanGenerate()); + } + + public Float getMaxStep() { + return maxStep; + } + + public void setMaxStep(Float maxStep) { + Object oldValue = getMaxStep(); + this.maxStep = maxStep; + firePropertyChange(PROPERTY_MAX_STEP, oldValue, maxStep); + firePropertyChange(PROPERTY_CAN_GENERATE, null, isCanGenerate()); + } + + public boolean isSimpleMode() { + return ConfigurationMode.SIMPLE == configurationMode; + } + + public boolean isAutoGenMode() { + return ConfigurationMode.AUTO_GEN == configurationMode; + } + + public boolean isRafaleMode() { + return ConfigurationMode.RAFALE == configurationMode; + } + + public boolean isCanGenerate() { + return minStep != null && maxStep != null && maxStep > minStep; + } + + public SpeciesBatchRowModel getBatch() { + return batch; + } + + public void setBatch(SpeciesBatchRowModel batch) { + this.batch = batch; + } + + public float getLengthStep(float lengthStep) { + int intValue = (int) (lengthStep * 10); + int intStep = (int) (step * 10); + int correctIntStep = intValue - (intValue % intStep); + float result = correctIntStep / 10f; + 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/catches/species/frequency/SpeciesFrequencyUIModel.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/fishing/environment/EnvironmentTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2012-12-28 08:34:01 UTC (rev 114) @@ -40,6 +40,7 @@ import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -73,7 +74,7 @@ } @Override - protected TableColumnModel createTableColumnModel() { + protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) { DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt(); @@ -116,7 +117,7 @@ JXTable table = getTable(); // create table column model - TableColumnModel columnModel = createTableColumnModel(); + TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class)); // create table model EnvironmentTableModel tableModel = Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2012-12-28 08:34:01 UTC (rev 114) @@ -40,6 +40,7 @@ import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -73,7 +74,7 @@ } @Override - protected TableColumnModel createTableColumnModel() { + protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) { DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt(); @@ -116,7 +117,7 @@ JXTable table = getTable(); // create table column model - TableColumnModel columnModel = createTableColumnModel(); + TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class)); // create table model GearShootingTableModel tableModel = Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2012-12-28 08:34:01 UTC (rev 114) @@ -40,6 +40,7 @@ import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -77,7 +78,7 @@ } @Override - protected TableColumnModel createTableColumnModel() { + protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) { DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt(); @@ -130,7 +131,7 @@ JXTable table = getTable(); // create table column model - TableColumnModel columnModel = createTableColumnModel(); + TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class)); // create table model HydrologyTableModel tableModel = Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-28 08:34:01 UTC (rev 114) @@ -86,7 +86,7 @@ protected abstract AbstractTuttiTableModel<R> getTableModel(); - protected abstract TableColumnModel createTableColumnModel(); + protected abstract TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer); protected abstract void onRowModified(R row, String propertyName, 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-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-28 08:34:01 UTC (rev 114) @@ -45,7 +45,6 @@ tutti.label.attachmentEditor.file=Fichier tutti.label.attachmentEditor.fileComment=Commentaire tutti.label.attachmentEditor.fileName=Nom -tutti.label.catches.accidentalObserved=Captures accidentelles observées ? tutti.label.catches.benthosTotalSampleSortedWeight=Poids total vrac échantillonné tutti.label.catches.benthosTotalSortedWeight=Poids total vrac tutti.label.catches.benthosTotalUnsortedWeight=Poids total hors vrac @@ -56,7 +55,6 @@ tutti.label.catches.catchTotalUnsortedWeight=Poids total hors vrac tutti.label.catches.catchTotalWeight=Poids total tutti.label.catches.macroWasteTotalWeight=Poids total -tutti.label.catches.planktonObserved=Plancton observé ? tutti.label.catches.planktonTotalSampleWeight=Poids total échantillonné tutti.label.catches.planktonTotalWeight=Poids total tutti.label.catches.speciesTotalSampleSortedWeight=Poids total vrac échantillonné @@ -73,9 +71,6 @@ tutti.label.cruise.program=Série tutti.label.cruise.surveyPart=Série partielle tutti.label.cruise.year=Année -tutti.label.fishingOperation.averageBottomSalinity=Salinité de fond moyenne -tutti.label.fishingOperation.averageBottomTemperature=Température de fond moyenne -tutti.label.fishingOperation.beaufortScale=Force du vent tutti.label.fishingOperation.date=Date tutti.label.fishingOperation.distanceChalutee=Distance chalutée tutti.label.fishingOperation.duree=Durée @@ -87,30 +82,12 @@ tutti.label.fishingOperation.gearLatitude=Latitude tutti.label.fishingOperation.gearLongitude=Longitude 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.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.gearShootingStartSurfaceSalinity=Salinité de surface début de traine -tutti.label.fishingOperation.gearShootingStartSurfaceTemperature=Temperature de surface début de traine tutti.label.fishingOperation.gearTime=Heure -tutti.label.fishingOperation.geometrieMesuree=Géométrie mesurée tutti.label.fishingOperation.location=Localité -tutti.label.fishingOperation.longueurBras=Longueur des funes -tutti.label.fishingOperation.longueurFunes=Longueur des bras -tutti.label.fishingOperation.ouvertureHorizontale=Ouverture horizontale -tutti.label.fishingOperation.ouvertureVerticale=Ouverture verticale -tutti.label.fishingOperation.seaState=Etat de la mer tutti.label.fishingOperation.stationNumber=Code Station tutti.label.fishingOperation.strata=Strate tutti.label.fishingOperation.subStrata=Sous strate -tutti.label.fishingOperation.systemeFermetureCul=Système de fermeture de cul -tutti.label.fishingOperation.windDirection=Direction du vent tutti.label.frequencyConfiguration.lengthStepCaracteristic=Type de mesure tutti.label.frequencyConfiguration.maxStep=Classe max tutti.label.frequencyConfiguration.minStep=Classe min @@ -133,7 +110,6 @@ tutti.label.program.name=Nom tutti.label.program.zone=Zone tutti.label.protocol=Protocol de saisie -tutti.label.species.speciesTotalUnsortedWeight= tutti.label.tab.accidentel=Captures accidentelles tutti.label.tab.benthos=Benthos tutti.label.tab.catches=Captures @@ -153,11 +129,9 @@ tutti.label.traitReminder=Trait \: %s tutti.legend.catch.benthos=Benthos tutti.legend.catch.macroWaste=Macro déchets -tutti.legend.catch.other=Autres tutti.legend.catch.species=Espèces tutti.legend.catch.total=Capture tutti.legend.frequencyConfiguration=Configuration -tutti.legend.macroWasteCatches=Macro déchets tutti.menu.actions=Actions tutti.menu.actions.tip=Actions tutti.menu.file=Fichier @@ -179,44 +153,20 @@ tutti.table.accidental.batch.header.weight=Poids observé tutti.table.benthos.batch.header.comment=Commentaire tutti.table.benthos.batch.header.file=Pièces jointes +tutti.table.benthos.batch.header.number=Nombre tutti.table.benthos.batch.header.sampleWeight=Poids échantillonné -tutti.table.benthos.batch.header.samplingRatio=Fraction d'élévation 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.fishing.environment.header.key=Clé tutti.table.fishing.environment.header.value=Valeur -tutti.table.fishing.environment.keys.beaufortScale=Force du vent -tutti.table.fishing.environment.keys.key3=Clé 3 -tutti.table.fishing.environment.keys.key4=Clé 4 -tutti.table.fishing.environment.keys.key5=Clé 5 -tutti.table.fishing.environment.keys.seaState=État de la mer -tutti.table.fishing.environment.keys.windDirection=Direction du vent tutti.table.fishing.gearShooting.header.key=Clé tutti.table.fishing.gearShooting.header.value=Valeur -tutti.table.fishing.gearShooting.keys.armLength=Longueur des bras -tutti.table.fishing.gearShooting.keys.endDepth=Profondeur fin de traine -tutti.table.fishing.gearShooting.keys.horizontalAperture=Ouverture horizontale -tutti.table.fishing.gearShooting.keys.key3=Clé 3 -tutti.table.fishing.gearShooting.keys.key4=Clé 4 -tutti.table.fishing.gearShooting.keys.key5=Clé 5 -tutti.table.fishing.gearShooting.keys.measuredGeometry=Géométrie mesurée -tutti.table.fishing.gearShooting.keys.startDepth=Profondeur début de traine -tutti.table.fishing.gearShooting.keys.systemeFermetureCul=Système de fermeture du cul -tutti.table.fishing.gearShooting.keys.verticalAperture=Ouverture verticale -tutti.table.fishing.gearShooting.keys.warpLength=Longueur des funes tutti.table.fishing.hydrology.header.averageValue=Moyenne tutti.table.fishing.hydrology.header.gearShootingEndValue=Fin de traîne tutti.table.fishing.hydrology.header.gearShootingStartValue=Début de traîne tutti.table.fishing.hydrology.header.key=Clé -tutti.table.fishing.hydrology.keys.key3=Clé 3 -tutti.table.fishing.hydrology.keys.key4=Clé 4 -tutti.table.fishing.hydrology.keys.key5=Clé 5 -tutti.table.fishing.hydrology.keys.salinity.bottom=Salinité au fond -tutti.table.fishing.hydrology.keys.salinity.surface=Salinité à la surface -tutti.table.fishing.hydrology.keys.temperature.bottom=Température au fond -tutti.table.fishing.hydrology.keys.temperature.surface=Température à la surface tutti.table.macrowaste.batch.header.comment=Commentaire tutti.table.macrowaste.batch.header.file=Pièces jointes tutti.table.macrowaste.batch.header.macroWasteCategory=Catégorie @@ -224,13 +174,13 @@ tutti.table.macrowaste.batch.header.number=Nombre 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.ageCategory=Age tutti.table.protocol.species.header.maturity=Maturité tutti.table.protocol.species.header.sex=Sexe tutti.table.protocol.species.header.sizeCategory=Catégorie Taille @@ -241,10 +191,9 @@ 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évation tutti.table.species.batch.header.file=Pièces jointes tutti.table.species.batch.header.maturityCategory=Maturité -tutti.table.species.batch.header.sampleWeight=Poids échantillonné +tutti.table.species.batch.header.number=Nombre tutti.table.species.batch.header.sexCategory=Sexe tutti.table.species.batch.header.sizeCategory=Catégorie Taille tutti.table.species.batch.header.sortedUnsortedCategory=Vrac / Hors Vrac Modified: trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyRowModelTest.java =================================================================== --- trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyRowModelTest.java 2012-12-27 17:52:49 UTC (rev 113) +++ trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyRowModelTest.java 2012-12-28 08:34:01 UTC (rev 114) @@ -24,7 +24,7 @@ * #L% */ -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesFrequencyRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel; import org.junit.Assert; import org.junit.Test;
participants (1)
-
tchemit@users.forge.codelutin.com