Tutti-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- 4058 discussions
26 Mar '13
Author: kmorin
Date: 2013-03-26 17:47:05 +0100 (Tue, 26 Mar 2013)
New Revision: 682
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/682
Log:
refs #1868 [CAPTURE] - Import/Export PUPITRI
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SplitSpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java
Removed:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractChangeScreenAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditCatchesAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUIHandler.java
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/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/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.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/java/fr/ifremer/tutti/ui/swing/content/AbstractChangeScreenAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractChangeScreenAction.java 2013-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractChangeScreenAction.java 2013-03-26 16:47:05 UTC (rev 682)
@@ -86,7 +86,6 @@
TuttiUIContext context = getContext();
- Exception error = null;
try {
TuttiScreen previousScreen = context.getScreen();
@@ -105,18 +104,20 @@
context.setScreen(screen);
} catch (Exception e) {
- error = e;
throw e;
- } finally {
+ }
+ }
- if (error != null)
-
- if (context.isDbLoaded()) {
-
- context.setScreen(TuttiScreen.SELECT_CRUISE);
- } else {
- context.setScreen(TuttiScreen.MANAGE_DB);
- }
+ @Override
+ public void postFailedAction(Throwable error) {
+ TuttiUIContext context = getContext();
+ if (error != null) {
+ if (context.isDbLoaded()) {
+ context.setScreen(TuttiScreen.SELECT_CRUISE);
+ } else {
+ context.setScreen(TuttiScreen.MANAGE_DB);
+ }
}
}
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditCatchesAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditCatchesAction.java 2013-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditCatchesAction.java 2013-03-26 16:47:05 UTC (rev 682)
@@ -57,4 +57,16 @@
getContext().setValidationContext(TuttiUIContext.VALIDATION_CONTEXT_EDIT);
super.doAction();
}
+
+ @Override
+ public void postFailedAction(Throwable error) {
+// TuttiUIContext context = getContext();
+// if (error != null) {
+// if (context.isDbLoaded()) {
+// context.setScreen(TuttiScreen.SELECT_CRUISE);
+// } else {
+// context.setScreen(TuttiScreen.MANAGE_DB);
+// }
+// }
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-03-26 16:47:05 UTC (rev 682)
@@ -537,7 +537,8 @@
Integer objectId = Integer.valueOf(batch.getId());
attachments = persistenceService.getAllAttachments(objectId);
getModel().setCatchEnabled(true);
- } catch (InvalidBatchModelException e) {
+
+ } catch (Exception e) {
// batch is not compatible with Tutti
if (log.isDebugEnabled()) {
@@ -569,7 +570,7 @@
// 4) Propagate new selected fishingoperation to others tabs
- ui.getSpeciesTabContent().getHandler().selectFishingOperation(batch == null ? null : bean);
+ ui.getSpeciesTabContent().getHandler().selectFishingOperation(batch == null ? null : bean);
ui.getBenthosTabContent().getHandler().selectFishingOperation(batch == null ? null : bean);
// ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean);
// ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2013-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2013-03-26 16:47:05 UTC (rev 682)
@@ -147,7 +147,13 @@
operation.setCruise(cruise);
}
editFishingOperationAction.setFishingOperation(operation);
- AbstractTuttiAction.runAction(editFishingOperationAction);
+// try {
+ AbstractTuttiAction.runAction(editFishingOperationAction);
+
+// } catch(RuntimeException e) {
+// getModel().setSelectedFishingOperation(null);
+//// throw e;
+// }
}
}
});
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriAction.java 2013-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriAction.java 2013-03-26 16:47:05 UTC (rev 682)
@@ -24,24 +24,25 @@
* #L%
*/
-import com.google.common.base.Function;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Multimaps;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SexEnum;
+import fr.ifremer.tutti.persistence.entities.data.SizeEnum;
import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.pupitri.PupitriCatch;
import fr.ifremer.tutti.service.pupitri.TuttiPupitriImportExportService;
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.content.operation.catches.species.SpeciesBatchUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SplitSpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
@@ -50,7 +51,6 @@
import javax.swing.JOptionPane;
import java.io.File;
import java.util.List;
-import java.util.Map;
import static org.nuiton.i18n.I18n._;
@@ -66,16 +66,49 @@
protected File importedCarrouselFile;
+ protected File importedSpeciesFile;
+
protected ImportPupitriPopupUI importPupitriDialog;
protected TuttiProtocol currentProtocol;
protected PersistenceService persistenceService;
+ protected CaracteristicQualitativeValue sortedCaracteristic;
+
+ protected CaracteristicQualitativeValue unsortedCaracteristic;
+
+ protected CaracteristicQualitativeValue maleCaracteristic;
+
+ protected CaracteristicQualitativeValue femaleCaracteristic;
+
+ protected CaracteristicQualitativeValue smallCaracteristic;
+
+ protected CaracteristicQualitativeValue mediumCaracteristic;
+
+ protected CaracteristicQualitativeValue bigCaracteristic;
+
public ImportPupitriAction(EditCatchesUIHandler handler) {
super(handler, false);
persistenceService = getContext().getPersistenceService();
importPupitriDialog = new ImportPupitriPopupUI(handler.getContext());
+
+ // get the sorted/unsorted caracteristics
+ Caracteristic sortedUnsortedcaracteristic =
+ persistenceService.getSortedUnsortedCaracteristic();
+ sortedCaracteristic =
+ SortedUnsortedEnum.SORTED.getValue(sortedUnsortedcaracteristic);
+ unsortedCaracteristic =
+ SortedUnsortedEnum.UNSORTED.getValue(sortedUnsortedcaracteristic);
+
+ Caracteristic sexCaracteristic = persistenceService.getSexCaracteristic();
+ maleCaracteristic = SexEnum.MALE.getValue(sexCaracteristic);
+ femaleCaracteristic = SexEnum.FEMALE.getValue(sexCaracteristic);
+
+ Caracteristic sizeCaracteristic = persistenceService.getSizeCategoryCaracteristic();
+ smallCaracteristic = SizeEnum.SMALL.getValue(sizeCaracteristic);
+ mediumCaracteristic = SizeEnum.MEDIUM.getValue(sizeCaracteristic);
+ bigCaracteristic = SizeEnum.BIG.getValue(sizeCaracteristic);
}
@Override
@@ -118,7 +151,10 @@
importPupitriDialog.open();
importedTrunkFile = importPupitriDialog.getTrunkFile().getSelectedFile();
importedCarrouselFile = importPupitriDialog.getCarrouselFile().getSelectedFile();
- result = importedTrunkFile != null && importedCarrouselFile != null;
+ importedSpeciesFile = importPupitriDialog.getSpeciesFile().getSelectedFile();
+ result = importedTrunkFile != null
+ && importedCarrouselFile != null
+ && importedSpeciesFile != null;
}
return result;
@@ -141,54 +177,85 @@
model.setCatchTotalRejectedWeight(catchBatch.getCatchTotalRejectedWeight());
model.setCatchTotalSortedTremisWeight(catchBatch.getCatchTotalSortedTremisWeight());
- addFileAsAttachment(importedTrunkFile);
-
-
// import carrousel
- Map<String, Float> sortedWeights = Maps.newLinkedHashMap();
- Map<String, Float> unsortedWeights = Maps.newLinkedHashMap();
- pupitriImportExportService.importPupitriCarrousel(importedCarrouselFile, operation, catchBatch, sortedWeights, unsortedWeights);
+ List<PupitriCatch> catches =
+ pupitriImportExportService.importPupitriCarrousel(importedCarrouselFile,
+ importedSpeciesFile,
+ operation,
+ catchBatch,
+ getDataContext().getReferentSpeciesWithSurveyCode());
// remove existing species
SpeciesBatchUIModel speciesBatchUIModel = getUI().getSpeciesTabContent().getModel();
List<SpeciesBatchRowModel> rows = speciesBatchUIModel.getRows();
for (SpeciesBatchRowModel row : rows) {
- persistenceService.deleteSpeciesBatch(row.getId());
+ if (row.isBatchRoot()) {
+ persistenceService.deleteSpeciesBatch(row.getId());
+ }
}
speciesBatchUIModel.setRows(null);
- // get the map of species by survey code
- Multimap<String, Species> speciesBySurveyCode =
- Multimaps.index(getDataContext().getReferentSpeciesWithSurveyCode(), new Function<Species, String>() {
- @Override
- public String apply(Species input) {
- String surveyCode = String.valueOf(input.getSurveyCode());
- int end = Math.min(surveyCode.length(), 7);
- return surveyCode.substring(0, end);
- }
- });
-
- // get the sorted/unsorted caracteristic
- Caracteristic caracteristic =
- persistenceService.getSortedUnsortedCaracteristic();
- CaracteristicQualitativeValue sortedvalue =
- SortedUnsortedEnum.SORTED.getValue(caracteristic);
-
// add the valid species in the species table
SpeciesBatchUIHandler speciesBatchUIHandler = getUI().getSpeciesTabContent().getHandler();
- for (String speciesId : sortedWeights.keySet()) {
+ for (PupitriCatch pupitriCatch : catches) {
+ Float catchWeight = pupitriCatch.getWeightBySign().get(PupitriCatch.Signs.DEFAULT);
+ CaracteristicQualitativeValue cqv = pupitriCatch.isSorted() ?
+ sortedCaracteristic : unsortedCaracteristic;
- Float weight = sortedWeights.get(speciesId);
- List<Species> speciesList = Lists.newArrayList(speciesBySurveyCode.get(speciesId.trim()));
- if (!speciesList.isEmpty()) {
- Species species = speciesList.get(0);
- ImportPupitriSpeciesBatchRootRowModel rowModel = new ImportPupitriSpeciesBatchRootRowModel(species, sortedvalue, weight);
- speciesBatchUIHandler.addBatch(rowModel);
+ ImportPupitriSpeciesBatchRootRowModel rowModel =
+ new ImportPupitriSpeciesBatchRootRowModel(
+ pupitriCatch.getSpecies(), cqv, catchWeight);
+
+ speciesBatchUIHandler.addBatch(rowModel);
+
+ if (catchWeight == null) {
+ SampleCategoryEnum category = null;
+ List<SplitSpeciesBatchRowModel> splitRows = Lists.newArrayList();
+ for (PupitriCatch.Signs s : pupitriCatch.getWeightBySign().keySet()) {
+ CaracteristicQualitativeValue splitCqv = null;
+ switch (s) {
+ case MALE:
+ splitCqv = maleCaracteristic;
+ category = SampleCategoryEnum.sex;
+ break;
+
+ case FEMALE:
+ splitCqv = femaleCaracteristic;
+ category = SampleCategoryEnum.sex;
+ break;
+
+ case SMALL:
+ splitCqv = smallCaracteristic;
+ category = SampleCategoryEnum.size;
+ break;
+
+ case MEDIUM:
+ splitCqv = mediumCaracteristic;
+ category = SampleCategoryEnum.size;
+ break;
+
+ case BIG:
+ splitCqv = bigCaracteristic;
+ category = SampleCategoryEnum.size;
+ break;
+ }
+ SplitSpeciesBatchRowModel row = new SplitSpeciesBatchRowModel();
+ row.setCategoryType(category);
+ row.setCategoryValue(splitCqv);
+ row.setWeight(pupitriCatch.getWeightBySign().get(s));
+ row.setValid(true);
+ splitRows.add(row);
+ }
+ speciesBatchUIHandler.splitBatch(category, splitRows);
}
}
model.setCatchTotalSortedCarousselWeight(catchBatch.getCatchTotalSortedCarousselWeight());
+
+ // add attachments
+ addFileAsAttachment(importedTrunkFile);
addFileAsAttachment(importedCarrouselFile);
+ addFileAsAttachment(importedSpeciesFile);
}
@@ -249,7 +316,7 @@
}
public boolean isValid() {
- return species != null && batchWeight != null && sortedUnsortedCategory != null;
+ return species != null && sortedUnsortedCategory != null;
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.css 2013-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.css 2013-03-26 16:47:05 UTC (rev 682)
@@ -51,6 +51,18 @@
acceptAllFileFilterUsed: false;
}
+#speciesFileLabel {
+ text: "tutti.importPupitri.field.speciesFile";
+ labelFor: {carrouselFile};
+}
+
+#speciesFile {
+ directoryEnabled: false;
+ exts: {_("tutti.importPupitri.speciesFile.extension")};
+ extsDescription: {_("tutti.importPupitri.speciesFile.extension.description")};
+ acceptAllFileFilterUsed: false;
+}
+
#cancelButton {
actionIcon: cancel;
text: "tutti.common.cancel";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.jaxx 2013-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUI.jaxx 2013-03-26 16:47:05 UTC (rev 682)
@@ -81,6 +81,15 @@
</row>
<row>
+ <cell>
+ <JLabel id='speciesFileLabel'/>
+ </cell>
+ <cell weightx='1'>
+ <FileEditor id='speciesFile'/>
+ </cell>
+ </row>
+
+ <row>
<cell columns='2'>
<JPanel layout='{new GridLayout(1,0)}'>
<JButton id='cancelButton' onActionPerformed='handler.cancel()'/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUIHandler.java 2013-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ImportPupitriPopupUIHandler.java 2013-03-26 16:47:05 UTC (rev 682)
@@ -67,6 +67,7 @@
protected void resetFields() {
ui.getTrunkFile().setSelectedFile((String) null);
ui.getCarrouselFile().setSelectedFile((String) null);
+ ui.getSpeciesFile().setSelectedFile((String) null);
}
public void open() {
@@ -82,7 +83,8 @@
public void validate() {
if (ui.getTrunkFile().getSelectedFile() != null
- && ui.getCarrouselFile().getSelectedFile() != null) {
+ && ui.getCarrouselFile().getSelectedFile() != null
+ && ui.getSpeciesFile().getSelectedFile() != null) {
ui.dispose();
} else {
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-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-03-26 16:47:05 UTC (rev 682)
@@ -48,7 +48,6 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.create.CreateSpeciesBatchUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyCellComponent;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
@@ -631,11 +630,11 @@
recomputeRowValidState(newRow);
+ saveRow(newRow);
+
tableModel.addNewRow(newRow);
AbstractSelectTableAction.doSelectCell(getTable(), tableModel.getRowCount() - 1, 0);
- saveRow(newRow);
-
// update speciesUsed
addToSpeciesUsed(newRow);
}
@@ -690,61 +689,52 @@
}
}
- public void splitBatch(SplitSpeciesBatchUIModel splitModel) {
- if (splitModel.isValid()) {
+ public void splitBatch(SampleCategoryEnum sampleCategoryEnum, List<SplitSpeciesBatchRowModel> rows) {
+ JXTable table = getTable();
- JXTable table = getTable();
+ // get selected row
+ int insertRow = table.getSelectedRow();
- // get selected row
- int insertRow = table.getSelectedRow();
+ SpeciesBatchTableModel tableModel = getTableModel();
+ SpeciesBatchRowModel parentBatch = tableModel.getEntry(insertRow);
- SpeciesBatchTableModel tableModel = getTableModel();
- SpeciesBatchRowModel parentBatch = tableModel.getEntry(insertRow);
+ // Create rows in batch table model
- // create batch rows
+ List<SpeciesBatchRowModel> newBatches = Lists.newArrayList();
+ for (SplitSpeciesBatchRowModel row : rows) {
+ if (row.isValid()) {
- SampleCategoryEnum sampleCategoryEnum = splitModel.getSelectedCategory();
+ // can keep this row
+ SpeciesBatchRowModel newBatch = tableModel.createNewRow();
- // Create rows in batch table model
+ loadBatchRow(parentBatch,
+ newBatch,
+ sampleCategoryEnum,
+ row.getCategoryValue(),
+ row.getWeight());
- List<SpeciesBatchRowModel> newBatches = Lists.newArrayList();
- for (SplitSpeciesBatchRowModel row : splitModel.getRows()) {
- if (row.isValid()) {
+ recomputeRowValidState(newBatch);
+ newBatches.add(newBatch);
- // can keep this row
- SpeciesBatchRowModel newBatch = tableModel.createNewRow();
-
- loadBatchRow(parentBatch,
- newBatch,
- sampleCategoryEnum,
- row.getCategoryValue(),
- row.getWeight());
-
- recomputeRowValidState(newBatch);
- newBatches.add(newBatch);
-
- tableModel.addNewRow(++insertRow, newBatch);
- }
+ tableModel.addNewRow(++insertRow, newBatch);
+ AbstractSelectTableAction.doSelectCell(getTable(), insertRow, 0);
}
+ }
- // add new batches to his parent
- parentBatch.setChildBatch(newBatches);
+ // add new batches to his parent
+ parentBatch.setChildBatch(newBatches);
- //TODO Should only save parentBatch (will persist all his childs)
+ //TODO Should only save parentBatch (will persist all his childs)
//saveRow(parentBatch);
- // save new batches
- saveRows(newBatches);
+ // save new batches
+ saveRows(newBatches);
- SpeciesBatchUIModel model = getModel();
- model.setLeafNumber(model.getLeafNumber() + newBatches.size() - 1);
- }
+ SpeciesBatchUIModel model = getModel();
+ model.setLeafNumber(model.getLeafNumber() + newBatches.size() - 1);
recomputeBatchActionEnable();
-// // reselect this cell
-// AbstractSelectTableAction.doSelectCell(table, rowIndex, 0);
-// table.requestFocus();
}
public void updateTotalFromFrequencies(SpeciesBatchRowModel row) {
@@ -797,11 +787,9 @@
if (TuttiEntities.isNew(catchBean)) {
- SpeciesBatchRowModel batchParent = row.getParentBatch();
String parentBatchId = null;
-
- if (batchParent != null) {
- parentBatchId = batchParent.getId();
+ if (parent != null) {
+ parentBatchId = parent.getId();
}
if (log.isInfoEnabled()) {
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SplitSpeciesBatchRowModel.java (from rev 677, 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/SplitSpeciesBatchRowModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SplitSpeciesBatchRowModel.java 2013-03-26 16:47:05 UTC (rev 682)
@@ -0,0 +1,102 @@
+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.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategory;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
+
+import java.io.Serializable;
+
+/**
+ * A row in the {@link SplitSpeciesBatchUIModel}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class SplitSpeciesBatchRowModel
+ extends AbstractTuttiBeanUIModel<SplitSpeciesBatchRowModel, SplitSpeciesBatchRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_CATEGORY_VALUE = "categoryValue";
+
+ public static final String PROPERTY_WEIGHT = "weight";
+
+ /**
+ * Delegate sample category which contains category value + weight.
+ *
+ * @since 0.3
+ */
+ protected final SampleCategory<Serializable> category = SampleCategory.newSample(null);
+
+ public SplitSpeciesBatchRowModel() {
+ super(SplitSpeciesBatchRowModel.class, null, null);
+ }
+
+ public SampleCategoryEnum getCategoryType() {
+ return category.getCategoryType();
+ }
+
+ public void setCategoryType(SampleCategoryEnum categoryType) {
+ category.setCategoryType(categoryType);
+ }
+
+ public Serializable getCategoryValue() {
+ return category.getCategoryValue();
+ }
+
+ public void setCategoryValue(Serializable categoryValue) {
+ Object oldValue = getCategoryValue();
+ category.setCategoryValue(categoryValue);
+ firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
+ }
+
+ public void setCategoryValue(CaracteristicQualitativeValue categoryValue) {
+ Object oldValue = getCategoryValue();
+ category.setCategoryValue(categoryValue);
+ firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
+ }
+
+ public void setCategoryValue(Float categoryValue) {
+ Object oldValue = getCategoryValue();
+ category.setCategoryValue(categoryValue);
+ firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
+ }
+
+ public Float getWeight() {
+ return category.getCategoryWeight();
+ }
+
+ public void setWeight(Float weight) {
+ Object oldValue = getWeight();
+ category.setCategoryWeight(weight);
+ firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
+ }
+
+}
\ No newline at end of file
Deleted: 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-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java 2013-03-26 16:47:05 UTC (rev 682)
@@ -1,110 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategory;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
-import org.nuiton.util.beans.Binder;
-import org.nuiton.util.beans.BinderFactory;
-
-import java.io.Serializable;
-
-/**
- * A row in the {@link SplitSpeciesBatchUIModel}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-public class SplitSpeciesBatchRowModel
- extends AbstractTuttiBeanUIModel<SplitSpeciesBatchRowModel, SplitSpeciesBatchRowModel> {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_CATEGORY_VALUE = "categoryValue";
-
- public static final String PROPERTY_WEIGHT = "weight";
-
- /**
- * Delegate sample category which contains category value + weight.
- *
- * @since 0.3
- */
- protected final SampleCategory<Serializable> category = SampleCategory.newSample(null);
-
- protected static final Binder<SplitSpeciesBatchRowModel, SplitSpeciesBatchRowModel> fromBeanBinder =
- BinderFactory.newBinder(SplitSpeciesBatchRowModel.class,
- SplitSpeciesBatchRowModel.class);
-
- protected static final Binder<SplitSpeciesBatchRowModel, SplitSpeciesBatchRowModel> toBeanBinder =
- BinderFactory.newBinder(SplitSpeciesBatchRowModel.class,
- SplitSpeciesBatchRowModel.class);
-
- public SplitSpeciesBatchRowModel() {
- super(SplitSpeciesBatchRowModel.class, fromBeanBinder, toBeanBinder);
- }
-
- public SampleCategoryEnum getCategoryType() {
- return category.getCategoryType();
- }
-
- public void setCategoryType(SampleCategoryEnum categoryType) {
- category.setCategoryType(categoryType);
- }
-
- public Serializable getCategoryValue() {
- return category.getCategoryValue();
- }
-
- public void setCategoryValue(Serializable categoryValue) {
- Object oldValue = getCategoryValue();
- category.setCategoryValue(categoryValue);
- firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
- }
-
- public void setCategoryValue(CaracteristicQualitativeValue categoryValue) {
- Object oldValue = getCategoryValue();
- category.setCategoryValue(categoryValue);
- firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
- }
-
- public void setCategoryValue(Float categoryValue) {
- Object oldValue = getCategoryValue();
- category.setCategoryValue(categoryValue);
- firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
- }
-
- public Float getWeight() {
- return category.getCategoryWeight();
- }
-
- public void setWeight(Float weight) {
- Object oldValue = getWeight();
- category.setCategoryWeight(weight);
- firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
- }
-
-}
\ No newline at end of file
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-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java 2013-03-26 16:47:05 UTC (rev 682)
@@ -24,6 +24,7 @@
* #L%
*/
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SplitSpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import org.jdesktop.swingx.table.TableColumnModelExt;
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-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-03-26 16:47:05 UTC (rev 682)
@@ -24,6 +24,7 @@
* #L%
*/
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SplitSpeciesBatchRowModel;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
@@ -32,6 +33,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategory;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
@@ -300,7 +302,12 @@
}
EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class);
- parent.getSpeciesTabContent().getHandler().splitBatch(getModel());
+ SplitSpeciesBatchUIModel model = getModel();
+ if (model.isValid()) {
+ parent.getSpeciesTabContent().getHandler().splitBatch(
+ model.getSelectedCategory(),
+ model.getRows());
+ }
// close dialog
closeUI(ui);
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-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java 2013-03-26 16:47:05 UTC (rev 682)
@@ -24,6 +24,7 @@
* #L%
*/
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SplitSpeciesBatchRowModel;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-03-26 16:47:05 UTC (rev 682)
@@ -201,6 +201,15 @@
_help: {"tutti.editProtocol.action.exportProtocolSpecies.help"};
}
+#exportPupitriButton {
+ actionIcon: export;
+ text: "tutti.editProtocol.action.exportPupitri";
+ toolTipText: "tutti.editProtocol.action.exportPupitri.tip";
+ i18nMnemonic: "tutti.editProtocol.action.exportPupitri.mnemonic";
+ _tuttiAction: {ExportPupitriAction.class};
+ _help: {"tutti.editProtocol.action.exportPupitri.help"};
+}
+
#selectOtherBenthosButton {
text: "tutti.editProtocol.action.selectOtherBenthos";
toolTipText: "tutti.editProtocol.action.selectOtherBenthos.tip";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2013-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2013-03-26 16:47:05 UTC (rev 682)
@@ -141,6 +141,7 @@
constraints='BorderLayout.NORTH'>
<JButton id='importSpeciesButton'/>
<JButton id='exportSpeciesButton'/>
+ <JButton id='exportPupitriButton'/>
</JPanel>
<Table fill='both' constraints='BorderLayout.CENTER'>
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java (from rev 677, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java 2013-03-26 16:47:05 UTC (rev 682)
@@ -0,0 +1,127 @@
+package fr.ifremer.tutti.ui.swing.content.protocol;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.TuttiIOUtil;
+import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
+import fr.ifremer.tutti.service.pupitri.TuttiPupitriImportExportService;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To export protocol species.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ExportPupitriAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportPupitriAction.class);
+
+ private File file;
+
+ public ExportPupitriAction(EditProtocolUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ protected boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to export
+ file = TuttiUIUtil.chooseFile(
+ getContext().getMainUI(),
+ _("tutti.editProtocol.title.choose.speciesExportFile"),
+ _("tutti.editProtocol.action.chooseProtocolSpeciesFile"),
+ "^.*\\.ibts", _("tutti.common.file.ibts")
+ );
+ if (file == null) {
+
+ // user cancel
+ doAction = false;
+ } else {
+
+ // add extension if missing
+ file = TuttiIOUtil.addExtensionIfMissing(file, ".ibts");
+
+ // ask user to confirm overwrite.
+ doAction = getHandler().askOverwriteFile(file);
+ }
+ }
+ return doAction;
+ }
+
+ @Override
+ protected void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ protected void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will export protocol species to file: " + file);
+ }
+
+ EditProtocolUIModel model = getModel();
+
+ // build species protocol to export
+
+ List<Species> speciesList = Lists.newArrayList();
+ for (EditProtocolSpeciesRowModel row : model.getSpecies()) {
+ if (row.isValid()) {
+ Species species = row.getSpecies();
+ species.setSurveyCode(row.getSpeciesSurveyCode());
+ speciesList.add(species);
+ }
+ }
+
+ // import
+ TuttiPupitriImportExportService service =
+ getContext().getTuttiPupitriImportExportService();
+
+ service.exportSpecies(speciesList, file);
+
+ sendMessage(_("tutti.flash.info.species.exported.from.protocol",
+ file));
+ }
+}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-03-26 16:47:05 UTC (rev 682)
@@ -366,11 +366,11 @@
protected Component getTopestUI() {
Component result;
TuttiActionUI actionUI = getContext().getActionUI();
- if (actionUI.isVisible()) {
+// if (actionUI.isVisible()) {
result = actionUI;
- } else {
- result = getContext().getMainUI();
- }
+// } else {
+// result = getContext().getMainUI();
+// }
return result;
}
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-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-03-26 16:47:05 UTC (rev 682)
@@ -53,6 +53,7 @@
tutti.common.cancel=
tutti.common.cancel.mnemonic=
tutti.common.file.csv=
+tutti.common.file.ibts=
tutti.common.file.protocol=
tutti.common.file.zip=
tutti.common.validate=
@@ -508,6 +509,9 @@
tutti.editProtocol.action.exportProtocolSpecies=
tutti.editProtocol.action.exportProtocolSpecies.mnemonic=
tutti.editProtocol.action.exportProtocolSpecies.tip=
+tutti.editProtocol.action.exportPupitri=
+tutti.editProtocol.action.exportPupitri.mnemonic=
+tutti.editProtocol.action.exportPupitri.tip=
tutti.editProtocol.action.importProtocolBenthos=
tutti.editProtocol.action.importProtocolBenthos.mnemonic=
tutti.editProtocol.action.importProtocolBenthos.tip=
@@ -716,7 +720,10 @@
tutti.importPupitri.error.fileMissing.message=
tutti.importPupitri.error.fileMissing.title=
tutti.importPupitri.field.carrouselFile=
+tutti.importPupitri.field.speciesFile=
tutti.importPupitri.field.trunkFile=
+tutti.importPupitri.speciesFile.extension=
+tutti.importPupitri.speciesFile.extension.description=
tutti.importPupitri.title=
tutti.importPupitri.trunkFile.extension=
tutti.importPupitri.trunkFile.extension.description=
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-03-26 16:46:19 UTC (rev 681)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-03-26 16:47:05 UTC (rev 682)
@@ -52,6 +52,7 @@
tutti.common.cancel=Annuler
tutti.common.cancel.mnemonic=A
tutti.common.file.csv=Extension d'un fichier csv
+tutti.common.file.ibts=
tutti.common.file.protocol=Extension d'un fichier de protocole Tutti
tutti.common.file.zip=Extension d'une archive zip
tutti.common.validate=Valider
@@ -518,6 +519,9 @@
tutti.editProtocol.action.exportProtocolSpecies=Exporter les espèces
tutti.editProtocol.action.exportProtocolSpecies.mnemonic=è
tutti.editProtocol.action.exportProtocolSpecies.tip=Exporter les espèces du protocole
+tutti.editProtocol.action.exportPupitri=
+tutti.editProtocol.action.exportPupitri.mnemonic=
+tutti.editProtocol.action.exportPupitri.tip=
tutti.editProtocol.action.importProtocolBenthos=Importer les benthos
tutti.editProtocol.action.importProtocolBenthos.mnemonic=i
tutti.editProtocol.action.importProtocolBenthos.tip=Importer les benthos dans le protocole
@@ -725,7 +729,10 @@
tutti.importPupitri.error.fileMissing.message=Vous devez sélectionner un fichier pour le trémie et un fichier pour le carrousel pour pouvoir continuer l'import.
tutti.importPupitri.error.fileMissing.title=Fichier non renseigné
tutti.importPupitri.field.carrouselFile=Fichier du carrousel
+tutti.importPupitri.field.speciesFile=Fichier des espèces
tutti.importPupitri.field.trunkFile=Fichier du trémie
+tutti.importPupitri.speciesFile.extension=ibts
+tutti.importPupitri.speciesFile.extension.description=Fichier des espèces (.ibts)
tutti.importPupitri.title=Import Pupitri
tutti.importPupitri.trunkFile.extension=tnk
tutti.importPupitri.trunkFile.extension.description=Fichier du trémie (.tnk)
1
0
r681 - trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri
by kmorin@users.forge.codelutin.com 26 Mar '13
by kmorin@users.forge.codelutin.com 26 Mar '13
26 Mar '13
Author: kmorin
Date: 2013-03-26 17:46:19 +0100 (Tue, 26 Mar 2013)
New Revision: 681
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/681
Log:
refs #1868 [CAPTURE] - Import/Export PUPITRI
Added:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/SpeciesRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/SpeciesRowModel.java
Modified:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java 2013-03-26 16:46:02 UTC (rev 680)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRow.java 2013-03-26 16:46:19 UTC (rev 681)
@@ -58,8 +58,6 @@
public static final String PROPERTY_WEIGHT = "weight";
- public static final String PROPERTY_EMPTY = "";
-
protected Integer operationCode;
protected String rigNumber;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java 2013-03-26 16:46:02 UTC (rev 680)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java 2013-03-26 16:46:19 UTC (rev 681)
@@ -25,13 +25,12 @@
*/
import fr.ifremer.tutti.service.TuttiCsvUtil;
+import java.text.ParseException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.csv.ValueParser;
-import java.text.ParseException;
-
/**
* @author kmorin <kmorin(a)codelutin.com>
* @since 1.2
@@ -58,7 +57,7 @@
newMandatoryColumn(CarrouselRow.PROPERTY_SPECIES_ID, new ValueParser<String>() {
public String parse(String string) throws ParseException {
- return StringUtils.remove(string, '-');
+ return StringUtils.remove(string, '-').trim();
}
});
newMandatoryColumn(CarrouselRow.PROPERTY_SIGN);
@@ -83,7 +82,6 @@
newIgnoredColumn(CarrouselRow.PROPERTY_BALANCE_ID);
newIgnoredColumn(CarrouselRow.PROPERTY_TO_CONFIRM);
newIgnoredColumn(CarrouselRow.PROPERTY_BOX_TYPE);
- newIgnoredColumn(CarrouselRow.PROPERTY_EMPTY);
}
Added: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriCatch.java 2013-03-26 16:46:19 UTC (rev 681)
@@ -0,0 +1,102 @@
+
+package fr.ifremer.tutti.service.pupitri;
+
+import com.google.common.collect.Maps;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.2
+ */
+public class PupitriCatch implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static enum Signs {
+ DEFAULT("0"),
+ MALE("1"),
+ FEMALE("2"),
+ SMALL("P"),
+ MEDIUM("M"),
+ BIG("G");
+
+ private String sign;
+
+ Signs(String sign) {
+ this.sign = sign;
+ }
+
+ public static Signs getSign(String sign) {
+ Signs result = null;
+ for (Signs s : values()) {
+ if (s.sign.equals(sign)) {
+ result = s;
+ break;
+ }
+ }
+ return result;
+ }
+ }
+
+ protected Species species;
+
+ protected boolean sorted;
+
+ protected Map<Signs, Float> weightBySign = Maps.newHashMap();
+
+ public PupitriCatch(Species species, boolean sorted) {
+ this.species = species;
+ this.sorted = sorted;
+ }
+
+ public Species getSpecies() {
+ return species;
+ }
+
+ public boolean isSorted() {
+ return sorted;
+ }
+
+ public Map<Signs, Float> getWeightBySign() {
+ return weightBySign;
+ }
+
+ public void addToSign(String sign, Float weight) {
+ Signs s = Signs.getSign(sign);
+ Float f = weightBySign.get(s);
+ if (f == null) {
+ f = 0f;
+ }
+ f += weight;
+ weightBySign.put(s, f);
+ }
+
+ @Override
+ public int hashCode() {
+ int speciesHashCode = species != null ? species.hashCode() : 0;
+ int sortedHashCode = sorted ? 0x55555555 : 0x2AAAAAAA;
+ return speciesHashCode ^ sortedHashCode;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final PupitriCatch other = (PupitriCatch) obj;
+ if (this.species != other.species && (this.species == null || !this.species.equals(other.species))) {
+ return false;
+ }
+ if (this.sorted != other.sorted) {
+ return false;
+ }
+ return true;
+ }
+
+}
Added: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/SpeciesRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/SpeciesRow.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/SpeciesRow.java 2013-03-26 16:46:19 UTC (rev 681)
@@ -0,0 +1,51 @@
+
+package fr.ifremer.tutti.service.pupitri;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.2
+ */
+public class SpeciesRow implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_CODE_FIRST_PART = "codeFirstPart";
+
+ public static final String PROPERTY_CODE_SECOND_PART = "codeSecondPart";
+
+ public static final String PROPERTY_SCIENTIFIC_NAME = "scientificName";
+
+ protected String codeFirstPart;
+
+ protected String codeSecondPart;
+
+ protected String scientificName;
+
+ public String getCodeFirstPart() {
+ return codeFirstPart;
+ }
+
+ public void setCodeFirstPart(String codeFirstPart) {
+ this.codeFirstPart = codeFirstPart;
+ }
+
+ public String getCodeSecondPart() {
+ return codeSecondPart;
+ }
+
+ public void setCodeSecondPart(String codeSecondPart) {
+ this.codeSecondPart = codeSecondPart;
+ }
+
+ public String getScientificName() {
+ return scientificName;
+ }
+
+ public void setScientificName(String scientificName) {
+ this.scientificName = scientificName;
+ }
+
+}
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/SpeciesRowModel.java (from rev 677, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/CarrouselRowModel.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/SpeciesRowModel.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/SpeciesRowModel.java 2013-03-26 16:46:19 UTC (rev 681)
@@ -0,0 +1,57 @@
+package fr.ifremer.tutti.service.pupitri;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 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.service.TuttiCsvUtil;
+import java.text.ParseException;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.csv.ValueParser;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.2
+ */
+public class SpeciesRowModel extends TuttiCsvUtil.AbstractTuttiImportExportModel<SpeciesRow> {
+
+ private static final Log log = LogFactory.getLog(SpeciesRowModel.class);
+
+ public SpeciesRowModel(char separator) {
+ super(separator);
+
+ // import definition
+
+ newColumnForImportExport(SpeciesRow.PROPERTY_CODE_FIRST_PART);
+ newColumnForImportExport(SpeciesRow.PROPERTY_CODE_SECOND_PART);
+ newColumnForImportExport(SpeciesRow.PROPERTY_SCIENTIFIC_NAME);
+
+ }
+
+ public SpeciesRow newEmptyInstance() {
+ return new SpeciesRow();
+ }
+
+}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java 2013-03-26 16:46:02 UTC (rev 680)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java 2013-03-26 16:46:19 UTC (rev 681)
@@ -25,11 +25,21 @@
*/
import com.google.common.base.Charsets;
+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 com.google.common.collect.Multimap;
+import com.google.common.collect.Multimaps;
import com.google.common.io.Files;
import fr.ifremer.tutti.TuttiTechnicalException;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.AbstractTuttiService;
+import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
+import java.io.BufferedWriter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
@@ -37,9 +47,16 @@
import org.nuiton.util.csv.Import;
import java.io.File;
+import java.io.IOException;
import java.io.Reader;
+import java.util.Collection;
import java.util.Collections;
+import java.util.List;
import java.util.Map;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.nuiton.util.csv.Export;
+import org.nuiton.util.csv.ExportModel;
/**
* @author kmorin <kmorin(a)codelutin.com>
@@ -123,102 +140,181 @@
}
- public void importPupitriCarrousel(File file,
+ public List<PupitriCatch> importPupitriCarrousel(File carrouselFile,
+ File speciesFile,
FishingOperation operation,
CatchBatch catchBatch,
- Map<String, Float> sortedWeights,
- Map<String, Float> unsortedWeights) {
+ List<Species> referentSpecies) {
if (log.isInfoEnabled()) {
log.info("Will import pupitri operation [" + operation.toString() +
- "] carrousel from file: " + file);
+ "] carrousel from file: " + carrouselFile);
}
- char separator = ',';
- CarrouselRowModel csvModel = new CarrouselRowModel(separator);
-
+ List<PupitriCatch> result = Lists.newArrayList();
Reader reader = null;
File fileWithHeaders = null;
- Import<CarrouselRow> importer = null;
+ Import<SpeciesRow> speciesImporter = null;
+ Import<CarrouselRow> carrouselImporter = null;
+
+ char speciesSeparator = ';';
+ SpeciesRowModel speciesCsvModel = new SpeciesRowModel(speciesSeparator);
+ char carrouselSeparator = ',';
+ CarrouselRowModel carrouselCsvModel = new CarrouselRowModel(carrouselSeparator);
+
try {
- fileWithHeaders = new File(FileUtils.getTempDirectory(), file.getName());
- String headers = CarrouselRow.PROPERTY_FILE_ORIGIN + separator +
- CarrouselRow.PROPERTY_DATE + separator +
- CarrouselRow.PROPERTY_TIME + separator +
- CarrouselRow.PROPERTY_BALANCE_ID + separator +
- CarrouselRow.PROPERTY_TO_CONFIRM + separator +
- CarrouselRow.PROPERTY_OPERATION_CODE + separator +
- CarrouselRow.PROPERTY_RIG_NUMBER + separator +
- CarrouselRow.PROPERTY_BOX_TYPE + separator +
- CarrouselRow.PROPERTY_SPECIES_ID + separator +
- CarrouselRow.PROPERTY_SIGN + separator +
- CarrouselRow.PROPERTY_DIRECTION + separator +
- CarrouselRow.PROPERTY_WEIGHT + separator +
- CarrouselRow.PROPERTY_EMPTY;
- FileUtils.writeLines(fileWithHeaders, Collections.singletonList(headers));
- log.info(FileUtils.readFileToString(fileWithHeaders));
- FileUtils.writeLines(fileWithHeaders, FileUtils.readLines(file), true);
- log.info(FileUtils.readFileToString(fileWithHeaders));
+ // import the species
+ String[] header = new String [] {
+ SpeciesRow.PROPERTY_CODE_FIRST_PART,
+ SpeciesRow.PROPERTY_CODE_SECOND_PART,
+ SpeciesRow.PROPERTY_SCIENTIFIC_NAME
+ };
+ fileWithHeaders = createFileWithHeaders(speciesFile, header, speciesSeparator);
+ reader = Files.newReader(fileWithHeaders, Charsets.UTF_8);
+ speciesImporter = Import.newImport(speciesCsvModel, reader);
+ // get the map of species by survey code
+ Multimap<String, Species> speciesBySurveyCode =
+ Multimaps.index(referentSpecies, new Function<Species, String>() {
+ @Override
+ public String apply(Species input) {
+ String surveyCode = String.valueOf(input.getSurveyCode());
+ int end = Math.min(surveyCode.length(), 7);
+ return surveyCode.substring(0, end);
+ }
+ });
+ // keep only the species whose survey code and name are the same
+ // in theimported file and the referent species
+ Map<String, Species> speciesMap = Maps.newHashMap();
+ for (SpeciesRow bean : speciesImporter) {
+ String code = bean.getCodeFirstPart() + bean.getCodeSecondPart();
+ Collection<Species> speciesCollection = speciesBySurveyCode.get(code.trim());
+ for (Species species : speciesCollection) {
+ if (species.getName().equals(bean.getScientificName())) {
+ speciesMap.put(code, species);
+ break;
+ }
+ }
+ }
+
+ // import the batches
+ header = new String[] {
+ CarrouselRow.PROPERTY_FILE_ORIGIN,
+ CarrouselRow.PROPERTY_DATE,
+ CarrouselRow.PROPERTY_TIME,
+ CarrouselRow.PROPERTY_BALANCE_ID,
+ CarrouselRow.PROPERTY_TO_CONFIRM,
+ CarrouselRow.PROPERTY_OPERATION_CODE,
+ CarrouselRow.PROPERTY_RIG_NUMBER,
+ CarrouselRow.PROPERTY_BOX_TYPE,
+ CarrouselRow.PROPERTY_SPECIES_ID,
+ CarrouselRow.PROPERTY_SIGN,
+ CarrouselRow.PROPERTY_DIRECTION,
+ CarrouselRow.PROPERTY_WEIGHT
+ };
+ fileWithHeaders = createFileWithHeaders(carrouselFile, header, carrouselSeparator);
reader = Files.newReader(fileWithHeaders, Charsets.UTF_8);
+ carrouselImporter = Import.newImport(carrouselCsvModel, reader);
- importer = Import.newImport(csvModel, reader);
-
Integer operationNumber = operation.getFishingOperationNumber();
String rigNumber = operation.getMultirigAggregation();
Float carrouselSortedWeight = 0f;
- for (CarrouselRow bean : importer) {
+ for (CarrouselRow bean : carrouselImporter) {
+ // is the bean from the current operation and rig ?
if (bean.getOperationCode().equals(operationNumber)
- && bean.getRigNumber().equals(rigNumber)
- && "0".equals(bean.getSign())) {
+ && bean.getRigNumber().equals(rigNumber)) {
String speciesId = bean.getSpeciesId();
- Map<String, Float> weights = null;
+ Species species = speciesMap.get(speciesId);
Float beanWeight = bean.getWeight();
if (beanWeight < 0f) {
beanWeight = 0f;
}
-
+ boolean sorted;
switch (bean.getDirection()) {
- case VAT:
- weights = sortedWeights;
- carrouselSortedWeight += beanWeight;
+ case HOV:
+ sorted = false;
break;
- case HOV:
- weights = unsortedWeights;
+ default :
+ sorted = true;
+ carrouselSortedWeight += beanWeight;
}
- if (weights != null) {
- Float speciesWeight = weights.get(speciesId);
+ if (species != null) {
- if (speciesWeight == null) {
- speciesWeight = beanWeight;
-
+ PupitriCatch pupitriCatch = new PupitriCatch(species, sorted);
+ int catchIndex = result.indexOf(pupitriCatch);
+ if (catchIndex >= 0) {
+ pupitriCatch = result.get(catchIndex);
} else {
- speciesWeight += beanWeight;
+ result.add(pupitriCatch);
}
- weights.put(speciesId, speciesWeight);
+ pupitriCatch.addToSign(bean.getSign(), beanWeight);
}
}
}
catchBatch.setCatchTotalSortedCarousselWeight(carrouselSortedWeight);
- importer.close();
+ carrouselImporter.close();
+ speciesImporter.close();
reader.close();
} catch (Exception e) {
- throw new TuttiTechnicalException("Could not import protocol [" + operation.toString() + "] caracteristic from file " + file, e);
+ throw new TuttiTechnicalException("Could not import protocol [" + operation.toString() + "] caracteristic from file " + carrouselFile, e);
} finally {
- IOUtils.closeQuietly(importer);
+ IOUtils.closeQuietly(carrouselImporter);
+ IOUtils.closeQuietly(speciesImporter);
IOUtils.closeQuietly(reader);
FileUtils.deleteQuietly(fileWithHeaders);
}
+
+ return result;
}
+
+ public void exportSpecies(List<Species> species, File target) {
+ SpeciesRowModel speciesCsvModel = new SpeciesRowModel(';');
+
+ List<SpeciesRow> rows = Lists.newArrayList();
+
+ if (CollectionUtils.isNotEmpty(species)) {
+ rows = Lists.transform(species, new Function<Species, SpeciesRow>() {
+
+ public SpeciesRow apply(Species input) {
+ Preconditions.checkNotNull(input.getSurveyCode(),
+ "Unable to export a species with a null survey code : " + input);
+ SpeciesRow row = new SpeciesRow();
+ String codeFirstPart = StringUtils.substring(input.getSurveyCode(), 0, 4);
+ row.setCodeFirstPart(StringUtils.rightPad(codeFirstPart, 4));
+ String codeSecondPart = StringUtils.substring(input.getSurveyCode(), 4, 7);
+ row.setCodeSecondPart(StringUtils.rightPad(codeSecondPart, 3));
+ row.setScientificName(input.getName());
+ return row;
+ }
+ });
+ }
+
+ try {
+ Export.exportToFile(speciesCsvModel, rows, target, Charsets.UTF_8, false);
+
+ } catch (Exception e) {
+ throw new TuttiTechnicalException("Could not export all species to file " + target, e);
+ }
+ }
+
+ protected File createFileWithHeaders(File file, String[] header, char separator) throws IOException {
+ File fileWithHeaders = new File(FileUtils.getTempDirectory(), file.getName());
+ String headers = StringUtils.join(header, separator);
+
+ FileUtils.writeLines(fileWithHeaders, Collections.singletonList(headers));
+ FileUtils.writeLines(fileWithHeaders, FileUtils.readLines(file), true);
+
+ return fileWithHeaders;
+ }
}
1
0
r680 - in trunk/tutti-persistence/src/main: java/fr/ifremer/tutti/persistence/entities/data java/fr/ifremer/tutti/persistence/service resources
by kmorin@users.forge.codelutin.com 26 Mar '13
by kmorin@users.forge.codelutin.com 26 Mar '13
26 Mar '13
Author: kmorin
Date: 2013-03-26 17:46:02 +0100 (Tue, 26 Mar 2013)
New Revision: 680
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/680
Log:
refs #1868 [CAPTURE] - Import/Export PUPITRI
Added:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SexEnum.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SizeEnum.java
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java
trunk/tutti-persistence/src/main/resources/tutti-db-enumerations.properties
Copied: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SexEnum.java (from rev 677, trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java)
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SexEnum.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SexEnum.java 2013-03-26 16:46:02 UTC (rev 680)
@@ -0,0 +1,95 @@
+package fr.ifremer.tutti.persistence.entities.data;
+
+/*
+ * #%L
+ * Tutti :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 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.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
+
+/**
+ * Represents the sorted - unsorted pmfm.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public enum SexEnum implements TuttiEnumerationFile.TuttiEnumerable<Integer> {
+
+ MALE("QUALITATIVE_SEX_MALE_ID"),
+ FEMALE("QUALITATIVE_SEX_FEMALE_ID");
+
+ private final String fieldName;
+
+ private Integer fieldValue;
+
+ private boolean init;
+
+ SexEnum(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
+ @Override
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ @Override
+ public Integer getFieldValue() {
+ Preconditions.checkState(isInit(), "Enumeration " + getClass() + " was not init!");
+ return fieldValue;
+ }
+
+ @Override
+ public void setFieldValue(Object fieldValue) {
+ this.fieldValue = (Integer) fieldValue;
+ }
+
+ @Override
+ public boolean isInit() {
+ return init;
+ }
+
+ @Override
+ public void setInit(boolean init) {
+ this.init = init;
+ }
+
+ public boolean matchValue(CaracteristicQualitativeValue value) {
+ return fieldValue.equals(Integer.valueOf(value.getId()));
+ }
+
+ public CaracteristicQualitativeValue getValue(Caracteristic c) {
+ Preconditions.checkNotNull(c);
+ Preconditions.checkState(!c.isQualitativeValueEmpty());
+ CaracteristicQualitativeValue result = null;
+ for (CaracteristicQualitativeValue value : c.getQualitativeValue()) {
+ if (matchValue(value)) {
+ result = value;
+ break;
+ }
+ }
+ return result;
+ }
+}
Copied: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SizeEnum.java (from rev 677, trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java)
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SizeEnum.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SizeEnum.java 2013-03-26 16:46:02 UTC (rev 680)
@@ -0,0 +1,96 @@
+package fr.ifremer.tutti.persistence.entities.data;
+
+/*
+ * #%L
+ * Tutti :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 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.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
+
+/**
+ * Represents the sorted - unsorted pmfm.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public enum SizeEnum implements TuttiEnumerationFile.TuttiEnumerable<Integer> {
+
+ SMALL("QUALITATIVE_SIZE_SMALL_ID"),
+ MEDIUM("QUALITATIVE_SIZE_MEDIUM_ID"),
+ BIG("QUALITATIVE_SIZE_BIG_ID");
+
+ private final String fieldName;
+
+ private Integer fieldValue;
+
+ private boolean init;
+
+ SizeEnum(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
+ @Override
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ @Override
+ public Integer getFieldValue() {
+ Preconditions.checkState(isInit(), "Enumeration " + getClass() + " was not init!");
+ return fieldValue;
+ }
+
+ @Override
+ public void setFieldValue(Object fieldValue) {
+ this.fieldValue = (Integer) fieldValue;
+ }
+
+ @Override
+ public boolean isInit() {
+ return init;
+ }
+
+ @Override
+ public void setInit(boolean init) {
+ this.init = init;
+ }
+
+ public boolean matchValue(CaracteristicQualitativeValue value) {
+ return fieldValue.equals(Integer.valueOf(value.getId()));
+ }
+
+ public CaracteristicQualitativeValue getValue(Caracteristic c) {
+ Preconditions.checkNotNull(c);
+ Preconditions.checkState(!c.isQualitativeValueEmpty());
+ CaracteristicQualitativeValue result = null;
+ for (CaracteristicQualitativeValue value : c.getQualitativeValue()) {
+ if (matchValue(value)) {
+ result = value;
+ break;
+ }
+ }
+ return result;
+ }
+}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-03-25 19:08:05 UTC (rev 679)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-03-26 16:46:02 UTC (rev 680)
@@ -29,6 +29,8 @@
import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
+import fr.ifremer.tutti.persistence.entities.data.SexEnum;
+import fr.ifremer.tutti.persistence.entities.data.SizeEnum;
import fr.ifremer.tutti.persistence.entities.data.SortedUnsortedEnum;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ReflectionUtils;
@@ -132,6 +134,21 @@
@Value("${QualitativeValueId.UNSORTED}")
public final Integer QUALITATIVE_UNSORTED_ID = null;
+ @Value("${QualitativeValueId.SEX_MALE}")
+ public final Integer QUALITATIVE_SEX_MALE_ID = null;
+
+ @Value("${QualitativeValueId.SEX_FEMALE}")
+ public final Integer QUALITATIVE_SEX_FEMALE_ID = null;
+
+ @Value("${QualitativeValueId.SIZE_SMALL}")
+ public final Integer QUALITATIVE_SIZE_SMALL_ID = null;
+
+ @Value("${QualitativeValueId.SIZE_MEDIUM}")
+ public final Integer QUALITATIVE_SIZE_MEDIUM_ID = null;
+
+ @Value("${QualitativeValueId.SIZE_BIG}")
+ public final Integer QUALITATIVE_SIZE_BIG_ID = null;
+
@Value("${QualitativeValueId.SORTING_TYPE_SPECIES}")
public final Integer QUALITATIVE_ID_SORTING_TYPE_SPECIES = null;
@@ -271,6 +288,8 @@
// init enums
initEnum(SortedUnsortedEnum.class, annotatedFieldValues);
+ initEnum(SexEnum.class, annotatedFieldValues);
+ initEnum(SizeEnum.class, annotatedFieldValues);
initEnum(AttachementObjectTypeEnum.class, annotatedFieldValues);
initEnum(SampleCategoryEnum.class, annotatedFieldValues);
Modified: trunk/tutti-persistence/src/main/resources/tutti-db-enumerations.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/tutti-db-enumerations.properties 2013-03-25 19:08:05 UTC (rev 679)
+++ trunk/tutti-persistence/src/main/resources/tutti-db-enumerations.properties 2013-03-26 16:46:02 UTC (rev 680)
@@ -317,8 +317,15 @@
# Catégorie Sex
PmfmId.SEX=196
+QualitativeValueId.SEX_MALE=300
+QualitativeValueId.SEX_FEMALE=301
+
# Catégorie classe de tri
PmfmId.SIZE_CATEGORY=198
+QualitativeValueId.SIZE_SMALL=307
+QualitativeValueId.SIZE_MEDIUM=306
+QualitativeValueId.SIZE_BIG=305
+
# Catégorie Age
PmfmId.AGE=1430
# Catégorie maturité
1
0
25 Mar '13
Author: tchemit
Date: 2013-03-25 20:08:05 +0100 (Mon, 25 Mar 2013)
New Revision: 679
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/679
Log:
fix properties files
Modified:
trunk/tutti-persistence/src/main/resources/tutti-db-conf.properties
Modified: trunk/tutti-persistence/src/main/resources/tutti-db-conf.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/tutti-db-conf.properties 2013-03-25 17:44:48 UTC (rev 678)
+++ trunk/tutti-persistence/src/main/resources/tutti-db-conf.properties 2013-03-25 19:08:05 UTC (rev 679)
@@ -47,5 +47,4 @@
hibernate.query.substitutions=true 1, false 0
hibernate.hbm2ddl.auto=none
hibernate.default_batch_fetch_size=1
-adagio.cache.use_tree_cache=true
-ehcache.disk.store.dir=c:/temp/ehcache
\ No newline at end of file
+adagio.cache.use_tree_cache=true
\ No newline at end of file
1
0
25 Mar '13
Author: tchemit
Date: 2013-03-25 18:44:48 +0100 (Mon, 25 Mar 2013)
New Revision: 678
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/678
Log:
fixes #1863: [BENTHOS] - Gestion de la saisie du benthos
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddBenthosProtocolAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolBenthosAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveBenthosProtocolAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherBenthosAction.java
Modified:
trunk/pom.xml
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceImpl.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocolsTest.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportServiceTest.java
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/TuttiDataContext.java
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/RenameBenthosBatchAction.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/protocol/AddSpeciesProtocolAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SaveProtocolAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
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/AbstractTuttiTableUIModel.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/pom.xml
===================================================================
--- trunk/pom.xml 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/pom.xml 2013-03-25 17:44:48 UTC (rev 678)
@@ -28,7 +28,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>3.4.8</version>
+ <version>3.4.9</version>
</parent>
<groupId>fr.ifremer</groupId>
@@ -120,8 +120,7 @@
<!-- libraries version -->
- <nuitonUtilsVersion>2.6.12-SNAPSHOT</nuitonUtilsVersion>
- <nuitonUpdaterVersion>2.6.12-SNAPSHOT</nuitonUpdaterVersion>
+ <nuitonUtilsVersion>2.6.12</nuitonUtilsVersion>
<nuitonI18nVersion>2.5</nuitonI18nVersion>
<eugenePluginVersion>2.6.1</eugenePluginVersion>
@@ -190,7 +189,7 @@
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-updater</artifactId>
- <version>${nuitonUpdaterVersion}</version>
+ <version>${nuitonUtilsVersion}</version>
</dependency>
<dependency>
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceImpl.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceImpl.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -133,6 +133,17 @@
}
result.setSpecies(species);
+ List<SpeciesProtocol> benthos= Lists.newArrayList();
+ if (!bean.isBenthosEmpty()) {
+ for (SpeciesProtocol speciesProtocol : bean.getBenthos()) {
+ SpeciesProtocol s = new SpeciesProtocol();
+ speciesProtocolBinder.copy(speciesProtocol, s);
+ s.setId(UUID.randomUUID().toString());
+ species.add(s);
+ }
+ }
+ result.setBenthos(benthos);
+
String id = result.getId();
File file = getProtocolFile(id);
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocolsTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocolsTest.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocolsTest.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -52,6 +52,28 @@
public static final String PROTOCOL_FILE_CONTENT =
"id: 1\n" +
"name: protocolName\n" +
+ "benthos: \n" +
+ "- !SpeciesProtocol\n" +
+ " id: 1\n" +
+ " calcifySampleEnabled: true\n" +
+ " lengthStepPmfmId: 1394\n" +
+ " maturityEnabled: true\n" +
+ " sexEnabled: true\n" +
+ " speciesReferenceTaxonId: 11242\n" +
+ " speciesSurveyCode: BAR\n" +
+ " weightEnabled: true\n" +
+ "- !SpeciesProtocol\n" +
+ " id: 2\n" +
+ " ageEnabled: true\n" +
+ " calcifySampleEnabled: true\n" +
+ " countIfNoFrequencyEnabled: true\n" +
+ " lengthStepPmfmId: 323\n" +
+ " maturityEnabled: true\n" +
+ " sexEnabled: true\n" +
+ " sizeEnabled: true\n" +
+ " speciesReferenceTaxonId: 3835\n" +
+ " speciesSurveyCode: CHIN\n" +
+ " weightEnabled: true\n" +
"comment: Commentaire\n" +
"gearUseFeaturePmfmId: \n" +
"- 21\n" +
@@ -137,6 +159,7 @@
Assert.assertEquals(Lists.newArrayList("14", "18"), protocol.getLengthClassesPmfmId());
Assert.assertEquals(Lists.newArrayList("114", "228", "821"), protocol.getVesselUseFeaturePmfmId());
Assert.assertEquals(Lists.newArrayList("21", "22"), protocol.getGearUseFeaturePmfmId());
+
Assert.assertNotNull(protocol.getSpecies());
Assert.assertEquals(2, protocol.getSpecies().size());
SpeciesProtocol sp1 = protocol.getSpecies().get(0);
@@ -166,6 +189,36 @@
Assert.assertTrue(sp2.isSexEnabled());
Assert.assertTrue(sp2.isSizeEnabled());
Assert.assertTrue(sp2.isWeightEnabled());
+
+ Assert.assertNotNull(protocol.getBenthos());
+ Assert.assertEquals(2, protocol.getBenthos().size());
+ SpeciesProtocol b1 = protocol.getBenthos().get(0);
+ Assert.assertNotNull(b1);
+ Assert.assertEquals("1", b1.getId());
+ Assert.assertEquals(11242, b1.getSpeciesReferenceTaxonId(), 0);
+ Assert.assertEquals("BAR", b1.getSpeciesSurveyCode());
+ Assert.assertEquals("1394", b1.getLengthStepPmfmId());
+ Assert.assertFalse(b1.isAgeEnabled());
+ Assert.assertTrue(b1.isCalcifySampleEnabled());
+ Assert.assertFalse(b1.isCountIfNoFrequencyEnabled());
+ Assert.assertTrue(b1.isMaturityEnabled());
+ Assert.assertTrue(b1.isSexEnabled());
+ Assert.assertFalse(b1.isSizeEnabled());
+ Assert.assertTrue(b1.isWeightEnabled());
+
+ SpeciesProtocol b2 = protocol.getBenthos().get(1);
+ Assert.assertNotNull(b2);
+ Assert.assertEquals("2", b2.getId());
+ Assert.assertEquals(3835, b2.getSpeciesReferenceTaxonId(), 0);
+ Assert.assertEquals("CHIN", b2.getSpeciesSurveyCode());
+ Assert.assertEquals("323", b2.getLengthStepPmfmId());
+ Assert.assertTrue(b2.isAgeEnabled());
+ Assert.assertTrue(b2.isCalcifySampleEnabled());
+ Assert.assertTrue(b2.isCountIfNoFrequencyEnabled());
+ Assert.assertTrue(b2.isMaturityEnabled());
+ Assert.assertTrue(b2.isSexEnabled());
+ Assert.assertTrue(b2.isSizeEnabled());
+ Assert.assertTrue(b2.isWeightEnabled());
}
private TuttiProtocol createProtocolFixture() {
@@ -202,6 +255,33 @@
sp2.setSizeEnabled(true);
sp2.setWeightEnabled(true);
protocol.addSpecies(sp2);
+
+ protocol.setBenthos(Lists.<SpeciesProtocol>newArrayList());
+ SpeciesProtocol b1 = new SpeciesProtocol();
+ b1.setId("1");
+ b1.setSpeciesReferenceTaxonId(11242);
+ b1.setSpeciesSurveyCode("BAR");
+ b1.setLengthStepPmfmId("1394");
+ b1.setCalcifySampleEnabled(true);
+ b1.setMaturityEnabled(true);
+ b1.setSexEnabled(true);
+ b1.setWeightEnabled(true);
+ protocol.addBenthos(b1);
+
+ SpeciesProtocol b2 = new SpeciesProtocol();
+ b2.setId("2");
+ b2.setSpeciesReferenceTaxonId(3835);
+ b2.setSpeciesSurveyCode("CHIN");
+ b2.setLengthStepPmfmId("323");
+ b2.setAgeEnabled(true);
+ b2.setCalcifySampleEnabled(true);
+ b2.setCountIfNoFrequencyEnabled(true);
+ b2.setMaturityEnabled(true);
+ b2.setSexEnabled(true);
+ b2.setSizeEnabled(true);
+ b2.setWeightEnabled(true);
+ protocol.addBenthos(b2);
+
return protocol;
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -272,6 +272,73 @@
protocol.setSpecies(values);
}
+ public void importProtocolBenthos(File file,
+ TuttiProtocol protocol,
+ Map<String, Caracteristic> caracteristicMap,
+ Map<String, Species> speciesMap) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Will import protocol [" + protocol.getName() +
+ "] species from file: " + file);
+ }
+
+ Map<Integer, SpeciesProtocol> ids = Maps.newLinkedHashMap();
+
+ if (!protocol.isBenthosEmpty()) {
+
+ // get existing species (will be replaced if required)
+
+ for (SpeciesProtocol speciesProtocol : protocol.getBenthos()) {
+ ids.put(speciesProtocol.getSpeciesReferenceTaxonId(), speciesProtocol);
+ }
+
+ }
+ SpeciesRowModel csvModel = new SpeciesRowModel(getCsvSeparator(),
+ caracteristicMap,
+ speciesMap);
+
+ Reader reader = null;
+ try {
+ reader = Files.newReader(file, Charsets.UTF_8);
+
+ Import<SpeciesRow> importer = Import.newImport(csvModel, reader);
+
+ try {
+
+ Binder<SpeciesRow, SpeciesProtocol> binder =
+ BinderFactory.newBinder(SpeciesRow.class,
+ SpeciesProtocol.class);
+
+ for (SpeciesRow bean : importer) {
+
+ Species species = bean.getSpecies();
+ Integer id = species.getReferenceTaxonId();
+
+ SpeciesProtocol sp = ids.get(id);
+ if (sp == null) {
+
+ // create a new species protocol
+ sp = new SpeciesProtocol();
+ }
+ binder.copy(bean, sp);
+
+ ids.put(id, sp);
+ }
+ importer.close();
+ } finally {
+ IOUtils.closeQuietly(importer);
+ }
+ reader.close();
+ } catch (Exception e) {
+ throw new TuttiTechnicalException("Could not import protocol [" + protocol.getName() + "] caracteristic from file " + file, e);
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+
+ List<SpeciesProtocol> values = Lists.newArrayList(ids.values());
+ protocol.setBenthos(values);
+ }
+
public void exportProtocolSpecies(File file,
List<SpeciesProtocol> protocol,
Map<String, Caracteristic> caracteristicMap,
@@ -306,6 +373,40 @@
}
}
+ public void exportProtocolBenthos(File file,
+ List<SpeciesProtocol> protocol,
+ Map<String, Caracteristic> caracteristicMap,
+ Map<String, Species> speciesMap) {
+ if (log.isInfoEnabled()) {
+ log.info("Will export benthos to file: " + file);
+ }
+
+ List<SpeciesRow> rows = Lists.newArrayList();
+
+ if (CollectionUtils.isNotEmpty(protocol)) {
+ rows = Lists.transform(protocol, new SpeciesProtocolToSpeciesRowFunction(
+ caracteristicMap,
+ speciesMap));
+ }
+
+ SpeciesRowModel csvModel =
+ new SpeciesRowModel(getCsvSeparator(),
+ caracteristicMap,
+ speciesMap);
+
+ BufferedWriter writer = null;
+ try {
+ writer = Files.newWriter(file, Charsets.UTF_8);
+ Export export = Export.newExport(csvModel, rows);
+ export.write(writer);
+ writer.close();
+ } catch (Exception e) {
+ throw new TuttiTechnicalException("Could not export species protocol to file " + file, e);
+ } finally {
+ IOUtils.closeQuietly(writer);
+ }
+ }
+
protected char getCsvSeparator() {
return context.getConfig().getCsvSeparator();
}
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportServiceTest.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportServiceTest.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -60,6 +60,25 @@
public static final String PROTOCOL_FILE_CONTENT =
"id: 1\n" +
"name: protocolName\n" +
+ "benthos: \n" +
+ "- !SpeciesProtocol\n" +
+ " calcifySampleEnabled: true\n" +
+ " lengthStepPmfmId: 1394\n" +
+ " maturityEnabled: true\n" +
+ " sexEnabled: true\n" +
+ " speciesReferenceTaxonId: 11242\n" +
+ " speciesSurveyCode: cruiseCode1\n" +
+ " weightEnabled: true\n" +
+ "- !SpeciesProtocol\n" +
+ " ageEnabled: true\n" +
+ " calcifySampleEnabled: true\n" +
+ " countIfNoFrequencyEnabled: true\n" +
+ " lengthStepPmfmId: 323\n" +
+ " maturityEnabled: true\n" +
+ " sexEnabled: true\n" +
+ " sizeEnabled: true\n" +
+ " speciesReferenceTaxonId: 3835\n" +
+ " weightEnabled: true\n" +
"comment: Commentaire\n" +
"gearUseFeaturePmfmId: \n" +
"- 21\n" +
@@ -110,6 +129,11 @@
"1;speciesRefTaxCode1;speciesName1;cruiseCode1;2;parameterName2;matrixName2;fractionName2;methodName2;Y;Y;Y;Y;Y;Y;Y;\n" +
"2;speciesRefTaxCode2;speciesName2;;;;;;;N;Y;N;Y;Y;Y;Y;";
+ public static final String PROTOCOL_BENTHOS_FILE_CONTENT =
+ "speciesReferenceTaxonId;speciesRefTaxCode;speciesName;speciesSurveyCode;lengthStepPmfmId;lengthStepPmfmParameterName;lengthStepPmfmMatrixName;lengthStepPmfmFractionName;lengthStepPmfmMethodName;sizeEnabled;sexEnabled;maturityEnabled;ageEnabled;weightEnabled;countIfNoFrequencyEnabled;calcifySampleEnabled\n" +
+ "1;speciesRefTaxCode1;speciesName1;cruiseCode1;2;parameterName2;matrixName2;fractionName2;methodName2;Y;Y;Y;Y;Y;Y;Y;\n" +
+ "2;speciesRefTaxCode2;speciesName2;;;;;;;N;Y;N;Y;Y;Y;Y;";
+
@Before
public void setUp() throws Exception {
datadirectory = FileUtil.getTestSpecificDirectory(getClass(),
@@ -164,6 +188,29 @@
sp2.setWeightEnabled(true);
protocol.addSpecies(sp2);
+ protocol.setBenthos(Lists.<SpeciesProtocol>newArrayList());
+ SpeciesProtocol b1 = new SpeciesProtocol();
+ b1.setSpeciesReferenceTaxonId(11242);
+ b1.setSpeciesSurveyCode("cruiseCode1");
+ b1.setLengthStepPmfmId("1394");
+ b1.setCalcifySampleEnabled(true);
+ b1.setMaturityEnabled(true);
+ b1.setSexEnabled(true);
+ b1.setWeightEnabled(true);
+ protocol.addBenthos(b1);
+
+ SpeciesProtocol b2 = new SpeciesProtocol();
+ b2.setSpeciesReferenceTaxonId(3835);
+ b2.setLengthStepPmfmId("323");
+ b2.setAgeEnabled(true);
+ b2.setCalcifySampleEnabled(true);
+ b2.setCountIfNoFrequencyEnabled(true);
+ b2.setMaturityEnabled(true);
+ b2.setSexEnabled(true);
+ b2.setSizeEnabled(true);
+ b2.setWeightEnabled(true);
+ protocol.addBenthos(b2);
+
service.exportProtocol(protocol, exportFile);
Assert.assertTrue(exportFile.exists());
@@ -189,9 +236,10 @@
Assert.assertEquals(Lists.newArrayList("14", "18"), protocol.getLengthClassesPmfmId());
Assert.assertEquals(Lists.newArrayList("114", "228", "821"), protocol.getVesselUseFeaturePmfmId());
Assert.assertEquals(Lists.newArrayList("21", "22"), protocol.getGearUseFeaturePmfmId());
+
Assert.assertNotNull(protocol.getSpecies());
- Assert.assertEquals(2, protocol.getSpecies().size());
- SpeciesProtocol sp1 = protocol.getSpecies().get(0);
+ Assert.assertEquals(2, protocol.sizeSpecies());
+ SpeciesProtocol sp1 = protocol.getSpecies(0);
Assert.assertNotNull(sp1);
Assert.assertEquals(11242, sp1.getSpeciesReferenceTaxonId(), 0);
Assert.assertEquals("cruiseCode1", sp1.getSpeciesSurveyCode());
@@ -204,7 +252,7 @@
Assert.assertFalse(sp1.isSizeEnabled());
Assert.assertTrue(sp1.isWeightEnabled());
- SpeciesProtocol sp2 = protocol.getSpecies().get(1);
+ SpeciesProtocol sp2 = protocol.getSpecies(1);
Assert.assertNotNull(sp2);
Assert.assertEquals(3835, sp2.getSpeciesReferenceTaxonId(), 0);
Assert.assertEquals("323", sp2.getLengthStepPmfmId());
@@ -215,6 +263,33 @@
Assert.assertTrue(sp2.isSexEnabled());
Assert.assertTrue(sp2.isSizeEnabled());
Assert.assertTrue(sp2.isWeightEnabled());
+
+ Assert.assertNotNull(protocol.getBenthos());
+ Assert.assertEquals(2, protocol.sizeBenthos());
+ SpeciesProtocol b1 = protocol.getBenthos(0);
+ Assert.assertNotNull(b1);
+ Assert.assertEquals(11242, b1.getSpeciesReferenceTaxonId(), 0);
+ Assert.assertEquals("cruiseCode1", b1.getSpeciesSurveyCode());
+ Assert.assertEquals("1394", b1.getLengthStepPmfmId());
+ Assert.assertFalse(b1.isAgeEnabled());
+ Assert.assertTrue(b1.isCalcifySampleEnabled());
+ Assert.assertFalse(b1.isCountIfNoFrequencyEnabled());
+ Assert.assertTrue(b1.isMaturityEnabled());
+ Assert.assertTrue(b1.isSexEnabled());
+ Assert.assertFalse(b1.isSizeEnabled());
+ Assert.assertTrue(b1.isWeightEnabled());
+
+ SpeciesProtocol b2 = protocol.getBenthos(1);
+ Assert.assertNotNull(b2);
+ Assert.assertEquals(3835, b2.getSpeciesReferenceTaxonId(), 0);
+ Assert.assertEquals("323", b2.getLengthStepPmfmId());
+ Assert.assertTrue(b2.isAgeEnabled());
+ Assert.assertTrue(b2.isCalcifySampleEnabled());
+ Assert.assertTrue(b2.isCountIfNoFrequencyEnabled());
+ Assert.assertTrue(b2.isMaturityEnabled());
+ Assert.assertTrue(b2.isSexEnabled());
+ Assert.assertTrue(b2.isSizeEnabled());
+ Assert.assertTrue(b2.isWeightEnabled());
}
@Test
@@ -382,6 +457,104 @@
Assert.assertEquals(PROTOCOL_SPECIES_FILE_CONTENT, exportFileToString);
}
+ @Test
+ public void importProtocolBenthos() throws Exception {
+
+ File file = new File(datadirectory, "importProtocolBenthos.csv");
+
+ Files.createParentDirs(file);
+
+ Files.write(PROTOCOL_BENTHOS_FILE_CONTENT, file, Charsets.UTF_8);
+
+ TuttiProtocol protocol = new TuttiProtocol();
+ Map<String, Species> speciesMap = createSpecies();
+ Map<String, Caracteristic> caracteristicMap = createCaracteristics();
+
+ service.importProtocolBenthos(file,
+ protocol,
+ caracteristicMap,
+ speciesMap);
+
+ Assert.assertEquals(2, protocol.sizeBenthos());
+
+ SpeciesProtocol sp1 = protocol.getBenthos(0);
+ Assert.assertNotNull(sp1);
+ Assert.assertEquals(1, sp1.getSpeciesReferenceTaxonId(), 0);
+ Assert.assertEquals("cruiseCode1", sp1.getSpeciesSurveyCode());
+ Assert.assertEquals("2", sp1.getLengthStepPmfmId());
+ Assert.assertTrue(sp1.isAgeEnabled());
+ Assert.assertTrue(sp1.isCalcifySampleEnabled());
+ Assert.assertTrue(sp1.isCountIfNoFrequencyEnabled());
+ Assert.assertTrue(sp1.isMaturityEnabled());
+ Assert.assertTrue(sp1.isSexEnabled());
+ Assert.assertTrue(sp1.isSizeEnabled());
+ Assert.assertTrue(sp1.isWeightEnabled());
+
+ SpeciesProtocol sp2 = protocol.getBenthos(1);
+ Assert.assertNotNull(sp2);
+ Assert.assertEquals(2, sp2.getSpeciesReferenceTaxonId(), 0);
+ Assert.assertNull(sp2.getSpeciesSurveyCode());
+ Assert.assertNull(sp2.getLengthStepPmfmId());
+ Assert.assertTrue(sp2.isAgeEnabled());
+ Assert.assertTrue(sp2.isCalcifySampleEnabled());
+ Assert.assertTrue(sp2.isCountIfNoFrequencyEnabled());
+ Assert.assertFalse(sp2.isMaturityEnabled());
+ Assert.assertTrue(sp2.isSexEnabled());
+ Assert.assertFalse(sp2.isSizeEnabled());
+ Assert.assertTrue(sp2.isWeightEnabled());
+ }
+
+ @Test
+ public void exportProtocolBenthos() throws Exception {
+
+ File file = new File(datadirectory, "exportProtocolBenthos.csv");
+
+ Files.createParentDirs(file);
+
+ Map<String, Species> speciesMap = createSpecies();
+
+ TuttiProtocol protocol = new TuttiProtocol();
+ protocol.setBenthos(Lists.<SpeciesProtocol>newArrayList());
+
+ SpeciesProtocol sp1 = new SpeciesProtocol();
+ sp1.setSpeciesReferenceTaxonId(1);
+ sp1.setSpeciesSurveyCode("cruiseCode1");
+ sp1.setAgeEnabled(true);
+ sp1.setSizeEnabled(true);
+ sp1.setMaturityEnabled(true);
+ sp1.setSexEnabled(true);
+ sp1.setWeightEnabled(true);
+ sp1.setCountIfNoFrequencyEnabled(true);
+ sp1.setCalcifySampleEnabled(true);
+ sp1.setLengthStepPmfmId("2");
+
+ protocol.addBenthos(sp1);
+
+ SpeciesProtocol sp2 = new SpeciesProtocol();
+ sp2.setSpeciesReferenceTaxonId(2);
+ sp2.setAgeEnabled(true);
+ sp1.setSizeEnabled(true);
+ sp1.setMaturityEnabled(true);
+ sp2.setSexEnabled(true);
+ sp2.setWeightEnabled(true);
+ sp2.setCalcifySampleEnabled(true);
+ sp2.setCountIfNoFrequencyEnabled(true);
+ sp2.setLengthStepPmfmId(null);
+
+ protocol.addBenthos(sp2);
+
+ Assert.assertFalse(file.exists());
+ service.exportProtocolBenthos(file,
+ protocol.getBenthos(),
+ createCaracteristics(),
+ speciesMap);
+
+ Assert.assertTrue(file.exists());
+
+ String exportFileToString = Files.toString(file, Charsets.UTF_8).trim();
+ Assert.assertEquals(PROTOCOL_BENTHOS_FILE_CONTENT, exportFileToString);
+ }
+
protected Map<String, Caracteristic> createCaracteristics() {
Map<String, Caracteristic> result = Maps.newTreeMap();
for (int i = 1; i < 6; i++) {
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-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-03-25 17:44:48 UTC (rev 678)
@@ -22,7 +22,7 @@
# #L%
###
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Sat Mar 23 16:49:12 CET 2013
+#Mon Mar 25 16:24:40 CET 2013
tutti.createBenthosBatch.action.addSpecies.help=
tutti.createBenthosBatch.action.cancel.help=
tutti.createBenthosBatch.action.save.help=
@@ -144,16 +144,22 @@
tutti.editProgram.field.name.help=editProgram.html\#fields
tutti.editProgram.field.zone.help=editProgram.html\#fields
tutti.editProgram.help=editProgram.html
+tutti.editProtocol.action.addBenthosProtocol.help=
tutti.editProtocol.action.addSpeciesProtocol.help=editProtocol.html\#actions
tutti.editProtocol.action.closeEditProtocol.help=editProtocol.html\#actions
tutti.editProtocol.action.exportProtocolAllCaracteristic.help=editProtocol.html\#actions
+tutti.editProtocol.action.exportProtocolBenthos.help=
tutti.editProtocol.action.exportProtocolCaracteristic.tip=editProtocol.html\#actions
tutti.editProtocol.action.exportProtocolSpecies.help=editProtocol.html\#actions
+tutti.editProtocol.action.importProtocolBenthos.help=
tutti.editProtocol.action.importProtocolCaracteristic.help=editProtocol.html\#actions
tutti.editProtocol.action.importProtocolSpecies.help=editProtocol.html\#actions
+tutti.editProtocol.action.removeBenthosProtocol.help=
tutti.editProtocol.action.removeSpeciesProtocol.help=editProtocol.html\#actions
tutti.editProtocol.action.saveProtocol.help=editProtocol.html\#actions
+tutti.editProtocol.action.selectOtherBenthos.help=
tutti.editProtocol.action.selectOtherSpecies.help=editProtocol.html\#actions
+tutti.editProtocol.field.benthos.help=
tutti.editProtocol.field.comment.help=editProtocol.html\#fields
tutti.editProtocol.field.gearUseFeature.help=editProtocol.html\#fields
tutti.editProtocol.field.lengthClasses.help=editProtocol.html\#fields
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-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-03-25 17:44:48 UTC (rev 678)
@@ -22,7 +22,7 @@
# #L%
###
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Sat Mar 23 16:49:12 CET 2013
+#Mon Mar 25 16:24:40 CET 2013
tutti.createBenthosBatch.action.addSpecies.help=createBenthosBatch.html\#actions
tutti.createBenthosBatch.action.cancel.help=createBenthosBatch.html\#actions
tutti.createBenthosBatch.action.save.help=createBenthosBatch.html\#actions
@@ -153,16 +153,22 @@
tutti.editProgram.field.name.help=editProgram.html\#fields
tutti.editProgram.field.zone.help=editProgram.html\#fields
tutti.editProgram.help=editProgram.html
+tutti.editProtocol.action.addBenthosProtocol.help=
tutti.editProtocol.action.addSpeciesProtocol.help=editProtocol.html\#actions
tutti.editProtocol.action.closeEditProtocol.help=editProtocol.html\#actions
tutti.editProtocol.action.exportProtocolAllCaracteristic.help=editProtocol.html\#actions
+tutti.editProtocol.action.exportProtocolBenthos.help=
tutti.editProtocol.action.exportProtocolCaracteristic.tip=editProtocol.html\#actions
tutti.editProtocol.action.exportProtocolSpecies.help=editProtocol.html\#actions
+tutti.editProtocol.action.importProtocolBenthos.help=
tutti.editProtocol.action.importProtocolCaracteristic.help=editProtocol.html\#actions
tutti.editProtocol.action.importProtocolSpecies.help=editProtocol.html\#actions
+tutti.editProtocol.action.removeBenthosProtocol.help=
tutti.editProtocol.action.removeSpeciesProtocol.help=editProtocol.html\#actions
tutti.editProtocol.action.saveProtocol.help=editProtocol.html\#actions
+tutti.editProtocol.action.selectOtherBenthos.help=
tutti.editProtocol.action.selectOtherSpecies.help=editProtocol.html\#actions
+tutti.editProtocol.field.benthos.help=
tutti.editProtocol.field.comment.help=editProtocol.html\#fields
tutti.editProtocol.field.gearUseFeature.help=editProtocol.html\#fields
tutti.editProtocol.field.lengthClasses.help=editProtocol.html\#fields
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDataContext.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDataContext.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDataContext.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -57,9 +57,7 @@
*/
public class TuttiDataContext implements Closeable {
- /**
- * Logger.
- */
+ /** Logger. */
private static final Log log = LogFactory.getLog(TuttiDataContext.class);
protected Program program;
@@ -78,6 +76,8 @@
protected List<Species> referentSpeciesWithSurveyCode;
+ protected List<Species> referentBenthosWithSurveyCode;
+
protected List<Species> referentSpecies;
protected List<Vessel> fishingVessels;
@@ -204,10 +204,9 @@
TuttiProtocol protocol = getProtocol();
Preconditions.checkNotNull(protocol,
- "Could not find protocol in ui context");
+ "Could not find protocol in ui context");
// fill available species from protocol
-
referentSpeciesWithSurveyCode = Lists.newArrayList();
if (!protocol.isSpeciesEmpty()) {
@@ -225,15 +224,52 @@
} else {
// no protocol, use default values
-
referentSpeciesWithSurveyCode = Lists.newArrayList(getReferentSpecies());
+ }
- }
referentSpeciesWithSurveyCode = Collections.unmodifiableList(referentSpeciesWithSurveyCode);
}
return referentSpeciesWithSurveyCode;
}
+ public List<Species> getReferentBenthosWithSurveyCode() {
+ if (referentBenthosWithSurveyCode == null) {
+
+ if (uiContext.isProtocolFilled()) {
+
+ // get loaded protocol
+
+ TuttiProtocol protocol = getProtocol();
+ Preconditions.checkNotNull(protocol,
+ "Could not find protocol in ui context");
+
+ // fill available species from protocol
+
+ referentBenthosWithSurveyCode = Lists.newArrayList();
+ if (!protocol.isBenthosEmpty()) {
+
+ // split by taxonId
+ Map<String, Species> map = TuttiEntities.splitByTaxonId(getReferentSpecies());
+
+ for (SpeciesProtocol protocolSpecy : protocol.getBenthos()) {
+ String taxonId = String.valueOf(protocolSpecy.getSpeciesReferenceTaxonId());
+ Species species = map.get(taxonId);
+ species.setSurveyCode(protocolSpecy.getSpeciesSurveyCode());
+ referentBenthosWithSurveyCode.add(species);
+ }
+ }
+
+ } else {
+
+ // no protocol, use default values
+ referentBenthosWithSurveyCode = Lists.newArrayList(getReferentSpecies());
+ }
+
+ referentBenthosWithSurveyCode = Collections.unmodifiableList(referentBenthosWithSurveyCode);
+ }
+ return referentBenthosWithSurveyCode;
+ }
+
public List<Species> getSpecies() {
if (species == null) {
if (log.isInfoEnabled()) {
@@ -349,6 +385,7 @@
species = null;
referentSpecies = null;
referentSpeciesWithSurveyCode = null;
+ referentBenthosWithSurveyCode = null;
}
public void resetCaracteristics() {
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-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -968,7 +968,7 @@
// the species of the parent is set to the children in loadBatchRow
if (parentRow == null && context.isProtocolFilled()) {
// get the surveycode from the species list of the model
- List<Species> speciesList = getDataContext().getReferentSpeciesWithSurveyCode();
+ List<Species> speciesList = getDataContext().getReferentBenthosWithSurveyCode();
int i = speciesList.indexOf(newRow.getSpecies());
if (i > -1) {
newRow.setSpecies(speciesList.get(i));
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RenameBenthosBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RenameBenthosBatchAction.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RenameBenthosBatchAction.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -59,7 +59,8 @@
BenthosBatchRowModel row = tableModel.getEntry(table.getSelectedRow());
BenthosBatchUIModel model = handler.getModel();
- List<Species> speciesList = Lists.newArrayList(getDataContext().getReferentSpeciesWithSurveyCode());
+ List<Species> speciesList = Lists.newArrayList(
+ getDataContext().getReferentBenthosWithSurveyCode());
speciesList.removeAll(
model.getSpeciesUsed().get(
row.getSortedUnsortedCategoryValue()));
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-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -208,7 +208,8 @@
// compute which species can still be used
- List<Species> allSpecies = getDataContext().getReferentSpeciesWithSurveyCode();
+ List<Species> allSpecies =
+ getDataContext().getReferentBenthosWithSurveyCode();
speciesToUse.addAll(allSpecies);
}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddBenthosProtocolAction.java (from rev 677, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddBenthosProtocolAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddBenthosProtocolAction.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -0,0 +1,89 @@
+package fr.ifremer.tutti.ui.swing.content.protocol;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 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.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
+
+import java.util.Collection;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To add a new benthos protocol.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class AddBenthosProtocolAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ public AddBenthosProtocolAction(EditProtocolUIHandler handler) {
+ super(handler, false);
+ }
+
+ protected Species species;
+
+ @Override
+ protected void doAction() throws Exception {
+
+ species = null;
+
+ EditProtocolUI ui = getUI();
+
+ EditProtocolSpeciesTableModel tableModel = handler.getBenthosTableModel();
+ BeanFilterableComboBox<Species> benthosComboBox = ui.getBenthosComboBox();
+
+ species = (Species) benthosComboBox.getSelectedItem();
+ Preconditions.checkNotNull(
+ species, "Can't add a benthosProtocol with a null species");
+ Preconditions.checkArgument(species.isReferenceTaxon(),
+ "Can't add a benthosProtocol with a not referent species");
+
+ Integer taxonId = species.getReferenceTaxonId();
+ String taxonIdStr = String.valueOf(taxonId);
+
+ // remove all synonyms of this taxon
+ Collection<Species> allSynonyms = getModel().getAllSynonyms(taxonIdStr);
+ getModel().getAllSynonyms().removeAll(allSynonyms);
+
+ benthosComboBox.removeItem(species);
+ ui.getSpeciesComboBox().removeItem(species);
+
+ // add new row to model (do it after combo stuff for ui best display)
+ EditProtocolSpeciesRowModel protocol = tableModel.createNewRow();
+ protocol.setSpecies(species);
+ tableModel.addNewRow(protocol);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ String speciesStr = decorate(species);
+ sendMessage(_("tutti.flash.info.benthos.add.to.protocol",
+ speciesStr));
+ }
+}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -27,6 +27,8 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
+
import java.util.Collection;
import static org.nuiton.i18n.I18n._;
@@ -43,13 +45,17 @@
super(handler, false);
}
+ protected Species species;
+
@Override
protected void doAction() throws Exception {
EditProtocolUI ui = getUI();
- EditProtocolSpeciesTableModel tableModel = handler.getTableModel();
- Species species = (Species) ui.getSpeciesComboBox().getSelectedItem();
+ EditProtocolSpeciesTableModel tableModel = handler.getSpeciesTableModel();
+ BeanFilterableComboBox<Species> speciesComboBox = ui.getSpeciesComboBox();
+
+ species = (Species) speciesComboBox.getSelectedItem();
Preconditions.checkNotNull(
species, "Can't add a speciesProtocol with a null species");
Preconditions.checkArgument(species.isReferenceTaxon(),
@@ -62,19 +68,20 @@
Collection<Species> allSynonyms = getModel().getAllSynonyms(taxonIdStr);
getModel().getAllSynonyms().removeAll(allSynonyms);
- ui.getSpeciesComboBox().getHandler().removeItem(species);
+ speciesComboBox.getHandler().removeItem(species);
+ ui.getBenthosComboBox().removeItem(species);
// add new row to model (do it after combo stuff for ui best display)
EditProtocolSpeciesRowModel protocol = tableModel.createNewRow();
protocol.setSpecies(species);
tableModel.addNewRow(protocol);
+ }
- getModel().setModify(true);
-
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
String speciesStr = decorate(species);
sendMessage(_("tutti.flash.info.species.add.to.protocol",
speciesStr));
-
}
-
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -94,8 +94,7 @@
setNoneEditableCols(SPECIES_ID);
}
- @Override
- public EditProtocolSpeciesRowModel createNewRow() {
+ public static EditProtocolSpeciesRowModel newRow() {
EditProtocolSpeciesRowModel result = new EditProtocolSpeciesRowModel();
result.setMaturityEnabled(true);
result.setSizeEnabled(true);
@@ -108,4 +107,20 @@
return result;
}
+ @Override
+ public EditProtocolSpeciesRowModel createNewRow() {
+ EditProtocolSpeciesRowModel result = newRow();
+ return result;
+ }
+
+ @Override
+ protected void setValueAt(Object aValue,
+ int rowIndex,
+ int columnIndex,
+ ColumnIdentifier<EditProtocolSpeciesRowModel> propertyName,
+ EditProtocolSpeciesRowModel entry) {
+ super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
+ fireTableCellUpdated(rowIndex, columnIndex);
+ }
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-03-25 17:44:48 UTC (rev 678)
@@ -58,7 +58,7 @@
}
#commentPane {
- border: {BorderFactory.createTitledBorder(_("tutti.editProgram.field.description"))};
+ border: {BorderFactory.createTitledBorder(_("tutti.editProtocol.field.comment"))};
toolTipText: "tutti.editProtocol.field.comment.tip";
_help: {"tutti.editProtocol.field.comment.help"};
}
@@ -84,7 +84,7 @@
_help: {"tutti.editProtocol.field.species.help"};
}
-#tablePopup {
+#speciesTablePopup {
label: "tutti.editProtocol.title.batchActions";
}
@@ -96,6 +96,24 @@
_help: {"tutti.editProtocol.field.species.help"};
}
+#benthosComboBox {
+ enabled: {!benthosComboBox.isEmpty()};
+ toolTipText: "tutti.editProtocol.field.benthos.tip";
+ _help: {"tutti.editProtocol.field.benthos.help"};
+}
+
+#benthosTablePopup {
+ label: "tutti.editProtocol.title.batchActions";
+}
+
+#benthosTable {
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+ _help: {"tutti.editProtocol.field.benthos.help"};
+}
+
#caracteristicPane {
tabPlacement: {JTabbedPane.LEFT};
_help: {"tutti.editProtocol.pane.caracteristic.help"};
@@ -183,6 +201,51 @@
_help: {"tutti.editProtocol.action.exportProtocolSpecies.help"};
}
+#selectOtherBenthosButton {
+ text: "tutti.editProtocol.action.selectOtherBenthos";
+ toolTipText: "tutti.editProtocol.action.selectOtherBenthos.tip";
+ i18nMnemonic: "tutti.editProtocol.action.selectOtherBenthos.mnemonic";
+ _tuttiAction: {SelectOtherBenthosAction.class};
+ _help: {"tutti.editProtocol.action.selectOtherBenthos.help"};
+}
+
+#addBenthosProtocolButton {
+ actionIcon: add;
+ toolTipText: "tutti.editProtocol.action.addBenthosProtocol.tip";
+ i18nMnemonic: "tutti.editProtocol.action.addBenthosProtocol.mnemonic";
+ _tuttiAction: {AddBenthosProtocolAction.class};
+ enabled: {benthosComboBox.getSelectedItem() != null};
+ _help: {"tutti.editProtocol.action.addBenthosProtocol.help"};
+}
+
+#removeBenthosProtocolButton {
+ actionIcon: batch-delete;
+ text: "tutti.editProtocol.action.removeBenthosProtocol";
+ toolTipText: "tutti.editProtocol.action.removeBenthosProtocol.tip";
+ i18nMnemonic: "tutti.editProtocol.action.removeBenthosProtocol.mnemonic";
+ _tuttiAction: {RemoveBenthosProtocolAction.class};
+ enabled: {model.isRemoveBenthosEnabled()};
+ _help: {"tutti.editProtocol.action.removeBenthosProtocol.help"};
+}
+
+#importBenthosButton {
+ actionIcon: import;
+ text: "tutti.editProtocol.action.importProtocolBenthos";
+ toolTipText: "tutti.editProtocol.action.importProtocolBenthos.tip";
+ i18nMnemonic: "tutti.editProtocol.action.importProtocolBenthos.mnemonic";
+ _tuttiAction: {ImportProtocolBenthosAction.class};
+ _help: {"tutti.editProtocol.action.importProtocolBenthos.help"};
+}
+
+#exportBenthosButton {
+ actionIcon: export;
+ text: "tutti.editProtocol.action.exportProtocolBenthos";
+ toolTipText: "tutti.editProtocol.action.exportProtocolBenthos.tip";
+ i18nMnemonic: "tutti.editProtocol.action.exportProtocolBenthos.mnemonic";
+ _tuttiAction: {ExportProtocolBenthosAction.class};
+ _help: {"tutti.editProtocol.action.exportProtocolBenthos.help"};
+}
+
#importCaracteristicButton {
actionIcon: import;
text: "tutti.editProtocol.action.importProtocolCaracteristic";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2013-03-25 17:44:48 UTC (rev 678)
@@ -29,13 +29,11 @@
fr.ifremer.tutti.persistence.entities.referential.Species
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
- fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.util.TuttiUI
jaxx.runtime.swing.editor.bean.BeanFilterableComboBox
jaxx.runtime.swing.editor.bean.BeanDoubleList
- java.awt.Dimension
java.awt.Color
javax.swing.ListSelectionModel
@@ -76,10 +74,14 @@
<field name='comment' component='commentPane'/>
</BeanValidator>
- <JPopupMenu id='tablePopup'>
+ <JPopupMenu id='speciesTablePopup'>
<JMenuItem id='removeSpeciesProtocolButton'/>
</JPopupMenu>
+ <JPopupMenu id='benthosTablePopup'>
+ <JMenuItem id='removeBenthosProtocolButton'/>
+ </JPopupMenu>
+
<JTabbedPane constraints='BorderLayout.CENTER'>
<tab title='tutti.editProtocol.tab.info'>
<Table id='protocolInfoForm' fill='both'>
@@ -160,15 +162,46 @@
<cell fill='both' columns='3'>
<JScrollPane>
<JXTable id='speciesTable'
- onMouseClicked='handler.autoSelectRowInTable(event, tablePopup)'/>
+ onMouseClicked='handler.autoSelectRowInTable(event, speciesTablePopup)'/>
</JScrollPane>
</cell>
</row>
</Table>
</JPanel>
</tab>
- <tab title='tutti.editProtocol.tab.benthos' enabled='false'>
- <JLabel text='tutti.to.be.done' horizontalAlignment="{JLabel.CENTER}"/>
+ <tab title='tutti.editProtocol.tab.benthos'>
+ <JPanel id='benthosPanel' layout="{new BorderLayout()}">
+ <JPanel id='benthosActions' layout="{new GridLayout()}"
+ constraints='BorderLayout.NORTH'>
+ <JButton id='importBenthosButton'/>
+ <JButton id='exportBenthosButton'/>
+ </JPanel>
+
+ <Table fill='both' constraints='BorderLayout.CENTER'>
+
+ <row fill='both'>
+ <cell fill='both' weightx='1'>
+ <BeanFilterableComboBox id='benthosComboBox'
+ constructorParams='this'
+ genericType='Species'/>
+ </cell>
+ <cell fill='both'>
+ <JButton id='selectOtherBenthosButton'/>
+ </cell>
+ <cell fill='both'>
+ <JButton id='addBenthosProtocolButton'/>
+ </cell>
+ </row>
+ <row fill='both' weighty='1'>
+ <cell fill='both' columns='3'>
+ <JScrollPane>
+ <JXTable id='benthosTable'
+ onMouseClicked='handler.autoSelectRowInTable(event, benthosTablePopup)'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
</tab>
<tab title='tutti.editProtocol.tab.plankton' enabled='false'>
<JLabel text='tutti.to.be.done' horizontalAlignment="{JLabel.CENTER}"/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -33,17 +33,19 @@
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.content.home.CloneProtocolAction;
import fr.ifremer.tutti.ui.swing.content.home.ImportProtocolAction;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+import fr.ifremer.tutti.ui.swing.util.CloseableUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUI;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUIModel;
-import fr.ifremer.tutti.ui.swing.util.CloseableUI;
-import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
-import fr.ifremer.tutti.ui.swing.util.TuttiUI;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.editor.bean.BeanDoubleList;
import jaxx.runtime.swing.editor.bean.BeanDoubleListModel;
+import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
import jaxx.runtime.swing.editor.bean.BeanUIUtil;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
@@ -52,21 +54,29 @@
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;
import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
import javax.swing.JComboBox;
import javax.swing.JTabbedPane;
+import javax.swing.ListSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
import javax.swing.table.TableColumnModel;
+import java.awt.Component;
import java.awt.Dimension;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Collection;
import java.util.List;
import java.util.Map;
-import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
import static org.nuiton.i18n.I18n._;
@@ -75,7 +85,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.3
*/
-public class EditProtocolUIHandler extends AbstractTuttiTableUIHandler<EditProtocolSpeciesRowModel, EditProtocolUIModel, EditProtocolUI> implements CloseableUI {
+public class EditProtocolUIHandler extends AbstractTuttiUIHandler<EditProtocolUIModel, EditProtocolUI> implements CloseableUI {
/** Logger. */
private static final Log log =
@@ -94,62 +104,75 @@
protected SelectSpeciesUI dialog;
+ /**
+ * Persistence service.
+ *
+ * @since 0.2
+ */
+ protected final PersistenceService persistenceService;
+
public EditProtocolUIHandler(TuttiUI parentUi, EditProtocolUI ui) {
super(parentUi.getHandler().getContext(), ui);
+ this.persistenceService = context.getPersistenceService();
}
- //------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public EditProtocolSpeciesTableModel getTableModel() {
- return (EditProtocolSpeciesTableModel) getTable().getModel();
- }
-
- @Override
- public JXTable getTable() {
+ public JXTable getSpeciesTable() {
return ui.getSpeciesTable();
}
- @Override
- protected boolean isRowValid(EditProtocolSpeciesRowModel row) {
- return true;
+ public JXTable getBenthosTable() {
+ return ui.getBenthosTable();
}
- @Override
- protected void onRowModified(int rowIndex,
- EditProtocolSpeciesRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
-
- recomputeRowValidState(row);
+ public EditProtocolSpeciesTableModel getSpeciesTableModel() {
+ return (EditProtocolSpeciesTableModel) getSpeciesTable().getModel();
}
-
- @Override
- protected void onRowValidStateChanged(int rowIndex,
- EditProtocolSpeciesRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- super.onRowValidStateChanged(rowIndex, row, oldValue, newValue);
-
- if (row != null && row.isModify() && newValue != null && newValue) {
- // row was modified and is valid, we can save protocol
- // even if after the row becomes again not valid, this is not a
- // problem since we will only save valid data!
- getModel().setModify(true);
- }
+ public EditProtocolSpeciesTableModel getBenthosTableModel() {
+ return (EditProtocolSpeciesTableModel) getBenthosTable().getModel();
}
- @Override
- protected void saveSelectedRowIfRequired(TuttiBeanMonitor<EditProtocolSpeciesRowModel> rowMonitor,
- EditProtocolSpeciesRowModel row) {
+//
+// @Override
+// public EditProtocolSpeciesTableModel getTableModel() {
+// return (EditProtocolSpeciesTableModel) getTable().getModel();
+// }
+//
+// @Override
+// public JXTable getTable() {
+// return ui.getSpeciesTable();
+// }
+//
+// @Override
+// protected boolean isRowValid(EditProtocolSpeciesRowModel row) {
+// return true;
+// }
- // nothing to save when row changes, model is marked to be save
- // when a row has changed and is valid or other protocol properties are modified
- }
+// @Override
+// protected void onRowModified(int rowIndex,
+// EditProtocolSpeciesRowModel row,
+// String propertyName,
+// Object oldValue,
+// Object newValue) {
+//
+// recomputeRowValidState(row);
+// }
+//
+//
+// @Override
+// protected void onRowValidStateChanged(int rowIndex,
+// EditProtocolSpeciesRowModel row,
+// Boolean oldValue,
+// Boolean newValue) {
+// super.onRowValidStateChanged(rowIndex, row, oldValue, newValue);
+//
+// if (row != null && row.isModify() && newValue != null && newValue) {
+// // row was modified and is valid, we can save protocol
+// // even if after the row becomes again not valid, this is not a
+// // problem since we will only save valid data!
+// getModel().setModify(true);
+// }
+// }
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
@@ -249,68 +272,136 @@
registerValidators(validator);
- // create table model
+ Collection<Species> referents =
+ model.getAllReferentSpeciesByTaxonId().values();
- JXTable table = getTable();
+ initBeanFilterableComboBox(ui.getSpeciesComboBox(),
+ Lists.newArrayList(referents), null);
+ initBeanFilterableComboBox(ui.getBenthosComboBox(),
+ Lists.newArrayList(referents), null);
- DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
+ List<EditProtocolSpeciesRowModel> speciesRows;
+ List<EditProtocolSpeciesRowModel> benthosRows;
- addColumnToModel(columnModel,
- null,
- newTableCellRender(Species.class),
- EditProtocolSpeciesTableModel.SPECIES_ID);
+ // build species and benthos rows
+ if (protocol == null) {
+ speciesRows = Lists.newArrayList();
+ benthosRows = Lists.newArrayList();
+ } else {
- addColumnToModel(columnModel,
- null,
- null,
- EditProtocolSpeciesTableModel.SURVEY_CODE_ID);
+ speciesRows = toRows(protocol.getSpecies());
+ benthosRows = toRows(protocol.getBenthos());
- addLengthClassesColumnToModel(columnModel, model.getLengthClassesPmfmId());
+ if (log.isDebugEnabled()) {
+ log.debug("Will edit protocol with " +
+ speciesRows.size() + " species and " +
+ benthosRows.size() + " benthos declared.");
+ }
+ }
- addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.WEIGHT_ENABLED, table);
- addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.COUNT_IF_NO_FREQUENCY_ENABLED, table);
+ // set to model ( will propagate to tableModel)
+ model.setSpecies(speciesRows);
+ model.setBenthos(benthosRows);
- addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SIZE_ENABLED, table);
- addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SEX_ENABLED, table);
- addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.MATURITY_ENABLED, table);
- addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.AGE_ENABLED, table);
+ ui.getSpeciesComboBox().getHandler().reset();
+ ui.getBenthosComboBox().getHandler().reset();
- addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.CALCIFY_SAMPLE_ENABLED, table);
+ {
+ // create species table model
- EditProtocolSpeciesTableModel tableModel =
- new EditProtocolSpeciesTableModel(columnModel);
- table.setModel(tableModel);
- table.setColumnModel(columnModel);
+ JXTable table = getSpeciesTable();
- initTable(table);
+ DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
- Collection<Species> referents =
- model.getAllReferentSpeciesByTaxonId().values();
- List<Species> speciesList = Lists.newArrayList(referents);
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(Species.class),
+ EditProtocolSpeciesTableModel.SPECIES_ID);
- initBeanFilterableComboBox(ui.getSpeciesComboBox(), speciesList, null);
+ addColumnToModel(columnModel,
+ null,
+ null,
+ EditProtocolSpeciesTableModel.SURVEY_CODE_ID);
- List<EditProtocolSpeciesRowModel> rows;
+ addLengthClassesColumnToModel(columnModel, model.getLengthClassesPmfmId());
- // build speciesProtocol rows
- if (protocol == null) {
- rows = Lists.newArrayList();
- } else {
+ addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.WEIGHT_ENABLED, table);
+ addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.COUNT_IF_NO_FREQUENCY_ENABLED, table);
- rows = toRows(protocol.getSpecies());
+ addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SIZE_ENABLED, table);
+ addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SEX_ENABLED, table);
+ addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.MATURITY_ENABLED, table);
+ addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.AGE_ENABLED, table);
- if (log.isDebugEnabled()) {
- log.debug("Will edit protocol with " +
- rows.size() + " species declared.");
- }
+ addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.CALCIFY_SAMPLE_ENABLED, table);
+
+ EditProtocolSpeciesTableModel tableModel =
+ new EditProtocolSpeciesTableModel(columnModel);
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
+
+ initTable(table);
+
+ table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ ListSelectionModel source = (ListSelectionModel) e.getSource();
+ ui.getRemoveSpeciesProtocolButton().setEnabled(
+ !source.isSelectionEmpty());
+ }
+ });
+
+ tableModel.setRows(speciesRows);
}
- // set to model ( will propagate to tableModel)
- model.setRows(rows);
+ {
+ // create benthos table model
-// selectFirstInCombo(ui.getSpeciesComboBox());
- ui.getSpeciesComboBox().getHandler().reset();
+ JXTable table = getBenthosTable();
+ DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
+
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(Species.class),
+ EditProtocolSpeciesTableModel.SPECIES_ID);
+
+ addColumnToModel(columnModel,
+ null,
+ null,
+ EditProtocolSpeciesTableModel.SURVEY_CODE_ID);
+
+ addLengthClassesColumnToModel(columnModel, model.getLengthClassesPmfmId());
+
+ addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.WEIGHT_ENABLED, table);
+ addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.COUNT_IF_NO_FREQUENCY_ENABLED, table);
+
+ addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SIZE_ENABLED, table);
+ addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SEX_ENABLED, table);
+ addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.MATURITY_ENABLED, table);
+ addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.AGE_ENABLED, table);
+
+ addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.CALCIFY_SAMPLE_ENABLED, table);
+
+ EditProtocolSpeciesTableModel tableModel =
+ new EditProtocolSpeciesTableModel(columnModel);
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
+
+ initTable(table);
+
+ table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ ListSelectionModel source = (ListSelectionModel) e.getSource();
+ ui.getRemoveBenthosProtocolButton().setEnabled(
+ !source.isSelectionEmpty());
+ }
+ });
+
+ tableModel.setRows(benthosRows);
+ }
+
initDoubleList(EditProtocolUIModel.PROPERTY_LENGTH_CLASSES_PMFM_ID,
ui.getLengthClassesList(),
Lists.newArrayList(model.getCaracteristics()),
@@ -388,6 +479,8 @@
public List<EditProtocolSpeciesRowModel> toRows(List<SpeciesProtocol> speciesProtocols) {
BeanFilterableComboBox<Species> speciesComboBox = ui.getSpeciesComboBox();
Preconditions.checkNotNull(speciesComboBox.getData());
+ BeanFilterableComboBox<Species> benthosComboBox = ui.getBenthosComboBox();
+ Preconditions.checkNotNull(benthosComboBox.getData());
EditProtocolUIModel model = getModel();
@@ -406,17 +499,18 @@
// get species referent taxon
Species species = allReferentSpeciesByTaxonId.get(taxonIdStr);
+
// remove it from the combo box
- speciesComboBox.getHandler().removeItem(species);
+ speciesComboBox.removeItem(species);
+ benthosComboBox.removeItem(species);
- EditProtocolSpeciesRowModel row = getTableModel().createNewRow();
+ EditProtocolSpeciesRowModel row = EditProtocolSpeciesTableModel.newRow();
row.setSpecies(species);
row.setLengthStepPmfm(allCaracteristic.get(speciesProtocol.getLengthStepPmfmId()));
row.fromBean(speciesProtocol);
result.add(row);
}
}
-
return result;
}
@@ -440,17 +534,6 @@
return result;
}
-
- @Override
- protected void onAfterSelectedRowChanged(int oldRowIndex,
- EditProtocolSpeciesRowModel oldRow,
- int newRowIndex,
- EditProtocolSpeciesRowModel newRow) {
-
- super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow);
- getModel().setRemoveSpeciesEnabled(newRow != null);
- }
-
//------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
@@ -544,7 +627,8 @@
SwingUtil.fillComboBox(comboBox, dataToList, null);
}
- protected void addLengthClassesColumnToModel(TableColumnModel model, List<String> selectedIds) {
+ protected void addLengthClassesColumnToModel(TableColumnModel model,
+ List<String> selectedIds) {
Decorator<Caracteristic> decorator =
getDecorator(Caracteristic.class, null);
@@ -565,13 +649,54 @@
BeanUIUtil.decorate(comboBox, converter);
ComboBoxCellEditor editor = new ComboBoxCellEditor(comboBox);
-
addColumnToModel(model,
editor,
newTableCellRender(decorator),
EditProtocolSpeciesTableModel.LENGTH_STEP_PMFM_ID);
}
+ protected void initTable(JXTable table) {
+
+ // by default do not authorize to change column orders
+ table.getTableHeader().setReorderingAllowed(false);
+
+ addHighlighters(table);
+
+ // always scroll to selected row
+ SwingUtil.scrollToTableSelection(table);
+
+ table.getModel().addTableModelListener(new TableModelListener() {
+ @Override
+ public void tableChanged(TableModelEvent e) {
+ getModel().setModify(true);
+ }
+ });
+ }
+
+ protected void addHighlighters(final JXTable table) {
+ // paint in a special color for read only cells
+ Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ HighlightPredicate.READ_ONLY, getConfig().getColorRowReadOnly());
+ table.addHighlighter(readOnlyHighlighter);
+
+ // paint in a special color inValid rows
+ Highlighter validHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(HighlightPredicate.EDITABLE, new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+
+ boolean result = false;
+ if (adapter.isEditable()) {
+ EditProtocolSpeciesTableModel model = (EditProtocolSpeciesTableModel) table.getModel();
+ EditProtocolSpeciesRowModel row = model.getEntry(adapter.row);
+ result = !row.isValid();
+ }
+ return result;
+ }
+ }), getConfig().getColorRowInvalid());
+ table.addHighlighter(validHighlighter);
+ }
+
protected static class UpdateSelectedList implements PropertyChangeListener {
private final BeanDoubleListModel<Caracteristic> model;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -30,7 +30,7 @@
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -42,7 +42,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.3
*/
-public class EditProtocolUIModel extends AbstractTuttiTableUIModel<TuttiProtocol, EditProtocolSpeciesRowModel, EditProtocolUIModel> {
+public class EditProtocolUIModel extends AbstractTuttiBeanUIModel<TuttiProtocol, EditProtocolUIModel> {
private static final long serialVersionUID = 1L;
@@ -50,6 +50,10 @@
public static final String PROPERTY_NAME = "name";
+ public static final String PROPERTY_SPECIES = "species";
+
+ public static final String PROPERTY_BENTHOS = "benthos";
+
public static final String PROPERTY_LENGTH_CLASSES_PMFM_ID = "lengthClassesPmfmId";
public static final String PROPERTY_GEAR_USE_FEATURE_PMFM_ID = "gearUseFeaturePmfmId";
@@ -58,6 +62,8 @@
public static final String PROPERTY_REMOVE_SPECIES_ENABLED = "removeSpeciesEnabled";
+ public static final String PROPERTY_REMOVE_BENTHOS_ENABLED = "removeBenthosEnabled";
+
public static final String PROPERTY_IMPORTED = "imported";
public static final String PROPERTY_CLONED = "cloned";
@@ -93,6 +99,13 @@
*/
protected boolean removeSpeciesEnabled;
+ /**
+ * Can user remove a selected benthos?
+ *
+ * @since 0.3
+ */
+ protected boolean removeBenthosEnabled;
+
protected List<Species> allSpecies;
protected List<Species> allSynonyms;
@@ -105,6 +118,10 @@
protected Map<String, Caracteristic> allCaracteristic;
+ protected List<EditProtocolSpeciesRowModel> species;
+
+ protected List<EditProtocolSpeciesRowModel> benthos;
+
protected static Binder<EditProtocolUIModel, TuttiProtocol> toBeanBinder =
BinderFactory.newBinder(EditProtocolUIModel.class,
TuttiProtocol.class);
@@ -183,6 +200,26 @@
setVesselUseFeaturePmfmId(ids);
}
+ public List<EditProtocolSpeciesRowModel> getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(List<EditProtocolSpeciesRowModel> species) {
+ Object oldValue = getSpecies();
+ this.species = species;
+ firePropertyChange(PROPERTY_SPECIES, oldValue, species);
+ }
+
+ public List<EditProtocolSpeciesRowModel> getBenthos() {
+ return benthos;
+ }
+
+ public void setBenthos(List<EditProtocolSpeciesRowModel> benthos) {
+ Object oldValue = getBenthos();
+ this.benthos = benthos;
+ firePropertyChange(PROPERTY_BENTHOS, oldValue, species);
+ }
+
public boolean isRemoveSpeciesEnabled() {
return removeSpeciesEnabled;
}
@@ -193,6 +230,16 @@
firePropertyChange(PROPERTY_REMOVE_SPECIES_ENABLED, oldValue, removeSpeciesEnabled);
}
+ public boolean isRemoveBenthosEnabled() {
+ return removeBenthosEnabled;
+ }
+
+ public void setRemoveBenthosEnabled(boolean removeBenthosEnabled) {
+ Object oldValue = isRemoveBenthosEnabled();
+ this.removeBenthosEnabled = removeBenthosEnabled;
+ firePropertyChange(PROPERTY_REMOVE_BENTHOS_ENABLED, oldValue, removeBenthosEnabled);
+ }
+
public boolean isImported() {
return imported;
}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolBenthosAction.java (from rev 677, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolBenthosAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolBenthosAction.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -0,0 +1,126 @@
+package fr.ifremer.tutti.ui.swing.content.protocol;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.TuttiIOUtil;
+import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
+import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To export protocol benthos.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ExportProtocolBenthosAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportProtocolBenthosAction.class);
+
+ private File file;
+
+ public ExportProtocolBenthosAction(EditProtocolUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ protected boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to export
+ file = TuttiUIUtil.chooseFile(
+ getContext().getMainUI(),
+ _("tutti.editProtocol.title.choose.benthosExportFile"),
+ _("tutti.editProtocol.action.chooseProtocolBenthosFile"),
+ "^.*\\.csv", _("tutti.common.file.csv")
+ );
+ if (file == null) {
+
+ // user cancel
+ doAction = false;
+ } else {
+
+ // add extension if missing
+ file = TuttiIOUtil.addExtensionIfMissing(file, ".csv");
+
+ // ask user to confirm overwrite.
+ doAction = getHandler().askOverwriteFile(file);
+ }
+ }
+ return doAction;
+ }
+
+ @Override
+ protected void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ protected void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will export protocol benthos to file: " + file);
+ }
+
+ EditProtocolUIModel model = getModel();
+
+ // build benthos protocol to export
+
+ List<SpeciesProtocol> protocols = Lists.newArrayList();
+ for (EditProtocolSpeciesRowModel row : model.getBenthos()) {
+ if (row.isValid()) {
+ protocols.add(row.toBean());
+ }
+ }
+
+ // import
+ TuttiProtocolImportExportService service =
+ getContext().getTuttiProtocolImportExportService();
+
+ service.exportProtocolBenthos(file,
+ protocols,
+ model.getAllCaracteristic(),
+ model.getAllReferentSpeciesByTaxonId());
+
+ sendMessage(_("tutti.flash.info.species.exported.from.protocol",
+ file));
+ }
+}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -105,7 +105,7 @@
// build species protocol to export
List<SpeciesProtocol> protocols = Lists.newArrayList();
- for (EditProtocolSpeciesRowModel row : model.getRows()) {
+ for (EditProtocolSpeciesRowModel row : model.getSpecies()) {
if (row.isValid()) {
protocols.add(row.toBean());
}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java (from rev 677, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -0,0 +1,147 @@
+package fr.ifremer.tutti.ui.swing.content.protocol;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 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.persistence.entities.protocol.SpeciesProtocol;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To import protocol benthos.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ImportProtocolBenthosAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ImportProtocolBenthosAction.class);
+
+ private File file;
+
+ public ImportProtocolBenthosAction(EditProtocolUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ protected boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to import
+ file = TuttiUIUtil.chooseFile(
+ getContext().getMainUI(),
+ _("tutti.editProtocol.title.choose.benthosImportFile"),
+ _("tutti.editProtocol.action.chooseProtocolBenthosFile"),
+ "^.*\\.csv", _("tutti.common.file.csv")
+ );
+
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ protected void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ protected void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will import protocol benthos file: " + file);
+ }
+
+ EditProtocolUIModel model = getModel();
+
+ // bind to a protocol
+ TuttiProtocol protocol = model.toBean();
+
+ // import
+ TuttiProtocolImportExportService service =
+ getContext().getTuttiProtocolImportExportService();
+
+ service.importProtocolBenthos(file,
+ protocol,
+ model.getAllCaracteristic(),
+ model.getAllReferentSpeciesByTaxonId());
+
+ // build rows from imported+merged protocol
+ // (will also remove all synonyms of species referent used)
+ List<EditProtocolSpeciesRowModel> rows =
+ handler.toRows(protocol.getBenthos());
+
+ // update species comboBox
+// getUI().getSpeciesComboBox().getHandler().sortData();
+ getUI().getSpeciesComboBox().getHandler().reset();
+
+ // update benthos comboBox
+// getUI().getBenthosComboBox().getHandler().sortData();
+ getUI().getBenthosComboBox().getHandler().reset();
+
+ // update rows in model
+ model.setBenthos(rows);
+
+ int nbSynonym = 0;
+ for (SpeciesProtocol speciesProtocol : protocol.getSpecies()) {
+ if (!speciesProtocol.isMadeFromAReferentTaxon()) {
+ nbSynonym++;
+ }
+ }
+
+ String message;
+ switch (nbSynonym) {
+ case 0:
+ message = _("tutti.flash.info.benthos.imported.in.protocol",
+ file);
+ break;
+
+ case 1:
+ message = _("tutti.flash.info.benthos.imported.in.protocol.oneReplaced",
+ file);
+ break;
+
+ default:
+ message = _("tutti.flash.info.benthos.imported.in.protocol.severalReplaced",
+ file, nbSynonym);
+ }
+ sendMessage(message);
+ }
+}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -27,11 +27,9 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -105,19 +103,21 @@
model.getAllCaracteristic(),
model.getAllReferentSpeciesByTaxonId());
- BeanFilterableComboBox<Species> speciesComboBox = getUI().getSpeciesComboBox();
-
// build rows from imported+merged protocol
// (will also remove all synonyms of species referent used)
List<EditProtocolSpeciesRowModel> rows =
handler.toRows(protocol.getSpecies());
// update species comboBox
- speciesComboBox.getHandler().sortData();
- speciesComboBox.getHandler().reset();
+// getUI().getSpeciesComboBox().getHandler().sortData();
+ getUI().getSpeciesComboBox().getHandler().reset();
+ // update benthos comboBox
+// getUI().getBenthosComboBox().getHandler().sortData();
+ getUI().getBenthosComboBox().getHandler().reset();
+
// update rows in model
- model.setRows(rows);
+ model.setSpecies(rows);
int nbSynonym = 0;
for (SpeciesProtocol speciesProtocol : protocol.getSpecies()) {
@@ -130,17 +130,17 @@
switch (nbSynonym) {
case 0:
message = _("tutti.flash.info.species.imported.in.protocol",
- file);
+ file);
break;
case 1:
message = _("tutti.flash.info.species.imported.in.protocol.oneReplaced",
- file);
+ file);
break;
default:
message = _("tutti.flash.info.species.imported.in.protocol.severalReplaced",
- file, nbSynonym);
+ file, nbSynonym);
}
sendMessage(message);
}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveBenthosProtocolAction.java (from rev 677, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveBenthosProtocolAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveBenthosProtocolAction.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -0,0 +1,90 @@
+package fr.ifremer.tutti.ui.swing.content.protocol;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import org.jdesktop.swingx.JXTable;
+
+import java.util.Collections;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To add a new species protocol.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class RemoveBenthosProtocolAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ public RemoveBenthosProtocolAction(EditProtocolUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ protected void doAction() throws Exception {
+
+ JXTable table = handler.getBenthosTable();
+
+ int rowIndex = table.getSelectedRow();
+
+ Preconditions.checkState(rowIndex != -1,
+ "Cant remove benthos if no benthos selected");
+
+ EditProtocolSpeciesTableModel tableModel = handler.getBenthosTableModel();
+
+ EditProtocolSpeciesRowModel selectedRow = tableModel.getEntry(rowIndex);
+
+ // re-add all synonym of this taxon to the species / benthos combobox
+ Species species = selectedRow.getSpecies();
+ getUI().getBenthosComboBox().addItem(species);
+ getUI().getSpeciesComboBox().addItem(species);
+
+ EditProtocolUIModel model = getModel();
+ Integer taxonId = species.getReferenceTaxonId();
+ List<Species> allSynonyms = Lists.newArrayList(
+ model.getAllSynonyms(String.valueOf(taxonId)));
+ allSynonyms.remove(species);
+ model.getAllSynonyms().addAll(allSynonyms);
+ // reorder the list by name, otherwise,
+ // all the species without a reftax code will be at the end
+ Collections.sort(model.getAllSynonyms(), TuttiEntities.SPECIES_BY_NAME_COMPARATOR);
+
+
+ table.clearSelection();
+ // remove the row from the model(do it after treating the comboBox which can be long)
+ tableModel.removeRow(rowIndex);
+
+ String speciesStr = decorate(selectedRow.getSpecies());
+ sendMessage(_("tutti.flash.info.benthos.remove.from.protocol",
+ speciesStr));
+ }
+
+}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -29,9 +29,8 @@
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
-import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
+import javax.swing.JTable;
import java.util.Collections;
import java.util.List;
@@ -52,19 +51,21 @@
@Override
protected void doAction() throws Exception {
- int rowIndex = handler.getTable().getSelectedRow();
+ JTable table = handler.getSpeciesTable();
+ int rowIndex = table.getSelectedRow();
+
Preconditions.checkState(rowIndex != -1,
"Cant remove species if no species selected");
- EditProtocolSpeciesTableModel tableModel = handler.getTableModel();
+ EditProtocolSpeciesTableModel tableModel = handler.getSpeciesTableModel();
EditProtocolSpeciesRowModel selectedRow = tableModel.getEntry(rowIndex);
- // re-add all synonym of this taxon to the species comobox
+ // re-add all synonym of this taxon to the species / benthos combobox
Species species = selectedRow.getSpecies();
- BeanFilterableComboBox<Species> combo = getUI().getSpeciesComboBox();
- combo.getHandler().addItem(species);
+ getUI().getBenthosComboBox().addItem(species);
+ getUI().getSpeciesComboBox().addItem(species);
EditProtocolUIModel model = getModel();
Integer taxonId = species.getReferenceTaxonId();
@@ -76,7 +77,7 @@
// all the species without a reftax code will be at the end
Collections.sort(model.getAllSynonyms(), TuttiEntities.SPECIES_BY_NAME_COMPARATOR);
- handler.getTable().clearSelection();
+ table.clearSelection();
// remove the row from the model(do it after treating the comboBox which can be long)
tableModel.removeRow(rowIndex);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SaveProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SaveProtocolAction.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SaveProtocolAction.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -68,16 +68,26 @@
TuttiProtocol bean = model.toBean();
// get the species protocols from the table
- List<SpeciesProtocol> protocols = Lists.newArrayList();
+ List<SpeciesProtocol> speciesProtocols = Lists.newArrayList();
- for (EditProtocolSpeciesRowModel row : model.getRows()) {
+ for (EditProtocolSpeciesRowModel row : model.getSpecies()) {
if (row.isValid()) {
SpeciesProtocol protocol = row.toBean();
- protocols.add(protocol);
+ speciesProtocols.add(protocol);
}
}
- bean.setSpecies(protocols);
+ bean.setSpecies(speciesProtocols);
+ List<SpeciesProtocol> benthosProtocols = Lists.newArrayList();
+
+ for (EditProtocolSpeciesRowModel row : model.getBenthos()) {
+ if (row.isValid()) {
+ SpeciesProtocol protocol = row.toBean();
+ benthosProtocols.add(protocol);
+ }
+ }
+ bean.setBenthos(benthosProtocols);
+
if (log.isDebugEnabled()) {
log.debug("protocol id to save: " + bean.getId());
}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherBenthosAction.java (from rev 677, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherSpeciesAction.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherBenthosAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherBenthosAction.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -0,0 +1,91 @@
+
+package fr.ifremer.tutti.ui.swing.content.protocol;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Action to select a benthos which is not in the referent list.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.1
+ */
+public class SelectOtherBenthosAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(SelectOtherBenthosAction.class);
+
+ protected Species selectedSpecies;
+
+ public SelectOtherBenthosAction(EditProtocolUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ protected boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+ if (result) {
+ EditProtocolUIModel model = getModel();
+
+ List<Species> species = Lists.newArrayList(model.getAllSynonyms());
+
+ selectedSpecies = getHandler().openSelectOtherSpeciesDialog(
+ _("tutti.selectBenthos.title"), species);
+
+ if (log.isInfoEnabled()) {
+ log.info("SelectedBenthos: " + selectedSpecies);
+ }
+ result = selectedSpecies != null;
+ }
+ return result;
+ }
+
+ @Override
+ protected void releaseAction() {
+ selectedSpecies = null;
+ super.releaseAction();
+ }
+
+ @Override
+ protected void doAction() throws Exception {
+ String decoratedSynonym = decorate(selectedSpecies);
+ String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId());
+ selectedSpecies = getModel().getAllReferentSpeciesByTaxonId().get(taxonId);
+ String decoratedReferent = decorate(selectedSpecies);
+ sendMessage(_("tutti.flash.info.benthos.replaced", decoratedSynonym, decoratedReferent));
+ getUI().getBenthosComboBox().setSelectedItem(selectedSpecies);
+ }
+
+}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -39,16 +39,26 @@
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionUI;
import fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment;
import fr.ifremer.tutti.ui.swing.util.editor.SimpleTimeEditor;
+import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.JAXXWidgetUtil;
import jaxx.runtime.swing.editor.NumberEditor;
import jaxx.runtime.swing.editor.bean.BeanDoubleList;
import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
+import jaxx.runtime.swing.editor.bean.BeanUIUtil;
+import jaxx.runtime.swing.editor.cell.NumberCellEditor;
import jaxx.runtime.swing.renderer.DecoratorListCellRenderer;
+import jaxx.runtime.swing.renderer.DecoratorTableCellRenderer;
import jaxx.runtime.validator.swing.SwingValidator;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXDatePicker;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;
+import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
+import org.jdesktop.swingx.table.TableColumnExt;
import org.nuiton.util.decorator.Decorator;
import org.nuiton.util.decorator.JXPathDecorator;
import org.nuiton.validator.bean.simple.SimpleBeanValidator;
@@ -57,30 +67,40 @@
import javax.swing.AbstractButton;
import javax.swing.Action;
import javax.swing.DefaultComboBoxModel;
+import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
+import javax.swing.JPopupMenu;
import javax.swing.JRootPane;
import javax.swing.JSpinner;
+import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
+import javax.swing.border.LineBorder;
import javax.swing.event.ListSelectionEvent;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumnModel;
import javax.swing.text.JTextComponent;
+import java.awt.Color;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
+import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent;
import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
@@ -763,4 +783,161 @@
validator.setContext(newContext);
validator.setBean(bean);
}
+
+
+ protected <R extends AbstractTuttiBeanUIModel> void addColumnToModel(TableColumnModel model,
+ TableCellEditor editor,
+ TableCellRenderer renderer,
+ ColumnIdentifier<R> identifier) {
+
+ TableColumnExt col = new TableColumnExt(model.getColumnCount());
+ col.setCellEditor(editor);
+ col.setCellRenderer(renderer);
+ col.setHeaderValue(_(identifier.getHeaderI18nKey()));
+ col.setToolTipText(_(identifier.getHeaderTipI18nKey()));
+
+ col.setIdentifier(identifier);
+ model.addColumn(col);
+ }
+
+ protected <R extends AbstractTuttiBeanUIModel> void addColumnToModel(TableColumnModel model,
+ ColumnIdentifier<R> identifier) {
+
+ addColumnToModel(model, null, null, identifier);
+ }
+
+ protected <R extends AbstractTuttiBeanUIModel> void addFloatColumnToModel(TableColumnModel model,
+ ColumnIdentifier<R> identifier,
+ String numberPattern) {
+
+ NumberCellEditor<Float> editor =
+ JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
+ editor.getNumberEditor().setSelectAllTextOnError(true);
+ editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
+ editor.getNumberEditor().setNumberPattern(numberPattern);
+
+ addColumnToModel(model, editor, null, identifier);
+
+ }
+
+ protected <R extends AbstractTuttiBeanUIModel> void addIntegerColumnToModel(TableColumnModel model,
+ ColumnIdentifier<R> identifier,
+ String numberPattern) {
+
+ NumberCellEditor<Integer> editor =
+ JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, false);
+ editor.getNumberEditor().setSelectAllTextOnError(true);
+ editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
+ editor.getNumberEditor().setNumberPattern(numberPattern);
+
+ addColumnToModel(model, editor, null, identifier);
+ }
+
+ protected <R extends AbstractTuttiBeanUIModel> void addBooleanColumnToModel(TableColumnModel model,
+ ColumnIdentifier<R> identifier,
+ JTable table) {
+
+ addColumnToModel(model,
+ table.getDefaultEditor(Boolean.class),
+ table.getDefaultRenderer(Boolean.class),
+ identifier);
+ }
+
+ protected <R extends AbstractTuttiBeanUIModel, B> void addComboDataColumnToModel(TableColumnModel model,
+ ColumnIdentifier<R> identifier,
+ Decorator<B> decorator,
+ List<B> data) {
+ JComboBox comboBox = new JComboBox();
+ comboBox.setRenderer(newListCellRender(decorator));
+
+ List<B> dataToList = Lists.newArrayList(data);
+
+ // add a null value at first position
+ if (!dataToList.isEmpty() && dataToList.get(0) != null) {
+ dataToList.add(0, null);
+ }
+ SwingUtil.fillComboBox(comboBox, dataToList, null);
+
+ ObjectToStringConverter converter = BeanUIUtil.newDecoratedObjectToStringConverter(decorator);
+ BeanUIUtil.decorate(comboBox, converter);
+ ComboBoxCellEditor editor = new ComboBoxCellEditor(comboBox);
+
+ addColumnToModel(model,
+ editor,
+ newTableCellRender(decorator),
+ identifier);
+ }
+
+ protected <O> TableCellRenderer newTableCellRender(Class<O> type) {
+
+ return newTableCellRender(type, null);
+ }
+
+ protected <O> TableCellRenderer newTableCellRender(Class<O> type, String name) {
+
+ Decorator<O> decorator = getDecorator(type, name);
+
+ TableCellRenderer result = newTableCellRender(decorator);
+ return result;
+ }
+
+ protected <O> TableCellRenderer newTableCellRender(Decorator<O> decorator) {
+
+ Preconditions.checkNotNull(decorator);
+
+ DecoratorTableCellRenderer result = new DecoratorTableCellRenderer(decorator, true);
+ return result;
+ }
+
+ public void autoSelectRowInTable(MouseEvent e, JPopupMenu popup) {
+
+ boolean rightClick = SwingUtilities.isRightMouseButton(e);
+
+ if (rightClick || SwingUtilities.isLeftMouseButton(e)) {
+
+ // get the coordinates of the mouse click
+ Point p = e.getPoint();
+
+ JXTable source = (JXTable) e.getSource();
+
+ int[] selectedRows = source.getSelectedRows();
+
+ // get the row index at this point
+ int rowIndex = source.rowAtPoint(p);
+
+ if (log.isDebugEnabled()) {
+ log.debug("At point [" + p + "] found Row " + rowIndex);
+ }
+
+ boolean canContinue = true;
+
+ if (source.isEditing()) {
+
+ // stop editing
+ boolean stopEdit = source.getCellEditor().stopCellEditing();
+ if (!stopEdit) {
+ if (log.isWarnEnabled()) {
+ log.warn("Could not stop edit cell...");
+ }
+ canContinue = false;
+ }
+ }
+
+ if (canContinue) {
+
+ // select row (could empty selection)
+ if (rowIndex == -1) {
+ source.clearSelection();
+ } else if (!ArrayUtils.contains(selectedRows, rowIndex)) {
+ source.setRowSelectionInterval(rowIndex, rowIndex);
+ }
+
+ if (rightClick) {
+
+ // on right click show popup
+ popup.show(source, e.getX(), e.getY());
+ }
+ }
+ }
+ }
}
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 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -25,7 +25,6 @@
*/
import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
@@ -36,42 +35,28 @@
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.JAXXWidgetUtil;
-import jaxx.runtime.swing.editor.bean.BeanUIUtil;
import jaxx.runtime.swing.editor.cell.NumberCellEditor;
-import jaxx.runtime.swing.renderer.DecoratorTableCellRenderer;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;
-import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
import org.jdesktop.swingx.decorator.ComponentAdapter;
import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.decorator.Highlighter;
-import org.jdesktop.swingx.table.TableColumnExt;
-import org.nuiton.util.decorator.Decorator;
-import javax.swing.JComboBox;
-import javax.swing.JPopupMenu;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
-import javax.swing.SwingUtilities;
-import javax.swing.border.LineBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import java.awt.Color;
import java.awt.Component;
-import java.awt.Point;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
-import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Collection;
@@ -79,8 +64,6 @@
import java.util.List;
import java.util.Set;
-import static org.nuiton.i18n.I18n._;
-
/**
* @param <R> type of a row
* @param <M> type of the ui model
@@ -313,7 +296,7 @@
installTableSaveOnRowChangedSelectionListener();
}
- protected void addHighlighters(JXTable table){
+ protected void addHighlighters(JXTable table) {
// paint in a special color for read only cells
Highlighter readOnlyHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
HighlightPredicate.READ_ONLY, getConfig().getColorRowReadOnly());
@@ -368,110 +351,110 @@
table.addHighlighter(validHighlighter);
}
- protected void addColumnToModel(TableColumnModel model,
- TableCellEditor editor,
- TableCellRenderer renderer,
- ColumnIdentifier<R> identifier) {
+// protected void addColumnToModel(TableColumnModel model,
+// TableCellEditor editor,
+// TableCellRenderer renderer,
+// ColumnIdentifier<R> identifier) {
+//
+// TableColumnExt col = new TableColumnExt(model.getColumnCount());
+// col.setCellEditor(editor);
+// col.setCellRenderer(renderer);
+// col.setHeaderValue(_(identifier.getHeaderI18nKey()));
+// col.setToolTipText(_(identifier.getHeaderTipI18nKey()));
+//
+// col.setIdentifier(identifier);
+// model.addColumn(col);
+// }
- TableColumnExt col = new TableColumnExt(model.getColumnCount());
- col.setCellEditor(editor);
- col.setCellRenderer(renderer);
- col.setHeaderValue(_(identifier.getHeaderI18nKey()));
- col.setToolTipText(_(identifier.getHeaderTipI18nKey()));
+// protected void addColumnToModel(TableColumnModel model,
+// ColumnIdentifier<R> identifier) {
+//
+// addColumnToModel(model, null, null, identifier);
+// }
+//
+// protected void addFloatColumnToModel(TableColumnModel model,
+// ColumnIdentifier<R> identifier,
+// String numberPattern) {
+//
+// NumberCellEditor<Float> editor =
+// JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
+// editor.getNumberEditor().setSelectAllTextOnError(true);
+// editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
+// editor.getNumberEditor().setNumberPattern(numberPattern);
+//
+// addColumnToModel(model, editor, null, identifier);
+//
+// }
- col.setIdentifier(identifier);
- model.addColumn(col);
- }
+// protected void addIntegerColumnToModel(TableColumnModel model,
+// ColumnIdentifier<R> identifier,
+// String numberPattern) {
+//
+// NumberCellEditor<Integer> editor =
+// JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, false);
+// editor.getNumberEditor().setSelectAllTextOnError(true);
+// editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
+// editor.getNumberEditor().setNumberPattern(numberPattern);
+//
+// addColumnToModel(model, editor, null, identifier);
+// }
- protected void addColumnToModel(TableColumnModel model,
- ColumnIdentifier<R> identifier) {
+// protected void addBooleanColumnToModel(TableColumnModel model,
+// ColumnIdentifier<R> identifier,
+// JTable table) {
+//
+// addColumnToModel(model,
+// table.getDefaultEditor(Boolean.class),
+// table.getDefaultRenderer(Boolean.class),
+// identifier);
+// }
- addColumnToModel(model, null, null, identifier);
- }
+// protected <B> void addComboDataColumnToModel(TableColumnModel model,
+// ColumnIdentifier<R> identifier,
+// Decorator<B> decorator,
+// List<B> data) {
+// JComboBox comboBox = new JComboBox();
+// comboBox.setRenderer(newListCellRender(decorator));
+//
+// List<B> dataToList = Lists.newArrayList(data);
+//
+// // add a null value at first position
+// if (!dataToList.isEmpty() && dataToList.get(0) != null) {
+// dataToList.add(0, null);
+// }
+// SwingUtil.fillComboBox(comboBox, dataToList, null);
+//
+// ObjectToStringConverter converter = BeanUIUtil.newDecoratedObjectToStringConverter(decorator);
+// BeanUIUtil.decorate(comboBox, converter);
+// ComboBoxCellEditor editor = new ComboBoxCellEditor(comboBox);
+//
+// addColumnToModel(model,
+// editor,
+// newTableCellRender(decorator),
+// identifier);
+// }
+//
+// protected <O> TableCellRenderer newTableCellRender(Class<O> type) {
+//
+// return newTableCellRender(type, null);
+// }
+//
+// protected <O> TableCellRenderer newTableCellRender(Class<O> type, String name) {
+//
+// Decorator<O> decorator = getDecorator(type, name);
+//
+// TableCellRenderer result = newTableCellRender(decorator);
+// return result;
+// }
+//
+// protected <O> TableCellRenderer newTableCellRender(Decorator<O> decorator) {
+//
+// Preconditions.checkNotNull(decorator);
+//
+// DecoratorTableCellRenderer result = new DecoratorTableCellRenderer(decorator, true);
+// return result;
+// }
- protected void addFloatColumnToModel(TableColumnModel model,
- ColumnIdentifier<R> identifier,
- String numberPattern) {
-
- NumberCellEditor<Float> editor =
- JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
- editor.getNumberEditor().setSelectAllTextOnError(true);
- editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
- editor.getNumberEditor().setNumberPattern(numberPattern);
-
- addColumnToModel(model, editor, null, identifier);
-
- }
-
- protected void addIntegerColumnToModel(TableColumnModel model,
- ColumnIdentifier<R> identifier,
- String numberPattern) {
-
- NumberCellEditor<Integer> editor =
- JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, false);
- editor.getNumberEditor().setSelectAllTextOnError(true);
- editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
- editor.getNumberEditor().setNumberPattern(numberPattern);
-
- addColumnToModel(model, editor, null, identifier);
- }
-
- protected void addBooleanColumnToModel(TableColumnModel model,
- ColumnIdentifier<R> identifier,
- JTable table) {
-
- addColumnToModel(model,
- table.getDefaultEditor(Boolean.class),
- table.getDefaultRenderer(Boolean.class),
- identifier);
- }
-
- protected <B> void addComboDataColumnToModel(TableColumnModel model,
- ColumnIdentifier<R> identifier,
- Decorator<B> decorator,
- List<B> data) {
- JComboBox comboBox = new JComboBox();
- comboBox.setRenderer(newListCellRender(decorator));
-
- List<B> dataToList = Lists.newArrayList(data);
-
- // add a null value at first position
- if (!dataToList.isEmpty() && dataToList.get(0) != null) {
- dataToList.add(0, null);
- }
- SwingUtil.fillComboBox(comboBox, dataToList, null);
-
- ObjectToStringConverter converter = BeanUIUtil.newDecoratedObjectToStringConverter(decorator);
- BeanUIUtil.decorate(comboBox, converter);
- ComboBoxCellEditor editor = new ComboBoxCellEditor(comboBox);
-
- addColumnToModel(model,
- editor,
- newTableCellRender(decorator),
- identifier);
- }
-
- protected <O> TableCellRenderer newTableCellRender(Class<O> type) {
-
- return newTableCellRender(type, null);
- }
-
- protected <O> TableCellRenderer newTableCellRender(Class<O> type, String name) {
-
- Decorator<O> decorator = getDecorator(type, name);
-
- TableCellRenderer result = newTableCellRender(decorator);
- return result;
- }
-
- protected <O> TableCellRenderer newTableCellRender(Decorator<O> decorator) {
-
- Preconditions.checkNotNull(decorator);
-
- DecoratorTableCellRenderer result = new DecoratorTableCellRenderer(decorator, true);
- return result;
- }
-
//------------------------------------------------------------------------//
//-- Internal methods (listener methods) --//
//------------------------------------------------------------------------//
@@ -686,55 +669,55 @@
//-- Public methods --//
//------------------------------------------------------------------------//
- public void autoSelectRowInTable(MouseEvent e, JPopupMenu popup) {
-
- boolean rightClick = SwingUtilities.isRightMouseButton(e);
-
- if (rightClick || SwingUtilities.isLeftMouseButton(e)) {
-
- // get the coordinates of the mouse click
- Point p = e.getPoint();
-
- JXTable source = (JXTable) e.getSource();
-
- int[] selectedRows = source.getSelectedRows();
-
- // get the row index at this point
- int rowIndex = source.rowAtPoint(p);
-
- if (log.isDebugEnabled()) {
- log.debug("At point [" + p + "] found Row " + rowIndex);
- }
-
- boolean canContinue = true;
-
- if (source.isEditing()) {
-
- // stop editing
- boolean stopEdit = source.getCellEditor().stopCellEditing();
- if (!stopEdit) {
- if (log.isWarnEnabled()) {
- log.warn("Could not stop edit cell...");
- }
- canContinue = false;
- }
- }
-
- if (canContinue) {
-
- // select row (could empty selection)
- if (rowIndex == -1) {
- source.clearSelection();
- } else if (!ArrayUtils.contains(selectedRows, rowIndex)) {
- source.setRowSelectionInterval(rowIndex, rowIndex);
- }
-
- if (rightClick) {
-
- // on right click show popup
- popup.show(source, e.getX(), e.getY());
- }
- }
- }
- }
+// public void autoSelectRowInTable(MouseEvent e, JPopupMenu popup) {
+//
+// boolean rightClick = SwingUtilities.isRightMouseButton(e);
+//
+// if (rightClick || SwingUtilities.isLeftMouseButton(e)) {
+//
+// // get the coordinates of the mouse click
+// Point p = e.getPoint();
+//
+// JXTable source = (JXTable) e.getSource();
+//
+// int[] selectedRows = source.getSelectedRows();
+//
+// // get the row index at this point
+// int rowIndex = source.rowAtPoint(p);
+//
+// if (log.isDebugEnabled()) {
+// log.debug("At point [" + p + "] found Row " + rowIndex);
+// }
+//
+// boolean canContinue = true;
+//
+// if (source.isEditing()) {
+//
+// // stop editing
+// boolean stopEdit = source.getCellEditor().stopCellEditing();
+// if (!stopEdit) {
+// if (log.isWarnEnabled()) {
+// log.warn("Could not stop edit cell...");
+// }
+// canContinue = false;
+// }
+// }
+//
+// if (canContinue) {
+//
+// // select row (could empty selection)
+// if (rowIndex == -1) {
+// source.clearSelection();
+// } else if (!ArrayUtils.contains(selectedRows, rowIndex)) {
+// source.setRowSelectionInterval(rowIndex, rowIndex);
+// }
+//
+// if (rightClick) {
+//
+// // on right click show popup
+// popup.show(source, e.getX(), e.getY());
+// }
+// }
+// }
+// }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIModel.java 2013-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIModel.java 2013-03-25 17:44:48 UTC (rev 678)
@@ -26,7 +26,6 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-import fr.ifremer.tutti.ui.swing.content.operation.fishing.VesselUseFeatureRowModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
@@ -67,7 +66,7 @@
@Override
public void propertyChange(PropertyChangeEvent evt) {
- Set<VesselUseFeatureRowModel> rowsInErorr = (Set<VesselUseFeatureRowModel>) evt.getNewValue();
+ Set<R> rowsInErorr = (Set<R>) evt.getNewValue();
if (log.isDebugEnabled()) {
log.debug(PROPERTY_ROWS_IN_ERROR + " changed " + rowsInErorr.size());
}
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-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-03-25 17:44:48 UTC (rev 678)
@@ -485,40 +485,57 @@
tutti.editProgram.field.zone.tip=
tutti.editProgram.title.create.program=
tutti.editProgram.title.edit.program=
+tutti.editProtocol.action.addBenthosProtocol.mnemonic=
+tutti.editProtocol.action.addBenthosProtocol.tip=
tutti.editProtocol.action.addSpeciesProtocol.mnemonic=
tutti.editProtocol.action.addSpeciesProtocol.tip=
+tutti.editProtocol.action.chooseProtocolBenthosFile=
tutti.editProtocol.action.chooseProtocolCaracteristicFile=
tutti.editProtocol.action.chooseProtocolSpeciesFile=
+tutti.editProtocol.action.chooseProtocolbenthosFile=
tutti.editProtocol.action.closeEditProtocol=
tutti.editProtocol.action.closeEditProtocol.mnemonic=
tutti.editProtocol.action.closeEditProtocol.tip=
tutti.editProtocol.action.exportProtocolAllCaracteristic=
tutti.editProtocol.action.exportProtocolAllCaracteristic.mnemonic=
tutti.editProtocol.action.exportProtocolAllCaracteristic.tip=
+tutti.editProtocol.action.exportProtocolBenthos=
+tutti.editProtocol.action.exportProtocolBenthos.mnemonic=
+tutti.editProtocol.action.exportProtocolBenthos.tip=
tutti.editProtocol.action.exportProtocolCaracteristic=
tutti.editProtocol.action.exportProtocolCaracteristic.mnemonic=
tutti.editProtocol.action.exportProtocolCaracteristic.tip=
tutti.editProtocol.action.exportProtocolSpecies=
tutti.editProtocol.action.exportProtocolSpecies.mnemonic=
tutti.editProtocol.action.exportProtocolSpecies.tip=
+tutti.editProtocol.action.importProtocolBenthos=
+tutti.editProtocol.action.importProtocolBenthos.mnemonic=
+tutti.editProtocol.action.importProtocolBenthos.tip=
tutti.editProtocol.action.importProtocolCaracteristic=
tutti.editProtocol.action.importProtocolCaracteristic.mnemonic=
tutti.editProtocol.action.importProtocolCaracteristic.tip=
tutti.editProtocol.action.importProtocolSpecies=
tutti.editProtocol.action.importProtocolSpecies.mnemonic=
tutti.editProtocol.action.importProtocolSpecies.tip=
+tutti.editProtocol.action.removeBenthosProtocol=
+tutti.editProtocol.action.removeBenthosProtocol.mnemonic=
+tutti.editProtocol.action.removeBenthosProtocol.tip=
tutti.editProtocol.action.removeSpeciesProtocol=
tutti.editProtocol.action.removeSpeciesProtocol.mnemonic=
tutti.editProtocol.action.removeSpeciesProtocol.tip=
tutti.editProtocol.action.saveProtocol=
tutti.editProtocol.action.saveProtocol.mnemonic=
tutti.editProtocol.action.saveProtocol.tip=
+tutti.editProtocol.action.selectOtherBenthos=
+tutti.editProtocol.action.selectOtherBenthos.mnemonic=
+tutti.editProtocol.action.selectOtherBenthos.tip=
tutti.editProtocol.action.selectOtherSpecies=
tutti.editProtocol.action.selectOtherSpecies.mnemonic=
tutti.editProtocol.action.selectOtherSpecies.tip=
tutti.editProtocol.askCancelEditBeforeLeaving.cancelSaveProtocol=
tutti.editProtocol.askSaveBeforeLeaving.saveProtocol=
tutti.editProtocol.field..tip=
+tutti.editProtocol.field.benthos.tip=
tutti.editProtocol.field.comment=
tutti.editProtocol.field.comment.tip=
tutti.editProtocol.field.protocol.name=
@@ -553,6 +570,8 @@
tutti.editProtocol.table.header.speciesSurveyCode.tip=
tutti.editProtocol.table.header.weight=
tutti.editProtocol.table.header.weight.tip=
+tutti.editProtocol.title.choose.benthosExportFile=
+tutti.editProtocol.title.choose.benthosImportFile=
tutti.editProtocol.title.choose.caracteristicExportFile=
tutti.editProtocol.title.choose.caracteristicImportFile=
tutti.editProtocol.title.choose.speciesExportFile=
@@ -657,7 +676,14 @@
tutti.fishingOperations.title.edit.operations=
tutti.fishingOperations.title.validate.operations=
tutti.fishingOperations.warn.invalid.batch.model=
+tutti.flash.benthos.species.remove.from.protocol=
tutti.flash.info.all.caractristic.exported=
+tutti.flash.info.benthos.add.to.protocol=
+tutti.flash.info.benthos.imported.in.protocol=
+tutti.flash.info.benthos.imported.in.protocol.oneReplaced=
+tutti.flash.info.benthos.imported.in.protocol.severalReplaced=
+tutti.flash.info.benthos.remove.from.protocol=
+tutti.flash.info.benthos.replaced=
tutti.flash.info.caracteristic.imported.in.protocol=
tutti.flash.info.caractristic.exported.from.protocol=
tutti.flash.info.cruiseCreated=
@@ -834,6 +860,7 @@
tutti.sampleCategoryType.sex=
tutti.sampleCategoryType.size=
tutti.sampleCategoryType.sortedUnsorted=
+tutti.selectBenthos.title=
tutti.selectCruise.action.chooseProtocolFile=
tutti.selectCruise.action.cloneProtocol=
tutti.selectCruise.action.cloneProtocol.mnemonic=
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-03-24 15:40:11 UTC (rev 677)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-03-25 17:44:48 UTC (rev 678)
@@ -63,8 +63,6 @@
tutti.config.application=Configuration de l'application Tutti
tutti.config.category.applications=Application
tutti.config.category.applications.description=Application
-tutti.config.category.shortcuts=Raccourcis
-tutti.config.category.shortcuts.description=Liste des raccourcis clavier
tutti.config.category.technical=Technique
tutti.config.category.technical.description=Informations techniques
tutti.config.category.ui=Interface utilisateur
@@ -498,8 +496,11 @@
tutti.editProgram.field.zone.tip=
tutti.editProgram.title.create.program=Créer une nouvelle série de campagne
tutti.editProgram.title.edit.program=Éditer une série de campagne existante
+tutti.editProtocol.action.addBenthosProtocol.mnemonic=j
+tutti.editProtocol.action.addBenthosProtocol.tip=Ajouter un benthos au protocole
tutti.editProtocol.action.addSpeciesProtocol.mnemonic=j
tutti.editProtocol.action.addSpeciesProtocol.tip=Ajouter une espèce au protocole
+tutti.editProtocol.action.chooseProtocolBenthosFile=Choisir le fichier des benthos
tutti.editProtocol.action.chooseProtocolCaracteristicFile=Choisir le fichier des caractéristiques
tutti.editProtocol.action.chooseProtocolSpeciesFile=Choisir le fichier des espèces
tutti.editProtocol.action.closeEditProtocol=Fermer
@@ -508,34 +509,47 @@
tutti.editProtocol.action.exportProtocolAllCaracteristic=Exporter toutes les caractéristiques
tutti.editProtocol.action.exportProtocolAllCaracteristic.mnemonic=t
tutti.editProtocol.action.exportProtocolAllCaracteristic.tip=Exporter toutes les caractéristiques (sans les affecter à un écran)
+tutti.editProtocol.action.exportProtocolBenthos=Exporter les benthos
+tutti.editProtocol.action.exportProtocolBenthos.mnemonic=b
+tutti.editProtocol.action.exportProtocolBenthos.tip=Exporter les benthos du protocole
tutti.editProtocol.action.exportProtocolCaracteristic=Exporter les caractéristiques
tutti.editProtocol.action.exportProtocolCaracteristic.mnemonic=c
tutti.editProtocol.action.exportProtocolCaracteristic.tip=Exporter les caractéristiques du protocole
tutti.editProtocol.action.exportProtocolSpecies=Exporter les espèces
tutti.editProtocol.action.exportProtocolSpecies.mnemonic=è
tutti.editProtocol.action.exportProtocolSpecies.tip=Exporter les espèces du protocole
+tutti.editProtocol.action.importProtocolBenthos=Importer les benthos
+tutti.editProtocol.action.importProtocolBenthos.mnemonic=i
+tutti.editProtocol.action.importProtocolBenthos.tip=Importer les benthos dans le protocole
tutti.editProtocol.action.importProtocolCaracteristic=Importer les caractéristiques
tutti.editProtocol.action.importProtocolCaracteristic.mnemonic=i
-tutti.editProtocol.action.importProtocolCaracteristic.tip=importer les caractéristiques dans le protocole
+tutti.editProtocol.action.importProtocolCaracteristic.tip=Importer les caractéristiques dans le protocole
tutti.editProtocol.action.importProtocolSpecies=Importer les espèces
tutti.editProtocol.action.importProtocolSpecies.mnemonic=é
-tutti.editProtocol.action.importProtocolSpecies.tip=importer les espèces dans le protocole
+tutti.editProtocol.action.importProtocolSpecies.tip=Importer les espèces dans le protocole
+tutti.editProtocol.action.removeBenthosProtocol=Supprimer le benthos
+tutti.editProtocol.action.removeBenthosProtocol.mnemonic=S
+tutti.editProtocol.action.removeBenthosProtocol.tip=Supprimer le benthos
tutti.editProtocol.action.removeSpeciesProtocol=Supprimer l'espèce
tutti.editProtocol.action.removeSpeciesProtocol.mnemonic=S
tutti.editProtocol.action.removeSpeciesProtocol.tip=Supprimer l'espèce
tutti.editProtocol.action.saveProtocol=Enregistrer
tutti.editProtocol.action.saveProtocol.mnemonic=E
tutti.editProtocol.action.saveProtocol.tip=Enregistrer le protocol
+tutti.editProtocol.action.selectOtherBenthos=...
+tutti.editProtocol.action.selectOtherBenthos.mnemonic=.
+tutti.editProtocol.action.selectOtherBenthos.tip=Sélectionner une autre espèce
tutti.editProtocol.action.selectOtherSpecies=...
tutti.editProtocol.action.selectOtherSpecies.mnemonic=.
tutti.editProtocol.action.selectOtherSpecies.tip=Sélectionner une autre espèce
tutti.editProtocol.askCancelEditBeforeLeaving.cancelSaveProtocol=Le protocole n'est pas valide et ne peut pas être enregistré.
tutti.editProtocol.askSaveBeforeLeaving.saveProtocol=Des modifications sur le protocole n'ont pas été enregistrées.
+tutti.editProtocol.field.benthos.tip=Benthos
tutti.editProtocol.field.comment=Commentaire
-tutti.editProtocol.field.comment.tip=
+tutti.editProtocol.field.comment.tip=Commentaire
tutti.editProtocol.field.protocol.name=Nom
-tutti.editProtocol.field.protocol.name.tip=
-tutti.editProtocol.field.species.tip=
+tutti.editProtocol.field.protocol.name.tip=Nom du protocole
+tutti.editProtocol.field.species.tip=Espèces
tutti.editProtocol.tab.accidental=Accidental
tutti.editProtocol.tab.benthos=Benthos
tutti.editProtocol.tab.caracteristic=Caractéristiques
@@ -565,6 +579,8 @@
tutti.editProtocol.table.header.speciesSurveyCode.tip=Code campagne (non synchronisable)
tutti.editProtocol.table.header.weight=Pesée
tutti.editProtocol.table.header.weight.tip=Pesée
+tutti.editProtocol.title.choose.benthosExportFile=Exporter les benthos
+tutti.editProtocol.title.choose.benthosImportFile=Importer les benthos
tutti.editProtocol.title.choose.caracteristicExportFile=Exporter les caractéristiques
tutti.editProtocol.title.choose.caracteristicImportFile=Importer les caractéristiques
tutti.editProtocol.title.choose.speciesExportFile=Exporter les espèces
@@ -671,6 +687,13 @@
tutti.fishingOperations.title.validate.operations=Validation des opérations de pêches (%s)
tutti.fishingOperations.warn.invalid.batch.model=L'arbre d'échantillonage n'est pas compatible. Les captures ne seront pas visibles.
tutti.flash.info.all.caractristic.exported=Toutes les caractéristiques exportées dans le fichier <strong>%s</strong>.
+tutti.flash.info.benthos.add.to.protocol=Le benthos <strong>%s</strong> a été ajoutée au protocole.
+tutti.flash.info.benthos.exported.from.protocol=Benthos du protocole exportées dans le fichier <strong>%s</strong>.
+tutti.flash.info.benthos.imported.in.protocol=Benthos importés dans le protocole depuis le fichier <strong>%s</strong>.
+tutti.flash.info.benthos.imported.in.protocol.oneReplaced=Benthos importés dans le protocole depuis le fichier <strong>%s</strong>. 1 remplacée par son référent.
+tutti.flash.info.benthos.imported.in.protocol.severalReplaced=Benthos importés dans le protocole depuis le fichier <strong>%s</strong>. %s remplacées par leur référent.
+tutti.flash.info.benthos.remove.from.protocol=Le benthos <strong>%s</strong> a été retiré du protocole.
+tutti.flash.info.benthos.replaced=Le benthos <strong>%s</strong> a été remplacé par son référent <strong>%s</strong>.
tutti.flash.info.caracteristic.imported.in.protocol=Caractéristiques importées dans le protocole depuis le fichier <strong>%s</strong>.
tutti.flash.info.caractristic.exported.from.protocol=Caractéristiques du protocole exportées dans le fichier <strong>%s</strong>.
tutti.flash.info.cruiseCreated=La campagne <strong>%s</strong> a été créée.
@@ -679,7 +702,6 @@
tutti.flash.info.db.exported=Base exportée dans l'archive <strong>%s</strong>.
tutti.flash.info.db.exported.and.clean=Base exportée dans l'archive <strong>%s</strong>.
tutti.flash.info.db.imported=La base de données <strong>%s</strong> est importée.
-tutti.flash.info.db.installed=La base de données <strong>%s</strong> est installée.
tutti.flash.info.db.opened=La base de données <strong>%s</strong> est ouverte.
tutti.flash.info.programCreated=La série de campagne <strong>%s</strong> a été créée.
tutti.flash.info.programSaved=La série de campagne <strong>%s</strong> a été enregistrée.
@@ -846,6 +868,7 @@
tutti.sampleCategoryType.sex=Sexe
tutti.sampleCategoryType.size=Class Tri.
tutti.sampleCategoryType.sortedUnsorted=V/HV
+tutti.selectBenthos.title=Choisissez un benthos
tutti.selectCruise.action.chooseProtocolFile=Choisir le fichier de protocole
tutti.selectCruise.action.cloneProtocol=Cloner
tutti.selectCruise.action.cloneProtocol.mnemonic=o
1
0
24 Mar '13
See <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/5…>
Changes:
[Tony Chemit] refs #1863: [BENTHOS] - Gestion de la saisie du benthos
- impact sur service de persistence
- debut de reusinage des APi d'ui
------------------------------------------
projectStarted fr.ifremer.tutti:tutti-persistence:1.2-SNAPSHOT
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutti :: Persistence 1.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
mojoStarted org.apache.maven.plugins:maven-clean-plugin:2.5(default-clean)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ tutti-persistence ---
[INFO] Deleting <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
mojoSucceeded org.apache.maven.plugins:maven-clean-plugin:2.5(default-clean)
mojoStarted org.apache.maven.plugins:maven-enforcer-plugin:1.2(check-project-files)
[INFO]
[INFO] --- maven-enforcer-plugin:1.2:enforce (check-project-files) @ tutti-persistence ---
mojoSucceeded org.apache.maven.plugins:maven-enforcer-plugin:1.2(check-project-files)
mojoStarted org.nuiton.eugene:eugene-maven-plugin:2.6.1(default)
[INFO]
[INFO] --- eugene-maven-plugin:2.6.1:generate (default) @ tutti-persistence ---
[INFO] Process phase [zargo] for one entry.
[INFO] Expanding 1 xmi file(s) from <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Will generate <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Copy file <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…> to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Generate one file in 348.113ms.
[INFO] Process phase [xmi] for one entry.
[INFO] Processing XSL tranformation on <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…> for 1 file(s).
[INFO] Will generate <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Copy file <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…> to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Generate one file in 8.289s.
[INFO] Process phase [model] for one entry.
WARN [pool-1-thread-1] (ObjectModelReader.java:580) getObjectElements - Invalid stereotype [fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol.attribute.hydrologyPmfmId.stereotype] : Element 'hydrologyPmfmId' of type 'attribute' on classifier 'fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol' is null.
INFO [pool-1-thread-1] (ObjectModelReader.java:273) loadModelProperties - 19 tag values were succesfull imported from <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Apply generator JavaInterfaceTransformer
[INFO] Apply generator SimpleJavaBeanTransformer
INFO [pool-1-thread-1] (ObjectModelTransformerToJava.java:911) isInClassPath - Will not generate [fr.ifremer.tutti.persistence.entities.data.Program], already found in class-path.
[INFO] Apply generator JavaEnumerationTransformer
INFO [pool-1-thread-1] (ObjectModelTransformerToJava.java:911) isInClassPath - Will not generate [fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum], already found in class-path.
INFO [pool-1-thread-1] (ObjectModelTransformerToJava.java:911) isInClassPath - Will not generate [fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum], already found in class-path.
[INFO] No file generated.
[INFO] Add compile source root : <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Add resource root :Resource {targetPath: null, filtering: false, FileSet {directory: <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…,> PatternSet [includes: {}, excludes: {**/*.java}]}}
mojoSucceeded org.nuiton.eugene:eugene-maven-plugin:2.6.1(default)
mojoStarted org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
[INFO]
[INFO] --- i18n-maven-plugin:2.5:parserJava (scan-sources) @ tutti-persistence ---
mojoSucceeded org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
forkedProjectStarted fr.ifremer.tutti:tutti-persistence:1.2-SNAPSHOT
mojoStarted org.nuiton.i18n:i18n-maven-plugin:2.5(get)
[INFO]
[INFO] --- i18n-maven-plugin:2.5:get (get) @ tutti-persistence ---
[INFO] Copying tutti-persistence.properties to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Copying tutti-persistence.properties to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
mojoSucceeded org.nuiton.i18n:i18n-maven-plugin:2.5(get)
forkedProjectSucceeded fr.ifremer.tutti:tutti-persistence:1.2-SNAPSHOT
mojoStarted org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
[INFO]
[INFO] --- i18n-maven-plugin:2.5:gen (scan-sources) @ tutti-persistence ---
[WARNING] bundle en_GB contains 27/27 empty entries! (use -Di18n.showEmpty to see these entries)
mojoSucceeded org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
mojoStarted org.apache.maven.plugins:maven-resources-plugin:2.6(default-resources)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ tutti-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 8 resources
[INFO] Copying 0 resource
mojoSucceeded org.apache.maven.plugins:maven-resources-plugin:2.6(default-resources)
mojoStarted org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-compile)
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ tutti-persistence ---
[INFO] Compiling 88 source files to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
mojoSucceeded org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-compile)
mojoStarted org.apache.maven.plugins:maven-antrun-plugin:1.7(generate-surefire-workdir)
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ tutti-persistence ---
[INFO] Executing tasks
main:
[mkdir] Created dir: <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Executed tasks
mojoSucceeded org.apache.maven.plugins:maven-antrun-plugin:1.7(generate-surefire-workdir)
mojoStarted org.apache.maven.plugins:maven-resources-plugin:2.6(default-testResources)
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ tutti-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
mojoSucceeded org.apache.maven.plugins:maven-resources-plugin:2.6(default-testResources)
mojoStarted org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-testCompile)
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ tutti-persistence ---
[INFO] Compiling 29 source files to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] bootstrap class path not set in conjunction with -source 1.6
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[858,15] error: no suitable method found for getSpeciesBatch(String,BatchContainer<SpeciesBatch>)
[INFO] 1 error
[INFO] -------------------------------------------------------------
mojoFailed org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-testCompile)
projectFailed fr.ifremer.tutti:tutti-persistence:1.2-SNAPSHOT
1
12
r677 - in trunk/tutti-persistence/src: main/java/fr/ifremer/tutti/persistence/entities/data test/java/fr/ifremer/tutti/persistence/service
by tchemit@users.forge.codelutin.com 24 Mar '13
by tchemit@users.forge.codelutin.com 24 Mar '13
24 Mar '13
Author: tchemit
Date: 2013-03-24 16:40:11 +0100 (Sun, 24 Mar 2013)
New Revision: 677
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/677
Log:
fix test build + add missing svn properties
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java 2013-03-24 15:33:27 UTC (rev 676)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java 2013-03-24 15:40:11 UTC (rev 677)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.persistence.entities.data;
+/*
+ * #%L
+ * Tutti :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 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.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SortedUnsortedEnum.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java 2013-03-24 15:33:27 UTC (rev 676)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java 2013-03-24 15:40:11 UTC (rev 677)
@@ -855,7 +855,7 @@
}
protected SpeciesBatch getBenthosBatch(String fishingOperationId, String speciesBatchId) {
- return getSpeciesBatch(speciesBatchId, service.getRootBenthosBatch(fishingOperationId));
+ return getSpeciesBatch(speciesBatchId, service.getRootBenthosBatch(fishingOperationId).getChildren());
}
protected SpeciesBatch getSpeciesBatch(String speciesBatchId, List<SpeciesBatch> speciesBatchs) {
1
0
r676 - trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service
by tchemit@users.forge.codelutin.com 24 Mar '13
by tchemit@users.forge.codelutin.com 24 Mar '13
24 Mar '13
Author: tchemit
Date: 2013-03-24 16:33:27 +0100 (Sun, 24 Mar 2013)
New Revision: 676
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/676
Log:
fix test build
Modified:
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceWriteTest.java
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceWriteTest.java 2013-03-24 14:58:00 UTC (rev 675)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceWriteTest.java 2013-03-24 15:33:27 UTC (rev 676)
@@ -358,7 +358,7 @@
fishingOperation.setStrata(null);
fishingOperation.setSubStrata(null);
fishingOperation.setLocation(null);
- fishingOperation.setVessel(cruise.getVessel(0));
+ fishingOperation.setVessel(cruise.getVessel());
fishingOperation.setVesselUseFeatures(environmentValuesOneEntry);
fishingOperation.setGearUseFeatures(gearShootingCaracteristicsOneEntry);
fishingOperation.setComment(fishingOperation.getComment() + "\n\nUnit test createFishingOperation() - Part n°5 : check if deleted sub items in DB");
1
0
r675 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: content/cruise content/home content/operation content/operation/catches content/operation/catches/benthos content/operation/catches/species content/program content/protocol util
by tchemit@users.forge.codelutin.com 24 Mar '13
by tchemit@users.forge.codelutin.com 24 Mar '13
24 Mar '13
Author: tchemit
Date: 2013-03-24 15:58:00 +0100 (Sun, 24 Mar 2013)
New Revision: 675
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/675
Log:
fixes #2171: [TRAIT] champ heure minute comportement ?\195?\160 corriger
refs #2186: [CAMPAGNE] Navire - remplacer la double liste par une simple liste (am?\195?\169lioration layout)
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
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/species/SpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css 2013-03-24 13:33:40 UTC (rev 674)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css 2013-03-24 14:58:00 UTC (rev 675)
@@ -39,8 +39,17 @@
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
bean: {model};
showReset: true;
+ _selectOnFocus: {true};
}
+JXDatePicker {
+ _selectOnFocus: {true};
+}
+
+JTextField {
+ _selectOnFocus: {true};
+}
+
#editCruiseTopPanel {
_help: {"tutti.editCruise.help"};
}
@@ -181,17 +190,13 @@
buttonGroup: "filterVesselType";
}
-#vesselLabel {
- text: "tutti.editCruise.field.vessel";
- labelFor: {vesselComboBox};
- toolTipText: "tutti.editCruise.field.vessel.tip";
- _help: {"tutti.editCruise.field.vessel.help"};
-}
-
#vesselComboBox {
+ border: {BorderFactory.createTitledBorder(_("tutti.editCruise.field.vessel"))};
property: vessel;
selectedItem: {model.getVessel()};
+ toolTipText: "tutti.editCruise.field.vessel.tip";
_validatorLabel : {_("tutti.editCruise.field.vessel")};
+ _help: {"tutti.editCruise.field.vessel.help"};
}
#gearList {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.jaxx 2013-03-24 13:33:40 UTC (rev 674)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.jaxx 2013-03-24 14:58:00 UTC (rev 675)
@@ -191,13 +191,17 @@
</cell>
</row>
<row weighty='0.3'>
- <cell>
+ <!--cell>
<JLabel id='vesselLabel'/>
+ </cell-->
+ <cell weightx='0.3' columns="3">
+ <JPanel layout='{new BorderLayout()}'>
+ <BeanFilterableComboBox id='vesselComboBox' constructorParams='this'
+ genericType='Vessel'
+ constraints='BorderLayout.NORTH'/>
+ </JPanel>
+
</cell>
- <cell weightx='0.3' columns="2">
- <BeanFilterableComboBox id='vesselComboBox' constructorParams='this'
- genericType='Vessel'/>
- </cell>
<cell columns="3">
<BeanDoubleList id='gearList' genericType='Gear'/>
</cell>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2013-03-24 13:33:40 UTC (rev 674)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2013-03-24 14:58:00 UTC (rev 675)
@@ -223,6 +223,7 @@
getValidator().setBean(model);
ui.applyDataBinding(SelectCruiseUI.BINDING_EDIT_PROGRAM_BUTTON_ENABLED);
+ ui.applyDataBinding(SelectCruiseUI.BINDING_NEW_CRUISE_BUTTON_ENABLED);
ui.applyDataBinding(SelectCruiseUI.BINDING_EDIT_CRUISE_BUTTON_ENABLED);
ui.applyDataBinding(SelectCruiseUI.BINDING_EDIT_CATCHES_BUTTON_ENABLED);
ui.applyDataBinding(SelectCruiseUI.BINDING_VALIDATE_CATCHES_BUTTON_ENABLED);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2013-03-24 13:33:40 UTC (rev 674)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2013-03-24 14:58:00 UTC (rev 675)
@@ -48,15 +48,22 @@
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
bean: {model};
showReset: true;
+ _selectOnFocus: {true};
}
SimpleTimeEditor {
bean: {model};
+ _selectOnFocus: {true};
}
+JXDatePicker {
+ _selectOnFocus: {true};
+}
+
#editFishingOperationTopPanel {
_help: {"tutti.editFishingOperation.help"};
}
+
#traitGeneralTabPaneToolBar {
floatable: false;
opaque: false;
@@ -83,6 +90,7 @@
#stationNumberField {
text: {model.getStationNumber()};
_validatorLabel : {_("tutti.editFishingOperation.field.stationNumber")};
+ _selectOnFocus: {true};
}
#fishingOperationNumberLabel {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx 2013-03-24 13:33:40 UTC (rev 674)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx 2013-03-24 14:58:00 UTC (rev 675)
@@ -24,9 +24,7 @@
<JPanel id='editFishingOperationTopPanel' layout='{new BorderLayout()}'
decorator='help'
implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<EditFishingOperationUIModel, EditFishingOperationUIHandler>'>
-
<import>
- fr.ifremer.tutti.persistence.entities.data.FishingOperation
fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation
fr.ifremer.tutti.persistence.entities.referential.Gear
fr.ifremer.tutti.persistence.entities.referential.Person
@@ -36,29 +34,19 @@
fr.ifremer.tutti.ui.swing.content.operation.fishing.GearUseFeatureTabUI
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
- fr.ifremer.tutti.ui.swing.util.TuttiUIUtil
fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment
fr.ifremer.tutti.ui.swing.util.editor.CoordinateEditorType
fr.ifremer.tutti.ui.swing.util.editor.SimpleTimeEditor
jaxx.runtime.swing.editor.bean.BeanFilterableComboBox
- jaxx.runtime.swing.editor.bean.BeanListHeader
jaxx.runtime.swing.editor.bean.BeanDoubleList
jaxx.runtime.swing.editor.NumberEditor
- jaxx.runtime.swing.editor.TimeEditor
jaxx.runtime.swing.CardLayout2Ext
org.jdesktop.swingx.JXDatePicker
- org.jdesktop.swingx.JXTable
org.jdesktop.swingx.JXTitledPanel
- java.awt.Dimension
-
- javax.swing.DefaultListModel
- javax.swing.ListSelectionModel
-
static org.nuiton.i18n.I18n._
- static jaxx.runtime.SwingUtil.getStringValue
</import>
<script><![CDATA[
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-03-24 13:33:40 UTC (rev 674)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-03-24 14:58:00 UTC (rev 675)
@@ -29,6 +29,7 @@
showReset: true;
useFloat: true;
numberPattern: {DECIMAL3_PATTERN};
+ _selectOnFocus: {true};
}
TuttiComputedOrNotDataEditor {
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-03-24 13:33:40 UTC (rev 674)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-03-24 14:58:00 UTC (rev 675)
@@ -29,6 +29,7 @@
showReset: true;
useFloat: true;
numberPattern: {DECIMAL3_PATTERN};
+ _selectOnFocus: {true};
}
TuttiComputedOrNotDataEditor {
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-03-24 13:33:40 UTC (rev 674)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-03-24 14:58:00 UTC (rev 675)
@@ -29,6 +29,7 @@
showReset: true;
useFloat: true;
numberPattern: {DECIMAL3_PATTERN};
+ _selectOnFocus: {true};
}
TuttiComputedOrNotDataEditor {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css 2013-03-24 13:33:40 UTC (rev 674)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css 2013-03-24 14:58:00 UTC (rev 675)
@@ -28,6 +28,10 @@
bean: {model};
}
+JTextField {
+ _selectOnFocus: {true};
+}
+
#editProgramTopPanel {
_help: {"tutti.editProgram.help"};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-03-24 13:33:40 UTC (rev 674)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-03-24 14:58:00 UTC (rev 675)
@@ -33,6 +33,10 @@
bean: {model};
}
+JTextField {
+ _selectOnFocus: {true};
+}
+
#editProtocolTopPanel {
_help: {"tutti.editProtocol.help"};
}
@@ -50,7 +54,7 @@
#nameField {
text: {model.getName()};
- _validatorLabel : {_("tutti.editProtocol.field.protocol.name")};
+ _validatorLabel: {_("tutti.editProtocol.field.protocol.name")};
}
#commentPane {
@@ -61,7 +65,7 @@
#commentField {
text: {getStringValue(model.getComment())};
- _validatorLabel : {_("tutti.editProtocol.field.comment")};
+ _validatorLabel: {_("tutti.editProtocol.field.comment")};
}
#saveWarningContainer {
@@ -73,7 +77,48 @@
actionIcon: warning;
border: {new javax.swing.border.EmptyBorder(5, 10, 5, 10)};
}
-
+
+#speciesComboBox {
+ enabled: {!speciesComboBox.isEmpty()};
+ toolTipText: "tutti.editProtocol.field.species.tip";
+ _help: {"tutti.editProtocol.field.species.help"};
+}
+
+#tablePopup {
+ label: "tutti.editProtocol.title.batchActions";
+}
+
+#speciesTable {
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+ _help: {"tutti.editProtocol.field.species.help"};
+}
+
+#caracteristicPane {
+ tabPlacement: {JTabbedPane.LEFT};
+ _help: {"tutti.editProtocol.pane.caracteristic.help"};
+}
+
+#gearUseFeatureList {
+ property: gearUseFeaturePmfm;
+ beanType: {Caracteristic.class};
+ _help: {"tutti.editProtocol.field.gearUseFeature.help"};
+}
+
+#vesselUseFeatureList {
+ property: vesselUseFeaturePmfm;
+ beanType: {Caracteristic.class};
+ _help: {"tutti.editProtocol.field.vesselUseFeature.help"};
+}
+
+#lengthClassesList {
+ property: lengthClassesPmfm;
+ beanType: {Caracteristic.class};
+ _help: {"tutti.editProtocol.field.lengthClasses.help"};
+}
+
#saveButton {
actionIcon: save;
text: "tutti.editProtocol.action.saveProtocol";
@@ -93,12 +138,6 @@
_help: {"tutti.editProtocol.action.closeEditProtocol.help"};
}
-#speciesComboBox {
- enabled: {!speciesComboBox.isEmpty()};
- toolTipText: "tutti.editProtocol.field.species.tip";
- _help: {"tutti.editProtocol.field.species.help"};
-}
-
#selectOtherSpeciesButton {
text: "tutti.editProtocol.action.selectOtherSpecies";
toolTipText: "tutti.editProtocol.action.selectOtherSpecies.tip";
@@ -116,10 +155,6 @@
_help: {"tutti.editProtocol.action.addSpeciesProtocol.help"};
}
-#tablePopup {
- label: "tutti.editProtocol.title.batchActions";
-}
-
#removeSpeciesProtocolButton {
actionIcon: batch-delete;
text: "tutti.editProtocol.action.removeSpeciesProtocol";
@@ -130,19 +165,6 @@
_help: {"tutti.editProtocol.action.removeSpeciesProtocol.help"};
}
-#speciesTable {
- selectionMode: {ListSelectionModel.SINGLE_SELECTION};
- selectionBackground: {null};
- selectionForeground: {Color.BLACK};
- sortable: false;
- _help: {"tutti.editProtocol.field.species.help"};
-}
-
-#caracteristicPane {
- tabPlacement: {JTabbedPane.LEFT};
- _help: {"tutti.editProtocol.pane.caracteristic.help"};
-}
-
#importSpeciesButton {
actionIcon: import;
text: "tutti.editProtocol.action.importProtocolSpecies";
@@ -188,21 +210,3 @@
_help: {"tutti.editProtocol.action.exportProtocolAllCaracteristic.help"};
}
-#gearUseFeatureList {
- property: gearUseFeaturePmfm;
- beanType: {Caracteristic.class};
- _help: {"tutti.editProtocol.field.gearUseFeature.help"};
-}
-
-#vesselUseFeatureList {
- property: vesselUseFeaturePmfm;
- beanType: {Caracteristic.class};
- _help: {"tutti.editProtocol.field.vesselUseFeature.help"};
-}
-
-#lengthClassesList {
- property: lengthClassesPmfm;
- beanType: {Caracteristic.class};
- _help: {"tutti.editProtocol.field.lengthClasses.help"};
-}
-
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-03-24 13:33:40 UTC (rev 674)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-03-24 14:58:00 UTC (rev 675)
@@ -35,7 +35,6 @@
import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import fr.ifremer.tutti.ui.swing.content.MainUI;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionUI;
import fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment;
@@ -64,10 +63,12 @@
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
+import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
+import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.text.JTextComponent;
import java.awt.Component;
@@ -352,8 +353,9 @@
}
return result;
}
+
//------------------------------------------------------------------------//
- //-- Internal methods --//
+ //-- Init methods --//
//------------------------------------------------------------------------//
protected void initUI(TuttiUI ui) {
@@ -361,175 +363,74 @@
for (Map.Entry<String, Object> entry : ui.get$objectMap().entrySet()) {
Object component = entry.getValue();
if (component instanceof NumberEditor) {
+
initNumberEditor((NumberEditor) component);
+ } else if (component instanceof JXDatePicker) {
- } else if (component instanceof JXDatePicker) {
initDatePicker((JXDatePicker) component);
+ } else if (component instanceof SimpleTimeEditor) {
- } else if (component instanceof SimpleTimeEditor) {
initTimeEditor((SimpleTimeEditor) component);
+ } else if (component instanceof ButtonAttachment) {
- } else if (component instanceof ButtonAttachment) {
initButtonAttachment((ButtonAttachment) component);
-
} else if (component instanceof JLabel) {
- JLabel jLabel = (JLabel) component;
- Boolean strongStyle = (Boolean) jLabel.getClientProperty("strongStyle");
- Boolean italicStyle = (Boolean) jLabel.getClientProperty("italicStyle");
- boolean addHtml = strongStyle != null && strongStyle || italicStyle != null && italicStyle;
- if (addHtml) {
- String text = jLabel.getText();
- if (strongStyle != null && strongStyle) {
- text = "<strong>" + text + "</strong>";
- }
- if (italicStyle != null && italicStyle) {
- text = "<em>" + text + "</em>";
- }
- jLabel.setText("<html>" + text + "</html>");
- }
+ initLabel((JLabel) component);
} else if (component instanceof JTextField) {
- JTextField jTextField = (JTextField) component;
- Boolean computed = (Boolean) jTextField.getClientProperty("computed");
- if (computed != null && computed) {
- Font font = jTextField.getFont().deriveFont(Font.ITALIC);
- jTextField.setFont(font);
- jTextField.setEditable(!computed);
- jTextField.setEnabled(!computed);
- jTextField.setDisabledTextColor(getConfig().getColorComputedWeights());
- }
+ initTextField((JTextField) component);
} else if (component instanceof AbstractButton) {
- AbstractButton abstractButton = (AbstractButton) component;
- Class<AbstractTuttiAction> actionName = (Class<AbstractTuttiAction>) abstractButton.getClientProperty("tuttiAction");
- if (actionName != null) {
- initAction(abstractButton, actionName);
- }
+
+ initButton((AbstractButton) component);
}
}
}
- protected void initButtonAttachment(ButtonAttachment component) {
+ protected void initTextField(JTextField jTextField) {
+ Boolean computed = (Boolean) jTextField.getClientProperty("computed");
+ if (computed != null && computed) {
+ Font font = jTextField.getFont().deriveFont(Font.ITALIC);
+ jTextField.setFont(font);
+ jTextField.setEditable(!computed);
+ jTextField.setEnabled(!computed);
+ jTextField.setDisabledTextColor(getConfig().getColorComputedWeights());
+ }
+ if (isAutoSelectOnFocus(jTextField)) {
+ addAutoSelectOnFocus(jTextField);
+ }
+ }
- component.init();
+ protected void initLabel(JLabel jLabel) {
+ Boolean strongStyle = (Boolean) jLabel.getClientProperty("strongStyle");
+ Boolean italicStyle = (Boolean) jLabel.getClientProperty("italicStyle");
+ boolean addHtml = strongStyle != null && strongStyle || italicStyle != null && italicStyle;
+ if (addHtml) {
+ String text = jLabel.getText();
+ if (strongStyle != null && strongStyle) {
+ text = "<strong>" + text + "</strong>";
+ }
+ if (italicStyle != null && italicStyle) {
+ text = "<em>" + text + "</em>";
+ }
+ jLabel.setText("<html>" + text + "</html>");
+ }
}
- protected <A extends AbstractTuttiAction> void initAction(AbstractButton abstractButton,
- Class<A> actionName) {
+ protected void initButtonAttachment(ButtonAttachment component) {
- Action action = TuttiActionHelper.createUIAction(this, abstractButton, actionName);
- abstractButton.setAction(action);
+ component.init();
}
-// public <A extends AbstractTuttiAction> TuttiUIAction<A> createUIAction(AbstractButton abstractButton,
-// Class<A> actionName) {
-// try {
-//
-// // create logic action
-// A logicAction = createLogicAction(actionName);
-//
-// // create ui action
-// TuttiUIAction<A> result = new TuttiUIAction<A>(abstractButton,
-// logicAction);
-// return result;
-// } catch (Exception e) {
-// throw new TuttiTechnicalException(
-// "Could not instanciate action " + actionName, e);
-// }
-//
-// }
+ protected void initButton(AbstractButton abstractButton) {
-// public <A extends AbstractTuttiAction> A createLogicAction(Class<A> actionName) {
-// try {
-//
-// AbstractTuttiUIHandler handler = this;
-//
-// if (AbstractMainUITuttiAction.class.isAssignableFrom(actionName) &&
-// getContext().getMainUI() != null) {
-// handler = getContext().getMainUI().getHandler();
-// }
-//
-// // create action
-// A result = ConstructorUtils.invokeConstructor(actionName, handler);
-// return result;
-// } catch (Exception e) {
-// throw new RuntimeException(
-// "Could not instanciate action " + actionName, e);
-// }
-// }
-
-// public <A extends AbstractTuttiAction> A getLogicAction(AbstractButton b) {
-// Action action = b.getAction();
-// Preconditions.checkNotNull(action);
-// Preconditions.checkState(action instanceof TuttiUIAction);
-// return ((TuttiUIAction<A>) action).getLogicAction();
-// }
-
-// protected void doAction(AbstractButton button, ActionEvent event) {
-// button.getAction().actionPerformed(event);
-// }
-
- protected boolean quitScreen(boolean modelIsValid,
- boolean modelIsModify,
- String askGiveUpMessage,
- String askSaveMessage,
- Action saveAction) {
- boolean result;
-
- if (!modelIsValid) {
-
- // model is not valid
- // ask user to qui or not
- result = askCancelEditBeforeLeaving(askGiveUpMessage);
-
- } else if (modelIsModify) {
-
- // something is modify ask user what to do
- int answer = askSaveBeforeLeaving(askSaveMessage);
- switch (answer) {
- case JOptionPane.YES_OPTION:
-
- // ok save
- saveAction.actionPerformed(null);
- result = true;
- break;
- case JOptionPane.NO_OPTION:
-
- // do not save but can still quit the screen (so nothing to do)
- result = true;
- break;
- default:
- // do not save and stay here (so nothing to do)
- result = false;
-
- }
- } else {
-
- // model is valid and not modify, can safely quit screen
- result = true;
+ Class actionName = (Class) abstractButton.getClientProperty("tuttiAction");
+ if (actionName != null) {
+ Action action = TuttiActionHelper.createUIAction(this, abstractButton, actionName);
+ abstractButton.setAction(action);
}
- return result;
}
- protected void registerValidators(SwingValidator... validators) {
- MainUI main = context.getMainUI();
- Preconditions.checkNotNull(
- main, "No mainUI registred in application context");
- MainUIHandler handler = main.getHandler();
- handler.clearValidators();
- for (SwingValidator validator : validators) {
- handler.registerValidator(validator);
- }
- }
-
- public void clearValidators() {
- MainUI main = context.getMainUI();
- Preconditions.checkNotNull(
- main, "No mainUI registred in application context");
- MainUIHandler handler = main.getHandler();
- handler.clearValidators();
- }
-
/**
* Prépare un component de choix d'entités pour un type d'entité donné et
* pour un service de persistance donné.
@@ -626,6 +527,11 @@
editor.setModel(null);
editor.setModel(model);
}
+
+ if (isAutoSelectOnFocus(editor)) {
+
+ addAutoSelectOnFocus(editor.getTextField());
+ }
}
protected void initTimeEditor(SimpleTimeEditor editor) {
@@ -634,6 +540,11 @@
" for property " + editor.getModel().getProperty());
}
editor.init();
+
+ if (isAutoSelectOnFocus(editor)) {
+ addAutoSelectOnFocus(((JSpinner.DefaultEditor) editor.getHour().getEditor()).getTextField());
+ addAutoSelectOnFocus(((JSpinner.DefaultEditor) editor.getMinute().getEditor()).getTextField());
+ }
}
protected void initDatePicker(final JXDatePicker picker) {
@@ -656,10 +567,100 @@
}
}
}
+ });
+ if (isAutoSelectOnFocus(picker)) {
+ addAutoSelectOnFocus(picker.getEditor());
+ }
+ }
+
+ protected boolean isAutoSelectOnFocus(JComponent comp) {
+ Object selectOnFocus = comp.getClientProperty("selectOnFocus");
+ return selectOnFocus != null && Boolean.valueOf(selectOnFocus.toString());
+ }
+
+ protected void addAutoSelectOnFocus(JTextField jTextField) {
+ jTextField.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusGained(final FocusEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ JTextField source = (JTextField) e.getSource();
+ source.selectAll();
+ }
+ });
+
+ }
});
}
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+
+ protected boolean quitScreen(boolean modelIsValid,
+ boolean modelIsModify,
+ String askGiveUpMessage,
+ String askSaveMessage,
+ Action saveAction) {
+ boolean result;
+
+ if (!modelIsValid) {
+
+ // model is not valid
+ // ask user to qui or not
+ result = askCancelEditBeforeLeaving(askGiveUpMessage);
+
+ } else if (modelIsModify) {
+
+ // something is modify ask user what to do
+ int answer = askSaveBeforeLeaving(askSaveMessage);
+ switch (answer) {
+ case JOptionPane.YES_OPTION:
+
+ // ok save
+ saveAction.actionPerformed(null);
+ result = true;
+ break;
+ case JOptionPane.NO_OPTION:
+
+ // do not save but can still quit the screen (so nothing to do)
+ result = true;
+ break;
+ default:
+ // do not save and stay here (so nothing to do)
+ result = false;
+
+ }
+ } else {
+
+ // model is valid and not modify, can safely quit screen
+ result = true;
+ }
+ return result;
+ }
+
+ protected void registerValidators(SwingValidator... validators) {
+ MainUI main = context.getMainUI();
+ Preconditions.checkNotNull(
+ main, "No mainUI registred in application context");
+ MainUIHandler handler = main.getHandler();
+ handler.clearValidators();
+ for (SwingValidator validator : validators) {
+ handler.registerValidator(validator);
+ }
+ }
+
+ public void clearValidators() {
+ MainUI main = context.getMainUI();
+ Preconditions.checkNotNull(
+ main, "No mainUI registred in application context");
+ MainUIHandler handler = main.getHandler();
+ handler.clearValidators();
+ }
+
public <O> Decorator<O> getDecorator(Class<O> type, String name) {
DecoratorService decoratorService =
context.getDecoratorService();
1
0
Author: tchemit
Date: 2013-03-24 14:33:40 +0100 (Sun, 24 Mar 2013)
New Revision: 674
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/674
Log:
fixes #2030: [TECH] Logiciel en Version 32 et 64 bits
fixes #2153: [TECH] Installation version 64 bits : ne marche pas
Modified:
trunk/tutti-ui-swing/pom.xml
Modified: trunk/tutti-ui-swing/pom.xml
===================================================================
--- trunk/tutti-ui-swing/pom.xml 2013-03-24 13:03:42 UTC (rev 673)
+++ trunk/tutti-ui-swing/pom.xml 2013-03-24 13:33:40 UTC (rev 674)
@@ -463,9 +463,9 @@
<redmine.releaseFiles>
target/${bundlePrefix}-full-windows-i586.zip,
- target/${bundlePrefix}-full-windows-x64.zip,
- target/${bundlePrefix}-full-linux-i586.zip,
- target/${bundlePrefix}-full-linux-x64.zip
+ target/${bundlePrefix}-full-linux-i586.zip
+ <!--target/${bundlePrefix}-full-windows-x64.zip,-->
+ <!--target/${bundlePrefix}-full-linux-x64.zip-->
</redmine.releaseFiles>
</properties>
<build>
@@ -475,12 +475,12 @@
<profile>
<id>linux-x64-bundle</id>
- <activation>
+ <!--activation>
<property>
<name>performFullRelease</name>
<value>true</value>
</property>
- </activation>
+ </activation-->
<build>
<defaultGoal>package</defaultGoal>
<plugins>
@@ -673,12 +673,12 @@
<profile>
<id>window-x64-bundle</id>
- <activation>
+ <!--activation>
<property>
<name>performFullRelease</name>
<value>true</value>
</property>
- </activation>
+ </activation-->
<build>
<defaultGoal>package</defaultGoal>
<plugins>
1
0