Author: tchemit Date: 2013-09-26 19:29:01 +0200 (Thu, 26 Sep 2013) New Revision: 1232 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1232 Log: fixes #3316: [ESPECES] Cat?\195?\169gorisation des lots : on ne peut plus ajouter une cat?\195?\169gorie une fois la cat?\195?\169gorisation effectu?\195?\169e Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.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.css 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/benthos/BenthosBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.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/SpeciesBatchUI.css 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/catches/species/create/CreateSpeciesBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties =================================================================== --- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-09-26 17:29:01 UTC (rev 1232) @@ -1,5 +1,5 @@ #Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo -#Tue Sep 24 18:46:35 CEST 2013 +#Thu Sep 26 18:46:04 CEST 2013 tutti.config.help=config.html tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions tutti.createAccidentalBatch.action.saveAndClose.help=editFishingOperation.html\#captureCapturesAccidentellesActions @@ -68,6 +68,7 @@ tutti.editAccidentalBatch.action.importMultiPost.help=editFishingOperation.html\#captureCapturesAccidentellesActions tutti.editAccidentalBatch.action.removeBatch.help=editFishingOperation.html\#captureCapturesAccidentellesActions tutti.editAccidentalBatch.help=editFishingOperation.html\#captureCapturesAccidentelles +tutti.editBenthosBatch.action.addSampleCategory.help= tutti.editBenthosBatch.action.changeSampleCategory.help=editFishingOperation.html\#captureBenthosActions tutti.editBenthosBatch.action.createBatch.help=editFishingOperation.html\#captureBenthosActions tutti.editBenthosBatch.action.createMelag.help=editFishingOperation.html\#captureBenthosActions @@ -232,6 +233,7 @@ tutti.editSampleCategoryModel.action.removeEntry.help=editSampleCategory.html\#actions tutti.editSampleCategoryModel.action.save.help=editSampleCategory.html\#actions tutti.editSampleCategoryModel.help=editSampleCategory.html +tutti.editSpeciesBatch.action.addSampleCategory.help= tutti.editSpeciesBatch.action.changeSampleCategory.help=editFishingOperation.html\#captureEspecesActions tutti.editSpeciesBatch.action.createBatch.help=editFishingOperation.html\#captureEspecesActions tutti.editSpeciesBatch.action.createMelag.help=editFishingOperation.html\#captureEspecesActions Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties =================================================================== --- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-09-26 17:29:01 UTC (rev 1232) @@ -1,5 +1,5 @@ #Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo -#Tue Sep 24 18:46:35 CEST 2013 +#Thu Sep 26 18:46:04 CEST 2013 tutti.config.help=config.html tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions tutti.createAccidentalBatch.action.saveAndClose.help=editFishingOperation.html\#captureCapturesAccidentellesActions @@ -67,6 +67,7 @@ tutti.editAccidentalBatch.action.importMultiPost.help=editFishingOperation.html\#captureCapturesAccidentellesActions tutti.editAccidentalBatch.action.removeBatch.help=editFishingOperation.html\#captureCapturesAccidentellesActions tutti.editAccidentalBatch.help=editFishingOperation.html\#captureCapturesAccidentelles +tutti.editBenthosBatch.action.addSampleCategory.help= tutti.editBenthosBatch.action.changeSampleCategory.help=editFishingOperation.html\#captureBenthosActions tutti.editBenthosBatch.action.createBatch.help=editFishingOperation.html\#captureBenthosActions tutti.editBenthosBatch.action.createMelag.help=editFishingOperation.html\#captureBenthosActions @@ -230,6 +231,7 @@ tutti.editSampleCategoryModel.action.removeEntry.help=editSampleCategory.html\#actions tutti.editSampleCategoryModel.action.save.help=editSampleCategory.html\#actions tutti.editSampleCategoryModel.help=editSampleCategory.html +tutti.editSpeciesBatch.action.addSampleCategory.help= tutti.editSpeciesBatch.action.changeSampleCategory.help=editFishingOperation.html\#captureEspecesActions tutti.editSpeciesBatch.action.createBatch.help=editFishingOperation.html\#captureEspecesActions tutti.editSpeciesBatch.action.createMelag.help=editFishingOperation.html\#captureEspecesActions Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-09-26 17:29:01 UTC (rev 1232) @@ -325,6 +325,11 @@ <SplitSpeciesBatchUI id='speciesTabSplitBatch' constructorParams='this'/> </JXTitledPanel> + <JXTitledPanel id='speciesTabAddSampleCategoryBatchReminderLabel' + constraints='EditCatchesUIHandler.ADD_SAMPLE_CATEGORY_BATCH_CARD'> + <SplitSpeciesBatchUI id='speciesTabAddSampleCategoryBatch' + constructorParams='this'/> + </JXTitledPanel> <JXTitledPanel id='speciesTabFrequencyEditorReminderLabel' constraints='EditCatchesUIHandler.EDIT_FREQUENCY_CARD'> <SpeciesFrequencyUI id='speciesTabFrequencyEditor' @@ -348,6 +353,11 @@ <SplitBenthosBatchUI id='benthosTabSplitBatch' constructorParams='this'/> </JXTitledPanel> + <JXTitledPanel id='benthosTabAddSampleCategoryBatchReminderLabel' + constraints='EditCatchesUIHandler.ADD_SAMPLE_CATEGORY_BATCH_CARD'> + <SplitBenthosBatchUI id='benthosTabAddSampleCategoryBatch' + constructorParams='this'/> + </JXTitledPanel> <JXTitledPanel id='benthosTabFrequencyEditorReminderLabel' constraints='EditCatchesUIHandler.EDIT_FREQUENCY_CARD'> <BenthosFrequencyUI id='benthosTabFrequencyEditor' Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -70,6 +70,8 @@ public static final String SPLIT_BATCH_CARD = "splitBatch"; + public static final String ADD_SAMPLE_CATEGORY_BATCH_CARD = "addSampleCategoryBatch"; + public static final String EDIT_FREQUENCY_CARD = "editFrequency"; public static final String EDIT_CARACTERISTICS_CARD = "caracteristicsCard"; @@ -121,6 +123,12 @@ @Override public void afterInitUI() { + ui.getBenthosTabSplitBatch().getModel().setSplitMode(true); + ui.getBenthosTabAddSampleCategoryBatch().getModel().setSplitMode(false); + + ui.getSpeciesTabSplitBatch().getModel().setSplitMode(true); + ui.getSpeciesTabAddSampleCategoryBatch().getModel().setSplitMode(false); + initUI(ui); EditCatchesUIModel model = getModel(); @@ -323,6 +331,23 @@ ui.getSpeciesTabSplitBatchReminderLabel().setTitle(title); } + public void addSampleCategorySpeciesBatch(SpeciesBatchRowModel editRow, + SplitSpeciesBatchUI splitBatchEditor, + int sampleCategoryId) { + + splitBatchEditor.getHandler().editBatch(editRow, sampleCategoryId); + + // open split editor + setSpeciesSelectedCard(EditCatchesUIHandler.ADD_SAMPLE_CATEGORY_BATCH_CARD); + + // update title + String title = buildReminderLabelTitle(editRow.getSpecies(), + editRow, + ui.getSpeciesTabFishingOperationReminderLabel().getTitle(), + _("tutti.addSampleCategorySpeciesBatch.title")); + ui.getSpeciesTabAddSampleCategoryBatchReminderLabel().setTitle(title); + } + public void setSpeciesSelectedCard(String card) { JPanel panel = ui.getSpeciesTabPanel(); CardLayout2Ext layout = (CardLayout2Ext) panel.getLayout(); @@ -348,6 +373,9 @@ } else if (SPLIT_BATCH_CARD.equals(card)) { tuttiUi = ui.getSpeciesTabSplitBatch(); + } else if (ADD_SAMPLE_CATEGORY_BATCH_CARD.equals(card)) { + tuttiUi = ui.getSpeciesTabAddSampleCategoryBatch(); + } else if (EDIT_FREQUENCY_CARD.equals(card)) { tuttiUi = ui.getSpeciesTabFrequencyEditor(); } @@ -397,6 +425,23 @@ ui.getBenthosTabSplitBatchReminderLabel().setTitle(title); } + public void addSampleCategoryBenthosBatch(BenthosBatchRowModel editRow, + SplitBenthosBatchUI splitBatchEditor, + int sampleCategoryId) { + + splitBatchEditor.getHandler().editBatch(editRow, sampleCategoryId); + + // open split editor + setBenthosSelectedCard(EditCatchesUIHandler.ADD_SAMPLE_CATEGORY_BATCH_CARD); + + // update title + String title = buildReminderLabelTitle(editRow.getSpecies(), + editRow, + ui.getBenthosTabFishingOperationReminderLabel().getTitle(), + _("tutti.addSampleCategoryBenthosBatch.title")); + ui.getBenthosTabAddSampleCategoryBatchReminderLabel().setTitle(title); + } + public void setBenthosSelectedCard(String card) { JPanel panel = ui.getBenthosTabPanel(); CardLayout2Ext layout = (CardLayout2Ext) panel.getLayout(); @@ -422,6 +467,9 @@ } else if (SPLIT_BATCH_CARD.equals(card)) { tuttiUi = ui.getBenthosTabSplitBatch(); + } else if (ADD_SAMPLE_CATEGORY_BATCH_CARD.equals(card)) { + tuttiUi = ui.getBenthosTabAddSampleCategoryBatch(); + } else if (EDIT_FREQUENCY_CARD.equals(card)) { tuttiUi = ui.getBenthosTabFrequencyEditor(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SampleCategoryAble.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -46,6 +46,8 @@ SampleCategory getSampleCategoryById(Integer sampleCategoryId); + SampleCategory<?> getSampleCategoryByIndex(int sampleCategoryIndex); + void setSampleCategoryValue(Integer sampleCategoryId, Serializable value); void setSampleCategoryWeight(Integer sampleCategoryId, Object value); 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 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -323,6 +323,11 @@ return result; } + public SampleCategory<?> getSampleCategoryByIndex(int sampleCategoryIndex) { + SampleCategory<?> result = categories[sampleCategoryIndex]; + return result; + } + @Override public void setSampleCategoryValue(Integer sampleCategoryId, Serializable value) { SampleCategory<?> sampleCategory = 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 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -307,12 +307,14 @@ return result; } - protected void updateShell(BenthosBatchRowModel entry, int columnIndex) { - - Set<BenthosBatchRowModel> shell = Sets.newHashSet(); - entry.collectShell(shell); - shell.add(entry); - + /** + * Update all the given cells for the given column. + * + * @param shell shell to update + * @param columnIndex the column index to update + * @since 2.6 + */ + public void updateShell(Set<BenthosBatchRowModel> shell, int columnIndex) { for (BenthosBatchRowModel batchRowModel : shell) { int currentRowIndex = getRowIndex(batchRowModel); if (log.isDebugEnabled()) { @@ -321,4 +323,19 @@ fireTableCellUpdated(currentRowIndex, columnIndex); } } + + /** + * Update all the cells of the given row shell for a given column. + * + * @param entry the first row to update + * @param columnIndex the column index to update + * @since 2.6 + */ + protected void updateShell(BenthosBatchRowModel entry, int columnIndex) { + + Set<BenthosBatchRowModel> shell = Sets.newHashSet(); + entry.collectShell(shell); + shell.add(entry); + updateShell(shell, columnIndex); + } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-09-26 17:29:01 UTC (rev 1232) @@ -28,7 +28,6 @@ bean: {model}; showReset: true; useFloat: true; - /*numberPattern: {DECIMAL3_PATTERN};*/ _selectOnFocus: {true}; } @@ -37,8 +36,6 @@ showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; showReset: true; useFloat: true; - /*numberPattern: {DECIMAL3_PATTERN}; - decimalNumber: 3;*/ computedDataColor: {handler.getConfig().getColorComputedWeights()}; } @@ -195,6 +192,15 @@ _help: {"tutti.editBenthosBatch.action.changeSampleCategory.help"}; } +#addSampleCategoryMenu { + actionIcon: batch-split; + text: "tutti.editBenthosBatch.action.addSampleCategory"; + toolTipText: "tutti.editBenthosBatch.action.addSampleCategory.tip"; + i18nMnemonic: "tutti.editBenthosBatch.action.addSampleCategory.mnemonic"; + enabled: {model.isTableViewModeAll() && model.isAddSampleCategoryEnabled()}; + _help: {"tutti.editBenthosBatch.action.addSampleCategory.help"}; +} + #removeBenthosBatchMenu { actionIcon: batch-delete; text: "tutti.editBenthosBatch.action.removeBatch"; 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 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2013-09-26 17:29:01 UTC (rev 1232) @@ -79,6 +79,8 @@ onActionPerformed='handler.splitBatch()'/> <JMenuItem id='changeSampleCategoryMenu' onActionPerformed='handler.changeBatchCategory()'/> + <JMenuItem id='addSampleCategoryMenu' + onActionPerformed='handler.addBatchCategory()'/> <JMenuItem id='removeBenthosBatchMenu'/> <JMenuItem id='removeBenthosSubBatchMenu'/> <JMenuItem id='renameBenthosBatchMenu'/> 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 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -136,6 +136,13 @@ */ protected final WeightUnit weightUnit; + /** + * id of the unsorted qualitative value to remove of V/HV universe. + * + * @since 2.6 + */ + protected final Integer qualitative_unsorted_id; + public BenthosBatchUIHandler(TuttiUI<?, ?> parentUi, BenthosBatchUI ui) { super(parentUi, ui, @@ -148,6 +155,9 @@ SpeciesBatchRowModel.PROPERTY_FREQUENCY, SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM); + qualitative_unsorted_id = + context.getPersistenceService().getEnumerationFile().QUALITATIVE_UNSORTED_ID; + weightUnit = getConfig().getBenthosWeightUnit(); sampleCategoryModel = getDataContext().getSampleCategoryModel(); @@ -456,6 +466,7 @@ boolean enableRename = false; boolean enableSplit = false; boolean enableChangeSampleCategory = false; + boolean enableAddSampleCategory = false; boolean enableRemove = false; boolean enableRemoveSub = false; boolean enableCreateMelag = false; @@ -485,6 +496,7 @@ enableCreateMelag = selectedRowCount > 1; enableEditFrequencies = selectedRowCount == 1; enableChangeSampleCategory = selectedRowCount == 1 && tableModel.isCellEditable(rowIndex, columnIndex); + enableAddSampleCategory = selectedRowCount == 1 && tableModel.isCellEditable(rowIndex, columnIndex); if (enableSplit) { @@ -500,11 +512,43 @@ || row.getComputedNumber() == 0); } + Integer sampleCategoryId = + tableModel.getSampleCategoryId(columnIndex); + boolean firstCategory = false; + SampleCategoryModelEntry category = null; + + List<CaracteristicQualitativeValue> available = null; + + if (sampleCategoryId != null) { + + // get category + category = sampleCategoryModel.getCategoryById(sampleCategoryId); + + // is first category ? + firstCategory = sampleCategoryModel.getFirstCategoryId().equals(sampleCategoryId); + + // get the first ancestor row using this category + BenthosBatchRowModel firstAncestorRow = row.getFirstAncestor(sampleCategoryId); + + // get all used values for this category + Set<Serializable> used = getSampleUsedValues( + firstAncestorRow, sampleCategoryId); + + // get all possible values + available = Lists.newArrayList(category.getCaracteristic().getQualitativeValue()); + available.removeAll(used); + + if (firstCategory) { + + // remove the unsorted qualitative value + TuttiEntities.removeQualitativeValue(available, qualitative_unsorted_id); + } + } + if (enableChangeSampleCategory) { - // can change category if there is still a brother category free - Integer sampleCategoryId = - tableModel.getSampleCategoryId(columnIndex); + // can change category if on a sample column and + // there is still a brother category free if (sampleCategoryId == null) { @@ -512,35 +556,41 @@ enableChangeSampleCategory = false; } else { - // get category - SampleCategoryModelEntry category = - sampleCategoryModel.getCategoryById(sampleCategoryId); + if (category.getCaracteristic().isNumericType()) { - // get the first ancestor row using this category - BenthosBatchRowModel firstAncestorRow = - row.getFirstAncestor(sampleCategoryId); + // if number then can always change it - // get all used values for this category - Set<Serializable> used = getSampleUsedValues( - firstAncestorRow, sampleCategoryId); + } else { + // action possible only if there is still some available values + enableChangeSampleCategory = CollectionUtils.isNotEmpty(available); + } + } + } + + if (enableAddSampleCategory) { + + // can change category if on a sample column and + // there is still a brother category free + // and sample category is not the first + + if (sampleCategoryId == null || firstCategory) { + + // not on a sample category column + // or using the first sample category (V/HV) + enableAddSampleCategory = false; + } else { + if (category.getCaracteristic().isNumericType()) { // if number then can always change it } else { - // get all possible values - - List<CaracteristicQualitativeValue> available = - Lists.newArrayList(category.getCaracteristic().getQualitativeValue()); - available.removeAll(used); - // action possible only if there is still some available values - enableChangeSampleCategory = !available.isEmpty(); + enableAddSampleCategory = CollectionUtils.isNotEmpty(available); } } - } if (enableEditFrequencies) { @@ -587,6 +637,7 @@ BenthosBatchUIModel model = getModel(); model.setSplitBatchEnabled(enableSplit); model.setChangeSampleCategoryEnabled(enableChangeSampleCategory); + model.setAddSampleCategoryEnabled(enableAddSampleCategory); model.setRemoveBatchEnabled(enableRemove); model.setRemoveSubBatchEnabled(enableRemoveSub); model.setRenameBatchEnabled(enableRename); @@ -597,6 +648,7 @@ StringBuilder builder = new StringBuilder("actions for (" + rowIndex + "," + columnIndex + "):"); builder.append("\nenableSplit: ").append(enableSplit); builder.append("\nenableChangeSampleCategory: ").append(enableChangeSampleCategory); + builder.append("\nenableAddSampleCategory: ").append(enableAddSampleCategory); builder.append("\nenableRemove: ").append(enableRemove); builder.append("\nenableRemoveSub: ").append(enableRemoveSub); builder.append("\nenableRename: ").append(enableRename); @@ -885,6 +937,49 @@ } } + public void addBatchCategory() { + + // get table model + BenthosBatchTableModel tableModel = getTableModel(); + + // get selected row + int rowIndex = getTable().getSelectedRow(); + Preconditions.checkState(rowIndex != -1, + "Cant split batch if no batch selected"); + + // get selected column + int columnIndex = getTable().getSelectedColumn(); + Preconditions.checkState(columnIndex != -1, + "Cant split batch if no batch selected"); + + // get selected row + BenthosBatchRowModel selectedRow = tableModel.getEntry(rowIndex); + + // get his sample category + Integer sampleCategoryId = tableModel.getSampleCategoryId(columnIndex); + + // get the first ancestor row using this category + BenthosBatchRowModel firstAncestorRow = + selectedRow.getFirstAncestor(sampleCategoryId); + + // get his parent (the one we will edit) + BenthosBatchRowModel parentBatch = firstAncestorRow.getParentBatch(); + + if (log.isDebugEnabled()) { + log.debug("Open addChangeCategory batch ui for row [" + rowIndex + "] and category " + sampleCategoryId); + } + + EditCatchesUI parent = + SwingUtil.getParentContainer(ui, EditCatchesUI.class); + SplitBenthosBatchUI splitBatchEditor = + parent.getBenthosTabAddSampleCategoryBatch(); + + parent.getHandler().addSampleCategoryBenthosBatch( + parentBatch, + splitBatchEditor, + sampleCategoryId); + } + public void changeBatchCategory() { // get table model @@ -956,6 +1051,16 @@ List<CaracteristicQualitativeValue> availableValues = Lists.newArrayList(caracteristic.getQualitativeValue()); + + boolean firstCategory = + sampleCategoryModel.getFirstCategoryId().equals(sampleCategoryId); + + if (firstCategory) { + + // remove the unsorted qualitative value + TuttiEntities.removeQualitativeValue(availableValues, qualitative_unsorted_id); + } + availableValues.removeAll(usedValues); JComboBox editor = new JComboBox(); @@ -1045,6 +1150,69 @@ model.setLeafNumber(model.getLeafNumber() + newBatches.size() - 1); } + public void addSampleCategoryBatch(BenthosBatchRowModel parentBatch, + SampleCategoryModelEntry sampleCategoryDef, + List<SplitBenthosBatchRowModel> rows, + Float totalRowWeight) { + + // get table model + BenthosBatchTableModel tableModel = getTableModel(); + + // get insert row index + int insertRow = tableModel.getRowIndex(parentBatch) + parentBatch.getChildBatch().size(); + + // Create rows in batch table model + List<BenthosBatchRowModel> newBatches = Lists.newArrayList(); + for (SplitBenthosBatchRowModel row : rows) { + if (row.isEditable() && row.isValid()) { + + // can keep this row + BenthosBatchRowModel newBatch = tableModel.createNewRow(); + + loadBatchRow(parentBatch, + newBatch, + sampleCategoryDef.getCategoryId(), + row.getCategoryValue(), + row.getWeight(), + null); + + recomputeRowValidState(newBatch); + newBatches.add(newBatch); + + tableModel.addNewRow(++insertRow, newBatch); + } + } + + // add new batches to his parent + List<BenthosBatchRowModel> childBatch = parentBatch.getChildBatch(); + childBatch.addAll(newBatches); + parentBatch.setChildBatch(childBatch); + + // re compute the sub sample property for all childs + int categoryIndex = sampleCategoryModel.indexOf(sampleCategoryDef); + + Float parentWeight = parentBatch.getSampleCategoryByIndex(categoryIndex - 1).getNotNullWeight(); + boolean subSample = parentWeight != null && totalRowWeight != null + && parentWeight > totalRowWeight; + + Set<BenthosBatchRowModel> shell = Sets.newHashSet(); + parentBatch.collectShell(shell); + + for (BenthosBatchRowModel rowModel : shell) { + rowModel.getSampleCategoryByIndex(categoryIndex).setSubSample(subSample); + } + + // save new batches + saveRows(newBatches); + + // update model number of leaf + BenthosBatchUIModel model = getModel(); + model.setLeafNumber(model.getLeafNumber() + newBatches.size() - 1); + + // update columns for the parent shell + tableModel.updateShell(shell, getTable().getSelectedColumn()); + } + public void updateTotalFromFrequencies(BenthosBatchRowModel row) { List<BenthosFrequencyRowModel> frequency = row.getFrequency(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -51,6 +51,8 @@ public static final String PROPERTY_CHANGE_SAMPLE_CATEGORY_ENABLED = "changeSampleCategoryEnabled"; + public static final String PROPERTY_ADD_SAMPLE_CATEGORY_ENABLED = "addSampleCategoryEnabled"; + public static final String PROPERTY_REMOVE_SUB_BATCH_ENABLED = "removeSubBatchEnabled"; public static final String PROPERTY_RENAME_BATCH_ENABLED = "renameBatchEnabled"; @@ -86,6 +88,13 @@ protected boolean changeSampleCategoryEnabled; /** + * Can user add a/some missing sample category of the selected species batch ? + * + * @since 2.6 + */ + protected boolean addSampleCategoryEnabled; + + /** * Can user remove a selected species batch? * * @since 0.3 @@ -313,6 +322,15 @@ firePropertyChange(PROPERTY_CHANGE_SAMPLE_CATEGORY_ENABLED, null, changeSampleCategoryEnabled); } + public boolean isAddSampleCategoryEnabled() { + return addSampleCategoryEnabled; + } + + public void setAddSampleCategoryEnabled(boolean addSampleCategoryEnabled) { + this.addSampleCategoryEnabled = addSampleCategoryEnabled; + firePropertyChange(PROPERTY_ADD_SAMPLE_CATEGORY_ENABLED, null, addSampleCategoryEnabled); + } + public boolean isRemoveBatchEnabled() { return removeBatchEnabled; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -97,6 +97,11 @@ if (selectedBatch.isBatchRoot()) { // update speciesUsed handler.removeFromSpeciesUsed(selectedBatch); + } else { + + // remove from his parent + BenthosBatchRowModel parentBatch = selectedBatch.getParentBatch(); + parentBatch.getChildBatch().remove(selectedBatch); } // collect of rows to remove from model Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -541,7 +541,8 @@ SplitBenthosBatchTableModel tableModel = new SplitBenthosBatchTableModel(columnModel, getModel(), - editableCategoryValue); + editableCategoryValue, + false); JXTable table = getTable(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchRowModel.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchRowModel.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -51,6 +51,8 @@ public static final String PROPERTY_SELECTED = "selected"; + public static final String PROPERTY_EDITABLE = "editable"; + /** * Delegate sample category which contains category value + weight. * @@ -58,8 +60,20 @@ */ protected final SampleCategory<Serializable> category = SampleCategory.newSample(null); + /** + * Is row selected? + * + * @since 2.5 + */ protected boolean selected; + /** + * Is row editable ? (in add mode incoming rows are all selected and not editable). + * + * @since 2.6 + */ + protected boolean editable; + protected static final Binder<SplitBenthosBatchRowModel, SplitBenthosBatchRowModel> fromBeanBinder = BinderFactory.newBinder(SplitBenthosBatchRowModel.class, SplitBenthosBatchRowModel.class); @@ -122,6 +136,16 @@ firePropertyChange(PROPERTY_SELECTED, oldValue, selected); } + public boolean isEditable() { + return editable; + } + + public void setEditable(boolean editable) { + Object oldValue = isEditable(); + this.editable = editable; + firePropertyChange(PROPERTY_EDITABLE, oldValue, editable); + } + @Override protected SplitBenthosBatchRowModel newEntity() { return new SplitBenthosBatchRowModel(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchTableModel.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchTableModel.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -64,11 +64,20 @@ private final SelectedCategoryAble uiModel; + /** + * Is the table is in split mode? + * + * @since 2.6 + */ + private final boolean splitMode; + public SplitBenthosBatchTableModel(TableColumnModelExt columnModel, SelectedCategoryAble uiModel, - boolean createEmptyRowIsEmpty) { + boolean createEmptyRowIsEmpty, + boolean splitMode) { super(columnModel, createEmptyRowIsEmpty, createEmptyRowIsEmpty); this.uiModel = uiModel; + this.splitMode = splitMode; setNoneEditableCols(READ_ONLY_CATEGORY_VALUE); } @@ -77,7 +86,23 @@ SplitBenthosBatchRowModel result = new SplitBenthosBatchRowModel(); result.setCategoryType(uiModel.getSelectedCategory()); result.setValid(false); + result.setEditable(true); return result; } + @Override + protected boolean isCellEditable(int rowIndex, + int columnIndex, + ColumnIdentifier<SplitBenthosBatchRowModel> propertyName) { + + boolean result = super.isCellEditable(rowIndex, + columnIndex, + propertyName); + if (result && !splitMode) { + // if editable and on edit mode, use editable property on row + SplitBenthosBatchRowModel entry = getEntry(rowIndex); + result = entry.isEditable(); + } + 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/split/SplitBenthosBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -24,8 +24,10 @@ * #L% */ +import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import fr.ifremer.tutti.persistence.entities.data.SampleCategory; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry; @@ -53,7 +55,9 @@ import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.io.Serializable; import java.util.List; +import java.util.Map; /** * Handler of {@link SplitBenthosBatchUI}. @@ -306,6 +310,61 @@ model.setBatch(batch); } + public void editBatch(BenthosBatchRowModel batch, + int sampleCategoryId) { + + Preconditions.checkNotNull(batch); + Preconditions.checkNotNull(sampleCategoryId); + + List<BenthosBatchRowModel> rows = batch.getChildBatch(); + Preconditions.checkNotNull(rows); + + // get possible the last used + List<SampleCategoryModelEntry> categories = Lists.newArrayList(); + + // get sample category model + SampleCategoryModel sampleCategoryModel = + getModel().getSampleCategoryModel(); + + // set only the given category + SampleCategoryModelEntry selectedCategory = + sampleCategoryModel.getCategoryById(sampleCategoryId); + categories.add(selectedCategory); + + SplitBenthosBatchUIModel model = getModel(); + + // connect model to validator + ui.getValidator().setBean(model); + + model.setSampleWeight(null); + model.setCategory(categories); + model.setSelectedCategory(selectedCategory); + + // keep batch (will be used to push back editing entry) + model.setBatch(batch); + + // add existing rows + Map<Serializable, SplitBenthosBatchRowModel> rowsByValue = Maps.uniqueIndex(model.getRows(), new Function<SplitBenthosBatchRowModel, Serializable>() { + @Override + public Serializable apply(SplitBenthosBatchRowModel input) { + return input.getCategoryValue(); + } + }); + for (BenthosBatchRowModel row : rows) { + + SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId); + Serializable categoryValue = sampleCategory.getCategoryValue(); + SplitBenthosBatchRowModel splitRow = rowsByValue.get(categoryValue); + splitRow.setWeight(sampleCategory.getCategoryWeight()); + splitRow.setSelected(true); + splitRow.setEditable(false); + } + + computeSampleWeight(); + + getTableModel().fireTableDataChanged(); + } + public void save() { if (log.isDebugEnabled()) { @@ -315,10 +374,18 @@ EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class); SplitBenthosBatchUIModel model = getModel(); if (model.isValid()) { - parent.getBenthosTabContent().getHandler().splitBatch( - model.getSelectedCategory(), - model.getRows(), - model.getSampleWeight()); + if (model.isSplitMode()) { + parent.getBenthosTabContent().getHandler().splitBatch( + model.getSelectedCategory(), + model.getRows(), + model.getSampleWeight()); + } else { + parent.getBenthosTabContent().getHandler().addSampleCategoryBatch( + model.getBatch(), + model.getSelectedCategory(), + model.getRows(), + model.getSampleWeight()); + } } // close dialog @@ -398,7 +465,8 @@ SplitBenthosBatchTableModel tableModel = new SplitBenthosBatchTableModel(columnModel, getModel(), - editableCategoryValue); + editableCategoryValue, + getModel().isSplitMode()); JXTable table = getTable(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIModel.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -52,6 +52,8 @@ public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight"; + private static final String PROPERTY_SPLIT_MODE = "splitMode"; + /** * Batch which fires the editor. * @@ -94,6 +96,12 @@ */ protected final WeightUnit weightUnit; + /** + * Is ui in split mode ? + * @since 2.6 + */ + protected boolean splitMode = true; + public SplitBenthosBatchUIModel(WeightUnit weightUnit, SampleCategoryModel sampleCategoryModel) { super(BenthosBatchRowModel.class, null, null); @@ -155,4 +163,14 @@ public SampleCategoryModel getSampleCategoryModel() { return sampleCategoryModel; } + + public boolean isSplitMode() { + return splitMode; + } + + public void setSplitMode(boolean splitMode) { + Object oldValue = isSplitMode(); + this.splitMode = splitMode; + firePropertyChange(PROPERTY_SPLIT_MODE, oldValue,splitMode); + } } \ No newline at end of file Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -97,6 +97,11 @@ if (selectedBatch.isBatchRoot()) { // update speciesUsed handler.removeFromSpeciesUsed(selectedBatch); + } else { + + // remove from his parent + SpeciesBatchRowModel parentBatch = selectedBatch.getParentBatch(); + parentBatch.getChildBatch().remove(selectedBatch); } // collect of rows to remove from model Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -475,6 +475,12 @@ } @Override + public SampleCategory<?> getSampleCategoryByIndex(int sampleCategoryIndex) { + SampleCategory<?> result = categories[sampleCategoryIndex]; + return result; + } + + @Override public void setSampleCategoryValue(Integer sampleCategoryId, Serializable value) { SampleCategory<?> sampleCategory = getSampleCategoryById(sampleCategoryId); 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 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -306,12 +306,14 @@ return result; } - protected void updateShell(SpeciesBatchRowModel entry, int columnIndex) { - - Set<SpeciesBatchRowModel> shell = Sets.newHashSet(); - entry.collectShell(shell); - shell.add(entry); - + /** + * Update all the given cells for the given column. + * + * @param shell shell to update + * @param columnIndex the column index to update + * @since 2.6 + */ + public void updateShell(Set<SpeciesBatchRowModel> shell, int columnIndex) { for (SpeciesBatchRowModel batchRowModel : shell) { int currentRowIndex = getRowIndex(batchRowModel); if (log.isDebugEnabled()) { @@ -320,4 +322,19 @@ fireTableCellUpdated(currentRowIndex, columnIndex); } } + + /** + * Update all the cells of the given row shell for a given column. + * + * @param entry the first row to update + * @param columnIndex the column index to update + * @since 2.6 + */ + protected void updateShell(SpeciesBatchRowModel entry, int columnIndex) { + + Set<SpeciesBatchRowModel> shell = Sets.newHashSet(); + entry.collectShell(shell); + shell.add(entry); + updateShell(shell, columnIndex); + } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-09-26 17:29:01 UTC (rev 1232) @@ -28,7 +28,6 @@ bean: {model}; showReset: true; useFloat: true; - /*numberPattern: {DECIMAL3_PATTERN};*/ _selectOnFocus: {true}; } @@ -37,8 +36,6 @@ showPopupButton: {handler.getConfig().isShowNumberEditorButton()}; showReset: true; useFloat: true; - /*numberPattern: {DECIMAL3_PATTERN}; - decimalNumber: 3;*/ computedDataColor: {handler.getConfig().getColorComputedWeights()}; } @@ -171,6 +168,15 @@ _help: {"tutti.editSpeciesBatch.action.changeSampleCategory.help"}; } +#addSampleCategoryMenu { + actionIcon: batch-split; + text: "tutti.editSpeciesBatch.action.addSampleCategory"; + toolTipText: "tutti.editSpeciesBatch.action.addSampleCategory.tip"; + i18nMnemonic: "tutti.editSpeciesBatch.action.addSampleCategory.mnemonic"; + enabled: {model.isTableViewModeAll() && model.isAddSampleCategoryEnabled()}; + _help: {"tutti.editSpeciesBatch.action.addSampleCategory.help"}; +} + #removeSpeciesBatchMenu { actionIcon: batch-delete; text: "tutti.editSpeciesBatch.action.removeBatch"; 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 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-09-26 17:29:01 UTC (rev 1232) @@ -80,6 +80,8 @@ onActionPerformed='handler.splitBatch()'/> <JMenuItem id='changeSampleCategoryMenu' onActionPerformed='handler.changeBatchCategory()'/> + <JMenuItem id='addSampleCategoryMenu' + onActionPerformed='handler.addBatchCategory()'/> <JMenuItem id='removeSpeciesBatchMenu'/> <JMenuItem id='removeSpeciesSubBatchMenu'/> <JMenuItem id='renameSpeciesBatchMenu'/> 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 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -137,6 +137,13 @@ */ protected final WeightUnit weightUnit; + /** + * id of the unsorted qualitative value to remove of V/HV universe. + * + * @since 2.6 + */ + protected final Integer qualitative_unsorted_id; + public SpeciesBatchUIHandler(EditCatchesUI parentUi, SpeciesBatchUI ui) { super(parentUi, ui, @@ -149,6 +156,9 @@ SpeciesBatchRowModel.PROPERTY_FREQUENCY, SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM); + qualitative_unsorted_id = + context.getPersistenceService().getEnumerationFile().QUALITATIVE_UNSORTED_ID; + weightUnit = getConfig().getSpeciesWeightUnit(); sampleCategoryModel = getDataContext().getSampleCategoryModel(); @@ -459,6 +469,7 @@ boolean enableRename = false; boolean enableSplit = false; boolean enableChangeSampleCategory = false; + boolean enableAddSampleCategory = false; boolean enableRemove = false; boolean enableRemoveSub = false; boolean enableCreateMelag = false; @@ -478,7 +489,6 @@ // can edit frequencies on a single selected leaf row - enableSplit = true; // action with single selection @@ -488,6 +498,7 @@ enableCreateMelag = selectedRowCount > 1; enableEditFrequencies = selectedRowCount == 1; enableChangeSampleCategory = selectedRowCount == 1 && tableModel.isCellEditable(rowIndex, columnIndex); + enableAddSampleCategory = selectedRowCount == 1 && tableModel.isCellEditable(rowIndex, columnIndex); if (enableSplit) { @@ -503,11 +514,44 @@ || row.getComputedNumber() == 0); } + boolean firstCategory = false; + Integer sampleCategoryId = + tableModel.getSampleCategoryId(columnIndex); + + SampleCategoryModelEntry category = null; + + List<CaracteristicQualitativeValue> available = null; + + if (sampleCategoryId != null) { + + // is first category ? + firstCategory = sampleCategoryModel.getFirstCategoryId().equals(sampleCategoryId); + + // get category + category = sampleCategoryModel.getCategoryById(sampleCategoryId); + + // get the first ancestor row using this category + SpeciesBatchRowModel firstAncestorRow = row.getFirstAncestor(sampleCategoryId); + + // get all used values for this category + Set<Serializable> used = getSampleUsedValues( + firstAncestorRow, sampleCategoryId); + + // get all possible values + available = Lists.newArrayList(category.getCaracteristic().getQualitativeValue()); + available.removeAll(used); + + if (firstCategory) { + + // remove the unsorted qualitative value + TuttiEntities.removeQualitativeValue(available, qualitative_unsorted_id); + } + } + if (enableChangeSampleCategory) { - // can change category if there is still a brother category free - Integer sampleCategoryId = - tableModel.getSampleCategoryId(columnIndex); + // can change category if on a sample column and + // there is still a brother category free if (sampleCategoryId == null) { @@ -515,35 +559,41 @@ enableChangeSampleCategory = false; } else { - // get category - SampleCategoryModelEntry category = - sampleCategoryModel.getCategoryById(sampleCategoryId); + if (category.getCaracteristic().isNumericType()) { - // get the first ancestor row using this category - SpeciesBatchRowModel firstAncestorRow = - row.getFirstAncestor(sampleCategoryId); + // if number then can always change it - // get all used values for this category - Set<Serializable> used = getSampleUsedValues( - firstAncestorRow, sampleCategoryId); + } else { + // action possible only if there is still some available values + enableChangeSampleCategory = CollectionUtils.isNotEmpty(available); + } + } + } + + if (enableAddSampleCategory) { + + // can change category if on a sample column and + // there is still a brother category free + // and sample category is not the first + + if (sampleCategoryId == null || firstCategory) { + + // not on a sample category column + // or using the first sample category (V/HV) + enableAddSampleCategory = false; + } else { + if (category.getCaracteristic().isNumericType()) { // if number then can always change it } else { - // get all possible values - - List<CaracteristicQualitativeValue> available = - Lists.newArrayList(category.getCaracteristic().getQualitativeValue()); - available.removeAll(used); - // action possible only if there is still some available values - enableChangeSampleCategory = !available.isEmpty(); + enableAddSampleCategory = CollectionUtils.isNotEmpty(available); } } - } if (enableEditFrequencies) { @@ -590,22 +640,24 @@ SpeciesBatchUIModel model = getModel(); model.setSplitBatchEnabled(enableSplit); model.setChangeSampleCategoryEnabled(enableChangeSampleCategory); + model.setAddSampleCategoryEnabled(enableAddSampleCategory); model.setRemoveBatchEnabled(enableRemove); model.setRemoveSubBatchEnabled(enableRemoveSub); model.setRenameBatchEnabled(enableRename); model.setCreateMelagEnabled(enableCreateMelag); model.setEditFrequenciesEnabled(enableEditFrequencies); - if (log.isInfoEnabled()) { + if (log.isDebugEnabled()) { StringBuilder builder = new StringBuilder("actions for (" + rowIndex + "," + columnIndex + "):"); builder.append("\nenableSplit: ").append(enableSplit); builder.append("\nenableChangeSampleCategory: ").append(enableChangeSampleCategory); + builder.append("\nenableAddSampleCategory: ").append(enableAddSampleCategory); builder.append("\nenableRemove: ").append(enableRemove); builder.append("\nenableRemoveSub: ").append(enableRemoveSub); builder.append("\nenableRename: ").append(enableRename); builder.append("\nenableCreateMelag: ").append(enableCreateMelag); builder.append("\nenableEditFrequencies: ").append(enableEditFrequencies); - log.info(builder.toString()); + log.debug(builder.toString()); } } @@ -887,6 +939,49 @@ } } + public void addBatchCategory() { + + // get table model + SpeciesBatchTableModel tableModel = getTableModel(); + + // get selected row + int rowIndex = getTable().getSelectedRow(); + Preconditions.checkState(rowIndex != -1, + "Cant split batch if no batch selected"); + + // get selected column + int columnIndex = getTable().getSelectedColumn(); + Preconditions.checkState(columnIndex != -1, + "Cant split batch if no batch selected"); + + // get selected row + SpeciesBatchRowModel selectedRow = tableModel.getEntry(rowIndex); + + // get his sample category + Integer sampleCategoryId = tableModel.getSampleCategoryId(columnIndex); + + // get the first ancestor row using this category + SpeciesBatchRowModel firstAncestorRow = + selectedRow.getFirstAncestor(sampleCategoryId); + + // get his parent (the one we will edit) + SpeciesBatchRowModel parentBatch = firstAncestorRow.getParentBatch(); + + if (log.isDebugEnabled()) { + log.debug("Open addChangeCategory batch ui for row [" + rowIndex + "] and category " + sampleCategoryId); + } + + EditCatchesUI parent = + SwingUtil.getParentContainer(ui, EditCatchesUI.class); + SplitSpeciesBatchUI splitBatchEditor = + parent.getSpeciesTabAddSampleCategoryBatch(); + + parent.getHandler().addSampleCategorySpeciesBatch( + parentBatch, + splitBatchEditor, + sampleCategoryId); + } + public void changeBatchCategory() { // get table model @@ -958,6 +1053,16 @@ List<CaracteristicQualitativeValue> availableValues = Lists.newArrayList(caracteristic.getQualitativeValue()); + + boolean firstCategory = + sampleCategoryModel.getFirstCategoryId().equals(sampleCategoryId); + + if (firstCategory) { + + // remove the unsorted qualitative value + TuttiEntities.removeQualitativeValue(availableValues, qualitative_unsorted_id); + } + availableValues.removeAll(usedValues); JComboBox editor = new JComboBox(); @@ -1047,6 +1152,69 @@ model.setLeafNumber(model.getLeafNumber() + newBatches.size() - 1); } + public void addSampleCategoryBatch(SpeciesBatchRowModel parentBatch, + SampleCategoryModelEntry sampleCategoryDef, + List<SplitSpeciesBatchRowModel> rows, + Float totalRowWeight) { + + // get table model + SpeciesBatchTableModel tableModel = getTableModel(); + + // get insert row index + int insertRow = tableModel.getRowIndex(parentBatch) + parentBatch.getChildBatch().size(); + + // Create rows in batch table model + List<SpeciesBatchRowModel> newBatches = Lists.newArrayList(); + for (SplitSpeciesBatchRowModel row : rows) { + if (row.isEditable() && row.isValid()) { + + // can keep this row + SpeciesBatchRowModel newBatch = tableModel.createNewRow(); + + loadBatchRow(parentBatch, + newBatch, + sampleCategoryDef.getCategoryId(), + row.getCategoryValue(), + row.getWeight(), + null); + + recomputeRowValidState(newBatch); + newBatches.add(newBatch); + + tableModel.addNewRow(++insertRow, newBatch); + } + } + + // add new batches to his parent + List<SpeciesBatchRowModel> childBatch = parentBatch.getChildBatch(); + childBatch.addAll(newBatches); + parentBatch.setChildBatch(childBatch); + + // re compute the sub sample property for all childs + int categoryIndex = sampleCategoryModel.indexOf(sampleCategoryDef); + + Float parentWeight = parentBatch.getSampleCategoryByIndex(categoryIndex - 1).getNotNullWeight(); + boolean subSample = parentWeight != null && totalRowWeight != null + && parentWeight > totalRowWeight; + + Set<SpeciesBatchRowModel> shell = Sets.newHashSet(); + parentBatch.collectShell(shell); + + for (SpeciesBatchRowModel rowModel : shell) { + rowModel.getSampleCategoryByIndex(categoryIndex).setSubSample(subSample); + } + + // save new batches + saveRows(newBatches); + + // update model number of leaf + SpeciesBatchUIModel model = getModel(); + model.setLeafNumber(model.getLeafNumber() + newBatches.size() - 1); + + // update columns for the parent shell + tableModel.updateShell(shell, getTable().getSelectedColumn()); + } + public void updateTotalFromFrequencies(SpeciesBatchRowModel row) { List<SpeciesFrequencyRowModel> frequency = row.getFrequency(); 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 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -49,6 +49,8 @@ public static final String PROPERTY_CHANGE_SAMPLE_CATEGORY_ENABLED = "changeSampleCategoryEnabled"; + public static final String PROPERTY_ADD_SAMPLE_CATEGORY_ENABLED = "addSampleCategoryEnabled"; + public static final String PROPERTY_REMOVE_SUB_BATCH_ENABLED = "removeSubBatchEnabled"; public static final String PROPERTY_RENAME_BATCH_ENABLED = "renameBatchEnabled"; @@ -86,6 +88,13 @@ protected boolean changeSampleCategoryEnabled; /** + * Can user add a/some missing sample category of the selected species batch ? + * + * @since 2.6 + */ + protected boolean addSampleCategoryEnabled; + + /** * Can user remove a selected species batch? * * @since 0.3 @@ -295,6 +304,15 @@ firePropertyChange(PROPERTY_CHANGE_SAMPLE_CATEGORY_ENABLED, null, changeSampleCategoryEnabled); } + public boolean isAddSampleCategoryEnabled() { + return addSampleCategoryEnabled; + } + + public void setAddSampleCategoryEnabled(boolean addSampleCategoryEnabled) { + this.addSampleCategoryEnabled = addSampleCategoryEnabled; + firePropertyChange(PROPERTY_ADD_SAMPLE_CATEGORY_ENABLED, null, addSampleCategoryEnabled); + } + public boolean isRemoveBatchEnabled() { return removeBatchEnabled; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -549,7 +549,8 @@ SplitSpeciesBatchTableModel tableModel = new SplitSpeciesBatchTableModel(columnModel, getModel(), - editableCategoryValue); + editableCategoryValue, + false); JXTable table = getTable(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -48,6 +48,8 @@ public static final String PROPERTY_SELECTED = "selected"; + public static final String PROPERTY_EDITABLE = "editable"; + /** * Delegate sample category which contains category value + weight. * @@ -55,8 +57,20 @@ */ protected final SampleCategory<Serializable> category = SampleCategory.newSample(null); + /** + * Is row selected? + * + * @since 2.5 + */ protected boolean selected; + /** + * Is row editable ? (in add mode incoming rows are all selected and not editable). + * + * @since 2.6 + */ + protected boolean editable; + public SplitSpeciesBatchRowModel() { super(SplitSpeciesBatchRowModel.class, null, null); } @@ -111,6 +125,16 @@ firePropertyChange(PROPERTY_SELECTED, oldValue, selected); } + public boolean isEditable() { + return editable; + } + + public void setEditable(boolean editable) { + Object oldValue = isEditable(); + this.editable = editable; + firePropertyChange(PROPERTY_EDITABLE, oldValue, editable); + } + @Override protected SplitSpeciesBatchRowModel newEntity() { return new SplitSpeciesBatchRowModel(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -64,11 +64,20 @@ private final SelectedCategoryAble uiModel; + /** + * Is the table is in split mode? + * + * @since 2.6 + */ + private final boolean splitMode; + public SplitSpeciesBatchTableModel(TableColumnModelExt columnModel, SelectedCategoryAble uiModel, - boolean createEmptyRowIsEmpty) { + boolean createEmptyRowIsEmpty, + boolean splitMode) { super(columnModel, createEmptyRowIsEmpty, createEmptyRowIsEmpty); this.uiModel = uiModel; + this.splitMode = splitMode; setNoneEditableCols(READ_ONLY_CATEGORY_VALUE); } @@ -77,7 +86,24 @@ SplitSpeciesBatchRowModel result = new SplitSpeciesBatchRowModel(); result.setCategoryType(uiModel.getSelectedCategory()); result.setValid(false); + result.setEditable(true); return result; } + @Override + protected boolean isCellEditable(int rowIndex, + int columnIndex, + ColumnIdentifier<SplitSpeciesBatchRowModel> propertyName) { + + boolean result = super.isCellEditable(rowIndex, + columnIndex, + propertyName); + if (result && !splitMode) { + // if editable and on edit mode, use editable property on row + SplitSpeciesBatchRowModel entry = getEntry(rowIndex); + result = entry.isEditable(); + } + return result; + } + } \ No newline at end of file Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -24,8 +24,10 @@ * #L% */ +import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import fr.ifremer.tutti.persistence.entities.data.SampleCategory; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry; @@ -53,7 +55,9 @@ import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.io.Serializable; import java.util.List; +import java.util.Map; /** * Handler of {@link SplitSpeciesBatchUI}. @@ -307,6 +311,61 @@ model.setBatch(batch); } + public void editBatch(SpeciesBatchRowModel batch, + int sampleCategoryId) { + + Preconditions.checkNotNull(batch); + Preconditions.checkNotNull(sampleCategoryId); + + List<SpeciesBatchRowModel> rows = batch.getChildBatch(); + Preconditions.checkNotNull(rows); + + // get possible the last used + List<SampleCategoryModelEntry> categories = Lists.newArrayList(); + + // get sample category model + SampleCategoryModel sampleCategoryModel = + getModel().getSampleCategoryModel(); + + // set only the given category + SampleCategoryModelEntry selectedCategory = + sampleCategoryModel.getCategoryById(sampleCategoryId); + categories.add(selectedCategory); + + SplitSpeciesBatchUIModel model = getModel(); + + // connect model to validator + ui.getValidator().setBean(model); + + model.setSampleWeight(null); + model.setCategory(categories); + model.setSelectedCategory(selectedCategory); + + // keep batch (will be used to push back editing entry) + model.setBatch(batch); + + // add existing rows + Map<Serializable, SplitSpeciesBatchRowModel> rowsByValue = Maps.uniqueIndex(model.getRows(), new Function<SplitSpeciesBatchRowModel, Serializable>() { + @Override + public Serializable apply(SplitSpeciesBatchRowModel input) { + return input.getCategoryValue(); + } + }); + for (SpeciesBatchRowModel row : rows) { + + SampleCategory<?> sampleCategory = row.getSampleCategoryById(sampleCategoryId); + Serializable categoryValue = sampleCategory.getCategoryValue(); + SplitSpeciesBatchRowModel splitRow = rowsByValue.get(categoryValue); + splitRow.setWeight(sampleCategory.getCategoryWeight()); + splitRow.setSelected(true); + splitRow.setEditable(false); + } + + computeSampleWeight(); + + getTableModel().fireTableDataChanged(); + } + public void save() { if (log.isDebugEnabled()) { @@ -316,10 +375,18 @@ EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class); SplitSpeciesBatchUIModel model = getModel(); if (model.isValid()) { - parent.getSpeciesTabContent().getHandler().splitBatch( - model.getSelectedCategory(), - model.getRows(), - model.getSampleWeight()); + if (model.isSplitMode()) { + parent.getSpeciesTabContent().getHandler().splitBatch( + model.getSelectedCategory(), + model.getRows(), + model.getSampleWeight()); + } else { + parent.getSpeciesTabContent().getHandler().addSampleCategoryBatch( + model.getBatch(), + model.getSelectedCategory(), + model.getRows(), + model.getSampleWeight()); + } } // close dialog @@ -401,7 +468,8 @@ SplitSpeciesBatchTableModel tableModel = new SplitSpeciesBatchTableModel(columnModel, getModel(), - editableCategoryValue); + editableCategoryValue, + getModel().isSplitMode()); JXTable table = getTable(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java 2013-09-26 17:29:01 UTC (rev 1232) @@ -52,6 +52,8 @@ public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight"; + public static final String PROPERTY_SPLIT_MODE = "splitMode"; + /** * Batch which fires the editor. * @@ -94,6 +96,12 @@ */ protected final WeightUnit weightUnit; + /** + * Is ui in split mode ? + * @since 2.6 + */ + protected boolean splitMode = true; + public SplitSpeciesBatchUIModel(WeightUnit weightUnit, SampleCategoryModel sampleCategoryModel) { super(SpeciesBatchRowModel.class, null, null); @@ -154,4 +162,14 @@ public SampleCategoryModel getSampleCategoryModel() { return sampleCategoryModel; } + + public boolean isSplitMode() { + return splitMode; + } + + public void setSplitMode(boolean splitMode) { + Object oldValue = isSplitMode(); + this.splitMode = splitMode; + firePropertyChange(PROPERTY_SPLIT_MODE, oldValue,splitMode); + } } \ No newline at end of file Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-09-26 17:29:01 UTC (rev 1232) @@ -14,6 +14,8 @@ tutti.about.update.content= tutti.about.update.title= tutti.action.create.error= +tutti.addSampleCategoryBenthosBatch.title= +tutti.addSampleCategorySpeciesBatch.title= tutti.applicationUpdater.prepareFirstDB.copyDirectory.error= tutti.applicationUpdater.prepareFirstDB.deleteDirectory.error= tutti.applicationUpdater.startUpdate.db.installation= @@ -362,6 +364,9 @@ tutti.editAccidentalBatch.table.header.species.tip= tutti.editAccidentalBatch.table.header.weight= tutti.editAccidentalBatch.table.header.weight.tip= +tutti.editBenthosBatch.action.addSampleCategory= +tutti.editBenthosBatch.action.addSampleCategory.mnemonic= +tutti.editBenthosBatch.action.addSampleCategory.tip= tutti.editBenthosBatch.action.changeSampleCategory= tutti.editBenthosBatch.action.changeSampleCategory.mnemonic= tutti.editBenthosBatch.action.changeSampleCategory.tip= @@ -883,6 +888,9 @@ tutti.editSampleCategoryModel.table.header.label= tutti.editSampleCategoryModel.table.header.label.tip= tutti.editSampleCategoryModel.title= +tutti.editSpeciesBatch.action.addSampleCategory= +tutti.editSpeciesBatch.action.addSampleCategory.mnemonic= +tutti.editSpeciesBatch.action.addSampleCategory.tip= tutti.editSpeciesBatch.action.changeSampleCategory= tutti.editSpeciesBatch.action.changeSampleCategory.mnemonic= tutti.editSpeciesBatch.action.changeSampleCategory.tip= 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 2013-09-26 11:07:00 UTC (rev 1231) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-09-26 17:29:01 UTC (rev 1232) @@ -14,6 +14,8 @@ tutti.about.update.content=<h2>Mise à jour de Tutti</h2><p>Fichier des mises à jour \: <ul><li>Applicatif \: <a href\="%1$s">%1$s</a></li><li>Base de données \: <a href\="%2$s">%2$s</a></li></ul></p><br/><hr/><br/><table><CAPTION><EM>Mises à jour des modules</EM></CAPTION><tr><th>Module</th><th>Version installée</th><th>Dernière version</th><th></th></tr>%3$s</table> tutti.about.update.title=Mise à jour Tutti tutti.action.create.error=Erreur à l'instanciation de l'action %s +tutti.addSampleCategoryBenthosBatch.title=Catégorisation du lot (ajout) +tutti.addSampleCategorySpeciesBatch.title=Catégorisation du lot (ajout) tutti.applicationUpdater.prepareFirstDB.copyDirectory.error=Erreur lors de la copie du contenu du dossier %1s vers %2s tutti.applicationUpdater.prepareFirstDB.deleteDirectory.error=Erreur lors de la suppression du dossier %s tutti.applicationUpdater.startUpdate.db.installation=Téléchargement et installation de la base (version %s) @@ -361,6 +363,9 @@ tutti.editAccidentalBatch.table.header.species.tip=Espèce tutti.editAccidentalBatch.table.header.weight=Poids observé tutti.editAccidentalBatch.table.header.weight.tip=Poids observé +tutti.editBenthosBatch.action.addSampleCategory=Ajouter une catégorie +tutti.editBenthosBatch.action.addSampleCategory.mnemonic=A +tutti.editBenthosBatch.action.addSampleCategory.tip=Ajouter une catégorie manquante tutti.editBenthosBatch.action.changeSampleCategory=Modifier la catégorie tutti.editBenthosBatch.action.changeSampleCategory.mnemonic=M tutti.editBenthosBatch.action.changeSampleCategory.tip=Modifier la catégorie de la cellule sélectionnée @@ -884,6 +889,9 @@ tutti.editSampleCategoryModel.table.header.label=Label tutti.editSampleCategoryModel.table.header.label.tip=Label de la catéogire (sera utilisée dans les entêtes de tableau) tutti.editSampleCategoryModel.title=Configurer les catégorisations +tutti.editSpeciesBatch.action.addSampleCategory=Ajouter une catégorie +tutti.editSpeciesBatch.action.addSampleCategory.mnemonic=A +tutti.editSpeciesBatch.action.addSampleCategory.tip=Ajouter une catégorie manquante tutti.editSpeciesBatch.action.changeSampleCategory=Modifier la catégorie tutti.editSpeciesBatch.action.changeSampleCategory.mnemonic=M tutti.editSpeciesBatch.action.changeSampleCategory.tip=Modifier la catégorie de la cellule sélectionnée