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
November 2013
- 5 participants
- 100 discussions
r1396 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create resources/i18n
by tchemit@users.forge.codelutin.com 26 Nov '13
by tchemit@users.forge.codelutin.com 26 Nov '13
26 Nov '13
Author: tchemit
Date: 2013-11-26 17:19:57 +0100 (Tue, 26 Nov 2013)
New Revision: 1396
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1396
Log:
fixes #3869: [CAPTURE] harmoniser les intitul?\195?\169s des boutons cr?\195?\169er - cr?\195?\169er et fermer
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUI.jaxx
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUI.jaxx 2013-11-26 16:16:18 UTC (rev 1395)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUI.jaxx 2013-11-26 16:19:57 UTC (rev 1396)
@@ -137,7 +137,6 @@
<JPanel layout='{new GridLayout(1, 0)}' constraints='BorderLayout.SOUTH'>
<JButton id='cancelButton' onActionPerformed='handler.cancel()'/>
<JButton id='saveAndContinueButton' onActionPerformed='handler.saveAndContinue()'/>
- <!--<JButton id='saveFromBatchAndCloseButton' onActionPerformed='handler.saveFromBatchAndClose()'/>-->
<JButton id='saveAndCloseButton' onActionPerformed='handler.saveAndClose()'/>
</JPanel>
</JPanel>
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-11-26 16:16:18 UTC (rev 1395)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-11-26 16:19:57 UTC (rev 1396)
@@ -242,7 +242,7 @@
tutti.createIndividualObservationBatch.action.saveAndClose=Créer et Fermer
tutti.createIndividualObservationBatch.action.saveAndClose.mnemonic=F
tutti.createIndividualObservationBatch.action.saveAndClose.tip=Créer l'observation individuelle et fermer
-tutti.createIndividualObservationBatch.action.saveAndContinue=Créer et Continuer
+tutti.createIndividualObservationBatch.action.saveAndContinue=Créer
tutti.createIndividualObservationBatch.action.saveAndContinue.mnemonic=C
tutti.createIndividualObservationBatch.action.saveAndContinue.tip=Créer et saisir une nouvelle observation indidivuelle
tutti.createIndividualObservationBatch.confirm.alreadyUsedSpecies.help=Que voulez-vous faire?<ul><li><strong>Annuler</strong> pour annuler la création des données individuelles</li><li><strong>Ok</strong> pour confirmer la création des données individuellesd</li></ul>
1
0
r1395 - in trunk/tutti-service/src: main/java/fr/ifremer/tutti/service test/java/fr/ifremer/tutti/service/export/generic
by tchemit@users.forge.codelutin.com 26 Nov '13
by tchemit@users.forge.codelutin.com 26 Nov '13
26 Nov '13
Author: tchemit
Date: 2013-11-26 17:16:18 +0100 (Tue, 26 Nov 2013)
New Revision: 1395
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1395
Log:
fixes #3870: [CAPTURE] observation individuelle : sur les crit?\195?\168res ajout?\195?\169s il apparait des parenth?\195?\168ses devant le titre du crit?\195?\168re ()
Modified:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-11-26 15:04:11 UTC (rev 1394)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-11-26 16:16:18 UTC (rev 1395)
@@ -40,6 +40,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+import org.apache.commons.lang3.StringUtils;
import org.nuiton.decorator.Decorator;
import org.nuiton.decorator.DecoratorProvider;
@@ -112,7 +113,9 @@
registerTuttiDecorator(Person.class, "${firstName}$s#${lastName}$s#${department}$s", SEPARATOR, " ");
registerTuttiDecorator(Caracteristic.class, "${parameterName}$s#${matrixName}$s#${fractionName}$s#${methodName}$s", SEPARATOR, " - ");
registerTuttiDecorator(Caracteristic.class, CARACTERISTIC_PARAMETER_ONLY, "${parameterName}$s", SEPARATOR, " - ");
- registerTuttiDecorator(Caracteristic.class, CARACTERISTIC_PARAMETER_ONLY_WITH_UNIT, "${parameterName}$s (${unit}$s)", SEPARATOR, " - ");
+// registerTuttiDecorator(Caracteristic.class, CARACTERISTIC_PARAMETER_ONLY_WITH_UNIT, "${parameterName}$s (${unit}$s)", SEPARATOR, " - ");
+ registerDecorator(CARACTERISTIC_PARAMETER_ONLY_WITH_UNIT, new SimpleCaracteristicDecorator("${parameterName}$s"));
+
registerTuttiDecorator(CaracteristicQualitativeValue.class, "${description}$s", SEPARATOR, " - ");
registerTuttiDecorator(SpeciesProtocol.class, "${speciesReferenceTaxonId}", SEPARATOR, " - ");
registerTuttiDecorator(Attachment.class, "${name}$s", SEPARATOR, " - ");
@@ -132,7 +135,8 @@
registerDecorator(new SpeciesDecorator());
registerDecorator(FROM_PROTOCOL, new SpeciesFromProtocolDecorator());
- registerTuttiDecorator(Caracteristic.class, CARACTERISTIC_WITH_UNIT, "${parameterName}$s#${matrixName}$s#${fractionName}$s#${methodName}$s (${unit}$s)", SEPARATOR, " - ");
+// registerTuttiDecorator(Caracteristic.class, CARACTERISTIC_WITH_UNIT, "${parameterName}$s#${matrixName}$s#${fractionName}$s#${methodName}$s (${unit}$s)", SEPARATOR, " - ");
+ registerDecorator(CARACTERISTIC_WITH_UNIT, new SimpleCaracteristicDecorator("${parameterName}$s#${matrixName}$s#${fractionName}$s#${methodName}$s"));
TuttiDecorator<FishingOperation> fishingOperationTuttiDecorator = (TuttiDecorator<FishingOperation>) getDecoratorByType(FishingOperation.class);
fishingOperationTuttiDecorator.setSortOnlyOnSelectedContext(true);
@@ -207,6 +211,26 @@
}
}
+ public static class SimpleCaracteristicDecorator extends TuttiDecorator<Caracteristic> implements Cloneable {
+
+ private static final long serialVersionUID = 1L;
+
+ public SimpleCaracteristicDecorator(String firstPart) throws IllegalArgumentException, NullPointerException {
+ super(Caracteristic.class, firstPart + "#${unit}$s", DecoratorService.SEPARATOR, " ");
+ }
+
+ @Override
+ protected Object getValue(Caracteristic bean, String token) {
+ Object result = super.getValue(bean, token);
+
+ if (Caracteristic.PROPERTY_UNIT.equals(token) &&
+ StringUtils.isNotBlank((String) result)) {
+ result = "(" + result + ")";
+ }
+ return result;
+ }
+ }
+
public static class SpeciesFromProtocolDecorator extends TuttiDecorator<Species> implements Cloneable {
private static final long serialVersionUID = 1L;
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java 2013-11-26 15:04:11 UTC (rev 1394)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java 2013-11-26 16:16:18 UTC (rev 1395)
@@ -112,35 +112,35 @@
public static final String CATCH_CONTENT_2 =
"Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;Taxon;Nom_scientifique;Commentaire;V_HV;Num_Ordre_V_HV_H2;Tot_V_HV;Ech_V_HV;Type_Volume_Poids_V_HV;Unite_Volume_Poids_V_HV;Class_Tri_;Num_Ordre_Class_Tri__H2;Tot_Class_Tri_;Ech_Class_Tri_;Type_Volume_Poids_Class_Tri_;Unite_Volume_Poids_Class_Tri_;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;365;Aequipecten opercularis;taxon;Vrac;1;0.005;0.005;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.005;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;491;Alloteuthis;taxon;Vrac;2;0.004;0.004;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.004;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;300;Buccinum undatum;taxon;Vrac;3;0.015;0.015;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.015;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1811;Callionymus lyra;taxon;Vrac;4;0.07;0.07;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.07;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1644;Dicentrarchus labrax;taxon;Vrac;5;1.06;1.06;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;36.0;1;;cm;1.0;1;1.06;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1644;Dicentrarchus labrax;taxon;Vrac;5;1.06;1.06;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;38.0;2;;cm;1.0;1;1.06;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1362;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;1;;cm;0.5;2;0.038;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1362;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;12.5;2;;cm;0.5;1;0.038;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1362;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;13.0;3;;cm;0.5;1;0.038;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1986;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;25.0;1;;cm;1.0;1;0.66;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1986;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;28.0;2;;cm;1.0;1;0.66;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1986;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;30.0;3;;cm;1.0;1;0.66;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;489;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;9.0;1;;cm;1.0;1;0.28;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;489;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;10.0;2;;cm;1.0;3;0.28;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;489;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;11.0;3;;cm;1.0;2;0.28;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1988;Microstomus kitt;taxon;Vrac;9;0.152;0.152;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;15.0;1;;cm;1.0;1;0.152;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1988;Microstomus kitt;taxon;Vrac;9;0.152;0.152;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;18.0;2;;cm;1.0;1;0.152;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1690;Mullus surmuletus;taxon;Vrac;10;0.036;0.036;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;11.0;1;;cm;1.0;1;0.036;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1978;Pleuronectes platessa;taxon;Vrac;11;0.852;0.852;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;26.0;1;;cm;1.0;1;0.852;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1978;Pleuronectes platessa;taxon;Vrac;11;0.852;0.852;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;30.0;2;;cm;1.0;1;0.852;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1351;Sardina pilchardus;taxon;Vrac;12;0.022;0.022;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;1;;cm;0.5;1;0.022;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1772;Scomber scombrus;taxon;Vrac;13;0.18;0.18;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;27.0;1;;cm;1.0;1;0.18;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1242;Scyliorhinus canicula;taxon|categorie_individu;Vrac;14;;;Poids;kg;NA;;;;;kg;Femelle;1;1.0;1.0;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;51.0;1;;cm;1.0;1;1.0;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1242;Scyliorhinus canicula;taxon|categorie_individu;Vrac;14;;;Poids;kg;NA;;;;;kg;Femelle;1;1.0;1.0;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;55.0;2;;cm;1.0;1;1.0;1.0;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;8.0;1;;cm;1.0;1;0.96;136.71875;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;9.0;2;;cm;1.0;20;0.96;136.71875;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;10.0;3;;cm;1.0;89;0.96;136.71875;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;11.0;4;;cm;1.0;5;0.96;136.71875;\n" +
- "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;G - Gros;2;0.13;0.13;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;23.0;1;;cm;1.0;1;0.13;1009.6154;";
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;365;Aequipecten opercularis;taxon;Vrac;1;0.005;0.005;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.005;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;491;Alloteuthis;taxon;Vrac;2;0.004;0.004;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.004;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;300;Buccinum undatum;taxon;Vrac;3;0.015;0.015;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.015;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1811;Callionymus lyra;taxon;Vrac;4;0.07;0.07;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.07;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1644;Dicentrarchus labrax;taxon;Vrac;5;1.06;1.06;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;36.0;1;;cm;1.0;1;1.06;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1644;Dicentrarchus labrax;taxon;Vrac;5;1.06;1.06;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;38.0;2;;cm;1.0;1;1.06;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1362;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;1;;cm;0.5;2;0.038;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1362;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;12.5;2;;cm;0.5;1;0.038;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1362;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;13.0;3;;cm;0.5;1;0.038;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1986;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;25.0;1;;cm;1.0;1;0.66;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1986;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;28.0;2;;cm;1.0;1;0.66;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1986;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;30.0;3;;cm;1.0;1;0.66;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;489;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;9.0;1;;cm;1.0;1;0.28;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;489;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;10.0;2;;cm;1.0;3;0.28;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;489;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;11.0;3;;cm;1.0;2;0.28;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1988;Microstomus kitt;taxon;Vrac;9;0.152;0.152;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;15.0;1;;cm;1.0;1;0.152;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1988;Microstomus kitt;taxon;Vrac;9;0.152;0.152;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;18.0;2;;cm;1.0;1;0.152;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1690;Mullus surmuletus;taxon;Vrac;10;0.036;0.036;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;11.0;1;;cm;1.0;1;0.036;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1978;Pleuronectes platessa;taxon;Vrac;11;0.852;0.852;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;26.0;1;;cm;1.0;1;0.852;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1978;Pleuronectes platessa;taxon;Vrac;11;0.852;0.852;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;30.0;2;;cm;1.0;1;0.852;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1351;Sardina pilchardus;taxon;Vrac;12;0.022;0.022;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;1;;cm;0.5;1;0.022;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1772;Scomber scombrus;taxon;Vrac;13;0.18;0.18;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;27.0;1;;cm;1.0;1;0.18;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1242;Scyliorhinus canicula;taxon|categorie_individu;Vrac;14;;;Poids;kg;NA;;;;;kg;Femelle;1;1.0;1.0;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;51.0;1;;cm;1.0;1;1.0;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1242;Scyliorhinus canicula;taxon|categorie_individu;Vrac;14;;;Poids;kg;NA;;;;;kg;Femelle;1;1.0;1.0;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;55.0;2;;cm;1.0;1;1.0;1.0001919;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;8.0;1;;cm;1.0;1;0.96;136.69289;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;9.0;2;;cm;1.0;20;0.96;136.69289;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;10.0;3;;cm;1.0;89;0.96;136.69289;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;11.0;4;;cm;1.0;5;0.96;136.69289;\n" +
+ "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;1662;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;G - Gros;2;0.13;0.13;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;23.0;1;;cm;1.0;1;0.13;1009.42444;";
public static final String MARINE_LITTER_CONTENT =
"Annee;Serie;Serie_Partielle;Engin;Code_station;Numero_Trait;Poche;Navire;MarineLitterCategory;MarineLitterSizeCategory;Number;Weight;Commentaire\n" +
1
0
Author: tchemit
Date: 2013-11-26 16:04:11 +0100 (Tue, 26 Nov 2013)
New Revision: 1394
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1394
Log:
new trunk
Added:
trunk/
Removed:
branches/tutti-with-ifremer-shared/
1
0
Author: tchemit
Date: 2013-11-26 15:57:55 +0100 (Tue, 26 Nov 2013)
New Revision: 1393
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1393
Log:
keep a backup, you never know...
Added:
branches/tutti-before-ifremer-shared/
Removed:
trunk/
1
0
r1392 - in branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation: . catches catches/accidental catches/benthos catches/individualobservation catches/marinelitter catches/species
by tchemit@users.forge.codelutin.com 26 Nov '13
by tchemit@users.forge.codelutin.com 26 Nov '13
26 Nov '13
Author: tchemit
Date: 2013-11-26 15:56:35 +0100 (Tue, 26 Nov 2013)
New Revision: 1392
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1392
Log:
move some classes
Added:
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractTuttiBatchTableUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractTuttiBatchUIModel.java
Removed:
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchUIModel.java
Modified:
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2013-11-26 14:56:06 UTC (rev 1391)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2013-11-26 14:56:35 UTC (rev 1392)
@@ -1,154 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
-import fr.ifremer.tutti.ui.swing.util.TuttiUI;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.shared.application.swing.table.AbstractApplicationTableModel;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
-import fr.ifremer.shared.application.swing.table.ColumnIdentifier;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.ComponentAdapter;
-import org.jdesktop.swingx.decorator.HighlightPredicate;
-import org.jdesktop.swingx.decorator.Highlighter;
-import org.jdesktop.swingx.sort.TableSortController;
-import org.jdesktop.swingx.table.TableColumnModelExt;
-
-import javax.swing.table.TableModel;
-import java.awt.Color;
-import java.awt.Component;
-import java.util.Collection;
-
-/**
- * Abstract ui handler forbatch ui.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public abstract class AbstractTuttiBatchTableUIHandler<R extends AbstractTuttiBeanUIModel, M extends AbstractTuttiBatchUIModel<R, M>, T extends AbstractApplicationTableModel<R>, UI extends TuttiUI<M, ?>> extends AbstractTuttiTableUIHandler<R, M, UI> {
-
- protected abstract ColumnIdentifier<R> getCommentIdentifier();
-
- protected abstract ColumnIdentifier<R> getAttachementIdentifier();
-
- public abstract void selectFishingOperation(FishingOperation bean);
-
- protected AbstractTuttiBatchTableUIHandler(TuttiUI<?, ?> parentUi,
- UI ui,
- String... properties) {
- super(parentUi.getHandler().getContext(), ui, properties);
- }
-
- /**
- * To clear the table selection.
- * <p/>
- * This method is invoked before changing the fishing operation.
- *
- * @since 0.3
- */
- public final void clearTableSelection() {
-
- JXTable table = getTable();
-
- if (table.isEditing()) {
-
- // make sure to stop editor
- table.editingCanceled(null);
- }
-
- // make sure selection is empty (will remove bean from monitor)
- table.clearSelection();
- }
-
- @Override
- protected void onRowModified(int rowIndex,
- R row,
- String propertyName,
- Object oldValue,
- Object newValue) {
- recomputeRowValidState(row);
-
- saveSelectedRowIfNeeded();
- }
-
- protected void initBatchTable(JXTable table,
- TableColumnModelExt columnModel,
- T tableModel) {
-
- installTableKeyListener(columnModel, table);
-
- TableSortController<TableModel> sorter = new TableSortController<TableModel>(tableModel);
- sorter.setSortable(false);
- table.setRowSorter(sorter);
-
- initTable(table);
- }
-
- @Override
- protected void addHighlighters(final JXTable table) {
- super.addHighlighters(table);
- addCommentHighlighter(table, getCommentIdentifier());
- addAttachementHighlighter(table, getAttachementIdentifier());
- }
-
- protected void addCommentHighlighter(JXTable table, ColumnIdentifier identifier) {
- Color cellWithValueColor = getConfig().getColorCellWithValue();
-
- Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate.AndHighlightPredicate(
- new HighlightPredicate.IdentifierHighlightPredicate(identifier),
- // for not null value
- new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
- String value = (String) adapter.getValue();
- return StringUtils.isNotBlank(value);
- }
- }), cellWithValueColor);
- table.addHighlighter(commentHighlighter);
- }
-
- protected void addAttachementHighlighter(JXTable table, ColumnIdentifier identifier) {
- Color cellWithValueColor = getConfig().getColorCellWithValue();
-
- Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
- new HighlightPredicate.AndHighlightPredicate(
- new HighlightPredicate.IdentifierHighlightPredicate(identifier),
- // for not null value
- new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
- Collection attachments = (Collection) adapter.getValue();
- return CollectionUtils.isNotEmpty(attachments);
- }
- }
- ), cellWithValueColor);
- table.addHighlighter(attachmentHighlighter);
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchUIModel.java 2013-11-26 14:56:06 UTC (rev 1391)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchUIModel.java 2013-11-26 14:56:35 UTC (rev 1392)
@@ -1,90 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.collect.Sets;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Set;
-
-/**
- * Abstract model for ui in batch tabs.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-public abstract class AbstractTuttiBatchUIModel<R extends AbstractTuttiBeanUIModel, B extends AbstractTuttiBatchUIModel<R, B>> extends AbstractTuttiTableUIModel<FishingOperation, R, B> {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Fishing Operation to prapagate to operations model.
- *
- * @since 0.3
- */
- protected final Set<String> propagateProperties;
-
- /**
- * Editing fishing operations model.
- *
- * @since 0.3
- */
- protected final EditCatchesUIModel catchesUIModel;
-
- protected AbstractTuttiBatchUIModel(EditCatchesUIModel catchesUIModel,
- String... properties) {
- super(FishingOperation.class, null, null);
- this.catchesUIModel = catchesUIModel;
- propagateProperties = Sets.newHashSet(properties);
- catchesUIModel.addPropertyChangeListener(new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (propagateProperties.contains(evt.getPropertyName())) {
- firePropertyChange(evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
- }
- }
- });
- }
-
- public final FishingOperation getFishingOperation() {
- return catchesUIModel == null ? null : catchesUIModel.getFishingOperation();
- }
-
- @Override
- protected FishingOperation newEntity() {
- return null;
- }
-
- public void fireBatchUpdated(R row) {
- if (catchesUIModel != null) {
- catchesUIModel.firePropertyChanged(EditCatchesUIModel.PROPERTY_BATCH_UPDATED, null, row);
- }
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2013-11-26 14:56:06 UTC (rev 1391)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2013-11-26 14:56:35 UTC (rev 1392)
@@ -410,7 +410,7 @@
propertyDegree: gearShootingStartLongitudeDmsDegree;
propertyMinute: gearShootingStartLongitudeDmsMinute;
propertySecond: gearShootingStartLongitudeDmsSecond;
- longitudeEditor: true;
+ _longitudeEditor: {true};
value: {model.getGearShootingStartLongitudeDms()};
showResetTip: "tutti.coordinate.action.reset.longitude.tip";
_validatorLabel: {_("tutti.editFishingOperation.field.gearShootingStartLongitude")};
@@ -421,7 +421,7 @@
propertyDegree: gearShootingStartLongitudeDmdDegree;
propertyMinute: gearShootingStartLongitudeDmdMinute;
propertyDecimal: gearShootingStartLongitudeDmdDecimal;
- longitudeEditor: true;
+ _longitudeEditor: {true};
value: {model.getGearShootingStartLongitudeDmd()};
showResetTip: "tutti.coordinate.action.reset.longitude.tip";
_validatorLabel: {_("tutti.editFishingOperation.field.gearShootingStartLongitude")};
@@ -490,7 +490,7 @@
propertyDegree: gearShootingEndLongitudeDmsDegree;
propertyMinute: gearShootingEndLongitudeDmsMinute;
propertySecond: gearShootingEndLongitudeDmsSecond;
- longitudeEditor: true;
+ _longitudeEditor: {true};
value: {model.getGearShootingEndLongitudeDms()};
showResetTip: "tutti.coordinate.action.reset.longitude.tip";
_validatorLabel: {_("tutti.editFishingOperation.field.gearShootingEndLongitude")};
@@ -501,7 +501,7 @@
propertyDegree: gearShootingEndLongitudeDmdDegree;
propertyMinute: gearShootingEndLongitudeDmdMinute;
propertyDecimal: gearShootingEndLongitudeDmdDecimal;
- longitudeEditor: true;
+ _longitudeEditor: {true};
value: {model.getGearShootingEndLongitudeDmd()};
showResetTip: "tutti.coordinate.action.reset.longitude.tip";
_validatorLabel: {_("tutti.editFishingOperation.field.gearShootingEndLongitude")};
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-11-26 14:56:06 UTC (rev 1391)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-11-26 14:56:35 UTC (rev 1392)
@@ -595,7 +595,7 @@
DmsCoordinate position =
DmsCoordinate.valueOf(decimal);
setGearShootingEndLatitudeDmsSign(position.isSign());
- setGearShootingEndLatitudeDmdDegree(position.getDegree());
+ setGearShootingEndLatitudeDmsDegree(position.getDegree());
setGearShootingEndLatitudeDmsMinute(position.getMinute());
setGearShootingEndLatitudeDmsSecond(position.getSecond());
firePropertyChange(PROPERTY_GEAR_SHOOTING_END_LATITUDE_DMS, null, getGearShootingEndLatitudeDms());
@@ -892,10 +892,6 @@
setGearShootingEndLongitudeDmd(getGearShootingEndLongitude());
break;
}
-
-// quadrant = GeoPositionHelper.getQuadrant(
-// getGearShootingStartLongitude(),
-// getGearShootingStartLatitude());
}
public void convertGearShootingCoordinatesToDD() {
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractTuttiBatchTableUIHandler.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractTuttiBatchTableUIHandler.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractTuttiBatchTableUIHandler.java 2013-11-26 14:56:35 UTC (rev 1392)
@@ -0,0 +1,154 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.shared.application.swing.table.AbstractApplicationTableModel;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
+import fr.ifremer.shared.application.swing.table.ColumnIdentifier;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
+import org.jdesktop.swingx.sort.TableSortController;
+import org.jdesktop.swingx.table.TableColumnModelExt;
+
+import javax.swing.table.TableModel;
+import java.awt.Color;
+import java.awt.Component;
+import java.util.Collection;
+
+/**
+ * Abstract ui handler forbatch ui.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public abstract class AbstractTuttiBatchTableUIHandler<R extends AbstractTuttiBeanUIModel, M extends AbstractTuttiBatchUIModel<R, M>, T extends AbstractApplicationTableModel<R>, UI extends TuttiUI<M, ?>> extends AbstractTuttiTableUIHandler<R, M, UI> {
+
+ protected abstract ColumnIdentifier<R> getCommentIdentifier();
+
+ protected abstract ColumnIdentifier<R> getAttachementIdentifier();
+
+ public abstract void selectFishingOperation(FishingOperation bean);
+
+ protected AbstractTuttiBatchTableUIHandler(TuttiUI<?, ?> parentUi,
+ UI ui,
+ String... properties) {
+ super(parentUi.getHandler().getContext(), ui, properties);
+ }
+
+ /**
+ * To clear the table selection.
+ * <p/>
+ * This method is invoked before changing the fishing operation.
+ *
+ * @since 0.3
+ */
+ public final void clearTableSelection() {
+
+ JXTable table = getTable();
+
+ if (table.isEditing()) {
+
+ // make sure to stop editor
+ table.editingCanceled(null);
+ }
+
+ // make sure selection is empty (will remove bean from monitor)
+ table.clearSelection();
+ }
+
+ @Override
+ protected void onRowModified(int rowIndex,
+ R row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+
+ saveSelectedRowIfNeeded();
+ }
+
+ protected void initBatchTable(JXTable table,
+ TableColumnModelExt columnModel,
+ T tableModel) {
+
+ installTableKeyListener(columnModel, table);
+
+ TableSortController<TableModel> sorter = new TableSortController<TableModel>(tableModel);
+ sorter.setSortable(false);
+ table.setRowSorter(sorter);
+
+ initTable(table);
+ }
+
+ @Override
+ protected void addHighlighters(final JXTable table) {
+ super.addHighlighters(table);
+ addCommentHighlighter(table, getCommentIdentifier());
+ addAttachementHighlighter(table, getAttachementIdentifier());
+ }
+
+ protected void addCommentHighlighter(JXTable table, ColumnIdentifier identifier) {
+ Color cellWithValueColor = getConfig().getColorCellWithValue();
+
+ Highlighter commentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ new HighlightPredicate.IdentifierHighlightPredicate(identifier),
+ // for not null value
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ String value = (String) adapter.getValue();
+ return StringUtils.isNotBlank(value);
+ }
+ }), cellWithValueColor);
+ table.addHighlighter(commentHighlighter);
+ }
+
+ protected void addAttachementHighlighter(JXTable table, ColumnIdentifier identifier) {
+ Color cellWithValueColor = getConfig().getColorCellWithValue();
+
+ Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
+ new HighlightPredicate.AndHighlightPredicate(
+ new HighlightPredicate.IdentifierHighlightPredicate(identifier),
+ // for not null value
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ Collection attachments = (Collection) adapter.getValue();
+ return CollectionUtils.isNotEmpty(attachments);
+ }
+ }
+ ), cellWithValueColor);
+ table.addHighlighter(attachmentHighlighter);
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractTuttiBatchUIModel.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchUIModel.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractTuttiBatchUIModel.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractTuttiBatchUIModel.java 2013-11-26 14:56:35 UTC (rev 1392)
@@ -0,0 +1,89 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Set;
+
+/**
+ * Abstract model for ui in batch tabs.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public abstract class AbstractTuttiBatchUIModel<R extends AbstractTuttiBeanUIModel, B extends AbstractTuttiBatchUIModel<R, B>> extends AbstractTuttiTableUIModel<FishingOperation, R, B> {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Fishing Operation to prapagate to operations model.
+ *
+ * @since 0.3
+ */
+ protected final Set<String> propagateProperties;
+
+ /**
+ * Editing fishing operations model.
+ *
+ * @since 0.3
+ */
+ protected final EditCatchesUIModel catchesUIModel;
+
+ protected AbstractTuttiBatchUIModel(EditCatchesUIModel catchesUIModel,
+ String... properties) {
+ super(FishingOperation.class, null, null);
+ this.catchesUIModel = catchesUIModel;
+ propagateProperties = Sets.newHashSet(properties);
+ catchesUIModel.addPropertyChangeListener(new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (propagateProperties.contains(evt.getPropertyName())) {
+ firePropertyChange(evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
+ }
+ }
+ });
+ }
+
+ public final FishingOperation getFishingOperation() {
+ return catchesUIModel == null ? null : catchesUIModel.getFishingOperation();
+ }
+
+ @Override
+ protected FishingOperation newEntity() {
+ return null;
+ }
+
+ public void fireBatchUpdated(R row) {
+ if (catchesUIModel != null) {
+ catchesUIModel.firePropertyChanged(EditCatchesUIModel.PROPERTY_BATCH_UPDATED, null, row);
+ }
+ }
+}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2013-11-26 14:56:06 UTC (rev 1391)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2013-11-26 14:56:35 UTC (rev 1392)
@@ -36,7 +36,7 @@
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.service.ValidationService;
import fr.ifremer.shared.application.type.WeightUnit;
-import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.AbstractTuttiBatchTableUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.java 2013-11-26 14:56:06 UTC (rev 1391)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.java 2013-11-26 14:56:35 UTC (rev 1392)
@@ -24,7 +24,7 @@
* #L%
*/
-import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.AbstractTuttiBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.shared.application.swing.tab.TabContentModel;
import org.apache.commons.collections.CollectionUtils;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-11-26 14:56:06 UTC (rev 1391)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-11-26 14:56:35 UTC (rev 1392)
@@ -46,7 +46,7 @@
import fr.ifremer.tutti.service.TuttiDecorator;
import fr.ifremer.tutti.service.ValidationService;
import fr.ifremer.tutti.service.catches.ValidateCruiseOperationsService;
-import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.AbstractTuttiBatchTableUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-11-26 14:56:06 UTC (rev 1391)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-11-26 14:56:35 UTC (rev 1392)
@@ -27,7 +27,7 @@
import com.google.common.collect.Multimap;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.AbstractTuttiBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode;
import fr.ifremer.shared.application.swing.tab.TabContentModel;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java 2013-11-26 14:56:06 UTC (rev 1391)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java 2013-11-26 14:56:35 UTC (rev 1392)
@@ -36,7 +36,7 @@
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.service.ValidationService;
import fr.ifremer.shared.application.type.WeightUnit;
-import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.AbstractTuttiBatchTableUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIModel.java 2013-11-26 14:56:06 UTC (rev 1391)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIModel.java 2013-11-26 14:56:35 UTC (rev 1392)
@@ -26,7 +26,7 @@
import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.AbstractTuttiBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.shared.application.swing.tab.TabContentModel;
import org.apache.commons.collections.CollectionUtils;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-11-26 14:56:06 UTC (rev 1391)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-11-26 14:56:35 UTC (rev 1392)
@@ -35,7 +35,7 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.service.ValidationService;
import fr.ifremer.shared.application.type.WeightUnit;
-import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.AbstractTuttiBatchTableUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java 2013-11-26 14:56:06 UTC (rev 1391)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java 2013-11-26 14:56:35 UTC (rev 1392)
@@ -26,7 +26,7 @@
import com.google.common.collect.Multimap;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.AbstractTuttiBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.shared.application.swing.tab.TabContentModel;
import fr.ifremer.shared.application.swing.computable.ComputableData;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-11-26 14:56:06 UTC (rev 1391)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-11-26 14:56:35 UTC (rev 1392)
@@ -45,7 +45,7 @@
import fr.ifremer.tutti.service.ValidationService;
import fr.ifremer.shared.application.type.WeightUnit;
import fr.ifremer.tutti.service.catches.ValidateCruiseOperationsService;
-import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.AbstractTuttiBatchTableUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-11-26 14:56:06 UTC (rev 1391)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-11-26 14:56:35 UTC (rev 1392)
@@ -30,7 +30,7 @@
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.AbstractTuttiBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
1
0
r1391 - branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action
by tchemit@users.forge.codelutin.com 26 Nov '13
by tchemit@users.forge.codelutin.com 26 Nov '13
26 Nov '13
Author: tchemit
Date: 2013-11-26 15:56:06 +0100 (Tue, 26 Nov 2013)
New Revision: 1391
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1391
Log:
fixes #3853: [CAPTURE] si on fait l'?\195?\169l?\195?\169vation des poids dans l'onglet r?\195?\169sum?\195?\169 le focus se met sur le champ poids total capture donc la valeur ne s'affiche pas
Modified:
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ComputeBatchWeightsAction.java
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ComputeBatchWeightsAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ComputeBatchWeightsAction.java 2013-11-26 14:51:38 UTC (rev 1390)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ComputeBatchWeightsAction.java 2013-11-26 14:56:06 UTC (rev 1391)
@@ -48,6 +48,7 @@
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
import java.util.List;
import static org.nuiton.i18n.I18n._;
@@ -261,6 +262,15 @@
super.postSuccessAction();
getUI().repaint();
+ // see http://forge.codelutin.com/issues/3853
+ SwingUtilities.invokeLater(
+ new Runnable() {
+ @Override
+ public void run() {
+ getUI().getComputeSpeciesBatchButton().requestFocus();
+ }
+ }
+ );
}
//------------------------------------------------------------------------//
1
0
r1390 - application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing
by tchemit@users.forge.codelutin.com 26 Nov '13
by tchemit@users.forge.codelutin.com 26 Nov '13
26 Nov '13
Author: tchemit
Date: 2013-11-26 15:51:38 +0100 (Tue, 26 Nov 2013)
New Revision: 1390
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1390
Log:
init coordinate editors
Modified:
application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/AbstractApplicationUIHandler.java
Modified: application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/AbstractApplicationUIHandler.java
===================================================================
--- application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/AbstractApplicationUIHandler.java 2013-11-26 14:22:59 UTC (rev 1389)
+++ application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/AbstractApplicationUIHandler.java 2013-11-26 14:51:38 UTC (rev 1390)
@@ -738,11 +738,15 @@
}
protected void initCoordinateDMSEditor(DmsCoordinateEditor editor) {
- editor.init();
+ Object property = editor.getClientProperty("longitudeEditor");
+ boolean longitudeEditor = property != null && Boolean.valueOf(property.toString());
+ editor.init(longitudeEditor);
}
protected void initCoordinateDMDEditor(DmdCoordinateEditor editor) {
- editor.init();
+ Object property = editor.getClientProperty("longitudeEditor");
+ boolean longitudeEditor = property != null && Boolean.valueOf(property.toString());
+ editor.init(longitudeEditor);
}
protected void initDatePicker(final JXDatePicker picker) {
1
0
r1389 - branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action
by tchemit@users.forge.codelutin.com 26 Nov '13
by tchemit@users.forge.codelutin.com 26 Nov '13
26 Nov '13
Author: tchemit
Date: 2013-11-26 15:22:59 +0100 (Tue, 26 Nov 2013)
New Revision: 1389
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1389
Log:
fixes #3854: [CAMPAGNE] erreur null au moment d'enregistrer
Modified:
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCruiseAction.java
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCruiseAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCruiseAction.java 2013-11-26 08:03:42 UTC (rev 1388)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCruiseAction.java 2013-11-26 14:22:59 UTC (rev 1389)
@@ -70,8 +70,8 @@
if (!TuttiEntities.isNew(bean)) {
Cruise oldCruise = persistenceService.getCruise(bean.getId());
- // check gear has not changed
- if (!oldCruise.getVessel().equals(bean.getVessel())) {
+ // check vessel has not changed
+ if (ObjectUtils.notEqual(oldCruise.getVessel(), bean.getVessel())) {
// if so ask user confirmation
String htmlMessage = String.format(
1
0
26 Nov '13
Author: tchemit
Date: 2013-11-26 09:03:42 +0100 (Tue, 26 Nov 2013)
New Revision: 1388
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1388
Log:
utilisation derni?\195?\168re api ifremer-shared + un seul paquetage pour toutes les actions
Added:
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractChangeLocaleAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractChangeScreenAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractExportMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractImportMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractMainUITuttiAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractTuttiAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AddBenthosProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AddSpeciesProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CancelEditCatchBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CancelEditFishingOperationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ChangeToLocaleFRAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ChangeToLocaleUKAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CleanBatchWeightsAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CloneProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CloseApplicationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CloseDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ComputeBatchWeightsAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateBenthosMelagAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateSpeciesMelagAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/DeleteFishingOperationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/DeleteProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCatchesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCruiseAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCruiseFishingOperationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditFishingOperationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditGearCaracteristicsAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditProgramAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSampleCategoryModelAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedCruiseAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedCruiseCatchesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedProgramAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportAccidentalMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportAllCaracteristicAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportAndCleanDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportBenthosMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseForSumatraAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseValidationMessagesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportFishingOperationForSumatraAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportFishingOperationReportAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportIndividualObservationMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportMarineLitterMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportOperationValidationMessagesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProgramAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolBenthosAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolCaracteristicAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolSpeciesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportPupitriAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportSpeciesMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporaryGearExampleAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporaryPersonExampleAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporarySpeciesExampleAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporaryVesselExampleAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/GenerateReportAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/GoToPreviousScreenAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportAccidentalMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBenthosMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportCasinoAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportIndividualObservationMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportMarineLitterMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportOrReimportDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolBenthosAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolCaracteristicAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolSpeciesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPupitriAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportSpeciesMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryGearAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryPersonAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryReferentialAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporarySpeciesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryVesselAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/InstallDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/InstallOrReinstallDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ManageDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewCruiseAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewFishingOperationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewProgramAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/OpenDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ReimportDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ReinstallDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ReloadTuttiAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveAccidentalBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveAllIndividualObservationBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveBenthosBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveBenthosProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveBenthosSubBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveIndividualObservationBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveMarineLitterBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveSpeciesBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveSpeciesProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveSpeciesSubBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RenameBenthosBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RenameSpeciesBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCatchBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCruiseAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveFishingOperationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveProgramAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveSampleCategoryModelAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectCruiseAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectOtherBenthosAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectOtherSpeciesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectSpeciesForBenthosBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectSpeciesForIndividualObservationBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectSpeciesForSpeciesBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SendCruiseReportAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ShowAboutAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ShowConfigAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ShowReportAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/StartAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/UpdateApplicationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/UpdateDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/UpdateReportAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ValidateCatchesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ValidateSelectedCruiseCatchesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ViewGearCaracteristicsAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicValueEditor.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicValueRenderer.java
Removed:
branches/tutti-with-ifremer-shared/tutti-persistence/src/main/java/fr/ifremer/tutti/PropagatePropertyChangeListener.java
branches/tutti-with-ifremer-shared/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractChangeLocaleAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractChangeScreenAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractMainUITuttiAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ChangeToLocaleFRAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ChangeToLocaleUKAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/CloseApplicationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedCruiseAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedCruiseCatchesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedProgramAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/GoToPreviousScreenAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ImportTemporaryReferentialAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ManageDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ReloadTuttiAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/SelectCruiseAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowConfigAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowReportAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/StartAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateReportAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ValidateSelectedCruiseCatchesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/SaveSampleCategoryModelAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseFishingOperationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditGearCaracteristicsAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportCruiseValidationMessagesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportOperationValidationMessagesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/SaveCruiseAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ViewGearCaracteristicsAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportOrReimportDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallOrReinstallDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ReimportDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ReinstallDbAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/CloneProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditCatchesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditCruiseAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProgramAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseForSumatraAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewCruiseAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewProgramAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SendCruiseReportAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ValidateCatchesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/DeleteFishingOperationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/ImportCasinoAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractExportMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CleanBatchWeightsAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeBatchWeightsAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationForSumatraAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationReportAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/ExportMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/ImportMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/RemoveAccidentalBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/CreateBenthosMelagAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/ExportMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/ImportMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RenameBenthosBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/SelectSpeciesForBenthosBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/ExportMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/ImportMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/RemoveAllIndividualObservationBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/RemoveIndividualObservationBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/SelectSpeciesForIndividualObservationBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/ExportMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/ImportMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/RemoveMarineLitterBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ExportMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportMultiPostAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportPupitriAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/SelectSpeciesForSpeciesBatchAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/SaveProgramAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddBenthosProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportAllCaracteristicAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolBenthosAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolCaracteristicAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveBenthosProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SaveProtocolAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherBenthosAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherSpeciesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryGearExampleAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryPersonExampleAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporarySpeciesExampleAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryVesselExampleAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryGearAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryPersonAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporarySpeciesAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryVesselAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/report/GenerateReportAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/ActionListCellRenderer.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/CustomTab.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TabContentModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TabHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java
Modified:
branches/tutti-with-ifremer-shared/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java
branches/tutti-with-ifremer-shared/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiActionFactory.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDbUpdaterCallBack.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiReportUpdaterCallBack.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/GearCaracteristicsEditorUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.jaxx
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.jaxx
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/create/CreateAccidentalBatchUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ManageTemporaryReferentialUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/report/ReportUI.css
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/report/ReportUI.jaxx
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiBeanUIModel.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiTabContainerUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiExceptionHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/SaveAttachmentAction.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicMapEditorUIHandler.java
branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
Deleted: branches/tutti-with-ifremer-shared/tutti-persistence/src/main/java/fr/ifremer/tutti/PropagatePropertyChangeListener.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-persistence/src/main/java/fr/ifremer/tutti/PropagatePropertyChangeListener.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-persistence/src/main/java/fr/ifremer/tutti/PropagatePropertyChangeListener.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,80 +0,0 @@
-package fr.ifremer.tutti;
-
-/*
- * #%L
- * Tutti :: Persistence
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import org.jdesktop.beans.AbstractBean;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-/**
- * To listen a bean and propagate some of properties.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class PropagatePropertyChangeListener implements PropertyChangeListener {
-
- public static interface PropagatePropertyChange {
- void firePropertyChanged(String propertyName,
- Object oldValue,
- Object newValue);
- }
-
- public static void listenAndPropagate(AbstractBean producer,
- PropagatePropertyChange consumer,
- String propertyNameToListen,
- String propertyNameToForward) {
- PropagatePropertyChangeListener listener =
- new PropagatePropertyChangeListener(propertyNameToForward,
- consumer);
- producer.addPropertyChangeListener(propertyNameToListen, listener);
- }
-
- public static void listenAndPropagateAll(AbstractBean producer,
- PropagatePropertyChange consumer) {
- PropagatePropertyChangeListener listener =
- new PropagatePropertyChangeListener(null, consumer);
- producer.addPropertyChangeListener(listener);
- }
-
- private String propertyName;
-
- private PropagatePropertyChange editor;
-
- public PropagatePropertyChangeListener(String propertyName,
- PropagatePropertyChange editor) {
- this.propertyName = propertyName;
- this.editor = editor;
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- String name = propertyName == null ? evt.getPropertyName() : propertyName;
- editor.firePropertyChanged(name,
- evt.getOldValue(),
- evt.getNewValue());
- }
-}
\ No newline at end of file
Modified: branches/tutti-with-ifremer-shared/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfiguration.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -559,6 +559,7 @@
return applicationConfig.getOptionAsColor(TuttiConfigurationOption.COLOR_SELECTED_ROW.getKey());
}
+ @Override
public KeyStroke getShortcutClosePopup() {
return applicationConfig.getOptionAsKeyStroke(TuttiConfigurationOption.SHORTCUT_CLOSE_POPUP.getKey());
}
Modified: branches/tutti-with-ifremer-shared/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1463,7 +1463,7 @@
tutti.persistence.cruise.gearUsedInOperations.error=Vous essayez d'enlever un ou plusieurs engins qui sont utilisés sur des traits.<hr/>Veuillez changer l'engin des traits en question pour pouvoir les enlever de la campagne.
tutti.persistence.dbMetadata.instanciation.error=Erreur lors de l'initialisation des metadata de la base de données par la connexion %s
tutti.persistence.error.caracteristic.notFound=Caractéristique inconnue
-tutti.persistence.error.no.convertor=Impossible de convertir en modeèle de catégorie le type %s avec la valeur %s
+tutti.persistence.error.no.convertor=Impossible de convertir en modèle de catégorie le type %s avec la valeur %s
tutti.persistence.error.protocol.categories.not.compatible=Le protocole utilise des catégories non connues par la configuration des catégorisations \: <ul>%s</ul>
tutti.persistence.loader.error=Erreur de conversion du dossier %s en URL
tutti.persistence.protocol.delete.error=Erreur lors de la suppression du protocole %1s (fichier %2s)
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/RunTutti.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -25,11 +25,11 @@
*/
import fr.ifremer.tutti.TuttiConfiguration;
+import fr.ifremer.tutti.ui.swing.action.StartAction;
+import fr.ifremer.tutti.ui.swing.action.UpdateApplicationAction;
+import fr.ifremer.tutti.ui.swing.action.UpdateReportAction;
import fr.ifremer.tutti.ui.swing.content.MainUI;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import fr.ifremer.tutti.ui.swing.content.StartAction;
-import fr.ifremer.tutti.ui.swing.content.UpdateApplicationAction;
-import fr.ifremer.tutti.ui.swing.content.UpdateReportAction;
import fr.ifremer.tutti.ui.swing.util.TuttiExceptionHandler;
import jaxx.runtime.SwingUtil;
import org.apache.commons.logging.Log;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiActionFactory.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiActionFactory.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiActionFactory.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -4,7 +4,7 @@
import fr.ifremer.shared.application.swing.AbstractApplicationUIHandler;
import fr.ifremer.shared.application.swing.action.AbstractApplicationAction;
import fr.ifremer.shared.application.swing.action.ApplicationActionFactory;
-import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
+import fr.ifremer.tutti.ui.swing.action.AbstractMainUITuttiAction;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import org.apache.commons.lang3.reflect.ConstructorUtils;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiApplicationUpdaterCallBack.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -32,7 +32,7 @@
import fr.ifremer.tutti.LabelAware;
import fr.ifremer.tutti.TuttiConfiguration;
import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import fr.ifremer.tutti.ui.swing.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.updater.ApplicationInfo;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDbUpdaterCallBack.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDbUpdaterCallBack.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiDbUpdaterCallBack.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -34,7 +34,7 @@
import fr.ifremer.tutti.persistence.service.synchro.ReferentialSynchronizeResult;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.referential.TuttiReferentialSynchronizeService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import fr.ifremer.tutti.ui.swing.action.AbstractTuttiAction;
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiReportUpdaterCallBack.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiReportUpdaterCallBack.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiReportUpdaterCallBack.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -27,7 +27,7 @@
import com.google.common.collect.Maps;
import fr.ifremer.shared.application.swing.action.ApplicationActionException;
import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import fr.ifremer.tutti.ui.swing.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.updater.ApplicationInfo;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -36,7 +36,7 @@
import fr.ifremer.shared.application.swing.action.ApplicationActionFactory;
import fr.ifremer.shared.application.swing.action.ApplicationActionUI;
import fr.ifremer.shared.application.swing.util.ApplicationErrorHelper;
-import fr.ifremer.tutti.PropagatePropertyChangeListener;
+import fr.ifremer.shared.application.listener.PropagatePropertyChangeListener;
import fr.ifremer.tutti.TuttiConfiguration;
import fr.ifremer.tutti.persistence.RessourceClassLoader;
import fr.ifremer.tutti.service.ClosedPersistenceService;
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractChangeLocaleAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractChangeLocaleAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractChangeLocaleAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractChangeLocaleAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,51 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.content.MainUIHandler;
+
+import java.util.Locale;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0.3
+ */
+public abstract class AbstractChangeLocaleAction extends AbstractChangeScreenAction {
+
+
+ protected AbstractChangeLocaleAction(MainUIHandler handler) {
+ super(handler, true, null);
+ }
+
+ protected abstract Locale getLocale();
+
+ @Override
+ public void doAction() throws Exception {
+
+ getHandler().changeLocale(getLocale());
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractChangeScreenAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractChangeScreenAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractChangeScreenAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractChangeScreenAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,118 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.context.JAXXContextEntryDef;
+
+/**
+ * Action to change the screen.
+ * <p/>
+ * Will just check that the current screen can be quit via
+ * the {@link MainUIHandler#quitCurrentScreen()}.
+ * <p/>
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public abstract class AbstractChangeScreenAction extends AbstractMainUITuttiAction {
+
+ /**
+ * Context entry to keep previous screen.
+ *
+ * @since 1.1
+ */
+ protected static final JAXXContextEntryDef<TuttiScreen> PREVIOUS_SCREEN =
+ SwingUtil.newContextEntryDef("previousScreen", TuttiScreen.class);
+
+ /**
+ * Screen where to go.
+ *
+ * @since 1.0
+ */
+ protected TuttiScreen screen;
+
+ /**
+ * Flag to skip the check of current screen.
+ *
+ * @since 1.1
+ */
+ protected boolean skipCheckCurrentScreen;
+
+ protected AbstractChangeScreenAction(MainUIHandler handler,
+ boolean hideBody,
+ TuttiScreen screen) {
+ super(handler, hideBody);
+ this.screen = screen;
+ }
+
+ public void setSkipCheckCurrentScreen(boolean skipCheckCurrentScreen) {
+ this.skipCheckCurrentScreen = skipCheckCurrentScreen;
+ }
+
+ protected void setScreen(TuttiScreen screen) {
+ this.screen = screen;
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+ result &= skipCheckCurrentScreen || getHandler().quitCurrentScreen();
+ return result;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ TuttiUIContext context = getContext();
+
+ TuttiScreen previousScreen = context.getScreen();
+ if (getUI() != null) {
+ if (previousScreen == null) {
+ PREVIOUS_SCREEN.removeContextValue(getUI());
+ } else {
+ PREVIOUS_SCREEN.setContextValue(getUI(), previousScreen);
+ }
+ }
+
+ // clean current screen
+ context.setScreen(null);
+
+ // change screen
+ context.setScreen(screen);
+ }
+
+ @Override
+ public void postFailedAction(Throwable error) {
+ if (error != null) {
+
+ getContext().setFallBackScreen();
+ }
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractExportMultiPostAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractExportMultiPostAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractExportMultiPostAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractExportMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,95 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.service.DecoratorService;
+import fr.ifremer.tutti.service.catches.multipost.MultiPostExportService;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+import fr.ifremer.tutti.ui.swing.util.TuttiUI;
+import org.jdesktop.beans.AbstractBean;
+
+import java.io.File;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.2
+ */
+public abstract class AbstractExportMultiPostAction<M extends AbstractBean, UI extends TuttiUI<M, ?>, H extends AbstractTuttiUIHandler<M, UI>>
+ extends AbstractTuttiAction<M, UI, H> {
+
+ protected File file;
+
+ protected FishingOperation currentOperation;
+
+ protected MultiPostExportService multiPostImportExportService;
+
+ public AbstractExportMultiPostAction(H handler) {
+ super(handler, false);
+ multiPostImportExportService = getContext().getMultiPostExportService();
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ EditCatchesUI catchesUI = getUI().getParentContainer(EditCatchesUI.class);
+ currentOperation = catchesUI.getModel().getFishingOperation();
+
+ String extension = getFileExtension();
+ // choose file to export
+ file = saveFile(
+ decorate(currentOperation, DecoratorService.FILE_NAME_COMPATIBLE),
+ extension,
+ getFileChooserTitle(),
+ getFileChooserButton(),
+ "^.*\\." + extension,
+ getFileExtensionDescription()
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ protected abstract String getFileExtension();
+
+ protected abstract String getFileExtensionDescription();
+
+ protected abstract String getFileChooserTitle();
+
+ protected abstract String getFileChooserButton();
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ currentOperation = null;
+ super.releaseAction();
+ }
+
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractImportMultiPostAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractImportMultiPostAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractImportMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,112 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.service.catches.multipost.MultiPostImportService;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
+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.util.AbstractTuttiUIHandler;
+import fr.ifremer.tutti.ui.swing.util.TuttiUI;
+import org.jdesktop.beans.AbstractBean;
+
+import java.io.File;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.2
+ */
+public abstract class AbstractImportMultiPostAction<M extends AbstractBean, UI extends TuttiUI<M, ?>, H extends AbstractTuttiUIHandler<M, UI>>
+ extends AbstractTuttiAction<M, UI, H> {
+
+ protected File file;
+
+ protected EditFishingOperationAction editAction;
+
+ protected MultiPostImportService multiPostImportExportService;
+
+ public AbstractImportMultiPostAction(H handler) {
+ super(handler, false);
+ multiPostImportExportService = getContext().getMultiPostImportService();
+ }
+
+ public EditFishingOperationAction getEditAction() {
+ FishingOperationsUI parentUI = getUI().getParentContainer(FishingOperationsUI.class);
+ if (editAction == null) {
+ editAction = getContext().getActionFactory().createLogicAction(parentUI.getHandler(),
+ EditFishingOperationAction.class);
+ }
+ return editAction;
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to import
+ file = chooseFile(
+ getFileChooserTitle(),
+ getFileChooserButton(),
+ "^.*\\." + getFileExtension(),
+ getFileExtensionDescription()
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ protected abstract String getFileExtension();
+
+ protected abstract String getFileExtensionDescription();
+
+ protected abstract String getFileChooserTitle();
+
+ protected abstract String getFileChooserButton();
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ EditCatchesUI editCatchesUI = getUI().getParentContainer(EditCatchesUI.class);
+ EditCatchesUIModel editCatchesUIModel = editCatchesUI.getModel();
+
+ FishingOperation operation = editCatchesUIModel.getFishingOperation();
+
+ importBatches(operation);
+
+ getEditAction().loadCatchBatch(operation);
+ }
+
+ protected abstract void importBatches(FishingOperation operation);
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractMainUITuttiAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractMainUITuttiAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractMainUITuttiAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractMainUITuttiAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,41 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.MainUI;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public abstract class AbstractMainUITuttiAction extends AbstractTuttiAction<TuttiUIContext, MainUI, MainUIHandler> {
+
+ protected AbstractMainUITuttiAction(MainUIHandler handler,
+ boolean hideBody) {
+ super(handler, hideBody);
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractTuttiAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/AbstractTuttiAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractTuttiAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AbstractTuttiAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,131 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.shared.application.swing.action.AbstractApplicationAction;
+import fr.ifremer.tutti.TuttiConfiguration;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.service.TuttiDataContext;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+import fr.ifremer.tutti.ui.swing.util.TuttiUI;
+import org.apache.commons.lang3.StringUtils;
+import org.jdesktop.beans.AbstractBean;
+import org.nuiton.util.StringUtil;
+
+import javax.swing.JOptionPane;
+import java.awt.Component;
+
+/**
+ * Tutti base action.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public abstract class AbstractTuttiAction<M extends AbstractBean, UI extends TuttiUI<M, ?>, H extends AbstractTuttiUIHandler<M, UI>>
+ extends AbstractApplicationAction<M, UI, H> {
+
+ public abstract void doAction() throws Exception;
+
+ protected AbstractTuttiAction(H handler, boolean hideBody) {
+ super(handler, hideBody);
+ }
+
+ @Override
+ public TuttiUIContext getContext() {
+ return handler.getContext();
+ }
+
+ public void setProgressionModel(ProgressionModel progressionModel) {
+ super.setProgressionModel(progressionModel);
+ }
+
+ @Override
+ protected ProgressionModel getProgressionModel() {
+ return (ProgressionModel) getContext().getActionUI().getModel().getProgressionModel();
+ }
+
+ public TuttiDataContext getDataContext() {
+ return getContext().getDataContext();
+ }
+
+ @Override
+ protected TuttiConfiguration getConfig() {
+ return getContext().getConfig();
+ }
+
+ @Override
+ protected void sendMessage(String message) {
+ getContext().showInformationMessage(message);
+ }
+
+ @Override
+ protected void createProgressionModelIfRequired(int total) {
+ ProgressionModel progressionModel = getProgressionModel();
+ if (progressionModel == null) {
+ progressionModel = new ProgressionModel();
+ progressionModel.setTotal(total);
+ progressionModel.setMessage("");
+ progressionModel.setCurrent(0);
+ setProgressionModel(progressionModel);
+ } else {
+ progressionModel.adaptTotal(total);
+ }
+ }
+
+ protected boolean askAdminPassword(String askMessage,
+ String askMessageTitle,
+ String errorMessage,
+ String errorMessageTitle) {
+
+ Component container = getContext().getActionUI();
+
+ String answer;
+ boolean result;
+ do {
+ answer = JOptionPane.showInputDialog(container,
+ askMessage,
+ askMessageTitle,
+ JOptionPane.WARNING_MESSAGE);
+ if (answer != null) {
+ String cryptedAnswer = StringUtil.encodeMD5(answer);
+ String correctAnswer = getConfig().getAdminPassword();
+ result = StringUtils.equals(cryptedAnswer, correctAnswer);
+
+ if (!result) {
+ JOptionPane.showMessageDialog(container,
+ errorMessage,
+ errorMessageTitle,
+ JOptionPane.ERROR_MESSAGE);
+ }
+
+ } else {
+ result = false;
+ }
+
+ } while (!result && answer != null);
+ return result;
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AddBenthosProtocolAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddBenthosProtocolAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AddBenthosProtocolAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AddBenthosProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,107 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesRowModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesTableModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
+
+import java.util.Collection;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To add a new benthos protocol.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class AddBenthosProtocolAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ public AddBenthosProtocolAction(EditProtocolUIHandler handler) {
+ super(handler, false);
+ }
+
+ protected Species species;
+
+ protected EditProtocolSpeciesRowModel newRow;
+
+ @Override
+ public void doAction() throws Exception {
+
+ species = null;
+
+ EditProtocolUI ui = getUI();
+
+ EditProtocolSpeciesTableModel tableModel = handler.getBenthosTableModel();
+ BeanFilterableComboBox<Species> benthosComboBox = ui.getBenthosComboBox();
+
+ species = (Species) benthosComboBox.getSelectedItem();
+ Preconditions.checkNotNull(
+ species, "Can't add a benthosProtocol with a null species");
+ Preconditions.checkArgument(species.isReferenceTaxon(),
+ "Can't add a benthosProtocol with a not referent species");
+
+ Integer taxonId = species.getReferenceTaxonId();
+ String taxonIdStr = String.valueOf(taxonId);
+
+ // remove all synonyms of this taxon
+ Collection<Species> allSynonyms = getModel().getAllSynonyms(taxonIdStr);
+ getModel().getAllSynonyms().removeAll(allSynonyms);
+
+ // add new row to model (do it after combo stuff for ui best display)
+ newRow = tableModel.createNewRow();
+ newRow.setSpecies(species);
+ getModel().getBenthosRow().add(newRow);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ // update comboboxes
+ getUI().getBenthosComboBox().removeItem(species);
+ getUI().getSpeciesComboBox().removeItem(species);
+
+ // fire row was inserted in table model
+ EditProtocolSpeciesTableModel tableModel = getHandler().getBenthosTableModel();
+ tableModel.fireTableRowsInserted(newRow);
+
+ // select this new row
+ int rowIndex = tableModel.getRowIndex(newRow);
+ SwingUtil.setSelectionInterval(handler.getBenthosTable(), rowIndex);
+
+ // add notification
+ String speciesStr = decorate(species);
+ sendMessage(_("tutti.flash.info.benthos.add.to.protocol",
+ speciesStr));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AddSpeciesProtocolAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AddSpeciesProtocolAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/AddSpeciesProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,105 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesRowModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesTableModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
+
+import java.util.Collection;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To add a new species protocol.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class AddSpeciesProtocolAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ public AddSpeciesProtocolAction(EditProtocolUIHandler handler) {
+ super(handler, false);
+ }
+
+ protected Species species;
+
+ protected EditProtocolSpeciesRowModel newRow;
+
+ @Override
+ public void doAction() throws Exception {
+
+ EditProtocolUI ui = getUI();
+
+ EditProtocolSpeciesTableModel tableModel = handler.getSpeciesTableModel();
+ BeanFilterableComboBox<Species> speciesComboBox = ui.getSpeciesComboBox();
+
+ species = (Species) speciesComboBox.getSelectedItem();
+ Preconditions.checkNotNull(
+ species, "Can't add a speciesProtocol with a null species");
+ Preconditions.checkArgument(species.isReferenceTaxon(),
+ "Can't add a speciesProtocol with a not referent species");
+
+ Integer taxonId = species.getReferenceTaxonId();
+ String taxonIdStr = String.valueOf(taxonId);
+
+ // remove all synonyms of this taxon
+ Collection<Species> allSynonyms = getModel().getAllSynonyms(taxonIdStr);
+ getModel().getAllSynonyms().removeAll(allSynonyms);
+
+ // add new row to model (do it after combo stuff for ui best display)
+ newRow = tableModel.createNewRow();
+ newRow.setSpecies(species);
+ getModel().getSpeciesRow().add(newRow);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ // update comboboxes
+ getUI().getBenthosComboBox().removeItem(species);
+ getUI().getSpeciesComboBox().removeItem(species);
+
+ // fire row was inserted in table model
+ EditProtocolSpeciesTableModel tableModel = getHandler().getSpeciesTableModel();
+ tableModel.fireTableRowsInserted(newRow);
+
+ // select this new row
+ int rowIndex = tableModel.getRowIndex(newRow);
+ SwingUtil.setSelectionInterval(handler.getSpeciesTable(), rowIndex);
+
+ // add notification
+ String speciesStr = decorate(species);
+ sendMessage(_("tutti.flash.info.species.add.to.protocol",
+ speciesStr));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CancelEditCatchBatchAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CancelEditCatchBatchAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CancelEditCatchBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,87 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * To cancel edit of a {@link CatchBatch}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class CancelEditCatchBatchAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
+
+ /** 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;
+
+ protected EditFishingOperationAction editAction;
+
+ public CancelEditCatchBatchAction(EditCatchesUIHandler handler) {
+ super(handler, true);
+ }
+
+ public EditFishingOperationAction getEditAction() {
+ if (editAction == null) {
+ editAction = getContext().getActionFactory().createLogicAction(getHandler().getParentHandler(),
+ EditFishingOperationAction.class);
+ }
+ return editAction;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ // cancel to create a catch batch ?
+ // Should never happen ?
+ Preconditions.checkState(
+ !getModel().isCreate(),
+ "Can't cancel edition of a not persisted catchBatch!");
+
+ if (log.isInfoEnabled()) {
+ log.info("Can edition of catchBatch (will reload catchBatch)");
+ }
+
+ FishingOperation operation = getModel().getFishingOperation();
+
+ getEditAction().loadCatchBatch(operation);
+ }
+
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CancelEditFishingOperationAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CancelEditFishingOperationAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CancelEditFishingOperationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,109 @@
+
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.content.operation.EditFishingOperationUI;
+import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Cancels the edition of a fishing operation and potentially switch to another tab.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public class CancelEditFishingOperationAction extends AbstractTuttiAction<EditFishingOperationUIModel, EditFishingOperationUI, EditFishingOperationUIHandler> {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(SaveFishingOperationAction.class);
+
+ /**
+ * Delegate edit action.
+ *
+ * @since 1.0
+ */
+ protected EditFishingOperationAction editAction;
+
+ public CancelEditFishingOperationAction(EditFishingOperationUIHandler handler) {
+ super(handler, true);
+ }
+
+ public EditFishingOperationAction getEditAction() {
+ if (editAction == null) {
+ editAction = getContext().getActionFactory().createLogicAction(
+ getHandler().getParentUi().getHandler(),
+ EditFishingOperationAction.class);
+ }
+ return editAction;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ EditFishingOperationAction action = getEditAction();
+
+ if (getModel().isCreate()) {
+ if (log.isInfoEnabled()) {
+ log.info("Cancel creation for fishingOperation");
+ }
+ // cancel to create a new fishingOperation
+ action.setFishingOperation(null);
+ getActionEngine().runInternalAction(action);
+
+ } else {
+
+ 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.setInternalAction(true);
+ getActionEngine().runInternalAction(action);
+ }
+
+ //FIXME-TC Make sure this works again
+// // 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);
+// }
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ getEditAction().displayValidationErrors();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ChangeToLocaleFRAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ChangeToLocaleFRAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ChangeToLocaleFRAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ChangeToLocaleFRAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,46 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.content.MainUIHandler;
+
+import java.util.Locale;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0.3
+ */
+public class ChangeToLocaleFRAction extends AbstractChangeLocaleAction {
+
+ public ChangeToLocaleFRAction(MainUIHandler handler) {
+ super(handler);
+ }
+
+ @Override
+ protected Locale getLocale() {
+ return Locale.FRANCE;
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ChangeToLocaleUKAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ChangeToLocaleUKAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ChangeToLocaleUKAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ChangeToLocaleUKAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,45 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.content.MainUIHandler;
+
+import java.util.Locale;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0.3
+ */
+public class ChangeToLocaleUKAction extends AbstractChangeLocaleAction {
+
+ public ChangeToLocaleUKAction(MainUIHandler handler) {
+ super(handler);
+ }
+
+ @Override
+ protected Locale getLocale() {
+ return Locale.UK;
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CleanBatchWeightsAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CleanBatchWeightsAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CleanBatchWeightsAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CleanBatchWeightsAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,145 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.Multimap;
+import fr.ifremer.tutti.persistence.InvalidBatchModelException;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.service.catches.WeightCleaningService;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JOptionPane;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To remove weight in double for species and benthos rows.
+ * <p/>
+ * Created on 9/27/13.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.6
+ */
+public class CleanBatchWeightsAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CleanBatchWeightsAction.class);
+
+ protected final WeightCleaningService cleaningService;
+
+ protected int nbErrors;
+
+ public CleanBatchWeightsAction(EditCatchesUIHandler handler) {
+ super(handler, false);
+ cleaningService = getContext().getWeightCleaningService();
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean doAction = super.prepareAction();
+ if (doAction) {
+
+
+ // do a check
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ Multimap<String, String> errors = cleaningService.checkFishingOperation(fishingOperation.getId());
+
+ nbErrors = errors.size();
+
+ if (nbErrors == 0) {
+
+ // no errors
+
+ sendMessage(_("tutti.editCatchBatch.action.cleanWeights.no.double.weight.detected"));
+ doAction = false;
+ } else {
+
+ // show errors to user and ask him to apply change
+
+ String errorsStr = cleaningService.errorsToString(errors);
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ _("tutti.editCatchBatch.action.cleanWeights.double.weight.detected", errorsStr),
+ _("tutti.editCatchBatch.action.cleanWeights.help"));
+
+ int answer = JOptionPane.showConfirmDialog(
+ getContext().getActionUI(),
+ htmlMessage,
+ _("tutti.editCatchBatch.action.cleanWieghts.resume.title"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+
+ doAction = (answer == JOptionPane.OK_OPTION);
+
+ }
+ }
+ return doAction;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ EditCatchesUIModel model = getModel();
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ model.setLoadingData(true);
+
+ cleaningService.cleanFishingOperation(fishingOperation.getId());
+
+ try {
+
+ getUI().getSpeciesTabContent().getHandler().selectFishingOperation(fishingOperation);
+ } catch (InvalidBatchModelException e) {
+
+ // invalid sample category model for species batches
+ if (log.isDebugEnabled()) {
+ log.debug("Invalid sample category model for species batches", e);
+ }
+ }
+
+ try {
+ getUI().getBenthosTabContent().getHandler().selectFishingOperation(fishingOperation);
+ } catch (InvalidBatchModelException e) {
+
+ // invalid sample category model for benthos batches
+ if (log.isDebugEnabled()) {
+ log.debug("Invalid sample category model for benthos batches", e);
+ }
+ }
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ sendMessage(_("tutti.editCatchBatch.action.cleanWeights.done", nbErrors));
+ }
+
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CloneProtocolAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/CloneProtocolAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CloneProtocolAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CloneProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,160 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JOptionPane;
+import javax.swing.UIManager;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Opens the protocol creation screen with the data of an already existing protocol.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class CloneProtocolAction extends AbstractChangeScreenAction {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(CloneProtocolAction.class);
+
+ public static final JAXXContextEntryDef<TuttiProtocol> CLONE_PROTOCOL_ENTRY = new JAXXContextEntryDef<TuttiProtocol>("cloneProtocol", TuttiProtocol.class);
+
+ protected TuttiProtocol protocol;
+
+ public CloneProtocolAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.EDIT_PROTOCOL);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ CLONE_PROTOCOL_ENTRY.removeContextValue(getContext().getMainUI());
+
+ boolean doAction = super.prepareAction();
+ if (doAction) {
+
+ // check that protocol is compatible with sample category model
+ SampleCategoryModel sampleCategoryModel =
+ getDataContext().getSampleCategoryModel();
+
+ if (log.isInfoEnabled()) {
+ log.info("Clone protocol: " + getContext().getProtocolId());
+ }
+
+ // get protocol
+ protocol = getContext().getPersistenceService().getProtocol(getContext().getProtocolId());
+
+ // remove id
+ protocol.setId((String) null);
+
+ Set<Integer> badCategories = Sets.newHashSet();
+
+ TuttiProtocols.checkSampleCategories(sampleCategoryModel,
+ protocol,
+ badCategories);
+
+ if (!badCategories.isEmpty()) {
+
+ // detect some bad categories
+ if (log.isWarnEnabled()) {
+ log.warn("There is some bad categories: " + badCategories);
+ }
+
+ String message = TuttiProtocols.getBadCategoriesMessage(
+ badCategories,
+ getDecorator(Caracteristic.class, null),
+ getContext().getPersistenceService());
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ message,
+ _("tutti.common.askBeforeCloneProtocol.help"));
+ int response = JOptionPane.showOptionDialog(
+ getContext().getActionUI(),
+ htmlMessage,
+ _("tutti.common.askBeforeEditProtocol.title"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.WARNING_MESSAGE,
+ UIManager.getIcon("warning"),
+ new Object[]{_("tutti.option.cleanAndClone"), _("tutti.option.clone"), _("tutti.option.cancel")},
+ _("tutti.option.cancel")
+ );
+
+ switch (response) {
+ case 0:
+ // clean and clone
+ if (log.isInfoEnabled()) {
+ log.info("Clean and Clone");
+ }
+ TuttiProtocols.removeBadCategories(sampleCategoryModel,
+ protocol);
+ break;
+
+ case 1:
+ // clone with no clean
+ if (log.isInfoEnabled()) {
+ log.info("Clone with no cleaning");
+ }
+ break;
+ default:
+
+ // cancel
+ doAction = false;
+ }
+ }
+ }
+ return doAction;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(protocol);
+
+ // store protocol in context
+ CLONE_PROTOCOL_ENTRY.setContextValue(getContext().getMainUI(), protocol);
+ protocol = null;
+
+ createProgressionModelIfRequired(4);
+
+ // removed selected protocol
+ getContext().setProtocolId(null);
+
+ super.doAction();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CloseApplicationAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/CloseApplicationAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CloseApplicationAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CloseApplicationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,66 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.RunTutti;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To close Tutti Application.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.1
+ */
+public class CloseApplicationAction extends AbstractChangeScreenAction {
+
+ protected int exitCode = RunTutti.NORMAL_EXIT_CODE;
+
+ public CloseApplicationAction(MainUIHandler handler) {
+ super(handler, false, null);
+ setSkipCheckCurrentScreen(true);
+ setActionDescription(_("tutti.main.action.exit.tip"));
+ }
+
+ public void setExitCode(int exitCode) {
+ this.exitCode = exitCode;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ super.doAction();
+
+ RunTutti.closeTutti(getHandler(), exitCode);
+ }
+
+
+ @Override
+ public void releaseAction() {
+ exitCode = RunTutti.NORMAL_EXIT_CODE;
+ super.releaseAction();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CloseDbAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CloseDbAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CloseDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,87 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.content.MainUIHandler;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To close a db.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.4
+ */
+public class CloseDbAction extends AbstractMainUITuttiAction {
+
+ protected String jdbcUrl;
+
+ public CloseDbAction(MainUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean canContinue = super.prepareAction();
+ if (canContinue) {
+ jdbcUrl = getConfig().getJdbcUrl();
+ }
+ return canContinue;
+ }
+
+ @Override
+ public void doAction() {
+
+ // close db
+ getContext().getPersistenceService().clearAllCaches();
+
+ // set to not reload a real db
+ getContext().setDbLoaded(false);
+
+ // close services + repon a fake persistence service
+ getHandler().reloadPersistenceService();
+
+ // clean db context
+ getContext().clearDbContext();
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ sendMessage(_("tutti.flash.info.db.closed", jdbcUrl));
+
+ // make sure title is reloaded
+ handler.reloadDbManagerText();
+ handler.changeTitle();
+ }
+
+ @Override
+ public void postFailedAction(Throwable error) {
+ handler.reloadDbManagerText();
+ super.postFailedAction(error);
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ComputeBatchWeightsAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeBatchWeightsAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ComputeBatchWeightsAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ComputeBatchWeightsAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,327 @@
+
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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 com.google.common.collect.Multimap;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.catches.TuttiWeightComputingException;
+import fr.ifremer.tutti.service.catches.WeightCleaningService;
+import fr.ifremer.tutti.service.catches.WeightComputingService;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+
+import javax.swing.JOptionPane;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public class ComputeBatchWeightsAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
+
+ protected final WeightCleaningService cleaningService;
+
+ public ComputeBatchWeightsAction(EditCatchesUIHandler handler) {
+ super(handler, true);
+ cleaningService = getContext().getWeightCleaningService();
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean doAction = super.prepareAction();
+ if (doAction) {
+
+ // do a check of double weights
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ Multimap<String, String> errors = cleaningService.checkFishingOperation(fishingOperation.getId());
+
+ if (errors.isEmpty()) {
+
+ // no errors
+
+ sendMessage(_("tutti.editCatchBatch.action.computeWeights.no.double.weight.detected"));
+ } else {
+
+ // show errors to user as warning
+
+ String errorsStr = cleaningService.errorsToString(errors);
+ String htmlMessage = _("tutti.editCatchBatch.action.computeWeights.double.weight.detected", errorsStr);
+
+ JOptionPane.showMessageDialog(getContext().getActionUI(),
+ htmlMessage,
+ _("tutti.editCatchBatch.action.computeWeights.double.weight.detected.title"),
+ JOptionPane.WARNING_MESSAGE);
+
+
+ }
+ }
+ return doAction;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ PersistenceService persistenceService = getContext().getPersistenceService();
+
+ WeightComputingService weightComputingService = getContext().getWeightComputingService();
+
+ EditCatchesUIModel model = getModel();
+ model.setLoadingData(true);
+
+ // ---------
+ // Compute species batches
+ // ---------
+
+ BatchContainer<SpeciesBatch> computedSpeciesBatches;
+ Float totalSpeciesSortedWeight;
+ String operationId = model.getFishingOperation().getId();
+ try {
+ computedSpeciesBatches =
+ weightComputingService.getComputedSpeciesBatches(operationId);
+ totalSpeciesSortedWeight = computeSpeciesBatches(persistenceService, computedSpeciesBatches);
+
+ } catch (TuttiWeightComputingException e) {
+ getUI().getTabPane().setSelectedIndex(1);
+
+ int index = e.getIndex();
+ SpeciesBatchRowModel row = getUI().getSpeciesTabContent().getModel().getRows().get(index);
+ int column;
+ if (SpeciesBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT.equals(e.getProperty())) {
+ column = getFinestCategoryColumn(row.getFinestCategory().getCategoryId());
+ } else {
+ column = 6;
+ }
+ TuttiUIUtil.doSelectCell(getUI().getSpeciesTabContent().getTable(), index, column);
+
+ throw e;
+ }
+
+ // ---------
+ // Compute benthos batches
+ // ---------
+
+ BatchContainer<BenthosBatch> computedBenthosBatches;
+ Float totalBenthosSortedWeight;
+ try {
+ computedBenthosBatches =
+ weightComputingService.getComputedBenthosBatches(operationId);
+ totalBenthosSortedWeight = computeBenthosBatches(persistenceService, computedBenthosBatches);
+
+ } catch (TuttiWeightComputingException e) {
+ getUI().getTabPane().setSelectedIndex(2);
+
+ int index = e.getIndex();
+ BenthosBatchRowModel row = getUI().getBenthosTabContent().getModel().getRows().get(index);
+ int column;
+ if (BenthosBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT.equals(e.getProperty())) {
+ column = getFinestCategoryColumn(row.getFinestCategory().getCategoryId());
+ } else {
+ column = 6;
+ }
+ TuttiUIUtil.doSelectCell(getUI().getBenthosTabContent().getTable(), index, column);
+
+ throw e;
+ }
+
+ // ---------
+ // Compute marine litter batches
+ // ---------
+
+ BatchContainer<MarineLitterBatch> computedMarineLitterBatches;
+ try {
+ computedMarineLitterBatches =
+ weightComputingService.getComputedMarineLitterBatches(operationId,
+ model.getMarineLitterTotalWeight());
+
+ } catch (TuttiWeightComputingException e) {
+ getUI().getTabPane().setSelectedIndex(3);
+ TuttiUIUtil.doSelectCell(getUI().getMarineLitterTabContent().getTable(), e.getIndex(), 3);
+ throw e;
+ }
+
+ // ---------
+ // Check species rates
+ // ---------
+
+ Float rate = getConfig().getDifferenceRateBetweenSortedAndTotalWeights();
+ if (model.getSpeciesTotalSortedWeight() != null
+ && model.getSpeciesTotalSortedWeight() >= totalSpeciesSortedWeight
+ && model.getSpeciesTotalSortedWeight() < (1 + rate / 100) * totalSpeciesSortedWeight) {
+
+ // Si le "Poids total VRAC" est saisi est que sa valeur
+ // est supérieure de moins de x% (x en configuration)
+ // du "Poids total Vrac trié", demander confirmation que
+ // le "Poids total VRAC" est bien une valeur observée
+ // sinon la remplacer par le "Poids total Vrac trié"
+
+ getUI().getTabPane().setSelectedIndex(1);
+
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.message.species", rate),
+ _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.help"));
+
+ int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
+ htmlMessage,
+ _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.title"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+
+ if (answer == JOptionPane.NO_OPTION) {
+ model.setSpeciesTotalSortedWeight(null);
+ model.setSpeciesTotalSortedComputedWeight(totalSpeciesSortedWeight);
+ }
+ }
+
+ // ---------
+ // Check benthos rates
+ // ---------
+
+ if (model.getBenthosTotalSortedWeight() != null
+ && model.getBenthosTotalSortedWeight() >= totalBenthosSortedWeight
+ && model.getBenthosTotalSortedWeight() < (1 + rate / 100) * totalBenthosSortedWeight) {
+
+ // Si le "Poids total VRAC" est saisi est que sa valeur
+ // est supérieure de moins de x% (x en configuration)
+ // du "Poids total Vrac trié", demander confirmation que
+ // le "Poids total VRAC" est bien une valeur observée
+ // sinon la remplacer par le "Poids total Vrac trié"
+
+ getUI().getTabPane().setSelectedIndex(2);
+
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.message.benthos", rate),
+ _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.help"));
+
+ int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
+ htmlMessage,
+ _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.title"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+
+ if (answer == JOptionPane.NO_OPTION) {
+ model.setBenthosTotalSortedWeight(null);
+ model.setBenthosTotalSortedComputedWeight(totalBenthosSortedWeight);
+ }
+ }
+
+ boolean modified = model.isModify();
+ CatchBatch catchBatch = model.toEntity();
+ weightComputingService.computeCatchBatchWeights(catchBatch,
+ computedSpeciesBatches,
+ computedBenthosBatches,
+ computedMarineLitterBatches);
+ model.fromEntity(catchBatch);
+ model.setLoadingData(false);
+
+ model.setModify(modified);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ getUI().repaint();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected Float computeSpeciesBatches(PersistenceService persistenceService, BatchContainer<SpeciesBatch> computedSpeciesBatches) {
+ Float totalSortedWeight = 0f;
+
+ if (computedSpeciesBatches != null) {
+ List<SpeciesBatchRowModel> rows = Lists.newArrayList();
+ List<SpeciesBatch> children = computedSpeciesBatches.getChildren();
+ for (SpeciesBatch batch : children) {
+ SpeciesBatchRowModel row = getUI().getSpeciesTabContent().getHandler().loadBatch(batch, null, rows);
+ if (persistenceService.isVracBatch(row)) {
+ SampleCategory<?> sampleCategory = row.getFirstSampleCategory();
+ Float weight = TuttiEntities.getValueOrComputedValue(
+ sampleCategory.getCategoryWeight(),
+ sampleCategory.getComputedWeight());
+ totalSortedWeight += weight;
+ }
+ }
+ getUI().getSpeciesTabContent().getModel().setRows(rows);
+ }
+
+ return totalSortedWeight;
+ }
+
+ protected Float computeBenthosBatches(PersistenceService persistenceService, BatchContainer<BenthosBatch> computedBenthosBatches) {
+ Float totalSortedWeight = 0f;
+
+ if (computedBenthosBatches != null) {
+ List<BenthosBatchRowModel> rows = Lists.newArrayList();
+ List<BenthosBatch> children = computedBenthosBatches.getChildren();
+ for (BenthosBatch batch : children) {
+ BenthosBatchRowModel row = getUI().getBenthosTabContent().getHandler().loadBatch(batch, null, rows);
+
+ if (persistenceService.isVracBatch(row)) {
+ SampleCategory<?> sampleCategory = row.getFirstSampleCategory();
+ Float weight = TuttiEntities.getValueOrComputedValue(
+ sampleCategory.getCategoryWeight(),
+ sampleCategory.getComputedWeight());
+ totalSortedWeight += weight;
+ }
+ }
+ getUI().getBenthosTabContent().getModel().setRows(rows);
+
+ }
+ return totalSortedWeight;
+ }
+
+ protected int getFinestCategoryColumn(Integer categoryId) {
+ int column = 1;
+
+ List<Integer> samplingOrderIds = getConfig().getSamplingOrderIds();
+
+ int index = samplingOrderIds.indexOf(categoryId);
+ if (index > -1) {
+ column += index + 1;
+ }
+
+ return column;
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateBenthosMelagAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/CreateBenthosMelagAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateBenthosMelagAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateBenthosMelagAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,201 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.Maps;
+import fr.ifremer.shared.application.type.WeightUnit;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchTableModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyRowModel;
+import fr.ifremer.tutti.ui.swing.util.species.EnterMelagWeightDialog;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.swing.JOptionPane;
+import java.awt.Frame;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0.2
+ */
+public class CreateBenthosMelagAction extends AbstractTuttiAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> {
+
+ protected Map<BenthosBatchRowModel, Float> selectedRows = Maps.newHashMap();
+
+ protected Float melagWeight = null;
+
+ protected Float sampleMelagWeight = null;
+
+ protected Float sortedWeight = null;
+
+ /**
+ * Weight unit.
+ *
+ * @since 2.5
+ */
+ protected final WeightUnit weightUnit;
+
+ public CreateBenthosMelagAction(BenthosBatchUIHandler handler) {
+ super(handler, false);
+ weightUnit = getConfig().getBenthosWeightUnit();
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+
+ int[] selectedRowIndexes = SwingUtil.getSelectedModelRows(handler.getTable());
+
+ BenthosBatchTableModel tableModel = handler.getTableModel();
+
+ // sum of the weights already entered by the user
+ Float alreadyKnownWeights = 0f;
+ sortedWeight = 0f;
+
+ for (int selectedRowIndex : selectedRowIndexes) {
+ BenthosBatchRowModel selectedRow =
+ tableModel.getEntry(selectedRowIndex);
+
+ Float sampleWeight = null;
+ if (selectedRow.getFinestCategory().getNotNullWeight() != null) {
+ alreadyKnownWeights += selectedRow.getFinestCategory().getNotNullWeight();
+
+ } else if (selectedRow.getWeight() != null) {
+ sampleWeight = selectedRow.getWeight();
+
+ } else {
+ sampleWeight = 0f;
+ if (selectedRow.getFrequency() != null) {
+ for (BenthosFrequencyRowModel frequency : selectedRow.getFrequency()) {
+ if (frequency.getWeight() == null) {
+ sampleWeight = 0f;
+ break;
+ }
+ sampleWeight += frequency.getWeight();
+ }
+ }
+ }
+
+ if (sampleWeight != null) {
+ if (sampleWeight == 0f) {
+ JOptionPane.showMessageDialog(
+ getUI(),
+ _("tutti.createBenthosMelag.error.message", selectedRowIndex + 1),
+ _("tutti.createBenthosMelag.error.title"),
+ JOptionPane.ERROR_MESSAGE);
+
+ SwingUtil.setSelectionInterval(handler.getTable(), selectedRowIndex);
+ result = false;
+ break;
+
+ } else {
+ sortedWeight += sampleWeight;
+ }
+ }
+
+ selectedRows.put(selectedRow, sampleWeight);
+ }
+
+ if (result) {
+ melagWeight = openMelagWeightDialog();
+
+ if (melagWeight != null) {
+ // substract the weights that the user already entered
+ // they must not be used to compute the other weights
+ sampleMelagWeight = melagWeight - alreadyKnownWeights;
+ }
+ }
+
+ return result && melagWeight != null;
+ }
+
+ protected Float openMelagWeightDialog() {
+ Frame frame = SwingUtil.getParentContainer(getUI(), Frame.class);
+
+ EnterMelagWeightDialog dialog = new EnterMelagWeightDialog(
+ frame, getConfig().getShortcutClosePopup());
+ dialog.setWeightUnit(weightUnit);
+ SwingUtil.center(frame, dialog);
+ dialog.pack();
+ dialog.setVisible(true);
+
+ Float result = null;
+ if (dialog.getEditor().getModel() != null) {
+ result = dialog.getEditor().getModel().floatValue();
+ }
+ return result;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ String unitLabel = weightUnit.getShortLabel();
+ String melagComment = _("tutti.createBenthosMelag.comment.part1") + "\n";
+ for (BenthosBatchRowModel batch : selectedRows.keySet()) {
+ Float sampleWeight = selectedRows.get(batch);
+ if (sampleWeight != null) {
+ Float weight = sampleMelagWeight * sampleWeight / sortedWeight;
+ batch.getFinestCategory().setCategoryWeight(weight);
+ }
+ melagComment += _("tutti.createBenthosMelag.comment.part2", sampleWeight, unitLabel, decorate(batch.getSpecies())) + "\n";
+ }
+ melagComment += _("tutti.createBenthosMelag.comment.part3", melagWeight, unitLabel);
+
+ for (BenthosBatchRowModel batch : selectedRows.keySet()) {
+ String comment = batch.getComment();
+ if (StringUtils.isBlank(comment)) {
+ comment = "";
+
+ } else {
+ comment += "\n";
+ }
+ comment += melagComment;
+ batch.setComment(comment);
+ }
+ getHandler().saveRows(selectedRows.keySet());
+ }
+
+ @Override
+ public void releaseAction() {
+ super.releaseAction();
+ //FIXME-TC No release action is not design to refresh ui...
+// getHandler().getTable().repaint();
+ selectedRows.clear();
+ melagWeight = null;
+ sortedWeight = null;
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ getHandler().getTable().repaint();
+
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateSpeciesMelagAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateSpeciesMelagAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/CreateSpeciesMelagAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,203 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.Maps;
+import fr.ifremer.shared.application.type.WeightUnit;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
+import fr.ifremer.tutti.ui.swing.util.species.EnterMelagWeightDialog;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.swing.JOptionPane;
+import java.awt.Frame;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0.2
+ */
+public class CreateSpeciesMelagAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> {
+
+ protected Map<SpeciesBatchRowModel, Float> selectedRows = Maps.newHashMap();
+
+ protected Float melagWeight = null;
+
+ protected Float sampleMelagWeight = null;
+
+ protected Float sortedWeight = null;
+
+ /**
+ * Weight unit.
+ *
+ * @since 2.5
+ */
+ protected final WeightUnit weightUnit;
+
+ public CreateSpeciesMelagAction(SpeciesBatchUIHandler handler) {
+ super(handler, false);
+ weightUnit = getConfig().getSpeciesWeightUnit();
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+
+ int[] selectedRowIndexes = SwingUtil.getSelectedModelRows(handler.getTable());
+
+ SpeciesBatchTableModel tableModel = handler.getTableModel();
+
+ // sum of the weights already entered by the user
+ Float alreadyKnownWeights = 0f;
+ sortedWeight = 0f;
+
+ for (int selectedRowIndex : selectedRowIndexes) {
+ SpeciesBatchRowModel selectedRow =
+ tableModel.getEntry(selectedRowIndex);
+
+ Float sampleWeight = null;
+ if (selectedRow.getFinestCategory().getNotNullWeight() != null) {
+ alreadyKnownWeights += selectedRow.getFinestCategory().getNotNullWeight();
+
+ } else if (selectedRow.getWeight() != null) {
+ sampleWeight = selectedRow.getWeight();
+
+ } else {
+ sampleWeight = 0f;
+ if (selectedRow.getFrequency() != null) {
+ for (SpeciesFrequencyRowModel frequency : selectedRow.getFrequency()) {
+ if (frequency.getWeight() == null) {
+ sampleWeight = 0f;
+ break;
+ }
+ sampleWeight += frequency.getWeight();
+ }
+ }
+ }
+
+ if (sampleWeight != null) {
+ if (sampleWeight == 0f) {
+ JOptionPane.showMessageDialog(
+ getUI(),
+ _("tutti.createSpeciesMelag.error.message", selectedRowIndex + 1),
+ _("tutti.createSpeciesMelag.error.title"),
+ JOptionPane.ERROR_MESSAGE);
+
+ SwingUtil.setSelectionInterval(handler.getTable(), selectedRowIndex);
+ result = false;
+ break;
+
+ } else {
+ sortedWeight += sampleWeight;
+ }
+ }
+
+ selectedRows.put(selectedRow, sampleWeight);
+ }
+
+ if (result) {
+ melagWeight = openMelagWeightDialog();
+
+ if (melagWeight != null) {
+ // substract the weights that the user already entered
+ // they must not be used to compute the other weights
+ sampleMelagWeight = melagWeight - alreadyKnownWeights;
+ }
+ }
+
+ return result && melagWeight != null;
+ }
+
+ protected Float openMelagWeightDialog() {
+ Frame frame = SwingUtil.getParentContainer(getUI(), Frame.class);
+
+ EnterMelagWeightDialog dialog = new EnterMelagWeightDialog(
+ frame, getConfig().getShortcutClosePopup());
+
+ dialog.setWeightUnit(weightUnit);
+
+ SwingUtil.center(frame, dialog);
+ dialog.pack();
+ dialog.setVisible(true);
+
+ Float result = null;
+ if (dialog.getEditor().getModel() != null) {
+ result = dialog.getEditor().getModel().floatValue();
+ }
+ return result;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ String unitLabel = weightUnit.getShortLabel();
+ String melagComment = _("tutti.createSpeciesMelag.comment.part1") + "\n";
+ for (SpeciesBatchRowModel batch : selectedRows.keySet()) {
+ Float sampleWeight = selectedRows.get(batch);
+ if (sampleWeight != null) {
+ Float weight = sampleMelagWeight * sampleWeight / sortedWeight;
+ batch.getFinestCategory().setCategoryWeight(weight);
+ }
+ melagComment += _("tutti.createSpeciesMelag.comment.part2", sampleWeight, unitLabel, decorate(batch.getSpecies())) + "\n";
+ }
+ melagComment += _("tutti.createSpeciesMelag.comment.part3", melagWeight, unitLabel);
+
+ for (SpeciesBatchRowModel batch : selectedRows.keySet()) {
+ String comment = batch.getComment();
+ if (StringUtils.isBlank(comment)) {
+ comment = "";
+
+ } else {
+ comment += "\n";
+ }
+ comment += melagComment;
+ batch.setComment(comment);
+ }
+ getHandler().saveRows(selectedRows.keySet());
+ }
+
+ @Override
+ public void releaseAction() {
+ super.releaseAction();
+ //FIXME-TC No release action is not design to refresh ui...
+// getHandler().getTable().repaint();
+ selectedRows.clear();
+ melagWeight = null;
+ sortedWeight = null;
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ getHandler().getTable().repaint();
+
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/DeleteFishingOperationAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/DeleteFishingOperationAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/DeleteFishingOperationAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/DeleteFishingOperationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,90 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To delete a fishing operation.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.2
+ */
+public class DeleteFishingOperationAction extends AbstractTuttiAction<FishingOperationsUIModel, FishingOperationsUI, FishingOperationsUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(DeleteFishingOperationAction.class);
+
+ public DeleteFishingOperationAction(FishingOperationsUIHandler handler) {
+ super(handler, true);
+ setActionDescription(
+ _("tutti.editFishingOperation.action.deleteFishingOperation.tip"));
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean canContinue = super.prepareAction();
+ FishingOperation fishingOperation = getModel().getSelectedFishingOperation();
+ canContinue &= fishingOperation != null &&
+ !TuttiEntities.isNew(fishingOperation) &&
+ askBeforeDelete(
+ _("tutti.editFishingOperation.action.deleteFishingOperation.title"),
+ _("tutti.editFishingOperation.action.deleteFishingOperation.message", decorate(fishingOperation))
+ );
+ return canContinue;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ FishingOperation fishingOperation =
+ getModel().getSelectedFishingOperation();
+
+ if (log.isInfoEnabled()) {
+ log.info("Will delete fishingOperation: " + fishingOperation);
+ }
+
+ getContext().getPersistenceService().deleteFishingOperation(fishingOperation.getId());
+
+ FishingOperationsUIModel model = getModel();
+
+ // unselect removed fishing operation
+ model.setSelectedFishingOperation(null);
+
+ // remove it from selection model
+ model.removeFishingOperation(fishingOperation);
+
+ sendMessage(_("tutti.editFishingOperation.message.operation.deleted", decorate(fishingOperation)));
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/DeleteProtocolAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/DeleteProtocolAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/DeleteProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,99 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUI;
+import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUIHandler;
+import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To delete the selected protocol.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class DeleteProtocolAction extends AbstractTuttiAction<SelectCruiseUIModel, SelectCruiseUI, SelectCruiseUIHandler> {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(EditProtocolAction.class);
+
+ public DeleteProtocolAction(SelectCruiseUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+
+ TuttiProtocol protocol = getHandler().getModel().getProtocol();
+
+ result &=
+ askBeforeDelete(
+ _("tutti.selectCruise.action.deleteProtocol.title"),
+ _("tutti.selectCruise.action.deleteProtocol.message", protocol.getName())
+ );
+
+ return result;
+ }
+
+ @Override
+ public void doAction() {
+ TuttiProtocol protocol = getModel().getProtocol();
+ Preconditions.checkNotNull(protocol);
+ String id = protocol.getId();
+ Preconditions.checkNotNull(id);
+ if (log.isInfoEnabled()) {
+ log.info("Delete protocol: " + id);
+ }
+
+ PersistenceService service = getContext().getPersistenceService();
+ service.deleteProtocol(id);
+
+ getModel().setProtocol(null);
+
+ List<TuttiProtocol> protocols = getModel().getProtocols();
+ protocols.remove(protocol);
+
+ if (log.isInfoEnabled()) {
+ log.info("nb protocols: " + protocols.size());
+ }
+ // reset (will clear combo-box)
+ getModel().setProtocols(null);
+
+ // set new list
+ getModel().setProtocols(protocols);
+
+ getHandler().resetEditProtolAction();
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCatchesAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditCatchesAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCatchesAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCatchesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,71 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.service.ValidationService;
+import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Opens the operations edition screen.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class EditCatchesAction extends AbstractChangeScreenAction {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(EditCatchesAction.class);
+
+ public EditCatchesAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.EDIT_FISHING_OPERATION);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkState(getContext().isProgramFilled());
+ Preconditions.checkState(getContext().isCruiseFilled());
+ if (log.isInfoEnabled()) {
+ log.info("Edit operations of cruise: " + getContext().getCruiseId());
+ }
+ getContext().setValidationContext(ValidationService.VALIDATION_CONTEXT_EDIT);
+ super.doAction();
+ }
+
+ @Override
+ public void postFailedAction(Throwable error) {
+// TuttiUIContext context = getContext();
+// if (error != null) {
+// if (context.isDbLoaded()) {
+// context.setScreen(TuttiScreen.SELECT_CRUISE);
+// } else {
+// context.setScreen(TuttiScreen.MANAGE_DB);
+// }
+// }
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCruiseAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditCruiseAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCruiseAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCruiseAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,49 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+
+/**
+ * Opens the cruise edition screen.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class EditCruiseAction extends AbstractChangeScreenAction {
+
+ public EditCruiseAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.EDIT_CRUISE);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkState(getContext().isProgramFilled());
+ Preconditions.checkState(getContext().isCruiseFilled());
+ super.doAction();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCruiseFishingOperationAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseFishingOperationAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCruiseFishingOperationAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditCruiseFishingOperationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,177 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.service.catches.ValidateCruiseOperationsService;
+import fr.ifremer.tutti.ui.swing.content.cruise.ValidateCruiseUI;
+import fr.ifremer.tutti.ui.swing.content.cruise.ValidateCruiseUIHandler;
+import fr.ifremer.tutti.ui.swing.content.cruise.ValidateCruiseUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import org.nuiton.validator.NuitonValidatorResult;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To edit the given fishing operation.
+ *
+ * @author kmorin <morin(a)codelutin.com>
+ * @since 1.4
+ */
+public class EditCruiseFishingOperationAction extends AbstractTuttiAction<ValidateCruiseUIModel, ValidateCruiseUI, ValidateCruiseUIHandler> {
+
+ /** Validation service. */
+ private final ValidateCruiseOperationsService validationService = getContext().getValidateCruiseOperationsService();
+
+ /**
+ * 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).
+ */
+ protected FishingOperation fishingOperation;
+
+ protected final PropertyChangeListener editFishingOperationModelListener = new PropertyChangeListener() {
+
+ protected final List<String> propertiesToIgnore = Lists.newArrayList(
+ EditFishingOperationUIModel.PROPERTY_MODIFY,
+ EditFishingOperationUIModel.PROPERTY_VALID,
+ EditFishingOperationUIModel.PROPERTY_PERSISTED
+ );
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ EditFishingOperationUIModel model = (EditFishingOperationUIModel) evt.getSource();
+
+ if (!model.isLoadingData()
+ && model.getFishingOperation() != null
+ && !propertiesToIgnore.contains(evt.getPropertyName())) {
+
+ model.convertGearShootingCoordinatesToDD();
+
+ FishingOperation operation = model.toBean();
+ NuitonValidatorResult validationResult = validationService.validateCruiseOperation(operation);
+
+ ValidateCruiseUIModel uiModel = getModel();
+ uiModel.getValidator().put(uiModel.getSelectedFishingOperation(), validationResult);
+
+ getHandler().updateCurrentOperationNode(validationResult);
+
+ }
+ }
+ };
+
+ protected final PropertyChangeListener editCatchesModelListener = new PropertyChangeListener() {
+
+ protected final List<String> propertiesToIgnore = Lists.newArrayList(
+ EditCatchesUIModel.PROPERTY_MODIFY,
+ EditCatchesUIModel.PROPERTY_VALID,
+ EditCatchesUIModel.PROPERTY_CATCH_TOTAL_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_CATCH_TOTAL_SORTED_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_CATCH_TOTAL_UNSORTED_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_CATCH_TOTAL_REJECTED_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SORTED_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_UNSORTED_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_INERT_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_SORTED_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_UNSORTED_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_INERT_COMPUTED_WEIGHT,
+ EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_COMPUTED_WEIGHT
+ );
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ EditCatchesUIModel model = (EditCatchesUIModel) evt.getSource();
+
+ if (!model.isLoadingData()
+ && model.getFishingOperation() != null
+ && !propertiesToIgnore.contains(evt.getPropertyName())) {
+
+ CatchBatch catchBatch = model.toBean();
+ NuitonValidatorResult validationResult = validationService.validateCruiseOperation(catchBatch);
+
+ ValidateCruiseUIModel uiModel = getModel();
+ uiModel.getValidator().put(uiModel.getSelectedFishingOperation(), validationResult);
+
+ getHandler().updateCurrentOperationNode(validationResult);
+ }
+ }
+ };
+
+ public EditCruiseFishingOperationAction(ValidateCruiseUIHandler handler) {
+ super(handler, true);
+ setActionDescription(_("tutti.editFishingOperation.action.editFishingOperation.tip"));
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ FishingOperationsUI operationPanel = getUI().getOperationPanel();
+ operationPanel.getFishingOperationTabContent().getModel().
+ removePropertyChangeListener(editFishingOperationModelListener);
+ operationPanel.getCatchesTabContent().getModel().
+ removePropertyChangeListener(editCatchesModelListener);
+
+ return super.prepareAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ getUI().getOperationPanel().getModel().setSelectedFishingOperation(fishingOperation);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ FishingOperationsUI operationPanel = getUI().getOperationPanel();
+ operationPanel.getFishingOperationTabContent().getModel().addPropertyChangeListener(editFishingOperationModelListener);
+ operationPanel.getCatchesTabContent().getModel().addPropertyChangeListener(editCatchesModelListener);
+ }
+
+ @Override
+ public void releaseAction() {
+ super.releaseAction();
+ fishingOperation = null;
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditFishingOperationAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditFishingOperationAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditFishingOperationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,798 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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 com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.InvalidBatchModelException;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.Attachment;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatchs;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperations;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrders;
+import fr.ifremer.tutti.persistence.entities.referential.Person;
+import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import fr.ifremer.tutti.persistence.entities.referential.Vessel;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI;
+import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.SecondaryVesselTypeEnum;
+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.fishing.GearUseFeatureTabUI;
+import fr.ifremer.tutti.ui.swing.content.operation.fishing.VesselUseFeatureTabUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JTabbedPane;
+import java.awt.BorderLayout;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+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> {
+
+ /** 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;
+
+ /**
+ * Delegate action to compute the weight of the operations.
+ *
+ * @since 1.1
+ */
+ protected ComputeBatchWeightsAction computeBatchWeightsAction;
+
+ /**
+ * Delegate action to save catch batch.
+ *
+ * @since 1.0
+ */
+ protected SaveCatchBatchAction saveCatchBatchAction;
+
+ /**
+ * To keep catch validation error while loading batches.
+ *
+ * @since 2.4
+ */
+ protected List<String> errorMessages = Lists.newArrayList();
+
+ /**
+ * Flag to know if this action is part of another action.
+ *
+ * @since 2.4
+ */
+ protected boolean internalAction;
+
+ /**
+ * To recompute distance when coordinate change.
+ *
+ * @since 2.4
+ */
+ 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_DMS_SIGN,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DMS_DEGREE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DMS_MINUTE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DMS_SECOND,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DMD_SIGN,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DMD_DEGREE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DMD_MINUTE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DMS_SIGN,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DMS_DEGREE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DMS_MINUTE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DMS_SECOND,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DMD_SIGN,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DMD_DEGREE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DMD_MINUTE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DMS_SIGN,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DMS_DEGREE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DMS_MINUTE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DMS_SECOND,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DMD_SIGN,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DMD_DEGREE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DMD_MINUTE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DMS_SIGN,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DMS_DEGREE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DMS_MINUTE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DMS_SECOND,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DMD_SIGN,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DMD_DEGREE,
+ EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DMD_MINUTE
+ );
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (properties.contains(evt.getPropertyName())) {
+ EditFishingOperationUIModel source = (EditFishingOperationUIModel) evt.getSource();
+ if (source.isFishingOperationRectiligne()) {
+ source.computeDistance();
+ }
+ }
+ }
+ };
+
+ public EditFishingOperationAction(FishingOperationsUIHandler handler) {
+ super(handler, true);
+ setActionDescription(_("tutti.editFishingOperation.action.editFishingOperation.tip"));
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ getDataContext().setFishingOperationId(fishingOperation != null ? fishingOperation.getId() : null);
+ }
+
+ public void setCheckPreviousEdit(boolean checkPreviousEdit) {
+ this.checkPreviousEdit = checkPreviousEdit;
+ }
+
+ @Override
+ public void releaseAction() {
+ fishingOperation = null;
+ checkPreviousEdit = true;
+ internalAction = false;
+ super.releaseAction();
+ }
+
+ 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;
+ }
+
+ protected ComputeBatchWeightsAction getComputeBatchWeightsAction() {
+ if (computeBatchWeightsAction == null) {
+ computeBatchWeightsAction = new ComputeBatchWeightsAction(getUI().getCatchesTabContent().getHandler());
+ }
+ return computeBatchWeightsAction;
+ }
+
+ @Override
+ public boolean prepareAction() {
+
+ boolean canContinue = true;
+ if (checkPreviousEdit) {
+ FishingOperationsUI ui = getUI();
+
+ final FishingOperationsUIModel model = ui.getModel();
+
+ FishingOperation editFishingOperation = model.getEditFishingOperation();
+
+ String editFishingOperationId = null;
+
+ if (editFishingOperation == null) {
+
+ // no previous fishing operation in edition, can continue
+ canContinue = true;
+ } else {
+
+ editFishingOperationId = editFishingOperation.getId();
+
+ boolean create = TuttiEntities.isNew(editFishingOperation);
+
+ boolean fishingOperationModified = getHandler().isFishingOperationModified();
+ boolean catchBatchModified = getHandler().isCatchBatchModified();
+
+ boolean fishingOperationValid = getHandler().isFishingOperationValid();
+ boolean catchBatchValid = getHandler().isCatchBatchValid();
+
+ boolean needSave = create || fishingOperationModified || catchBatchModified;
+
+
+ if (needSave) {
+
+ boolean canSave = fishingOperationValid && catchBatchValid;
+
+ canContinue = false;
+
+ if (canSave) {
+
+ String message;
+
+ if (create) {
+ message = _("tutti.editFishingOperation.askSaveBeforeLeaving.createFishingOperation");
+ } else if (fishingOperationModified) {
+ message = _("tutti.editFishingOperation.askSaveBeforeLeaving.saveFishingOperation");
+ } else {
+ message = _("tutti.editCatchBatch.askSaveBeforeLeaving.saveCatchBatch");
+ }
+
+ int answer = getHandler().askSaveBeforeLeaving(message);
+
+
+ switch (answer) {
+ case JOptionPane.OK_OPTION:
+
+ // persist previous fishing operation
+ if (fishingOperationModified) {
+ getSaveFishingOperationAction().setUpdateUI(false);
+ getActionEngine().runInternalAction(getSaveFishingOperationAction());
+ }
+
+ if (catchBatchModified) {
+ getSaveCatchBatchAction().setUpdateUI(false);
+ getActionEngine().runInternalAction(getSaveCatchBatchAction());
+ }
+
+ 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;
+ }
+ } else {
+
+ // data are not valid
+ String message;
+
+ if (fishingOperationValid) {
+ message = _("tutti.editCatchBatch.askCancelEditBeforeLeaving.cancelEditCatchBatch");
+ } else {
+ message = _("tutti.editFishingOperation.askCancelEditBeforeLeaving.cancelEditFishingOperation");
+ }
+
+ // ok will revert any modification by
+ // editing new fishing operation (if user says yes)
+ canContinue = handler.askCancelEditBeforeLeaving(message);
+ }
+ }
+ }
+
+ if (!canContinue) {
+
+ FishingOperation selectFishingOperation;
+ if (TuttiEntities.isNew(editFishingOperation)) {
+
+ // no selection
+ selectFishingOperation = null;
+ } else {
+ // rollback selected fishing operation
+ selectFishingOperation =
+ model.getFishingOperation(editFishingOperationId);
+ }
+
+ model.setEditionAdjusting(true);
+ try {
+ model.setSelectedFishingOperation(selectFishingOperation);
+ } finally {
+ model.setEditionAdjusting(false);
+ }
+ }
+ }
+
+ return canContinue;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ errorMessages.clear();
+
+ FishingOperationsUI ui = getUI();
+
+ FishingOperationsUIModel model = ui.getModel();
+
+ // edit new fishing operation
+ if (log.isDebugEnabled()) {
+ log.debug("Edit fishingOperation: " + fishingOperation);
+ }
+
+ // now fishing operation is edited
+ model.setEditFishingOperation(fishingOperation);
+
+ loadFishingOperation(fishingOperation);
+
+ loadCatchBatch(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);
+
+ ui.getFishingOperationTabContent().getFishingOperationTabPane().setSelectedIndex(0);
+
+ if (checkPreviousEdit) {
+ ui.getTabPane().setSelectedIndex(0);
+ }
+ }
+
+ model.addPropertyChangeListener(coordinatePropertiesListener);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ final EditFishingOperationUI fishingOperationTabContent = getUI().getFishingOperationTabContent();
+ fishingOperationTabContent.getModel().setModify(false);
+// SwingUtilities.invokeLater(
+// new Runnable() {
+// @Override
+// public void run() {
+// if (log.isInfoEnabled()) {
+// log.info("startLongitude: " + fishingOperationTabContent.getGearShootingStartLongitudeDMSField().getEditor().getText());
+// }
+// fishingOperationTabContent.getGearShootingStartLongitudeDMSField().getEditor().repaint();
+// fishingOperationTabContent.getGearShootingEndLongitudeDMSField().getEditor().repaint();
+// }
+// }
+// );
+ getUI().repaint();
+
+ if (!internalAction) {
+ displayValidationErrors();
+ }
+ }
+
+ public void displayValidationErrors() {
+ if (CollectionUtils.isNotEmpty(errorMessages)) {
+ for (String errorMessage : errorMessages) {
+ getContext().getErrorHelper().showErrorDialog(errorMessage, null);
+ }
+ }
+ }
+
+ public void loadFishingOperation(FishingOperation bean) {
+
+ EditFishingOperationUI ui = getUI().getFishingOperationTabContent();
+
+ EditFishingOperationUIHandler handler = ui.getHandler();
+
+ EditFishingOperationUIModel editFishingOperationUIModel = ui.getModel();
+
+ editFishingOperationUIModel.setLoadingData(true);
+
+ editFishingOperationUIModel.removeAllAttachment(editFishingOperationUIModel.getAttachment());
+
+ handler.uninstallStartDateListener();
+ handler.uninstallCoordinatesListener();
+
+ if (bean == null) {
+
+ editFishingOperationUIModel.fromBean(
+ FishingOperations.newFishingOperation());
+
+ editFishingOperationUIModel.setFishingOperation(bean);
+
+ editFishingOperationUIModel.setAllSecondaryVessel(null);
+ editFishingOperationUIModel.setFishingSecondaryVessel(null);
+ editFishingOperationUIModel.setScientificSecondaryVessel(null);
+ editFishingOperationUIModel.setOnlyCruisSecondaryVessel(null);
+ editFishingOperationUIModel.setSecondaryVesselType(null);
+
+ handler.clearValidators();
+
+ handler.resetAllModels();
+
+ } else { //if (!bean.equals(editFishingOperationUIModel.getFishingOperation()) || handler.isAModelModified()) {
+
+ TuttiLocation strata = bean.getStrata();
+ TuttiLocation subStrata = bean.getSubStrata();
+ TuttiLocation location = bean.getLocation();
+
+ PersistenceService persistenceService = getContext().getPersistenceService();
+
+ Cruise cruise = bean.getCruise();
+ if (cruise != null) {
+
+ // update gear universe
+ // add a equals on id + rankOrder
+ List<Gear> gears = Lists.newArrayList();
+ for (Gear gear : cruise.getGear()) {
+ CaracteristicMap caracteristics =
+ persistenceService.getGearCaracteristics(
+ cruise.getId(),
+ gear.getId(),
+ gear.getRankOrder());
+
+ Gear toKeep = GearWithOriginalRankOrders.newGearWithOriginalRankOrder(gear);
+ toKeep.setCaracteristics(caracteristics);
+
+ gears.add(toKeep);
+ }
+ ui.getGearComboBox().setData(gears);
+ }
+
+ editFishingOperationUIModel.fromBean(bean);
+
+ // to be sure combo list will be reloaded
+ editFishingOperationUIModel.setStrata(null);
+ editFishingOperationUIModel.setSubStrata(null);
+ editFishingOperationUIModel.setLocation(null);
+
+ editFishingOperationUIModel.convertGearShootingCoordinatesFromDD();
+
+ 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 saisisseur selection
+ List<Person> saisisseur = editFishingOperationUIModel.getRecorderPerson();
+ ui.getRecorderPersonList().getHandler().setSelected(saisisseur);
+
+ //reset gear use feature tab
+ GearUseFeatureTabUI gearUseFeatureTabContent = ui.getGearUseFeatureTabContent();
+ gearUseFeatureTabContent.getHandler().reset(bean);
+
+ //reset vessel use feature tab
+ VesselUseFeatureTabUI vesselUseFeatureTabContent = ui.getVesselUseFeatureTabContent();
+ vesselUseFeatureTabContent.getHandler().reset(bean);
+
+ Integer objectId = editFishingOperationUIModel.getObjectId();
+ if (objectId != null) {
+
+ List<Attachment> attachments =
+ persistenceService.getAllAttachments(
+ editFishingOperationUIModel.getObjectType(),
+ objectId);
+
+ editFishingOperationUIModel.addAllAttachment(attachments);
+ }
+
+ Vessel cruiseVessel = getDataContext().getCruise().getVessel();
+ List<Vessel> scientificVessels = getDataContext().getScientificVessels();
+ List<Vessel> fishingVessels = getDataContext().getFishingVessels();
+
+ { // update all secondary vessel universe
+ List<Vessel> vessels = Lists.newArrayList();
+ vessels.addAll(scientificVessels);
+ vessels.addAll(fishingVessels);
+ vessels.remove(cruiseVessel);
+ editFishingOperationUIModel.setAllSecondaryVessel(vessels);
+ }
+
+ { // update scientific secondary vessel universe
+ List<Vessel> vessels = Lists.newArrayList();
+ vessels.addAll(scientificVessels);
+ vessels.remove(cruiseVessel);
+ editFishingOperationUIModel.setScientificSecondaryVessel(vessels);
+ }
+
+ { // update fishing secondary vessel universe
+ List<Vessel> vessels = Lists.newArrayList();
+ vessels.addAll(fishingVessels);
+ vessels.remove(cruiseVessel);
+ editFishingOperationUIModel.setFishingSecondaryVessel(vessels);
+ }
+
+ { // update only cruise vessel universe
+
+ List<FishingOperation> fishingOperation =
+ getModel().getFishingOperation();
+
+ Set<Vessel> vesselSet = Sets.newHashSet();
+ for (FishingOperation operation : fishingOperation) {
+ List<Vessel> secondaryVessel = persistenceService.getFishingOperationSecondaryVessel(operation.getId());
+ if (CollectionUtils.isNotEmpty(secondaryVessel)) {
+ vesselSet.addAll(secondaryVessel);
+ }
+ }
+ List<Vessel> vessel = Lists.newArrayList(vesselSet);
+ editFishingOperationUIModel.setOnlyCruisSecondaryVessel(vessel);
+ }
+
+ // will propagate to model
+ ui.getSecondaryVesselList().getModel().setSelected(bean.getSecondaryVessel());
+
+ editFishingOperationUIModel.setSecondaryVesselType(SecondaryVesselTypeEnum.ALL);
+
+ editFishingOperationUIModel.setModify(false);
+ handler.getFishingOperationMonitor().clearModified();
+ handler.registerValidator();
+ }
+
+ editFishingOperationUIModel.setLoadingData(false);
+
+ handler.installStartDateListener();
+ handler.installCoordinatesListener();
+ }
+
+ public void loadCatchBatch(FishingOperation bean) {
+
+ boolean empty = bean == null || TuttiEntities.isNew(bean);
+
+ EditCatchesUI ui = getUI().getCatchesTabContent();
+ TuttiBeanMonitor<EditCatchesUIModel> catchBatchMonitor =
+ ui.getHandler().getCatchBatchMonitor();
+
+ EditCatchesUIModel catchesUIModel = ui.getModel();
+
+ catchesUIModel.setLoadingData(true);
+
+ catchesUIModel.reset();
+
+ CatchBatch batch;
+
+ List<Attachment> attachments;
+
+ boolean catchNotFound;
+ boolean catchEnabled;
+
+ String operationId = bean == null ? null : bean.getId();
+
+ ProgressionModel progressionModel = getProgressionModel();
+ if (progressionModel == null) {
+ progressionModel = new ProgressionModel();
+ setProgressionModel(progressionModel);
+ }
+ progressionModel.adaptTotal(empty ? 1 : 6);
+
+ if (empty) {
+
+ // create a new CatchBatch
+ progressionModel.increments("Create new catch batch");
+ if (log.isDebugEnabled()) {
+ log.debug("Create a new CatchBatch (fishing operation is null)");
+ }
+ batch = CatchBatchs.newCatchBatch();
+ batch.setFishingOperation(bean);
+
+ attachments = Collections.emptyList();
+
+ catchEnabled = true;
+ catchNotFound = false;
+
+ } else {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Load existing CatchBatch from operation id: " +
+ operationId);
+ }
+
+ PersistenceService persistenceService =
+ getContext().getPersistenceService();
+
+ progressionModel.increments("Chargement de la capture");
+
+ boolean withCatchBath =
+ persistenceService.isFishingOperationWithCatchBatch(
+ operationId);
+
+ if (withCatchBath) {
+
+ // load it
+ try {
+ batch = persistenceService.getCatchBatchFromFishingOperation(operationId);
+ batch.setFishingOperation(bean);
+ Integer objectId = batch.getIdAsInt();
+ attachments = persistenceService.getAllAttachments(catchesUIModel.getObjectType(), objectId);
+ catchNotFound = false;
+ catchEnabled = true;
+
+ } catch (InvalidBatchModelException e) {
+
+ // batch is not compatible with Tutti
+ if (log.isDebugEnabled()) {
+ log.debug("Invalid batch model", e);
+ }
+ batch = null;
+ attachments = Collections.emptyList();
+
+ catchEnabled = false;
+ catchNotFound = false;
+ }
+ } else {
+
+ // no catch batch
+ batch = null;
+ attachments = Collections.emptyList();
+
+ catchEnabled = false;
+ catchNotFound = true;
+ }
+ }
+
+ setCatch(attachments,
+ catchesUIModel,
+ catchBatchMonitor,
+ batch,
+ true,
+ catchEnabled,
+ catchNotFound);
+
+
+ // 4) Propagate new selected fishingoperation to others tabs
+
+ FishingOperation operationToLoad = batch == null ? null : bean;
+
+ boolean catchValid = true;
+
+ try {
+ progressionModel.increments("Chargement des captures Espèces");
+
+ ui.getSpeciesTabContent().getHandler().selectFishingOperation(operationToLoad);
+ } catch (InvalidBatchModelException e) {
+
+ // invalid sample category model for species batches
+ if (log.isDebugEnabled()) {
+ log.debug("Invalid sample category model for species batches", e);
+ }
+ errorMessages.add(e.getMessage());
+ catchValid = false;
+ }
+
+ try {
+ progressionModel.increments("Chargement des captures Benthos");
+ ui.getBenthosTabContent().getHandler().selectFishingOperation(operationToLoad);
+ } catch (InvalidBatchModelException e) {
+
+ // invalid sample category model for benthos batches
+ if (log.isDebugEnabled()) {
+ log.debug("Invalid sample category model for benthos batches", e);
+ }
+ errorMessages.add(e.getMessage());
+ catchValid = false;
+ }
+
+ if (catchValid) {
+
+ // load other tabs
+
+ progressionModel.increments("Chargmenent des macro-déchets");
+ ui.getMarineLitterTabContent().getHandler().selectFishingOperation(operationToLoad);
+
+ progressionModel.increments("Chargement des captures accidentelles");
+ ui.getAccidentalTabContent().getHandler().selectFishingOperation(operationToLoad);
+
+ progressionModel.increments("Chargement des données individuelles");
+ ui.getIndividualObservationTabContent().getHandler().selectFishingOperation(operationToLoad);
+
+ } else {
+
+ // remove catch
+ setCatch(Collections.<Attachment>emptyList(),
+ catchesUIModel,
+ catchBatchMonitor,
+ null,
+ false,
+ false,
+ false);
+ }
+
+ catchesUIModel.setLoadingData(false);
+ }
+
+ @Override
+ public void postFailedAction(Throwable error) {
+ super.postFailedAction(error);
+ }
+
+
+ protected void setCatch(List<Attachment> attachments,
+ EditCatchesUIModel catchesUIModel,
+ TuttiBeanMonitor<EditCatchesUIModel> catchBatchMonitor,
+ CatchBatch batch,
+ boolean sampleModelValid,
+ boolean catchEnabled,
+ boolean catchNotFound) {
+
+ getModel().setCatchEnabled(catchEnabled);
+ getModel().setCatchNotFound(catchNotFound);
+ getModel().setSampleCatchModelValid(sampleModelValid);
+
+ catchesUIModel.fromEntity(batch);
+ catchesUIModel.addAllAttachment(attachments);
+
+ catchesUIModel.setModify(false);
+ catchBatchMonitor.clearModified();
+ }
+
+ public void setInternalAction(boolean internalAction) {
+ this.internalAction = internalAction;
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditGearCaracteristicsAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditGearCaracteristicsAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditGearCaracteristicsAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditGearCaracteristicsAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,81 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrder;
+import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrders;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUI;
+import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUIHandler;
+import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUIModel;
+import fr.ifremer.tutti.ui.swing.content.cruise.GearCaracteristicsEditorUI;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.1
+ */
+public class EditGearCaracteristicsAction extends AbstractTuttiAction<EditCruiseUIModel, EditCruiseUI, EditCruiseUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(EditGearCaracteristicsAction.class);
+
+ protected final PersistenceService persistenceService;
+
+ public EditGearCaracteristicsAction(EditCruiseUIHandler handler) {
+ super(handler, false);
+ persistenceService = getContext().getPersistenceService();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ GearCaracteristicsEditorUI editor = getUI().getGearCaracteristicsEditor();
+ editor.getModel().setEditable(true);
+
+ GearWithOriginalRankOrder gear =
+ EditCruiseUIHandler.GEAR_EDIT_CONTEXT.getContextValue(getUI());
+
+ CaracteristicMap caracteristics =
+ persistenceService.getGearCaracteristics(
+ getDataContext().getCruise().getId(),
+ gear.getId(),
+ gear.getOriginalRankOrder());
+
+ GearWithOriginalRankOrder gearToView =
+ GearWithOriginalRankOrders.newGearWithOriginalRankOrder(gear);
+ gearToView.setCaracteristics(caracteristics);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will edit gear " + decorate(gearToView) +
+ " with " + gearToView.getCaracteristics().size() + " caracteristics.");
+ }
+ editor.getModel().setGear(gearToView);
+
+ getUI().getMainPanelLayout().setSelected(EditCruiseUIHandler.GEAR_CARACTERISTICS_CARD);
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditProgramAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProgramAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditProgramAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditProgramAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,56 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Opens the program edition screen.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class EditProgramAction extends AbstractChangeScreenAction {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(EditProgramAction.class);
+
+ public EditProgramAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.EDIT_PROGRAM);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkState(getContext().isProgramFilled());
+ if (log.isInfoEnabled()) {
+ log.info("Edit program: " + getContext().getProgramId());
+ }
+ super.doAction();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditProtocolAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProtocolAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditProtocolAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,154 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JOptionPane;
+import javax.swing.UIManager;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Opens the protocol edition screen.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class EditProtocolAction extends AbstractChangeScreenAction {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(EditProtocolAction.class);
+
+ public static final JAXXContextEntryDef<TuttiProtocol> CLEAN_PROTOCOL_ENTRY = new JAXXContextEntryDef<TuttiProtocol>("cleanProtocol", TuttiProtocol.class);
+
+ public EditProtocolAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.EDIT_PROTOCOL);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ CLEAN_PROTOCOL_ENTRY.removeContextValue(getContext().getMainUI());
+
+ boolean doAction = super.prepareAction();
+ if (doAction) {
+
+ // check that protocol is compatible with sample category model
+ SampleCategoryModel sampleCategoryModel =
+ getDataContext().getSampleCategoryModel();
+
+ TuttiProtocol protocol = getDataContext().getProtocol();
+
+ Set<Integer> badCategories = Sets.newHashSet();
+
+ TuttiProtocols.checkSampleCategories(sampleCategoryModel,
+ protocol,
+ badCategories);
+
+ if (!badCategories.isEmpty()) {
+
+ // detect some bad categories
+ if (log.isWarnEnabled()) {
+ log.warn("There is some bad categories: " + badCategories);
+ }
+
+ String message = TuttiProtocols.getBadCategoriesMessage(
+ badCategories,
+ getDecorator(Caracteristic.class, null),
+ getContext().getPersistenceService());
+
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ message,
+ _("tutti.common.askBeforeEditProtocol.help"));
+ int response = JOptionPane.showOptionDialog(
+ getContext().getActionUI(),
+ htmlMessage,
+ _("tutti.common.askBeforeEditProtocol.title"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.WARNING_MESSAGE,
+ UIManager.getIcon("warning"),
+ new Object[]{_("tutti.option.cleanAndEdit"), _("tutti.option.edit"), _("tutti.option.cancel")},
+ _("tutti.option.cancel")
+ );
+
+ switch (response) {
+ case 0:
+ // edit and clean
+ if (log.isInfoEnabled()) {
+ log.info("Clean and edit");
+ }
+
+ protocol = getContext().getPersistenceService().getProtocol(getContext().getProtocolId());
+
+ CLEAN_PROTOCOL_ENTRY.setContextValue(getContext().getMainUI(), protocol);
+
+ TuttiProtocols.removeBadCategories(sampleCategoryModel,
+ protocol);
+
+ break;
+
+ case 1:
+ // edit with no modification
+ if (log.isInfoEnabled()) {
+ log.info("Edit with no cleaning");
+ }
+ break;
+
+ default:
+
+ // cancel
+ doAction = false;
+ }
+
+ }
+ }
+ return doAction;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkState(getContext().isProtocolFilled());
+ if (log.isInfoEnabled()) {
+ log.info("Edit protocol: " + getContext().getProtocolId());
+ }
+ createProgressionModelIfRequired(4);
+ super.doAction();
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSampleCategoryModelAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSampleCategoryModelAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSampleCategoryModelAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,57 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To show {@link TuttiScreen#EDIT_SAMPLE_CATEGORY_MODEL} config screen.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.4
+ */
+public class EditSampleCategoryModelAction extends AbstractChangeScreenAction {
+
+ public EditSampleCategoryModelAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.EDIT_SAMPLE_CATEGORY_MODEL);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+ if (result) {
+ result = askAdminPassword(
+ _("tutti.editSampleCategoryModel.passwordDialog.message"),
+ _("tutti.editSampleCategoryModel.passwordDialog.title"),
+ _("tutti.editSampleCategoryModel.passwordDialog.error.message"),
+ _("tutti.editSampleCategoryModel.passwordDialog.error.title")
+ );
+ }
+ return result;
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedCruiseAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedCruiseAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedCruiseAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedCruiseAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,57 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Opens the cruise edition screen to edit the selected cruise.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class EditSelectedCruiseAction extends AbstractChangeScreenAction {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(EditSelectedCruiseAction.class);
+
+ public EditSelectedCruiseAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.EDIT_CRUISE);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkState(getContext().isCruiseFilled());
+ if (log.isInfoEnabled()) {
+ log.info("Edit cruise: " + getContext().getCruiseId());
+ }
+ super.doAction();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedCruiseCatchesAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedCruiseCatchesAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedCruiseCatchesAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedCruiseCatchesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,60 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.service.ValidationService;
+import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Opens the operations edition screen to edit the selected operations.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class EditSelectedCruiseCatchesAction extends AbstractChangeScreenAction {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(EditSelectedCruiseCatchesAction.class);
+
+ public EditSelectedCruiseCatchesAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.EDIT_FISHING_OPERATION);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkState(getContext().isCruiseFilled());
+ if (log.isInfoEnabled()) {
+ log.info("Edit operations of cruise: " + getContext().getCruiseId());
+ }
+ getContext().setValidationContext(ValidationService.VALIDATION_CONTEXT_EDIT);
+ super.doAction();
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedProgramAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedProgramAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedProgramAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedProgramAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,57 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Opens the program edition screen to edit the selected program.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class EditSelectedProgramAction extends AbstractChangeScreenAction {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(EditSelectedProgramAction.class);
+
+ public EditSelectedProgramAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.EDIT_PROGRAM);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkState(getContext().isProgramFilled());
+ if (log.isInfoEnabled()) {
+ log.info("Edit program: " + getContext().getProgramId());
+ }
+ super.doAction();
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedProtocolAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedProtocolAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedProtocolAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/EditSelectedProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,59 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Opens the protocol edition screen to edit the selected protocol.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class EditSelectedProtocolAction extends AbstractChangeScreenAction {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(EditSelectedProtocolAction.class);
+
+ public EditSelectedProtocolAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.EDIT_PROTOCOL);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkState(getContext().isProtocolFilled());
+ if (log.isDebugEnabled()) {
+ log.debug("Edit protocol: " + getContext().getProtocolId());
+ }
+ createProgressionModelIfRequired(4);
+ super.doAction();
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportAccidentalMultiPostAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/ExportMultiPostAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportAccidentalMultiPostAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportAccidentalMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,74 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.content.operation.catches.accidental.AccidentalBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.AccidentalBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.AccidentalBatchUIModel;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.2
+ */
+public class ExportAccidentalMultiPostAction
+ extends AbstractExportMultiPostAction<AccidentalBatchUIModel, AccidentalBatchUI, AccidentalBatchUIHandler> {
+
+ public ExportAccidentalMultiPostAction(AccidentalBatchUIHandler handler) {
+ super(handler);
+ }
+
+ @Override
+ protected String getFileExtension() {
+ return "tuttiAccidental";
+ }
+
+ @Override
+ protected String getFileExtensionDescription() {
+ return _("tutti.common.file.tuttiAccidental");
+ }
+
+ @Override
+ protected String getFileChooserTitle() {
+ return _("tutti.editAccidentalBatch.action.exportMultiPost.destinationFile.title");
+ }
+
+ @Override
+ protected String getFileChooserButton() {
+ return _("tutti.editAccidentalBatch.action.exportMultiPost.destinationFile.button");
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ multiPostImportExportService.exportAccidentalCatch(file, currentOperation);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.editAccidentalBatch.action.exportMultiPost.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportAllCaracteristicAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportAllCaracteristicAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportAllCaracteristicAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportAllCaracteristicAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,98 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To export all caracteristics.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ExportAllCaracteristicAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportAllCaracteristicAction.class);
+
+ protected File file;
+
+ public ExportAllCaracteristicAction(EditProtocolUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to export
+ file = saveFile(
+ "tuttiProtocol-" + getModel().getName() + "-allCaracteristics",
+ "csv",
+ _("tutti.editProtocol.title.choose.caracteristicExportFile"),
+ _("tutti.editProtocol.action.chooseProtocolCaracteristicFile"),
+ "^.*\\.csv", _("tutti.common.file.csv")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will export all caracteristic to file: " + file);
+ }
+
+ // export protocol caracteristics
+ ProtocolImportExportService service =
+ getContext().getTuttiProtocolImportExportService();
+
+ service.exportAllCaracteristic(file, getModel().getAllCaracteristic());
+
+ sendMessage(_("tutti.flash.info.all.caractristic.exported", file));
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportAndCleanDbAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportAndCleanDbAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportAndCleanDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,136 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.ui.swing.RunTutti;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To export a db attached to Tutti.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ExportAndCleanDbAction extends AbstractMainUITuttiAction {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportAndCleanDbAction.class);
+
+ public static final DateFormat df = new SimpleDateFormat("yyy-MM-dd");
+
+ protected File file;
+
+ public ExportAndCleanDbAction(MainUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ file = null;
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // ask user file where to export db
+
+ // choose file to import
+ file = saveFile(
+ "tutti-db-" + df.format(new Date()),
+ "zip",
+ _("tutti.dbManager.title.choose.dbExportFile"),
+ _("tutti.dbManager.action.chooseDbExportFile"),
+ "^.*\\.zip", _("tutti.common.file.zip")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void doAction() {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will export db to " + file);
+ }
+
+ ProgressionModel progressionModel = new ProgressionModel();
+ setProgressionModel(progressionModel);
+ progressionModel.setTotal(3);
+
+ // close db
+
+ progressionModel.setMessage(_("tutti.exportDb.step.closeDb"));
+
+ // clear all caches
+ getContext().getPersistenceService().clearAllCaches();
+
+ // set to not reload a real db
+ getContext().setDbLoaded(false);
+
+ // close services + repon a fake persistence service
+ getHandler().reloadPersistenceService();
+
+ // clean db context
+ getContext().clearDbContext();
+
+ // export db
+
+ progressionModel.increments(1);
+ progressionModel.setMessage(_("tutti.exportDb.step.createArchive", file));
+
+ getContext().getPersistenceService().exportDb(file);
+
+ // clean files
+
+ progressionModel.increments(1);
+ progressionModel.setMessage(_("tutti.exportDb.step.reloadApplication"));
+
+ // Close the application, will exit and restart application
+ RunTutti.closeTutti(getHandler(), RunTutti.DELETE_DB_EXIT_CODE);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ sendMessage(_("tutti.flash.info.db.exported.and.clean", file));
+
+ // make sure title is reloaded
+ getUI().getHandler().changeTitle();
+ }
+
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportBenthosMultiPostAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/ExportMultiPostAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportBenthosMultiPostAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportBenthosMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,73 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.content.operation.catches.benthos.BenthosBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIModel;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.2
+ */
+public class ExportBenthosMultiPostAction extends AbstractExportMultiPostAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> {
+
+ public ExportBenthosMultiPostAction(BenthosBatchUIHandler handler) {
+ super(handler);
+ }
+
+ @Override
+ protected String getFileExtension() {
+ return "tuttiBenthos";
+ }
+
+ @Override
+ protected String getFileExtensionDescription() {
+ return _("tutti.common.file.tuttiBenthos");
+ }
+
+ @Override
+ protected String getFileChooserTitle() {
+ return _("tutti.editBenthosBatch.action.exportMultiPost.destinationFile.title");
+ }
+
+ @Override
+ protected String getFileChooserButton() {
+ return _("tutti.editBenthosBatch.action.exportMultiPost.destinationFile.button");
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ multiPostImportExportService.exportBenthos(file, currentOperation);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.editBenthosBatch.action.exportMultiPost.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,132 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.shared.application.ApplicationBusinessException;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.service.export.generic.TuttiExportService;
+import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUI;
+import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUIHandler;
+import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To export a selected cruise.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class ExportCruiseAction extends AbstractTuttiAction<SelectCruiseUIModel, SelectCruiseUI, SelectCruiseUIHandler> {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ExportCruiseAction.class);
+
+ protected File file;
+
+ public ExportCruiseAction(SelectCruiseUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ Cruise cruise = getModel().getCruise();
+
+ // choose file to export
+ file = saveFile(
+ "exportCruise-" + cruise.getName(),
+ "zip",
+ _("tutti.selectCruise.title.choose.exportCruiseFile"),
+ _("tutti.selectCruise.action.chooseCruiseExportFile"),
+ "^.+\\.zip$", _("tutti.common.file.zip")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Cruise cruise = getModel().getCruise();
+ Preconditions.checkNotNull(cruise);
+ Preconditions.checkNotNull(file);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will save cruise " + cruise.getId() +
+ " to file: " + file);
+ }
+
+ ProgressionModel progressionModel = new ProgressionModel();
+ setProgressionModel(progressionModel);
+ // (check cruise / export cruise / gear caracteristics / operation / parameter / accidental catches / catches / individual observation / species) / zip
+ progressionModel.setTotal(10);
+
+// TuttiProtocol protocol = null;
+// if (getContext().isProtocolFilled()) {
+// protocol = getDataContext().getProtocol();
+// if (log.isInfoEnabled()) {
+// log.info("Will use protocol " + protocol.getName());
+// }
+// }
+
+ ApplicationBusinessException exportError = null;
+
+ TuttiExportService service = getContext().getTuttiExportService();
+ try {
+ service.exportCruise(cruise.getId(), file, progressionModel);
+ } catch (ApplicationBusinessException e) {
+
+ String errorMessage;
+ errorMessage = _("tutti.exportCruise.action.exportErrors", cruise.getName(), e.getMessage());
+ exportError = new ApplicationBusinessException(errorMessage);
+ }
+
+ sendMessage(_("tutti.exportCruise.action.success",
+ cruise.getName(), file.getName()));
+
+ handler.resetEditCruiseAction();
+
+ if (exportError != null) {
+ throw exportError;
+ }
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseForSumatraAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseForSumatraAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseForSumatraAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseForSumatraAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,108 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.service.export.sumatra.CatchesSumatraExportService;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.DateUtil;
+
+import java.io.File;
+import java.util.Date;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Opens a file chooser, exports the cruise catches into the selected file and open the default email editor.
+ *
+ * @author kmorin <morin(a)codelutin.com>
+ * @since 1.0
+ */
+public class ExportCruiseForSumatraAction extends AbstractMainUITuttiAction {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportCruiseForSumatraAction.class);
+
+ protected File file;
+
+ public ExportCruiseForSumatraAction(MainUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ String date = DateUtil.formatDate(new Date(), "dd-MM-yyyy");
+ // choose file to export
+ file = saveFile(
+ String.format("sumatra_%s_%s", getDataContext().getCruise().getName(), date),
+ "csv",
+ _("tutti.exportCruiseForSumatra.title.choose.exportFile"),
+ _("tutti.exportCruiseForSumatra.action.chooseFile"),
+ "^.+\\.csv$", _("tutti.common.file.csv")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Cruise cruise = getDataContext().getCruise();
+ Preconditions.checkNotNull(cruise);
+ Preconditions.checkNotNull(file);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will export cruise " + cruise.getId() +
+ " to file: " + file);
+ }
+
+ // export catches
+ CatchesSumatraExportService service =
+ getContext().getCatchesSumatraExportService();
+ service.exportCruiseForSumatra(file, cruise.getId());
+
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.exportCruiseForSumatra.action.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseValidationMessagesAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportCruiseValidationMessagesAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseValidationMessagesAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportCruiseValidationMessagesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,86 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.service.catches.ValidateCruiseOperationsService;
+import fr.ifremer.tutti.ui.swing.content.cruise.ValidateCruiseUI;
+import fr.ifremer.tutti.ui.swing.content.cruise.ValidateCruiseUIHandler;
+import fr.ifremer.tutti.ui.swing.content.cruise.ValidateCruiseUIModel;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.0.1
+ */
+public class ExportCruiseValidationMessagesAction extends AbstractTuttiAction<ValidateCruiseUIModel, ValidateCruiseUI, ValidateCruiseUIHandler> {
+
+ protected File file;
+
+ /** Validation service. */
+ protected ValidateCruiseOperationsService validationService = getContext().getValidateCruiseOperationsService();
+
+ public ExportCruiseValidationMessagesAction(ValidateCruiseUIHandler handler) {
+ super(handler, false);
+ setActionDescription(_("tutti.validateCruise.action.export.all.tip"));
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+ // choose file to export
+ file = saveFile(
+ String.format("validation_%s", getDataContext().getCruise().getName()),
+ "txt",
+ _("tutti.validateCruise.action.export.all.chooseFile.title"),
+ _("tutti.validateCruise.action.export.all.chooseFile.label")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ ValidateCruiseUIModel uiModel = getModel();
+ validationService.exportValidationResults(file, uiModel.getValidator());
+ }
+
+ @Override
+ public void releaseAction() {
+ super.releaseAction();
+ file = null;
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.validateCruise.action.export.all.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportDbAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportDbAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportDbAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,130 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To export a db attached to Tutti.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ExportDbAction extends AbstractMainUITuttiAction {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ExportDbAction.class);
+
+ public static final int TOTAL_STEP = 3;
+
+ protected File file;
+
+ public static final DateFormat df = new SimpleDateFormat("yyy-MM-dd");
+
+ public ExportDbAction(MainUIHandler handler) {
+ super(handler, true);
+ }
+
+ public void setFile(File file) {
+ this.file = file;
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ file = null;
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // ask user file where to export db
+ file = saveFile(
+ "tutti-db-" + df.format(new Date()),
+ "zip",
+ _("tutti.dbManager.title.choose.dbExportFile"),
+ _("tutti.dbManager.action.chooseDbExportFile"),
+ "^.*\\.zip", _("tutti.common.file.zip")
+ );
+ doAction = file != null;
+ }
+
+ if (doAction) {
+
+ ProgressionModel progressionModel = new ProgressionModel();
+ setProgressionModel(progressionModel);
+ progressionModel.setTotal(TOTAL_STEP);
+ }
+ return doAction;
+ }
+
+ @Override
+ public void doAction() {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will export db to " + file);
+ }
+
+ ProgressionModel progressionModel = getProgressionModel();
+
+ // close db
+
+ progressionModel.setMessage(_("tutti.exportDb.step.closeDb"));
+
+ getContext().setDbLoaded(false);
+ getHandler().reloadPersistenceService();
+
+ // export
+
+ progressionModel.increments(_("tutti.exportDb.step.createArchive", file));
+
+ getContext().getPersistenceService().exportDb(file);
+
+ // reopen db
+
+ progressionModel.increments(_("tutti.exportDb.step.openDb"));
+
+ getContext().setDbLoaded(true);
+ getHandler().reloadPersistenceService();
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.flash.info.db.exported", file));
+
+ // make sure title is reloaded
+ getUI().getHandler().changeTitle();
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportFishingOperationForSumatraAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationForSumatraAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportFishingOperationForSumatraAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportFishingOperationForSumatraAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,117 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.service.export.sumatra.CatchesSumatraExportService;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.DateUtil;
+
+import java.io.File;
+import java.util.Date;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created on 10/1/13.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.7
+ */
+public class ExportFishingOperationForSumatraAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportFishingOperationForSumatraAction.class);
+
+ protected File file;
+
+ public ExportFishingOperationForSumatraAction(EditCatchesUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+
+ String date = DateUtil.formatDate(new Date(), "dd-MM-yyyy");
+ // choose file to export
+ file = saveFile(
+ String.format("sumatra_%s_%s_%s", getDataContext().getCruise().getName(), fishingOperation.getId(), date),
+ "csv",
+ _("tutti.exportFishingOperationForSumatra.title.choose.exportFile"),
+ _("tutti.exportFishingOperationForSumatra.action.chooseFile"),
+ "^.+\\.csv$", _("tutti.common.file.csv")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Cruise cruise = getDataContext().getCruise();
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ Preconditions.checkNotNull(cruise);
+ Preconditions.checkNotNull(fishingOperation);
+ Preconditions.checkNotNull(file);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will export fishingOperation " + cruise.getId() + "-" + fishingOperation.getStationNumber() +
+ " to file: " + file);
+ }
+
+ // export catches
+ CatchesSumatraExportService service =
+ getContext().getCatchesSumatraExportService();
+ service.exportFishingOperationForSumatra(file,
+ cruise.getId(),
+ fishingOperation.getId());
+
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.exportFishingOperationForSumatra.action.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportFishingOperationReportAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationReportAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportFishingOperationReportAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportFishingOperationReportAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,112 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.service.export.pdf.CatchesPdfExportService;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Opens a file chooser, exports the cruise catches into the selected file and open the default email editor.
+ *
+ * @author kmorin <morin(a)codelutin.com>
+ * @since 1.0
+ */
+public class ExportFishingOperationReportAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportFishingOperationReportAction.class);
+
+ protected File file;
+
+ public ExportFishingOperationReportAction(EditCatchesUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ Cruise cruise = getDataContext().getCruise();
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ // choose file to export
+ file = saveFile(
+ "exportFishingOperation-" + cruise.getName() + "-" + fishingOperation.getStationNumber(),
+ "pdf",
+ _("tutti.exportFishingOperationReport.title.choose.exportFile"),
+ _("tutti.exportFishingOperationReport.action.chooseFile"),
+ "^.+\\.pdf$", _("tutti.common.file.pdf")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Cruise cruise = getDataContext().getCruise();
+ FishingOperation fishingOperation = getModel().getFishingOperation();
+ Preconditions.checkNotNull(cruise);
+ Preconditions.checkNotNull(fishingOperation);
+ Preconditions.checkNotNull(file);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will export fishingOperation " + cruise.getId() + "-" + fishingOperation.getStationNumber() +
+ " to file: " + file);
+ }
+
+ // export catches
+ CatchesPdfExportService service =
+ getContext().getGeneratePDFService();
+ service.generateFishingOperationPDFFile(file, fishingOperation.getId(), getConfig().getI18nLocale());
+
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.exportFishingOperationReport.action.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportIndividualObservationMultiPostAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/ExportMultiPostAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportIndividualObservationMultiPostAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportIndividualObservationMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,74 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchUIModel;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.2
+ */
+public class ExportIndividualObservationMultiPostAction
+ extends AbstractExportMultiPostAction<IndividualObservationBatchUIModel, IndividualObservationBatchUI, IndividualObservationBatchUIHandler> {
+
+ public ExportIndividualObservationMultiPostAction(IndividualObservationBatchUIHandler handler) {
+ super(handler);
+ }
+
+ @Override
+ protected String getFileExtension() {
+ return "tuttiIndividualObservation";
+ }
+
+ @Override
+ protected String getFileExtensionDescription() {
+ return _("tutti.common.file.tuttiIndividualObservation");
+ }
+
+ @Override
+ protected String getFileChooserTitle() {
+ return _("tutti.editIndividualObservationBatch.action.exportMultiPost.destinationFile.title");
+ }
+
+ @Override
+ protected String getFileChooserButton() {
+ return _("tutti.editIndividualObservationBatch.action.exportMultiPost.destinationFile.button");
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ multiPostImportExportService.exportIndividualObservation(file, currentOperation);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.editIndividualObservationBatch.action.exportMultiPost.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportMarineLitterMultiPostAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/ExportMultiPostAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportMarineLitterMultiPostAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportMarineLitterMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,73 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchUIModel;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.2
+ */
+public class ExportMarineLitterMultiPostAction extends AbstractExportMultiPostAction<MarineLitterBatchUIModel, MarineLitterBatchUI, MarineLitterBatchUIHandler> {
+
+ public ExportMarineLitterMultiPostAction(MarineLitterBatchUIHandler handler) {
+ super(handler);
+ }
+
+ @Override
+ protected String getFileExtension() {
+ return "tuttiMarineLitter";
+ }
+
+ @Override
+ protected String getFileExtensionDescription() {
+ return _("tutti.common.file.tuttiMarineLitter");
+ }
+
+ @Override
+ protected String getFileChooserTitle() {
+ return _("tutti.editMarineLitterBatch.action.exportMultiPost.destinationFile.title");
+ }
+
+ @Override
+ protected String getFileChooserButton() {
+ return _("tutti.editMarineLitterBatch.action.exportMultiPost.destinationFile.button");
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ multiPostImportExportService.exportMarineLitter(file, currentOperation);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.editMarineLitterBatch.action.exportMultiPost.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportOperationValidationMessagesAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportOperationValidationMessagesAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportOperationValidationMessagesAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportOperationValidationMessagesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,91 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.service.DecoratorService;
+import fr.ifremer.tutti.service.catches.ValidateCruiseOperationsService;
+import fr.ifremer.tutti.ui.swing.content.cruise.ValidateCruiseUI;
+import fr.ifremer.tutti.ui.swing.content.cruise.ValidateCruiseUIHandler;
+import fr.ifremer.tutti.ui.swing.content.cruise.ValidateCruiseUIModel;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.0.1
+ */
+public class ExportOperationValidationMessagesAction extends AbstractTuttiAction<ValidateCruiseUIModel, ValidateCruiseUI, ValidateCruiseUIHandler> {
+
+ protected File file;
+
+ /** Validation service. */
+ protected ValidateCruiseOperationsService validationService = getContext().getValidateCruiseOperationsService();
+
+ public ExportOperationValidationMessagesAction(ValidateCruiseUIHandler handler) {
+ super(handler, false);
+ setActionDescription(_("tutti.validateCruise.action.export.operation.tip"));
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to export
+ file = saveFile(
+ String.format("validation_%s",
+ decorate(getModel().getSelectedFishingOperation(), DecoratorService.FILE_NAME_COMPATIBLE)),
+ "txt",
+ _("tutti.validateCruise.action.export.operation.chooseFile.title"),
+ _("tutti.validateCruise.action.export.operation.chooseFile.label")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ ValidateCruiseUIModel uiModel = getModel();
+ FishingOperation operation = getModel().getSelectedFishingOperation();
+ validationService.exportValidationResult(file, operation, uiModel.getValidator().get(operation));
+ }
+
+ @Override
+ public void releaseAction() {
+ super.releaseAction();
+ file = null;
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.validateCruise.action.export.operation.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProgramAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProgramAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProgramAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,135 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.shared.application.ApplicationBusinessException;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.service.export.generic.TuttiExportService;
+import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUI;
+import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUIHandler;
+import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To export a selected program.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.0
+ */
+public class ExportProgramAction extends AbstractTuttiAction<SelectCruiseUIModel, SelectCruiseUI, SelectCruiseUIHandler> {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ExportProgramAction.class);
+
+ protected File file;
+
+ public ExportProgramAction(SelectCruiseUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ Program program = getModel().getProgram();
+ if (doAction) {
+
+ // choose file to export
+ file = saveFile(
+ "exportProgram-" + program.getName(), "zip",
+ _("tutti.selectCruise.title.choose.exportProgramFile"),
+ _("tutti.selectCruise.action.chooseProgramExportFile"),
+ "^.+\\.zip$", _("tutti.common.file.zip")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Program program = getModel().getProgram();
+ Preconditions.checkNotNull(program);
+ Preconditions.checkNotNull(file);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will save program " + program.getId() +
+ " to file: " + file);
+ }
+
+ // nbCruise * (check cruise / export cruise / gear caracteristics / operation / parameter / catches / individual observation / accidental catches / species) + zip
+ List<Cruise> allCruise =
+ getContext().getPersistenceService().getAllCruise(program.getId());
+
+ ProgressionModel progressionModel = new ProgressionModel();
+ setProgressionModel(progressionModel);
+ progressionModel.setTotal(9 * allCruise.size() + 1);
+
+// TuttiProtocol protocol = null;
+// if (getContext().isProtocolFilled()) {
+// protocol = getDataContext().getProtocol();
+// if (log.isInfoEnabled()) {
+// log.info("Will use protocol " + protocol.getName());
+// }
+// }
+ ApplicationBusinessException exportError = null;
+
+ TuttiExportService service = getContext().getTuttiExportService();
+ try {
+ service.exportProgram(program.getId(), file, progressionModel);
+ } catch (ApplicationBusinessException e) {
+
+ String errorMessage;
+ errorMessage = _("tutti.exportProgram.action.exportErrors", program.getName(), e.getMessage());
+
+ exportError = new ApplicationBusinessException(errorMessage);
+ }
+
+ handler.resetEditProgramAction();
+
+ sendMessage(_("tutti.exportProgram.action.success", program.getName(),
+ file.getName()));
+
+ if (exportError != null) {
+ throw exportError;
+ }
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,110 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
+import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUI;
+import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUIHandler;
+import fr.ifremer.tutti.ui.swing.content.home.SelectCruiseUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Opens a file chooser and exports the protocol into the selected file.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ExportProtocolAction extends AbstractTuttiAction<SelectCruiseUIModel, SelectCruiseUI, SelectCruiseUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportProtocolAction.class);
+
+ protected File file;
+
+ public ExportProtocolAction(SelectCruiseUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ TuttiProtocol protocol = getModel().getProtocol();
+ // choose file to export
+ file = saveFile(
+ "protocol-" + protocol.getName().replaceAll(" ", "_"),
+ "tuttiProtocol",
+ _("tutti.selectCruise.title.choose.exportFile"),
+ _("tutti.selectCruise.action.exportProtocol"),
+ "^.+\\.tuttiProtocol$", _("tutti.common.file.protocol")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ TuttiProtocol protocol = getModel().getProtocol();
+ Preconditions.checkNotNull(protocol);
+ Preconditions.checkNotNull(file);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will save protocol " + protocol.getId() +
+ " to file: " + file);
+ }
+
+ // export protocol
+ ProtocolImportExportService service =
+ getContext().getTuttiProtocolImportExportService();
+ service.exportProtocol(protocol, file);
+
+ getHandler().resetEditProtolAction();
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ TuttiProtocol protocol = getModel().getProtocol();
+ sendMessage(_("tutti.exportProtocol.action.success", protocol.getName(), file.getName()));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolBenthosAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolBenthosAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolBenthosAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolBenthosAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,117 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
+import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesRowModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To export protocol benthos.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ExportProtocolBenthosAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportProtocolBenthosAction.class);
+
+ private File file;
+
+ public ExportProtocolBenthosAction(EditProtocolUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to export
+ file = saveFile(
+ "tuttiProtocol-" + getModel().getName() + "-benthos",
+ "csv",
+ _("tutti.editProtocol.title.choose.benthosExportFile"),
+ _("tutti.editProtocol.action.chooseProtocolBenthosFile"),
+ "^.*\\.csv", _("tutti.common.file.csv")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will export protocol benthos to file: " + file);
+ }
+
+ EditProtocolUIModel model = getModel();
+
+ // build benthos protocol to export
+
+ List<SpeciesProtocol> protocols = Lists.newArrayList();
+ for (EditProtocolSpeciesRowModel row : model.getBenthosRow()) {
+ if (row.isValid()) {
+ protocols.add(row.toBean());
+ }
+ }
+
+ // import
+ ProtocolImportExportService service =
+ getContext().getTuttiProtocolImportExportService();
+
+ service.exportProtocolBenthos(file,
+ protocols,
+ model.getAllCaracteristic(),
+ model.getAllReferentSpeciesByTaxonId());
+
+ sendMessage(_("tutti.flash.info.species.exported.from.protocol",
+ file));
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolCaracteristicAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolCaracteristicAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolCaracteristicAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolCaracteristicAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,105 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To import protocol caracteristics.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ExportProtocolCaracteristicAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportProtocolCaracteristicAction.class);
+
+ private File file;
+
+ public ExportProtocolCaracteristicAction(EditProtocolUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to export
+ file = saveFile(
+ "tuttiProtocol-" + getModel().getName() + "-caracteristics",
+ "csv",
+ _("tutti.editProtocol.title.choose.caracteristicExportFile"),
+ _("tutti.editProtocol.action.chooseProtocolCaracteristicFile"),
+ "^.*\\.csv", _("tutti.common.file.csv")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will export protocol caracteristic to file: " + file);
+ }
+
+ // bind to a protocol
+ TuttiProtocol protocol = getModel().toBean();
+
+ // export protocol caracteristics
+ ProtocolImportExportService service =
+ getContext().getTuttiProtocolImportExportService();
+
+ service.exportProtocolCaracteristic(file,
+ protocol,
+ getModel().getAllCaracteristic());
+
+ sendMessage(_("tutti.flash.info.caractristic.exported.from.protocol",
+ file));
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolSpeciesAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolSpeciesAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportProtocolSpeciesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,117 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
+import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesRowModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To export protocol species.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ExportProtocolSpeciesAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportProtocolSpeciesAction.class);
+
+ private File file;
+
+ public ExportProtocolSpeciesAction(EditProtocolUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to export
+ file = saveFile(
+ "tuttiProtocol-" + getModel().getName() + "-species",
+ "csv",
+ _("tutti.editProtocol.title.choose.speciesExportFile"),
+ _("tutti.editProtocol.action.chooseProtocolSpeciesFile"),
+ "^.*\\.csv", _("tutti.common.file.csv")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will export protocol species to file: " + file);
+ }
+
+ EditProtocolUIModel model = getModel();
+
+ // build species protocol to export
+
+ List<SpeciesProtocol> protocols = Lists.newArrayList();
+ for (EditProtocolSpeciesRowModel row : model.getSpeciesRow()) {
+ if (row.isValid()) {
+ protocols.add(row.toBean());
+ }
+ }
+
+ // import
+ ProtocolImportExportService service =
+ getContext().getTuttiProtocolImportExportService();
+
+ service.exportProtocolSpecies(file,
+ protocols,
+ model.getAllCaracteristic(),
+ model.getAllReferentSpeciesByTaxonId());
+
+ sendMessage(_("tutti.flash.info.species.exported.from.protocol",
+ file));
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportPupitriAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportPupitriAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportPupitriAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,115 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.pupitri.PupitriImportExportService;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesRowModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To export protocol species.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ExportPupitriAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportPupitriAction.class);
+
+ private File file;
+
+ public ExportPupitriAction(EditProtocolUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to export
+ file = saveFile(
+ "tuttiProtocol-" + getModel().getName() + "-pupitri",
+ "csv",
+ _("tutti.editProtocol.title.choose.speciesExportFile"),
+ _("tutti.editProtocol.action.chooseProtocolSpeciesFile")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will export protocol species to file: " + file);
+ }
+
+ EditProtocolUIModel model = getModel();
+
+ // build species protocol to export
+
+ List<Species> speciesList = Lists.newArrayList();
+ for (EditProtocolSpeciesRowModel row : model.getSpeciesRow()) {
+ if (row.isValid()) {
+ Species species = row.getSpecies();
+ species.setSurveyCode(row.getSpeciesSurveyCode());
+ speciesList.add(species);
+ }
+ }
+
+ // import
+ PupitriImportExportService service =
+ getContext().getTuttiPupitriImportExportService();
+
+ service.exportSpecies(speciesList, file);
+
+ sendMessage(_("tutti.flash.info.species.exported.from.protocol",
+ file));
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportSpeciesMultiPostAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ExportMultiPostAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportSpeciesMultiPostAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportSpeciesMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,73 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.content.operation.catches.species.SpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.2
+ */
+public class ExportSpeciesMultiPostAction extends AbstractExportMultiPostAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> {
+
+ public ExportSpeciesMultiPostAction(SpeciesBatchUIHandler handler) {
+ super(handler);
+ }
+
+ @Override
+ protected String getFileExtension() {
+ return "tuttiSpecies";
+ }
+
+ @Override
+ protected String getFileExtensionDescription() {
+ return _("tutti.common.file.tuttiSpecies");
+ }
+
+ @Override
+ protected String getFileChooserTitle() {
+ return _("tutti.editSpeciesBatch.action.exportMultiPost.destinationFile.title");
+ }
+
+ @Override
+ protected String getFileChooserButton() {
+ return _("tutti.editSpeciesBatch.action.exportMultiPost.destinationFile.button");
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ multiPostImportExportService.exportSpecies(file, currentOperation);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.editSpeciesBatch.action.exportMultiPost.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporaryGearExampleAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryGearExampleAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporaryGearExampleAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporaryGearExampleAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,102 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUI;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Export an example file of temporary gears referential.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ExportTemporaryGearExampleAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportTemporaryGearExampleAction.class);
+
+ private File file;
+
+ public ExportTemporaryGearExampleAction(ManageTemporaryReferentialUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to export
+ file = saveFile(
+ "exportGearExample",
+ "csv",
+ _("tutti.manageTemporaryReferential.title.choose.exportTemporaryGearExampleFile"),
+ _("tutti.manageTemporaryReferential.action.chooseReferentialGearFile.export"),
+ "^.*\\.csv", _("tutti.common.file.csv")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will export example gears temporary " +
+ "referential to file: " + file);
+ }
+
+ ReferentialImportExportService service =
+ getContext().getTuttiReferentialImportExportService();
+ service.exportTemporaryGearExample(file);
+
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialGearFile.export.success", file));
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporaryPersonExampleAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryPersonExampleAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporaryPersonExampleAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporaryPersonExampleAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,103 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUI;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Export an example file of temporary person referential.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ExportTemporaryPersonExampleAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
+
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportTemporaryPersonExampleAction.class);
+
+ private File file;
+
+ public ExportTemporaryPersonExampleAction(ManageTemporaryReferentialUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to export
+ file = saveFile(
+ "exportPersonExample",
+ "csv",
+ _("tutti.manageTemporaryReferential.title.choose.exportTemporaryPersonExampleFile"),
+ _("tutti.manageTemporaryReferential.action.chooseReferentialPersonFile.export"),
+ "^.*\\.csv", _("tutti.common.file.csv")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will export example persons temporary " +
+ "referential to file: " + file);
+ }
+
+ ReferentialImportExportService service =
+ getContext().getTuttiReferentialImportExportService();
+
+ service.exportTemporaryPersonExample(file);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialPersonFile.export.success", file));
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporarySpeciesExampleAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporarySpeciesExampleAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporarySpeciesExampleAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporarySpeciesExampleAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,102 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUI;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Export an example file of temporary species referential.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ExportTemporarySpeciesExampleAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportTemporarySpeciesExampleAction.class);
+
+ private File file;
+
+ public ExportTemporarySpeciesExampleAction(ManageTemporaryReferentialUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to export
+ file = saveFile(
+ "exportSpeciesExample",
+ "csv",
+ _("tutti.manageTemporaryReferential.title.choose.exportTemporarySpeciesExampleFile"),
+ _("tutti.manageTemporaryReferential.action.chooseReferentialSpeciesFile.export"),
+ "^.*\\.csv", _("tutti.common.file.csv")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will export example species temporary " +
+ "referential to file: " + file);
+ }
+
+ ReferentialImportExportService service =
+ getContext().getTuttiReferentialImportExportService();
+
+ service.exportTemporarySpeciesExample(file);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialSpeciesFile.export.success", file));
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporaryVesselExampleAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryVesselExampleAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporaryVesselExampleAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ExportTemporaryVesselExampleAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,102 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUI;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Export an example file of temporary species referential.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ExportTemporaryVesselExampleAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ExportTemporaryVesselExampleAction.class);
+
+ private File file;
+
+ public ExportTemporaryVesselExampleAction(ManageTemporaryReferentialUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to export
+ file = saveFile(
+ "exportVesselExample",
+ "csv",
+ _("tutti.manageTemporaryReferential.title.choose.exportTemporaryVesselExampleFile"),
+ _("tutti.manageTemporaryReferential.action.chooseReferentialVesselFile.export"),
+ "^.*\\.csv", _("tutti.common.file.csv")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will export example vessels temporary " +
+ "referential to file: " + file);
+ }
+
+ ReferentialImportExportService service =
+ getContext().getTuttiReferentialImportExportService();
+
+ service.exportTemporaryVesselExample(file);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialVesselFile.export.success", file));
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/GenerateReportAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/report/GenerateReportAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/GenerateReportAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/GenerateReportAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,75 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.service.report.ReportModel;
+import fr.ifremer.tutti.ui.swing.content.report.ReportUI;
+import fr.ifremer.tutti.ui.swing.content.report.ReportUIHandler;
+import fr.ifremer.tutti.ui.swing.content.report.ReportUIModel;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To generate the selected report.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.9
+ */
+public class GenerateReportAction extends AbstractTuttiAction<ReportUIModel, ReportUI, ReportUIHandler> {
+
+ public GenerateReportAction(ReportUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // ask user to confirm overwrite if required
+ doAction = askOverwriteFile(getModel().getOutputFile());
+ }
+ return doAction;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkState(getModel().isValid());
+
+ ReportModel reportModel = getModel().toBean();
+ getContext().getReportService().generateReport(reportModel);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ sendMessage(_("tutti.report.generated", getModel().getOutputFile()));
+
+ getModel().reloadOuputFile();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/GoToPreviousScreenAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/GoToPreviousScreenAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/GoToPreviousScreenAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/GoToPreviousScreenAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,46 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.content.MainUIHandler;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To return on previous screen.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.1
+ */
+public class GoToPreviousScreenAction extends AbstractChangeScreenAction {
+
+ public GoToPreviousScreenAction(MainUIHandler handler) {
+ super(handler,
+ true,
+ PREVIOUS_SCREEN.getContextValue(handler.getUI())
+ );
+ setActionDescription(_("tutti.main.action.goto.previousScreen.tip"));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportAccidentalMultiPostAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/ImportMultiPostAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportAccidentalMultiPostAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportAccidentalMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,76 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.content.operation.catches.accidental.AccidentalBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.AccidentalBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.AccidentalBatchUIModel;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.2
+ */
+public class ImportAccidentalMultiPostAction
+ extends AbstractImportMultiPostAction<AccidentalBatchUIModel, AccidentalBatchUI, AccidentalBatchUIHandler> {
+
+ public ImportAccidentalMultiPostAction(AccidentalBatchUIHandler handler) {
+ super(handler);
+ }
+
+ @Override
+ protected String getFileExtension() {
+ return "tuttiAccidental";
+ }
+
+ @Override
+ protected String getFileExtensionDescription() {
+ return _("tutti.common.file.tuttiAccidental");
+ }
+
+ @Override
+ protected String getFileChooserTitle() {
+ return _("tutti.editAccidentalBatch.action.importMultiPost.sourceFile.title");
+ }
+
+ @Override
+ protected String getFileChooserButton() {
+ return _("tutti.editAccidentalBatch.action.importMultiPost.sourceFile.button");
+ }
+
+ @Override
+ protected void importBatches(FishingOperation operation) {
+ multiPostImportExportService.importAccidentalCatches(file, operation);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ sendMessage(_("tutti.editAccidentalBatch.action.importMultiPost.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBenthosMultiPostAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/ImportMultiPostAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBenthosMultiPostAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBenthosMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,128 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.service.catches.multipost.MultiPostImportService;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.MultiPostImportLogDialog;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIModel;
+
+import javax.swing.JTextArea;
+import java.awt.Dialog;
+import java.util.Collection;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.2
+ */
+public class ImportBenthosMultiPostAction extends AbstractImportMultiPostAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> {
+
+ protected Map<String, Object> notImportedData;
+
+ public ImportBenthosMultiPostAction(BenthosBatchUIHandler handler) {
+ super(handler);
+ }
+
+ @Override
+ protected String getFileExtension() {
+ return "tuttiBenthos";
+ }
+
+ @Override
+ protected String getFileExtensionDescription() {
+ return _("tutti.common.file.tuttiBenthos");
+ }
+
+ @Override
+ protected String getFileChooserTitle() {
+ return _("tutti.editBenthosBatch.action.importMultiPost.sourceFile.title");
+ }
+
+ @Override
+ protected String getFileChooserButton() {
+ return _("tutti.editBenthosBatch.action.importMultiPost.sourceFile.button");
+ }
+
+ @Override
+ public void releaseAction() {
+ notImportedData = null;
+ super.releaseAction();
+ }
+
+ @Override
+ protected void importBatches(FishingOperation operation) {
+ notImportedData = multiPostImportExportService.importBenthos(file, operation);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ if (!notImportedData.isEmpty()) {
+ MultiPostImportLogDialog dialog = new MultiPostImportLogDialog((Dialog) getContext().getActionUI());
+
+ Collection<BenthosBatch> notImportedBenthosBatches =
+ (Collection<BenthosBatch>) notImportedData.get(MultiPostImportService.BATCHES_KEY);
+
+ StringBuffer stringBuffer = new StringBuffer();
+ Float totalSortedWeight = (Float) notImportedData.get(CatchBatch.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT);
+ if (totalSortedWeight != null) {
+ stringBuffer.append("- " + _("tutti.multiPostImportLog.totalSortedWeight", totalSortedWeight) + "\n");
+ }
+
+ Float inertWeight = (Float) notImportedData.get(CatchBatch.PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT);
+ if (inertWeight != null) {
+ stringBuffer.append("- " + _("tutti.multiPostImportLog.inertWeight", inertWeight) + "\n");
+ }
+
+ Float livingNotItemizedWeight =
+ (Float) notImportedData.get(CatchBatch.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT);
+ if (livingNotItemizedWeight != null) {
+ stringBuffer.append("- " + _("tutti.multiPostImportLog.livingNotItemizedWeight", livingNotItemizedWeight) + "\n");
+ }
+
+ for (BenthosBatch sb : notImportedBenthosBatches) {
+ stringBuffer.append("- " + decorate(sb.getSpecies()) + " / " + decorate(sb.getSampleCategoryValue()) + "\n");
+ }
+
+ if (stringBuffer.length() > 0) {
+ JTextArea batchList = dialog.getBatchList();
+ batchList.setText(stringBuffer.toString());
+ dialog.setSize(400, 300);
+ dialog.setLocationRelativeTo(getContext().getMainUI());
+ dialog.setVisible(true);
+ }
+ }
+
+ sendMessage(_("tutti.editBenthosBatch.action.importMultiPost.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportCasinoAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/ImportCasinoAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportCasinoAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportCasinoAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,46 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.content.operation.EditFishingOperationUI;
+import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ImportCasinoAction extends AbstractTuttiAction<EditFishingOperationUIModel, EditFishingOperationUI, EditFishingOperationUIHandler> {
+
+ public ImportCasinoAction(EditFishingOperationUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ //TODO
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportDbAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportDbAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,331 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.shared.application.ApplicationBusinessException;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.persistence.TuttiPersistence;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.Version;
+
+import javax.swing.JOptionPane;
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To import a db and use it.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.1
+ */
+public class ImportDbAction extends AbstractMainUITuttiAction {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ImportDbAction.class);
+
+ protected File importFile;
+
+ protected String jdbcUrl;
+
+ protected boolean updateSchema;
+
+ protected boolean closeDb;
+
+ protected Version dbVersion;
+
+ protected Version applicationVersion;
+
+ protected PersistenceService.ImportStructureType importStructureType;
+
+ public ImportDbAction(MainUIHandler handler) {
+ super(handler, true);
+ setActionDescription(_("tutti.dbManager.action.importDb.tip"));
+ }
+
+ public void setImportFile(File importFile) {
+ this.importFile = importFile;
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ importStructureType = null;
+ jdbcUrl = null;
+ dbVersion = applicationVersion = null;
+ closeDb = updateSchema = false;
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ jdbcUrl = getConfig().getJdbcUrl();
+
+ if (importFile == null) {
+
+ // choose file to import
+ importFile = chooseFile(
+ _("tutti.dbManager.title.choose.dbImportFile"),
+ _("tutti.dbManager.action.chooseDbFile"),
+ "^.*\\.zip", _("tutti.common.file.zip")
+ );
+
+ if (importFile == null) {
+
+ displayWarningMessage(
+ _("tutti.dbManager.title.choose.dbImportFile"),
+ _("tutti.dbManager.action.importdb.no.import.file.choosen")
+ );
+
+ doAction = false;
+ }
+ }
+
+ if (doAction) {
+
+ ProgressionModel progressionModel = new ProgressionModel();
+ progressionModel.setTotal(3);
+ setProgressionModel(progressionModel);
+
+ importStructureType =
+ getContext().getPersistenceService().checkImportStructure(importFile);
+ }
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ importFile = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(importFile);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will import db: " + importFile);
+ }
+
+ ProgressionModel progressionModel = getProgressionModel();
+
+ // ------------------------------------------------------------------ //
+ // --- import db //
+ // ------------------------------------------------------------------ //
+
+ progressionModel.increments(_("tutti.importDb.step.unzipArchive"));
+
+ getContext().getPersistenceService().importDb(importStructureType, importFile);
+
+ // ------------------------------------------------------------------ //
+ // --- open db //
+ // ------------------------------------------------------------------ //
+
+ progressionModel.increments(_("tutti.importDb.step.openDb", jdbcUrl));
+ try {
+ getContext().setDbExist(true);
+ getContext().setDbLoaded(true);
+ handler.reloadPersistenceService();
+ } catch (Exception e) {
+
+ if (log.isErrorEnabled()) {
+ log.error("Could not open db", e);
+ }
+ // no more db
+ getContext().setDbLoaded(false);
+ handler.reloadPersistenceService();
+
+ // could not load db
+ throw new ApplicationBusinessException(_("tutti.dbManager.action.importdb.couldNotOpen"), e);
+ }
+
+ // ------------------------------------------------------------------ //
+ // --- check schema version //
+ // ------------------------------------------------------------------ //
+
+ progressionModel.increments(_("tutti.importDb.step.checkSchemaVersion"));
+
+ TuttiPersistence persistenceService =
+ handler.getPersistenceService();
+
+ dbVersion = persistenceService.getDbVersion();
+
+ if (log.isInfoEnabled()) {
+ log.info("Detected database version: " + dbVersion);
+ }
+ applicationVersion = persistenceService.getApplicationVersion();
+
+ if (log.isInfoEnabled()) {
+ log.info("Detected schema application version:" + applicationVersion);
+ }
+
+ if (dbVersion == null) {
+
+ // no database version filled (can not migrate schema)
+ String message = _("tutti.dbManager.action.upgradeDb.schema.version.not.found");
+ displayWarningMessage(_("tutti.dbManager.title.schema.toupdate"), message);
+
+ closeDb = true;
+ } else if (dbVersion.equals(applicationVersion)) {
+
+ // database schema is up to date
+ if (log.isInfoEnabled()) {
+ log.info("Database schema is up-to-date at version: " + dbVersion);
+ }
+ } else if (dbVersion.compareTo(applicationVersion) < 0) {
+
+ // database schema need to migrate
+ // ask user to migrate or not (if not will close db)
+
+ String message = _("tutti.dbManager.action.upgradeDb.schema.to.update.message", dbVersion, applicationVersion);
+
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ message,
+ _("tutti.dbManager.action.upgradeDb.schema.to.update.message.help"));
+ int i = JOptionPane.showConfirmDialog(
+ handler.getTopestUI(),
+ htmlMessage,
+ _("tutti.dbManager.title.schema.toupdate"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+ boolean continueAction = i == JOptionPane.OK_OPTION;
+
+ if (continueAction) {
+
+ // will migrate
+ updateSchema = true;
+ } else {
+
+ //close db
+ closeDb = true;
+ }
+
+
+ } else {
+
+ // database schema version is higher than application one
+ String message = _("tutti.dbManager.action.upgradeDb.schema.too.high", dbVersion, applicationVersion);
+
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ message,
+ _("tutti.dbManager.action.upgradeDb.schema.too.high.help"));
+ int i = JOptionPane.showConfirmDialog(
+ handler.getTopestUI(),
+ htmlMessage,
+ _("tutti.dbManager.title.schema.toupdate"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+ boolean continueAction = i == JOptionPane.OK_OPTION;
+
+ if (!continueAction) {
+
+ //close db
+ closeDb = true;
+ }
+ }
+
+ if (closeDb) {
+
+ // ------------------------------------------------------------------ //
+ // --- close db //
+ // ------------------------------------------------------------------ //
+
+ progressionModel.increments(_("tutti.importDb.step.closeDb"));
+ getActionEngine().runInternalAction(handler, CloseDbAction.class);
+
+ return;
+ }
+
+ if (updateSchema) {
+
+ // need to migrate schema
+ progressionModel.adaptTotal(progressionModel.getTotal() + 2);
+
+ // ------------------------------------------------------------------ //
+ // --- update schema //
+ // ------------------------------------------------------------------ //
+
+ String message = _("tutti.importDb.step.will.migrateSchema",
+ dbVersion, applicationVersion);
+
+ progressionModel.increments(message);
+ sendMessage(message);
+ handler.getPersistenceService().updateSchema();
+
+ sendMessage(_("tutti.flash.info.db.schema.updated", dbVersion, applicationVersion));
+ }
+
+ // ------------------------------------------------------------------ //
+ // --- check db context //
+ // ------------------------------------------------------------------ //
+
+ String message = _("tutti.importDb.step.check.dbContext",
+ dbVersion, applicationVersion);
+
+ progressionModel.increments(message);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Check db context");
+ }
+ getContext().checkDbContext();
+
+ // ------------------------------------------------------------------ //
+ // --- change screen //
+ // ------------------------------------------------------------------ //
+
+ getActionEngine().runInternalAction(handler, SelectCruiseAction.class);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ handler.reloadDbManagerText();
+
+ super.postSuccessAction();
+
+ if (closeDb) {
+ sendMessage(_("tutti.flash.info.db.imported.but.closed", jdbcUrl));
+ } else {
+ sendMessage(_("tutti.flash.info.db.imported", jdbcUrl));
+ }
+
+ // make sure title is reloaded
+ getUI().getHandler().changeTitle();
+ }
+
+ @Override
+ public void postFailedAction(Throwable error) {
+ handler.reloadDbManagerText();
+ super.postFailedAction(error);
+ }
+
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportIndividualObservationMultiPostAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/ImportMultiPostAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportIndividualObservationMultiPostAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportIndividualObservationMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,76 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.content.operation.catches.individualobservation.IndividualObservationBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchUIModel;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.2
+ */
+public class ImportIndividualObservationMultiPostAction
+ extends AbstractImportMultiPostAction<IndividualObservationBatchUIModel, IndividualObservationBatchUI, IndividualObservationBatchUIHandler> {
+
+ public ImportIndividualObservationMultiPostAction(IndividualObservationBatchUIHandler handler) {
+ super(handler);
+ }
+
+ @Override
+ protected String getFileExtension() {
+ return "tuttiIndividualObservation";
+ }
+
+ @Override
+ protected String getFileExtensionDescription() {
+ return _("tutti.common.file.tuttiIndividualObservation");
+ }
+
+ @Override
+ protected String getFileChooserTitle() {
+ return _("tutti.editIndividualObservationBatch.action.importMultiPost.sourceFile.title");
+ }
+
+ @Override
+ protected String getFileChooserButton() {
+ return _("tutti.editIndividualObservationBatch.action.importMultiPost.sourceFile.button");
+ }
+
+ @Override
+ protected void importBatches(FishingOperation operation) {
+ multiPostImportExportService.importIndividualObservation(file, operation);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ sendMessage(_("tutti.editIndividualObservationBatch.action.importMultiPost.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportMarineLitterMultiPostAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/ImportMultiPostAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportMarineLitterMultiPostAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportMarineLitterMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,117 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
+import fr.ifremer.tutti.service.catches.multipost.MultiPostImportService;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.MultiPostImportLogDialog;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchUIModel;
+
+import javax.swing.JTextArea;
+import java.awt.Dialog;
+import java.util.Collection;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.2
+ */
+public class ImportMarineLitterMultiPostAction extends AbstractImportMultiPostAction<MarineLitterBatchUIModel, MarineLitterBatchUI, MarineLitterBatchUIHandler> {
+
+ protected Map<String, Object> notImportedData;
+
+ public ImportMarineLitterMultiPostAction(MarineLitterBatchUIHandler handler) {
+ super(handler);
+ }
+
+ @Override
+ protected String getFileExtension() {
+ return "tuttiMarineLitter";
+ }
+
+ @Override
+ protected String getFileExtensionDescription() {
+ return _("tutti.common.file.tuttiMarineLitter");
+ }
+
+ @Override
+ protected String getFileChooserTitle() {
+ return _("tutti.editMarineLitterBatch.action.importMultiPost.sourceFile.title");
+ }
+
+ @Override
+ protected String getFileChooserButton() {
+ return _("tutti.editMarineLitterBatch.action.importMultiPost.sourceFile.button");
+ }
+
+ @Override
+ public void releaseAction() {
+ notImportedData = null;
+ super.releaseAction();
+ }
+
+ @Override
+ protected void importBatches(FishingOperation operation) {
+ notImportedData = multiPostImportExportService.importMarineLitter(file, operation);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ if (!notImportedData.isEmpty()) {
+ MultiPostImportLogDialog dialog = new MultiPostImportLogDialog((Dialog) getContext().getActionUI());
+
+ Collection<MarineLitterBatch> notImportedMarineLitterBatches =
+ (Collection<MarineLitterBatch>) notImportedData.get(MultiPostImportService.BATCHES_KEY);
+
+ StringBuffer stringBuffer = new StringBuffer();
+ Float totalWeight = (Float) notImportedData.get(CatchBatch.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT);
+ if (totalWeight != null) {
+ stringBuffer.append("- " + _("tutti.multiPostImportLog.totalWeight", totalWeight) + "\n");
+ }
+
+ for (MarineLitterBatch mlb : notImportedMarineLitterBatches) {
+ stringBuffer.append("- " + decorate(mlb.getMarineLitterCategory()) + " / " + decorate(mlb.getMarineLitterSizeCategory()) + "\n");
+ }
+
+ if (stringBuffer.length() > 0) {
+ JTextArea batchList = dialog.getBatchList();
+ batchList.setText(stringBuffer.toString());
+ dialog.setSize(400, 300);
+ dialog.setLocationRelativeTo(getContext().getMainUI());
+ dialog.setVisible(true);
+ }
+ }
+
+ sendMessage(_("tutti.editMarineLitterBatch.action.importMultiPost.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportOrReimportDbAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportOrReimportDbAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportOrReimportDbAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportOrReimportDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,72 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.content.MainUIHandler;
+
+/**
+ * To import or reimport a db (will delegate to correct action).
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.4
+ */
+public class ImportOrReimportDbAction extends AbstractMainUITuttiAction {
+
+ protected AbstractMainUITuttiAction delegateAction;
+
+ public ImportOrReimportDbAction(MainUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ if (getContext().isDbExist()) {
+
+ // reimport action
+ delegateAction = getContext().getActionFactory().createLogicAction(getHandler(), ReimportDbAction.class);
+ } else {
+
+ // import action
+ delegateAction = getContext().getActionFactory().createLogicAction(getHandler(), ImportDbAction.class);
+ }
+
+ setActionDescription(delegateAction.getActionDescription());
+
+ return delegateAction.prepareAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ getActionEngine().runInternalAction(delegateAction);
+ }
+
+ @Override
+ protected void releaseAction() {
+ delegateAction = null;
+ super.releaseAction();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,180 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
+import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JOptionPane;
+import javax.swing.UIManager;
+import java.io.File;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Opens a file chooser and imports the protocol from the selected file.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ImportProtocolAction extends AbstractChangeScreenAction {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ImportProtocolAction.class);
+
+ public static final JAXXContextEntryDef<TuttiProtocol> IMPORT_PROTOCOL_ENTRY = new JAXXContextEntryDef<TuttiProtocol>("importProtocol", TuttiProtocol.class);
+
+ protected TuttiProtocol protocol;
+
+ public ImportProtocolAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.EDIT_PROTOCOL);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ IMPORT_PROTOCOL_ENTRY.removeContextValue(getContext().getMainUI());
+
+ boolean doAction = super.prepareAction();
+
+ File file = null;
+
+ if (doAction) {
+ // choose file to import
+ file = chooseFile(
+ _("tutti.selectCruise.title.choose.importFile"),
+ _("tutti.selectCruise.action.importProtocol"),
+ "^.+\\.tuttiProtocol$", _("tutti.common.file.protocol")
+ );
+
+ doAction = file != null;
+ }
+
+ if (doAction) {
+
+ // import protocol
+ if (log.isInfoEnabled()) {
+ log.info("Will import protocol file: " + file);
+ }
+
+ ProtocolImportExportService service =
+ getContext().getTuttiProtocolImportExportService();
+
+ protocol = service.importProtocol(file);
+
+ // remove id
+ protocol.setId((String) null);
+
+ sendMessage(_("tutti.importProtocol.action.success", protocol.getName()));
+
+ // check that protocol is compatible with sample category model
+ SampleCategoryModel sampleCategoryModel =
+ getDataContext().getSampleCategoryModel();
+
+ Set<Integer> badCategories = Sets.newHashSet();
+
+ TuttiProtocols.checkSampleCategories(sampleCategoryModel,
+ protocol,
+ badCategories);
+
+ if (!badCategories.isEmpty()) {
+
+ // detect some bad categories
+ if (log.isWarnEnabled()) {
+ log.warn("There is some bad categories: " + badCategories);
+ }
+
+ String message = TuttiProtocols.getBadCategoriesMessage(
+ badCategories,
+ getDecorator(Caracteristic.class, null),
+ getContext().getPersistenceService());
+
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ message,
+ _("tutti.common.askBeforeImportProtocol.help"));
+ int response = JOptionPane.showOptionDialog(
+ getContext().getActionUI(),
+ htmlMessage,
+ _("tutti.common.askBeforeEditProtocol.title"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.WARNING_MESSAGE,
+ UIManager.getIcon("warning"),
+ new Object[]{_("tutti.option.cleanAndImport"), _("tutti.option.import"), _("tutti.option.cancel")},
+ _("tutti.option.cancel")
+ );
+
+ switch (response) {
+ case 0:
+ // clean and import
+ if (log.isInfoEnabled()) {
+ log.info("Clean and Import");
+ }
+ TuttiProtocols.removeBadCategories(sampleCategoryModel,
+ protocol);
+ break;
+ case 1:
+ // import with no clean
+ if (log.isInfoEnabled()) {
+ log.info("Import with no cleaning");
+ }
+ break;
+ default:
+
+ // cancel
+ doAction = false;
+ }
+ }
+ }
+ return doAction;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(protocol);
+
+ // store protocol in context
+ IMPORT_PROTOCOL_ENTRY.setContextValue(getContext().getMainUI(), protocol);
+ protocol = null;
+ createProgressionModelIfRequired(4);
+
+ // removed selected protocol
+ getContext().setProtocolId(null);
+ super.doAction();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolBenthosAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolBenthosAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolBenthosAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,148 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesRowModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To import protocol benthos.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ImportProtocolBenthosAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ImportProtocolBenthosAction.class);
+
+ private File file;
+
+ public ImportProtocolBenthosAction(EditProtocolUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to import
+ file = chooseFile(
+ _("tutti.editProtocol.title.choose.benthosImportFile"),
+ _("tutti.editProtocol.action.chooseProtocolBenthosFile"),
+ "^.*\\.csv", _("tutti.common.file.csv")
+ );
+
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will import protocol benthos file: " + file);
+ }
+
+ EditProtocolUIModel model = getModel();
+
+ // bind to a protocol
+ TuttiProtocol protocol = model.toBean();
+
+ // import
+ ProtocolImportExportService service =
+ getContext().getTuttiProtocolImportExportService();
+
+ service.importProtocolBenthos(file,
+ protocol,
+ model.getAllCaracteristic(),
+ model.getAllReferentSpeciesByTaxonId());
+
+ // build rows from imported+merged protocol
+ // (will also remove all synonyms of species referent used)
+ List<EditProtocolSpeciesRowModel> rows =
+ handler.toRows(protocol.getBenthos());
+
+ // update species comboBox
+ getUI().getSpeciesComboBox().getHandler().reset();
+
+ // update benthos comboBox
+ getUI().getBenthosComboBox().getHandler().reset();
+
+ // update rows in model
+ model.setBenthosRow(rows);
+
+ getHandler().getBenthosTableModel().setRows(rows);
+
+ int nbSynonym = 0;
+ for (SpeciesProtocol speciesProtocol : protocol.getBenthos()) {
+ if (!speciesProtocol.isMadeFromAReferentTaxon()) {
+ nbSynonym++;
+ }
+ }
+
+ String message;
+ switch (nbSynonym) {
+ case 0:
+ message = _("tutti.flash.info.benthos.imported.in.protocol",
+ file);
+ break;
+
+ case 1:
+ message = _("tutti.flash.info.benthos.imported.in.protocol.oneReplaced",
+ file);
+ break;
+
+ default:
+ message = _("tutti.flash.info.benthos.imported.in.protocol.severalReplaced",
+ file, nbSynonym);
+ }
+ sendMessage(message);
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolCaracteristicAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolCaracteristicAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolCaracteristicAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,116 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To import protocol caracteristics.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ImportProtocolCaracteristicAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ImportProtocolCaracteristicAction.class);
+
+ private File file;
+
+ public ImportProtocolCaracteristicAction(EditProtocolUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to import
+ file = chooseFile(
+ _("tutti.editProtocol.title.choose.caracteristicImportFile"),
+ _("tutti.editProtocol.action.chooseProtocolCaracteristicFile"),
+ "^.*\\.csv", _("tutti.common.file.csv")
+ );
+
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will import protocol caracteristic file: " + file);
+ }
+
+ EditProtocolUIModel model = getModel();
+
+ // bind to a protocol
+ TuttiProtocol protocol = model.toBean();
+
+ ProtocolImportExportService service =
+ getContext().getTuttiProtocolImportExportService();
+
+ service.importProtocolCaracteristic(file,
+ protocol,
+ model.getAllCaracteristic());
+
+ handler.addDoubleListListeners();
+
+ try {
+ // rebind to model
+ model.fromBean(protocol);
+ } finally {
+ handler.removeDoubleListListeners();
+ }
+
+ sendMessage(
+ _("tutti.flash.info.caracteristic.imported.in.protocol",
+ file));
+
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolSpeciesAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolSpeciesAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportProtocolSpeciesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,148 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesRowModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To import protocol species.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ImportProtocolSpeciesAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ImportProtocolSpeciesAction.class);
+
+ private File file;
+
+ public ImportProtocolSpeciesAction(EditProtocolUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to import
+ file = chooseFile(
+ _("tutti.editProtocol.title.choose.speciesImportFile"),
+ _("tutti.editProtocol.action.chooseProtocolSpeciesFile"),
+ "^.*\\.csv", _("tutti.common.file.csv")
+ );
+
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will import protocol species file: " + file);
+ }
+
+ EditProtocolUIModel model = getModel();
+
+ // bind to a protocol
+ TuttiProtocol protocol = model.toBean();
+
+ // import
+ ProtocolImportExportService service =
+ getContext().getTuttiProtocolImportExportService();
+
+ service.importProtocolSpecies(file,
+ protocol,
+ model.getAllCaracteristic(),
+ model.getAllReferentSpeciesByTaxonId());
+
+ // build rows from imported+merged protocol
+ // (will also remove all synonyms of species referent used)
+ List<EditProtocolSpeciesRowModel> rows =
+ handler.toRows(protocol.getSpecies());
+
+ // update species comboBox
+ getUI().getSpeciesComboBox().getHandler().reset();
+
+ // update benthos comboBox
+ getUI().getBenthosComboBox().getHandler().reset();
+
+ // update rows in model
+ model.setSpeciesRow(rows);
+
+ getHandler().getSpeciesTableModel().setRows(rows);
+
+ int nbSynonym = 0;
+ for (SpeciesProtocol speciesProtocol : protocol.getSpecies()) {
+ if (!speciesProtocol.isMadeFromAReferentTaxon()) {
+ nbSynonym++;
+ }
+ }
+
+ String message;
+ switch (nbSynonym) {
+ case 0:
+ message = _("tutti.flash.info.species.imported.in.protocol",
+ file);
+ break;
+
+ case 1:
+ message = _("tutti.flash.info.species.imported.in.protocol.oneReplaced",
+ file);
+ break;
+
+ default:
+ message = _("tutti.flash.info.species.imported.in.protocol.severalReplaced",
+ file, nbSynonym);
+ }
+ sendMessage(message);
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPupitriAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportPupitriAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPupitriAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPupitriAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,170 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.pupitri.PupitriImportExportService;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.ImportPupitriPopupUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+
+import javax.swing.JOptionPane;
+import javax.swing.UIManager;
+import java.io.File;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ImportPupitriAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> {
+
+ protected File importedTrunkFile;
+
+ protected File importedCarrouselFile;
+
+ protected ImportPupitriPopupUI importPupitriDialog;
+
+// protected TuttiProtocol currentProtocol;
+
+ protected PersistenceService persistenceService;
+
+ protected EditFishingOperationAction editAction;
+
+ public ImportPupitriAction(SpeciesBatchUIHandler handler) {
+ super(handler, false);
+ persistenceService = getContext().getPersistenceService();
+ importPupitriDialog = new ImportPupitriPopupUI(handler.getContext());
+ }
+
+ public EditFishingOperationAction getEditAction() {
+ if (editAction == null) {
+ editAction = getContext().getActionFactory().createLogicAction(getHandler().getParentUi().getHandler().getParentHandler(),
+ EditFishingOperationAction.class);
+ }
+ return editAction;
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = true;
+
+ // must check that sample category model is compatible for pupitri import
+ // means need some categories
+
+ TuttiEnumerationFile enumerationFile = persistenceService.getEnumerationFile();
+ SampleCategoryModel sampleCategoryModel = getDataContext().getSampleCategoryModel();
+
+ List<String> missingCategories = Lists.newArrayList();
+ if (!sampleCategoryModel.containsCategoryId(enumerationFile.PMFM_ID_SIZE_CATEGORY)) {
+ missingCategories.add("<li>" + persistenceService.getSizeCategoryCaracteristic().getParameterName() + "</li>");
+ }
+ if (!sampleCategoryModel.containsCategoryId(enumerationFile.PMFM_ID_SEX)) {
+ missingCategories.add("<li>" + persistenceService.getSexCaracteristic().getParameterName() + "</li>");
+ }
+ if (!missingCategories.isEmpty()) {
+ result = false;
+ JOptionPane.showMessageDialog(
+ getContext().getActionUI(),
+ _("tutti.editSpeciesBatch.action.importPupitri.invalidSampleCategoryModel.message", Joiner.on("").join(missingCategories)),
+ _("tutti.editSpeciesBatch.action.importPupitri.invalidSampleCategoryModel.title"),
+ JOptionPane.ERROR_MESSAGE,
+ UIManager.getIcon("error")
+ );
+ }
+ if (result) {
+// currentProtocol = getDataContext().getProtocol();
+
+ SpeciesBatchUIModel speciesBatchUIModel = getUI().getModel();
+ if (speciesBatchUIModel.getRowCount() > 0) {
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ _("tutti.editSpeciesBatch.action.importPupitri.existingData.message"),
+ _("tutti.editSpeciesBatch.action.importPupitri.existingData.help"));
+
+ int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
+ htmlMessage,
+ _("tutti.editSpeciesBatch.action.importPupitri.existingData.title"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.WARNING_MESSAGE);
+
+ result = answer == JOptionPane.OK_OPTION;
+ }
+ }
+
+ if (result) {
+ importPupitriDialog.open();
+ importedTrunkFile = importPupitriDialog.getTrunkFile().getSelectedFile();
+ importedCarrouselFile = importPupitriDialog.getCarrouselFile().getSelectedFile();
+ result = importedTrunkFile != null
+ && importedCarrouselFile != null;
+ }
+
+ return result;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ PupitriImportExportService pupitriImportExportService =
+ getContext().getTuttiPupitriImportExportService();
+
+ EditCatchesUIModel model = getUI().getHandler().getParentUi().getModel();
+
+ FishingOperation operation = model.getFishingOperation();
+ CatchBatch catchBatch = model.toEntity();
+
+ // import
+ int rejectedSpeciesNb =
+ pupitriImportExportService.importPupitri(importedTrunkFile,
+ importedCarrouselFile,
+ operation,
+ catchBatch);
+
+ getEditAction().loadCatchBatch(operation);
+
+ sendMessage(_("tutti.editSpeciesBatch.action.importPupitri.success",
+ getModel().getRootNumber(), rejectedSpeciesNb));
+ }
+
+ @Override
+ public void releaseAction() {
+ super.releaseAction();
+ importedTrunkFile = null;
+ importedCarrouselFile = null;
+// currentProtocol = null;
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportSpeciesMultiPostAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportMultiPostAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportSpeciesMultiPostAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportSpeciesMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,128 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.service.catches.multipost.MultiPostImportService;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.MultiPostImportLogDialog;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel;
+
+import javax.swing.JTextArea;
+import java.awt.Dialog;
+import java.util.Collection;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.2
+ */
+public class ImportSpeciesMultiPostAction extends AbstractImportMultiPostAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> {
+
+ protected Map<String, Object> notImportedData;
+
+ public ImportSpeciesMultiPostAction(SpeciesBatchUIHandler handler) {
+ super(handler);
+ }
+
+ @Override
+ protected String getFileExtension() {
+ return "tuttiSpecies";
+ }
+
+ @Override
+ protected String getFileExtensionDescription() {
+ return _("tutti.common.file.tuttiSpecies");
+ }
+
+ @Override
+ protected String getFileChooserTitle() {
+ return _("tutti.editSpeciesBatch.action.importMultiPost.sourceFile.title");
+ }
+
+ @Override
+ protected String getFileChooserButton() {
+ return _("tutti.editSpeciesBatch.action.importMultiPost.sourceFile.button");
+ }
+
+ @Override
+ public void releaseAction() {
+ notImportedData = null;
+ super.releaseAction();
+ }
+
+ @Override
+ protected void importBatches(FishingOperation operation) {
+ notImportedData = multiPostImportExportService.importSpecies(file, operation);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ if (!notImportedData.isEmpty()) {
+ MultiPostImportLogDialog dialog = new MultiPostImportLogDialog((Dialog) getContext().getActionUI());
+
+ Collection<SpeciesBatch> notImportedSpeciesBatches =
+ (Collection<SpeciesBatch>) notImportedData.get(MultiPostImportService.BATCHES_KEY);
+
+ StringBuffer stringBuffer = new StringBuffer();
+ Float totalSortedWeight = (Float) notImportedData.get(CatchBatch.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT);
+ if (totalSortedWeight != null) {
+ stringBuffer.append("- " + _("tutti.multiPostImportLog.totalSortedWeight", totalSortedWeight) + "\n");
+ }
+
+ Float inertWeight = (Float) notImportedData.get(CatchBatch.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT);
+ if (inertWeight != null) {
+ stringBuffer.append("- " + _("tutti.multiPostImportLog.inertWeight", inertWeight) + "\n");
+ }
+
+ Float livingNotItemizedWeight =
+ (Float) notImportedData.get(CatchBatch.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT);
+ if (livingNotItemizedWeight != null) {
+ stringBuffer.append("- " + _("tutti.multiPostImportLog.livingNotItemizedWeight", livingNotItemizedWeight) + "\n");
+ }
+
+ for (SpeciesBatch sb : notImportedSpeciesBatches) {
+ stringBuffer.append("- " + decorate(sb.getSpecies()) + " / " + decorate(sb.getSampleCategoryValue()) + "\n");
+ }
+
+ if (stringBuffer.length() > 0) {
+ JTextArea batchList = dialog.getBatchList();
+ batchList.setText(stringBuffer.toString());
+ dialog.setSize(400, 300);
+ dialog.setLocationRelativeTo(getContext().getMainUI());
+ dialog.setVisible(true);
+ }
+ }
+
+ sendMessage(_("tutti.editSpeciesBatch.action.importMultiPost.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryGearAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryGearAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryGearAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryGearAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,105 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUI;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Import temporary gear referential.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ImportTemporaryGearAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ImportTemporaryGearAction.class);
+
+ private File file;
+
+ public ImportTemporaryGearAction(ManageTemporaryReferentialUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to import
+ file = chooseFile(
+ _("tutti.manageTemporaryReferential.title.choose.importTemporaryGearFile"),
+ _("tutti.manageTemporaryReferential.action.chooseReferentialGearFile.import"),
+ "^.*\\.csv", _("tutti.common.file.csv"));
+
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will import gear temporary " +
+ "referential from file: " + file);
+ }
+
+ ReferentialImportExportService service =
+ getContext().getTuttiReferentialImportExportService();
+
+ service.importTemporaryGear(file);
+
+ // reset ui cache
+ getDataContext().resetGears();
+
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialGearFile.import.success", file));
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryPersonAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryPersonAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryPersonAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryPersonAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,104 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUI;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Import temporary person referential.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ImportTemporaryPersonAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ImportTemporaryPersonAction.class);
+
+ private File file;
+
+ public ImportTemporaryPersonAction(ManageTemporaryReferentialUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // choose file to import
+ file = chooseFile(
+ _("tutti.manageTemporaryReferential.title.choose.importTemporaryPersonFile"),
+ _("tutti.manageTemporaryReferential.action.chooseReferentialPersonFile.import"),
+ "^.*\\.csv", _("tutti.common.file.csv"));
+
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will import person temporary " +
+ "referential from file: " + file);
+ }
+
+ ReferentialImportExportService service =
+ getContext().getTuttiReferentialImportExportService();
+
+ service.importTemporaryPerson(file);
+
+ // reset ui cache
+ getDataContext().resetPersons();
+
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialPersonFile.import.success", file));
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryReferentialAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ImportTemporaryReferentialAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryReferentialAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryReferentialAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,71 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+
+import javax.swing.SwingUtilities;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Open screen to import referential
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ImportTemporaryReferentialAction extends AbstractChangeScreenAction {
+
+ public ImportTemporaryReferentialAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.IMPORT_TEMPORARY_REFERENTIAL);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+ if (result) {
+ result = askAdminPassword(
+ _("tutti.manageTemporaryReferential.passwordDialog.message"),
+ _("tutti.manageTemporaryReferential.passwordDialog.title"),
+ _("tutti.manageTemporaryReferential.passwordDialog.error.message"),
+ _("tutti.manageTemporaryReferential.passwordDialog.error.title")
+ );
+ }
+ return result;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ super.doAction();
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ getContext().getMainUI().getBody().revalidate();
+ }
+ });
+
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporarySpeciesAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporarySpeciesAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporarySpeciesAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporarySpeciesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,103 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUI;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Import temporary species referential.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ImportTemporarySpeciesAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ImportTemporarySpeciesAction.class);
+
+ private File file;
+
+ public ImportTemporarySpeciesAction(ManageTemporaryReferentialUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+ // choose file to import
+ file = chooseFile(
+ _("tutti.manageTemporaryReferential.title.choose.importTemporarySpeciesFile"),
+ _("tutti.manageTemporaryReferential.action.chooseReferentialSpeciesFile.import"),
+ "^.*\\.csv", _("tutti.common.file.csv"));
+
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will import species temporary " +
+ "referential from file: " + file);
+ }
+
+ ReferentialImportExportService service =
+ getContext().getTuttiReferentialImportExportService();
+
+ service.importTemporarySpecies(file);
+
+ // reset ui cache
+ getDataContext().resetSpecies();
+
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialSpeciesFile.import.success", file));
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryVesselAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryVesselAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryVesselAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportTemporaryVesselAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,103 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUI;
+import fr.ifremer.tutti.ui.swing.content.referential.ManageTemporaryReferentialUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Import temporary vessel referential.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ImportTemporaryVesselAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ImportTemporaryVesselAction.class);
+
+ private File file;
+
+ public ImportTemporaryVesselAction(ManageTemporaryReferentialUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+ // choose file to import
+ file = chooseFile(
+ _("tutti.manageTemporaryReferential.title.choose.importTemporaryVesselFile"),
+ _("tutti.manageTemporaryReferential.action.chooseReferentialVesselFile.import"),
+ "^.*\\.csv", _("tutti.common.file.csv"));
+
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(file);
+ if (log.isInfoEnabled()) {
+ log.info("Will import vessel temporary " +
+ "referential from file: " + file);
+ }
+
+ ReferentialImportExportService service =
+ getContext().getTuttiReferentialImportExportService();
+
+ service.importTemporaryVessel(file);
+
+ // reset ui cache
+ getDataContext().resetVessels();
+
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialVesselFile.import.success", file));
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/InstallDbAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallDbAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/InstallDbAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/InstallDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,125 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.TuttiConfiguration;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.updater.ApplicationUpdater;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To install (or reinstall) a db from last network one.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.4
+ */
+public class InstallDbAction extends AbstractMainUITuttiAction {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(InstallDbAction.class);
+
+ protected File backupFile;
+
+ protected boolean doBackup;
+
+ protected String jdbcUrl;
+
+ public InstallDbAction(MainUIHandler handler) {
+ super(handler, true);
+ setActionDescription(_("tutti.dbManager.action.installDb.tip"));
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // check db url is reachable
+ doAction = getContext().checkUpdateDataReachable();
+ }
+
+ if (doAction) {
+
+ ProgressionModel progressionModel = new ProgressionModel();
+ progressionModel.setTotal(2);
+ setProgressionModel(progressionModel);
+ }
+ return doAction;
+ }
+
+ @Override
+ public void doAction() {
+
+ ProgressionModel progressionModel = getProgressionModel();
+
+ // ------------------------------------------------------------------ //
+ // --- install db //
+ // ------------------------------------------------------------------ //
+
+ TuttiConfiguration config = getConfig();
+
+ File current = config.getDataDirectory();
+ String url = config.getUpdateDataUrl();
+
+ if (log.isInfoEnabled()) {
+ log.info(String.format("Try to install / update db (current data location: %s), using update url: %s", current, url));
+ }
+
+ File dest = new File(config.getBasedir(), "NEW");
+
+ progressionModel.increments(_("tutti.dbManager.action.upgradeDb.check"));
+ TuttiDbUpdaterCallBack callback =
+ new TuttiDbUpdaterCallBack(this, progressionModel);
+ ApplicationUpdater up = new ApplicationUpdater();
+ up.update(url,
+ current,
+ dest,
+ false,
+ callback,
+ progressionModel);
+
+ Preconditions.checkState(callback.isDbInstalled());
+
+ progressionModel.increments(_("tutti.dbManager.action.upgradeDb.opening"));
+
+ getContext().setDbExist(true);
+
+ // ------------------------------------------------------------------ //
+ // --- open db //
+ // ------------------------------------------------------------------ //
+
+ getActionEngine().runInternalAction(getHandler(), OpenDbAction.class);
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/InstallOrReinstallDbAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallOrReinstallDbAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/InstallOrReinstallDbAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/InstallOrReinstallDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,73 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.content.MainUIHandler;
+
+/**
+ * To install or reinstall a db (will delegate to correct action).
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.4
+ */
+public class InstallOrReinstallDbAction extends AbstractMainUITuttiAction {
+
+ protected AbstractMainUITuttiAction delegateAction;
+
+ public InstallOrReinstallDbAction(MainUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ if (getContext().isDbExist()) {
+
+ // reinstall action
+ delegateAction = getContext().getActionFactory().createLogicAction(getHandler(), ReinstallDbAction.class);
+ } else {
+
+ // install action
+ delegateAction = getContext().getActionFactory().createLogicAction(getHandler(), InstallDbAction.class);
+ }
+
+ setActionDescription(delegateAction.getActionDescription());
+
+ return delegateAction.prepareAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ getActionEngine().runInternalAction(delegateAction);
+ }
+
+ @Override
+ protected void releaseAction() {
+ delegateAction = null;
+ super.releaseAction();
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ManageDbAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ManageDbAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ManageDbAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ManageDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,42 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+
+/**
+ * To manage db in Tutti.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ManageDbAction extends AbstractChangeScreenAction {
+
+ public ManageDbAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.MANAGE_DB);
+ }
+
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewCruiseAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewCruiseAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewCruiseAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewCruiseAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,47 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+
+/**
+ * Opens the cruise creation screen.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class NewCruiseAction extends AbstractChangeScreenAction {
+
+ public NewCruiseAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.EDIT_CRUISE);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ getContext().setCruiseId(null);
+ super.doAction();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewFishingOperationAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewFishingOperationAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewFishingOperationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,88 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperations;
+import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrder;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUIModel;
+
+import java.util.List;
+
+/**
+ * To create a new fishing operation.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class NewFishingOperationAction extends EditFishingOperationAction {
+
+ public NewFishingOperationAction(FishingOperationsUIHandler handler) {
+ super(handler);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ FishingOperationsUIModel model = getModel();
+
+ // deselect selected fishingOperation
+ // Will remove the selection fishing operation from the comboBox
+
+ model.setCatchEnabled(true);
+
+ model.setEditionAdjusting(true);
+ try {
+ model.setSelectedFishingOperation(null);
+ } finally {
+ model.setEditionAdjusting(false);
+ }
+
+ // creates a empty bean
+
+ FishingOperation newFishingOperation =
+ FishingOperations.newFishingOperation();
+ Cruise cruise = getDataContext().getCruise();
+ newFishingOperation.setCruise(cruise);
+ newFishingOperation.setVessel(cruise.getVessel());
+
+ List<GearWithOriginalRankOrder> gears = cruise.getGear();
+ if (gears.size() == 1) {
+ newFishingOperation.setGear(gears.get(0));
+ }
+
+ if (cruise.getMultirigNumber() == 1) {
+ newFishingOperation.setMultirigAggregation("1");
+ }
+
+ newFishingOperation.setGearShootingStartDate(null);
+ newFishingOperation.setGearShootingEndDate(null);
+ setFishingOperation(newFishingOperation);
+
+ super.doAction();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewProgramAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewProgramAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewProgramAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewProgramAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,48 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+
+/**
+ * Opens the program creation screen.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class NewProgramAction extends AbstractChangeScreenAction {
+
+ public NewProgramAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.EDIT_PROGRAM);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ getContext().setProgramId(null);
+ getContext().setCruiseId(null);
+ super.doAction();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewProtocolAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewProtocolAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewProtocolAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/NewProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,48 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+
+/**
+ * Opens the protocol creation screen.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class NewProtocolAction extends AbstractChangeScreenAction {
+
+ public NewProtocolAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.EDIT_PROTOCOL);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ getContext().setProtocolId(null);
+ createProgressionModelIfRequired(4);
+ super.doAction();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/OpenDbAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/OpenDbAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/OpenDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,375 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.shared.application.ApplicationBusinessException;
+import fr.ifremer.shared.application.swing.action.ApplicationUIAction;
+import fr.ifremer.tutti.TuttiConfiguration;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.persistence.TuttiPersistence;
+import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
+import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.updater.ApplicationInfo;
+import org.nuiton.updater.ApplicationUpdater;
+import org.nuiton.util.Version;
+
+import javax.swing.JOptionPane;
+import java.io.File;
+import java.util.Date;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To open existing db.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class OpenDbAction extends AbstractChangeScreenAction {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(OpenDbAction.class);
+
+ protected Version dbVersion;
+
+ protected Version applicationVersion;
+
+ protected File file;
+
+ protected boolean updateSchema;
+
+ protected boolean updateReferentiel;
+
+ protected boolean closeDb;
+
+ protected String jdbcUrl;
+
+ protected ApplicationInfo updateDbVersion;
+
+ public OpenDbAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.SELECT_CRUISE);
+ setActionDescription(_("tutti.dbManager.action.openDb.tip"));
+ }
+
+ public void setUpdateReferentiel(boolean updateReferentiel) {
+ this.updateReferentiel = updateReferentiel;
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean canContinue = super.prepareAction();
+ if (canContinue) {
+ jdbcUrl = null;
+ dbVersion = applicationVersion = null;
+ file = null;
+ closeDb = updateSchema = false;
+ updateDbVersion = null;
+
+ updateReferentiel &= getContext().checkUpdateDataReachable();
+
+ if (updateReferentiel) {
+
+ // get the next db version
+ ApplicationUpdater up = new ApplicationUpdater();
+
+ // get db updates
+ Map<String, ApplicationInfo> dbVersions =
+ up.getVersions(getConfig().getUpdateDataUrl(),
+ getConfig().getDataDirectory());
+ updateDbVersion =
+ dbVersions.get(TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
+
+ if (updateDbVersion != null && updateDbVersion.newVersion != null) {
+
+ // ask user if it wants to do the update
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ _("tutti.dbManager.updatedb.found", updateDbVersion.newVersion),
+ _("tutti.common.askBeforeUpdate.help"));
+ int i = JOptionPane.showConfirmDialog(
+ getHandler().getTopestUI(),
+ htmlMessage,
+ _("tutti.dbManager.title.confirm.updatedb"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+
+ updateReferentiel = i == JOptionPane.OK_OPTION;
+ }
+
+ }
+ }
+ return canContinue;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Will open db...");
+ }
+
+ jdbcUrl = getConfig().getJdbcUrl();
+
+ // at the beginning 3 steps (open db + check version + check db context)
+ ProgressionModel progressionModel = new ProgressionModel();
+ setProgressionModel(progressionModel);
+ progressionModel.setTotal(3 + (updateReferentiel ? 1 : 0));
+
+ // ------------------------------------------------------------------ //
+ // --- open db //
+ // ------------------------------------------------------------------ //
+
+ progressionModel.increments(_("tutti.openDb.step.open", jdbcUrl));
+ try {
+ getContext().setDbLoaded(true);
+ getHandler().reloadPersistenceService();
+ } catch (Exception e) {
+
+ if (log.isErrorEnabled()) {
+ log.error("Could not open db", e);
+ }
+ // no more db
+ getContext().setDbLoaded(false);
+ getHandler().reloadPersistenceService();
+
+ // could not load db
+ throw new ApplicationBusinessException(_("tutti.dbManager.action.openDb.couldNotOpen"));
+ }
+
+ // ------------------------------------------------------------------ //
+ // --- check schema version //
+ // ------------------------------------------------------------------ //
+
+ progressionModel.increments(_("tutti.openDb.step.checkSchemaVersion"));
+
+ TuttiPersistence persistenceService =
+ getHandler().getPersistenceService();
+
+ dbVersion = persistenceService.getDbVersion();
+
+ if (log.isInfoEnabled()) {
+ log.info("Detected database version: " + dbVersion);
+ }
+ applicationVersion = persistenceService.getApplicationVersion();
+
+ if (log.isInfoEnabled()) {
+ log.info("Detected schema application version:" + applicationVersion);
+ }
+
+ TuttiConfiguration config = getConfig();
+ if (dbVersion.equals(applicationVersion)) {
+
+ // database schema is up to date
+ if (log.isInfoEnabled()) {
+ log.info("Database schema is up-to-date at version: " + dbVersion);
+ }
+ } else if (dbVersion.compareTo(applicationVersion) < 0) {
+
+ // database schema need to migrate
+ // ask user to migrate or not (if not will close db)
+
+ // ask user where to backup db
+
+ String message = _("tutti.dbManager.action.upgradeDb.schema.to.update.message", dbVersion, applicationVersion);
+
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ message,
+ _("tutti.dbManager.action.upgradeDb.schema.to.update.message.help"));
+ int i = JOptionPane.showConfirmDialog(
+ getHandler().getTopestUI(),
+ htmlMessage,
+ _("tutti.dbManager.title.schema.toupdate"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+ boolean continueAction = i == JOptionPane.OK_OPTION;
+
+ if (continueAction) {
+
+ // ask user file where to backup db
+
+ file = saveFile(
+ config.getDbBackupDirectory(),
+ "tutti-db-" + ExportDbAction.df.format(new Date()),
+ "zip",
+ _("tutti.dbManager.title.choose.dbBackupFile"),
+ _("tutti.dbManager.action.chooseDbBackupFile"),
+ "^.*\\.zip", _("tutti.common.file.zip")
+ );
+
+ if (file == null) {
+
+ // won't migrate db
+ closeDb = true;
+
+ displayWarningMessage(
+ _("tutti.dbManager.title.choose.dbBackupFile"),
+ _("tutti.dbManager.action.upgradeDb.no.backup.db.choosen")
+ );
+ } else {
+
+ updateSchema = true;
+ }
+ } else {
+
+ //close db
+ closeDb = true;
+ }
+
+ } else {
+
+ // database schema version is higher than application one
+ displayWarningMessage(
+ _("tutti.dbManager.title.schema.toupdate"),
+ _("tutti.dbManager.action.upgradeDb.schema.not.update.message", dbVersion, applicationVersion)
+ );
+ }
+
+ if (closeDb) {
+
+ // ------------------------------------------------------------------ //
+ // --- close current db //
+ // ------------------------------------------------------------------ //
+
+ progressionModel.increments(_("tutti.importDb.step.closeDb"));
+ getActionEngine().runInternalAction(getHandler(), CloseDbAction.class);
+
+ setScreen(TuttiScreen.MANAGE_DB);
+ super.doAction();
+ return;
+ }
+
+ if (updateSchema) {
+
+ // need to export db + migrate schema)
+ progressionModel.adaptTotal(progressionModel.getTotal() + ExportDbAction.TOTAL_STEP + 1);
+
+ // ------------------------------------------------------------------ //
+ // --- backup current db //
+ // ------------------------------------------------------------------ //
+
+ ApplicationUIAction<ExportDbAction> backupAction =
+ getActionFactory().createUIAction(getHandler(), ExportDbAction.class);
+ backupAction.getLogicAction().setProgressionModel(getProgressionModel());
+ backupAction.getLogicAction().setFile(file);
+ getActionEngine().runInternalAction(backupAction.getLogicAction());
+
+ // ------------------------------------------------------------------ //
+ // --- update schema //
+ // ------------------------------------------------------------------ //
+
+ String message = _("tutti.openDb.step.will.migrateSchema",
+ dbVersion, applicationVersion);
+
+ progressionModel.increments(message);
+ sendMessage(message);
+ getHandler().getPersistenceService().updateSchema();
+ }
+
+ if (updateReferentiel) {
+
+ // ------------------------------------------------------------------ //
+ // --- update referentiel //
+ // ------------------------------------------------------------------ //
+
+ progressionModel.increments(_("tutti.openDb.step.updateReferential"));
+
+ File current = config.getDataDirectory();
+ String url = config.getUpdateDataUrl();
+
+ File dest = new File(config.getBasedir(), "NEW");
+
+ progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.check"));
+ TuttiDbUpdaterCallBack callback =
+ new TuttiDbUpdaterCallBack(this, progressionModel);
+ ApplicationUpdater up = new ApplicationUpdater();
+ up.update(url,
+ current,
+ dest,
+ false,
+ callback,
+ progressionModel);
+
+ if (callback.isDbUpdated()) {
+
+ progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.reloading"));
+
+ } else {
+ sendMessage(_("tutti.dbManager.action.upgradeDb.upToDate"));
+ }
+ }
+
+ // ------------------------------------------------------------------ //
+ // --- check db context //
+ // ------------------------------------------------------------------ //
+
+ String message = _("tutti.openDb.step.check.dbContext",
+ dbVersion, applicationVersion);
+
+ progressionModel.increments(message);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Check db context");
+ }
+ getContext().checkDbContext();
+
+ super.doAction();
+ }
+
+ @Override
+ public void postSuccessAction() {
+
+ handler.reloadDbManagerText();
+
+ // make sure title is reloaded
+ handler.changeTitle();
+
+ if (closeDb) {
+ sendMessage(_("tutti.flash.info.db.not.opened", jdbcUrl));
+ } else {
+
+ if (updateSchema) {
+
+ sendMessage(_("tutti.flash.info.db.schema.updated", dbVersion, applicationVersion));
+ }
+
+ sendMessage(_("tutti.flash.info.db.opened", jdbcUrl));
+ }
+ }
+
+ @Override
+ public void postFailedAction(Throwable error) {
+
+ handler.reloadDbManagerText();
+
+ super.postFailedAction(error);
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ReimportDbAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ReimportDbAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ReimportDbAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ReimportDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,166 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.shared.application.ApplicationIOUtil;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.ui.swing.RunTutti;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+
+import java.io.File;
+import java.util.Date;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To import a db after restart application.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.1
+ */
+public class ReimportDbAction extends AbstractMainUITuttiAction {
+
+ protected File backupFile;
+
+ protected File importFile;
+
+ protected String jdbcUrl;
+
+ public ReimportDbAction(MainUIHandler handler) {
+ super(handler, true);
+ setActionDescription(_("tutti.dbManager.action.importDb.tip"));
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ jdbcUrl = null;
+ backupFile = importFile = null;
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ jdbcUrl = getConfig().getJdbcUrl();
+
+ if (getModel().isDbExist()) {
+
+ displayInfoMessage(
+ _("tutti.dbManager.title.backup.db"),
+ _("tutti.dbManager.action.importDb.backup.db")
+ );
+
+ // choose backup file
+ backupFile = saveFile(
+ getConfig().getDbBackupDirectory(),
+ "tutti-db-" + ExportDbAction.df.format(new Date()),
+ "zip",
+ _("tutti.dbManager.title.choose.dbExportFile"),
+ _("tutti.dbManager.action.chooseDbExportFile"),
+ "^.*\\.zip", _("tutti.common.file.zip")
+ );
+
+ if (backupFile == null) {
+
+ displayWarningMessage(
+ _("tutti.dbManager.title.backup.db"),
+ _("tutti.dbManager.action.importdb.no.backup.db.choosen")
+ );
+
+ doAction = false;
+ }
+ }
+
+ if (doAction && importFile == null) {
+
+ // choose file to import
+ importFile = chooseFile(
+ _("tutti.dbManager.title.choose.dbImportFile"),
+ _("tutti.dbManager.action.chooseDbFile"),
+ "^.*\\.zip", _("tutti.common.file.zip")
+ );
+
+ if (importFile == null) {
+
+ displayWarningMessage(
+ _("tutti.dbManager.title.choose.dbImportFile"),
+ _("tutti.dbManager.action.importdb.no.import.file.choosen")
+ );
+
+ doAction = false;
+ }
+ }
+
+ if (doAction) {
+
+ ProgressionModel progressionModel = new ProgressionModel();
+ progressionModel.setTotal(3);
+ setProgressionModel(progressionModel);
+
+ getContext().getPersistenceService().checkImportStructure(importFile);
+ }
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ importFile = backupFile = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkNotNull(importFile);
+ Preconditions.checkNotNull(backupFile);
+
+ ProgressionModel progressionModel = getProgressionModel();
+
+ // close db
+ progressionModel.increments(_("tutti.reimport.step.closeDb", jdbcUrl));
+ getContext().setDbLoaded(false);
+ getHandler().reloadPersistenceService();
+
+ // backup db
+ progressionModel.increments(_("tutti.reimport.step.backupDb", backupFile));
+ getContext().getPersistenceService().exportDb(backupFile);
+
+ // clean db context
+ getContext().clearDbContext();
+
+ // write restart action file (will be load at restart)
+ String actionContent = ImportDbAction.class.getName() + ":" + importFile.getAbsolutePath();
+
+ File startActionFile = getConfig().getStartActionFile();
+ ApplicationIOUtil.writeContent(startActionFile, actionContent, _("tutti.error.write.startActionFile", startActionFile));
+
+ // restart application
+ progressionModel.increments(_("tutti.reimport.step.reloadApplication"));
+
+ RunTutti.closeTutti(getHandler(), RunTutti.DELETE_DB_EXIT_CODE);
+ }
+
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ReinstallDbAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ReinstallDbAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ReinstallDbAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ReinstallDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,145 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.shared.application.ApplicationIOUtil;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.ui.swing.RunTutti;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+
+import java.io.File;
+import java.util.Date;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To install (or reinstall) a db from last network one.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.4
+ */
+public class ReinstallDbAction extends AbstractMainUITuttiAction {
+
+ protected File backupFile;
+
+ protected String jdbcUrl;
+
+ public ReinstallDbAction(MainUIHandler handler) {
+ super(handler, true);
+ setActionDescription(_("tutti.dbManager.action.installDb.tip"));
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ // check we can connect to remote install server
+
+ // check db url is reachable
+ TuttiUIContext context = getContext();
+ doAction = context.checkUpdateDataReachable();
+ }
+
+ if (doAction) {
+
+ jdbcUrl = null;
+ backupFile = null;
+
+ jdbcUrl = getConfig().getJdbcUrl();
+
+ if (getModel().isDbExist()) {
+
+ displayInfoMessage(
+ _("tutti.dbManager.title.backup.db"),
+ _("tutti.dbManager.action.installDb.backup.db")
+ );
+
+ // choose backup file
+ backupFile = saveFile(
+ getConfig().getDbBackupDirectory(),
+ "tutti-db-" + ExportDbAction.df.format(new Date()),
+ "zip",
+ _("tutti.dbManager.title.choose.dbExportFile"),
+ _("tutti.dbManager.action.chooseDbExportFile"),
+ "^.*\\.zip", _("tutti.common.file.zip")
+ );
+
+ if (backupFile == null) {
+
+ displayWarningMessage(
+ _("tutti.dbManager.title.backup.db"),
+ _("tutti.dbManager.action.installDb.no.backup.db.choosen")
+ );
+
+ doAction = false;
+ }
+ }
+ }
+
+ if (doAction) {
+
+ ProgressionModel progressionModel = new ProgressionModel();
+ progressionModel.setTotal(3);
+ setProgressionModel(progressionModel);
+ }
+ return doAction;
+ }
+
+ @Override
+ public void doAction() {
+
+ Preconditions.checkNotNull(backupFile);
+
+ ProgressionModel progressionModel = getProgressionModel();
+
+ // close db
+ progressionModel.increments(_("tutti.reinstallDb.step.closeDb", jdbcUrl));
+
+ getContext().setDbLoaded(false);
+ getHandler().reloadPersistenceService();
+
+ // backup db
+ progressionModel.increments(_("tutti.reinstallDb.step.backupDb", backupFile));
+ getContext().getPersistenceService().exportDb(backupFile);
+
+ // clean db context
+ getContext().clearDbContext();
+
+ // write restart action file (will be loaded at restart)
+ String actionContent = InstallDbAction.class.getName();
+
+ File startActionFile = getConfig().getStartActionFile();
+ ApplicationIOUtil.writeContent(startActionFile, actionContent, _("tutti.error.write.startActionFile", startActionFile));
+
+ // restart application
+ progressionModel.increments(_("tutti.reinstallDb.step.reloadApplication"));
+
+ RunTutti.closeTutti(getHandler(), RunTutti.DELETE_DB_EXIT_CODE);
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ReloadTuttiAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ReloadTuttiAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ReloadTuttiAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ReloadTuttiAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,52 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.RunTutti;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To reload Tutti application.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0.3
+ */
+public class ReloadTuttiAction extends AbstractChangeScreenAction {
+
+ public ReloadTuttiAction(MainUIHandler handler) {
+ super(handler, true, null);
+ setActionDescription(_("tutti.main.action.reloadTutti"));
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ // Close the application, will exit and restart application
+ RunTutti.closeTutti(getHandler(), RunTutti.UPATE_EXIT_CODE);
+ }
+
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveAccidentalBatchAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/RemoveAccidentalBatchAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveAccidentalBatchAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveAccidentalBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,116 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.TuttiPersistence;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.AccidentalBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.AccidentalBatchTableModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.AccidentalBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.AccidentalBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.AccidentalBatchUIModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+
+import javax.swing.JOptionPane;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.4
+ */
+public class RemoveAccidentalBatchAction extends AbstractTuttiAction<AccidentalBatchUIModel, AccidentalBatchUI, AccidentalBatchUIHandler> {
+
+ private static final Log log =
+ LogFactory.getLog(RemoveAccidentalBatchAction.class);
+
+ public RemoveAccidentalBatchAction(AccidentalBatchUIHandler handler) {
+ super(handler, false);
+ }
+
+ int rowIndex;
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+
+ if (result) {
+ int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
+ _("tutti.editAccidentalBatch.action.removeBatch.confirm.message"),
+ _("tutti.editAccidentalBatch.action.removeBatch.confirm.title"),
+ JOptionPane.YES_NO_OPTION);
+ result = answer == JOptionPane.YES_OPTION;
+ }
+
+ return result;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ JXTable table = handler.getTable();
+
+ rowIndex = table.getSelectedRow();
+
+ Preconditions.checkState(rowIndex != -1,
+ "Cant remove batch if none is selected");
+
+ AccidentalBatchTableModel tableModel = handler.getTableModel();
+ AccidentalBatchRowModel selectedBatch = tableModel.getEntry(rowIndex);
+
+ boolean persisted = !TuttiEntities.isNew(selectedBatch);
+
+ if (persisted) {
+
+ // remove it from db
+
+ String id = selectedBatch.getId();
+
+ if (log.isInfoEnabled()) {
+ log.info("Remove accidental with id: " + id);
+ }
+
+ TuttiPersistence persistenceService =
+ getContext().getPersistenceService();
+
+ persistenceService.deleteAccidentalBatch(id);
+ }
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ JXTable table = handler.getTable();
+
+ AccidentalBatchTableModel tableModel = handler.getTableModel();
+
+ tableModel.removeRow(rowIndex);
+
+ TuttiUIUtil.selectFirstCellOnFirstRowAndStopEditing(table);
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveAllIndividualObservationBatchAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/RemoveAllIndividualObservationBatchAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveAllIndividualObservationBatchAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveAllIndividualObservationBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,157 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.TuttiPersistence;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchTableModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchUIModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+
+import javax.swing.JOptionPane;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created on 10/3/13.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 2.7
+ */
+public class RemoveAllIndividualObservationBatchAction
+ extends AbstractTuttiAction<IndividualObservationBatchUIModel, IndividualObservationBatchUI, IndividualObservationBatchUIHandler> {
+
+ private static final Log log =
+ LogFactory.getLog(RemoveAllIndividualObservationBatchAction.class);
+
+ public RemoveAllIndividualObservationBatchAction(IndividualObservationBatchUIHandler handler) {
+ super(handler, false);
+ }
+
+ protected Species species;
+
+ protected List<Integer> rowIndexToRemove;
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+
+ rowIndexToRemove = null;
+ species = null;
+
+ int rowIndex = -1;
+
+ if (result) {
+ JXTable table = handler.getTable();
+
+ rowIndex = table.getSelectedRow();
+
+ Preconditions.checkState(rowIndex != -1,
+ "Cant remove batch if none is selected");
+ }
+
+ if (result) {
+
+ IndividualObservationBatchTableModel tableModel = handler.getTableModel();
+
+ IndividualObservationBatchRowModel entry = tableModel.getEntry(rowIndex);
+
+ species = entry.getSpecies();
+
+ rowIndexToRemove = Lists.newArrayList();
+
+ for (IndividualObservationBatchRowModel rowModel : tableModel.getRows()) {
+ if (species.equals(rowModel.getSpecies())) {
+ rowIndexToRemove.add(0, tableModel.getRowIndex(rowModel));
+ }
+ }
+
+ int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
+ _("tutti.editIndividualObservationBatch.action.removeAllBatch.confirm.message", rowIndexToRemove.size(), decorate(species)),
+ _("tutti.editIndividualObservationBatch.action.removeAllBatch.confirm.title"),
+ JOptionPane.YES_NO_OPTION);
+ result = answer == JOptionPane.YES_OPTION;
+ }
+
+ return result;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ Preconditions.checkNotNull(rowIndexToRemove);
+ Preconditions.checkNotNull(species);
+
+ IndividualObservationBatchTableModel tableModel = handler.getTableModel();
+
+ for (Integer rowIndex : rowIndexToRemove) {
+ IndividualObservationBatchRowModel selectedBatch = tableModel.getEntry(rowIndex);
+
+ boolean persisted = !TuttiEntities.isNew(selectedBatch);
+
+ if (persisted) {
+
+ // remove it from db
+
+ String id = selectedBatch.getId();
+
+ if (log.isInfoEnabled()) {
+ log.info("Remove individual observation with id: " + id);
+ }
+
+ TuttiPersistence persistenceService =
+ getContext().getPersistenceService();
+
+ persistenceService.deleteIndividualObservationBatch(id);
+ }
+ }
+
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ JXTable table = handler.getTable();
+
+ IndividualObservationBatchTableModel tableModel = handler.getTableModel();
+
+ for (Integer rowIndex : rowIndexToRemove) {
+ tableModel.removeRow(rowIndex);
+ }
+
+ TuttiUIUtil.selectFirstCellOnFirstRowAndStopEditing(table);
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveBenthosBatchAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveBenthosBatchAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveBenthosBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,145 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.TuttiPersistence;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchTableModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import jaxx.runtime.SwingUtil;
+import org.jdesktop.swingx.JXTable;
+
+import javax.swing.JOptionPane;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To remove a species batch and all his children.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class RemoveBenthosBatchAction extends AbstractTuttiAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> {
+
+ /**
+ * Selected row to treat.
+ *
+ * @since 2.8
+ */
+ protected int rowIndex;
+
+ /**
+ * Rows to delete after all.
+ *
+ * @since 3.0-rc-1
+ */
+ protected Set<BenthosBatchRowModel> rowToRemove;
+
+ public RemoveBenthosBatchAction(BenthosBatchUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+
+ rowIndex = -1;
+
+ if (result) {
+ int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
+ _("tutti.editBenthosBatch.action.removeBatch.confirm.message"),
+ _("tutti.editBenthosBatch.action.removeBatch.confirm.title"),
+ JOptionPane.YES_NO_OPTION);
+ result = answer == JOptionPane.YES_OPTION;
+ }
+
+ return result;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ TuttiPersistence persistenceService =
+ getContext().getPersistenceService();
+
+ JXTable table = handler.getTable();
+
+ rowIndex = SwingUtil.getSelectedModelRow(table);
+
+ Preconditions.checkState(rowIndex != -1,
+ "Cant remove batch if no batch selected");
+
+ BenthosBatchTableModel tableModel = handler.getTableModel();
+ BenthosBatchRowModel selectedBatch = tableModel.getEntry(rowIndex);
+
+ Preconditions.checkState(!TuttiEntities.isNew(selectedBatch),
+ "Can't remove batch if batch is not persisted");
+
+ // remove selected batch and all his children
+
+ // remove parent batch (will destroy all his childs from db)
+ persistenceService.deleteBenthosBatch(selectedBatch.getId());
+
+ if (selectedBatch.isBatchRoot()) {
+ // update speciesUsed
+ handler.removeFromSpeciesUsed(selectedBatch);
+ } else {
+
+ // remove from his parent
+ BenthosBatchRowModel parentBatch = selectedBatch.getParentBatch();
+ parentBatch.getChildBatch().remove(selectedBatch);
+ }
+
+ // collect of rows to remove from model
+ rowToRemove = Sets.newHashSet();
+ rowToRemove.add(selectedBatch);
+
+ handler.collectChildren(selectedBatch, rowToRemove);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ JXTable table = handler.getTable();
+
+ // remove all rows from the model
+ getModel().getRows().removeAll(rowToRemove);
+
+ // refresh table from parent batch row index to the end
+ handler.getTableModel().fireTableDataChanged();
+
+ // select parent batch row
+ TuttiUIUtil.selectFirstCellOnFirstRowAndStopEditing(table);
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveBenthosProtocolAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveBenthosProtocolAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveBenthosProtocolAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveBenthosProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,136 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesRowModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesTableModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
+import jaxx.runtime.SwingUtil;
+
+import javax.swing.JTable;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To remove all the selected benthos rows from protocol.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class RemoveBenthosProtocolAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+
+ /**
+ * Set of removed species.
+ *
+ * @since 2.8
+ */
+ protected Set<Species> removedSpecies;
+
+ /**
+ * Set of removed rows.
+ *
+ * @since 2.8
+ */
+ protected Set<EditProtocolSpeciesRowModel> removedRows;
+
+
+ public RemoveBenthosProtocolAction(EditProtocolUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ JTable table = handler.getBenthosTable();
+
+ // need to have a selection
+ Preconditions.checkState(!table.getSelectionModel().isSelectionEmpty());
+
+ EditProtocolSpeciesTableModel tableModel =
+ (EditProtocolSpeciesTableModel) table.getModel();
+
+ removedSpecies = Sets.newHashSet();
+ removedRows = Sets.newHashSet();
+
+ EditProtocolUIModel model = getModel();
+
+ for (Integer rowIndex : SwingUtil.getSelectedModelRows(table)) {
+
+ // get row to remove
+ EditProtocolSpeciesRowModel selectedRow =
+ tableModel.getEntry(rowIndex);
+
+ // re-add all synonym of this taxon to the species / benthos combobox
+ Species species = selectedRow.getSpecies();
+ removedSpecies.add(species);
+
+ Integer taxonId = species.getReferenceTaxonId();
+ List<Species> allSynonyms = Lists.newArrayList(
+ model.getAllSynonyms(String.valueOf(taxonId)));
+ allSynonyms.remove(species);
+ model.getAllSynonyms().addAll(allSynonyms);
+
+ // mark row to be removed at the very last moment
+ removedRows.add(selectedRow);
+ }
+
+ // reorder the list by name, otherwise,
+ // all the species without a reftax code will be at the end
+ Collections.sort(model.getAllSynonyms(),
+ TuttiEntities.SPECIES_BY_NAME_COMPARATOR);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ // update comboboxes
+ getUI().getBenthosComboBox().addItems(removedSpecies);
+ getUI().getSpeciesComboBox().addItems(removedSpecies);
+
+ // remove all rows from model
+ getModel().getBenthosRow().removeAll(removedRows);
+
+ // fire table data changed
+ handler.getBenthosTableModel().fireTableDataChanged();
+
+ // clear table selection
+ handler.getBenthosTable().clearSelection();
+
+ // notify user
+ sendMessage(_("tutti.flash.info.benthos.remove.from.protocol"));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveBenthosSubBatchAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveBenthosSubBatchAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveBenthosSubBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,139 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.TuttiPersistence;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import jaxx.runtime.SwingUtil;
+import org.jdesktop.swingx.JXTable;
+
+import javax.swing.JOptionPane;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To remove a species batch children.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class RemoveBenthosSubBatchAction extends AbstractTuttiAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> {
+
+ /**
+ * Selected row to treat.
+ *
+ * @since 2.8
+ */
+ protected int rowIndex;
+
+ /**
+ * Rows to delete after all.
+ *
+ * @since 3.0-rc-1
+ */
+ protected Set<BenthosBatchRowModel> rowToRemove;
+
+ /**
+ * Parent batch of rows to delete.
+ *
+ * @since 3.0-rc-1
+ */
+ protected BenthosBatchRowModel parentBatch;
+
+ public RemoveBenthosSubBatchAction(BenthosBatchUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+
+ rowIndex = -1;
+
+ if (result) {
+ int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
+ _("tutti.editBenthosBatch.action.removeSubBatch.confirm.message"),
+ _("tutti.editBenthosBatch.action.removeSubBatch.confirm.title"),
+ JOptionPane.YES_NO_OPTION);
+ result = answer == JOptionPane.YES_OPTION;
+ }
+
+ return result;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ TuttiPersistence persistenceService =
+ getContext().getPersistenceService();
+
+ JXTable table = handler.getTable();
+
+ rowIndex = SwingUtil.getSelectedModelRow(table);
+
+ Preconditions.checkState(rowIndex != -1,
+ "Cant remove sub batch if no batch selected");
+
+ parentBatch = handler.getTableModel().getEntry(rowIndex);
+
+ Preconditions.checkState(!TuttiEntities.isNew(parentBatch),
+ "Can't remove sub batch if batch is not persisted");
+
+ // save parent batch (will destroy all his childs from db)
+ persistenceService.deleteSpeciesSubBatch(parentBatch.getId());
+
+ // collect of rows to remove from model
+ rowToRemove = Sets.newHashSet();
+
+ handler.collectChildren(parentBatch, rowToRemove);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ JXTable table = handler.getTable();
+
+ // remove all rows from the model
+ getModel().getRows().removeAll(rowToRemove);
+
+ // remove childs from parent batch
+ parentBatch.setChildBatch(null);
+
+ // refresh table from parent batch row index to the end
+ handler.getTableModel().fireTableDataChanged();
+
+ // select parent batch row
+ TuttiUIUtil.selectFirstCellOnRow(table, rowIndex, true);
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveIndividualObservationBatchAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/RemoveIndividualObservationBatchAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveIndividualObservationBatchAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveIndividualObservationBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,117 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.TuttiPersistence;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchTableModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchUIModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+
+import javax.swing.JOptionPane;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.4
+ */
+public class RemoveIndividualObservationBatchAction
+ extends AbstractTuttiAction<IndividualObservationBatchUIModel, IndividualObservationBatchUI, IndividualObservationBatchUIHandler> {
+
+ private static final Log log =
+ LogFactory.getLog(RemoveIndividualObservationBatchAction.class);
+
+ public RemoveIndividualObservationBatchAction(IndividualObservationBatchUIHandler handler) {
+ super(handler, false);
+ }
+
+ int rowIndex;
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+
+ if (result) {
+ int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
+ _("tutti.editIndividualObservationBatch.action.removeBatch.confirm.message"),
+ _("tutti.editIndividualObservationBatch.action.removeBatch.confirm.title"),
+ JOptionPane.YES_NO_OPTION);
+ result = answer == JOptionPane.YES_OPTION;
+ }
+
+ return result;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ JXTable table = handler.getTable();
+
+ rowIndex = table.getSelectedRow();
+
+ Preconditions.checkState(rowIndex != -1,
+ "Cant remove batch if none is selected");
+
+ IndividualObservationBatchTableModel tableModel = handler.getTableModel();
+ IndividualObservationBatchRowModel selectedBatch = tableModel.getEntry(rowIndex);
+
+ boolean persisted = !TuttiEntities.isNew(selectedBatch);
+
+ if (persisted) {
+
+ // remove it from db
+
+ String id = selectedBatch.getId();
+
+ if (log.isInfoEnabled()) {
+ log.info("Remove individual observation with id: " + id);
+ }
+
+ TuttiPersistence persistenceService =
+ getContext().getPersistenceService();
+
+ persistenceService.deleteIndividualObservationBatch(id);
+ }
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ JXTable table = handler.getTable();
+
+ IndividualObservationBatchTableModel tableModel = handler.getTableModel();
+
+ tableModel.removeRow(rowIndex);
+
+ TuttiUIUtil.selectFirstCellOnFirstRowAndStopEditing(table);
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveMarineLitterBatchAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/RemoveMarineLitterBatchAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveMarineLitterBatchAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveMarineLitterBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,126 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.TuttiPersistence;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchTableModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchUIModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+
+import javax.swing.JOptionPane;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To remove a selected marine litter batch in the table.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
+ */
+public class RemoveMarineLitterBatchAction extends AbstractTuttiAction<MarineLitterBatchUIModel, MarineLitterBatchUI, MarineLitterBatchUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(RemoveMarineLitterBatchAction.class);
+
+ protected RemoveSpeciesSubBatchAction removeSpeciesSubBatchAction;
+
+ public RemoveMarineLitterBatchAction(MarineLitterBatchUIHandler handler) {
+ super(handler, false);
+ }
+
+ int rowIndex;
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+
+ if (result) {
+ int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
+ _("tutti.editMarineLitterBatch.action.removeBatch.confirm.message"),
+ _("tutti.editMarineLitterBatch.action.removeBatch.confirm.title"),
+ JOptionPane.YES_NO_OPTION);
+ result = answer == JOptionPane.YES_OPTION;
+ }
+
+ return result;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ JXTable table = handler.getTable();
+
+ rowIndex = table.getSelectedRow();
+
+ Preconditions.checkState(rowIndex != -1,
+ "Cant remove batch if none is selected");
+
+ MarineLitterBatchTableModel tableModel = handler.getTableModel();
+ MarineLitterBatchRowModel selectedBatch = tableModel.getEntry(rowIndex);
+
+ boolean persisted = !TuttiEntities.isNew(selectedBatch);
+
+ if (persisted) {
+
+ // remove it from db
+
+ String id = selectedBatch.getId();
+
+ if (log.isInfoEnabled()) {
+ log.info("Remove marineLitter with id: " + id);
+ }
+
+ TuttiPersistence persistenceService =
+ getContext().getPersistenceService();
+
+ persistenceService.deleteMarineLitterBatch(id);
+ }
+
+ // update speciesUsed
+ handler.removeFromMarineLitterCategoriesUsed(selectedBatch);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ JXTable table = handler.getTable();
+
+ MarineLitterBatchTableModel tableModel = handler.getTableModel();
+
+ tableModel.removeRow(rowIndex);
+
+ TuttiUIUtil.selectFirstCellOnFirstRowAndStopEditing(table);
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveSpeciesBatchAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveSpeciesBatchAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveSpeciesBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,136 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.TuttiPersistence;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import jaxx.runtime.SwingUtil;
+import org.jdesktop.swingx.JXTable;
+
+import javax.swing.JOptionPane;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To remove a species batch and all his children.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class RemoveSpeciesBatchAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> {
+
+ /**
+ * Rows to delete after all.
+ *
+ * @since 3.0-rc-1
+ */
+ protected Set<SpeciesBatchRowModel> rowToRemove;
+
+ public RemoveSpeciesBatchAction(SpeciesBatchUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+
+ if (result) {
+ int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
+ _("tutti.editSpeciesBatch.action.removeBatch.confirm.message"),
+ _("tutti.editSpeciesBatch.action.removeBatch.confirm.title"),
+ JOptionPane.YES_NO_OPTION);
+ result = answer == JOptionPane.YES_OPTION;
+ }
+
+ return result;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ TuttiPersistence persistenceService =
+ getContext().getPersistenceService();
+
+ JXTable table = handler.getTable();
+
+ int rowIndex = SwingUtil.getSelectedModelRow(table);
+
+ Preconditions.checkState(rowIndex != -1,
+ "Cant remove batch if no batch selected");
+
+ SpeciesBatchTableModel tableModel = handler.getTableModel();
+
+ SpeciesBatchRowModel selectedBatch = tableModel.getEntry(rowIndex);
+
+ Preconditions.checkState(!TuttiEntities.isNew(selectedBatch),
+ "Can't remove batch if batch is not persisted");
+
+ // remove selected batch and all his children
+
+ // remove parent batch (will destroy all his childs from db)
+ persistenceService.deleteSpeciesBatch(selectedBatch.getId());
+
+ if (selectedBatch.isBatchRoot()) {
+ // update speciesUsed
+ handler.removeFromSpeciesUsed(selectedBatch);
+ } else {
+
+ // remove from his parent
+ SpeciesBatchRowModel parentBatch = selectedBatch.getParentBatch();
+ parentBatch.getChildBatch().remove(selectedBatch);
+ }
+
+ // collect of rows to remove from model
+ rowToRemove = Sets.newHashSet();
+ rowToRemove.add(selectedBatch);
+
+ handler.collectChildren(selectedBatch, rowToRemove);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ JXTable table = handler.getTable();
+
+ // remove all rows from the model
+ getModel().getRows().removeAll(rowToRemove);
+
+ // refresh table from parent batch row index to the end
+ handler.getTableModel().fireTableDataChanged();
+
+ // select parent batch row
+ TuttiUIUtil.selectFirstCellOnFirstRowAndStopEditing(table);
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveSpeciesProtocolAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveSpeciesProtocolAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveSpeciesProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,134 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesRowModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesTableModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
+import jaxx.runtime.SwingUtil;
+
+import javax.swing.JTable;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To remove all the selected species rows from protocol.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class RemoveSpeciesProtocolAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /**
+ * Set of removed species.
+ *
+ * @since 2.8
+ */
+ protected Set<Species> removedSpecies;
+
+ /**
+ * Set of removed rows.
+ *
+ * @since 2.8
+ */
+ protected Set<EditProtocolSpeciesRowModel> removedRows;
+
+ public RemoveSpeciesProtocolAction(EditProtocolUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ JTable table = handler.getSpeciesTable();
+
+ // need to have a selection
+ Preconditions.checkState(!table.getSelectionModel().isSelectionEmpty());
+
+ EditProtocolSpeciesTableModel tableModel =
+ (EditProtocolSpeciesTableModel) table.getModel();
+
+ EditProtocolUIModel model = getModel();
+
+ removedSpecies = Sets.newHashSet();
+ removedRows = Sets.newHashSet();
+
+ for (Integer rowIndex : SwingUtil.getSelectedModelRows(table)) {
+
+ // get row to remove
+ EditProtocolSpeciesRowModel selectedRow =
+ tableModel.getEntry(rowIndex);
+
+ // re-add all synonym of this taxon to the species / benthos combobox
+ Species species = selectedRow.getSpecies();
+ removedSpecies.add(species);
+
+ Integer taxonId = species.getReferenceTaxonId();
+ List<Species> allSynonyms = Lists.newArrayList(
+ model.getAllSynonyms(String.valueOf(taxonId)));
+ allSynonyms.remove(species);
+ model.getAllSynonyms().addAll(allSynonyms);
+
+ // mark row to be removed at the very last moment
+ removedRows.add(selectedRow);
+ }
+
+ // reorder the list by name, otherwise,
+ // all the species without a reftax code will be at the end
+ Collections.sort(model.getAllSynonyms(), TuttiEntities.SPECIES_BY_NAME_COMPARATOR);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ // update comboboxes
+ getUI().getBenthosComboBox().addItems(removedSpecies);
+ getUI().getSpeciesComboBox().addItems(removedSpecies);
+
+ // remove all rows from model
+ getModel().getSpeciesRow().removeAll(removedRows);
+
+ // fire table data changed
+ handler.getSpeciesTableModel().fireTableDataChanged();
+
+ // clear table selection
+ handler.getSpeciesTable().clearSelection();
+
+ // notify user
+ sendMessage(_("tutti.flash.info.species.remove.from.protocol"));
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveSpeciesSubBatchAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveSpeciesSubBatchAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RemoveSpeciesSubBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,141 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.TuttiPersistence;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import jaxx.runtime.SwingUtil;
+import org.jdesktop.swingx.JXTable;
+
+import javax.swing.JOptionPane;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To remove a species batch children.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class RemoveSpeciesSubBatchAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> {
+
+ /**
+ * Selected row to treat.
+ *
+ * @since 2.8
+ */
+ protected int rowIndex;
+
+ /**
+ * Rows to delete after all.
+ *
+ * @since 3.0-rc-1
+ */
+ protected Set<SpeciesBatchRowModel> rowToRemove;
+
+ /**
+ * Parent batch of rows to delete.
+ *
+ * @since 3.0-rc-1
+ */
+ protected SpeciesBatchRowModel parentBatch;
+
+ public RemoveSpeciesSubBatchAction(SpeciesBatchUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+
+ rowIndex = -1;
+
+ if (result) {
+ int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
+ _("tutti.editSpeciesBatch.action.removeSubBatch.confirm.message"),
+ _("tutti.editSpeciesBatch.action.removeSubBatch.confirm.title"),
+ JOptionPane.YES_NO_OPTION);
+ result = answer == JOptionPane.YES_OPTION;
+ }
+
+ return result;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ TuttiPersistence persistenceService =
+ getContext().getPersistenceService();
+
+ JXTable table = handler.getTable();
+
+ rowIndex = SwingUtil.getSelectedModelRow(table);
+
+ Preconditions.checkState(rowIndex != -1,
+ "Cant remove sub batch if no batch selected");
+
+
+ parentBatch = handler.getTableModel().getEntry(rowIndex);
+
+ Preconditions.checkState(!TuttiEntities.isNew(parentBatch),
+ "Can't remove sub batch if batch is not persisted");
+
+ // save parent batch (will destroy all his childs from db)
+ persistenceService.deleteSpeciesSubBatch(parentBatch.getId());
+
+ // collect of rows to remove from model
+
+ rowToRemove = Sets.newHashSet();
+
+ handler.collectChildren(parentBatch, rowToRemove);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ JXTable table = handler.getTable();
+
+ // remove all rows from the model
+ getModel().getRows().removeAll(rowToRemove);
+
+ // remove childs from parent batch
+ parentBatch.setChildBatch(null);
+
+ // refresh table from parent batch row index to the end
+ handler.getTableModel().fireTableDataChanged();
+
+ // select parent batch row
+ TuttiUIUtil.selectFirstCellOnRow(table, rowIndex, true);
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RenameBenthosBatchAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RenameBenthosBatchAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RenameBenthosBatchAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RenameBenthosBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,124 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.data.SampleCategory;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchTableModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIModel;
+import jaxx.runtime.SwingUtil;
+import org.jdesktop.swingx.JXTable;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To rename the species for a species batch and all his children.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class RenameBenthosBatchAction extends AbstractTuttiAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> {
+
+ protected Species selectedSpecies;
+
+ public RenameBenthosBatchAction(BenthosBatchUIHandler handler) {
+ super(handler, false);
+
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+
+ BenthosBatchTableModel tableModel = handler.getTableModel();
+ JXTable table = handler.getTable();
+ int selectedRowIndex = SwingUtil.getSelectedModelRow(table);
+ BenthosBatchRowModel row = tableModel.getEntry(selectedRowIndex);
+
+ BenthosBatchUIModel model = handler.getModel();
+ List<Species> speciesList = Lists.newArrayList(
+ getDataContext().getReferentBenthosWithSurveyCode());
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ Serializable categoryValue = firstSampleCategory.getCategoryValue();
+ speciesList.removeAll(
+ model.getSpeciesUsed().get(
+ (CaracteristicQualitativeValue) categoryValue));
+
+ selectedSpecies = getHandler().openAddSpeciesDialog(
+ _("tutti.selectSpecies.title"),
+ speciesList
+ );
+
+ result &= selectedSpecies != null;
+ return result;
+ }
+
+ @Override
+ public void releaseAction() {
+ selectedSpecies = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ BenthosBatchTableModel tableModel = handler.getTableModel();
+ JXTable table = handler.getTable();
+ int selectedRowIndex = SwingUtil.getSelectedModelRow(table);
+ BenthosBatchRowModel row = tableModel.getEntry(selectedRowIndex);
+
+ PersistenceService persistenceService = getContext().getPersistenceService();
+ persistenceService.changeBenthosBatchSpecies(row.getId(), selectedSpecies);
+
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ Serializable categoryValue = firstSampleCategory.getCategoryValue();
+ Collection<Species> speciesUsed = getModel().getSpeciesUsed()
+ .get((CaracteristicQualitativeValue) categoryValue);
+ speciesUsed.remove(row.getSpecies());
+ changeChildrenSpecies(row, selectedSpecies);
+ speciesUsed.add(selectedSpecies);
+ }
+
+ protected void changeChildrenSpecies(BenthosBatchRowModel row,
+ Species species) {
+ row.setSpecies(species);
+ List<BenthosBatchRowModel> children = row.getChildBatch();
+ if (children != null) {
+ for (BenthosBatchRowModel child : children) {
+ changeChildrenSpecies(child, species);
+ }
+ }
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RenameSpeciesBatchAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RenameSpeciesBatchAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/RenameSpeciesBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,124 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.data.SampleCategory;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel;
+import jaxx.runtime.SwingUtil;
+import org.jdesktop.swingx.JXTable;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To rename the species for a species batch and all his children.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class RenameSpeciesBatchAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> {
+
+ protected Species selectedSpecies;
+
+ public RenameSpeciesBatchAction(SpeciesBatchUIHandler handler) {
+ super(handler, false);
+
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+
+ SpeciesBatchTableModel tableModel = handler.getTableModel();
+ JXTable table = handler.getTable();
+ int selectedRowIndex = SwingUtil.getSelectedModelRow(table);
+ SpeciesBatchRowModel row = tableModel.getEntry(selectedRowIndex);
+
+ SpeciesBatchUIModel model = handler.getModel();
+ List<Species> speciesList = Lists.newArrayList(
+ getDataContext().getReferentSpeciesWithSurveyCode());
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ Serializable categoryValue = firstSampleCategory.getCategoryValue();
+ speciesList.removeAll(
+ model.getSpeciesUsed().get((CaracteristicQualitativeValue) categoryValue));
+
+ selectedSpecies = getHandler().openAddSpeciesDialog(
+ _("tutti.selectSpecies.title"),
+ speciesList
+ );
+
+ result &= selectedSpecies != null;
+ return result;
+ }
+
+ @Override
+ public void releaseAction() {
+ selectedSpecies = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ SpeciesBatchTableModel tableModel = handler.getTableModel();
+ JXTable table = handler.getTable();
+ int selectedRowIndex = SwingUtil.getSelectedModelRow(table);
+ SpeciesBatchRowModel row = tableModel.getEntry(selectedRowIndex);
+
+ PersistenceService persistenceService = getContext().getPersistenceService();
+ persistenceService.changeSpeciesBatchSpecies(row.getId(), selectedSpecies);
+
+ SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
+ Serializable categoryValue = firstSampleCategory.getCategoryValue();
+
+ Collection<Species> speciesUsed = getModel().getSpeciesUsed()
+ .get((CaracteristicQualitativeValue) categoryValue);
+ speciesUsed.remove(row.getSpecies());
+ changeChildrenSpecies(row, selectedSpecies);
+ speciesUsed.add(selectedSpecies);
+ }
+
+ protected void changeChildrenSpecies(SpeciesBatchRowModel row,
+ Species species) {
+ row.setSpecies(species);
+ List<SpeciesBatchRowModel> children = row.getChildBatch();
+ if (children != null) {
+ for (SpeciesBatchRowModel child : children) {
+ changeChildrenSpecies(child, species);
+ }
+ }
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCatchBatchAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCatchBatchAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCatchBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,109 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.content.operation.catches.EditCatchesUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * To save a {@link CatchBatch}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class SaveCatchBatchAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
+
+ /** 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, true);
+ }
+
+ public void setUpdateUI(boolean updateUI) {
+ this.updateUI = updateUI;
+ }
+
+ @Override
+ public void releaseAction() {
+ updateUI = true;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ 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 =
+ getContext().getPersistenceService();
+
+ CatchBatch catchBatch = beanToSave.toEntity();
+
+ if (log.isInfoEnabled()) {
+ log.info("FishingOperation " + catchBatch.getId() +
+ " was modified, will save it.");
+ }
+
+ //FIXME I18n
+ sendMessage(
+ "[ Captures - Caractéristiques générales ] " +
+ "Sauvegarde des modifications du résumé de la capture.");
+
+ persistenceService.saveCatchBatch(catchBatch);
+
+ monitor.clearModified();
+ getModel().setModify(false);
+ }
+
+ getUI().getSpeciesTabContent().getHandler().clearTableSelection();
+
+ }
+
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCruiseAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/SaveCruiseAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCruiseAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCruiseAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,181 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.Sets;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.referential.Gear;
+import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrder;
+import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrders;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUI;
+import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUIHandler;
+import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUIModel;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+import org.apache.commons.lang3.ObjectUtils;
+
+import javax.swing.JOptionPane;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Saves a cruise
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public class SaveCruiseAction extends AbstractTuttiAction<EditCruiseUIModel, EditCruiseUI, EditCruiseUIHandler> {
+
+ protected PersistenceService persistenceService;
+
+ protected boolean updateVessel;
+
+ protected boolean updateGear;
+
+ public SaveCruiseAction(EditCruiseUIHandler handler) {
+ super(handler, true);
+ persistenceService = getContext().getPersistenceService();
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+
+ Cruise bean = getModel().toBean();
+ if (!TuttiEntities.isNew(bean)) {
+ Cruise oldCruise = persistenceService.getCruise(bean.getId());
+
+ // check gear has not changed
+ if (!oldCruise.getVessel().equals(bean.getVessel())) {
+
+ // if so ask user confirmation
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ _("tutti.editCruise.action.save.vesselChanged.message"),
+ _("tutti.editCruise.action.save.vesselChanged.help"));
+
+ int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
+ htmlMessage,
+ _("tutti.editCruise.action.save.vesselChanged.title"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.WARNING_MESSAGE);
+
+ result = updateVessel = answer == JOptionPane.OK_OPTION;
+ }
+
+ if (result) {
+
+ if (ObjectUtils.notEqual(oldCruise.getGear(), bean.getGear())) {
+
+ // get all gears to remove
+
+ Set<Gear> gearsToRemove =
+ Sets.<Gear>newHashSet(oldCruise.getGear());
+
+ for (GearWithOriginalRankOrder gearWithOriginalRankOrder : bean.getGear()) {
+ GearWithOriginalRankOrder g =
+ GearWithOriginalRankOrders.newGearWithOriginalRankOrder(
+ gearWithOriginalRankOrder.getIdAsInt(),
+ gearWithOriginalRankOrder.getOriginalRankOrder()
+ );
+ gearsToRemove.remove(g);
+ }
+
+ // check they are not used by any operation of the cruise
+ boolean obsoleteGearIsUsed = persistenceService.isOperationUseGears(
+ bean.getIdAsInt(), gearsToRemove);
+
+ if (obsoleteGearIsUsed) {
+
+ // not possible, can't removed used gears
+
+ String message = _("tutti.persistence.cruise.gearUsedInOperations.error");
+ displayWarningMessage(
+ _("tutti.editCruise.action.save.gearChanged.title"),
+ "<html><body>" + message + "</body></html>"
+ );
+ result = false;
+ } else {
+
+ // if so ask user confirmation
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ _("tutti.editCruise.action.save.gearChanged.message"),
+ _("tutti.editCruise.action.save.gearChanged.help"));
+
+ int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
+ htmlMessage,
+ _("tutti.editCruise.action.save.gearChanged.title"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.WARNING_MESSAGE);
+
+ result = updateGear = answer == JOptionPane.OK_OPTION;
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ TuttiUIContext context = getContext();
+ EditCruiseUIModel model = getModel();
+
+ Cruise bean = model.toBean();
+
+ Cruise saved;
+ if (TuttiEntities.isNew(bean)) {
+
+ saved = persistenceService.createCruise(bean);
+ model.setId(saved.getId());
+ sendMessage(_("tutti.flash.info.cruiseCreated", bean.getName()));
+ } else {
+ saved = persistenceService.saveCruise(bean, updateVessel, updateGear);
+ sendMessage(_("tutti.flash.info.cruiseSaved", bean.getName()));
+ }
+
+ context.setProgramId(saved.getProgram().getId());
+ context.setCruiseId(saved.getId());
+
+ // update originalRankOrder for all gears of the cruise
+ for (GearWithOriginalRankOrder gear : model.getGear()) {
+ gear.setOriginalRankOrder(gear.getRankOrder());
+ }
+ model.setModify(false);
+ }
+
+ @Override
+ public void postSuccessAction() {
+
+ getContext().getMainUI().getHandler().setBodyTitle(
+ EditCruiseUIHandler.getTitle(true));
+
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveFishingOperationAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveFishingOperationAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveFishingOperationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,185 @@
+
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatchs;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.ValidationService;
+import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI;
+import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.fishing.AbstractCaracteristicTabUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.fishing.GearUseFeatureTabUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.fishing.VesselUseFeatureTabUIModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Saves a fishing operation and potentially sets another screen or switch to another tab.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public class SaveFishingOperationAction extends AbstractTuttiAction<EditFishingOperationUIModel, EditFishingOperationUI, EditFishingOperationUIHandler> {
+
+ /** Logger. */
+ 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, true);
+ }
+
+ public void setUpdateUI(boolean updateUI) {
+ this.updateUI = updateUI;
+ }
+
+ @Override
+ public void releaseAction() {
+ updateUI = true;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ TuttiBeanMonitor<EditFishingOperationUIModel> monitor =
+ handler.getFishingOperationMonitor();
+
+ // previous fishingOperation was modified, let's save it
+ EditFishingOperationUIModel beanToSave = monitor.getBean();
+
+ // must save when bean is new or was modifiy and is valid
+ boolean mustSave = beanToSave.getFishingOperation() != null
+ && beanToSave.isValid();
+
+ if (mustSave) {
+
+ // prepare model
+ beanToSave.convertGearShootingCoordinatesToDD();
+
+ // save modified fishing operation
+ FishingOperation toSave = beanToSave.toBean();
+
+ AbstractCaracteristicTabUIModel[] subModels = handler.getSubModels();
+ for (AbstractCaracteristicTabUIModel subModel : subModels) {
+ Class<?> modelClass = subModel.getClass();
+ CaracteristicMap caracteristics = subModel.getCaracteristicMap();
+
+ if (modelClass.isAssignableFrom(VesselUseFeatureTabUIModel.class)) {
+ toSave.setVesselUseFeatures(caracteristics);
+
+ } else if (modelClass.isAssignableFrom(GearUseFeatureTabUIModel.class)) {
+ toSave.setGearUseFeatures(caracteristics);
+
+ }
+ subModel.setModify(false);
+ }
+
+ sendMessage(
+ "[ Trait - Caractéristiques générales ] " +
+ "Sauvegarde des modifications de " + decorate(toSave) +
+ ".");
+
+ if (log.isInfoEnabled()) {
+ log.info("FishingOperation " + toSave.getId() +
+ " was modified, will save it.");
+ }
+
+ monitor.clearModified();
+ getModel().setModify(false);
+
+ saveFishingOperation(toSave);
+
+ if (ValidationService.VALIDATION_CONTEXT_EDIT.equals(getContext().getValidationContext())) {
+ handler.getParentUi().getTabPane().setSelectedIndex(1);
+ handler.getParentUi().getCatchesTabContent().getTabPane().setSelectedIndex(1);
+ }
+ }
+
+ }
+
+ protected void saveFishingOperation(FishingOperation toSave) {
+
+ PersistenceService service = getContext().getPersistenceService();
+
+ 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 = CatchBatchs.newCatchBatch();
+ 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 {
+
+ model.setEditionAdjusting(true);
+
+ try {
+ // save fishing operation
+ savedFishingOperation = service.saveFishingOperation(toSave);
+
+ model.setSelectedFishingOperation(null);
+
+ // reinject it in model
+ model.updateFishingOperation(savedFishingOperation);
+
+ model.setSelectedFishingOperation(savedFishingOperation);
+ } finally {
+ model.setEditionAdjusting(false);
+ }
+ }
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveProgramAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/SaveProgramAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveProgramAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveProgramAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,81 @@
+
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.program.EditProgramUI;
+import fr.ifremer.tutti.ui.swing.content.program.EditProgramUIHandler;
+import fr.ifremer.tutti.ui.swing.content.program.EditProgramUIModel;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class SaveProgramAction extends AbstractTuttiAction<EditProgramUIModel, EditProgramUI, EditProgramUIHandler> {
+
+ public SaveProgramAction(EditProgramUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ TuttiUIContext context = getContext();
+ PersistenceService persistenceService =
+ getContext().getPersistenceService();
+
+ EditProgramUIModel model = getModel();
+
+ Program bean = model.toBean();
+
+ Program saved;
+ if (TuttiEntities.isNew(bean)) {
+
+ saved = persistenceService.createProgram(bean);
+ model.setId(saved.getId());
+ sendMessage(_("tutti.flash.info.programCreated", bean.getName()));
+ } else {
+ saved = persistenceService.saveProgram(bean);
+ sendMessage(_("tutti.flash.info.programSaved", bean.getName()));
+ }
+
+ context.setProgramId(saved.getId());
+
+ model.setModify(false);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ getContext().getMainUI().getHandler().setBodyTitle(
+ EditProgramUIHandler.getTitle(true));
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveProtocolAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SaveProtocolAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveProtocolAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,122 @@
+
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.protocol.SpeciesProtocol;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolSpeciesRowModel;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Saves a protocol
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public class SaveProtocolAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(SaveProtocolAction.class);
+
+ public SaveProtocolAction(EditProtocolUIHandler handler) {
+ super(handler, true);
+ }
+
+ /**
+ * If the event source is a TuttiScreen, then the screen changes to the source.
+ * Otherwise, the screen changes to the home.
+ */
+ @Override
+ public void doAction() throws Exception {
+ EditProtocolUIModel model = getModel();
+ TuttiUIContext context = getContext();
+
+ PersistenceService persistenceService = context.getPersistenceService();
+
+ TuttiProtocol bean = model.toBean();
+
+ // get the species protocols from the table
+ List<SpeciesProtocol> speciesProtocols = Lists.newArrayList();
+
+ for (EditProtocolSpeciesRowModel row : model.getSpeciesRow()) {
+ if (row.isValid()) {
+ SpeciesProtocol protocol = row.toBean();
+ speciesProtocols.add(protocol);
+ }
+ }
+ bean.setSpecies(speciesProtocols);
+
+ List<SpeciesProtocol> benthosProtocols = Lists.newArrayList();
+
+ for (EditProtocolSpeciesRowModel row : model.getBenthosRow()) {
+ if (row.isValid()) {
+ SpeciesProtocol protocol = row.toBean();
+ benthosProtocols.add(protocol);
+ }
+ }
+ bean.setBenthos(benthosProtocols);
+
+ if (log.isDebugEnabled()) {
+ log.debug("protocol id to save: " + bean.getId());
+ }
+
+ TuttiProtocol saved;
+
+ if (TuttiEntities.isNew(bean)) {
+
+ saved = persistenceService.createProtocol(bean);
+ model.setId(saved.getId());
+ sendMessage(_("tutti.flash.info.protocolCreated", bean.getName()));
+ } else {
+ saved = persistenceService.saveProtocol(bean);
+ sendMessage(_("tutti.flash.info.protocolSaved", bean.getName()));
+ }
+
+ context.setProtocolId(saved.getId());
+
+ model.setModify(false);
+ }
+
+ @Override
+ public void postSuccessAction() {
+ getContext().getMainUI().getHandler().setBodyTitle(
+ EditProtocolUIHandler.getTitle(true));
+ getUI().getSaveWarningContainer().setVisible(false);
+
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveSampleCategoryModelAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/SaveSampleCategoryModelAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveSampleCategoryModelAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveSampleCategoryModelAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,68 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.SampleCategoryModel;
+import fr.ifremer.tutti.ui.swing.content.category.EditSampleCategoryModelUI;
+import fr.ifremer.tutti.ui.swing.content.category.EditSampleCategoryModelUIHandler;
+import fr.ifremer.tutti.ui.swing.content.category.EditSampleCategoryModelUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * To save the sample category model.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.4
+ */
+public class SaveSampleCategoryModelAction extends AbstractTuttiAction<EditSampleCategoryModelUIModel, EditSampleCategoryModelUI, EditSampleCategoryModelUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(SaveSampleCategoryModelAction.class);
+
+ public SaveSampleCategoryModelAction(EditSampleCategoryModelUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ EditSampleCategoryModelUIModel model = getModel();
+
+ SampleCategoryModel bean = model.toBean();
+
+ if (log.isInfoEnabled()) {
+ log.info("Will save sampleCategoryModel: " + bean);
+ }
+ getConfig().setSampleCategoryModel(bean);
+
+ getConfig().save();
+
+ getDataContext().loadSampleCategoryModel(bean);
+
+ model.setModify(false);
+
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectCruiseAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/SelectCruiseAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectCruiseAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectCruiseAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,42 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+
+/**
+ * Opens the cruise selection screen (home).
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class SelectCruiseAction extends AbstractChangeScreenAction {
+
+ public SelectCruiseAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.SELECT_CRUISE);
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectOtherBenthosAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherBenthosAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectOtherBenthosAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectOtherBenthosAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,93 @@
+
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Action to select a benthos which is not in the referent list.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.1
+ */
+public class SelectOtherBenthosAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(SelectOtherBenthosAction.class);
+
+ protected Species selectedSpecies;
+
+ public SelectOtherBenthosAction(EditProtocolUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+ if (result) {
+ EditProtocolUIModel model = getModel();
+
+ List<Species> species = Lists.newArrayList(model.getAllSynonyms());
+
+ selectedSpecies = getHandler().openSelectOtherSpeciesDialog(
+ _("tutti.selectBenthos.title"), species);
+
+ if (log.isInfoEnabled()) {
+ log.info("SelectedBenthos: " + selectedSpecies);
+ }
+ result = selectedSpecies != null;
+ }
+ return result;
+ }
+
+ @Override
+ public void releaseAction() {
+ selectedSpecies = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ String decoratedSynonym = decorate(selectedSpecies);
+ String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId());
+ selectedSpecies = getModel().getAllReferentSpeciesByTaxonId().get(taxonId);
+ String decoratedReferent = decorate(selectedSpecies);
+ sendMessage(_("tutti.flash.info.benthos.replaced", decoratedSynonym, decoratedReferent));
+ getUI().getBenthosComboBox().setSelectedItem(selectedSpecies);
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectOtherSpeciesAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherSpeciesAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectOtherSpeciesAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectOtherSpeciesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,93 @@
+
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUI;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIHandler;
+import fr.ifremer.tutti.ui.swing.content.protocol.EditProtocolUIModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Action to select a species which is not in the referent list.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.1
+ */
+public class SelectOtherSpeciesAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(SelectOtherSpeciesAction.class);
+
+ protected Species selectedSpecies;
+
+ public SelectOtherSpeciesAction(EditProtocolUIHandler handler) {
+ super(handler, false);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+ if (result) {
+ EditProtocolUIModel model = getModel();
+
+ List<Species> species = Lists.newArrayList(model.getAllSynonyms());
+
+ selectedSpecies = getHandler().openSelectOtherSpeciesDialog(
+ _("tutti.selectSpecies.title"), species);
+
+ if (log.isInfoEnabled()) {
+ log.info("SelectedSpecies: " + selectedSpecies);
+ }
+ result = selectedSpecies != null;
+ }
+ return result;
+ }
+
+ @Override
+ public void releaseAction() {
+ selectedSpecies = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ String decoratedSynonym = decorate(selectedSpecies);
+ String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId());
+ selectedSpecies = getModel().getAllReferentSpeciesByTaxonId().get(taxonId);
+ String decoratedReferent = decorate(selectedSpecies);
+ sendMessage(_("tutti.flash.info.species.replaced", decoratedSynonym, decoratedReferent));
+ getUI().getSpeciesComboBox().setSelectedItem(selectedSpecies);
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectSpeciesForBenthosBatchAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/SelectSpeciesForBenthosBatchAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectSpeciesForBenthosBatchAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectSpeciesForBenthosBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,103 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.referential.Species;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.create.CreateBenthosBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.create.CreateBenthosBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.create.CreateBenthosBatchUIModel;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Enable to select a species to the species selected in the protocol.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public class SelectSpeciesForBenthosBatchAction extends AbstractTuttiAction<CreateBenthosBatchUIModel, CreateBenthosBatchUI, CreateBenthosBatchUIHandler> {
+
+ protected List<Species> allSpecies;
+
+ protected List<Species> referentSpecies;
+
+ protected Species selectedSpecies;
+
+ public SelectSpeciesForBenthosBatchAction(CreateBenthosBatchUIHandler handler) {
+ super(handler, false);
+
+ allSpecies = getDataContext().getSpecies();
+ referentSpecies = getDataContext().getReferentSpecies();
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean canContinue = super.prepareAction();
+ if (canContinue) {
+
+ CreateBenthosBatchUIModel model = getModel();
+
+ List<Species> species = Lists.newArrayList(allSpecies);
+ species.removeAll(model.getAvailableSpecies());
+
+ selectedSpecies = getHandler().openAddSpeciesDialog(
+ _("tutti.selectSpecies.title"), species);
+ canContinue = selectedSpecies != null;
+ }
+ return canContinue;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ CreateBenthosBatchUIModel model = getModel();
+
+ List<Species> availableSpecies = Lists.newArrayList(model.getAvailableSpecies());
+
+ if (!selectedSpecies.isReferenceTaxon()) {
+ String decoratedSynonym = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL);
+ List<Species> referents = referentSpecies;
+ Map<String, Species> referentsById = TuttiEntities.splitByTaxonId(referents);
+ String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId());
+ selectedSpecies = referentsById.get(taxonId);
+ String decoratedReferent = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL);
+ sendMessage(_("tutti.flash.info.species.replaced", decoratedSynonym, decoratedReferent));
+ }
+
+ if (!availableSpecies.contains(selectedSpecies)) {
+ availableSpecies.add(selectedSpecies);
+ }
+ model.setAvailableSpecies(availableSpecies);
+ model.setSpecies(selectedSpecies);
+
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectSpeciesForIndividualObservationBatchAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/SelectSpeciesForIndividualObservationBatchAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectSpeciesForIndividualObservationBatchAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectSpeciesForIndividualObservationBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,105 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.referential.Species;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.create.CreateIndividualObservationBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.create.CreateIndividualObservationBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.create.CreateIndividualObservationBatchUIModel;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Enable to select a species to the species selected in the protocol.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.0
+ */
+public class SelectSpeciesForIndividualObservationBatchAction extends AbstractTuttiAction<CreateIndividualObservationBatchUIModel,
+ CreateIndividualObservationBatchUI,
+ CreateIndividualObservationBatchUIHandler> {
+
+ protected List<Species> allSpecies;
+
+ protected List<Species> referentSpecies;
+
+ protected Species selectedSpecies;
+
+ public SelectSpeciesForIndividualObservationBatchAction(CreateIndividualObservationBatchUIHandler handler) {
+ super(handler, false);
+
+ allSpecies = getDataContext().getSpecies();
+ referentSpecies = getDataContext().getReferentSpecies();
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean canContinue = super.prepareAction();
+ if (canContinue) {
+
+ CreateIndividualObservationBatchUIModel model = getModel();
+
+ List<Species> species = Lists.newArrayList(allSpecies);
+ species.removeAll(model.getAvailableSpecies());
+
+ selectedSpecies = getHandler().openAddSpeciesDialog(
+ _("tutti.selectSpecies.title"), species);
+ canContinue = selectedSpecies != null;
+ }
+ return canContinue;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ CreateIndividualObservationBatchUIModel model = getModel();
+
+ List<Species> availableSpecies = Lists.newArrayList(model.getAvailableSpecies());
+
+ if (!selectedSpecies.isReferenceTaxon()) {
+ String decoratedSynonym = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL);
+ List<Species> referents = referentSpecies;
+ Map<String, Species> referentsById = TuttiEntities.splitByTaxonId(referents);
+ String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId());
+ selectedSpecies = referentsById.get(taxonId);
+ String decoratedReferent = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL);
+ sendMessage(_("tutti.flash.info.species.replaced", decoratedSynonym, decoratedReferent));
+ }
+
+ if (!availableSpecies.contains(selectedSpecies)) {
+ availableSpecies.add(selectedSpecies);
+ }
+ model.setAvailableSpecies(availableSpecies);
+ model.setSpecies(selectedSpecies);
+
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectSpeciesForSpeciesBatchAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/SelectSpeciesForSpeciesBatchAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectSpeciesForSpeciesBatchAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SelectSpeciesForSpeciesBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,103 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.referential.Species;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.create.CreateSpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.create.CreateSpeciesBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.create.CreateSpeciesBatchUIModel;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Enable to select a species to the species selected in the protocol.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public class SelectSpeciesForSpeciesBatchAction extends AbstractTuttiAction<CreateSpeciesBatchUIModel, CreateSpeciesBatchUI, CreateSpeciesBatchUIHandler> {
+
+ protected List<Species> allSpecies;
+
+ protected List<Species> referentSpecies;
+
+ protected Species selectedSpecies;
+
+ public SelectSpeciesForSpeciesBatchAction(CreateSpeciesBatchUIHandler handler) {
+ super(handler, false);
+
+ allSpecies = getDataContext().getSpecies();
+ referentSpecies = getDataContext().getReferentSpecies();
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean canContinue = super.prepareAction();
+ if (canContinue) {
+
+ CreateSpeciesBatchUIModel model = getModel();
+
+ List<Species> species = Lists.newArrayList(allSpecies);
+ species.removeAll(model.getAvailableSpecies());
+
+ selectedSpecies = getHandler().openAddSpeciesDialog(
+ _("tutti.selectSpecies.title"), species);
+ canContinue = selectedSpecies != null;
+ }
+ return canContinue;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ CreateSpeciesBatchUIModel model = getModel();
+
+ List<Species> availableSpecies = Lists.newArrayList(model.getAvailableSpecies());
+
+ if (!selectedSpecies.isReferenceTaxon()) {
+ String decoratedSynonym = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL);
+ List<Species> referents = referentSpecies;
+ Map<String, Species> referentsById = TuttiEntities.splitByTaxonId(referents);
+ String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId());
+ selectedSpecies = referentsById.get(taxonId);
+ String decoratedReferent = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL);
+ sendMessage(_("tutti.flash.info.species.replaced", decoratedSynonym, decoratedReferent));
+ }
+
+ if (!availableSpecies.contains(selectedSpecies)) {
+ availableSpecies.add(selectedSpecies);
+ }
+ model.setAvailableSpecies(availableSpecies);
+ model.setSpecies(selectedSpecies);
+
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SendCruiseReportAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SendCruiseReportAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SendCruiseReportAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SendCruiseReportAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,121 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.shared.application.ApplicationTechnicalException;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.service.export.pdf.CatchesPdfExportService;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JOptionPane;
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Opens a file chooser, exports the cruise catches into the selected file and open the default email editor.
+ *
+ * @author kmorin <morin(a)codelutin.com>
+ * @since 1.0
+ */
+public class SendCruiseReportAction extends AbstractMainUITuttiAction {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(SendCruiseReportAction.class);
+
+ protected File file;
+
+ public SendCruiseReportAction(MainUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+
+ Cruise cruise = getDataContext().getCruise();
+ // choose file to export
+ file = saveFile(
+ "exportCruise-" + cruise.getName(),
+ "pdf",
+ _("tutti.sendCruiseReport.title.choose.exportFile"),
+ _("tutti.sendCruiseReport.action.chooseFile"),
+ "^.+\\.pdf$", _("tutti.common.file.pdf")
+ );
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ file = null;
+ super.releaseAction();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Cruise cruise = getDataContext().getCruise();
+ Preconditions.checkNotNull(cruise);
+ Preconditions.checkNotNull(file);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will export cruise " + cruise.getId() +
+ " to file: " + file);
+ }
+
+ // export catches
+ CatchesPdfExportService service =
+ getContext().getGeneratePDFService();
+ service.generateCruisePDFFile(file, cruise.getId(), getConfig().getI18nLocale());
+
+ try {
+
+ TuttiUIUtil.mail(_("tutti.sendCruiseReport.mail.subject", cruise.getName()),
+ _("tutti.sendCruiseReport.mail.body", cruise.getName(), file.getAbsolutePath()));
+
+ } catch (ApplicationTechnicalException e) {
+ JOptionPane.showMessageDialog(getContext().getMainUI(),
+ _("tutti.sendCruiseReport.action.error.mail.message", file),
+ _("tutti.sendCruiseReport.action.error.mail.title"),
+ JOptionPane.WARNING_MESSAGE);
+ }
+
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ sendMessage(_("tutti.sendCruiseReport.action.success", file));
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ShowAboutAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ShowAboutAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ShowAboutAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,304 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import fr.ifremer.tutti.TuttiConfiguration;
+import fr.ifremer.tutti.ui.swing.TuttiApplicationUpdaterCallBack;
+import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
+import fr.ifremer.tutti.ui.swing.TuttiReportUpdaterCallBack;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import jaxx.runtime.swing.AboutPanel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.updater.ApplicationInfo;
+import org.nuiton.updater.ApplicationUpdater;
+
+import javax.swing.JEditorPane;
+import javax.swing.JScrollPane;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+import java.io.File;
+import java.net.URL;
+import java.util.Calendar;
+import java.util.List;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To show about panel.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public class ShowAboutAction extends AbstractMainUITuttiAction {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ShowAboutAction.class);
+
+ protected AboutPanel about;
+
+ public ShowAboutAction(MainUIHandler handler) {
+ super(handler, false);
+ }
+
+ protected boolean canUpdateApplication;
+
+ protected boolean canUpdateData;
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+ // check db url is reachable
+ TuttiUIContext context = getContext();
+ canUpdateApplication = context.checkUpdateApplicationReachable();
+ canUpdateData = context.checkUpdateDataReachable();
+
+ }
+
+ return doAction;
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ about.showInDialog(getUI(), true);
+
+ // register on swing session
+ getContext().getSwingSession().add(about);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ about = null;
+
+ String iconPath = "/icons/allegro_about.png";
+ String name = "tutti";
+ String licensePath = "META-INF/" + name + "-LICENSE.txt";
+ String thirdPartyPath = "META-INF/" + name + "-THIRD-PARTY.txt";
+
+ about = new AboutPanel();
+ about.setTitle(_("tutti.about.title"));
+ about.setAboutText(_("tutti.about.message"));
+
+ TuttiConfiguration config = getConfig();
+ int currentYear = Calendar.getInstance().get(Calendar.YEAR);
+ int inceptionYear = config.getInceptionYear();
+ String years;
+ if (currentYear != inceptionYear) {
+ years = inceptionYear + "-" + currentYear;
+ } else {
+ years = inceptionYear + "";
+ }
+
+ about.setBottomText(_("tutti.about.bottomText",
+ config.getOrganizationName(),
+ years,
+ config.getVersion()));
+ about.setIconPath(iconPath);
+ about.setLicenseFile(licensePath);
+ about.setThirdpartyFile(thirdPartyPath);
+ about.buildTopPanel();
+
+ //
+ // translate tab
+ //
+
+ JScrollPane translatePane = new JScrollPane();
+ JEditorPane translateArea = new JEditorPane();
+ translateArea.setContentType("text/html");
+ translateArea.setEditable(false);
+ if (translateArea.getFont() != null) {
+ translateArea.setFont(translateArea.getFont().deriveFont((float) 11));
+ }
+
+ translateArea.setBorder(null);
+ File csvFile = new File(config.getI18nDirectory(), "tutti-i18n.csv");
+ String translateText = _("tutti.about.translate.content", csvFile.toURI().toURL());
+ translateArea.setText(translateText);
+ translatePane.getViewport().add(translateArea);
+ translateArea.addHyperlinkListener(new HyperlinkListener() {
+ @Override
+ public void hyperlinkUpdate(HyperlinkEvent e) {
+ if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) {
+ URL url = e.getURL();
+ if (log.isInfoEnabled()) {
+ log.info("edit url: " + url);
+ }
+ TuttiUIUtil.openLink(url);
+ }
+ }
+ });
+
+ about.getTabs().add(_("tutti.about.translate.title"), translatePane);
+
+ if (canUpdateApplication || canUpdateData) {
+
+ //
+ // update tab
+ //
+
+ addUpdateTab(config);
+
+ }
+ about.init();
+ }
+
+ protected void addUpdate(Map<String, ApplicationInfo> source,
+ Map<String, ApplicationInfo> target,
+ String type) {
+ ApplicationInfo info = source.get(type.toLowerCase());
+ target.put(type, info);
+ }
+
+ protected void addUpdateTab(TuttiConfiguration config) {
+ File current = config.getBasedir();
+ String urlApplication = config.getUpdateApplicationUrl();
+ String urlData = config.getUpdateDataUrl();
+
+ ApplicationUpdater up = new ApplicationUpdater();
+
+ // create final update map
+ final Map<String, ApplicationInfo> versions = Maps.newLinkedHashMap();
+
+ if (canUpdateApplication) {
+
+ // get application updates
+ Map<String, ApplicationInfo> applicationVersions = up.getVersions(urlApplication, current);
+
+ addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.JRE.name());
+ addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.TUTTI.name());
+ addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.I18N.name());
+ addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.HELP.name());
+ }
+
+ if (canUpdateData) {
+
+ // get report updates
+ Map<String, ApplicationInfo> reportVersions = up.getVersions(urlData, current);
+ addUpdate(reportVersions, versions, TuttiReportUpdaterCallBack.REPORT_UPDATE_NAME);
+
+ // get db updates
+ Map<String, ApplicationInfo> dbVersions = up.getVersions(urlData, config.getDataDirectory());
+ addUpdate(dbVersions, versions, TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
+ }
+ JScrollPane updatePane = new JScrollPane();
+ JEditorPane updateArea = new JEditorPane();
+ updateArea.setContentType("text/html");
+ updateArea.setEditable(false);
+ if (updateArea.getFont() != null) {
+ updateArea.setFont(updateArea.getFont().deriveFont((float) 11));
+ }
+ updateArea.setBorder(null);
+
+ List<String> params = Lists.newArrayList();
+ for (Map.Entry<String, ApplicationInfo> entry : versions.entrySet()) {
+ String appName = entry.getKey();
+ ApplicationInfo info = entry.getValue();
+ String oldVersion = info.oldVersion;
+ String newVersion = info.newVersion;
+ String i18nKey = "tutti.update." + appName.toLowerCase();
+ String appLabel = _(i18nKey);
+
+ if (log.isInfoEnabled()) {
+ log.info(String.format(
+ "Module %s, version courante %s, nouvelle version %s",
+ appLabel, oldVersion, newVersion));
+ }
+ if (newVersion == null) {
+
+ // no update
+ params.add(_("tutti.about.update.app.noup.detail", appLabel, oldVersion));
+ } else {
+ // update exists
+ params.add(_("tutti.about.update.app.up.detail", appLabel, oldVersion, newVersion, appName));
+ }
+ }
+
+ String updateText = _("tutti.about.update.content", urlApplication, urlData, Joiner.on("\n").join(params));
+ updateArea.setText(updateText);
+ updatePane.getViewport().add(updateArea);
+ updateArea.addHyperlinkListener(new HyperlinkListener() {
+ @Override
+ public void hyperlinkUpdate(HyperlinkEvent e) {
+ if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) {
+ URL url = e.getURL();
+ if (url != null) {
+ TuttiUIUtil.openLink(url);
+ } else {
+ String appType = e.getDescription();
+
+
+ if (log.isInfoEnabled()) {
+ log.info("Open url: " + appType);
+ }
+ AbstractTuttiAction action;
+
+ if (TuttiDbUpdaterCallBack.DB_UPDATE_NAME.equals(appType)) {
+ UpdateDbAction logicAction = getContext().getActionFactory().createLogicAction(getHandler(), UpdateDbAction.class);
+ action = logicAction;
+ if (!getContext().isDbExist()) {
+
+ // install db
+ action.setActionDescription(
+ _("tutti.dbManager.action.installDb.tip"));
+ }
+ } else if (TuttiReportUpdaterCallBack.REPORT_UPDATE_NAME.equals(appType)) {
+ UpdateReportAction logicAction = getContext().getActionFactory().createLogicAction(getHandler(), UpdateReportAction.class);
+ action = logicAction;
+ } else {
+
+ TuttiApplicationUpdaterCallBack.UpdateType updateType =
+ TuttiApplicationUpdaterCallBack.UpdateType.valueOf(appType.toUpperCase());
+
+ UpdateApplicationAction logicAction = getContext().getActionFactory().createLogicAction(getHandler(), UpdateApplicationAction.class);
+ logicAction.setTypes(updateType);
+ logicAction.setActionDescription(_("tutti.main.action.updateSpecificApplication.tip", updateType.getLabel()));
+ action = logicAction;
+ }
+
+ // close this dialog
+ getActionEngine().runAction(about.getClose());
+
+ // do update
+ getActionEngine().runAction(action);
+ }
+
+ }
+ }
+ });
+ about.getTabs().add(_("tutti.about.update.title"), updatePane);
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ShowConfigAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowConfigAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ShowConfigAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ShowConfigAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,41 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+
+/**
+ * To show config screen.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.1
+ */
+public class ShowConfigAction extends AbstractChangeScreenAction {
+
+ public ShowConfigAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.CONFIG);
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ShowReportAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowReportAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ShowReportAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ShowReportAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,54 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * To show report screen.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.9
+ */
+public class ShowReportAction extends AbstractChangeScreenAction {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ShowReportAction.class);
+
+ public ShowReportAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.REPORT);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ if (log.isDebugEnabled()) {
+ log.debug("Show report screen");
+ }
+ super.doAction();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/StartAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/StartAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/StartAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/StartAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,173 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.shared.application.ApplicationIOUtil;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Start action.
+ * <p/>
+ * If there is a start action file, then load it and run inside actions, otherwise
+ * just starts normal ui action (open db if exists, or go to manage db screen).
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.4
+ */
+public class StartAction extends AbstractMainUITuttiAction {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(StartAction.class);
+
+ protected AbstractMainUITuttiAction delegateAction;
+
+ public StartAction(MainUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+
+ File actionfile = getConfig().getStartActionFile();
+ boolean doAction = actionfile.exists();
+
+ if (doAction) {
+
+ try {
+ // get action to execute
+ String content = ApplicationIOUtil.readContent(actionfile, _("tutti.error.read.startActionFile", actionfile));
+ content = content.trim();
+
+ if (InstallDbAction.class.getName().equals(content)) {
+
+ // install db
+ delegateAction = getContext().getActionFactory().createLogicAction(handler, InstallDbAction.class);
+
+ if (log.isInfoEnabled()) {
+ log.info("Found install db action");
+ }
+ deleteOldDatabaseDirectory();
+
+ } else if (content.startsWith(ImportDbAction.class.getName())) {
+
+ // import db
+ ImportDbAction action = getContext().getActionFactory().createLogicAction(handler, ImportDbAction.class);
+ File importFile = new File(content.substring(ImportDbAction.class.getName().length() + 1));
+ action.setImportFile(importFile);
+ delegateAction = action;
+ if (log.isInfoEnabled()) {
+ log.info("Found import db action (with file " + importFile + ")");
+ }
+ deleteOldDatabaseDirectory();
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("Unknown start action: " + content);
+ }
+ doAction = false;
+ }
+
+ } finally {
+
+ // delete start action file
+ ApplicationIOUtil.deleteFile(
+ actionfile,
+ _("tutti.error.delete.startActionFile", actionfile));
+ }
+ }
+
+ if (!doAction) {
+
+ // no start action, normal start
+
+ TuttiUIContext context = getContext();
+
+ if (context.isDbLoaded()) {
+
+ // db already opened (happens when reloading ui)
+ // just go to select cruise screen
+ SelectCruiseAction action = getContext().getActionFactory().createLogicAction(handler, SelectCruiseAction.class);
+ action.setSkipCheckCurrentScreen(true);
+ action.setActionDescription(getUI().getMenuActionSelectCruise().getToolTipText());
+ delegateAction = action;
+
+ } else {
+
+ if (context.isDbExist()) {
+
+ // open tutti db (using a fake button to have simple api)
+ OpenDbAction action = getContext().getActionFactory().createLogicAction(handler, OpenDbAction.class);
+ action.setSkipCheckCurrentScreen(true);
+ action.setUpdateReferentiel(true);
+ delegateAction = action;
+
+ } else {
+
+ // clean db context
+ context.clearDbContext();
+
+ // go to manage db screen (to install db)
+ ManageDbAction action = getContext().getActionFactory().createLogicAction(handler, ManageDbAction.class);
+ action.setSkipCheckCurrentScreen(true);
+ delegateAction = action;
+ }
+ }
+ }
+
+ setActionDescription(delegateAction.getActionDescription());
+ doAction = delegateAction.prepareAction();
+ return doAction;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ getActionEngine().runInternalAction(delegateAction);
+ }
+
+ @Override
+ protected void releaseAction() {
+ delegateAction = null;
+ super.releaseAction();
+ }
+
+ protected void deleteOldDatabaseDirectory() {
+ File dbDirectory = getConfig().getDbDirectory();
+ if (dbDirectory.exists()) {
+
+ // delete it before install
+ if (log.isInfoEnabled()) {
+ log.info("Delete previous database directory: " + dbDirectory);
+ }
+ ApplicationIOUtil.deleteDirectory(dbDirectory, "Could not delete old db directory");
+ }
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/UpdateApplicationAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/UpdateApplicationAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/UpdateApplicationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,167 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.TuttiConfiguration;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.ui.swing.RunTutti;
+import fr.ifremer.tutti.ui.swing.TuttiApplicationUpdaterCallBack;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.MainUI;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.updater.ApplicationUpdater;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To update jre / i18n or tutti using the {@link ApplicationUpdater} mecanism.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class UpdateApplicationAction extends AbstractTuttiAction<TuttiUIContext, MainUI, MainUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(UpdateApplicationAction.class);
+
+ public UpdateApplicationAction(MainUIHandler handler) {
+ super(handler, true);
+ setActionDescription(_("tutti.main.action.updateApplication.tip"));
+ types = TuttiApplicationUpdaterCallBack.UpdateType.values();
+ }
+
+ protected TuttiApplicationUpdaterCallBack.UpdateType[] types;
+
+ protected boolean reload;
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+ // check application url is reachable
+ TuttiUIContext context = getContext();
+ doAction = context.checkUpdateApplicationReachable();
+ }
+ return doAction;
+ }
+
+ @Override
+ public void releaseAction() {
+ super.releaseAction();
+ types = TuttiApplicationUpdaterCallBack.UpdateType.values();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ reload = false;
+
+ TuttiUIContext context = getContext();
+ TuttiConfiguration config = getConfig();
+
+ File current = config.getBasedir();
+ if (current == null || !current.exists()) {
+
+ // can not update application
+ if (log.isWarnEnabled()) {
+ log.warn("No application base directory defined, skip updates.");
+ }
+ } else {
+
+ String url = config.getUpdateApplicationUrl();
+ File dest = new File(config.getBasedir(), "NEW");
+
+ if (log.isInfoEnabled()) {
+ log.info(String.format("Try to update jre, i18N, help or tutti (current application location: %s), using update url: %s", current, url));
+ }
+
+ ProgressionModel progressionModel = new ProgressionModel();
+ context.getActionUI().getModel().setProgressionModel(progressionModel);
+ progressionModel.setMessage(_("tutti.updateApplication.checkUpdates"));
+
+ TuttiApplicationUpdaterCallBack callback =
+ new TuttiApplicationUpdaterCallBack(this, progressionModel);
+
+ callback.setTypes(types);
+
+ ApplicationUpdater up = new ApplicationUpdater();
+ up.update(url,
+ current,
+ dest,
+ false,
+ callback,
+ progressionModel);
+
+ if (callback.isApplicationUpdated()) {
+
+ reload = true;
+
+ } else {
+
+ sendMessage(_("tutti.updateApplication.noUpdate"));
+ }
+ }
+ }
+
+ public void setTypes(TuttiApplicationUpdaterCallBack.UpdateType... types) {
+ this.types = types;
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ if (reload) {
+ // wait 1 second to be sure action ui is up
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ if (log.isWarnEnabled()) {
+ log.warn("Could not wait 1 second...", e);
+ }
+ }
+
+ // tell user restart will be done
+
+ getHandler().showSuccessMessage(_("tutti.updateApplication.title.success"),
+ _("tutti.updateApplication.message.success"));
+
+ CloseApplicationAction action = getContext().getActionFactory().createLogicAction(
+ getHandler(), CloseApplicationAction.class);
+ action.setExitCode(RunTutti.UPATE_EXIT_CODE);
+ getActionEngine().runAction(action);
+ }
+ }
+
+ public boolean isReload() {
+ return reload;
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/UpdateDbAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/UpdateDbAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/UpdateDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,154 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.TuttiConfiguration;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.updater.ApplicationInfo;
+import org.nuiton.updater.ApplicationUpdater;
+
+import javax.swing.JOptionPane;
+import java.io.File;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To update - install database.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class UpdateDbAction extends AbstractMainUITuttiAction {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(UpdateDbAction.class);
+
+ protected ApplicationInfo updateDbVersion;
+
+ public UpdateDbAction(MainUIHandler handler) {
+ super(handler, true);
+ setActionDescription(_("tutti.dbManager.action.upgradeDb.tip"));
+ }
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean doAction = super.prepareAction();
+
+ updateDbVersion = null;
+
+ if (doAction) {
+ // check db url is reachable
+ doAction = getContext().checkUpdateDataReachable();
+ }
+
+ if (doAction) {
+
+ // get the next db version
+ ApplicationUpdater up = new ApplicationUpdater();
+
+ // get db updates
+ Map<String, ApplicationInfo> dbVersions =
+ up.getVersions(getConfig().getUpdateDataUrl(),
+ getConfig().getDataDirectory());
+ updateDbVersion =
+ dbVersions.get(TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
+
+ if (getContext().isDbExist() &&
+ updateDbVersion != null &&
+ updateDbVersion.newVersion != null) {
+
+ // ask user if it wants to do the update
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ _("tutti.dbManager.updatedb.found", updateDbVersion.newVersion),
+ _("tutti.common.askBeforeUpdate.help"));
+ int i = JOptionPane.showConfirmDialog(
+ getHandler().getUI(),
+ htmlMessage,
+ _("tutti.dbManager.title.confirm.updatedb"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+
+ doAction = i == JOptionPane.OK_OPTION;
+ }
+ }
+ return doAction;
+ }
+
+ @Override
+ public void doAction() {
+ TuttiUIContext context = getContext();
+ TuttiConfiguration config = getConfig();
+
+ File current = config.getDataDirectory();
+ String url = config.getUpdateDataUrl();
+
+ if (log.isInfoEnabled()) {
+ log.info(String.format("Try to install / update db (current data location: %s), using update url: %s", current, url));
+ }
+
+ File dest = new File(config.getBasedir(), "NEW");
+ ProgressionModel progressionModel = new ProgressionModel();
+ context.getActionUI().getModel().setProgressionModel(progressionModel);
+ progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.check"));
+ TuttiDbUpdaterCallBack callback =
+ new TuttiDbUpdaterCallBack(this, progressionModel);
+ ApplicationUpdater up = new ApplicationUpdater();
+
+ up.update(url,
+ current,
+ dest,
+ false,
+ callback,
+ progressionModel);
+
+ if (callback.isDbUpdated()) {
+
+ sendMessage(_("tutti.dbManager.action.upgradeDb.done", updateDbVersion.newVersion));
+
+ } else {
+ sendMessage(_("tutti.dbManager.action.upgradeDb.upToDate"));
+ }
+ }
+
+ @Override
+ public void postSuccessAction() {
+ handler.reloadDbManagerText();
+ super.postSuccessAction();
+ }
+
+ @Override
+ public void postFailedAction(Throwable error) {
+ handler.reloadDbManagerText();
+ super.postFailedAction(error);
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/UpdateReportAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateReportAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/UpdateReportAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/UpdateReportAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,152 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.TuttiConfiguration;
+import fr.ifremer.tutti.persistence.ProgressionModel;
+import fr.ifremer.tutti.ui.swing.RunTutti;
+import fr.ifremer.tutti.ui.swing.TuttiReportUpdaterCallBack;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.MainUI;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.updater.ApplicationUpdater;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To update reports using the {@link ApplicationUpdater} mecanism.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class UpdateReportAction extends AbstractTuttiAction<TuttiUIContext, MainUI, MainUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(UpdateReportAction.class);
+
+ public UpdateReportAction(MainUIHandler handler) {
+ super(handler, true);
+ setActionDescription(_("tutti.main.action.updateReport.tip"));
+ }
+
+ protected boolean reload;
+
+ @Override
+ public boolean prepareAction() throws Exception {
+ boolean doAction = super.prepareAction();
+
+ if (doAction) {
+ // check data url is reachable
+ TuttiUIContext context = getContext();
+ doAction = context.checkUpdateDataReachable();
+ }
+ return doAction;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ reload = false;
+
+ TuttiUIContext context = getContext();
+ TuttiConfiguration config = getConfig();
+
+ File current = config.getBasedir();
+ if (current == null || !current.exists()) {
+
+ // can not update application
+ if (log.isWarnEnabled()) {
+ log.warn("No application base directory defined, skip updates.");
+ }
+ } else {
+
+ String url = config.getUpdateDataUrl();
+ File dest = new File(config.getBasedir(), "NEW");
+
+ if (log.isInfoEnabled()) {
+ log.info(String.format("Try to update repport (current application location: %s), using update url: %s", current, url));
+ }
+
+ ProgressionModel progressionModel = new ProgressionModel();
+ context.getActionUI().getModel().setProgressionModel(progressionModel);
+ progressionModel.setMessage(_("tutti.updateApplication.checkUpdates"));
+
+ TuttiReportUpdaterCallBack callback =
+ new TuttiReportUpdaterCallBack(this, progressionModel);
+
+ ApplicationUpdater up = new ApplicationUpdater();
+ up.update(url,
+ current,
+ dest,
+ false,
+ callback,
+ progressionModel);
+
+ if (callback.isReportUpdated()) {
+
+ reload = true;
+
+ } else {
+
+ sendMessage(_("tutti.updateReport.noUpdate"));
+ }
+ }
+ }
+
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+
+ if (reload) {
+ // wait 1 second to be sure action ui is up
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ if (log.isWarnEnabled()) {
+ log.warn("Could not wait 1 second...", e);
+ }
+ }
+
+ // tell user restart will be done
+
+ getHandler().showSuccessMessage(_("tutti.updateReport.title.success"),
+ _("tutti.updateReport.message.success"));
+
+ CloseApplicationAction action = getContext().getActionFactory().createLogicAction(
+ getHandler(), CloseApplicationAction.class);
+ action.setExitCode(RunTutti.UPATE_EXIT_CODE);
+ getActionEngine().runAction(action);
+ }
+ }
+
+ public boolean isReload() {
+ return reload;
+ }
+}
\ No newline at end of file
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ValidateCatchesAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ValidateCatchesAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ValidateCatchesAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ValidateCatchesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,60 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.service.ValidationService;
+import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Opens the operations validation screen.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ValidateCatchesAction extends AbstractChangeScreenAction {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ValidateCatchesAction.class);
+
+ public ValidateCatchesAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.VALIDATE_CRUISE);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkState(getContext().isProgramFilled());
+ Preconditions.checkState(getContext().isCruiseFilled());
+ getContext().setValidationContext(ValidationService.VALIDATION_CONTEXT_VALIDATE);
+ if (log.isInfoEnabled()) {
+ log.info("Validate operations of cruise: " + getContext().getCruiseId());
+ }
+ super.doAction();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ValidateSelectedCruiseCatchesAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ValidateSelectedCruiseCatchesAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ValidateSelectedCruiseCatchesAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ValidateSelectedCruiseCatchesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,59 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.service.ValidationService;
+import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Opens the operations validation screen to edit the selected operations.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ValidateSelectedCruiseCatchesAction extends AbstractChangeScreenAction {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ValidateSelectedCruiseCatchesAction.class);
+
+ public ValidateSelectedCruiseCatchesAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.VALIDATE_CRUISE);
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ Preconditions.checkState(getContext().isCruiseFilled());
+ getContext().setValidationContext(ValidationService.VALIDATION_CONTEXT_VALIDATE);
+ if (log.isInfoEnabled()) {
+ log.info("Validate operations of cruise: " + getContext().getCruiseId());
+ }
+ super.doAction();
+ }
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ViewGearCaracteristicsAction.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ViewGearCaracteristicsAction.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ViewGearCaracteristicsAction.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ViewGearCaracteristicsAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,82 @@
+package fr.ifremer.tutti.ui.swing.action;
+
+/*
+ * #%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.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrder;
+import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrders;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUI;
+import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUIHandler;
+import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUIModel;
+import fr.ifremer.tutti.ui.swing.content.cruise.GearCaracteristicsEditorUI;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.1
+ */
+public class ViewGearCaracteristicsAction extends AbstractTuttiAction<EditCruiseUIModel, EditCruiseUI, EditCruiseUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(ViewGearCaracteristicsAction.class);
+
+ protected final PersistenceService persistenceService;
+
+ public ViewGearCaracteristicsAction(EditCruiseUIHandler handler) {
+ super(handler, false);
+ persistenceService = getContext().getPersistenceService();
+ }
+
+ @Override
+ public void doAction() throws Exception {
+ GearCaracteristicsEditorUI editor = getUI().getGearCaracteristicsEditor();
+ editor.getModel().setEditable(false);
+
+ GearWithOriginalRankOrder gear =
+ EditCruiseUIHandler.GEAR_EDIT_CONTEXT.getContextValue(getUI());
+
+ CaracteristicMap caracteristics =
+ persistenceService.getGearCaracteristics(
+ getDataContext().getCruise().getId(),
+ gear.getId(),
+ gear.getOriginalRankOrder());
+
+ GearWithOriginalRankOrder gearToEdit =
+ GearWithOriginalRankOrders.newGearWithOriginalRankOrder(gear);
+ gearToEdit.setCaracteristics(caracteristics);
+
+ if (log.isInfoEnabled()) {
+ log.info("Will edit gear " + decorate(gearToEdit) +
+ " with " + gearToEdit.getCaracteristics().size() + " caracteristics.");
+ }
+
+ editor.getModel().setGear(gearToEdit);
+
+ getUI().getMainPanelLayout().setSelected(EditCruiseUIHandler.GEAR_CARACTERISTICS_CARD);
+ }
+}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractChangeLocaleAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractChangeLocaleAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractChangeLocaleAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,49 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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 java.util.Locale;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0.3
- */
-public abstract class AbstractChangeLocaleAction extends AbstractChangeScreenAction {
-
-
- protected AbstractChangeLocaleAction(MainUIHandler handler) {
- super(handler, true, null);
- }
-
- protected abstract Locale getLocale();
-
- @Override
- public void doAction() throws Exception {
-
- getHandler().changeLocale(getLocale());
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractChangeScreenAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractChangeScreenAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractChangeScreenAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,117 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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.ui.swing.TuttiScreen;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import jaxx.runtime.SwingUtil;
-import jaxx.runtime.context.JAXXContextEntryDef;
-
-/**
- * Action to change the screen.
- * <p/>
- * Will just check that the current screen can be quit via
- * the {@link MainUIHandler#quitCurrentScreen()}.
- * <p/>
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.0
- */
-public abstract class AbstractChangeScreenAction extends AbstractMainUITuttiAction {
-
- /**
- * Context entry to keep previous screen.
- *
- * @since 1.1
- */
- protected static final JAXXContextEntryDef<TuttiScreen> PREVIOUS_SCREEN =
- SwingUtil.newContextEntryDef("previousScreen", TuttiScreen.class);
-
- /**
- * Screen where to go.
- *
- * @since 1.0
- */
- protected TuttiScreen screen;
-
- /**
- * Flag to skip the check of current screen.
- *
- * @since 1.1
- */
- protected boolean skipCheckCurrentScreen;
-
- protected AbstractChangeScreenAction(MainUIHandler handler,
- boolean hideBody,
- TuttiScreen screen) {
- super(handler, hideBody);
- this.screen = screen;
- }
-
- public void setSkipCheckCurrentScreen(boolean skipCheckCurrentScreen) {
- this.skipCheckCurrentScreen = skipCheckCurrentScreen;
- }
-
- protected void setScreen(TuttiScreen screen) {
- this.screen = screen;
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
- result &= skipCheckCurrentScreen || getHandler().quitCurrentScreen();
- return result;
- }
-
- @Override
- public void doAction() throws Exception {
-
- TuttiUIContext context = getContext();
-
- TuttiScreen previousScreen = context.getScreen();
- if (getUI() != null) {
- if (previousScreen == null) {
- PREVIOUS_SCREEN.removeContextValue(getUI());
- } else {
- PREVIOUS_SCREEN.setContextValue(getUI(), previousScreen);
- }
- }
-
- // clean current screen
- context.setScreen(null);
-
- // change screen
- context.setScreen(screen);
- }
-
- @Override
- public void postFailedAction(Throwable error) {
- if (error != null) {
-
- getContext().setFallBackScreen();
- }
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractMainUITuttiAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractMainUITuttiAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/AbstractMainUITuttiAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,40 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public abstract class AbstractMainUITuttiAction extends AbstractTuttiAction<TuttiUIContext, MainUI, MainUIHandler> {
-
- protected AbstractMainUITuttiAction(MainUIHandler handler,
- boolean hideBody) {
- super(handler, hideBody);
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ChangeToLocaleFRAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ChangeToLocaleFRAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ChangeToLocaleFRAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,44 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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 java.util.Locale;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0.3
- */
-public class ChangeToLocaleFRAction extends AbstractChangeLocaleAction {
-
- public ChangeToLocaleFRAction(MainUIHandler handler) {
- super(handler);
- }
-
- @Override
- protected Locale getLocale() {
- return Locale.FRANCE;
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ChangeToLocaleUKAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ChangeToLocaleUKAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ChangeToLocaleUKAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,43 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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 java.util.Locale;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0.3
- */
-public class ChangeToLocaleUKAction extends AbstractChangeLocaleAction {
-
- public ChangeToLocaleUKAction(MainUIHandler handler) {
- super(handler);
- }
-
- @Override
- protected Locale getLocale() {
- return Locale.UK;
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/CloseApplicationAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/CloseApplicationAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/CloseApplicationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,65 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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.ui.swing.RunTutti;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To close Tutti Application.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.1
- */
-public class CloseApplicationAction extends AbstractChangeScreenAction {
-
- protected int exitCode = RunTutti.NORMAL_EXIT_CODE;
-
- public CloseApplicationAction(MainUIHandler handler) {
- super(handler, false, null);
- setSkipCheckCurrentScreen(true);
- setActionDescription(_("tutti.main.action.exit.tip"));
- }
-
- public void setExitCode(int exitCode) {
- this.exitCode = exitCode;
- }
-
- @Override
- public void doAction() throws Exception {
-
- super.doAction();
-
- RunTutti.closeTutti(getHandler(), exitCode);
- }
-
-
- @Override
- public void releaseAction() {
- exitCode = RunTutti.NORMAL_EXIT_CODE;
- super.releaseAction();
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,56 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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.ui.swing.TuttiScreen;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To show {@link TuttiScreen#EDIT_SAMPLE_CATEGORY_MODEL} config screen.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.4
- */
-public class EditSampleCategoryModelAction extends AbstractChangeScreenAction {
-
- public EditSampleCategoryModelAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.EDIT_SAMPLE_CATEGORY_MODEL);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
- if (result) {
- result = askAdminPassword(
- _("tutti.editSampleCategoryModel.passwordDialog.message"),
- _("tutti.editSampleCategoryModel.passwordDialog.title"),
- _("tutti.editSampleCategoryModel.passwordDialog.error.message"),
- _("tutti.editSampleCategoryModel.passwordDialog.error.title")
- );
- }
- return result;
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedCruiseAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedCruiseAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedCruiseAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,56 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Opens the cruise edition screen to edit the selected cruise.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class EditSelectedCruiseAction extends AbstractChangeScreenAction {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(EditSelectedCruiseAction.class);
-
- public EditSelectedCruiseAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.EDIT_CRUISE);
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkState(getContext().isCruiseFilled());
- if (log.isInfoEnabled()) {
- log.info("Edit cruise: " + getContext().getCruiseId());
- }
- super.doAction();
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedCruiseCatchesAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedCruiseCatchesAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedCruiseCatchesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,59 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.service.ValidationService;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Opens the operations edition screen to edit the selected operations.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class EditSelectedCruiseCatchesAction extends AbstractChangeScreenAction {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(EditSelectedCruiseCatchesAction.class);
-
- public EditSelectedCruiseCatchesAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.EDIT_FISHING_OPERATION);
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkState(getContext().isCruiseFilled());
- if (log.isInfoEnabled()) {
- log.info("Edit operations of cruise: " + getContext().getCruiseId());
- }
- getContext().setValidationContext(ValidationService.VALIDATION_CONTEXT_EDIT);
- super.doAction();
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedProgramAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedProgramAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedProgramAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,56 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Opens the program edition screen to edit the selected program.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class EditSelectedProgramAction extends AbstractChangeScreenAction {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(EditSelectedProgramAction.class);
-
- public EditSelectedProgramAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.EDIT_PROGRAM);
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkState(getContext().isProgramFilled());
- if (log.isInfoEnabled()) {
- log.info("Edit program: " + getContext().getProgramId());
- }
- super.doAction();
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedProtocolAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedProtocolAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSelectedProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,58 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Opens the protocol edition screen to edit the selected protocol.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class EditSelectedProtocolAction extends AbstractChangeScreenAction {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(EditSelectedProtocolAction.class);
-
- public EditSelectedProtocolAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.EDIT_PROTOCOL);
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkState(getContext().isProtocolFilled());
- if (log.isDebugEnabled()) {
- log.debug("Edit protocol: " + getContext().getProtocolId());
- }
- createProgressionModelIfRequired(4);
- super.doAction();
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/GoToPreviousScreenAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/GoToPreviousScreenAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/GoToPreviousScreenAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,44 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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 static org.nuiton.i18n.I18n._;
-
-/**
- * To return on previous screen.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.1
- */
-public class GoToPreviousScreenAction extends AbstractChangeScreenAction {
-
- public GoToPreviousScreenAction(MainUIHandler handler) {
- super(handler,
- true,
- PREVIOUS_SCREEN.getContextValue(handler.getUI())
- );
- setActionDescription(_("tutti.main.action.goto.previousScreen.tip"));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ImportTemporaryReferentialAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ImportTemporaryReferentialAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ImportTemporaryReferentialAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,70 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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.ui.swing.TuttiScreen;
-
-import javax.swing.SwingUtilities;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Open screen to import referential
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ImportTemporaryReferentialAction extends AbstractChangeScreenAction {
-
- public ImportTemporaryReferentialAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.IMPORT_TEMPORARY_REFERENTIAL);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
- if (result) {
- result = askAdminPassword(
- _("tutti.manageTemporaryReferential.passwordDialog.message"),
- _("tutti.manageTemporaryReferential.passwordDialog.title"),
- _("tutti.manageTemporaryReferential.passwordDialog.error.message"),
- _("tutti.manageTemporaryReferential.passwordDialog.error.title")
- );
- }
- return result;
- }
-
- @Override
- public void doAction() throws Exception {
- super.doAction();
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- getContext().getMainUI().getBody().revalidate();
- }
- });
-
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -48,7 +48,7 @@
toolTipText: "tutti.main.action.configuration.tip";
i18nMnemonic: "tutti.main.action.configuration.mnemonic";
enabled: {model.getScreen() != TuttiScreen.CONFIG};
- _applicationAction: {ShowConfigAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ShowConfigAction.class};
_help: {"tutti.main.menu.action.configuration.help"};
}
@@ -58,7 +58,7 @@
toolTipText: "tutti.main.action.editSampleCategoryModel.tip";
i18nMnemonic: "tutti.main.action.editSampleCategoryModel.mnemonic";
enabled: {model.getScreen() != TuttiScreen.EDIT_SAMPLE_CATEGORY_MODEL};
- _applicationAction: {EditSampleCategoryModelAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.EditSampleCategoryModelAction.class};
_help: {"tutti.main.menu.action.editSampleCategoryModel.help"};
}
@@ -68,7 +68,7 @@
toolTipText: "tutti.main.action.report.tip";
i18nMnemonic: "tutti.main.action.report.mnemonic";
enabled: {model.getScreen() != TuttiScreen.REPORT};
- _applicationAction: {ShowReportAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ShowReportAction.class};
_help: {"tutti.main.menu.action.report.help"};
}
@@ -77,7 +77,7 @@
text: "tutti.main.action.exit";
toolTipText: "tutti.main.action.exit.tip";
i18nMnemonic: "tutti.main.action.exit.mnemonic";
- _applicationAction: {CloseApplicationAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.CloseApplicationAction.class};
_help: {"tutti.main.menu.action.exit.help"};
}
@@ -86,7 +86,7 @@
text: "tutti.main.action.updateApplication";
toolTipText: "tutti.main.action.updateApplication.tip";
i18nMnemonic: "tutti.main.action.updateApplication.mnemonic";
- _applicationAction: {UpdateApplicationAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.UpdateApplicationAction.class};
_help: {"tutti.main.menu.action.updateApplication.help"};
}
@@ -95,7 +95,7 @@
text: "tutti.main.action.updateReport";
toolTipText: "tutti.main.action.updateReport.tip";
i18nMnemonic: "tutti.main.action.updateReport.mnemonic";
- _applicationAction: {UpdateReportAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.UpdateReportAction.class};
_help: {"tutti.main.menu.action.updateReport.help"};
}
@@ -105,7 +105,7 @@
toolTipText: "tutti.main.action.manageDb.tip";
i18nMnemonic: "tutti.main.action.manageDb.mnemonic";
enabled: {model.getScreen() != TuttiScreen.MANAGE_DB};
- _applicationAction: {ManageDbAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ManageDbAction.class};
_help: {"tutti.main.menu.action.manageDb.help"};
}
@@ -123,7 +123,7 @@
toolTipText: "tutti.main.action.changeLocaleFR.tip";
i18nMnemonic: "tutti.main.action.changeLocaleFR.mnemonic";
enabled: {!handler.acceptLocale(model.getLocale(), "fr_FR")};
- _applicationAction: {ChangeToLocaleFRAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ChangeToLocaleFRAction.class};
_help: {"tutti.main.menu.action.changeLocaleFR.help"};
}
@@ -133,7 +133,7 @@
toolTipText: "tutti.main.action.changeLocaleUK.tip";
i18nMnemonic: "tutti.main.action.changeLocaleUK.mnemonic";
enabled: {!handler.acceptLocale(model.getLocale(), "en_GB")};
- _applicationAction: {ChangeToLocaleUKAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ChangeToLocaleUKAction.class};
_help: {"tutti.main.menu.action.changeLocaleUK.help"};
}
@@ -150,7 +150,7 @@
toolTipText: "tutti.main.action.selectCruise.tip";
enabled: {model.getScreen() != TuttiScreen.SELECT_CRUISE};
i18nMnemonic: "tutti.main.action.selectCruise.mnemonic";
- _applicationAction: {SelectCruiseAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SelectCruiseAction.class};
_help: {"tutti.main.menu.action.selectCruise.help"};
}
@@ -160,7 +160,7 @@
toolTipText: "tutti.main.action.editProgram.tip";
i18nMnemonic: "tutti.main.action.editSelectedProgram.mnemonic";
enabled: {model.getScreen() != TuttiScreen.EDIT_PROGRAM && model.isProgramFilled()};
- _applicationAction: {EditSelectedProgramAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.EditSelectedProgramAction.class};
_help: {"tutti.main.menu.action.editProgram.help"};
}
@@ -170,7 +170,7 @@
toolTipText: "tutti.main.action.editSelectedCruise.tip";
i18nMnemonic: "tutti.main.action.editSelectedCruise.mnemonic";
enabled: {model.getScreen() != TuttiScreen.EDIT_CRUISE && model.isCruiseFilled()};
- _applicationAction: {EditSelectedCruiseAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.EditSelectedCruiseAction.class};
_help: {"tutti.main.menu.action.editCruise.help"};
}
@@ -180,7 +180,7 @@
toolTipText: "tutti.main.action.editSelectedProtocol.tip";
i18nMnemonic: "tutti.main.action.editSelectedProtocol.mnemonic";
enabled: {model.getScreen() != TuttiScreen.EDIT_PROTOCOL && model.isProtocolFilled()};
- _applicationAction: {EditSelectedProtocolAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.EditSelectedProtocolAction.class};
_help: {"tutti.main.menu.action.editProtocol.help"};
}
@@ -190,7 +190,7 @@
toolTipText: "tutti.main.action.editCatches.tip";
i18nMnemonic: "tutti.main.action.editCatches.mnemonic";
enabled: {model.getScreen() != TuttiScreen.EDIT_FISHING_OPERATION && model.isCruiseFilled()};
- _applicationAction: {EditSelectedCruiseCatchesAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.EditSelectedCruiseCatchesAction.class};
_help: {"tutti.main.menu.action.editCatches.help"};
}
@@ -200,7 +200,7 @@
toolTipText: "tutti.main.action.validateCatches.tip";
i18nMnemonic: "tutti.main.action.validateCatches.mnemonic";
enabled: {model.getScreen() != TuttiScreen.VALIDATE_CRUISE && model.isCruiseFilled()};
- _applicationAction: {ValidateSelectedCruiseCatchesAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ValidateSelectedCruiseCatchesAction.class};
_help: {"tutti.main.menu.action.validateCatches.help"};
}
@@ -217,7 +217,7 @@
toolTipText: "tutti.main.action.importTemporaryReferential.tip";
i18nMnemonic: "tutti.main.action.importTemporaryReferential.mnemonic";
enabled: {model.getScreen() != TuttiScreen.IMPORT_TEMPORARY_REFERENTIAL};
- _applicationAction: {ImportTemporaryReferentialAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportTemporaryReferentialAction.class};
_help: {"tutti.main.menu.action.importTemporaryReferential.help"};
}
@@ -248,7 +248,7 @@
toolTipText: "tutti.main.action.about.tip";
actionIcon: about;
i18nMnemonic: "tutti.main.action.about.mnemonic";
- _applicationAction: {ShowAboutAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ShowAboutAction.class};
_help: {"tutti.main.menu.action.about.help"};
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx 2013-11-26 08:03:42 UTC (rev 1388)
@@ -30,6 +30,7 @@
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.TuttiScreen
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
+ fr.ifremer.tutti.ui.swing.action.*
jaxx.runtime.swing.BlockingLayerUI
jaxx.runtime.validator.swing.SwingValidatorMessageWidget
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ManageDbAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ManageDbAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ManageDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,41 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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.ui.swing.TuttiScreen;
-
-/**
- * To manage db in Tutti.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ManageDbAction extends AbstractChangeScreenAction {
-
- public ManageDbAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.MANAGE_DB);
- }
-
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ReloadTuttiAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ReloadTuttiAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ReloadTuttiAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,51 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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.ui.swing.RunTutti;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To reload Tutti application.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0.3
- */
-public class ReloadTuttiAction extends AbstractChangeScreenAction {
-
- public ReloadTuttiAction(MainUIHandler handler) {
- super(handler, true, null);
- setActionDescription(_("tutti.main.action.reloadTutti"));
- }
-
- @Override
- public void doAction() throws Exception {
-
- // Close the application, will exit and restart application
- RunTutti.closeTutti(getHandler(), RunTutti.UPATE_EXIT_CODE);
- }
-
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/SelectCruiseAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/SelectCruiseAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/SelectCruiseAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,41 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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.ui.swing.TuttiScreen;
-
-/**
- * Opens the cruise selection screen (home).
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class SelectCruiseAction extends AbstractChangeScreenAction {
-
- public SelectCruiseAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.SELECT_CRUISE);
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowAboutAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,304 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import fr.ifremer.tutti.TuttiConfiguration;
-import fr.ifremer.tutti.ui.swing.TuttiApplicationUpdaterCallBack;
-import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
-import fr.ifremer.tutti.ui.swing.TuttiReportUpdaterCallBack;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import jaxx.runtime.swing.AboutPanel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.updater.ApplicationInfo;
-import org.nuiton.updater.ApplicationUpdater;
-
-import javax.swing.JEditorPane;
-import javax.swing.JScrollPane;
-import javax.swing.event.HyperlinkEvent;
-import javax.swing.event.HyperlinkListener;
-import java.io.File;
-import java.net.URL;
-import java.util.Calendar;
-import java.util.List;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To show about panel.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class ShowAboutAction extends AbstractMainUITuttiAction {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(ShowAboutAction.class);
-
- protected AboutPanel about;
-
- public ShowAboutAction(MainUIHandler handler) {
- super(handler, false);
- }
-
- protected boolean canUpdateApplication;
-
- protected boolean canUpdateData;
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean doAction = super.prepareAction();
-
- if (doAction) {
- // check db url is reachable
- TuttiUIContext context = getContext();
- canUpdateApplication = context.checkUpdateApplicationReachable();
- canUpdateData = context.checkUpdateDataReachable();
-
- }
-
- return doAction;
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- about.showInDialog(getUI(), true);
-
- // register on swing session
- getContext().getSwingSession().add(about);
- }
-
- @Override
- public void doAction() throws Exception {
-
- about = null;
-
- String iconPath = "/icons/allegro_about.png";
- String name = "tutti";
- String licensePath = "META-INF/" + name + "-LICENSE.txt";
- String thirdPartyPath = "META-INF/" + name + "-THIRD-PARTY.txt";
-
- about = new AboutPanel();
- about.setTitle(_("tutti.about.title"));
- about.setAboutText(_("tutti.about.message"));
-
- TuttiConfiguration config = getConfig();
- int currentYear = Calendar.getInstance().get(Calendar.YEAR);
- int inceptionYear = config.getInceptionYear();
- String years;
- if (currentYear != inceptionYear) {
- years = inceptionYear + "-" + currentYear;
- } else {
- years = inceptionYear + "";
- }
-
- about.setBottomText(_("tutti.about.bottomText",
- config.getOrganizationName(),
- years,
- config.getVersion()));
- about.setIconPath(iconPath);
- about.setLicenseFile(licensePath);
- about.setThirdpartyFile(thirdPartyPath);
- about.buildTopPanel();
-
- //
- // translate tab
- //
-
- JScrollPane translatePane = new JScrollPane();
- JEditorPane translateArea = new JEditorPane();
- translateArea.setContentType("text/html");
- translateArea.setEditable(false);
- if (translateArea.getFont() != null) {
- translateArea.setFont(translateArea.getFont().deriveFont((float) 11));
- }
-
- translateArea.setBorder(null);
- File csvFile = new File(config.getI18nDirectory(), "tutti-i18n.csv");
- String translateText = _("tutti.about.translate.content", csvFile.toURI().toURL());
- translateArea.setText(translateText);
- translatePane.getViewport().add(translateArea);
- translateArea.addHyperlinkListener(new HyperlinkListener() {
- @Override
- public void hyperlinkUpdate(HyperlinkEvent e) {
- if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) {
- URL url = e.getURL();
- if (log.isInfoEnabled()) {
- log.info("edit url: " + url);
- }
- TuttiUIUtil.openLink(url);
- }
- }
- });
-
- about.getTabs().add(_("tutti.about.translate.title"), translatePane);
-
- if (canUpdateApplication || canUpdateData) {
-
- //
- // update tab
- //
-
- addUpdateTab(config);
-
- }
- about.init();
- }
-
- protected void addUpdate(Map<String, ApplicationInfo> source,
- Map<String, ApplicationInfo> target,
- String type) {
- ApplicationInfo info = source.get(type.toLowerCase());
- target.put(type, info);
- }
-
- protected void addUpdateTab(TuttiConfiguration config) {
- File current = config.getBasedir();
- String urlApplication = config.getUpdateApplicationUrl();
- String urlData = config.getUpdateDataUrl();
-
- ApplicationUpdater up = new ApplicationUpdater();
-
- // create final update map
- final Map<String, ApplicationInfo> versions = Maps.newLinkedHashMap();
-
- if (canUpdateApplication) {
-
- // get application updates
- Map<String, ApplicationInfo> applicationVersions = up.getVersions(urlApplication, current);
-
- addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.JRE.name());
- addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.TUTTI.name());
- addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.I18N.name());
- addUpdate(applicationVersions, versions, TuttiApplicationUpdaterCallBack.UpdateType.HELP.name());
- }
-
- if (canUpdateData) {
-
- // get report updates
- Map<String, ApplicationInfo> reportVersions = up.getVersions(urlData, current);
- addUpdate(reportVersions, versions, TuttiReportUpdaterCallBack.REPORT_UPDATE_NAME);
-
- // get db updates
- Map<String, ApplicationInfo> dbVersions = up.getVersions(urlData, config.getDataDirectory());
- addUpdate(dbVersions, versions, TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
- }
- JScrollPane updatePane = new JScrollPane();
- JEditorPane updateArea = new JEditorPane();
- updateArea.setContentType("text/html");
- updateArea.setEditable(false);
- if (updateArea.getFont() != null) {
- updateArea.setFont(updateArea.getFont().deriveFont((float) 11));
- }
- updateArea.setBorder(null);
-
- List<String> params = Lists.newArrayList();
- for (Map.Entry<String, ApplicationInfo> entry : versions.entrySet()) {
- String appName = entry.getKey();
- ApplicationInfo info = entry.getValue();
- String oldVersion = info.oldVersion;
- String newVersion = info.newVersion;
- String i18nKey = "tutti.update." + appName.toLowerCase();
- String appLabel = _(i18nKey);
-
- if (log.isInfoEnabled()) {
- log.info(String.format(
- "Module %s, version courante %s, nouvelle version %s",
- appLabel, oldVersion, newVersion));
- }
- if (newVersion == null) {
-
- // no update
- params.add(_("tutti.about.update.app.noup.detail", appLabel, oldVersion));
- } else {
- // update exists
- params.add(_("tutti.about.update.app.up.detail", appLabel, oldVersion, newVersion, appName));
- }
- }
-
- String updateText = _("tutti.about.update.content", urlApplication, urlData, Joiner.on("\n").join(params));
- updateArea.setText(updateText);
- updatePane.getViewport().add(updateArea);
- updateArea.addHyperlinkListener(new HyperlinkListener() {
- @Override
- public void hyperlinkUpdate(HyperlinkEvent e) {
- if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) {
- URL url = e.getURL();
- if (url != null) {
- TuttiUIUtil.openLink(url);
- } else {
- String appType = e.getDescription();
-
-
- if (log.isInfoEnabled()) {
- log.info("Open url: " + appType);
- }
- AbstractTuttiAction action;
-
- if (TuttiDbUpdaterCallBack.DB_UPDATE_NAME.equals(appType)) {
- UpdateDbAction logicAction = getContext().getActionFactory().createLogicAction(getHandler(), UpdateDbAction.class);
- action = logicAction;
- if (!getContext().isDbExist()) {
-
- // install db
- action.setActionDescription(
- _("tutti.dbManager.action.installDb.tip"));
- }
- } else if (TuttiReportUpdaterCallBack.REPORT_UPDATE_NAME.equals(appType)) {
- UpdateReportAction logicAction = getContext().getActionFactory().createLogicAction(getHandler(), UpdateReportAction.class);
- action = logicAction;
- } else {
-
- TuttiApplicationUpdaterCallBack.UpdateType updateType =
- TuttiApplicationUpdaterCallBack.UpdateType.valueOf(appType.toUpperCase());
-
- UpdateApplicationAction logicAction = getContext().getActionFactory().createLogicAction(getHandler(), UpdateApplicationAction.class);
- logicAction.setTypes(updateType);
- logicAction.setActionDescription(_("tutti.main.action.updateSpecificApplication.tip", updateType.getLabel()));
- action = logicAction;
- }
-
- // close this dialog
- getActionEngine().runAction(about.getClose());
-
- // do update
- getActionEngine().runAction(action);
- }
-
- }
- }
- });
- about.getTabs().add(_("tutti.about.update.title"), updatePane);
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowConfigAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowConfigAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowConfigAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,40 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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.ui.swing.TuttiScreen;
-
-/**
- * To show config screen.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.1
- */
-public class ShowConfigAction extends AbstractChangeScreenAction {
-
- public ShowConfigAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.CONFIG);
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowReportAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowReportAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ShowReportAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,53 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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.ui.swing.TuttiScreen;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * To show report screen.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.9
- */
-public class ShowReportAction extends AbstractChangeScreenAction {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(ShowReportAction.class);
-
- public ShowReportAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.REPORT);
- }
-
- @Override
- public void doAction() throws Exception {
- if (log.isDebugEnabled()) {
- log.debug("Show report screen");
- }
- super.doAction();
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/StartAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/StartAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/StartAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,175 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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.shared.application.ApplicationIOUtil;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.content.db.ImportDbAction;
-import fr.ifremer.tutti.ui.swing.content.db.InstallDbAction;
-import fr.ifremer.tutti.ui.swing.content.db.OpenDbAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Start action.
- * <p/>
- * If there is a start action file, then load it and run inside actions, otherwise
- * just starts normal ui action (open db if exists, or go to manage db screen).
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.4
- */
-public class StartAction extends AbstractMainUITuttiAction {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(StartAction.class);
-
- protected AbstractMainUITuttiAction delegateAction;
-
- public StartAction(MainUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- File actionfile = getConfig().getStartActionFile();
- boolean doAction = actionfile.exists();
-
- if (doAction) {
-
- try {
- // get action to execute
- String content = ApplicationIOUtil.readContent(actionfile, _("tutti.error.read.startActionFile", actionfile));
- content = content.trim();
-
- if (InstallDbAction.class.getName().equals(content)) {
-
- // install db
- delegateAction = getContext().getActionFactory().createLogicAction(handler, InstallDbAction.class);
-
- if (log.isInfoEnabled()) {
- log.info("Found install db action");
- }
- deleteOldDatabaseDirectory();
-
- } else if (content.startsWith(ImportDbAction.class.getName())) {
-
- // import db
- ImportDbAction action = getContext().getActionFactory().createLogicAction(handler, ImportDbAction.class);
- File importFile = new File(content.substring(ImportDbAction.class.getName().length() + 1));
- action.setImportFile(importFile);
- delegateAction = action;
- if (log.isInfoEnabled()) {
- log.info("Found import db action (with file " + importFile + ")");
- }
- deleteOldDatabaseDirectory();
- } else {
- if (log.isWarnEnabled()) {
- log.warn("Unknown start action: " + content);
- }
- doAction = false;
- }
-
- } finally {
-
- // delete start action file
- ApplicationIOUtil.deleteFile(
- actionfile,
- _("tutti.error.delete.startActionFile", actionfile));
- }
- }
-
- if (!doAction) {
-
- // no start action, normal start
-
- TuttiUIContext context = getContext();
-
- if (context.isDbLoaded()) {
-
- // db already opened (happens when reloading ui)
- // just go to select cruise screen
- SelectCruiseAction action = getContext().getActionFactory().createLogicAction(handler, SelectCruiseAction.class);
- action.setSkipCheckCurrentScreen(true);
- action.setActionDescription(getUI().getMenuActionSelectCruise().getToolTipText());
- delegateAction = action;
-
- } else {
-
- if (context.isDbExist()) {
-
- // open tutti db (using a fake button to have simple api)
- OpenDbAction action = getContext().getActionFactory().createLogicAction(handler, OpenDbAction.class);
- action.setSkipCheckCurrentScreen(true);
- action.setUpdateReferentiel(true);
- delegateAction = action;
-
- } else {
-
- // clean db context
- context.clearDbContext();
-
- // go to manage db screen (to install db)
- ManageDbAction action = getContext().getActionFactory().createLogicAction(handler, ManageDbAction.class);
- action.setSkipCheckCurrentScreen(true);
- delegateAction = action;
- }
- }
- }
-
- setActionDescription(delegateAction.getActionDescription());
- doAction = delegateAction.prepareAction();
- return doAction;
- }
-
- @Override
- public void doAction() throws Exception {
-
- getActionEngine().runInternalAction(delegateAction);
- }
-
- @Override
- protected void releaseAction() {
- delegateAction = null;
- super.releaseAction();
- }
-
- protected void deleteOldDatabaseDirectory() {
- File dbDirectory = getConfig().getDbDirectory();
- if (dbDirectory.exists()) {
-
- // delete it before install
- if (log.isInfoEnabled()) {
- log.info("Delete previous database directory: " + dbDirectory);
- }
- ApplicationIOUtil.deleteDirectory(dbDirectory, "Could not delete old db directory");
- }
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateApplicationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,166 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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.TuttiConfiguration;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.ui.swing.RunTutti;
-import fr.ifremer.tutti.ui.swing.TuttiApplicationUpdaterCallBack;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.updater.ApplicationUpdater;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To update jre / i18n or tutti using the {@link ApplicationUpdater} mecanism.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class UpdateApplicationAction extends AbstractTuttiAction<TuttiUIContext, MainUI, MainUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(UpdateApplicationAction.class);
-
- public UpdateApplicationAction(MainUIHandler handler) {
- super(handler, true);
- setActionDescription(_("tutti.main.action.updateApplication.tip"));
- types = TuttiApplicationUpdaterCallBack.UpdateType.values();
- }
-
- protected TuttiApplicationUpdaterCallBack.UpdateType[] types;
-
- protected boolean reload;
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean doAction = super.prepareAction();
-
- if (doAction) {
- // check application url is reachable
- TuttiUIContext context = getContext();
- doAction = context.checkUpdateApplicationReachable();
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- super.releaseAction();
- types = TuttiApplicationUpdaterCallBack.UpdateType.values();
- }
-
- @Override
- public void doAction() throws Exception {
-
- reload = false;
-
- TuttiUIContext context = getContext();
- TuttiConfiguration config = getConfig();
-
- File current = config.getBasedir();
- if (current == null || !current.exists()) {
-
- // can not update application
- if (log.isWarnEnabled()) {
- log.warn("No application base directory defined, skip updates.");
- }
- } else {
-
- String url = config.getUpdateApplicationUrl();
- File dest = new File(config.getBasedir(), "NEW");
-
- if (log.isInfoEnabled()) {
- log.info(String.format("Try to update jre, i18N, help or tutti (current application location: %s), using update url: %s", current, url));
- }
-
- ProgressionModel progressionModel = new ProgressionModel();
- context.getActionUI().getModel().setProgressionModel(progressionModel);
- progressionModel.setMessage(_("tutti.updateApplication.checkUpdates"));
-
- TuttiApplicationUpdaterCallBack callback =
- new TuttiApplicationUpdaterCallBack(this, progressionModel);
-
- callback.setTypes(types);
-
- ApplicationUpdater up = new ApplicationUpdater();
- up.update(url,
- current,
- dest,
- false,
- callback,
- progressionModel);
-
- if (callback.isApplicationUpdated()) {
-
- reload = true;
-
- } else {
-
- sendMessage(_("tutti.updateApplication.noUpdate"));
- }
- }
- }
-
- public void setTypes(TuttiApplicationUpdaterCallBack.UpdateType... types) {
- this.types = types;
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- if (reload) {
- // wait 1 second to be sure action ui is up
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- if (log.isWarnEnabled()) {
- log.warn("Could not wait 1 second...", e);
- }
- }
-
- // tell user restart will be done
-
- getHandler().showSuccessMessage(_("tutti.updateApplication.title.success"),
- _("tutti.updateApplication.message.success"));
-
- CloseApplicationAction action = getContext().getActionFactory().createLogicAction(
- getHandler(), CloseApplicationAction.class);
- action.setExitCode(RunTutti.UPATE_EXIT_CODE);
- getActionEngine().runAction(action);
- }
- }
-
- public boolean isReload() {
- return reload;
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,153 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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.TuttiConfiguration;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.updater.ApplicationInfo;
-import org.nuiton.updater.ApplicationUpdater;
-
-import javax.swing.JOptionPane;
-import java.io.File;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To update - install database.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class UpdateDbAction extends AbstractMainUITuttiAction {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(UpdateDbAction.class);
-
- protected ApplicationInfo updateDbVersion;
-
- public UpdateDbAction(MainUIHandler handler) {
- super(handler, true);
- setActionDescription(_("tutti.dbManager.action.upgradeDb.tip"));
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean doAction = super.prepareAction();
-
- updateDbVersion = null;
-
- if (doAction) {
- // check db url is reachable
- doAction = getContext().checkUpdateDataReachable();
- }
-
- if (doAction) {
-
- // get the next db version
- ApplicationUpdater up = new ApplicationUpdater();
-
- // get db updates
- Map<String, ApplicationInfo> dbVersions =
- up.getVersions(getConfig().getUpdateDataUrl(),
- getConfig().getDataDirectory());
- updateDbVersion =
- dbVersions.get(TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
-
- if (getContext().isDbExist() &&
- updateDbVersion != null &&
- updateDbVersion.newVersion != null) {
-
- // ask user if it wants to do the update
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- _("tutti.dbManager.updatedb.found", updateDbVersion.newVersion),
- _("tutti.common.askBeforeUpdate.help"));
- int i = JOptionPane.showConfirmDialog(
- getHandler().getUI(),
- htmlMessage,
- _("tutti.dbManager.title.confirm.updatedb"),
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.QUESTION_MESSAGE);
-
- doAction = i == JOptionPane.OK_OPTION;
- }
- }
- return doAction;
- }
-
- @Override
- public void doAction() {
- TuttiUIContext context = getContext();
- TuttiConfiguration config = getConfig();
-
- File current = config.getDataDirectory();
- String url = config.getUpdateDataUrl();
-
- if (log.isInfoEnabled()) {
- log.info(String.format("Try to install / update db (current data location: %s), using update url: %s", current, url));
- }
-
- File dest = new File(config.getBasedir(), "NEW");
- ProgressionModel progressionModel = new ProgressionModel();
- context.getActionUI().getModel().setProgressionModel(progressionModel);
- progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.check"));
- TuttiDbUpdaterCallBack callback =
- new TuttiDbUpdaterCallBack(this, progressionModel);
- ApplicationUpdater up = new ApplicationUpdater();
-
- up.update(url,
- current,
- dest,
- false,
- callback,
- progressionModel);
-
- if (callback.isDbUpdated()) {
-
- sendMessage(_("tutti.dbManager.action.upgradeDb.done", updateDbVersion.newVersion));
-
- } else {
- sendMessage(_("tutti.dbManager.action.upgradeDb.upToDate"));
- }
- }
-
- @Override
- public void postSuccessAction() {
- handler.reloadDbManagerText();
- super.postSuccessAction();
- }
-
- @Override
- public void postFailedAction(Throwable error) {
- handler.reloadDbManagerText();
- super.postFailedAction(error);
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateReportAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateReportAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/UpdateReportAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,151 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%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.TuttiConfiguration;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.ui.swing.RunTutti;
-import fr.ifremer.tutti.ui.swing.TuttiReportUpdaterCallBack;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.updater.ApplicationUpdater;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To update reports using the {@link ApplicationUpdater} mecanism.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class UpdateReportAction extends AbstractTuttiAction<TuttiUIContext, MainUI, MainUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(UpdateReportAction.class);
-
- public UpdateReportAction(MainUIHandler handler) {
- super(handler, true);
- setActionDescription(_("tutti.main.action.updateReport.tip"));
- }
-
- protected boolean reload;
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean doAction = super.prepareAction();
-
- if (doAction) {
- // check data url is reachable
- TuttiUIContext context = getContext();
- doAction = context.checkUpdateDataReachable();
- }
- return doAction;
- }
-
- @Override
- public void doAction() throws Exception {
-
- reload = false;
-
- TuttiUIContext context = getContext();
- TuttiConfiguration config = getConfig();
-
- File current = config.getBasedir();
- if (current == null || !current.exists()) {
-
- // can not update application
- if (log.isWarnEnabled()) {
- log.warn("No application base directory defined, skip updates.");
- }
- } else {
-
- String url = config.getUpdateDataUrl();
- File dest = new File(config.getBasedir(), "NEW");
-
- if (log.isInfoEnabled()) {
- log.info(String.format("Try to update repport (current application location: %s), using update url: %s", current, url));
- }
-
- ProgressionModel progressionModel = new ProgressionModel();
- context.getActionUI().getModel().setProgressionModel(progressionModel);
- progressionModel.setMessage(_("tutti.updateApplication.checkUpdates"));
-
- TuttiReportUpdaterCallBack callback =
- new TuttiReportUpdaterCallBack(this, progressionModel);
-
- ApplicationUpdater up = new ApplicationUpdater();
- up.update(url,
- current,
- dest,
- false,
- callback,
- progressionModel);
-
- if (callback.isReportUpdated()) {
-
- reload = true;
-
- } else {
-
- sendMessage(_("tutti.updateReport.noUpdate"));
- }
- }
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- if (reload) {
- // wait 1 second to be sure action ui is up
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- if (log.isWarnEnabled()) {
- log.warn("Could not wait 1 second...", e);
- }
- }
-
- // tell user restart will be done
-
- getHandler().showSuccessMessage(_("tutti.updateReport.title.success"),
- _("tutti.updateReport.message.success"));
-
- CloseApplicationAction action = getContext().getActionFactory().createLogicAction(
- getHandler(), CloseApplicationAction.class);
- action.setExitCode(RunTutti.UPATE_EXIT_CODE);
- getActionEngine().runAction(action);
- }
- }
-
- public boolean isReload() {
- return reload;
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ValidateSelectedCruiseCatchesAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ValidateSelectedCruiseCatchesAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ValidateSelectedCruiseCatchesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,58 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.service.ValidationService;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Opens the operations validation screen to edit the selected operations.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ValidateSelectedCruiseCatchesAction extends AbstractChangeScreenAction {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ValidateSelectedCruiseCatchesAction.class);
-
- public ValidateSelectedCruiseCatchesAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.VALIDATE_CRUISE);
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkState(getContext().isCruiseFilled());
- getContext().setValidationContext(ValidationService.VALIDATION_CONTEXT_VALIDATE);
- if (log.isInfoEnabled()) {
- log.info("Validate operations of cruise: " + getContext().getCruiseId());
- }
- super.doAction();
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -79,7 +79,7 @@
text: "tutti.editSampleCategoryModel.action.close";
toolTipText: "tutti.editSampleCategoryModel.action.close.tip";
i18nMnemonic: "tutti.editSampleCategoryModel.action.close.mnemonic";
- _applicationAction: {fr.ifremer.tutti.ui.swing.content.SelectCruiseAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SelectCruiseAction.class};
_help: {"tutti.editSampleCategoryModel.action.close.help"};
}
@@ -89,6 +89,6 @@
toolTipText: "tutti.editSampleCategoryModel.action.save.tip";
i18nMnemonic: "tutti.editSampleCategoryModel.action.save.mnemonic";
enabled: {model.isModify() && model.isValid()};
- _applicationAction: {SaveSampleCategoryModelAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SaveSampleCategoryModelAction.class};
_help: {"tutti.editSampleCategoryModel.action.save.help"};
}
\ No newline at end of file
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -30,7 +30,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.Cancelable;
+import fr.ifremer.shared.application.swing.util.Cancelable;
import fr.ifremer.shared.application.swing.util.CloseableUI;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/SaveSampleCategoryModelAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/SaveSampleCategoryModelAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/SaveSampleCategoryModelAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,66 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.category;
-
-/*
- * #%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.SampleCategoryModel;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * To save the sample category model.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.4
- */
-public class SaveSampleCategoryModelAction extends AbstractTuttiAction<EditSampleCategoryModelUIModel, EditSampleCategoryModelUI, EditSampleCategoryModelUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(SaveSampleCategoryModelAction.class);
-
- public SaveSampleCategoryModelAction(EditSampleCategoryModelUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public void doAction() throws Exception {
- EditSampleCategoryModelUIModel model = getModel();
-
- SampleCategoryModel bean = model.toBean();
-
- if (log.isInfoEnabled()) {
- log.info("Will save sampleCategoryModel: " + bean);
- }
- getConfig().setSampleCategoryModel(bean);
-
- getConfig().save();
-
- getDataContext().loadSampleCategoryModel(bean);
-
- model.setModify(false);
-
- }
-}
\ No newline at end of file
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -27,8 +27,8 @@
import fr.ifremer.tutti.TuttiConfiguration;
import fr.ifremer.tutti.TuttiConfigurationOption;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.content.GoToPreviousScreenAction;
-import fr.ifremer.tutti.ui.swing.content.ReloadTuttiAction;
+import fr.ifremer.tutti.ui.swing.action.GoToPreviousScreenAction;
+import fr.ifremer.tutti.ui.swing.action.ReloadTuttiAction;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.editor.TuttiLocationTableCell;
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseFishingOperationAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseFishingOperationAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseFishingOperationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,180 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.cruise;
-
-/*
- * #%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.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.service.catches.ValidateCruiseOperationsService;
-import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel;
-import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.validator.NuitonValidatorResult;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To edit the given fishing operation.
- *
- * @author kmorin <morin(a)codelutin.com>
- * @since 1.4
- */
-public class EditCruiseFishingOperationAction extends AbstractTuttiAction<ValidateCruiseUIModel, ValidateCruiseUI, ValidateCruiseUIHandler> {
-
- private static final Log log =
- LogFactory.getLog(EditCruiseFishingOperationAction.class);
-
- /** Validation service. */
- private final ValidateCruiseOperationsService validationService = getContext().getValidateCruiseOperationsService();
-
- /**
- * 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).
- */
- protected FishingOperation fishingOperation;
-
- protected final PropertyChangeListener editFishingOperationModelListener = new PropertyChangeListener() {
-
- protected final List<String> propertiesToIgnore = Lists.newArrayList(
- EditFishingOperationUIModel.PROPERTY_MODIFY,
- EditFishingOperationUIModel.PROPERTY_VALID,
- EditFishingOperationUIModel.PROPERTY_PERSISTED
- );
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
-
- EditFishingOperationUIModel model = (EditFishingOperationUIModel) evt.getSource();
-
- if (!model.isLoadingData()
- && model.getFishingOperation() != null
- && !propertiesToIgnore.contains(evt.getPropertyName())) {
-
- model.convertGearShootingCoordinatesToDD();
-
- FishingOperation operation = model.toBean();
- NuitonValidatorResult validationResult = validationService.validateCruiseOperation(operation);
-
- ValidateCruiseUIModel uiModel = getModel();
- uiModel.getValidator().put(uiModel.getSelectedFishingOperation(), validationResult);
-
- getHandler().updateCurrentOperationNode(validationResult);
-
- }
- }
- };
-
- protected final PropertyChangeListener editCatchesModelListener = new PropertyChangeListener() {
-
- protected final List<String> propertiesToIgnore = Lists.newArrayList(
- EditCatchesUIModel.PROPERTY_MODIFY,
- EditCatchesUIModel.PROPERTY_VALID,
- EditCatchesUIModel.PROPERTY_CATCH_TOTAL_COMPUTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_CATCH_TOTAL_SORTED_COMPUTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_CATCH_TOTAL_UNSORTED_COMPUTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_CATCH_TOTAL_REJECTED_COMPUTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_COMPUTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SORTED_COMPUTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_UNSORTED_COMPUTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_INERT_COMPUTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_COMPUTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_SORTED_COMPUTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_UNSORTED_COMPUTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_COMPUTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_INERT_COMPUTED_WEIGHT,
- EditCatchesUIModel.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_COMPUTED_WEIGHT
- );
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- EditCatchesUIModel model = (EditCatchesUIModel) evt.getSource();
-
- if (!model.isLoadingData()
- && model.getFishingOperation() != null
- && !propertiesToIgnore.contains(evt.getPropertyName())) {
-
- CatchBatch catchBatch = model.toBean();
- NuitonValidatorResult validationResult = validationService.validateCruiseOperation(catchBatch);
-
- ValidateCruiseUIModel uiModel = getModel();
- uiModel.getValidator().put(uiModel.getSelectedFishingOperation(), validationResult);
-
- getHandler().updateCurrentOperationNode(validationResult);
- }
- }
- };
-
- public EditCruiseFishingOperationAction(ValidateCruiseUIHandler handler) {
- super(handler, true);
- setActionDescription(_("tutti.editFishingOperation.action.editFishingOperation.tip"));
- }
-
- public void setFishingOperation(FishingOperation fishingOperation) {
- this.fishingOperation = fishingOperation;
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- FishingOperationsUI operationPanel = getUI().getOperationPanel();
- operationPanel.getFishingOperationTabContent().getModel().
- removePropertyChangeListener(editFishingOperationModelListener);
- operationPanel.getCatchesTabContent().getModel().
- removePropertyChangeListener(editCatchesModelListener);
-
- return super.prepareAction();
- }
-
- @Override
- public void doAction() throws Exception {
- getUI().getOperationPanel().getModel().setSelectedFishingOperation(fishingOperation);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- FishingOperationsUI operationPanel = getUI().getOperationPanel();
- operationPanel.getFishingOperationTabContent().getModel().addPropertyChangeListener(editFishingOperationModelListener);
- operationPanel.getCatchesTabContent().getModel().addPropertyChangeListener(editCatchesModelListener);
- }
-
- @Override
- public void releaseAction() {
- super.releaseAction();
- fishingOperation = null;
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -54,7 +54,7 @@
text: "tutti.editCruise.action.editGearCaracteristics";
toolTipText: "tutti.editCruise.action.editGearCaracteristics.tip";
enabled: {model.isCanEditGearCatacteristic()};
- _applicationAction: {EditGearCaracteristicsAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.EditGearCaracteristicsAction.class};
_help: {"tutti.editCruise.action.editGearCaracteristics.help"};
}
@@ -63,7 +63,7 @@
text: "tutti.editCruise.action.viewGearCaracteristics";
toolTipText: "tutti.editCruise.action.viewGearCaracteristics.tip";
enabled: {model.isCanShowGearCatacteristic()};
- _applicationAction: {ViewGearCaracteristicsAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ViewGearCaracteristicsAction.class};
_help: {"tutti.editCruise.action.viewGearCaracteristics.help"};
}
@@ -266,7 +266,7 @@
text: "tutti.editCruise.action.saveCruise";
toolTipText: "tutti.editCruise.action.saveCruise.tip";
i18nMnemonic: "tutti.editCruise.action.saveCruise.mnemonic";
- _applicationAction: {SaveCruiseAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SaveCruiseAction.class};
enabled: {model.isModify() && model.isValid()};
_help: {"tutti.editCruise.action.save.help"};
}
@@ -276,7 +276,7 @@
text: "tutti.editCruise.action.closeEditCruise";
toolTipText: "tutti.editCruise.action.closeEditCruise.tip";
i18nMnemonic: "tutti.editCruise.action.closeEditCruise.mnemonic";
- _applicationAction: {fr.ifremer.tutti.ui.swing.content.SelectCruiseAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SelectCruiseAction.class};
_help: {"tutti.editCruise.action.close.help"};
}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditGearCaracteristicsAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditGearCaracteristicsAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditGearCaracteristicsAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,78 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.cruise;
-
-/*
- * #%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.CaracteristicMap;
-import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrder;
-import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrders;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.1
- */
-public class EditGearCaracteristicsAction extends AbstractTuttiAction<EditCruiseUIModel, EditCruiseUI, EditCruiseUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(EditGearCaracteristicsAction.class);
-
- protected final PersistenceService persistenceService;
-
- public EditGearCaracteristicsAction(EditCruiseUIHandler handler) {
- super(handler, false);
- persistenceService = getContext().getPersistenceService();
- }
-
- @Override
- public void doAction() throws Exception {
- GearCaracteristicsEditorUI editor = getUI().getGearCaracteristicsEditor();
- editor.getModel().setEditable(true);
-
- GearWithOriginalRankOrder gear =
- EditCruiseUIHandler.GEAR_EDIT_CONTEXT.getContextValue(getUI());
-
- CaracteristicMap caracteristics =
- persistenceService.getGearCaracteristics(
- getDataContext().getCruise().getId(),
- gear.getId(),
- gear.getOriginalRankOrder());
-
- GearWithOriginalRankOrder gearToView =
- GearWithOriginalRankOrders.newGearWithOriginalRankOrder(gear);
- gearToView.setCaracteristics(caracteristics);
-
- if (log.isInfoEnabled()) {
- log.info("Will edit gear " + decorate(gearToView) +
- " with " + gearToView.getCaracteristics().size() + " caracteristics.");
- }
- editor.getModel().setGear(gearToView);
-
- getUI().getMainPanelLayout().setSelected(EditCruiseUIHandler.GEAR_CARACTERISTICS_CARD);
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportCruiseValidationMessagesAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportCruiseValidationMessagesAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportCruiseValidationMessagesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,84 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.cruise;
-
-/*
- * #%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.service.catches.ValidateCruiseOperationsService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.0.1
- */
-public class ExportCruiseValidationMessagesAction extends AbstractTuttiAction<ValidateCruiseUIModel, ValidateCruiseUI, ValidateCruiseUIHandler> {
-
- protected File file;
-
- /** Validation service. */
- protected ValidateCruiseOperationsService validationService = getContext().getValidateCruiseOperationsService();
-
- public ExportCruiseValidationMessagesAction(ValidateCruiseUIHandler handler) {
- super(handler, false);
- setActionDescription(_("tutti.validateCruise.action.export.all.tip"));
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean doAction = super.prepareAction();
-
- if (doAction) {
- // choose file to export
- file = saveFile(
- String.format("validation_%s", getDataContext().getCruise().getName()),
- "txt",
- _("tutti.validateCruise.action.export.all.chooseFile.title"),
- _("tutti.validateCruise.action.export.all.chooseFile.label")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void doAction() throws Exception {
- ValidateCruiseUIModel uiModel = getModel();
- validationService.exportValidationResults(file, uiModel.getValidator());
- }
-
- @Override
- public void releaseAction() {
- super.releaseAction();
- file = null;
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.validateCruise.action.export.all.success", file));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportOperationValidationMessagesAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportOperationValidationMessagesAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportOperationValidationMessagesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,89 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.cruise;
-
-/*
- * #%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.service.DecoratorService;
-import fr.ifremer.tutti.service.catches.ValidateCruiseOperationsService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.0.1
- */
-public class ExportOperationValidationMessagesAction extends AbstractTuttiAction<ValidateCruiseUIModel, ValidateCruiseUI, ValidateCruiseUIHandler> {
-
- protected File file;
-
- /** Validation service. */
- protected ValidateCruiseOperationsService validationService = getContext().getValidateCruiseOperationsService();
-
- public ExportOperationValidationMessagesAction(ValidateCruiseUIHandler handler) {
- super(handler, false);
- setActionDescription(_("tutti.validateCruise.action.export.operation.tip"));
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to export
- file = saveFile(
- String.format("validation_%s",
- decorate(getModel().getSelectedFishingOperation(), DecoratorService.FILE_NAME_COMPATIBLE)),
- "txt",
- _("tutti.validateCruise.action.export.operation.chooseFile.title"),
- _("tutti.validateCruise.action.export.operation.chooseFile.label")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void doAction() throws Exception {
- ValidateCruiseUIModel uiModel = getModel();
- FishingOperation operation = getModel().getSelectedFishingOperation();
- validationService.exportValidationResult(file, operation, uiModel.getValidator().get(operation));
- }
-
- @Override
- public void releaseAction() {
- super.releaseAction();
- file = null;
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.validateCruise.action.export.operation.success", file));
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/GearCaracteristicsEditorUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/GearCaracteristicsEditorUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/GearCaracteristicsEditorUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -29,11 +29,11 @@
import fr.ifremer.tutti.persistence.entities.referential.Gear;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.util.Cancelable;
+import fr.ifremer.shared.application.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
-import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor;
-import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
+import fr.ifremer.tutti.ui.swing.util.caracteristics.CaracteristicValueEditor;
+import fr.ifremer.tutti.ui.swing.util.caracteristics.CaracteristicValueRenderer;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
import jaxx.runtime.validator.swing.SwingValidator;
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/SaveCruiseAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/SaveCruiseAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/SaveCruiseAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,179 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.cruise;
-
-/*
- * #%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.Sets;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrder;
-import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrders;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.lang3.ObjectUtils;
-
-import javax.swing.JOptionPane;
-import java.util.Set;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Saves a cruise
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.0
- */
-public class SaveCruiseAction extends AbstractTuttiAction<EditCruiseUIModel, EditCruiseUI, EditCruiseUIHandler> {
-
- protected PersistenceService persistenceService;
-
- protected boolean updateVessel;
-
- protected boolean updateGear;
-
- public SaveCruiseAction(EditCruiseUIHandler handler) {
- super(handler, true);
- persistenceService = getContext().getPersistenceService();
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
-
- Cruise bean = getModel().toBean();
- if (!TuttiEntities.isNew(bean)) {
- Cruise oldCruise = persistenceService.getCruise(bean.getId());
-
- // check gear has not changed
- if (!oldCruise.getVessel().equals(bean.getVessel())) {
-
- // if so ask user confirmation
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- _("tutti.editCruise.action.save.vesselChanged.message"),
- _("tutti.editCruise.action.save.vesselChanged.help"));
-
- int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- htmlMessage,
- _("tutti.editCruise.action.save.vesselChanged.title"),
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.WARNING_MESSAGE);
-
- result = updateVessel = answer == JOptionPane.OK_OPTION;
- }
-
- if (result) {
-
- if (ObjectUtils.notEqual(oldCruise.getGear(), bean.getGear())) {
-
- // get all gears to remove
-
- Set<Gear> gearsToRemove =
- Sets.<Gear>newHashSet(oldCruise.getGear());
-
- for (GearWithOriginalRankOrder gearWithOriginalRankOrder : bean.getGear()) {
- GearWithOriginalRankOrder g =
- GearWithOriginalRankOrders.newGearWithOriginalRankOrder(
- gearWithOriginalRankOrder.getIdAsInt(),
- gearWithOriginalRankOrder.getOriginalRankOrder()
- );
- gearsToRemove.remove(g);
- }
-
- // check they are not used by any operation of the cruise
- boolean obsoleteGearIsUsed = persistenceService.isOperationUseGears(
- bean.getIdAsInt(), gearsToRemove);
-
- if (obsoleteGearIsUsed) {
-
- // not possible, can't removed used gears
-
- String message = _("tutti.persistence.cruise.gearUsedInOperations.error");
- displayWarningMessage(
- _("tutti.editCruise.action.save.gearChanged.title"),
- "<html><body>" + message + "</body></html>"
- );
- result = false;
- } else {
-
- // if so ask user confirmation
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- _("tutti.editCruise.action.save.gearChanged.message"),
- _("tutti.editCruise.action.save.gearChanged.help"));
-
- int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- htmlMessage,
- _("tutti.editCruise.action.save.gearChanged.title"),
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.WARNING_MESSAGE);
-
- result = updateGear = answer == JOptionPane.OK_OPTION;
- }
- }
- }
- }
-
- return result;
- }
-
- @Override
- public void doAction() throws Exception {
- TuttiUIContext context = getContext();
- EditCruiseUIModel model = getModel();
-
- Cruise bean = model.toBean();
-
- Cruise saved;
- if (TuttiEntities.isNew(bean)) {
-
- saved = persistenceService.createCruise(bean);
- model.setId(saved.getId());
- sendMessage(_("tutti.flash.info.cruiseCreated", bean.getName()));
- } else {
- saved = persistenceService.saveCruise(bean, updateVessel, updateGear);
- sendMessage(_("tutti.flash.info.cruiseSaved", bean.getName()));
- }
-
- context.setProgramId(saved.getProgram().getId());
- context.setCruiseId(saved.getId());
-
- // update originalRankOrder for all gears of the cruise
- for (GearWithOriginalRankOrder gear : model.getGear()) {
- gear.setOriginalRankOrder(gear.getRankOrder());
- }
- model.setModify(false);
- }
-
- @Override
- public void postSuccessAction() {
-
- getContext().getMainUI().getHandler().setBodyTitle(
- EditCruiseUIHandler.getTitle(true));
-
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -37,7 +37,7 @@
#exportButton {
actionIcon: export;
toolTipText: "tutti.validateCruise.navigation.action.export.all.tip";
- _applicationAction: {ExportCruiseValidationMessagesAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportCruiseValidationMessagesAction.class};
_help: {"tutti.validateCruise.navigation.action.export.all.help"};
}
@@ -50,7 +50,7 @@
text: "tutti.validateCruise.navigation.action.export.operation";
toolTipText: "tutti.validateCruise.navigation.action.export.operation.tip";
i18nMnemonic: "tutti.validateCruise.navigation.action.export.operation.mnemonic";
- _applicationAction: {ExportOperationValidationMessagesAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportOperationValidationMessagesAction.class};
enabled: {model.getSelectedFishingOperation() != null};
_help: {"tutti.validateCruise.navigation.action.export.operation.help"};
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -32,6 +32,7 @@
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.service.catches.ValidateCruiseOperationsService;
+import fr.ifremer.tutti.ui.swing.action.EditCruiseFishingOperationAction;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.RemoveablePropertyChangeListener;
@@ -213,7 +214,7 @@
}
}
- protected void updateCurrentOperationNode(NuitonValidatorResult validationResult) {
+ public void updateCurrentOperationNode(NuitonValidatorResult validationResult) {
JTree navigation = ui.getNavigation();
TreePath selectionPath = navigation.getSelectionPath();
Preconditions.checkArgument(selectionPath.getPathCount() > 1);
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ViewGearCaracteristicsAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ViewGearCaracteristicsAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ViewGearCaracteristicsAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,79 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.cruise;
-
-/*
- * #%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.CaracteristicMap;
-import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrder;
-import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrders;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.1
- */
-public class ViewGearCaracteristicsAction extends AbstractTuttiAction<EditCruiseUIModel, EditCruiseUI, EditCruiseUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ViewGearCaracteristicsAction.class);
-
- protected final PersistenceService persistenceService;
-
- public ViewGearCaracteristicsAction(EditCruiseUIHandler handler) {
- super(handler, false);
- persistenceService = getContext().getPersistenceService();
- }
-
- @Override
- public void doAction() throws Exception {
- GearCaracteristicsEditorUI editor = getUI().getGearCaracteristicsEditor();
- editor.getModel().setEditable(false);
-
- GearWithOriginalRankOrder gear =
- EditCruiseUIHandler.GEAR_EDIT_CONTEXT.getContextValue(getUI());
-
- CaracteristicMap caracteristics =
- persistenceService.getGearCaracteristics(
- getDataContext().getCruise().getId(),
- gear.getId(),
- gear.getOriginalRankOrder());
-
- GearWithOriginalRankOrder gearToEdit =
- GearWithOriginalRankOrders.newGearWithOriginalRankOrder(gear);
- gearToEdit.setCaracteristics(caracteristics);
-
- if (log.isInfoEnabled()) {
- log.info("Will edit gear " + decorate(gearToEdit) +
- " with " + gearToEdit.getCaracteristics().size() + " caracteristics.");
- }
-
- editor.getModel().setGear(gearToEdit);
-
- getUI().getMainPanelLayout().setSelected(EditCruiseUIHandler.GEAR_CARACTERISTICS_CARD);
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/CloseDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,88 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.db;
-
-/*
- * #%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.ui.swing.content.AbstractMainUITuttiAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To close a db.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.4
- */
-public class CloseDbAction extends AbstractMainUITuttiAction {
-
- protected String jdbcUrl;
-
- public CloseDbAction(MainUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean canContinue = super.prepareAction();
- if (canContinue) {
- jdbcUrl = getConfig().getJdbcUrl();
- }
- return canContinue;
- }
-
- @Override
- public void doAction() {
-
- // close db
- getContext().getPersistenceService().clearAllCaches();
-
- // set to not reload a real db
- getContext().setDbLoaded(false);
-
- // close services + repon a fake persistence service
- getHandler().reloadPersistenceService();
-
- // clean db context
- getContext().clearDbContext();
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- sendMessage(_("tutti.flash.info.db.closed", jdbcUrl));
-
- // make sure title is reloaded
- handler.reloadDbManagerText();
- handler.changeTitle();
- }
-
- @Override
- public void postFailedAction(Throwable error) {
- handler.reloadDbManagerText();
- super.postFailedAction(error);
- }
-}
\ No newline at end of file
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -43,7 +43,7 @@
text: {handler.getInstallButtonText(model.isDbExist())};
toolTipText: {handler.getInstallButtonTip(model.isDbExist())};
i18nMnemonic: "tutti.dbManager.action.installDb.mnemonic";
- _applicationAction: {InstallOrReinstallDbAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.InstallOrReinstallDbAction.class};
_help: {"tutti.dbManager.action.installDb.help"};
}
@@ -51,7 +51,7 @@
actionIcon: import-db;
text: "tutti.dbManager.action.importDb";
i18nMnemonic: "tutti.dbManager.action.importDb.mnemonic";
- _applicationAction: {ImportOrReimportDbAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportOrReimportDbAction.class};
toolTipText: "tutti.dbManager.action.importDb.tip";
_help: {"tutti.dbManager.action.importDb.help"};
}
@@ -61,7 +61,7 @@
text: "tutti.dbManager.action.openDb";
i18nMnemonic: "tutti.dbManager.action.openDb.mnemonic";
visible: {model.isDbExist() && !model.isDbLoaded()};
- _applicationAction: {OpenDbAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.OpenDbAction.class};
toolTipText: "tutti.dbManager.action.openDb.tip";
_help: {"tutti.dbManager.action.openDb.help"};
}
@@ -71,7 +71,7 @@
text: "tutti.dbManager.action.upgradeDb";
i18nMnemonic: "tutti.dbManager.action.upgradeDb.mnemonic";
visible: {model.isDbLoaded()};
- _applicationAction: {UpdateDbAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.UpdateDbAction.class};
toolTipText: "tutti.dbManager.action.upgradeDb.tip";
_help: {"tutti.dbManager.action.upgradeDb.help"};
}
@@ -81,7 +81,7 @@
text: "tutti.dbManager.action.exportDb";
i18nMnemonic: "tutti.dbManager.action.exportDb.mnemonic";
visible: {model.isDbLoaded()};
- _applicationAction: {ExportDbAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportDbAction.class};
toolTipText: "tutti.dbManager.action.exportDb.tip";
_help: {"tutti.dbManager.action.exportDb.help"};
}
\ No newline at end of file
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.jaxx
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.jaxx 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/DbManagerUI.jaxx 2013-11-26 08:03:42 UTC (rev 1388)
@@ -27,7 +27,6 @@
<import>
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
fr.ifremer.tutti.ui.swing.TuttiUIContext
- fr.ifremer.tutti.ui.swing.content.UpdateDbAction
fr.ifremer.tutti.ui.swing.util.TuttiUI
javax.swing.border.EmptyBorder
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,137 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.db;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.ui.swing.RunTutti;
-import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To export a db attached to Tutti.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ExportAndCleanDbAction extends AbstractMainUITuttiAction {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ExportAndCleanDbAction.class);
-
- public static final DateFormat df = new SimpleDateFormat("yyy-MM-dd");
-
- protected File file;
-
- public ExportAndCleanDbAction(MainUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- file = null;
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // ask user file where to export db
-
- // choose file to import
- file = saveFile(
- "tutti-db-" + df.format(new Date()),
- "zip",
- _("tutti.dbManager.title.choose.dbExportFile"),
- _("tutti.dbManager.action.chooseDbExportFile"),
- "^.*\\.zip", _("tutti.common.file.zip")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void doAction() {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will export db to " + file);
- }
-
- ProgressionModel progressionModel = new ProgressionModel();
- setProgressionModel(progressionModel);
- progressionModel.setTotal(3);
-
- // close db
-
- progressionModel.setMessage(_("tutti.exportDb.step.closeDb"));
-
- // clear all caches
- getContext().getPersistenceService().clearAllCaches();
-
- // set to not reload a real db
- getContext().setDbLoaded(false);
-
- // close services + repon a fake persistence service
- getHandler().reloadPersistenceService();
-
- // clean db context
- getContext().clearDbContext();
-
- // export db
-
- progressionModel.increments(1);
- progressionModel.setMessage(_("tutti.exportDb.step.createArchive", file));
-
- getContext().getPersistenceService().exportDb(file);
-
- // clean files
-
- progressionModel.increments(1);
- progressionModel.setMessage(_("tutti.exportDb.step.reloadApplication"));
-
- // Close the application, will exit and restart application
- RunTutti.closeTutti(getHandler(), RunTutti.DELETE_DB_EXIT_CODE);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- sendMessage(_("tutti.flash.info.db.exported.and.clean", file));
-
- // make sure title is reloaded
- getUI().getHandler().changeTitle();
- }
-
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportDbAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportDbAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,131 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.db;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To export a db attached to Tutti.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ExportDbAction extends AbstractMainUITuttiAction {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(ExportDbAction.class);
-
- public static final int TOTAL_STEP = 3;
-
- protected File file;
-
- public static final DateFormat df = new SimpleDateFormat("yyy-MM-dd");
-
- public ExportDbAction(MainUIHandler handler) {
- super(handler, true);
- }
-
- public void setFile(File file) {
- this.file = file;
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- file = null;
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // ask user file where to export db
- file = saveFile(
- "tutti-db-" + df.format(new Date()),
- "zip",
- _("tutti.dbManager.title.choose.dbExportFile"),
- _("tutti.dbManager.action.chooseDbExportFile"),
- "^.*\\.zip", _("tutti.common.file.zip")
- );
- doAction = file != null;
- }
-
- if (doAction) {
-
- ProgressionModel progressionModel = new ProgressionModel();
- setProgressionModel(progressionModel);
- progressionModel.setTotal(TOTAL_STEP);
- }
- return doAction;
- }
-
- @Override
- public void doAction() {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will export db to " + file);
- }
-
- ProgressionModel progressionModel = getProgressionModel();
-
- // close db
-
- progressionModel.setMessage(_("tutti.exportDb.step.closeDb"));
-
- getContext().setDbLoaded(false);
- getHandler().reloadPersistenceService();
-
- // export
-
- progressionModel.increments(_("tutti.exportDb.step.createArchive", file));
-
- getContext().getPersistenceService().exportDb(file);
-
- // reopen db
-
- progressionModel.increments(_("tutti.exportDb.step.openDb"));
-
- getContext().setDbLoaded(true);
- getHandler().reloadPersistenceService();
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.flash.info.db.exported", file));
-
- // make sure title is reloaded
- getUI().getHandler().changeTitle();
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,333 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.db;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.shared.application.ApplicationBusinessException;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.persistence.TuttiPersistence;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import fr.ifremer.tutti.ui.swing.content.SelectCruiseAction;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.Version;
-
-import javax.swing.JOptionPane;
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To import a db and use it.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.1
- */
-public class ImportDbAction extends AbstractMainUITuttiAction {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(ImportDbAction.class);
-
- protected File importFile;
-
- protected String jdbcUrl;
-
- protected boolean updateSchema;
-
- protected boolean closeDb;
-
- protected Version dbVersion;
-
- protected Version applicationVersion;
-
- protected PersistenceService.ImportStructureType importStructureType;
-
- public ImportDbAction(MainUIHandler handler) {
- super(handler, true);
- setActionDescription(_("tutti.dbManager.action.importDb.tip"));
- }
-
- public void setImportFile(File importFile) {
- this.importFile = importFile;
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- importStructureType = null;
- jdbcUrl = null;
- dbVersion = applicationVersion = null;
- closeDb = updateSchema = false;
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- jdbcUrl = getConfig().getJdbcUrl();
-
- if (importFile == null) {
-
- // choose file to import
- importFile = chooseFile(
- _("tutti.dbManager.title.choose.dbImportFile"),
- _("tutti.dbManager.action.chooseDbFile"),
- "^.*\\.zip", _("tutti.common.file.zip")
- );
-
- if (importFile == null) {
-
- displayWarningMessage(
- _("tutti.dbManager.title.choose.dbImportFile"),
- _("tutti.dbManager.action.importdb.no.import.file.choosen")
- );
-
- doAction = false;
- }
- }
-
- if (doAction) {
-
- ProgressionModel progressionModel = new ProgressionModel();
- progressionModel.setTotal(3);
- setProgressionModel(progressionModel);
-
- importStructureType =
- getContext().getPersistenceService().checkImportStructure(importFile);
- }
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- importFile = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(importFile);
-
- if (log.isInfoEnabled()) {
- log.info("Will import db: " + importFile);
- }
-
- ProgressionModel progressionModel = getProgressionModel();
-
- // ------------------------------------------------------------------ //
- // --- import db //
- // ------------------------------------------------------------------ //
-
- progressionModel.increments(_("tutti.importDb.step.unzipArchive"));
-
- getContext().getPersistenceService().importDb(importStructureType, importFile);
-
- // ------------------------------------------------------------------ //
- // --- open db //
- // ------------------------------------------------------------------ //
-
- progressionModel.increments(_("tutti.importDb.step.openDb", jdbcUrl));
- try {
- getContext().setDbExist(true);
- getContext().setDbLoaded(true);
- handler.reloadPersistenceService();
- } catch (Exception e) {
-
- if (log.isErrorEnabled()) {
- log.error("Could not open db", e);
- }
- // no more db
- getContext().setDbLoaded(false);
- handler.reloadPersistenceService();
-
- // could not load db
- throw new ApplicationBusinessException(_("tutti.dbManager.action.importdb.couldNotOpen"), e);
- }
-
- // ------------------------------------------------------------------ //
- // --- check schema version //
- // ------------------------------------------------------------------ //
-
- progressionModel.increments(_("tutti.importDb.step.checkSchemaVersion"));
-
- TuttiPersistence persistenceService =
- handler.getPersistenceService();
-
- dbVersion = persistenceService.getDbVersion();
-
- if (log.isInfoEnabled()) {
- log.info("Detected database version: " + dbVersion);
- }
- applicationVersion = persistenceService.getApplicationVersion();
-
- if (log.isInfoEnabled()) {
- log.info("Detected schema application version:" + applicationVersion);
- }
-
- if (dbVersion == null) {
-
- // no database version filled (can not migrate schema)
- String message = _("tutti.dbManager.action.upgradeDb.schema.version.not.found");
- displayWarningMessage(_("tutti.dbManager.title.schema.toupdate"), message);
-
- closeDb = true;
- } else if (dbVersion.equals(applicationVersion)) {
-
- // database schema is up to date
- if (log.isInfoEnabled()) {
- log.info("Database schema is up-to-date at version: " + dbVersion);
- }
- } else if (dbVersion.compareTo(applicationVersion) < 0) {
-
- // database schema need to migrate
- // ask user to migrate or not (if not will close db)
-
- String message = _("tutti.dbManager.action.upgradeDb.schema.to.update.message", dbVersion, applicationVersion);
-
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- message,
- _("tutti.dbManager.action.upgradeDb.schema.to.update.message.help"));
- int i = JOptionPane.showConfirmDialog(
- handler.getTopestUI(),
- htmlMessage,
- _("tutti.dbManager.title.schema.toupdate"),
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.QUESTION_MESSAGE);
- boolean continueAction = i == JOptionPane.OK_OPTION;
-
- if (continueAction) {
-
- // will migrate
- updateSchema = true;
- } else {
-
- //close db
- closeDb = true;
- }
-
-
- } else {
-
- // database schema version is higher than application one
- String message = _("tutti.dbManager.action.upgradeDb.schema.too.high", dbVersion, applicationVersion);
-
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- message,
- _("tutti.dbManager.action.upgradeDb.schema.too.high.help"));
- int i = JOptionPane.showConfirmDialog(
- handler.getTopestUI(),
- htmlMessage,
- _("tutti.dbManager.title.schema.toupdate"),
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.QUESTION_MESSAGE);
- boolean continueAction = i == JOptionPane.OK_OPTION;
-
- if (!continueAction) {
-
- //close db
- closeDb = true;
- }
- }
-
- if (closeDb) {
-
- // ------------------------------------------------------------------ //
- // --- close db //
- // ------------------------------------------------------------------ //
-
- progressionModel.increments(_("tutti.importDb.step.closeDb"));
- getActionEngine().runInternalAction(handler, CloseDbAction.class);
-
- return;
- }
-
- if (updateSchema) {
-
- // need to migrate schema
- progressionModel.adaptTotal(progressionModel.getTotal() + 2);
-
- // ------------------------------------------------------------------ //
- // --- update schema //
- // ------------------------------------------------------------------ //
-
- String message = _("tutti.importDb.step.will.migrateSchema",
- dbVersion, applicationVersion);
-
- progressionModel.increments(message);
- sendMessage(message);
- handler.getPersistenceService().updateSchema();
-
- sendMessage(_("tutti.flash.info.db.schema.updated", dbVersion, applicationVersion));
- }
-
- // ------------------------------------------------------------------ //
- // --- check db context //
- // ------------------------------------------------------------------ //
-
- String message = _("tutti.importDb.step.check.dbContext",
- dbVersion, applicationVersion);
-
- progressionModel.increments(message);
-
- if (log.isDebugEnabled()) {
- log.debug("Check db context");
- }
- getContext().checkDbContext();
-
- // ------------------------------------------------------------------ //
- // --- change screen //
- // ------------------------------------------------------------------ //
-
- getActionEngine().runInternalAction(handler, SelectCruiseAction.class);
- }
-
- @Override
- public void postSuccessAction() {
- handler.reloadDbManagerText();
-
- super.postSuccessAction();
-
- if (closeDb) {
- sendMessage(_("tutti.flash.info.db.imported.but.closed", jdbcUrl));
- } else {
- sendMessage(_("tutti.flash.info.db.imported", jdbcUrl));
- }
-
- // make sure title is reloaded
- getUI().getHandler().changeTitle();
- }
-
- @Override
- public void postFailedAction(Throwable error) {
- handler.reloadDbManagerText();
- super.postFailedAction(error);
- }
-
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportOrReimportDbAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportOrReimportDbAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportOrReimportDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,73 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.db;
-
-/*
- * #%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.ui.swing.content.AbstractMainUITuttiAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-
-/**
- * To import or reimport a db (will delegate to correct action).
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.4
- */
-public class ImportOrReimportDbAction extends AbstractMainUITuttiAction {
-
- protected AbstractMainUITuttiAction delegateAction;
-
- public ImportOrReimportDbAction(MainUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- if (getContext().isDbExist()) {
-
- // reimport action
- delegateAction = getContext().getActionFactory().createLogicAction(getHandler(), ReimportDbAction.class);
- } else {
-
- // import action
- delegateAction = getContext().getActionFactory().createLogicAction(getHandler(), ImportDbAction.class);
- }
-
- setActionDescription(delegateAction.getActionDescription());
-
- return delegateAction.prepareAction();
- }
-
- @Override
- public void doAction() throws Exception {
-
- getActionEngine().runInternalAction(delegateAction);
- }
-
- @Override
- protected void releaseAction() {
- delegateAction = null;
- super.releaseAction();
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallDbAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallDbAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,126 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.db;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.TuttiConfiguration;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
-import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.updater.ApplicationUpdater;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To install (or reinstall) a db from last network one.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.4
- */
-public class InstallDbAction extends AbstractMainUITuttiAction {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(InstallDbAction.class);
-
- protected File backupFile;
-
- protected boolean doBackup;
-
- protected String jdbcUrl;
-
- public InstallDbAction(MainUIHandler handler) {
- super(handler, true);
- setActionDescription(_("tutti.dbManager.action.installDb.tip"));
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // check db url is reachable
- doAction = getContext().checkUpdateDataReachable();
- }
-
- if (doAction) {
-
- ProgressionModel progressionModel = new ProgressionModel();
- progressionModel.setTotal(2);
- setProgressionModel(progressionModel);
- }
- return doAction;
- }
-
- @Override
- public void doAction() {
-
- ProgressionModel progressionModel = getProgressionModel();
-
- // ------------------------------------------------------------------ //
- // --- install db //
- // ------------------------------------------------------------------ //
-
- TuttiConfiguration config = getConfig();
-
- File current = config.getDataDirectory();
- String url = config.getUpdateDataUrl();
-
- if (log.isInfoEnabled()) {
- log.info(String.format("Try to install / update db (current data location: %s), using update url: %s", current, url));
- }
-
- File dest = new File(config.getBasedir(), "NEW");
-
- progressionModel.increments(_("tutti.dbManager.action.upgradeDb.check"));
- TuttiDbUpdaterCallBack callback =
- new TuttiDbUpdaterCallBack(this, progressionModel);
- ApplicationUpdater up = new ApplicationUpdater();
- up.update(url,
- current,
- dest,
- false,
- callback,
- progressionModel);
-
- Preconditions.checkState(callback.isDbInstalled());
-
- progressionModel.increments(_("tutti.dbManager.action.upgradeDb.opening"));
-
- getContext().setDbExist(true);
-
- // ------------------------------------------------------------------ //
- // --- open db //
- // ------------------------------------------------------------------ //
-
- getActionEngine().runInternalAction(getHandler(), OpenDbAction.class);
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallOrReinstallDbAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallOrReinstallDbAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/InstallOrReinstallDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,74 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.db;
-
-/*
- * #%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.ui.swing.content.AbstractMainUITuttiAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-
-/**
- * To install or reinstall a db (will delegate to correct action).
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.4
- */
-public class InstallOrReinstallDbAction extends AbstractMainUITuttiAction {
-
- protected AbstractMainUITuttiAction delegateAction;
-
- public InstallOrReinstallDbAction(MainUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- if (getContext().isDbExist()) {
-
- // reinstall action
- delegateAction = getContext().getActionFactory().createLogicAction(getHandler(), ReinstallDbAction.class);
- } else {
-
- // install action
- delegateAction = getContext().getActionFactory().createLogicAction(getHandler(), InstallDbAction.class);
- }
-
- setActionDescription(delegateAction.getActionDescription());
-
- return delegateAction.prepareAction();
- }
-
- @Override
- public void doAction() throws Exception {
-
- getActionEngine().runInternalAction(delegateAction);
- }
-
- @Override
- protected void releaseAction() {
- delegateAction = null;
- super.releaseAction();
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/OpenDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,376 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.db;
-
-/*
- * #%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.shared.application.ApplicationBusinessException;
-import fr.ifremer.shared.application.swing.action.ApplicationUIAction;
-import fr.ifremer.tutti.TuttiConfiguration;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.persistence.TuttiPersistence;
-import fr.ifremer.tutti.ui.swing.TuttiDbUpdaterCallBack;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.updater.ApplicationInfo;
-import org.nuiton.updater.ApplicationUpdater;
-import org.nuiton.util.Version;
-
-import javax.swing.JOptionPane;
-import java.io.File;
-import java.util.Date;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To open existing db.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class OpenDbAction extends AbstractChangeScreenAction {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(OpenDbAction.class);
-
- protected Version dbVersion;
-
- protected Version applicationVersion;
-
- protected File file;
-
- protected boolean updateSchema;
-
- protected boolean updateReferentiel;
-
- protected boolean closeDb;
-
- protected String jdbcUrl;
-
- protected ApplicationInfo updateDbVersion;
-
- public OpenDbAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.SELECT_CRUISE);
- setActionDescription(_("tutti.dbManager.action.openDb.tip"));
- }
-
- public void setUpdateReferentiel(boolean updateReferentiel) {
- this.updateReferentiel = updateReferentiel;
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean canContinue = super.prepareAction();
- if (canContinue) {
- jdbcUrl = null;
- dbVersion = applicationVersion = null;
- file = null;
- closeDb = updateSchema = false;
- updateDbVersion = null;
-
- updateReferentiel &= getContext().checkUpdateDataReachable();
-
- if (updateReferentiel) {
-
- // get the next db version
- ApplicationUpdater up = new ApplicationUpdater();
-
- // get db updates
- Map<String, ApplicationInfo> dbVersions =
- up.getVersions(getConfig().getUpdateDataUrl(),
- getConfig().getDataDirectory());
- updateDbVersion =
- dbVersions.get(TuttiDbUpdaterCallBack.DB_UPDATE_NAME);
-
- if (updateDbVersion != null && updateDbVersion.newVersion != null) {
-
- // ask user if it wants to do the update
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- _("tutti.dbManager.updatedb.found", updateDbVersion.newVersion),
- _("tutti.common.askBeforeUpdate.help"));
- int i = JOptionPane.showConfirmDialog(
- getHandler().getTopestUI(),
- htmlMessage,
- _("tutti.dbManager.title.confirm.updatedb"),
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.QUESTION_MESSAGE);
-
- updateReferentiel = i == JOptionPane.OK_OPTION;
- }
-
- }
- }
- return canContinue;
- }
-
- @Override
- public void doAction() throws Exception {
-
- if (log.isDebugEnabled()) {
- log.debug("Will open db...");
- }
-
- jdbcUrl = getConfig().getJdbcUrl();
-
- // at the beginning 3 steps (open db + check version + check db context)
- ProgressionModel progressionModel = new ProgressionModel();
- setProgressionModel(progressionModel);
- progressionModel.setTotal(3 + (updateReferentiel ? 1 : 0));
-
- // ------------------------------------------------------------------ //
- // --- open db //
- // ------------------------------------------------------------------ //
-
- progressionModel.increments(_("tutti.openDb.step.open", jdbcUrl));
- try {
- getContext().setDbLoaded(true);
- getHandler().reloadPersistenceService();
- } catch (Exception e) {
-
- if (log.isErrorEnabled()) {
- log.error("Could not open db", e);
- }
- // no more db
- getContext().setDbLoaded(false);
- getHandler().reloadPersistenceService();
-
- // could not load db
- throw new ApplicationBusinessException(_("tutti.dbManager.action.openDb.couldNotOpen"));
- }
-
- // ------------------------------------------------------------------ //
- // --- check schema version //
- // ------------------------------------------------------------------ //
-
- progressionModel.increments(_("tutti.openDb.step.checkSchemaVersion"));
-
- TuttiPersistence persistenceService =
- getHandler().getPersistenceService();
-
- dbVersion = persistenceService.getDbVersion();
-
- if (log.isInfoEnabled()) {
- log.info("Detected database version: " + dbVersion);
- }
- applicationVersion = persistenceService.getApplicationVersion();
-
- if (log.isInfoEnabled()) {
- log.info("Detected schema application version:" + applicationVersion);
- }
-
- TuttiConfiguration config = getConfig();
- if (dbVersion.equals(applicationVersion)) {
-
- // database schema is up to date
- if (log.isInfoEnabled()) {
- log.info("Database schema is up-to-date at version: " + dbVersion);
- }
- } else if (dbVersion.compareTo(applicationVersion) < 0) {
-
- // database schema need to migrate
- // ask user to migrate or not (if not will close db)
-
- // ask user where to backup db
-
- String message = _("tutti.dbManager.action.upgradeDb.schema.to.update.message", dbVersion, applicationVersion);
-
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- message,
- _("tutti.dbManager.action.upgradeDb.schema.to.update.message.help"));
- int i = JOptionPane.showConfirmDialog(
- getHandler().getTopestUI(),
- htmlMessage,
- _("tutti.dbManager.title.schema.toupdate"),
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.QUESTION_MESSAGE);
- boolean continueAction = i == JOptionPane.OK_OPTION;
-
- if (continueAction) {
-
- // ask user file where to backup db
-
- file = saveFile(
- config.getDbBackupDirectory(),
- "tutti-db-" + ExportDbAction.df.format(new Date()),
- "zip",
- _("tutti.dbManager.title.choose.dbBackupFile"),
- _("tutti.dbManager.action.chooseDbBackupFile"),
- "^.*\\.zip", _("tutti.common.file.zip")
- );
-
- if (file == null) {
-
- // won't migrate db
- closeDb = true;
-
- displayWarningMessage(
- _("tutti.dbManager.title.choose.dbBackupFile"),
- _("tutti.dbManager.action.upgradeDb.no.backup.db.choosen")
- );
- } else {
-
- updateSchema = true;
- }
- } else {
-
- //close db
- closeDb = true;
- }
-
- } else {
-
- // database schema version is higher than application one
- displayWarningMessage(
- _("tutti.dbManager.title.schema.toupdate"),
- _("tutti.dbManager.action.upgradeDb.schema.not.update.message", dbVersion, applicationVersion)
- );
- }
-
- if (closeDb) {
-
- // ------------------------------------------------------------------ //
- // --- close current db //
- // ------------------------------------------------------------------ //
-
- progressionModel.increments(_("tutti.importDb.step.closeDb"));
- getActionEngine().runInternalAction(getHandler(), CloseDbAction.class);
-
- setScreen(TuttiScreen.MANAGE_DB);
- super.doAction();
- return;
- }
-
- if (updateSchema) {
-
- // need to export db + migrate schema)
- progressionModel.adaptTotal(progressionModel.getTotal() + ExportDbAction.TOTAL_STEP + 1);
-
- // ------------------------------------------------------------------ //
- // --- backup current db //
- // ------------------------------------------------------------------ //
-
- ApplicationUIAction<ExportDbAction> backupAction =
- getActionFactory().createUIAction(getHandler(), ExportDbAction.class);
- backupAction.getLogicAction().setProgressionModel(getProgressionModel());
- backupAction.getLogicAction().setFile(file);
- getActionEngine().runInternalAction(backupAction.getLogicAction());
-
- // ------------------------------------------------------------------ //
- // --- update schema //
- // ------------------------------------------------------------------ //
-
- String message = _("tutti.openDb.step.will.migrateSchema",
- dbVersion, applicationVersion);
-
- progressionModel.increments(message);
- sendMessage(message);
- getHandler().getPersistenceService().updateSchema();
- }
-
- if (updateReferentiel) {
-
- // ------------------------------------------------------------------ //
- // --- update referentiel //
- // ------------------------------------------------------------------ //
-
- progressionModel.increments(_("tutti.openDb.step.updateReferential"));
-
- File current = config.getDataDirectory();
- String url = config.getUpdateDataUrl();
-
- File dest = new File(config.getBasedir(), "NEW");
-
- progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.check"));
- TuttiDbUpdaterCallBack callback =
- new TuttiDbUpdaterCallBack(this, progressionModel);
- ApplicationUpdater up = new ApplicationUpdater();
- up.update(url,
- current,
- dest,
- false,
- callback,
- progressionModel);
-
- if (callback.isDbUpdated()) {
-
- progressionModel.setMessage(_("tutti.dbManager.action.upgradeDb.reloading"));
-
- } else {
- sendMessage(_("tutti.dbManager.action.upgradeDb.upToDate"));
- }
- }
-
- // ------------------------------------------------------------------ //
- // --- check db context //
- // ------------------------------------------------------------------ //
-
- String message = _("tutti.openDb.step.check.dbContext",
- dbVersion, applicationVersion);
-
- progressionModel.increments(message);
-
- if (log.isDebugEnabled()) {
- log.debug("Check db context");
- }
- getContext().checkDbContext();
-
- super.doAction();
- }
-
- @Override
- public void postSuccessAction() {
-
- handler.reloadDbManagerText();
-
- // make sure title is reloaded
- handler.changeTitle();
-
- if (closeDb) {
- sendMessage(_("tutti.flash.info.db.not.opened", jdbcUrl));
- } else {
-
- if (updateSchema) {
-
- sendMessage(_("tutti.flash.info.db.schema.updated", dbVersion, applicationVersion));
- }
-
- sendMessage(_("tutti.flash.info.db.opened", jdbcUrl));
- }
- }
-
- @Override
- public void postFailedAction(Throwable error) {
-
- handler.reloadDbManagerText();
-
- super.postFailedAction(error);
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ReimportDbAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ReimportDbAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ReimportDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,167 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.db;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.shared.application.ApplicationIOUtil;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.ui.swing.RunTutti;
-import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-
-import java.io.File;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To import a db after restart application.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.1
- */
-public class ReimportDbAction extends AbstractMainUITuttiAction {
-
- protected File backupFile;
-
- protected File importFile;
-
- protected String jdbcUrl;
-
- public ReimportDbAction(MainUIHandler handler) {
- super(handler, true);
- setActionDescription(_("tutti.dbManager.action.importDb.tip"));
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- jdbcUrl = null;
- backupFile = importFile = null;
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- jdbcUrl = getConfig().getJdbcUrl();
-
- if (getModel().isDbExist()) {
-
- displayInfoMessage(
- _("tutti.dbManager.title.backup.db"),
- _("tutti.dbManager.action.importDb.backup.db")
- );
-
- // choose backup file
- backupFile = saveFile(
- getConfig().getDbBackupDirectory(),
- "tutti-db-" + ExportDbAction.df.format(new Date()),
- "zip",
- _("tutti.dbManager.title.choose.dbExportFile"),
- _("tutti.dbManager.action.chooseDbExportFile"),
- "^.*\\.zip", _("tutti.common.file.zip")
- );
-
- if (backupFile == null) {
-
- displayWarningMessage(
- _("tutti.dbManager.title.backup.db"),
- _("tutti.dbManager.action.importdb.no.backup.db.choosen")
- );
-
- doAction = false;
- }
- }
-
- if (doAction && importFile == null) {
-
- // choose file to import
- importFile = chooseFile(
- _("tutti.dbManager.title.choose.dbImportFile"),
- _("tutti.dbManager.action.chooseDbFile"),
- "^.*\\.zip", _("tutti.common.file.zip")
- );
-
- if (importFile == null) {
-
- displayWarningMessage(
- _("tutti.dbManager.title.choose.dbImportFile"),
- _("tutti.dbManager.action.importdb.no.import.file.choosen")
- );
-
- doAction = false;
- }
- }
-
- if (doAction) {
-
- ProgressionModel progressionModel = new ProgressionModel();
- progressionModel.setTotal(3);
- setProgressionModel(progressionModel);
-
- getContext().getPersistenceService().checkImportStructure(importFile);
- }
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- importFile = backupFile = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(importFile);
- Preconditions.checkNotNull(backupFile);
-
- ProgressionModel progressionModel = getProgressionModel();
-
- // close db
- progressionModel.increments(_("tutti.reimport.step.closeDb", jdbcUrl));
- getContext().setDbLoaded(false);
- getHandler().reloadPersistenceService();
-
- // backup db
- progressionModel.increments(_("tutti.reimport.step.backupDb", backupFile));
- getContext().getPersistenceService().exportDb(backupFile);
-
- // clean db context
- getContext().clearDbContext();
-
- // write restart action file (will be load at restart)
- String actionContent = ImportDbAction.class.getName() + ":" + importFile.getAbsolutePath();
-
- File startActionFile = getConfig().getStartActionFile();
- ApplicationIOUtil.writeContent(startActionFile, actionContent, _("tutti.error.write.startActionFile", startActionFile));
-
- // restart application
- progressionModel.increments(_("tutti.reimport.step.reloadApplication"));
-
- RunTutti.closeTutti(getHandler(), RunTutti.DELETE_DB_EXIT_CODE);
- }
-
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ReinstallDbAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ReinstallDbAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ReinstallDbAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,146 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.db;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.shared.application.ApplicationIOUtil;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.ui.swing.RunTutti;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-
-import java.io.File;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To install (or reinstall) a db from last network one.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.4
- */
-public class ReinstallDbAction extends AbstractMainUITuttiAction {
-
- protected File backupFile;
-
- protected String jdbcUrl;
-
- public ReinstallDbAction(MainUIHandler handler) {
- super(handler, true);
- setActionDescription(_("tutti.dbManager.action.installDb.tip"));
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // check we can connect to remote install server
-
- // check db url is reachable
- TuttiUIContext context = getContext();
- doAction = context.checkUpdateDataReachable();
- }
-
- if (doAction) {
-
- jdbcUrl = null;
- backupFile = null;
-
- jdbcUrl = getConfig().getJdbcUrl();
-
- if (getModel().isDbExist()) {
-
- displayInfoMessage(
- _("tutti.dbManager.title.backup.db"),
- _("tutti.dbManager.action.installDb.backup.db")
- );
-
- // choose backup file
- backupFile = saveFile(
- getConfig().getDbBackupDirectory(),
- "tutti-db-" + ExportDbAction.df.format(new Date()),
- "zip",
- _("tutti.dbManager.title.choose.dbExportFile"),
- _("tutti.dbManager.action.chooseDbExportFile"),
- "^.*\\.zip", _("tutti.common.file.zip")
- );
-
- if (backupFile == null) {
-
- displayWarningMessage(
- _("tutti.dbManager.title.backup.db"),
- _("tutti.dbManager.action.installDb.no.backup.db.choosen")
- );
-
- doAction = false;
- }
- }
- }
-
- if (doAction) {
-
- ProgressionModel progressionModel = new ProgressionModel();
- progressionModel.setTotal(3);
- setProgressionModel(progressionModel);
- }
- return doAction;
- }
-
- @Override
- public void doAction() {
-
- Preconditions.checkNotNull(backupFile);
-
- ProgressionModel progressionModel = getProgressionModel();
-
- // close db
- progressionModel.increments(_("tutti.reinstallDb.step.closeDb", jdbcUrl));
-
- getContext().setDbLoaded(false);
- getHandler().reloadPersistenceService();
-
- // backup db
- progressionModel.increments(_("tutti.reinstallDb.step.backupDb", backupFile));
- getContext().getPersistenceService().exportDb(backupFile);
-
- // clean db context
- getContext().clearDbContext();
-
- // write restart action file (will be loaded at restart)
- String actionContent = InstallDbAction.class.getName();
-
- File startActionFile = getConfig().getStartActionFile();
- ApplicationIOUtil.writeContent(startActionFile, actionContent, _("tutti.error.write.startActionFile", startActionFile));
-
- // restart application
- progressionModel.increments(_("tutti.reinstallDb.step.reloadApplication"));
-
- RunTutti.closeTutti(getHandler(), RunTutti.DELETE_DB_EXIT_CODE);
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/CloneProtocolAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/CloneProtocolAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/CloneProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,161 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
-import jaxx.runtime.context.JAXXContextEntryDef;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JOptionPane;
-import javax.swing.UIManager;
-import java.util.Set;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Opens the protocol creation screen with the data of an already existing protocol.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class CloneProtocolAction extends AbstractChangeScreenAction {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(CloneProtocolAction.class);
-
- public static final JAXXContextEntryDef<TuttiProtocol> CLONE_PROTOCOL_ENTRY = new JAXXContextEntryDef<TuttiProtocol>("cloneProtocol", TuttiProtocol.class);
-
- protected TuttiProtocol protocol;
-
- public CloneProtocolAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.EDIT_PROTOCOL);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- CLONE_PROTOCOL_ENTRY.removeContextValue(getContext().getMainUI());
-
- boolean doAction = super.prepareAction();
- if (doAction) {
-
- // check that protocol is compatible with sample category model
- SampleCategoryModel sampleCategoryModel =
- getDataContext().getSampleCategoryModel();
-
- if (log.isInfoEnabled()) {
- log.info("Clone protocol: " + getContext().getProtocolId());
- }
-
- // get protocol
- protocol = getContext().getPersistenceService().getProtocol(getContext().getProtocolId());
-
- // remove id
- protocol.setId((String) null);
-
- Set<Integer> badCategories = Sets.newHashSet();
-
- TuttiProtocols.checkSampleCategories(sampleCategoryModel,
- protocol,
- badCategories);
-
- if (!badCategories.isEmpty()) {
-
- // detect some bad categories
- if (log.isWarnEnabled()) {
- log.warn("There is some bad categories: " + badCategories);
- }
-
- String message = TuttiProtocols.getBadCategoriesMessage(
- badCategories,
- getDecorator(Caracteristic.class, null),
- getContext().getPersistenceService());
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- message,
- _("tutti.common.askBeforeCloneProtocol.help"));
- int response = JOptionPane.showOptionDialog(
- getContext().getActionUI(),
- htmlMessage,
- _("tutti.common.askBeforeEditProtocol.title"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.WARNING_MESSAGE,
- UIManager.getIcon("warning"),
- new Object[]{_("tutti.option.cleanAndClone"), _("tutti.option.clone"), _("tutti.option.cancel")},
- _("tutti.option.cancel")
- );
-
- switch (response) {
- case 0:
- // clean and clone
- if (log.isInfoEnabled()) {
- log.info("Clean and Clone");
- }
- TuttiProtocols.removeBadCategories(sampleCategoryModel,
- protocol);
- break;
-
- case 1:
- // clone with no clean
- if (log.isInfoEnabled()) {
- log.info("Clone with no cleaning");
- }
- break;
- default:
-
- // cancel
- doAction = false;
- }
- }
- }
- return doAction;
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(protocol);
-
- // store protocol in context
- CLONE_PROTOCOL_ENTRY.setContextValue(getContext().getMainUI(), protocol);
- protocol = null;
-
- createProgressionModelIfRequired(4);
-
- // removed selected protocol
- getContext().setProtocolId(null);
-
- super.doAction();
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,97 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To delete the selected protocol.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class DeleteProtocolAction extends AbstractTuttiAction<SelectCruiseUIModel, SelectCruiseUI, SelectCruiseUIHandler> {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(EditProtocolAction.class);
-
- public DeleteProtocolAction(SelectCruiseUIHandler handler) {
- super(handler, false);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
-
- TuttiProtocol protocol = getHandler().getModel().getProtocol();
-
- result &=
- askBeforeDelete(
- _("tutti.selectCruise.action.deleteProtocol.title"),
- _("tutti.selectCruise.action.deleteProtocol.message", protocol.getName())
- );
-
- return result;
- }
-
- @Override
- public void doAction() {
- TuttiProtocol protocol = getModel().getProtocol();
- Preconditions.checkNotNull(protocol);
- String id = protocol.getId();
- Preconditions.checkNotNull(id);
- if (log.isInfoEnabled()) {
- log.info("Delete protocol: " + id);
- }
-
- PersistenceService service = getContext().getPersistenceService();
- service.deleteProtocol(id);
-
- getModel().setProtocol(null);
-
- List<TuttiProtocol> protocols = getModel().getProtocols();
- protocols.remove(protocol);
-
- if (log.isInfoEnabled()) {
- log.info("nb protocols: " + protocols.size());
- }
- // reset (will clear combo-box)
- getModel().setProtocols(null);
-
- // set new list
- getModel().setProtocols(protocols);
-
- getHandler().resetEditProtolAction();
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditCatchesAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditCatchesAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditCatchesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,72 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.service.ValidationService;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Opens the operations edition screen.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class EditCatchesAction extends AbstractChangeScreenAction {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(EditCatchesAction.class);
-
- public EditCatchesAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.EDIT_FISHING_OPERATION);
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkState(getContext().isProgramFilled());
- Preconditions.checkState(getContext().isCruiseFilled());
- if (log.isInfoEnabled()) {
- log.info("Edit operations of cruise: " + getContext().getCruiseId());
- }
- getContext().setValidationContext(ValidationService.VALIDATION_CONTEXT_EDIT);
- super.doAction();
- }
-
- @Override
- public void postFailedAction(Throwable error) {
-// TuttiUIContext context = getContext();
-// if (error != null) {
-// if (context.isDbLoaded()) {
-// context.setScreen(TuttiScreen.SELECT_CRUISE);
-// } else {
-// context.setScreen(TuttiScreen.MANAGE_DB);
-// }
-// }
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditCruiseAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditCruiseAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditCruiseAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,50 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-
-/**
- * Opens the cruise edition screen.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class EditCruiseAction extends AbstractChangeScreenAction {
-
- public EditCruiseAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.EDIT_CRUISE);
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkState(getContext().isProgramFilled());
- Preconditions.checkState(getContext().isCruiseFilled());
- super.doAction();
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProgramAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProgramAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProgramAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,57 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Opens the program edition screen.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class EditProgramAction extends AbstractChangeScreenAction {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(EditProgramAction.class);
-
- public EditProgramAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.EDIT_PROGRAM);
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkState(getContext().isProgramFilled());
- if (log.isInfoEnabled()) {
- log.info("Edit program: " + getContext().getProgramId());
- }
- super.doAction();
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProtocolAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProtocolAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,155 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
-import jaxx.runtime.context.JAXXContextEntryDef;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JOptionPane;
-import javax.swing.UIManager;
-import java.util.Set;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Opens the protocol edition screen.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class EditProtocolAction extends AbstractChangeScreenAction {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(EditProtocolAction.class);
-
- public static final JAXXContextEntryDef<TuttiProtocol> CLEAN_PROTOCOL_ENTRY = new JAXXContextEntryDef<TuttiProtocol>("cleanProtocol", TuttiProtocol.class);
-
- public EditProtocolAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.EDIT_PROTOCOL);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- CLEAN_PROTOCOL_ENTRY.removeContextValue(getContext().getMainUI());
-
- boolean doAction = super.prepareAction();
- if (doAction) {
-
- // check that protocol is compatible with sample category model
- SampleCategoryModel sampleCategoryModel =
- getDataContext().getSampleCategoryModel();
-
- TuttiProtocol protocol = getDataContext().getProtocol();
-
- Set<Integer> badCategories = Sets.newHashSet();
-
- TuttiProtocols.checkSampleCategories(sampleCategoryModel,
- protocol,
- badCategories);
-
- if (!badCategories.isEmpty()) {
-
- // detect some bad categories
- if (log.isWarnEnabled()) {
- log.warn("There is some bad categories: " + badCategories);
- }
-
- String message = TuttiProtocols.getBadCategoriesMessage(
- badCategories,
- getDecorator(Caracteristic.class, null),
- getContext().getPersistenceService());
-
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- message,
- _("tutti.common.askBeforeEditProtocol.help"));
- int response = JOptionPane.showOptionDialog(
- getContext().getActionUI(),
- htmlMessage,
- _("tutti.common.askBeforeEditProtocol.title"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.WARNING_MESSAGE,
- UIManager.getIcon("warning"),
- new Object[]{_("tutti.option.cleanAndEdit"), _("tutti.option.edit"), _("tutti.option.cancel")},
- _("tutti.option.cancel")
- );
-
- switch (response) {
- case 0:
- // edit and clean
- if (log.isInfoEnabled()) {
- log.info("Clean and edit");
- }
-
- protocol = getContext().getPersistenceService().getProtocol(getContext().getProtocolId());
-
- CLEAN_PROTOCOL_ENTRY.setContextValue(getContext().getMainUI(), protocol);
-
- TuttiProtocols.removeBadCategories(sampleCategoryModel,
- protocol);
-
- break;
-
- case 1:
- // edit with no modification
- if (log.isInfoEnabled()) {
- log.info("Edit with no cleaning");
- }
- break;
-
- default:
-
- // cancel
- doAction = false;
- }
-
- }
- }
- return doAction;
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkState(getContext().isProtocolFilled());
- if (log.isInfoEnabled()) {
- log.info("Edit protocol: " + getContext().getProtocolId());
- }
- createProgressionModelIfRequired(4);
- super.doAction();
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,130 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.shared.application.ApplicationBusinessException;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.service.export.generic.TuttiExportService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To export a selected cruise.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class ExportCruiseAction extends AbstractTuttiAction<SelectCruiseUIModel, SelectCruiseUI, SelectCruiseUIHandler> {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(ExportCruiseAction.class);
-
- protected File file;
-
- public ExportCruiseAction(SelectCruiseUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- Cruise cruise = getModel().getCruise();
-
- // choose file to export
- file = saveFile(
- "exportCruise-" + cruise.getName(),
- "zip",
- _("tutti.selectCruise.title.choose.exportCruiseFile"),
- _("tutti.selectCruise.action.chooseCruiseExportFile"),
- "^.+\\.zip$", _("tutti.common.file.zip")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Cruise cruise = getModel().getCruise();
- Preconditions.checkNotNull(cruise);
- Preconditions.checkNotNull(file);
-
- if (log.isInfoEnabled()) {
- log.info("Will save cruise " + cruise.getId() +
- " to file: " + file);
- }
-
- ProgressionModel progressionModel = new ProgressionModel();
- setProgressionModel(progressionModel);
- // (check cruise / export cruise / gear caracteristics / operation / parameter / accidental catches / catches / individual observation / species) / zip
- progressionModel.setTotal(10);
-
-// TuttiProtocol protocol = null;
-// if (getContext().isProtocolFilled()) {
-// protocol = getDataContext().getProtocol();
-// if (log.isInfoEnabled()) {
-// log.info("Will use protocol " + protocol.getName());
-// }
-// }
-
- ApplicationBusinessException exportError = null;
-
- TuttiExportService service = getContext().getTuttiExportService();
- try {
- service.exportCruise(cruise.getId(), file, progressionModel);
- } catch (ApplicationBusinessException e) {
-
- String errorMessage;
- errorMessage = _("tutti.exportCruise.action.exportErrors", cruise.getName(), e.getMessage());
- exportError = new ApplicationBusinessException(errorMessage);
- }
-
- sendMessage(_("tutti.exportCruise.action.success",
- cruise.getName(), file.getName()));
-
- handler.resetEditCruiseAction();
-
- if (exportError != null) {
- throw exportError;
- }
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseForSumatraAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseForSumatraAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseForSumatraAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,109 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.service.export.sumatra.CatchesSumatraExportService;
-import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.DateUtil;
-
-import java.io.File;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Opens a file chooser, exports the cruise catches into the selected file and open the default email editor.
- *
- * @author kmorin <morin(a)codelutin.com>
- * @since 1.0
- */
-public class ExportCruiseForSumatraAction extends AbstractMainUITuttiAction {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ExportCruiseForSumatraAction.class);
-
- protected File file;
-
- public ExportCruiseForSumatraAction(MainUIHandler handler) {
- super(handler, false);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- String date = DateUtil.formatDate(new Date(), "dd-MM-yyyy");
- // choose file to export
- file = saveFile(
- String.format("sumatra_%s_%s", getDataContext().getCruise().getName(), date),
- "csv",
- _("tutti.exportCruiseForSumatra.title.choose.exportFile"),
- _("tutti.exportCruiseForSumatra.action.chooseFile"),
- "^.+\\.csv$", _("tutti.common.file.csv")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Cruise cruise = getDataContext().getCruise();
- Preconditions.checkNotNull(cruise);
- Preconditions.checkNotNull(file);
-
- if (log.isInfoEnabled()) {
- log.info("Will export cruise " + cruise.getId() +
- " to file: " + file);
- }
-
- // export catches
- CatchesSumatraExportService service =
- getContext().getCatchesSumatraExportService();
- service.exportCruiseForSumatra(file, cruise.getId());
-
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.exportCruiseForSumatra.action.success", file));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,133 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.shared.application.ApplicationBusinessException;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.service.export.generic.TuttiExportService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To export a selected program.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.0
- */
-public class ExportProgramAction extends AbstractTuttiAction<SelectCruiseUIModel, SelectCruiseUI, SelectCruiseUIHandler> {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(ExportProgramAction.class);
-
- protected File file;
-
- public ExportProgramAction(SelectCruiseUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- Program program = getModel().getProgram();
- if (doAction) {
-
- // choose file to export
- file = saveFile(
- "exportProgram-" + program.getName(), "zip",
- _("tutti.selectCruise.title.choose.exportProgramFile"),
- _("tutti.selectCruise.action.chooseProgramExportFile"),
- "^.+\\.zip$", _("tutti.common.file.zip")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Program program = getModel().getProgram();
- Preconditions.checkNotNull(program);
- Preconditions.checkNotNull(file);
-
- if (log.isInfoEnabled()) {
- log.info("Will save program " + program.getId() +
- " to file: " + file);
- }
-
- // nbCruise * (check cruise / export cruise / gear caracteristics / operation / parameter / catches / individual observation / accidental catches / species) + zip
- List<Cruise> allCruise =
- getContext().getPersistenceService().getAllCruise(program.getId());
-
- ProgressionModel progressionModel = new ProgressionModel();
- setProgressionModel(progressionModel);
- progressionModel.setTotal(9 * allCruise.size() + 1);
-
-// TuttiProtocol protocol = null;
-// if (getContext().isProtocolFilled()) {
-// protocol = getDataContext().getProtocol();
-// if (log.isInfoEnabled()) {
-// log.info("Will use protocol " + protocol.getName());
-// }
-// }
- ApplicationBusinessException exportError = null;
-
- TuttiExportService service = getContext().getTuttiExportService();
- try {
- service.exportProgram(program.getId(), file, progressionModel);
- } catch (ApplicationBusinessException e) {
-
- String errorMessage;
- errorMessage = _("tutti.exportProgram.action.exportErrors", program.getName(), e.getMessage());
-
- exportError = new ApplicationBusinessException(errorMessage);
- }
-
- handler.resetEditProgramAction();
-
- sendMessage(_("tutti.exportProgram.action.success", program.getName(),
- file.getName()));
-
- if (exportError != null) {
- throw exportError;
- }
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,108 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Opens a file chooser and exports the protocol into the selected file.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ExportProtocolAction extends AbstractTuttiAction<SelectCruiseUIModel, SelectCruiseUI, SelectCruiseUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ExportProtocolAction.class);
-
- protected File file;
-
- public ExportProtocolAction(SelectCruiseUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- TuttiProtocol protocol = getModel().getProtocol();
- // choose file to export
- file = saveFile(
- "protocol-" + protocol.getName().replaceAll(" ", "_") ,
- "tuttiProtocol",
- _("tutti.selectCruise.title.choose.exportFile"),
- _("tutti.selectCruise.action.exportProtocol"),
- "^.+\\.tuttiProtocol$", _("tutti.common.file.protocol")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- TuttiProtocol protocol = getModel().getProtocol();
- Preconditions.checkNotNull(protocol);
- Preconditions.checkNotNull(file);
-
- if (log.isInfoEnabled()) {
- log.info("Will save protocol " + protocol.getId() +
- " to file: " + file);
- }
-
- // export protocol
- ProtocolImportExportService service =
- getContext().getTuttiProtocolImportExportService();
- service.exportProtocol(protocol, file);
-
- getHandler().resetEditProtolAction();
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- TuttiProtocol protocol = getModel().getProtocol();
- sendMessage(_("tutti.exportProtocol.action.success", protocol.getName(), file.getName()));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,181 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
-import jaxx.runtime.context.JAXXContextEntryDef;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JOptionPane;
-import javax.swing.UIManager;
-import java.io.File;
-import java.util.Set;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Opens a file chooser and imports the protocol from the selected file.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ImportProtocolAction extends AbstractChangeScreenAction {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ImportProtocolAction.class);
-
- public static final JAXXContextEntryDef<TuttiProtocol> IMPORT_PROTOCOL_ENTRY = new JAXXContextEntryDef<TuttiProtocol>("importProtocol", TuttiProtocol.class);
-
- protected TuttiProtocol protocol;
-
- public ImportProtocolAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.EDIT_PROTOCOL);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- IMPORT_PROTOCOL_ENTRY.removeContextValue(getContext().getMainUI());
-
- boolean doAction = super.prepareAction();
-
- File file = null;
-
- if (doAction) {
- // choose file to import
- file = chooseFile(
- _("tutti.selectCruise.title.choose.importFile"),
- _("tutti.selectCruise.action.importProtocol"),
- "^.+\\.tuttiProtocol$", _("tutti.common.file.protocol")
- );
-
- doAction = file != null;
- }
-
- if (doAction) {
-
- // import protocol
- if (log.isInfoEnabled()) {
- log.info("Will import protocol file: " + file);
- }
-
- ProtocolImportExportService service =
- getContext().getTuttiProtocolImportExportService();
-
- protocol = service.importProtocol(file);
-
- // remove id
- protocol.setId((String) null);
-
- sendMessage(_("tutti.importProtocol.action.success", protocol.getName()));
-
- // check that protocol is compatible with sample category model
- SampleCategoryModel sampleCategoryModel =
- getDataContext().getSampleCategoryModel();
-
- Set<Integer> badCategories = Sets.newHashSet();
-
- TuttiProtocols.checkSampleCategories(sampleCategoryModel,
- protocol,
- badCategories);
-
- if (!badCategories.isEmpty()) {
-
- // detect some bad categories
- if (log.isWarnEnabled()) {
- log.warn("There is some bad categories: " + badCategories);
- }
-
- String message = TuttiProtocols.getBadCategoriesMessage(
- badCategories,
- getDecorator(Caracteristic.class, null),
- getContext().getPersistenceService());
-
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- message,
- _("tutti.common.askBeforeImportProtocol.help"));
- int response = JOptionPane.showOptionDialog(
- getContext().getActionUI(),
- htmlMessage,
- _("tutti.common.askBeforeEditProtocol.title"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.WARNING_MESSAGE,
- UIManager.getIcon("warning"),
- new Object[]{_("tutti.option.cleanAndImport"), _("tutti.option.import"), _("tutti.option.cancel")},
- _("tutti.option.cancel")
- );
-
- switch (response) {
- case 0:
- // clean and import
- if (log.isInfoEnabled()) {
- log.info("Clean and Import");
- }
- TuttiProtocols.removeBadCategories(sampleCategoryModel,
- protocol);
- break;
- case 1:
- // import with no clean
- if (log.isInfoEnabled()) {
- log.info("Import with no cleaning");
- }
- break;
- default:
-
- // cancel
- doAction = false;
- }
- }
- }
- return doAction;
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(protocol);
-
- // store protocol in context
- IMPORT_PROTOCOL_ENTRY.setContextValue(getContext().getMainUI(), protocol);
- protocol = null;
- createProgressionModelIfRequired(4);
-
- // removed selected protocol
- getContext().setProtocolId(null);
- super.doAction();
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewCruiseAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewCruiseAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewCruiseAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,48 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%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.ui.swing.TuttiScreen;
-import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-
-/**
- * Opens the cruise creation screen.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class NewCruiseAction extends AbstractChangeScreenAction {
-
- public NewCruiseAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.EDIT_CRUISE);
- }
-
- @Override
- public void doAction() throws Exception {
- getContext().setCruiseId(null);
- super.doAction();
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewProgramAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewProgramAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewProgramAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,49 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%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.ui.swing.TuttiScreen;
-import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-
-/**
- * Opens the program creation screen.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class NewProgramAction extends AbstractChangeScreenAction {
-
- public NewProgramAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.EDIT_PROGRAM);
- }
-
- @Override
- public void doAction() throws Exception {
- getContext().setProgramId(null);
- getContext().setCruiseId(null);
- super.doAction();
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewProtocolAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewProtocolAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/NewProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,49 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%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.ui.swing.TuttiScreen;
-import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-
-/**
- * Opens the protocol creation screen.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class NewProtocolAction extends AbstractChangeScreenAction {
-
- public NewProtocolAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.EDIT_PROTOCOL);
- }
-
- @Override
- public void doAction() throws Exception {
- getContext().setProtocolId(null);
- createProgressionModelIfRequired(4);
- super.doAction();
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -65,7 +65,7 @@
#editProgramButton {
actionIcon: edit;
text: "tutti.selectCruise.action.editProgram";
- _applicationAction: {EditProgramAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.EditProgramAction.class};
toolTipText: "tutti.selectCruise.action.editProgram.tip";
_help: {"tutti.selectCruise.action.editProgram.help"};
}
@@ -74,7 +74,7 @@
actionIcon: export;
text: "tutti.selectCruise.action.exportProgram";
enabled: false;
- _applicationAction: {ExportProgramAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportProgramAction.class};
toolTipText: "tutti.selectCruise.action.exportProgram.tip";
_help: {"tutti.selectCruise.action.exportProgram.help"};
}
@@ -82,7 +82,7 @@
#newProgramButton {
actionIcon: add;
text: "tutti.selectCruise.action.newProgram";
- _applicationAction: {NewProgramAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.NewProgramAction.class};
toolTipText: "tutti.selectCruise.action.newProgram.tip";
_help: {"tutti.selectCruise.action.newProgram.help"};
}
@@ -111,7 +111,7 @@
#editCruiseButton {
actionIcon: edit;
text: "tutti.selectCruise.action.editCruise";
- _applicationAction: {EditCruiseAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.EditCruiseAction.class};
toolTipText: "tutti.selectCruise.action.editCruise.tip";
_help: {"tutti.selectCruise.action.editCruise.help"};
}
@@ -120,7 +120,7 @@
actionIcon: export;
text: "tutti.selectCruise.action.exportCruise";
enabled: false;
- _applicationAction: {ExportCruiseAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportCruiseAction.class};
toolTipText: "tutti.selectCruise.action.exportCruise.tip";
_help: {"tutti.selectCruise.action.exportCruise.help"};
}
@@ -129,7 +129,7 @@
actionIcon: email;
text: "tutti.selectCruise.action.sendCruiseReport";
toolTipText: "tutti.selectCruise.action.sendCruiseReport.tip";
- _applicationAction: {SendCruiseReportAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SendCruiseReportAction.class};
_help: {"tutti.selectCruise.action.sendCruiseReport.help"};
}
@@ -137,7 +137,7 @@
actionIcon: export;
text: "tutti.selectCruise.action.exportCruiseForSumatra";
toolTipText: "tutti.selectCruise.action.exportCruiseForSumatra.tip";
- _applicationAction: {ExportCruiseForSumatraAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportCruiseForSumatraAction.class};
_help: {"tutti.selectCruise.action.exportCruiseForSumatra.help"};
}
@@ -145,7 +145,7 @@
actionIcon: add;
text: "tutti.selectCruise.action.newCruise";
enabled: {model.isProgramFound()};
- _applicationAction: {NewCruiseAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.NewCruiseAction.class};
toolTipText: "tutti.selectCruise.action.newCruise.tip";
_help: {"tutti.selectCruise.action.newCruise.help"};
}
@@ -179,7 +179,7 @@
#newProtocolButton {
actionIcon: add;
text: "tutti.selectCruise.action.newProtocol";
- _applicationAction: {NewProtocolAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.NewProtocolAction.class};
toolTipText: "tutti.selectCruise.action.newProtocol.tip";
_help: {"tutti.selectCruise.action.newProtocol.help"};
}
@@ -187,7 +187,7 @@
#importProtocolButton {
actionIcon: import;
text: "tutti.selectCruise.action.importProtocol";
- _applicationAction: {ImportProtocolAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportProtocolAction.class};
toolTipText: "tutti.selectCruise.action.importProtocol.tip";
_help: {"tutti.selectCruise.action.importProtocol.help"};
}
@@ -195,7 +195,7 @@
#editProtocolButton {
actionIcon: edit;
text: "tutti.selectCruise.action.editProtocol";
- _applicationAction: {EditProtocolAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.EditProtocolAction.class};
toolTipText: "tutti.selectCruise.action.editProtocol.tip";
_help: {"tutti.selectCruise.action.editProtocol.help"};
}
@@ -203,7 +203,7 @@
#cloneProtocolButton {
actionIcon: copy;
text: "tutti.selectCruise.action.cloneProtocol";
- _applicationAction: {CloneProtocolAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.CloneProtocolAction.class};
toolTipText: "tutti.selectCruise.action.cloneProtocol.tip";
_help: {"tutti.selectCruise.action.cloneProtocol.help"};
}
@@ -211,7 +211,7 @@
#exportProtocolButton {
actionIcon: export;
text: "tutti.selectCruise.action.exportProtocol";
- _applicationAction: {ExportProtocolAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportProtocolAction.class};
toolTipText: "tutti.selectCruise.action.exportProtocol.tip";
_help: {"tutti.selectCruise.action.exportProtocol.help"};
}
@@ -219,7 +219,7 @@
#deleteProtocolButton {
actionIcon: delete;
text: "tutti.selectCruise.action.deleteProtocol";
- _applicationAction: {DeleteProtocolAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.DeleteProtocolAction.class};
toolTipText: "tutti.selectCruise.action.deleteProtocol.tip";
_help: {"tutti.selectCruise.action.deleteProtocol.help"};
}
@@ -228,7 +228,7 @@
actionIcon: edit;
text: "tutti.selectCruise.action.editCatches";
i18nMnemonic: "tutti.selectCruise.action.editCatches.mnemonic";
- _applicationAction: {EditCatchesAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.EditCatchesAction.class};
enabled: {model.isValid() && uiContext.isCruiseFilled()};
toolTipText: "tutti.selectCruise.action.editCatches.tip";
_help: {"tutti.selectCruise.action.editCatches.help"};
@@ -239,7 +239,7 @@
text: "tutti.selectCruise.action.validateCatches";
toolTipText: "tutti.selectCruise.action.validateCatches.tip";
i18nMnemonic: "tutti.selectCruise.action.validateCatches.mnemonic";
- _applicationAction: {ValidateCatchesAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ValidateCatchesAction.class};
enabled: {model.isValid() && uiContext.isCruiseFilled()};
_help: {"tutti.selectCruise.action.validateCatches.help"};
}
\ No newline at end of file
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.jaxx 2013-11-26 08:03:42 UTC (rev 1388)
@@ -32,7 +32,7 @@
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.util.TuttiUI
- fr.ifremer.tutti.ui.swing.util.ActionListCellRenderer
+ fr.ifremer.shared.application.swing.util.ActionListCellRenderer
jaxx.runtime.swing.editor.bean.BeanFilterableComboBox
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SendCruiseReportAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SendCruiseReportAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SendCruiseReportAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,122 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.shared.application.ApplicationTechnicalException;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.service.export.pdf.CatchesPdfExportService;
-import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JOptionPane;
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Opens a file chooser, exports the cruise catches into the selected file and open the default email editor.
- *
- * @author kmorin <morin(a)codelutin.com>
- * @since 1.0
- */
-public class SendCruiseReportAction extends AbstractMainUITuttiAction {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(SendCruiseReportAction.class);
-
- protected File file;
-
- public SendCruiseReportAction(MainUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- Cruise cruise = getDataContext().getCruise();
- // choose file to export
- file = saveFile(
- "exportCruise-" + cruise.getName(),
- "pdf",
- _("tutti.sendCruiseReport.title.choose.exportFile"),
- _("tutti.sendCruiseReport.action.chooseFile"),
- "^.+\\.pdf$", _("tutti.common.file.pdf")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Cruise cruise = getDataContext().getCruise();
- Preconditions.checkNotNull(cruise);
- Preconditions.checkNotNull(file);
-
- if (log.isInfoEnabled()) {
- log.info("Will export cruise " + cruise.getId() +
- " to file: " + file);
- }
-
- // export catches
- CatchesPdfExportService service =
- getContext().getGeneratePDFService();
- service.generateCruisePDFFile(file, cruise.getId(), getConfig().getI18nLocale());
-
- try {
-
- TuttiUIUtil.mail(_("tutti.sendCruiseReport.mail.subject", cruise.getName()),
- _("tutti.sendCruiseReport.mail.body", cruise.getName(), file.getAbsolutePath()));
-
- } catch (ApplicationTechnicalException e) {
- JOptionPane.showMessageDialog(getContext().getMainUI(),
- _("tutti.sendCruiseReport.action.error.mail.message", file),
- _("tutti.sendCruiseReport.action.error.mail.title"),
- JOptionPane.WARNING_MESSAGE);
- }
-
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.sendCruiseReport.action.success", file));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ValidateCatchesAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ValidateCatchesAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ValidateCatchesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,61 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.home;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.service.ValidationService;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
-import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Opens the operations validation screen.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ValidateCatchesAction extends AbstractChangeScreenAction {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ValidateCatchesAction.class);
-
- public ValidateCatchesAction(MainUIHandler handler) {
- super(handler, true, TuttiScreen.VALIDATE_CRUISE);
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkState(getContext().isProgramFilled());
- Preconditions.checkState(getContext().isCruiseFilled());
- getContext().setValidationContext(ValidationService.VALIDATION_CONTEXT_VALIDATE);
- if (log.isInfoEnabled()) {
- log.info("Validate operations of cruise: " + getContext().getCruiseId());
- }
- super.doAction();
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,107 +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.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Cancels the edition of a fishing operation and potentially switch to another tab.
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.0
- */
-public class CancelEditFishingOperationAction extends AbstractTuttiAction<EditFishingOperationUIModel, EditFishingOperationUI, EditFishingOperationUIHandler> {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(SaveFishingOperationAction.class);
-
- /**
- * Delegate edit action.
- *
- * @since 1.0
- */
- protected EditFishingOperationAction editAction;
-
- public CancelEditFishingOperationAction(EditFishingOperationUIHandler handler) {
- super(handler, true);
- }
-
- public EditFishingOperationAction getEditAction() {
- if (editAction == null) {
- editAction = getContext().getActionFactory().createLogicAction(
- getHandler().getParentUi().getHandler(),
- EditFishingOperationAction.class);
- }
- return editAction;
- }
-
- @Override
- public void doAction() throws Exception {
-
- EditFishingOperationAction action = getEditAction();
-
- if (getModel().isCreate()) {
- if (log.isInfoEnabled()) {
- log.info("Cancel creation for fishingOperation");
- }
- // cancel to create a new fishingOperation
- action.setFishingOperation(null);
- getActionEngine().runInternalAction(action);
-
- } else {
-
- 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.setInternalAction(true);
- getActionEngine().runInternalAction(action);
- }
-
- //FIXME-TC Make sure this works again
-// // 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);
-// }
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- getEditAction().displayValidationErrors();
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/DeleteFishingOperationAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/DeleteFishingOperationAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/DeleteFishingOperationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,88 +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.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To delete a fishing operation.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.2
- */
-public class DeleteFishingOperationAction extends AbstractTuttiAction<FishingOperationsUIModel, FishingOperationsUI, FishingOperationsUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(DeleteFishingOperationAction.class);
-
- public DeleteFishingOperationAction(FishingOperationsUIHandler handler) {
- super(handler, true);
- setActionDescription(
- _("tutti.editFishingOperation.action.deleteFishingOperation.tip"));
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean canContinue = super.prepareAction();
- FishingOperation fishingOperation = getModel().getSelectedFishingOperation();
- canContinue &= fishingOperation != null &&
- !TuttiEntities.isNew(fishingOperation) &&
- askBeforeDelete(
- _("tutti.editFishingOperation.action.deleteFishingOperation.title"),
- _("tutti.editFishingOperation.action.deleteFishingOperation.message", decorate(fishingOperation))
- );
- return canContinue;
- }
-
- @Override
- public void doAction() throws Exception {
-
- FishingOperation fishingOperation =
- getModel().getSelectedFishingOperation();
-
- if (log.isInfoEnabled()) {
- log.info("Will delete fishingOperation: " + fishingOperation);
- }
-
- getContext().getPersistenceService().deleteFishingOperation(fishingOperation.getId());
-
- FishingOperationsUIModel model = getModel();
-
- // unselect removed fishing operation
- model.setSelectedFishingOperation(null);
-
- // remove it from selection model
- model.removeFishingOperation(fishingOperation);
-
- sendMessage(_("tutti.editFishingOperation.message.operation.deleted", decorate(fishingOperation)));
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,782 +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 com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import fr.ifremer.tutti.persistence.InvalidBatchModelException;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.Attachment;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatchs;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperations;
-import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrders;
-import fr.ifremer.tutti.persistence.entities.referential.Person;
-import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
-import fr.ifremer.tutti.persistence.entities.referential.Vessel;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.ComputeBatchWeightsAction;
-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.GearUseFeatureTabUI;
-import fr.ifremer.tutti.ui.swing.content.operation.fishing.VesselUseFeatureTabUI;
-import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JTabbedPane;
-import java.awt.BorderLayout;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-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> {
-
- /** 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;
-
- /**
- * Delegate action to compute the weight of the operations.
- *
- * @since 1.1
- */
- protected ComputeBatchWeightsAction computeBatchWeightsAction;
-
- /**
- * Delegate action to save catch batch.
- *
- * @since 1.0
- */
- protected SaveCatchBatchAction saveCatchBatchAction;
-
- /**
- * To keep catch validation error while loading batches.
- *
- * @since 2.4
- */
- protected List<String> errorMessages = Lists.newArrayList();
-
- /**
- * Flag to know if this action is part of another action.
- *
- * @since 2.4
- */
- protected boolean internalAction;
-
- /**
- * To recompute distance when coordinate change.
- *
- * @since 2.4
- */
- 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_DMS_SIGN,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DMS_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DMS_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DMS_SECOND,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DMD_SIGN,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DMD_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DMD_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DMS_SIGN,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DMS_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DMS_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DMS_SECOND,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DMD_SIGN,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DMD_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DMD_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DMS_SIGN,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DMS_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DMS_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DMS_SECOND,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DMD_SIGN,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DMD_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DMD_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DMS_SIGN,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DMS_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DMS_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DMS_SECOND,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DMD_SIGN,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DMD_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DMD_MINUTE
- );
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (properties.contains(evt.getPropertyName())) {
- EditFishingOperationUIModel source = (EditFishingOperationUIModel) evt.getSource();
- if (source.isFishingOperationRectiligne()) {
- source.computeDistance();
- }
- }
- }
- };
-
- public EditFishingOperationAction(FishingOperationsUIHandler handler) {
- super(handler, true);
- setActionDescription(_("tutti.editFishingOperation.action.editFishingOperation.tip"));
- }
-
- public void setFishingOperation(FishingOperation fishingOperation) {
- this.fishingOperation = fishingOperation;
- getDataContext().setFishingOperationId(fishingOperation != null ? fishingOperation.getId() : null);
- }
-
- public void setCheckPreviousEdit(boolean checkPreviousEdit) {
- this.checkPreviousEdit = checkPreviousEdit;
- }
-
- @Override
- public void releaseAction() {
- fishingOperation = null;
- checkPreviousEdit = true;
- internalAction = false;
- super.releaseAction();
- }
-
- 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;
- }
-
- protected ComputeBatchWeightsAction getComputeBatchWeightsAction() {
- if (computeBatchWeightsAction == null) {
- computeBatchWeightsAction = new ComputeBatchWeightsAction(getUI().getCatchesTabContent().getHandler());
- }
- return computeBatchWeightsAction;
- }
-
- @Override
- public boolean prepareAction() {
-
- boolean canContinue = true;
- if (checkPreviousEdit) {
- FishingOperationsUI ui = getUI();
-
- final FishingOperationsUIModel model = ui.getModel();
-
- FishingOperation editFishingOperation = model.getEditFishingOperation();
-
- String editFishingOperationId = null;
-
- if (editFishingOperation == null) {
-
- // no previous fishing operation in edition, can continue
- canContinue = true;
- } else {
-
- editFishingOperationId = editFishingOperation.getId();
-
- boolean create = TuttiEntities.isNew(editFishingOperation);
-
- boolean fishingOperationModified = getHandler().isFishingOperationModified();
- boolean catchBatchModified = getHandler().isCatchBatchModified();
-
- boolean fishingOperationValid = getHandler().isFishingOperationValid();
- boolean catchBatchValid = getHandler().isCatchBatchValid();
-
- boolean needSave = create || fishingOperationModified || catchBatchModified;
-
-
- if (needSave) {
-
- boolean canSave = fishingOperationValid && catchBatchValid;
-
- canContinue = false;
-
- if (canSave) {
-
- String message;
-
- if (create) {
- message = _("tutti.editFishingOperation.askSaveBeforeLeaving.createFishingOperation");
- } else if (fishingOperationModified) {
- message = _("tutti.editFishingOperation.askSaveBeforeLeaving.saveFishingOperation");
- } else {
- message = _("tutti.editCatchBatch.askSaveBeforeLeaving.saveCatchBatch");
- }
-
- int answer = getHandler().askSaveBeforeLeaving(message);
-
-
- switch (answer) {
- case JOptionPane.OK_OPTION:
-
- // persist previous fishing operation
- if (fishingOperationModified) {
- getSaveFishingOperationAction().setUpdateUI(false);
- getActionEngine().runInternalAction(getSaveFishingOperationAction());
- }
-
- if (catchBatchModified) {
- getSaveCatchBatchAction().setUpdateUI(false);
- getActionEngine().runInternalAction(getSaveCatchBatchAction());
- }
-
- 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;
- }
- } else {
-
- // data are not valid
- String message;
-
- if (fishingOperationValid) {
- message = _("tutti.editCatchBatch.askCancelEditBeforeLeaving.cancelEditCatchBatch");
- } else {
- message = _("tutti.editFishingOperation.askCancelEditBeforeLeaving.cancelEditFishingOperation");
- }
-
- // ok will revert any modification by
- // editing new fishing operation (if user says yes)
- canContinue = handler.askCancelEditBeforeLeaving(message);
- }
- }
- }
-
- if (!canContinue) {
-
- FishingOperation selectFishingOperation;
- if (TuttiEntities.isNew(editFishingOperation)) {
-
- // no selection
- selectFishingOperation = null;
- } else {
- // rollback selected fishing operation
- selectFishingOperation =
- model.getFishingOperation(editFishingOperationId);
- }
-
- model.setEditionAdjusting(true);
- try {
- model.setSelectedFishingOperation(selectFishingOperation);
- } finally {
- model.setEditionAdjusting(false);
- }
- }
- }
-
- return canContinue;
- }
-
- @Override
- public void doAction() throws Exception {
-
- errorMessages.clear();
-
- FishingOperationsUI ui = getUI();
-
- FishingOperationsUIModel model = ui.getModel();
-
- // edit new fishing operation
- if (log.isDebugEnabled()) {
- log.debug("Edit fishingOperation: " + fishingOperation);
- }
-
- // now fishing operation is edited
- model.setEditFishingOperation(fishingOperation);
-
- loadFishingOperation(fishingOperation);
-
- loadCatchBatch(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);
-
- ui.getFishingOperationTabContent().getFishingOperationTabPane().setSelectedIndex(0);
-
- if (checkPreviousEdit) {
- ui.getTabPane().setSelectedIndex(0);
- }
- }
-
- model.addPropertyChangeListener(coordinatePropertiesListener);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- getUI().getFishingOperationTabContent().getModel().setModify(false);
- getUI().repaint();
-
- if (!internalAction) {
- displayValidationErrors();
- }
- }
-
- public void displayValidationErrors() {
- if (CollectionUtils.isNotEmpty(errorMessages)) {
- for (String errorMessage : errorMessages) {
- getContext().getErrorHelper().showErrorDialog(errorMessage, null);
- }
- }
- }
-
- public void loadFishingOperation(FishingOperation bean) {
-
- EditFishingOperationUI ui = getUI().getFishingOperationTabContent();
-
- EditFishingOperationUIHandler handler = ui.getHandler();
-
- EditFishingOperationUIModel editFishingOperationUIModel = ui.getModel();
-
- editFishingOperationUIModel.setLoadingData(true);
-
- editFishingOperationUIModel.removeAllAttachment(editFishingOperationUIModel.getAttachment());
-
- handler.uninstallStartDateListener();
- handler.uninstallCoordinatesListener();
-
- if (bean == null) {
-
- editFishingOperationUIModel.fromBean(
- FishingOperations.newFishingOperation());
-
- editFishingOperationUIModel.setFishingOperation(bean);
-
- editFishingOperationUIModel.setAllSecondaryVessel(null);
- editFishingOperationUIModel.setFishingSecondaryVessel(null);
- editFishingOperationUIModel.setScientificSecondaryVessel(null);
- editFishingOperationUIModel.setOnlyCruisSecondaryVessel(null);
- editFishingOperationUIModel.setSecondaryVesselType(null);
-
- handler.clearValidators();
-
- handler.resetAllModels();
-
- } else { //if (!bean.equals(editFishingOperationUIModel.getFishingOperation()) || handler.isAModelModified()) {
-
- TuttiLocation strata = bean.getStrata();
- TuttiLocation subStrata = bean.getSubStrata();
- TuttiLocation location = bean.getLocation();
-
- PersistenceService persistenceService = getContext().getPersistenceService();
-
- Cruise cruise = bean.getCruise();
- if (cruise != null) {
-
- // update gear universe
- // add a equals on id + rankOrder
- List<Gear> gears = Lists.newArrayList();
- for (Gear gear : cruise.getGear()) {
- CaracteristicMap caracteristics =
- persistenceService.getGearCaracteristics(
- cruise.getId(),
- gear.getId(),
- gear.getRankOrder());
-
- Gear toKeep = GearWithOriginalRankOrders.newGearWithOriginalRankOrder(gear);
- toKeep.setCaracteristics(caracteristics);
-
- gears.add(toKeep);
- }
- ui.getGearComboBox().setData(gears);
- }
-
- editFishingOperationUIModel.fromBean(bean);
-
- // to be sure combo list will be reloaded
- editFishingOperationUIModel.setStrata(null);
- editFishingOperationUIModel.setSubStrata(null);
- editFishingOperationUIModel.setLocation(null);
-
- editFishingOperationUIModel.convertGearShootingCoordinatesFromDD();
-
- 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 saisisseur selection
- List<Person> saisisseur = editFishingOperationUIModel.getRecorderPerson();
- ui.getRecorderPersonList().getHandler().setSelected(saisisseur);
-
- //reset gear use feature tab
- GearUseFeatureTabUI gearUseFeatureTabContent = ui.getGearUseFeatureTabContent();
- gearUseFeatureTabContent.getHandler().reset(bean);
-
- //reset vessel use feature tab
- VesselUseFeatureTabUI vesselUseFeatureTabContent = ui.getVesselUseFeatureTabContent();
- vesselUseFeatureTabContent.getHandler().reset(bean);
-
- Integer objectId = editFishingOperationUIModel.getObjectId();
- if (objectId != null) {
-
- List<Attachment> attachments =
- persistenceService.getAllAttachments(
- editFishingOperationUIModel.getObjectType(),
- objectId);
-
- editFishingOperationUIModel.addAllAttachment(attachments);
- }
-
- Vessel cruiseVessel = getDataContext().getCruise().getVessel();
- List<Vessel> scientificVessels = getDataContext().getScientificVessels();
- List<Vessel> fishingVessels = getDataContext().getFishingVessels();
-
- { // update all secondary vessel universe
- List<Vessel> vessels = Lists.newArrayList();
- vessels.addAll(scientificVessels);
- vessels.addAll(fishingVessels);
- vessels.remove(cruiseVessel);
- editFishingOperationUIModel.setAllSecondaryVessel(vessels);
- }
-
- { // update scientific secondary vessel universe
- List<Vessel> vessels = Lists.newArrayList();
- vessels.addAll(scientificVessels);
- vessels.remove(cruiseVessel);
- editFishingOperationUIModel.setScientificSecondaryVessel(vessels);
- }
-
- { // update fishing secondary vessel universe
- List<Vessel> vessels = Lists.newArrayList();
- vessels.addAll(fishingVessels);
- vessels.remove(cruiseVessel);
- editFishingOperationUIModel.setFishingSecondaryVessel(vessels);
- }
-
- { // update only cruise vessel universe
-
- List<FishingOperation> fishingOperation =
- getModel().getFishingOperation();
-
- Set<Vessel> vesselSet = Sets.newHashSet();
- for (FishingOperation operation : fishingOperation) {
- List<Vessel> secondaryVessel = persistenceService.getFishingOperationSecondaryVessel(operation.getId());
- if (CollectionUtils.isNotEmpty(secondaryVessel)) {
- vesselSet.addAll(secondaryVessel);
- }
- }
- List<Vessel> vessel = Lists.newArrayList(vesselSet);
- editFishingOperationUIModel.setOnlyCruisSecondaryVessel(vessel);
- }
-
- // will propagate to model
- ui.getSecondaryVesselList().getModel().setSelected(bean.getSecondaryVessel());
-
- editFishingOperationUIModel.setSecondaryVesselType(SecondaryVesselTypeEnum.ALL);
-
- editFishingOperationUIModel.setModify(false);
- handler.getFishingOperationMonitor().clearModified();
- handler.registerValidator();
- }
-
- editFishingOperationUIModel.setLoadingData(false);
-
- handler.installStartDateListener();
- handler.installCoordinatesListener();
- }
-
- public void loadCatchBatch(FishingOperation bean) {
-
- boolean empty = bean == null || TuttiEntities.isNew(bean);
-
- EditCatchesUI ui = getUI().getCatchesTabContent();
- TuttiBeanMonitor<EditCatchesUIModel> catchBatchMonitor =
- ui.getHandler().getCatchBatchMonitor();
-
- EditCatchesUIModel catchesUIModel = ui.getModel();
-
- catchesUIModel.setLoadingData(true);
-
- catchesUIModel.reset();
-
- CatchBatch batch;
-
- List<Attachment> attachments;
-
- boolean catchNotFound;
- boolean catchEnabled;
-
- String operationId = bean == null ? null : bean.getId();
-
- ProgressionModel progressionModel = getProgressionModel();
- if (progressionModel == null) {
- progressionModel = new ProgressionModel();
- setProgressionModel(progressionModel);
- }
- progressionModel.adaptTotal(empty ? 1 : 6);
-
- if (empty) {
-
- // create a new CatchBatch
- progressionModel.increments("Create new catch batch");
- if (log.isDebugEnabled()) {
- log.debug("Create a new CatchBatch (fishing operation is null)");
- }
- batch = CatchBatchs.newCatchBatch();
- batch.setFishingOperation(bean);
-
- attachments = Collections.emptyList();
-
- catchEnabled = true;
- catchNotFound = false;
-
- } else {
-
- if (log.isDebugEnabled()) {
- log.debug("Load existing CatchBatch from operation id: " +
- operationId);
- }
-
- PersistenceService persistenceService =
- getContext().getPersistenceService();
-
- progressionModel.increments("Chargement de la capture");
-
- boolean withCatchBath =
- persistenceService.isFishingOperationWithCatchBatch(
- operationId);
-
- if (withCatchBath) {
-
- // load it
- try {
- batch = persistenceService.getCatchBatchFromFishingOperation(operationId);
- batch.setFishingOperation(bean);
- Integer objectId = batch.getIdAsInt();
- attachments = persistenceService.getAllAttachments(catchesUIModel.getObjectType(), objectId);
- catchNotFound = false;
- catchEnabled = true;
-
- } catch (InvalidBatchModelException e) {
-
- // batch is not compatible with Tutti
- if (log.isDebugEnabled()) {
- log.debug("Invalid batch model", e);
- }
- batch = null;
- attachments = Collections.emptyList();
-
- catchEnabled = false;
- catchNotFound = false;
- }
- } else {
-
- // no catch batch
- batch = null;
- attachments = Collections.emptyList();
-
- catchEnabled = false;
- catchNotFound = true;
- }
- }
-
- setCatch(attachments,
- catchesUIModel,
- catchBatchMonitor,
- batch,
- true,
- catchEnabled,
- catchNotFound);
-
-
- // 4) Propagate new selected fishingoperation to others tabs
-
- FishingOperation operationToLoad = batch == null ? null : bean;
-
- boolean catchValid = true;
-
- try {
- progressionModel.increments("Chargement des captures Espèces");
-
- ui.getSpeciesTabContent().getHandler().selectFishingOperation(operationToLoad);
- } catch (InvalidBatchModelException e) {
-
- // invalid sample category model for species batches
- if (log.isDebugEnabled()) {
- log.debug("Invalid sample category model for species batches", e);
- }
- errorMessages.add(e.getMessage());
- catchValid = false;
- }
-
- try {
- progressionModel.increments("Chargement des captures Benthos");
- ui.getBenthosTabContent().getHandler().selectFishingOperation(operationToLoad);
- } catch (InvalidBatchModelException e) {
-
- // invalid sample category model for benthos batches
- if (log.isDebugEnabled()) {
- log.debug("Invalid sample category model for benthos batches", e);
- }
- errorMessages.add(e.getMessage());
- catchValid = false;
- }
-
- if (catchValid) {
-
- // load other tabs
-
- progressionModel.increments("Chargmenent des macro-déchets");
- ui.getMarineLitterTabContent().getHandler().selectFishingOperation(operationToLoad);
-
- progressionModel.increments("Chargement des captures accidentelles");
- ui.getAccidentalTabContent().getHandler().selectFishingOperation(operationToLoad);
-
- progressionModel.increments("Chargement des données individuelles");
- ui.getIndividualObservationTabContent().getHandler().selectFishingOperation(operationToLoad);
-
- } else {
-
- // remove catch
- setCatch(Collections.<Attachment>emptyList(),
- catchesUIModel,
- catchBatchMonitor,
- null,
- false,
- false,
- false);
- }
-
- catchesUIModel.setLoadingData(false);
- }
-
- @Override
- public void postFailedAction(Throwable error) {
- super.postFailedAction(error);
- }
-
-
- protected void setCatch(List<Attachment> attachments,
- EditCatchesUIModel catchesUIModel,
- TuttiBeanMonitor<EditCatchesUIModel> catchBatchMonitor,
- CatchBatch batch,
- boolean sampleModelValid,
- boolean catchEnabled,
- boolean catchNotFound) {
-
- getModel().setCatchEnabled(catchEnabled);
- getModel().setCatchNotFound(catchNotFound);
- getModel().setSampleCatchModelValid(sampleModelValid);
-
- catchesUIModel.fromEntity(batch);
- catchesUIModel.addAllAttachment(attachments);
-
- catchesUIModel.setModify(false);
- catchBatchMonitor.clearModified();
- }
-
- public void setInternalAction(boolean internalAction) {
- this.internalAction = internalAction;
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -627,7 +627,7 @@
toolTipText: "tutti.editFishingOperation.action.saveEditFishingOperation.tip";
i18nMnemonic: "tutti.editFishingOperation.action.saveEditFishingOperation.mnemonic";
enabled: {model.isValid() && model.isModify()};
- _applicationAction: {SaveFishingOperationAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SaveFishingOperationAction.class};
_help: {"tutti.editFishingOperation.action.saveEditFishingOperation.help"};
}
@@ -636,6 +636,6 @@
text: "tutti.editFishingOperation.action.cancelEditFishingOperation";
toolTipText: "tutti.editFishingOperation.action.cancelEditFishingOperation.tip";
i18nMnemonic: "tutti.editFishingOperation.action.cancelEditFishingOperation.mnemonic";
- _applicationAction: {CancelEditFishingOperationAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.CancelEditFishingOperationAction.class};
_help: {"tutti.editFishingOperation.action.cancelEditFishingOperation.help"};
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -40,11 +40,12 @@
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.action.CancelEditFishingOperationAction;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.AbstractCaracteristicTabUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.GearUseFeatureTabUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.VesselUseFeatureTabUIModel;
+import fr.ifremer.shared.application.swing.tab.TabHandler;
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.caracteristics.GearCaracteristicListCellRenderer;
import jaxx.runtime.validator.swing.SwingValidator;
@@ -582,13 +583,13 @@
//------------------------------------------------------------------------//
@Override
- protected boolean onTabChanged(int currentIndex, int newIndex) {
+ public boolean onTabChanged(int currentIndex, int newIndex) {
ui.getFishingOperationAttachmentsButton().onCloseUI();
return super.onTabChanged(currentIndex, newIndex);
}
@Override
- protected JTabbedPane getTabPanel() {
+ public JTabbedPane getTabPanel() {
return ui.getFishingOperationTabPane();
}
@@ -822,7 +823,7 @@
return result;
}
- protected void resetAllModels() {
+ public void resetAllModels() {
for (AbstractCaracteristicTabUIModel subModel : getSubModels()) {
subModel.setModify(false);
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -39,12 +39,14 @@
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
import fr.ifremer.shared.application.type.CoordinateEditorType;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
-import fr.ifremer.tutti.ui.swing.util.TabContentModel;
+import fr.ifremer.shared.application.swing.tab.TabContentModel;
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import jaxx.runtime.swing.editor.gis.DmdCoordinate;
import jaxx.runtime.swing.editor.gis.DmsCoordinate;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.nuiton.util.DateUtil;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -865,6 +867,10 @@
return CoordinateEditorType.DMD.equals(getCoordinateEditorType());
}
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(EditFishingOperationUIModel.class);
+
public void convertGearShootingCoordinatesFromDD() {
switch (coordinateEditorType) {
@@ -873,6 +879,10 @@
setGearShootingStartLongitudeDms(getGearShootingStartLongitude());
setGearShootingEndLatitudeDms(getGearShootingEndLatitude());
setGearShootingEndLongitudeDms(getGearShootingEndLongitude());
+
+ if (log.isInfoEnabled()) {
+ log.info("startLongitude dms: "+gearShootingStartLongitudeDms);
+ }
break;
case DMD:
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -35,7 +35,7 @@
actionIcon: add;
toolTipText: "tutti.fishingOperations.action.newFishingOperation.tip";
i18nMnemonic: "tutti.fishingOperations.action.newFishingOperation.mnemonic";
- _applicationAction: {NewFishingOperationAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.NewFishingOperationAction.class};
_help: {"tutti.fishingOperations.action.newFishingOperation.help"};
}
@@ -44,7 +44,7 @@
enabled:{model.getSelectedFishingOperation() != null};
toolTipText: "tutti.fishingOperations.action.deleteFishingOperation.tip";
i18nMnemonic: "tutti.fishingOperations.action.deleteFishingOperation.mnemonic";
- _applicationAction: {DeleteFishingOperationAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.DeleteFishingOperationAction.class};
_help: {"tutti.fishingOperations.action.deleteFishingOperation.help"};
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -32,6 +32,7 @@
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.action.EditFishingOperationAction;
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.util.AbstractTuttiTabContainerUIHandler;
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/ImportCasinoAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/ImportCasinoAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/ImportCasinoAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,44 +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.ui.swing.util.action.AbstractTuttiAction;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ImportCasinoAction extends AbstractTuttiAction<EditFishingOperationUIModel, EditFishingOperationUI, EditFishingOperationUIHandler> {
-
- public ImportCasinoAction(EditFishingOperationUIHandler handler) {
- super(handler, false);
- }
-
- @Override
- public void doAction() throws Exception {
- //TODO
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,86 +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.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperations;
-import fr.ifremer.tutti.persistence.entities.referential.GearWithOriginalRankOrder;
-
-import java.util.List;
-
-/**
- * To create a new fishing operation.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class NewFishingOperationAction extends EditFishingOperationAction {
-
- public NewFishingOperationAction(FishingOperationsUIHandler handler) {
- super(handler);
- }
-
- @Override
- public void doAction() throws Exception {
-
- FishingOperationsUIModel model = getModel();
-
- // deselect selected fishingOperation
- // Will remove the selection fishing operation from the comboBox
-
- model.setCatchEnabled(true);
-
- model.setEditionAdjusting(true);
- try {
- model.setSelectedFishingOperation(null);
- } finally {
- model.setEditionAdjusting(false);
- }
-
- // creates a empty bean
-
- FishingOperation newFishingOperation =
- FishingOperations.newFishingOperation();
- Cruise cruise = getDataContext().getCruise();
- newFishingOperation.setCruise(cruise);
- newFishingOperation.setVessel(cruise.getVessel());
-
- List<GearWithOriginalRankOrder> gears = cruise.getGear();
- if (gears.size() == 1) {
- newFishingOperation.setGear(gears.get(0));
- }
-
- if (cruise.getMultirigNumber() == 1) {
- newFishingOperation.setMultirigAggregation("1");
- }
-
- newFishingOperation.setGearShootingStartDate(null);
- newFishingOperation.setGearShootingEndDate(null);
- setFishingOperation(newFishingOperation);
-
- super.doAction();
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,182 +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.CaracteristicMap;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatchs;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.ValidationService;
-import fr.ifremer.tutti.ui.swing.content.operation.fishing.AbstractCaracteristicTabUIModel;
-import fr.ifremer.tutti.ui.swing.content.operation.fishing.GearUseFeatureTabUIModel;
-import fr.ifremer.tutti.ui.swing.content.operation.fishing.VesselUseFeatureTabUIModel;
-import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Saves a fishing operation and potentially sets another screen or switch to another tab.
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.0
- */
-public class SaveFishingOperationAction extends AbstractTuttiAction<EditFishingOperationUIModel, EditFishingOperationUI, EditFishingOperationUIHandler> {
-
- /** Logger. */
- 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, true);
- }
-
- public void setUpdateUI(boolean updateUI) {
- this.updateUI = updateUI;
- }
-
- @Override
- public void releaseAction() {
- updateUI = true;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
-
- TuttiBeanMonitor<EditFishingOperationUIModel> monitor =
- handler.getFishingOperationMonitor();
-
- // previous fishingOperation was modified, let's save it
- EditFishingOperationUIModel beanToSave = monitor.getBean();
-
- // must save when bean is new or was modifiy and is valid
- boolean mustSave = beanToSave.getFishingOperation() != null
- && beanToSave.isValid();
-
- if (mustSave) {
-
- // prepare model
- beanToSave.convertGearShootingCoordinatesToDD();
-
- // save modified fishing operation
- FishingOperation toSave = beanToSave.toBean();
-
- AbstractCaracteristicTabUIModel[] subModels = handler.getSubModels();
- for (AbstractCaracteristicTabUIModel subModel : subModels) {
- Class<?> modelClass = subModel.getClass();
- CaracteristicMap caracteristics = subModel.getCaracteristicMap();
-
- if (modelClass.isAssignableFrom(VesselUseFeatureTabUIModel.class)) {
- toSave.setVesselUseFeatures(caracteristics);
-
- } else if (modelClass.isAssignableFrom(GearUseFeatureTabUIModel.class)) {
- toSave.setGearUseFeatures(caracteristics);
-
- }
- subModel.setModify(false);
- }
-
- sendMessage(
- "[ Trait - Caractéristiques générales ] " +
- "Sauvegarde des modifications de " + decorate(toSave) +
- ".");
-
- if (log.isInfoEnabled()) {
- log.info("FishingOperation " + toSave.getId() +
- " was modified, will save it.");
- }
-
- monitor.clearModified();
- getModel().setModify(false);
-
- saveFishingOperation(toSave);
-
- if (ValidationService.VALIDATION_CONTEXT_EDIT.equals(getContext().getValidationContext())) {
- handler.getParentUi().getTabPane().setSelectedIndex(1);
- handler.getParentUi().getCatchesTabContent().getTabPane().setSelectedIndex(1);
- }
- }
-
- }
-
- protected void saveFishingOperation(FishingOperation toSave) {
-
- PersistenceService service = getContext().getPersistenceService();
-
- 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 = CatchBatchs.newCatchBatch();
- 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 {
-
- model.setEditionAdjusting(true);
-
- try {
- // save fishing operation
- savedFishingOperation = service.saveFishingOperation(toSave);
-
- model.setSelectedFishingOperation(null);
-
- // reinject it in model
- model.updateFishingOperation(savedFishingOperation);
-
- model.setSelectedFishingOperation(savedFishingOperation);
- } finally {
- model.setEditionAdjusting(false);
- }
- }
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractExportMultiPostAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractExportMultiPostAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractExportMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,95 +0,0 @@
-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.FishingOperation;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.service.catches.multipost.MultiPostExportService;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
-import fr.ifremer.tutti.ui.swing.util.TuttiUI;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.jdesktop.beans.AbstractBean;
-
-import java.io.File;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.2
- */
-public abstract class AbstractExportMultiPostAction<M extends AbstractBean, UI extends TuttiUI<M, ?>, H extends AbstractTuttiUIHandler<M, UI>>
- extends AbstractTuttiAction<M, UI, H> {
-
- protected File file;
-
- protected FishingOperation currentOperation;
-
- protected MultiPostExportService multiPostImportExportService;
-
- public AbstractExportMultiPostAction(H handler) {
- super(handler, false);
- multiPostImportExportService = getContext().getMultiPostExportService();
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- EditCatchesUI catchesUI = getUI().getParentContainer(EditCatchesUI.class);
- currentOperation = catchesUI.getModel().getFishingOperation();
-
- String extension = getFileExtension();
- // choose file to export
- file = saveFile(
- decorate(currentOperation, DecoratorService.FILE_NAME_COMPATIBLE),
- extension,
- getFileChooserTitle(),
- getFileChooserButton(),
- "^.*\\." + extension,
- getFileExtensionDescription()
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- protected abstract String getFileExtension();
-
- protected abstract String getFileExtensionDescription();
-
- protected abstract String getFileChooserTitle();
-
- protected abstract String getFileChooserButton();
-
- @Override
- public void releaseAction() {
- file = null;
- currentOperation = null;
- super.releaseAction();
- }
-
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,112 +0,0 @@
-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.FishingOperation;
-import fr.ifremer.tutti.service.catches.multipost.MultiPostImportService;
-import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationAction;
-import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
-import fr.ifremer.tutti.ui.swing.util.TuttiUI;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.jdesktop.beans.AbstractBean;
-
-import java.io.File;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.2
- */
-public abstract class AbstractImportMultiPostAction<M extends AbstractBean, UI extends TuttiUI<M, ?>, H extends AbstractTuttiUIHandler<M, UI>>
- extends AbstractTuttiAction<M, UI, H> {
-
- protected File file;
-
- protected EditFishingOperationAction editAction;
-
- protected MultiPostImportService multiPostImportExportService;
-
- public AbstractImportMultiPostAction(H handler) {
- super(handler, false);
- multiPostImportExportService = getContext().getMultiPostImportService();
- }
-
- public EditFishingOperationAction getEditAction() {
- FishingOperationsUI parentUI = getUI().getParentContainer(FishingOperationsUI.class);
- if (editAction == null) {
- editAction = getContext().getActionFactory().createLogicAction(parentUI.getHandler(),
- EditFishingOperationAction.class);
- }
- return editAction;
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to import
- file = chooseFile(
- getFileChooserTitle(),
- getFileChooserButton(),
- "^.*\\." + getFileExtension(),
- getFileExtensionDescription()
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- protected abstract String getFileExtension();
-
- protected abstract String getFileExtensionDescription();
-
- protected abstract String getFileChooserTitle();
-
- protected abstract String getFileChooserButton();
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- EditCatchesUI editCatchesUI = getUI().getParentContainer(EditCatchesUI.class);
- EditCatchesUIModel editCatchesUIModel = editCatchesUI.getModel();
-
- FishingOperation operation = editCatchesUIModel.getFishingOperation();
-
- importBatches(operation);
-
- getEditAction().loadCatchBatch(operation);
- }
-
- protected abstract void importBatches(FishingOperation operation);
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,86 +0,0 @@
-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 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.content.operation.EditFishingOperationAction;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * To cancel edit of a {@link CatchBatch}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class CancelEditCatchBatchAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
-
- /** 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;
-
- protected EditFishingOperationAction editAction;
-
- public CancelEditCatchBatchAction(EditCatchesUIHandler handler) {
- super(handler, true);
- }
-
- public EditFishingOperationAction getEditAction() {
- if (editAction == null) {
- editAction = getContext().getActionFactory().createLogicAction(getHandler().getParentHandler(),
- EditFishingOperationAction.class);
- }
- return editAction;
- }
-
- @Override
- public void doAction() throws Exception {
-
- // cancel to create a catch batch ?
- // Should never happen ?
- Preconditions.checkState(
- !getModel().isCreate(),
- "Can't cancel edition of a not persisted catchBatch!");
-
- if (log.isInfoEnabled()) {
- log.info("Can edition of catchBatch (will reload catchBatch)");
- }
-
- FishingOperation operation = getModel().getFishingOperation();
-
- getEditAction().loadCatchBatch(operation);
- }
-
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CleanBatchWeightsAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CleanBatchWeightsAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CleanBatchWeightsAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,143 +0,0 @@
-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 com.google.common.collect.Multimap;
-import fr.ifremer.tutti.persistence.InvalidBatchModelException;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.service.catches.WeightCleaningService;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JOptionPane;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To remove weight in double for species and benthos rows.
- * <p/>
- * Created on 9/27/13.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 2.6
- */
-public class CleanBatchWeightsAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(CleanBatchWeightsAction.class);
-
- protected final WeightCleaningService cleaningService;
-
- protected int nbErrors;
-
- public CleanBatchWeightsAction(EditCatchesUIHandler handler) {
- super(handler, false);
- cleaningService = getContext().getWeightCleaningService();
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean doAction = super.prepareAction();
- if (doAction) {
-
-
- // do a check
- FishingOperation fishingOperation = getModel().getFishingOperation();
- Multimap<String, String> errors = cleaningService.checkFishingOperation(fishingOperation.getId());
-
- nbErrors = errors.size();
-
- if (nbErrors == 0) {
-
- // no errors
-
- sendMessage(_("tutti.editCatchBatch.action.cleanWeights.no.double.weight.detected"));
- doAction = false;
- } else {
-
- // show errors to user and ask him to apply change
-
- String errorsStr = cleaningService.errorsToString(errors);
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- _("tutti.editCatchBatch.action.cleanWeights.double.weight.detected", errorsStr),
- _("tutti.editCatchBatch.action.cleanWeights.help"));
-
- int answer = JOptionPane.showConfirmDialog(
- getContext().getActionUI(),
- htmlMessage,
- _("tutti.editCatchBatch.action.cleanWieghts.resume.title"),
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.QUESTION_MESSAGE);
-
- doAction = (answer == JOptionPane.OK_OPTION);
-
- }
- }
- return doAction;
- }
-
- @Override
- public void doAction() throws Exception {
-
- EditCatchesUIModel model = getModel();
- FishingOperation fishingOperation = getModel().getFishingOperation();
- model.setLoadingData(true);
-
- cleaningService.cleanFishingOperation(fishingOperation.getId());
-
- try {
-
- getUI().getSpeciesTabContent().getHandler().selectFishingOperation(fishingOperation);
- } catch (InvalidBatchModelException e) {
-
- // invalid sample category model for species batches
- if (log.isDebugEnabled()) {
- log.debug("Invalid sample category model for species batches", e);
- }
- }
-
- try {
- getUI().getBenthosTabContent().getHandler().selectFishingOperation(fishingOperation);
- } catch (InvalidBatchModelException e) {
-
- // invalid sample category model for benthos batches
- if (log.isDebugEnabled()) {
- log.debug("Invalid sample category model for benthos batches", e);
- }
- }
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- sendMessage(_("tutti.editCatchBatch.action.cleanWeights.done", nbErrors));
- }
-
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeBatchWeightsAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeBatchWeightsAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeBatchWeightsAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,325 +0,0 @@
-
-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 com.google.common.collect.Lists;
-import com.google.common.collect.Multimap;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
-import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.catches.TuttiWeightComputingException;
-import fr.ifremer.tutti.service.catches.WeightCleaningService;
-import fr.ifremer.tutti.service.catches.WeightComputingService;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-
-import javax.swing.JOptionPane;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.0
- */
-public class ComputeBatchWeightsAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
-
- protected final WeightCleaningService cleaningService;
-
- public ComputeBatchWeightsAction(EditCatchesUIHandler handler) {
- super(handler, true);
- cleaningService = getContext().getWeightCleaningService();
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean doAction = super.prepareAction();
- if (doAction) {
-
- // do a check of double weights
- FishingOperation fishingOperation = getModel().getFishingOperation();
- Multimap<String, String> errors = cleaningService.checkFishingOperation(fishingOperation.getId());
-
- if (errors.isEmpty()) {
-
- // no errors
-
- sendMessage(_("tutti.editCatchBatch.action.computeWeights.no.double.weight.detected"));
- } else {
-
- // show errors to user as warning
-
- String errorsStr = cleaningService.errorsToString(errors);
- String htmlMessage = _("tutti.editCatchBatch.action.computeWeights.double.weight.detected", errorsStr);
-
- JOptionPane.showMessageDialog(getContext().getActionUI(),
- htmlMessage,
- _("tutti.editCatchBatch.action.computeWeights.double.weight.detected.title"),
- JOptionPane.WARNING_MESSAGE);
-
-
- }
- }
- return doAction;
- }
-
- @Override
- public void doAction() throws Exception {
- PersistenceService persistenceService = getContext().getPersistenceService();
-
- WeightComputingService weightComputingService = getContext().getWeightComputingService();
-
- EditCatchesUIModel model = getModel();
- model.setLoadingData(true);
-
- // ---------
- // Compute species batches
- // ---------
-
- BatchContainer<SpeciesBatch> computedSpeciesBatches;
- Float totalSpeciesSortedWeight;
- String operationId = model.getFishingOperation().getId();
- try {
- computedSpeciesBatches =
- weightComputingService.getComputedSpeciesBatches(operationId);
- totalSpeciesSortedWeight = computeSpeciesBatches(persistenceService, computedSpeciesBatches);
-
- } catch (TuttiWeightComputingException e) {
- getUI().getTabPane().setSelectedIndex(1);
-
- int index = e.getIndex();
- SpeciesBatchRowModel row = getUI().getSpeciesTabContent().getModel().getRows().get(index);
- int column;
- if (SpeciesBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT.equals(e.getProperty())) {
- column = getFinestCategoryColumn(row.getFinestCategory().getCategoryId());
- } else {
- column = 6;
- }
- TuttiUIUtil.doSelectCell(getUI().getSpeciesTabContent().getTable(), index, column);
-
- throw e;
- }
-
- // ---------
- // Compute benthos batches
- // ---------
-
- BatchContainer<BenthosBatch> computedBenthosBatches;
- Float totalBenthosSortedWeight;
- try {
- computedBenthosBatches =
- weightComputingService.getComputedBenthosBatches(operationId);
- totalBenthosSortedWeight = computeBenthosBatches(persistenceService, computedBenthosBatches);
-
- } catch (TuttiWeightComputingException e) {
- getUI().getTabPane().setSelectedIndex(2);
-
- int index = e.getIndex();
- BenthosBatchRowModel row = getUI().getBenthosTabContent().getModel().getRows().get(index);
- int column;
- if (BenthosBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT.equals(e.getProperty())) {
- column = getFinestCategoryColumn(row.getFinestCategory().getCategoryId());
- } else {
- column = 6;
- }
- TuttiUIUtil.doSelectCell(getUI().getBenthosTabContent().getTable(), index, column);
-
- throw e;
- }
-
- // ---------
- // Compute marine litter batches
- // ---------
-
- BatchContainer<MarineLitterBatch> computedMarineLitterBatches;
- try {
- computedMarineLitterBatches =
- weightComputingService.getComputedMarineLitterBatches(operationId,
- model.getMarineLitterTotalWeight());
-
- } catch (TuttiWeightComputingException e) {
- getUI().getTabPane().setSelectedIndex(3);
- TuttiUIUtil.doSelectCell(getUI().getMarineLitterTabContent().getTable(), e.getIndex(), 3);
- throw e;
- }
-
- // ---------
- // Check species rates
- // ---------
-
- Float rate = getConfig().getDifferenceRateBetweenSortedAndTotalWeights();
- if (model.getSpeciesTotalSortedWeight() != null
- && model.getSpeciesTotalSortedWeight() >= totalSpeciesSortedWeight
- && model.getSpeciesTotalSortedWeight() < (1 + rate / 100) * totalSpeciesSortedWeight) {
-
- // Si le "Poids total VRAC" est saisi est que sa valeur
- // est supérieure de moins de x% (x en configuration)
- // du "Poids total Vrac trié", demander confirmation que
- // le "Poids total VRAC" est bien une valeur observée
- // sinon la remplacer par le "Poids total Vrac trié"
-
- getUI().getTabPane().setSelectedIndex(1);
-
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.message.species", rate),
- _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.help"));
-
- int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- htmlMessage,
- _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.title"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE);
-
- if (answer == JOptionPane.NO_OPTION) {
- model.setSpeciesTotalSortedWeight(null);
- model.setSpeciesTotalSortedComputedWeight(totalSpeciesSortedWeight);
- }
- }
-
- // ---------
- // Check benthos rates
- // ---------
-
- if (model.getBenthosTotalSortedWeight() != null
- && model.getBenthosTotalSortedWeight() >= totalBenthosSortedWeight
- && model.getBenthosTotalSortedWeight() < (1 + rate / 100) * totalBenthosSortedWeight) {
-
- // Si le "Poids total VRAC" est saisi est que sa valeur
- // est supérieure de moins de x% (x en configuration)
- // du "Poids total Vrac trié", demander confirmation que
- // le "Poids total VRAC" est bien une valeur observée
- // sinon la remplacer par le "Poids total Vrac trié"
-
- getUI().getTabPane().setSelectedIndex(2);
-
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.message.benthos", rate),
- _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.help"));
-
- int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- htmlMessage,
- _("tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.title"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE);
-
- if (answer == JOptionPane.NO_OPTION) {
- model.setBenthosTotalSortedWeight(null);
- model.setBenthosTotalSortedComputedWeight(totalBenthosSortedWeight);
- }
- }
-
- boolean modified = model.isModify();
- CatchBatch catchBatch = model.toEntity();
- weightComputingService.computeCatchBatchWeights(catchBatch,
- computedSpeciesBatches,
- computedBenthosBatches,
- computedMarineLitterBatches);
- model.fromEntity(catchBatch);
- model.setLoadingData(false);
-
- model.setModify(modified);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- getUI().repaint();
- }
-
- //------------------------------------------------------------------------//
- //-- Internal methods --//
- //------------------------------------------------------------------------//
-
- protected Float computeSpeciesBatches(PersistenceService persistenceService, BatchContainer<SpeciesBatch> computedSpeciesBatches) {
- Float totalSortedWeight = 0f;
-
- if (computedSpeciesBatches != null) {
- List<SpeciesBatchRowModel> rows = Lists.newArrayList();
- List<SpeciesBatch> children = computedSpeciesBatches.getChildren();
- for (SpeciesBatch batch : children) {
- SpeciesBatchRowModel row = getUI().getSpeciesTabContent().getHandler().loadBatch(batch, null, rows);
- if (persistenceService.isVracBatch(row)) {
- SampleCategory<?> sampleCategory = row.getFirstSampleCategory();
- Float weight = TuttiEntities.getValueOrComputedValue(
- sampleCategory.getCategoryWeight(),
- sampleCategory.getComputedWeight());
- totalSortedWeight += weight;
- }
- }
- getUI().getSpeciesTabContent().getModel().setRows(rows);
- }
-
- return totalSortedWeight;
- }
-
- protected Float computeBenthosBatches(PersistenceService persistenceService, BatchContainer<BenthosBatch> computedBenthosBatches) {
- Float totalSortedWeight = 0f;
-
- if (computedBenthosBatches != null) {
- List<BenthosBatchRowModel> rows = Lists.newArrayList();
- List<BenthosBatch> children = computedBenthosBatches.getChildren();
- for (BenthosBatch batch : children) {
- BenthosBatchRowModel row = getUI().getBenthosTabContent().getHandler().loadBatch(batch, null, rows);
-
- if (persistenceService.isVracBatch(row)) {
- SampleCategory<?> sampleCategory = row.getFirstSampleCategory();
- Float weight = TuttiEntities.getValueOrComputedValue(
- sampleCategory.getCategoryWeight(),
- sampleCategory.getComputedWeight());
- totalSortedWeight += weight;
- }
- }
- getUI().getBenthosTabContent().getModel().setRows(rows);
-
- }
- return totalSortedWeight;
- }
-
- protected int getFinestCategoryColumn(Integer categoryId) {
- int column = 1;
-
- List<Integer> samplingOrderIds = getConfig().getSamplingOrderIds();
-
- int index = samplingOrderIds.indexOf(categoryId);
- if (index > -1) {
- column += index + 1;
- }
-
- return column;
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -30,7 +30,7 @@
useFloat: true;
}
-TuttiComputedOrNotDataEditor {
+ComputableDataEditor {
autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
showReset: true;
@@ -332,7 +332,7 @@
text: "tutti.editCatchBatch.action.exportFishingOperationReport";
toolTipText: "tutti.editCatchBatch.action.exportFishingOperationReport.tip";
i18nMnemonic: "tutti.editCatchBatch.action.exportFishingOperationReport.mnemonic";
- _applicationAction: {ExportFishingOperationReportAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportFishingOperationReportAction.class};
_help: {"tutti.editCatchBatch.action.exportFishingOperationReport.help"};
}
@@ -341,7 +341,7 @@
text: "tutti.editCatchBatch.action.exportFishingOperationReportForSumatra";
toolTipText: "tutti.editCatchBatch.action.exportFishingOperationReportForSumatra.tip";
i18nMnemonic: "tutti.editCatchBatch.action.exportFishingOperationReportForSumatra.mnemonic";
- _applicationAction: {ExportFishingOperationForSumatraAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportFishingOperationForSumatraAction.class};
_help: {"tutti.editCatchBatch.action.exportFishingOperationReportForSumatra.help"};
}
@@ -351,7 +351,7 @@
toolTipText: "tutti.editCatchBatch.action.saveCatchBatch.tip";
i18nMnemonic: "tutti.editCatchBatch.action.saveCatchBatch.mnemonic";
enabled: {model.isModify()};
- _applicationAction: {SaveCatchBatchAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SaveCatchBatchAction.class};
_help: {"tutti.editCatchBatch.action.saveCatchBatch.help"};
}
@@ -360,7 +360,7 @@
text: "tutti.editCatchBatch.action.cancelEditCatchBatch";
toolTipText: "tutti.editCatchBatch.action.cancelEditCatchBatch.tip";
i18nMnemonic: "tutti.editCatchBatch.action.cancelEditCatchBatch.mnemonic";
- _applicationAction: {CancelEditCatchBatchAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.CancelEditCatchBatchAction.class};
_help: {"tutti.editCatchBatch.action.cancelEditCatchBatch.help"};
}
@@ -369,7 +369,7 @@
text: "tutti.editCatchBatch.action.cleanWeights";
toolTipText: "tutti.editCatchBatch.action.cleanWeights.tip";
i18nMnemonic: "tutti.editCatchBatch.action.cleanWeights.mnemonic";
- _applicationAction: {CleanBatchWeightsAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.CleanBatchWeightsAction.class};
_help: {"tutti.editCatchBatch.action.cleanWeights.help"};
}
@@ -378,6 +378,6 @@
text: "tutti.editCatchBatch.action.computeWeights";
toolTipText: "tutti.editCatchBatch.action.computeWeights.tip";
i18nMnemonic: "tutti.editCatchBatch.action.computeWeights.mnemonic";
- _applicationAction: {ComputeBatchWeightsAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ComputeBatchWeightsAction.class};
_help: {"tutti.editCatchBatch.action.computeWeights.help"};
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-11-26 08:03:42 UTC (rev 1388)
@@ -24,12 +24,9 @@
<JPanel id='editCatchesTopPanel' layout='{new BorderLayout()}' decorator='help'
implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<EditCatchesUIModel, EditCatchesUIHandler>'>
- <import>
+ <import><![CDATA[
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
- fr.ifremer.tutti.ui.swing.content.home.SendCruiseReportAction
- fr.ifremer.tutti.ui.swing.content.home.ExportCruiseForSumatraAction
-
fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI
fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.AccidentalBatchUI
fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.create.CreateAccidentalBatchUI
@@ -50,17 +47,15 @@
fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment
fr.ifremer.tutti.ui.swing.util.caracteristics.CaracteristicMapEditorUI
- fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor
+ fr.ifremer.shared.application.swing.computable.ComputableDataEditor
org.jdesktop.swingx.JXTitledPanel
jaxx.runtime.swing.CardLayout2Ext
- jaxx.runtime.swing.editor.NumberEditor
static org.nuiton.i18n.I18n._
- static jaxx.runtime.SwingUtil.getStringValue
static fr.ifremer.shared.application.ApplicationDataUtil.getWeightStringValue
- </import>
+ ]]></import>
<script><![CDATA[
@@ -138,8 +133,9 @@
<JLabel id='catchTotalWeightLabel'/>
</cell>
<cell columns='4' weightx='1.0'>
- <TuttiComputedOrNotDataEditor id='catchTotalWeightField'
- constructorParams='this'/>
+ <ComputableDataEditor id='catchTotalWeightField'
+ genericType="Float"
+ constructorParams='this'/>
</cell>
</row>
<!-- Poids total trié balance tremie / caroussel-->
@@ -189,9 +185,9 @@
<JLabel id='catchTotalRejectedWeightLabel'/>
</cell>
<cell columns='4' weightx='1.0'>
- <TuttiComputedOrNotDataEditor
- id='catchTotalRejectedWeightField'
- constructorParams='this'/>
+ <ComputableDataEditor genericType="Float"
+ id='catchTotalRejectedWeightField'
+ constructorParams='this'/>
</cell>
</row>
</Table>
@@ -216,9 +212,9 @@
<JLabel id='speciesTotalSortedWeightLabel'/>
</cell>
<cell weightx='1.0'>
- <TuttiComputedOrNotDataEditor
- id='speciesTotalSortedWeightField'
- constructorParams='this'/>
+ <ComputableDataEditor genericType="Float"
+ id='speciesTotalSortedWeightField'
+ constructorParams='this'/>
</cell>
</row>
@@ -262,9 +258,9 @@
<JLabel id='benthosTotalSortedWeightLabel'/>
</cell>
<cell weightx='1.0'>
- <TuttiComputedOrNotDataEditor
- id='benthosTotalSortedWeightField'
- constructorParams='this'/>
+ <ComputableDataEditor genericType="Float"
+ id='benthosTotalSortedWeightField'
+ constructorParams='this'/>
</cell>
</row>
@@ -299,9 +295,9 @@
<JLabel id='marineLitterTotalWeightLabel'/>
</cell>
<cell weightx='1.0'>
- <TuttiComputedOrNotDataEditor
- id='marineLitterTotalWeightField'
- constructorParams='this'/>
+ <ComputableDataEditor genericType="Float"
+ id='marineLitterTotalWeightField'
+ constructorParams='this'/>
</cell>
</row>
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -36,8 +36,8 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyCellComponent;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI;
+import fr.ifremer.shared.application.swing.tab.TabHandler;
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.TuttiUI;
import jaxx.runtime.swing.CardLayout2Ext;
@@ -194,12 +194,12 @@
}
@Override
- protected JTabbedPane getTabPanel() {
+ public JTabbedPane getTabPanel() {
return ui.getTabPane();
}
@Override
- protected boolean onTabChanged(int currentIndex, int newIndex) {
+ public boolean onTabChanged(int currentIndex, int newIndex) {
ui.getCatchesCaracteristicsAttachmentsButton().onCloseUI();
ui.getComputeSpeciesBatchButton().setVisible(newIndex < 4);
ui.getCleanSpeciesBatchButton().setVisible(newIndex < 3);
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -28,6 +28,7 @@
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
+import fr.ifremer.shared.application.swing.computable.ComputableData;
import fr.ifremer.shared.application.type.WeightUnit;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
@@ -37,8 +38,7 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
-import fr.ifremer.tutti.ui.swing.util.TabContentModel;
-import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
+import fr.ifremer.shared.application.swing.tab.TabContentModel;
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import org.apache.commons.collections.CollectionUtils;
import org.nuiton.util.beans.Binder;
@@ -67,36 +67,36 @@
protected Float speciesTotalComputedWeight;
- protected TuttiComputedOrNotData<Float> speciesTotalSortedComputedOrNotWeight = new TuttiComputedOrNotData<Float>();
+ protected ComputableData<Float> speciesTotalSortedComputedOrNotWeight = new ComputableData<Float>();
protected Float speciesTotalUnsortedComputedWeight;
protected Float speciesTotalSampleSortedComputedWeight;
- protected TuttiComputedOrNotData<Float> speciesTotalInertComputedOrNotWeight = new TuttiComputedOrNotData<Float>();
+ protected ComputableData<Float> speciesTotalInertComputedOrNotWeight = new ComputableData<Float>();
- protected TuttiComputedOrNotData<Float> speciesTotalLivingNotItemizedComputedOrNotWeight = new TuttiComputedOrNotData<Float>();
+ protected ComputableData<Float> speciesTotalLivingNotItemizedComputedOrNotWeight = new ComputableData<Float>();
protected Float benthosTotalComputedWeight;
- protected TuttiComputedOrNotData<Float> benthosTotalSortedComputedOrNotWeight = new TuttiComputedOrNotData<Float>();
+ protected ComputableData<Float> benthosTotalSortedComputedOrNotWeight = new ComputableData<Float>();
protected Float benthosTotalUnsortedComputedWeight;
protected Float benthosTotalSampleSortedComputedWeight;
- protected TuttiComputedOrNotData<Float> benthosTotalInertComputedOrNotWeight = new TuttiComputedOrNotData<Float>();
+ protected ComputableData<Float> benthosTotalInertComputedOrNotWeight = new ComputableData<Float>();
- protected TuttiComputedOrNotData<Float> benthosTotalLivingNotItemizedComputedOrNotWeight = new TuttiComputedOrNotData<Float>();
+ protected ComputableData<Float> benthosTotalLivingNotItemizedComputedOrNotWeight = new ComputableData<Float>();
protected Float planktonTotalWeight;
protected Float planktonTotalSampleWeight;
- protected TuttiComputedOrNotData<Float> marineLitterTotalComputedOrNotWeight = new TuttiComputedOrNotData<Float>();
+ protected ComputableData<Float> marineLitterTotalComputedOrNotWeight = new ComputableData<Float>();
- protected TuttiComputedOrNotData<Float> catchTotalComputedOrNotWeight
- = new TuttiComputedOrNotData<Float>();
+ protected ComputableData<Float> catchTotalComputedOrNotWeight
+ = new ComputableData<Float>();
protected Float catchTotalSortedComputedWeight;
@@ -106,8 +106,8 @@
protected Float catchTotalSortedCarousselWeight;
- protected TuttiComputedOrNotData<Float> catchTotalRejectedComputedOrNotWeight
- = new TuttiComputedOrNotData<Float>();
+ protected ComputableData<Float> catchTotalRejectedComputedOrNotWeight
+ = new ComputableData<Float>();
protected FishingOperation fishingOperation;
@@ -385,7 +385,7 @@
//-- Total --//
//------------------------------------------------------------------------//
- public TuttiComputedOrNotData<Float> getCatchTotalComputedOrNotWeight() {
+ public ComputableData<Float> getCatchTotalComputedOrNotWeight() {
return catchTotalComputedOrNotWeight;
}
@@ -461,7 +461,7 @@
firePropertyChange(PROPERTY_CATCH_TOTAL_SORTED_CAROUSSEL_WEIGHT, oldValue, catchTotalSortedCarousselWeight);
}
- public TuttiComputedOrNotData<Float> getCatchTotalRejectedComputedOrNotWeight() {
+ public ComputableData<Float> getCatchTotalRejectedComputedOrNotWeight() {
return catchTotalRejectedComputedOrNotWeight;
}
@@ -505,7 +505,7 @@
firePropertyChange(PROPERTY_SPECIES_TOTAL_COMPUTED_WEIGHT, oldValue, speciesTotalComputedWeight);
}
- public TuttiComputedOrNotData<Float> getSpeciesTotalSortedComputedOrNotWeight() {
+ public ComputableData<Float> getSpeciesTotalSortedComputedOrNotWeight() {
return speciesTotalSortedComputedOrNotWeight;
}
@@ -557,7 +557,7 @@
firePropertyChange(PROPERTY_SPECIES_TOTAL_UNSORTED_COMPUTED_WEIGHT, oldValue, speciesTotalUnsortedComputedWeight);
}
- public TuttiComputedOrNotData<Float> getSpeciesTotalInertComputedOrNotWeight() {
+ public ComputableData<Float> getSpeciesTotalInertComputedOrNotWeight() {
return speciesTotalInertComputedOrNotWeight;
}
@@ -585,7 +585,7 @@
firePropertyChange(PROPERTY_SPECIES_TOTAL_INERT_COMPUTED_WEIGHT, oldValue, speciesTotalInertComputedWeight);
}
- public TuttiComputedOrNotData<Float> getSpeciesTotalLivingNotItemizedComputedOrNotWeight() {
+ public ComputableData<Float> getSpeciesTotalLivingNotItemizedComputedOrNotWeight() {
return speciesTotalLivingNotItemizedComputedOrNotWeight;
}
@@ -629,7 +629,7 @@
firePropertyChange(PROPERTY_BENTHOS_TOTAL_COMPUTED_WEIGHT, oldValue, benthosTotalComputedWeight);
}
- public TuttiComputedOrNotData<Float> getBenthosTotalSortedComputedOrNotWeight() {
+ public ComputableData<Float> getBenthosTotalSortedComputedOrNotWeight() {
return benthosTotalSortedComputedOrNotWeight;
}
@@ -681,7 +681,7 @@
firePropertyChange(PROPERTY_BENTHOS_TOTAL_UNSORTED_COMPUTED_WEIGHT, oldValue, benthosTotalUnsortedComputedWeight);
}
- public TuttiComputedOrNotData<Float> getBenthosTotalInertComputedOrNotWeight() {
+ public ComputableData<Float> getBenthosTotalInertComputedOrNotWeight() {
return benthosTotalInertComputedOrNotWeight;
}
@@ -709,7 +709,7 @@
firePropertyChange(PROPERTY_BENTHOS_TOTAL_INERT_COMPUTED_WEIGHT, oldValue, benthosTotalInertComputedWeight);
}
- public TuttiComputedOrNotData<Float> getBenthosTotalLivingNotItemizedComputedOrNotWeight() {
+ public ComputableData<Float> getBenthosTotalLivingNotItemizedComputedOrNotWeight() {
return benthosTotalLivingNotItemizedComputedOrNotWeight;
}
@@ -769,7 +769,7 @@
//-- Marine Litter --//
//------------------------------------------------------------------------//
- public TuttiComputedOrNotData<Float> getMarineLitterTotalComputedOrNotWeight() {
+ public ComputableData<Float> getMarineLitterTotalComputedOrNotWeight() {
return marineLitterTotalComputedOrNotWeight;
}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationForSumatraAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationForSumatraAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationForSumatraAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,115 +0,0 @@
-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 com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.service.export.sumatra.CatchesSumatraExportService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.DateUtil;
-
-import java.io.File;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Created on 10/1/13.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 2.7
- */
-public class ExportFishingOperationForSumatraAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ExportFishingOperationForSumatraAction.class);
-
- protected File file;
-
- public ExportFishingOperationForSumatraAction(EditCatchesUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- FishingOperation fishingOperation = getModel().getFishingOperation();
-
- String date = DateUtil.formatDate(new Date(), "dd-MM-yyyy");
- // choose file to export
- file = saveFile(
- String.format("sumatra_%s_%s_%s", getDataContext().getCruise().getName(), fishingOperation.getId(), date),
- "csv",
- _("tutti.exportFishingOperationForSumatra.title.choose.exportFile"),
- _("tutti.exportFishingOperationForSumatra.action.chooseFile"),
- "^.+\\.csv$", _("tutti.common.file.csv")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Cruise cruise = getDataContext().getCruise();
- FishingOperation fishingOperation = getModel().getFishingOperation();
- Preconditions.checkNotNull(cruise);
- Preconditions.checkNotNull(fishingOperation);
- Preconditions.checkNotNull(file);
-
- if (log.isInfoEnabled()) {
- log.info("Will export fishingOperation " + cruise.getId() + "-" + fishingOperation.getStationNumber() +
- " to file: " + file);
- }
-
- // export catches
- CatchesSumatraExportService service =
- getContext().getCatchesSumatraExportService();
- service.exportFishingOperationForSumatra(file,
- cruise.getId(),
- fishingOperation.getId());
-
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.exportFishingOperationForSumatra.action.success", file));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationReportAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationReportAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ExportFishingOperationReportAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,110 +0,0 @@
-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 com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.service.export.pdf.CatchesPdfExportService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Opens a file chooser, exports the cruise catches into the selected file and open the default email editor.
- *
- * @author kmorin <morin(a)codelutin.com>
- * @since 1.0
- */
-public class ExportFishingOperationReportAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ExportFishingOperationReportAction.class);
-
- protected File file;
-
- public ExportFishingOperationReportAction(EditCatchesUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- Cruise cruise = getDataContext().getCruise();
- FishingOperation fishingOperation = getModel().getFishingOperation();
- // choose file to export
- file = saveFile(
- "exportFishingOperation-" + cruise.getName() + "-" + fishingOperation.getStationNumber(),
- "pdf",
- _("tutti.exportFishingOperationReport.title.choose.exportFile"),
- _("tutti.exportFishingOperationReport.action.chooseFile"),
- "^.+\\.pdf$", _("tutti.common.file.pdf")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Cruise cruise = getDataContext().getCruise();
- FishingOperation fishingOperation = getModel().getFishingOperation();
- Preconditions.checkNotNull(cruise);
- Preconditions.checkNotNull(fishingOperation);
- Preconditions.checkNotNull(file);
-
- if (log.isInfoEnabled()) {
- log.info("Will export fishingOperation " + cruise.getId() + "-" + fishingOperation.getStationNumber() +
- " to file: " + file);
- }
-
- // export catches
- CatchesPdfExportService service =
- getContext().getGeneratePDFService();
- service.generateFishingOperationPDFFile(file, fishingOperation.getId(), getConfig().getI18nLocale());
-
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.exportFishingOperationReport.action.success", file));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,107 +0,0 @@
-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.util.TuttiBeanMonitor;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * To save a {@link CatchBatch}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class SaveCatchBatchAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
-
- /** 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, true);
- }
-
- public void setUpdateUI(boolean updateUI) {
- this.updateUI = updateUI;
- }
-
- @Override
- public void releaseAction() {
- updateUI = true;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
-
- 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 =
- getContext().getPersistenceService();
-
- CatchBatch catchBatch = beanToSave.toEntity();
-
- if (log.isInfoEnabled()) {
- log.info("FishingOperation " + catchBatch.getId() +
- " was modified, will save it.");
- }
-
- //FIXME I18n
- sendMessage(
- "[ Captures - Caractéristiques générales ] " +
- "Sauvegarde des modifications du résumé de la capture.");
-
- persistenceService.saveCatchBatch(catchBatch);
-
- monitor.clearModified();
- getModel().setModify(false);
- }
-
- getUI().getSpeciesTabContent().getHandler().clearTableSelection();
-
- }
-
-}
\ No newline at end of file
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -54,7 +54,7 @@
text: "tutti.editAccidentalBatch.action.importMultiPost";
toolTipText: "tutti.editAccidentalBatch.action.importMultiPost.tip";
i18nMnemonic: "tutti.editAccidentalBatch.action.importMultiPost.mnemonic";
- _applicationAction: {ImportMultiPostAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportAccidentalMultiPostAction.class};
_help: {"tutti.editAccidentalBatch.action.importMultiPost.help"};
}
@@ -63,7 +63,7 @@
text: "tutti.editAccidentalBatch.action.exportMultiPost";
toolTipText: "tutti.editAccidentalBatch.action.exportMultiPost.tip";
i18nMnemonic: "tutti.editAccidentalBatch.action.exportMultiPost.mnemonic";
- _applicationAction: {ExportMultiPostAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportAccidentalMultiPostAction.class};
_help: {"tutti.editAccidentalBatch.action.exportMultiPost.help"};
}
@@ -80,7 +80,7 @@
text: "tutti.editAccidentalBatch.action.removeBatch";
toolTipText: "tutti.editAccidentalBatch.action.removeBatch.tip";
i18nMnemonic: "tutti.editAccidentalBatch.action.removeBatch.mnemonic";
- _applicationAction: {RemoveAccidentalBatchAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.RemoveAccidentalBatchAction.class};
enabled: {model.isRemoveBatchEnabled()};
_help: {"tutti.editAccidentalBatch.action.removeBatch.help"};
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.jaxx
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.jaxx 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.jaxx 2013-11-26 08:03:42 UTC (rev 1388)
@@ -30,8 +30,6 @@
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.util.TuttiUI
- jaxx.runtime.swing.editor.NumberEditor
-
org.jdesktop.swingx.JXTable
javax.swing.ListSelectionModel
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIModel.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -26,7 +26,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
-import fr.ifremer.tutti.ui.swing.util.TabContentModel;
+import fr.ifremer.shared.application.swing.tab.TabContentModel;
import org.apache.commons.collections.CollectionUtils;
import static org.nuiton.i18n.I18n.n_;
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/ExportMultiPostAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/ExportMultiPostAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/ExportMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,72 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.accidental;
-
-/*
- * #%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.ui.swing.content.operation.catches.AbstractExportMultiPostAction;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.2
- */
-public class ExportMultiPostAction
- extends AbstractExportMultiPostAction<AccidentalBatchUIModel, AccidentalBatchUI, AccidentalBatchUIHandler> {
-
- public ExportMultiPostAction(AccidentalBatchUIHandler handler) {
- super(handler);
- }
-
- @Override
- protected String getFileExtension() {
- return "tuttiAccidental";
- }
-
- @Override
- protected String getFileExtensionDescription() {
- return _("tutti.common.file.tuttiAccidental");
- }
-
- @Override
- protected String getFileChooserTitle() {
- return _("tutti.editAccidentalBatch.action.exportMultiPost.destinationFile.title");
- }
-
- @Override
- protected String getFileChooserButton() {
- return _("tutti.editAccidentalBatch.action.exportMultiPost.destinationFile.button");
- }
-
- @Override
- public void doAction() throws Exception {
- multiPostImportExportService.exportAccidentalCatch(file, currentOperation);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.editAccidentalBatch.action.exportMultiPost.success", file));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/ImportMultiPostAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/ImportMultiPostAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/ImportMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,74 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.accidental;
-
-/*
- * #%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.content.operation.catches.AbstractImportMultiPostAction;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.2
- */
-public class ImportMultiPostAction
- extends AbstractImportMultiPostAction<AccidentalBatchUIModel, AccidentalBatchUI, AccidentalBatchUIHandler> {
-
- public ImportMultiPostAction(AccidentalBatchUIHandler handler) {
- super(handler);
- }
-
- @Override
- protected String getFileExtension() {
- return "tuttiAccidental";
- }
-
- @Override
- protected String getFileExtensionDescription() {
- return _("tutti.common.file.tuttiAccidental");
- }
-
- @Override
- protected String getFileChooserTitle() {
- return _("tutti.editAccidentalBatch.action.importMultiPost.sourceFile.title");
- }
-
- @Override
- protected String getFileChooserButton() {
- return _("tutti.editAccidentalBatch.action.importMultiPost.sourceFile.button");
- }
-
- @Override
- protected void importBatches(FishingOperation operation) {
- multiPostImportExportService.importAccidentalCatches(file, operation);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- sendMessage(_("tutti.editAccidentalBatch.action.importMultiPost.success", file));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/RemoveAccidentalBatchAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/RemoveAccidentalBatchAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/RemoveAccidentalBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,112 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.accidental;
-
-/*
- * #%L
- * Tutti :: UI
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.TuttiPersistence;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.JXTable;
-
-import javax.swing.JOptionPane;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.4
- */
-public class RemoveAccidentalBatchAction extends AbstractTuttiAction<AccidentalBatchUIModel, AccidentalBatchUI, AccidentalBatchUIHandler> {
-
- private static final Log log =
- LogFactory.getLog(RemoveAccidentalBatchAction.class);
-
- public RemoveAccidentalBatchAction(AccidentalBatchUIHandler handler) {
- super(handler, false);
- }
-
- int rowIndex;
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
-
- if (result) {
- int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- _("tutti.editAccidentalBatch.action.removeBatch.confirm.message"),
- _("tutti.editAccidentalBatch.action.removeBatch.confirm.title"),
- JOptionPane.YES_NO_OPTION);
- result = answer == JOptionPane.YES_OPTION;
- }
-
- return result;
- }
-
- @Override
- public void doAction() throws Exception {
-
- JXTable table = handler.getTable();
-
- rowIndex = table.getSelectedRow();
-
- Preconditions.checkState(rowIndex != -1,
- "Cant remove batch if none is selected");
-
- AccidentalBatchTableModel tableModel = handler.getTableModel();
- AccidentalBatchRowModel selectedBatch = tableModel.getEntry(rowIndex);
-
- boolean persisted = !TuttiEntities.isNew(selectedBatch);
-
- if (persisted) {
-
- // remove it from db
-
- String id = selectedBatch.getId();
-
- if (log.isInfoEnabled()) {
- log.info("Remove accidental with id: " + id);
- }
-
- TuttiPersistence persistenceService =
- getContext().getPersistenceService();
-
- persistenceService.deleteAccidentalBatch(id);
- }
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- JXTable table = handler.getTable();
-
- AccidentalBatchTableModel tableModel = handler.getTableModel();
-
- tableModel.removeRow(rowIndex);
-
- TuttiUIUtil.selectFirstCellOnFirstRowAndStopEditing(table);
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/create/CreateAccidentalBatchUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/create/CreateAccidentalBatchUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/create/CreateAccidentalBatchUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -28,7 +28,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.AccidentalBatchUI;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
-import fr.ifremer.tutti.ui.swing.util.Cancelable;
+import fr.ifremer.shared.application.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUI;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUIModel;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -41,7 +41,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryAble;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyRowModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
-import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
+import fr.ifremer.shared.application.swing.computable.ComputableData;
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
@@ -124,16 +124,16 @@
*
* @since 0.2
*/
- protected TuttiComputedOrNotData<Float> computedOrNotWeight =
- new TuttiComputedOrNotData<Float>();
+ protected ComputableData<Float> computedOrNotWeight =
+ new ComputableData<Float>();
/**
* Total computed number (from frequencies).
*
* @since 0.2
*/
- protected TuttiComputedOrNotData<Integer> computedOrNotNumber =
- new TuttiComputedOrNotData<Integer>();
+ protected ComputableData<Integer> computedOrNotNumber =
+ new ComputableData<Integer>();
/**
* Comment.
@@ -554,19 +554,19 @@
computedOrNotWeight.setComputedData(computedWeight);
}
- public TuttiComputedOrNotData<Integer> getComputedOrNotNumber() {
+ public ComputableData<Integer> getComputedOrNotNumber() {
return computedOrNotNumber;
}
- public void setComputedOrNotNumber(TuttiComputedOrNotData<Integer> computedOrNotNumber) {
+ public void setComputedOrNotNumber(ComputableData<Integer> computedOrNotNumber) {
this.computedOrNotNumber = computedOrNotNumber;
}
- public TuttiComputedOrNotData<Float> getComputedOrNotWeight() {
+ public ComputableData<Float> getComputedOrNotWeight() {
return computedOrNotWeight;
}
- public void setComputedOrNotWeight(TuttiComputedOrNotData<Float> computedOrNotWeight) {
+ public void setComputedOrNotWeight(ComputableData<Float> computedOrNotWeight) {
this.computedOrNotWeight = computedOrNotWeight;
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -31,7 +31,7 @@
_selectOnFocus: {true};
}
-TuttiComputedOrNotDataEditor {
+ComputableDataEditor {
autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
showReset: true;
@@ -205,7 +205,7 @@
text: "tutti.editBenthosBatch.action.removeBatch";
toolTipText: "tutti.editBenthosBatch.action.removeBatch.tip";
i18nMnemonic: "tutti.editBenthosBatch.action.removeBatch.mnemonic";
- _applicationAction: {RemoveBenthosBatchAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.RemoveBenthosBatchAction.class};
enabled: {model.isTableViewModeAll() && model.isRemoveBatchEnabled()};
_help: {"tutti.editBenthosBatch.action.removeBatch.help"};
}
@@ -215,7 +215,7 @@
text: "tutti.editBenthosBatch.action.removeSubBatch";
toolTipText: "tutti.editBenthosBatch.action.removeSubBatch.tip";
i18nMnemonic: "tutti.editBenthosBatch.action.removeSubBatch.mnemonic";
- _applicationAction: {RemoveBenthosSubBatchAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.RemoveBenthosSubBatchAction.class};
enabled: {model.isTableViewModeAll() && model.isRemoveSubBatchEnabled()};
_help: {"tutti.editBenthosBatch.action.removeSubBatch.help"};
}
@@ -225,7 +225,7 @@
text: "tutti.editBenthosBatch.action.renameBatch";
toolTipText: "tutti.editBenthosBatch.action.renameBatch.tip";
i18nMnemonic: "tutti.editBenthosBatch.action.renameBatch.mnemonic";
- _applicationAction: {RenameBenthosBatchAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.RenameBenthosBatchAction.class};
enabled: {model.isTableViewModeAll() && model.isRenameBatchEnabled()};
_help: {"tutti.editBenthosBatch.action.renameBatch.help"};
}
@@ -235,7 +235,7 @@
text: "tutti.editBenthosBatch.action.createMelag";
toolTipText: "tutti.editBenthosBatch.action.createMelag.tip";
i18nMnemonic: "tutti.editBenthosBatch.action.createMelag.mnemonic";
- _applicationAction: {CreateBenthosMelagAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.CreateBenthosMelagAction.class};
enabled: {!model.isTableViewModeLeaf() && model.isCreateMelagEnabled()};
_help: {"tutti.editBenthosBatch.action.createMelag.help"};
}
@@ -254,7 +254,7 @@
text: "tutti.editBenthosBatch.action.importMultiPost";
toolTipText: "tutti.editBenthosBatch.action.importMultiPost.tip";
i18nMnemonic: "tutti.editBenthosBatch.action.importMultiPost.mnemonic";
- _applicationAction: {ImportMultiPostAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportBenthosMultiPostAction.class};
_help: {"tutti.editBenthosBatch.action.importMultiPost.help"};
}
@@ -263,7 +263,7 @@
text: "tutti.editBenthosBatch.action.exportMultiPost";
toolTipText: "tutti.editBenthosBatch.action.exportMultiPost.tip";
i18nMnemonic: "tutti.editBenthosBatch.action.exportMultiPost.mnemonic";
- _applicationAction: {ExportMultiPostAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportBenthosMultiPostAction.class};
_help: {"tutti.editBenthosBatch.action.exportMultiPost.help"};
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2013-11-26 08:03:42 UTC (rev 1388)
@@ -25,12 +25,12 @@
decorator='help'
implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<BenthosBatchUIModel, BenthosBatchUIHandler>'>
- <import>
+ <import><![CDATA[
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode
fr.ifremer.tutti.ui.swing.util.TuttiUI
- fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor
+ fr.ifremer.shared.application.swing.computable.ComputableDataEditor
org.jdesktop.swingx.JXTable
@@ -40,7 +40,7 @@
static org.nuiton.i18n.I18n._
static fr.ifremer.shared.application.ApplicationDataUtil.getWeightStringValue
- </import>
+ ]]></import>
<script><![CDATA[
@@ -102,8 +102,8 @@
<JLabel id='benthosTotalSortedWeightLabel'/>
</cell>
<cell weightx='1.0'>
- <TuttiComputedOrNotDataEditor id='benthosTotalSortedWeightField'
- constructorParams='this'/>
+ <ComputableDataEditor id='benthosTotalSortedWeightField'
+ genericType="Float" constructorParams='this'/>
</cell>
</row>
@@ -129,16 +129,15 @@
<JLabel id='benthosTotalInertWeightLabel'/>
</cell>
<cell>
- <TuttiComputedOrNotDataEditor id='benthosTotalInertWeightField'
- constructorParams='this'/>
+ <ComputableDataEditor id='benthosTotalInertWeightField'
+ genericType="Float" constructorParams='this'/>
</cell>
<cell>
<JLabel id='benthosTotalLivingNotItemizedWeightLabel'/>
</cell>
<cell>
- <TuttiComputedOrNotDataEditor
- id='benthosTotalLivingNotItemizedWeightField'
- constructorParams='this'/>
+ <ComputableDataEditor id='benthosTotalLivingNotItemizedWeightField'
+ genericType="Float" constructorParams='this'/>
</cell>
</row>
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -27,6 +27,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
+import fr.ifremer.shared.application.swing.computable.ComputableDataTableCell;
import fr.ifremer.shared.application.swing.table.ColumnIdentifier;
import fr.ifremer.shared.application.type.WeightUnit;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
@@ -67,7 +68,6 @@
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellRenderer;
import fr.ifremer.tutti.ui.swing.util.comment.CommentCellEditor;
import fr.ifremer.tutti.ui.swing.util.comment.CommentCellRenderer;
-import fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataTableCell;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUI;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUIModel;
import jaxx.runtime.SwingUtil;
@@ -750,9 +750,9 @@
{ // Weight column
addColumnToModel(columnModel,
- TuttiComputedOrNotDataTableCell.newEditor(
+ ComputableDataTableCell.newEditor(
Float.class, weightUnit, computedDataColor),
- TuttiComputedOrNotDataTableCell.newRender(
+ ComputableDataTableCell.newRender(
defaultRenderer, weightUnit, computedDataColor),
BenthosBatchTableModel.WEIGHT,
weightUnit);
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -30,8 +30,8 @@
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode;
-import fr.ifremer.tutti.ui.swing.util.TabContentModel;
-import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
+import fr.ifremer.shared.application.swing.tab.TabContentModel;
+import fr.ifremer.shared.application.swing.computable.ComputableData;
import org.apache.commons.collections.CollectionUtils;
import static org.nuiton.i18n.I18n.n_;
@@ -179,7 +179,7 @@
catchesUIModel.setBenthosTotalComputedWeight(speciesTotalComputedWeight);
}
- public TuttiComputedOrNotData<Float> getBenthosTotalSortedComputedOrNotWeight() {
+ public ComputableData<Float> getBenthosTotalSortedComputedOrNotWeight() {
return catchesUIModel.getBenthosTotalSortedComputedOrNotWeight();
}
@@ -215,7 +215,7 @@
catchesUIModel.setBenthosTotalSampleSortedComputedWeight(speciesTotalSampleSortedComputedWeight);
}
- public TuttiComputedOrNotData<Float> getBenthosTotalInertComputedOrNotWeight() {
+ public ComputableData<Float> getBenthosTotalInertComputedOrNotWeight() {
return catchesUIModel.getBenthosTotalInertComputedOrNotWeight();
}
@@ -235,7 +235,7 @@
catchesUIModel.setBenthosTotalInertComputedWeight(speciesTotalInertComputedWeight);
}
- public TuttiComputedOrNotData<Float> getBenthosTotalLivingNotItemizedComputedOrNotWeight() {
+ public ComputableData<Float> getBenthosTotalLivingNotItemizedComputedOrNotWeight() {
return catchesUIModel.getBenthosTotalLivingNotItemizedComputedOrNotWeight();
}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/CreateBenthosMelagAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/CreateBenthosMelagAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/CreateBenthosMelagAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,197 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos;
-
-/*
- * #%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.Maps;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.frequency.BenthosFrequencyRowModel;
-import fr.ifremer.shared.application.type.WeightUnit;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import fr.ifremer.tutti.ui.swing.util.species.EnterMelagWeightDialog;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.lang3.StringUtils;
-
-import javax.swing.JOptionPane;
-import java.awt.Frame;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.0.2
- */
-public class CreateBenthosMelagAction extends AbstractTuttiAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> {
-
- protected Map<BenthosBatchRowModel, Float> selectedRows = Maps.newHashMap();
-
- protected Float melagWeight = null;
-
- protected Float sampleMelagWeight = null;
-
- protected Float sortedWeight = null;
-
- /**
- * Weight unit.
- *
- * @since 2.5
- */
- protected final WeightUnit weightUnit;
-
- public CreateBenthosMelagAction(BenthosBatchUIHandler handler) {
- super(handler, false);
- weightUnit = getConfig().getBenthosWeightUnit();
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
-
- int[] selectedRowIndexes = SwingUtil.getSelectedModelRows(handler.getTable());
-
- BenthosBatchTableModel tableModel = handler.getTableModel();
-
- // sum of the weights already entered by the user
- Float alreadyKnownWeights = 0f;
- sortedWeight = 0f;
-
- for (int selectedRowIndex : selectedRowIndexes) {
- BenthosBatchRowModel selectedRow =
- tableModel.getEntry(selectedRowIndex);
-
- Float sampleWeight = null;
- if (selectedRow.getFinestCategory().getNotNullWeight() != null) {
- alreadyKnownWeights += selectedRow.getFinestCategory().getNotNullWeight();
-
- } else if (selectedRow.getWeight() != null) {
- sampleWeight = selectedRow.getWeight();
-
- } else {
- sampleWeight = 0f;
- if (selectedRow.getFrequency() != null) {
- for (BenthosFrequencyRowModel frequency : selectedRow.getFrequency()) {
- if (frequency.getWeight() == null) {
- sampleWeight = 0f;
- break;
- }
- sampleWeight += frequency.getWeight();
- }
- }
- }
-
- if (sampleWeight != null) {
- if (sampleWeight == 0f) {
- JOptionPane.showMessageDialog(
- getUI(),
- _("tutti.createBenthosMelag.error.message", selectedRowIndex + 1),
- _("tutti.createBenthosMelag.error.title"),
- JOptionPane.ERROR_MESSAGE);
-
- SwingUtil.setSelectionInterval(handler.getTable(), selectedRowIndex);
- result = false;
- break;
-
- } else {
- sortedWeight += sampleWeight;
- }
- }
-
- selectedRows.put(selectedRow, sampleWeight);
- }
-
- if (result) {
- melagWeight = openMelagWeightDialog();
-
- if (melagWeight != null) {
- // substract the weights that the user already entered
- // they must not be used to compute the other weights
- sampleMelagWeight = melagWeight - alreadyKnownWeights;
- }
- }
-
- return result && melagWeight != null;
- }
-
- protected Float openMelagWeightDialog() {
- Frame frame = SwingUtil.getParentContainer(getUI(), Frame.class);
-
- EnterMelagWeightDialog dialog = new EnterMelagWeightDialog(
- frame, getConfig().getShortcutClosePopup());
- dialog.setWeightUnit(weightUnit);
- SwingUtil.center(frame, dialog);
- dialog.pack();
- dialog.setVisible(true);
-
- Float result = null;
- if (dialog.getEditor().getModel() != null) {
- result = dialog.getEditor().getModel().floatValue();
- }
- return result;
- }
-
- @Override
- public void doAction() throws Exception {
- String unitLabel = weightUnit.getShortLabel();
- String melagComment = _("tutti.createBenthosMelag.comment.part1") + "\n";
- for (BenthosBatchRowModel batch : selectedRows.keySet()) {
- Float sampleWeight = selectedRows.get(batch);
- if (sampleWeight != null) {
- Float weight = sampleMelagWeight * sampleWeight / sortedWeight;
- batch.getFinestCategory().setCategoryWeight(weight);
- }
- melagComment += _("tutti.createBenthosMelag.comment.part2", sampleWeight, unitLabel, decorate(batch.getSpecies())) + "\n";
- }
- melagComment += _("tutti.createBenthosMelag.comment.part3", melagWeight, unitLabel);
-
- for (BenthosBatchRowModel batch : selectedRows.keySet()) {
- String comment = batch.getComment();
- if (StringUtils.isBlank(comment)) {
- comment = "";
-
- } else {
- comment += "\n";
- }
- comment += melagComment;
- batch.setComment(comment);
- }
- getHandler().saveRows(selectedRows.keySet());
- }
-
- @Override
- public void releaseAction() {
- super.releaseAction();
- //FIXME-TC No release action is not design to refresh ui...
-// getHandler().getTable().repaint();
- selectedRows.clear();
- melagWeight = null;
- sortedWeight = null;
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- getHandler().getTable().repaint();
-
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/ExportMultiPostAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/ExportMultiPostAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/ExportMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,71 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos;
-
-/*
- * #%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.ui.swing.content.operation.catches.AbstractExportMultiPostAction;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.2
- */
-public class ExportMultiPostAction extends AbstractExportMultiPostAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> {
-
- public ExportMultiPostAction(BenthosBatchUIHandler handler) {
- super(handler);
- }
-
- @Override
- protected String getFileExtension() {
- return "tuttiBenthos";
- }
-
- @Override
- protected String getFileExtensionDescription() {
- return _("tutti.common.file.tuttiBenthos");
- }
-
- @Override
- protected String getFileChooserTitle() {
- return _("tutti.editBenthosBatch.action.exportMultiPost.destinationFile.title");
- }
-
- @Override
- protected String getFileChooserButton() {
- return _("tutti.editBenthosBatch.action.exportMultiPost.destinationFile.button");
- }
-
- @Override
- public void doAction() throws Exception {
- multiPostImportExportService.exportBenthos(file, currentOperation);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.editBenthosBatch.action.exportMultiPost.success", file));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/ImportMultiPostAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/ImportMultiPostAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/ImportMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,126 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos;
-
-/*
- * #%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.BenthosBatch;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.service.catches.multipost.MultiPostImportService;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.AbstractImportMultiPostAction;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.MultiPostImportLogDialog;
-
-import javax.swing.JTextArea;
-import java.awt.Dialog;
-import java.util.Collection;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.2
- */
-public class ImportMultiPostAction extends AbstractImportMultiPostAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> {
-
- protected Map<String, Object> notImportedData;
-
- public ImportMultiPostAction(BenthosBatchUIHandler handler) {
- super(handler);
- }
-
- @Override
- protected String getFileExtension() {
- return "tuttiBenthos";
- }
-
- @Override
- protected String getFileExtensionDescription() {
- return _("tutti.common.file.tuttiBenthos");
- }
-
- @Override
- protected String getFileChooserTitle() {
- return _("tutti.editBenthosBatch.action.importMultiPost.sourceFile.title");
- }
-
- @Override
- protected String getFileChooserButton() {
- return _("tutti.editBenthosBatch.action.importMultiPost.sourceFile.button");
- }
-
- @Override
- public void releaseAction() {
- notImportedData = null;
- super.releaseAction();
- }
-
- @Override
- protected void importBatches(FishingOperation operation) {
- notImportedData = multiPostImportExportService.importBenthos(file, operation);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- if (!notImportedData.isEmpty()) {
- MultiPostImportLogDialog dialog = new MultiPostImportLogDialog((Dialog) getContext().getActionUI());
-
- Collection<BenthosBatch> notImportedBenthosBatches =
- (Collection<BenthosBatch>) notImportedData.get(MultiPostImportService.BATCHES_KEY);
-
- StringBuffer stringBuffer = new StringBuffer();
- Float totalSortedWeight = (Float) notImportedData.get(CatchBatch.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT);
- if (totalSortedWeight != null) {
- stringBuffer.append("- " + _("tutti.multiPostImportLog.totalSortedWeight", totalSortedWeight) + "\n");
- }
-
- Float inertWeight = (Float) notImportedData.get(CatchBatch.PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT);
- if (inertWeight != null) {
- stringBuffer.append("- " + _("tutti.multiPostImportLog.inertWeight", inertWeight) + "\n");
- }
-
- Float livingNotItemizedWeight =
- (Float) notImportedData.get(CatchBatch.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT);
- if (livingNotItemizedWeight != null) {
- stringBuffer.append("- " + _("tutti.multiPostImportLog.livingNotItemizedWeight", livingNotItemizedWeight) + "\n");
- }
-
- for (BenthosBatch sb : notImportedBenthosBatches) {
- stringBuffer.append("- " + decorate(sb.getSpecies()) + " / " + decorate(sb.getSampleCategoryValue()) + "\n");
- }
-
- if (stringBuffer.length() > 0) {
- JTextArea batchList = dialog.getBatchList();
- batchList.setText(stringBuffer.toString());
- dialog.setSize(400, 300);
- dialog.setLocationRelativeTo(getContext().getMainUI());
- dialog.setVisible(true);
- }
- }
-
- sendMessage(_("tutti.editBenthosBatch.action.importMultiPost.success", file));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,141 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
-import fr.ifremer.tutti.persistence.TuttiPersistence;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import jaxx.runtime.SwingUtil;
-import org.jdesktop.swingx.JXTable;
-
-import javax.swing.JOptionPane;
-import java.util.Set;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To remove a species batch and all his children.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class RemoveBenthosBatchAction extends AbstractTuttiAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> {
-
- /**
- * Selected row to treat.
- *
- * @since 2.8
- */
- protected int rowIndex;
-
- /**
- * Rows to delete after all.
- *
- * @since 3.0-rc-1
- */
- protected Set<BenthosBatchRowModel> rowToRemove;
-
- public RemoveBenthosBatchAction(BenthosBatchUIHandler handler) {
- super(handler, false);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
-
- rowIndex = -1;
-
- if (result) {
- int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- _("tutti.editBenthosBatch.action.removeBatch.confirm.message"),
- _("tutti.editBenthosBatch.action.removeBatch.confirm.title"),
- JOptionPane.YES_NO_OPTION);
- result = answer == JOptionPane.YES_OPTION;
- }
-
- return result;
- }
-
- @Override
- public void doAction() throws Exception {
-
- TuttiPersistence persistenceService =
- getContext().getPersistenceService();
-
- JXTable table = handler.getTable();
-
- rowIndex = SwingUtil.getSelectedModelRow(table);
-
- Preconditions.checkState(rowIndex != -1,
- "Cant remove batch if no batch selected");
-
- BenthosBatchTableModel tableModel = handler.getTableModel();
- BenthosBatchRowModel selectedBatch = tableModel.getEntry(rowIndex);
-
- Preconditions.checkState(!TuttiEntities.isNew(selectedBatch),
- "Can't remove batch if batch is not persisted");
-
- // remove selected batch and all his children
-
- // remove parent batch (will destroy all his childs from db)
- persistenceService.deleteBenthosBatch(selectedBatch.getId());
-
- if (selectedBatch.isBatchRoot()) {
- // update speciesUsed
- handler.removeFromSpeciesUsed(selectedBatch);
- } else {
-
- // remove from his parent
- BenthosBatchRowModel parentBatch = selectedBatch.getParentBatch();
- parentBatch.getChildBatch().remove(selectedBatch);
- }
-
- // collect of rows to remove from model
- rowToRemove = Sets.newHashSet();
- rowToRemove.add(selectedBatch);
-
- handler.collectChildren(selectedBatch, rowToRemove);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- JXTable table = handler.getTable();
-
- // remove all rows from the model
- getModel().getRows().removeAll(rowToRemove);
-
- // refresh table from parent batch row index to the end
- handler.getTableModel().fireTableDataChanged();
-
- // select parent batch row
- TuttiUIUtil.selectFirstCellOnFirstRowAndStopEditing(table);
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RemoveBenthosSubBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,136 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
-import fr.ifremer.tutti.persistence.TuttiPersistence;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import jaxx.runtime.SwingUtil;
-import org.jdesktop.swingx.JXTable;
-
-import javax.swing.JOptionPane;
-import java.util.Set;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To remove a species batch children.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class RemoveBenthosSubBatchAction extends AbstractTuttiAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> {
-
- /**
- * Selected row to treat.
- *
- * @since 2.8
- */
- protected int rowIndex;
-
- /**
- * Rows to delete after all.
- *
- * @since 3.0-rc-1
- */
- protected Set<BenthosBatchRowModel> rowToRemove;
-
- /**
- * Parent batch of rows to delete.
- *
- * @since 3.0-rc-1
- */
- protected BenthosBatchRowModel parentBatch;
-
- public RemoveBenthosSubBatchAction(BenthosBatchUIHandler handler) {
- super(handler, false);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
-
- rowIndex = -1;
-
- if (result) {
- int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- _("tutti.editBenthosBatch.action.removeSubBatch.confirm.message"),
- _("tutti.editBenthosBatch.action.removeSubBatch.confirm.title"),
- JOptionPane.YES_NO_OPTION);
- result = answer == JOptionPane.YES_OPTION;
- }
-
- return result;
- }
-
- @Override
- public void doAction() throws Exception {
-
- TuttiPersistence persistenceService =
- getContext().getPersistenceService();
-
- JXTable table = handler.getTable();
-
- rowIndex = SwingUtil.getSelectedModelRow(table);
-
- Preconditions.checkState(rowIndex != -1,
- "Cant remove sub batch if no batch selected");
-
- parentBatch = handler.getTableModel().getEntry(rowIndex);
-
- Preconditions.checkState(!TuttiEntities.isNew(parentBatch),
- "Can't remove sub batch if batch is not persisted");
-
- // save parent batch (will destroy all his childs from db)
- persistenceService.deleteSpeciesSubBatch(parentBatch.getId());
-
- // collect of rows to remove from model
- rowToRemove = Sets.newHashSet();
-
- handler.collectChildren(parentBatch, rowToRemove);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- JXTable table = handler.getTable();
-
- // remove all rows from the model
- getModel().getRows().removeAll(rowToRemove);
-
- // remove childs from parent batch
- parentBatch.setChildBatch(null);
-
- // refresh table from parent batch row index to the end
- handler.getTableModel().fireTableDataChanged();
-
- // select parent batch row
- TuttiUIUtil.selectFirstCellOnRow(table, rowIndex, true);
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RenameBenthosBatchAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RenameBenthosBatchAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/RenameBenthosBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,120 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos;
-
-/*
- * #%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.data.SampleCategory;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import jaxx.runtime.SwingUtil;
-import org.jdesktop.swingx.JXTable;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To rename the species for a species batch and all his children.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class RenameBenthosBatchAction extends AbstractTuttiAction<BenthosBatchUIModel, BenthosBatchUI, BenthosBatchUIHandler> {
-
- protected Species selectedSpecies;
-
- public RenameBenthosBatchAction(BenthosBatchUIHandler handler) {
- super(handler, false);
-
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
-
- BenthosBatchTableModel tableModel = handler.getTableModel();
- JXTable table = handler.getTable();
- int selectedRowIndex = SwingUtil.getSelectedModelRow(table);
- BenthosBatchRowModel row = tableModel.getEntry(selectedRowIndex);
-
- BenthosBatchUIModel model = handler.getModel();
- List<Species> speciesList = Lists.newArrayList(
- getDataContext().getReferentBenthosWithSurveyCode());
- SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
- Serializable categoryValue = firstSampleCategory.getCategoryValue();
- speciesList.removeAll(
- model.getSpeciesUsed().get(
- (CaracteristicQualitativeValue) categoryValue));
-
- selectedSpecies = getHandler().openAddSpeciesDialog(
- _("tutti.selectSpecies.title"),
- speciesList
- );
-
- result &= selectedSpecies != null;
- return result;
- }
-
- @Override
- public void releaseAction() {
- selectedSpecies = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
-
- BenthosBatchTableModel tableModel = handler.getTableModel();
- JXTable table = handler.getTable();
- int selectedRowIndex = SwingUtil.getSelectedModelRow(table);
- BenthosBatchRowModel row = tableModel.getEntry(selectedRowIndex);
-
- PersistenceService persistenceService = getContext().getPersistenceService();
- persistenceService.changeBenthosBatchSpecies(row.getId(), selectedSpecies);
-
- SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
- Serializable categoryValue = firstSampleCategory.getCategoryValue();
- Collection<Species> speciesUsed = getModel().getSpeciesUsed()
- .get((CaracteristicQualitativeValue) categoryValue);
- speciesUsed.remove(row.getSpecies());
- changeChildrenSpecies(row, selectedSpecies);
- speciesUsed.add(selectedSpecies);
- }
-
- protected void changeChildrenSpecies(BenthosBatchRowModel row,
- Species species) {
- row.setSpecies(species);
- List<BenthosBatchRowModel> children = row.getChildBatch();
- if (children != null) {
- for (BenthosBatchRowModel child : children) {
- changeChildrenSpecies(child, species);
- }
- }
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -139,7 +139,7 @@
text: "tutti.createBenthosBatch.action.addSpecies";
toolTipText: "tutti.createBenthosBatch.action.addSpecies.tip";
i18nMnemonic: "tutti.createBenthosBatch.action.addSpecies.mnemonic";
- _applicationAction: {SelectSpeciesForBenthosBatchAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SelectSpeciesForBenthosBatchAction.class};
_help: {"tutti.createBenthosBatch.action.addSpecies.help"};
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -41,7 +41,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split.SplitBenthosBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.split.SplitBenthosBatchTableModel;
-import fr.ifremer.tutti.ui.swing.util.Cancelable;
+import fr.ifremer.shared.application.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.shared.application.type.WeightUnit;
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/SelectSpeciesForBenthosBatchAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/SelectSpeciesForBenthosBatchAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/SelectSpeciesForBenthosBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,101 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.create;
-
-/*
- * #%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.referential.Species;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Enable to select a species to the species selected in the protocol.
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.0
- */
-public class SelectSpeciesForBenthosBatchAction extends AbstractTuttiAction<CreateBenthosBatchUIModel, CreateBenthosBatchUI, CreateBenthosBatchUIHandler> {
-
- protected List<Species> allSpecies;
-
- protected List<Species> referentSpecies;
-
- protected Species selectedSpecies;
-
- public SelectSpeciesForBenthosBatchAction(CreateBenthosBatchUIHandler handler) {
- super(handler, false);
-
- allSpecies = getDataContext().getSpecies();
- referentSpecies = getDataContext().getReferentSpecies();
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean canContinue = super.prepareAction();
- if (canContinue) {
-
- CreateBenthosBatchUIModel model = getModel();
-
- List<Species> species = Lists.newArrayList(allSpecies);
- species.removeAll(model.getAvailableSpecies());
-
- selectedSpecies = getHandler().openAddSpeciesDialog(
- _("tutti.selectSpecies.title"), species);
- canContinue = selectedSpecies != null;
- }
- return canContinue;
- }
-
- @Override
- public void doAction() throws Exception {
-
- CreateBenthosBatchUIModel model = getModel();
-
- List<Species> availableSpecies = Lists.newArrayList(model.getAvailableSpecies());
-
- if (!selectedSpecies.isReferenceTaxon()) {
- String decoratedSynonym = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL);
- List<Species> referents = referentSpecies;
- Map<String, Species> referentsById = TuttiEntities.splitByTaxonId(referents);
- String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId());
- selectedSpecies = referentsById.get(taxonId);
- String decoratedReferent = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL);
- sendMessage(_("tutti.flash.info.species.replaced", decoratedSynonym, decoratedReferent));
- }
-
- if (!availableSpecies.contains(selectedSpecies)) {
- availableSpecies.add(selectedSpecies);
- }
- model.setAvailableSpecies(availableSpecies);
- model.setSpecies(selectedSpecies);
-
- }
-
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -30,7 +30,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchTableModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchUI;
-import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
+import fr.ifremer.shared.application.swing.computable.ComputableData;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.shared.application.swing.table.ColumnIdentifier;
import jaxx.runtime.SwingUtil;
@@ -79,7 +79,7 @@
this.computedDataColor = computedDataColor;
}
- public void setComputedOrNotText(TuttiComputedOrNotData<Integer> data) {
+ public void setComputedOrNotText(ComputableData<Integer> data) {
String text;
if (data != null && data.getData() != null) {
@@ -303,7 +303,7 @@
if (log.isDebugEnabled()) {
log.debug("Set columnIdentifier (" + column + ") :: " + columnIdentifier.getPropertyName());
}
- TuttiComputedOrNotData<Integer> data = (TuttiComputedOrNotData<Integer>) value;
+ ComputableData<Integer> data = (ComputableData<Integer>) value;
component.setComputedOrNotText(data);
rowIndex = row;
@@ -357,7 +357,7 @@
int column) {
component.setForeground(Color.BLACK);
- TuttiComputedOrNotData<Integer> data = (TuttiComputedOrNotData<Integer>) value;
+ ComputableData<Integer> data = (ComputableData<Integer>) value;
BenthosFrequencyCellComponent result =
(BenthosFrequencyCellComponent) component.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -38,7 +38,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel;
-import fr.ifremer.tutti.ui.swing.util.Cancelable;
+import fr.ifremer.shared.application.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/split/SplitBenthosBatchUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -36,7 +36,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.benthos.BenthosBatchRowModel;
-import fr.ifremer.tutti.ui.swing.util.Cancelable;
+import fr.ifremer.shared.application.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/ExportMultiPostAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/ExportMultiPostAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/ExportMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,72 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation;
-
-/*
- * #%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.ui.swing.content.operation.catches.AbstractExportMultiPostAction;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.2
- */
-public class ExportMultiPostAction
- extends AbstractExportMultiPostAction<IndividualObservationBatchUIModel, IndividualObservationBatchUI, IndividualObservationBatchUIHandler> {
-
- public ExportMultiPostAction(IndividualObservationBatchUIHandler handler) {
- super(handler);
- }
-
- @Override
- protected String getFileExtension() {
- return "tuttiIndividualObservation";
- }
-
- @Override
- protected String getFileExtensionDescription() {
- return _("tutti.common.file.tuttiIndividualObservation");
- }
-
- @Override
- protected String getFileChooserTitle() {
- return _("tutti.editIndividualObservationBatch.action.exportMultiPost.destinationFile.title");
- }
-
- @Override
- protected String getFileChooserButton() {
- return _("tutti.editIndividualObservationBatch.action.exportMultiPost.destinationFile.button");
- }
-
- @Override
- public void doAction() throws Exception {
- multiPostImportExportService.exportIndividualObservation(file, currentOperation);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.editIndividualObservationBatch.action.exportMultiPost.success", file));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/ImportMultiPostAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/ImportMultiPostAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/ImportMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,74 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation;
-
-/*
- * #%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.content.operation.catches.AbstractImportMultiPostAction;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.2
- */
-public class ImportMultiPostAction
- extends AbstractImportMultiPostAction<IndividualObservationBatchUIModel, IndividualObservationBatchUI, IndividualObservationBatchUIHandler> {
-
- public ImportMultiPostAction(IndividualObservationBatchUIHandler handler) {
- super(handler);
- }
-
- @Override
- protected String getFileExtension() {
- return "tuttiIndividualObservation";
- }
-
- @Override
- protected String getFileExtensionDescription() {
- return _("tutti.common.file.tuttiIndividualObservation");
- }
-
- @Override
- protected String getFileChooserTitle() {
- return _("tutti.editIndividualObservationBatch.action.importMultiPost.sourceFile.title");
- }
-
- @Override
- protected String getFileChooserButton() {
- return _("tutti.editIndividualObservationBatch.action.importMultiPost.sourceFile.button");
- }
-
- @Override
- protected void importBatches(FishingOperation operation) {
- multiPostImportExportService.importIndividualObservation(file, operation);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- sendMessage(_("tutti.editIndividualObservationBatch.action.importMultiPost.success", file));
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -48,7 +48,7 @@
text: "tutti.editIndividualObservationBatch.action.importMultiPost";
toolTipText: "tutti.editIndividualObservationBatch.action.importMultiPost.tip";
i18nMnemonic: "tutti.editIndividualObservationBatch.action.importMultiPost.mnemonic";
- _applicationAction: {ImportMultiPostAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportIndividualObservationMultiPostAction.class};
_help: {"tutti.editIndividualObservationBatch.action.importMultiPost.help"};
}
@@ -57,7 +57,7 @@
text: "tutti.editIndividualObservationBatch.action.exportMultiPost";
toolTipText: "tutti.editIndividualObservationBatch.action.exportMultiPost.tip";
i18nMnemonic: "tutti.editIndividualObservationBatch.action.exportMultiPost.mnemonic";
- _applicationAction: {ExportMultiPostAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportIndividualObservationMultiPostAction.class};
_help: {"tutti.editIndividualObservationBatch.action.exportMultiPost.help"};
}
@@ -74,7 +74,7 @@
text: "tutti.editIndividualObservationBatch.action.removeBatch";
toolTipText: "tutti.editIndividualObservationBatch.action.removeBatch.tip";
i18nMnemonic: "tutti.editIndividualObservationBatch.action.removeBatch.mnemonic";
- _applicationAction: {RemoveIndividualObservationBatchAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.RemoveIndividualObservationBatchAction.class};
enabled: {model.isRemoveBatchEnabled()};
_help: {"tutti.editIndividualObservationBatch.action.removeBatch.help"};
}
@@ -84,7 +84,7 @@
text: "tutti.editIndividualObservationBatch.action.removeAllBatch";
toolTipText: "tutti.editIndividualObservationBatch.action.removeAllBatch.tip";
i18nMnemonic: "tutti.editIndividualObservationBatch.action.removeAllBatch.mnemonic";
- _applicationAction: {RemoveAllIndividualObservationBatchAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.RemoveAllIndividualObservationBatchAction.class};
enabled: {model.isRemoveBatchEnabled()};
_help: {"tutti.editIndividualObservationBatch.action.removeAllBatch.help"};
}
\ No newline at end of file
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIModel.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIModel.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -28,7 +28,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
-import fr.ifremer.tutti.ui.swing.util.TabContentModel;
+import fr.ifremer.shared.application.swing.tab.TabContentModel;
import org.apache.commons.collections.CollectionUtils;
import java.util.List;
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/RemoveAllIndividualObservationBatchAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/RemoveAllIndividualObservationBatchAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/RemoveAllIndividualObservationBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,153 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.TuttiPersistence;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.JXTable;
-
-import javax.swing.JOptionPane;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Created on 10/3/13.
- *
- * @author Tony Chemit <chemit(a)codelutin.com>
- * @since 2.7
- */
-public class RemoveAllIndividualObservationBatchAction
- extends AbstractTuttiAction<IndividualObservationBatchUIModel, IndividualObservationBatchUI, IndividualObservationBatchUIHandler> {
-
- private static final Log log =
- LogFactory.getLog(RemoveAllIndividualObservationBatchAction.class);
-
- public RemoveAllIndividualObservationBatchAction(IndividualObservationBatchUIHandler handler) {
- super(handler, false);
- }
-
- protected Species species;
-
- protected List<Integer> rowIndexToRemove;
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
-
- rowIndexToRemove = null;
- species = null;
-
- int rowIndex = -1;
-
- if (result) {
- JXTable table = handler.getTable();
-
- rowIndex = table.getSelectedRow();
-
- Preconditions.checkState(rowIndex != -1,
- "Cant remove batch if none is selected");
- }
-
- if (result) {
-
- IndividualObservationBatchTableModel tableModel = handler.getTableModel();
-
- IndividualObservationBatchRowModel entry = tableModel.getEntry(rowIndex);
-
- species = entry.getSpecies();
-
- rowIndexToRemove = Lists.newArrayList();
-
- for (IndividualObservationBatchRowModel rowModel : tableModel.getRows()) {
- if (species.equals(rowModel.getSpecies())) {
- rowIndexToRemove.add(0, tableModel.getRowIndex(rowModel));
- }
- }
-
- int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- _("tutti.editIndividualObservationBatch.action.removeAllBatch.confirm.message", rowIndexToRemove.size(), decorate(species)),
- _("tutti.editIndividualObservationBatch.action.removeAllBatch.confirm.title"),
- JOptionPane.YES_NO_OPTION);
- result = answer == JOptionPane.YES_OPTION;
- }
-
- return result;
- }
-
- @Override
- public void doAction() throws Exception {
-
- Preconditions.checkNotNull(rowIndexToRemove);
- Preconditions.checkNotNull(species);
-
- IndividualObservationBatchTableModel tableModel = handler.getTableModel();
-
- for (Integer rowIndex : rowIndexToRemove) {
- IndividualObservationBatchRowModel selectedBatch = tableModel.getEntry(rowIndex);
-
- boolean persisted = !TuttiEntities.isNew(selectedBatch);
-
- if (persisted) {
-
- // remove it from db
-
- String id = selectedBatch.getId();
-
- if (log.isInfoEnabled()) {
- log.info("Remove individual observation with id: " + id);
- }
-
- TuttiPersistence persistenceService =
- getContext().getPersistenceService();
-
- persistenceService.deleteIndividualObservationBatch(id);
- }
- }
-
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- JXTable table = handler.getTable();
-
- IndividualObservationBatchTableModel tableModel = handler.getTableModel();
-
- for (Integer rowIndex : rowIndexToRemove) {
- tableModel.removeRow(rowIndex);
- }
-
- TuttiUIUtil.selectFirstCellOnFirstRowAndStopEditing(table);
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/RemoveIndividualObservationBatchAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/RemoveIndividualObservationBatchAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/RemoveIndividualObservationBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,113 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation;
-
-/*
- * #%L
- * Tutti :: UI
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.TuttiPersistence;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.JXTable;
-
-import javax.swing.JOptionPane;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.4
- */
-public class RemoveIndividualObservationBatchAction
- extends AbstractTuttiAction<IndividualObservationBatchUIModel, IndividualObservationBatchUI, IndividualObservationBatchUIHandler> {
-
- private static final Log log =
- LogFactory.getLog(RemoveIndividualObservationBatchAction.class);
-
- public RemoveIndividualObservationBatchAction(IndividualObservationBatchUIHandler handler) {
- super(handler, false);
- }
-
- int rowIndex;
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
-
- if (result) {
- int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- _("tutti.editIndividualObservationBatch.action.removeBatch.confirm.message"),
- _("tutti.editIndividualObservationBatch.action.removeBatch.confirm.title"),
- JOptionPane.YES_NO_OPTION);
- result = answer == JOptionPane.YES_OPTION;
- }
-
- return result;
- }
-
- @Override
- public void doAction() throws Exception {
-
- JXTable table = handler.getTable();
-
- rowIndex = table.getSelectedRow();
-
- Preconditions.checkState(rowIndex != -1,
- "Cant remove batch if none is selected");
-
- IndividualObservationBatchTableModel tableModel = handler.getTableModel();
- IndividualObservationBatchRowModel selectedBatch = tableModel.getEntry(rowIndex);
-
- boolean persisted = !TuttiEntities.isNew(selectedBatch);
-
- if (persisted) {
-
- // remove it from db
-
- String id = selectedBatch.getId();
-
- if (log.isInfoEnabled()) {
- log.info("Remove individual observation with id: " + id);
- }
-
- TuttiPersistence persistenceService =
- getContext().getPersistenceService();
-
- persistenceService.deleteIndividualObservationBatch(id);
- }
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- JXTable table = handler.getTable();
-
- IndividualObservationBatchTableModel tableModel = handler.getTableModel();
-
- tableModel.removeRow(rowIndex);
-
- TuttiUIUtil.selectFirstCellOnFirstRowAndStopEditing(table);
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -98,7 +98,7 @@
text: "tutti.createIndividualObservationBatch.action.addSpecies";
toolTipText: "tutti.createIndividualObservationBatch.action.addSpecies.tip";
i18nMnemonic: "tutti.createIndividualObservationBatch.action.addSpecies.mnemonic";
- _applicationAction: {SelectSpeciesForIndividualObservationBatchAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SelectSpeciesForIndividualObservationBatchAction.class};
_help: {"tutti.createIndividualObservationBatch.action.addSpecies.help"};
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/CreateIndividualObservationBatchUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -40,7 +40,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
-import fr.ifremer.tutti.ui.swing.util.Cancelable;
+import fr.ifremer.shared.application.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUI;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUIModel;
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/SelectSpeciesForIndividualObservationBatchAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/SelectSpeciesForIndividualObservationBatchAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/create/SelectSpeciesForIndividualObservationBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,103 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.create;
-
-/*
- * #%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.referential.Species;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Enable to select a species to the species selected in the protocol.
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.0
- */
-public class SelectSpeciesForIndividualObservationBatchAction extends AbstractTuttiAction<CreateIndividualObservationBatchUIModel,
- CreateIndividualObservationBatchUI,
- CreateIndividualObservationBatchUIHandler> {
-
- protected List<Species> allSpecies;
-
- protected List<Species> referentSpecies;
-
- protected Species selectedSpecies;
-
- public SelectSpeciesForIndividualObservationBatchAction(CreateIndividualObservationBatchUIHandler handler) {
- super(handler, false);
-
- allSpecies = getDataContext().getSpecies();
- referentSpecies = getDataContext().getReferentSpecies();
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean canContinue = super.prepareAction();
- if (canContinue) {
-
- CreateIndividualObservationBatchUIModel model = getModel();
-
- List<Species> species = Lists.newArrayList(allSpecies);
- species.removeAll(model.getAvailableSpecies());
-
- selectedSpecies = getHandler().openAddSpeciesDialog(
- _("tutti.selectSpecies.title"), species);
- canContinue = selectedSpecies != null;
- }
- return canContinue;
- }
-
- @Override
- public void doAction() throws Exception {
-
- CreateIndividualObservationBatchUIModel model = getModel();
-
- List<Species> availableSpecies = Lists.newArrayList(model.getAvailableSpecies());
-
- if (!selectedSpecies.isReferenceTaxon()) {
- String decoratedSynonym = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL);
- List<Species> referents = referentSpecies;
- Map<String, Species> referentsById = TuttiEntities.splitByTaxonId(referents);
- String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId());
- selectedSpecies = referentsById.get(taxonId);
- String decoratedReferent = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL);
- sendMessage(_("tutti.flash.info.species.replaced", decoratedSynonym, decoratedReferent));
- }
-
- if (!availableSpecies.contains(selectedSpecies)) {
- availableSpecies.add(selectedSpecies);
- }
- model.setAvailableSpecies(availableSpecies);
- model.setSpecies(selectedSpecies);
-
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/ExportMultiPostAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/ExportMultiPostAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/ExportMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,71 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter;
-
-/*
- * #%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.ui.swing.content.operation.catches.AbstractExportMultiPostAction;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.2
- */
-public class ExportMultiPostAction extends AbstractExportMultiPostAction<MarineLitterBatchUIModel, MarineLitterBatchUI, MarineLitterBatchUIHandler> {
-
- public ExportMultiPostAction(MarineLitterBatchUIHandler handler) {
- super(handler);
- }
-
- @Override
- protected String getFileExtension() {
- return "tuttiMarineLitter";
- }
-
- @Override
- protected String getFileExtensionDescription() {
- return _("tutti.common.file.tuttiMarineLitter");
- }
-
- @Override
- protected String getFileChooserTitle() {
- return _("tutti.editMarineLitterBatch.action.exportMultiPost.destinationFile.title");
- }
-
- @Override
- protected String getFileChooserButton() {
- return _("tutti.editMarineLitterBatch.action.exportMultiPost.destinationFile.button");
- }
-
- @Override
- public void doAction() throws Exception {
- multiPostImportExportService.exportMarineLitter(file, currentOperation);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.editMarineLitterBatch.action.exportMultiPost.success", file));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/ImportMultiPostAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/ImportMultiPostAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/ImportMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,115 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter;
-
-/*
- * #%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.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
-import fr.ifremer.tutti.service.catches.multipost.MultiPostImportService;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.AbstractImportMultiPostAction;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.MultiPostImportLogDialog;
-
-import javax.swing.JTextArea;
-import java.awt.Dialog;
-import java.util.Collection;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.2
- */
-public class ImportMultiPostAction extends AbstractImportMultiPostAction<MarineLitterBatchUIModel, MarineLitterBatchUI, MarineLitterBatchUIHandler> {
-
- protected Map<String, Object> notImportedData;
-
- public ImportMultiPostAction(MarineLitterBatchUIHandler handler) {
- super(handler);
- }
-
- @Override
- protected String getFileExtension() {
- return "tuttiMarineLitter";
- }
-
- @Override
- protected String getFileExtensionDescription() {
- return _("tutti.common.file.tuttiMarineLitter");
- }
-
- @Override
- protected String getFileChooserTitle() {
- return _("tutti.editMarineLitterBatch.action.importMultiPost.sourceFile.title");
- }
-
- @Override
- protected String getFileChooserButton() {
- return _("tutti.editMarineLitterBatch.action.importMultiPost.sourceFile.button");
- }
-
- @Override
- public void releaseAction() {
- notImportedData = null;
- super.releaseAction();
- }
-
- @Override
- protected void importBatches(FishingOperation operation) {
- notImportedData = multiPostImportExportService.importMarineLitter(file, operation);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- if (!notImportedData.isEmpty()) {
- MultiPostImportLogDialog dialog = new MultiPostImportLogDialog((Dialog) getContext().getActionUI());
-
- Collection<MarineLitterBatch> notImportedMarineLitterBatches =
- (Collection<MarineLitterBatch>) notImportedData.get(MultiPostImportService.BATCHES_KEY);
-
- StringBuffer stringBuffer = new StringBuffer();
- Float totalWeight = (Float) notImportedData.get(CatchBatch.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT);
- if (totalWeight != null) {
- stringBuffer.append("- " + _("tutti.multiPostImportLog.totalWeight", totalWeight) + "\n");
- }
-
- for (MarineLitterBatch mlb : notImportedMarineLitterBatches) {
- stringBuffer.append("- " + decorate(mlb.getMarineLitterCategory()) + " / " + decorate(mlb.getMarineLitterSizeCategory()) + "\n");
- }
-
- if (stringBuffer.length() > 0) {
- JTextArea batchList = dialog.getBatchList();
- batchList.setText(stringBuffer.toString());
- dialog.setSize(400, 300);
- dialog.setLocationRelativeTo(getContext().getMainUI());
- dialog.setVisible(true);
- }
- }
-
- sendMessage(_("tutti.editMarineLitterBatch.action.importMultiPost.success", file));
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -22,7 +22,7 @@
* #L%
*/
-TuttiComputedOrNotDataEditor {
+ComputableDataEditor {
autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
showReset: true;
@@ -71,7 +71,7 @@
text: "tutti.editMarineLitterBatch.action.importMultiPost";
toolTipText: "tutti.editMarineLitterBatch.action.importMultiPost.tip";
i18nMnemonic: "tutti.editMarineLitterBatch.action.importMultiPost.mnemonic";
- _applicationAction: {ImportMultiPostAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportMarineLitterMultiPostAction.class};
_help: {"tutti.editMarineLitterBatch.action.importMultiPost.help"};
}
@@ -80,7 +80,7 @@
text: "tutti.editMarineLitterBatch.action.exportMultiPost";
toolTipText: "tutti.editMarineLitterBatch.action.exportMultiPost.tip";
i18nMnemonic: "tutti.editMarineLitterBatch.action.exportMultiPost.mnemonic";
- _applicationAction: {ExportMultiPostAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportMarineLitterMultiPostAction.class};
_help: {"tutti.editMarineLitterBatch.action.exportMultiPost.help"};
}
@@ -98,7 +98,7 @@
text: "tutti.editMarineLitterBatch.action.removeBatch";
toolTipText: "tutti.editMarineLitterBatch.action.removeBatch.tip";
i18nMnemonic: "tutti.editMarineLitterBatch.action.removeBatch.mnemonic";
- _applicationAction: {RemoveMarineLitterBatchAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.RemoveMarineLitterBatchAction.class};
enabled: {model.isRemoveBatchEnabled()};
_help: {"tutti.editMarineLitterBatch.action.removeBatch.help"};
}
\ No newline at end of file
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUI.jaxx 2013-11-26 08:03:42 UTC (rev 1388)
@@ -29,7 +29,7 @@
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.util.TuttiUI
- fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor
+ fr.ifremer.shared.application.swing.computable.ComputableDataEditor
org.jdesktop.swingx.JXTable
@@ -85,8 +85,8 @@
<JLabel id='marineLitterTotalWeightLabel'/>
</cell>
<cell weightx='1.0'>
- <TuttiComputedOrNotDataEditor id='marineLitterTotalWeightField'
- constructorParams='this'/>
+ <ComputableDataEditor id='marineLitterTotalWeightField'
+ genericType="Float" constructorParams='this'/>
</cell>
</row>
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -26,7 +26,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
-import fr.ifremer.tutti.PropagatePropertyChangeListener;
+import fr.ifremer.shared.application.listener.PropagatePropertyChangeListener;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -28,8 +28,8 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
-import fr.ifremer.tutti.ui.swing.util.TabContentModel;
-import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
+import fr.ifremer.shared.application.swing.tab.TabContentModel;
+import fr.ifremer.shared.application.swing.computable.ComputableData;
import org.apache.commons.collections.CollectionUtils;
import static org.nuiton.i18n.I18n.n_;
@@ -58,7 +58,7 @@
EditCatchesUIModel.PROPERTY_BATCH_UPDATED);
}
- public TuttiComputedOrNotData<Float> getMarineLitterTotalComputedOrNotWeight() {
+ public ComputableData<Float> getMarineLitterTotalComputedOrNotWeight() {
return catchesUIModel.getMarineLitterTotalComputedOrNotWeight();
}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/RemoveMarineLitterBatchAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/RemoveMarineLitterBatchAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/RemoveMarineLitterBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,123 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.TuttiPersistence;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.RemoveSpeciesSubBatchAction;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.JXTable;
-
-import javax.swing.JOptionPane;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To remove a selected marine litter batch in the table.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.3
- */
-public class RemoveMarineLitterBatchAction extends AbstractTuttiAction<MarineLitterBatchUIModel, MarineLitterBatchUI, MarineLitterBatchUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(RemoveMarineLitterBatchAction.class);
-
- protected RemoveSpeciesSubBatchAction removeSpeciesSubBatchAction;
-
- public RemoveMarineLitterBatchAction(MarineLitterBatchUIHandler handler) {
- super(handler, false);
- }
-
- int rowIndex;
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
-
- if (result) {
- int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- _("tutti.editMarineLitterBatch.action.removeBatch.confirm.message"),
- _("tutti.editMarineLitterBatch.action.removeBatch.confirm.title"),
- JOptionPane.YES_NO_OPTION);
- result = answer == JOptionPane.YES_OPTION;
- }
-
- return result;
- }
-
- @Override
- public void doAction() throws Exception {
-
- JXTable table = handler.getTable();
-
- rowIndex = table.getSelectedRow();
-
- Preconditions.checkState(rowIndex != -1,
- "Cant remove batch if none is selected");
-
- MarineLitterBatchTableModel tableModel = handler.getTableModel();
- MarineLitterBatchRowModel selectedBatch = tableModel.getEntry(rowIndex);
-
- boolean persisted = !TuttiEntities.isNew(selectedBatch);
-
- if (persisted) {
-
- // remove it from db
-
- String id = selectedBatch.getId();
-
- if (log.isInfoEnabled()) {
- log.info("Remove marineLitter with id: " + id);
- }
-
- TuttiPersistence persistenceService =
- getContext().getPersistenceService();
-
- persistenceService.deleteMarineLitterBatch(id);
- }
-
- // update speciesUsed
- handler.removeFromMarineLitterCategoriesUsed(selectedBatch);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- JXTable table = handler.getTable();
-
- MarineLitterBatchTableModel tableModel = handler.getTableModel();
-
- tableModel.removeRow(rowIndex);
-
- TuttiUIUtil.selectFirstCellOnFirstRowAndStopEditing(table);
- }
-}
\ No newline at end of file
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/create/CreateMarineLitterBatchUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -35,7 +35,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchUIModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
-import fr.ifremer.tutti.ui.swing.util.Cancelable;
+import fr.ifremer.shared.application.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUI;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUIModel;
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/CreateSpeciesMelagAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,199 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
-
-/*
- * #%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.Maps;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
-import fr.ifremer.shared.application.type.WeightUnit;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import fr.ifremer.tutti.ui.swing.util.species.EnterMelagWeightDialog;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.lang3.StringUtils;
-
-import javax.swing.JOptionPane;
-import java.awt.Frame;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.0.2
- */
-public class CreateSpeciesMelagAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> {
-
- protected Map<SpeciesBatchRowModel, Float> selectedRows = Maps.newHashMap();
-
- protected Float melagWeight = null;
-
- protected Float sampleMelagWeight = null;
-
- protected Float sortedWeight = null;
-
- /**
- * Weight unit.
- *
- * @since 2.5
- */
- protected final WeightUnit weightUnit;
-
- public CreateSpeciesMelagAction(SpeciesBatchUIHandler handler) {
- super(handler, false);
- weightUnit = getConfig().getSpeciesWeightUnit();
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
-
- int[] selectedRowIndexes = SwingUtil.getSelectedModelRows(handler.getTable());
-
- SpeciesBatchTableModel tableModel = handler.getTableModel();
-
- // sum of the weights already entered by the user
- Float alreadyKnownWeights = 0f;
- sortedWeight = 0f;
-
- for (int selectedRowIndex : selectedRowIndexes) {
- SpeciesBatchRowModel selectedRow =
- tableModel.getEntry(selectedRowIndex);
-
- Float sampleWeight = null;
- if (selectedRow.getFinestCategory().getNotNullWeight() != null) {
- alreadyKnownWeights += selectedRow.getFinestCategory().getNotNullWeight();
-
- } else if (selectedRow.getWeight() != null) {
- sampleWeight = selectedRow.getWeight();
-
- } else {
- sampleWeight = 0f;
- if (selectedRow.getFrequency() != null) {
- for (SpeciesFrequencyRowModel frequency : selectedRow.getFrequency()) {
- if (frequency.getWeight() == null) {
- sampleWeight = 0f;
- break;
- }
- sampleWeight += frequency.getWeight();
- }
- }
- }
-
- if (sampleWeight != null) {
- if (sampleWeight == 0f) {
- JOptionPane.showMessageDialog(
- getUI(),
- _("tutti.createSpeciesMelag.error.message", selectedRowIndex + 1),
- _("tutti.createSpeciesMelag.error.title"),
- JOptionPane.ERROR_MESSAGE);
-
- SwingUtil.setSelectionInterval(handler.getTable(), selectedRowIndex);
- result = false;
- break;
-
- } else {
- sortedWeight += sampleWeight;
- }
- }
-
- selectedRows.put(selectedRow, sampleWeight);
- }
-
- if (result) {
- melagWeight = openMelagWeightDialog();
-
- if (melagWeight != null) {
- // substract the weights that the user already entered
- // they must not be used to compute the other weights
- sampleMelagWeight = melagWeight - alreadyKnownWeights;
- }
- }
-
- return result && melagWeight != null;
- }
-
- protected Float openMelagWeightDialog() {
- Frame frame = SwingUtil.getParentContainer(getUI(), Frame.class);
-
- EnterMelagWeightDialog dialog = new EnterMelagWeightDialog(
- frame, getConfig().getShortcutClosePopup());
-
- dialog.setWeightUnit(weightUnit);
-
- SwingUtil.center(frame, dialog);
- dialog.pack();
- dialog.setVisible(true);
-
- Float result = null;
- if (dialog.getEditor().getModel() != null) {
- result = dialog.getEditor().getModel().floatValue();
- }
- return result;
- }
-
- @Override
- public void doAction() throws Exception {
- String unitLabel = weightUnit.getShortLabel();
- String melagComment = _("tutti.createSpeciesMelag.comment.part1")+"\n";
- for (SpeciesBatchRowModel batch : selectedRows.keySet()) {
- Float sampleWeight = selectedRows.get(batch);
- if (sampleWeight != null) {
- Float weight = sampleMelagWeight * sampleWeight / sortedWeight;
- batch.getFinestCategory().setCategoryWeight(weight);
- }
- melagComment += _("tutti.createSpeciesMelag.comment.part2", sampleWeight, unitLabel, decorate(batch.getSpecies()))+"\n";
- }
- melagComment += _("tutti.createSpeciesMelag.comment.part3", melagWeight, unitLabel);
-
- for (SpeciesBatchRowModel batch : selectedRows.keySet()) {
- String comment = batch.getComment();
- if (StringUtils.isBlank(comment)) {
- comment = "";
-
- } else {
- comment += "\n";
- }
- comment += melagComment;
- batch.setComment(comment);
- }
- getHandler().saveRows(selectedRows.keySet());
- }
-
- @Override
- public void releaseAction() {
- super.releaseAction();
- //FIXME-TC No release action is not design to refresh ui...
-// getHandler().getTable().repaint();
- selectedRows.clear();
- melagWeight = null;
- sortedWeight = null;
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- getHandler().getTable().repaint();
-
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ExportMultiPostAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ExportMultiPostAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ExportMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,71 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
-
-/*
- * #%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.ui.swing.content.operation.catches.AbstractExportMultiPostAction;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.2
- */
-public class ExportMultiPostAction extends AbstractExportMultiPostAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> {
-
- public ExportMultiPostAction(SpeciesBatchUIHandler handler) {
- super(handler);
- }
-
- @Override
- protected String getFileExtension() {
- return "tuttiSpecies";
- }
-
- @Override
- protected String getFileExtensionDescription() {
- return _("tutti.common.file.tuttiSpecies");
- }
-
- @Override
- protected String getFileChooserTitle() {
- return _("tutti.editSpeciesBatch.action.exportMultiPost.destinationFile.title");
- }
-
- @Override
- protected String getFileChooserButton() {
- return _("tutti.editSpeciesBatch.action.exportMultiPost.destinationFile.button");
- }
-
- @Override
- public void doAction() throws Exception {
- multiPostImportExportService.exportSpecies(file, currentOperation);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.editSpeciesBatch.action.exportMultiPost.success", file));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportMultiPostAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportMultiPostAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportMultiPostAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,126 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
-
-/*
- * #%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.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.service.catches.multipost.MultiPostImportService;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.AbstractImportMultiPostAction;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.MultiPostImportLogDialog;
-
-import javax.swing.JTextArea;
-import java.awt.Dialog;
-import java.util.Collection;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 2.2
- */
-public class ImportMultiPostAction extends AbstractImportMultiPostAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> {
-
- protected Map<String, Object> notImportedData;
-
- public ImportMultiPostAction(SpeciesBatchUIHandler handler) {
- super(handler);
- }
-
- @Override
- protected String getFileExtension() {
- return "tuttiSpecies";
- }
-
- @Override
- protected String getFileExtensionDescription() {
- return _("tutti.common.file.tuttiSpecies");
- }
-
- @Override
- protected String getFileChooserTitle() {
- return _("tutti.editSpeciesBatch.action.importMultiPost.sourceFile.title");
- }
-
- @Override
- protected String getFileChooserButton() {
- return _("tutti.editSpeciesBatch.action.importMultiPost.sourceFile.button");
- }
-
- @Override
- public void releaseAction() {
- notImportedData = null;
- super.releaseAction();
- }
-
- @Override
- protected void importBatches(FishingOperation operation) {
- notImportedData = multiPostImportExportService.importSpecies(file, operation);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- if (!notImportedData.isEmpty()) {
- MultiPostImportLogDialog dialog = new MultiPostImportLogDialog((Dialog) getContext().getActionUI());
-
- Collection<SpeciesBatch> notImportedSpeciesBatches =
- (Collection<SpeciesBatch>) notImportedData.get(MultiPostImportService.BATCHES_KEY);
-
- StringBuffer stringBuffer = new StringBuffer();
- Float totalSortedWeight = (Float) notImportedData.get(CatchBatch.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT);
- if (totalSortedWeight != null) {
- stringBuffer.append("- " + _("tutti.multiPostImportLog.totalSortedWeight", totalSortedWeight) + "\n");
- }
-
- Float inertWeight = (Float) notImportedData.get(CatchBatch.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT);
- if (inertWeight != null) {
- stringBuffer.append("- " + _("tutti.multiPostImportLog.inertWeight", inertWeight) + "\n");
- }
-
- Float livingNotItemizedWeight =
- (Float) notImportedData.get(CatchBatch.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT);
- if (livingNotItemizedWeight != null) {
- stringBuffer.append("- " + _("tutti.multiPostImportLog.livingNotItemizedWeight", livingNotItemizedWeight) + "\n");
- }
-
- for (SpeciesBatch sb : notImportedSpeciesBatches) {
- stringBuffer.append("- " + decorate(sb.getSpecies()) + " / " + decorate(sb.getSampleCategoryValue()) + "\n");
- }
-
- if (stringBuffer.length() > 0) {
- JTextArea batchList = dialog.getBatchList();
- batchList.setText(stringBuffer.toString());
- dialog.setSize(400, 300);
- dialog.setLocationRelativeTo(getContext().getMainUI());
- dialog.setVisible(true);
- }
- }
-
- sendMessage(_("tutti.editSpeciesBatch.action.importMultiPost.success", file));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportPupitriAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportPupitriAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportPupitriAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,168 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
-import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.pupitri.PupitriImportExportService;
-import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationAction;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-
-import javax.swing.JOptionPane;
-import javax.swing.UIManager;
-import java.io.File;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ImportPupitriAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> {
-
- protected File importedTrunkFile;
-
- protected File importedCarrouselFile;
-
- protected ImportPupitriPopupUI importPupitriDialog;
-
-// protected TuttiProtocol currentProtocol;
-
- protected PersistenceService persistenceService;
-
- protected EditFishingOperationAction editAction;
-
- public ImportPupitriAction(SpeciesBatchUIHandler handler) {
- super(handler, false);
- persistenceService = getContext().getPersistenceService();
- importPupitriDialog = new ImportPupitriPopupUI(handler.getContext());
- }
-
- public EditFishingOperationAction getEditAction() {
- if (editAction == null) {
- editAction = getContext().getActionFactory().createLogicAction(getHandler().getParentUi().getHandler().getParentHandler(),
- EditFishingOperationAction.class);
- }
- return editAction;
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = true;
-
- // must check that sample category model is compatible for pupitri import
- // means need some categories
-
- TuttiEnumerationFile enumerationFile = persistenceService.getEnumerationFile();
- SampleCategoryModel sampleCategoryModel = getDataContext().getSampleCategoryModel();
-
- List<String> missingCategories = Lists.newArrayList();
- if (!sampleCategoryModel.containsCategoryId(enumerationFile.PMFM_ID_SIZE_CATEGORY)) {
- missingCategories.add("<li>" + persistenceService.getSizeCategoryCaracteristic().getParameterName() + "</li>");
- }
- if (!sampleCategoryModel.containsCategoryId(enumerationFile.PMFM_ID_SEX)) {
- missingCategories.add("<li>" + persistenceService.getSexCaracteristic().getParameterName() + "</li>");
- }
- if (!missingCategories.isEmpty()) {
- result = false;
- JOptionPane.showMessageDialog(
- getContext().getActionUI(),
- _("tutti.editSpeciesBatch.action.importPupitri.invalidSampleCategoryModel.message", Joiner.on("").join(missingCategories)),
- _("tutti.editSpeciesBatch.action.importPupitri.invalidSampleCategoryModel.title"),
- JOptionPane.ERROR_MESSAGE,
- UIManager.getIcon("error")
- );
- }
- if (result) {
-// currentProtocol = getDataContext().getProtocol();
-
- SpeciesBatchUIModel speciesBatchUIModel = getUI().getModel();
- if (speciesBatchUIModel.getRowCount() > 0) {
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- _("tutti.editSpeciesBatch.action.importPupitri.existingData.message"),
- _("tutti.editSpeciesBatch.action.importPupitri.existingData.help"));
-
- int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- htmlMessage,
- _("tutti.editSpeciesBatch.action.importPupitri.existingData.title"),
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.WARNING_MESSAGE);
-
- result = answer == JOptionPane.OK_OPTION;
- }
- }
-
- if (result) {
- importPupitriDialog.open();
- importedTrunkFile = importPupitriDialog.getTrunkFile().getSelectedFile();
- importedCarrouselFile = importPupitriDialog.getCarrouselFile().getSelectedFile();
- result = importedTrunkFile != null
- && importedCarrouselFile != null;
- }
-
- return result;
- }
-
- @Override
- public void doAction() throws Exception {
- PupitriImportExportService pupitriImportExportService =
- getContext().getTuttiPupitriImportExportService();
-
- EditCatchesUIModel model = getUI().getHandler().getParentUi().getModel();
-
- FishingOperation operation = model.getFishingOperation();
- CatchBatch catchBatch = model.toEntity();
-
- // import
- int rejectedSpeciesNb =
- pupitriImportExportService.importPupitri(importedTrunkFile,
- importedCarrouselFile,
- operation,
- catchBatch);
-
- getEditAction().loadCatchBatch(operation);
-
- sendMessage(_("tutti.editSpeciesBatch.action.importPupitri.success",
- getModel().getRootNumber(), rejectedSpeciesNb));
- }
-
- @Override
- public void releaseAction() {
- super.releaseAction();
- importedTrunkFile = null;
- importedCarrouselFile = null;
-// currentProtocol = null;
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,132 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
-import fr.ifremer.tutti.persistence.TuttiPersistence;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import jaxx.runtime.SwingUtil;
-import org.jdesktop.swingx.JXTable;
-
-import javax.swing.JOptionPane;
-import java.util.Set;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To remove a species batch and all his children.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class RemoveSpeciesBatchAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> {
-
- /**
- * Rows to delete after all.
- *
- * @since 3.0-rc-1
- */
- protected Set<SpeciesBatchRowModel> rowToRemove;
-
- public RemoveSpeciesBatchAction(SpeciesBatchUIHandler handler) {
- super(handler, false);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
-
- if (result) {
- int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- _("tutti.editSpeciesBatch.action.removeBatch.confirm.message"),
- _("tutti.editSpeciesBatch.action.removeBatch.confirm.title"),
- JOptionPane.YES_NO_OPTION);
- result = answer == JOptionPane.YES_OPTION;
- }
-
- return result;
- }
-
- @Override
- public void doAction() throws Exception {
-
- TuttiPersistence persistenceService =
- getContext().getPersistenceService();
-
- JXTable table = handler.getTable();
-
- int rowIndex = SwingUtil.getSelectedModelRow(table);
-
- Preconditions.checkState(rowIndex != -1,
- "Cant remove batch if no batch selected");
-
- SpeciesBatchTableModel tableModel = handler.getTableModel();
-
- SpeciesBatchRowModel selectedBatch = tableModel.getEntry(rowIndex);
-
- Preconditions.checkState(!TuttiEntities.isNew(selectedBatch),
- "Can't remove batch if batch is not persisted");
-
- // remove selected batch and all his children
-
- // remove parent batch (will destroy all his childs from db)
- persistenceService.deleteSpeciesBatch(selectedBatch.getId());
-
- if (selectedBatch.isBatchRoot()) {
- // update speciesUsed
- handler.removeFromSpeciesUsed(selectedBatch);
- } else {
-
- // remove from his parent
- SpeciesBatchRowModel parentBatch = selectedBatch.getParentBatch();
- parentBatch.getChildBatch().remove(selectedBatch);
- }
-
- // collect of rows to remove from model
- rowToRemove = Sets.newHashSet();
- rowToRemove.add(selectedBatch);
-
- handler.collectChildren(selectedBatch, rowToRemove);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- JXTable table = handler.getTable();
-
- // remove all rows from the model
- getModel().getRows().removeAll(rowToRemove);
-
- // refresh table from parent batch row index to the end
- handler.getTableModel().fireTableDataChanged();
-
- // select parent batch row
- TuttiUIUtil.selectFirstCellOnFirstRowAndStopEditing(table);
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RemoveSpeciesSubBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,138 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
-import fr.ifremer.tutti.persistence.TuttiPersistence;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import jaxx.runtime.SwingUtil;
-import org.jdesktop.swingx.JXTable;
-
-import javax.swing.JOptionPane;
-import java.util.Set;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To remove a species batch children.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class RemoveSpeciesSubBatchAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> {
-
- /**
- * Selected row to treat.
- *
- * @since 2.8
- */
- protected int rowIndex;
-
- /**
- * Rows to delete after all.
- *
- * @since 3.0-rc-1
- */
- protected Set<SpeciesBatchRowModel> rowToRemove;
-
- /**
- * Parent batch of rows to delete.
- *
- * @since 3.0-rc-1
- */
- protected SpeciesBatchRowModel parentBatch;
-
- public RemoveSpeciesSubBatchAction(SpeciesBatchUIHandler handler) {
- super(handler, false);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
-
- rowIndex = -1;
-
- if (result) {
- int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- _("tutti.editSpeciesBatch.action.removeSubBatch.confirm.message"),
- _("tutti.editSpeciesBatch.action.removeSubBatch.confirm.title"),
- JOptionPane.YES_NO_OPTION);
- result = answer == JOptionPane.YES_OPTION;
- }
-
- return result;
- }
-
- @Override
- public void doAction() throws Exception {
-
- TuttiPersistence persistenceService =
- getContext().getPersistenceService();
-
- JXTable table = handler.getTable();
-
- rowIndex = SwingUtil.getSelectedModelRow(table);
-
- Preconditions.checkState(rowIndex != -1,
- "Cant remove sub batch if no batch selected");
-
-
- parentBatch = handler.getTableModel().getEntry(rowIndex);
-
- Preconditions.checkState(!TuttiEntities.isNew(parentBatch),
- "Can't remove sub batch if batch is not persisted");
-
- // save parent batch (will destroy all his childs from db)
- persistenceService.deleteSpeciesSubBatch(parentBatch.getId());
-
- // collect of rows to remove from model
-
- rowToRemove = Sets.newHashSet();
-
- handler.collectChildren(parentBatch, rowToRemove);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- JXTable table = handler.getTable();
-
- // remove all rows from the model
- getModel().getRows().removeAll(rowToRemove);
-
- // remove childs from parent batch
- parentBatch.setChildBatch(null);
-
- // refresh table from parent batch row index to the end
- handler.getTableModel().fireTableDataChanged();
-
- // select parent batch row
- TuttiUIUtil.selectFirstCellOnRow(table, rowIndex, true);
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,120 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
-
-/*
- * #%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.data.SampleCategory;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import jaxx.runtime.SwingUtil;
-import org.jdesktop.swingx.JXTable;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To rename the species for a species batch and all his children.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class RenameSpeciesBatchAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> {
-
- protected Species selectedSpecies;
-
- public RenameSpeciesBatchAction(SpeciesBatchUIHandler handler) {
- super(handler, false);
-
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
-
- SpeciesBatchTableModel tableModel = handler.getTableModel();
- JXTable table = handler.getTable();
- int selectedRowIndex = SwingUtil.getSelectedModelRow(table);
- SpeciesBatchRowModel row = tableModel.getEntry(selectedRowIndex);
-
- SpeciesBatchUIModel model = handler.getModel();
- List<Species> speciesList = Lists.newArrayList(
- getDataContext().getReferentSpeciesWithSurveyCode());
- SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
- Serializable categoryValue = firstSampleCategory.getCategoryValue();
- speciesList.removeAll(
- model.getSpeciesUsed().get((CaracteristicQualitativeValue) categoryValue));
-
- selectedSpecies = getHandler().openAddSpeciesDialog(
- _("tutti.selectSpecies.title"),
- speciesList
- );
-
- result &= selectedSpecies != null;
- return result;
- }
-
- @Override
- public void releaseAction() {
- selectedSpecies = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
-
- SpeciesBatchTableModel tableModel = handler.getTableModel();
- JXTable table = handler.getTable();
- int selectedRowIndex = SwingUtil.getSelectedModelRow(table);
- SpeciesBatchRowModel row = tableModel.getEntry(selectedRowIndex);
-
- PersistenceService persistenceService = getContext().getPersistenceService();
- persistenceService.changeSpeciesBatchSpecies(row.getId(), selectedSpecies);
-
- SampleCategory<?> firstSampleCategory = row.getFirstSampleCategory();
- Serializable categoryValue = firstSampleCategory.getCategoryValue();
-
- Collection<Species> speciesUsed = getModel().getSpeciesUsed()
- .get((CaracteristicQualitativeValue) categoryValue);
- speciesUsed.remove(row.getSpecies());
- changeChildrenSpecies(row, selectedSpecies);
- speciesUsed.add(selectedSpecies);
- }
-
- protected void changeChildrenSpecies(SpeciesBatchRowModel row,
- Species species) {
- row.setSpecies(species);
- List<SpeciesBatchRowModel> children = row.getChildBatch();
- if (children != null) {
- for (SpeciesBatchRowModel child : children) {
- changeChildrenSpecies(child, species);
- }
- }
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -41,7 +41,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.SampleCategoryAble;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
-import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
+import fr.ifremer.shared.application.swing.computable.ComputableData;
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
@@ -107,16 +107,16 @@
*
* @since 0.2
*/
- protected TuttiComputedOrNotData<Float> computedOrNotWeight =
- new TuttiComputedOrNotData<Float>();
+ protected ComputableData<Float> computedOrNotWeight =
+ new ComputableData<Float>();
/**
* Total computed number (from frequencies).
*
* @since 0.2
*/
- protected TuttiComputedOrNotData<Integer> computedOrNotNumber =
- new TuttiComputedOrNotData<Integer>();
+ protected ComputableData<Integer> computedOrNotNumber =
+ new ComputableData<Integer>();
/**
* Attachments (should never be null).
@@ -624,19 +624,19 @@
firePropertyChange(PROPERTY_FREQUENCY, null, frequency);
}
- public TuttiComputedOrNotData<Integer> getComputedOrNotNumber() {
+ public ComputableData<Integer> getComputedOrNotNumber() {
return computedOrNotNumber;
}
- public void setComputedOrNotNumber(TuttiComputedOrNotData<Integer> computedOrNotNumber) {
+ public void setComputedOrNotNumber(ComputableData<Integer> computedOrNotNumber) {
this.computedOrNotNumber = computedOrNotNumber;
}
- public TuttiComputedOrNotData<Float> getComputedOrNotWeight() {
+ public ComputableData<Float> getComputedOrNotWeight() {
return computedOrNotWeight;
}
- public void setComputedOrNotWeight(TuttiComputedOrNotData<Float> computedOrNotWeight) {
+ public void setComputedOrNotWeight(ComputableData<Float> computedOrNotWeight) {
this.computedOrNotWeight = computedOrNotWeight;
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -31,7 +31,7 @@
_selectOnFocus: {true};
}
-TuttiComputedOrNotDataEditor {
+ComputableDataEditor {
autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
showReset: true;
@@ -181,7 +181,7 @@
text: "tutti.editSpeciesBatch.action.removeBatch";
toolTipText: "tutti.editSpeciesBatch.action.removeBatch.tip";
i18nMnemonic: "tutti.editSpeciesBatch.action.removeBatch.mnemonic";
- _applicationAction: {RemoveSpeciesBatchAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.RemoveSpeciesBatchAction.class};
enabled: {model.isTableViewModeAll() && model.isRemoveBatchEnabled()};
_help: {"tutti.editSpeciesBatch.action.removeBatch.help"};
}
@@ -191,7 +191,7 @@
text: "tutti.editSpeciesBatch.action.removeSubBatch";
toolTipText: "tutti.editSpeciesBatch.action.removeSubBatch.tip";
i18nMnemonic: "tutti.editSpeciesBatch.action.removeSubBatch.mnemonic";
- _applicationAction: {RemoveSpeciesSubBatchAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.RemoveSpeciesSubBatchAction.class};
enabled: {model.isTableViewModeAll() && model.isRemoveSubBatchEnabled()};
_help: {"tutti.editSpeciesBatch.action.removeSubBatch.help"};
}
@@ -201,7 +201,7 @@
text: "tutti.editSpeciesBatch.action.renameBatch";
toolTipText: "tutti.editSpeciesBatch.action.renameBatch.tip";
i18nMnemonic: "tutti.editSpeciesBatch.action.renameBatch.mnemonic";
- _applicationAction: {RenameSpeciesBatchAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.RenameSpeciesBatchAction.class};
enabled: {model.isTableViewModeAll() && model.isRenameBatchEnabled()};
_help: {"tutti.editSpeciesBatch.action.renameBatch.help"};
}
@@ -211,7 +211,7 @@
text: "tutti.editSpeciesBatch.action.createMelag";
toolTipText: "tutti.editSpeciesBatch.action.createMelag.tip";
i18nMnemonic: "tutti.editSpeciesBatch.action.createMelag.mnemonic";
- _applicationAction: {CreateSpeciesMelagAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.CreateSpeciesMelagAction.class};
enabled: {!model.isTableViewModeLeaf() && model.isCreateMelagEnabled()};
_help: {"tutti.editSpeciesBatch.action.createMelag.help"};
}
@@ -230,7 +230,7 @@
text: "tutti.editSpeciesBatch.action.importPupitri";
toolTipText: "tutti.editSpeciesBatch.action.importPupitri.tip";
i18nMnemonic: "tutti.editSpeciesBatch.action.importPupitri.mnemonic";
- _applicationAction: {ImportPupitriAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportPupitriAction.class};
_help: {"tutti.editSpeciesBatch.action.importPupitri.help"};
}
@@ -239,7 +239,7 @@
text: "tutti.editSpeciesBatch.action.importMultiPost";
toolTipText: "tutti.editSpeciesBatch.action.importMultiPost.tip";
i18nMnemonic: "tutti.editSpeciesBatch.action.importMultiPost.mnemonic";
- _applicationAction: {ImportMultiPostAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportSpeciesMultiPostAction.class};
_help: {"tutti.editSpeciesBatch.action.importMultiPost.help"};
}
@@ -248,7 +248,7 @@
text: "tutti.editSpeciesBatch.action.exportMultiPost";
toolTipText: "tutti.editSpeciesBatch.action.exportMultiPost.tip";
i18nMnemonic: "tutti.editSpeciesBatch.action.exportMultiPost.mnemonic";
- _applicationAction: {ExportMultiPostAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportSpeciesMultiPostAction.class};
_help: {"tutti.editSpeciesBatch.action.exportMultiPost.help"};
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-11-26 08:03:42 UTC (rev 1388)
@@ -25,12 +25,12 @@
decorator='help'
implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<SpeciesBatchUIModel, SpeciesBatchUIHandler>'>
- <import>
+ <import><![CDATA[
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI
fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode
fr.ifremer.tutti.ui.swing.util.TuttiUI
- fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor
+ fr.ifremer.shared.application.swing.computable.ComputableDataEditor
org.jdesktop.swingx.JXTable
@@ -40,7 +40,7 @@
static org.nuiton.i18n.I18n._
static fr.ifremer.shared.application.ApplicationDataUtil.getWeightStringValue
- </import>
+ ]]></import>
<script><![CDATA[
@@ -104,8 +104,8 @@
<JLabel id='speciesTotalSortedWeightLabel'/>
</cell>
<cell weightx='1.0'>
- <TuttiComputedOrNotDataEditor id='speciesTotalSortedWeightField'
- constructorParams='this'/>
+ <ComputableDataEditor id='speciesTotalSortedWeightField'
+ genericType="Float" constructorParams='this'/>
</cell>
</row>
@@ -131,16 +131,15 @@
<JLabel id='speciesTotalInertWeightLabel'/>
</cell>
<cell>
- <TuttiComputedOrNotDataEditor id='speciesTotalInertWeightField'
- constructorParams='this'/>
+ <ComputableDataEditor id='speciesTotalInertWeightField'
+ genericType="Float" constructorParams='this'/>
</cell>
<cell>
<JLabel id='speciesTotalLivingNotItemizedWeightLabel'/>
</cell>
<cell>
- <TuttiComputedOrNotDataEditor
- id='speciesTotalLivingNotItemizedWeightField'
- constructorParams='this'/>
+ <ComputableDataEditor id='speciesTotalLivingNotItemizedWeightField'
+ genericType="Float" constructorParams='this'/>
</cell>
</row>
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -27,6 +27,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
+import fr.ifremer.shared.application.swing.computable.ComputableDataTableCell;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
@@ -65,7 +66,6 @@
import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellRenderer;
import fr.ifremer.tutti.ui.swing.util.comment.CommentCellEditor;
import fr.ifremer.tutti.ui.swing.util.comment.CommentCellRenderer;
-import fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataTableCell;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUI;
import fr.ifremer.tutti.ui.swing.util.species.SelectSpeciesUIModel;
import fr.ifremer.shared.application.swing.table.ColumnIdentifier;
@@ -758,9 +758,9 @@
{ // Weight column
addColumnToModel(columnModel,
- TuttiComputedOrNotDataTableCell.newEditor(
+ ComputableDataTableCell.newEditor(
Float.class, weightUnit, computedDataColor),
- TuttiComputedOrNotDataTableCell.newRender(
+ ComputableDataTableCell.newRender(
defaultRenderer, weightUnit, computedDataColor),
SpeciesBatchTableModel.WEIGHT,
weightUnit);
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -34,8 +34,8 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.TableViewMode;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
-import fr.ifremer.tutti.ui.swing.util.TabContentModel;
-import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
+import fr.ifremer.shared.application.swing.tab.TabContentModel;
+import fr.ifremer.shared.application.swing.computable.ComputableData;
import org.apache.commons.collections.CollectionUtils;
import java.util.List;
@@ -168,7 +168,7 @@
catchesUIModel.setSpeciesTotalComputedWeight(speciesTotalComputedWeight);
}
- public TuttiComputedOrNotData<Float> getSpeciesTotalSortedComputedOrNotWeight() {
+ public ComputableData<Float> getSpeciesTotalSortedComputedOrNotWeight() {
return catchesUIModel.getSpeciesTotalSortedComputedOrNotWeight();
}
@@ -204,7 +204,7 @@
catchesUIModel.setSpeciesTotalSampleSortedComputedWeight(speciesTotalSampleSortedComputedWeight);
}
- public TuttiComputedOrNotData<Float> getSpeciesTotalInertComputedOrNotWeight() {
+ public ComputableData<Float> getSpeciesTotalInertComputedOrNotWeight() {
return catchesUIModel.getSpeciesTotalInertComputedOrNotWeight();
}
@@ -224,7 +224,7 @@
catchesUIModel.setSpeciesTotalInertComputedWeight(speciesTotalInertComputedWeight);
}
- public TuttiComputedOrNotData<Float> getSpeciesTotalLivingNotItemizedComputedOrNotWeight() {
+ public ComputableData<Float> getSpeciesTotalLivingNotItemizedComputedOrNotWeight() {
return catchesUIModel.getSpeciesTotalLivingNotItemizedComputedOrNotWeight();
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -139,7 +139,7 @@
text: "tutti.createSpeciesBatch.action.addSpecies";
toolTipText: "tutti.createSpeciesBatch.action.addSpecies.tip";
i18nMnemonic: "tutti.createSpeciesBatch.action.addSpecies.mnemonic";
- _applicationAction: {SelectSpeciesForSpeciesBatchAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SelectSpeciesForSpeciesBatchAction.class};
_help: {"tutti.createSpeciesBatch.action.addSpecies.help"};
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/CreateSpeciesBatchUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -41,7 +41,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchTableModel;
-import fr.ifremer.tutti.ui.swing.util.Cancelable;
+import fr.ifremer.shared.application.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.shared.application.type.WeightUnit;
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/SelectSpeciesForSpeciesBatchAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/SelectSpeciesForSpeciesBatchAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/create/SelectSpeciesForSpeciesBatchAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,101 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species.create;
-
-/*
- * #%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.referential.Species;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Enable to select a species to the species selected in the protocol.
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.0
- */
-public class SelectSpeciesForSpeciesBatchAction extends AbstractTuttiAction<CreateSpeciesBatchUIModel, CreateSpeciesBatchUI, CreateSpeciesBatchUIHandler> {
-
- protected List<Species> allSpecies;
-
- protected List<Species> referentSpecies;
-
- protected Species selectedSpecies;
-
- public SelectSpeciesForSpeciesBatchAction(CreateSpeciesBatchUIHandler handler) {
- super(handler, false);
-
- allSpecies = getDataContext().getSpecies();
- referentSpecies = getDataContext().getReferentSpecies();
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean canContinue = super.prepareAction();
- if (canContinue) {
-
- CreateSpeciesBatchUIModel model = getModel();
-
- List<Species> species = Lists.newArrayList(allSpecies);
- species.removeAll(model.getAvailableSpecies());
-
- selectedSpecies = getHandler().openAddSpeciesDialog(
- _("tutti.selectSpecies.title"), species);
- canContinue = selectedSpecies != null;
- }
- return canContinue;
- }
-
- @Override
- public void doAction() throws Exception {
-
- CreateSpeciesBatchUIModel model = getModel();
-
- List<Species> availableSpecies = Lists.newArrayList(model.getAvailableSpecies());
-
- if (!selectedSpecies.isReferenceTaxon()) {
- String decoratedSynonym = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL);
- List<Species> referents = referentSpecies;
- Map<String, Species> referentsById = TuttiEntities.splitByTaxonId(referents);
- String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId());
- selectedSpecies = referentsById.get(taxonId);
- String decoratedReferent = decorate(selectedSpecies, DecoratorService.FROM_PROTOCOL);
- sendMessage(_("tutti.flash.info.species.replaced", decoratedSynonym, decoratedReferent));
- }
-
- if (!availableSpecies.contains(selectedSpecies)) {
- availableSpecies.add(selectedSpecies);
- }
- model.setAvailableSpecies(availableSpecies);
- model.setSpecies(selectedSpecies);
-
- }
-
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -26,11 +26,11 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
+import fr.ifremer.shared.application.swing.computable.ComputableData;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
-import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.shared.application.swing.table.ColumnIdentifier;
import jaxx.runtime.SwingUtil;
@@ -79,7 +79,7 @@
this.computedDataColor = computedDataColor;
}
- public void setComputedOrNotText(TuttiComputedOrNotData<Integer> data) {
+ public void setComputedOrNotText(ComputableData<Integer> data) {
String text;
if (data != null && data.getData() != null) {
@@ -303,7 +303,7 @@
if (log.isDebugEnabled()) {
log.debug("Set columnIdentifier (" + column + ") :: " + columnIdentifier.getPropertyName());
}
- TuttiComputedOrNotData<Integer> data = (TuttiComputedOrNotData<Integer>) value;
+ ComputableData<Integer> data = (ComputableData<Integer>) value;
component.setComputedOrNotText(data);
rowIndex = row;
@@ -356,7 +356,7 @@
int row,
int column) {
component.setForeground(Color.BLACK);
- TuttiComputedOrNotData<Integer> data = (TuttiComputedOrNotData<Integer>) value;
+ ComputableData<Integer> data = (ComputableData<Integer>) value;
SpeciesFrequencyCellComponent result =
(SpeciesFrequencyCellComponent) component.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -39,7 +39,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyCellComponent.FrequencyCellEditor;
-import fr.ifremer.tutti.ui.swing.util.Cancelable;
+import fr.ifremer.shared.application.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -36,7 +36,7 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
-import fr.ifremer.tutti.ui.swing.util.Cancelable;
+import fr.ifremer.shared.application.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIModel.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIModel.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -31,7 +31,7 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
-import fr.ifremer.tutti.ui.swing.util.TabContentModel;
+import fr.ifremer.shared.application.swing.tab.TabContentModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
import java.io.Serializable;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -29,8 +29,8 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI;
-import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor;
-import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
+import fr.ifremer.tutti.ui.swing.util.caracteristics.CaracteristicValueEditor;
+import fr.ifremer.tutti.ui.swing.util.caracteristics.CaracteristicValueRenderer;
import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -29,8 +29,8 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI;
-import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor;
-import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
+import fr.ifremer.tutti.ui.swing.util.caracteristics.CaracteristicValueEditor;
+import fr.ifremer.tutti.ui.swing.util.caracteristics.CaracteristicValueRenderer;
import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -80,7 +80,7 @@
text: "tutti.editProgram.action.saveProgram";
toolTipText: "tutti.editProgram.action.saveProgram.tip";
i18nMnemonic: "tutti.editProgram.action.saveProgram.mnemonic";
- _applicationAction: {SaveProgramAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SaveProgramAction.class};
enabled: {model.isModify() && model.isValid()};
_help: {"tutti.editProgram.action.saveProgram.help"};
}
@@ -90,6 +90,6 @@
text: "tutti.editProgram.action.closeEditProgram";
toolTipText: "tutti.editProgram.action.closeEditProgram.tip";
i18nMnemonic: "tutti.editProgram.action.closeEditProgram.mnemonic";
- _applicationAction: {fr.ifremer.tutti.ui.swing.content.SelectCruiseAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SelectCruiseAction.class};
_help: {"tutti.editProgram.action.cancelProgram.help"};
}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/SaveProgramAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/SaveProgramAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/SaveProgramAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,79 +0,0 @@
-
-package fr.ifremer.tutti.ui.swing.content.program;
-
-/*
- * #%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.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.Program;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class SaveProgramAction extends AbstractTuttiAction<EditProgramUIModel, EditProgramUI, EditProgramUIHandler> {
-
- public SaveProgramAction(EditProgramUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public void doAction() throws Exception {
- TuttiUIContext context = getContext();
- PersistenceService persistenceService =
- getContext().getPersistenceService();
-
- EditProgramUIModel model = getModel();
-
- Program bean = model.toBean();
-
- Program saved;
- if (TuttiEntities.isNew(bean)) {
-
- saved = persistenceService.createProgram(bean);
- model.setId(saved.getId());
- sendMessage(_("tutti.flash.info.programCreated", bean.getName()));
- } else {
- saved = persistenceService.saveProgram(bean);
- sendMessage(_("tutti.flash.info.programSaved", bean.getName()));
- }
-
- context.setProgramId(saved.getId());
-
- model.setModify(false);
- }
-
- @Override
- public void postSuccessAction() {
- getContext().getMainUI().getHandler().setBodyTitle(
- EditProgramUIHandler.getTitle(true));
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddBenthosProtocolAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddBenthosProtocolAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddBenthosProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,103 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
-
-import java.util.Collection;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To add a new benthos protocol.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class AddBenthosProtocolAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
-
- public AddBenthosProtocolAction(EditProtocolUIHandler handler) {
- super(handler, false);
- }
-
- protected Species species;
-
- protected EditProtocolSpeciesRowModel newRow;
-
- @Override
- public void doAction() throws Exception {
-
- species = null;
-
- EditProtocolUI ui = getUI();
-
- EditProtocolSpeciesTableModel tableModel = handler.getBenthosTableModel();
- BeanFilterableComboBox<Species> benthosComboBox = ui.getBenthosComboBox();
-
- species = (Species) benthosComboBox.getSelectedItem();
- Preconditions.checkNotNull(
- species, "Can't add a benthosProtocol with a null species");
- Preconditions.checkArgument(species.isReferenceTaxon(),
- "Can't add a benthosProtocol with a not referent species");
-
- Integer taxonId = species.getReferenceTaxonId();
- String taxonIdStr = String.valueOf(taxonId);
-
- // remove all synonyms of this taxon
- Collection<Species> allSynonyms = getModel().getAllSynonyms(taxonIdStr);
- getModel().getAllSynonyms().removeAll(allSynonyms);
-
- // add new row to model (do it after combo stuff for ui best display)
- newRow = tableModel.createNewRow();
- newRow.setSpecies(species);
- getModel().getBenthosRow().add(newRow);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- // update comboboxes
- getUI().getBenthosComboBox().removeItem(species);
- getUI().getSpeciesComboBox().removeItem(species);
-
- // fire row was inserted in table model
- EditProtocolSpeciesTableModel tableModel = getHandler().getBenthosTableModel();
- tableModel.fireTableRowsInserted(newRow);
-
- // select this new row
- int rowIndex = tableModel.getRowIndex(newRow);
- SwingUtil.setSelectionInterval(handler.getBenthosTable(), rowIndex);
-
- // add notification
- String speciesStr = decorate(species);
- sendMessage(_("tutti.flash.info.benthos.add.to.protocol",
- speciesStr));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,101 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
-
-import java.util.Collection;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To add a new species protocol.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class AddSpeciesProtocolAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
-
- public AddSpeciesProtocolAction(EditProtocolUIHandler handler) {
- super(handler, false);
- }
-
- protected Species species;
-
- protected EditProtocolSpeciesRowModel newRow;
-
- @Override
- public void doAction() throws Exception {
-
- EditProtocolUI ui = getUI();
-
- EditProtocolSpeciesTableModel tableModel = handler.getSpeciesTableModel();
- BeanFilterableComboBox<Species> speciesComboBox = ui.getSpeciesComboBox();
-
- species = (Species) speciesComboBox.getSelectedItem();
- Preconditions.checkNotNull(
- species, "Can't add a speciesProtocol with a null species");
- Preconditions.checkArgument(species.isReferenceTaxon(),
- "Can't add a speciesProtocol with a not referent species");
-
- Integer taxonId = species.getReferenceTaxonId();
- String taxonIdStr = String.valueOf(taxonId);
-
- // remove all synonyms of this taxon
- Collection<Species> allSynonyms = getModel().getAllSynonyms(taxonIdStr);
- getModel().getAllSynonyms().removeAll(allSynonyms);
-
- // add new row to model (do it after combo stuff for ui best display)
- newRow = tableModel.createNewRow();
- newRow.setSpecies(species);
- getModel().getSpeciesRow().add(newRow);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- // update comboboxes
- getUI().getBenthosComboBox().removeItem(species);
- getUI().getSpeciesComboBox().removeItem(species);
-
- // fire row was inserted in table model
- EditProtocolSpeciesTableModel tableModel = getHandler().getSpeciesTableModel();
- tableModel.fireTableRowsInserted(newRow);
-
- // select this new row
- int rowIndex = tableModel.getRowIndex(newRow);
- SwingUtil.setSelectionInterval(handler.getSpeciesTable(), rowIndex);
-
- // add notification
- String speciesStr = decorate(species);
- sendMessage(_("tutti.flash.info.species.add.to.protocol",
- speciesStr));
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -140,7 +140,7 @@
toolTipText: "tutti.editProtocol.action.saveProtocol.tip";
i18nMnemonic: "tutti.editProtocol.action.saveProtocol.mnemonic";
enabled: {model.isModify() && model.isValid()};
- _applicationAction: {SaveProtocolAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SaveProtocolAction.class};
_help: {"tutti.editProtocol.action.saveProtocol.help"};
}
@@ -149,7 +149,7 @@
text: "tutti.editProtocol.action.closeEditProtocol";
toolTipText: "tutti.editProtocol.action.closeEditProtocol.tip";
i18nMnemonic: "tutti.editProtocol.action.closeEditProtocol.mnemonic";
- _applicationAction: {fr.ifremer.tutti.ui.swing.content.SelectCruiseAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SelectCruiseAction.class};
_help: {"tutti.editProtocol.action.closeEditProtocol.help"};
}
@@ -157,7 +157,7 @@
text: "tutti.editProtocol.action.selectOtherSpecies";
toolTipText: "tutti.editProtocol.action.selectOtherSpecies.tip";
i18nMnemonic: "tutti.editProtocol.action.selectOtherSpecies.mnemonic";
- _applicationAction: {SelectOtherSpeciesAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SelectOtherSpeciesAction.class};
_help: {"tutti.editProtocol.action.selectOtherSpecies.help"};
}
@@ -165,7 +165,7 @@
actionIcon: add;
toolTipText: "tutti.editProtocol.action.addSpeciesProtocol.tip";
i18nMnemonic: "tutti.editProtocol.action.addSpeciesProtocol.mnemonic";
- _applicationAction: {AddSpeciesProtocolAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.AddSpeciesProtocolAction.class};
enabled: {speciesComboBox.getSelectedItem() != null};
_help: {"tutti.editProtocol.action.addSpeciesProtocol.help"};
}
@@ -175,7 +175,7 @@
text: "tutti.editProtocol.action.removeSpeciesProtocol";
toolTipText: "tutti.editProtocol.action.removeSpeciesProtocol.tip";
i18nMnemonic: "tutti.editProtocol.action.removeSpeciesProtocol.mnemonic";
- _applicationAction: {RemoveSpeciesProtocolAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.RemoveSpeciesProtocolAction.class};
enabled: {model.isRemoveSpeciesEnabled()};
_help: {"tutti.editProtocol.action.removeSpeciesProtocol.help"};
}
@@ -185,7 +185,7 @@
text: "tutti.editProtocol.action.importProtocolSpecies";
toolTipText: "tutti.editProtocol.action.importProtocolSpecies.tip";
i18nMnemonic: "tutti.editProtocol.action.importProtocolSpecies.mnemonic";
- _applicationAction: {ImportProtocolSpeciesAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportProtocolSpeciesAction.class};
_help: {"tutti.editProtocol.action.importProtocolSpecies.help"};
}
@@ -194,7 +194,7 @@
text: "tutti.editProtocol.action.exportProtocolSpecies";
toolTipText: "tutti.editProtocol.action.exportProtocolSpecies.tip";
i18nMnemonic: "tutti.editProtocol.action.exportProtocolSpecies.mnemonic";
- _applicationAction: {ExportProtocolSpeciesAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportProtocolSpeciesAction.class};
_help: {"tutti.editProtocol.action.exportProtocolSpecies.help"};
}
@@ -203,7 +203,7 @@
text: "tutti.editProtocol.action.exportPupitri";
toolTipText: "tutti.editProtocol.action.exportPupitri.tip";
i18nMnemonic: "tutti.editProtocol.action.exportPupitri.mnemonic";
- _applicationAction: {ExportPupitriAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportPupitriAction.class};
_help: {"tutti.editProtocol.action.exportPupitri.help"};
}
@@ -211,7 +211,7 @@
text: "tutti.editProtocol.action.selectOtherBenthos";
toolTipText: "tutti.editProtocol.action.selectOtherBenthos.tip";
i18nMnemonic: "tutti.editProtocol.action.selectOtherBenthos.mnemonic";
- _applicationAction: {SelectOtherBenthosAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.SelectOtherBenthosAction.class};
_help: {"tutti.editProtocol.action.selectOtherBenthos.help"};
}
@@ -219,7 +219,7 @@
actionIcon: add;
toolTipText: "tutti.editProtocol.action.addBenthosProtocol.tip";
i18nMnemonic: "tutti.editProtocol.action.addBenthosProtocol.mnemonic";
- _applicationAction: {AddBenthosProtocolAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.AddBenthosProtocolAction.class};
enabled: {benthosComboBox.getSelectedItem() != null};
_help: {"tutti.editProtocol.action.addBenthosProtocol.help"};
}
@@ -229,7 +229,7 @@
text: "tutti.editProtocol.action.removeBenthosProtocol";
toolTipText: "tutti.editProtocol.action.removeBenthosProtocol.tip";
i18nMnemonic: "tutti.editProtocol.action.removeBenthosProtocol.mnemonic";
- _applicationAction: {RemoveBenthosProtocolAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.RemoveBenthosProtocolAction.class};
enabled: {model.isRemoveBenthosEnabled()};
_help: {"tutti.editProtocol.action.removeBenthosProtocol.help"};
}
@@ -239,7 +239,7 @@
text: "tutti.editProtocol.action.importProtocolBenthos";
toolTipText: "tutti.editProtocol.action.importProtocolBenthos.tip";
i18nMnemonic: "tutti.editProtocol.action.importProtocolBenthos.mnemonic";
- _applicationAction: {ImportProtocolBenthosAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportProtocolBenthosAction.class};
_help: {"tutti.editProtocol.action.importProtocolBenthos.help"};
}
@@ -248,7 +248,7 @@
text: "tutti.editProtocol.action.exportProtocolBenthos";
toolTipText: "tutti.editProtocol.action.exportProtocolBenthos.tip";
i18nMnemonic: "tutti.editProtocol.action.exportProtocolBenthos.mnemonic";
- _applicationAction: {ExportProtocolBenthosAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportProtocolBenthosAction.class};
_help: {"tutti.editProtocol.action.exportProtocolBenthos.help"};
}
@@ -257,7 +257,7 @@
text: "tutti.editProtocol.action.importProtocolCaracteristic";
toolTipText: "tutti.editProtocol.action.importProtocolCaracteristic.tip";
i18nMnemonic: "tutti.editProtocol.action.importProtocolCaracteristic.mnemonic";
- _applicationAction: {ImportProtocolCaracteristicAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportProtocolCaracteristicAction.class};
_help: {"tutti.editProtocol.action.importProtocolCaracteristic.help"};
}
@@ -266,7 +266,7 @@
text: "tutti.editProtocol.action.exportProtocolCaracteristic";
toolTipText: "tutti.editProtocol.action.exportProtocolCaracteristic.tip";
i18nMnemonic: "tutti.editProtocol.action.exportProtocolCaracteristic.mnemonic";
- _applicationAction: {ExportProtocolCaracteristicAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportProtocolCaracteristicAction.class};
_help: {"tutti.editProtocol.action.exportProtocolCaracteristic.tip"};
}
@@ -275,7 +275,7 @@
text: "tutti.editProtocol.action.exportProtocolAllCaracteristic";
toolTipText: "tutti.editProtocol.action.exportProtocolAllCaracteristic.tip";
i18nMnemonic: "tutti.editProtocol.action.exportProtocolAllCaracteristic.mnemonic";
- _applicationAction: {ExportAllCaracteristicAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportAllCaracteristicAction.class};
_help: {"tutti.editProtocol.action.exportProtocolAllCaracteristic.help"};
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -39,9 +39,9 @@
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.TuttiDecorator;
-import fr.ifremer.tutti.ui.swing.content.home.CloneProtocolAction;
-import fr.ifremer.tutti.ui.swing.content.home.EditProtocolAction;
-import fr.ifremer.tutti.ui.swing.content.home.ImportProtocolAction;
+import fr.ifremer.tutti.ui.swing.action.CloneProtocolAction;
+import fr.ifremer.tutti.ui.swing.action.EditProtocolAction;
+import fr.ifremer.tutti.ui.swing.action.ImportProtocolAction;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.shared.application.swing.util.CloseableUI;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportAllCaracteristicAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportAllCaracteristicAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportAllCaracteristicAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,96 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To export all caracteristics.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ExportAllCaracteristicAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ExportAllCaracteristicAction.class);
-
- protected File file;
-
- public ExportAllCaracteristicAction(EditProtocolUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to export
- file = saveFile(
- "tuttiProtocol-" + getModel().getName() + "-allCaracteristics",
- "csv",
- _("tutti.editProtocol.title.choose.caracteristicExportFile"),
- _("tutti.editProtocol.action.chooseProtocolCaracteristicFile"),
- "^.*\\.csv", _("tutti.common.file.csv")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will export all caracteristic to file: " + file);
- }
-
- // export protocol caracteristics
- ProtocolImportExportService service =
- getContext().getTuttiProtocolImportExportService();
-
- service.exportAllCaracteristic(file, getModel().getAllCaracteristic());
-
- sendMessage(_("tutti.flash.info.all.caractristic.exported", file));
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolBenthosAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolBenthosAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolBenthosAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,114 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
-import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To export protocol benthos.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.2
- */
-public class ExportProtocolBenthosAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ExportProtocolBenthosAction.class);
-
- private File file;
-
- public ExportProtocolBenthosAction(EditProtocolUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to export
- file = saveFile(
- "tuttiProtocol-" + getModel().getName() + "-benthos",
- "csv",
- _("tutti.editProtocol.title.choose.benthosExportFile"),
- _("tutti.editProtocol.action.chooseProtocolBenthosFile"),
- "^.*\\.csv", _("tutti.common.file.csv")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will export protocol benthos to file: " + file);
- }
-
- EditProtocolUIModel model = getModel();
-
- // build benthos protocol to export
-
- List<SpeciesProtocol> protocols = Lists.newArrayList();
- for (EditProtocolSpeciesRowModel row : model.getBenthosRow()) {
- if (row.isValid()) {
- protocols.add(row.toBean());
- }
- }
-
- // import
- ProtocolImportExportService service =
- getContext().getTuttiProtocolImportExportService();
-
- service.exportProtocolBenthos(file,
- protocols,
- model.getAllCaracteristic(),
- model.getAllReferentSpeciesByTaxonId());
-
- sendMessage(_("tutti.flash.info.species.exported.from.protocol",
- file));
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolCaracteristicAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolCaracteristicAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolCaracteristicAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,103 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To import protocol caracteristics.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ExportProtocolCaracteristicAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ExportProtocolCaracteristicAction.class);
-
- private File file;
-
- public ExportProtocolCaracteristicAction(EditProtocolUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to export
- file = saveFile(
- "tuttiProtocol-" + getModel().getName() + "-caracteristics",
- "csv",
- _("tutti.editProtocol.title.choose.caracteristicExportFile"),
- _("tutti.editProtocol.action.chooseProtocolCaracteristicFile"),
- "^.*\\.csv", _("tutti.common.file.csv")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will export protocol caracteristic to file: " + file);
- }
-
- // bind to a protocol
- TuttiProtocol protocol = getModel().toBean();
-
- // export protocol caracteristics
- ProtocolImportExportService service =
- getContext().getTuttiProtocolImportExportService();
-
- service.exportProtocolCaracteristic(file,
- protocol,
- getModel().getAllCaracteristic());
-
- sendMessage(_("tutti.flash.info.caractristic.exported.from.protocol",
- file));
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,114 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
-import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To export protocol species.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ExportProtocolSpeciesAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ExportProtocolSpeciesAction.class);
-
- private File file;
-
- public ExportProtocolSpeciesAction(EditProtocolUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to export
- file = saveFile(
- "tuttiProtocol-" + getModel().getName() + "-species",
- "csv",
- _("tutti.editProtocol.title.choose.speciesExportFile"),
- _("tutti.editProtocol.action.chooseProtocolSpeciesFile"),
- "^.*\\.csv", _("tutti.common.file.csv")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will export protocol species to file: " + file);
- }
-
- EditProtocolUIModel model = getModel();
-
- // build species protocol to export
-
- List<SpeciesProtocol> protocols = Lists.newArrayList();
- for (EditProtocolSpeciesRowModel row : model.getSpeciesRow()) {
- if (row.isValid()) {
- protocols.add(row.toBean());
- }
- }
-
- // import
- ProtocolImportExportService service =
- getContext().getTuttiProtocolImportExportService();
-
- service.exportProtocolSpecies(file,
- protocols,
- model.getAllCaracteristic(),
- model.getAllReferentSpeciesByTaxonId());
-
- sendMessage(_("tutti.flash.info.species.exported.from.protocol",
- file));
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,112 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.pupitri.PupitriImportExportService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To export protocol species.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ExportPupitriAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ExportPupitriAction.class);
-
- private File file;
-
- public ExportPupitriAction(EditProtocolUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to export
- file = saveFile(
- "tuttiProtocol-" + getModel().getName() + "-pupitri",
- "csv",
- _("tutti.editProtocol.title.choose.speciesExportFile"),
- _("tutti.editProtocol.action.chooseProtocolSpeciesFile")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will export protocol species to file: " + file);
- }
-
- EditProtocolUIModel model = getModel();
-
- // build species protocol to export
-
- List<Species> speciesList = Lists.newArrayList();
- for (EditProtocolSpeciesRowModel row : model.getSpeciesRow()) {
- if (row.isValid()) {
- Species species = row.getSpecies();
- species.setSurveyCode(row.getSpeciesSurveyCode());
- speciesList.add(species);
- }
- }
-
- // import
- PupitriImportExportService service =
- getContext().getTuttiPupitriImportExportService();
-
- service.exportSpecies(speciesList, file);
-
- sendMessage(_("tutti.flash.info.species.exported.from.protocol",
- file));
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,145 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To import protocol benthos.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ImportProtocolBenthosAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ImportProtocolBenthosAction.class);
-
- private File file;
-
- public ImportProtocolBenthosAction(EditProtocolUIHandler handler) {
- super(handler, false);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to import
- file = chooseFile(
- _("tutti.editProtocol.title.choose.benthosImportFile"),
- _("tutti.editProtocol.action.chooseProtocolBenthosFile"),
- "^.*\\.csv", _("tutti.common.file.csv")
- );
-
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will import protocol benthos file: " + file);
- }
-
- EditProtocolUIModel model = getModel();
-
- // bind to a protocol
- TuttiProtocol protocol = model.toBean();
-
- // import
- ProtocolImportExportService service =
- getContext().getTuttiProtocolImportExportService();
-
- service.importProtocolBenthos(file,
- protocol,
- model.getAllCaracteristic(),
- model.getAllReferentSpeciesByTaxonId());
-
- // build rows from imported+merged protocol
- // (will also remove all synonyms of species referent used)
- List<EditProtocolSpeciesRowModel> rows =
- handler.toRows(protocol.getBenthos());
-
- // update species comboBox
- getUI().getSpeciesComboBox().getHandler().reset();
-
- // update benthos comboBox
- getUI().getBenthosComboBox().getHandler().reset();
-
- // update rows in model
- model.setBenthosRow(rows);
-
- getHandler().getBenthosTableModel().setRows(rows);
-
- int nbSynonym = 0;
- for (SpeciesProtocol speciesProtocol : protocol.getBenthos()) {
- if (!speciesProtocol.isMadeFromAReferentTaxon()) {
- nbSynonym++;
- }
- }
-
- String message;
- switch (nbSynonym) {
- case 0:
- message = _("tutti.flash.info.benthos.imported.in.protocol",
- file);
- break;
-
- case 1:
- message = _("tutti.flash.info.benthos.imported.in.protocol.oneReplaced",
- file);
- break;
-
- default:
- message = _("tutti.flash.info.benthos.imported.in.protocol.severalReplaced",
- file, nbSynonym);
- }
- sendMessage(message);
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,114 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To import protocol caracteristics.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ImportProtocolCaracteristicAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ImportProtocolCaracteristicAction.class);
-
- private File file;
-
- public ImportProtocolCaracteristicAction(EditProtocolUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to import
- file = chooseFile(
- _("tutti.editProtocol.title.choose.caracteristicImportFile"),
- _("tutti.editProtocol.action.chooseProtocolCaracteristicFile"),
- "^.*\\.csv", _("tutti.common.file.csv")
- );
-
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will import protocol caracteristic file: " + file);
- }
-
- EditProtocolUIModel model = getModel();
-
- // bind to a protocol
- TuttiProtocol protocol = model.toBean();
-
- ProtocolImportExportService service =
- getContext().getTuttiProtocolImportExportService();
-
- service.importProtocolCaracteristic(file,
- protocol,
- model.getAllCaracteristic());
-
- handler.addDoubleListListeners();
-
- try {
- // rebind to model
- model.fromBean(protocol);
- } finally {
- handler.removeDoubleListListeners();
- }
-
- sendMessage(
- _("tutti.flash.info.caracteristic.imported.in.protocol",
- file));
-
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,145 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.service.protocol.ProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To import protocol species.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ImportProtocolSpeciesAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ImportProtocolSpeciesAction.class);
-
- private File file;
-
- public ImportProtocolSpeciesAction(EditProtocolUIHandler handler) {
- super(handler, false);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to import
- file = chooseFile(
- _("tutti.editProtocol.title.choose.speciesImportFile"),
- _("tutti.editProtocol.action.chooseProtocolSpeciesFile"),
- "^.*\\.csv", _("tutti.common.file.csv")
- );
-
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will import protocol species file: " + file);
- }
-
- EditProtocolUIModel model = getModel();
-
- // bind to a protocol
- TuttiProtocol protocol = model.toBean();
-
- // import
- ProtocolImportExportService service =
- getContext().getTuttiProtocolImportExportService();
-
- service.importProtocolSpecies(file,
- protocol,
- model.getAllCaracteristic(),
- model.getAllReferentSpeciesByTaxonId());
-
- // build rows from imported+merged protocol
- // (will also remove all synonyms of species referent used)
- List<EditProtocolSpeciesRowModel> rows =
- handler.toRows(protocol.getSpecies());
-
- // update species comboBox
- getUI().getSpeciesComboBox().getHandler().reset();
-
- // update benthos comboBox
- getUI().getBenthosComboBox().getHandler().reset();
-
- // update rows in model
- model.setSpeciesRow(rows);
-
- getHandler().getSpeciesTableModel().setRows(rows);
-
- int nbSynonym = 0;
- for (SpeciesProtocol speciesProtocol : protocol.getSpecies()) {
- if (!speciesProtocol.isMadeFromAReferentTaxon()) {
- nbSynonym++;
- }
- }
-
- String message;
- switch (nbSynonym) {
- case 0:
- message = _("tutti.flash.info.species.imported.in.protocol",
- file);
- break;
-
- case 1:
- message = _("tutti.flash.info.species.imported.in.protocol.oneReplaced",
- file);
- break;
-
- default:
- message = _("tutti.flash.info.species.imported.in.protocol.severalReplaced",
- file, nbSynonym);
- }
- sendMessage(message);
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveBenthosProtocolAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveBenthosProtocolAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveBenthosProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,132 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import jaxx.runtime.SwingUtil;
-
-import javax.swing.JTable;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To remove all the selected benthos rows from protocol.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class RemoveBenthosProtocolAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
-
-
- /**
- * Set of removed species.
- *
- * @since 2.8
- */
- protected Set<Species> removedSpecies;
-
- /**
- * Set of removed rows.
- *
- * @since 2.8
- */
- protected Set<EditProtocolSpeciesRowModel> removedRows;
-
-
- public RemoveBenthosProtocolAction(EditProtocolUIHandler handler) {
- super(handler, false);
- }
-
- @Override
- public void doAction() throws Exception {
-
- JTable table = handler.getBenthosTable();
-
- // need to have a selection
- Preconditions.checkState(!table.getSelectionModel().isSelectionEmpty());
-
- EditProtocolSpeciesTableModel tableModel =
- (EditProtocolSpeciesTableModel) table.getModel();
-
- removedSpecies = Sets.newHashSet();
- removedRows = Sets.newHashSet();
-
- EditProtocolUIModel model = getModel();
-
- for (Integer rowIndex : SwingUtil.getSelectedModelRows(table)) {
-
- // get row to remove
- EditProtocolSpeciesRowModel selectedRow =
- tableModel.getEntry(rowIndex);
-
- // re-add all synonym of this taxon to the species / benthos combobox
- Species species = selectedRow.getSpecies();
- removedSpecies.add(species);
-
- Integer taxonId = species.getReferenceTaxonId();
- List<Species> allSynonyms = Lists.newArrayList(
- model.getAllSynonyms(String.valueOf(taxonId)));
- allSynonyms.remove(species);
- model.getAllSynonyms().addAll(allSynonyms);
-
- // mark row to be removed at the very last moment
- removedRows.add(selectedRow);
- }
-
- // reorder the list by name, otherwise,
- // all the species without a reftax code will be at the end
- Collections.sort(model.getAllSynonyms(),
- TuttiEntities.SPECIES_BY_NAME_COMPARATOR);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- // update comboboxes
- getUI().getBenthosComboBox().addItems(removedSpecies);
- getUI().getSpeciesComboBox().addItems(removedSpecies);
-
- // remove all rows from model
- getModel().getBenthosRow().removeAll(removedRows);
-
- // fire table data changed
- handler.getBenthosTableModel().fireTableDataChanged();
-
- // clear table selection
- handler.getBenthosTable().clearSelection();
-
- // notify user
- sendMessage(_("tutti.flash.info.benthos.remove.from.protocol"));
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,130 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import jaxx.runtime.SwingUtil;
-
-import javax.swing.JTable;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To remove all the selected species rows from protocol.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class RemoveSpeciesProtocolAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
-
- /**
- * Set of removed species.
- *
- * @since 2.8
- */
- protected Set<Species> removedSpecies;
-
- /**
- * Set of removed rows.
- *
- * @since 2.8
- */
- protected Set<EditProtocolSpeciesRowModel> removedRows;
-
- public RemoveSpeciesProtocolAction(EditProtocolUIHandler handler) {
- super(handler, false);
- }
-
- @Override
- public void doAction() throws Exception {
-
- JTable table = handler.getSpeciesTable();
-
- // need to have a selection
- Preconditions.checkState(!table.getSelectionModel().isSelectionEmpty());
-
- EditProtocolSpeciesTableModel tableModel =
- (EditProtocolSpeciesTableModel) table.getModel();
-
- EditProtocolUIModel model = getModel();
-
- removedSpecies = Sets.newHashSet();
- removedRows = Sets.newHashSet();
-
- for (Integer rowIndex : SwingUtil.getSelectedModelRows(table)) {
-
- // get row to remove
- EditProtocolSpeciesRowModel selectedRow =
- tableModel.getEntry(rowIndex);
-
- // re-add all synonym of this taxon to the species / benthos combobox
- Species species = selectedRow.getSpecies();
- removedSpecies.add(species);
-
- Integer taxonId = species.getReferenceTaxonId();
- List<Species> allSynonyms = Lists.newArrayList(
- model.getAllSynonyms(String.valueOf(taxonId)));
- allSynonyms.remove(species);
- model.getAllSynonyms().addAll(allSynonyms);
-
- // mark row to be removed at the very last moment
- removedRows.add(selectedRow);
- }
-
- // reorder the list by name, otherwise,
- // all the species without a reftax code will be at the end
- Collections.sort(model.getAllSynonyms(), TuttiEntities.SPECIES_BY_NAME_COMPARATOR);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- // update comboboxes
- getUI().getBenthosComboBox().addItems(removedSpecies);
- getUI().getSpeciesComboBox().addItems(removedSpecies);
-
- // remove all rows from model
- getModel().getSpeciesRow().removeAll(removedRows);
-
- // fire table data changed
- handler.getSpeciesTableModel().fireTableDataChanged();
-
- // clear table selection
- handler.getSpeciesTable().clearSelection();
-
- // notify user
- sendMessage(_("tutti.flash.info.species.remove.from.protocol"));
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SaveProtocolAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SaveProtocolAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SaveProtocolAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,119 +0,0 @@
-
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Saves a protocol
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.0
- */
-public class SaveProtocolAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(SaveProtocolAction.class);
-
- public SaveProtocolAction(EditProtocolUIHandler handler) {
- super(handler, true);
- }
-
- /**
- * If the event source is a TuttiScreen, then the screen changes to the source.
- * Otherwise, the screen changes to the home.
- */
- @Override
- public void doAction() throws Exception {
- EditProtocolUIModel model = getModel();
- TuttiUIContext context = getContext();
-
- PersistenceService persistenceService = context.getPersistenceService();
-
- TuttiProtocol bean = model.toBean();
-
- // get the species protocols from the table
- List<SpeciesProtocol> speciesProtocols = Lists.newArrayList();
-
- for (EditProtocolSpeciesRowModel row : model.getSpeciesRow()) {
- if (row.isValid()) {
- SpeciesProtocol protocol = row.toBean();
- speciesProtocols.add(protocol);
- }
- }
- bean.setSpecies(speciesProtocols);
-
- List<SpeciesProtocol> benthosProtocols = Lists.newArrayList();
-
- for (EditProtocolSpeciesRowModel row : model.getBenthosRow()) {
- if (row.isValid()) {
- SpeciesProtocol protocol = row.toBean();
- benthosProtocols.add(protocol);
- }
- }
- bean.setBenthos(benthosProtocols);
-
- if (log.isDebugEnabled()) {
- log.debug("protocol id to save: " + bean.getId());
- }
-
- TuttiProtocol saved;
-
- if (TuttiEntities.isNew(bean)) {
-
- saved = persistenceService.createProtocol(bean);
- model.setId(saved.getId());
- sendMessage(_("tutti.flash.info.protocolCreated", bean.getName()));
- } else {
- saved = persistenceService.saveProtocol(bean);
- sendMessage(_("tutti.flash.info.protocolSaved", bean.getName()));
- }
-
- context.setProtocolId(saved.getId());
-
- model.setModify(false);
- }
-
- @Override
- public void postSuccessAction() {
- getContext().getMainUI().getHandler().setBodyTitle(
- EditProtocolUIHandler.getTitle(true));
- getUI().getSaveWarningContainer().setVisible(false);
-
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherBenthosAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherBenthosAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherBenthosAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,91 +0,0 @@
-
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Action to select a benthos which is not in the referent list.
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.1
- */
-public class SelectOtherBenthosAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(SelectOtherBenthosAction.class);
-
- protected Species selectedSpecies;
-
- public SelectOtherBenthosAction(EditProtocolUIHandler handler) {
- super(handler, false);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
- if (result) {
- EditProtocolUIModel model = getModel();
-
- List<Species> species = Lists.newArrayList(model.getAllSynonyms());
-
- selectedSpecies = getHandler().openSelectOtherSpeciesDialog(
- _("tutti.selectBenthos.title"), species);
-
- if (log.isInfoEnabled()) {
- log.info("SelectedBenthos: " + selectedSpecies);
- }
- result = selectedSpecies != null;
- }
- return result;
- }
-
- @Override
- public void releaseAction() {
- selectedSpecies = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- String decoratedSynonym = decorate(selectedSpecies);
- String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId());
- selectedSpecies = getModel().getAllReferentSpeciesByTaxonId().get(taxonId);
- String decoratedReferent = decorate(selectedSpecies);
- sendMessage(_("tutti.flash.info.benthos.replaced", decoratedSynonym, decoratedReferent));
- getUI().getBenthosComboBox().setSelectedItem(selectedSpecies);
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherSpeciesAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherSpeciesAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherSpeciesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,91 +0,0 @@
-
-package fr.ifremer.tutti.ui.swing.content.protocol;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Action to select a species which is not in the referent list.
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.1
- */
-public class SelectOtherSpeciesAction extends AbstractTuttiAction<EditProtocolUIModel, EditProtocolUI, EditProtocolUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(SelectOtherSpeciesAction.class);
-
- protected Species selectedSpecies;
-
- public SelectOtherSpeciesAction(EditProtocolUIHandler handler) {
- super(handler, false);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean result = super.prepareAction();
- if (result) {
- EditProtocolUIModel model = getModel();
-
- List<Species> species = Lists.newArrayList(model.getAllSynonyms());
-
- selectedSpecies = getHandler().openSelectOtherSpeciesDialog(
- _("tutti.selectSpecies.title"), species);
-
- if (log.isInfoEnabled()) {
- log.info("SelectedSpecies: " + selectedSpecies);
- }
- result = selectedSpecies != null;
- }
- return result;
- }
-
- @Override
- public void releaseAction() {
- selectedSpecies = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- String decoratedSynonym = decorate(selectedSpecies);
- String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId());
- selectedSpecies = getModel().getAllReferentSpeciesByTaxonId().get(taxonId);
- String decoratedReferent = decorate(selectedSpecies);
- sendMessage(_("tutti.flash.info.species.replaced", decoratedSynonym, decoratedReferent));
- getUI().getSpeciesComboBox().setSelectedItem(selectedSpecies);
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryGearExampleAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryGearExampleAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryGearExampleAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,101 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.referential;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Export an example file of temporary gears referential.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ExportTemporaryGearExampleAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ExportTemporaryGearExampleAction.class);
-
- private File file;
-
- public ExportTemporaryGearExampleAction(ManageTemporaryReferentialUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to export
- file = saveFile(
- "exportGearExample",
- "csv",
- _("tutti.manageTemporaryReferential.title.choose.exportTemporaryGearExampleFile"),
- _("tutti.manageTemporaryReferential.action.chooseReferentialGearFile.export"),
- "^.*\\.csv", _("tutti.common.file.csv")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will export example gears temporary " +
- "referential to file: " + file);
- }
-
- ReferentialImportExportService service =
- getContext().getTuttiReferentialImportExportService();
- service.exportTemporaryGearExample(file);
-
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialGearFile.export.success", file));
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryPersonExampleAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryPersonExampleAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryPersonExampleAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,102 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.referential;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Export an example file of temporary person referential.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ExportTemporaryPersonExampleAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
-
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ExportTemporaryPersonExampleAction.class);
-
- private File file;
-
- public ExportTemporaryPersonExampleAction(ManageTemporaryReferentialUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to export
- file = saveFile(
- "exportPersonExample",
- "csv",
- _("tutti.manageTemporaryReferential.title.choose.exportTemporaryPersonExampleFile"),
- _("tutti.manageTemporaryReferential.action.chooseReferentialPersonFile.export"),
- "^.*\\.csv", _("tutti.common.file.csv")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will export example persons temporary " +
- "referential to file: " + file);
- }
-
- ReferentialImportExportService service =
- getContext().getTuttiReferentialImportExportService();
-
- service.exportTemporaryPersonExample(file);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialPersonFile.export.success", file));
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporarySpeciesExampleAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporarySpeciesExampleAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporarySpeciesExampleAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,101 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.referential;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Export an example file of temporary species referential.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ExportTemporarySpeciesExampleAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ExportTemporarySpeciesExampleAction.class);
-
- private File file;
-
- public ExportTemporarySpeciesExampleAction(ManageTemporaryReferentialUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to export
- file = saveFile(
- "exportSpeciesExample",
- "csv",
- _("tutti.manageTemporaryReferential.title.choose.exportTemporarySpeciesExampleFile"),
- _("tutti.manageTemporaryReferential.action.chooseReferentialSpeciesFile.export"),
- "^.*\\.csv", _("tutti.common.file.csv")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will export example species temporary " +
- "referential to file: " + file);
- }
-
- ReferentialImportExportService service =
- getContext().getTuttiReferentialImportExportService();
-
- service.exportTemporarySpeciesExample(file);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialSpeciesFile.export.success", file));
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryVesselExampleAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryVesselExampleAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryVesselExampleAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,101 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.referential;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Export an example file of temporary species referential.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ExportTemporaryVesselExampleAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ExportTemporaryVesselExampleAction.class);
-
- private File file;
-
- public ExportTemporaryVesselExampleAction(ManageTemporaryReferentialUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to export
- file = saveFile(
- "exportVesselExample",
- "csv",
- _("tutti.manageTemporaryReferential.title.choose.exportTemporaryVesselExampleFile"),
- _("tutti.manageTemporaryReferential.action.chooseReferentialVesselFile.export"),
- "^.*\\.csv", _("tutti.common.file.csv")
- );
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will export example vessels temporary " +
- "referential to file: " + file);
- }
-
- ReferentialImportExportService service =
- getContext().getTuttiReferentialImportExportService();
-
- service.exportTemporaryVesselExample(file);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialVesselFile.export.success", file));
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryGearAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryGearAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryGearAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,104 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.referential;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Import temporary gear referential.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ImportTemporaryGearAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ImportTemporaryGearAction.class);
-
- private File file;
-
- public ImportTemporaryGearAction(ManageTemporaryReferentialUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to import
- file = chooseFile(
- _("tutti.manageTemporaryReferential.title.choose.importTemporaryGearFile"),
- _("tutti.manageTemporaryReferential.action.chooseReferentialGearFile.import"),
- "^.*\\.csv", _("tutti.common.file.csv"));
-
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will import gear temporary " +
- "referential from file: " + file);
- }
-
- ReferentialImportExportService service =
- getContext().getTuttiReferentialImportExportService();
-
- service.importTemporaryGear(file);
-
- // reset ui cache
- getDataContext().resetGears();
-
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialGearFile.import.success", file));
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryPersonAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryPersonAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryPersonAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,103 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.referential;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Import temporary person referential.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ImportTemporaryPersonAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ImportTemporaryPersonAction.class);
-
- private File file;
-
- public ImportTemporaryPersonAction(ManageTemporaryReferentialUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // choose file to import
- file = chooseFile(
- _("tutti.manageTemporaryReferential.title.choose.importTemporaryPersonFile"),
- _("tutti.manageTemporaryReferential.action.chooseReferentialPersonFile.import"),
- "^.*\\.csv", _("tutti.common.file.csv"));
-
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will import person temporary " +
- "referential from file: " + file);
- }
-
- ReferentialImportExportService service =
- getContext().getTuttiReferentialImportExportService();
-
- service.importTemporaryPerson(file);
-
- // reset ui cache
- getDataContext().resetPersons();
-
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialPersonFile.import.success", file));
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporarySpeciesAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporarySpeciesAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporarySpeciesAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,102 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.referential;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Import temporary species referential.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ImportTemporarySpeciesAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ImportTemporarySpeciesAction.class);
-
- private File file;
-
- public ImportTemporarySpeciesAction(ManageTemporaryReferentialUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
- // choose file to import
- file = chooseFile(
- _("tutti.manageTemporaryReferential.title.choose.importTemporarySpeciesFile"),
- _("tutti.manageTemporaryReferential.action.chooseReferentialSpeciesFile.import"),
- "^.*\\.csv", _("tutti.common.file.csv"));
-
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will import species temporary " +
- "referential from file: " + file);
- }
-
- ReferentialImportExportService service =
- getContext().getTuttiReferentialImportExportService();
-
- service.importTemporarySpecies(file);
-
- // reset ui cache
- getDataContext().resetSpecies();
-
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialSpeciesFile.import.success", file));
- }
-}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryVesselAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryVesselAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryVesselAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,102 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.referential;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.service.referential.ReferentialImportExportService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Import temporary vessel referential.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ImportTemporaryVesselAction extends AbstractTuttiAction<TuttiUIContext, ManageTemporaryReferentialUI, ManageTemporaryReferentialUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(ImportTemporaryVesselAction.class);
-
- private File file;
-
- public ImportTemporaryVesselAction(ManageTemporaryReferentialUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
-
- boolean doAction = super.prepareAction();
-
- if (doAction) {
- // choose file to import
- file = chooseFile(
- _("tutti.manageTemporaryReferential.title.choose.importTemporaryVesselFile"),
- _("tutti.manageTemporaryReferential.action.chooseReferentialVesselFile.import"),
- "^.*\\.csv", _("tutti.common.file.csv"));
-
- doAction = file != null;
- }
- return doAction;
- }
-
- @Override
- public void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkNotNull(file);
- if (log.isInfoEnabled()) {
- log.info("Will import vessel temporary " +
- "referential from file: " + file);
- }
-
- ReferentialImportExportService service =
- getContext().getTuttiReferentialImportExportService();
-
- service.importTemporaryVessel(file);
-
- // reset ui cache
- getDataContext().resetVessels();
-
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
- sendMessage(_("tutti.manageTemporaryReferential.action.chooseReferentialVesselFile.import.success", file));
- }
-}
\ No newline at end of file
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ManageTemporaryReferentialUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ManageTemporaryReferentialUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ManageTemporaryReferentialUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -40,7 +40,7 @@
#exportSpeciesExampleButton {
actionIcon: export;
text: "tutti.manageTemporaryReferential.action.exportTemporarySpeciesExample";
- _applicationAction: {ExportTemporarySpeciesExampleAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportTemporarySpeciesExampleAction.class};
toolTipText: "tutti.manageTemporaryReferential.action.exportTemporarySpeciesExample.tip";
_help: {"tutti.manageTemporaryReferential.action.exportTemporarySpeciesExample.help"};
}
@@ -48,7 +48,7 @@
#importSpeciesButton {
actionIcon: import;
text: "tutti.manageTemporaryReferential.action.importTemporarySpecies";
- _applicationAction: {ImportTemporarySpeciesAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportTemporarySpeciesAction.class};
toolTipText: "tutti.manageTemporaryReferential.action.importTemporarySpecies.tip";
_help: {"tutti.manageTemporaryReferential.action.importTemporarySpecies.help"};
}
@@ -62,7 +62,7 @@
#exportVesselExampleButton {
actionIcon: export;
text: "tutti.manageTemporaryReferential.action.exportTemporaryVesselExample";
- _applicationAction: {ExportTemporaryVesselExampleAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportTemporaryVesselExampleAction.class};
toolTipText: "tutti.manageTemporaryReferential.action.exportTemporaryVesselExample.tip";
_help: {"tutti.manageTemporaryReferential.action.exportTemporaryVesselExample.help"};
}
@@ -70,7 +70,7 @@
#importVesselButton {
actionIcon: import;
text: "tutti.manageTemporaryReferential.action.importTemporaryVessel";
- _applicationAction: {ImportTemporaryVesselAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportTemporaryVesselAction.class};
toolTipText: "tutti.manageTemporaryReferential.action.importTemporaryVessel.tip";
_help: {"tutti.manageTemporaryReferential.action.importTemporaryVessel.help"};
}
@@ -84,7 +84,7 @@
#exportGearExampleButton {
actionIcon: export;
text: "tutti.manageTemporaryReferential.action.exportTemporaryGearExample";
- _applicationAction: {ExportTemporaryGearExampleAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportTemporaryGearExampleAction.class};
toolTipText: "tutti.manageTemporaryReferential.action.exportTemporaryGearExample.tip";
_help: {"tutti.manageTemporaryReferential.action.exportTemporaryGearExample.help"};
}
@@ -92,7 +92,7 @@
#importGearButton {
actionIcon: import;
text: "tutti.manageTemporaryReferential.action.importTemporaryGear";
- _applicationAction: {ImportTemporaryGearAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportTemporaryGearAction.class};
toolTipText: "tutti.manageTemporaryReferential.action.importTemporaryGear.tip";
_help: {"tutti.manageTemporaryReferential.action.importTemporaryGear.help"};
}
@@ -106,7 +106,7 @@
#exportPersonExampleButton {
actionIcon: export;
text: "tutti.manageTemporaryReferential.action.exportTemporaryPersonExample";
- _applicationAction: {ExportTemporaryPersonExampleAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ExportTemporaryPersonExampleAction.class};
toolTipText: "tutti.manageTemporaryReferential.action.exportTemporaryPersonExample.tip";
_help: {"tutti.manageTemporaryReferential.action.exportTemporaryPersonExample.help"};
}
@@ -114,7 +114,7 @@
#importPersonButton {
actionIcon: import;
text: "tutti.manageTemporaryReferential.action.importTemporaryPerson";
- _applicationAction: {ImportTemporaryPersonAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportTemporaryPersonAction.class};
toolTipText: "tutti.manageTemporaryReferential.action.importTemporaryPerson.tip";
_help: {"tutti.manageTemporaryReferential.action.importTemporaryPerson.help"};
}
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/report/GenerateReportAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/report/GenerateReportAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/report/GenerateReportAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,73 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.report;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.service.report.ReportModel;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To generate the selected report.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.9
- */
-public class GenerateReportAction extends AbstractTuttiAction<ReportUIModel, ReportUI, ReportUIHandler> {
-
- public GenerateReportAction(ReportUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- public boolean prepareAction() throws Exception {
- boolean doAction = super.prepareAction();
-
- if (doAction) {
-
- // ask user to confirm overwrite if required
- doAction = askOverwriteFile(getModel().getOutputFile());
- }
- return doAction;
- }
-
- @Override
- public void doAction() throws Exception {
- Preconditions.checkState(getModel().isValid());
-
- ReportModel reportModel = getModel().toBean();
- getContext().getReportService().generateReport(reportModel);
- }
-
- @Override
- public void postSuccessAction() {
- super.postSuccessAction();
-
- sendMessage(_("tutti.report.generated", getModel().getOutputFile()));
-
- getModel().reloadOuputFile();
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/report/ReportUI.css
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/report/ReportUI.css 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/report/ReportUI.css 2013-11-26 08:03:42 UTC (rev 1388)
@@ -93,7 +93,7 @@
text: "tutti.report.action.cancel";
toolTipText: "tutti.report.action.cancel.tip";
i18nMnemonic: "tutti.report.action.cancel.mnemonic";
- _applicationAction: {GoToPreviousScreenAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.GoToPreviousScreenAction.class};
_help: {"tutti.report.action.cancel.help"};
}
@@ -102,7 +102,7 @@
text: "tutti.report.action.generate";
toolTipText: "tutti.report.action.generate.tip";
i18nMnemonic: "tutti.report.action.generate.mnemonic";
- _applicationAction: {GenerateReportAction.class};
+ _applicationAction: {fr.ifremer.tutti.ui.swing.action.GenerateReportAction.class};
enabled: {model.isValid()};
_help: {"tutti.report.action.generate.help"};
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/report/ReportUI.jaxx
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/report/ReportUI.jaxx 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/report/ReportUI.jaxx 2013-11-26 08:03:42 UTC (rev 1388)
@@ -26,7 +26,6 @@
<import>
fr.ifremer.tutti.ui.swing.TuttiHelpBroker
- fr.ifremer.tutti.ui.swing.content.GoToPreviousScreenAction
fr.ifremer.tutti.ui.swing.util.TuttiUI
jaxx.runtime.swing.editor.FileEditor
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiBeanUIModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiBeanUIModel.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiBeanUIModel.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -24,7 +24,7 @@
* #L%
*/
-import fr.ifremer.tutti.PropagatePropertyChangeListener;
+import fr.ifremer.shared.application.listener.PropagatePropertyChangeListener;
import fr.ifremer.tutti.persistence.entities.TuttiEntity;
import org.jdesktop.beans.AbstractSerializableBean;
import org.nuiton.util.CollectionUtil;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiTabContainerUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiTabContainerUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiTabContainerUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -25,12 +25,12 @@
* #L%
*/
+import fr.ifremer.shared.application.swing.tab.DelegateTabContainerHandler;
+import fr.ifremer.shared.application.swing.tab.TabContainerHandler;
+import fr.ifremer.shared.application.swing.tab.TabContentModel;
+import fr.ifremer.shared.application.swing.tab.TabHandler;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import javax.swing.DefaultSingleSelectionModel;
-import javax.swing.JTabbedPane;
-import java.awt.Component;
-
/**
* UI containing a tab panel.
*
@@ -38,40 +38,15 @@
* @author kmorin <kmorin(a)codelutin.com>
* @since 0.3
*/
-public abstract class AbstractTuttiTabContainerUIHandler<M, UI extends TuttiUI<M, ?>> extends AbstractTuttiUIHandler<M, UI> {
+public abstract class AbstractTuttiTabContainerUIHandler<M, UI extends TuttiUI<M, ?>> extends AbstractTuttiUIHandler<M, UI> implements TabContainerHandler {
+ DelegateTabContainerHandler delegateTabHandler;
+
protected AbstractTuttiTabContainerUIHandler(TuttiUIContext context, UI ui) {
super(context, ui);
}
- /** @return the tab panel of the UI */
- protected abstract JTabbedPane getTabPanel();
-
/**
- * Method called when the user selects a tab.
- *
- * @param currentIndex
- * @param newIndex
- * @return <code>false</code> if you want to prevent the tab change,
- * <code>true</code> otherwise
- */
- protected boolean onTabChanged(int currentIndex, int newIndex) {
- boolean result = true;
- if (currentIndex != newIndex) {
- TabHandler handler = getTabHandler(currentIndex);
- if (handler != null) {
- result = handler.onHideTab(currentIndex, newIndex);
- }
-
- handler = getTabHandler(newIndex);
- if (handler != null) {
- handler.onShowTab(currentIndex, newIndex);
- }
- }
- return result;
- }
-
- /**
* Returns the tab handler of the tab i.
*
* @param index the index of the tab
@@ -79,49 +54,31 @@
* the {@link TabHandler} interface,
* <code>null</code> otherwise
*/
- protected TabHandler getTabHandler(int index) {
- TabHandler tabHandler = null;
- JTabbedPane tabPanel = getTabPanel();
- if (index >= 0 && index < tabPanel.getTabCount()) {
- Component tab = tabPanel.getComponentAt(index);
- if (TuttiUI.class.isInstance(tab)) {
- TuttiUI tuttiTab = (TuttiUI) tabPanel.getComponentAt(index);
- AbstractTuttiUIHandler handler = tuttiTab.getHandler();
- if (TabHandler.class.isInstance(handler)) {
- tabHandler = (TabHandler) handler;
- }
- }
- }
+ @Override
+ public TabHandler getTabHandler(int index) {
+ TabHandler tabHandler = delegateTabHandler.getTabHandler(index);
return tabHandler;
}
@Override
+ public void setCustomTab(int index, TabContentModel model) {
+ delegateTabHandler.setCustomTab(index, model);
+ }
+
+ @Override
protected void initUI(UI ui) {
super.initUI(ui);
+ delegateTabHandler = new DelegateTabContainerHandler(getTabPanel());
+ delegateTabHandler.init();
+ }
- final JTabbedPane tabPanel = getTabPanel();
- tabPanel.setModel(new DefaultSingleSelectionModel() {
-
- @Override
- public void setSelectedIndex(int index) {
- int currentIndex = tabPanel.getSelectedIndex();
- boolean mustChangeTab = onTabChanged(currentIndex, index);
-
- if (mustChangeTab) {
- super.setSelectedIndex(index);
- }
- }
-
- });
+ @Override
+ public void init() {
+ delegateTabHandler.init();
}
- /**
- * Sets a {@link CustomTab} as tab component.
- *
- * @param index
- * @param model
- */
- protected void setCustomTab(int index, TabContentModel model) {
- getTabPanel().setTabComponentAt(index, new CustomTab(model));
+ @Override
+ public boolean onTabChanged(int currentIndex, int newIndex) {
+ return delegateTabHandler.onTabChanged(currentIndex, newIndex);
}
}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -29,8 +29,6 @@
import fr.ifremer.shared.application.swing.AbstractApplicationUIHandler;
import fr.ifremer.shared.application.swing.action.ApplicationActionUI;
import fr.ifremer.shared.application.swing.table.AbstractApplicationTableModel;
-import fr.ifremer.shared.application.type.ApplicationProgressionModel;
-import fr.ifremer.shared.application.type.WeightUnit;
import fr.ifremer.tutti.LabelAware;
import fr.ifremer.tutti.TuttiConfiguration;
import fr.ifremer.tutti.persistence.entities.data.SampleCategory;
@@ -41,10 +39,6 @@
import fr.ifremer.tutti.ui.swing.content.MainUI;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
import fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachment;
-import fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor;
-import jaxx.runtime.JAXXUtil;
-import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.editor.NumberEditor;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -56,23 +50,11 @@
import org.nuiton.decorator.Decorator;
import org.nuiton.validator.bean.simple.SimpleBeanValidator;
-import javax.swing.AbstractAction;
-import javax.swing.JComponent;
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-import javax.swing.JRootPane;
import javax.swing.JTextField;
-import javax.swing.KeyStroke;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import java.awt.Component;
-import java.awt.Dialog;
-import java.awt.Dimension;
import java.awt.Font;
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Set;
@@ -83,61 +65,26 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
-public abstract class AbstractTuttiUIHandler<M, UI extends TuttiUI<M, ?>> extends fr.ifremer.shared.application.swing.AbstractApplicationUIHandler<M, UI> implements UIMessageNotifier {
+public abstract class AbstractTuttiUIHandler<M, UI extends TuttiUI<M, ?>> extends AbstractApplicationUIHandler<M, UI> implements UIMessageNotifier {
/** Logger. */
private static final Log log =
LogFactory.getLog(AbstractTuttiUIHandler.class);
-// public abstract void beforeInitUI();
-//
-// public abstract void afterInitUI();
-//
-// public abstract void onCloseUI();
-//
-// public abstract SwingValidator<M> getValidator();
-
-// /**
-// * Global application context.
-// *
-// * @since 0.1
-// */
-// protected final TuttiUIContext context;
-//
-// /**
-// * UI handled.
-// *
-// * @since 0.1
-// */
-// protected final UI ui;
-
protected AbstractTuttiUIHandler(TuttiUIContext context, UI ui) {
super(context, ui);
-// this.context = context;
-// this.ui = ui;
}
//------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
-// public DefaultComboBoxModel newComboModel(Object... items) {
-// return new DefaultComboBoxModel(items);
-// }
-
-// public final M getModel() {
-// return ui.getModel();
-// }
-//
-// public final UI getUI() {
-// return ui;
-// }
-
@Override
public void showInformationMessage(String message) {
getContext().showInformationMessage(message);
}
+ @Override
public TuttiUIContext getContext() {
return (TuttiUIContext) super.getContext();
}
@@ -150,165 +97,7 @@
return getContext().getConfig();
}
-// public void setText(KeyEvent event, String property) {
-// JTextComponent field = (JTextComponent) event.getSource();
-// String value = field.getText();
-// TuttiUIUtil.setProperty(getModel(), property, value);
-// }
-
-// public void setFile(ActionEvent event, String property) {
-// FileEditor field = (FileEditor) event.getSource();
-// File value = field.getSelectedFile();
-// TuttiUIUtil.setProperty(getModel(), property, value);
-// }
-
-// public void setBoolean(ItemEvent event, String property) {
-// boolean value = event.getStateChange() == ItemEvent.SELECTED;
-// TuttiUIUtil.setProperty(getModel(), property, value);
-// }
-
-// public void setDate(ActionEvent event, String property) {
-// JXDatePicker field = (JXDatePicker) event.getSource();
-// Date value = field.getDate();
-// TuttiUIUtil.setProperty(getModel(), property, value);
-// }
-
-// public void selectListData(ListSelectionEvent event, String property) {
-// if (!event.getValueIsAdjusting()) {
-// JList list = (JList) event.getSource();
-// ListSelectionModel selectionModel = list.getSelectionModel();
-//
-// selectionModel.setValueIsAdjusting(true);
-// try {
-// List selectedList = Lists.newLinkedList();
-//
-// for (int index : list.getSelectedIndices()) {
-// Object o = list.getModel().getElementAt(index);
-// selectedList.add(o);
-// }
-// TuttiUIUtil.setProperty(getModel(), property, selectedList);
-// } finally {
-// selectionModel.setValueIsAdjusting(false);
-// }
-// }
-// }
-
- public void openDialog(TuttiUI dialogContent,
- String title, Dimension dim) {
- Component topestUI = getTopestUI();
-
- JDialog result;
- if (topestUI instanceof Frame) {
- result = new JDialog((Frame) topestUI, title, true);
- } else {
- result = new JDialog((Dialog) topestUI, title, true);
- }
-
- result.add((Component) dialogContent);
- result.setResizable(true);
-
- result.setSize(dim);
-
- final AbstractApplicationUIHandler handler = dialogContent.getHandler();
-
- if (handler instanceof Cancelable) {
-
- // add a auto-close action
- JRootPane rootPane = result.getRootPane();
-
- KeyStroke shortcutClosePopup = getConfig().getShortcutClosePopup();
-
- rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
- shortcutClosePopup, "close");
- rootPane.getActionMap().put("close", new AbstractAction() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void actionPerformed(ActionEvent e) {
- ((Cancelable) handler).cancel();
- }
- });
- }
-
- result.addWindowListener(new WindowAdapter() {
-
- @Override
- public void windowClosed(WindowEvent e) {
- Component ui = (Component) e.getSource();
- if (log.isDebugEnabled()) {
- log.debug("Destroy ui " + ui);
- }
- JAXXUtil.destroy(ui);
- }
- });
- SwingUtil.center(getContext().getMainUI(), result);
- result.setVisible(true);
- }
-
- public void closeDialog(TuttiUI ui) {
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
- }
-
- public static final String CONFIRMATION_FORMAT = "<html>%s<hr/><br/>%s</html>";
-
-// public int askSaveBeforeLeaving(String message) {
-// String htmlMessage = String.format(
-// CONFIRMATION_FORMAT,
-// message,
-// _("tutti.common.askSaveBeforeLeaving.help"));
-// int result = JOptionPane.showConfirmDialog(
-// getTopestUI(),
-// htmlMessage,
-// _("tutti.common.askSaveBeforeLeaving.title"),
-// JOptionPane.YES_NO_CANCEL_OPTION,
-// JOptionPane.QUESTION_MESSAGE);
-// return result;
-// }
-
-// public boolean askCancelEditBeforeLeaving(String message) {
-// String htmlMessage = String.format(
-// CONFIRMATION_FORMAT,
-// message,
-// _("tutti.common.askCancelEditBeforeLeaving.help"));
-// int i = JOptionPane.showConfirmDialog(
-// getTopestUI(),
-// htmlMessage,
-// _("tutti.common.askCancelEditBeforeLeaving.title"),
-// JOptionPane.OK_CANCEL_OPTION,
-// JOptionPane.QUESTION_MESSAGE);
-//
-// boolean result = i == JOptionPane.OK_OPTION;
-// return result;
-// }
-
-// public void showSuccessMessage(String title, String message) {
-//
-// Component topestUI = getTopestUI();
-// boolean alwaysOnTop = false;
-//
-// if (topestUI instanceof JDialog) {
-// alwaysOnTop = ((JDialog) topestUI).isAlwaysOnTop();
-// }
-//
-// if (alwaysOnTop) {
-// ((JDialog) topestUI).setAlwaysOnTop(false);
-// }
-// try {
-//
-// JOptionPane.showMessageDialog(
-// topestUI,
-// message,
-// title,
-// JOptionPane.INFORMATION_MESSAGE,
-// UIManager.getIcon("info")
-// );
-// } finally {
-// if (alwaysOnTop) {
-// ((JDialog) topestUI).setAlwaysOnTop(true);
-// }
-// }
-// }
-
+ @Override
public Component getTopestUI() {
Component result;
ApplicationActionUI actionUI = getContext().getActionUI();
@@ -346,81 +135,7 @@
return decorator;
}
-// public void autoSelectRowInTable(MouseEvent e, JPopupMenu popup) {
-//
-// boolean rightClick = SwingUtilities.isRightMouseButton(e);
-//
-// if (rightClick || SwingUtilities.isLeftMouseButton(e)) {
-//
-// // get the coordinates of the mouse click
-// Point p = e.getPoint();
-//
-// JXTable source = (JXTable) e.getSource();
-//
-// int[] selectedRows = source.getSelectedRows();
-// int[] selectedColumns = source.getSelectedColumns();
-//
-// // get the row index at this point
-// int rowIndex = source.rowAtPoint(p);
-//
-// // get the column index at this point
-// int columnIndex = source.columnAtPoint(p);
-//
-// if (log.isDebugEnabled()) {
-// log.debug("At point [" + p + "] found Row " + rowIndex + ", Column " + columnIndex);
-// }
-//
-// boolean canContinue = true;
-//
-// if (source.isEditing()) {
-//
-// // stop editing
-// boolean stopEdit = source.getCellEditor().stopCellEditing();
-// if (!stopEdit) {
-// if (log.isWarnEnabled()) {
-// log.warn("Could not stop edit cell...");
-// }
-// canContinue = false;
-// }
-// }
-//
-// if (canContinue) {
-//
-// // select row (could empty selection)
-// if (rowIndex == -1) {
-// source.clearSelection();
-// } else if (!ArrayUtils.contains(selectedRows, rowIndex)) {
-// if (ListSelectionModel.MULTIPLE_INTERVAL_SELECTION == source.getSelectionMode()) {
-// // add to selection
-// source.addRowSelectionInterval(rowIndex, rowIndex);
-// } else {
-// // set selection
-// source.setRowSelectionInterval(rowIndex, rowIndex);
-// }
-// }
-//
-// // select column (could empty selection)
-// if (columnIndex == -1) {
-// source.clearSelection();
-// } else if (!ArrayUtils.contains(selectedColumns, columnIndex)) {
-// source.setColumnSelectionInterval(columnIndex, columnIndex);
-// }
-//
-// if (rightClick) {
-//
-// // use now model coordinate
-// int modelRowIndex = source.convertRowIndexToModel(rowIndex);
-// int modelColumnIndex = source.convertColumnIndexToModel(columnIndex);
-//
-// beforeOpenPopup(modelRowIndex, modelColumnIndex);
-//
-// // on right click show popup
-// popup.show(source, e.getX(), e.getY());
-// }
-// }
-// }
-// }
-
+ @Override
protected void addHighlighters(final JXTable table) {
HighlightPredicate notSelectedPredicate = new HighlightPredicate.NotHighlightPredicate(HighlightPredicate.IS_SELECTED);
@@ -528,60 +243,10 @@
});
}
-// public void openRowMenu(KeyEvent e, JPopupMenu popup) {
-//
-// if (e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU) {
-//
-// JXTable source = (JXTable) e.getSource();
-//
-// // get the lowest selected row
-// int[] selectedRows = source.getSelectedRows();
-// int lowestRow = -1;
-// for (int row : selectedRows) {
-// lowestRow = Math.max(lowestRow, row);
-// }
-// // get the selected column
-// int selectedColumn = source.getSelectedColumn();
-// Rectangle r = source.getCellRect(lowestRow, selectedColumn, true);
-//
-// // get the point in the middle lower of the cell
-// Point p = new Point(r.x + r.width / 2, r.y + r.height);
-//
-// if (log.isDebugEnabled()) {
-// log.debug("Row " + lowestRow + " found t point [" + p + "]");
-// }
-//
-// boolean canContinue = true;
-//
-// if (source.isEditing()) {
-//
-// // stop editing
-// boolean stopEdit = source.getCellEditor().stopCellEditing();
-// if (!stopEdit) {
-// if (log.isWarnEnabled()) {
-// log.warn("Could not stop edit cell...");
-// }
-// canContinue = false;
-// }
-// }
-//
-// if (canContinue) {
-//
-// // use now model coordinate
-// int rowIndex = source.convertRowIndexToModel(lowestRow);
-// int columnIndex = source.convertColumnIndexToModel(selectedColumn);
-// beforeOpenPopup(rowIndex, columnIndex);
-//
-// popup.show(source, p.x, p.y);
-// }
-// }
-// }
-
//------------------------------------------------------------------------//
//-- Init methods --//
//------------------------------------------------------------------------//
-
@Override
protected void initUIComponent(Object component) {
if (component instanceof ButtonAttachment) {
@@ -592,58 +257,6 @@
}
}
-// protected void initUI(TuttiUI ui) {
-//
-// for (Map.Entry<String, Object> entry : ui.get$objectMap().entrySet()) {
-// Object component = entry.getValue();
-// if (component instanceof NumberEditor) {
-//
-// initNumberEditor((NumberEditor) component);
-// } else if (component instanceof JXDatePicker) {
-//
-// initDatePicker((JXDatePicker) component);
-// } else if (component instanceof SimpleTimeEditor) {
-//
-// initTimeEditor((SimpleTimeEditor) component);
-// } else if (component instanceof ButtonAttachment) {
-//
-// initButtonAttachment((ButtonAttachment) component);
-// } else if (component instanceof JLabel) {
-//
-// initLabel((JLabel) component);
-// } else if (component instanceof JTextField) {
-//
-// initTextField((JTextField) component);
-// } else if (component instanceof AbstractButton) {
-//
-// initButton((AbstractButton) component);
-// } else if (component instanceof JScrollPane) {
-//
-// initScrollPane((JScrollPane) component);
-// } else if (component instanceof DmsCoordinateEditor) {
-//
-// initCoordinateDMSEditor((DmsCoordinateEditor) component);
-// } else if (component instanceof DmdCoordinateEditor) {
-//
-// initCoordinateDMDEditor((DmdCoordinateEditor) component);
-// }
-// }
-//
-// ((Component) ui).addHierarchyListener(new HierarchyListener() {
-// @Override
-// public void hierarchyChanged(HierarchyEvent e) {
-// JComponent component = getComponentToFocus();
-// if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) > 0
-// && e.getChanged().isShowing()
-// && component != null) {
-// component.requestFocus();
-// }
-// }
-// });
-// }
-
-// protected abstract JComponent getComponentToFocus();
-
protected void initTextField(JTextField jTextField) {
super.initTextField(jTextField);
Boolean computed = (Boolean) jTextField.getClientProperty("computed");
@@ -654,323 +267,17 @@
jTextField.setEnabled(false);
jTextField.setDisabledTextColor(getConfig().getColorComputedWeights());
}
-// if (isAutoSelectOnFocus(jTextField)) {
-// addAutoSelectOnFocus(jTextField);
-// }
}
- protected void initLabel(JLabel jLabel) {
- super.initLabel(jLabel);
-// Boolean strongStyle = (Boolean) jLabel.getClientProperty("strongStyle");
-// Boolean italicStyle = (Boolean) jLabel.getClientProperty("italicStyle");
-// Font font = jLabel.getFont();
-// int style = font.getStyle();
-// if (strongStyle != null && strongStyle) {
-// style |= Font.BOLD;
-// }
-// if (italicStyle != null && italicStyle) {
-// style |= Font.ITALIC;
-// }
-// jLabel.setFont(font.deriveFont(style));
-
- WeightUnit weightUnit = (WeightUnit) jLabel.getClientProperty("addWeightUnit");
- if (weightUnit != null) {
- String text = weightUnit.decorateLabel(jLabel.getText());
- jLabel.setText(text);
-
- String tip = weightUnit.decorateTip(jLabel.getToolTipText());
- jLabel.setToolTipText(tip);
-
- Component labelFor = jLabel.getLabelFor();
- if (labelFor instanceof TuttiComputedOrNotDataEditor) {
-
- // set also the number of digits (4 for kg, 1 for g)
- TuttiComputedOrNotDataEditor editor = (TuttiComputedOrNotDataEditor) labelFor;
- editor.setNumberPattern(weightUnit.getNumberEditorPattern());
- editor.setDecimalNumber(weightUnit.getNumberDigits());
- } else if (labelFor instanceof NumberEditor) {
-
- // set also the number of digits (4 for kg, 1 for g)
- NumberEditor editor = (NumberEditor) labelFor;
- editor.setNumberPattern(weightUnit.getNumberEditorPattern());
- }
- }
- }
-
protected void initButtonAttachment(ButtonAttachment component) {
component.init();
}
-// protected void initButton(AbstractButton abstractButton) {
-//
-// Class actionName = (Class) abstractButton.getClientProperty("tuttiAction");
-// if (actionName != null) {
-// Action action = TuttiActionHelper.createUIAction(this, abstractButton, actionName);
-// abstractButton.setAction(action);
-// }
-// }
-//
-// /**
-// * Prépare un component de choix d'entités pour un type d'entité donné et
-// * pour un service de persistance donné.
-// *
-// * @param comboBox le component graphique à initialiser
-// */
-// protected <E extends Serializable> void initBeanFilterableComboBox(
-// BeanFilterableComboBox<E> comboBox,
-// List<E> data,
-// E selectedData) {
-//
-// initBeanFilterableComboBox(comboBox, data, selectedData, null);
-// }
-//
-// protected <E extends Serializable> void initBeanFilterableComboBox(
-// BeanFilterableComboBox<E> comboBox,
-// List<E> data,
-// E selectedData,
-// String decoratorContext) {
-//
-// Preconditions.checkNotNull(comboBox, "No comboBox!");
-//
-// Class<E> beanType = comboBox.getBeanType();
-//
-// Preconditions.checkNotNull(beanType, "No beanType on the combobox!");
-//
-// Decorator<E> decorator = getDecorator(beanType, decoratorContext);
-//
-// if (data == null) {
-// data = Lists.newArrayList();
-// }
-//
-// if (log.isDebugEnabled()) {
-// log.debug("entity comboBox list [" + beanType.getName() + "] : " +
-// (data == null ? 0 : data.size()));
-// }
-//
-// comboBox.setI18nPrefix("tutti.property.");
-//
-// // add data list to combo box
-// comboBox.init((JXPathDecorator<E>) decorator, data);
-//
-// comboBox.setSelectedItem(selectedData);
-//
-// if (log.isDebugEnabled()) {
-// log.debug("combo [" + beanType.getName() + "] : " +
-// comboBox.getData().size());
-// }
-// }
-
-// /**
-// * Prépare un component de choix d'entités pour un type d'entité donné et
-// * pour un service de persistance donné.
-// *
-// * @param list le component graphique à initialiser
-// * @param data la liste des données à mettre dans la liste de gauche
-// * @param selectedData la liste des données à mettre dans la liste de droite
-// */
-// protected <E extends Serializable> void initBeanList(
-// BeanDoubleList<E> list,
-// List<E> data,
-// List<E> selectedData,
-// Decorator<E> selectedDecorator) {
-//
-// Preconditions.checkNotNull(list, "No list!");
-//
-// Class<E> beanType = list.getBeanType();
-// Preconditions.checkNotNull(beanType, "No beanType on the double list!");
-//
-// Decorator<E> decorator = getDecorator(beanType, null);
-//
-// if (log.isDebugEnabled()) {
-// log.debug("entity list [" + beanType.getName() + "] : " +
-// (data == null ? 0 : data.size()));
-// }
-//
-// list.setI18nPrefix("tutti.property.");
-//
-// // add data list to combo box
-// list.init((JXPathDecorator<E>) decorator,
-// (JXPathDecorator<E>) selectedDecorator,
-// data,
-// selectedData);
-//
-// if (log.isDebugEnabled()) {
-// log.debug("Jlist [" + beanType.getName() + "] : " +
-// list.getUniverseList().getModel().getSize());
-// }
-// }
-
-// /**
-// * Prépare un component de choix d'entités pour un type d'entité donné et
-// * pour un service de persistance donné.
-// *
-// * @param list le component graphique à initialiser
-// * @param data la liste des données à mettre dans la liste de gauche
-// * @param selectedData la liste des données à mettre dans la liste de droite
-// */
-// protected <E extends Serializable> void initBeanList(
-// BeanDoubleList<E> list,
-// List<E> data,
-// List<E> selectedData) {
-//
-// initBeanList(list, data, selectedData, null);
-// }
-
-// protected void initNumberEditor(NumberEditor editor) {
-// if (log.isDebugEnabled()) {
-// log.debug("init number editor " + editor.getName());
-// }
-// editor.init();
-//
-// // Force binding if value is already in model
-// Number model = editor.getModel();
-// if (model != null) {
-// editor.setModel(null);
-// editor.setModel(model);
-// }
-//
-// if (isAutoSelectOnFocus(editor)) {
-//
-// addAutoSelectOnFocus(editor.getTextField());
-// }
-// }
-
-// protected void initTimeEditor(SimpleTimeEditor editor) {
-// if (log.isDebugEnabled()) {
-// log.debug("init time editor " + editor.getName() +
-// " for property " + editor.getModel().getProperty());
-// }
-// editor.init();
-//
-// if (isAutoSelectOnFocus(editor)) {
-// addAutoSelectOnFocus(((JSpinner.DefaultEditor) editor.getHour().getEditor()).getTextField());
-// addAutoSelectOnFocus(((JSpinner.DefaultEditor) editor.getMinute().getEditor()).getTextField());
-// }
-// }
-
-// protected void initCoordinateDMSEditor(DmsCoordinateEditor editor) {
-// editor.init();
-// }
-//
-// protected void initCoordinateDMDEditor(DmdCoordinateEditor editor) {
-// editor.init();
-// }
-
-// protected void initDatePicker(final JXDatePicker picker) {
-//
-// if (log.isDebugEnabled()) {
-// log.debug("disable JXDatePicker editor" + picker.getName());
-// }
-// String dateFormat = getConfig().getDateFormat();
-// picker.setFormats(dateFormat);
-// picker.setToolTipText(_("tutti.common.datefield.tip", dateFormat));
-// picker.getEditor().addFocusListener(new FocusAdapter() {
-//
-// @Override
-// public void focusLost(FocusEvent e) {
-// try {
-// picker.commitEdit();
-//
-// } catch (ParseException ex) {
-// if (log.isDebugEnabled()) {
-// log.debug("format error", ex);
-// }
-// picker.requestFocus();
-// }
-// }
-// });
-//
-// if (isAutoSelectOnFocus(picker)) {
-// addAutoSelectOnFocus(picker.getEditor());
-// }
-// }
-
-// protected void initScrollPane(JScrollPane scrollPane) {
-// Boolean onlyVerticalScrollable = (Boolean) scrollPane.getClientProperty("onlyVerticalScrollable");
-// if (onlyVerticalScrollable != null && onlyVerticalScrollable) {
-// scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
-// scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
-//
-// final JViewport viewport = scrollPane.getViewport();
-// viewport.addChangeListener(new ChangeListener() {
-// @Override
-// public void stateChanged(ChangeEvent e) {
-// Dimension newDimension = new Dimension(viewport.getExtentSize().width,
-// viewport.getViewSize().height);
-// viewport.setViewSize(newDimension);
-// }
-// });
-// }
-// }
-
-// protected boolean isAutoSelectOnFocus(JComponent comp) {
-// Object selectOnFocus = comp.getClientProperty("selectOnFocus");
-// return selectOnFocus != null && Boolean.valueOf(selectOnFocus.toString());
-// }
-
-// protected void addAutoSelectOnFocus(JTextField jTextField) {
-// jTextField.addFocusListener(new FocusAdapter() {
-// @Override
-// public void focusGained(final FocusEvent e) {
-// SwingUtilities.invokeLater(new Runnable() {
-// @Override
-// public void run() {
-// JTextField source = (JTextField) e.getSource();
-// source.selectAll();
-// }
-// });
-//
-// }
-// });
-// }
-
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
-// protected boolean quitScreen(boolean modelIsValid,
-// boolean modelIsModify,
-// String askGiveUpMessage,
-// String askSaveMessage,
-// Action saveAction) {
-// boolean result;
-//
-// if (!modelIsValid) {
-//
-// // model is not valid
-// // ask user to qui or not
-// result = askCancelEditBeforeLeaving(askGiveUpMessage);
-//
-// } else if (modelIsModify) {
-//
-// // something is modify ask user what to do
-// int answer = askSaveBeforeLeaving(askSaveMessage);
-// switch (answer) {
-// case JOptionPane.YES_OPTION:
-//
-// // ok save
-// saveAction.actionPerformed(null);
-// result = true;
-// break;
-// case JOptionPane.NO_OPTION:
-//
-// // do not save but can still quit the screen (so nothing to do)
-// result = true;
-// break;
-// default:
-// // do not save and stay here (so nothing to do)
-// result = false;
-//
-// }
-// } else {
-//
-// // model is valid and not modify, can safely quit screen
-// result = true;
-// }
-// return result;
-// }
-
protected void registerValidators(SwingValidator... validators) {
MainUI main = getContext().getMainUI();
Preconditions.checkNotNull(
@@ -982,37 +289,6 @@
}
}
-// protected String decorate(Serializable object) {
-// return decorate(object, null);
-// }
-//
-// protected String decorate(Serializable object, String context) {
-// String result = "";
-// if (object != null) {
-// result = getDecorator(object.getClass(), context).toString(object);
-// }
-// return result;
-// }
-//
-// protected <O extends Serializable> ListCellRenderer newListCellRender(Class<O> type) {
-//
-// return newListCellRender(type, null);
-// }
-//
-// protected <O extends Serializable> ListCellRenderer newListCellRender(Class<O> type, String name) {
-//
-// Decorator<O> decorator = getDecorator(type, name);
-// return newListCellRender(decorator);
-// }
-//
-// protected <O> ListCellRenderer newListCellRender(Decorator<O> decorator) {
-//
-// Preconditions.checkNotNull(decorator);
-//
-// ListCellRenderer result = new DecoratorListCellRenderer(decorator);
-// return result;
-// }
-
protected void listenValidatorValid(SimpleBeanValidator validator,
final AbstractTuttiBeanUIModel model) {
validator.addPropertyChangeListener(SimpleBeanValidator.VALID_PROPERTY, new PropertyChangeListener() {
@@ -1067,195 +343,6 @@
ui.getHandler().onCloseUI();
}
-// protected <B> void changeValidatorContext(String newContext,
-// SwingValidator<B> validator) {
-// B bean = validator.getBean();
-// validator.setContext(newContext);
-// validator.setBean(bean);
-// }
-
-// protected <R> TableColumnExt addColumnToModel(TableColumnModel model,
-// TableCellEditor editor,
-// TableCellRenderer renderer,
-// ColumnIdentifier<R> identifier) {
-//
-// return addColumnToModel(model, editor, renderer, identifier, null);
-// }
-
-
-// protected <R> TableColumnExt addColumnToModel(TableColumnModel model,
-// TableCellEditor editor,
-// TableCellRenderer renderer,
-// ColumnIdentifier<R> identifier,
-// WeightUnit weightUnit) {
-//
-// TableColumnExt col = new TableColumnExt(model.getColumnCount());
-// col.setCellEditor(editor);
-// col.setCellRenderer(renderer);
-// String label = _(identifier.getHeaderI18nKey());
-// if (weightUnit != null) {
-// label = weightUnit.decorateLabel(label);
-// }
-// col.setHeaderValue(label);
-// String tip = _(identifier.getHeaderTipI18nKey());
-// if (weightUnit != null) {
-// tip = weightUnit.decorateTip(tip);
-// }
-// col.setToolTipText(tip);
-//
-// col.setIdentifier(identifier);
-// model.addColumn(col);
-// // by default no column is sortable, must specify it
-// col.setSortable(false);
-// return col;
-// }
-
-// protected <R> TableColumnExt addColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier) {
-//
-// return addColumnToModel(model, null, null, identifier, null);
-// }
-
-// protected <R> TableColumnExt addFloatColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier,
-// String numberPattern,
-// JTable table) {
-//
-// NumberCellEditor<Float> editor =
-// JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
-// editor.getNumberEditor().setSelectAllTextOnError(true);
-// editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
-// editor.getNumberEditor().setNumberPattern(numberPattern);
-//
-// TableCellRenderer renderer =
-// newNumberCellRenderer(table.getDefaultRenderer(Number.class));
-//
-// return addColumnToModel(model, editor, renderer, identifier, null);
-// }
-
-// protected <R> TableColumnExt addFloatColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier,
-// WeightUnit weightUnit,
-// JTable table) {
-//
-// Preconditions.checkNotNull(weightUnit);
-// NumberCellEditor<Float> editor =
-// JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
-// editor.getNumberEditor().setSelectAllTextOnError(true);
-// editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
-// editor.getNumberEditor().setNumberPattern(weightUnit.getNumberEditorPattern());
-//
-// TableCellRenderer renderer =
-// newNumberCellRenderer(table.getDefaultRenderer(Number.class));
-//
-// return addColumnToModel(model, editor, renderer, identifier, weightUnit);
-// }
-
-// protected <R> TableColumnExt addIntegerColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier,
-// String numberPattern,
-// JTable table) {
-//
-// NumberCellEditor<Integer> editor =
-// JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, false);
-// editor.getNumberEditor().setSelectAllTextOnError(true);
-// editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
-// editor.getNumberEditor().setNumberPattern(numberPattern);
-//
-// TableCellRenderer renderer = newNumberCellRenderer(table.getDefaultRenderer(Number.class));
-// return addColumnToModel(model, editor, renderer, identifier, null);
-// }
-
-
-// TableCellRenderer newNumberCellRenderer(final TableCellRenderer defaultRenderer) {
-// TableCellRenderer result = new TableCellRenderer() {
-// @Override
-// public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
-// Component result = defaultRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
-// if (result instanceof JLabel) {
-// JLabel jLabel = (JLabel) result;
-// jLabel.setHorizontalTextPosition(SwingConstants.RIGHT);
-//
-// }
-// return result;
-// }
-// };
-// return result;
-// }
-
-
-// protected <R> TableColumnExt addBooleanColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier,
-// JTable table) {
-//
-// return addColumnToModel(model,
-// table.getDefaultEditor(Boolean.class),
-// table.getDefaultRenderer(Boolean.class),
-// identifier,
-// null);
-// }
-
-// protected <R, B> TableColumnExt addComboDataColumnToModel(TableColumnModel model,
-// ColumnIdentifier<R> identifier,
-// Decorator<B> decorator,
-// List<B> data) {
-// JComboBox comboBox = new JComboBox();
-// comboBox.setRenderer(newListCellRender(decorator));
-//
-// List<B> dataToList = Lists.newArrayList(data);
-//
-// // add a null value at first position
-// if (!dataToList.isEmpty() && dataToList.get(0) != null) {
-// dataToList.add(0, null);
-// }
-// SwingUtil.fillComboBox(comboBox, dataToList, null);
-//
-// ObjectToStringConverter converter = BeanUIUtil.newDecoratedObjectToStringConverter(decorator);
-// BeanUIUtil.decorate(comboBox, converter);
-// ComboBoxCellEditor editor = new ComboBoxCellEditor(comboBox);
-//
-// return addColumnToModel(model,
-// editor,
-// newTableCellRender(decorator),
-// identifier,
-// null);
-// }
-
-// protected <O extends Serializable> TableCellRenderer newTableCellRender(Class<O> type) {
-//
-// return newTableCellRender(type, null);
-// }
-
-// protected <O extends Serializable> TableCellRenderer newTableCellRender(Class<O> type, String name) {
-//
-// Decorator<O> decorator = getDecorator(type, name);
-//
-// TableCellRenderer result = newTableCellRender(decorator);
-// return result;
-// }
-
-// protected <O> TableCellRenderer newTableCellRender(Decorator<O> decorator) {
-//
-// Preconditions.checkNotNull(decorator);
-//
-// DecoratorTableCellRenderer result = new DecoratorTableCellRenderer(decorator, true);
-// return result;
-// }
-
-// /**
-// * Hook to prepare popup just before showing it.
-// * <p/>
-// * The right place to update actions accessibility; a quite better design
-// * than trying to update each time something change in the table...
-// *
-// * @param rowIndex selected row index (or lowest selected one)
-// * @param columnIndex selected column index
-// * @since 2.6
-// */
-// protected void beforeOpenPopup(int rowIndex, int columnIndex) {
-//
-// }
-
protected String buildReminderLabelTitle(Species species,
Iterable<SampleCategory<?>> categories,
String prefix,
@@ -1289,14 +376,4 @@
return title.toString();
}
- protected void incrementsMessage(String message) {
-
- ApplicationActionUI actionUI = getContext().getActionUI();
- if (actionUI != null) {
- ApplicationProgressionModel progressionModel = actionUI.getModel().getProgressionModel();
- if (progressionModel != null)
-
- progressionModel.increments(message);
- }
- }
}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/ActionListCellRenderer.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/ActionListCellRenderer.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/ActionListCellRenderer.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,61 +0,0 @@
-package fr.ifremer.tutti.ui.swing.util;
-
-/*
- * #%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 javax.swing.Action;
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.Icon;
-import javax.swing.JButton;
-import javax.swing.JList;
-import javax.swing.border.EmptyBorder;
-import java.awt.Component;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class ActionListCellRenderer extends DefaultListCellRenderer {
-
- private static final long serialVersionUID = 1L;
-
- protected final EmptyBorder border = new EmptyBorder(4, 8, 4, 8);
-
- @Override
- public Component getListCellRendererComponent(JList list,
- Object value,
- int index,
- boolean isSelected,
- boolean cellHasFocus) {
-
- Component result = super.getListCellRendererComponent(
- list, value, index, isSelected, cellHasFocus);
- Action action = ((JButton) value).getAction();
- setIcon((Icon) action.getValue(Action.LARGE_ICON_KEY));
- setText((String) action.getValue(Action.NAME));
- setToolTipText((String) action.getValue(Action.SHORT_DESCRIPTION));
- setBorder(border);
- return result;
- }
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,36 +0,0 @@
-package fr.ifremer.tutti.ui.swing.util;
-
-/*
- * #%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%
- */
-
-/**
- * To cancel contract.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-public interface Cancelable {
-
- void cancel();
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/CustomTab.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/CustomTab.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/CustomTab.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,127 +0,0 @@
-
-package fr.ifremer.tutti.ui.swing.util;
-
-/*
- * #%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 jaxx.runtime.SwingUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.beans.BeanUtil;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.UIManager;
-import java.awt.Color;
-import java.awt.Font;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Custom tab component which adds a * in the end of the title
- * when the content is modified.
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.3
- */
-public class CustomTab extends JPanel {
-
- private static final long serialVersionUID = 1L;
-
- private static final Log log = LogFactory.getLog(CustomTab.class);
-
- protected TabContentModel model;
-
- protected JLabel title = new JLabel();
-
- public TabContentModel getModel() {
- return model;
- }
-
- public CustomTab(TabContentModel model) {
- this.model = model;
- try {
- BeanUtil.addPropertyChangeListener(
- new PropertyChangeListener() {
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- updateTitle();
- }
- }, this.model);
-
- } catch (Exception ex) {
- log.error("Error while adding the listener to the model modifications", ex);
- }
-
- setBackground(null);
-
- updateTitle();
- String actionIcon = model.getIcon();
- if (actionIcon != null) {
- title.setIcon(SwingUtil.createActionIcon(actionIcon));
- }
- add(title);
- }
-
- @Override
- public void setBackground(Color bg) {
- if (bg == null) {
- bg = new Color(0, 0, 0, 0);
- }
- super.setBackground(bg);
- revalidate();
- }
-
- @Override
- public void setForeground(Color fg) {
- super.setForeground(fg);
- if (title != null) {
- title.setForeground(fg);
- }
- }
-
- protected void updateTitle() {
- Font f = UIManager.getDefaults().getFont("Label.font");
- String titleValue = _(model.getTitle());
-
- int style;
- if (model.isModify()) {
- style = Font.BOLD;
- titleValue += "*";
-
- } else if (model.isEmpty()) {
- style = Font.ITALIC;
-
- } else {
- style = Font.PLAIN;
- }
-
- title.setText(titleValue);
- title.setFont(f.deriveFont(style));
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TabContentModel.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TabContentModel.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TabContentModel.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,44 +0,0 @@
-package fr.ifremer.tutti.ui.swing.util;
-
-/*
- * #%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%
- */
-
-/**
- * Interface defining the models of the tab content UIs.
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.2
- */
-public interface TabContentModel {
-
- boolean isEmpty();
-
- boolean isValid();
-
- boolean isModify();
-
- String getTitle();
-
- String getIcon();
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TabHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TabHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TabHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,53 +0,0 @@
-
-package fr.ifremer.tutti.ui.swing.util;
-
-/*
- * #%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%
- */
-
-/**
- * Interface describing UI contained in a tab.
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.3
- */
-public interface TabHandler {
-
- /**
- * Method called when the tab is hidden
- *
- * @param currentIndex
- * @param newIndex
- * @return <code>false</code> to prevent the tab to be hidden,
- * <code>true</code> otherwise.
- */
- boolean onHideTab(int currentIndex, int newIndex);
-
- /**
- * Method called when the tab is shown
- *
- * @param currentIndex
- * @param newIndex
- */
- void onShowTab(int currentIndex, int newIndex);
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,122 +0,0 @@
-package fr.ifremer.tutti.ui.swing.util;
-
-/*
- * #%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.PropagatePropertyChangeListener;
-import org.jdesktop.beans.AbstractSerializableBean;
-
-
-/** @author kmorin <kmorin(a)codelutin.com> */
-public class TuttiComputedOrNotData<N extends Number> extends AbstractSerializableBean {
-
- public static final String PROPERTY_DATA = "data";
-
- public static final String PROPERTY_COMPUTED_DATA = "computedData";
-
- private static final long serialVersionUID = 1L;
-
- protected N data;
-
- protected N computedData;
-
- public TuttiComputedOrNotData() {
- data = null;
- computedData = null;
- }
-
- public TuttiComputedOrNotData(N data, N computedData) {
- this.data = data;
- this.computedData = computedData;
- }
-
- public N getData() {
- return data;
- }
-
- public void setData(N data) {
- Object oldValue = getData();
- this.data = data;
- firePropertyChange(PROPERTY_DATA, oldValue, data);
- }
-
- public N getComputedData() {
- return computedData;
- }
-
- public void setComputedData(N computedData) {
- Object oldValue = getComputedData();
- this.computedData = computedData;
- firePropertyChange(PROPERTY_COMPUTED_DATA, oldValue, computedData);
- }
-
- @Override
- public String toString() {
- String result = null;
- if (data != null) {
- result = data.toString();
- } else if (computedData != null) {
- result = computedData.toString();
- }
- return result;
- }
-
- /**
- * Add a listener to propagate the modification of the
- * {@link #PROPERTY_DATA} property to a given {@code propertyName}.
- *
- * @param propertyName name of the property to fire on given bean
- * @param otherBean bean that will fires
- * @since 1.2
- */
- public void addPropagateListener(String propertyName,
- PropagatePropertyChangeListener.PropagatePropertyChange otherBean) {
-
- PropagatePropertyChangeListener.listenAndPropagate(this,
- otherBean,
- PROPERTY_DATA,
- propertyName);
-
-// PropagatePropertyChangeListener listener = new PropagatePropertyChangeListener(propertyName, otherBean);
-// addPropertyChangeListener(PROPERTY_DATA, listener);
- }
-
-// private static class PropagateProperyChangeListener implements PropertyChangeListener {
-//
-// private String propertyName;
-//
-// private AbstractTuttiBeanUIModel otherBean;
-//
-// public PropagatePropertyChangeLstener(String propertyName,
-// AbstractTuttiBeanUIModel otherBean) {
-// this.propertyName = propertyName;
-// this.otherBean = otherBean;
-// }
-//
-// @Override
-// public void propertyChange(PropertyChangeEvent evt) {
-// otherBean.firePropertyChanged(propertyName, evt.getOldValue(), evt.getNewValue());
-// }
-// }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiExceptionHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiExceptionHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiExceptionHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -27,8 +27,8 @@
import fr.ifremer.shared.application.swing.action.ApplicationActionException;
import fr.ifremer.shared.application.swing.util.ApplicationErrorHelper;
import fr.ifremer.shared.application.swing.util.ApplicationExceptionHandler;
-import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import fr.ifremer.tutti.ui.swing.action.AbstractChangeScreenAction;
+import fr.ifremer.tutti.ui.swing.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -78,143 +78,6 @@
// never instanciate util class
}
-// public static void setProperty(Object bean, String property, Object value) {
-// Preconditions.checkNotNull(bean);
-// Preconditions.checkNotNull(property);
-// try {
-// PropertyUtils.setSimpleProperty(bean, property, value);
-// } catch (Exception e) {
-// throw new TuttiTechnicalException(_("tutti.property.set.error", property, bean.getClass().getName()), e);
-// }
-// }
-//
-// public static Object getProperty(Object bean, String property) {
-// Preconditions.checkNotNull(bean);
-// Preconditions.checkNotNull(property);
-// try {
-// return PropertyUtils.getSimpleProperty(bean, property);
-// } catch (Exception e) {
-// throw new TuttiTechnicalException(_("tutti.property.get.error", property, bean.getClass().getName()), e);
-// }
-// }
-
-// public static Highlighter newBackgroundColorHighlighter(HighlightPredicate predicate, Color color) {
-// return new TuttiColorHighlighter(predicate, color, false);
-// }
-//
-// public static Highlighter newForegroundColorHighlighter(HighlightPredicate predicate, Color color) {
-// return new TuttiColorHighlighter(predicate, color, true);
-// }
-
- // private static DecimalFormatSymbols symbols;
-//
-// public static DecimalFormatSymbols getDecimalFormatSymbols() {
-// if (symbols == null) {
-// symbols = new DecimalFormatSymbols();
-// symbols.setDecimalSeparator('.');
-// symbols.setGroupingSeparator(' ');
-// }
-// return symbols;
-// }
-//
-// private static DecimalFormat decimalFormat;
-//
-// public static DecimalFormat getDecimalFormat(int minDecimal, int maxDecimal) {
-// if (decimalFormat == null) {
-// decimalFormat = new DecimalFormat();
-// decimalFormat.setDecimalFormatSymbols(getDecimalFormatSymbols());
-// decimalFormat.setGroupingUsed(false);
-// }
-// decimalFormat.setMinimumFractionDigits(minDecimal);
-// decimalFormat.setMaximumFractionDigits(maxDecimal);
-// return decimalFormat;
-// }
-
-// public static String getWeightStringValue(Float weight) {
-// String textValue;
-// if (weight != null) {
-// DecimalFormat weightDecimalFormat = getDecimalFormat(1, 3);
-// textValue = weightDecimalFormat.format(weight);
-//
-// } else {
-// textValue = "";
-// }
-// return textValue;
-// }
-//
-// public static void openLink(URL url) {
-// try {
-// openLink(url.toURI());
-// } catch (URISyntaxException e) {
-// throw new TuttiTechnicalException(_("application.error.cannot.open.link", url), e);
-// }
-// }
-//
-// public static Desktop getDesktopForBrowse() {
-//
-// if (!Desktop.isDesktopSupported()) {
-// throw new TuttiTechnicalException(
-// _("application.error.desktop.not.supported"));
-// }
-//
-// Desktop desktop = Desktop.getDesktop();
-//
-// if (!desktop.isSupported(Desktop.Action.BROWSE)) {
-//
-// throw new TuttiTechnicalException(
-// _("application.error.desktop.browse.not.supported"));
-// }
-//
-// return desktop;
-// }
-//
-// public static void openLink(URI uri) {
-//
-// Desktop desktop = getDesktopForBrowse();
-//
-// try {
-//
-// desktop.browse(uri);
-// } catch (Exception e) {
-//
-// throw new TuttiTechnicalException(
-// _("application.error.cannot.open.link", uri), e);
-// }
-// }
-//
-// public static Desktop getDesktopForMail() {
-//
-// if (!Desktop.isDesktopSupported()) {
-// throw new TuttiTechnicalException(
-// _("application.error.desktop.not.supported"));
-// }
-//
-// Desktop desktop = Desktop.getDesktop();
-//
-// if (!desktop.isSupported(Desktop.Action.MAIL)) {
-//
-// throw new TuttiTechnicalException(
-// _("application.error.desktop.mail.not.supported"));
-// }
-//
-// return desktop;
-// }
-//
-// public static void mail(String subject, String body) {
-//
-// Desktop desktop = getDesktopForMail();
-//
-// try {
-// URI mailtoURI = new URI("mailto", null, null, "subject=" + subject + "&body=" + body, null);
-// desktop.mail(mailtoURI);
-//
-// } catch (Exception e) {
-//
-// throw new TuttiTechnicalException(
-// _("application.error.cannot.mail"), e);
-// }
-// }
-
public static void tryToConnectToUpdateUrl(String urlAsString,
String badUrlFormatI18nKey,
String notReachI18nKey,
@@ -307,81 +170,6 @@
}
-// public static void selectFirstCellOnFirstRowAndStopEditing(JXTable table) {
-//
-// // select first cell
-// doSelectCell(table, 0, 0);
-//
-// if (table.isEditing()) {
-//
-// // but no edit it
-// table.getCellEditor().stopCellEditing();
-// }
-// }
-//
-// public static void selectFirstCellOnLastRow(JXTable table) {
-//
-// // select first cell
-// doSelectCell(table, table.getRowCount() - 1, 0);
-// }
-//
-// public static void selectFirstCellOnRow(JXTable table, int row, boolean stopEdit) {
-//
-// // select first cell
-// doSelectCell(table, row, 0);
-//
-// if (stopEdit && table.isEditing()) {
-//
-// table.getCellEditor().stopCellEditing();
-// }
-// }
-
-// public static void doSelectCell(JTable table,
-// int rowIndex,
-// int columnIndex) {
-//
-// int rowCount = table.getRowCount();
-// if (rowCount == 0) {
-//
-// // no row, can not selected any cell
-// if (log.isWarnEnabled()) {
-// log.warn("No row in table, can not select any cell");
-// }
-// return;
-// }
-// int columnCount = table.getColumnCount();
-// if (columnCount == 0) {
-//
-// // no column, can not selected any cell
-// if (log.isWarnEnabled()) {
-// log.warn("No column in table, can not select any cell");
-// }
-// return;
-// }
-// if (columnIndex > columnCount) {
-// if (log.isWarnEnabled()) {
-// log.warn(String.format("ColumnIndex: %s is more than columnCount %s", columnIndex, columnCount));
-// }
-// columnIndex = columnCount - 1;
-// }
-// if (columnIndex < 0) {
-// columnIndex = 0;
-// }
-// if (rowIndex >= rowCount) {
-// if (log.isWarnEnabled()) {
-// log.warn(String.format("RowIndex: %s is more than rowCount %s", rowIndex, rowCount));
-// }
-// rowIndex = rowCount - 1;
-// }
-// if (rowIndex < 0) {
-// rowIndex = 0;
-// }
-//
-// table.setColumnSelectionInterval(columnIndex, columnIndex);
-// table.setRowSelectionInterval(rowIndex, rowIndex);
-// table.editCellAt(rowIndex, columnIndex);
-// }
-
protected static class SpeciesDecoratorListener<R extends Serializable, T extends AbstractApplicationTableModel<R>> implements ActionListener {
protected final JXTable table;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/SaveAttachmentAction.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/SaveAttachmentAction.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/SaveAttachmentAction.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -27,7 +27,7 @@
import fr.ifremer.shared.application.ApplicationIOUtil;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import fr.ifremer.tutti.ui.swing.action.AbstractTuttiAction;
import java.io.File;
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicMapEditorUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicMapEditorUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicMapEditorUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -29,11 +29,9 @@
import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.ui.swing.util.Cancelable;
+import fr.ifremer.shared.application.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
-import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor;
-import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
import jaxx.runtime.validator.swing.SwingValidator;
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicValueEditor.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicValueEditor.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicValueEditor.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,139 @@
+
+package fr.ifremer.tutti.ui.swing.util.caracteristics;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.JAXXWidgetUtil;
+import jaxx.runtime.swing.editor.bean.BeanUIUtil;
+import jaxx.runtime.swing.editor.cell.NumberCellEditor;
+import jaxx.runtime.swing.renderer.DecoratorListCellRenderer;
+import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;
+import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
+import org.nuiton.decorator.Decorator;
+
+import javax.swing.AbstractCellEditor;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.border.LineBorder;
+import javax.swing.table.TableCellEditor;
+import java.awt.Color;
+import java.awt.Component;
+import java.util.List;
+
+/**
+ * Editor for the values of the caracteristics of the fishing operations.
+ * The editor depends on the caracteristic value type.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.3
+ */
+public class CaracteristicValueEditor extends AbstractCellEditor implements TableCellEditor {
+
+ private static final long serialVersionUID = 1L;
+
+ protected int caracteristicColumn;
+
+ protected TableCellEditor editor;
+
+ protected Decorator<CaracteristicQualitativeValue> decorator;
+
+ public CaracteristicValueEditor(TuttiUIContext context) {
+ this(0, context);
+ }
+
+ public CaracteristicValueEditor(int caracteristicColumn, TuttiUIContext context) {
+ super();
+ this.caracteristicColumn = caracteristicColumn;
+ DecoratorService decoratorService = context.getDecoratorService();
+ decorator = decoratorService.getDecoratorByType(CaracteristicQualitativeValue.class);
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return editor.getCellEditorValue();
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ int row,
+ int column) {
+
+ Caracteristic caracteristic = (Caracteristic)
+ table.getModel().getValueAt(row, caracteristicColumn);
+ if (caracteristic == null) {
+
+ // can't edit a null value ?
+
+ } else {
+ switch (caracteristic.getCaracteristicType()) {
+
+ case NUMBER:
+ // by default this is a number
+ NumberCellEditor<Float> editor =
+ JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
+ editor.getNumberEditor().setSelectAllTextOnError(true);
+ editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
+ this.editor = editor;
+ break;
+ case QUALITATIVE:
+ JComboBox comboBox = new JComboBox();
+ comboBox.setRenderer(new DecoratorListCellRenderer(decorator));
+
+ // always use a copy of data
+ List<CaracteristicQualitativeValue> data =
+ Lists.newArrayList(caracteristic.getQualitativeValue());
+ // add a null value at first position
+ if (!data.isEmpty() && data.get(0) != null) {
+ data.add(0, null);
+ }
+ SwingUtil.fillComboBox(comboBox, data, null);
+
+ ObjectToStringConverter converter =
+ BeanUIUtil.newDecoratedObjectToStringConverter(decorator);
+ BeanUIUtil.decorate(comboBox, converter);
+ this.editor = new ComboBoxCellEditor(comboBox);
+ break;
+ case TEXT:
+ // use default editor
+
+ this.editor = table.getDefaultEditor(Object.class);
+ break;
+ }
+ }
+
+ Component result = editor.getTableCellEditorComponent(
+ table, value, isSelected, row, column);
+ return result;
+ }
+
+}
Copied: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicValueRenderer.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java)
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicValueRenderer.java (rev 0)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicValueRenderer.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -0,0 +1,122 @@
+
+package fr.ifremer.tutti.ui.swing.util.caracteristics;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import jaxx.runtime.swing.renderer.DecoratorTableCellRenderer;
+import org.nuiton.decorator.Decorator;
+
+import javax.swing.JLabel;
+import javax.swing.JTable;
+import javax.swing.SwingConstants;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Component;
+
+/**
+ * Renderer for the values of the caracteristics of the fishing operations.
+ * The renderer depends on the caracteristic value type.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.3
+ */
+public class CaracteristicValueRenderer implements TableCellRenderer {
+
+ protected int caracteristicColumn;
+
+ protected Decorator<CaracteristicQualitativeValue> decorator;
+
+ public CaracteristicValueRenderer(TuttiUIContext context) {
+ this(0, context);
+ }
+
+ public CaracteristicValueRenderer(int caracteristicColumn, TuttiUIContext context) {
+ super();
+ this.caracteristicColumn = caracteristicColumn;
+ DecoratorService decoratorService = context.getDecoratorService();
+ decorator = decoratorService.getDecoratorByType(CaracteristicQualitativeValue.class);
+ }
+
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column) {
+ TableCellRenderer renderer;
+
+ Caracteristic caracteristic = (Caracteristic)
+ table.getModel().getValueAt(row, caracteristicColumn);
+
+ boolean numericType = false;
+ if (caracteristic == null) {
+
+ // should be render a null value ?
+ renderer = table.getDefaultRenderer(Object.class);
+
+ } else {
+ switch (caracteristic.getCaracteristicType()) {
+
+ case QUALITATIVE:
+ renderer = new DecoratorTableCellRenderer(decorator);
+ break;
+
+ case NUMBER:
+
+ // use default text renderer with align at east
+ renderer = table.getDefaultRenderer(Object.class);
+ numericType = true;
+ break;
+ default:
+ case TEXT:
+ // use default text renderer
+ renderer = table.getDefaultRenderer(Object.class);
+ }
+ }
+
+ Component result = renderer.getTableCellRendererComponent(
+ table, value, isSelected, hasFocus, row, column);
+
+ if (numericType) {
+
+ if (result instanceof JLabel) {
+ JLabel jLabel = (JLabel) result;
+ jLabel.setHorizontalAlignment(SwingConstants.RIGHT);
+
+ }
+ } else {
+ if (result instanceof JLabel) {
+ JLabel jLabel = (JLabel) result;
+ jLabel.setHorizontalAlignment(SwingConstants.LEFT);
+ }
+ }
+
+ return result;
+ }
+
+}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,139 +0,0 @@
-
-package fr.ifremer.tutti.ui.swing.util.editor;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.JAXXWidgetUtil;
-import jaxx.runtime.swing.editor.bean.BeanUIUtil;
-import jaxx.runtime.swing.editor.cell.NumberCellEditor;
-import jaxx.runtime.swing.renderer.DecoratorListCellRenderer;
-import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;
-import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
-import org.nuiton.decorator.Decorator;
-
-import javax.swing.AbstractCellEditor;
-import javax.swing.JComboBox;
-import javax.swing.JTable;
-import javax.swing.border.LineBorder;
-import javax.swing.table.TableCellEditor;
-import java.awt.Color;
-import java.awt.Component;
-import java.util.List;
-
-/**
- * Editor for the values of the caracteristics of the fishing operations.
- * The editor depends on the caracteristic value type.
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.3
- */
-public class CaracteristicValueEditor extends AbstractCellEditor implements TableCellEditor {
-
- private static final long serialVersionUID = 1L;
-
- protected int caracteristicColumn;
-
- protected TableCellEditor editor;
-
- protected Decorator<CaracteristicQualitativeValue> decorator;
-
- public CaracteristicValueEditor(TuttiUIContext context) {
- this(0, context);
- }
-
- public CaracteristicValueEditor(int caracteristicColumn, TuttiUIContext context) {
- super();
- this.caracteristicColumn = caracteristicColumn;
- DecoratorService decoratorService = context.getDecoratorService();
- decorator = decoratorService.getDecoratorByType(CaracteristicQualitativeValue.class);
- }
-
- @Override
- public Object getCellEditorValue() {
- return editor.getCellEditorValue();
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table,
- Object value,
- boolean isSelected,
- int row,
- int column) {
-
- Caracteristic caracteristic = (Caracteristic)
- table.getModel().getValueAt(row, caracteristicColumn);
- if (caracteristic == null) {
-
- // can't edit a null value ?
-
- } else {
- switch (caracteristic.getCaracteristicType()) {
-
- case NUMBER:
- // by default this is a number
- NumberCellEditor<Float> editor =
- JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
- editor.getNumberEditor().setSelectAllTextOnError(true);
- editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
- this.editor = editor;
- break;
- case QUALITATIVE:
- JComboBox comboBox = new JComboBox();
- comboBox.setRenderer(new DecoratorListCellRenderer(decorator));
-
- // always use a copy of data
- List<CaracteristicQualitativeValue> data =
- Lists.newArrayList(caracteristic.getQualitativeValue());
- // add a null value at first position
- if (!data.isEmpty() && data.get(0) != null) {
- data.add(0, null);
- }
- SwingUtil.fillComboBox(comboBox, data, null);
-
- ObjectToStringConverter converter =
- BeanUIUtil.newDecoratedObjectToStringConverter(decorator);
- BeanUIUtil.decorate(comboBox, converter);
- this.editor = new ComboBoxCellEditor(comboBox);
- break;
- case TEXT:
- // use default editor
-
- this.editor = table.getDefaultEditor(Object.class);
- break;
- }
- }
-
- Component result = editor.getTableCellEditorComponent(
- table, value, isSelected, row, column);
- return result;
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,122 +0,0 @@
-
-package fr.ifremer.tutti.ui.swing.util.editor;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import jaxx.runtime.swing.renderer.DecoratorTableCellRenderer;
-import org.nuiton.decorator.Decorator;
-
-import javax.swing.JLabel;
-import javax.swing.JTable;
-import javax.swing.SwingConstants;
-import javax.swing.table.TableCellRenderer;
-import java.awt.Component;
-
-/**
- * Renderer for the values of the caracteristics of the fishing operations.
- * The renderer depends on the caracteristic value type.
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 0.3
- */
-public class CaracteristicValueRenderer implements TableCellRenderer {
-
- protected int caracteristicColumn;
-
- protected Decorator<CaracteristicQualitativeValue> decorator;
-
- public CaracteristicValueRenderer(TuttiUIContext context) {
- this(0, context);
- }
-
- public CaracteristicValueRenderer(int caracteristicColumn, TuttiUIContext context) {
- super();
- this.caracteristicColumn = caracteristicColumn;
- DecoratorService decoratorService = context.getDecoratorService();
- decorator = decoratorService.getDecoratorByType(CaracteristicQualitativeValue.class);
- }
-
- public Component getTableCellRendererComponent(JTable table,
- Object value,
- boolean isSelected,
- boolean hasFocus,
- int row,
- int column) {
- TableCellRenderer renderer;
-
- Caracteristic caracteristic = (Caracteristic)
- table.getModel().getValueAt(row, caracteristicColumn);
-
- boolean numericType = false;
- if (caracteristic == null) {
-
- // should be render a null value ?
- renderer = table.getDefaultRenderer(Object.class);
-
- } else {
- switch (caracteristic.getCaracteristicType()) {
-
- case QUALITATIVE:
- renderer = new DecoratorTableCellRenderer(decorator);
- break;
-
- case NUMBER:
-
- // use default text renderer with align at east
- renderer = table.getDefaultRenderer(Object.class);
- numericType = true;
- break;
- default:
- case TEXT:
- // use default text renderer
- renderer = table.getDefaultRenderer(Object.class);
- }
- }
-
- Component result = renderer.getTableCellRendererComponent(
- table, value, isSelected, hasFocus, row, column);
-
- if (numericType) {
-
- if (result instanceof JLabel) {
- JLabel jLabel = (JLabel) result;
- jLabel.setHorizontalAlignment(SwingConstants.RIGHT);
-
- }
- } else {
- if (result instanceof JLabel) {
- JLabel jLabel = (JLabel) result;
- jLabel.setHorizontalAlignment(SwingConstants.LEFT);
- }
- }
-
- return result;
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,49 +0,0 @@
-<!--
- #%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%
- -->
-<jaxx.runtime.swing.editor.NumberEditor>
-
- <import>
- fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData
- java.awt.Color
- </import>
-
- <String id='property' javaBean='TuttiComputedOrNotData.PROPERTY_DATA'/>
-
- <TuttiComputedOrNotData id='bean' genericType='?' javaBean='null'/>
-
- <Color id='computedDataColor' javaBean='null'/>
-
- <!-- ui handler -->
- <TuttiComputedOrNotDataEditorHandler id='handler' constructorParams='this'/>
-
- <Integer id='decimalNumber' javaBean='null'/>
-
- <script><![CDATA[
- public void setProperty(String property) {
- // cannot change the property
- }
-]]>
- </script>
-
-</jaxx.runtime.swing.editor.NumberEditor>
\ No newline at end of file
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,143 +0,0 @@
-
-package fr.ifremer.tutti.ui.swing.util.editor;
-
-/*
- * #%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.shared.application.ApplicationDataUtil;
-import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
-import fr.ifremer.tutti.ui.swing.util.TuttiUI;
-import jaxx.runtime.JAXXUtil;
-import jaxx.runtime.swing.editor.NumberEditorHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JTextField;
-import java.awt.Color;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.text.DecimalFormat;
-
-/**
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.0
- */
-public class TuttiComputedOrNotDataEditorHandler extends NumberEditorHandler {
-
- private static final Log log = LogFactory.getLog(TuttiComputedOrNotDataEditorHandler.class);
-
- protected Integer decimalNumber;
-
- public TuttiComputedOrNotDataEditorHandler(TuttiComputedOrNotDataEditor ui) {
- super(ui);
- }
-
- @Override
- public void init() {
- final PropertyChangeListener l = new PropertyChangeListener() {
-
- public void propertyChange(PropertyChangeEvent evt) {
- setComputedTextIfNullModel();
- }
- };
-
- TuttiComputedOrNotData bean = (TuttiComputedOrNotData) editor.getBean();
- if (bean != null) {
- bean.addPropertyChangeListener(l);
- }
- editor.addPropertyChangeListener(TuttiComputedOrNotDataEditor.PROPERTY_BEAN, new PropertyChangeListener() {
-
- public void propertyChange(PropertyChangeEvent evt) {
-
- TuttiComputedOrNotData bean = (TuttiComputedOrNotData) evt.getOldValue();
- if (bean != null) {
- bean.removePropertyChangeListener(TuttiComputedOrNotData.PROPERTY_COMPUTED_DATA, l);
- }
-
- bean = (TuttiComputedOrNotData) evt.getNewValue();
- if (bean != null) {
- bean.addPropertyChangeListener(TuttiComputedOrNotData.PROPERTY_COMPUTED_DATA, l);
- }
- }
- });
-
- editor.addPropertyChangeListener(TuttiComputedOrNotDataEditor.PROPERTY_MODEL, l);
-
- editor.getTextField().addFocusListener(new FocusListener() {
-
- public void focusGained(FocusEvent e) {
- JTextField tf = editor.getTextField();
- tf.setFont(TuttiUI.TEXTFIELD_NORMAL_FONT);
- tf.setForeground(Color.BLACK);
- if (editor.getModel() == null) {
- tf.setText("");
- }
- }
-
- public void focusLost(FocusEvent e) {
- setComputedTextIfNullModel();
- }
- });
-
- editor.addPropertyChangeListener(TuttiComputedOrNotDataEditor.PROPERTY_DECIMAL_NUMBER,
- new PropertyChangeListener() {
-
- public void propertyChange(PropertyChangeEvent evt) {
- decimalNumber = (Integer) evt.getNewValue();
- }
- });
-
- decimalNumber = ((TuttiComputedOrNotDataEditor) editor).getDecimalNumber();
-
- super.init();
-
- }
-
- protected void setComputedTextIfNullModel() {
- TuttiComputedOrNotData bean = (TuttiComputedOrNotData) editor.getBean();
- JTextField tf = editor.getTextField();
- if (bean != null && editor.getModel() == null) {
- tf.setFont(TuttiUI.TEXTFIELD_COMPUTED_FONT);
- tf.setForeground(((TuttiComputedOrNotDataEditor) editor).getComputedDataColor());
-
- String modelText;
- Number computedData = bean.getComputedData();
- if (editor.isUseFloat()
- && decimalNumber != null && computedData != null) {
- DecimalFormat decimalFormat = ApplicationDataUtil.getDecimalFormat(1, decimalNumber);
- modelText = decimalFormat.format(computedData);
- } else {
- modelText = JAXXUtil.getStringValue(computedData);
- }
- tf.setText(modelText);
-
- } else {
- tf.setFont(TuttiUI.TEXTFIELD_NORMAL_FONT);
- tf.setForeground(Color.BLACK);
- }
- }
-
-}
Deleted: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -1,260 +0,0 @@
-package fr.ifremer.tutti.ui.swing.util.editor;
-
-/*
- * #%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.shared.application.ApplicationDataUtil;
-import fr.ifremer.shared.application.type.WeightUnit;
-import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
-import fr.ifremer.tutti.ui.swing.util.TuttiUI;
-import jaxx.runtime.JAXXUtil;
-
-import javax.swing.AbstractCellEditor;
-import javax.swing.JLabel;
-import javax.swing.JTable;
-import javax.swing.SwingConstants;
-import javax.swing.SwingUtilities;
-import javax.swing.border.LineBorder;
-import javax.swing.event.AncestorEvent;
-import javax.swing.event.AncestorListener;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Font;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.text.DecimalFormat;
-
-/**
- * Editor for TuttiComputedOrNotData
- *
- * @author kmorin <kmorin(a)codelutin.com>
- * @since 1.0
- */
-public class TuttiComputedOrNotDataTableCell extends DefaultTableCellRenderer {
- private static final long serialVersionUID = 1L;
-
- public static TableCellRenderer newRender(TableCellRenderer renderer,
- WeightUnit weightUnit,
- Color computedDataColor) {
-
- return new TuttiComputedOrNotDataTableCellRenderer(renderer,
- true,
- weightUnit.getNumberDigits(),
- computedDataColor);
- }
-
- public static TableCellEditor newEditor(Class type,
- WeightUnit weightUnit,
- Color computedDataColor) {
-
- return new TuttiComputedOrNotDataTableCellEditor(type,
- false,
- true,
- weightUnit.getNumberDigits(),
- weightUnit.getNumberEditorPattern(),
- computedDataColor);
- }
-
- public static class TuttiComputedOrNotDataTableCellEditor
- extends AbstractCellEditor
- implements TableCellEditor, FocusListener, AncestorListener {
-
- private static final long serialVersionUID = 1L;
-
- protected final TuttiComputedOrNotDataEditor numberEditor;
-
- protected TuttiComputedOrNotData data;
-
- /** constructor */
- public TuttiComputedOrNotDataTableCellEditor(Class type,
- boolean useSign,
- boolean useFloat,
- Integer decimalNumber,
- String numberPattern,
- Color computedDataColor) {
-
- numberEditor = new TuttiComputedOrNotDataEditor();
- numberEditor.setComputedDataColor(computedDataColor);
- numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT);
- numberEditor.getTextField().addFocusListener(this);
- numberEditor.getTextField().addAncestorListener(this);
- numberEditor.getTextField().setBorder(new LineBorder(Color.GRAY, 2));
- numberEditor.setSelectAllTextOnError(true);
-
- numberEditor.setNumberPattern(numberPattern);
- numberEditor.setModelType(type);
- numberEditor.setUseSign(useSign);
- numberEditor.setUseFloat(useFloat);
- numberEditor.setDecimalNumber(decimalNumber);
- numberEditor.init();
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table, Object value,
- boolean isSelected, int row, int column) {
-
- data = (TuttiComputedOrNotData) value;
- numberEditor.setModel(data.getData());
-
- // Check nullity and set the text that will be selected with the current value
- if (data.getData() != null) {
- numberEditor.setModelText(String.valueOf(data.getData()));
- }
- return numberEditor;
- }
-
- public TuttiComputedOrNotDataEditor getNumberEditor() {
- return numberEditor;
- }
-
- @Override
- public TuttiComputedOrNotData getCellEditorValue() {
- return data;
- }
-
- @Override
- public void focusGained(FocusEvent e) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- numberEditor.getTextField().requestFocus();
- numberEditor.getTextField().selectAll();
- }
- });
- }
-
- @Override
- public void focusLost(FocusEvent e) {
- }
-
- @Override
- public void ancestorAdded(AncestorEvent event) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- numberEditor.getTextField().requestFocus();
- numberEditor.getTextField().selectAll();
- }
- });
- }
-
- @Override
- public void ancestorRemoved(AncestorEvent event) {
- }
-
- @Override
- public void ancestorMoved(AncestorEvent event) {
- }
-
- @Override
- public boolean stopCellEditing() {
- boolean result = super.stopCellEditing();
- // Reset previous data to avoid keeping it on other cell edition
- if (result) {
- data.setData(numberEditor.getModel());
-
- numberEditor.setBean(null);
-
- data = null;
- }
- return result;
- }
- }
-
- public static class TuttiComputedOrNotDataTableCellRenderer
- implements TableCellRenderer {
-
- protected final TableCellRenderer delegate;
-
- protected Integer decimalNumber;
-
- protected Color computedDataColor;
-
- protected boolean useFloat;
-
- public TuttiComputedOrNotDataTableCellRenderer(
- TableCellRenderer delegate,
- boolean useFloat,
- Integer decimalNumber,
- Color computedDataColor) {
-
- this.delegate = delegate;
- this.useFloat = useFloat;
- this.decimalNumber = decimalNumber;
- this.computedDataColor = computedDataColor;
- }
-
- public Component getTableCellRendererComponent(JTable table,
- Object value,
- boolean isSelected,
- boolean hasFocus,
- int row,
- int column) {
-
- TuttiComputedOrNotData data = (TuttiComputedOrNotData) value;
- Number dataValue = data.getData();
- Font font;
- Color foreground;
- String text;
- if (dataValue == null) {
- dataValue = data.getComputedData();
- font = TuttiUI.TEXTFIELD_COMPUTED_FONT;
- foreground = computedDataColor;
-
- if (useFloat && decimalNumber != null && dataValue != null) {
- DecimalFormat decimalFormat = ApplicationDataUtil.getDecimalFormat(1, decimalNumber);
- text = JAXXUtil.getStringValue(decimalFormat.format(dataValue));
- } else {
- text = JAXXUtil.getStringValue(dataValue);
- }
-
- } else {
- font = TuttiUI.TEXTFIELD_NORMAL_FONT;
- foreground = Color.BLACK;
- text = JAXXUtil.getStringValue(dataValue);
- }
-
- Component component = delegate.getTableCellRendererComponent(table,
- text,
- isSelected,
- hasFocus,
- row,
- column);
-
- if (isSelected) {
- font = font.deriveFont(Font.BOLD);
- }
- component.setFont(font);
- component.setForeground(foreground);
- if (component instanceof JLabel) {
- JLabel jLabel = (JLabel) component;
- jLabel.setHorizontalAlignment(RIGHT);
- }
-
- return component;
- }
-
- }
-}
Modified: branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
===================================================================
--- branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
+++ branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-11-26 08:03:42 UTC (rev 1388)
@@ -38,7 +38,7 @@
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
-import fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataTableCell.TuttiComputedOrNotDataTableCellEditor;
+import fr.ifremer.shared.application.swing.computable.ComputableDataTableCell.TuttiComputedOrNotDataTableCellEditor;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.editor.cell.NumberCellEditor;
import org.apache.commons.collections.CollectionUtils;
1
0
25 Nov '13
Author: tchemit
Date: 2013-11-25 17:03:00 +0100 (Mon, 25 Nov 2013)
New Revision: 1387
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1387
Log:
continue adding some stuff
Added:
application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/
application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableData.java
application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableDataEditor.jaxx
application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableDataEditorHandler.java
application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableDataTableCell.java
application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/
application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/CustomTab.java
application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/DelegateTabContainerHandler.java
application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/TabContainerHandler.java
application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/TabContentModel.java
application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/TabHandler.java
application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/util/ActionListCellRenderer.java
application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/util/Cancelable.java
application/trunk/application/src/main/java/fr/ifremer/shared/application/listener/
application/trunk/application/src/main/java/fr/ifremer/shared/application/listener/PropagatePropertyChangeListener.java
Modified:
application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/AbstractApplicationUIHandler.java
application/trunk/application/src/main/java/fr/ifremer/shared/application/ApplicationConfiguration.java
Modified: application/trunk/application/src/main/java/fr/ifremer/shared/application/ApplicationConfiguration.java
===================================================================
--- application/trunk/application/src/main/java/fr/ifremer/shared/application/ApplicationConfiguration.java 2013-11-24 23:48:14 UTC (rev 1386)
+++ application/trunk/application/src/main/java/fr/ifremer/shared/application/ApplicationConfiguration.java 2013-11-25 16:03:00 UTC (rev 1387)
@@ -27,6 +27,8 @@
import org.nuiton.config.ApplicationConfig;
import org.nuiton.util.Version;
+import javax.swing.KeyStroke;
+
/**
* Created on 11/24/13.
*
@@ -44,6 +46,8 @@
public abstract Version getVersion();
+ public abstract KeyStroke getShortcutClosePopup();
+
public ApplicationConfiguration(ApplicationConfig applicationConfig) {
this.applicationConfig = applicationConfig;
}
Copied: application/trunk/application/src/main/java/fr/ifremer/shared/application/listener/PropagatePropertyChangeListener.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-persistence/src/main/java/fr/ifremer/tutti/PropagatePropertyChangeListener.java)
===================================================================
--- application/trunk/application/src/main/java/fr/ifremer/shared/application/listener/PropagatePropertyChangeListener.java (rev 0)
+++ application/trunk/application/src/main/java/fr/ifremer/shared/application/listener/PropagatePropertyChangeListener.java 2013-11-25 16:03:00 UTC (rev 1387)
@@ -0,0 +1,80 @@
+package fr.ifremer.shared.application.listener;
+
+/*
+ * #%L
+ * Ifremer shared :: Application
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 Ifremer, CodeLutin, Tony CHEMIT
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import org.jdesktop.beans.AbstractBean;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+/**
+ * To listen a bean and propagate some of properties.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class PropagatePropertyChangeListener implements PropertyChangeListener {
+
+ public static interface PropagatePropertyChange {
+ void firePropertyChanged(String propertyName,
+ Object oldValue,
+ Object newValue);
+ }
+
+ public static void listenAndPropagate(AbstractBean producer,
+ PropagatePropertyChange consumer,
+ String propertyNameToListen,
+ String propertyNameToForward) {
+ PropagatePropertyChangeListener listener =
+ new PropagatePropertyChangeListener(propertyNameToForward,
+ consumer);
+ producer.addPropertyChangeListener(propertyNameToListen, listener);
+ }
+
+ public static void listenAndPropagateAll(AbstractBean producer,
+ PropagatePropertyChange consumer) {
+ PropagatePropertyChangeListener listener =
+ new PropagatePropertyChangeListener(null, consumer);
+ producer.addPropertyChangeListener(listener);
+ }
+
+ private String propertyName;
+
+ private PropagatePropertyChange editor;
+
+ public PropagatePropertyChangeListener(String propertyName,
+ PropagatePropertyChange editor) {
+ this.propertyName = propertyName;
+ this.editor = editor;
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ String name = propertyName == null ? evt.getPropertyName() : propertyName;
+ editor.firePropertyChanged(name,
+ evt.getOldValue(),
+ evt.getNewValue());
+ }
+}
\ No newline at end of file
Modified: application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/AbstractApplicationUIHandler.java
===================================================================
--- application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/AbstractApplicationUIHandler.java 2013-11-24 23:48:14 UTC (rev 1386)
+++ application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/AbstractApplicationUIHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
@@ -27,8 +27,13 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import fr.ifremer.shared.application.ApplicationDataUtil;
+import fr.ifremer.shared.application.swing.action.ApplicationActionUI;
+import fr.ifremer.shared.application.swing.computable.ComputableDataEditor;
import fr.ifremer.shared.application.swing.table.ColumnIdentifier;
+import fr.ifremer.shared.application.swing.util.Cancelable;
+import fr.ifremer.shared.application.type.ApplicationProgressionModel;
import fr.ifremer.shared.application.type.WeightUnit;
+import jaxx.runtime.JAXXUtil;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.JAXXWidgetUtil;
import jaxx.runtime.swing.editor.FileEditor;
@@ -54,6 +59,7 @@
import org.nuiton.decorator.Decorator;
import org.nuiton.decorator.JXPathDecorator;
+import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.Action;
import javax.swing.DefaultComboBoxModel;
@@ -64,11 +70,13 @@
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
+import javax.swing.JRootPane;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JViewport;
+import javax.swing.KeyStroke;
import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
@@ -85,8 +93,9 @@
import javax.swing.text.JTextComponent;
import java.awt.Color;
import java.awt.Component;
+import java.awt.Dialog;
import java.awt.Dimension;
-import java.awt.Font;
+import java.awt.Frame;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
@@ -97,6 +106,8 @@
import java.awt.event.ItemEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
import java.io.File;
import java.io.Serializable;
import java.text.ParseException;
@@ -211,7 +222,7 @@
selectionModel.setValueIsAdjusting(true);
try {
- List selectedList = Lists.newLinkedList();
+ List<Object> selectedList = Lists.newLinkedList();
for (int index : list.getSelectedIndices()) {
Object o = list.getModel().getElementAt(index);
@@ -224,62 +235,62 @@
}
}
-// public void openDialog(TuttiUI dialogContent,
-// String title, Dimension dim) {
-// Component topestUI = getTopestUI();
-//
-// JDialog result;
-// if (topestUI instanceof Frame) {
-// result = new JDialog((Frame) topestUI, title, true);
-// } else {
-// result = new JDialog((Dialog) topestUI, title, true);
-// }
-//
-// result.add((Component) dialogContent);
-// result.setResizable(true);
-//
-// result.setSize(dim);
-//
-// final AbstractTuttiUIHandler handler = dialogContent.getHandler();
-//
-// if (handler instanceof Cancelable) {
-//
-// // add a auto-close action
-// JRootPane rootPane = result.getRootPane();
-//
-// KeyStroke shortcutClosePopup = getConfig().getShortcutClosePopup();
-//
-// rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
-// shortcutClosePopup, "close");
-// rootPane.getActionMap().put("close", new AbstractAction() {
-// private static final long serialVersionUID = 1L;
-//
-// @Override
-// public void actionPerformed(ActionEvent e) {
-// ((Cancelable) handler).cancel();
-// }
-// });
-// }
-//
-// result.addWindowListener(new WindowAdapter() {
-//
-// @Override
-// public void windowClosed(WindowEvent e) {
-// Component ui = (Component) e.getSource();
-// if (log.isDebugEnabled()) {
-// log.debug("Destroy ui " + ui);
-// }
-// JAXXUtil.destroy(ui);
-// }
-// });
-// SwingUtil.center(getContext().getMainUI(), result);
-// result.setVisible(true);
-// }
-//
-// public void closeDialog(ApplicationUI ui) {
-// SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
-// }
+ public void openDialog(ApplicationUI dialogContent,
+ String title, Dimension dim) {
+ Component topestUI = getTopestUI();
+ JDialog result;
+ if (topestUI instanceof Frame) {
+ result = new JDialog((Frame) topestUI, title, true);
+ } else {
+ result = new JDialog((Dialog) topestUI, title, true);
+ }
+
+ result.add((Component) dialogContent);
+ result.setResizable(true);
+
+ result.setSize(dim);
+
+ final AbstractApplicationUIHandler handler = dialogContent.getHandler();
+
+ if (handler instanceof Cancelable) {
+
+ // add a auto-close action
+ JRootPane rootPane = result.getRootPane();
+
+ KeyStroke shortcutClosePopup = getContext().getConfiguration().getShortcutClosePopup();
+
+ rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+ shortcutClosePopup, "close");
+ rootPane.getActionMap().put("close", new AbstractAction() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ ((Cancelable) handler).cancel();
+ }
+ });
+ }
+
+ result.addWindowListener(new WindowAdapter() {
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ Component ui = (Component) e.getSource();
+ if (log.isDebugEnabled()) {
+ log.debug("Destroy ui " + ui);
+ }
+ JAXXUtil.destroy(ui);
+ }
+ });
+ SwingUtil.center(getContext().getMainUI(), result);
+ result.setVisible(true);
+ }
+
+ public void closeDialog(ApplicationUI ui) {
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
+
public static final String CONFIRMATION_FORMAT = "<html>%s<hr/><br/>%s</html>";
public int askSaveBeforeLeaving(String message) {
@@ -349,6 +360,10 @@
// handler.clearValidators();
// }
+ protected void addHighlighters(final JXTable table) {
+
+ }
+
public void autoSelectRowInTable(MouseEvent e, JPopupMenu popup) {
boolean rightClick = SwingUtilities.isRightMouseButton(e);
@@ -545,40 +560,29 @@
}
protected void initLabel(JLabel jLabel) {
- Boolean strongStyle = (Boolean) jLabel.getClientProperty("strongStyle");
- Boolean italicStyle = (Boolean) jLabel.getClientProperty("italicStyle");
- Font font = jLabel.getFont();
- int style = font.getStyle();
- if (strongStyle != null && strongStyle) {
- style |= Font.BOLD;
+
+ WeightUnit weightUnit = (WeightUnit) jLabel.getClientProperty("addWeightUnit");
+ if (weightUnit != null) {
+ String text = weightUnit.decorateLabel(jLabel.getText());
+ jLabel.setText(text);
+
+ String tip = weightUnit.decorateTip(jLabel.getToolTipText());
+ jLabel.setToolTipText(tip);
+
+ Component labelFor = jLabel.getLabelFor();
+ if (labelFor instanceof ComputableDataEditor) {
+
+ // set also the number of digits (4 for kg, 1 for g)
+ ComputableDataEditor editor = (ComputableDataEditor) labelFor;
+ editor.setNumberPattern(weightUnit.getNumberEditorPattern());
+ editor.setDecimalNumber(weightUnit.getNumberDigits());
+ } else if (labelFor instanceof NumberEditor) {
+
+ // set also the number of digits (4 for kg, 1 for g)
+ NumberEditor editor = (NumberEditor) labelFor;
+ editor.setNumberPattern(weightUnit.getNumberEditorPattern());
+ }
}
- if (italicStyle != null && italicStyle) {
- style |= Font.ITALIC;
- }
- jLabel.setFont(font.deriveFont(style));
-
-// WeightUnit weightUnit = (WeightUnit) jLabel.getClientProperty("addWeightUnit");
-// if (weightUnit != null) {
-// String text = weightUnit.decorateLabel(jLabel.getText());
-// jLabel.setText(text);
-//
-// String tip = weightUnit.decorateTip(jLabel.getToolTipText());
-// jLabel.setToolTipText(tip);
-//
-// Component labelFor = jLabel.getLabelFor();
-// if (labelFor instanceof TuttiComputedOrNotDataEditor) {
-//
-// // set also the number of digits (4 for kg, 1 for g)
-// TuttiComputedOrNotDataEditor editor = (TuttiComputedOrNotDataEditor) labelFor;
-// editor.setNumberPattern(weightUnit.getNumberEditorPattern());
-// editor.setDecimalNumber(weightUnit.getNumberDigits());
-// } else if (labelFor instanceof NumberEditor) {
-//
-// // set also the number of digits (4 for kg, 1 for g)
-// NumberEditor editor = (NumberEditor) labelFor;
-// editor.setNumberPattern(weightUnit.getNumberEditorPattern());
-// }
-// }
}
// protected void initButtonAttachment(ButtonAttachment component) {
@@ -1067,4 +1071,15 @@
DecoratorTableCellRenderer result = new DecoratorTableCellRenderer(decorator, true);
return result;
}
+
+ protected void incrementsMessage(String message) {
+
+ ApplicationActionUI actionUI = getContext().getActionUI();
+ if (actionUI != null) {
+ ApplicationProgressionModel progressionModel = actionUI.getModel().getProgressionModel();
+ if (progressionModel != null)
+
+ progressionModel.increments(message);
+ }
+ }
}
Copied: application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableData.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java)
===================================================================
--- application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableData.java (rev 0)
+++ application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableData.java 2013-11-25 16:03:00 UTC (rev 1387)
@@ -0,0 +1,127 @@
+package fr.ifremer.shared.application.swing.computable;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer, CodeLutin, Tony CHEMIT
+ * %%
+ * 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.shared.application.listener.PropagatePropertyChangeListener;
+import org.jdesktop.beans.AbstractSerializableBean;
+
+
+/**
+ * A number data plus a possible computed value.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public class ComputableData<N extends Number> extends AbstractSerializableBean {
+
+ public static final String PROPERTY_DATA = "data";
+
+ public static final String PROPERTY_COMPUTED_DATA = "computedData";
+
+ private static final long serialVersionUID = 1L;
+
+ protected N data;
+
+ protected N computedData;
+
+ public ComputableData() {
+ data = null;
+ computedData = null;
+ }
+
+ public ComputableData(N data, N computedData) {
+ this.data = data;
+ this.computedData = computedData;
+ }
+
+ public N getData() {
+ return data;
+ }
+
+ public void setData(N data) {
+ Object oldValue = getData();
+ this.data = data;
+ firePropertyChange(PROPERTY_DATA, oldValue, data);
+ }
+
+ public N getComputedData() {
+ return computedData;
+ }
+
+ public void setComputedData(N computedData) {
+ Object oldValue = getComputedData();
+ this.computedData = computedData;
+ firePropertyChange(PROPERTY_COMPUTED_DATA, oldValue, computedData);
+ }
+
+ @Override
+ public String toString() {
+ String result = null;
+ if (data != null) {
+ result = data.toString();
+ } else if (computedData != null) {
+ result = computedData.toString();
+ }
+ return result;
+ }
+
+ /**
+ * Add a listener to propagate the modification of the
+ * {@link #PROPERTY_DATA} property to a given {@code propertyName}.
+ *
+ * @param propertyName name of the property to fire on given bean
+ * @param otherBean bean that will fires
+ * @since 1.2
+ */
+ public void addPropagateListener(String propertyName,
+ PropagatePropertyChangeListener.PropagatePropertyChange otherBean) {
+
+ PropagatePropertyChangeListener.listenAndPropagate(this,
+ otherBean,
+ PROPERTY_DATA,
+ propertyName);
+
+// PropagatePropertyChangeListener listener = new PropagatePropertyChangeListener(propertyName, otherBean);
+// addPropertyChangeListener(PROPERTY_DATA, listener);
+ }
+
+// private static class PropagateProperyChangeListener implements PropertyChangeListener {
+//
+// private String propertyName;
+//
+// private AbstractTuttiBeanUIModel otherBean;
+//
+// public PropagatePropertyChangeLstener(String propertyName,
+// AbstractTuttiBeanUIModel otherBean) {
+// this.propertyName = propertyName;
+// this.otherBean = otherBean;
+// }
+//
+// @Override
+// public void propertyChange(PropertyChangeEvent evt) {
+// otherBean.firePropertyChanged(propertyName, evt.getOldValue(), evt.getNewValue());
+// }
+// }
+}
Copied: application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableDataEditor.jaxx (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditor.jaxx)
===================================================================
--- application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableDataEditor.jaxx (rev 0)
+++ application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableDataEditor.jaxx 2013-11-25 16:03:00 UTC (rev 1387)
@@ -0,0 +1,54 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 - 2013 Ifremer, CodeLutin, Tony CHEMIT
+ %%
+ 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%
+ -->
+<jaxx.runtime.swing.editor.NumberEditor genericType='E extends Number'>
+
+ <import>
+ fr.ifremer.shared.application.swing.computable.ComputableData
+ java.awt.Color
+ </import>
+
+ <String id='property' javaBean='ComputableData.PROPERTY_DATA'/>
+
+ <ComputableData id='bean' genericType='E' javaBean='null'/>
+
+ <Color id='computedDataColor' javaBean='null'/>
+
+ <!-- ui handler -->
+ <ComputableDataEditorHandler id='handler' constructorParams='this'/>
+
+ <Integer id='decimalNumber' javaBean='null'/>
+
+ <script><![CDATA[
+
+ public void setBean(ComputableData<E> bean) {
+ super.setBean(bean);
+ }
+
+ public void setProperty(String property) {
+ // cannot change the property
+ }
+]]>
+ </script>
+
+</jaxx.runtime.swing.editor.NumberEditor>
\ No newline at end of file
Copied: application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableDataEditorHandler.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataEditorHandler.java)
===================================================================
--- application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableDataEditorHandler.java (rev 0)
+++ application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableDataEditorHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
@@ -0,0 +1,138 @@
+
+package fr.ifremer.shared.application.swing.computable;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer, CodeLutin, Tony CHEMIT
+ * %%
+ * 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.shared.application.ApplicationDataUtil;
+import fr.ifremer.shared.application.swing.ApplicationUI;
+import jaxx.runtime.JAXXUtil;
+import jaxx.runtime.swing.editor.NumberEditorHandler;
+
+import javax.swing.JTextField;
+import java.awt.Color;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.text.DecimalFormat;
+
+/**
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public class ComputableDataEditorHandler extends NumberEditorHandler {
+
+ protected Integer decimalNumber;
+
+ public ComputableDataEditorHandler(ComputableDataEditor ui) {
+ super(ui);
+ }
+
+ @Override
+ public void init() {
+ final PropertyChangeListener l = new PropertyChangeListener() {
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ setComputedTextIfNullModel();
+ }
+ };
+
+ ComputableData bean = (ComputableData) editor.getBean();
+ if (bean != null) {
+ bean.addPropertyChangeListener(l);
+ }
+ editor.addPropertyChangeListener(ComputableDataEditor.PROPERTY_BEAN, new PropertyChangeListener() {
+
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ ComputableData bean = (ComputableData) evt.getOldValue();
+ if (bean != null) {
+ bean.removePropertyChangeListener(ComputableData.PROPERTY_COMPUTED_DATA, l);
+ }
+
+ bean = (ComputableData) evt.getNewValue();
+ if (bean != null) {
+ bean.addPropertyChangeListener(ComputableData.PROPERTY_COMPUTED_DATA, l);
+ }
+ }
+ });
+
+ editor.addPropertyChangeListener(ComputableDataEditor.PROPERTY_MODEL, l);
+
+ editor.getTextField().addFocusListener(new FocusListener() {
+
+ public void focusGained(FocusEvent e) {
+ JTextField tf = editor.getTextField();
+ tf.setFont(ApplicationUI.TEXTFIELD_NORMAL_FONT);
+ tf.setForeground(Color.BLACK);
+ if (editor.getModel() == null) {
+ tf.setText("");
+ }
+ }
+
+ public void focusLost(FocusEvent e) {
+ setComputedTextIfNullModel();
+ }
+ });
+
+ editor.addPropertyChangeListener(ComputableDataEditor.PROPERTY_DECIMAL_NUMBER,
+ new PropertyChangeListener() {
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ decimalNumber = (Integer) evt.getNewValue();
+ }
+ });
+
+ decimalNumber = ((ComputableDataEditor) editor).getDecimalNumber();
+
+ super.init();
+
+ }
+
+ protected void setComputedTextIfNullModel() {
+ ComputableData bean = (ComputableData) editor.getBean();
+ JTextField tf = editor.getTextField();
+ if (bean != null && editor.getModel() == null) {
+ tf.setFont(ApplicationUI.TEXTFIELD_COMPUTED_FONT);
+ tf.setForeground(((ComputableDataEditor) editor).getComputedDataColor());
+
+ String modelText;
+ Number computedData = bean.getComputedData();
+ if (editor.isUseFloat()
+ && decimalNumber != null && computedData != null) {
+ DecimalFormat decimalFormat = ApplicationDataUtil.getDecimalFormat(1, decimalNumber);
+ modelText = decimalFormat.format(computedData);
+ } else {
+ modelText = JAXXUtil.getStringValue(computedData);
+ }
+ tf.setText(modelText);
+
+ } else {
+ tf.setFont(ApplicationUI.TEXTFIELD_NORMAL_FONT);
+ tf.setForeground(Color.BLACK);
+ }
+ }
+
+}
Copied: application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableDataTableCell.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/TuttiComputedOrNotDataTableCell.java)
===================================================================
--- application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableDataTableCell.java (rev 0)
+++ application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/computable/ComputableDataTableCell.java 2013-11-25 16:03:00 UTC (rev 1387)
@@ -0,0 +1,259 @@
+package fr.ifremer.shared.application.swing.computable;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer, CodeLutin, Tony CHEMIT
+ * %%
+ * 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.shared.application.ApplicationDataUtil;
+import fr.ifremer.shared.application.swing.ApplicationUI;
+import fr.ifremer.shared.application.type.WeightUnit;
+import jaxx.runtime.JAXXUtil;
+
+import javax.swing.AbstractCellEditor;
+import javax.swing.JLabel;
+import javax.swing.JTable;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.border.LineBorder;
+import javax.swing.event.AncestorEvent;
+import javax.swing.event.AncestorListener;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.text.DecimalFormat;
+
+/**
+ * Editor for TuttiComputedOrNotData
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public class ComputableDataTableCell extends DefaultTableCellRenderer {
+ private static final long serialVersionUID = 1L;
+
+ public static TableCellRenderer newRender(TableCellRenderer renderer,
+ WeightUnit weightUnit,
+ Color computedDataColor) {
+
+ return new TuttiComputedOrNotDataTableCellRenderer(renderer,
+ true,
+ weightUnit.getNumberDigits(),
+ computedDataColor);
+ }
+
+ public static TableCellEditor newEditor(Class type,
+ WeightUnit weightUnit,
+ Color computedDataColor) {
+
+ return new TuttiComputedOrNotDataTableCellEditor(type,
+ false,
+ true,
+ weightUnit.getNumberDigits(),
+ weightUnit.getNumberEditorPattern(),
+ computedDataColor);
+ }
+
+ public static class TuttiComputedOrNotDataTableCellEditor
+ extends AbstractCellEditor
+ implements TableCellEditor, FocusListener, AncestorListener {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final ComputableDataEditor numberEditor;
+
+ protected ComputableData data;
+
+ /** constructor */
+ public TuttiComputedOrNotDataTableCellEditor(Class type,
+ boolean useSign,
+ boolean useFloat,
+ Integer decimalNumber,
+ String numberPattern,
+ Color computedDataColor) {
+
+ numberEditor = new ComputableDataEditor();
+ numberEditor.setComputedDataColor(computedDataColor);
+ numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT);
+ numberEditor.getTextField().addFocusListener(this);
+ numberEditor.getTextField().addAncestorListener(this);
+ numberEditor.getTextField().setBorder(new LineBorder(Color.GRAY, 2));
+ numberEditor.setSelectAllTextOnError(true);
+
+ numberEditor.setNumberPattern(numberPattern);
+ numberEditor.setModelType(type);
+ numberEditor.setUseSign(useSign);
+ numberEditor.setUseFloat(useFloat);
+ numberEditor.setDecimalNumber(decimalNumber);
+ numberEditor.init();
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value,
+ boolean isSelected, int row, int column) {
+
+ data = (ComputableData) value;
+ numberEditor.setModel(data.getData());
+
+ // Check nullity and set the text that will be selected with the current value
+ if (data.getData() != null) {
+ numberEditor.setModelText(String.valueOf(data.getData()));
+ }
+ return numberEditor;
+ }
+
+ public ComputableDataEditor getNumberEditor() {
+ return numberEditor;
+ }
+
+ @Override
+ public ComputableData getCellEditorValue() {
+ return data;
+ }
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ numberEditor.getTextField().requestFocus();
+ numberEditor.getTextField().selectAll();
+ }
+ });
+ }
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ }
+
+ @Override
+ public void ancestorAdded(AncestorEvent event) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ numberEditor.getTextField().requestFocus();
+ numberEditor.getTextField().selectAll();
+ }
+ });
+ }
+
+ @Override
+ public void ancestorRemoved(AncestorEvent event) {
+ }
+
+ @Override
+ public void ancestorMoved(AncestorEvent event) {
+ }
+
+ @Override
+ public boolean stopCellEditing() {
+ boolean result = super.stopCellEditing();
+ // Reset previous data to avoid keeping it on other cell edition
+ if (result) {
+ data.setData(numberEditor.getModel());
+
+ numberEditor.setBean(null);
+
+ data = null;
+ }
+ return result;
+ }
+ }
+
+ public static class TuttiComputedOrNotDataTableCellRenderer
+ implements TableCellRenderer {
+
+ protected final TableCellRenderer delegate;
+
+ protected Integer decimalNumber;
+
+ protected Color computedDataColor;
+
+ protected boolean useFloat;
+
+ public TuttiComputedOrNotDataTableCellRenderer(
+ TableCellRenderer delegate,
+ boolean useFloat,
+ Integer decimalNumber,
+ Color computedDataColor) {
+
+ this.delegate = delegate;
+ this.useFloat = useFloat;
+ this.decimalNumber = decimalNumber;
+ this.computedDataColor = computedDataColor;
+ }
+
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column) {
+
+ ComputableData data = (ComputableData) value;
+ Number dataValue = data.getData();
+ Font font;
+ Color foreground;
+ String text;
+ if (dataValue == null) {
+ dataValue = data.getComputedData();
+ font = ApplicationUI.TEXTFIELD_COMPUTED_FONT;
+ foreground = computedDataColor;
+
+ if (useFloat && decimalNumber != null && dataValue != null) {
+ DecimalFormat decimalFormat = ApplicationDataUtil.getDecimalFormat(1, decimalNumber);
+ text = JAXXUtil.getStringValue(decimalFormat.format(dataValue));
+ } else {
+ text = JAXXUtil.getStringValue(dataValue);
+ }
+
+ } else {
+ font = ApplicationUI.TEXTFIELD_NORMAL_FONT;
+ foreground = Color.BLACK;
+ text = JAXXUtil.getStringValue(dataValue);
+ }
+
+ Component component = delegate.getTableCellRendererComponent(table,
+ text,
+ isSelected,
+ hasFocus,
+ row,
+ column);
+
+ if (isSelected) {
+ font = font.deriveFont(Font.BOLD);
+ }
+ component.setFont(font);
+ component.setForeground(foreground);
+ if (component instanceof JLabel) {
+ JLabel jLabel = (JLabel) component;
+ jLabel.setHorizontalAlignment(RIGHT);
+ }
+
+ return component;
+ }
+
+ }
+}
Copied: application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/CustomTab.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/CustomTab.java)
===================================================================
--- application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/CustomTab.java (rev 0)
+++ application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/CustomTab.java 2013-11-25 16:03:00 UTC (rev 1387)
@@ -0,0 +1,126 @@
+package fr.ifremer.shared.application.swing.tab;
+
+/*
+ * #%L
+ * Ifremer shared :: Application Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 Ifremer, CodeLutin, Tony CHEMIT
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.beans.BeanUtil;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.UIManager;
+import java.awt.Color;
+import java.awt.Font;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Custom tab component which adds a * in the end of the title
+ * when the content is modified.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public class CustomTab extends JPanel {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Log log = LogFactory.getLog(CustomTab.class);
+
+ protected TabContentModel model;
+
+ protected JLabel title = new JLabel();
+
+ public TabContentModel getModel() {
+ return model;
+ }
+
+ public CustomTab(TabContentModel model) {
+ this.model = model;
+ try {
+ BeanUtil.addPropertyChangeListener(
+ new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ updateTitle();
+ }
+ }, this.model);
+
+ } catch (Exception ex) {
+ log.error("Error while adding the listener to the model modifications", ex);
+ }
+
+ setBackground(null);
+
+ updateTitle();
+ String actionIcon = model.getIcon();
+ if (actionIcon != null) {
+ title.setIcon(SwingUtil.createActionIcon(actionIcon));
+ }
+ add(title);
+ }
+
+ @Override
+ public void setBackground(Color bg) {
+ if (bg == null) {
+ bg = new Color(0, 0, 0, 0);
+ }
+ super.setBackground(bg);
+ revalidate();
+ }
+
+ @Override
+ public void setForeground(Color fg) {
+ super.setForeground(fg);
+ if (title != null) {
+ title.setForeground(fg);
+ }
+ }
+
+ protected void updateTitle() {
+ Font f = UIManager.getDefaults().getFont("Label.font");
+ String titleValue = _(model.getTitle());
+
+ int style;
+ if (model.isModify()) {
+ style = Font.BOLD;
+ titleValue += "*";
+
+ } else if (model.isEmpty()) {
+ style = Font.ITALIC;
+
+ } else {
+ style = Font.PLAIN;
+ }
+
+ title.setText(titleValue);
+ title.setFont(f.deriveFont(style));
+ }
+
+}
Added: application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/DelegateTabContainerHandler.java
===================================================================
--- application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/DelegateTabContainerHandler.java (rev 0)
+++ application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/DelegateTabContainerHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
@@ -0,0 +1,112 @@
+package fr.ifremer.shared.application.swing.tab;
+
+/*
+ * #%L
+ * Ifremer shared :: Application Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 Ifremer, CodeLutin, Tony CHEMIT
+ * %%
+ * 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.shared.application.swing.AbstractApplicationUIHandler;
+import fr.ifremer.shared.application.swing.ApplicationUI;
+
+import javax.swing.DefaultSingleSelectionModel;
+import javax.swing.JTabbedPane;
+import java.awt.Component;
+
+/**
+ * Created on 11/25/13.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class DelegateTabContainerHandler implements TabContainerHandler {
+
+ final JTabbedPane tabbedPane;
+
+ public DelegateTabContainerHandler(JTabbedPane tabbedPane) {
+ this.tabbedPane = tabbedPane;
+ }
+
+ @Override
+ public JTabbedPane getTabPanel() {
+ return tabbedPane;
+ }
+
+ @Override
+ public void init() {
+
+ getTabPanel().setModel(new DefaultSingleSelectionModel() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void setSelectedIndex(int index) {
+ int currentIndex = getTabPanel().getSelectedIndex();
+ boolean mustChangeTab = onTabChanged(currentIndex, index);
+
+ if (mustChangeTab) {
+ super.setSelectedIndex(index);
+ }
+ }
+
+ });
+ }
+
+
+ @Override
+ public boolean onTabChanged(int currentIndex, int newIndex) {
+ boolean result = true;
+ if (currentIndex != newIndex) {
+ TabHandler handler = getTabHandler(currentIndex);
+ if (handler != null) {
+ result = handler.onHideTab(currentIndex, newIndex);
+ }
+
+ handler = getTabHandler(newIndex);
+ if (handler != null) {
+ handler.onShowTab(currentIndex, newIndex);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public TabHandler getTabHandler(int index) {
+ TabHandler tabHandler = null;
+ JTabbedPane tabPanel = getTabPanel();
+ if (index >= 0 && index < tabPanel.getTabCount()) {
+ Component tab = tabPanel.getComponentAt(index);
+ if (ApplicationUI.class.isInstance(tab)) {
+ ApplicationUI tuttiTab = (ApplicationUI) tabPanel.getComponentAt(index);
+ AbstractApplicationUIHandler handler = tuttiTab.getHandler();
+ if (TabHandler.class.isInstance(handler)) {
+ tabHandler = (TabHandler) handler;
+ }
+ }
+ }
+ return tabHandler;
+ }
+
+ @Override
+ public void setCustomTab(int index, TabContentModel model) {
+ getTabPanel().setTabComponentAt(index, new CustomTab(model));
+ }
+}
Property changes on: application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/DelegateTabContainerHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/TabContainerHandler.java
===================================================================
--- application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/TabContainerHandler.java (rev 0)
+++ application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/TabContainerHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
@@ -0,0 +1,68 @@
+package fr.ifremer.shared.application.swing.tab;
+
+/*
+ * #%L
+ * Ifremer shared :: Application Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 Ifremer, CodeLutin, Tony CHEMIT
+ * %%
+ * 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 javax.swing.JTabbedPane;
+
+/**
+ * Created on 11/25/13.
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public interface TabContainerHandler {
+
+ JTabbedPane getTabPanel();
+
+ void init();
+
+ /**
+ * Method called when the user selects a tab.
+ *
+ * @param currentIndex
+ * @param newIndex
+ * @return <code>false</code> if you want to prevent the tab change,
+ * <code>true</code> otherwise
+ */
+ boolean onTabChanged(int currentIndex, int newIndex);
+
+ /**
+ * Returns the tab handler of the tab i.
+ *
+ * @param index the index of the tab
+ * @return the tab handler of the index i if the handler implements
+ * the {@link TabHandler} interface,
+ * <code>null</code> otherwise
+ */
+ TabHandler getTabHandler(int index);
+
+ /**
+ * Sets a {@link CustomTab} as tab component.
+ *
+ * @param index
+ * @param model
+ */
+ void setCustomTab(int index, TabContentModel model);
+}
Property changes on: application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/TabContainerHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/TabContentModel.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TabContentModel.java)
===================================================================
--- application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/TabContentModel.java (rev 0)
+++ application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/TabContentModel.java 2013-11-25 16:03:00 UTC (rev 1387)
@@ -0,0 +1,44 @@
+package fr.ifremer.shared.application.swing.tab;
+
+/*
+ * #%L
+ * Ifremer shared :: Application Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 Ifremer, CodeLutin, Tony CHEMIT
+ * %%
+ * 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%
+ */
+
+/**
+ * Interface defining the models of the tab content UIs.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public interface TabContentModel {
+
+ boolean isEmpty();
+
+ boolean isValid();
+
+ boolean isModify();
+
+ String getTitle();
+
+ String getIcon();
+}
Copied: application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/TabHandler.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TabHandler.java)
===================================================================
--- application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/TabHandler.java (rev 0)
+++ application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/tab/TabHandler.java 2013-11-25 16:03:00 UTC (rev 1387)
@@ -0,0 +1,52 @@
+package fr.ifremer.shared.application.swing.tab;
+
+/*
+ * #%L
+ * Ifremer shared :: Application Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 Ifremer, CodeLutin, Tony CHEMIT
+ * %%
+ * 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%
+ */
+
+/**
+ * Interface describing UI contained in a tab.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 1.0
+ */
+public interface TabHandler {
+
+ /**
+ * Method called when the tab is hidden
+ *
+ * @param currentIndex
+ * @param newIndex
+ * @return <code>false</code> to prevent the tab to be hidden,
+ * <code>true</code> otherwise.
+ */
+ boolean onHideTab(int currentIndex, int newIndex);
+
+ /**
+ * Method called when the tab is shown
+ *
+ * @param currentIndex
+ * @param newIndex
+ */
+ void onShowTab(int currentIndex, int newIndex);
+}
Copied: application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/util/ActionListCellRenderer.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/ActionListCellRenderer.java)
===================================================================
--- application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/util/ActionListCellRenderer.java (rev 0)
+++ application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/util/ActionListCellRenderer.java 2013-11-25 16:03:00 UTC (rev 1387)
@@ -0,0 +1,61 @@
+package fr.ifremer.shared.application.swing.util;
+
+/*
+ * #%L
+ * Ifremer shared :: Application Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 Ifremer, CodeLutin, Tony CHEMIT
+ * %%
+ * 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 javax.swing.Action;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JList;
+import javax.swing.border.EmptyBorder;
+import java.awt.Component;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class ActionListCellRenderer extends DefaultListCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final EmptyBorder border = new EmptyBorder(4, 8, 4, 8);
+
+ @Override
+ public Component getListCellRendererComponent(JList list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus) {
+
+ Component result = super.getListCellRendererComponent(
+ list, value, index, isSelected, cellHasFocus);
+ Action action = ((JButton) value).getAction();
+ setIcon((Icon) action.getValue(Action.LARGE_ICON_KEY));
+ setText((String) action.getValue(Action.NAME));
+ setToolTipText((String) action.getValue(Action.SHORT_DESCRIPTION));
+ setBorder(border);
+ return result;
+ }
+}
Copied: application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/util/Cancelable.java (from rev 1385, branches/tutti-with-ifremer-shared/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java)
===================================================================
--- application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/util/Cancelable.java (rev 0)
+++ application/trunk/application-swing/src/main/java/fr/ifremer/shared/application/swing/util/Cancelable.java 2013-11-25 16:03:00 UTC (rev 1387)
@@ -0,0 +1,36 @@
+package fr.ifremer.shared.application.swing.util;
+
+/*
+ * #%L
+ * Ifremer shared :: Application Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 Ifremer, CodeLutin, Tony CHEMIT
+ * %%
+ * 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%
+ */
+
+/**
+ * To cancel contract.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public interface Cancelable {
+
+ void cancel();
+}
1
0