r546 - in trunk: tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service tutti-persistence/src/main/xmi tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/entities/protocol tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service tutti-service/src/main/java/fr/ifremer/tutti/service/protocol tutti-service/src/te
Author: tchemit Date: 2013-03-06 09:11:58 +0100 (Wed, 06 Mar 2013) New Revision: 546 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/546 Log: fixes #2065: [TRAIT] - Gestion des caract?\195?\169ristiques environnement et hydrologique - renommage de champs (saisisseur en recorderPerson + protocol et fishingoperation caracteristics) - nettoyage code dans les services de persistences Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTableModel.java Removed: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AttachmentsAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/CaracteristicRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/CaracteristicTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/CaracteristicTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java 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/ProtocolPersistenceServiceImpl.java trunk/tutti-persistence/src/main/xmi/tutti-persistence.properties trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocolsTest.java trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceWriteTest.java trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceReadTest.java trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceWriteTest.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/CaracteristicType.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportServiceTest.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/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/SaveFishingOperationAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/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 trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SaveProtocolAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherSpeciesAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIModel.java trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-error-validation.xml trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-03-06 08:11:58 UTC (rev 546) @@ -50,6 +50,7 @@ import java.sql.Statement; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Properties; @@ -63,6 +64,20 @@ */ public class TuttiEntities { + public static final Comparator<Species> SPECIES_BY_NAME_COMPARATOR = new Comparator<Species>() { + + public int compare(Species o1, Species o2) { + if (o1 == null) { + return -1; + } + if (o2 == null) { + return 1; + } + return o1.getName().compareTo(o2.getName()); + } + + }; + /** Logger. */ private static final Log log = LogFactory.getLog(TuttiEntities.class); Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java 2013-03-06 08:11:58 UTC (rev 546) @@ -25,16 +25,15 @@ */ import com.esotericsoftware.yamlbeans.YamlConfig; -import com.esotericsoftware.yamlbeans.YamlException; import com.esotericsoftware.yamlbeans.YamlReader; import com.esotericsoftware.yamlbeans.YamlWriter; import com.google.common.base.Charsets; import com.google.common.io.Closeables; import com.google.common.io.Files; +import fr.ifremer.tutti.TuttiTechnicalException; import java.io.BufferedWriter; import java.io.File; -import java.io.IOException; import java.io.Reader; /** @@ -45,34 +44,36 @@ */ public class TuttiProtocols { - public static void toFile(TuttiProtocol protocol, File file) throws IOException { + public static void toFile(TuttiProtocol protocol, File file) { String id = protocol.getId(); - BufferedWriter fileWriter = Files.newWriter(file, Charsets.UTF_8); + BufferedWriter fileWriter = null; try { + fileWriter = Files.newWriter(file, Charsets.UTF_8); YamlWriter writer = new YamlWriter(fileWriter, createConfig()); writer.write(protocol); writer.close(); fileWriter.close(); - } catch (YamlException e) { - throw new IOException("Could not transform protocol " + id + " to file " + file, e); + } catch (Exception e) { + throw new TuttiTechnicalException("Could not transform protocol " + id + " to file " + file, e); } finally { Closeables.closeQuietly(fileWriter); } } - public static TuttiProtocol fromFile(File file) throws IOException { + public static TuttiProtocol fromFile(File file) { - Reader fileReader = Files.newReader(file, Charsets.UTF_8); + Reader fileReader = null; try { + fileReader = Files.newReader(file, Charsets.UTF_8); YamlReader reader = new YamlReader(fileReader, createConfig()); TuttiProtocol result = reader.read(TuttiProtocol.class); fileReader.close(); return result; - } catch (YamlException e) { - throw new IOException("Could not import protocol from file " + file, e); + } catch (Exception e) { + throw new TuttiTechnicalException("Could not import protocol from file " + file, e); } finally { Closeables.closeQuietly(fileReader); } 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-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2013-03-06 08:11:58 UTC (rev 546) @@ -37,6 +37,7 @@ import org.springframework.dao.DataIntegrityViolationException; import java.io.Serializable; +import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; @@ -187,7 +188,11 @@ } protected Date newCreateDate() { - calendar.setTime(new Date()); + return dateWithNoTime(new Date()); + } + + protected Date dateWithNoTime(Date date) { + calendar.setTime(date); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); @@ -195,6 +200,12 @@ return calendar.getTime(); } + protected Date dateWithNoMiliSecond(Date date) { + calendar.setTime(date); + calendar.set(Calendar.MILLISECOND, 0); + return calendar.getTime(); + } + protected Date dateWithNoSecondAndMiliSecond(Date date) { calendar.setTime(date); calendar.set(Calendar.SECOND, 0); @@ -202,6 +213,13 @@ return calendar.getTime(); } + protected Date dateWithNoSecondAndOneMiliSecond(Date date) { + calendar.setTime(date); + calendar.add(Calendar.SECOND, 0); + calendar.add(Calendar.MILLISECOND, 1); + return calendar.getTime(); + } + protected Date dateWithOneMiliSecond(Date date) { calendar.setTime(date); calendar.add(Calendar.MILLISECOND, 1); @@ -222,6 +240,62 @@ return calendar.getTimeInMillis(); } + /** + * Test if the date has millisecond set. This yes, return null, then return the date itself. + * + * @param databaseValue the date stored in the database (could be fake date, not null only because of database constraints) + * @return null if the date is a fake date + */ + protected Date convertDatabase2UI(Timestamp databaseValue) { + Date result; + if (databaseValue == null) { + result = null; + } else { + + calendar.setTimeInMillis(databaseValue.getTime()); + if (calendar.get(Calendar.MILLISECOND) != 0) { + result = null; + } else { + result = calendar.getTime(); + } + } + return result; + } + + /** + * Convert a UI date, when the database value is mandatory. + * If the given value is null, use the default date, then set millisecond to '1', to be able to retrieve the null value later. + * + * @param uiValue the date used in the UI + * @return null if the date is a fake date + */ + protected Date convertUI2DatabaseMandatoryDate(Date uiValue, + Date defaultNotEmptyDate, + boolean addOneSecondToDefaultDate) { + Date result; + + // if ui date is not empty, then use it (but reset millisecond) + if (uiValue == null) { + + Preconditions.checkState( + defaultNotEmptyDate == null, + "'defaultNotEmptyDate' could not be null."); + + + calendar.setTime(defaultNotEmptyDate); + if (addOneSecondToDefaultDate) { + calendar.add(Calendar.SECOND, 1); + } + calendar.set(Calendar.MILLISECOND, 1); + result = calendar.getTime(); + } else { + + result = dateWithNoMiliSecond(uiValue); + } + + return result; + } + private Calendar calendar = new GregorianCalendar(); 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-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-03-06 08:11:58 UTC (rev 546) @@ -27,7 +27,6 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import fr.ifremer.adagio.core.dao.data.batch.denormalized.DenormalizedBatch; import fr.ifremer.adagio.core.dao.data.fishingArea.FishingArea; import fr.ifremer.adagio.core.dao.data.fishingArea.FishingArea2RegulationLocation; import fr.ifremer.adagio.core.dao.data.fishingArea.FishingArea2RegulationLocationPK; @@ -82,9 +81,7 @@ import java.sql.Timestamp; import java.text.MessageFormat; import java.util.ArrayList; -import java.util.Calendar; import java.util.Date; -import java.util.GregorianCalendar; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -128,8 +125,6 @@ protected static String MISC_DATA_RECORDER_PERSONS_TAG = "#REC_PERSONS="; - protected Calendar calendar = new GregorianCalendar(); - @Override public List<FishingOperation> getAllFishingOperation(String cruiseId) { Preconditions.checkNotNull(cruiseId); @@ -265,12 +260,12 @@ miscData = miscData.substring(0, recorderPersonsIndex); if (!recorderPersonsStr.isEmpty()) { String[] recorderPersonsArray = recorderPersonsStr.split(","); - List<Person> persons = new ArrayList<Person>(); + List<Person> persons = Lists.newArrayList(); for (String personId : recorderPersonsArray) { Person person = referentialService.getPerson(Integer.valueOf(personId)); persons.add(person); } - result.setSaisisseur(persons); + result.setRecorderPerson(persons); } } } @@ -335,10 +330,10 @@ result.setVessel(vessel); } - // Retrieve gear shooting caracteristics + // Retrieve gear use features getGearUseCaracteristics(id, result); - // TODO-TC Retrieve environment caracteristics with protocol + // Retrieve vessel use features getVesselUseCaracteristics(id, result); return result; @@ -405,7 +400,7 @@ "fishingOperationId", IntegerType.INSTANCE, Integer.valueOf(fishingOperationId) ); - CaracteristicMap environmentCaracteristics = new CaracteristicMap(); + CaracteristicMap vesselUseCaracteristics = new CaracteristicMap(); while (list.hasNext()) { int colIndex = 0; Object[] source = list.next(); @@ -438,11 +433,9 @@ result.setStationNumber(alphanumericalValue); } - // Environment caracteristic + // Vessel Use caracteristic else { - //TODO Split en fonction du protocole - Caracteristic environmentCaracteristic = referentialService.getCaracteristic(pmfmId); Serializable value = null; if (environmentCaracteristic.getCaracteristicType() == CaracteristicType.NUMBER) { @@ -457,12 +450,12 @@ } } } - environmentCaracteristics.put(environmentCaracteristic, value); + vesselUseCaracteristics.put(environmentCaracteristic, value); } } - if (environmentCaracteristics.size() > 0) { - result.setEnvironmentCaracteristics(environmentCaracteristics); + if (vesselUseCaracteristics.size() > 0) { + result.setVesselUseFeatures(vesselUseCaracteristics); } } @@ -510,7 +503,7 @@ } if (gearShootingCaracteristics.size() > 0) { - result.setGearShootingCaracteristics(gearShootingCaracteristics); + result.setGearUseFeatures(gearShootingCaracteristics); } } @@ -672,11 +665,10 @@ target.setStartDateTime(null); target.setFishingStartDateTime(null); } else if (source.getGearShootingStartDate() != null) { - calendar.setTime(source.getGearShootingStartDate()); // Reset millisecond (as need for Allegro) - calendar.set(Calendar.MILLISECOND, 0); - target.setStartDateTime(calendar.getTime()); - target.setFishingStartDateTime(calendar.getTime()); + Date d = dateWithNoMiliSecond(source.getGearShootingStartDate()); + target.setStartDateTime(d); + target.setFishingStartDateTime(d); } // End date : @@ -684,11 +676,10 @@ target.setEndDateTime(null); target.setFishingEndDateTime(null); } else if (source.getGearShootingEndDate() != null) { - calendar.setTime(source.getGearShootingEndDate()); // Reset millisecond (as need for Allegro) - calendar.set(Calendar.MILLISECOND, 0); - target.setEndDateTime(calendar.getTime()); - target.setFishingEndDateTime(calendar.getTime()); + Date d = dateWithNoMiliSecond(source.getGearShootingEndDate()); + target.setEndDateTime(d); + target.setFishingEndDateTime(d); } // Trawl distance @@ -732,12 +723,10 @@ // Settings not null properties : if (target.getStartDateTime() == null) { - // Generate a fake departureDate (precision=minute) then add 1 millisecond - calendar.setTime(scientificCruise.getDepartureDateTime()); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.MILLISECOND, 1); - target.setStartDateTime(calendar.getTime()); - target.setFishingStartDateTime(calendar.getTime()); + // Generate a fake departureDate (precision=minute) then add 1 millisecond + Date d = dateWithNoSecondAndOneMiliSecond(scientificCruise.getDepartureDateTime()); + target.setStartDateTime(d); + target.setFishingStartDateTime(d); } // VesselUseFeatures : @@ -750,12 +739,8 @@ vesselUseFeatures.setProgram(scientificCruise.getProgram()); vesselUseFeatures.setIsActive(isActive.ACTIVE.getValue()); if (vesselUseFeatures.getCreationDate() == null) { - calendar.setTime(new Date()); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.MILLISECOND, 0); - vesselUseFeatures.setCreationDate(calendar.getTime()); + Date d = newCreateDate(); + vesselUseFeatures.setCreationDate(d); } if (vesselUseFeatures.getQualityFlag() == null) { vesselUseFeatures.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); @@ -770,12 +755,8 @@ gearUseFeatures.setVessel(target.getVessel()); gearUseFeatures.setProgram(scientificCruise.getProgram()); if (gearUseFeatures.getCreationDate() == null) { - calendar.setTime(new Date()); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.MILLISECOND, 0); - gearUseFeatures.setCreationDate(calendar.getTime()); + Date d = newCreateDate(); + gearUseFeatures.setCreationDate(d); } if (gearUseFeatures.getQualityFlag() == null) { gearUseFeatures.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); @@ -847,25 +828,23 @@ target.getVesselPositions().remove(endPosition); } - // Environment Caracteristics - CaracteristicMap environmentCaracteristics = source.getEnvironmentCaracteristics(); - if (copyIfNull && environmentCaracteristics == null || environmentCaracteristics.size() == 0) { + // Vessel user features + CaracteristicMap vesselUseCaracteristics = source.getVesselUseFeatures(); + if (copyIfNull && vesselUseCaracteristics == null || vesselUseCaracteristics.size() == 0) { // Nothing to do : will be removed later, using notChangedVesselUseMeasurements - } else if (environmentCaracteristics != null && environmentCaracteristics.size() > 0) { - for (Caracteristic caracteristic : environmentCaracteristics.keySet()) { - VesselUseMeasurement vum = setVesselUseMeasurement(scientificCruise, vesselUseFeatures, caracteristic, environmentCaracteristics.get(caracteristic)); + } else if (vesselUseCaracteristics != null && vesselUseCaracteristics.size() > 0) { + for (Caracteristic caracteristic : vesselUseCaracteristics.keySet()) { + VesselUseMeasurement vum = setVesselUseMeasurement(scientificCruise, vesselUseFeatures, caracteristic, vesselUseCaracteristics.get(caracteristic)); notChangedVesselUseMeasurements.remove(vum); } } - //TODO Add also *other + hydrologic* caracteristics - // Recorder persons StringBuilder miscDataBuffer = new StringBuilder(); - if (copyIfNull && (source.getSaisisseur() == null || source.getSaisisseur().size() == 0)) { + if (copyIfNull && (source.getRecorderPerson() == null || source.getRecorderPerson().size() == 0)) { miscDataBuffer.append(MISC_DATA_RECORDER_PERSONS_TAG); - } else if (source.getSaisisseur() != null && source.getSaisisseur().size() > 0) { - List<Person> persons = source.getSaisisseur(); + } else if (source.getRecorderPerson() != null && source.getRecorderPerson().size() > 0) { + List<Person> persons = source.getRecorderPerson(); miscDataBuffer.append(MISC_DATA_RECORDER_PERSONS_TAG); for (int i = 0; i < persons.size(); i++) { if (i > 0) miscDataBuffer.append(','); @@ -887,12 +866,12 @@ // ---------------------------------------------------------------- // Gear use Caracteristics - CaracteristicMap gearShootingCaracteristics = source.getGearShootingCaracteristics(); - if (copyIfNull && gearShootingCaracteristics == null || gearShootingCaracteristics.size() == 0) { + CaracteristicMap gearUseCaracteristics = source.getGearUseFeatures(); + if (copyIfNull && gearUseCaracteristics == null || gearUseCaracteristics.size() == 0) { // Nothing to do : will be removed later, using notChangedGearUseMeasurements - } else if (gearShootingCaracteristics != null && gearShootingCaracteristics.size() > 0) { - for (Caracteristic caracteristic : gearShootingCaracteristics.keySet()) { - GearUseMeasurement gum = setGearUseMeasurement(scientificCruise, gearUseFeatures, caracteristic, environmentCaracteristics.get(caracteristic)); + } else if (gearUseCaracteristics != null && gearUseCaracteristics.size() > 0) { + for (Caracteristic caracteristic : gearUseCaracteristics.keySet()) { + GearUseMeasurement gum = setGearUseMeasurement(scientificCruise, gearUseFeatures, caracteristic, vesselUseCaracteristics.get(caracteristic)); notChangedGearUseMeasurements.remove(gum); } } @@ -922,7 +901,6 @@ statisticalLocationId = locationService.getLocationIdByLatLong(source.getGearShootingEndLatitude(), source.getGearShootingEndLongitude()); } - //TODO Do a notchange area and remove it at then end // Strata : if (copyIfNull && (source.getStrata() == null || source.getStrata().getId() == null)) { @@ -935,7 +913,6 @@ fa2rlPK.setFishingArea(fishingArea); fa2rlPK.setLocation(load(LocationImpl.class, Integer.valueOf(source.getStrata().getId()))); - //TODO Make this work notChangedRegulationLocation.remove(fa2rl); if (fishingArea.getRegulationLocation() == null) { fishingArea.setRegulationLocation(Sets.newHashSet(fa2rl)); @@ -959,7 +936,6 @@ fa2rlPK.setFishingArea(fishingArea); fa2rlPK.setLocation(load(LocationImpl.class, Integer.valueOf(source.getSubStrata().getId()))); - //TODO Make this work notChangedRegulationLocation.remove(fa2rl); if (fishingArea.getRegulationLocation() == null) { @@ -984,7 +960,6 @@ fa2rlPK.setFishingArea(fishingArea); fa2rlPK.setLocation(load(LocationImpl.class, Integer.valueOf(source.getLocation().getId()))); - //TODO Make this work notChangedRegulationLocation.remove(fa2rl); if (fishingArea.getRegulationLocation() == null) { fishingArea.setRegulationLocation(Sets.newHashSet(fa2rl)); @@ -996,7 +971,6 @@ } } - //TODO Test well if not removed use fishingArea2RegulationLocationDAO... fishingArea.getRegulationLocation().removeAll(notChangedRegulationLocation); // Fishing Area location (should be a statistical location) @@ -1012,51 +986,7 @@ } } - /** - * Test if the date has millisecond set. This yes, return null, then return the date itself. - * - * @param databaseValue the date stored in the database (could be fake date, not null only because of database constraints) - * @return null if the date is a fake date - */ - protected Date convertDatabase2UI(Timestamp databaseValue) { - if (databaseValue == null) { - return null; - } - calendar.setTimeInMillis(databaseValue.getTime()); - if (calendar.get(Calendar.MILLISECOND) != 0) { - return null; - } - return calendar.getTime(); - } - - /** - * Convert a UI date, when the database value is mandatory. - * If the given value is null, use the default date, then set millisecond to '1', to be able to retrieve the null value later. - * - * @param uiValue the date used in the UI - * @return null if the date is a fake date - */ - protected Date convertUI2DatabaseMandatoryDate(Date uiValue, Date defaultNotEmptyDate, boolean addOneSecondToDefaultDate) { - // if ui date is not empty, then use it (but reset millisecond) - if (uiValue != null) { - calendar.setTime(uiValue); - calendar.set(Calendar.MILLISECOND, 0); - return calendar.getTime(); - } - if (defaultNotEmptyDate == null) { - throw new IllegalArgumentException("'defaultNotEmptyDate' could not be null."); - } - - calendar.setTime(defaultNotEmptyDate); - if (addOneSecondToDefaultDate) { - calendar.add(Calendar.SECOND, 1); - } - calendar.set(Calendar.MILLISECOND, 1); - return calendar.getTime(); - } - - /** * Test if the latitude is null, and return a default value if yes * * @param databaseValue the latitude used in UI (could be null) @@ -1245,20 +1175,20 @@ return gearUseMeasurement; } - protected DenormalizedBatch getDenormalizedBatch(Integer fishingOperationId) { - Iterator<DenormalizedBatch> list = queryListTyped( - "fishingOperationBatchs", - "fishingOperationId", IntegerType.INSTANCE, fishingOperationId - ); +// protected DenormalizedBatch getDenormalizedBatch(Integer fishingOperationId) { +// Iterator<DenormalizedBatch> list = queryListTyped( +// "fishingOperationBatchs", +// "fishingOperationId", IntegerType.INSTANCE, fishingOperationId +// ); +// +// CaracteristicMap environmentCaracteristics = new CaracteristicMap(); +// while (list.hasNext()) { +// DenormalizedBatch batch = list.next(); +// System.out.println(batch.getTreeIndent() + batch.getSortingValuesText()); +// } +// return null; +// } - CaracteristicMap environmentCaracteristics = new CaracteristicMap(); - while (list.hasNext()) { - DenormalizedBatch batch = list.next(); - System.out.println(batch.getTreeIndent() + batch.getSortingValuesText()); - } - return null; - } - protected void setOperationVesselAssociation(Operation target, String vesselCode) { OperationVesselAssociation ova = null; OperationVesselAssociationPK ovaPK = new OperationVesselAssociationPK(); Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceImpl.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceImpl.java 2013-03-06 08:11:58 UTC (rev 546) @@ -25,6 +25,7 @@ */ import com.google.common.collect.Lists; +import fr.ifremer.tutti.TuttiIOUtil; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; @@ -37,7 +38,6 @@ import org.springframework.stereotype.Service; import java.io.File; -import java.io.IOException; import java.util.Collection; import java.util.List; import java.util.UUID; @@ -103,12 +103,8 @@ @Override public TuttiProtocol getProtocol(String id) { File file = getProtocolFile(id); - try { - TuttiProtocol result = TuttiProtocols.fromFile(file); - return result; - } catch (IOException e) { - throw new RuntimeException("Could not read protocol " + id + " from file " + file, e); - } + TuttiProtocol result = TuttiProtocols.fromFile(file); + return result; } @Override @@ -121,9 +117,8 @@ result.setId(UUID.randomUUID().toString()); result.setLengthClassesPmfmId(TuttiEntities.getList(bean.getLengthClassesPmfmId())); - result.setEnvironmentPmfmId(TuttiEntities.getList(bean.getEnvironmentPmfmId())); - result.setGearPmfmId(TuttiEntities.getList(bean.getGearPmfmId())); - result.setHydrologyPmfmId(TuttiEntities.getList(bean.getHydrologyPmfmId())); + result.setVesselUseFeaturePmfmId(TuttiEntities.getList(bean.getVesselUseFeaturePmfmId())); + result.setGearUseFeaturePmfmId(TuttiEntities.getList(bean.getGearUseFeaturePmfmId())); Binder<SpeciesProtocol, SpeciesProtocol> speciesProtocolBinder = BinderFactory.newBinder(SpeciesProtocol.class); List<SpeciesProtocol> species = Lists.newArrayList(); @@ -140,13 +135,8 @@ String id = result.getId(); File file = getProtocolFile(id); - try { - TuttiProtocols.toFile(result, file); - return result; - } catch (IOException e) { - throw new RuntimeException( - "Could not write protocol " + id + " to file " + file, e); - } + TuttiProtocols.toFile(result, file); + return result; } @Override @@ -154,25 +144,17 @@ String id = bean.getId(); File file = getProtocolFile(id); - try { - TuttiProtocols.toFile(bean, file); - return bean; - } catch (IOException e) { - throw new RuntimeException( - "Could not write protocol " + id + " to file " + file, e); - } + TuttiProtocols.toFile(bean, file); + return bean; } @Override public void deleteProtocol(String protocolId) { File file = getProtocolFile(protocolId); - try { - if (file.exists()) { - FileUtils.forceDelete(file); - } - } catch (IOException e) { - throw new RuntimeException( + if (file.exists()) { + TuttiIOUtil.deleteFile( + file, "Could not delete protocol " + protocolId + " (file " + file + ")"); } } Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.properties =================================================================== --- trunk/tutti-persistence/src/main/xmi/tutti-persistence.properties 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-persistence/src/main/xmi/tutti-persistence.properties 2013-03-06 08:11:58 UTC (rev 546) @@ -32,13 +32,13 @@ fr.ifremer.tutti.persistence.entities.data.Cruise.attribute.headOfMission.stereotype=ordered fr.ifremer.tutti.persistence.entities.data.Cruise.attribute.headOfSortRoom.stereotype=ordered fr.ifremer.tutti.persistence.entities.data.Cruise.attribute.vessel.stereotype=ordered -fr.ifremer.tutti.persistence.entities.data.FishingOperation.attribute.saisisseur.stereotype=ordered +fr.ifremer.tutti.persistence.entities.data.FishingOperation.attribute.recorderPerson.stereotype=ordered fr.ifremer.tutti.persistence.entities.data.MacroWasteBatch.attribute.macroWasteCategory.stereotype=ordered fr.ifremer.tutti.persistence.entities.data.SpeciesBatch.attribute.childBatchs.stereotype=ordered -fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol.attribute.gearPmfmId.stereotype=ordered -fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol.attribute.environmentPmfmId.stereotype=ordered +fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol.attribute.gearUseFeaturePmfmId.stereotype=ordered +fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol.attribute.vesselUseFeaturePmfmId.stereotype=ordered fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol.attribute.hydrologyPmfmId.stereotype=ordered fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol.attribute.lengthClassesPmfmId.stereotype=ordered fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol.attribute.species.stereotype=ordered Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo =================================================================== (Binary files differ) Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocolsTest.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocolsTest.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocolsTest.java 2013-03-06 08:11:58 UTC (rev 546) @@ -49,19 +49,13 @@ /** Logger. */ private static final Log log = LogFactory.getLog(TuttiProtocolsTest.class); - public static final String PROTOCOL_FILE_CONTENT = "id: 1\n" + "name: protocolName\n" + "comment: Commentaire\n" + - "environmentPmfmId: \n" + - "- 114\n" + - "- 228\n" + - "- 821\n" + - "gearPmfmId: \n" + + "gearUseFeaturePmfmId: \n" + "- 21\n" + "- 22\n" + - "hydrologyPmfmId: []\n" + "lengthClassesPmfmId: \n" + "- 14\n" + "- 18\n" + @@ -86,7 +80,11 @@ " sizeEnabled: true\n" + " speciesReferenceTaxonId: 3835\n" + " speciesSurveyCode: CHIN\n" + - " weightEnabled: true"; + " weightEnabled: true\n" + + "vesselUseFeaturePmfmId: \n" + + "- 114\n" + + "- 228\n" + + "- 821"; public static final long TIMESTAMP = System.nanoTime(); @@ -137,9 +135,8 @@ Assert.assertEquals("protocolName", protocol.getName()); Assert.assertEquals("Commentaire", protocol.getComment()); Assert.assertEquals(Lists.newArrayList("14", "18"), protocol.getLengthClassesPmfmId()); - Assert.assertEquals(Lists.newArrayList("114", "228", "821"), protocol.getEnvironmentPmfmId()); - Assert.assertEquals(Lists.newArrayList("21", "22"), protocol.getGearPmfmId()); - Assert.assertEquals(Lists.<String>newArrayList(), protocol.getHydrologyPmfmId()); + Assert.assertEquals(Lists.newArrayList("114", "228", "821"), protocol.getVesselUseFeaturePmfmId()); + Assert.assertEquals(Lists.newArrayList("21", "22"), protocol.getGearUseFeaturePmfmId()); Assert.assertNotNull(protocol.getSpecies()); Assert.assertEquals(2, protocol.getSpecies().size()); SpeciesProtocol sp1 = protocol.getSpecies().get(0); @@ -177,9 +174,8 @@ protocol.setName("protocolName"); protocol.setComment("Commentaire"); protocol.setLengthClassesPmfmId(Lists.newArrayList("14", "18")); - protocol.setEnvironmentPmfmId(Lists.newArrayList("114", "228", "821")); - protocol.setGearPmfmId(Lists.newArrayList("21", "22")); - protocol.setHydrologyPmfmId(Lists.<String>newArrayList()); + protocol.setVesselUseFeaturePmfmId(Lists.newArrayList("114", "228", "821")); + protocol.setGearUseFeaturePmfmId(Lists.newArrayList("21", "22")); protocol.setSpecies(Lists.<SpeciesProtocol>newArrayList()); SpeciesProtocol sp1 = new SpeciesProtocol(); Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceWriteTest.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceWriteTest.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceWriteTest.java 2013-03-06 08:11:58 UTC (rev 546) @@ -220,8 +220,8 @@ fishingOperation.setComment("Unit test createFishingOperation() - Part n°2 : All properties set"); fishingOperation.setGear(cruiseGear); fishingOperation.setVessel(notCruiseVessel); - fishingOperation.setEnvironmentCaracteristics(environmentCaracteristics); - fishingOperation.setGearShootingCaracteristics(gearShootingCaracteristics); + fishingOperation.setVesselUseFeatures(environmentCaracteristics); + fishingOperation.setGearUseFeatures(gearShootingCaracteristics); FishingOperationLocation strata = new FishingOperationLocation(); strata.setId(dbResource.getFixtures().strataId()); @@ -261,10 +261,10 @@ assertEquals(fishingOperation.isFishingOperationRectiligne(), reloadedFishingOperation.isFishingOperationRectiligne()); assertEquals(fishingOperation.getFishingOperationValid(), reloadedFishingOperation.getFishingOperationValid()); assertEquals(fishingOperation.getComment(), reloadedFishingOperation.getComment()); - assertNotNull(reloadedFishingOperation.getEnvironmentCaracteristics()); - assertEquals(environmentCaracteristics.size(), fishingOperation.getEnvironmentCaracteristics().size()); - assertNotNull(reloadedFishingOperation.getGearShootingCaracteristics()); - assertEquals(gearShootingCaracteristics.size(), reloadedFishingOperation.getGearShootingCaracteristics().size()); + assertNotNull(reloadedFishingOperation.getVesselUseFeatures()); + assertEquals(environmentCaracteristics.size(), fishingOperation.getVesselUseFeatures().size()); + assertNotNull(reloadedFishingOperation.getGearUseFeatures()); + assertEquals(gearShootingCaracteristics.size(), reloadedFishingOperation.getGearUseFeatures().size()); assertNotNull(reloadedFishingOperation.getStrata()); assertNotNull(reloadedFishingOperation.getStrata().getId()); assertEquals(fishingOperation.getStrata().getId(), reloadedFishingOperation.getStrata().getId()); @@ -358,8 +358,8 @@ fishingOperation.setSubStrata(null); fishingOperation.setLocation(null); fishingOperation.setVessel(cruise.getVessel(0)); - fishingOperation.setEnvironmentCaracteristics(environmentValuesOneEntry); - fishingOperation.setGearShootingCaracteristics(gearShootingCaracteristicsOneEntry); + fishingOperation.setVesselUseFeatures(environmentValuesOneEntry); + fishingOperation.setGearUseFeatures(gearShootingCaracteristicsOneEntry); fishingOperation.setComment(fishingOperation.getComment() + "\n\nUnit test createFishingOperation() - Part n°5 : check if deleted sub items in DB"); createdFishingOperation = service.saveFishingOperation(fishingOperation); reloadedFishingOperation = service.getFishingOperation(createdFishingOperation.getId()); @@ -371,10 +371,10 @@ assertNull(reloadedFishingOperation.getStrata()); assertNull(reloadedFishingOperation.getSubStrata()); assertNull(reloadedFishingOperation.getLocation()); - assertNotNull(reloadedFishingOperation.getEnvironmentCaracteristics()); - assertEquals(environmentValuesOneEntry.size(), reloadedFishingOperation.getEnvironmentCaracteristics().size()); - assertNotNull(reloadedFishingOperation.getGearShootingCaracteristics()); - assertEquals(gearShootingCaracteristicsOneEntry.size(), reloadedFishingOperation.getGearShootingCaracteristics().size()); + assertNotNull(reloadedFishingOperation.getVesselUseFeatures()); + assertEquals(environmentValuesOneEntry.size(), reloadedFishingOperation.getVesselUseFeatures().size()); + assertNotNull(reloadedFishingOperation.getGearUseFeatures()); + assertEquals(gearShootingCaracteristicsOneEntry.size(), reloadedFishingOperation.getGearUseFeatures().size()); } @Test Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceReadTest.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceReadTest.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceReadTest.java 2013-03-06 08:11:58 UTC (rev 546) @@ -84,9 +84,8 @@ protocol.setName("protocolName"); protocol.setComment("Commentaire"); protocol.setLengthClassesPmfmId(Lists.newArrayList("14", "18")); - protocol.setEnvironmentPmfmId(Lists.newArrayList("114", "228", "821")); - protocol.setGearPmfmId(Lists.newArrayList("21", "22")); - protocol.setHydrologyPmfmId(Lists.<String>newArrayList()); + protocol.setVesselUseFeaturePmfmId(Lists.newArrayList("114", "228", "821")); + protocol.setGearUseFeaturePmfmId(Lists.newArrayList("21", "22")); protocol.setSpecies(Lists.<SpeciesProtocol>newArrayList()); SpeciesProtocol sp1 = new SpeciesProtocol(); Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceWriteTest.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceWriteTest.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ProtocolPersistenceServiceWriteTest.java 2013-03-06 08:11:58 UTC (rev 546) @@ -52,14 +52,9 @@ "id: 1\n" + "name: protocolName\n" + "comment: Commentaire\n" + - "environmentPmfmId: \n" + - "- 114\n" + - "- 228\n" + - "- 821\n" + - "gearPmfmId: \n" + + "gearUseFeaturePmfmId: \n" + "- 21\n" + "- 22\n" + - "hydrologyPmfmId: []\n" + "lengthClassesPmfmId: \n" + "- 14\n" + "- 18\n" + @@ -82,7 +77,11 @@ " sexEnabled: true\n" + " sizeEnabled: true\n" + " speciesReferenceTaxonId: 3835\n" + - " weightEnabled: true"; + " weightEnabled: true\n" + + "vesselUseFeaturePmfmId: \n" + + "- 114\n" + + "- 228\n" + + "- 821"; @Before public void setUp() throws Exception { @@ -134,9 +133,8 @@ protocol.setName("protocolName"); protocol.setComment("Commentaire"); protocol.setLengthClassesPmfmId(Lists.newArrayList("14", "18")); - protocol.setEnvironmentPmfmId(Lists.newArrayList("114", "228", "821")); - protocol.setGearPmfmId(Lists.newArrayList("21", "22")); - protocol.setHydrologyPmfmId(Lists.<String>newArrayList()); + protocol.setVesselUseFeaturePmfmId(Lists.newArrayList("114", "228", "821")); + protocol.setGearUseFeaturePmfmId(Lists.newArrayList("21", "22")); protocol.setSpecies(Lists.<SpeciesProtocol>newArrayList()); SpeciesProtocol sp1 = new SpeciesProtocol(); Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/CaracteristicType.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/CaracteristicType.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/CaracteristicType.java 2013-03-06 08:11:58 UTC (rev 546) @@ -33,7 +33,7 @@ public enum CaracteristicType { LENGTH_STEP, - ENVIRONMENT, + VESSEL_USE_FEATURE, HYDROLOGY, - GEAR + GEAR_USE_FEATURE } Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportService.java 2013-03-06 08:11:58 UTC (rev 546) @@ -33,6 +33,7 @@ import com.google.common.collect.TreeMultimap; import com.google.common.io.Closeables; import com.google.common.io.Files; +import fr.ifremer.tutti.TuttiTechnicalException; import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols; @@ -67,11 +68,11 @@ private static final Log log = LogFactory.getLog(TuttiProtocolImportExportService.class); - public void exportProtocol(TuttiProtocol protocol, File file) throws IOException { + public void exportProtocol(TuttiProtocol protocol, File file) { TuttiProtocols.toFile(protocol, file); } - public TuttiProtocol importProtocol(File file) throws IOException { + public TuttiProtocol importProtocol(File file) { TuttiProtocol result = TuttiProtocols.fromFile(file); return result; } @@ -120,21 +121,17 @@ mergeIds(protocol.getLengthClassesPmfmId(), ids.get(CaracteristicType.LENGTH_STEP))); - protocol.setEnvironmentPmfmId( - mergeIds(protocol.getEnvironmentPmfmId(), - ids.get(CaracteristicType.ENVIRONMENT))); + protocol.setVesselUseFeaturePmfmId( + mergeIds(protocol.getVesselUseFeaturePmfmId(), + ids.get(CaracteristicType.VESSEL_USE_FEATURE))); - protocol.setGearPmfmId( - mergeIds(protocol.getGearPmfmId(), - ids.get(CaracteristicType.GEAR))); - - protocol.setHydrologyPmfmId( - mergeIds(protocol.getHydrologyPmfmId(), - ids.get(CaracteristicType.HYDROLOGY))); + protocol.setGearUseFeaturePmfmId( + mergeIds(protocol.getGearUseFeaturePmfmId(), + ids.get(CaracteristicType.GEAR_USE_FEATURE))); } public void exportAllCaracteristic(File file, - Map<String, Caracteristic> caracteristicMap) throws Exception { + Map<String, Caracteristic> caracteristicMap) { if (log.isInfoEnabled()) { log.info("Will export all caracteristics to file: " + file); @@ -151,11 +148,14 @@ new CaracteristicRowModel(getCsvSeparator(), caracteristicMap); - BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8); + BufferedWriter writer = null; try { + writer = Files.newWriter(file, Charsets.UTF_8); Export export = Export.newExport(csvModel, rows); export.write(writer); writer.close(); + } catch (Exception e) { + throw new TuttiTechnicalException("Could not export all caracteristics to file " + file, e); } finally { Closeables.closeQuietly(writer); } @@ -163,7 +163,7 @@ public void exportProtocolCaracteristic(File file, TuttiProtocol protocol, - Map<String, Caracteristic> caracteristicMap) throws Exception { + Map<String, Caracteristic> caracteristicMap) { if (log.isInfoEnabled()) { log.info("Will export all caracteristics to file: " + file); @@ -179,28 +179,27 @@ rows.addAll(Lists.transform(protocol.getLengthClassesPmfmId(), function)); } - if (!protocol.isEnvironmentPmfmIdEmpty()) { - function.setType(CaracteristicType.ENVIRONMENT); - rows.addAll(Lists.transform(protocol.getEnvironmentPmfmId(), function)); + if (!protocol.isVesselUseFeaturePmfmIdEmpty()) { + function.setType(CaracteristicType.VESSEL_USE_FEATURE); + rows.addAll(Lists.transform(protocol.getVesselUseFeaturePmfmId(), function)); } - if (!protocol.isGearPmfmIdEmpty()) { + if (!protocol.isGearUseFeaturePmfmIdEmpty()) { - function.setType(CaracteristicType.GEAR); - rows.addAll(Lists.transform(protocol.getGearPmfmId(), function)); + function.setType(CaracteristicType.GEAR_USE_FEATURE); + rows.addAll(Lists.transform(protocol.getGearUseFeaturePmfmId(), function)); } - if (!protocol.isHydrologyPmfmIdEmpty()) { - function.setType(CaracteristicType.HYDROLOGY); - rows.addAll(Lists.transform(protocol.getHydrologyPmfmId(), function)); - } CaracteristicRowModel csvModel = new CaracteristicRowModel(getCsvSeparator(), caracteristicMap); - BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8); + BufferedWriter writer = null; try { + writer = Files.newWriter(file, Charsets.UTF_8); Export export = Export.newExport(csvModel, rows); export.write(writer); writer.close(); + } catch (Exception e) { + throw new TuttiTechnicalException("Could not export protocol [" + protocol.getName() + "] caracteristic to file " + file, e); } finally { Closeables.closeQuietly(writer); } @@ -209,7 +208,7 @@ public void importProtocolSpecies(File file, TuttiProtocol protocol, Map<String, Caracteristic> caracteristicMap, - Map<String, Species> speciesMap) throws IOException { + Map<String, Species> speciesMap) { if (log.isInfoEnabled()) { log.info("Will import protocol [" + protocol.getName() + @@ -231,8 +230,9 @@ caracteristicMap, speciesMap); - Reader reader = Files.newReader(file, Charsets.UTF_8); + Reader reader = null; try { + reader = Files.newReader(file, Charsets.UTF_8); Import<SpeciesRow> importer = Import.newImport(csvModel, reader); @@ -263,7 +263,7 @@ } reader.close(); } catch (Exception e) { - throw new IOException("Could not import protocol [" + protocol.getName() + "] caracteristic from file " + file, e); + throw new TuttiTechnicalException("Could not import protocol [" + protocol.getName() + "] caracteristic from file " + file, e); } finally { Closeables.closeQuietly(reader); } @@ -275,7 +275,7 @@ public void exportProtocolSpecies(File file, List<SpeciesProtocol> protocol, Map<String, Caracteristic> caracteristicMap, - Map<String, Species> speciesMap) throws Exception { + Map<String, Species> speciesMap) { if (log.isInfoEnabled()) { log.info("Will export species to file: " + file); } @@ -293,11 +293,14 @@ caracteristicMap, speciesMap); - BufferedWriter writer = Files.newWriter(file, Charsets.UTF_8); + BufferedWriter writer = null; try { + writer = Files.newWriter(file, Charsets.UTF_8); Export export = Export.newExport(csvModel, rows); export.write(writer); writer.close(); + } catch (Exception e) { + throw new TuttiTechnicalException("Could not export species protocol to file " + file, e); } finally { Closeables.closeQuietly(writer); } Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportServiceTest.java =================================================================== --- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportServiceTest.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/protocol/TuttiProtocolImportExportServiceTest.java 2013-03-06 08:11:58 UTC (rev 546) @@ -61,14 +61,9 @@ "id: 1\n" + "name: protocolName\n" + "comment: Commentaire\n" + - "environmentPmfmId: \n" + - "- 114\n" + - "- 228\n" + - "- 821\n" + - "gearPmfmId: \n" + + "gearUseFeaturePmfmId: \n" + "- 21\n" + "- 22\n" + - "hydrologyPmfmId: []\n" + "lengthClassesPmfmId: \n" + "- 14\n" + "- 18\n" + @@ -90,15 +85,17 @@ " sexEnabled: true\n" + " sizeEnabled: true\n" + " speciesReferenceTaxonId: 3835\n" + - " weightEnabled: true"; + " weightEnabled: true\n" + + "vesselUseFeaturePmfmId: \n" + + "- 114\n" + + "- 228\n" + + "- 821"; public static final String PROTOCOL_CARACTERISTIC_FILE_CONTENT = "pmfmId;pmfmType;pmfmParameterName;pmfmMatrixName;pmfmFractionName;pmfmMethodName\n" + "1;LENGTH_STEP;parameterName1;matrixName1;fractionName1;methodName1;\n" + - "2;ENVIRONMENT;parameterName2;matrixName2;fractionName2;methodName2;\n" + - "3;GEAR;parameterName3;matrixName3;fractionName3;methodName3;\n" + - "4;HYDROLOGY;parameterName4;matrixName4;fractionName4;methodName4;\n" + - "5;HYDROLOGY;parameterName5;matrixName5;fractionName5;methodName5;"; + "2;VESSEL_USE_FEATURE;parameterName2;matrixName2;fractionName2;methodName2;\n" + + "3;GEAR_USE_FEATURE;parameterName3;matrixName3;fractionName3;methodName3;"; public static final String ALL_CARACTERISTIC_FILE_CONTENT = "pmfmId;pmfmType;pmfmParameterName;pmfmMatrixName;pmfmFractionName;pmfmMethodName\n" + @@ -141,9 +138,8 @@ protocol.setName("protocolName"); protocol.setComment("Commentaire"); protocol.setLengthClassesPmfmId(Lists.newArrayList("14", "18")); - protocol.setEnvironmentPmfmId(Lists.newArrayList("114", "228", "821")); - protocol.setGearPmfmId(Lists.newArrayList("21", "22")); - protocol.setHydrologyPmfmId(Lists.<String>newArrayList()); + protocol.setVesselUseFeaturePmfmId(Lists.newArrayList("114", "228", "821")); + protocol.setGearUseFeaturePmfmId(Lists.newArrayList("21", "22")); protocol.setSpecies(Lists.<SpeciesProtocol>newArrayList()); SpeciesProtocol sp1 = new SpeciesProtocol(); @@ -191,9 +187,8 @@ Assert.assertEquals("protocolName", protocol.getName()); Assert.assertEquals("Commentaire", protocol.getComment()); Assert.assertEquals(Lists.newArrayList("14", "18"), protocol.getLengthClassesPmfmId()); - Assert.assertEquals(Lists.newArrayList("114", "228", "821"), protocol.getEnvironmentPmfmId()); - Assert.assertEquals(Lists.newArrayList("21", "22"), protocol.getGearPmfmId()); - Assert.assertEquals(Lists.<String>newArrayList(), protocol.getHydrologyPmfmId()); + Assert.assertEquals(Lists.newArrayList("114", "228", "821"), protocol.getVesselUseFeaturePmfmId()); + Assert.assertEquals(Lists.newArrayList("21", "22"), protocol.getGearUseFeaturePmfmId()); Assert.assertNotNull(protocol.getSpecies()); Assert.assertEquals(2, protocol.getSpecies().size()); SpeciesProtocol sp1 = protocol.getSpecies().get(0); @@ -241,11 +236,9 @@ Assert.assertEquals(Lists.newArrayList("1"), protocol.getLengthClassesPmfmId()); Assert.assertEquals(Lists.newArrayList("2"), - protocol.getEnvironmentPmfmId()); + protocol.getVesselUseFeaturePmfmId()); Assert.assertEquals(Lists.newArrayList("3"), - protocol.getGearPmfmId()); - Assert.assertEquals(Lists.newArrayList("4", "5"), - protocol.getHydrologyPmfmId()); + protocol.getGearUseFeaturePmfmId()); } @Test @@ -259,9 +252,8 @@ TuttiProtocol protocol = new TuttiProtocol(); protocol.setLengthClassesPmfmId(Lists.newArrayList("1")); - protocol.setEnvironmentPmfmId(Lists.newArrayList("2")); - protocol.setGearPmfmId(Lists.newArrayList("3")); - protocol.setHydrologyPmfmId(Lists.newArrayList("4", "5")); + protocol.setVesselUseFeaturePmfmId(Lists.newArrayList("2")); + protocol.setGearUseFeaturePmfmId(Lists.newArrayList("3")); Assert.assertFalse(file.exists()); service.exportProtocolCaracteristic(file, Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AttachmentsAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AttachmentsAction.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AttachmentsAction.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,50 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; - -import static org.nuiton.i18n.I18n._; - -/** - * @author kmorin <kmorin@codelutin.com> - * @since 1.0 - */ -public class AttachmentsAction extends AbstractTuttiAction<EditFishingOperationUIModel, EditFishingOperationUI, EditFishingOperationUIHandler> { - - public AttachmentsAction(EditFishingOperationUIHandler handler) { - super(handler, - "edit-attachment", - _("tutti.action.attachments", 0), - _("tutti.action.attachments.tip"), - true); - } - - @Override - protected void doAction() throws Exception { - //TODO - } - -} Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-03-06 08:11:58 UTC (rev 546) @@ -10,15 +10,15 @@ * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the + * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -37,9 +37,8 @@ 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.content.operation.fishing.GearUseFeatureTabUI; +import fr.ifremer.tutti.ui.swing.content.operation.fishing.VesselUseFeatureTabUI; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; import org.apache.commons.logging.Log; @@ -436,24 +435,20 @@ editFishingOperationUIModel.setFishingOperation(bean); // update saisissuer selection - List<Person> saisisseur = editFishingOperationUIModel.getSaisisseur(); - ui.getSaisisseurList().getHandler().setSelected(saisisseur); + List<Person> saisisseur = editFishingOperationUIModel.getRecorderPerson(); + ui.getRecorderPersonList().getHandler().setSelected(saisisseur); // update model empty property editFishingOperationUIModel.setEmpty(false); - //reset gear shooting - GearShootingTabUI gearShootingTab = ui.getGearShootingTabContent(); - gearShootingTab.getHandler().reset(bean); + //reset gear use feature tab + GearUseFeatureTabUI gearUseFeatureTabContent = ui.getGearUseFeatureTabContent(); + gearUseFeatureTabContent.getHandler().reset(bean); - //reset environment - EnvironmentTabUI environmentTab = ui.getEnvironmentTabContent(); - environmentTab.getHandler().reset(bean); + //reset vessel use feature tab + VesselUseFeatureTabUI vesselUseFeatureTabContent = ui.getVesselUseFeatureTabContent(); + vesselUseFeatureTabContent.getHandler().reset(bean); - //reset hydrology - HydrologyTabUI hydrologyTab = ui.getHydrologyTabContent(); - hydrologyTab.getHandler().reset(bean); - String id = editFishingOperationUIModel.getObjectId(); if (id != null) { Integer objectId = Integer.valueOf(id); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2013-03-06 08:11:58 UTC (rev 546) @@ -471,10 +471,10 @@ _validatorLabel : {_("tutti.label.fishingOperation.duration")}; } -#saisisseurList { - property: saisisseur; - border: {BorderFactory.createTitledBorder(_("tutti.label.list.saisisseur"))}; - _validatorLabel : {_("tutti.label.list.saisisseur")}; +#recorderPersonList { + property: recorderPerson; + border: {BorderFactory.createTitledBorder(_("tutti.label.list.recorderPerson"))}; + _validatorLabel : {_("tutti.label.list.recorderPerson")}; } #commentPane { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx 2013-03-06 08:11:58 UTC (rev 546) @@ -31,9 +31,9 @@ fr.ifremer.tutti.persistence.entities.referential.Person fr.ifremer.tutti.persistence.entities.referential.Vessel - fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUI - fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUI - fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUI + fr.ifremer.tutti.ui.swing.content.operation.fishing.VesselUseFeatureTabUI + fr.ifremer.tutti.ui.swing.content.operation.fishing.GearUseFeatureTabUI + fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachmentEditor fr.ifremer.tutti.ui.swing.util.editor.CoordinateEditorType fr.ifremer.tutti.ui.swing.util.editor.SimpleTimeEditor @@ -90,7 +90,7 @@ <field name='gearShootingStartDate' component='gearShootingStartDateField'/> <field name='gearShootingEndDate' component='gearShootingEndDateField'/> <field name='comment' component='commentPane'/> - <field name='saisisseur' component='saisisseurList'/> + <field name='recorderPerson' component='recorderPersonList'/> <field name='trawlDistance' component='trawlDistanceField'/> <field name='vessel' component='vesselComboBox'/> <field name='gear' component='gearComboBox'/> @@ -468,11 +468,11 @@ </cell> </row> - <!-- Saisisseur --> + <!-- RecorderPerson / Vessel / Gear --> <row weighty='0.2'> <cell columns='6'> <JPanel layout='{new GridLayout(1,0)}'> - <BeanDoubleList id='saisisseurList' genericType='Person'/> + <BeanDoubleList id='recorderPersonList' genericType='Person'/> <Table fill="both" weightx='1' id='traitVesselPanel'> <row> <cell anchor='west'> @@ -513,22 +513,18 @@ <!--</JScrollPane>--> </tab> - <tab id='traitGearShootingTab'> + <tab id='gearUseFeatureTab'> - <GearShootingTabUI id='gearShootingTabContent' + <GearUseFeatureTabUI id='gearUseFeatureTabContent' constructorParams='this'/> </tab> - <tab id='environmentTab'> + <tab id='vesselUseFeatureTab'> - <EnvironmentTabUI id='environmentTabContent' constructorParams='this'/> + <VesselUseFeatureTabUI id='vesselUseFeatureTabContent' + constructorParams='this'/> </tab> - <tab id='traitHydrologyTabContent'> - - <HydrologyTabUI id='hydrologyTabContent' constructorParams='this'/> - - </tab> </JTabbedPane> <!-- Actions --> 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-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-03-06 08:11:58 UTC (rev 546) @@ -38,10 +38,9 @@ import fr.ifremer.tutti.persistence.entities.referential.Zone; import fr.ifremer.tutti.service.PersistenceService; 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; -import fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUIModel; -import fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.fishing.AbstractCaracteristicTabUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.fishing.GearUseFeatureTabUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.fishing.VesselUseFeatureTabUIModel; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiTabContainerUIHandler; import fr.ifremer.tutti.ui.swing.util.TabHandler; @@ -166,7 +165,7 @@ EditFishingOperationUIModel.PROPERTY_TRAWL_DISTANCE, EditFishingOperationUIModel.PROPERTY_FISHING_OPERATION_VALID, EditFishingOperationUIModel.PROPERTY_LOCATION, - EditFishingOperationUIModel.PROPERTY_SAISISSEUR, + EditFishingOperationUIModel.PROPERTY_RECORDER_PERSON, EditFishingOperationUIModel.PROPERTY_VESSEL, EditFishingOperationUIModel.PROPERTY_GEAR, EditFishingOperationUIModel.PROPERTY_MULTIRIG_AGGREGATION, @@ -241,10 +240,10 @@ initUI(ui); - List<Person> people = persistenceService.getAllPerson(); - initBeanList(ui.getSaisisseurList(), + List<Person> people = getDataContext().getPersons(); + initBeanList(ui.getRecorderPersonList(), people, - model.getSaisisseur()); + model.getRecorderPerson()); initBeanComboBox(ui.getVesselComboBox(), Lists.<Vessel>newArrayList(), @@ -298,22 +297,18 @@ setCustomTab(0, model); listModelIsModify(model); - //init gear shooting - GearShootingTabUIModel gearShootingModel = - ui.getGearShootingTabContent().getModel(); - gearShootingModel.setAvailableCaracteristics(persistenceService.getAllCaracteristic()); - setCustomTab(1, gearShootingModel); + //init gear use features + GearUseFeatureTabUIModel gearUseFeatureModel = + ui.getGearUseFeatureTabContent().getModel(); + gearUseFeatureModel.setAvailableCaracteristics(getDataContext().getCaracteristics()); + setCustomTab(1, gearUseFeatureModel); - //init environment - EnvironmentTabUIModel environmentModel = - ui.getEnvironmentTabContent().getModel(); - environmentModel.setAvailableCaracteristics(persistenceService.getAllCaracteristic()); - setCustomTab(2, environmentModel); + //init vessel use features - //init hydrology - HydrologyTabUIModel hydrologyModel = ui.getHydrologyTabContent().getModel(); - hydrologyModel.setAvailableCaracteristics(persistenceService.getAllCaracteristic()); - setCustomTab(3, hydrologyModel); + VesselUseFeatureTabUIModel vesselUseFeatureModel = + ui.getVesselUseFeatureTabContent().getModel(); + vesselUseFeatureModel.setAvailableCaracteristics(getDataContext().getCaracteristics()); + setCustomTab(2, vesselUseFeatureModel); if (TuttiUIContext.VALIDATION_CONTEXT_VALIDATE.equals(model.getValidationContext())) { PropertyChangeListener pcl = new PropertyChangeListener() { @@ -324,9 +319,8 @@ ui.getSaveButton().setEnabled(allModelsValid); } }; - gearShootingModel.addPropertyChangeListener(AbstractTuttiBeanUIModel.PROPERTY_VALID, pcl); - environmentModel.addPropertyChangeListener(AbstractTuttiBeanUIModel.PROPERTY_VALID, pcl); - hydrologyModel.addPropertyChangeListener(AbstractTuttiBeanUIModel.PROPERTY_VALID, pcl); + gearUseFeatureModel.addPropertyChangeListener(AbstractTuttiBeanUIModel.PROPERTY_VALID, pcl); + vesselUseFeatureModel.addPropertyChangeListener(AbstractTuttiBeanUIModel.PROPERTY_VALID, pcl); model.addPropertyChangeListener(AbstractTuttiBeanUIModel.PROPERTY_VALID, pcl); } else { @@ -363,9 +357,8 @@ clearValidators(); - closeUI(ui.getGearShootingTabContent()); - closeUI(ui.getEnvironmentTabContent()); - closeUI(ui.getHydrologyTabContent()); + closeUI(ui.getGearUseFeatureTabContent()); + closeUI(ui.getVesselUseFeatureTabContent()); } @Override @@ -451,11 +444,10 @@ //-- Public methods --// //------------------------------------------------------------------------// - public CaracteristicTabUIModel[] getSubModels() { - return new CaracteristicTabUIModel[]{ - ui.getGearShootingTabContent().getModel(), - ui.getEnvironmentTabContent().getModel(), - ui.getHydrologyTabContent().getModel() + public AbstractCaracteristicTabUIModel[] getSubModels() { + return new AbstractCaracteristicTabUIModel[]{ + ui.getGearUseFeatureTabContent().getModel(), + ui.getVesselUseFeatureTabContent().getModel() }; } @@ -572,8 +564,8 @@ protected boolean areAllModelsValid() { boolean result = getModel().isValid(); - CaracteristicTabUIModel[] subModels = getSubModels(); - for (CaracteristicTabUIModel subModel : subModels) { + AbstractCaracteristicTabUIModel[] subModels = getSubModels(); + for (AbstractCaracteristicTabUIModel subModel : subModels) { result &= subModel.isValid(); } return result; @@ -581,8 +573,8 @@ protected boolean isAModelModified() { boolean result = getModel().isModify(); - CaracteristicTabUIModel[] subModels = getSubModels(); - for (CaracteristicTabUIModel subModel : subModels) { + AbstractCaracteristicTabUIModel[] subModels = getSubModels(); + for (AbstractCaracteristicTabUIModel subModel : subModels) { result |= subModel.isModify(); } return result; @@ -590,7 +582,7 @@ protected void resetAllModels() { - for (CaracteristicTabUIModel subModel : getSubModels()) { + for (AbstractCaracteristicTabUIModel subModel : getSubModels()) { subModel.setModify(false); } getModel().setModify(false); 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-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -130,7 +130,7 @@ public static final String PROPERTY_COMMENT = "comment"; - public static final String PROPERTY_SAISISSEUR = "saisisseur"; + public static final String PROPERTY_RECORDER_PERSON = "recorderPerson"; public static final String PROPERTY_VESSEL = "vessel"; @@ -187,7 +187,7 @@ protected String comment; - protected List<Person> saisisseur = Lists.newArrayList(); + protected List<Person> recorderPerson = Lists.newArrayList(); protected final List<Attachment> attachment = Lists.newArrayList(); @@ -706,17 +706,17 @@ firePropertyChange(PROPERTY_COMMENT, oldValue, comment); } - public List<Person> getSaisisseur() { - return saisisseur; + public List<Person> getRecorderPerson() { + return recorderPerson; } - public void setSaisisseur(List<Person> saisisseur) { - Object oldValue = Lists.newArrayList(getSaisisseur()); - this.saisisseur = Lists.newArrayList(); - if (saisisseur != null) { - this.saisisseur.addAll(saisisseur); + public void setRecorderPerson(List<Person> recorderPerson) { + Object oldValue = Lists.newArrayList(getRecorderPerson()); + this.recorderPerson = Lists.newArrayList(); + if (recorderPerson != null) { + this.recorderPerson.addAll(recorderPerson); } - firePropertyChange(PROPERTY_SAISISSEUR, oldValue, saisisseur); + firePropertyChange(PROPERTY_RECORDER_PERSON, oldValue, recorderPerson); } public String getValidationContext() { 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-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/SaveFishingOperationAction.java 2013-03-06 08:11:58 UTC (rev 546) @@ -30,10 +30,9 @@ 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.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; -import fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.fishing.AbstractCaracteristicTabUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.fishing.GearUseFeatureTabUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.fishing.VesselUseFeatureTabUIModel; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; import fr.ifremer.tutti.ui.swing.util.editor.CoordinateEditorType; @@ -113,19 +112,17 @@ // save modified fishing operation FishingOperation toSave = beanToSave.toBean(); - CaracteristicTabUIModel[] subModels = handler.getSubModels(); - for (CaracteristicTabUIModel subModel : subModels) { + AbstractCaracteristicTabUIModel[] subModels = handler.getSubModels(); + for (AbstractCaracteristicTabUIModel subModel : subModels) { Class<?> modelClass = subModel.getClass(); CaracteristicMap caracteristics = subModel.getCaracteristicMap(); - if (modelClass.isAssignableFrom(EnvironmentTabUIModel.class)) { - toSave.setEnvironmentCaracteristics(caracteristics); + if (modelClass.isAssignableFrom(VesselUseFeatureTabUIModel.class)) { + toSave.setVesselUseFeatures(caracteristics); - } else if (modelClass.isAssignableFrom(GearShootingTabUIModel.class)) { - toSave.setGearShootingCaracteristics(caracteristics); + } else if (modelClass.isAssignableFrom(GearUseFeatureTabUIModel.class)) { + toSave.setGearUseFeatures(caracteristics); - } else if (modelClass.isAssignableFrom(HydrologyTabUIModel.class)) { - toSave.setHydrologyCaracteristics(caracteristics); } subModel.setModify(false); } Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicRowModel.java (from rev 543, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/CaracteristicRowModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicRowModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicRowModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -0,0 +1,78 @@ + +package fr.ifremer.tutti.ui.swing.content.operation.fishing; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; +import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; + +import java.io.Serializable; + +/** + * @author kmorin <kmorin@codelutin.com> + * @since 1.0 + */ +public abstract class AbstractCaracteristicRowModel<RM extends AbstractCaracteristicRowModel<RM>> extends AbstractTuttiBeanUIModel<Serializable, RM> { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_KEY = "key"; + + public static final String PROPERTY_VALUE = "value"; + + protected Caracteristic key; + + protected Serializable value; + + public AbstractCaracteristicRowModel() { + super(Serializable.class, null, null); + } + + public AbstractCaracteristicRowModel(Caracteristic key, Serializable value) { + this(); + this.key = key; + this.value = value; + } + + public Caracteristic getKey() { + return key; + } + + public void setKey(Caracteristic key) { + Object oldValue = getKey(); + this.key = key; + firePropertyChange(PROPERTY_KEY, oldValue, key); + } + + public Serializable getValue() { + return value; + } + + public void setValue(Serializable value) { + Object oldValue = getValue(); + this.value = value; + firePropertyChange(PROPERTY_VALUE, oldValue, value); + } +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIHandler.java (from rev 543, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/CaracteristicTabUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIHandler.java 2013-03-06 08:11:58 UTC (rev 546) @@ -0,0 +1,272 @@ + +package fr.ifremer.tutti.ui.swing.content.operation.fishing; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.CaracteristicMap; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; +import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; +import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI; +import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; +import fr.ifremer.tutti.ui.swing.util.TuttiUI; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; +import jaxx.runtime.swing.editor.bean.BeanComboBox; +import jaxx.runtime.validator.swing.SwingValidator; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.List; + +/** + * @author kmorin <kmorin@codelutin.com> + * @since 1.0 + */ +public abstract class AbstractCaracteristicTabUIHandler + <RM extends AbstractCaracteristicRowModel<RM>, + M extends AbstractCaracteristicTabUIModel<RM, M>, + TM extends AbstractTuttiTableModel<RM>, + UI extends TuttiUI<M, ?>> + extends AbstractTuttiTableUIHandler<RM, M, UI> { + + private static final Log log = LogFactory.getLog(AbstractCaracteristicTabUIHandler.class); + + public AbstractCaracteristicTabUIHandler(EditFishingOperationUI parentUi, UI ui, String... properties) { + super(parentUi.getHandler().getContext(), ui, properties); + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiTableUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public TM getTableModel() { + return (TM) getTable().getModel(); + } + + @Override + protected boolean isRowValid(RM row) { + //TODO + return row.getValue() != null; + } + + @Override + protected void onRowModified(int rowIndex, RM row, String propertyName, Object oldValue, Object newValue) { + recomputeRowValidState(row); + super.onRowModified(rowIndex, row, propertyName, oldValue, newValue); + } + + @Override + protected void saveSelectedRowIfRequired(TuttiBeanMonitor<RM> rowMonitor, RM row) { + if (row.isValid()) { + // there is a valid bean attached to the monitor + + if (rowMonitor.wasModified()) { + + // monitored bean was modified, save it + if (log.isInfoEnabled()) { + log.info("Row " + row + " was modified, will save it"); + } + + saveRow(row); + + } + } + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public SwingValidator<M> getValidator() { + return null; + } + + @Override + protected void onAfterSelectedRowChanged(int oldRowIndex, + RM oldRow, + int newRowIndex, + RM newRow) { + + super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow); + getModel().setRemoveCaracteristicEnabled(newRow != null); + } + + @Override + public void beforeInitUI() { + M model = createModel(); + getUI().setContextValue(model); + } + + @Override + public void afterInitUI() { + initUI(getUI()); + + initBeanComboBox(getKeyCombo(), Lists.<Caracteristic>newArrayList(), null); + + } + + @Override + public void onCloseUI() { + if (log.isInfoEnabled()) { + log.info("closing: " + getUI()); + } + } + + //------------------------------------------------------------------------// + //-- Protected methods --// + //------------------------------------------------------------------------// + + protected void saveRow(RM row) { + + if (row.isValid()) { + CaracteristicMap caracteristics = getModel().getCaracteristicMap(); + Preconditions.checkNotNull(caracteristics); + + caracteristics.put(row.getKey(), row.getValue()); + } + } + + protected abstract M createModel(); + + protected abstract BeanComboBox<Caracteristic> getKeyCombo(); + + protected abstract CaracteristicMap getCaracteristics(FishingOperation operation); + + protected abstract List<String> getProtocolPmfmIds(TuttiProtocol protocol); + + //------------------------------------------------------------------------// + //-- Public methods --// + //------------------------------------------------------------------------// + + /** Adds a row with the parameter selected in the combo box */ + public void addRow() { + BeanComboBox<Caracteristic> keyCombo = getKeyCombo(); + Caracteristic selectedItem = (Caracteristic) keyCombo.getSelectedItem(); + TM tableModel = getTableModel(); + + RM row = tableModel.createNewRow(); + row.setKey(selectedItem); +// tableModel.addNewRow(row); + getModel().getRows().add(row); + + int rowIndex = tableModel.getRowCount() - 1; + tableModel.fireTableRowsInserted(rowIndex, rowIndex); + + keyCombo.getData().remove(selectedItem); + selectFirstInCombo(keyCombo); + + M model = getModel(); + model.setModify(true); + recomputeRowValidState(row); + } + + /** Resets the table with the data from the database */ + public void reset(FishingOperation fishingOperation) { + TM tableModel = getTableModel(); + M model = getModel(); + + CaracteristicMap caracteristicMap = getCaracteristics(fishingOperation); + if (caracteristicMap == null) { + caracteristicMap = new CaracteristicMap(); + } + model.setCaracteristicMap(caracteristicMap); + + TuttiProtocol protocol = getDataContext().getProtocol(); + List<String> pmfmIds = Lists.newArrayList(); + if (protocol != null) { + List<String> protocolPmfmId = getProtocolPmfmIds(protocol); + if (protocolPmfmId != null) { + pmfmIds.addAll(protocolPmfmId); + } + } + + List<RM> rows = Lists.newArrayList(); + List<Caracteristic> caracteristics = Lists.newArrayList(caracteristicMap.keySet()); + + List<Caracteristic> availableCaracteristics = model.getAvailableCaracteristics(); + for (String id : pmfmIds) { + Caracteristic caracteristic = TuttiEntities.findById(availableCaracteristics, id); + if (!caracteristics.contains(caracteristic)) { + caracteristics.add(caracteristic); + } + } + + for (Caracteristic key : caracteristics) { + RM newRow = tableModel.createNewRow(); + newRow.setKey(key); + newRow.setValue(caracteristicMap.get(key)); + rows.add(newRow); + } + + model.setRows(rows); + + List<Caracteristic> caracteristicList = Lists.newArrayList(); + + for (Caracteristic caracteristic : availableCaracteristics) { + if (!caracteristics.contains(caracteristic)) { + caracteristicList.add(caracteristic); + } + } + + BeanComboBox<Caracteristic> keyCombo = getKeyCombo(); + keyCombo.setData(caracteristicList); + selectFirstInCombo(keyCombo); + model.setModify(false); + } + + public void removeCaracteristic() { + int rowIndex = getTable().getSelectedRow(); + + Preconditions.checkState( + rowIndex != -1, + "Cant remove caracteristic if no caracteristic selected"); + + RM row = getTableModel().getEntry(rowIndex); + + CaracteristicMap caracteristicMap = getModel().getCaracteristicMap(); + if (caracteristicMap != null) { + caracteristicMap.remove(row.getKey()); + } + + //add the row in the combo + BeanComboBox keyCombo = getKeyCombo(); + keyCombo.addItem(row.getKey()); + selectFirstInCombo(keyCombo); + + // remove the row from the model + getModel().getRows().remove(rowIndex); + + // refresh all the table + getTableModel().fireTableRowsDeleted(rowIndex, rowIndex); + + getModel().removeRowInError(row); + } +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIModel.java (from rev 543, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/CaracteristicTabUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/AbstractCaracteristicTabUIModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -0,0 +1,101 @@ + +package fr.ifremer.tutti.ui.swing.content.operation.fishing; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.CaracteristicMap; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; +import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; + +import java.io.Serializable; +import java.util.List; + +/** + * @author kmorin <kmorin@codelutin.com> + * @since 1.0 + */ +public abstract class AbstractCaracteristicTabUIModel<RM extends AbstractTuttiBeanUIModel<Serializable, RM>, M extends AbstractCaracteristicTabUIModel<RM, M>> + extends AbstractTuttiTableUIModel<FishingOperation, RM, M> { + + public static final String PROPERTY_CARACTERISTIC_MAP = "caracteristicMap"; + + public static final String PROPERTY_REMOVE_CARACTERISTIC_ENABLED = "removeCaracteristicEnabled"; + + public static final String PROPERTY_AVAILABLE_CARACTERISTICS = "availableCaracteristics"; + + private static final long serialVersionUID = 1L; + + protected List<Caracteristic> availableCaracteristics; + + /** + * Caracteristics + * + * @since 1.0 + */ + protected CaracteristicMap caracteristicMap; + + /** + * Can user remove a selected caracteristic? + * + * @since 1.0 + */ + protected boolean removeCaracteristicEnabled; + + public AbstractCaracteristicTabUIModel() { + super(FishingOperation.class, null, null); + } + + public List<Caracteristic> getAvailableCaracteristics() { + return availableCaracteristics; + } + + public void setAvailableCaracteristics(List<Caracteristic> availableCaracteristics) { + Object oldValue = getAvailableCaracteristics(); + this.availableCaracteristics = availableCaracteristics; + firePropertyChange(PROPERTY_AVAILABLE_CARACTERISTICS, oldValue, availableCaracteristics); + } + + public CaracteristicMap getCaracteristicMap() { + return caracteristicMap; + } + + public void setCaracteristicMap(CaracteristicMap caracteristicMap) { + Object oldValue = getCaracteristicMap(); + this.caracteristicMap = caracteristicMap != null ? (CaracteristicMap) caracteristicMap.clone() : null; + firePropertyChange(PROPERTY_CARACTERISTIC_MAP, oldValue, this.caracteristicMap); + } + + public boolean isRemoveCaracteristicEnabled() { + return removeCaracteristicEnabled; + } + + public void setRemoveCaracteristicEnabled(boolean removeCaracteristicEnabled) { + Object oldValue = isRemoveCaracteristicEnabled(); + this.removeCaracteristicEnabled = removeCaracteristicEnabled; + firePropertyChange(PROPERTY_REMOVE_CARACTERISTIC_ENABLED, oldValue, removeCaracteristicEnabled); + } +} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/CaracteristicRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/CaracteristicRowModel.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/CaracteristicRowModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,78 +0,0 @@ - -package fr.ifremer.tutti.ui.swing.content.operation.fishing; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; -import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; - -import java.io.Serializable; - -/** - * @author kmorin <kmorin@codelutin.com> - * @since 1.0 - */ -public abstract class CaracteristicRowModel<RM extends CaracteristicRowModel<RM>> extends AbstractTuttiBeanUIModel<Serializable, RM> { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_KEY = "key"; - - public static final String PROPERTY_VALUE = "value"; - - protected Caracteristic key; - - protected Serializable value; - - public CaracteristicRowModel() { - super(Serializable.class, null, null); - } - - public CaracteristicRowModel(Caracteristic key, Serializable value) { - this(); - this.key = key; - this.value = value; - } - - public Caracteristic getKey() { - return key; - } - - public void setKey(Caracteristic key) { - Object oldValue = getKey(); - this.key = key; - firePropertyChange(PROPERTY_KEY, oldValue, key); - } - - public Serializable getValue() { - return value; - } - - public void setValue(Serializable value) { - Object oldValue = getValue(); - this.value = value; - firePropertyChange(PROPERTY_VALUE, oldValue, value); - } -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/CaracteristicTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/CaracteristicTabUIHandler.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/CaracteristicTabUIHandler.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,272 +0,0 @@ - -package fr.ifremer.tutti.ui.swing.content.operation.fishing; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; -import fr.ifremer.tutti.persistence.entities.CaracteristicMap; -import fr.ifremer.tutti.persistence.entities.TuttiEntities; -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; -import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; -import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI; -import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; -import fr.ifremer.tutti.ui.swing.util.TuttiUI; -import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; -import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; -import jaxx.runtime.swing.editor.bean.BeanComboBox; -import jaxx.runtime.validator.swing.SwingValidator; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.List; - -/** - * @author kmorin <kmorin@codelutin.com> - * @since 1.0 - */ -public abstract class CaracteristicTabUIHandler - <RM extends CaracteristicRowModel<RM>, - M extends CaracteristicTabUIModel<RM, M>, - TM extends AbstractTuttiTableModel<RM>, - UI extends TuttiUI<M, ?>> - extends AbstractTuttiTableUIHandler<RM, M, UI> { - - private static final Log log = LogFactory.getLog(CaracteristicTabUIHandler.class); - - public CaracteristicTabUIHandler(EditFishingOperationUI parentUi, UI ui, String... properties) { - super(parentUi.getHandler().getContext(), ui, properties); - } - - //------------------------------------------------------------------------// - //-- AbstractTuttiTableUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - public TM getTableModel() { - return (TM) getTable().getModel(); - } - - @Override - protected boolean isRowValid(RM row) { - //TODO - return row.getValue() != null; - } - - @Override - protected void onRowModified(int rowIndex, RM row, String propertyName, Object oldValue, Object newValue) { - recomputeRowValidState(row); - super.onRowModified(rowIndex, row, propertyName, oldValue, newValue); - } - - @Override - protected void saveSelectedRowIfRequired(TuttiBeanMonitor<RM> rowMonitor, RM row) { - if (row.isValid()) { - // there is a valid bean attached to the monitor - - if (rowMonitor.wasModified()) { - - // monitored bean was modified, save it - if (log.isInfoEnabled()) { - log.info("Row " + row + " was modified, will save it"); - } - - saveRow(row); - - } - } - } - - //------------------------------------------------------------------------// - //-- AbstractTuttiUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - public SwingValidator<M> getValidator() { - return null; - } - - @Override - protected void onAfterSelectedRowChanged(int oldRowIndex, - RM oldRow, - int newRowIndex, - RM newRow) { - - super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow); - getModel().setRemoveCaracteristicEnabled(newRow != null); - } - - @Override - public void beforeInitUI() { - M model = createModel(); - getUI().setContextValue(model); - } - - @Override - public void afterInitUI() { - initUI(getUI()); - - initBeanComboBox(getKeyCombo(), Lists.<Caracteristic>newArrayList(), null); - - } - - @Override - public void onCloseUI() { - if (log.isInfoEnabled()) { - log.info("closing: " + getUI()); - } - } - - //------------------------------------------------------------------------// - //-- Protected methods --// - //------------------------------------------------------------------------// - - protected void saveRow(RM row) { - - if (row.isValid()) { - CaracteristicMap caracteristics = getModel().getCaracteristicMap(); - Preconditions.checkNotNull(caracteristics); - - caracteristics.put(row.getKey(), row.getValue()); - } - } - - protected abstract M createModel(); - - protected abstract BeanComboBox<Caracteristic> getKeyCombo(); - - protected abstract CaracteristicMap getCaracteristics(FishingOperation operation); - - protected abstract List<String> getProtocolPmfmIds(TuttiProtocol protocol); - - //------------------------------------------------------------------------// - //-- Public methods --// - //------------------------------------------------------------------------// - - /** Adds a row with the parameter selected in the combo box */ - public void addRow() { - BeanComboBox<Caracteristic> keyCombo = getKeyCombo(); - Caracteristic selectedItem = (Caracteristic) keyCombo.getSelectedItem(); - TM tableModel = getTableModel(); - - RM row = tableModel.createNewRow(); - row.setKey(selectedItem); -// tableModel.addNewRow(row); - getModel().getRows().add(row); - - int rowIndex = tableModel.getRowCount() - 1; - tableModel.fireTableRowsInserted(rowIndex, rowIndex); - - keyCombo.getData().remove(selectedItem); - selectFirstInCombo(keyCombo); - - M model = getModel(); - model.setModify(true); - recomputeRowValidState(row); - } - - /** Resets the table with the data from the database */ - public void reset(FishingOperation fishingOperation) { - TM tableModel = getTableModel(); - M model = getModel(); - - CaracteristicMap caracteristicMap = getCaracteristics(fishingOperation); - if (caracteristicMap == null) { - caracteristicMap = new CaracteristicMap(); - } - model.setCaracteristicMap(caracteristicMap); - - TuttiProtocol protocol = getDataContext().getProtocol(); - List<String> pmfmIds = Lists.newArrayList(); - if (protocol != null) { - List<String> protocolPmfmId = getProtocolPmfmIds(protocol); - if (protocolPmfmId != null) { - pmfmIds.addAll(protocolPmfmId); - } - } - - List<RM> rows = Lists.newArrayList(); - List<Caracteristic> caracteristics = Lists.newArrayList(caracteristicMap.keySet()); - - List<Caracteristic> availableCaracteristics = model.getAvailableCaracteristics(); - for (String id : pmfmIds) { - Caracteristic caracteristic = TuttiEntities.findById(availableCaracteristics, id); - if (!caracteristics.contains(caracteristic)) { - caracteristics.add(caracteristic); - } - } - - for (Caracteristic key : caracteristics) { - RM newRow = tableModel.createNewRow(); - newRow.setKey(key); - newRow.setValue(caracteristicMap.get(key)); - rows.add(newRow); - } - - model.setRows(rows); - - List<Caracteristic> caracteristicList = Lists.newArrayList(); - - for (Caracteristic caracteristic : availableCaracteristics) { - if (!caracteristics.contains(caracteristic)) { - caracteristicList.add(caracteristic); - } - } - - BeanComboBox<Caracteristic> keyCombo = getKeyCombo(); - keyCombo.setData(caracteristicList); - selectFirstInCombo(keyCombo); - model.setModify(false); - } - - public void removeCaracteristic() { - int rowIndex = getTable().getSelectedRow(); - - Preconditions.checkState(rowIndex != -1, - "Cant remove caracteristic if no caracteristic selected"); - - RM row = getTableModel().getEntry(rowIndex); - - CaracteristicMap caracteristicMap = getModel().getCaracteristicMap(); - if (caracteristicMap != null) { - caracteristicMap.remove(row.getKey()); - } - - //add the row in the combo - BeanComboBox keyCombo = getKeyCombo(); - keyCombo.addItem(row.getKey()); - selectFirstInCombo(keyCombo); - - // remove the row from the model - getModel().getRows().remove(rowIndex); - - // refresh all the table - getTableModel().fireTableRowsDeleted(rowIndex, rowIndex); - - getModel().removeRowInError(row); - - } -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/CaracteristicTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/CaracteristicTabUIModel.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/CaracteristicTabUIModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,99 +0,0 @@ - -package fr.ifremer.tutti.ui.swing.content.operation.fishing; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.CaracteristicMap; -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; -import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; -import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; - -import java.io.Serializable; -import java.util.List; - -/** - * @author kmorin <kmorin@codelutin.com> - * @since 1.0 - */ -public abstract class CaracteristicTabUIModel<RM extends AbstractTuttiBeanUIModel<Serializable, RM>, M extends CaracteristicTabUIModel<RM, M>> - extends AbstractTuttiTableUIModel<FishingOperation, RM, M> { - - public static final String PROPERTY_CARACTERISTIC_MAP = "caracteristicMap"; - - public static final String PROPERTY_REMOVE_CARACTERISTIC_ENABLED = "removeCaracteristicEnabled"; - - public static final String PROPERTY_AVAILABLE_CARACTERISTICS = "availableCaracteristics"; - - protected List<Caracteristic> availableCaracteristics; - - /** - * Caracteristics - * - * @since 1.0 - */ - protected CaracteristicMap caracteristicMap; - - /** - * Can user remove a selected caracteristic? - * - * @since 1.0 - */ - protected boolean removeCaracteristicEnabled; - - public CaracteristicTabUIModel() { - super(FishingOperation.class, null, null); - } - - public List<Caracteristic> getAvailableCaracteristics() { - return availableCaracteristics; - } - - public void setAvailableCaracteristics(List<Caracteristic> availableCaracteristics) { - Object oldValue = getAvailableCaracteristics(); - this.availableCaracteristics = availableCaracteristics; - firePropertyChange(PROPERTY_AVAILABLE_CARACTERISTICS, oldValue, availableCaracteristics); - } - - public CaracteristicMap getCaracteristicMap() { - return caracteristicMap; - } - - public void setCaracteristicMap(CaracteristicMap caracteristicMap) { - Object oldValue = getCaracteristicMap(); - this.caracteristicMap = caracteristicMap != null ? (CaracteristicMap) caracteristicMap.clone() : null; - firePropertyChange(PROPERTY_CARACTERISTIC_MAP, oldValue, this.caracteristicMap); - } - - public boolean isRemoveCaracteristicEnabled() { - return removeCaracteristicEnabled; - } - - public void setRemoveCaracteristicEnabled(boolean removeCaracteristicEnabled) { - Object oldValue = isRemoveCaracteristicEnabled(); - this.removeCaracteristicEnabled = removeCaracteristicEnabled; - firePropertyChange(PROPERTY_REMOVE_CARACTERISTIC_ENABLED, oldValue, removeCaracteristicEnabled); - } -} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureRowModel.java (from rev 543, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingRowModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureRowModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureRowModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -0,0 +1,32 @@ + +package fr.ifremer.tutti.ui.swing.content.operation.fishing; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +/** @author kmorin <kmorin@codelutin.com> */ +public class GearUseFeatureRowModel extends AbstractCaracteristicRowModel<GearUseFeatureRowModel> { + + private static final long serialVersionUID = 1L; +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUI.css (from rev 543, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUI.css 2013-03-06 08:11:58 UTC (rev 546) @@ -0,0 +1,56 @@ +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +BeanComboBox { + i18nPrefix: "tutti.property."; +} + +#newRowKey { + showReset: false; + property: selectedCaracteristic; + enabled: {!newRowKey.isEmpty()}; +} + +#addRow { + actionIcon: add; + enabled: {newRowKey.getSelectedItem() != null}; +} + +#gearUseFeatureTable { + selectionMode: {ListSelectionModel.SINGLE_SELECTION}; + selectionBackground: {null}; + selectionForeground: {Color.BLACK}; + sortable: false; +} + +#tablePopup { + label: "tutti.title.batchActions"; +} + +#removeCaracteristicMenu { + text: "tutti.action.removeCaracteristic"; + mnemonic: R; + actionIcon: batch-delete; + enabled: {model.isRemoveCaracteristicEnabled()}; +} \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUI.jaxx (from rev 543, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUI.jaxx 2013-03-06 08:11:58 UTC (rev 546) @@ -0,0 +1,80 @@ +<!-- + #%L + Tutti :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 Ifremer + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<Table + implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<GearUseFeatureTabUIModel, GearUseFeatureTabUIHandler>'> + + <import> + fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI + fr.ifremer.tutti.persistence.entities.referential.Caracteristic + + jaxx.runtime.swing.editor.bean.BeanComboBox + org.jdesktop.swingx.JXTable + javax.swing.ListSelectionModel + java.awt.Color + </import> + + <GearUseFeatureTabUIHandler id='handler' + initializer='getContextValue(GearUseFeatureTabUIHandler.class)'/> + + <GearUseFeatureTabUIModel id='model' + initializer='getContextValue(GearUseFeatureTabUIModel.class)'/> + + <JPopupMenu id='tablePopup'> + <JMenuItem id='removeCaracteristicMenu' + onActionPerformed='handler.removeCaracteristic()'/> + </JPopupMenu> + + <row fill='both'> + <cell fill='both' weightx='1'> + <BeanComboBox id='newRowKey' constructorParams='this' + genericType='Caracteristic'/> + </cell> + <cell fill='both'> + <JButton id='addRow' onActionPerformed='handler.addRow()'/> + </cell> + </row> + <row fill='both' weighty='1'> + <cell fill='both' columns='2'> + <JScrollPane> + <JXTable id='gearUseFeatureTable' + onMouseClicked='handler.autoSelectRowInTable(event, tablePopup)'/> + </JScrollPane> + </cell> + </row> + <script><![CDATA[ + +public GearUseFeatureTabUI(EditFishingOperationUI parentUI) { + JAXXUtil.initContext(this, parentUI); + GearUseFeatureTabUIHandler handler = new GearUseFeatureTabUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +protected void $afterCompleteSetup() { + handler.afterInitUI(); +} + + ]]></script> + +</Table> \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUIHandler.java (from rev 543, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUIHandler.java 2013-03-06 08:11:58 UTC (rev 546) @@ -0,0 +1,130 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.CaracteristicMap; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; +import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; +import fr.ifremer.tutti.service.DecoratorService; +import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI; +import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor; +import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer; +import jaxx.runtime.swing.editor.bean.BeanComboBox; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.table.DefaultTableColumnModelExt; + +import java.util.List; + +/** + * @author kmorin + * @since 0.3 + */ +public class GearUseFeatureTabUIHandler extends AbstractCaracteristicTabUIHandler<GearUseFeatureRowModel, GearUseFeatureTabUIModel, GearUseFeatureTableModel, GearUseFeatureTabUI> { + + private final static Log log = + LogFactory.getLog(GearUseFeatureTabUIHandler.class); + + public GearUseFeatureTabUIHandler(EditFishingOperationUI parentUi, + GearUseFeatureTabUI ui) { + super(parentUi, ui, GearUseFeatureRowModel.PROPERTY_VALUE); + } + + //------------------------------------------------------------------------// + //-- AbstractCaracteristicTabUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + protected BeanComboBox<Caracteristic> getKeyCombo() { + return ui.getNewRowKey(); + } + + @Override + protected GearUseFeatureTabUIModel createModel() { + return new GearUseFeatureTabUIModel(); + } + + @Override + protected CaracteristicMap getCaracteristics(FishingOperation operation) { + return operation.getGearUseFeatures(); + } + + @Override + protected List<String> getProtocolPmfmIds(TuttiProtocol protocol) { + return protocol.getGearUseFeaturePmfmId(); + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiTableUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public JXTable getTable() { + return ui.getGearUseFeatureTable(); + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public void afterInitUI() { + super.afterInitUI(); + + JXTable table = getTable(); + + // create table column model + DefaultTableColumnModelExt columnModel = + new DefaultTableColumnModelExt(); + + { + + addColumnToModel(columnModel, + null, + newTableCellRender(Caracteristic.class, DecoratorService.CARACTERISTIC_WITH_UNIT), + GearUseFeatureTableModel.KEY); + } + + { + + addColumnToModel(columnModel, + new CaracteristicValueEditor(context), + new CaracteristicValueRenderer(context), + GearUseFeatureTableModel.VALUE); + } + + // create table model + GearUseFeatureTableModel tableModel = + new GearUseFeatureTableModel(columnModel); + + table.setModel(tableModel); + table.setColumnModel(columnModel); + + initTable(table); + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUIModel.java (from rev 543, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTabUIModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -0,0 +1,46 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import static org.nuiton.i18n.I18n.n_; + + +/** + * @author kmorin + * @since 0.3 + */ +public class GearUseFeatureTabUIModel extends AbstractCaracteristicTabUIModel<GearUseFeatureRowModel, GearUseFeatureTabUIModel> { + + private static final long serialVersionUID = 1L; + + public static final String TITLE = + n_("tutti.label.tab.fishingOperation.gearUseFeature"); + + @Override + public String getTitle() { + return TITLE; + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTableModel.java (from rev 543, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/GearUseFeatureTableModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -0,0 +1,62 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; +import org.jdesktop.swingx.table.TableColumnModelExt; + +import static org.nuiton.i18n.I18n.n_; + +/** + * @author kmorin + * @since 0.3 + */ +public class GearUseFeatureTableModel extends AbstractTuttiTableModel<GearUseFeatureRowModel> { + + private static final long serialVersionUID = 1L; + + public static final ColumnIdentifier<GearUseFeatureRowModel> KEY = ColumnIdentifier.newId( + GearUseFeatureRowModel.PROPERTY_KEY, + n_("tutti.table.fishing.gearUseFeature.header.key"), + n_("tutti.table.fishing.gearUseFeature.header.key")); + + public static final ColumnIdentifier<GearUseFeatureRowModel> VALUE = ColumnIdentifier.newId( + GearUseFeatureRowModel.PROPERTY_VALUE, + n_("tutti.table.fishing.gearUseFeature.header.value"), + n_("tutti.table.fishing.gearUseFeature.header.value")); + + public GearUseFeatureTableModel(TableColumnModelExt columnModel) { + super(columnModel, false, false); + setNoneEditableCols(KEY); + } + + @Override + public GearUseFeatureRowModel createNewRow() { + GearUseFeatureRowModel result = new GearUseFeatureRowModel(); + return result; + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureRowModel.java (from rev 543, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureRowModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureRowModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -0,0 +1,32 @@ + +package fr.ifremer.tutti.ui.swing.content.operation.fishing; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +/** @author kmorin <kmorin@codelutin.com> */ +public class VesselUseFeatureRowModel extends AbstractCaracteristicRowModel<VesselUseFeatureRowModel> { + + private static final long serialVersionUID = 1L; +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUI.css (from rev 543, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUI.css 2013-03-06 08:11:58 UTC (rev 546) @@ -0,0 +1,56 @@ +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +BeanComboBox { + i18nPrefix: "tutti.property."; +} + +#newRowKey { + showReset: false; + property: selectedCaracteristic; + enabled: {!newRowKey.isEmpty()}; +} + +#addRow { + actionIcon: add; + enabled: {newRowKey.getSelectedItem() != null}; +} + +#vesselUseFeatureTable { + selectionMode: {ListSelectionModel.SINGLE_SELECTION}; + selectionBackground: {null}; + selectionForeground: {Color.BLACK}; + sortable: false; +} + +#tablePopup { + label: "tutti.title.batchActions"; +} + +#removeCaracteristicMenu { + text: "tutti.action.removeCaracteristic"; + mnemonic: R; + actionIcon: batch-delete; + enabled: {model.isRemoveCaracteristicEnabled()}; +} \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUI.jaxx (from rev 543, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUI.jaxx 2013-03-06 08:11:58 UTC (rev 546) @@ -0,0 +1,81 @@ +<!-- + #%L + Tutti :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 Ifremer + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> +<Table + implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<VesselUseFeatureTabUIModel, VesselUseFeatureTabUIHandler>'> + + <import> + fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI + fr.ifremer.tutti.persistence.entities.referential.Caracteristic + + jaxx.runtime.swing.editor.bean.BeanComboBox + + org.jdesktop.swingx.JXTable + + javax.swing.ListSelectionModel + java.awt.Color + </import> + + <VesselUseFeatureTabUIHandler id='handler' + initializer='getContextValue(VesselUseFeatureTabUIHandler.class)'/> + + <VesselUseFeatureTabUIModel id='model' + initializer='getContextValue(VesselUseFeatureTabUIModel.class)'/> + + <JPopupMenu id='tablePopup'> + <JMenuItem id='removeCaracteristicMenu' + onActionPerformed='handler.removeCaracteristic()'/> + </JPopupMenu> + + <row fill='both'> + <cell fill='both' weightx='1'> + <BeanComboBox id='newRowKey' constructorParams='this' + genericType='Caracteristic'/> + </cell> + <cell fill='both'> + <JButton id='addRow' onActionPerformed='handler.addRow()'/> + </cell> + </row> + <row fill='both' weighty='1'> + <cell fill='both' columns='2'> + <JScrollPane> + <JXTable id='vesselUseFeatureTable' + onMouseClicked='handler.autoSelectRowInTable(event, tablePopup)'/> + </JScrollPane> + </cell> + </row> + <script><![CDATA[ + +public VesselUseFeatureTabUI(EditFishingOperationUI parentUI) { + JAXXUtil.initContext(this, parentUI); + VesselUseFeatureTabUIHandler handler = new VesselUseFeatureTabUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +protected void $afterCompleteSetup() { + handler.afterInitUI(); +} + + ]]></script> +</Table> \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUIHandler.java (from rev 543, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUIHandler.java 2013-03-06 08:11:58 UTC (rev 546) @@ -0,0 +1,128 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.CaracteristicMap; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; +import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; +import fr.ifremer.tutti.service.DecoratorService; +import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI; +import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor; +import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer; +import jaxx.runtime.swing.editor.bean.BeanComboBox; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.table.DefaultTableColumnModelExt; + +import java.util.List; + +/** + * @author kmorin + * @since 0.3 + */ +public class VesselUseFeatureTabUIHandler extends AbstractCaracteristicTabUIHandler<VesselUseFeatureRowModel, VesselUseFeatureTabUIModel, VesselUseFeatureTableModel, VesselUseFeatureTabUI> { + + private final static Log log = + LogFactory.getLog(VesselUseFeatureTabUIHandler.class); + + public VesselUseFeatureTabUIHandler(EditFishingOperationUI parentUi, + VesselUseFeatureTabUI ui) { + super(parentUi, ui, VesselUseFeatureRowModel.PROPERTY_VALUE); + } + + //------------------------------------------------------------------------// + //-- AbstractCaracteristicTabUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + protected BeanComboBox<Caracteristic> getKeyCombo() { + return ui.getNewRowKey(); + } + + @Override + protected VesselUseFeatureTabUIModel createModel() { + return new VesselUseFeatureTabUIModel(); + } + + @Override + protected CaracteristicMap getCaracteristics(FishingOperation operation) { + return operation.getVesselUseFeatures(); + } + + @Override + protected List<String> getProtocolPmfmIds(TuttiProtocol protocol) { + return protocol.getVesselUseFeaturePmfmId(); + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiTableUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public JXTable getTable() { + return ui.getVesselUseFeatureTable(); + } + + //------------------------------------------------------------------------// + //-- AbstractTuttiUIHandler methods --// + //------------------------------------------------------------------------// + + @Override + public void afterInitUI() { + super.afterInitUI(); + + JXTable table = getTable(); + + // create table column model + DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt(); + + { + + addColumnToModel(columnModel, + null, + newTableCellRender(Caracteristic.class, DecoratorService.CARACTERISTIC_WITH_UNIT), + VesselUseFeatureTableModel.KEY); + } + + { + + addColumnToModel(columnModel, + new CaracteristicValueEditor(context), + new CaracteristicValueRenderer(context), + VesselUseFeatureTableModel.VALUE); + } + + // create table model + VesselUseFeatureTableModel tableModel = + new VesselUseFeatureTableModel(columnModel); + + table.setModel(tableModel); + table.setColumnModel(columnModel); + initTable(table); + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUIModel.java (from rev 543, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTabUIModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -0,0 +1,45 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import static org.nuiton.i18n.I18n.n_; + +/** + * @author kmorin + * @since 0.3 + */ +public class VesselUseFeatureTabUIModel extends AbstractCaracteristicTabUIModel<VesselUseFeatureRowModel, VesselUseFeatureTabUIModel> { + + private static final long serialVersionUID = 1L; + + public static final String TITLE = + n_("tutti.label.tab.fishingOperation.vesselUseFeature"); + + @Override + public String getTitle() { + return TITLE; + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTableModel.java (from rev 543, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/VesselUseFeatureTableModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -0,0 +1,62 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; +import org.jdesktop.swingx.table.TableColumnModelExt; + +import static org.nuiton.i18n.I18n.n_; + +/** + * @author kmorin + * @since 0.3 + */ +public class VesselUseFeatureTableModel extends AbstractTuttiTableModel<VesselUseFeatureRowModel> { + + private static final long serialVersionUID = 1L; + + public static final ColumnIdentifier<VesselUseFeatureRowModel> KEY = ColumnIdentifier.newId( + VesselUseFeatureRowModel.PROPERTY_KEY, + n_("tutti.table.fishing.vesselUseFeature.header.key"), + n_("tutti.table.fishing.vesselUseFeature.header.key")); + + public static final ColumnIdentifier<VesselUseFeatureRowModel> VALUE = ColumnIdentifier.newId( + VesselUseFeatureRowModel.PROPERTY_VALUE, + n_("tutti.table.fishing.vesselUseFeature.header.value"), + n_("tutti.table.fishing.vesselUseFeature.header.value")); + + public VesselUseFeatureTableModel(TableColumnModelExt columnModel) { + super(columnModel, false, false); + setNoneEditableCols(KEY); + } + + @Override + public VesselUseFeatureRowModel createNewRow() { + VesselUseFeatureRowModel result = new VesselUseFeatureRowModel(); + return result; + } + +} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,33 +0,0 @@ - -package fr.ifremer.tutti.ui.swing.content.operation.fishing.environment; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.ui.swing.content.operation.fishing.CaracteristicRowModel; - -/** @author kmorin <kmorin@codelutin.com> */ -public class EnvironmentRowModel extends CaracteristicRowModel<EnvironmentRowModel> { - -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css 2013-03-06 08:11:58 UTC (rev 546) @@ -1,56 +0,0 @@ -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -BeanComboBox { - i18nPrefix: "tutti.property."; -} - -#newRowKey { - showReset: false; - property: selectedCaracteristic; - enabled: {!newRowKey.isEmpty()}; -} - -#addRow { - actionIcon: add; - enabled: {newRowKey.getSelectedItem() != null}; -} - -#environmentTable { - selectionMode: {ListSelectionModel.SINGLE_SELECTION}; - selectionBackground: {null}; - selectionForeground: {Color.BLACK}; - sortable: false; -} - -#tablePopup { - label: "tutti.title.batchActions"; -} - -#removeCaracteristicMenu { - text: "tutti.action.removeCaracteristic"; - mnemonic: R; - actionIcon: batch-delete; - enabled: {model.isRemoveCaracteristicEnabled()}; -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.jaxx 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.jaxx 2013-03-06 08:11:58 UTC (rev 546) @@ -1,81 +0,0 @@ -<!-- - #%L - Tutti :: UI - $Id$ - $HeadURL$ - %% - Copyright (C) 2012 Ifremer - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> -<Table - implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<EnvironmentTabUIModel, EnvironmentTabUIHandler>'> - - <import> - fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI - fr.ifremer.tutti.persistence.entities.referential.Caracteristic - - jaxx.runtime.swing.editor.bean.BeanComboBox - - org.jdesktop.swingx.JXTable - - javax.swing.ListSelectionModel - java.awt.Color - </import> - - <EnvironmentTabUIHandler id='handler' - initializer='getContextValue(EnvironmentTabUIHandler.class)'/> - - <EnvironmentTabUIModel id='model' - initializer='getContextValue(EnvironmentTabUIModel.class)'/> - - <JPopupMenu id='tablePopup'> - <JMenuItem id='removeCaracteristicMenu' - onActionPerformed='handler.removeCaracteristic()'/> - </JPopupMenu> - - <row fill='both'> - <cell fill='both' weightx='1'> - <BeanComboBox id='newRowKey' constructorParams='this' - genericType='Caracteristic'/> - </cell> - <cell fill='both'> - <JButton id='addRow' onActionPerformed='handler.addRow()'/> - </cell> - </row> - <row fill='both' weighty='1'> - <cell fill='both' columns='2'> - <JScrollPane> - <JXTable id='environmentTable' - onMouseClicked='handler.autoSelectRowInTable(event, tablePopup)'/> - </JScrollPane> - </cell> - </row> - <script><![CDATA[ - -public EnvironmentTabUI(EditFishingOperationUI parentUI) { - JAXXUtil.initContext(this, parentUI); - EnvironmentTabUIHandler handler = new EnvironmentTabUIHandler(parentUI, this); - setContextValue(handler); - handler.beforeInitUI(); -} - -protected void $afterCompleteSetup() { - handler.afterInitUI(); -} - - ]]></script> -</Table> \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,129 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.fishing.environment; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.CaracteristicMap; -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; -import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; -import fr.ifremer.tutti.service.DecoratorService; -import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI; -import fr.ifremer.tutti.ui.swing.content.operation.fishing.CaracteristicTabUIHandler; -import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor; -import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer; -import jaxx.runtime.swing.editor.bean.BeanComboBox; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.JXTable; -import org.jdesktop.swingx.table.DefaultTableColumnModelExt; - -import java.util.List; - -/** - * @author kmorin - * @since 0.3 - */ -public class EnvironmentTabUIHandler extends CaracteristicTabUIHandler<EnvironmentRowModel, EnvironmentTabUIModel, EnvironmentTableModel, EnvironmentTabUI> { - - private final static Log log = - LogFactory.getLog(EnvironmentTabUIHandler.class); - - public EnvironmentTabUIHandler(EditFishingOperationUI parentUi, - EnvironmentTabUI ui) { - super(parentUi, ui, EnvironmentRowModel.PROPERTY_VALUE); - } - - //------------------------------------------------------------------------// - //-- CaracteristicTabUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - protected BeanComboBox<Caracteristic> getKeyCombo() { - return ui.getNewRowKey(); - } - - @Override - protected EnvironmentTabUIModel createModel() { - return new EnvironmentTabUIModel(); - } - - @Override - protected CaracteristicMap getCaracteristics(FishingOperation operation) { - return operation.getEnvironmentCaracteristics(); - } - - @Override - protected List<String> getProtocolPmfmIds(TuttiProtocol protocol) { - return protocol.getEnvironmentPmfmId(); - } - - //------------------------------------------------------------------------// - //-- AbstractTuttiTableUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - public JXTable getTable() { - return ui.getEnvironmentTable(); - } - - //------------------------------------------------------------------------// - //-- AbstractTuttiUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - public void afterInitUI() { - super.afterInitUI(); - - JXTable table = getTable(); - - // create table column model - DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt(); - - { - - addColumnToModel(columnModel, - null, - newTableCellRender(Caracteristic.class, DecoratorService.CARACTERISTIC_WITH_UNIT), - EnvironmentTableModel.KEY); - } - - { - - addColumnToModel(columnModel, - new CaracteristicValueEditor(context), - new CaracteristicValueRenderer(context), - EnvironmentTableModel.VALUE); - } - - // create table model - EnvironmentTableModel tableModel = - new EnvironmentTableModel(columnModel); - - table.setModel(tableModel); - table.setColumnModel(columnModel); - initTable(table); - } - -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,47 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.fishing.environment; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.ui.swing.content.operation.fishing.CaracteristicTabUIModel; - -import static org.nuiton.i18n.I18n.n_; - -/** - * @author kmorin - * @since 0.3 - */ -public class EnvironmentTabUIModel extends CaracteristicTabUIModel<EnvironmentRowModel, EnvironmentTabUIModel> { - - private static final long serialVersionUID = 1L; - - public static final String TITLE = - n_("tutti.label.tab.fishingOperation.environment"); - - @Override - public String getTitle() { - return TITLE; - } - -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,62 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.fishing.environment; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; -import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; -import org.jdesktop.swingx.table.TableColumnModelExt; - -import static org.nuiton.i18n.I18n.n_; - -/** - * @author kmorin - * @since 0.3 - */ -public class EnvironmentTableModel extends AbstractTuttiTableModel<EnvironmentRowModel> { - - private static final long serialVersionUID = 1L; - - public static final ColumnIdentifier<EnvironmentRowModel> KEY = ColumnIdentifier.newId( - EnvironmentRowModel.PROPERTY_KEY, - n_("tutti.table.fishing.environment.header.key"), - n_("tutti.table.fishing.environment.header.key")); - - public static final ColumnIdentifier<EnvironmentRowModel> VALUE = ColumnIdentifier.newId( - EnvironmentRowModel.PROPERTY_VALUE, - n_("tutti.table.fishing.environment.header.value"), - n_("tutti.table.fishing.environment.header.value")); - - public EnvironmentTableModel(TableColumnModelExt columnModel) { - super(columnModel, false, false); - setNoneEditableCols(KEY); - } - - @Override - public EnvironmentRowModel createNewRow() { - EnvironmentRowModel result = new EnvironmentRowModel(); - return result; - } - -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingRowModel.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingRowModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,34 +0,0 @@ - -package fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.ui.swing.content.operation.fishing.CaracteristicRowModel; - -/** @author kmorin <kmorin@codelutin.com> */ -public class GearShootingRowModel extends CaracteristicRowModel<GearShootingRowModel> { - - private static final long serialVersionUID = 1L; -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css 2013-03-06 08:11:58 UTC (rev 546) @@ -1,56 +0,0 @@ -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -BeanComboBox { - i18nPrefix: "tutti.property."; -} - -#newRowKey { - showReset: false; - property: selectedCaracteristic; - enabled: {!newRowKey.isEmpty()}; -} - -#addRow { - actionIcon: add; - enabled: {newRowKey.getSelectedItem() != null}; -} - -#gearShootingTable { - selectionMode: {ListSelectionModel.SINGLE_SELECTION}; - selectionBackground: {null}; - selectionForeground: {Color.BLACK}; - sortable: false; -} - -#tablePopup { - label: "tutti.title.batchActions"; -} - -#removeCaracteristicMenu { - text: "tutti.action.removeCaracteristic"; - mnemonic: R; - actionIcon: batch-delete; - enabled: {model.isRemoveCaracteristicEnabled()}; -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.jaxx 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.jaxx 2013-03-06 08:11:58 UTC (rev 546) @@ -1,80 +0,0 @@ -<!-- - #%L - Tutti :: UI - $Id$ - $HeadURL$ - %% - Copyright (C) 2012 Ifremer - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> -<Table - implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<GearShootingTabUIModel, GearShootingTabUIHandler>'> - - <import> - fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI - fr.ifremer.tutti.persistence.entities.referential.Caracteristic - - jaxx.runtime.swing.editor.bean.BeanComboBox - org.jdesktop.swingx.JXTable - javax.swing.ListSelectionModel - java.awt.Color - </import> - - <GearShootingTabUIHandler id='handler' - initializer='getContextValue(GearShootingTabUIHandler.class)'/> - - <GearShootingTabUIModel id='model' - initializer='getContextValue(GearShootingTabUIModel.class)'/> - - <JPopupMenu id='tablePopup'> - <JMenuItem id='removeCaracteristicMenu' - onActionPerformed='handler.removeCaracteristic()'/> - </JPopupMenu> - - <row fill='both'> - <cell fill='both' weightx='1'> - <BeanComboBox id='newRowKey' constructorParams='this' - genericType='Caracteristic'/> - </cell> - <cell fill='both'> - <JButton id='addRow' onActionPerformed='handler.addRow()'/> - </cell> - </row> - <row fill='both' weighty='1'> - <cell fill='both' columns='2'> - <JScrollPane> - <JXTable id='gearShootingTable' - onMouseClicked='handler.autoSelectRowInTable(event, tablePopup)'/> - </JScrollPane> - </cell> - </row> - <script><![CDATA[ - -public GearShootingTabUI(EditFishingOperationUI parentUI) { - JAXXUtil.initContext(this, parentUI); - GearShootingTabUIHandler handler = new GearShootingTabUIHandler(parentUI, this); - setContextValue(handler); - handler.beforeInitUI(); -} - -protected void $afterCompleteSetup() { - handler.afterInitUI(); -} - - ]]></script> - -</Table> \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,164 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.common.base.Preconditions; -import fr.ifremer.tutti.persistence.entities.CaracteristicMap; -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; -import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; -import fr.ifremer.tutti.service.DecoratorService; -import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI; -import fr.ifremer.tutti.ui.swing.content.operation.fishing.CaracteristicTabUIHandler; -import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor; -import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer; -import jaxx.runtime.swing.editor.bean.BeanComboBox; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.JXTable; -import org.jdesktop.swingx.table.DefaultTableColumnModelExt; - -import java.util.List; - -/** - * @author kmorin - * @since 0.3 - */ -public class GearShootingTabUIHandler extends CaracteristicTabUIHandler<GearShootingRowModel, GearShootingTabUIModel, GearShootingTableModel, GearShootingTabUI> { - - private final static Log log = - LogFactory.getLog(GearShootingTabUIHandler.class); - - public GearShootingTabUIHandler(EditFishingOperationUI parentUi, - GearShootingTabUI ui) { - super(parentUi, ui, GearShootingRowModel.PROPERTY_VALUE); - } - - //------------------------------------------------------------------------// - //-- CaracteristicTabUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - protected BeanComboBox<Caracteristic> getKeyCombo() { - return ui.getNewRowKey(); - } - - @Override - protected GearShootingTabUIModel createModel() { - return new GearShootingTabUIModel(); - } - - @Override - protected CaracteristicMap getCaracteristics(FishingOperation operation) { - return operation.getGearShootingCaracteristics(); - } - - @Override - protected List<String> getProtocolPmfmIds(TuttiProtocol protocol) { - return protocol.getGearPmfmId(); - } - - //------------------------------------------------------------------------// - //-- AbstractTuttiTableUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - public JXTable getTable() { - return ui.getGearShootingTable(); - } - - //------------------------------------------------------------------------// - //-- AbstractTuttiUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - public void afterInitUI() { - super.afterInitUI(); - - JXTable table = getTable(); - - // create table column model - DefaultTableColumnModelExt columnModel = - new DefaultTableColumnModelExt(); - - { - - addColumnToModel(columnModel, - null, - newTableCellRender(Caracteristic.class, DecoratorService.CARACTERISTIC_WITH_UNIT), - GearShootingTableModel.KEY); - } - - { - - addColumnToModel(columnModel, - new CaracteristicValueEditor(context), - new CaracteristicValueRenderer(context), - GearShootingTableModel.VALUE); - } - - // create table model - GearShootingTableModel tableModel = - new GearShootingTableModel(columnModel); - - table.setModel(tableModel); - table.setColumnModel(columnModel); - - initTable(table); - } - - //------------------------------------------------------------------------// - //-- Public methods --// - //------------------------------------------------------------------------// - - public void removeCaracteristic() { - int rowIndex = getTable().getSelectedRow(); - - Preconditions.checkState(rowIndex != -1, - "Cant remove caracteristic if no caracteristic selected"); - - GearShootingRowModel row = getTableModel().getEntry(rowIndex); - - CaracteristicMap caracteristicMap = getModel().getCaracteristicMap(); - if (caracteristicMap != null) { - caracteristicMap.remove(row.getKey()); - } - - //add the row in the combo - BeanComboBox keyCombo = ui.getNewRowKey(); - keyCombo.addItem(row.getKey()); - selectFirstInCombo(keyCombo); - - // remove the row from the model - getModel().getRows().remove(rowIndex); - - // refresh all the table - getTableModel().fireTableRowsDeleted(rowIndex, rowIndex); - - getModel().removeRowInError(row); - - } - -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,48 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.ui.swing.content.operation.fishing.CaracteristicTabUIModel; - -import static org.nuiton.i18n.I18n.n_; - - -/** - * @author kmorin - * @since 0.3 - */ -public class GearShootingTabUIModel extends CaracteristicTabUIModel<GearShootingRowModel, GearShootingTabUIModel> { - - private static final long serialVersionUID = 1L; - - public static final String TITLE = - n_("tutti.label.tab.fishingOperation.gearShooting"); - - @Override - public String getTitle() { - return TITLE; - } - -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,62 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; -import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; -import org.jdesktop.swingx.table.TableColumnModelExt; - -import static org.nuiton.i18n.I18n.n_; - -/** - * @author kmorin - * @since 0.3 - */ -public class GearShootingTableModel extends AbstractTuttiTableModel<GearShootingRowModel> { - - private static final long serialVersionUID = 1L; - - public static final ColumnIdentifier<GearShootingRowModel> KEY = ColumnIdentifier.newId( - GearShootingRowModel.PROPERTY_KEY, - n_("tutti.table.fishing.gearShooting.header.key"), - n_("tutti.table.fishing.gearShooting.header.key")); - - public static final ColumnIdentifier<GearShootingRowModel> VALUE = ColumnIdentifier.newId( - GearShootingRowModel.PROPERTY_VALUE, - n_("tutti.table.fishing.gearShooting.header.value"), - n_("tutti.table.fishing.gearShooting.header.value")); - - public GearShootingTableModel(TableColumnModelExt columnModel) { - super(columnModel, false, false); - setNoneEditableCols(KEY); - } - - @Override - public GearShootingRowModel createNewRow() { - GearShootingRowModel result = new GearShootingRowModel(); - return result; - } - -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,96 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.ui.swing.content.operation.fishing.CaracteristicRowModel; - -/** - * @author kmorin - * @since 0.3 - */ -public class HydrologyRowModel extends CaracteristicRowModel<HydrologyRowModel> { - - private static final long serialVersionUID = 1L; -// -// public static final String PROPERTY_GEAR_SHOOTING_START_VALUE = "gearShootingStartValue"; -// -// public static final String PROPERTY_GEAR_SHOOTING_END_VALUE = "gearShootingEndValue"; -// -// public static final String PROPERTY_AVERAGE_VALUE = "averageValue"; -// -// protected Serializable gearShootingStartValue; -// -// protected Serializable gearShootingEndValue; -// -// protected Serializable averageValue; - -// public HydrologyRowModel() { -// super(); -// } -// -// public HydrologyRowModel(Caracteristic key) { -// this(key, null, null, null); -// } -// -// public HydrologyRowModel(Caracteristic key, Serializable gearShootingStartValue, -// Serializable gearShootingEndValue, Serializable averageValue) { -// this(); -// this.key = key; -// this.gearShootingStartValue = gearShootingStartValue; -// this.gearShootingEndValue = gearShootingEndValue; -// this.averageValue = averageValue; -// } -// -// public Serializable getGearShootingStartValue() { -// return gearShootingStartValue; -// } -// -// public void setGearShootingStartValue(Serializable gearShootingStartValue) { -// Object oldValue = getGearShootingStartValue(); -// this.gearShootingStartValue = gearShootingStartValue; -// firePropertyChange(PROPERTY_GEAR_SHOOTING_START_VALUE, oldValue, gearShootingStartValue); -// } -// -// public Serializable getGearShootingEndValue() { -// return gearShootingEndValue; -// } -// -// public void setGearShootingEndValue(Serializable gearShootingEndValue) { -// Object oldValue = getGearShootingEndValue(); -// this.gearShootingEndValue = gearShootingEndValue; -// firePropertyChange(PROPERTY_GEAR_SHOOTING_END_VALUE, oldValue, gearShootingEndValue); -// } -// -// public Serializable getAverageValue() { -// return averageValue; -// } -// -// public void setAverageValue(Serializable averageValue) { -// Object oldValue = getAverageValue(); -// this.averageValue = averageValue; -// firePropertyChange(PROPERTY_AVERAGE_VALUE, oldValue, averageValue); -// } - -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css 2013-03-06 08:11:58 UTC (rev 546) @@ -1,56 +0,0 @@ -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -BeanComboBox { - i18nPrefix: "tutti.property."; -} - -#newRowKey { - showReset: false; - property: selectedCaracteristic; - enabled: {!newRowKey.isEmpty()}; -} - -#addRow { - actionIcon: add; - enabled: {newRowKey.getSelectedItem() != null}; -} - -#hydrologyTable { - selectionMode: {ListSelectionModel.SINGLE_SELECTION}; - selectionBackground: {null}; - selectionForeground: {Color.BLACK}; - sortable: false; -} - -#tablePopup { - label: "tutti.title.batchActions"; -} - -#removeCaracteristicMenu { - text: "tutti.action.removeCaracteristic"; - mnemonic: R; - actionIcon: batch-delete; - enabled: {model.isRemoveCaracteristicEnabled()}; -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx 2013-03-06 08:11:58 UTC (rev 546) @@ -1,80 +0,0 @@ -<!-- - #%L - Tutti :: UI - $Id$ - $HeadURL$ - %% - Copyright (C) 2012 Ifremer - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> -<Table - implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<HydrologyTabUIModel, HydrologyTabUIHandler>'> - - <import> - fr.ifremer.tutti.persistence.entities.referential.Caracteristic - - fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI - - jaxx.runtime.swing.editor.bean.BeanComboBox - - org.jdesktop.swingx.JXTable - - javax.swing.ListSelectionModel - java.awt.Color - </import> - - <HydrologyTabUIHandler id='handler' - initializer='getContextValue(HydrologyTabUIHandler.class)'/> - - <HydrologyTabUIModel id='model' - initializer='getContextValue(HydrologyTabUIModel.class)'/> - <JPopupMenu id='tablePopup'> - <JMenuItem id='removeCaracteristicMenu' - onActionPerformed='handler.removeCaracteristic()'/> - </JPopupMenu> - - <row fill='both'> - <cell fill='both' weightx='1'> - <BeanComboBox id='newRowKey' constructorParams='this' - genericType='Caracteristic'/> - </cell> - <cell fill='both'> - <JButton id='addRow' onActionPerformed='handler.addRow()'/> - </cell> - </row> - <row fill='both' weighty='1'> - <cell fill='both' columns='2'> - <JScrollPane> - <JXTable id='hydrologyTable' - onMouseClicked='handler.autoSelectRowInTable(event, tablePopup)'/> - </JScrollPane> - </cell> - </row> - <script><![CDATA[ - -public HydrologyTabUI(EditFishingOperationUI parentUI) { - JAXXUtil.initContext(this, parentUI); - HydrologyTabUIHandler handler = new HydrologyTabUIHandler(parentUI, this); - setContextValue(handler); - handler.beforeInitUI(); -} - -protected void $afterCompleteSetup() { - handler.afterInitUI(); -} - ]]></script> -</Table> \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,345 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.common.base.Preconditions; -import fr.ifremer.tutti.persistence.entities.CaracteristicMap; -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; -import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; -import fr.ifremer.tutti.service.DecoratorService; -import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI; -import fr.ifremer.tutti.ui.swing.content.operation.fishing.CaracteristicTabUIHandler; -import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor; -import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer; -import jaxx.runtime.swing.editor.bean.BeanComboBox; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.JXTable; -import org.jdesktop.swingx.table.DefaultTableColumnModelExt; - -import java.util.List; - -/** - * @author kmorin - * @since 0.3 - */ -public class HydrologyTabUIHandler extends CaracteristicTabUIHandler<HydrologyRowModel, HydrologyTabUIModel, HydrologyTableModel, HydrologyTabUI> { - - private final static Log log = - LogFactory.getLog(HydrologyTabUIHandler.class); - -// protected Map<Caracteristic, Map<Type, Caracteristic>> availableGlobalCaracteristics; - - public HydrologyTabUIHandler(EditFishingOperationUI parentUi, - HydrologyTabUI ui) { - super(parentUi, ui, - HydrologyRowModel.PROPERTY_VALUE -// HydrologyRowModel.PROPERTY_GEAR_SHOOTING_START_VALUE, -// HydrologyRowModel.PROPERTY_AVERAGE_VALUE, -// HydrologyRowModel.PROPERTY_GEAR_SHOOTING_END_VALUE - ); - } - - - //------------------------------------------------------------------------// - //-- CaracteristicTabUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - protected BeanComboBox<Caracteristic> getKeyCombo() { - return ui.getNewRowKey(); - } - - @Override - protected HydrologyTabUIModel createModel() { - return new HydrologyTabUIModel(); - } - - @Override - protected CaracteristicMap getCaracteristics(FishingOperation operation) { - return operation.getHydrologyCaracteristics(); - } - - @Override - protected List<String> getProtocolPmfmIds(TuttiProtocol protocol) { - return protocol.getHydrologyPmfmId(); - } - - //------------------------------------------------------------------------// - //-- AbstractTuttiTableUIHandler methods --// - //------------------------------------------------------------------------// - - @Override - public JXTable getTable() { - return ui.getHydrologyTable(); - } - -// @Override -// protected boolean isRowValid(HydrologyRowModel row) { -// //TODO -// return row.getGearShootingStartValue() != null || -// row.getGearShootingEndValue() != null || -// row.getAverageValue() != null; -// } - - //------------------------------------------------------------------------// - //-- AbstractTuttiUIHandler methods --// - //------------------------------------------------------------------------// - -// @Override -// public void beforeInitUI() { -// HydrologyTabUIModel model = new HydrologyTabUIModel(); -// ui.setContextValue(model); -// -// model.addPropertyChangeListener(HydrologyTabUIModel.PROPERTY_AVAILABLE_CARACTERISTICS, new PropertyChangeListener() { -// -// public void propertyChange(PropertyChangeEvent evt) { -// List<Caracteristic> hydrologyPmfm = (List<Caracteristic>) evt.getNewValue(); -// availableGlobalCaracteristics = Maps.newHashMap(); -// if (hydrologyPmfm != null) { -// for (Caracteristic caracteristic : hydrologyPmfm) { -// String name = HydrologicCaracteristicUtil.getGlobalName(caracteristic.getName()); -// Caracteristic globalCaracteristic = HydrologicCaracteristicUtil.createGlobalCaracteristic(name, caracteristic); -// Map<Type, Caracteristic> values = availableGlobalCaracteristics.get(globalCaracteristic); -// if (values == null) { -// values = Maps.newHashMap(); -// availableGlobalCaracteristics.put(globalCaracteristic, values); -// } -// Type type = HydrologicCaracteristicUtil.getTypeOfCaracteristic(caracteristic); -// values.put(type, caracteristic); -// } -// } -// } -// }); -// } - - @Override - public void afterInitUI() { - super.afterInitUI(); - - JXTable table = getTable(); - - // create table column model - DefaultTableColumnModelExt columnModel = - new DefaultTableColumnModelExt(); - - { - - addColumnToModel(columnModel, - null, - newTableCellRender(Caracteristic.class, DecoratorService.CARACTERISTIC_WITH_UNIT), - HydrologyTableModel.KEY); - } - - { - addColumnToModel(columnModel, - new CaracteristicValueEditor(context), - new CaracteristicValueRenderer(context), - HydrologyTableModel.VALUE); - } - -// { -// -// addColumnToModel(columnModel, -// new CaracteristicValueEditor(context), -// new CaracteristicValueRenderer(context), -// HydrologyTableModel.GEAR_SHOOTING_START_VALUE); -// } -// -// { -// -// addColumnToModel(columnModel, -// new CaracteristicValueEditor(context), -// new CaracteristicValueRenderer(context), -// HydrologyTableModel.GEAR_SHOOTING_END_VALUE); -// } -// -// { -// -// addColumnToModel(columnModel, -// new CaracteristicValueEditor(context), -// new CaracteristicValueRenderer(context), -// HydrologyTableModel.AVERAGE_VALUE); -// } - - // create table model - HydrologyTableModel tableModel = - new HydrologyTableModel(columnModel); - - table.setModel(tableModel); - table.setColumnModel(columnModel); - initTable(table); - } - - //------------------------------------------------------------------------// - //-- Public methods --// - //------------------------------------------------------------------------// - -// @Override -// public void reset(FishingOperation fishingOperation) { -// HydrologyTableModel tableModel = getTableModel(); -// HydrologyTabUIModel model = getModel(); -// -// CaracteristicMap hydrologyCaracteristics = fishingOperation.getHydrologyCaracteristics(); -// if (hydrologyCaracteristics == null) { -// hydrologyCaracteristics = new CaracteristicMap(); -// } -// model.setCaracteristicMap(hydrologyCaracteristics); -// -// TuttiProtocol protocol = TuttiUIUtil.getProtocol(ui); -// List<String> gearPmfmIds = Lists.newArrayList(); -// if (protocol != null) { -// List<String> protocolHydrologyPmfmId = protocol.getHydrologyPmfmId(); -// if (protocolHydrologyPmfmId != null) { -// gearPmfmIds.addAll(protocolHydrologyPmfmId); -// } -// } -// -// List<HydrologyRowModel> rows = Lists.newArrayList(); -// List<Caracteristic> caracteristicList = Lists.newArrayList(); -// List<Caracteristic> selectedCaracteristics = Lists.newArrayList(hydrologyCaracteristics.keySet()); -// -// List<Caracteristic> availableCaracteristics = model.getAvailableCaracteristics(); -// for (String id : gearPmfmIds) { -// Caracteristic caracteristic = TuttiEntities.findById(availableCaracteristics, id); -// if (!selectedCaracteristics.contains(caracteristic)) { -// selectedCaracteristics.add(caracteristic); -// } -// } -// -// Set<Caracteristic> globalCaracteristics = availableGlobalCaracteristics.keySet(); -// -// for (Caracteristic availableCaracteristic : globalCaracteristics) { -// Map<Type, Caracteristic> caracteristics = availableGlobalCaracteristics.get(availableCaracteristic); -// -// //should add the global caracteristic to the combo or to the table? -// boolean selectedCaracteristic = false; -// for (Caracteristic caracteristic : caracteristics.values()) { -// selectedCaracteristic |= selectedCaracteristics.contains(caracteristic); -// } -// -// if (selectedCaracteristic) { -// HydrologyRowModel row = tableModel.createNewRow(); -// row.setKey(availableCaracteristic); -// row.setGearShootingStartValue(hydrologyCaracteristics.get(caracteristics.get(Type.START))); -// row.setGearShootingEndValue(hydrologyCaracteristics.get(caracteristics.get(Type.END))); -// row.setAverageValue(hydrologyCaracteristics.get(caracteristics.get(Type.AVERAGE))); -// rows.add(row); -// -// } else { -// caracteristicList.add(availableCaracteristic); -// } -// } -// -// model.setRows(rows); -// -// ui.getNewRowKey().setData(caracteristicList); -// selectFirstInCombo(ui.getNewRowKey()); -// model.setModify(false); -// } - - @Override - public void removeCaracteristic() { - int rowIndex = getTable().getSelectedRow(); - - Preconditions.checkState(rowIndex != -1, - "Cant remove caracteristic if no caracteristic selected"); - - HydrologyRowModel row = getTableModel().getEntry(rowIndex); - - CaracteristicMap caracteristicMap = getModel().getCaracteristicMap(); - if (caracteristicMap != null) { - caracteristicMap.remove(row.getKey()); - } - - //add the row in the combo - BeanComboBox keyCombo = ui.getNewRowKey(); - keyCombo.addItem(row.getKey()); - selectFirstInCombo(keyCombo); - - // remove the row from the model - getModel().getRows().remove(rowIndex); - - // refresh all the table - getTableModel().fireTableRowsDeleted(rowIndex, rowIndex); - - getModel().removeRowInError(row); - -// Map<Type, Caracteristic> caracteristics = availableGlobalCaracteristics.get(row.getKey()); -// for (Type type : caracteristics.keySet()) { -// Caracteristic caracteristic = caracteristics.get(type); -// -// CaracteristicMap caracteristicMap = getModel().getCaracteristicMap(); -// if (caracteristicMap != null) { -// caracteristicMap.remove(caracteristic); -// } -// } -// -// //add the row in the combo -// BeanComboBox keyCombo = ui.getNewRowKey(); -// keyCombo.addItem(row.getKey()); -// selectFirstInCombo(keyCombo); -// -// // remove the row from the model -// getModel().getRows().remove(rowIndex); -// -// // refresh all the table -// getTableModel().fireTableRowsDeleted(rowIndex, rowIndex); -// -// getModel().removeRowInError(row); - } - - //------------------------------------------------------------------------// - //-- Protected methods --// - //------------------------------------------------------------------------// - -// @Override -// protected void saveRow(HydrologyRowModel row) { -// if (row.isValid()) { -// CaracteristicMap caracteristicMap = getModel().getCaracteristicMap(); -// Preconditions.checkNotNull(caracteristicMap); -// -// Map<Type, Caracteristic> caracteristics = availableGlobalCaracteristics.get(row.getKey()); -// CaracteristicMap map = new CaracteristicMap(); -// for (Type type : caracteristics.keySet()) { -// Serializable value = null; -// switch (type) { -// case START: -// value = row.getGearShootingStartValue(); -// break; -// case END: -// value = row.getGearShootingEndValue(); -// break; -// case AVERAGE: -// value = row.getAverageValue(); -// } -// map.put(caracteristics.get(type), value); -// } -// caracteristicMap.putAll(map); -// } -// } - -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,47 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.ui.swing.content.operation.fishing.CaracteristicTabUIModel; - -import static org.nuiton.i18n.I18n.n_; - - -/** - * @author kmorin - * @since 0.3 - */ -public class HydrologyTabUIModel extends CaracteristicTabUIModel<HydrologyRowModel, HydrologyTabUIModel> { - - private static final long serialVersionUID = 1L; - - public static final String TITLE = - n_("tutti.label.tab.fishingOperation.hydrology"); - - @Override - public String getTitle() { - return TITLE; - } -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -1,77 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; -import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; -import org.jdesktop.swingx.table.TableColumnModelExt; - -import static org.nuiton.i18n.I18n.n_; - -/** - * @author kmorin - * @since 0.3 - */ -public class HydrologyTableModel extends AbstractTuttiTableModel<HydrologyRowModel> { - - private static final long serialVersionUID = 1L; - - public static final ColumnIdentifier<HydrologyRowModel> KEY = ColumnIdentifier.newId( - HydrologyRowModel.PROPERTY_KEY, - n_("tutti.table.fishing.hydrology.header.key"), - n_("tutti.table.fishing.hydrology.header.key")); - - public static final ColumnIdentifier<HydrologyRowModel> VALUE = ColumnIdentifier.newId( - HydrologyRowModel.PROPERTY_VALUE, - n_("tutti.table.fishing.hydrology.header.value"), - n_("tutti.table.fishing.hydrology.header.value")); - -// public static final ColumnIdentifier<HydrologyRowModel> GEAR_SHOOTING_START_VALUE = ColumnIdentifier.newId( -// HydrologyRowModel.PROPERTY_GEAR_SHOOTING_START_VALUE, -// n_("tutti.table.fishing.hydrology.header.gearShootingStartValue"), -// n_("tutti.table.fishing.hydrology.header.gearShootingStartValue")); -// -// public static final ColumnIdentifier<HydrologyRowModel> GEAR_SHOOTING_END_VALUE = ColumnIdentifier.newId( -// HydrologyRowModel.PROPERTY_GEAR_SHOOTING_END_VALUE, -// n_("tutti.table.fishing.hydrology.header.gearShootingEndValue"), -// n_("tutti.table.fishing.hydrology.header.gearShootingEndValue")); -// -// public static final ColumnIdentifier<HydrologyRowModel> AVERAGE_VALUE = ColumnIdentifier.newId( -// HydrologyRowModel.PROPERTY_AVERAGE_VALUE, -// n_("tutti.table.fishing.hydrology.header.averageValue"), -// n_("tutti.table.fishing.hydrology.header.averageValue")); - - public HydrologyTableModel(TableColumnModelExt columnModel) { - super(columnModel, false, false); - setNoneEditableCols(KEY); - } - - @Override - public HydrologyRowModel createNewRow() { - HydrologyRowModel result = new HydrologyRowModel(); - return result; - } - -} Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/AddSpeciesProtocolAction.java 2013-03-06 08:11:58 UTC (rev 546) @@ -55,8 +55,6 @@ EditProtocolUI ui = getUI(); - EditProtocolUIHandler handler = getHandler(); - EditProtocolSpeciesTableModel tableModel = handler.getTableModel(); Species species = (Species) ui.getSpeciesComboBox().getSelectedItem(); Preconditions.checkNotNull( Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -46,7 +46,6 @@ n_("tutti.table.protocol.species.header.speciesSurveyCode"), n_("tutti.table.protocol.species.header.speciesSurveyCode.tip")); - public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SIZE_ENABLED = ColumnIdentifier.newId( EditProtocolSpeciesRowModel.PROPERTY_SIZE_ENABLED, n_("tutti.table.protocol.species.header.size"), @@ -87,7 +86,6 @@ n_("tutti.table.protocol.species.header.calcifySample"), n_("tutti.table.protocol.species.header.calcifySample.tip")); - private static final long serialVersionUID = 1L; public EditProtocolSpeciesTableModel(TableColumnModelExt columnModel) { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-03-06 08:11:58 UTC (rev 546) @@ -129,21 +129,16 @@ _tuttiAction: {ExportAllCaracteristicAction.class}; } -#gearList { - property: gearPmfm; +#gearUseFeatureList { + property: gearUseFeaturePmfm; beanType: {Caracteristic.class}; } -#environmentList { - property: environmentPmfm; +#vesselUseFeatureList { + property: vesselUseFeaturePmfm; beanType: {Caracteristic.class}; } -#hydrologyList { - property: hydrologyPmfm; - beanType: {Caracteristic.class}; -} - #lengthClassesList { property: lengthClassesPmfm; beanType: {Caracteristic.class}; Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2013-03-06 08:11:58 UTC (rev 546) @@ -121,15 +121,12 @@ <tab title='tutti.label.tab.protocol.caracteristic.lengthClasses'> <BeanDoubleList id='lengthClassesList' genericType='Caracteristic'/> </tab> - <tab title='tutti.label.tab.protocol.caracteristic.gear'> - <BeanDoubleList id='gearList' genericType='Caracteristic'/> + <tab title='tutti.label.tab.protocol.caracteristic.gearUseFeature'> + <BeanDoubleList id='gearUseFeatureList' genericType='Caracteristic'/> </tab> - <tab title='tutti.label.tab.protocol.caracteristic.environment'> - <BeanDoubleList id='environmentList' genericType='Caracteristic'/> + <tab title='tutti.label.tab.protocol.caracteristic.vesselUseFeature'> + <BeanDoubleList id='vesselUseFeatureList' genericType='Caracteristic'/> </tab> - <tab title='tutti.label.tab.protocol.caracteristic.hydrology'> - <BeanDoubleList id='hydrologyList' genericType='Caracteristic'/> - </tab> </JTabbedPane> </JPanel> </tab> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-03-06 08:11:58 UTC (rev 546) @@ -304,21 +304,16 @@ Lists.newArrayList(model.getCaracteristics()), model.getLengthClassesPmfmId()); - initDoubleList(EditProtocolUIModel.PROPERTY_GEAR_PMFM_ID, - ui.getGearList(), + initDoubleList(EditProtocolUIModel.PROPERTY_GEAR_USE_FEATURE_PMFM_ID, + ui.getGearUseFeatureList(), Lists.newArrayList(model.getCaracteristics()), - model.getGearPmfmId()); + model.getGearUseFeaturePmfmId()); - initDoubleList(EditProtocolUIModel.PROPERTY_ENVIRONMENT_PMFM_ID, - ui.getEnvironmentList(), + initDoubleList(EditProtocolUIModel.PROPERTY_VESSEL_USE_FEATURE_PMFM_ID, + ui.getVesselUseFeatureList(), Lists.newArrayList(model.getCaracteristics()), - model.getEnvironmentPmfmId()); + model.getVesselUseFeaturePmfmId()); - initDoubleList(EditProtocolUIModel.PROPERTY_HYDROLOGY_PMFM_ID, - ui.getHydrologyList(), - Lists.newArrayList(model.getCaracteristics()), - model.getHydrologyPmfmId()); - // if new protocol can already cancel his creation model.setModify(model.isCreate()); @@ -405,17 +400,13 @@ updateListener = (UpdateSelectedList) ui.getLengthClassesList().getClientProperty("_updateListener"); model.addPropertyChangeListener(id, updateListener); - id = (String) ui.getEnvironmentList().getClientProperty("_updateListenerId"); - updateListener = (UpdateSelectedList) ui.getEnvironmentList().getClientProperty("_updateListener"); + id = (String) ui.getVesselUseFeatureList().getClientProperty("_updateListenerId"); + updateListener = (UpdateSelectedList) ui.getVesselUseFeatureList().getClientProperty("_updateListener"); model.addPropertyChangeListener(id, updateListener); - id = (String) ui.getGearList().getClientProperty("_updateListenerId"); - updateListener = (UpdateSelectedList) ui.getGearList().getClientProperty("_updateListener"); + id = (String) ui.getGearUseFeatureList().getClientProperty("_updateListenerId"); + updateListener = (UpdateSelectedList) ui.getGearUseFeatureList().getClientProperty("_updateListener"); model.addPropertyChangeListener(id, updateListener); - - id = (String) ui.getHydrologyList().getClientProperty("_updateListenerId"); - updateListener = (UpdateSelectedList) ui.getHydrologyList().getClientProperty("_updateListener"); - model.addPropertyChangeListener(id, updateListener); } public void removeDoubleListListeners() { @@ -428,17 +419,13 @@ model.removePropertyChangeListener(id, updateListener); - id = (String) ui.getEnvironmentList().getClientProperty("_updateListenerId"); - updateListener = (UpdateSelectedList) ui.getEnvironmentList().getClientProperty("_updateListener"); + id = (String) ui.getVesselUseFeatureList().getClientProperty("_updateListenerId"); + updateListener = (UpdateSelectedList) ui.getVesselUseFeatureList().getClientProperty("_updateListener"); model.removePropertyChangeListener(id, updateListener); - id = (String) ui.getGearList().getClientProperty("_updateListenerId"); - updateListener = (UpdateSelectedList) ui.getGearList().getClientProperty("_updateListener"); + id = (String) ui.getGearUseFeatureList().getClientProperty("_updateListenerId"); + updateListener = (UpdateSelectedList) ui.getGearUseFeatureList().getClientProperty("_updateListener"); model.removePropertyChangeListener(id, updateListener); - - id = (String) ui.getHydrologyList().getClientProperty("_updateListenerId"); - updateListener = (UpdateSelectedList) ui.getHydrologyList().getClientProperty("_updateListener"); - model.removePropertyChangeListener(id, updateListener); } public Species openSelectOtherSpeciesDialog(String title, List<Species> species) { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -52,12 +52,10 @@ public static final String PROPERTY_LENGTH_CLASSES_PMFM_ID = "lengthClassesPmfmId"; - public static final String PROPERTY_GEAR_PMFM_ID = "gearPmfmId"; + public static final String PROPERTY_GEAR_USE_FEATURE_PMFM_ID = "gearUseFeaturePmfmId"; - public static final String PROPERTY_ENVIRONMENT_PMFM_ID = "environmentPmfmId"; + public static final String PROPERTY_VESSEL_USE_FEATURE_PMFM_ID = "vesselUseFeaturePmfmId"; - public static final String PROPERTY_HYDROLOGY_PMFM_ID = "hydrologyPmfmId"; - public static final String PROPERTY_REMOVE_SPECIES_ENABLED = "removeSpeciesEnabled"; public static final String PROPERTY_IMPORTED = "imported"; @@ -70,12 +68,10 @@ protected List<String> lengthClassesPmfmId; - protected List<String> gearPmfmId; + protected List<String> gearUseFeaturePmfmId; - protected List<String> environmentPmfmId; + protected List<String> vesselUseFeaturePmfmId; - protected List<String> hydrologyPmfmId; - /** * Flag when a incoming protocol is imported. * @@ -157,51 +153,36 @@ setLengthClassesPmfmId(ids); } - public List<String> getGearPmfmId() { - return gearPmfmId; + public List<String> getGearUseFeaturePmfmId() { + return gearUseFeaturePmfmId; } - public void setGearPmfmId(List<String> gearPmfmId) { - Object oldValue = getGearPmfmId(); - this.gearPmfmId = gearPmfmId; - firePropertyChange(PROPERTY_GEAR_PMFM_ID, oldValue, gearPmfmId); + public void setGearUseFeaturePmfmId(List<String> gearUseFeaturePmfmId) { + Object oldValue = getGearUseFeaturePmfmId(); + this.gearUseFeaturePmfmId = gearUseFeaturePmfmId; + firePropertyChange(PROPERTY_GEAR_USE_FEATURE_PMFM_ID, oldValue, gearUseFeaturePmfmId); } - public void setGearPmfm(List<Caracteristic> gearPmfm) { - List<String> ids = TuttiEntities.collecIds(gearPmfm); - setGearPmfmId(ids); + public void setGearUseFeaturePmfm(List<Caracteristic> gearUseFeaturePmfm) { + List<String> ids = TuttiEntities.collecIds(gearUseFeaturePmfm); + setGearUseFeaturePmfmId(ids); } - public List<String> getEnvironmentPmfmId() { - return environmentPmfmId; + public List<String> getVesselUseFeaturePmfmId() { + return vesselUseFeaturePmfmId; } - public void setEnvironmentPmfmId(List<String> environmentPmfmId) { - Object oldValue = getEnvironmentPmfmId(); - this.environmentPmfmId = environmentPmfmId; - firePropertyChange(PROPERTY_ENVIRONMENT_PMFM_ID, oldValue, environmentPmfmId); + public void setVesselUseFeaturePmfmId(List<String> vesselUseFeaturePmfmId) { + Object oldValue = getVesselUseFeaturePmfmId(); + this.vesselUseFeaturePmfmId = vesselUseFeaturePmfmId; + firePropertyChange(PROPERTY_VESSEL_USE_FEATURE_PMFM_ID, oldValue, vesselUseFeaturePmfmId); } - public void setEnvironmentPmfm(List<Caracteristic> environmentPmfm) { - List<String> ids = TuttiEntities.collecIds(environmentPmfm); - setEnvironmentPmfmId(ids); + public void setVesselUseFeaturePmfm(List<Caracteristic> vesselUseFeaturePmfm) { + List<String> ids = TuttiEntities.collecIds(vesselUseFeaturePmfm); + setVesselUseFeaturePmfmId(ids); } - public List<String> getHydrologyPmfmId() { - return hydrologyPmfmId; - } - - public void setHydrologyPmfmId(List<String> hydrologyPmfmId) { - Object oldValue = getHydrologyPmfmId(); - this.hydrologyPmfmId = hydrologyPmfmId; - firePropertyChange(PROPERTY_HYDROLOGY_PMFM_ID, oldValue, hydrologyPmfmId); - } - - public void setHydrologyPmfm(List<Caracteristic> hydrologyPmfm) { - List<String> ids = TuttiEntities.collecIds(hydrologyPmfm); - setHydrologyPmfmId(ids); - } - public boolean isRemoveSpeciesEnabled() { return removeSpeciesEnabled; } 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-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java 2013-03-06 08:11:58 UTC (rev 546) @@ -82,8 +82,8 @@ @Override protected void releaseAction() { + file = null; super.releaseAction(); - file = null; } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java 2013-03-06 08:11:58 UTC (rev 546) @@ -85,8 +85,8 @@ @Override protected void releaseAction() { + file = null; super.releaseAction(); - file = null; } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/RemoveSpeciesProtocolAction.java 2013-03-06 08:11:58 UTC (rev 546) @@ -26,13 +26,13 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.service.DecoratorService; import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction; import jaxx.runtime.swing.editor.bean.BeanComboBox; import java.util.Collections; -import java.util.Comparator; import java.util.List; import static org.nuiton.i18n.I18n._; @@ -57,7 +57,6 @@ @Override protected void doAction() { - EditProtocolUIHandler handler = getHandler(); int rowIndex = handler.getTable().getSelectedRow(); Preconditions.checkState(rowIndex != -1, @@ -81,20 +80,8 @@ model.getAllSynonyms().addAll(allSynonyms); // reorder the list by name, otherwise, // all the species without a reftax code will be at the end - Collections.sort(model.getAllSynonyms(), new Comparator<Species>() { + Collections.sort(model.getAllSynonyms(), TuttiEntities.SPECIES_BY_NAME_COMPARATOR); - public int compare(Species o1, Species o2) { - if (o1 == null) { - return -1; - } - if (o2 == null) { - return 1; - } - return o1.getName().compareTo(o2.getName()); - } - - }); - // remove the row from the model(do it after treating the comboBox which can be long) tableModel.removeRow(rowIndex); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SaveProtocolAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SaveProtocolAction.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SaveProtocolAction.java 2013-03-06 08:11:58 UTC (rev 546) @@ -67,7 +67,7 @@ protected void doAction() { EditProtocolUIModel model = getModel(); TuttiUIContext context = getContext(); - EditProtocolUIHandler handler = getHandler(); + PersistenceService persistenceService = context.getPersistenceService(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherSpeciesAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherSpeciesAction.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/SelectOtherSpeciesAction.java 2013-03-06 08:11:58 UTC (rev 546) @@ -73,6 +73,12 @@ } @Override + protected void releaseAction() { + selectedSpecies = null; + super.releaseAction(); + } + + @Override protected void doAction() { String decoratedSynonym = decorate(selectedSpecies); String taxonId = String.valueOf(selectedSpecies.getReferenceTaxonId()); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIModel.java 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIModel.java 2013-03-06 08:11:58 UTC (rev 546) @@ -26,7 +26,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentRowModel; +import fr.ifremer.tutti.ui.swing.content.operation.fishing.VesselUseFeatureRowModel; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; @@ -67,7 +67,7 @@ @Override public void propertyChange(PropertyChangeEvent evt) { - Set<EnvironmentRowModel> rowsInErorr = (Set<EnvironmentRowModel>) evt.getNewValue(); + Set<VesselUseFeatureRowModel> rowsInErorr = (Set<VesselUseFeatureRowModel>) evt.getNewValue(); if (log.isDebugEnabled()) { log.debug(PROPERTY_ROWS_IN_ERROR + " changed " + rowsInErorr.size()); } Modified: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-error-validation.xml =================================================================== --- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-error-validation.xml 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel-validate-error-validation.xml 2013-03-06 08:11:58 UTC (rev 546) @@ -668,7 +668,7 @@ </field> - <field name="saisisseur"> + <field name="recorderPerson"> <field-validator type="fieldexpression" short-circuit="true"> <param name="expression"> Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-03-05 18:10:53 UTC (rev 545) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-03-06 08:11:58 UTC (rev 546) @@ -321,7 +321,7 @@ tutti.label.list.gear=Engin(s) tutti.label.list.headOfMission=Chef(s) de mission tutti.label.list.headOfSortRoom=Reponsable(s) de salle de tri -tutti.label.list.saisisseur=Saisisseur(s) +tutti.label.list.recorderPerson=Saisisseur(s) tutti.label.list.vessel=Navire(s) tutti.label.no.fishingOperation.selected=< Aucun trait sélectionné > tutti.label.program=Série de campagne @@ -344,20 +344,19 @@ tutti.label.tab.catches=Captures tutti.label.tab.catchesCaracteristics=Résumé tutti.label.tab.fishingOperation=Trait -tutti.label.tab.fishingOperation.environment=Environnement -tutti.label.tab.fishingOperation.gearShooting=Mise en oeuvre de l'engin +tutti.label.tab.fishingOperation.gearUseFeature=Mise en oeuvre de l'engin tutti.label.tab.fishingOperation.general=Trait tutti.label.tab.fishingOperation.hydrology=Paramètres hydrologiques +tutti.label.tab.fishingOperation.vesselUseFeature=Autres caractéristiques tutti.label.tab.macroDechet=Macro déchets tutti.label.tab.observationIndividuel=Observations individuelles tutti.label.tab.plancton=Plancton tutti.label.tab.protocol.accidental=Accidental tutti.label.tab.protocol.benthos=Benthos tutti.label.tab.protocol.caracteristic=Caractéristiques -tutti.label.tab.protocol.caracteristic.environment=Environnement -tutti.label.tab.protocol.caracteristic.gear=Mise en oeuvre de l'engin -tutti.label.tab.protocol.caracteristic.hydrology=Paramètres hydrologiques +tutti.label.tab.protocol.caracteristic.gearUseFeature=Mise en oeuvre de l'engin tutti.label.tab.protocol.caracteristic.lengthClasses=Classes de taille +tutti.label.tab.protocol.caracteristic.vesselUseFeature=Mise en oeuvre du navire tutti.label.tab.protocol.info=Informations générales tutti.label.tab.protocol.plankton=Plancton tutti.label.tab.protocol.species=Espèces @@ -422,15 +421,15 @@ tutti.table.benthos.batch.header.speciesByGenusCode=Espèce tutti.table.benthos.batch.header.toConfirm=A Confirmer tutti.table.benthos.batch.header.weight=Poids -tutti.table.fishing.environment.header.key=Caractéristique -tutti.table.fishing.environment.header.value=Valeur -tutti.table.fishing.gearShooting.header.key=Caractéristique -tutti.table.fishing.gearShooting.header.value=Valeur +tutti.table.fishing.gearUseFeature.header.key=Caractéristique +tutti.table.fishing.gearUseFeature.header.value=Valeur tutti.table.fishing.hydrology.header.averageValue=Moyenne tutti.table.fishing.hydrology.header.gearShootingEndValue=Fin de traîne tutti.table.fishing.hydrology.header.gearShootingStartValue=Début de traîne tutti.table.fishing.hydrology.header.key=Caractéristique tutti.table.fishing.hydrology.header.value=Valeur +tutti.table.fishing.vesselUseFeature.header.key=Caractéristique +tutti.table.fishing.vesselUseFeature.header.value=Valeur tutti.table.macrowaste.batch.header.comment=Commentaire tutti.table.macrowaste.batch.header.file=Pièces jointes tutti.table.macrowaste.batch.header.macroWasteCategory=Catégorie
participants (1)
-
tchemit@users.forge.codelutin.com