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
February 2013
- 6 participants
- 236 discussions
r395 - in trunk/tutti-persistence/src: main/java/fr/ifremer/tutti/persistence/service main/java/fr/ifremer/tutti/persistence/service/measure main/resources test/java/fr/ifremer/tutti/persistence/service
by blavenier@users.forge.codelutin.com 11 Feb '13
by blavenier@users.forge.codelutin.com 11 Feb '13
11 Feb '13
Author: blavenier
Date: 2013-02-11 17:32:28 +0100 (Mon, 11 Feb 2013)
New Revision: 395
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/395
Log:
ref refs #1936: [CAPTURE] - Esp?\195?\168ce - pouvoir changer le nom d'une esp?\195?\168ce
- Add changeSpeciesBatchSpecies() implementation
ref refs #1920: [Persistence] Adagio Donnees thematiques
Fix :
- Change storage of sampleCategoryWeight and weight (inversion was mdae between this 2 weights)
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/measure/MeasurementPersistenceHelper.java
trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-02-11 16:21:12 UTC (rev 394)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-02-11 16:32:28 UTC (rev 395)
@@ -149,7 +149,7 @@
//TODO BLA : uncomment if a property speciesBatch.speciesBatchFrequency exists
//List<SpeciesBatchFrequency> batchFrequencies = batchFrequenciesMapByParentId.get(speciesBatch.getId());
//if (batchFrequencies != null) {
- // speciesBatch.setSpeciesBatchFrequency(batchFrequencies)
+ // speciesBatch.setSpeciesBatchFrequency(batchFrequencies);
//}
}
}
@@ -172,7 +172,7 @@
// TODO BLA uncomment this after v1.0 :
//Preconditions.checkNotNull(bean.getCatchBatch());
- getCurrentSession().setFlushMode(FlushMode.ALWAYS);
+ getCurrentSession().setFlushMode(FlushMode.COMMIT);
SortingBatch batch = SortingBatch.Factory.newInstance();
beanToEntity(bean, batch, parentBatchId, true);
@@ -225,9 +225,17 @@
@Override
public void changeSpeciesBatchSpecies(String batchId, Species species) {
+ Preconditions.checkNotNull(batchId);
+ Preconditions.checkNotNull(species);
+ Preconditions.checkNotNull(species.getReferenceTaxonId());
- log.debug("Changing species for batch id="+batchId);
+ if (log.isDebugEnabled()) {
+ log.debug("Changing species for batch id="+batchId);
+ }
+ int rowUpdated = queryUpdate("updateBatchSpecies",
+ "batchId", IntegerType.INSTANCE, Integer.valueOf(batchId),
+ "referenceTaxonId", IntegerType.INSTANCE, species.getReferenceTaxonId());
}
@Override
@@ -380,10 +388,12 @@
target.setSamplingRatio(null);
target.setSamplingRatioText(null);
} else if (source.getSampleCategoryWeight() != null && source.getWeight() != null) {
- String samplingRatioText = source.getSampleCategoryWeight() + "/" + source.getWeight();
+ String samplingRatioText = source.getWeight() + "/" + source.getSampleCategoryWeight();
samplingRatioText = samplingRatioText.replaceAll(",", ".");
target.setSamplingRatioText(samplingRatioText);
- target.setSamplingRatio(source.getSampleCategoryWeight() / source.getWeight());
+ target.setSamplingRatio(source.getWeight() / source.getSampleCategoryWeight());
+ QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target, enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
+ notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
// Sorting measurement
@@ -409,7 +419,7 @@
if (copyIfNull && (source.getSpecies() == null || parentBatchId != null)) {
target.setReferenceTaxon(null);
} else if (source.getSpecies() != null && parentBatchId == null) {
- ReferenceTaxon referenceTaxon = load(ReferenceTaxonImpl.class, Integer.valueOf(source.getSpecies().getReferenceTaxonId()));
+ ReferenceTaxon referenceTaxon = load(ReferenceTaxonImpl.class, source.getSpecies().getReferenceTaxonId());
target.setReferenceTaxon(referenceTaxon);
}
@@ -500,7 +510,7 @@
String sourceSamplingRatioText = (String) source[colIndex++];
UIWeight uiWeight = convertDatabase2UI(sourceWeight, sourceSamplingRatio, sourceSamplingRatioText);
result.setWeight(uiWeight.weight);
- result.setSampleCategoryWeight(uiWeight.sampleWeight);
+ result.setSampleCategoryWeight(uiWeight.sampleCategoryWeight);
// Comments
result.setComment((String) source[colIndex++]);
@@ -777,22 +787,25 @@
// Weight & sampleCategory Weight
if (samplingRatio == null) {
- result.weight = weight;
- } else if (weight != null) {
+ result.sampleCategoryWeight = weight;
+ } else if (weight != null) {
String startStr = weight.toString().replace(',', '.') + "/";
if (samplingRatioText != null && samplingRatioText.startsWith(startStr)) {
String weightStr = samplingRatioText.substring(startStr.length());
if (weightStr != null && !weightStr.isEmpty()) {
- result.sampleWeight = weight;
- result.weight = Float.parseFloat(weightStr);
+ result.sampleCategoryWeight = Float.parseFloat(weightStr);
+ result.weight = weight;
}
}
+ else {
+ result.sampleCategoryWeight = weight;
+ }
}
return result;
}
static class UIWeight {
- Float sampleWeight = null;
+ Float sampleCategoryWeight = null;
Float weight = null;
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/measure/MeasurementPersistenceHelper.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/measure/MeasurementPersistenceHelper.java 2013-02-11 16:21:12 UTC (rev 394)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/measure/MeasurementPersistenceHelper.java 2013-02-11 16:32:28 UTC (rev 395)
@@ -70,13 +70,13 @@
public QuantificationMeasurement setQuantificationMeasurement(
Batch batch, Integer pmfmId, Integer recorderDepartmentId,
- Float weightValue, boolean isReferenceSorting) {
+ Float weightValue, boolean isReferenceQuantitification) {
QuantificationMeasurement quantificationMeasurement = getQuantificationMeasurement(
batch, pmfmId, recorderDepartmentId, true);
quantificationMeasurement.setNumericalValue(weightValue);
quantificationMeasurement
- .setIsReferenceQuantification(isReferenceSorting);
+ .setIsReferenceQuantification(isReferenceQuantitification);
return quantificationMeasurement;
}
Modified: trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
===================================================================
--- trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-02-11 16:21:12 UTC (rev 394)
+++ trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-02-11 16:32:28 UTC (rev 395)
@@ -381,6 +381,17 @@
<query-param name="batchId" type="java.lang.Integer"/>
</query>
+ <query name="updateBatchSpecies">
+ <![CDATA[
+ UPDATE SortingBatchImpl b
+ SET b.referenceTaxon.id=:referenceTaxonId
+ WHERE
+ b.id=:batchId
+ ]]>
+ <query-param name="referenceTaxonId" type="java.lang.Integer"/>
+ <query-param name="batchId" type="java.lang.Integer"/>
+ </query>
+
<query name="allSpeciesBatchFrequency">
<![CDATA[
SELECT
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java 2013-02-11 16:21:12 UTC (rev 394)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java 2013-02-11 16:32:28 UTC (rev 395)
@@ -61,7 +61,6 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.3
*/
-@Ignore
public class SpeciesBatchPersistenceServiceWriteTest {
@ClassRule
@@ -194,7 +193,7 @@
batch.setSpecies(taxon1);
batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
batch.setSampleCategoryValue(vracQualitativeValue);
- batch.setWeight(5f);
+ batch.setSampleCategoryWeight(5f);
assertCreateAndReloadSpeciesBatch(batch, null);
@@ -210,10 +209,10 @@
batch.setParentBatch(esp1Batch);
batch.setSpecies(taxon1);
batch.setComment("ESP1 - Vrac/5 Male/2 ss-ech/1 Nombre/7");
- batch.setWeight(2f);
batch.setSampleCategoryType(SampleCategoryEnum.sex);
batch.setSampleCategoryValue(maleQualitativeValue);
- batch.setSampleCategoryWeight(1f);
+ batch.setSampleCategoryWeight(2f);
+ batch.setWeight(1f);
batch.setNumber(7);
assertCreateAndReloadSpeciesBatch(batch, batch.getParentBatch().getId());
@@ -227,10 +226,10 @@
batch.setParentBatch(esp1Batch);
batch.setSpecies(taxon1);
batch.setComment("ESP1 - Vrac/5 Female/3 Nombre/14");
- batch.setWeight(3f);
batch.setSampleCategoryType(SampleCategoryEnum.sex);
batch.setSampleCategoryValue(femaleQualitativeValue);
- batch.setSampleCategoryWeight(null);
+ batch.setSampleCategoryWeight(3f);
+ batch.setWeight(null);
batch.setNumber(14);
assertCreateAndReloadSpeciesBatch(batch, batch.getParentBatch().getId());
@@ -247,7 +246,7 @@
batch.setSpecies(taxon2);
batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
batch.setSampleCategoryValue(vracQualitativeValue);
- batch.setWeight(7f);
+ batch.setSampleCategoryWeight(7f);
assertCreateAndReloadSpeciesBatch(batch, null);
esp2Batch = batch;
@@ -260,8 +259,8 @@
batch.setComment("ESP2 - Vrac/7 UNK/2 ss-ech/1 Nombre/11");
batch.setSampleCategoryType(SampleCategoryEnum.maturity);
batch.setSampleCategoryValue(firstMaturityQualitativeValue);
- batch.setWeight(2f);
- batch.setSampleCategoryWeight(1f);
+ batch.setSampleCategoryWeight(2f);
+ batch.setWeight(1f);
batch.setNumber(11);
assertCreateAndReloadSpeciesBatch(batch, batch.getParentBatch().getId());
@@ -270,11 +269,11 @@
// 5. Test save after modifications
// -----------------------------------------------------------------------------
// Batch : ESP2 - Vrac/7 UNK/1.75 ss-ech/1.11 Nombre/99
+ batch.setComment("ESP2 - Vrac/7 UNK/1.75 ss-ech/1.11 Nombre/99");
batch.setSampleCategoryType(SampleCategoryEnum.sex);
batch.setSampleCategoryValue(unkQualitativeValue);
- batch.setComment("ESP2 - Vrac/7 UNK/1.75 ss-ech/1.11 Nombre/99");
- batch.setWeight(1.75f);
- batch.setSampleCategoryWeight(1.11f);
+ batch.setSampleCategoryWeight(1.75f);
+ batch.setWeight(1.11f);
batch.setFishingOperation(fishingOperation);
batch.setNumber(99);
@@ -354,7 +353,7 @@
batch.setSpecies(taxon1);
batch.setSampleCategoryType(SampleCategoryEnum.sortedUnsorted);
batch.setSampleCategoryValue(vracQualitativeValue);
- batch.setWeight(5f);
+ batch.setSampleCategoryWeight(5f);
assertCreateAndReloadSpeciesBatch(batch, null);
esp1Batch = batch;
@@ -365,7 +364,7 @@
batch.setSpecies(taxon1);
batch.setSampleCategoryType(SampleCategoryEnum.sex);
batch.setSampleCategoryValue(maleQualitativeValue);
- batch.setWeight(2f);
+ batch.setSampleCategoryWeight(2f);
assertCreateAndReloadSpeciesBatch(batch, esp1Batch.getId());
// Try to remove
1
0
r394 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species
by tchemit@users.forge.codelutin.com 11 Feb '13
by tchemit@users.forge.codelutin.com 11 Feb '13
11 Feb '13
Author: tchemit
Date: 2013-02-11 17:21:12 +0100 (Mon, 11 Feb 2013)
New Revision: 394
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/394
Log:
refs #1936: [CAPTURE] - Esp?\195?\168ce - pouvoir changer le nom d'une esp?\195?\168ce
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java 2013-02-11 15:57:22 UTC (rev 393)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java 2013-02-11 16:21:12 UTC (rev 394)
@@ -26,6 +26,7 @@
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -89,6 +90,12 @@
}
@Override
+ protected void releaseAction(ActionEvent event) {
+ selectedSpecies = null;
+ super.releaseAction(event);
+ }
+
+ @Override
protected void doAction(ActionEvent event) {
SpeciesBatchUIHandler handler = getHandler();
@@ -96,17 +103,14 @@
JXTable table = handler.getTable();
SpeciesBatchRowModel row = tableModel.getEntry(table.getSelectedRow());
- // TODO 20130206 kmorin uncomment the following lines when the service is available
-// PersistenceService persistenceService = getContext().getService(PersistenceService.class);
-// persistenceService.changeSpeciesBatchSpecies(row.getId(), selectedSpecies);
+ PersistenceService persistenceService = getService(PersistenceService.class);
+ persistenceService.changeSpeciesBatchSpecies(row.getId(), selectedSpecies);
- Collection<Species> speciesUSed = handler.getModel().getSpeciesUsed()
+ Collection<Species> speciesUsed = getModel().getSpeciesUsed()
.get(row.getSortedUnsortedCategoryValue());
- speciesUSed.remove(row.getSpecies());
+ speciesUsed.remove(row.getSpecies());
changeChildrenSpecies(row, selectedSpecies);
- speciesUSed.add(selectedSpecies);
-
- selectedSpecies = null;
+ speciesUsed.add(selectedSpecies);
}
protected void changeChildrenSpecies(SpeciesBatchRowModel row,
1
0
r393 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro
by blavenier@users.forge.codelutin.com 11 Feb '13
by blavenier@users.forge.codelutin.com 11 Feb '13
11 Feb '13
Author: blavenier
Date: 2013-02-11 16:57:22 +0100 (Mon, 11 Feb 2013)
New Revision: 393
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/393
Log:
Fix :
- put in comments all association tables
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java 2013-02-11 15:41:35 UTC (rev 392)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java 2013-02-11 15:57:22 UTC (rev 393)
@@ -42,32 +42,32 @@
PARAMETER,
MATRIX,
FRACTION,
- FRACTION2MATRIX,
+ //assocation:FRACTION2MATRIX,
METHOD,
PMFM,
- PMFM2QUALITATIVE_VALUE,
+ //assocation:PMFM2QUALITATIVE_VALUE,
// GEAR
GEAR_CLASSIFICATION,
- GEAR_CLASSIFICATION_ASSOCIATIO,
+ //assocation:GEAR_CLASSIFICATION_ASSOCIATIO,
GEAR,
- GEAR_ASSOCIATION,
+ //assocation:GEAR_ASSOCIATION,
// LOCATION
LOCATION_CLASSIFICATION,
LOCATION_LEVEL,
- LOCATION_ASSOCIATION,
+ //assocation:LOCATION_ASSOCIATION,
LOCATION,
- LOCATION_HIERARCHY,
+ //assocation:LOCATION_HIERARCHY,
LOCATION_HIERARCHY_EXCEPTION,
// TAXON
TAXONOMIC_LEVEL,
REFERENCE_TAXON,
TAXON_NAME,
- TAXON_INFORMATION,
+ //assocation:TAXON_INFORMATION,
TAXON_INFORMATION_HISTORY,
- VIRTUAL_COMPONENT,
+ //assocation:VIRTUAL_COMPONENT,
TAXON_NAME_HISTORY,
REFERENCE_DOCUMENT,
AUTHOR,
@@ -77,7 +77,7 @@
TAXON_GROUP_TYPE,
TAXON_GROUP,
TAXON_GROUP_HISTORICAL_RECORD,
- TAXON_GROUP_INFORMATION,
+ //assocation:TAXON_GROUP_INFORMATION,
// CONVERSION
ROUND_WEIGHT_CONVERSION,
@@ -86,8 +86,7 @@
// VESSEL
VESSEL_TYPE,
- VESSEL_REGISTRATION_PERIOD,
-// VESSEL_FLEET_EVENT,
+ //assocation:VESSEL_REGISTRATION_PERIOD,
VESEL_FEATURES,
VESSEL,
@@ -95,7 +94,7 @@
USER_PROFIL,
DEPARTMENT,
PERSON,
- PERSON2USER_PROFIL,
+ //assocation:PERSON2USER_PROFIL,
//ORDER
ORDER_ITEM,
1
0
r392 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro
by blavenier@users.forge.codelutin.com 11 Feb '13
by blavenier@users.forge.codelutin.com 11 Feb '13
11 Feb '13
Author: blavenier
Date: 2013-02-11 16:41:35 +0100 (Mon, 11 Feb 2013)
New Revision: 392
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/392
Log:
Fix :
- Add some database tables to synchronize
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java 2013-02-11 14:40:21 UTC (rev 391)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java 2013-02-11 15:41:35 UTC (rev 392)
@@ -42,42 +42,70 @@
PARAMETER,
MATRIX,
FRACTION,
+ FRACTION2MATRIX,
METHOD,
PMFM,
+ PMFM2QUALITATIVE_VALUE,
// GEAR
GEAR_CLASSIFICATION,
+ GEAR_CLASSIFICATION_ASSOCIATIO,
GEAR,
+ GEAR_ASSOCIATION,
// LOCATION
LOCATION_CLASSIFICATION,
LOCATION_LEVEL,
- //TODO Association LOCATIONAssociation(TableToSynchronize.newId("LOCATIONAssociation")),
+ LOCATION_ASSOCIATION,
LOCATION,
-//TODO Association LOCATIONHierarchy(TableToSynchronize.newId("LOCATIONHierarchy")),
-//TODO Association LOCATIONHierarchyException(TableToSynchronize.newId("LOCATIONHierarchyException")),
+ LOCATION_HIERARCHY,
+ LOCATION_HIERARCHY_EXCEPTION,
// TAXON
TAXONOMIC_LEVEL,
REFERENCE_TAXON,
TAXON_NAME,
+ TAXON_INFORMATION,
+ TAXON_INFORMATION_HISTORY,
+ VIRTUAL_COMPONENT,
+ TAXON_NAME_HISTORY,
+ REFERENCE_DOCUMENT,
+ AUTHOR,
+ CITATION,
// TAXON GROUP
TAXON_GROUP_TYPE,
TAXON_GROUP,
+ TAXON_GROUP_HISTORICAL_RECORD,
+ TAXON_GROUP_INFORMATION,
// CONVERSION
ROUND_WEIGHT_CONVERSION,
WEIGHT_LENGTH_CONVERSION,
+ UNIT_CONVERSION,
// VESSEL
VESSEL_TYPE,
- //TODO Association VESSEL_REGISTRATION_PERIOD(false),
+ VESSEL_REGISTRATION_PERIOD,
// VESSEL_FLEET_EVENT,
+ VESEL_FEATURES,
VESSEL,
+ // PERSON
USER_PROFIL,
DEPARTMENT,
PERSON,
+ PERSON2USER_PROFIL,
+
+ //ORDER
+ ORDER_ITEM,
+ ORDER_ITEM_TYPE,
+ //OTHER
+ PRECISION_TYPE,
+ NUMERICAL_PECISION,
+ PHOTO_TYPE,
+ OBJECT_TYPE,
+ ORDER_TYPE,
+ ANALYSIS_INSTRUMENT
}
1
0
r391 - in trunk/tutti-persistence/src/main: java/fr/ifremer/tutti/persistence/service resources
by blavenier@users.forge.codelutin.com 11 Feb '13
by blavenier@users.forge.codelutin.com 11 Feb '13
11 Feb '13
Author: blavenier
Date: 2013-02-11 15:40:21 +0100 (Mon, 11 Feb 2013)
New Revision: 391
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/391
Log:
Fix :
- fishingOperation add preconditions on date
- save batchSpecies
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2013-02-11 12:45:44 UTC (rev 390)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2013-02-11 14:40:21 UTC (rev 391)
@@ -34,6 +34,7 @@
import org.hibernate.classic.Session;
import org.hibernate.type.Type;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataIntegrityViolationException;
import java.io.Serializable;
import java.util.Iterator;
@@ -50,6 +51,8 @@
private static final Log log =
LogFactory.getLog(AbstractPersistenceService.class);
+ private boolean debug = false;
+
/**
* Session factory.
*
@@ -146,9 +149,23 @@
}
protected <T extends Serializable> T load(Class<? extends T> clazz, Serializable id) {
+ // TODO BLA : ajouter une annotation qui rejoue une méthode
+ // avec debug=true. puis repasse à faux,
+ // lorsqu'une erreur
+ if (debug) {
+ T load = (T) getCurrentSession().get(clazz, id);
+ if (load == null) {
+ throw new DataIntegrityViolationException("Unable to load entity " + clazz.getName() + " with id="+id+" : not found in database.");
+ }
+ }
T load = (T) getCurrentSession().load(clazz, id);
return load;
}
+
+ protected <T extends Serializable> T get(Class<? extends T> clazz, Serializable id) {
+ T load = (T) getCurrentSession().get(clazz, id);
+ return load;
+ }
protected int queryUpdate(String queryName, Object... params) {
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-02-11 12:45:44 UTC (rev 390)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-02-11 14:40:21 UTC (rev 391)
@@ -316,24 +316,21 @@
// Strata :
Integer strataId = (Integer) source[colIndex++];
if (strataId != null) {
- FishingOperationLocation strata = new FishingOperationLocation();
- strata.setId(strataId.toString());
+ FishingOperationLocation strata = referentialService.getFishingOperationLocation(strataId.toString());
result.setStrata(strata);
}
// Sub Strata :
Integer subStrataId = (Integer) source[colIndex++];
if (subStrataId != null) {
- FishingOperationLocation subStrata = new FishingOperationLocation();
- subStrata.setId(subStrataId.toString());
+ FishingOperationLocation subStrata = referentialService.getFishingOperationLocation(subStrataId.toString());
result.setSubStrata(subStrata);
}
// Localite :
Integer localiteId = (Integer) source[colIndex++];
if (localiteId != null) {
- FishingOperationLocation localite = new FishingOperationLocation();
- localite.setId(localiteId.toString());
+ FishingOperationLocation localite = referentialService.getFishingOperationLocation(localiteId.toString());
result.setLocation(localite);
}
@@ -375,6 +372,10 @@
Preconditions.checkNotNull(bean.getId());
Preconditions.checkNotNull(bean.getCruise());
Preconditions.checkNotNull(bean.getCruise().getId());
+
+ if (bean.getGearShootingStartDate() != null && bean.getGearShootingEndDate() != null) {
+ Preconditions.checkArgument(bean.getGearShootingStartDate().equals(bean.getGearShootingEndDate()) == false);
+ }
getCurrentSession().clear();
getCurrentSession().setFlushMode(FlushMode.COMMIT);
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-02-11 12:45:44 UTC (rev 390)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-02-11 14:40:21 UTC (rev 391)
@@ -104,6 +104,15 @@
List<FishingOperationLocation> getAllFishingOperationLocation(String zoneId, String strataId, String subStrataId);
/**
+ * Get a location by id (location could be of any type : strata, substrata, localite, etc.).
+ *
+ * @param id the id of locations to load
+ * @return the locations with given ids
+ * @since 1.0
+ */
+ FishingOperationLocation getFishingOperationLocation(String id);
+
+ /**
* @return all scientific vessels (used by a {@link Cruise}).
* @see Cruise#getVessel()
* @see Cruise#setVessel(List)
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-02-11 12:45:44 UTC (rev 390)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-02-11 14:40:21 UTC (rev 391)
@@ -212,7 +212,27 @@
parentLocationLevelId);
return result;
}
+
+ @Override
+ public FishingOperationLocation getFishingOperationLocation(String id) {
+ Object[] source = queryUnique(
+ "fishingOperationLocationById",
+ "locationId", IntegerType.INSTANCE, Integer.valueOf(id)
+ );
+ if (source == null) {
+ return null;
+ }
+ FishingOperationLocation target = new FishingOperationLocation();
+ target.setId(String.valueOf(source[0]));
+ target.setLabel((String) source[1]);
+ target.setName((String) source[2]);
+ target.setLocationLevel((Integer) source[3]);
+ setStatus((fr.ifremer.adagio.core.dao.referential.Status) source[4], target);
+
+ return target;
+ }
+
@Override
public List<Vessel> getAllScientificVessel() {
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-02-11 12:45:44 UTC (rev 390)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-02-11 14:40:21 UTC (rev 391)
@@ -170,13 +170,18 @@
Preconditions.checkNotNull(bean.getFishingOperation());
Preconditions.checkNotNull(bean.getFishingOperation().getId());
// TODO BLA uncomment this after v1.0 :
- // Preconditions.checkNotNull(bean.getCatchBatch());
+ //Preconditions.checkNotNull(bean.getCatchBatch());
+
+ getCurrentSession().setFlushMode(FlushMode.ALWAYS);
SortingBatch batch = SortingBatch.Factory.newInstance();
beanToEntity(bean, batch, parentBatchId, true);
batch = sortingBatchDao.create(batch);
bean.setId(String.valueOf(batch.getId()));
+
+ getCurrentSession().flush();
+
return bean;
}
@@ -220,7 +225,9 @@
@Override
public void changeSpeciesBatchSpecies(String batchId, Species species) {
- //TODO
+
+ log.debug("Changing species for batch id="+batchId);
+
}
@Override
@@ -330,7 +337,6 @@
// TODO BLA : prendre le service du 1er saisisseur ?
Integer recorderDepartmentId = enumeration.DEPARTMENT_ID_UNKNOWN_RECORDER_DEPARTMENT;
-
// Create lists to store all updates, then remove not updated items
Set<QuantificationMeasurement> notChangedQuantificationMeasurements = new HashSet<QuantificationMeasurement>();
if (target.getQuantificationMeasurements() != null) {
@@ -359,12 +365,12 @@
}
// Weight or SampleCategoryWeight
- if (copyIfNull && source.getWeight() == null) {
+ if (copyIfNull && source.getWeight() == null && source.getSampleCategoryWeight() == null) {
// Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else if (source.getSampleCategoryWeight() != null) {
+ } else if (source.getSampleCategoryWeight() != null && source.getWeight() == null) {
QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target, enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getSampleCategoryWeight(), true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
- } else if (source.getWeight() != null) {
+ } else if (source.getWeight() != null && source.getSampleCategoryWeight() == null) {
QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target, enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -403,7 +409,7 @@
if (copyIfNull && (source.getSpecies() == null || parentBatchId != null)) {
target.setReferenceTaxon(null);
} else if (source.getSpecies() != null && parentBatchId == null) {
- ReferenceTaxon referenceTaxon = load(ReferenceTaxonImpl.class, Integer.valueOf(source.getSpecies().getId()));
+ ReferenceTaxon referenceTaxon = load(ReferenceTaxonImpl.class, Integer.valueOf(source.getSpecies().getReferenceTaxonId()));
target.setReferenceTaxon(referenceTaxon);
}
Modified: trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
===================================================================
--- trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-02-11 12:45:44 UTC (rev 390)
+++ trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-02-11 14:40:21 UTC (rev 391)
@@ -575,6 +575,22 @@
<query-param name="statusValidCode" type="java.lang.String"/>
<query-param name="statusTemporaryCode" type="java.lang.String"/>
</query>
+
+ <query cacheable="true" name="fishingOperationLocationById">
+ <![CDATA[
+ SELECT
+ l.id as locationId,
+ l.label as locationLabel,
+ l.name as locationName,
+ l.locationLevel.id as locationLevelId,
+ l.status as status
+ FROM
+ LocationImpl l
+ WHERE
+ l.id = :locationId
+ ]]>
+ <query-param name="locationId" type="java.lang.Integer"/>
+ </query>
<!-- [REF-04] et [REF-05] Get all vessel for a given vesselType -->
<query cacheable="true" name="allVessels">
1
0
r390 - in trunk/tutti-persistence/src/main: java/fr/ifremer/tutti/persistence/service resources
by blavenier@users.forge.codelutin.com 11 Feb '13
by blavenier@users.forge.codelutin.com 11 Feb '13
11 Feb '13
Author: blavenier
Date: 2013-02-11 13:45:44 +0100 (Mon, 11 Feb 2013)
New Revision: 390
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/390
Log:
Fix :
- do not load Spring context twice
Added:
trunk/tutti-persistence/src/main/resources/tuttiBeanRefFactory.xml
Removed:
trunk/tutti-persistence/src/main/resources/beanRefFactory.xml
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2013-02-11 08:14:47 UTC (rev 389)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2013-02-11 12:45:44 UTC (rev 390)
@@ -42,9 +42,9 @@
}
public static void initTuttiDefault() {
- instance().init("beanRefFactory.xml", "TuttiBeanRefFactory");
+ instance().init("tuttiBeanRefFactory.xml", "TuttiBeanRefFactory");
}
-
+
public static void initTutti(String beanFactoryReferenceLocation,
String beanRefFactoryReferenceId) {
instance().init(beanFactoryReferenceLocation, beanRefFactoryReferenceId);
Deleted: trunk/tutti-persistence/src/main/resources/beanRefFactory.xml
===================================================================
--- trunk/tutti-persistence/src/main/resources/beanRefFactory.xml 2013-02-11 08:14:47 UTC (rev 389)
+++ trunk/tutti-persistence/src/main/resources/beanRefFactory.xml 2013-02-11 12:45:44 UTC (rev 390)
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- #%L
- Tutti :: Persistence API
- $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%
- -->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
-
- <bean id="TuttiBeanRefFactory"
- class="org.springframework.context.support.ClassPathXmlApplicationContext">
- <constructor-arg>
- <list>
- <value>applicationContext-conf.xml</value>
- <value>applicationContext-dataSource-${dataSource.type}.xml</value>
- <value>applicationContext-entities.xml</value>
- <value>applicationContext-service.xml</value>
- <value>applicationContext-service-tutti.xml</value>
- </list>
- </constructor-arg>
- </bean>
-
-</beans>
\ No newline at end of file
Added: trunk/tutti-persistence/src/main/resources/tuttiBeanRefFactory.xml
===================================================================
--- trunk/tutti-persistence/src/main/resources/tuttiBeanRefFactory.xml (rev 0)
+++ trunk/tutti-persistence/src/main/resources/tuttiBeanRefFactory.xml 2013-02-11 12:45:44 UTC (rev 390)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Tutti :: Persistence API
+ $Id: beanRefFactory.xml 300 2013-02-02 14:11:58Z tchemit $
+ $HeadURL: http://svn.forge.codelutin.com/svn/tutti/trunk/tutti-persistence/src/main/r… $
+ %%
+ 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%
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+ <import resource="classpath*:applicationContext-conf.xml"/>
+
+ <bean id="TuttiBeanRefFactory"
+ class="org.springframework.context.support.ClassPathXmlApplicationContext">
+ <constructor-arg>
+ <list>
+ <value>classpath:applicationContext-conf.xml</value>
+ <value>classpath:applicationContext-dataSource-${dataSource.type}.xml</value>
+ <value>classpath:applicationContext-entities.xml</value>
+ <value>classpath:applicationContext-service.xml</value>
+ <value>classpath:applicationContext-service-tutti.xml</value>
+ </list>
+ </constructor-arg>
+ </bean>
+
+</beans>
\ No newline at end of file
1
0
r389 - 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/species content/operation/catches/species/frequency content/operation/catches/species/split content/program content/protocol util
by tchemit@users.forge.codelutin.com 11 Feb '13
by tchemit@users.forge.codelutin.com 11 Feb '13
11 Feb '13
Author: tchemit
Date: 2013-02-11 09:14:47 +0100 (Mon, 11 Feb 2013)
New Revision: 389
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/389
Log:
- debug select - save - cancel of fishing operation (pretty cool ?)
- debug save - cancel of catchBatch
- reformat code
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.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/EditFishingOperationUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.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/CancelEditCatchBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiTabContainerUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -212,7 +212,7 @@
return handler.getModel();
}
- protected <S extends TuttiService> S getService(Class<S> serviceType) {
+ protected <S extends TuttiService> S getService(Class<S> serviceType) {
return getContext().getService(serviceType);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -25,7 +25,6 @@
*/
import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.referential.Gear;
@@ -38,7 +37,6 @@
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.validator.swing.SwingValidator;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -31,12 +31,12 @@
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import org.apache.commons.lang3.StringUtils;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
import java.util.Date;
import java.util.List;
-import org.apache.commons.lang3.StringUtils;
/**
* Model of UI {@link EditCruiseUI}.
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -31,9 +31,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.JOptionPane;
import java.awt.event.ActionEvent;
import java.util.List;
-import javax.swing.JOptionPane;
import static org.nuiton.i18n.I18n._;
@@ -63,16 +63,16 @@
@Override
protected boolean prepareAction(ActionEvent event) {
boolean result = super.prepareAction(event);
-
+
TuttiProtocol protocol = getHandler().getModel().getProtocol();
int answer = JOptionPane.showConfirmDialog(
- getHandler().getUI(),
- _("tutti.action.deleteProtocol.message", protocol.getName()),
+ getHandler().getUI(),
+ _("tutti.action.deleteProtocol.message", protocol.getName()),
_("tutti.action.deleteProtocol.title"),
JOptionPane.OK_CANCEL_OPTION
- );
+ );
result &= answer == JOptionPane.OK_OPTION;
-
+
return result;
}
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-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -140,125 +140,132 @@
return saveCatchBatchAction;
}
+
@Override
- protected void doAction(ActionEvent event) throws Exception {
+ protected boolean prepareAction(ActionEvent event) {
+ boolean canContinue = super.prepareAction(event);
+ if (canContinue && checkPreviousEdit) {
+ FishingOperationsUI ui = getUI();
- if (log.isInfoEnabled()) {
- log.info("Try to edit fishingOperation: " + fishingOperation);
- }
+ final FishingOperationsUIModel model = ui.getModel();
- FishingOperationsUI ui = getUI();
+ FishingOperation editFishingOperation = model.getEditFishingOperation();
- FishingOperationsUIModel model = ui.getModel();
+ String editFishingOperationId = null;
- FishingOperation editFishingOperation = model.getEditFishingOperation();
+ if (editFishingOperation == null) {
- boolean canContinue;
+ // no previous fishing operation in edition, can continue
+ canContinue = true;
+ } else {
- String editFishingOperationId;
+ editFishingOperationId = editFishingOperation.getId();
- if (editFishingOperation == null) {
+ boolean create = TuttiEntities.isNew(editFishingOperation);
- // no previous fishing operation in edition, can continue
- canContinue = true;
- editFishingOperationId = null;
+ // must close current edition
+ String message;
- } else {
+ if (create) {
+ message = _("tutti.dialog.askSaveBeforeLeaving.createFishingOperation");
+ } else {
+ message = _("tutti.dialog.askSaveBeforeLeaving.saveFishingOperation");
+ }
- editFishingOperationId = editFishingOperation.getId();
+ int answer = getHandler().askSaveBeforeLeaving(message);
- boolean create = TuttiEntities.isNew(editFishingOperation);
+ canContinue = false;
+ switch (answer) {
+ case JOptionPane.OK_OPTION:
- // must close current edition
- String message;
+ // persist previous fishing operation
+ getSaveFishingOperationAction().setUpdateUI(false);
+ getSaveFishingOperationAction().actionPerformed(event);
+ getSaveCatchBatchAction().setUpdateUI(false);
+ getSaveCatchBatchAction().actionPerformed(event);
- if (create) {
- message = _("tutti.dialog.askSaveBeforeLeaving.createFishingOperation");
- } else {
- message = _("tutti.dialog.askSaveBeforeLeaving.saveFishingOperation");
- }
+ canContinue = true;
+ break;
- int answer = getHandler().askSaveBeforeLeaving(message);
+ case JOptionPane.NO_OPTION:
- canContinue = false;
- switch (answer) {
- case JOptionPane.OK_OPTION:
+ // won't save modification
+ // so since we will edit a new operation, nothing to do here
- // persist previous fishing operation
- getSaveFishingOperationAction().setUpdateUI(false);
- getSaveFishingOperationAction().actionPerformed(event);
- getSaveCatchBatchAction().setUpdateUI(false);
- getSaveCatchBatchAction().actionPerformed(event);
+ canContinue = true;
+ break;
+ }
+ }
+ if (!canContinue) {
- canContinue = true;
- break;
+ // rollback selected fishing operation
+ FishingOperation selectFishingOperation =
+ model.getFishingOperation(editFishingOperationId);
- case JOptionPane.NO_OPTION:
+ model.setEditionAdjusting(true);
+ try {
+ model.setSelectedFishingOperation(selectFishingOperation);
+ } finally {
+ model.setEditionAdjusting(false);
+ }
+ }
+ }
- // won't save modification
- // so since we will edit a new operation, nothing to do here
+ return canContinue;
+ }
- canContinue = true;
- break;
- }
+ @Override
+ protected void doAction(ActionEvent event) throws Exception {
+
+ if (log.isInfoEnabled()) {
+ log.info("Try to edit fishingOperation: " + fishingOperation);
}
- if (canContinue) {
+ FishingOperationsUI ui = getUI();
- // edit new fishing operation
- if (log.isInfoEnabled()) {
- log.info("Edit in ui fishingOperation: " + fishingOperation);
- }
+ FishingOperationsUIModel model = ui.getModel();
- selectNewFishingOperation(fishingOperation);
+ // edit new fishing operation
+ if (log.isInfoEnabled()) {
+ log.info("Edit in ui fishingOperation: " + fishingOperation);
+ }
- selectNewCatchBatch(fishingOperation);
+ // now fishing operation is edited
+ model.setEditFishingOperation(fishingOperation);
- JTabbedPane form = ui.getTabPane();
- JLabel noContentPane = ui.getNoTraitPane();
+ loadFishingOperation(fishingOperation);
- if (fishingOperation == null) {
+ loadCatchBatch(fishingOperation, true);
- // nothing to display
+ JTabbedPane form = ui.getTabPane();
+ JLabel noContentPane = ui.getNoTraitPane();
- ui.remove(form);
+ if (fishingOperation == null) {
- // just display <no trait!>
- ui.add(noContentPane, BorderLayout.CENTER);
+ // nothing to display
- } else {
+ ui.remove(form);
- ui.remove(noContentPane);
+ // just display <no trait!>
+ ui.add(noContentPane, BorderLayout.CENTER);
- // wait last minute to display (avoid dirty display effects)
- ui.add(form, BorderLayout.CENTER);
- }
-
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- getUI().repaint();
- }
- });
} else {
- // user cancel save of previous bean
+ ui.remove(noContentPane);
- // get previous edit fishing operation (in selection model)
- FishingOperation selectFishingOperation =
- model.getFishingOperation(editFishingOperationId);
+ // wait last minute to display (avoid dirty display effects)
+ ui.add(form, BorderLayout.CENTER);
+ }
- model.setEditionAdjusting(true);
-
- try {
- model.setSelectedFishingOperation(selectFishingOperation);
- } finally {
- model.setEditionAdjusting(false);
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ getUI().repaint();
}
- }
+ });
}
- protected void selectNewFishingOperation(FishingOperation bean) {
+ public void loadFishingOperation(FishingOperation bean) {
EditFishingOperationUI ui = getUI().getFishingOperationTabContent();
@@ -343,7 +350,7 @@
handler.installStartDateListener();
}
- protected void selectNewCatchBatch(FishingOperation bean) {
+ public void loadCatchBatch(FishingOperation bean, boolean loadOtherTabs) {
boolean empty = bean == null || TuttiEntities.isNew(bean);
@@ -401,6 +408,7 @@
decorator.toString(fishingOperation));
}
+
// 3) Propagate title to others tabs
ui.getCatchesCaracteristicsTabPane().setTitle(fishingOperationText);
ui.getSpeciesTabFishingOperationReminderLabel().setTitle(fishingOperationText);
@@ -409,14 +417,18 @@
// ui.getMacroWasteTabFishingOperationReminderLabel().setTitle(fishingOperationText);
// ui.getAccidentalTabFishingOperationReminderLabel().setTitle(fishingOperationText);
- // 4) Propagate new selected fishingoperation to others tabs
+ if (loadOtherTabs) {
- ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean);
+ // 4) Propagate new selected fishingoperation to others tabs
+
+ ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean);
// ui.getBenthosTabContent().getHandler().selectFishingOperation(bean);
// ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean);
// ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean);
// ui.getAccidentalTabContent().getHandler().selectFishingOperation(bean);
+
+ }
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -37,7 +37,6 @@
import fr.ifremer.tutti.persistence.entities.referential.Zone;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.CaracteristicTabUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUIModel;
@@ -318,22 +317,6 @@
}
@Override
- public boolean canCloseUI(TuttiScreen nextScreen) {
- boolean result = !isAModelModified();
- if (!result) {
- int answer = askSaveBeforeLeaving(ui);
- ActionEvent event = new ActionEvent(nextScreen, nextScreen.ordinal(), null);
- switch (answer) {
- case JOptionPane.OK_OPTION:
- doAction(ui.getSaveButton(), event);
- break;
- }
- result = answer == JOptionPane.NO_OPTION;
- }
- return result;
- }
-
- @Override
public boolean onHideTab(int currentIndex, int newIndex) {
boolean result = !isAModelModified();
if (!result) {
@@ -342,10 +325,12 @@
switch (answer) {
case JOptionPane.OK_OPTION:
doAction(ui.getSaveButton(), event);
+ result = true;
break;
case JOptionPane.NO_OPTION:
doAction(ui.getCancelButton(), event);
+ result = true;
break;
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -196,7 +196,7 @@
protected String multirigAggregation;
protected CoordinateEditorType coordinateEditorType;
-
+
protected List<FishingOperation> existingOperations;
protected static Binder<EditFishingOperationUIModel, FishingOperation> toBeanBinder =
@@ -726,7 +726,7 @@
public void setExistingOperations(List<FishingOperation> existingOperations) {
this.existingOperations = existingOperations;
}
-
+
public void convertGearShootingCoordinatesDDToDMS() {
SexagecimalPosition position;
Integer degree;
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-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -160,24 +160,26 @@
} else {
operation = persistenceService.getFishingOperation(newValue.getId());
}
- getModel().setEditFishingOperation(operation);
+ editFishingOperationAction.setFishingOperation(operation);
+ editFishingOperationAction.actionPerformed(null);
+// getModel().setEditFishingOperation(operation);
}
}
});
- model.addPropertyChangeListener(FishingOperationsUIModel.PROPERTY_EDITED_FISHING_OPERATION, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (log.isDebugEnabled()) {
- log.debug("propertyChange " + FishingOperationsUIModel.PROPERTY_EDITED_FISHING_OPERATION);
- }
-
- // only rebuild stuff if model is not adjusting
- editFishingOperationAction.setFishingOperation((FishingOperation) evt.getNewValue());
- editFishingOperationAction.actionPerformed(null);
-
- }
- });
+// model.addPropertyChangeListener(FishingOperationsUIModel.PROPERTY_EDITED_FISHING_OPERATION, new PropertyChangeListener() {
+// @Override
+// public void propertyChange(PropertyChangeEvent evt) {
+// if (log.isDebugEnabled()) {
+// log.debug("propertyChange " + FishingOperationsUIModel.PROPERTY_EDITED_FISHING_OPERATION);
+// }
+//
+// // only rebuild stuff if model is not adjusting
+// editFishingOperationAction.setFishingOperation((FishingOperation) evt.getNewValue());
+// editFishingOperationAction.actionPerformed(null);
+//
+// }
+// });
model.addPropertyChangeListener(FishingOperationsUIModel.PROPERTY_FISHING_OPERATION, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
@@ -208,10 +210,15 @@
@Override
public boolean canCloseUI(TuttiScreen nextScreen) {
- boolean result = super.canCloseUI(nextScreen);
- if (getTabPanel().getSelectedIndex() == 0) {
- result = ui.getFishingOperationTabContent().getHandler().canCloseUI(nextScreen);
- }
+// boolean result = super.canCloseUI(nextScreen);
+ // try to reset current fishing operation, if afterall the fishing operation still
+ // there, it means user cancel save operation, so stay here
+ getUI().getFishingOperationComboBox().setSelectedItem(null);
+// getModel().setSelectedFishingOperation(null);
+ boolean result = getModel().getSelectedFishingOperation() == null;
+// if (getTabPanel().getSelectedIndex() == 0) {
+// result = ui.getFishingOperationTabContent().getHandler().canCloseUI(nextScreen);
+// }
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -24,8 +24,11 @@
* #L%
*/
+import com.google.common.base.Preconditions;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
+import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,6 +57,8 @@
*/
protected boolean updateUI;
+ protected EditFishingOperationAction editAction;
+
public CancelEditCatchBatchAction(EditCatchesUIHandler handler) {
super(handler,
"cancelEditCatchBatch",
@@ -64,21 +69,34 @@
);
}
+ public EditFishingOperationAction getEditAction() {
+ if (editAction == null) {
+ editAction = new EditFishingOperationAction(getHandler().getParentHandler());
+ }
+ return editAction;
+ }
+
@Override
protected void doAction(ActionEvent event) throws Exception {
if (getModel().isCreate()) {
- if (log.isInfoEnabled()) {
- log.info("Cancel creation for catchBatch");
- }
// cancel to create a catch batch ?
-
+ // Should never happen ?
+ Preconditions.checkState(
+ false,
+ "Can't cancel edition of a not persisted catchBatch!");
} else {
if (log.isInfoEnabled()) {
- log.info("Can edition of catchBatch");
+ log.info("Can edition of catchBatch (will reload catchBatch)");
}
+
+ FishingOperation operation = getModel().getFishingOperation();
+
+ //TODO Should we also reload other tabs ??? Probably yes
+
+ getEditAction().loadCatchBatch(operation, false);
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -26,6 +26,7 @@
import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUIHandler;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiTabContainerUIHandler;
import fr.ifremer.tutti.ui.swing.util.TabHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
@@ -35,6 +36,7 @@
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTitledPanel;
+import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
@@ -74,8 +76,10 @@
*/
private final TuttiBeanMonitor<EditCatchesUIModel> catchBatchMonitor;
+ protected final FishingOperationsUI parentUi;
public EditCatchesUIHandler(FishingOperationsUI parentUi, EditCatchesUI ui) {
super(parentUi.getHandler().getContext(), ui);
+ this.parentUi=parentUi;
// this.persistenceService = context.getService(PersistenceService.class);
this.catchBatchMonitor = new TuttiBeanMonitor<EditCatchesUIModel>(
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_WEIGHT,
@@ -135,6 +139,7 @@
return ui.getValidator();
}
+
@Override
protected JTabbedPane getTabPanel() {
return ui.getTabPane();
@@ -145,13 +150,36 @@
//FIXME 20130203 kmorin: cannot change tab if model is modified
// (I do not even know why it is set to modified and have no time
// before the demo)
-// AbstractTuttiBeanUIModel model = getModel();
-// boolean result = model.isValid();
-// if (result && model.isModify()) {
-// save();
-// }
-// return result;
- return true;
+ EditCatchesUIModel model = getModel();
+ boolean result = model.isValid();
+ if (model.isModify()) {
+ int answer = askSaveBeforeLeaving(getUI());
+ switch (answer) {
+ case JOptionPane.OK_OPTION:
+
+ // persist catch batch
+ doAction(getUI().getSaveButton(), null);
+
+ result = true;
+ break;
+
+ case JOptionPane.NO_OPTION:
+
+ // won't save modification
+ // so since we will edit a new operation, nothing to do here
+
+ // persist catch batch
+ doAction(getUI().getCancelButton(), null);
+
+ result = true;
+ break;
+ default:
+
+ // other case, use cancel action
+ result = false;
+ }
+ }
+ return result;
}
@Override
@@ -167,7 +195,15 @@
return catchBatchMonitor;
}
-// public void selectFishingOperation(FishingOperation bean,
+ public FishingOperationsUI getParentUi() {
+ return parentUi;
+ }
+
+ public FishingOperationsUIHandler getParentHandler() {
+ return getParentUi().getHandler();
+ }
+
+ // public void selectFishingOperation(FishingOperation bean,
// String fishingOperationText) {
//
// boolean empty = bean == null;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -28,7 +28,7 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
import org.nuiton.util.beans.Binder;
-import org.nuiton.util.beans.BinderModelBuilder;
+import org.nuiton.util.beans.BinderFactory;
import static org.nuiton.i18n.I18n._;
@@ -80,8 +80,9 @@
public static final String PROPERTY_CATCH_BATCH = "catchBatch";
- protected static final Binder<CatchBatch, EditCatchesUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(CatchBatch.class, EditCatchesUIModel.class)
+ /*protected static final Binder<CatchBatch, EditCatchesUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(CatchBatch.class, EditCatchesUIModel.class)
.addSimpleProperties(
+ PROPERTY_CATCH_TOTAL_WEIGHT,
PROPERTY_SPECIES_TOTAL_WEIGHT,
PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT,
PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT,
@@ -112,8 +113,12 @@
PROPERTY_PLANKTON_TOTAL_WEIGHT,
PROPERTY_PLANKTON_TOTAL_SAMPLE_WEIGHT,
PROPERTY_MACRO_WASTE_TOTAL_WEIGHT
- ).toBinder();
+ ).toBinder();*/
+ protected static final Binder<CatchBatch, EditCatchesUIModel> fromBeanBinder = BinderFactory.newBinder(CatchBatch.class, EditCatchesUIModel.class);
+
+ protected static final Binder<EditCatchesUIModel, CatchBatch> toBeanBinder = BinderFactory.newBinder(EditCatchesUIModel.class, CatchBatch.class);
+
protected Float speciesTotalWeight;
protected Float speciesTotalSortedWeight;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -111,6 +111,7 @@
persistenceService.saveCatchBatch(catchBatch);
monitor.clearModified();
+ getModel().setModify(false);
}
getUI().getSpeciesTabContent().getHandler().clearTableSelection();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -25,9 +25,7 @@
*/
import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -70,21 +68,21 @@
boolean result = super.prepareAction(event);
SpeciesBatchUIHandler handler = getHandler();
-
+
SpeciesBatchTableModel tableModel = handler.getTableModel();
JXTable table = handler.getTable();
SpeciesBatchRowModel row = tableModel.getEntry(table.getSelectedRow());
-
+
SpeciesBatchUIModel model = handler.getModel();
List<Species> speciesList = Lists.newArrayList(model.getAllSpecies());
speciesList.removeAll(
model.getSpeciesUsed().get(
- row.getSortedUnsortedCategoryValue()));
+ row.getSortedUnsortedCategoryValue()));
selectedSpecies = getHandler().openAddSpeciesDialog(
_("tutti.title.selectSpecies"),
speciesList
- );
+ );
result &= selectedSpecies != null;
return result;
@@ -101,17 +99,17 @@
// TODO 20130206 kmorin uncomment the following lines when the service is available
// PersistenceService persistenceService = getContext().getService(PersistenceService.class);
// persistenceService.changeSpeciesBatchSpecies(row.getId(), selectedSpecies);
-
+
Collection<Species> speciesUSed = handler.getModel().getSpeciesUsed()
.get(row.getSortedUnsortedCategoryValue());
speciesUSed.remove(row.getSpecies());
changeChildrenSpecies(row, selectedSpecies);
speciesUSed.add(selectedSpecies);
-
+
selectedSpecies = null;
}
- protected void changeChildrenSpecies(SpeciesBatchRowModel row,
+ protected void changeChildrenSpecies(SpeciesBatchRowModel row,
Species species) {
row.setSpecies(species);
List<SpeciesBatchRowModel> children = row.getBatchChild();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -58,7 +58,7 @@
* @since 0.3
*/
protected Float categoryWeight;
-
+
/**
* Sample computed weight.
*
@@ -112,9 +112,9 @@
}
public boolean isEmpty() {
- return categoryValue == null
- && categoryWeight == null
- && computedWeight == null;
+ return categoryValue == null
+ && categoryWeight == null
+ && computedWeight == null;
}
public boolean isEmptyOrValid() {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -218,7 +218,7 @@
} else {
Float number = sampleCategory.getCategoryWeight();
Float computedNumber = sampleCategory.getComputedWeight();
-
+
text = "<html>" + categoryDecorator.toString(categoryValue) + " / ";
if (number != null) {
@@ -228,7 +228,7 @@
} else {
text += "-";
}
-
+
text += "</html>";
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -59,7 +59,7 @@
public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_VALUE = "sortedUnsortedCategoryValue";
public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT = "sortedUnsortedCategoryWeight";
-
+
public static final String PROPERTY_SORTED_UNSORTED_COMPUTED_WEIGHT = "sortedUnsortedComputedWeight";
public static final String PROPERTY_SIZE_CATEGORY = "sizeCategory";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-02-11 08:14:47 UTC (rev 389)
@@ -156,7 +156,8 @@
<JRadioButton id='filterSpeciesBatchRootButton'
onActionPerformed='model.setTableViewMode(TableViewMode.ROOT)'/>
</JPanel>
- <JButton id='computeSpeciesBatchButton' constraints='BorderLayout.EAST'
+ <JButton id='computeSpeciesBatchButton'
+ constraints='BorderLayout.EAST'
onActionPerformed='handler.computeSpeciesBatch()'/>
</JPanel>
</cell>
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-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -843,20 +843,20 @@
}
row.setComputedNumber(totalNumber);
-
+
SampleCategory finestCategory;
if (row.getAgeCategory().isValid()) {
finestCategory = row.getAgeCategory();
-
+
} else if (row.getMaturityCategory().isValid()) {
finestCategory = row.getMaturityCategory();
-
+
} else if (row.getSexCategory().isValid()) {
finestCategory = row.getSexCategory();
-
+
} else if (row.getSizeCategory().isValid()) {
finestCategory = row.getSizeCategory();
-
+
} else {
finestCategory = row.getSortedUnsortedCategory();
}
@@ -865,7 +865,7 @@
}
}
-
+
public void computeSpeciesBatch() {
Float totalSortedWeight = 0f;
Float totalUnsortedWeight = 0f;
@@ -876,8 +876,8 @@
if (weight == null) {
JOptionPane.showMessageDialog(
ui,
- _("tutti.dialog.catches.species.computeWeight.error.message"),
- _("tutti.dialog.catches.species.computeWeight.error.title"),
+ _("tutti.dialog.catches.species.computeWeight.error.message"),
+ _("tutti.dialog.catches.species.computeWeight.error.title"),
JOptionPane.ERROR_MESSAGE);
totalSortedWeight = null;
totalUnsortedWeight = null;
@@ -912,7 +912,7 @@
sum += weight;
}
}
-
+
SampleCategory finestCategory;
if (row.getAgeCategory().isValid()) {
finestCategory = row.getAgeCategory();
@@ -937,13 +937,13 @@
if (sum != null && weight == null) {
finestCategory.setComputedWeight(sum);
result = sum;
-
+
} else {
result = weight;
}
return result;
}
-
+
protected void saveRows(Iterable<SpeciesBatchRowModel> rows) {
for (SpeciesBatchRowModel row : rows) {
saveRow(row);
@@ -1081,7 +1081,7 @@
if (enableSplit) {
// can split if selected batch is a leaf
- enableSplit = row.isBatchLeaf()
+ enableSplit = row.isBatchLeaf()
&& row.getComputedNumber() == null;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -156,7 +156,7 @@
} else {
// transfer rows to editor
List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList();
-
+
for (SpeciesFrequencyRowModel row : frequencyModel.getRows()) {
if (row.isValid()) {
@@ -174,7 +174,7 @@
editRow.setNumber(null);
}
-
+
// update frequencies total
ui.getHandler().updateTotalFromFrequencies(editRow);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -54,7 +54,7 @@
* @since 0.3
*/
protected final SampleCategory<Serializable> category = SampleCategory.newSample(null);
-
+
protected static final Binder<SplitSpeciesBatchRowModel, SplitSpeciesBatchRowModel> fromBeanBinder =
BinderFactory.newBinder(SplitSpeciesBatchRowModel.class,
SplitSpeciesBatchRowModel.class);
@@ -106,5 +106,5 @@
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-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -46,7 +46,7 @@
SplitSpeciesBatchRowModel.PROPERTY_VALID,
n_("tutti.table.species.sampleCategory.header.selected"),
n_("tutti.table.species.sampleCategory.header.selected"));
-
+
public static final ColumnIdentifier<SplitSpeciesBatchRowModel> EDITABLE_CATEGORY_VALUE = ColumnIdentifier.newId(
SplitSpeciesBatchRowModel.PROPERTY_CATEGORY_VALUE,
n_("tutti.table.species.sampleCategory.header.category"),
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-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -342,7 +342,7 @@
addBooleanColumnToModel(columnModel, SplitSpeciesBatchTableModel.SELECTED, getTable());
}
-
+
boolean editableCategoryValue = false;
if (category != null) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -76,7 +76,7 @@
loadedPrograms.add(persistenceService.getProgram(program.getId()));
}
model.setExistingPrograms(loadedPrograms);
-
+
String surveyId = context.getProgramId();
if (surveyId == null) {
@@ -92,7 +92,7 @@
Program program = persistenceService.getProgram(surveyId);
model.fromBean(program);
-
+
model.getExistingPrograms().remove(program);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIModel.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIModel.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -27,10 +27,11 @@
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.referential.Zone;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
-import java.util.List;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
+import java.util.List;
+
/**
* Bean to edit a program.
*
@@ -52,7 +53,7 @@
protected String comment;
protected Zone zone;
-
+
private List<Program> existingPrograms;
protected static Binder<EditProgramUIModel, Program> toBeanBinder =
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -25,10 +25,8 @@
*/
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.service.TuttiService;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
-import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiTabContainerUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiTabContainerUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiTabContainerUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -55,7 +55,7 @@
protected abstract JTabbedPane getTabPanel();
/**
- * Method called when the user selects a tab
+ * Method called when the user selects a tab.
*
* @param currentIndex
* @param newIndex
1
0
r388 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation: . catches
by tchemit@users.forge.codelutin.com 10 Feb '13
by tchemit@users.forge.codelutin.com 10 Feb '13
10 Feb '13
Author: tchemit
Date: 2013-02-10 16:04:13 +0100 (Sun, 10 Feb 2013)
New Revision: 388
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/388
Log:
begin of save operation cinematic
Added:
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/catches/CancelEditCatchBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java
Removed:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SelectFishingOperationAction.java
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -46,7 +46,12 @@
/** Logger. */
private static final Log log = LogFactory.getLog(SaveFishingOperationAction.class);
- private final SelectFishingOperationAction delegate;
+ /**
+ * Delegate edit action.
+ *
+ * @since 1.0
+ */
+ protected EditFishingOperationAction editAction;
public CancelEditFishingOperationAction(EditFishingOperationUIHandler handler) {
super(handler,
@@ -56,9 +61,15 @@
_("tutti.action.cancel.editFishingOperation.tip"),
true
);
- delegate = new SelectFishingOperationAction(handler.getParentUi().getHandler());
}
+ public EditFishingOperationAction getEditAction() {
+ if (editAction == null) {
+ editAction = new EditFishingOperationAction(getHandler().getParentUi().getHandler());
+ }
+ return editAction;
+ }
+
/**
* If the event source is an EditFishingOperationUIHandler,
* then the tab panel of the parent switch to the index set
@@ -69,38 +80,39 @@
*/
@Override
protected void doAction(ActionEvent event) throws Exception {
- FishingOperationsUI parentUi = getHandler().getParentUi();
- FishingOperationsUIHandler parentHandler = parentUi.getHandler();
+
+ EditFishingOperationAction action = getEditAction();
+
if (getModel().isCreate()) {
if (log.isInfoEnabled()) {
- log.info("Cancel edition for fishingOperation ");
+ log.info("Cancel creation for fishingOperation");
}
// cancel to create a new fishingOperation
- delegate.setFishingOperation(null);
- delegate.doAction(event);
+ action.setFishingOperation(null);
+ action.doAction(event);
-// parentUi.getFishingOperationTabContent().getHandler().selectFishingOperation(null);
-// parentUi.getCatchesTabContent().getHandler().selectFishingOperation(null, "");
-// parentHandler.closeCurrentFishingOperation();
-
} else {
- // reload fishing operation
- delegate.setFishingOperation(parentHandler.getModel().getSelectedFishingOperation());
- delegate.doAction(event);
-// parentHandler.reloadFishingOperation();
+ if (log.isInfoEnabled()) {
+ log.info("Can edition of fishingOperation");
+ }
+
+ // re-edit current fishing operation (but do not perform any check)
+ action.setCheckPreviousEdit(false);
+ action.setFishingOperation(getModel().getFishingOperation());
+ action.actionPerformed(event);
}
- // if called directly from the EditFishingOperationUIHandler:
- // the user does not want to save the modifications before
- // selecting another tab, we must reload the current tab before setting
- // the new index of the tab pane
- if (event.getSource() != null
- && event.getSource().getClass().isAssignableFrom(EditFishingOperationUIHandler.class)) {
-
- int newIndex = event.getID();
- parentHandler.getTabPanel().setSelectedIndex(newIndex);
- }
+// // if called directly from the EditFishingOperationUIHandler:
+// // the user does not want to save the modifications before
+// // selecting another tab, we must reload the current tab before setting
+// // the new index of the tab pane
+// if (event.getSource() != null
+// && event.getSource().getClass().isAssignableFrom(EditFishingOperationUIHandler.class)) {
+//
+// int newIndex = event.getID();
+// parentHandler.getTabPanel().setSelectedIndex(newIndex);
+// }
}
}
Added: 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 (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -0,0 +1,422 @@
+package fr.ifremer.tutti.ui.swing.content.operation;
+
+/*
+ * #%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.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation;
+import fr.ifremer.tutti.persistence.entities.referential.Person;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.SaveCatchBatchAction;
+import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUI;
+import fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUI;
+import fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.decorator.Decorator;
+
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JTabbedPane;
+import javax.swing.SwingUtilities;
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To edit the given fishing operation.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class EditFishingOperationAction extends AbstractTuttiAction<FishingOperationsUIModel, FishingOperationsUI, FishingOperationsUIHandler> {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(EditFishingOperationAction.class);
+
+ /**
+ * The incoming fishing operation to edit.
+ * <p/>
+ * Can be null (means do not edit any fishing operation), or with no id
+ * (means create a ne fishing operation), or with an id (means edit an
+ * existing fishing operation).
+ *
+ * @since 1.0
+ */
+ protected FishingOperation fishingOperation;
+
+ /**
+ * A flag to not check if there is a previous edit.
+ * <p/>
+ * This flag is used when we launch the cancel action.
+ *
+ * @since 1.0
+ */
+ protected boolean checkPreviousEdit = true;
+
+ /**
+ * Delegate action to save Fising Operation.
+ *
+ * @since 1.0
+ */
+ protected SaveFishingOperationAction saveFishingOperationAction;
+
+ /**
+ * Delgate action to save catch batch.
+ *
+ * @since 1.0
+ */
+ protected SaveCatchBatchAction saveCatchBatchAction;
+
+ public EditFishingOperationAction(FishingOperationsUIHandler handler) {
+ super(handler,
+ "editFishingOperation",
+ "edit",
+ null,
+ _("tutti.action.editFishingOperation.tip"),
+ true);
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ }
+
+ public void setCheckPreviousEdit(boolean checkPreviousEdit) {
+ this.checkPreviousEdit = checkPreviousEdit;
+ }
+
+ @Override
+ protected void releaseAction(ActionEvent event) {
+ fishingOperation = null;
+ checkPreviousEdit = true;
+ super.releaseAction(event);
+ }
+
+ protected SaveFishingOperationAction getSaveFishingOperationAction() {
+ if (saveFishingOperationAction == null) {
+ saveFishingOperationAction = new SaveFishingOperationAction(getUI().getFishingOperationTabContent().getHandler());
+ }
+ return saveFishingOperationAction;
+ }
+
+ protected SaveCatchBatchAction getSaveCatchBatchAction() {
+ if (saveCatchBatchAction == null) {
+ saveCatchBatchAction = new SaveCatchBatchAction(getUI().getCatchesTabContent().getHandler());
+ }
+ return saveCatchBatchAction;
+ }
+
+ @Override
+ protected void doAction(ActionEvent event) throws Exception {
+
+ if (log.isInfoEnabled()) {
+ log.info("Try to edit fishingOperation: " + fishingOperation);
+ }
+
+ FishingOperationsUI ui = getUI();
+
+ FishingOperationsUIModel model = ui.getModel();
+
+ FishingOperation editFishingOperation = model.getEditFishingOperation();
+
+ boolean canContinue;
+
+ String editFishingOperationId;
+
+ if (editFishingOperation == null) {
+
+ // no previous fishing operation in edition, can continue
+ canContinue = true;
+ editFishingOperationId = null;
+
+ } else {
+
+ editFishingOperationId = editFishingOperation.getId();
+
+ boolean create = TuttiEntities.isNew(editFishingOperation);
+
+ // must close current edition
+ String message;
+
+ if (create) {
+ message = _("tutti.dialog.askSaveBeforeLeaving.createFishingOperation");
+ } else {
+ message = _("tutti.dialog.askSaveBeforeLeaving.saveFishingOperation");
+ }
+
+ int answer = getHandler().askSaveBeforeLeaving(message);
+
+ canContinue = false;
+ switch (answer) {
+ case JOptionPane.OK_OPTION:
+
+ // persist previous fishing operation
+ getSaveFishingOperationAction().setUpdateUI(false);
+ getSaveFishingOperationAction().actionPerformed(event);
+ getSaveCatchBatchAction().setUpdateUI(false);
+ getSaveCatchBatchAction().actionPerformed(event);
+
+ canContinue = true;
+ break;
+
+ case JOptionPane.NO_OPTION:
+
+ // won't save modification
+ // so since we will edit a new operation, nothing to do here
+
+ canContinue = true;
+ break;
+ }
+ }
+
+ if (canContinue) {
+
+ // edit new fishing operation
+ if (log.isInfoEnabled()) {
+ log.info("Edit in ui fishingOperation: " + fishingOperation);
+ }
+
+ selectNewFishingOperation(fishingOperation);
+
+ selectNewCatchBatch(fishingOperation);
+
+ JTabbedPane form = ui.getTabPane();
+ JLabel noContentPane = ui.getNoTraitPane();
+
+ if (fishingOperation == null) {
+
+ // nothing to display
+
+ ui.remove(form);
+
+ // just display <no trait!>
+ ui.add(noContentPane, BorderLayout.CENTER);
+
+ } else {
+
+ ui.remove(noContentPane);
+
+ // wait last minute to display (avoid dirty display effects)
+ ui.add(form, BorderLayout.CENTER);
+ }
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ getUI().repaint();
+ }
+ });
+ } else {
+
+ // user cancel save of previous bean
+
+ // get previous edit fishing operation (in selection model)
+ FishingOperation selectFishingOperation =
+ model.getFishingOperation(editFishingOperationId);
+
+ model.setEditionAdjusting(true);
+
+ try {
+ model.setSelectedFishingOperation(selectFishingOperation);
+ } finally {
+ model.setEditionAdjusting(false);
+ }
+ }
+ }
+
+ protected void selectNewFishingOperation(FishingOperation bean) {
+
+ EditFishingOperationUI ui = getUI().getFishingOperationTabContent();
+
+ EditFishingOperationUIHandler handler = ui.getHandler();
+
+ EditFishingOperationUIModel editFishingOperationUIModel = ui.getModel();
+
+ handler.uninstallStartDateListener();
+
+ if (bean == null) {
+
+ editFishingOperationUIModel.fromBean(new FishingOperation());
+
+ editFishingOperationUIModel.setFishingOperation(bean);
+
+ handler.clearValidators();
+
+ handler.resetAllModels();
+
+ } else { //if (!bean.equals(editFishingOperationUIModel.getFishingOperation()) || handler.isAModelModified()) {
+
+ FishingOperationLocation strata = bean.getStrata();
+ FishingOperationLocation subStrata = bean.getSubStrata();
+ FishingOperationLocation location = bean.getLocation();
+
+ Cruise cruise = bean.getCruise();
+ if (cruise != null) {
+ // update gear universe
+ ui.getGearComboBox().setData(Lists.newArrayList(cruise.getGear()));
+
+ // update vessel universe
+ ui.getVesselComboBox().setData(Lists.newArrayList(cruise.getVessel()));
+ }
+
+ editFishingOperationUIModel.fromBean(bean);
+
+ // to be sure combo list will be reloaded
+ editFishingOperationUIModel.setStrata(null);
+ editFishingOperationUIModel.setSubStrata(null);
+ editFishingOperationUIModel.setLocation(null);
+ editFishingOperationUIModel.convertGearShootingCoordinatesDDToDMS();
+
+ if (strata != null) {
+ ui.getStrataComboBox().setSelectedItem(strata);
+ }
+
+ if (subStrata != null) {
+ ui.getSubStrataComboBox().setSelectedItem(subStrata);
+ }
+
+ if (location != null) {
+ ui.getLocationComboBox().setSelectedItem(location);
+ }
+
+ editFishingOperationUIModel.setFishingOperation(bean);
+
+ // update saisissuer selection
+ List<Person> saisisseur = editFishingOperationUIModel.getSaisisseur();
+ ui.getSaisisseurList().getModel().setSelected(saisisseur);
+
+ // update model empty property
+ editFishingOperationUIModel.setEmpty(false);
+
+ //reset gear shooting
+ GearShootingTabUI gearShootingTab = ui.getGearShootingTabContent();
+ gearShootingTab.getHandler().reset(bean);
+
+ //reset environment
+ EnvironmentTabUI environmentTab = ui.getEnvironmentTabContent();
+ environmentTab.getHandler().reset(bean);
+
+ //reset hydrology
+ HydrologyTabUI hydrologyTab = ui.getHydrologyTabContent();
+ hydrologyTab.getHandler().reset(bean);
+
+ editFishingOperationUIModel.setModify(false);
+ handler.getFishingOperationMonitor().clearModified();
+
+ handler.registerValidator();
+ }
+
+ handler.installStartDateListener();
+ }
+
+ protected void selectNewCatchBatch(FishingOperation bean) {
+
+ boolean empty = bean == null || TuttiEntities.isNew(bean);
+
+ EditCatchesUI ui = getUI().getCatchesTabContent();
+ TuttiBeanMonitor<EditCatchesUIModel> catchBatchMonitor =
+ ui.getHandler().getCatchBatchMonitor();
+
+ EditCatchesUIModel catchesUIModel = ui.getModel();
+
+ CatchBatch batch;
+
+ if (empty) {
+
+ // create a new CatchBatch
+ if (log.isInfoEnabled()) {
+ log.info("Create a new CatchBatch (fishing operation is null)");
+ }
+ batch = new CatchBatch();
+ batch.setFishingOperation(bean);
+
+ } else {
+
+ String operationId = bean.getId();
+
+ if (log.isInfoEnabled()) {
+ log.info("Load existing CatchBatch from operation id: " +
+ operationId);
+ }
+
+ PersistenceService persistenceService =
+ getService(PersistenceService.class);
+
+ batch = persistenceService.getCatchBatchFromFishingOperation(
+ operationId);
+ batch.setFishingOperation(bean);
+ }
+
+ catchesUIModel.setCatchBatch(batch);
+ catchesUIModel.setFishingOperation(bean);
+
+ catchesUIModel.fromBean(batch);
+
+ catchesUIModel.setModify(false);
+ catchBatchMonitor.clearModified();
+
+ Decorator<FishingOperation> decorator =
+ getDecorator(FishingOperation.class, null);
+
+ String fishingOperationText;
+
+ if (bean == null) {
+ fishingOperationText = null;
+ } else {
+ fishingOperationText = _("tutti.label.traitReminder",
+ decorator.toString(fishingOperation));
+ }
+
+ // 3) Propagate title to others tabs
+ ui.getCatchesCaracteristicsTabPane().setTitle(fishingOperationText);
+ ui.getSpeciesTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+// ui.getBenthosTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+// ui.getPlanktonTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+// ui.getMacroWasteTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+// ui.getAccidentalTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+
+ // 4) Propagate new selected fishingoperation to others tabs
+
+ ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean);
+// ui.getBenthosTabContent().getHandler().selectFishingOperation(bean);
+// ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean);
+// ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean);
+// ui.getAccidentalTabContent().getHandler().selectFishingOperation(bean);
+
+ }
+
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -30,11 +30,9 @@
import com.javadocmd.simplelatlng.LatLngTool;
import com.javadocmd.simplelatlng.util.LengthUnit;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation;
import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
import fr.ifremer.tutti.persistence.entities.referential.Zone;
import fr.ifremer.tutti.service.PersistenceService;
@@ -42,17 +40,13 @@
import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.CaracteristicTabUIModel;
-import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUI;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUIModel;
-import fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUI;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUIModel;
-import fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUI;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUIModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiTabContainerUIHandler;
import fr.ifremer.tutti.ui.swing.util.TabHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.editor.CoordinateEditorType;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.time.DateUtils;
@@ -61,8 +55,6 @@
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
-import java.awt.Color;
-import java.awt.Component;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -101,43 +93,8 @@
getModel().setGearShootingEndDate(newDate);
}
}
- };
-
- private final PropertyChangeListener coordinatePropertiesListener = new PropertyChangeListener() {
- private List<String> properties = Lists.newArrayList(
- EditFishingOperationUIModel.PROPERTY_FISHING_OPERATION_RECTILIGNE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DECIMAL_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_SECOND,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DECIMAL_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_SECOND,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DECIMAL_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_SECOND,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DECIMAL_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_SECOND
- );
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (properties.contains(evt.getPropertyName())) {
- EditFishingOperationUIModel source = (EditFishingOperationUIModel) evt.getSource();
- if (source.isFishingOperationRectiligne()) {
- source.computeDictance();
- }
- }
- }
};
/**
@@ -180,24 +137,6 @@
EditFishingOperationUIModel model = new EditFishingOperationUIModel();
model.setCoordinateEditorType(getConfig().getCoordinateEditorType());
model.setValidationContext(getContext().getValidationContext());
-
-// model.addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_EMPTY, new PropertyChangeListener() {
-// @Override
-// public void propertyChange(PropertyChangeEvent evt) {
-// JPanel form = ui.getFishingOperationPane();
-// JLabel noContentPane = ui.getNoTraitPane();
-//
-// Boolean empty = (Boolean) evt.getNewValue();
-// ui.remove(form);
-// ui.remove(noContentPane);
-// if (empty) {
-// ui.add(noContentPane, BorderLayout.CENTER);
-// } else {
-// ui.add(form, BorderLayout.CENTER);
-// }
-// ui.repaint();
-// }
-// });
model.addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_STRATA, new PropertyChangeListener() {
@Override
@@ -217,23 +156,26 @@
}
});
- model.addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_FISHING_OPERATION_VALID, new PropertyChangeListener() {
+ model.addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_FISHING_OPERATION_RECTILIGNE, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
- Boolean valid = (Boolean) evt.getNewValue();
- Color color = null;
- Color fontColor = Color.BLACK;
- if (valid == Boolean.TRUE) {
- color = Color.GREEN;
+ Boolean rectiligne = (Boolean) evt.getNewValue();
+ if (rectiligne) {
+ EditFishingOperationUIModel source = (EditFishingOperationUIModel) evt.getSource();
+ Float latS = source.getGearShootingStartLatitude();
+ Float longS = source.getGearShootingStartLongitude();
+ Float latE = source.getGearShootingEndLatitude();
+ Float longE = source.getGearShootingEndLongitude();
- } else if (valid == Boolean.FALSE) {
- color = Color.RED;
- fontColor = Color.WHITE;
+ if (latS != null && longS != null
+ && latE != null && longE != null) {
+ LatLng start = new LatLng(latS, longS);
+ LatLng end = new LatLng(latE, longE);
+ Double distance = LatLngTool.distance(start, end, LengthUnit.METER);
+ source.setTrawlDistance(distance.floatValue());
+ }
}
- Component tab = getTabPanel().getTabComponentAt(0);
- tab.setForeground(fontColor);
- tab.setBackground(color);
}
});
@@ -412,6 +354,10 @@
@Override
public void onShowTab(int currentIndex, int newIndex) {
+// registerValidators(ui.getValidator());
+ }
+
+ public void registerValidator() {
registerValidators(ui.getValidator());
}
@@ -437,94 +383,96 @@
};
}
- public void clearFishingOperation() {
- EditFishingOperationUIModel model = getModel();
- model.fromBean(new FishingOperation());
+// public void clearFishingOperation() {
+// EditFishingOperationUIModel model = getModel();
+// model.fromBean(new FishingOperation());
+//
+// model.setModify(false);
+// fishingOperationMonitor.clearModified();
+//
+// model.setEmpty(true);
+//
+// }
- model.setModify(false);
- fishingOperationMonitor.clearModified();
+// public void selectFishingOperation(FishingOperation bean) {
+// boolean empty = bean == null;
+//
+// EditFishingOperationUIModel editFishingOperationUIModel = getModel();
+//
+// uninstallStartDateListener();
+//
+// if (empty || !bean.equals(editFishingOperationUIModel.getFishingOperation()) || isAModelModified()) {
+// if (empty) {
+// bean = new FishingOperation();
+// }
+//
+// FishingOperationLocation strata = bean.getStrata();
+// FishingOperationLocation subStrata = bean.getSubStrata();
+// FishingOperationLocation location = bean.getLocation();
+//
+// Cruise cruise = bean.getCruise();
+// if (cruise != null) {
+// // update gear universe
+// ui.getGearComboBox().setData(Lists.newArrayList(cruise.getGear()));
+//
+// // update vessel universe
+// ui.getVesselComboBox().setData(Lists.newArrayList(cruise.getVessel()));
+// }
+//
+// editFishingOperationUIModel.fromBean(bean);
+//
+// // to be sure combo list will be reloaded
+// editFishingOperationUIModel.setStrata(null);
+// editFishingOperationUIModel.setSubStrata(null);
+// editFishingOperationUIModel.setLocation(null);
+// editFishingOperationUIModel.convertGearShootingCoordinatesDDToDMS();
+//
+// if (strata != null) {
+// ui.getStrataComboBox().setSelectedItem(strata);
+// }
+//
+// if (subStrata != null) {
+// ui.getSubStrataComboBox().setSelectedItem(subStrata);
+// }
+//
+// if (location != null) {
+// ui.getLocationComboBox().setSelectedItem(location);
+// }
+//
+// editFishingOperationUIModel.setFishingOperation(bean);
+//
+// // update saisissuer selection
+// List<Person> saisisseur = editFishingOperationUIModel.getSaisisseur();
+// ui.getSaisisseurList().getModel().setSelected(saisisseur);
+//
+// // update model empty property
+// editFishingOperationUIModel.setEmpty(empty);
+//
+// //reset gear shooting
+// GearShootingTabUI gearShootingTab = ui.getGearShootingTabContent();
+// gearShootingTab.getHandler().reset(bean);
+//
+// //reset environment
+// EnvironmentTabUI environmentTab = ui.getEnvironmentTabContent();
+// environmentTab.getHandler().reset(bean);
+//
+// //reset hydrology
+// HydrologyTabUI hydrologyTab = ui.getHydrologyTabContent();
+// hydrologyTab.getHandler().reset(bean);
+//
+// editFishingOperationUIModel.setModify(false);
+// fishingOperationMonitor.clearModified();
+//
+// editFishingOperationUIModel.addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_DATE, startDateListener);
+// }
+// }
- model.setEmpty(true);
-
+ public void uninstallStartDateListener() {
+ getModel().removePropertyChangeListener(EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_DATE, startDateListener);
}
- public void selectFishingOperation(FishingOperation bean) {
- boolean empty = bean == null;
-
- EditFishingOperationUIModel model = getModel();
-
- model.removePropertyChangeListener(EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_DATE, startDateListener);
- model.removePropertyChangeListener(coordinatePropertiesListener);
-
- if (empty || !bean.equals(model.getFishingOperation()) || isAModelModified()) {
- if (empty) {
- bean = new FishingOperation();
- }
-
- List<FishingOperation> operations = parentUi.getModel().getFishingOperation();
- operations.remove(bean);
- model.setExistingOperations(operations);
-
- FishingOperationLocation strata = bean.getStrata();
- FishingOperationLocation subStrata = bean.getSubStrata();
- FishingOperationLocation location = bean.getLocation();
-
- Cruise cruise = bean.getCruise();
- if (cruise != null) {
- // update gear universe
- ui.getGearComboBox().setData(Lists.newArrayList(cruise.getGear()));
-
- // update vessel universe
- ui.getVesselComboBox().setData(Lists.newArrayList(cruise.getVessel()));
- }
-
- model.fromBean(bean);
-
- // to be sure combo list will be reloaded
- model.setStrata(null);
- model.setSubStrata(null);
- model.setLocation(null);
- model.convertGearShootingCoordinatesDDToDMS();
-
- if (strata != null) {
- ui.getStrataComboBox().setSelectedItem(strata);
- }
-
- if (subStrata != null) {
- ui.getSubStrataComboBox().setSelectedItem(subStrata);
- }
-
- if (location != null) {
- ui.getLocationComboBox().setSelectedItem(location);
- }
-
- model.setFishingOperation(bean);
-
- // update saisissuer selection
- List<Person> saisisseur = model.getSaisisseur();
- ui.getSaisisseurList().getModel().setSelected(saisisseur);
-
- // update model empty property
- model.setEmpty(empty);
-
- //reset gear shooting
- GearShootingTabUI gearShootingTab = ui.getGearShootingTabContent();
- gearShootingTab.getHandler().reset(bean);
-
- //reset environment
- EnvironmentTabUI environmentTab = ui.getEnvironmentTabContent();
- environmentTab.getHandler().reset(bean);
-
- //reset hydrology
- HydrologyTabUI hydrologyTab = ui.getHydrologyTabContent();
- hydrologyTab.getHandler().reset(bean);
-
- model.setModify(false);
- fishingOperationMonitor.clearModified();
-
- model.addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_DATE, startDateListener);
- model.addPropertyChangeListener(coordinatePropertiesListener);
- }
+ public void installStartDateListener() {
+ getModel().addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_DATE, startDateListener);
}
public FishingOperationsUI getParentUi() {
@@ -576,8 +524,6 @@
if (CollectionUtils.isEmpty(subStrata)) {
// try to load localite
-
-
ui.getLocationComboBox().grabFocus();
}
}
@@ -629,4 +575,12 @@
return result;
}
+ protected void resetAllModels() {
+
+ for (CaracteristicTabUIModel subModel : getSubModels()) {
+ subModel.setModify(false);
+ }
+ getModel().setModify(false);
+ }
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2013-02-10 15:04:13 UTC (rev 388)
@@ -58,7 +58,7 @@
<Table fill='both' id='topPanel' constraints='BorderLayout.NORTH'>
- <!-- FishingOperations fishingOperation -->
+ <!-- Cruise fishingOperations -->
<row>
<cell anchor='west' weightx='1.0'>
<BeanComboBox id='fishingOperationComboBox' constructorParams='this'
@@ -70,8 +70,7 @@
</row>
</Table>
- <JLabel id='noTraitPane' constraints='BorderLayout.CENTER'/>
-
+ <!-- Current selected fishingOperation -->
<JTabbedPane id='tabPane'>
<tab id='fishingOperationTab' title='tutti.label.tab.fishingOperation'>
<EditFishingOperationUI id='fishingOperationTabContent'
@@ -82,4 +81,7 @@
</tab>
</JTabbedPane>
+ <!-- When no fishing operation selected -->
+ <JLabel id='noTraitPane' constraints='BorderLayout.CENTER'/>
+
</JPanel>
\ No newline at end of file
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-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -41,9 +41,6 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;
-import java.util.Timer;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
/**
* Handler of UI {@link FishingOperationsUI}.
@@ -59,13 +56,8 @@
private final PersistenceService persistenceService;
- private static final ExecutorService executorService =
- Executors.newSingleThreadExecutor();
+ protected EditFishingOperationAction editFishingOperationAction;
- private static final Timer t = new Timer();
-
- protected SelectFishingOperationAction selectFishingOperationAction;
-
public FishingOperationsUIHandler(TuttiUI parentUI,
FishingOperationsUI ui) {
super(parentUI.getHandler().getContext(), ui);
@@ -138,10 +130,11 @@
initUI(ui);
- selectFishingOperationAction = createAction(SelectFishingOperationAction.class);
+ editFishingOperationAction =
+ createAction(EditFishingOperationAction.class);
+
FishingOperationsUIModel model = getModel();
-
List<FishingOperation> fishingOperations = model.getFishingOperation();
initBeanComboBox(ui.getFishingOperationComboBox(),
@@ -155,16 +148,36 @@
log.debug("propertyChange " + FishingOperationsUIModel.PROPERTY_SELECTED_FISHING_OPERATION);
}
- if (!getModel().isValueIsAdjusting()) {
+ if (!getModel().isEditionAdjusting()) {
- // only rebuild stuff if model is not adjusting
- selectFishingOperationAction.setFishingOperation((FishingOperation) evt.getNewValue());
- selectFishingOperationAction.actionPerformed(null);
-// selectFishingOperation((FishingOperation) evt.getNewValue());
+ // selected fishing operation is now the editing one
+
+ FishingOperation newValue = (FishingOperation) evt.getNewValue();
+
+ FishingOperation operation;
+ if (newValue == null) {
+ operation = null;
+ } else {
+ operation = persistenceService.getFishingOperation(newValue.getId());
+ }
+ getModel().setEditFishingOperation(operation);
}
}
});
+ model.addPropertyChangeListener(FishingOperationsUIModel.PROPERTY_EDITED_FISHING_OPERATION, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (log.isDebugEnabled()) {
+ log.debug("propertyChange " + FishingOperationsUIModel.PROPERTY_EDITED_FISHING_OPERATION);
+ }
+
+ // only rebuild stuff if model is not adjusting
+ editFishingOperationAction.setFishingOperation((FishingOperation) evt.getNewValue());
+ editFishingOperationAction.actionPerformed(null);
+
+ }
+ });
model.addPropertyChangeListener(FishingOperationsUIModel.PROPERTY_FISHING_OPERATION, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
@@ -212,78 +225,4 @@
return ui.getTabPane();
}
-// public void selectFishingOperation(FishingOperation fishingOperation) {
-//
-// if (log.isInfoEnabled()) {
-// log.info("New selected fishingOperation: " + fishingOperation);
-// }
-//
-// // back to general tab of fishingOperation tabs
-// ui.getFishingOperationTabContent().getFishingOperationTabPane().setSelectedIndex(0);
-//
-// if (fishingOperation != null) {
-// Decorator<FishingOperation> decorator =
-// getDecorator(FishingOperation.class, null);
-//
-// String fishingOperationText =
-// _("tutti.label.traitReminder",
-// decorator.toString(fishingOperation));
-//
-// // propagate fishingOperation to his tabs
-// ui.getFishingOperationTabContent().getHandler().selectFishingOperation(fishingOperation);
-// if (ui.getFishingOperationTabContent().getModel().isCreate()) {
-// // back to fishingOperation tab
-// ui.getTabPane().setSelectedIndex(0);
-// }
-//
-// ui.getCatchesTabContent().getHandler().selectFishingOperation(fishingOperation,
-// fishingOperationText);
-//
-// // repaint tabs
-// ui.getTabPane().repaint();
-//
-// } else {
-// ui.getFishingOperationTabContent().getHandler().clearFishingOperation();
-// // back to fishingOperation tab
-// ui.getTabPane().setSelectedIndex(0);
-// }
-// }
-
-// public void closeCurrentFishingOperation() {
-// ui.getFishingOperationTabContent().getHandler().selectFishingOperation(null);
-// ui.getCatchesTabContent().getHandler().selectFishingOperation(null, "");
-// }
-
-// public void saveFishingOperation(FishingOperation toSave) {
-//
-// // persist the fishingOperation
-//
-// boolean create = toSave.getId() == null;
-// FishingOperationsUIModel model = getModel();
-// FishingOperation savedFishingOperation;
-//
-// if (create) {
-//
-// savedFishingOperation = persistenceService.createFishingOperation(toSave);
-// model.addFishingOperation(savedFishingOperation);
-// model.setSelectedFishingOperation(savedFishingOperation);
-//
-// } else {
-// savedFishingOperation = persistenceService.saveFishingOperation(toSave);
-//
-// // add the saved fishingOperation to fishingOperation list
-// List<FishingOperation> data = model.getFishingOperation();
-//
-// FishingOperation existingFishingOperation =
-// TuttiEntities.findById(data, savedFishingOperation.getId());
-// model.updateFishingOperation(existingFishingOperation, savedFishingOperation);
-// }
-// }
-
-// public void reloadFishingOperation() {
-// FishingOperation operation = getModel().getSelectedFishingOperation();
-// selectFishingOperation(operation);
-// }
-
-
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -24,8 +24,12 @@
* #L%
*/
+import com.ezware.oxbow.swingbits.util.Preconditions;
import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jdesktop.beans.AbstractSerializableBean;
import java.util.List;
@@ -40,16 +44,68 @@
private static final long serialVersionUID = 1L;
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(FishingOperationsUIModel.class);
+
public static final String PROPERTY_FISHING_OPERATION = "fishingOperation";
public static final String PROPERTY_SELECTED_FISHING_OPERATION = "selectedFishingOperation";
+ public static final String PROPERTY_EDITED_FISHING_OPERATION = "editedFishingOperation";
+
+ /**
+ * List of existing fishing operation for the selected cruise.
+ * <p/>
+ * <strong>Note:</strong> These objects are not fully loaded, they will
+ * never be edited.
+ *
+ * @since 0.1
+ */
protected List<FishingOperation> fishingOperation;
+ /**
+ * Selected fishing operation in the combo box.
+ * <p/>
+ * For example if you create a new fishing operation then
+ * {@code selectedFishingOperation} will be {@code null}.
+ * <p/>
+ * <strong>Note:</strong> These object ise not fully loaded, they will
+ * never be edited.
+ *
+ * @since 0.1
+ */
protected FishingOperation selectedFishingOperation;
- private boolean valueIsAdjusting;
+ /**
+ * Current editied fishing operation.
+ *
+ * @since 1.0
+ */
+ protected FishingOperation editFishingOperation;
+ /**
+ * Flag to not listen the {@link #selectedFishingOperation}
+ * changes while adjusting the model.
+ * <p/>
+ * When flag is {@code true}, then the changes of the
+ * {@link #selectedFishingOperation} should not trigger any changes.
+ *
+ * @since 1.0
+ */
+ protected boolean selectionAdjusting;
+
+ /**
+ * Flag to not listen the {@link #editFishingOperation}
+ * changes while adjusting the model.
+ * <p/>
+ * When flag is {@code true}, then the changes of the
+ * {@link #editFishingOperation} should not trigger any changes.
+ *
+ * @since 1.0
+ */
+ protected boolean editionAdjusting;
+
public List<FishingOperation> getFishingOperation() {
return fishingOperation;
}
@@ -72,15 +128,21 @@
firePropertyChange(PROPERTY_FISHING_OPERATION, oldValue, this.fishingOperation);
}
- public void updateFishingOperation(FishingOperation oldFishingOperation,
- FishingOperation newFishingOperation) {
+ public void updateFishingOperation(FishingOperation newFishingOperation) {
+
+ Preconditions.checkNotNull(newFishingOperation);
+ String id = newFishingOperation.getId();
+ Preconditions.checkNotNull(id);
+ FishingOperation oldFishingOperation = getFishingOperation(id);
+ Preconditions.checkNotNull(oldFishingOperation);
+
+ if (log.isInfoEnabled()) {
+ log.info("Update existing fishing operation: " + id);
+ }
+
int oldFishingOperationIndex = fishingOperation.indexOf(oldFishingOperation);
fishingOperation.remove(oldFishingOperation);
- if (oldFishingOperationIndex >= 0) {
- fishingOperation.add(oldFishingOperationIndex, newFishingOperation);
- } else {
- fishingOperation.add(newFishingOperation);
- }
+ fishingOperation.add(oldFishingOperationIndex, newFishingOperation);
firePropertyChange(PROPERTY_FISHING_OPERATION, null, fishingOperation);
}
@@ -91,14 +153,46 @@
public void setSelectedFishingOperation(FishingOperation selectedFishingOperation) {
Object oldValue = getSelectedFishingOperation();
this.selectedFishingOperation = selectedFishingOperation;
- firePropertyChange(PROPERTY_SELECTED_FISHING_OPERATION, oldValue, selectedFishingOperation);
+ if (!isSelectionAdjusting()) {
+
+ // only fires when authorize to
+ firePropertyChange(PROPERTY_SELECTED_FISHING_OPERATION, oldValue, selectedFishingOperation);
+ }
}
- public void setValueIsAdjusting(boolean valueIsAdjusting) {
- this.valueIsAdjusting = valueIsAdjusting;
+ public FishingOperation getEditFishingOperation() {
+ return editFishingOperation;
}
- public boolean isValueIsAdjusting() {
- return valueIsAdjusting;
+ public void setEditFishingOperation(FishingOperation editFishingOperation) {
+ Object oldValue = getEditFishingOperation();
+ this.editFishingOperation = editFishingOperation;
+ if (!isEditionAdjusting()) {
+
+ // only fires when authorize to
+ firePropertyChange(PROPERTY_EDITED_FISHING_OPERATION, oldValue, editFishingOperation);
+ }
}
+
+ public boolean isSelectionAdjusting() {
+ return selectionAdjusting;
+ }
+
+ public void setSelectionAdjusting(boolean selectionAdjusting) {
+ this.selectionAdjusting = selectionAdjusting;
+ }
+
+ public boolean isEditionAdjusting() {
+ return editionAdjusting;
+ }
+
+ public void setEditionAdjusting(boolean editionAdjusting) {
+ this.editionAdjusting = editionAdjusting;
+ }
+
+ public FishingOperation getFishingOperation(String id) {
+ FishingOperation result =
+ TuttiEntities.findById(fishingOperation, id);
+ return result;
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -37,7 +37,7 @@
import static org.nuiton.i18n.I18n._;
/**
- * TODO
+ * To create a new fishing operation.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.0
@@ -46,7 +46,12 @@
private static final long serialVersionUID = 1L;
- private final SelectFishingOperationAction delegate;
+ /**
+ * Delegate action to edit new FishingOperation.
+ *
+ * @since 1.0
+ */
+ protected EditFishingOperationAction editFishingOperationAction;
public NewFishingOperationAction(FishingOperationsUIHandler handler) {
super(handler,
@@ -55,8 +60,6 @@
null,
_("tutti.action.newFishingOperation.tip"),
true);
-
- delegate = new SelectFishingOperationAction(getHandler());
}
@Override
@@ -64,45 +67,50 @@
FishingOperationsUIModel model = getModel();
- model.setValueIsAdjusting(true);
+ // deselect selected fishingOperation
+ // Will remove the selection fishing operation from the comboBox
+ model.setEditionAdjusting(true);
try {
- // deselect selected fishingOperation
model.setSelectedFishingOperation(null);
+ } finally {
+ model.setEditionAdjusting(false);
+ }
- // use a new empty fishingOperation
- FishingOperation newFishingOperation = new FishingOperation();
- Cruise cruise = TuttiUIUtil.getCruise(getContext());
- newFishingOperation.setCruise(cruise);
+ // creates a empty bean
- //TODO Should select vessel from possible one ?
- List<Vessel> vessels = cruise.getVessel();
- if (vessels.size() == 1) {
- newFishingOperation.setVessel(vessels.get(0));
- }
+ FishingOperation newFishingOperation = new FishingOperation();
+ Cruise cruise = TuttiUIUtil.getCruise(getContext());
+ newFishingOperation.setCruise(cruise);
- //TODO Should select gear from possible one ?
- List<Gear> gears = cruise.getGear();
- if (gears.size() == 1) {
- newFishingOperation.setGear(gears.get(0));
- }
+ //TODO Should select vessel from possible one ?
+ List<Vessel> vessels = cruise.getVessel();
+ if (vessels.size() == 1) {
+ newFishingOperation.setVessel(vessels.get(0));
+ }
- if (cruise.getMultirigNumber() == 1) {
- newFishingOperation.setMultirigAggregation("1");
- }
+ //TODO Should select gear from possible one ?
+ List<Gear> gears = cruise.getGear();
+ if (gears.size() == 1) {
+ newFishingOperation.setGear(gears.get(0));
+ }
- // by default use the current day with no time information
-// Date currentDate = DateUtils.setMinutes(
-// DateUtils.setHours(new Date(), 0), 0);
+ if (cruise.getMultirigNumber() == 1) {
+ newFishingOperation.setMultirigAggregation("1");
+ }
- newFishingOperation.setGearShootingStartDate(null);
- newFishingOperation.setGearShootingEndDate(null);
+ newFishingOperation.setGearShootingStartDate(null);
+ newFishingOperation.setGearShootingEndDate(null);
- delegate.setFishingOperation(newFishingOperation);
- delegate.doAction(event);
+ getEditFishingOperationAction().setFishingOperation(newFishingOperation);
+ getEditFishingOperationAction().actionPerformed(event);
- } finally {
- model.setValueIsAdjusting(false);
+ }
+
+ public EditFishingOperationAction getEditFishingOperationAction() {
+ if (editFishingOperationAction == null) {
+ editFishingOperationAction = new EditFishingOperationAction(getHandler());
}
+ return editFishingOperationAction;
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -27,10 +27,10 @@
import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.CaracteristicTabUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUIModel;
@@ -41,7 +41,6 @@
import org.apache.commons.logging.LogFactory;
import java.awt.event.ActionEvent;
-import java.util.List;
import static org.nuiton.i18n.I18n._;
@@ -56,8 +55,17 @@
private static final long serialVersionUID = 1L;
/** Logger. */
- private static final Log log = LogFactory.getLog(SaveFishingOperationAction.class);
+ private static final Log log =
+ LogFactory.getLog(SaveFishingOperationAction.class);
+
+ /**
+ * A flag to update ui after create or save the edit fishing operation.
+ *
+ * @since 1.0
+ */
+ protected boolean updateUI;
+
public SaveFishingOperationAction(EditFishingOperationUIHandler handler) {
super(handler,
"saveFishingOperation",
@@ -68,6 +76,16 @@
);
}
+ public void setUpdateUI(boolean updateUI) {
+ this.updateUI = updateUI;
+ }
+
+ @Override
+ protected void releaseAction(ActionEvent event) {
+ updateUI = true;
+ super.releaseAction(event);
+ }
+
/**
* If the event source is an EditFishingOperationUIHandler,
* then the tab panel of the parent switch to the index set
@@ -75,13 +93,11 @@
* If the event source is a TuttiScreen, then the screen changes to the source.
*
* @param event
- * @throws Exception
*/
@Override
protected void doAction(ActionEvent event) {
EditFishingOperationUIHandler handler = getHandler();
- FishingOperationsUIHandler parentHandler = getHandler().getParentUi().getHandler();
TuttiBeanMonitor<EditFishingOperationUIModel> monitor =
handler.getFishingOperationMonitor();
@@ -89,13 +105,14 @@
// previous fishingOperation was modified, let's save it
EditFishingOperationUIModel beanToSave = monitor.getBean();
- if (beanToSave.isEmpty()) {
+ // must save when bean is new or was modifiy and is valid
+ boolean mustSave = (beanToSave.isCreate() || !beanToSave.isEmpty()) &&
+ beanToSave.isValid();
- // user must use save button
- if (log.isWarnEnabled()) {
- log.warn("Won't save new fishing operation, use explicit save button instead...");
- }
- } else if (beanToSave.isValid()) {
+ if (mustSave) {
+
+ // prepare model
+
if (beanToSave.getCoordinateEditorType() != CoordinateEditorType.DD) {
beanToSave.convertGearShootingCoordinatesDMSToDD();
}
@@ -119,7 +136,7 @@
}
}
- handler.showInformationMessage(
+ sendMessage(
"[ Trait - Caractéristiques générales ] " +
"Sauvegarde des modifications de " + decorate(toSave) +
".");
@@ -132,47 +149,61 @@
monitor.clearModified();
getModel().setModify(false);
- // persist current fishingOperation
saveFishingOperation(toSave);
}
- if (event.getSource() != null) {
- Class<?> sourceClass = event.getSource().getClass();
- if (sourceClass.isAssignableFrom(EditFishingOperationUIHandler.class)) {
- int newIndex = event.getID();
- parentHandler.getTabPanel().setSelectedIndex(newIndex);
-
- } else if (sourceClass.isAssignableFrom(TuttiScreen.class)) {
- TuttiScreen nextScreen = (TuttiScreen) event.getSource();
- getContext().setScreen(nextScreen);
- }
- }
+// if (event.getSource() != null) {
+// Class<?> sourceClass = event.getSource().getClass();
+// if (sourceClass.isAssignableFrom(EditFishingOperationUIHandler.class)) {
+// int newIndex = event.getID();
+// parentHandler.getTabPanel().setSelectedIndex(newIndex);
+//
+// } else if (sourceClass.isAssignableFrom(TuttiScreen.class)) {
+// TuttiScreen nextScreen = (TuttiScreen) event.getSource();
+// getContext().setScreen(nextScreen);
+// }
+// }
}
protected void saveFishingOperation(FishingOperation toSave) {
- PersistenceService service =
- getContext().getService(PersistenceService.class);
+ PersistenceService service = getService(PersistenceService.class);
- boolean create = toSave.getId() == null;
- FishingOperationsUIModel model = getHandler().getParentUi().getModel();
+ boolean create = TuttiEntities.isNew(toSave);
+
+ FishingOperationsUIModel model =
+ getHandler().getParentUi().getModel();
FishingOperation savedFishingOperation;
if (create) {
+ // create fishing operation
savedFishingOperation = service.createFishingOperation(toSave);
+
+ // create then the CatchBatch
+ CatchBatch catchBatch = new CatchBatch();
+ catchBatch.setFishingOperation(savedFishingOperation);
+ service.createCatchBatch(catchBatch);
+
+ // add new created fishing operation to list
model.addFishingOperation(savedFishingOperation);
+
+ // select it (will reload editing fishing operation)
model.setSelectedFishingOperation(savedFishingOperation);
} else {
- savedFishingOperation = service.saveFishingOperation(toSave);
- // add the saved fishingOperation to fishingOperation list
- List<FishingOperation> data = model.getFishingOperation();
+ model.setEditionAdjusting(true);
- FishingOperation existingFishingOperation =
- TuttiEntities.findById(data, savedFishingOperation.getId());
- model.updateFishingOperation(existingFishingOperation, savedFishingOperation);
+ try {
+ // save fishing operation
+ savedFishingOperation = service.saveFishingOperation(toSave);
+
+ // reinject it in model
+ model.updateFishingOperation(savedFishingOperation);
+ } finally {
+ model.setEditionAdjusting(false);
+ }
}
}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SelectFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SelectFishingOperationAction.java 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SelectFishingOperationAction.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -1,140 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation;
-
-/*
- * #%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 fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.decorator.Decorator;
-
-import javax.swing.JLabel;
-import javax.swing.JTabbedPane;
-import javax.swing.SwingUtilities;
-import java.awt.BorderLayout;
-import java.awt.event.ActionEvent;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class SelectFishingOperationAction extends AbstractTuttiAction<FishingOperationsUIModel, FishingOperationsUI, FishingOperationsUIHandler> {
-
- private static final long serialVersionUID = 1L;
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(SelectFishingOperationAction.class);
-
- protected FishingOperation fishingOperation;
-
- public SelectFishingOperationAction(FishingOperationsUIHandler handler) {
- super(handler,
- "selectFishingOperation",
- "select",
- null,
- _("tutti.action.selectFishingOperation.tip"),
- true);
- }
-
- public void setFishingOperation(FishingOperation fishingOperation) {
- this.fishingOperation = fishingOperation;
- }
-
- @Override
- protected void releaseAction(ActionEvent event) {
- fishingOperation = null;
- super.releaseAction(event);
- }
-
- @Override
- protected void doAction(ActionEvent event) throws Exception {
-
- if (log.isInfoEnabled()) {
- log.info("New selected fishingOperation: " + fishingOperation);
- }
-
- FishingOperationsUI ui = getHandler().getUi();
-
- JTabbedPane form = ui.getTabPane();
- JLabel noContentPane = ui.getNoTraitPane();
-
- if (fishingOperation == null) {
-
- // nothing to display
-
- ui.remove(form);
-
- // just display <no trait!>
- ui.add(noContentPane, BorderLayout.CENTER);
-
- } else {
-
- // select a fishing operation
-
- Decorator<FishingOperation> decorator =
- getDecorator(FishingOperation.class, null);
-
- String fishingOperationText =
- _("tutti.label.traitReminder",
- decorator.toString(fishingOperation));
-
- // propagate fishingOperation to his tabs
- ui.getFishingOperationTabContent().getHandler().selectFishingOperation(fishingOperation);
- if (ui.getFishingOperationTabContent().getModel().isCreate()) {
-
- // back to fishingOperation tab
- ui.getTabPane().setSelectedIndex(0);
- }
-
- ui.getCatchesTabContent().getHandler().selectFishingOperation(fishingOperation,
- fishingOperationText);
-
- // back to general tab of fishingOperation tabs
- ui.getFishingOperationTabContent().getFishingOperationTabPane().setSelectedIndex(0);
-
- ui.remove(noContentPane);
-
- // wait last minute to display (avoid dirty display effects)
- ui.add(form, BorderLayout.CENTER);
-
- // repaint tabs
-// ui.getTabPane().repaint();
-
- }
-
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- getHandler().getUi().repaint();
- }
- });
-
- }
-}
\ No newline at end of file
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -0,0 +1,87 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches;
+
+/*
+ * #%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 fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To cancel edit of a {@link CatchBatch}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class CancelEditCatchBatchAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CancelEditCatchBatchAction.class);
+
+ /**
+ * A flag to update ui after create or save the edit catch batch.
+ *
+ * @since 1.0
+ */
+ protected boolean updateUI;
+
+ public CancelEditCatchBatchAction(EditCatchesUIHandler handler) {
+ super(handler,
+ "cancelEditCatchBatch",
+ "cancel",
+ _("tutti.action.cancelEditCatchBatch"),
+ _("tutti.action.cancelEditCatchBatch.tip"),
+ true
+ );
+ }
+
+ @Override
+ protected void doAction(ActionEvent event) throws Exception {
+
+ if (getModel().isCreate()) {
+ if (log.isInfoEnabled()) {
+ log.info("Cancel creation for catchBatch");
+ }
+
+ // cancel to create a catch batch ?
+
+ } else {
+
+ if (log.isInfoEnabled()) {
+ log.info("Can edition of catchBatch");
+ }
+ }
+
+ }
+
+
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -24,11 +24,6 @@
* #L%
*/
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiTabContainerUIHandler;
@@ -36,7 +31,6 @@
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import jaxx.runtime.swing.CardLayout2Ext;
import jaxx.runtime.validator.swing.SwingValidator;
-import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTitledPanel;
@@ -45,6 +39,7 @@
import javax.swing.JTabbedPane;
import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -65,24 +60,24 @@
private static final Log log =
LogFactory.getLog(EditCatchesUIHandler.class);
- /**
- * Persistence service.
- *
- * @since 0.3
- */
- private final PersistenceService persistenceService;
+// /**
+// * Persistence service.
+// *
+// * @since 0.3
+// */
+// private final PersistenceService persistenceService;
/**
* To monitor changes on the incoming fishing operation.
*
* @since 0.3
*/
- private final TuttiBeanMonitor<EditCatchesUIModel> fishingOperationMonitor;
+ private final TuttiBeanMonitor<EditCatchesUIModel> catchBatchMonitor;
public EditCatchesUIHandler(FishingOperationsUI parentUi, EditCatchesUI ui) {
super(parentUi.getHandler().getContext(), ui);
- this.persistenceService = context.getService(PersistenceService.class);
- this.fishingOperationMonitor = new TuttiBeanMonitor<EditCatchesUIModel>(
+// this.persistenceService = context.getService(PersistenceService.class);
+ this.catchBatchMonitor = new TuttiBeanMonitor<EditCatchesUIModel>(
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_WEIGHT,
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT,
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT,
@@ -105,7 +100,7 @@
listModelIsModify(model);
- fishingOperationMonitor.setBean(model);
+ catchBatchMonitor.setBean(model);
}
@Override
@@ -168,108 +163,113 @@
//-- Public methods --//
//------------------------------------------------------------------------//
- public void selectFishingOperation(FishingOperation bean,
- String fishingOperationText) {
-
- boolean empty = bean == null;
- Preconditions.checkState(!empty, "can not edit a null fishing operation.");
- boolean newOperation = TuttiEntities.isNew(bean);
- boolean wasModified = fishingOperationMonitor.wasModified();
-
- // 1) Save any modification of the current fishingOperation
-
- if (wasModified) {
- save();
- }
-
- ui.getSpeciesTabContent().getHandler().clearTableSelection();
-// ui.getBenthosTabContent().getHandler().clearTableSelection();
-// ui.getPlanktonTabContent().getHandler().clearTableSelection();
-// ui.getMacroWasteTabContent().getHandler().clearTableSelection();
-// ui.getAccidentalTabContent().getHandler().clearTableSelection();
-
- // 2) Use new selected fishingOperation
-
- EditCatchesUIModel model = getModel();
-
- boolean otherOperation =
- ObjectUtils.notEqual(bean, model.getFishingOperation());
-
- if (empty || newOperation || otherOperation || wasModified) {
-
- CatchBatch batch;
-
- if (empty || newOperation) {
-
- // create a new CatchBatch
- if (log.isInfoEnabled()) {
- log.info("Create a new CatchBatch");
- }
- batch = new CatchBatch();
- batch.setFishingOperation(bean);
-
- } else {
-
- String operationId = bean.getId();
-
- if (log.isInfoEnabled()) {
- log.info("Load existing CatchBatch from operation id: " +
- operationId);
- }
-
- batch = persistenceService.getCatchBatchFromFishingOperation(
- operationId);
-
-// model.setCatchBatch(batch);
-// model.setFishingOperation(bean);
- }
-
- model.setCatchBatch(batch);
- model.setFishingOperation(bean);
-
- model.fromBean(batch);
-
- model.setModify(false);
- fishingOperationMonitor.clearModified();
-
- // 3) Propagate title to others tabs
- ui.getCatchesCaracteristicsTabPane().setTitle(fishingOperationText);
- ui.getSpeciesTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-// ui.getBenthosTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-// ui.getPlanktonTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-// ui.getMacroWasteTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-// ui.getAccidentalTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-
- // 4) Propagate new selected fishingoperation to others tabs
-
- ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean);
-// ui.getBenthosTabContent().getHandler().selectFishingOperation(bean);
-// ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean);
-// ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean);
-// ui.getAccidentalTabContent().getHandler().selectFishingOperation(bean);
-
- ui.getTabPane().repaint();
- }
+ public TuttiBeanMonitor<EditCatchesUIModel> getCatchBatchMonitor() {
+ return catchBatchMonitor;
}
- protected void save() {
- // previous fishingOperation was modified, let's save it
- EditCatchesUIModel beanToSave = fishingOperationMonitor.getBean();
+// public void selectFishingOperation(FishingOperation bean,
+// String fishingOperationText) {
+//
+// boolean empty = bean == null;
+// Preconditions.checkState(!empty, "can not edit a null fishing operation.");
+// boolean newOperation = TuttiEntities.isNew(bean);
+// boolean wasModified = fishingOperationMonitor.wasModified();
+//
+// // 1) Save any modification of the current fishingOperation
+//
+// if (wasModified) {
+// save();
+// }
+//
+// ui.getSpeciesTabContent().getHandler().clearTableSelection();
+//// ui.getBenthosTabContent().getHandler().clearTableSelection();
+//// ui.getPlanktonTabContent().getHandler().clearTableSelection();
+//// ui.getMacroWasteTabContent().getHandler().clearTableSelection();
+//// ui.getAccidentalTabContent().getHandler().clearTableSelection();
+//
+// // 2) Use new selected fishingOperation
+//
+// EditCatchesUIModel catchesUIModel = getModel();
+//
+// boolean otherOperation =
+// ObjectUtils.notEqual(bean, catchesUIModel.getFishingOperation());
+//
+// if (empty || newOperation || otherOperation || wasModified) {
+//
+// CatchBatch batch;
+//
+// if (empty || newOperation) {
+//
+// // create a new CatchBatch
+// if (log.isInfoEnabled()) {
+// log.info("Create a new CatchBatch");
+// }
+// batch = new CatchBatch();
+// batch.setFishingOperation(bean);
+//
+// } else {
+//
+// String operationId = bean.getId();
+//
+// if (log.isInfoEnabled()) {
+// log.info("Load existing CatchBatch from operation id: " +
+// operationId);
+// }
+//
+// batch = persistenceService.getCatchBatchFromFishingOperation(
+// operationId);
+//
+//// model.setCatchBatch(batch);
+//// model.setFishingOperation(bean);
+// }
+//
+// catchesUIModel.setCatchBatch(batch);
+// catchesUIModel.setFishingOperation(bean);
+//
+// catchesUIModel.fromBean(batch);
+//
+// catchesUIModel.setModify(false);
+// fishingOperationMonitor.clearModified();
+//
+// // 3) Propagate title to others tabs
+// ui.getCatchesCaracteristicsTabPane().setTitle(fishingOperationText);
+// ui.getSpeciesTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+//// ui.getBenthosTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+//// ui.getPlanktonTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+//// ui.getMacroWasteTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+//// ui.getAccidentalTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+//
+// // 4) Propagate new selected fishingoperation to others tabs
+//
+// ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean);
+//// ui.getBenthosTabContent().getHandler().selectFishingOperation(bean);
+//// ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean);
+//// ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean);
+//// ui.getAccidentalTabContent().getHandler().selectFishingOperation(bean);
+//
+// ui.getTabPane().repaint();
+// }
+// }
- CatchBatch catchBatch = beanToSave.toBean();
+// public void save() {
+//
+// // previous fishingOperation was modified, let's save it
+// EditCatchesUIModel beanToSave = catchBatchMonitor.getBean();
+//
+// CatchBatch catchBatch = beanToSave.toBean();
+//
+// if (log.isInfoEnabled()) {
+// log.info("FishingOperation " + catchBatch.getId() +
+// " was modified, will save it.");
+// }
+//
+// showInformationMessage(
+// "[ Captures - Caractéristiques générales ] " +
+// "Sauvegarde des modifications du résumé de la capture.");
+//
+// persistenceService.saveCatchBatch(catchBatch);
+// }
- if (log.isInfoEnabled()) {
- log.info("FishingOperation " + catchBatch.getId() +
- " was modified, will save it.");
- }
-
- showInformationMessage(
- "[ Captures - Caractéristiques générales ] " +
- "Sauvegarde des modifications du résumé de la capture.");
-
- persistenceService.saveCatchBatch(catchBatch);
- }
-
protected void registerValidators() {
registerValidators(getValidator(), ui.getSpeciesTabContent().getHandler().getValidator());
}
@@ -289,17 +289,17 @@
if (CREATE_BATCH_CARD.equals(card)) {
tuttiUi = ui.getSpeciesTabCreateBatch();
titlePanel = ui.getSpeciesTabCreateBatchReminderLabel();
- title = "tutti.title.createBatch";
+ title = n_("tutti.title.createBatch");
} else if (SPLIT_BATCH_CARD.equals(card)) {
tuttiUi = ui.getSpeciesTabSplitBatch();
titlePanel = ui.getSpeciesTabSplitBatchReminderLabel();
- title = "tutti.title.splitBatch";
+ title = n_("tutti.title.splitBatch");
} else if (EDIT_FREQUENCY_CARD.equals(card)) {
tuttiUi = ui.getSpeciesTabFrequencyEditor();
titlePanel = ui.getSpeciesTabFrequencyEditorReminderLabel();
- title = "tutti.title.editFrequency";
+ title = n_("tutti.title.editFrequency");
}
if (tuttiUi != null) {
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -0,0 +1,120 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches;
+
+/*
+ * #%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 fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To save a {@link CatchBatch}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class SaveCatchBatchAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(SaveCatchBatchAction.class);
+
+
+ /**
+ * A flag to update ui after create or save the edit catch batch.
+ *
+ * @since 1.0
+ */
+ protected boolean updateUI;
+
+ public SaveCatchBatchAction(EditCatchesUIHandler handler) {
+ super(handler,
+ "saveCatchBatch",
+ "save",
+ _("tutti.action.saveCatchBatch"),
+ _("tutti.action.saveCatchBatch.tip"),
+ true
+ );
+ }
+
+ public void setUpdateUI(boolean updateUI) {
+ this.updateUI = updateUI;
+ }
+
+ @Override
+ protected void releaseAction(ActionEvent event) {
+ updateUI = true;
+ super.releaseAction(event);
+ }
+
+ @Override
+ protected void doAction(ActionEvent event) {
+
+ EditCatchesUIHandler handler = getHandler();
+
+ TuttiBeanMonitor<EditCatchesUIModel> monitor =
+ handler.getCatchBatchMonitor();
+
+ // previous fishingOperation was modified, let's save it
+ EditCatchesUIModel beanToSave = monitor.getBean();
+
+ // must save when bean is new or was modifiy and is valid
+ boolean mustSave = (beanToSave.isCreate() || beanToSave.isModify()) &&
+ beanToSave.isValid();
+
+ if (mustSave) {
+
+ PersistenceService persistenceService =
+ getService(PersistenceService.class);
+
+ CatchBatch catchBatch = beanToSave.toBean();
+
+ if (log.isInfoEnabled()) {
+ log.info("FishingOperation " + catchBatch.getId() +
+ " was modified, will save it.");
+ }
+
+ getHandler().showInformationMessage(
+ "[ Captures - Caractéristiques générales ] " +
+ "Sauvegarde des modifications du résumé de la capture.");
+
+ persistenceService.saveCatchBatch(catchBatch);
+
+ monitor.clearModified();
+ }
+
+ getUI().getSpeciesTabContent().getHandler().clearTableSelection();
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r387 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches
by tchemit@users.forge.codelutin.com 10 Feb '13
by tchemit@users.forge.codelutin.com 10 Feb '13
10 Feb '13
Author: tchemit
Date: 2013-02-10 16:03:24 +0100 (Sun, 10 Feb 2013)
New Revision: 387
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/387
Log:
add cancel - save actions on catchBatch ui
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.jaxx
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-02-10 15:02:42 UTC (rev 386)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-02-10 15:03:24 UTC (rev 387)
@@ -252,3 +252,11 @@
#observationIndividuelTab {
enabled: {false};
}
+
+#saveButton {
+ _tuttiAction: {SaveCatchBatchAction.class};
+}
+
+#cancelButton {
+ _tuttiAction: {CancelEditCatchBatchAction.class};
+}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-02-10 15:02:42 UTC (rev 386)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-02-10 15:03:24 UTC (rev 387)
@@ -344,4 +344,13 @@
</tab>
</JTabbedPane>
+ <!-- Actions -->
+ <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.SOUTH'>
+ <JPanel id='createFishingOperationActions' layout='{new GridLayout(1,0)}'
+ constraints='BorderLayout.CENTER'>
+ <JButton id='cancelButton'/>
+ <JButton id='saveButton'/>
+ </JPanel>
+ </JPanel>
+
</JPanel>
\ No newline at end of file
1
0
r386 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing
by tchemit@users.forge.codelutin.com 10 Feb '13
by tchemit@users.forge.codelutin.com 10 Feb '13
10 Feb '13
Author: tchemit
Date: 2013-02-10 16:02:42 +0100 (Sun, 10 Feb 2013)
New Revision: 386
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/386
Log:
open api
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-02-10 15:02:10 UTC (rev 385)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-02-10 15:02:42 UTC (rev 386)
@@ -356,7 +356,7 @@
}
}
- protected void clearValidators() {
+ public void clearValidators() {
MainUI main = context.getMainUI();
Preconditions.checkNotNull(
main, "No mainUI registred in application context");
1
0