Tutti-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- 4058 discussions
r391 - in trunk/tutti-persistence/src/main: java/fr/ifremer/tutti/persistence/service resources
by blavenier@users.forge.codelutin.com 11 Feb '13
by blavenier@users.forge.codelutin.com 11 Feb '13
11 Feb '13
Author: blavenier
Date: 2013-02-11 15:40:21 +0100 (Mon, 11 Feb 2013)
New Revision: 391
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/391
Log:
Fix :
- fishingOperation add preconditions on date
- save batchSpecies
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2013-02-11 12:45:44 UTC (rev 390)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2013-02-11 14:40:21 UTC (rev 391)
@@ -34,6 +34,7 @@
import org.hibernate.classic.Session;
import org.hibernate.type.Type;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataIntegrityViolationException;
import java.io.Serializable;
import java.util.Iterator;
@@ -50,6 +51,8 @@
private static final Log log =
LogFactory.getLog(AbstractPersistenceService.class);
+ private boolean debug = false;
+
/**
* Session factory.
*
@@ -146,9 +149,23 @@
}
protected <T extends Serializable> T load(Class<? extends T> clazz, Serializable id) {
+ // TODO BLA : ajouter une annotation qui rejoue une méthode
+ // avec debug=true. puis repasse à faux,
+ // lorsqu'une erreur
+ if (debug) {
+ T load = (T) getCurrentSession().get(clazz, id);
+ if (load == null) {
+ throw new DataIntegrityViolationException("Unable to load entity " + clazz.getName() + " with id="+id+" : not found in database.");
+ }
+ }
T load = (T) getCurrentSession().load(clazz, id);
return load;
}
+
+ protected <T extends Serializable> T get(Class<? extends T> clazz, Serializable id) {
+ T load = (T) getCurrentSession().get(clazz, id);
+ return load;
+ }
protected int queryUpdate(String queryName, Object... params) {
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-02-11 12:45:44 UTC (rev 390)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-02-11 14:40:21 UTC (rev 391)
@@ -316,24 +316,21 @@
// Strata :
Integer strataId = (Integer) source[colIndex++];
if (strataId != null) {
- FishingOperationLocation strata = new FishingOperationLocation();
- strata.setId(strataId.toString());
+ FishingOperationLocation strata = referentialService.getFishingOperationLocation(strataId.toString());
result.setStrata(strata);
}
// Sub Strata :
Integer subStrataId = (Integer) source[colIndex++];
if (subStrataId != null) {
- FishingOperationLocation subStrata = new FishingOperationLocation();
- subStrata.setId(subStrataId.toString());
+ FishingOperationLocation subStrata = referentialService.getFishingOperationLocation(subStrataId.toString());
result.setSubStrata(subStrata);
}
// Localite :
Integer localiteId = (Integer) source[colIndex++];
if (localiteId != null) {
- FishingOperationLocation localite = new FishingOperationLocation();
- localite.setId(localiteId.toString());
+ FishingOperationLocation localite = referentialService.getFishingOperationLocation(localiteId.toString());
result.setLocation(localite);
}
@@ -375,6 +372,10 @@
Preconditions.checkNotNull(bean.getId());
Preconditions.checkNotNull(bean.getCruise());
Preconditions.checkNotNull(bean.getCruise().getId());
+
+ if (bean.getGearShootingStartDate() != null && bean.getGearShootingEndDate() != null) {
+ Preconditions.checkArgument(bean.getGearShootingStartDate().equals(bean.getGearShootingEndDate()) == false);
+ }
getCurrentSession().clear();
getCurrentSession().setFlushMode(FlushMode.COMMIT);
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-02-11 12:45:44 UTC (rev 390)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-02-11 14:40:21 UTC (rev 391)
@@ -104,6 +104,15 @@
List<FishingOperationLocation> getAllFishingOperationLocation(String zoneId, String strataId, String subStrataId);
/**
+ * Get a location by id (location could be of any type : strata, substrata, localite, etc.).
+ *
+ * @param id the id of locations to load
+ * @return the locations with given ids
+ * @since 1.0
+ */
+ FishingOperationLocation getFishingOperationLocation(String id);
+
+ /**
* @return all scientific vessels (used by a {@link Cruise}).
* @see Cruise#getVessel()
* @see Cruise#setVessel(List)
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-02-11 12:45:44 UTC (rev 390)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-02-11 14:40:21 UTC (rev 391)
@@ -212,7 +212,27 @@
parentLocationLevelId);
return result;
}
+
+ @Override
+ public FishingOperationLocation getFishingOperationLocation(String id) {
+ Object[] source = queryUnique(
+ "fishingOperationLocationById",
+ "locationId", IntegerType.INSTANCE, Integer.valueOf(id)
+ );
+ if (source == null) {
+ return null;
+ }
+ FishingOperationLocation target = new FishingOperationLocation();
+ target.setId(String.valueOf(source[0]));
+ target.setLabel((String) source[1]);
+ target.setName((String) source[2]);
+ target.setLocationLevel((Integer) source[3]);
+ setStatus((fr.ifremer.adagio.core.dao.referential.Status) source[4], target);
+
+ return target;
+ }
+
@Override
public List<Vessel> getAllScientificVessel() {
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-02-11 12:45:44 UTC (rev 390)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-02-11 14:40:21 UTC (rev 391)
@@ -170,13 +170,18 @@
Preconditions.checkNotNull(bean.getFishingOperation());
Preconditions.checkNotNull(bean.getFishingOperation().getId());
// TODO BLA uncomment this after v1.0 :
- // Preconditions.checkNotNull(bean.getCatchBatch());
+ //Preconditions.checkNotNull(bean.getCatchBatch());
+
+ getCurrentSession().setFlushMode(FlushMode.ALWAYS);
SortingBatch batch = SortingBatch.Factory.newInstance();
beanToEntity(bean, batch, parentBatchId, true);
batch = sortingBatchDao.create(batch);
bean.setId(String.valueOf(batch.getId()));
+
+ getCurrentSession().flush();
+
return bean;
}
@@ -220,7 +225,9 @@
@Override
public void changeSpeciesBatchSpecies(String batchId, Species species) {
- //TODO
+
+ log.debug("Changing species for batch id="+batchId);
+
}
@Override
@@ -330,7 +337,6 @@
// TODO BLA : prendre le service du 1er saisisseur ?
Integer recorderDepartmentId = enumeration.DEPARTMENT_ID_UNKNOWN_RECORDER_DEPARTMENT;
-
// Create lists to store all updates, then remove not updated items
Set<QuantificationMeasurement> notChangedQuantificationMeasurements = new HashSet<QuantificationMeasurement>();
if (target.getQuantificationMeasurements() != null) {
@@ -359,12 +365,12 @@
}
// Weight or SampleCategoryWeight
- if (copyIfNull && source.getWeight() == null) {
+ if (copyIfNull && source.getWeight() == null && source.getSampleCategoryWeight() == null) {
// Nothing to do : will be removed later, using notChangedSortingMeasurements
- } else if (source.getSampleCategoryWeight() != null) {
+ } else if (source.getSampleCategoryWeight() != null && source.getWeight() == null) {
QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target, enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getSampleCategoryWeight(), true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
- } else if (source.getWeight() != null) {
+ } else if (source.getWeight() != null && source.getSampleCategoryWeight() == null) {
QuantificationMeasurement quantificationMeasurement = measurementHelper.setQuantificationMeasurement(target, enumeration.PMFM_ID_WEIGHT_MEASURED, recorderDepartmentId, source.getWeight(), true);
notChangedQuantificationMeasurements.remove(quantificationMeasurement);
}
@@ -403,7 +409,7 @@
if (copyIfNull && (source.getSpecies() == null || parentBatchId != null)) {
target.setReferenceTaxon(null);
} else if (source.getSpecies() != null && parentBatchId == null) {
- ReferenceTaxon referenceTaxon = load(ReferenceTaxonImpl.class, Integer.valueOf(source.getSpecies().getId()));
+ ReferenceTaxon referenceTaxon = load(ReferenceTaxonImpl.class, Integer.valueOf(source.getSpecies().getReferenceTaxonId()));
target.setReferenceTaxon(referenceTaxon);
}
Modified: trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml
===================================================================
--- trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-02-11 12:45:44 UTC (rev 390)
+++ trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-02-11 14:40:21 UTC (rev 391)
@@ -575,6 +575,22 @@
<query-param name="statusValidCode" type="java.lang.String"/>
<query-param name="statusTemporaryCode" type="java.lang.String"/>
</query>
+
+ <query cacheable="true" name="fishingOperationLocationById">
+ <![CDATA[
+ SELECT
+ l.id as locationId,
+ l.label as locationLabel,
+ l.name as locationName,
+ l.locationLevel.id as locationLevelId,
+ l.status as status
+ FROM
+ LocationImpl l
+ WHERE
+ l.id = :locationId
+ ]]>
+ <query-param name="locationId" type="java.lang.Integer"/>
+ </query>
<!-- [REF-04] et [REF-05] Get all vessel for a given vesselType -->
<query cacheable="true" name="allVessels">
1
0
r390 - in trunk/tutti-persistence/src/main: java/fr/ifremer/tutti/persistence/service resources
by blavenier@users.forge.codelutin.com 11 Feb '13
by blavenier@users.forge.codelutin.com 11 Feb '13
11 Feb '13
Author: blavenier
Date: 2013-02-11 13:45:44 +0100 (Mon, 11 Feb 2013)
New Revision: 390
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/390
Log:
Fix :
- do not load Spring context twice
Added:
trunk/tutti-persistence/src/main/resources/tuttiBeanRefFactory.xml
Removed:
trunk/tutti-persistence/src/main/resources/beanRefFactory.xml
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2013-02-11 08:14:47 UTC (rev 389)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2013-02-11 12:45:44 UTC (rev 390)
@@ -42,9 +42,9 @@
}
public static void initTuttiDefault() {
- instance().init("beanRefFactory.xml", "TuttiBeanRefFactory");
+ instance().init("tuttiBeanRefFactory.xml", "TuttiBeanRefFactory");
}
-
+
public static void initTutti(String beanFactoryReferenceLocation,
String beanRefFactoryReferenceId) {
instance().init(beanFactoryReferenceLocation, beanRefFactoryReferenceId);
Deleted: trunk/tutti-persistence/src/main/resources/beanRefFactory.xml
===================================================================
--- trunk/tutti-persistence/src/main/resources/beanRefFactory.xml 2013-02-11 08:14:47 UTC (rev 389)
+++ trunk/tutti-persistence/src/main/resources/beanRefFactory.xml 2013-02-11 12:45:44 UTC (rev 390)
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- #%L
- Tutti :: Persistence API
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2012 Ifremer
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/gpl-3.0.html>.
- #L%
- -->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
-
- <bean id="TuttiBeanRefFactory"
- class="org.springframework.context.support.ClassPathXmlApplicationContext">
- <constructor-arg>
- <list>
- <value>applicationContext-conf.xml</value>
- <value>applicationContext-dataSource-${dataSource.type}.xml</value>
- <value>applicationContext-entities.xml</value>
- <value>applicationContext-service.xml</value>
- <value>applicationContext-service-tutti.xml</value>
- </list>
- </constructor-arg>
- </bean>
-
-</beans>
\ No newline at end of file
Added: trunk/tutti-persistence/src/main/resources/tuttiBeanRefFactory.xml
===================================================================
--- trunk/tutti-persistence/src/main/resources/tuttiBeanRefFactory.xml (rev 0)
+++ trunk/tutti-persistence/src/main/resources/tuttiBeanRefFactory.xml 2013-02-11 12:45:44 UTC (rev 390)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ Tutti :: Persistence API
+ $Id: beanRefFactory.xml 300 2013-02-02 14:11:58Z tchemit $
+ $HeadURL: http://svn.forge.codelutin.com/svn/tutti/trunk/tutti-persistence/src/main/r… $
+ %%
+ Copyright (C) 2012 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+ <import resource="classpath*:applicationContext-conf.xml"/>
+
+ <bean id="TuttiBeanRefFactory"
+ class="org.springframework.context.support.ClassPathXmlApplicationContext">
+ <constructor-arg>
+ <list>
+ <value>classpath:applicationContext-conf.xml</value>
+ <value>classpath:applicationContext-dataSource-${dataSource.type}.xml</value>
+ <value>classpath:applicationContext-entities.xml</value>
+ <value>classpath:applicationContext-service.xml</value>
+ <value>classpath:applicationContext-service-tutti.xml</value>
+ </list>
+ </constructor-arg>
+ </bean>
+
+</beans>
\ No newline at end of file
1
0
r389 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: . content/cruise content/home content/operation content/operation/catches content/operation/catches/species content/operation/catches/species/frequency content/operation/catches/species/split content/program content/protocol util
by tchemit@users.forge.codelutin.com 11 Feb '13
by tchemit@users.forge.codelutin.com 11 Feb '13
11 Feb '13
Author: tchemit
Date: 2013-02-11 09:14:47 +0100 (Mon, 11 Feb 2013)
New Revision: 389
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/389
Log:
- debug select - save - cancel of fishing operation (pretty cool ?)
- debug save - cancel of catchBatch
- reformat code
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiTabContainerUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -212,7 +212,7 @@
return handler.getModel();
}
- protected <S extends TuttiService> S getService(Class<S> serviceType) {
+ protected <S extends TuttiService> S getService(Class<S> serviceType) {
return getContext().getService(serviceType);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -25,7 +25,6 @@
*/
import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.referential.Gear;
@@ -38,7 +37,6 @@
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.validator.swing.SwingValidator;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -31,12 +31,12 @@
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import org.apache.commons.lang3.StringUtils;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
import java.util.Date;
import java.util.List;
-import org.apache.commons.lang3.StringUtils;
/**
* Model of UI {@link EditCruiseUI}.
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -31,9 +31,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.JOptionPane;
import java.awt.event.ActionEvent;
import java.util.List;
-import javax.swing.JOptionPane;
import static org.nuiton.i18n.I18n._;
@@ -63,16 +63,16 @@
@Override
protected boolean prepareAction(ActionEvent event) {
boolean result = super.prepareAction(event);
-
+
TuttiProtocol protocol = getHandler().getModel().getProtocol();
int answer = JOptionPane.showConfirmDialog(
- getHandler().getUI(),
- _("tutti.action.deleteProtocol.message", protocol.getName()),
+ getHandler().getUI(),
+ _("tutti.action.deleteProtocol.message", protocol.getName()),
_("tutti.action.deleteProtocol.title"),
JOptionPane.OK_CANCEL_OPTION
- );
+ );
result &= answer == JOptionPane.OK_OPTION;
-
+
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -140,125 +140,132 @@
return saveCatchBatchAction;
}
+
@Override
- protected void doAction(ActionEvent event) throws Exception {
+ protected boolean prepareAction(ActionEvent event) {
+ boolean canContinue = super.prepareAction(event);
+ if (canContinue && checkPreviousEdit) {
+ FishingOperationsUI ui = getUI();
- if (log.isInfoEnabled()) {
- log.info("Try to edit fishingOperation: " + fishingOperation);
- }
+ final FishingOperationsUIModel model = ui.getModel();
- FishingOperationsUI ui = getUI();
+ FishingOperation editFishingOperation = model.getEditFishingOperation();
- FishingOperationsUIModel model = ui.getModel();
+ String editFishingOperationId = null;
- FishingOperation editFishingOperation = model.getEditFishingOperation();
+ if (editFishingOperation == null) {
- boolean canContinue;
+ // no previous fishing operation in edition, can continue
+ canContinue = true;
+ } else {
- String editFishingOperationId;
+ editFishingOperationId = editFishingOperation.getId();
- if (editFishingOperation == null) {
+ boolean create = TuttiEntities.isNew(editFishingOperation);
- // no previous fishing operation in edition, can continue
- canContinue = true;
- editFishingOperationId = null;
+ // must close current edition
+ String message;
- } else {
+ if (create) {
+ message = _("tutti.dialog.askSaveBeforeLeaving.createFishingOperation");
+ } else {
+ message = _("tutti.dialog.askSaveBeforeLeaving.saveFishingOperation");
+ }
- editFishingOperationId = editFishingOperation.getId();
+ int answer = getHandler().askSaveBeforeLeaving(message);
- boolean create = TuttiEntities.isNew(editFishingOperation);
+ canContinue = false;
+ switch (answer) {
+ case JOptionPane.OK_OPTION:
- // must close current edition
- String message;
+ // persist previous fishing operation
+ getSaveFishingOperationAction().setUpdateUI(false);
+ getSaveFishingOperationAction().actionPerformed(event);
+ getSaveCatchBatchAction().setUpdateUI(false);
+ getSaveCatchBatchAction().actionPerformed(event);
- if (create) {
- message = _("tutti.dialog.askSaveBeforeLeaving.createFishingOperation");
- } else {
- message = _("tutti.dialog.askSaveBeforeLeaving.saveFishingOperation");
- }
+ canContinue = true;
+ break;
- int answer = getHandler().askSaveBeforeLeaving(message);
+ case JOptionPane.NO_OPTION:
- canContinue = false;
- switch (answer) {
- case JOptionPane.OK_OPTION:
+ // won't save modification
+ // so since we will edit a new operation, nothing to do here
- // persist previous fishing operation
- getSaveFishingOperationAction().setUpdateUI(false);
- getSaveFishingOperationAction().actionPerformed(event);
- getSaveCatchBatchAction().setUpdateUI(false);
- getSaveCatchBatchAction().actionPerformed(event);
+ canContinue = true;
+ break;
+ }
+ }
+ if (!canContinue) {
- canContinue = true;
- break;
+ // rollback selected fishing operation
+ FishingOperation selectFishingOperation =
+ model.getFishingOperation(editFishingOperationId);
- case JOptionPane.NO_OPTION:
+ model.setEditionAdjusting(true);
+ try {
+ model.setSelectedFishingOperation(selectFishingOperation);
+ } finally {
+ model.setEditionAdjusting(false);
+ }
+ }
+ }
- // won't save modification
- // so since we will edit a new operation, nothing to do here
+ return canContinue;
+ }
- canContinue = true;
- break;
- }
+ @Override
+ protected void doAction(ActionEvent event) throws Exception {
+
+ if (log.isInfoEnabled()) {
+ log.info("Try to edit fishingOperation: " + fishingOperation);
}
- if (canContinue) {
+ FishingOperationsUI ui = getUI();
- // edit new fishing operation
- if (log.isInfoEnabled()) {
- log.info("Edit in ui fishingOperation: " + fishingOperation);
- }
+ FishingOperationsUIModel model = ui.getModel();
- selectNewFishingOperation(fishingOperation);
+ // edit new fishing operation
+ if (log.isInfoEnabled()) {
+ log.info("Edit in ui fishingOperation: " + fishingOperation);
+ }
- selectNewCatchBatch(fishingOperation);
+ // now fishing operation is edited
+ model.setEditFishingOperation(fishingOperation);
- JTabbedPane form = ui.getTabPane();
- JLabel noContentPane = ui.getNoTraitPane();
+ loadFishingOperation(fishingOperation);
- if (fishingOperation == null) {
+ loadCatchBatch(fishingOperation, true);
- // nothing to display
+ JTabbedPane form = ui.getTabPane();
+ JLabel noContentPane = ui.getNoTraitPane();
- ui.remove(form);
+ if (fishingOperation == null) {
- // just display <no trait!>
- ui.add(noContentPane, BorderLayout.CENTER);
+ // nothing to display
- } else {
+ ui.remove(form);
- ui.remove(noContentPane);
+ // just display <no trait!>
+ ui.add(noContentPane, BorderLayout.CENTER);
- // wait last minute to display (avoid dirty display effects)
- ui.add(form, BorderLayout.CENTER);
- }
-
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- getUI().repaint();
- }
- });
} else {
- // user cancel save of previous bean
+ ui.remove(noContentPane);
- // get previous edit fishing operation (in selection model)
- FishingOperation selectFishingOperation =
- model.getFishingOperation(editFishingOperationId);
+ // wait last minute to display (avoid dirty display effects)
+ ui.add(form, BorderLayout.CENTER);
+ }
- model.setEditionAdjusting(true);
-
- try {
- model.setSelectedFishingOperation(selectFishingOperation);
- } finally {
- model.setEditionAdjusting(false);
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ getUI().repaint();
}
- }
+ });
}
- protected void selectNewFishingOperation(FishingOperation bean) {
+ public void loadFishingOperation(FishingOperation bean) {
EditFishingOperationUI ui = getUI().getFishingOperationTabContent();
@@ -343,7 +350,7 @@
handler.installStartDateListener();
}
- protected void selectNewCatchBatch(FishingOperation bean) {
+ public void loadCatchBatch(FishingOperation bean, boolean loadOtherTabs) {
boolean empty = bean == null || TuttiEntities.isNew(bean);
@@ -401,6 +408,7 @@
decorator.toString(fishingOperation));
}
+
// 3) Propagate title to others tabs
ui.getCatchesCaracteristicsTabPane().setTitle(fishingOperationText);
ui.getSpeciesTabFishingOperationReminderLabel().setTitle(fishingOperationText);
@@ -409,14 +417,18 @@
// ui.getMacroWasteTabFishingOperationReminderLabel().setTitle(fishingOperationText);
// ui.getAccidentalTabFishingOperationReminderLabel().setTitle(fishingOperationText);
- // 4) Propagate new selected fishingoperation to others tabs
+ if (loadOtherTabs) {
- ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean);
+ // 4) Propagate new selected fishingoperation to others tabs
+
+ ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean);
// ui.getBenthosTabContent().getHandler().selectFishingOperation(bean);
// ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean);
// ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean);
// ui.getAccidentalTabContent().getHandler().selectFishingOperation(bean);
+
+ }
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -37,7 +37,6 @@
import fr.ifremer.tutti.persistence.entities.referential.Zone;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.CaracteristicTabUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUIModel;
@@ -318,22 +317,6 @@
}
@Override
- public boolean canCloseUI(TuttiScreen nextScreen) {
- boolean result = !isAModelModified();
- if (!result) {
- int answer = askSaveBeforeLeaving(ui);
- ActionEvent event = new ActionEvent(nextScreen, nextScreen.ordinal(), null);
- switch (answer) {
- case JOptionPane.OK_OPTION:
- doAction(ui.getSaveButton(), event);
- break;
- }
- result = answer == JOptionPane.NO_OPTION;
- }
- return result;
- }
-
- @Override
public boolean onHideTab(int currentIndex, int newIndex) {
boolean result = !isAModelModified();
if (!result) {
@@ -342,10 +325,12 @@
switch (answer) {
case JOptionPane.OK_OPTION:
doAction(ui.getSaveButton(), event);
+ result = true;
break;
case JOptionPane.NO_OPTION:
doAction(ui.getCancelButton(), event);
+ result = true;
break;
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -196,7 +196,7 @@
protected String multirigAggregation;
protected CoordinateEditorType coordinateEditorType;
-
+
protected List<FishingOperation> existingOperations;
protected static Binder<EditFishingOperationUIModel, FishingOperation> toBeanBinder =
@@ -726,7 +726,7 @@
public void setExistingOperations(List<FishingOperation> existingOperations) {
this.existingOperations = existingOperations;
}
-
+
public void convertGearShootingCoordinatesDDToDMS() {
SexagecimalPosition position;
Integer degree;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -160,24 +160,26 @@
} else {
operation = persistenceService.getFishingOperation(newValue.getId());
}
- getModel().setEditFishingOperation(operation);
+ editFishingOperationAction.setFishingOperation(operation);
+ editFishingOperationAction.actionPerformed(null);
+// getModel().setEditFishingOperation(operation);
}
}
});
- model.addPropertyChangeListener(FishingOperationsUIModel.PROPERTY_EDITED_FISHING_OPERATION, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (log.isDebugEnabled()) {
- log.debug("propertyChange " + FishingOperationsUIModel.PROPERTY_EDITED_FISHING_OPERATION);
- }
-
- // only rebuild stuff if model is not adjusting
- editFishingOperationAction.setFishingOperation((FishingOperation) evt.getNewValue());
- editFishingOperationAction.actionPerformed(null);
-
- }
- });
+// model.addPropertyChangeListener(FishingOperationsUIModel.PROPERTY_EDITED_FISHING_OPERATION, new PropertyChangeListener() {
+// @Override
+// public void propertyChange(PropertyChangeEvent evt) {
+// if (log.isDebugEnabled()) {
+// log.debug("propertyChange " + FishingOperationsUIModel.PROPERTY_EDITED_FISHING_OPERATION);
+// }
+//
+// // only rebuild stuff if model is not adjusting
+// editFishingOperationAction.setFishingOperation((FishingOperation) evt.getNewValue());
+// editFishingOperationAction.actionPerformed(null);
+//
+// }
+// });
model.addPropertyChangeListener(FishingOperationsUIModel.PROPERTY_FISHING_OPERATION, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
@@ -208,10 +210,15 @@
@Override
public boolean canCloseUI(TuttiScreen nextScreen) {
- boolean result = super.canCloseUI(nextScreen);
- if (getTabPanel().getSelectedIndex() == 0) {
- result = ui.getFishingOperationTabContent().getHandler().canCloseUI(nextScreen);
- }
+// boolean result = super.canCloseUI(nextScreen);
+ // try to reset current fishing operation, if afterall the fishing operation still
+ // there, it means user cancel save operation, so stay here
+ getUI().getFishingOperationComboBox().setSelectedItem(null);
+// getModel().setSelectedFishingOperation(null);
+ boolean result = getModel().getSelectedFishingOperation() == null;
+// if (getTabPanel().getSelectedIndex() == 0) {
+// result = ui.getFishingOperationTabContent().getHandler().canCloseUI(nextScreen);
+// }
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -24,8 +24,11 @@
* #L%
*/
+import com.google.common.base.Preconditions;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
+import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,6 +57,8 @@
*/
protected boolean updateUI;
+ protected EditFishingOperationAction editAction;
+
public CancelEditCatchBatchAction(EditCatchesUIHandler handler) {
super(handler,
"cancelEditCatchBatch",
@@ -64,21 +69,34 @@
);
}
+ public EditFishingOperationAction getEditAction() {
+ if (editAction == null) {
+ editAction = new EditFishingOperationAction(getHandler().getParentHandler());
+ }
+ return editAction;
+ }
+
@Override
protected void doAction(ActionEvent event) throws Exception {
if (getModel().isCreate()) {
- if (log.isInfoEnabled()) {
- log.info("Cancel creation for catchBatch");
- }
// cancel to create a catch batch ?
-
+ // Should never happen ?
+ Preconditions.checkState(
+ false,
+ "Can't cancel edition of a not persisted catchBatch!");
} else {
if (log.isInfoEnabled()) {
- log.info("Can edition of catchBatch");
+ log.info("Can edition of catchBatch (will reload catchBatch)");
}
+
+ FishingOperation operation = getModel().getFishingOperation();
+
+ //TODO Should we also reload other tabs ??? Probably yes
+
+ getEditAction().loadCatchBatch(operation, false);
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -26,6 +26,7 @@
import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
+import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUIHandler;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiTabContainerUIHandler;
import fr.ifremer.tutti.ui.swing.util.TabHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
@@ -35,6 +36,7 @@
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTitledPanel;
+import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
@@ -74,8 +76,10 @@
*/
private final TuttiBeanMonitor<EditCatchesUIModel> catchBatchMonitor;
+ protected final FishingOperationsUI parentUi;
public EditCatchesUIHandler(FishingOperationsUI parentUi, EditCatchesUI ui) {
super(parentUi.getHandler().getContext(), ui);
+ this.parentUi=parentUi;
// this.persistenceService = context.getService(PersistenceService.class);
this.catchBatchMonitor = new TuttiBeanMonitor<EditCatchesUIModel>(
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_WEIGHT,
@@ -135,6 +139,7 @@
return ui.getValidator();
}
+
@Override
protected JTabbedPane getTabPanel() {
return ui.getTabPane();
@@ -145,13 +150,36 @@
//FIXME 20130203 kmorin: cannot change tab if model is modified
// (I do not even know why it is set to modified and have no time
// before the demo)
-// AbstractTuttiBeanUIModel model = getModel();
-// boolean result = model.isValid();
-// if (result && model.isModify()) {
-// save();
-// }
-// return result;
- return true;
+ EditCatchesUIModel model = getModel();
+ boolean result = model.isValid();
+ if (model.isModify()) {
+ int answer = askSaveBeforeLeaving(getUI());
+ switch (answer) {
+ case JOptionPane.OK_OPTION:
+
+ // persist catch batch
+ doAction(getUI().getSaveButton(), null);
+
+ result = true;
+ break;
+
+ case JOptionPane.NO_OPTION:
+
+ // won't save modification
+ // so since we will edit a new operation, nothing to do here
+
+ // persist catch batch
+ doAction(getUI().getCancelButton(), null);
+
+ result = true;
+ break;
+ default:
+
+ // other case, use cancel action
+ result = false;
+ }
+ }
+ return result;
}
@Override
@@ -167,7 +195,15 @@
return catchBatchMonitor;
}
-// public void selectFishingOperation(FishingOperation bean,
+ public FishingOperationsUI getParentUi() {
+ return parentUi;
+ }
+
+ public FishingOperationsUIHandler getParentHandler() {
+ return getParentUi().getHandler();
+ }
+
+ // public void selectFishingOperation(FishingOperation bean,
// String fishingOperationText) {
//
// boolean empty = bean == null;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -28,7 +28,7 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
import org.nuiton.util.beans.Binder;
-import org.nuiton.util.beans.BinderModelBuilder;
+import org.nuiton.util.beans.BinderFactory;
import static org.nuiton.i18n.I18n._;
@@ -80,8 +80,9 @@
public static final String PROPERTY_CATCH_BATCH = "catchBatch";
- protected static final Binder<CatchBatch, EditCatchesUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(CatchBatch.class, EditCatchesUIModel.class)
+ /*protected static final Binder<CatchBatch, EditCatchesUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(CatchBatch.class, EditCatchesUIModel.class)
.addSimpleProperties(
+ PROPERTY_CATCH_TOTAL_WEIGHT,
PROPERTY_SPECIES_TOTAL_WEIGHT,
PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT,
PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT,
@@ -112,8 +113,12 @@
PROPERTY_PLANKTON_TOTAL_WEIGHT,
PROPERTY_PLANKTON_TOTAL_SAMPLE_WEIGHT,
PROPERTY_MACRO_WASTE_TOTAL_WEIGHT
- ).toBinder();
+ ).toBinder();*/
+ protected static final Binder<CatchBatch, EditCatchesUIModel> fromBeanBinder = BinderFactory.newBinder(CatchBatch.class, EditCatchesUIModel.class);
+
+ protected static final Binder<EditCatchesUIModel, CatchBatch> toBeanBinder = BinderFactory.newBinder(EditCatchesUIModel.class, CatchBatch.class);
+
protected Float speciesTotalWeight;
protected Float speciesTotalSortedWeight;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -111,6 +111,7 @@
persistenceService.saveCatchBatch(catchBatch);
monitor.clearModified();
+ getModel().setModify(false);
}
getUI().getSpeciesTabContent().getHandler().clearTableSelection();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/RenameSpeciesBatchAction.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -25,9 +25,7 @@
*/
import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -70,21 +68,21 @@
boolean result = super.prepareAction(event);
SpeciesBatchUIHandler handler = getHandler();
-
+
SpeciesBatchTableModel tableModel = handler.getTableModel();
JXTable table = handler.getTable();
SpeciesBatchRowModel row = tableModel.getEntry(table.getSelectedRow());
-
+
SpeciesBatchUIModel model = handler.getModel();
List<Species> speciesList = Lists.newArrayList(model.getAllSpecies());
speciesList.removeAll(
model.getSpeciesUsed().get(
- row.getSortedUnsortedCategoryValue()));
+ row.getSortedUnsortedCategoryValue()));
selectedSpecies = getHandler().openAddSpeciesDialog(
_("tutti.title.selectSpecies"),
speciesList
- );
+ );
result &= selectedSpecies != null;
return result;
@@ -101,17 +99,17 @@
// TODO 20130206 kmorin uncomment the following lines when the service is available
// PersistenceService persistenceService = getContext().getService(PersistenceService.class);
// persistenceService.changeSpeciesBatchSpecies(row.getId(), selectedSpecies);
-
+
Collection<Species> speciesUSed = handler.getModel().getSpeciesUsed()
.get(row.getSortedUnsortedCategoryValue());
speciesUSed.remove(row.getSpecies());
changeChildrenSpecies(row, selectedSpecies);
speciesUSed.add(selectedSpecies);
-
+
selectedSpecies = null;
}
- protected void changeChildrenSpecies(SpeciesBatchRowModel row,
+ protected void changeChildrenSpecies(SpeciesBatchRowModel row,
Species species) {
row.setSpecies(species);
List<SpeciesBatchRowModel> children = row.getBatchChild();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -58,7 +58,7 @@
* @since 0.3
*/
protected Float categoryWeight;
-
+
/**
* Sample computed weight.
*
@@ -112,9 +112,9 @@
}
public boolean isEmpty() {
- return categoryValue == null
- && categoryWeight == null
- && computedWeight == null;
+ return categoryValue == null
+ && categoryWeight == null
+ && computedWeight == null;
}
public boolean isEmptyOrValid() {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -218,7 +218,7 @@
} else {
Float number = sampleCategory.getCategoryWeight();
Float computedNumber = sampleCategory.getComputedWeight();
-
+
text = "<html>" + categoryDecorator.toString(categoryValue) + " / ";
if (number != null) {
@@ -228,7 +228,7 @@
} else {
text += "-";
}
-
+
text += "</html>";
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -59,7 +59,7 @@
public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_VALUE = "sortedUnsortedCategoryValue";
public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT = "sortedUnsortedCategoryWeight";
-
+
public static final String PROPERTY_SORTED_UNSORTED_COMPUTED_WEIGHT = "sortedUnsortedComputedWeight";
public static final String PROPERTY_SIZE_CATEGORY = "sizeCategory";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-02-11 08:14:47 UTC (rev 389)
@@ -156,7 +156,8 @@
<JRadioButton id='filterSpeciesBatchRootButton'
onActionPerformed='model.setTableViewMode(TableViewMode.ROOT)'/>
</JPanel>
- <JButton id='computeSpeciesBatchButton' constraints='BorderLayout.EAST'
+ <JButton id='computeSpeciesBatchButton'
+ constraints='BorderLayout.EAST'
onActionPerformed='handler.computeSpeciesBatch()'/>
</JPanel>
</cell>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -843,20 +843,20 @@
}
row.setComputedNumber(totalNumber);
-
+
SampleCategory finestCategory;
if (row.getAgeCategory().isValid()) {
finestCategory = row.getAgeCategory();
-
+
} else if (row.getMaturityCategory().isValid()) {
finestCategory = row.getMaturityCategory();
-
+
} else if (row.getSexCategory().isValid()) {
finestCategory = row.getSexCategory();
-
+
} else if (row.getSizeCategory().isValid()) {
finestCategory = row.getSizeCategory();
-
+
} else {
finestCategory = row.getSortedUnsortedCategory();
}
@@ -865,7 +865,7 @@
}
}
-
+
public void computeSpeciesBatch() {
Float totalSortedWeight = 0f;
Float totalUnsortedWeight = 0f;
@@ -876,8 +876,8 @@
if (weight == null) {
JOptionPane.showMessageDialog(
ui,
- _("tutti.dialog.catches.species.computeWeight.error.message"),
- _("tutti.dialog.catches.species.computeWeight.error.title"),
+ _("tutti.dialog.catches.species.computeWeight.error.message"),
+ _("tutti.dialog.catches.species.computeWeight.error.title"),
JOptionPane.ERROR_MESSAGE);
totalSortedWeight = null;
totalUnsortedWeight = null;
@@ -912,7 +912,7 @@
sum += weight;
}
}
-
+
SampleCategory finestCategory;
if (row.getAgeCategory().isValid()) {
finestCategory = row.getAgeCategory();
@@ -937,13 +937,13 @@
if (sum != null && weight == null) {
finestCategory.setComputedWeight(sum);
result = sum;
-
+
} else {
result = weight;
}
return result;
}
-
+
protected void saveRows(Iterable<SpeciesBatchRowModel> rows) {
for (SpeciesBatchRowModel row : rows) {
saveRow(row);
@@ -1081,7 +1081,7 @@
if (enableSplit) {
// can split if selected batch is a leaf
- enableSplit = row.isBatchLeaf()
+ enableSplit = row.isBatchLeaf()
&& row.getComputedNumber() == null;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -156,7 +156,7 @@
} else {
// transfer rows to editor
List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList();
-
+
for (SpeciesFrequencyRowModel row : frequencyModel.getRows()) {
if (row.isValid()) {
@@ -174,7 +174,7 @@
editRow.setNumber(null);
}
-
+
// update frequencies total
ui.getHandler().updateTotalFromFrequencies(editRow);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -54,7 +54,7 @@
* @since 0.3
*/
protected final SampleCategory<Serializable> category = SampleCategory.newSample(null);
-
+
protected static final Binder<SplitSpeciesBatchRowModel, SplitSpeciesBatchRowModel> fromBeanBinder =
BinderFactory.newBinder(SplitSpeciesBatchRowModel.class,
SplitSpeciesBatchRowModel.class);
@@ -106,5 +106,5 @@
category.setCategoryWeight(weight);
firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
}
-
+
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -46,7 +46,7 @@
SplitSpeciesBatchRowModel.PROPERTY_VALID,
n_("tutti.table.species.sampleCategory.header.selected"),
n_("tutti.table.species.sampleCategory.header.selected"));
-
+
public static final ColumnIdentifier<SplitSpeciesBatchRowModel> EDITABLE_CATEGORY_VALUE = ColumnIdentifier.newId(
SplitSpeciesBatchRowModel.PROPERTY_CATEGORY_VALUE,
n_("tutti.table.species.sampleCategory.header.category"),
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -342,7 +342,7 @@
addBooleanColumnToModel(columnModel, SplitSpeciesBatchTableModel.SELECTED, getTable());
}
-
+
boolean editableCategoryValue = false;
if (category != null) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -76,7 +76,7 @@
loadedPrograms.add(persistenceService.getProgram(program.getId()));
}
model.setExistingPrograms(loadedPrograms);
-
+
String surveyId = context.getProgramId();
if (surveyId == null) {
@@ -92,7 +92,7 @@
Program program = persistenceService.getProgram(surveyId);
model.fromBean(program);
-
+
model.getExistingPrograms().remove(program);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIModel.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUIModel.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -27,10 +27,11 @@
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.referential.Zone;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
-import java.util.List;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
+import java.util.List;
+
/**
* Bean to edit a program.
*
@@ -52,7 +53,7 @@
protected String comment;
protected Zone zone;
-
+
private List<Program> existingPrograms;
protected static Binder<EditProgramUIModel, Program> toBeanBinder =
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -25,10 +25,8 @@
*/
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.service.TuttiService;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
-import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiTabContainerUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiTabContainerUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiTabContainerUIHandler.java 2013-02-11 08:14:47 UTC (rev 389)
@@ -55,7 +55,7 @@
protected abstract JTabbedPane getTabPanel();
/**
- * Method called when the user selects a tab
+ * Method called when the user selects a tab.
*
* @param currentIndex
* @param newIndex
1
0
r388 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation: . catches
by tchemit@users.forge.codelutin.com 10 Feb '13
by tchemit@users.forge.codelutin.com 10 Feb '13
10 Feb '13
Author: tchemit
Date: 2013-02-10 16:04:13 +0100 (Sun, 10 Feb 2013)
New Revision: 388
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/388
Log:
begin of save operation cinematic
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java
Removed:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SelectFishingOperationAction.java
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -46,7 +46,12 @@
/** Logger. */
private static final Log log = LogFactory.getLog(SaveFishingOperationAction.class);
- private final SelectFishingOperationAction delegate;
+ /**
+ * Delegate edit action.
+ *
+ * @since 1.0
+ */
+ protected EditFishingOperationAction editAction;
public CancelEditFishingOperationAction(EditFishingOperationUIHandler handler) {
super(handler,
@@ -56,9 +61,15 @@
_("tutti.action.cancel.editFishingOperation.tip"),
true
);
- delegate = new SelectFishingOperationAction(handler.getParentUi().getHandler());
}
+ public EditFishingOperationAction getEditAction() {
+ if (editAction == null) {
+ editAction = new EditFishingOperationAction(getHandler().getParentUi().getHandler());
+ }
+ return editAction;
+ }
+
/**
* If the event source is an EditFishingOperationUIHandler,
* then the tab panel of the parent switch to the index set
@@ -69,38 +80,39 @@
*/
@Override
protected void doAction(ActionEvent event) throws Exception {
- FishingOperationsUI parentUi = getHandler().getParentUi();
- FishingOperationsUIHandler parentHandler = parentUi.getHandler();
+
+ EditFishingOperationAction action = getEditAction();
+
if (getModel().isCreate()) {
if (log.isInfoEnabled()) {
- log.info("Cancel edition for fishingOperation ");
+ log.info("Cancel creation for fishingOperation");
}
// cancel to create a new fishingOperation
- delegate.setFishingOperation(null);
- delegate.doAction(event);
+ action.setFishingOperation(null);
+ action.doAction(event);
-// parentUi.getFishingOperationTabContent().getHandler().selectFishingOperation(null);
-// parentUi.getCatchesTabContent().getHandler().selectFishingOperation(null, "");
-// parentHandler.closeCurrentFishingOperation();
-
} else {
- // reload fishing operation
- delegate.setFishingOperation(parentHandler.getModel().getSelectedFishingOperation());
- delegate.doAction(event);
-// parentHandler.reloadFishingOperation();
+ if (log.isInfoEnabled()) {
+ log.info("Can edition of fishingOperation");
+ }
+
+ // re-edit current fishing operation (but do not perform any check)
+ action.setCheckPreviousEdit(false);
+ action.setFishingOperation(getModel().getFishingOperation());
+ action.actionPerformed(event);
}
- // if called directly from the EditFishingOperationUIHandler:
- // the user does not want to save the modifications before
- // selecting another tab, we must reload the current tab before setting
- // the new index of the tab pane
- if (event.getSource() != null
- && event.getSource().getClass().isAssignableFrom(EditFishingOperationUIHandler.class)) {
-
- int newIndex = event.getID();
- parentHandler.getTabPanel().setSelectedIndex(newIndex);
- }
+// // if called directly from the EditFishingOperationUIHandler:
+// // the user does not want to save the modifications before
+// // selecting another tab, we must reload the current tab before setting
+// // the new index of the tab pane
+// if (event.getSource() != null
+// && event.getSource().getClass().isAssignableFrom(EditFishingOperationUIHandler.class)) {
+//
+// int newIndex = event.getID();
+// parentHandler.getTabPanel().setSelectedIndex(newIndex);
+// }
}
}
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -0,0 +1,422 @@
+package fr.ifremer.tutti.ui.swing.content.operation;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation;
+import fr.ifremer.tutti.persistence.entities.referential.Person;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.SaveCatchBatchAction;
+import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUI;
+import fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUI;
+import fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.decorator.Decorator;
+
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JTabbedPane;
+import javax.swing.SwingUtilities;
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To edit the given fishing operation.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class EditFishingOperationAction extends AbstractTuttiAction<FishingOperationsUIModel, FishingOperationsUI, FishingOperationsUIHandler> {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(EditFishingOperationAction.class);
+
+ /**
+ * The incoming fishing operation to edit.
+ * <p/>
+ * Can be null (means do not edit any fishing operation), or with no id
+ * (means create a ne fishing operation), or with an id (means edit an
+ * existing fishing operation).
+ *
+ * @since 1.0
+ */
+ protected FishingOperation fishingOperation;
+
+ /**
+ * A flag to not check if there is a previous edit.
+ * <p/>
+ * This flag is used when we launch the cancel action.
+ *
+ * @since 1.0
+ */
+ protected boolean checkPreviousEdit = true;
+
+ /**
+ * Delegate action to save Fising Operation.
+ *
+ * @since 1.0
+ */
+ protected SaveFishingOperationAction saveFishingOperationAction;
+
+ /**
+ * Delgate action to save catch batch.
+ *
+ * @since 1.0
+ */
+ protected SaveCatchBatchAction saveCatchBatchAction;
+
+ public EditFishingOperationAction(FishingOperationsUIHandler handler) {
+ super(handler,
+ "editFishingOperation",
+ "edit",
+ null,
+ _("tutti.action.editFishingOperation.tip"),
+ true);
+ }
+
+ public void setFishingOperation(FishingOperation fishingOperation) {
+ this.fishingOperation = fishingOperation;
+ }
+
+ public void setCheckPreviousEdit(boolean checkPreviousEdit) {
+ this.checkPreviousEdit = checkPreviousEdit;
+ }
+
+ @Override
+ protected void releaseAction(ActionEvent event) {
+ fishingOperation = null;
+ checkPreviousEdit = true;
+ super.releaseAction(event);
+ }
+
+ protected SaveFishingOperationAction getSaveFishingOperationAction() {
+ if (saveFishingOperationAction == null) {
+ saveFishingOperationAction = new SaveFishingOperationAction(getUI().getFishingOperationTabContent().getHandler());
+ }
+ return saveFishingOperationAction;
+ }
+
+ protected SaveCatchBatchAction getSaveCatchBatchAction() {
+ if (saveCatchBatchAction == null) {
+ saveCatchBatchAction = new SaveCatchBatchAction(getUI().getCatchesTabContent().getHandler());
+ }
+ return saveCatchBatchAction;
+ }
+
+ @Override
+ protected void doAction(ActionEvent event) throws Exception {
+
+ if (log.isInfoEnabled()) {
+ log.info("Try to edit fishingOperation: " + fishingOperation);
+ }
+
+ FishingOperationsUI ui = getUI();
+
+ FishingOperationsUIModel model = ui.getModel();
+
+ FishingOperation editFishingOperation = model.getEditFishingOperation();
+
+ boolean canContinue;
+
+ String editFishingOperationId;
+
+ if (editFishingOperation == null) {
+
+ // no previous fishing operation in edition, can continue
+ canContinue = true;
+ editFishingOperationId = null;
+
+ } else {
+
+ editFishingOperationId = editFishingOperation.getId();
+
+ boolean create = TuttiEntities.isNew(editFishingOperation);
+
+ // must close current edition
+ String message;
+
+ if (create) {
+ message = _("tutti.dialog.askSaveBeforeLeaving.createFishingOperation");
+ } else {
+ message = _("tutti.dialog.askSaveBeforeLeaving.saveFishingOperation");
+ }
+
+ int answer = getHandler().askSaveBeforeLeaving(message);
+
+ canContinue = false;
+ switch (answer) {
+ case JOptionPane.OK_OPTION:
+
+ // persist previous fishing operation
+ getSaveFishingOperationAction().setUpdateUI(false);
+ getSaveFishingOperationAction().actionPerformed(event);
+ getSaveCatchBatchAction().setUpdateUI(false);
+ getSaveCatchBatchAction().actionPerformed(event);
+
+ canContinue = true;
+ break;
+
+ case JOptionPane.NO_OPTION:
+
+ // won't save modification
+ // so since we will edit a new operation, nothing to do here
+
+ canContinue = true;
+ break;
+ }
+ }
+
+ if (canContinue) {
+
+ // edit new fishing operation
+ if (log.isInfoEnabled()) {
+ log.info("Edit in ui fishingOperation: " + fishingOperation);
+ }
+
+ selectNewFishingOperation(fishingOperation);
+
+ selectNewCatchBatch(fishingOperation);
+
+ JTabbedPane form = ui.getTabPane();
+ JLabel noContentPane = ui.getNoTraitPane();
+
+ if (fishingOperation == null) {
+
+ // nothing to display
+
+ ui.remove(form);
+
+ // just display <no trait!>
+ ui.add(noContentPane, BorderLayout.CENTER);
+
+ } else {
+
+ ui.remove(noContentPane);
+
+ // wait last minute to display (avoid dirty display effects)
+ ui.add(form, BorderLayout.CENTER);
+ }
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ getUI().repaint();
+ }
+ });
+ } else {
+
+ // user cancel save of previous bean
+
+ // get previous edit fishing operation (in selection model)
+ FishingOperation selectFishingOperation =
+ model.getFishingOperation(editFishingOperationId);
+
+ model.setEditionAdjusting(true);
+
+ try {
+ model.setSelectedFishingOperation(selectFishingOperation);
+ } finally {
+ model.setEditionAdjusting(false);
+ }
+ }
+ }
+
+ protected void selectNewFishingOperation(FishingOperation bean) {
+
+ EditFishingOperationUI ui = getUI().getFishingOperationTabContent();
+
+ EditFishingOperationUIHandler handler = ui.getHandler();
+
+ EditFishingOperationUIModel editFishingOperationUIModel = ui.getModel();
+
+ handler.uninstallStartDateListener();
+
+ if (bean == null) {
+
+ editFishingOperationUIModel.fromBean(new FishingOperation());
+
+ editFishingOperationUIModel.setFishingOperation(bean);
+
+ handler.clearValidators();
+
+ handler.resetAllModels();
+
+ } else { //if (!bean.equals(editFishingOperationUIModel.getFishingOperation()) || handler.isAModelModified()) {
+
+ FishingOperationLocation strata = bean.getStrata();
+ FishingOperationLocation subStrata = bean.getSubStrata();
+ FishingOperationLocation location = bean.getLocation();
+
+ Cruise cruise = bean.getCruise();
+ if (cruise != null) {
+ // update gear universe
+ ui.getGearComboBox().setData(Lists.newArrayList(cruise.getGear()));
+
+ // update vessel universe
+ ui.getVesselComboBox().setData(Lists.newArrayList(cruise.getVessel()));
+ }
+
+ editFishingOperationUIModel.fromBean(bean);
+
+ // to be sure combo list will be reloaded
+ editFishingOperationUIModel.setStrata(null);
+ editFishingOperationUIModel.setSubStrata(null);
+ editFishingOperationUIModel.setLocation(null);
+ editFishingOperationUIModel.convertGearShootingCoordinatesDDToDMS();
+
+ if (strata != null) {
+ ui.getStrataComboBox().setSelectedItem(strata);
+ }
+
+ if (subStrata != null) {
+ ui.getSubStrataComboBox().setSelectedItem(subStrata);
+ }
+
+ if (location != null) {
+ ui.getLocationComboBox().setSelectedItem(location);
+ }
+
+ editFishingOperationUIModel.setFishingOperation(bean);
+
+ // update saisissuer selection
+ List<Person> saisisseur = editFishingOperationUIModel.getSaisisseur();
+ ui.getSaisisseurList().getModel().setSelected(saisisseur);
+
+ // update model empty property
+ editFishingOperationUIModel.setEmpty(false);
+
+ //reset gear shooting
+ GearShootingTabUI gearShootingTab = ui.getGearShootingTabContent();
+ gearShootingTab.getHandler().reset(bean);
+
+ //reset environment
+ EnvironmentTabUI environmentTab = ui.getEnvironmentTabContent();
+ environmentTab.getHandler().reset(bean);
+
+ //reset hydrology
+ HydrologyTabUI hydrologyTab = ui.getHydrologyTabContent();
+ hydrologyTab.getHandler().reset(bean);
+
+ editFishingOperationUIModel.setModify(false);
+ handler.getFishingOperationMonitor().clearModified();
+
+ handler.registerValidator();
+ }
+
+ handler.installStartDateListener();
+ }
+
+ protected void selectNewCatchBatch(FishingOperation bean) {
+
+ boolean empty = bean == null || TuttiEntities.isNew(bean);
+
+ EditCatchesUI ui = getUI().getCatchesTabContent();
+ TuttiBeanMonitor<EditCatchesUIModel> catchBatchMonitor =
+ ui.getHandler().getCatchBatchMonitor();
+
+ EditCatchesUIModel catchesUIModel = ui.getModel();
+
+ CatchBatch batch;
+
+ if (empty) {
+
+ // create a new CatchBatch
+ if (log.isInfoEnabled()) {
+ log.info("Create a new CatchBatch (fishing operation is null)");
+ }
+ batch = new CatchBatch();
+ batch.setFishingOperation(bean);
+
+ } else {
+
+ String operationId = bean.getId();
+
+ if (log.isInfoEnabled()) {
+ log.info("Load existing CatchBatch from operation id: " +
+ operationId);
+ }
+
+ PersistenceService persistenceService =
+ getService(PersistenceService.class);
+
+ batch = persistenceService.getCatchBatchFromFishingOperation(
+ operationId);
+ batch.setFishingOperation(bean);
+ }
+
+ catchesUIModel.setCatchBatch(batch);
+ catchesUIModel.setFishingOperation(bean);
+
+ catchesUIModel.fromBean(batch);
+
+ catchesUIModel.setModify(false);
+ catchBatchMonitor.clearModified();
+
+ Decorator<FishingOperation> decorator =
+ getDecorator(FishingOperation.class, null);
+
+ String fishingOperationText;
+
+ if (bean == null) {
+ fishingOperationText = null;
+ } else {
+ fishingOperationText = _("tutti.label.traitReminder",
+ decorator.toString(fishingOperation));
+ }
+
+ // 3) Propagate title to others tabs
+ ui.getCatchesCaracteristicsTabPane().setTitle(fishingOperationText);
+ ui.getSpeciesTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+// ui.getBenthosTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+// ui.getPlanktonTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+// ui.getMacroWasteTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+// ui.getAccidentalTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+
+ // 4) Propagate new selected fishingoperation to others tabs
+
+ ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean);
+// ui.getBenthosTabContent().getHandler().selectFishingOperation(bean);
+// ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean);
+// ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean);
+// ui.getAccidentalTabContent().getHandler().selectFishingOperation(bean);
+
+ }
+
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -30,11 +30,9 @@
import com.javadocmd.simplelatlng.LatLngTool;
import com.javadocmd.simplelatlng.util.LengthUnit;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation;
import fr.ifremer.tutti.persistence.entities.referential.Gear;
-import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
import fr.ifremer.tutti.persistence.entities.referential.Zone;
import fr.ifremer.tutti.service.PersistenceService;
@@ -42,17 +40,13 @@
import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.CaracteristicTabUIModel;
-import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUI;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUIModel;
-import fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUI;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUIModel;
-import fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUI;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUIModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiTabContainerUIHandler;
import fr.ifremer.tutti.ui.swing.util.TabHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.editor.CoordinateEditorType;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.time.DateUtils;
@@ -61,8 +55,6 @@
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
-import java.awt.Color;
-import java.awt.Component;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -101,43 +93,8 @@
getModel().setGearShootingEndDate(newDate);
}
}
- };
-
- private final PropertyChangeListener coordinatePropertiesListener = new PropertyChangeListener() {
- private List<String> properties = Lists.newArrayList(
- EditFishingOperationUIModel.PROPERTY_FISHING_OPERATION_RECTILIGNE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DECIMAL_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LATITUDE_SECOND,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DECIMAL_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_END_LONGITUDE_SECOND,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DECIMAL_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LATITUDE_SECOND,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DECIMAL_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_DEGREE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_MINUTE,
- EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_LONGITUDE_SECOND
- );
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (properties.contains(evt.getPropertyName())) {
- EditFishingOperationUIModel source = (EditFishingOperationUIModel) evt.getSource();
- if (source.isFishingOperationRectiligne()) {
- source.computeDictance();
- }
- }
- }
};
/**
@@ -180,24 +137,6 @@
EditFishingOperationUIModel model = new EditFishingOperationUIModel();
model.setCoordinateEditorType(getConfig().getCoordinateEditorType());
model.setValidationContext(getContext().getValidationContext());
-
-// model.addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_EMPTY, new PropertyChangeListener() {
-// @Override
-// public void propertyChange(PropertyChangeEvent evt) {
-// JPanel form = ui.getFishingOperationPane();
-// JLabel noContentPane = ui.getNoTraitPane();
-//
-// Boolean empty = (Boolean) evt.getNewValue();
-// ui.remove(form);
-// ui.remove(noContentPane);
-// if (empty) {
-// ui.add(noContentPane, BorderLayout.CENTER);
-// } else {
-// ui.add(form, BorderLayout.CENTER);
-// }
-// ui.repaint();
-// }
-// });
model.addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_STRATA, new PropertyChangeListener() {
@Override
@@ -217,23 +156,26 @@
}
});
- model.addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_FISHING_OPERATION_VALID, new PropertyChangeListener() {
+ model.addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_FISHING_OPERATION_RECTILIGNE, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
- Boolean valid = (Boolean) evt.getNewValue();
- Color color = null;
- Color fontColor = Color.BLACK;
- if (valid == Boolean.TRUE) {
- color = Color.GREEN;
+ Boolean rectiligne = (Boolean) evt.getNewValue();
+ if (rectiligne) {
+ EditFishingOperationUIModel source = (EditFishingOperationUIModel) evt.getSource();
+ Float latS = source.getGearShootingStartLatitude();
+ Float longS = source.getGearShootingStartLongitude();
+ Float latE = source.getGearShootingEndLatitude();
+ Float longE = source.getGearShootingEndLongitude();
- } else if (valid == Boolean.FALSE) {
- color = Color.RED;
- fontColor = Color.WHITE;
+ if (latS != null && longS != null
+ && latE != null && longE != null) {
+ LatLng start = new LatLng(latS, longS);
+ LatLng end = new LatLng(latE, longE);
+ Double distance = LatLngTool.distance(start, end, LengthUnit.METER);
+ source.setTrawlDistance(distance.floatValue());
+ }
}
- Component tab = getTabPanel().getTabComponentAt(0);
- tab.setForeground(fontColor);
- tab.setBackground(color);
}
});
@@ -412,6 +354,10 @@
@Override
public void onShowTab(int currentIndex, int newIndex) {
+// registerValidators(ui.getValidator());
+ }
+
+ public void registerValidator() {
registerValidators(ui.getValidator());
}
@@ -437,94 +383,96 @@
};
}
- public void clearFishingOperation() {
- EditFishingOperationUIModel model = getModel();
- model.fromBean(new FishingOperation());
+// public void clearFishingOperation() {
+// EditFishingOperationUIModel model = getModel();
+// model.fromBean(new FishingOperation());
+//
+// model.setModify(false);
+// fishingOperationMonitor.clearModified();
+//
+// model.setEmpty(true);
+//
+// }
- model.setModify(false);
- fishingOperationMonitor.clearModified();
+// public void selectFishingOperation(FishingOperation bean) {
+// boolean empty = bean == null;
+//
+// EditFishingOperationUIModel editFishingOperationUIModel = getModel();
+//
+// uninstallStartDateListener();
+//
+// if (empty || !bean.equals(editFishingOperationUIModel.getFishingOperation()) || isAModelModified()) {
+// if (empty) {
+// bean = new FishingOperation();
+// }
+//
+// FishingOperationLocation strata = bean.getStrata();
+// FishingOperationLocation subStrata = bean.getSubStrata();
+// FishingOperationLocation location = bean.getLocation();
+//
+// Cruise cruise = bean.getCruise();
+// if (cruise != null) {
+// // update gear universe
+// ui.getGearComboBox().setData(Lists.newArrayList(cruise.getGear()));
+//
+// // update vessel universe
+// ui.getVesselComboBox().setData(Lists.newArrayList(cruise.getVessel()));
+// }
+//
+// editFishingOperationUIModel.fromBean(bean);
+//
+// // to be sure combo list will be reloaded
+// editFishingOperationUIModel.setStrata(null);
+// editFishingOperationUIModel.setSubStrata(null);
+// editFishingOperationUIModel.setLocation(null);
+// editFishingOperationUIModel.convertGearShootingCoordinatesDDToDMS();
+//
+// if (strata != null) {
+// ui.getStrataComboBox().setSelectedItem(strata);
+// }
+//
+// if (subStrata != null) {
+// ui.getSubStrataComboBox().setSelectedItem(subStrata);
+// }
+//
+// if (location != null) {
+// ui.getLocationComboBox().setSelectedItem(location);
+// }
+//
+// editFishingOperationUIModel.setFishingOperation(bean);
+//
+// // update saisissuer selection
+// List<Person> saisisseur = editFishingOperationUIModel.getSaisisseur();
+// ui.getSaisisseurList().getModel().setSelected(saisisseur);
+//
+// // update model empty property
+// editFishingOperationUIModel.setEmpty(empty);
+//
+// //reset gear shooting
+// GearShootingTabUI gearShootingTab = ui.getGearShootingTabContent();
+// gearShootingTab.getHandler().reset(bean);
+//
+// //reset environment
+// EnvironmentTabUI environmentTab = ui.getEnvironmentTabContent();
+// environmentTab.getHandler().reset(bean);
+//
+// //reset hydrology
+// HydrologyTabUI hydrologyTab = ui.getHydrologyTabContent();
+// hydrologyTab.getHandler().reset(bean);
+//
+// editFishingOperationUIModel.setModify(false);
+// fishingOperationMonitor.clearModified();
+//
+// editFishingOperationUIModel.addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_DATE, startDateListener);
+// }
+// }
- model.setEmpty(true);
-
+ public void uninstallStartDateListener() {
+ getModel().removePropertyChangeListener(EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_DATE, startDateListener);
}
- public void selectFishingOperation(FishingOperation bean) {
- boolean empty = bean == null;
-
- EditFishingOperationUIModel model = getModel();
-
- model.removePropertyChangeListener(EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_DATE, startDateListener);
- model.removePropertyChangeListener(coordinatePropertiesListener);
-
- if (empty || !bean.equals(model.getFishingOperation()) || isAModelModified()) {
- if (empty) {
- bean = new FishingOperation();
- }
-
- List<FishingOperation> operations = parentUi.getModel().getFishingOperation();
- operations.remove(bean);
- model.setExistingOperations(operations);
-
- FishingOperationLocation strata = bean.getStrata();
- FishingOperationLocation subStrata = bean.getSubStrata();
- FishingOperationLocation location = bean.getLocation();
-
- Cruise cruise = bean.getCruise();
- if (cruise != null) {
- // update gear universe
- ui.getGearComboBox().setData(Lists.newArrayList(cruise.getGear()));
-
- // update vessel universe
- ui.getVesselComboBox().setData(Lists.newArrayList(cruise.getVessel()));
- }
-
- model.fromBean(bean);
-
- // to be sure combo list will be reloaded
- model.setStrata(null);
- model.setSubStrata(null);
- model.setLocation(null);
- model.convertGearShootingCoordinatesDDToDMS();
-
- if (strata != null) {
- ui.getStrataComboBox().setSelectedItem(strata);
- }
-
- if (subStrata != null) {
- ui.getSubStrataComboBox().setSelectedItem(subStrata);
- }
-
- if (location != null) {
- ui.getLocationComboBox().setSelectedItem(location);
- }
-
- model.setFishingOperation(bean);
-
- // update saisissuer selection
- List<Person> saisisseur = model.getSaisisseur();
- ui.getSaisisseurList().getModel().setSelected(saisisseur);
-
- // update model empty property
- model.setEmpty(empty);
-
- //reset gear shooting
- GearShootingTabUI gearShootingTab = ui.getGearShootingTabContent();
- gearShootingTab.getHandler().reset(bean);
-
- //reset environment
- EnvironmentTabUI environmentTab = ui.getEnvironmentTabContent();
- environmentTab.getHandler().reset(bean);
-
- //reset hydrology
- HydrologyTabUI hydrologyTab = ui.getHydrologyTabContent();
- hydrologyTab.getHandler().reset(bean);
-
- model.setModify(false);
- fishingOperationMonitor.clearModified();
-
- model.addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_DATE, startDateListener);
- model.addPropertyChangeListener(coordinatePropertiesListener);
- }
+ public void installStartDateListener() {
+ getModel().addPropertyChangeListener(EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_START_DATE, startDateListener);
}
public FishingOperationsUI getParentUi() {
@@ -576,8 +524,6 @@
if (CollectionUtils.isEmpty(subStrata)) {
// try to load localite
-
-
ui.getLocationComboBox().grabFocus();
}
}
@@ -629,4 +575,12 @@
return result;
}
+ protected void resetAllModels() {
+
+ for (CaracteristicTabUIModel subModel : getSubModels()) {
+ subModel.setModify(false);
+ }
+ getModel().setModify(false);
+ }
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2013-02-10 15:04:13 UTC (rev 388)
@@ -58,7 +58,7 @@
<Table fill='both' id='topPanel' constraints='BorderLayout.NORTH'>
- <!-- FishingOperations fishingOperation -->
+ <!-- Cruise fishingOperations -->
<row>
<cell anchor='west' weightx='1.0'>
<BeanComboBox id='fishingOperationComboBox' constructorParams='this'
@@ -70,8 +70,7 @@
</row>
</Table>
- <JLabel id='noTraitPane' constraints='BorderLayout.CENTER'/>
-
+ <!-- Current selected fishingOperation -->
<JTabbedPane id='tabPane'>
<tab id='fishingOperationTab' title='tutti.label.tab.fishingOperation'>
<EditFishingOperationUI id='fishingOperationTabContent'
@@ -82,4 +81,7 @@
</tab>
</JTabbedPane>
+ <!-- When no fishing operation selected -->
+ <JLabel id='noTraitPane' constraints='BorderLayout.CENTER'/>
+
</JPanel>
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -41,9 +41,6 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;
-import java.util.Timer;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
/**
* Handler of UI {@link FishingOperationsUI}.
@@ -59,13 +56,8 @@
private final PersistenceService persistenceService;
- private static final ExecutorService executorService =
- Executors.newSingleThreadExecutor();
+ protected EditFishingOperationAction editFishingOperationAction;
- private static final Timer t = new Timer();
-
- protected SelectFishingOperationAction selectFishingOperationAction;
-
public FishingOperationsUIHandler(TuttiUI parentUI,
FishingOperationsUI ui) {
super(parentUI.getHandler().getContext(), ui);
@@ -138,10 +130,11 @@
initUI(ui);
- selectFishingOperationAction = createAction(SelectFishingOperationAction.class);
+ editFishingOperationAction =
+ createAction(EditFishingOperationAction.class);
+
FishingOperationsUIModel model = getModel();
-
List<FishingOperation> fishingOperations = model.getFishingOperation();
initBeanComboBox(ui.getFishingOperationComboBox(),
@@ -155,16 +148,36 @@
log.debug("propertyChange " + FishingOperationsUIModel.PROPERTY_SELECTED_FISHING_OPERATION);
}
- if (!getModel().isValueIsAdjusting()) {
+ if (!getModel().isEditionAdjusting()) {
- // only rebuild stuff if model is not adjusting
- selectFishingOperationAction.setFishingOperation((FishingOperation) evt.getNewValue());
- selectFishingOperationAction.actionPerformed(null);
-// selectFishingOperation((FishingOperation) evt.getNewValue());
+ // selected fishing operation is now the editing one
+
+ FishingOperation newValue = (FishingOperation) evt.getNewValue();
+
+ FishingOperation operation;
+ if (newValue == null) {
+ operation = null;
+ } else {
+ operation = persistenceService.getFishingOperation(newValue.getId());
+ }
+ getModel().setEditFishingOperation(operation);
}
}
});
+ model.addPropertyChangeListener(FishingOperationsUIModel.PROPERTY_EDITED_FISHING_OPERATION, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (log.isDebugEnabled()) {
+ log.debug("propertyChange " + FishingOperationsUIModel.PROPERTY_EDITED_FISHING_OPERATION);
+ }
+
+ // only rebuild stuff if model is not adjusting
+ editFishingOperationAction.setFishingOperation((FishingOperation) evt.getNewValue());
+ editFishingOperationAction.actionPerformed(null);
+
+ }
+ });
model.addPropertyChangeListener(FishingOperationsUIModel.PROPERTY_FISHING_OPERATION, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
@@ -212,78 +225,4 @@
return ui.getTabPane();
}
-// public void selectFishingOperation(FishingOperation fishingOperation) {
-//
-// if (log.isInfoEnabled()) {
-// log.info("New selected fishingOperation: " + fishingOperation);
-// }
-//
-// // back to general tab of fishingOperation tabs
-// ui.getFishingOperationTabContent().getFishingOperationTabPane().setSelectedIndex(0);
-//
-// if (fishingOperation != null) {
-// Decorator<FishingOperation> decorator =
-// getDecorator(FishingOperation.class, null);
-//
-// String fishingOperationText =
-// _("tutti.label.traitReminder",
-// decorator.toString(fishingOperation));
-//
-// // propagate fishingOperation to his tabs
-// ui.getFishingOperationTabContent().getHandler().selectFishingOperation(fishingOperation);
-// if (ui.getFishingOperationTabContent().getModel().isCreate()) {
-// // back to fishingOperation tab
-// ui.getTabPane().setSelectedIndex(0);
-// }
-//
-// ui.getCatchesTabContent().getHandler().selectFishingOperation(fishingOperation,
-// fishingOperationText);
-//
-// // repaint tabs
-// ui.getTabPane().repaint();
-//
-// } else {
-// ui.getFishingOperationTabContent().getHandler().clearFishingOperation();
-// // back to fishingOperation tab
-// ui.getTabPane().setSelectedIndex(0);
-// }
-// }
-
-// public void closeCurrentFishingOperation() {
-// ui.getFishingOperationTabContent().getHandler().selectFishingOperation(null);
-// ui.getCatchesTabContent().getHandler().selectFishingOperation(null, "");
-// }
-
-// public void saveFishingOperation(FishingOperation toSave) {
-//
-// // persist the fishingOperation
-//
-// boolean create = toSave.getId() == null;
-// FishingOperationsUIModel model = getModel();
-// FishingOperation savedFishingOperation;
-//
-// if (create) {
-//
-// savedFishingOperation = persistenceService.createFishingOperation(toSave);
-// model.addFishingOperation(savedFishingOperation);
-// model.setSelectedFishingOperation(savedFishingOperation);
-//
-// } else {
-// savedFishingOperation = persistenceService.saveFishingOperation(toSave);
-//
-// // add the saved fishingOperation to fishingOperation list
-// List<FishingOperation> data = model.getFishingOperation();
-//
-// FishingOperation existingFishingOperation =
-// TuttiEntities.findById(data, savedFishingOperation.getId());
-// model.updateFishingOperation(existingFishingOperation, savedFishingOperation);
-// }
-// }
-
-// public void reloadFishingOperation() {
-// FishingOperation operation = getModel().getSelectedFishingOperation();
-// selectFishingOperation(operation);
-// }
-
-
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -24,8 +24,12 @@
* #L%
*/
+import com.ezware.oxbow.swingbits.util.Preconditions;
import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jdesktop.beans.AbstractSerializableBean;
import java.util.List;
@@ -40,16 +44,68 @@
private static final long serialVersionUID = 1L;
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(FishingOperationsUIModel.class);
+
public static final String PROPERTY_FISHING_OPERATION = "fishingOperation";
public static final String PROPERTY_SELECTED_FISHING_OPERATION = "selectedFishingOperation";
+ public static final String PROPERTY_EDITED_FISHING_OPERATION = "editedFishingOperation";
+
+ /**
+ * List of existing fishing operation for the selected cruise.
+ * <p/>
+ * <strong>Note:</strong> These objects are not fully loaded, they will
+ * never be edited.
+ *
+ * @since 0.1
+ */
protected List<FishingOperation> fishingOperation;
+ /**
+ * Selected fishing operation in the combo box.
+ * <p/>
+ * For example if you create a new fishing operation then
+ * {@code selectedFishingOperation} will be {@code null}.
+ * <p/>
+ * <strong>Note:</strong> These object ise not fully loaded, they will
+ * never be edited.
+ *
+ * @since 0.1
+ */
protected FishingOperation selectedFishingOperation;
- private boolean valueIsAdjusting;
+ /**
+ * Current editied fishing operation.
+ *
+ * @since 1.0
+ */
+ protected FishingOperation editFishingOperation;
+ /**
+ * Flag to not listen the {@link #selectedFishingOperation}
+ * changes while adjusting the model.
+ * <p/>
+ * When flag is {@code true}, then the changes of the
+ * {@link #selectedFishingOperation} should not trigger any changes.
+ *
+ * @since 1.0
+ */
+ protected boolean selectionAdjusting;
+
+ /**
+ * Flag to not listen the {@link #editFishingOperation}
+ * changes while adjusting the model.
+ * <p/>
+ * When flag is {@code true}, then the changes of the
+ * {@link #editFishingOperation} should not trigger any changes.
+ *
+ * @since 1.0
+ */
+ protected boolean editionAdjusting;
+
public List<FishingOperation> getFishingOperation() {
return fishingOperation;
}
@@ -72,15 +128,21 @@
firePropertyChange(PROPERTY_FISHING_OPERATION, oldValue, this.fishingOperation);
}
- public void updateFishingOperation(FishingOperation oldFishingOperation,
- FishingOperation newFishingOperation) {
+ public void updateFishingOperation(FishingOperation newFishingOperation) {
+
+ Preconditions.checkNotNull(newFishingOperation);
+ String id = newFishingOperation.getId();
+ Preconditions.checkNotNull(id);
+ FishingOperation oldFishingOperation = getFishingOperation(id);
+ Preconditions.checkNotNull(oldFishingOperation);
+
+ if (log.isInfoEnabled()) {
+ log.info("Update existing fishing operation: " + id);
+ }
+
int oldFishingOperationIndex = fishingOperation.indexOf(oldFishingOperation);
fishingOperation.remove(oldFishingOperation);
- if (oldFishingOperationIndex >= 0) {
- fishingOperation.add(oldFishingOperationIndex, newFishingOperation);
- } else {
- fishingOperation.add(newFishingOperation);
- }
+ fishingOperation.add(oldFishingOperationIndex, newFishingOperation);
firePropertyChange(PROPERTY_FISHING_OPERATION, null, fishingOperation);
}
@@ -91,14 +153,46 @@
public void setSelectedFishingOperation(FishingOperation selectedFishingOperation) {
Object oldValue = getSelectedFishingOperation();
this.selectedFishingOperation = selectedFishingOperation;
- firePropertyChange(PROPERTY_SELECTED_FISHING_OPERATION, oldValue, selectedFishingOperation);
+ if (!isSelectionAdjusting()) {
+
+ // only fires when authorize to
+ firePropertyChange(PROPERTY_SELECTED_FISHING_OPERATION, oldValue, selectedFishingOperation);
+ }
}
- public void setValueIsAdjusting(boolean valueIsAdjusting) {
- this.valueIsAdjusting = valueIsAdjusting;
+ public FishingOperation getEditFishingOperation() {
+ return editFishingOperation;
}
- public boolean isValueIsAdjusting() {
- return valueIsAdjusting;
+ public void setEditFishingOperation(FishingOperation editFishingOperation) {
+ Object oldValue = getEditFishingOperation();
+ this.editFishingOperation = editFishingOperation;
+ if (!isEditionAdjusting()) {
+
+ // only fires when authorize to
+ firePropertyChange(PROPERTY_EDITED_FISHING_OPERATION, oldValue, editFishingOperation);
+ }
}
+
+ public boolean isSelectionAdjusting() {
+ return selectionAdjusting;
+ }
+
+ public void setSelectionAdjusting(boolean selectionAdjusting) {
+ this.selectionAdjusting = selectionAdjusting;
+ }
+
+ public boolean isEditionAdjusting() {
+ return editionAdjusting;
+ }
+
+ public void setEditionAdjusting(boolean editionAdjusting) {
+ this.editionAdjusting = editionAdjusting;
+ }
+
+ public FishingOperation getFishingOperation(String id) {
+ FishingOperation result =
+ TuttiEntities.findById(fishingOperation, id);
+ return result;
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/NewFishingOperationAction.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -37,7 +37,7 @@
import static org.nuiton.i18n.I18n._;
/**
- * TODO
+ * To create a new fishing operation.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.0
@@ -46,7 +46,12 @@
private static final long serialVersionUID = 1L;
- private final SelectFishingOperationAction delegate;
+ /**
+ * Delegate action to edit new FishingOperation.
+ *
+ * @since 1.0
+ */
+ protected EditFishingOperationAction editFishingOperationAction;
public NewFishingOperationAction(FishingOperationsUIHandler handler) {
super(handler,
@@ -55,8 +60,6 @@
null,
_("tutti.action.newFishingOperation.tip"),
true);
-
- delegate = new SelectFishingOperationAction(getHandler());
}
@Override
@@ -64,45 +67,50 @@
FishingOperationsUIModel model = getModel();
- model.setValueIsAdjusting(true);
+ // deselect selected fishingOperation
+ // Will remove the selection fishing operation from the comboBox
+ model.setEditionAdjusting(true);
try {
- // deselect selected fishingOperation
model.setSelectedFishingOperation(null);
+ } finally {
+ model.setEditionAdjusting(false);
+ }
- // use a new empty fishingOperation
- FishingOperation newFishingOperation = new FishingOperation();
- Cruise cruise = TuttiUIUtil.getCruise(getContext());
- newFishingOperation.setCruise(cruise);
+ // creates a empty bean
- //TODO Should select vessel from possible one ?
- List<Vessel> vessels = cruise.getVessel();
- if (vessels.size() == 1) {
- newFishingOperation.setVessel(vessels.get(0));
- }
+ FishingOperation newFishingOperation = new FishingOperation();
+ Cruise cruise = TuttiUIUtil.getCruise(getContext());
+ newFishingOperation.setCruise(cruise);
- //TODO Should select gear from possible one ?
- List<Gear> gears = cruise.getGear();
- if (gears.size() == 1) {
- newFishingOperation.setGear(gears.get(0));
- }
+ //TODO Should select vessel from possible one ?
+ List<Vessel> vessels = cruise.getVessel();
+ if (vessels.size() == 1) {
+ newFishingOperation.setVessel(vessels.get(0));
+ }
- if (cruise.getMultirigNumber() == 1) {
- newFishingOperation.setMultirigAggregation("1");
- }
+ //TODO Should select gear from possible one ?
+ List<Gear> gears = cruise.getGear();
+ if (gears.size() == 1) {
+ newFishingOperation.setGear(gears.get(0));
+ }
- // by default use the current day with no time information
-// Date currentDate = DateUtils.setMinutes(
-// DateUtils.setHours(new Date(), 0), 0);
+ if (cruise.getMultirigNumber() == 1) {
+ newFishingOperation.setMultirigAggregation("1");
+ }
- newFishingOperation.setGearShootingStartDate(null);
- newFishingOperation.setGearShootingEndDate(null);
+ newFishingOperation.setGearShootingStartDate(null);
+ newFishingOperation.setGearShootingEndDate(null);
- delegate.setFishingOperation(newFishingOperation);
- delegate.doAction(event);
+ getEditFishingOperationAction().setFishingOperation(newFishingOperation);
+ getEditFishingOperationAction().actionPerformed(event);
- } finally {
- model.setValueIsAdjusting(false);
+ }
+
+ public EditFishingOperationAction getEditFishingOperationAction() {
+ if (editFishingOperationAction == null) {
+ editFishingOperationAction = new EditFishingOperationAction(getHandler());
}
+ return editFishingOperationAction;
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -27,10 +27,10 @@
import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
-import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.CaracteristicTabUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUIModel;
@@ -41,7 +41,6 @@
import org.apache.commons.logging.LogFactory;
import java.awt.event.ActionEvent;
-import java.util.List;
import static org.nuiton.i18n.I18n._;
@@ -56,8 +55,17 @@
private static final long serialVersionUID = 1L;
/** Logger. */
- private static final Log log = LogFactory.getLog(SaveFishingOperationAction.class);
+ private static final Log log =
+ LogFactory.getLog(SaveFishingOperationAction.class);
+
+ /**
+ * A flag to update ui after create or save the edit fishing operation.
+ *
+ * @since 1.0
+ */
+ protected boolean updateUI;
+
public SaveFishingOperationAction(EditFishingOperationUIHandler handler) {
super(handler,
"saveFishingOperation",
@@ -68,6 +76,16 @@
);
}
+ public void setUpdateUI(boolean updateUI) {
+ this.updateUI = updateUI;
+ }
+
+ @Override
+ protected void releaseAction(ActionEvent event) {
+ updateUI = true;
+ super.releaseAction(event);
+ }
+
/**
* If the event source is an EditFishingOperationUIHandler,
* then the tab panel of the parent switch to the index set
@@ -75,13 +93,11 @@
* If the event source is a TuttiScreen, then the screen changes to the source.
*
* @param event
- * @throws Exception
*/
@Override
protected void doAction(ActionEvent event) {
EditFishingOperationUIHandler handler = getHandler();
- FishingOperationsUIHandler parentHandler = getHandler().getParentUi().getHandler();
TuttiBeanMonitor<EditFishingOperationUIModel> monitor =
handler.getFishingOperationMonitor();
@@ -89,13 +105,14 @@
// previous fishingOperation was modified, let's save it
EditFishingOperationUIModel beanToSave = monitor.getBean();
- if (beanToSave.isEmpty()) {
+ // must save when bean is new or was modifiy and is valid
+ boolean mustSave = (beanToSave.isCreate() || !beanToSave.isEmpty()) &&
+ beanToSave.isValid();
- // user must use save button
- if (log.isWarnEnabled()) {
- log.warn("Won't save new fishing operation, use explicit save button instead...");
- }
- } else if (beanToSave.isValid()) {
+ if (mustSave) {
+
+ // prepare model
+
if (beanToSave.getCoordinateEditorType() != CoordinateEditorType.DD) {
beanToSave.convertGearShootingCoordinatesDMSToDD();
}
@@ -119,7 +136,7 @@
}
}
- handler.showInformationMessage(
+ sendMessage(
"[ Trait - Caractéristiques générales ] " +
"Sauvegarde des modifications de " + decorate(toSave) +
".");
@@ -132,47 +149,61 @@
monitor.clearModified();
getModel().setModify(false);
- // persist current fishingOperation
saveFishingOperation(toSave);
}
- if (event.getSource() != null) {
- Class<?> sourceClass = event.getSource().getClass();
- if (sourceClass.isAssignableFrom(EditFishingOperationUIHandler.class)) {
- int newIndex = event.getID();
- parentHandler.getTabPanel().setSelectedIndex(newIndex);
-
- } else if (sourceClass.isAssignableFrom(TuttiScreen.class)) {
- TuttiScreen nextScreen = (TuttiScreen) event.getSource();
- getContext().setScreen(nextScreen);
- }
- }
+// if (event.getSource() != null) {
+// Class<?> sourceClass = event.getSource().getClass();
+// if (sourceClass.isAssignableFrom(EditFishingOperationUIHandler.class)) {
+// int newIndex = event.getID();
+// parentHandler.getTabPanel().setSelectedIndex(newIndex);
+//
+// } else if (sourceClass.isAssignableFrom(TuttiScreen.class)) {
+// TuttiScreen nextScreen = (TuttiScreen) event.getSource();
+// getContext().setScreen(nextScreen);
+// }
+// }
}
protected void saveFishingOperation(FishingOperation toSave) {
- PersistenceService service =
- getContext().getService(PersistenceService.class);
+ PersistenceService service = getService(PersistenceService.class);
- boolean create = toSave.getId() == null;
- FishingOperationsUIModel model = getHandler().getParentUi().getModel();
+ boolean create = TuttiEntities.isNew(toSave);
+
+ FishingOperationsUIModel model =
+ getHandler().getParentUi().getModel();
FishingOperation savedFishingOperation;
if (create) {
+ // create fishing operation
savedFishingOperation = service.createFishingOperation(toSave);
+
+ // create then the CatchBatch
+ CatchBatch catchBatch = new CatchBatch();
+ catchBatch.setFishingOperation(savedFishingOperation);
+ service.createCatchBatch(catchBatch);
+
+ // add new created fishing operation to list
model.addFishingOperation(savedFishingOperation);
+
+ // select it (will reload editing fishing operation)
model.setSelectedFishingOperation(savedFishingOperation);
} else {
- savedFishingOperation = service.saveFishingOperation(toSave);
- // add the saved fishingOperation to fishingOperation list
- List<FishingOperation> data = model.getFishingOperation();
+ model.setEditionAdjusting(true);
- FishingOperation existingFishingOperation =
- TuttiEntities.findById(data, savedFishingOperation.getId());
- model.updateFishingOperation(existingFishingOperation, savedFishingOperation);
+ try {
+ // save fishing operation
+ savedFishingOperation = service.saveFishingOperation(toSave);
+
+ // reinject it in model
+ model.updateFishingOperation(savedFishingOperation);
+ } finally {
+ model.setEditionAdjusting(false);
+ }
}
}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SelectFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SelectFishingOperationAction.java 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SelectFishingOperationAction.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -1,140 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.decorator.Decorator;
-
-import javax.swing.JLabel;
-import javax.swing.JTabbedPane;
-import javax.swing.SwingUtilities;
-import java.awt.BorderLayout;
-import java.awt.event.ActionEvent;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.0
- */
-public class SelectFishingOperationAction extends AbstractTuttiAction<FishingOperationsUIModel, FishingOperationsUI, FishingOperationsUIHandler> {
-
- private static final long serialVersionUID = 1L;
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(SelectFishingOperationAction.class);
-
- protected FishingOperation fishingOperation;
-
- public SelectFishingOperationAction(FishingOperationsUIHandler handler) {
- super(handler,
- "selectFishingOperation",
- "select",
- null,
- _("tutti.action.selectFishingOperation.tip"),
- true);
- }
-
- public void setFishingOperation(FishingOperation fishingOperation) {
- this.fishingOperation = fishingOperation;
- }
-
- @Override
- protected void releaseAction(ActionEvent event) {
- fishingOperation = null;
- super.releaseAction(event);
- }
-
- @Override
- protected void doAction(ActionEvent event) throws Exception {
-
- if (log.isInfoEnabled()) {
- log.info("New selected fishingOperation: " + fishingOperation);
- }
-
- FishingOperationsUI ui = getHandler().getUi();
-
- JTabbedPane form = ui.getTabPane();
- JLabel noContentPane = ui.getNoTraitPane();
-
- if (fishingOperation == null) {
-
- // nothing to display
-
- ui.remove(form);
-
- // just display <no trait!>
- ui.add(noContentPane, BorderLayout.CENTER);
-
- } else {
-
- // select a fishing operation
-
- Decorator<FishingOperation> decorator =
- getDecorator(FishingOperation.class, null);
-
- String fishingOperationText =
- _("tutti.label.traitReminder",
- decorator.toString(fishingOperation));
-
- // propagate fishingOperation to his tabs
- ui.getFishingOperationTabContent().getHandler().selectFishingOperation(fishingOperation);
- if (ui.getFishingOperationTabContent().getModel().isCreate()) {
-
- // back to fishingOperation tab
- ui.getTabPane().setSelectedIndex(0);
- }
-
- ui.getCatchesTabContent().getHandler().selectFishingOperation(fishingOperation,
- fishingOperationText);
-
- // back to general tab of fishingOperation tabs
- ui.getFishingOperationTabContent().getFishingOperationTabPane().setSelectedIndex(0);
-
- ui.remove(noContentPane);
-
- // wait last minute to display (avoid dirty display effects)
- ui.add(form, BorderLayout.CENTER);
-
- // repaint tabs
-// ui.getTabPane().repaint();
-
- }
-
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- getHandler().getUi().repaint();
- }
- });
-
- }
-}
\ No newline at end of file
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -0,0 +1,87 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To cancel edit of a {@link CatchBatch}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class CancelEditCatchBatchAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CancelEditCatchBatchAction.class);
+
+ /**
+ * A flag to update ui after create or save the edit catch batch.
+ *
+ * @since 1.0
+ */
+ protected boolean updateUI;
+
+ public CancelEditCatchBatchAction(EditCatchesUIHandler handler) {
+ super(handler,
+ "cancelEditCatchBatch",
+ "cancel",
+ _("tutti.action.cancelEditCatchBatch"),
+ _("tutti.action.cancelEditCatchBatch.tip"),
+ true
+ );
+ }
+
+ @Override
+ protected void doAction(ActionEvent event) throws Exception {
+
+ if (getModel().isCreate()) {
+ if (log.isInfoEnabled()) {
+ log.info("Cancel creation for catchBatch");
+ }
+
+ // cancel to create a catch batch ?
+
+ } else {
+
+ if (log.isInfoEnabled()) {
+ log.info("Can edition of catchBatch");
+ }
+ }
+
+ }
+
+
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-02-10 15:03:24 UTC (rev 387)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -24,11 +24,6 @@
* #L%
*/
-import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiTabContainerUIHandler;
@@ -36,7 +31,6 @@
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import jaxx.runtime.swing.CardLayout2Ext;
import jaxx.runtime.validator.swing.SwingValidator;
-import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTitledPanel;
@@ -45,6 +39,7 @@
import javax.swing.JTabbedPane;
import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -65,24 +60,24 @@
private static final Log log =
LogFactory.getLog(EditCatchesUIHandler.class);
- /**
- * Persistence service.
- *
- * @since 0.3
- */
- private final PersistenceService persistenceService;
+// /**
+// * Persistence service.
+// *
+// * @since 0.3
+// */
+// private final PersistenceService persistenceService;
/**
* To monitor changes on the incoming fishing operation.
*
* @since 0.3
*/
- private final TuttiBeanMonitor<EditCatchesUIModel> fishingOperationMonitor;
+ private final TuttiBeanMonitor<EditCatchesUIModel> catchBatchMonitor;
public EditCatchesUIHandler(FishingOperationsUI parentUi, EditCatchesUI ui) {
super(parentUi.getHandler().getContext(), ui);
- this.persistenceService = context.getService(PersistenceService.class);
- this.fishingOperationMonitor = new TuttiBeanMonitor<EditCatchesUIModel>(
+// this.persistenceService = context.getService(PersistenceService.class);
+ this.catchBatchMonitor = new TuttiBeanMonitor<EditCatchesUIModel>(
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_WEIGHT,
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT,
EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT,
@@ -105,7 +100,7 @@
listModelIsModify(model);
- fishingOperationMonitor.setBean(model);
+ catchBatchMonitor.setBean(model);
}
@Override
@@ -168,108 +163,113 @@
//-- Public methods --//
//------------------------------------------------------------------------//
- public void selectFishingOperation(FishingOperation bean,
- String fishingOperationText) {
-
- boolean empty = bean == null;
- Preconditions.checkState(!empty, "can not edit a null fishing operation.");
- boolean newOperation = TuttiEntities.isNew(bean);
- boolean wasModified = fishingOperationMonitor.wasModified();
-
- // 1) Save any modification of the current fishingOperation
-
- if (wasModified) {
- save();
- }
-
- ui.getSpeciesTabContent().getHandler().clearTableSelection();
-// ui.getBenthosTabContent().getHandler().clearTableSelection();
-// ui.getPlanktonTabContent().getHandler().clearTableSelection();
-// ui.getMacroWasteTabContent().getHandler().clearTableSelection();
-// ui.getAccidentalTabContent().getHandler().clearTableSelection();
-
- // 2) Use new selected fishingOperation
-
- EditCatchesUIModel model = getModel();
-
- boolean otherOperation =
- ObjectUtils.notEqual(bean, model.getFishingOperation());
-
- if (empty || newOperation || otherOperation || wasModified) {
-
- CatchBatch batch;
-
- if (empty || newOperation) {
-
- // create a new CatchBatch
- if (log.isInfoEnabled()) {
- log.info("Create a new CatchBatch");
- }
- batch = new CatchBatch();
- batch.setFishingOperation(bean);
-
- } else {
-
- String operationId = bean.getId();
-
- if (log.isInfoEnabled()) {
- log.info("Load existing CatchBatch from operation id: " +
- operationId);
- }
-
- batch = persistenceService.getCatchBatchFromFishingOperation(
- operationId);
-
-// model.setCatchBatch(batch);
-// model.setFishingOperation(bean);
- }
-
- model.setCatchBatch(batch);
- model.setFishingOperation(bean);
-
- model.fromBean(batch);
-
- model.setModify(false);
- fishingOperationMonitor.clearModified();
-
- // 3) Propagate title to others tabs
- ui.getCatchesCaracteristicsTabPane().setTitle(fishingOperationText);
- ui.getSpeciesTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-// ui.getBenthosTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-// ui.getPlanktonTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-// ui.getMacroWasteTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-// ui.getAccidentalTabFishingOperationReminderLabel().setTitle(fishingOperationText);
-
- // 4) Propagate new selected fishingoperation to others tabs
-
- ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean);
-// ui.getBenthosTabContent().getHandler().selectFishingOperation(bean);
-// ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean);
-// ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean);
-// ui.getAccidentalTabContent().getHandler().selectFishingOperation(bean);
-
- ui.getTabPane().repaint();
- }
+ public TuttiBeanMonitor<EditCatchesUIModel> getCatchBatchMonitor() {
+ return catchBatchMonitor;
}
- protected void save() {
- // previous fishingOperation was modified, let's save it
- EditCatchesUIModel beanToSave = fishingOperationMonitor.getBean();
+// public void selectFishingOperation(FishingOperation bean,
+// String fishingOperationText) {
+//
+// boolean empty = bean == null;
+// Preconditions.checkState(!empty, "can not edit a null fishing operation.");
+// boolean newOperation = TuttiEntities.isNew(bean);
+// boolean wasModified = fishingOperationMonitor.wasModified();
+//
+// // 1) Save any modification of the current fishingOperation
+//
+// if (wasModified) {
+// save();
+// }
+//
+// ui.getSpeciesTabContent().getHandler().clearTableSelection();
+//// ui.getBenthosTabContent().getHandler().clearTableSelection();
+//// ui.getPlanktonTabContent().getHandler().clearTableSelection();
+//// ui.getMacroWasteTabContent().getHandler().clearTableSelection();
+//// ui.getAccidentalTabContent().getHandler().clearTableSelection();
+//
+// // 2) Use new selected fishingOperation
+//
+// EditCatchesUIModel catchesUIModel = getModel();
+//
+// boolean otherOperation =
+// ObjectUtils.notEqual(bean, catchesUIModel.getFishingOperation());
+//
+// if (empty || newOperation || otherOperation || wasModified) {
+//
+// CatchBatch batch;
+//
+// if (empty || newOperation) {
+//
+// // create a new CatchBatch
+// if (log.isInfoEnabled()) {
+// log.info("Create a new CatchBatch");
+// }
+// batch = new CatchBatch();
+// batch.setFishingOperation(bean);
+//
+// } else {
+//
+// String operationId = bean.getId();
+//
+// if (log.isInfoEnabled()) {
+// log.info("Load existing CatchBatch from operation id: " +
+// operationId);
+// }
+//
+// batch = persistenceService.getCatchBatchFromFishingOperation(
+// operationId);
+//
+//// model.setCatchBatch(batch);
+//// model.setFishingOperation(bean);
+// }
+//
+// catchesUIModel.setCatchBatch(batch);
+// catchesUIModel.setFishingOperation(bean);
+//
+// catchesUIModel.fromBean(batch);
+//
+// catchesUIModel.setModify(false);
+// fishingOperationMonitor.clearModified();
+//
+// // 3) Propagate title to others tabs
+// ui.getCatchesCaracteristicsTabPane().setTitle(fishingOperationText);
+// ui.getSpeciesTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+//// ui.getBenthosTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+//// ui.getPlanktonTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+//// ui.getMacroWasteTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+//// ui.getAccidentalTabFishingOperationReminderLabel().setTitle(fishingOperationText);
+//
+// // 4) Propagate new selected fishingoperation to others tabs
+//
+// ui.getSpeciesTabContent().getHandler().selectFishingOperation(bean);
+//// ui.getBenthosTabContent().getHandler().selectFishingOperation(bean);
+//// ui.getPlanktonTabContent().getHandler().selectFishingOperation(bean);
+//// ui.getMacroWasteTabContent().getHandler().selectFishingOperation(bean);
+//// ui.getAccidentalTabContent().getHandler().selectFishingOperation(bean);
+//
+// ui.getTabPane().repaint();
+// }
+// }
- CatchBatch catchBatch = beanToSave.toBean();
+// public void save() {
+//
+// // previous fishingOperation was modified, let's save it
+// EditCatchesUIModel beanToSave = catchBatchMonitor.getBean();
+//
+// CatchBatch catchBatch = beanToSave.toBean();
+//
+// if (log.isInfoEnabled()) {
+// log.info("FishingOperation " + catchBatch.getId() +
+// " was modified, will save it.");
+// }
+//
+// showInformationMessage(
+// "[ Captures - Caractéristiques générales ] " +
+// "Sauvegarde des modifications du résumé de la capture.");
+//
+// persistenceService.saveCatchBatch(catchBatch);
+// }
- if (log.isInfoEnabled()) {
- log.info("FishingOperation " + catchBatch.getId() +
- " was modified, will save it.");
- }
-
- showInformationMessage(
- "[ Captures - Caractéristiques générales ] " +
- "Sauvegarde des modifications du résumé de la capture.");
-
- persistenceService.saveCatchBatch(catchBatch);
- }
-
protected void registerValidators() {
registerValidators(getValidator(), ui.getSpeciesTabContent().getHandler().getValidator());
}
@@ -289,17 +289,17 @@
if (CREATE_BATCH_CARD.equals(card)) {
tuttiUi = ui.getSpeciesTabCreateBatch();
titlePanel = ui.getSpeciesTabCreateBatchReminderLabel();
- title = "tutti.title.createBatch";
+ title = n_("tutti.title.createBatch");
} else if (SPLIT_BATCH_CARD.equals(card)) {
tuttiUi = ui.getSpeciesTabSplitBatch();
titlePanel = ui.getSpeciesTabSplitBatchReminderLabel();
- title = "tutti.title.splitBatch";
+ title = n_("tutti.title.splitBatch");
} else if (EDIT_FREQUENCY_CARD.equals(card)) {
tuttiUi = ui.getSpeciesTabFrequencyEditor();
titlePanel = ui.getSpeciesTabFrequencyEditorReminderLabel();
- title = "tutti.title.editFrequency";
+ title = n_("tutti.title.editFrequency");
}
if (tuttiUi != null) {
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java 2013-02-10 15:04:13 UTC (rev 388)
@@ -0,0 +1,120 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To save a {@link CatchBatch}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0
+ */
+public class SaveCatchBatchAction extends AbstractTuttiAction<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(SaveCatchBatchAction.class);
+
+
+ /**
+ * A flag to update ui after create or save the edit catch batch.
+ *
+ * @since 1.0
+ */
+ protected boolean updateUI;
+
+ public SaveCatchBatchAction(EditCatchesUIHandler handler) {
+ super(handler,
+ "saveCatchBatch",
+ "save",
+ _("tutti.action.saveCatchBatch"),
+ _("tutti.action.saveCatchBatch.tip"),
+ true
+ );
+ }
+
+ public void setUpdateUI(boolean updateUI) {
+ this.updateUI = updateUI;
+ }
+
+ @Override
+ protected void releaseAction(ActionEvent event) {
+ updateUI = true;
+ super.releaseAction(event);
+ }
+
+ @Override
+ protected void doAction(ActionEvent event) {
+
+ EditCatchesUIHandler handler = getHandler();
+
+ TuttiBeanMonitor<EditCatchesUIModel> monitor =
+ handler.getCatchBatchMonitor();
+
+ // previous fishingOperation was modified, let's save it
+ EditCatchesUIModel beanToSave = monitor.getBean();
+
+ // must save when bean is new or was modifiy and is valid
+ boolean mustSave = (beanToSave.isCreate() || beanToSave.isModify()) &&
+ beanToSave.isValid();
+
+ if (mustSave) {
+
+ PersistenceService persistenceService =
+ getService(PersistenceService.class);
+
+ CatchBatch catchBatch = beanToSave.toBean();
+
+ if (log.isInfoEnabled()) {
+ log.info("FishingOperation " + catchBatch.getId() +
+ " was modified, will save it.");
+ }
+
+ getHandler().showInformationMessage(
+ "[ Captures - Caractéristiques générales ] " +
+ "Sauvegarde des modifications du résumé de la capture.");
+
+ persistenceService.saveCatchBatch(catchBatch);
+
+ monitor.clearModified();
+ }
+
+ getUI().getSpeciesTabContent().getHandler().clearTableSelection();
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/SaveCatchBatchAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r387 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches
by tchemit@users.forge.codelutin.com 10 Feb '13
by tchemit@users.forge.codelutin.com 10 Feb '13
10 Feb '13
Author: tchemit
Date: 2013-02-10 16:03:24 +0100 (Sun, 10 Feb 2013)
New Revision: 387
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/387
Log:
add cancel - save actions on catchBatch ui
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-02-10 15:02:42 UTC (rev 386)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-02-10 15:03:24 UTC (rev 387)
@@ -252,3 +252,11 @@
#observationIndividuelTab {
enabled: {false};
}
+
+#saveButton {
+ _tuttiAction: {SaveCatchBatchAction.class};
+}
+
+#cancelButton {
+ _tuttiAction: {CancelEditCatchBatchAction.class};
+}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-02-10 15:02:42 UTC (rev 386)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-02-10 15:03:24 UTC (rev 387)
@@ -344,4 +344,13 @@
</tab>
</JTabbedPane>
+ <!-- Actions -->
+ <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.SOUTH'>
+ <JPanel id='createFishingOperationActions' layout='{new GridLayout(1,0)}'
+ constraints='BorderLayout.CENTER'>
+ <JButton id='cancelButton'/>
+ <JButton id='saveButton'/>
+ </JPanel>
+ </JPanel>
+
</JPanel>
\ No newline at end of file
1
0
r386 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing
by tchemit@users.forge.codelutin.com 10 Feb '13
by tchemit@users.forge.codelutin.com 10 Feb '13
10 Feb '13
Author: tchemit
Date: 2013-02-10 16:02:42 +0100 (Sun, 10 Feb 2013)
New Revision: 386
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/386
Log:
open api
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-02-10 15:02:10 UTC (rev 385)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-02-10 15:02:42 UTC (rev 386)
@@ -356,7 +356,7 @@
}
}
- protected void clearValidators() {
+ public void clearValidators() {
MainUI main = context.getMainUI();
Preconditions.checkNotNull(
main, "No mainUI registred in application context");
1
0
r385 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species
by tchemit@users.forge.codelutin.com 10 Feb '13
by tchemit@users.forge.codelutin.com 10 Feb '13
10 Feb '13
Author: tchemit
Date: 2013-02-10 16:02:10 +0100 (Sun, 10 Feb 2013)
New Revision: 385
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/385
Log:
use renmaed species protocol id
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-02-10 15:01:31 UTC (rev 384)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-02-10 15:02:10 UTC (rev 385)
@@ -470,7 +470,7 @@
if (!protocol.isSpeciesEmpty()) {
Map<String, Species> map = TuttiEntities.splitById(speciesUniverse);
for (SpeciesProtocol protocolSpecy : protocol.getSpecies()) {
- Species species = map.get(protocolSpecy.getSpeciesId());
+ Species species = map.get(protocolSpecy.getSpeciesReferenceTaxonId());
allSpecies.add(species);
speciesSampleCategories.put(species, SampleCategoryType.sortedUnsorted);
speciesSampleCategories.put(species, SampleCategoryType.size);
1
0
r384 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing java/fr/ifremer/tutti/ui/swing/content/cruise java/fr/ifremer/tutti/ui/swing/content/home java/fr/ifremer/tutti/ui/swing/content/program resources/i18n
by tchemit@users.forge.codelutin.com 10 Feb '13
by tchemit@users.forge.codelutin.com 10 Feb '13
10 Feb '13
Author: tchemit
Date: 2013-02-10 16:01:31 +0100 (Sun, 10 Feb 2013)
New Revision: 384
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/384
Log:
improve action api and logs
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/SaveCruiseAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/SaveProgramAction.java
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/AbstractTuttiAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java 2013-02-10 15:00:32 UTC (rev 383)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiAction.java 2013-02-10 15:01:31 UTC (rev 384)
@@ -27,6 +27,8 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.TuttiService;
+import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.ErrorDialogUI;
import org.apache.commons.logging.Log;
@@ -119,7 +121,7 @@
public final void actionPerformed(final ActionEvent event) {
if (log.isInfoEnabled()) {
- log.info("Will starts action: " + this);
+ log.info("Task [" + this + "] starting");
}
boolean doAction = prepareAction(event);
@@ -150,6 +152,8 @@
runAction(false, event);
}
+ } else {
+ releaseAction(event);
}
}
@@ -170,14 +174,14 @@
this.doAction(event);
} catch (Throwable e) {
if (log.isErrorEnabled()) {
- log.error("Error:" + e.getMessage(), e);
+ log.error("Task [" + this + "] error: " + e.getMessage(), e);
}
if (e instanceof Exception) {
ErrorDialogUI.showError((Exception) e);
}
} finally {
if (log.isInfoEnabled()) {
- log.info("After action: " + this);
+ log.info("Task [" + this + "] done");
}
if (timer != null) {
@@ -208,6 +212,14 @@
return handler.getModel();
}
+ protected <S extends TuttiService> S getService(Class<S> serviceType) {
+ return getContext().getService(serviceType);
+ }
+
+ protected TuttiApplicationConfig getConfig() {
+ return getContext().getConfig();
+ }
+
protected void setMnemonic(int key) {
putValue(MNEMONIC_KEY, key);
}
@@ -243,8 +255,8 @@
if (canceled) {
- if (log.isInfoEnabled()) {
- log.info("Task [" + action + "] was already canceled, do nothing");
+ if (log.isDebugEnabled()) {
+ log.debug("Task [" + action + "] was already canceled, do nothing");
}
} else {
@@ -275,8 +287,8 @@
d.pack();
SwingUtil.center(ui, d);
- if (log.isInfoEnabled()) {
- log.info("Try to open dialog (was canceled ? " + canceled + ")");
+ if (log.isDebugEnabled()) {
+ log.debug("Try to open dialog (was canceled ? " + canceled + ")");
}
if (!canceled) {
@@ -292,8 +304,8 @@
public boolean cancel() {
synchronized (lock) {
canceled = true;
- if (log.isInfoEnabled()) {
- log.info("Task [" + action + "] canceled.");
+ if (log.isDebugEnabled()) {
+ log.debug("Task [" + action + "] canceled.");
}
boolean cancel = super.cancel();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/SaveCruiseAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/SaveCruiseAction.java 2013-02-10 15:00:32 UTC (rev 383)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/SaveCruiseAction.java 2013-02-10 15:01:31 UTC (rev 384)
@@ -66,7 +66,7 @@
TuttiUIContext context = getContext();
EditCruiseUIModel model = getModel();
PersistenceService persistenceService =
- context.getService(PersistenceService.class);
+ getService(PersistenceService.class);
Cruise bean = model.toBean();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java 2013-02-10 15:00:32 UTC (rev 383)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java 2013-02-10 15:01:31 UTC (rev 384)
@@ -86,7 +86,7 @@
log.info("Delete protocol: " + id);
}
- PersistenceService service = getContext().getService(PersistenceService.class);
+ PersistenceService service = getService(PersistenceService.class);
service.deleteProtocol(id);
getModel().setProtocol(null);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java 2013-02-10 15:00:32 UTC (rev 383)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java 2013-02-10 15:01:31 UTC (rev 384)
@@ -107,7 +107,7 @@
}
// export protocol
TuttiProtocolImportExportService service =
- getContext().getService(TuttiProtocolImportExportService.class);
+ getService(TuttiProtocolImportExportService.class);
service.exportProtocol(protocol, file);
sendMessage("Protocole [" + protocol.getName() +
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java 2013-02-10 15:00:32 UTC (rev 383)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java 2013-02-10 15:01:31 UTC (rev 384)
@@ -102,7 +102,7 @@
// import protocol
TuttiProtocolImportExportService service =
- getContext().getService(TuttiProtocolImportExportService.class);
+ getService(TuttiProtocolImportExportService.class);
TuttiProtocol protocol = service.importProtocol(file);
sendMessage("Protocole [" + protocol.getName() + "] lu depuis le fichier.");
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/SaveProgramAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/SaveProgramAction.java 2013-02-10 15:00:32 UTC (rev 383)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/SaveProgramAction.java 2013-02-10 15:01:31 UTC (rev 384)
@@ -68,7 +68,9 @@
@Override
protected void doAction(ActionEvent event) {
TuttiUIContext context = getContext();
- PersistenceService persistenceService = context.getService(PersistenceService.class);
+ PersistenceService persistenceService =
+ getService(PersistenceService.class);
+
EditProgramUIModel model = getModel();
Program bean = model.toBean();
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-02-10 15:00:32 UTC (rev 383)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-02-10 15:01:31 UTC (rev 384)
@@ -3,6 +3,7 @@
tutti.action.about=À propos
tutti.action.about.tip=À Propos
tutti.action.addSpecies.tip=Ajouter une espèce
+tutti.action.addSpeciesProtocol.tip=Ajouter une espèce au protocole
tutti.action.attachments=Pièces jointes (%s)
tutti.action.attachments.tip=Pièces jointes
tutti.action.cancel=Annuler
@@ -14,6 +15,8 @@
tutti.action.cancel.editProgram.tip=Annuler l'édition (ou la création) de la série de campagne
tutti.action.cancel.editProtocol=Annuler
tutti.action.cancel.editProtocol.tip=Annuler l'édition (ou la création) du protocole
+tutti.action.cancelEditCatchBatch=Annuler
+tutti.action.cancelEditCatchBatch.tip=Annuler l'édition de la capture
tutti.action.casino-import=Import Casino
tutti.action.chooseProtocolCaracteristicFile=Choisir le fichier des caractéristiques
tutti.action.chooseProtocolFile=Choisir le fichier de protocole
@@ -37,6 +40,7 @@
tutti.action.editCatches.tip=Saisir des captures
tutti.action.editCruise=Éditer
tutti.action.editCruise.tip=Éditer la campagne sélectionnée
+tutti.action.editFishingOperation.tip=Éditer l'opération de pêche
tutti.action.editProgram=Éditer
tutti.action.editProgram.tip=Éditer le programme sélectionné
tutti.action.editProtocol=Éditer
@@ -103,12 +107,16 @@
tutti.action.removeSpecies=Supprimer l'espèce
tutti.action.removeSpeciesBatch=Supprimer le lot
tutti.action.removeSpeciesBatch.tip=Supprimer le lot courant (celui de la ligne sélectionnée) et tous ces fils
+tutti.action.removeSpeciesProtocol=Supprimer l'espèce
+tutti.action.removeSpeciesProtocol.tip=Supprimer l'espèce
tutti.action.removeSpeciesSubBatch=Supprimer les lots fils
tutti.action.removeSpeciesSubBatch.tip=Supprimer tous les lots fils du lot sélectionné
tutti.action.renameSpeciesBatch=Corriger l'espèce
tutti.action.renameSpeciesBatch.tip=Corriger l'espèce sur tout le lot sélectionné
tutti.action.reset.fishingOperationValidState=Réinitialiser
tutti.action.save=Enregistrer
+tutti.action.saveCatchBatch=Sauver
+tutti.action.saveCatchBatch.tip=Sauver la capture
tutti.action.saveCruise=Enregistrer
tutti.action.saveCruise.tip=Enregistrer la campagne
tutti.action.saveFishingOperation=Enregistrer
@@ -139,7 +147,9 @@
tutti.config.category.shortcuts.description=Liste des raccourcis clavier
tutti.config.category.ui=Interface utilisateur
tutti.config.category.ui.description=Options de l'interface utilisateur
+tutti.dialog.askSaveBeforeLeaving.createFishingOperation=Vous avez fait des modifications qu vous n'avez pas enregistrées. Voulez-vous les enregistrer ?
tutti.dialog.askSaveBeforeLeaving.message=Vous avez fait des modifications qu vous n'avez pas enregistrées. Voulez-vous les enregistrer ?
+tutti.dialog.askSaveBeforeLeaving.saveFishingOperation=Vous avez fait des modifications qu vous n'avez pas enregistrées. Voulez-vous les enregistrer ?
tutti.dialog.askSaveBeforeLeaving.title=Modifications non enregistrées
tutti.dialog.catches.species.computeWeight.error.message=Erreur lors de l'élévation des poids
tutti.dialog.catches.species.computeWeight.error.title=Erreur
@@ -148,6 +158,13 @@
tutti.duration.format=dj Hh m'm'
tutti.file.csv=Extension d'un fichier csv
tutti.file.protocol=Extension d'un fichier de protocole Tutti
+tutti.flash.information.all.caractristic.exported=Toutes les caractéristiques exportées dans le fichier %s.
+tutti.flash.information.caracteristic.imported.in.protocol=Caractéristiques importées dans le protocole depuis le fichier %s.
+tutti.flash.information.caractristic.exported.from.protocol=Caractéristiques du protocole exportées dans le fichier %s.
+tutti.flash.information.species.add.to.protocol=L'espèce %s a été ajoutée au protocole
+tutti.flash.information.species.exported.from.protocol=Espèces du protocole exportées dans le fichier %s.
+tutti.flash.information.species.imported.in.protocol=Espèces importées dans le protocole depuis le fichier %s.
+tutti.flash.information.species.remove.from.protocol=L'espèce %s a été retirée du protocole
tutti.information.import.temporary.referential=Vous pouvez ici importer des référentiels temporaires
tutti.label.attachmentEditor.file=Fichier
tutti.label.attachmentEditor.fileComment=Commentaire
@@ -374,8 +391,8 @@
tutti.table.protocol.species.header.sex.tip=Catégorisation sur le sexe ?
tutti.table.protocol.species.header.size=Catégorie Tri
tutti.table.protocol.species.header.size.tip=Catégorisation sur la catégorie de tri ?
-tutti.table.protocol.species.header.speciesId=Espèce
-tutti.table.protocol.species.header.speciesId.tip=Espèce (code permanent - nom scientifique)
+tutti.table.protocol.species.header.speciesReferenceTaxonId=Espèce
+tutti.table.protocol.species.header.speciesReferenceTaxonId.tip=Espèce (code refTax - nom scientifique)
tutti.table.protocol.species.header.speciesSurveyCode=Code
tutti.table.protocol.species.header.speciesSurveyCode.tip=Code campagne (non synchronisable)
tutti.table.protocol.species.header.weight=Pesée
@@ -419,6 +436,7 @@
tutti.title.create.cruise=Créer une nouvelle campagne
tutti.title.create.program=Créer une nouvelle série de campagne
tutti.title.create.protocol=Créer un nouveau protocol de saisie
+tutti.title.createBatch=Créer un lot
tutti.title.edit.cruise=Éditer une campagne existante
tutti.title.edit.operations=Saisie des opérations de pêches (%s)
tutti.title.edit.program=Éditer une série de campagne existante
1
0
r383 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol
by tchemit@users.forge.codelutin.com 10 Feb '13
by tchemit@users.forge.codelutin.com 10 Feb '13
10 Feb '13
Author: tchemit
Date: 2013-02-10 16:00:32 +0100 (Sun, 10 Feb 2013)
New Revision: 383
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/383
Log:
imporve protocol action
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportAllCaracteristicAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolCaracteristicAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java 2013-02-10 14:59:07 UTC (rev 382)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java 2013-02-10 15:00:32 UTC (rev 383)
@@ -26,9 +26,11 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
import java.awt.event.ActionEvent;
+import java.util.Collection;
import static org.nuiton.i18n.I18n._;
@@ -58,27 +60,39 @@
EditProtocolUI ui = getUI();
- EditProtocolSpeciesTableModel tableModel = getHandler().getTableModel();
+ EditProtocolUIHandler handler = getHandler();
+
+ EditProtocolSpeciesTableModel tableModel = handler.getTableModel();
Species species = (Species) ui.getSpeciesComboBox().getSelectedItem();
- Preconditions.checkNotNull(species);
- EditProtocolSpeciesRowModel protocol = tableModel.createNewRow();
+ Preconditions.checkNotNull(
+ species, "Cant add a speciesProtocol with a null species");
+
Integer taxonId = species.getReferenceTaxonId();
// get referent species
String taxonIdStr = String.valueOf(taxonId);
- Species referentSpecies = getHandler().getAllReferentSpeciesByTaxonId().get(taxonIdStr);
- protocol.setSpecies(referentSpecies);
- tableModel.addNewRow(protocol);
+ Species referentSpecies =
+ getModel().getAllReferentSpeciesByTaxonId().get(taxonIdStr);
+
// remove all synonyms of this taxon
- getHandler().removeSpeciesSynonyms(ui.getSpeciesComboBox().getData(), taxonIdStr);
+ Collection<Species> allSynonyms = getModel().getAllSynonyms(taxonIdStr);
+ ui.getSpeciesComboBox().getData().removeAll(allSynonyms);
ui.getSpeciesComboBox().getHandler().sortData();
+ handler.selectFirstInCombo(ui.getSpeciesComboBox());
- getHandler().selectFirstInCombo(ui.getSpeciesComboBox());
+ // add new row to model (do it after combo stuff for ui best display)
+ EditProtocolSpeciesRowModel protocol = tableModel.createNewRow();
+ protocol.setSpecies(referentSpecies);
+ tableModel.addNewRow(protocol);
getModel().setModify(true);
+ String speciesStr = getDecorator(Species.class, DecoratorService.SPECIES_BY_CRUISE_CODE).toString(referentSpecies);
+ sendMessage(_("tutti.flash.information.species.add.to.protocol",
+ speciesStr));
+
}
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-02-10 14:59:07 UTC (rev 382)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-02-10 15:00:32 UTC (rev 383)
@@ -24,6 +24,7 @@
* #L%
*/
+import com.ezware.oxbow.swingbits.util.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
@@ -58,6 +59,7 @@
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -72,16 +74,6 @@
private static final Log log =
LogFactory.getLog(EditProtocolUIHandler.class);
- protected List<Species> allSpecies;
-
- protected Multimap<String, Species> allSpeciesByTaxonId;
-
- protected Map<String, Species> allReferentSpeciesByTaxonId;
-
- protected List<Caracteristic> caracteristics;
-
- protected Map<String, Caracteristic> allCaracteristic;
-
public EditProtocolUIHandler(TuttiUI parentUi, EditProtocolUI ui) {
super(parentUi.getHandler().getContext(), ui);
}
@@ -153,45 +145,36 @@
EditProtocolUIModel model = new EditProtocolUIModel();
- // can't load directly model from database here, since we want to
- // fill only the model with rows (transformed from speciesProtocol)
- // As we still don't have the table model at this point, wait the
- // afterUI method to fill model
+ // load cache data
- listModelIsModify(model);
- ui.setContextValue(model);
+ List<Species> allSpecies = Lists.newArrayList(persistenceService.getAllSpecies());
+ model.setAllSpecies(allSpecies);
+ Multimap<String, Species> allSpeciesByTaxonId = Multimaps.index(allSpecies,
+ TuttiEntities.GET_TAXON_ID);
- allSpecies = Lists.newArrayList(persistenceService.getAllSpecies());
-
- allSpeciesByTaxonId = Multimaps.index(allSpecies,
- TuttiEntities.GET_TAXON_ID);
-
- allReferentSpeciesByTaxonId = TuttiEntities.splitByTaxonId(
+ model.setAllSpeciesByTaxonId(allSpeciesByTaxonId);
+ Map<String, Species> allReferentSpeciesByTaxonId = TuttiEntities.splitByTaxonId(
persistenceService.getAllReferentSpecies());
+ model.setAllReferentSpeciesByTaxonId(allReferentSpeciesByTaxonId);
List<TuttiProtocol> protocols = persistenceService.getAllProtocol();
model.setExistingProtocols(protocols);
- caracteristics = persistenceService.getAllCaracteristic();
- allCaracteristic = TuttiEntities.splitById(caracteristics);
- }
+ List<Caracteristic> caracteristics = persistenceService.getAllCaracteristic();
+ model.setCaracteristics(caracteristics);
- public Map<String, Caracteristic> getAllCaracteristic() {
- return allCaracteristic;
- }
+ Map<String, Caracteristic> allCaracteristic = TuttiEntities.splitById(caracteristics);
+ model.setAllCaracteristic(allCaracteristic);
- public List<Species> getAllSpecies() {
- return allSpecies;
- }
+ // can't load directly model from database here, since we want to
+ // fill only the model with rows (transformed from speciesProtocol)
+ // As we still don't have the table model at this point, wait the
+ // afterUI method to fill model
- public Map<String, Species> getAllReferentSpeciesByTaxonId() {
- return allReferentSpeciesByTaxonId;
+ listModelIsModify(model);
+ ui.setContextValue(model);
}
- public Multimap<String, Species> getAllSpeciesByTaxonId() {
- return allSpeciesByTaxonId;
- }
-
@Override
public void afterInitUI() {
@@ -280,7 +263,7 @@
initTable(table);
- List<Species> speciesList = Lists.newArrayList(allSpecies);
+ List<Species> speciesList = Lists.newArrayList(model.getAllSpecies());
List<EditProtocolSpeciesRowModel> rows;
@@ -305,22 +288,22 @@
initDoubleList(EditProtocolUIModel.PROPERTY_LENGTH_CLASSES_PMFM_ID,
ui.getLengthClassesList(),
- Lists.newArrayList(caracteristics),
+ Lists.newArrayList(model.getCaracteristics()),
model.getLengthClassesPmfmId());
initDoubleList(EditProtocolUIModel.PROPERTY_GEAR_PMFM_ID,
ui.getGearList(),
- Lists.newArrayList(caracteristics),
+ Lists.newArrayList(model.getCaracteristics()),
model.getGearPmfmId());
initDoubleList(EditProtocolUIModel.PROPERTY_ENVIRONMENT_PMFM_ID,
ui.getEnvironmentList(),
- Lists.newArrayList(caracteristics),
+ Lists.newArrayList(model.getCaracteristics()),
model.getEnvironmentPmfmId());
initDoubleList(EditProtocolUIModel.PROPERTY_HYDROLOGY_PMFM_ID,
ui.getHydrologyList(),
- Lists.newArrayList(caracteristics),
+ Lists.newArrayList(model.getCaracteristics()),
model.getHydrologyPmfmId());
// if new protocol can already cancel his creation
@@ -330,18 +313,22 @@
public List<EditProtocolSpeciesRowModel> toRows(List<Species> speciesList,
List<SpeciesProtocol> speciesProtocols) {
- boolean useComboData = speciesList == null;
+ Preconditions.checkNotNull(speciesList);
- if (useComboData) {
- speciesList = ui.getSpeciesComboBox().getData();
- }
+ EditProtocolUIModel model = getModel();
+
+ Map<String, Species> allReferentSpeciesByTaxonId = model.getAllReferentSpeciesByTaxonId();
+ Map<String, Caracteristic> allCaracteristic = model.getAllCaracteristic();
+
List<EditProtocolSpeciesRowModel> result = Lists.newArrayList();
if (CollectionUtils.isNotEmpty(speciesProtocols)) {
for (SpeciesProtocol speciesProtocol : speciesProtocols) {
Integer taxonId = speciesProtocol.getSpeciesReferenceTaxonId();
String taxonIdStr = String.valueOf(taxonId);
+
// remove all synonyms from available species list
- removeSpeciesSynonyms(speciesList, taxonIdStr);
+ Collection<Species> allSynonyms = model.getAllSynonyms(taxonIdStr);
+ speciesList.removeAll(allSynonyms);
EditProtocolSpeciesRowModel row = getTableModel().createNewRow();
@@ -354,9 +341,6 @@
}
}
- if (useComboData) {
- selectFirstInCombo(ui.getSpeciesComboBox());
- }
return result;
}
@@ -453,7 +437,9 @@
initBeanList(widget, availableCaracteristics,
Lists.<Caracteristic>newArrayList());
- UpdateSelectedList listener = new UpdateSelectedList(widget, allCaracteristic);
+ UpdateSelectedList listener = new UpdateSelectedList(
+ widget,
+ getModel().getAllCaracteristic());
widget.putClientProperty("_updateListener", listener);
widget.putClientProperty("_updateListenerId", propertyId);
listener.select(selectedCaracteristics);
@@ -461,6 +447,7 @@
protected void selectLengthClasses(List<String> ids, JComboBox comboBox) {
+ Map<String, Caracteristic> allCaracteristic = getModel().getAllCaracteristic();
List<Caracteristic> selection = Lists.newArrayList();
if (CollectionUtils.isNotEmpty(ids)) {
for (String id : ids) {
@@ -505,10 +492,6 @@
EditProtocolSpeciesTableModel.LENGTH_STEP_PMFM_ID);
}
- protected void removeSpeciesSynonyms(List<Species> speciesList, String taxonId) {
- speciesList.removeAll(allSpeciesByTaxonId.get(taxonId));
- }
-
protected static class UpdateSelectedList implements PropertyChangeListener {
private final BeanDoubleListModel<Caracteristic> model;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-02-10 14:59:07 UTC (rev 382)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-02-10 15:00:32 UTC (rev 383)
@@ -24,14 +24,18 @@
* #L%
*/
+import com.google.common.collect.Multimap;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
+import java.util.Collection;
import java.util.List;
+import java.util.Map;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -78,6 +82,16 @@
*/
protected boolean removeSpeciesEnabled;
+ protected List<Species> allSpecies;
+
+ protected Multimap<String, Species> allSpeciesByTaxonId;
+
+ protected Map<String, Species> allReferentSpeciesByTaxonId;
+
+ protected List<Caracteristic> caracteristics;
+
+ protected Map<String, Caracteristic> allCaracteristic;
+
protected static Binder<EditProtocolUIModel, TuttiProtocol> toBeanBinder =
BinderFactory.newBinder(EditProtocolUIModel.class,
TuttiProtocol.class);
@@ -199,4 +213,47 @@
this.existingProtocols = existingProtocols;
}
+ public List<Species> getAllSpecies() {
+ return allSpecies;
+ }
+
+ public void setAllSpecies(List<Species> allSpecies) {
+ this.allSpecies = allSpecies;
+ }
+
+ public Multimap<String, Species> getAllSpeciesByTaxonId() {
+ return allSpeciesByTaxonId;
+ }
+
+ public Collection<Species> getAllSynonyms(String taxonId) {
+ return allSpeciesByTaxonId.get(taxonId);
+ }
+
+ public void setAllSpeciesByTaxonId(Multimap<String, Species> allSpeciesByTaxonId) {
+ this.allSpeciesByTaxonId = allSpeciesByTaxonId;
+ }
+
+ public Map<String, Species> getAllReferentSpeciesByTaxonId() {
+ return allReferentSpeciesByTaxonId;
+ }
+
+ public void setAllReferentSpeciesByTaxonId(Map<String, Species> allReferentSpeciesByTaxonId) {
+ this.allReferentSpeciesByTaxonId = allReferentSpeciesByTaxonId;
+ }
+
+ public List<Caracteristic> getCaracteristics() {
+ return caracteristics;
+ }
+
+ public void setCaracteristics(List<Caracteristic> caracteristics) {
+ this.caracteristics = caracteristics;
+ }
+
+ public Map<String, Caracteristic> getAllCaracteristic() {
+ return allCaracteristic;
+ }
+
+ public void setAllCaracteristic(Map<String, Caracteristic> allCaracteristic) {
+ this.allCaracteristic = allCaracteristic;
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportAllCaracteristicAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportAllCaracteristicAction.java 2013-02-10 14:59:07 UTC (rev 382)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportAllCaracteristicAction.java 2013-02-10 15:00:32 UTC (rev 383)
@@ -94,12 +94,10 @@
// export protocol caracteristics
TuttiProtocolImportExportService service =
- getContext().getService(TuttiProtocolImportExportService.class);
+ getService(TuttiProtocolImportExportService.class);
- service.exportAllCaracteristic(file,
- getHandler().getAllCaracteristic());
+ service.exportAllCaracteristic(file, getModel().getAllCaracteristic());
- sendMessage("Toutes les caractéristiques exportées dans le fichier "
- + file + ".");
+ sendMessage(_("tutti.flash.information.all.caractristic.exported", file));
}
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolCaracteristicAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolCaracteristicAction.java 2013-02-10 14:59:07 UTC (rev 382)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolCaracteristicAction.java 2013-02-10 15:00:32 UTC (rev 383)
@@ -98,13 +98,13 @@
// export protocol caracteristics
TuttiProtocolImportExportService service =
- getContext().getService(TuttiProtocolImportExportService.class);
+ getService(TuttiProtocolImportExportService.class);
service.exportProtocolCaracteristic(file,
protocol,
- getHandler().getAllCaracteristic());
+ getModel().getAllCaracteristic());
- sendMessage("Caractéristiques du Protocole exportées dans le fichier "
- + file + ".");
+ sendMessage(_("tutti.flash.information.caractristic.exported.from.protocol",
+ file));
}
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java 2013-02-10 14:59:07 UTC (rev 382)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java 2013-02-10 15:00:32 UTC (rev 383)
@@ -26,7 +26,6 @@
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
-import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
@@ -96,12 +95,12 @@
log.info("Will export protocol species to file: " + file);
}
- // bind to a protocol
- TuttiProtocol protocol = getModel().toBean();
+ EditProtocolUIModel model = getModel();
+ // build species protocol to export
+
List<SpeciesProtocol> protocols = Lists.newArrayList();
-
- for (EditProtocolSpeciesRowModel row : getModel().getRows()) {
+ for (EditProtocolSpeciesRowModel row : model.getRows()) {
if (row.isValid()) {
protocols.add(row.toBean());
}
@@ -109,13 +108,14 @@
// import
TuttiProtocolImportExportService service =
- getContext().getService(TuttiProtocolImportExportService.class);
+ getService(TuttiProtocolImportExportService.class);
service.exportProtocolSpecies(file,
protocols,
- getHandler().getAllCaracteristic(),
- getHandler().getAllReferentSpeciesByTaxonId());
+ model.getAllCaracteristic(),
+ model.getAllReferentSpeciesByTaxonId());
- sendMessage("Espèces du Protocole exportés dans le fichier " + file + ".");
+ sendMessage(_("tutti.flash.information.species.exported.from.protocol",
+ file));
}
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java 2013-02-10 14:59:07 UTC (rev 382)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java 2013-02-10 15:00:32 UTC (rev 383)
@@ -25,8 +25,10 @@
*/
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.service.TuttiService;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
+import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -93,27 +95,31 @@
log.info("Will import protocol caracteristic file: " + file);
}
+ EditProtocolUIHandler handler = getHandler();
EditProtocolUIModel model = getModel();
// bind to a protocol
TuttiProtocol protocol = model.toBean();
TuttiProtocolImportExportService service =
- getContext().getService(TuttiProtocolImportExportService.class);
+ getService(TuttiProtocolImportExportService.class);
service.importProtocolCaracteristic(file,
protocol,
- getHandler().getAllCaracteristic());
+ model.getAllCaracteristic());
- getHandler().addDoubleListListeners();
+ handler.addDoubleListListeners();
try {
// rebind to model
model.fromBean(protocol);
} finally {
- getHandler().removeDoubleListListeners();
+ handler.removeDoubleListListeners();
}
- sendMessage("Caractéristiques importées depuis le fichier " + file);
+ sendMessage(
+ _("tutti.flash.information.caracteristic.imported.in.protocol",
+ file));
+
}
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java 2013-02-10 14:59:07 UTC (rev 382)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java 2013-02-10 15:00:32 UTC (rev 383)
@@ -25,9 +25,11 @@
*/
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import jaxx.runtime.swing.editor.bean.BeanComboBox;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -94,6 +96,7 @@
log.info("Will import protocol species file: " + file);
}
+ EditProtocolUIHandler handler = getHandler();
EditProtocolUIModel model = getModel();
// bind to a protocol
@@ -101,19 +104,29 @@
// import
TuttiProtocolImportExportService service =
- getContext().getService(TuttiProtocolImportExportService.class);
+ getService(TuttiProtocolImportExportService.class);
service.importProtocolSpecies(file,
protocol,
- getHandler().getAllCaracteristic(),
- getHandler().getAllReferentSpeciesByTaxonId());
+ model.getAllCaracteristic(),
+ model.getAllReferentSpeciesByTaxonId());
+ BeanComboBox<Species> speciesComboBox = getUI().getSpeciesComboBox();
+
+ // build rows from imported+merged protocol
+ // (will also remove all synonyms of species referent used)
List<EditProtocolSpeciesRowModel> rows =
- getHandler().toRows(null, protocol.getSpecies());
+ handler.toRows(speciesComboBox.getData(),
+ protocol.getSpecies());
+
+ // update species comboBox
+ speciesComboBox.getHandler().sortData();
+ handler.selectFirstInCombo(speciesComboBox);
+
+ // update rows in model
model.setRows(rows);
- // update
-
- sendMessage("Espèces importées depuis le fichier " + file + ".");
+ sendMessage(_("tutti.flash.information.species.imported.in.protocol",
+ file));
}
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java 2013-02-10 14:59:07 UTC (rev 382)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java 2013-02-10 15:00:32 UTC (rev 383)
@@ -25,9 +25,12 @@
*/
import com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiAction;
import java.awt.event.ActionEvent;
+import java.util.Collection;
import static org.nuiton.i18n.I18n._;
@@ -45,7 +48,7 @@
super(handler,
"removeSpeciesProtocol",
"batch-delete",
- null,
+ _("tutti.action.removeSpeciesProtocol"),
_("tutti.action.removeSpeciesProtocol.tip"),
false
);
@@ -60,16 +63,23 @@
Preconditions.checkState(rowIndex != -1,
"Cant remove species if no species selected");
- // remove the row from the model
- EditProtocolSpeciesRowModel removedRow = getModel().getRows().remove(rowIndex);
+ EditProtocolSpeciesTableModel tableModel = getHandler().getTableModel();
- // readd all synonym of this taxon to the species comobox
- Integer taxonId = removedRow.getSpecies().getReferenceTaxonId();
- getUI().getSpeciesComboBox().getData().addAll(handler.getAllSpeciesByTaxonId().get(String.valueOf(taxonId)));
+ EditProtocolSpeciesRowModel selectedRow = tableModel.getEntry(rowIndex);
+
+ // re-add all synonym of this taxon to the species comobox
+ Integer taxonId = selectedRow.getSpecies().getReferenceTaxonId();
+ Collection<Species> allSynonyms = getModel().getAllSynonyms(String.valueOf(taxonId));
+ getUI().getSpeciesComboBox().getData().addAll(allSynonyms);
getUI().getSpeciesComboBox().getHandler().sortData();
- // refresh all the table
- handler.getTableModel().fireTableRowsDeleted(rowIndex, rowIndex);
+
+ // remove the row from the model(do it after treating the comboBox which can be long)
+ tableModel.removeRow(rowIndex);
+
+ String speciesStr = getDecorator(Species.class, DecoratorService.SPECIES_BY_CRUISE_CODE).toString(selectedRow.getSpecies());
+ sendMessage(_("tutti.flash.information.species.remove.from.protocol",
+ speciesStr));
}
}
\ No newline at end of file
1
0
r382 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential
by tchemit@users.forge.codelutin.com 10 Feb '13
by tchemit@users.forge.codelutin.com 10 Feb '13
10 Feb '13
Author: tchemit
Date: 2013-02-10 15:59:07 +0100 (Sun, 10 Feb 2013)
New Revision: 382
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/382
Log:
use new action api
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryGearExampleAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryPersonExampleAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporarySpeciesExampleAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryVesselExampleAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryGearAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryPersonAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporarySpeciesAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryVesselAction.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryGearExampleAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryGearExampleAction.java 2013-02-10 14:57:58 UTC (rev 381)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryGearExampleAction.java 2013-02-10 14:59:07 UTC (rev 382)
@@ -95,7 +95,7 @@
}
TuttiReferentialImportExportService service =
- getContext().getService(TuttiReferentialImportExportService.class);
+ getService(TuttiReferentialImportExportService.class);
service.exportTemporaryGearExample(file);
sendMessage("Exemple de référentiel temporaire d'engins exporté " +
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryPersonExampleAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryPersonExampleAction.java 2013-02-10 14:57:58 UTC (rev 381)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryPersonExampleAction.java 2013-02-10 14:59:07 UTC (rev 382)
@@ -95,7 +95,7 @@
}
TuttiReferentialImportExportService service =
- getContext().getService(TuttiReferentialImportExportService.class);
+ getService(TuttiReferentialImportExportService.class);
service.exportTemporaryPersonExample(file);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporarySpeciesExampleAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporarySpeciesExampleAction.java 2013-02-10 14:57:58 UTC (rev 381)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporarySpeciesExampleAction.java 2013-02-10 14:59:07 UTC (rev 382)
@@ -95,7 +95,7 @@
}
TuttiReferentialImportExportService service =
- getContext().getService(TuttiReferentialImportExportService.class);
+ getService(TuttiReferentialImportExportService.class);
service.exportTemporarySpeciesExample(file);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryVesselExampleAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryVesselExampleAction.java 2013-02-10 14:57:58 UTC (rev 381)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryVesselExampleAction.java 2013-02-10 14:59:07 UTC (rev 382)
@@ -95,7 +95,7 @@
}
TuttiReferentialImportExportService service =
- getContext().getService(TuttiReferentialImportExportService.class);
+ getService(TuttiReferentialImportExportService.class);
service.exportTemporaryVesselExample(file);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryGearAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryGearAction.java 2013-02-10 14:57:58 UTC (rev 381)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryGearAction.java 2013-02-10 14:59:07 UTC (rev 382)
@@ -95,7 +95,7 @@
}
TuttiReferentialImportExportService service =
- getContext().getService(TuttiReferentialImportExportService.class);
+ getService(TuttiReferentialImportExportService.class);
service.importTemporaryGear(file);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryPersonAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryPersonAction.java 2013-02-10 14:57:58 UTC (rev 381)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryPersonAction.java 2013-02-10 14:59:07 UTC (rev 382)
@@ -95,7 +95,7 @@
}
TuttiReferentialImportExportService service =
- getContext().getService(TuttiReferentialImportExportService.class);
+ getService(TuttiReferentialImportExportService.class);
service.importTemporaryPerson(file);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporarySpeciesAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporarySpeciesAction.java 2013-02-10 14:57:58 UTC (rev 381)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporarySpeciesAction.java 2013-02-10 14:59:07 UTC (rev 382)
@@ -95,7 +95,7 @@
}
TuttiReferentialImportExportService service =
- getContext().getService(TuttiReferentialImportExportService.class);
+ getService(TuttiReferentialImportExportService.class);
service.importTemporarySpecies(file);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryVesselAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryVesselAction.java 2013-02-10 14:57:58 UTC (rev 381)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryVesselAction.java 2013-02-10 14:59:07 UTC (rev 382)
@@ -95,7 +95,7 @@
}
TuttiReferentialImportExportService service =
- getContext().getService(TuttiReferentialImportExportService.class);
+ getService(TuttiReferentialImportExportService.class);
service.importTemporaryVessel(file);
1
0