Sammoa-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- 446 discussions
r345 - trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map
by tchemit@users.forge.codelutin.com 02 Aug '12
by tchemit@users.forge.codelutin.com 02 Aug '12
02 Aug '12
Author: tchemit
Date: 2012-08-02 15:17:22 +0200 (Thu, 02 Aug 2012)
New Revision: 345
Url: http://forge.codelutin.com/repositories/revision/sammoa/345
Log:
add export GeoPoints method
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapService.java
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java 2012-08-02 13:15:58 UTC (rev 344)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java 2012-08-02 13:17:22 UTC (rev 345)
@@ -60,6 +60,7 @@
protected List<StringRef> speciesTypes;
protected File exportDirectory;
+
protected String exportFilename;
public File getExportDirectory() {
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapService.java 2012-08-02 13:15:58 UTC (rev 344)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapService.java 2012-08-02 13:17:22 UTC (rev 345)
@@ -6,8 +6,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-
/**
* Export map service
*
@@ -38,4 +36,10 @@
public void exportObservationsMap(ExportMapModel dataModel) {
}
+
+ public void exportGeoPointsMap(ExportMapModel dataModel) {
+
+ }
+
+
}
1
0
r344 - in trunk: . sammoa-application/src/main/resources/i18n sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing sammoa-ui-swing/src/main/resources/i18n
by tchemit@users.forge.codelutin.com 02 Aug '12
by tchemit@users.forge.codelutin.com 02 Aug '12
02 Aug '12
Author: tchemit
Date: 2012-08-02 15:15:58 +0200 (Thu, 02 Aug 2012)
New Revision: 344
Url: http://forge.codelutin.com/repositories/revision/sammoa/344
Log:
use only gb i18n
Removed:
trunk/sammoa-application/src/main/resources/i18n/sammoa-application_fr_FR.properties
trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_fr_FR.properties
Modified:
trunk/pom.xml
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUI.css
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUI.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java
trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-08-01 16:35:52 UTC (rev 343)
+++ trunk/pom.xml 2012-08-02 13:15:58 UTC (rev 344)
@@ -128,6 +128,9 @@
<slf4jVersion>1.6.6</slf4jVersion>
<logbackVersion>1.0.2</logbackVersion>
+ <i18n.bundles>en_GB</i18n.bundles>
+ <i18n.silent>false</i18n.silent>
+
<!--<googleSearchEnabled>true</googleSearchEnabled>-->
<!-- license header configuration -->
Deleted: trunk/sammoa-application/src/main/resources/i18n/sammoa-application_fr_FR.properties
===================================================================
--- trunk/sammoa-application/src/main/resources/i18n/sammoa-application_fr_FR.properties 2012-08-01 16:35:52 UTC (rev 343)
+++ trunk/sammoa-application/src/main/resources/i18n/sammoa-application_fr_FR.properties 2012-08-02 13:15:58 UTC (rev 344)
@@ -1,33 +0,0 @@
-sammoa.config.admin.email=E-mail de l'administrateur
-sammoa.config.application.site.url=Site Internet de l'application
-sammoa.config.application.version=Version de l'application
-sammoa.config.audio.directory=Répertoire où sont stockés les enregistrements audio
-sammoa.config.background.shape.file=
-sammoa.config.campaign.id=
-sammoa.config.data.directory=Répertoire principale où sont stockées les données. Vous pouvez utiliser ${data.directory} pour d'autres propriétés (ex\: ${data.directory}/audio).
-sammoa.config.effort.number=
-sammoa.config.flight.number=
-sammoa.config.fly.mode=
-sammoa.config.gps.check.period=
-sammoa.config.gps.device=
-sammoa.config.gps.handler=
-sammoa.config.gps.speed=
-sammoa.config.gps.timeout=
-sammoa.config.log.file=Chemin vers le fichier journal (log) de l'application
-sammoa.config.observation.number=
-sammoa.config.strate.shape.file=
-sammoa.config.system.id=
-sammoa.config.transect.shape.file=
-sammoa.config.ui.add=Ajouter
-sammoa.config.ui.begin=Démarrer
-sammoa.config.ui.centerObservation=Observation depuis la place du milieu
-sammoa.config.ui.circleBack=Faire un "circle-back"
-sammoa.config.ui.config=Chemin vers le fichier de configuration des fenêtres de l'application
-sammoa.config.ui.end=Fin
-sammoa.config.ui.leftObservation=Observation depuis la place de gauche
-sammoa.config.ui.locale=Langue
-sammoa.config.ui.next=Suivant
-sammoa.config.ui.rightObservation=Observation depuis la place de droite
-sammoa.config.ui.start=Démarrer
-sammoa.config.ui.stop=Arrêter
-sammoa.copyright.text=Copyright CRMM 2012
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUI.css
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUI.css 2012-08-01 16:35:52 UTC (rev 343)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUI.css 2012-08-02 13:15:58 UTC (rev 344)
@@ -32,18 +32,6 @@
mnemonic:F;
}
-#menuApplicationLanguageFR {
- text:"sammoa.action.locale.fr";
- toolTipText:"sammoa.action.locale.fr.tip";
- actionIcon:"i18n-fr";
-}
-
-#menuApplicationLanguageUK {
- text:"sammoa.action.locale.uk";
- toolTipText:"sammoa.action.locale.uk.tip";
- actionIcon:"i18n-uk";
-}
-
#menuFileConfiguration {
text:"sammoa.action.configuration";
toolTipText:"sammoa.action.configuration.tip";
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUI.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUI.jaxx 2012-08-01 16:35:52 UTC (rev 343)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUI.jaxx 2012-08-02 13:15:58 UTC (rev 344)
@@ -62,11 +62,6 @@
<JMenuItem id='menuFileConfiguration'
onActionPerformed="getHandler().showConfig()"/>
<JSeparator/>
- <JMenuItem id='menuApplicationLanguageUK'
- onActionPerformed="getHandler().changeLanguage(Locale.UK)"/>
- <JMenuItem id='menuApplicationLanguageFR'
- onActionPerformed="getHandler().changeLanguage(Locale.FRANCE)"/>
- <JSeparator/>
<JMenuItem id='exit'
onActionPerformed='getHandler().closeSammoa()'/>
</JMenu>
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java 2012-08-01 16:35:52 UTC (rev 343)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java 2012-08-02 13:15:58 UTC (rev 344)
@@ -49,7 +49,6 @@
import java.awt.Desktop;
import java.io.File;
import java.net.URL;
-import java.util.Locale;
import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
@@ -214,16 +213,6 @@
ui.setVisible(true);
}
- public void changeLanguage(Locale locale) {
-
- // sauvegarde de la nouvelle locale
- getConfig().setLocale(locale);
- getConfig().save();
-
- // reload sammoa
- reloadSammoa();
- }
-
public void showConfig() {
SammoaConfig config = context.getConfig();
Modified: trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties
===================================================================
--- trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties 2012-08-01 16:35:52 UTC (rev 343)
+++ trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties 2012-08-02 13:15:58 UTC (rev 344)
@@ -5,7 +5,7 @@
sammoa.action.about.tip=About
sammoa.action.break.tip=Break
sammoa.action.cancel=Cancel
-sammoa.action.choose.export.directory=
+sammoa.action.choose.export.directory=Accept
sammoa.action.circleback.tip=Circle Back
sammoa.action.close=Close
sammoa.action.configuration=Configuration
@@ -14,6 +14,7 @@
sammoa.action.edit=Edit
sammoa.action.export=Export
sammoa.action.exportEffortsMap=Export Efforts
+sammoa.action.exportGeoPointsMap=Export GPS Points
sammoa.action.exportMap=Export Maps
sammoa.action.exportObservationsMap=Export Observations
sammoa.action.home=Home
@@ -85,6 +86,7 @@
sammoa.label.campaign.transect=Transects\:
sammoa.label.exportDirectory=Export directory
sammoa.label.exportEffortsFilename=Export filename (Efforts)
+sammoa.label.exportGeoPointsFilename=Export filename (GeoPoints)
sammoa.label.exportObservationsFilename=Export filename (Observations)
sammoa.label.flight=Flight\:
sammoa.label.flight.beginDate=Start
@@ -199,8 +201,11 @@
sammoa.timePattern=HH\:mm\:ss
sammoa.title.about=About Sammoa
sammoa.title.campaign=Campaign
-sammoa.title.choose.export.directory=
-sammoa.title.exportshape=
+sammoa.title.choose.export.directory=Choose directory where to export maps
+sammoa.title.export.exportEfforts=
+sammoa.title.export.exportGeoPoints=
+sammoa.title.export.exportObservations=
+sammoa.title.exportshape=Export Maps
sammoa.title.flight=System %1$s - Campaign %2$s - Region %3$s - Flight n°%4$d
sammoa.title.home=Home
sammoa.title.validation=
Deleted: trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_fr_FR.properties
===================================================================
--- trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_fr_FR.properties 2012-08-01 16:35:52 UTC (rev 343)
+++ trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_fr_FR.properties 2012-08-02 13:15:58 UTC (rev 344)
@@ -1,236 +0,0 @@
-SAMMOA=Sammoa
-csv.import.error.unableToReadField=Unable to read value of column '%s' at line %s
-sammoa.about.message=About Sammoa
-sammoa.action.about=About
-sammoa.action.about.tip=About
-sammoa.action.break.tip=Break
-sammoa.action.cancel=Cancel
-sammoa.action.choose.export.directory=
-sammoa.action.circleback.tip=Circle Back
-sammoa.action.close=Close
-sammoa.action.configuration=Configuration
-sammoa.action.configuration.tip=Configuration
-sammoa.action.create=Create
-sammoa.action.edit=Edit
-sammoa.action.export=Export
-sammoa.action.exportEffortsMap=Export des efforts
-sammoa.action.exportMap=Export Cartes
-sammoa.action.exportObservationsMap=Export des Observations
-sammoa.action.home=Home
-sammoa.action.home.tip=Home
-sammoa.action.import=Import
-sammoa.action.locale.fr=fr
-sammoa.action.locale.fr.tip=French
-sammoa.action.locale.uk=en
-sammoa.action.locale.uk.tip=English
-sammoa.action.new=New
-sammoa.action.next.tip=Next
-sammoa.action.onBoard=On Board
-sammoa.action.play.tip=Play
-sammoa.action.quitExportMaps=Quitter
-sammoa.action.reload.actions=Reload actions
-sammoa.action.reload.ui=Reload sammoa ui
-sammoa.action.save=Save
-sammoa.action.site=Site
-sammoa.action.site.tip=Display project site
-sammoa.action.startFlight.tip=Start the flight
-sammoa.action.stop.tip=Stop
-sammoa.action.stopFlight.tip=Stop the flight
-sammoa.action.validation=Validation
-sammoa.config.category.applications=Application
-sammoa.config.category.applications.description=Application
-sammoa.config.category.other=Other
-sammoa.config.category.other.description=Other
-sammoa.config.category.shortcuts=Shortcuts
-sammoa.config.category.shortcuts.description=List of all the shortcuts
-sammoa.confirmDialog.campaignNotLoaded.message=
-sammoa.confirmDialog.campaignNotLoaded.title=
-sammoa.confirmDialog.flightInProgress.message.exit=A flight is in progress, are you sure you want to quit ?
-sammoa.confirmDialog.flightInProgress.message.showHome=A flight is in progress, are you sure you want to go back to the home screen ?
-sammoa.confirmDialog.flightInProgress.title=Flight in progress
-sammoa.copyright.text=Version %1$s UMS 3462, Codelutin @ 2012
-sammoa.datePattern=dd/MM/yyyy
-sammoa.dateTimePattern=dd/MM/yyyy HH\:mm\:ss
-sammoa.dialog.title.observerFile=Choose a csv file for observers
-sammoa.dialog.title.region=Region
-sammoa.dialog.title.speciesFile=Choose a csv file for species
-sammoa.dialog.title.strateFile=Choose a shape file for strates
-sammoa.dialog.title.transect=New Transect
-sammoa.dialog.title.transectFile=Choose a shape file for transects
-sammoa.flight.decorator.flight=Flight %1$d
-sammoa.flight.decorator.newFlight=New flight
-sammoa.flight.decorator.notEnded=not ended
-sammoa.flight.decorator.notStarted=not started
-sammoa.flightDialog.transecLbl=Transects / tracks\:
-sammoa.flightPanel.table.column.action=Next
-sammoa.flightPanel.table.column.crossingNumber=Crossing
-sammoa.flightPanel.table.column.deleted=Del
-sammoa.flightPanel.table.column.index=N°
-sammoa.flightPanel.table.column.name=Name
-sammoa.flightPanel.table.column.nbTimes=Nb Times
-sammoa.flightPanel.table.column.position.co-navigator=Co-Nav
-sammoa.flightPanel.table.column.position.left=Left
-sammoa.flightPanel.table.column.position.navigator=Nav
-sammoa.flightPanel.table.column.position.right=Right
-sammoa.label.campaign=Campaign\:
-sammoa.label.campaign.beginDate=Begin\:
-sammoa.label.campaign.code=Code\:
-sammoa.label.campaign.endDate=End\:
-sammoa.label.campaign.name=Name\:
-sammoa.label.campaign.observer=Observers\:
-sammoa.label.campaign.period=Period\:
-sammoa.label.campaign.period.filter=Period filter
-sammoa.label.campaign.region=Region\:
-sammoa.label.campaign.strate=Strates\:
-sammoa.label.campaign.transect=Transects\:
-sammoa.label.exportDirectory=Répertoire d'export
-sammoa.label.exportEffortsFilename=Nom du fichier (Effort)
-sammoa.label.exportObservationsFilename=Nom du fichier (Observations)
-sammoa.label.flight=Flight\:
-sammoa.label.flight.beginDate=Start
-sammoa.label.flight.comment=Comment\:
-sammoa.label.flight.endDate=Stop
-sammoa.label.flight.immatriculation=Plane imma.\:
-sammoa.label.flight.period=Time\:
-sammoa.label.flight.platformType=Type\:
-sammoa.label.observers=Observers\:
-sammoa.label.region.code=Code\:
-sammoa.label.region.name=Name\:
-sammoa.label.region.species=Species\:
-sammoa.label.routeTypeFilter=Route type filter
-sammoa.label.speciesFilter=Species filter
-sammoa.label.speciesTypeFilter=Species type filter
-sammoa.label.strateFilter=Strate filter
-sammoa.label.systemId=System Id\:
-sammoa.label.transect.name=Name\:
-sammoa.label.transect.strate=Strate\:
-sammoa.map.mapFollow=Follow plane
-sammoa.menu.exit=Exit
-sammoa.menu.file=File
-sammoa.menu.file.tip=File
-sammoa.menu.help=Help
-sammoa.menu.help.tip=Help
-sammoa.menu.showLogs=Display logs
-sammoa.menu.showLogs.tip=Display logs
-sammoa.message.goto.site=Opening %1$s on navigator
-sammoa.messageDialog.observers.import.success=%1$d observers are successfully imported
-sammoa.messageDialog.species.import.success=%1$d species are successfully imported
-sammoa.messageDialog.strates.import.success=%1$d strates are successfully imported
-sammoa.messageDialog.transects.import.success=%1$d transects are successfully imported
-sammoa.observation.observations.center=Center
-sammoa.observation.observations.left=Left
-sammoa.observation.observations.right=Right
-sammoa.observation.title=<html><b>Observation</b></html>
-sammoa.observationCondition.title=<html><b>Conditions</b></html>
-sammoa.observations.observationTable.column.age=Age
-sammoa.observations.observationTable.column.age.tip=Age
-sammoa.observations.observationTable.column.behaviour=Behaviour
-sammoa.observations.observationTable.column.behaviour.tip=Behaviour
-sammoa.observations.observationTable.column.calves=Calves
-sammoa.observations.observationTable.column.calves.tip=Calves
-sammoa.observations.observationTable.column.circleback=Circle back
-sammoa.observations.observationTable.column.circleback.tip=Circle back
-sammoa.observations.observationTable.column.comment=Comments
-sammoa.observations.observationTable.column.comment.tip=Comments
-sammoa.observations.observationTable.column.cue=Cue
-sammoa.observations.observationTable.column.cue.tip=Cue
-sammoa.observations.observationTable.column.decAngle=Angle
-sammoa.observations.observationTable.column.decAngle.tip=Angle
-sammoa.observations.observationTable.column.deleted=Del
-sammoa.observations.observationTable.column.deleted.tip=Del
-sammoa.observations.observationTable.column.observationNumber=N°
-sammoa.observations.observationTable.column.observationNumber.tip=N°
-sammoa.observations.observationTable.column.observationStatus=Status
-sammoa.observations.observationTable.column.observationStatus.tip=Status
-sammoa.observations.observationTable.column.observationTime=Time
-sammoa.observations.observationTable.column.observationTime.tip=Time
-sammoa.observations.observationTable.column.observer=Obs
-sammoa.observations.observationTable.column.observer.tip=Obs
-sammoa.observations.observationTable.column.photo=Photo
-sammoa.observations.observationTable.column.photo.tip=Photo
-sammoa.observations.observationTable.column.podSize=Pod size
-sammoa.observations.observationTable.column.podSize.tip=Pod size
-sammoa.observations.observationTable.column.species=Species
-sammoa.observations.observationTable.column.species.tip=Species
-sammoa.observations.observationTable.column.swimDir=Swim dir
-sammoa.observations.observationTable.column.swimDir.tip=Swim dir
-sammoa.observations.routeTable.column.beginTime=Time
-sammoa.observations.routeTable.column.beginTime.tip=Time
-sammoa.observations.routeTable.column.cloudCover=Cloud
-sammoa.observations.routeTable.column.cloudCover.tip=Cloud
-sammoa.observations.routeTable.column.comment=Comment
-sammoa.observations.routeTable.column.comment.tip=Comment
-sammoa.observations.routeTable.column.deleted=Del
-sammoa.observations.routeTable.column.deleted.tip=Del
-sammoa.observations.routeTable.column.effortNumber=N°
-sammoa.observations.routeTable.column.effortNumber.tip=N°
-sammoa.observations.routeTable.column.glareFrom=Gl from
-sammoa.observations.routeTable.column.glareFrom.tip=Gl from
-sammoa.observations.routeTable.column.glareSeverity=Gl sev
-sammoa.observations.routeTable.column.glareSeverity.tip=Gl sev
-sammoa.observations.routeTable.column.glareTo=Gl to
-sammoa.observations.routeTable.column.glareTo.tip=Gl to
-sammoa.observations.routeTable.column.glareUnder=Gl under
-sammoa.observations.routeTable.column.glareUnder.tip=Gl under
-sammoa.observations.routeTable.column.routeType=Type
-sammoa.observations.routeTable.column.routeType.tip=Type
-sammoa.observations.routeTable.column.seaState=Sea
-sammoa.observations.routeTable.column.seaState.tip=Sea
-sammoa.observations.routeTable.column.skyGlint=Glint
-sammoa.observations.routeTable.column.skyGlint.tip=Glint
-sammoa.observations.routeTable.column.subjectiveConditions=Subj
-sammoa.observations.routeTable.column.subjectiveConditions.tip=Subj
-sammoa.observations.routeTable.column.swell=Swell
-sammoa.observations.routeTable.column.swell.tip=Swell
-sammoa.observations.routeTable.column.transect=Transect
-sammoa.observations.routeTable.column.transect.tip=Transect
-sammoa.observations.routeTable.column.turbidity=Turb
-sammoa.observations.routeTable.column.turbidity.tip=Turb
-sammoa.observations.routeTable.column.unexpectedLeft=Left
-sammoa.observations.routeTable.column.unexpectedLeft.tip=Left
-sammoa.observations.routeTable.column.unexpectedRight=Right
-sammoa.observations.routeTable.column.unexpectedRight.tip=Right
-sammoa.statusBar.audio=Audio
-sammoa.statusBar.gps=GPS
-sammoa.statusbar.alt=Alt %1$s ft
-sammoa.statusbar.speed=Speed %1$s km/h
-sammoa.strate.decorator.all=All strates
-sammoa.strate.decorator.strate=Strate %1$s
-sammoa.timePattern=HH\:mm\:ss
-sammoa.title.about=About Sammoa
-sammoa.title.campaign=Campaign
-sammoa.title.choose.export.directory=
-sammoa.title.exportshape=
-sammoa.title.flight=System %1$s - Campaign %2$s - Region %3$s - Flight n°%4$d
-sammoa.title.home=Home
-sammoa.title.validation=
-sammoa.validator.campaign.beginDate.required=The begin date must be defined
-sammoa.validator.campaign.code.required=The campaign code must be defined
-sammoa.validator.campaign.code.uniqueKey=The campaign code already exists
-sammoa.validator.campaign.endDate.anterior=The end date can't be anterior to the begin date
-sammoa.validator.campaign.endDate.required=The end date must be defined
-sammoa.validator.campaign.region.required=The region must be set
-sammoa.validator.campaign.uniqueKey=The campaign code '%1$s' already exists for the region '%2$s'
-sammoa.validator.observation.age.unkownValue=The age must be \: J for "juvénile", I for "immature", A for "adulte" and M for mixed groups
-sammoa.validator.observation.behaviour.unkownValue=The behaviour must be one of this value \: SW (normal), MI (milling), BR (breaching), LO (logging), FE (feeding), FA (feeding aggregation), SB (following boat), OT (other)
-sammoa.validator.observation.cue.unkownValue=The cue must be between 2 and 9 or U for underwater and A for surface
-sammoa.validator.observation.decAngle.invalidRange=The angle must be between %1$s and %2$s degrees or for the band \: 1 (in the band), 2 (outside the band), 3 (put in the band)
-sammoa.validator.observation.podSize.invalidMin=The pod size must be higher than %1$s
-sammoa.validator.observation.species.required=The species is mandatory
-sammoa.validator.observation.swimDir.invalidRange=The swim direction must be between %1$s and %2$s degrees
-sammoa.validator.region.code.required=The region code must be defined
-sammoa.validator.region.uniqueKey=The region code '%1$s' already exists
-sammoa.validator.route.cloudCover.invalidRange=The cloud cover must be between %1$s and %2$s (octa system \: 8 for covered, 0 for cleared)
-sammoa.validator.route.glareFrom.invalidRange=The glare must be in degrees between %1$s and %2$s (plane nose is at 0°)
-sammoa.validator.route.glareSeverity.invalidRange=The glare severity must be between %1$s and %2$s (0 \: no glare, 3 \: strong glare)
-sammoa.validator.route.glareTo.invalidRange=The glare must be in degrees between %1$s and %2$s (plane nose is at 0°)
-sammoa.validator.route.seaState.invalidRange=The sea state must be between %1$s and %2$s (beaufort system)
-sammoa.validator.route.skyGlint.invalidMin=The sky glint must be higher than %1$s
-sammoa.validator.route.subjectiveConditions.badLength=The subjective conditions must have %1$s characters (one letter for each side)
-sammoa.validator.route.subjectiveConditions.required=The subjective conditions is mandatory
-sammoa.validator.route.subjectiveConditions.unkownValue=The subjective conditions must be \: E for excellent, G for good, M for medium, P for poor
-sammoa.validator.route.swell.invalidRange=The swell must be between %1$s and %2$s (0 means no swell)
-sammoa.validator.route.turbidity.unkownValue=The turbidity must be between 0 (clear water) and 2 (turbid water) or 9 for unkown
-sammoa.validator.transect.name.required=The transect name must be defined
-sammoa.validator.transect.strate.required=The strate must be defined
-sammoa.validator.transect.uniqueKey=The transect name '%1$s' already exists
1
0
01 Aug '12
Author: tchemit
Date: 2012-08-01 18:35:52 +0200 (Wed, 01 Aug 2012)
New Revision: 343
Url: http://forge.codelutin.com/repositories/revision/sammoa/343
Log:
refs #1203: Export SHP (add ui parts) + persistence
Added:
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/RouteType.java
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/StringRef.java
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/StringRefs.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportApplication/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUI.css
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUI.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/importApplication/
trunk/sammoa-ui-swing/src/main/resources/icons/action-fileChooser.png
trunk/sammoa-ui-swing/src/test/resources/
trunk/sammoa-ui-swing/src/test/resources/logback-test.xml
Modified:
trunk/pom.xml
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaDecoratorProvider.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaScreen.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaUIContext.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.css
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/SammoaUtil.java
trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties
trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_fr_FR.properties
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-08-01 16:34:48 UTC (rev 342)
+++ trunk/pom.xml 2012-08-01 16:35:52 UTC (rev 343)
@@ -121,7 +121,7 @@
<h2Version>1.3.167</h2Version>
<postgresqlVersion>9.1-901-1.jdbc4</postgresqlVersion>
- <jaxxVersion>2.5.3</jaxxVersion>
+ <jaxxVersion>2.5.4-SNAPSHOT</jaxxVersion>
<swingXVersion>1.6.3</swingXVersion>
<xworkVersion>2.3.4</xworkVersion>
Added: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/RouteType.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/RouteType.java (rev 0)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/RouteType.java 2012-08-01 16:35:52 UTC (rev 343)
@@ -0,0 +1,11 @@
+package fr.ulr.sammoa.persistence;
+
+public enum RouteType {
+ TRANSIT,
+ LEG,
+ CIRCLE_BACK;
+
+ public String getName() {
+ return name();
+ }
+} //RouteType
Property changes on: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/RouteType.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/StringRef.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/StringRef.java (rev 0)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/StringRef.java 2012-08-01 16:35:52 UTC (rev 343)
@@ -0,0 +1,24 @@
+package fr.ulr.sammoa.persistence;
+
+import java.io.Serializable;
+
+/**
+ * To be able to use String inside decorators.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.5
+ */
+public class StringRef implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String value;
+
+ public StringRef(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
Property changes on: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/StringRef.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/StringRefs.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/StringRefs.java (rev 0)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/StringRefs.java 2012-08-01 16:35:52 UTC (rev 343)
@@ -0,0 +1,42 @@
+package fr.ulr.sammoa.persistence;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+import java.util.List;
+
+/**
+ * Usefulmethod aroun {@link StringRef}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.5
+ */
+public class StringRefs {
+
+
+ public static List<StringRef> toRefs(List<String> strings) {
+
+ List<StringRef> result =
+ Lists.newArrayList(Iterables.transform(strings, TO_STRING_REF_FUNCTION));
+ return result;
+ }
+
+ protected static Function<String, StringRef> TO_STRING_REF_FUNCTION =
+ new Function<String, StringRef>() {
+
+ @Override
+ public StringRef apply(String input) {
+ return new StringRef(input);
+ }
+ };
+
+ protected static Function<StringRef, String> TO_STRING_FUNCTION =
+ new Function<StringRef, String>() {
+
+ @Override
+ public String apply(StringRef input) {
+ return input.getValue();
+ }
+ };
+}
Property changes on: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/StringRefs.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java 2012-08-01 16:34:48 UTC (rev 342)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java 2012-08-01 16:35:52 UTC (rev 343)
@@ -33,6 +33,7 @@
import fr.ulr.sammoa.ui.swing.campaign.CampaignUI;
import fr.ulr.sammoa.ui.swing.flight.FlightUI;
import fr.ulr.sammoa.ui.swing.home.HomeUI;
+import fr.ulr.sammoa.ui.swing.io.exportMap.ExportMapUI;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.AboutPanel;
import jaxx.runtime.swing.ErrorDialogUI;
@@ -42,8 +43,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.swing.*;
-import java.awt.*;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.UIManager;
+import java.awt.Desktop;
import java.io.File;
import java.net.URL;
import java.util.Locale;
@@ -165,6 +168,14 @@
ui.getBody().setTitle(_("sammoa.title.campaign"));
ui.getBody().add(currentBody);
break;
+
+ case EXPORT_MAP:
+ currentBody = new ExportMapUI(context);
+ context.getSwingSession().add(currentBody);
+ ui.getBody().setTitle(_("sammoa.title.exportshape"));
+ ui.getBody().add(currentBody);
+ break;
+
}
ui.setScreen(screen);
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaDecoratorProvider.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaDecoratorProvider.java 2012-08-01 16:34:48 UTC (rev 342)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaDecoratorProvider.java 2012-08-01 16:35:52 UTC (rev 343)
@@ -30,8 +30,11 @@
import fr.ulr.sammoa.persistence.Observer;
import fr.ulr.sammoa.persistence.Region;
import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.RouteType;
import fr.ulr.sammoa.persistence.Sector;
+import fr.ulr.sammoa.persistence.Species;
import fr.ulr.sammoa.persistence.Strate;
+import fr.ulr.sammoa.persistence.StringRef;
import fr.ulr.sammoa.persistence.Transect;
import fr.ulr.sammoa.ui.swing.flight.StrateModel;
import fr.ulr.sammoa.ui.swing.flight.TransectModel;
@@ -57,7 +60,11 @@
registerJXPathDecorator(Observation.class, "${observationNumber}$s ${observationTime}$tH:%2$tM:%2$tS");
registerJXPathDecorator(Transect.class, "${name}$s");
registerJXPathDecorator(Observer.class, "${initials}$s");
-// registerJXPathDecorator(Strate.class, "${code}$s");
+ registerMultiJXPathDecorator(Strate.class, "${code}$s##${name}$s", "##", " - ");
+ registerMultiJXPathDecorator(RouteType.class, "${name}$s", "##", " - ");
+ registerMultiJXPathDecorator(Species.class, "${code}$s##${commonName}$s", "##", " - ");
+ registerMultiJXPathDecorator(StringRef.class, "${value}$s", "##", " - ");
+
registerJXPathDecorator(TransectModel.class, "${source/name}$s");
registerJXPathDecorator(Sector.class, "${name}$s");
registerJXPathDecorator(Region.class, "${code}$s");
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaScreen.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaScreen.java 2012-08-01 16:34:48 UTC (rev 342)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaScreen.java 2012-08-01 16:35:52 UTC (rev 343)
@@ -2,8 +2,8 @@
/*
* #%L
* SAMMOA :: UI Swing
- * $Id:$
- * $HeadURL:$
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2012 UMS 3462, Code Lutin
* %%
@@ -34,5 +34,7 @@
CAMPAIGN,
- FLIGHT;
+ FLIGHT,
+
+ EXPORT_MAP
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaUIContext.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaUIContext.java 2012-08-01 16:34:48 UTC (rev 342)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/SammoaUIContext.java 2012-08-01 16:35:52 UTC (rev 343)
@@ -185,6 +185,11 @@
mainUIHandler.setScreen(SammoaScreen.HOME);
}
+ public void setExportMapScreen(String campaignId) {
+ this.campaignId = campaignId;
+ mainUIHandler.setScreen(SammoaScreen.EXPORT_MAP);
+ }
+
public void open() {
context.open();
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.css
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.css 2012-08-01 16:34:48 UTC (rev 342)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.css 2012-08-01 16:35:52 UTC (rev 343)
@@ -57,10 +57,16 @@
}
#importButton {
+ enabled:false;
text: "sammoa.action.import";
}
+#exportMapButton {
+ text: "sammoa.action.exportMap";
+}
+
#exportButton {
+ enabled:false;
text: "sammoa.action.export";
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.jaxx 2012-08-01 16:34:48 UTC (rev 342)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUI.jaxx 2012-08-01 16:35:52 UTC (rev 343)
@@ -101,9 +101,11 @@
</row>
<row>
<cell fill='both' columns='3'>
- <JPanel layout='{new GridLayout(1,4,0,0)}'>
+ <JPanel layout='{new GridLayout(1,0,0,0)}'>
<JButton id='importButton'
onActionPerformed='getHandler().showImport()'/>
+ <JButton id='exportMapButton'
+ onActionPerformed='getHandler().showExportMap()'/>
<JButton id='exportButton'
onActionPerformed='getHandler().showExport()'/>
<JButton id='onBoardButton'
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUIHandler.java 2012-08-01 16:34:48 UTC (rev 342)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/home/HomeUIHandler.java 2012-08-01 16:35:52 UTC (rev 343)
@@ -2,8 +2,8 @@
/*
* #%L
* SAMMOA :: UI Swing
- * $Id:$
- * $HeadURL:$
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2012 UMS 3462, Code Lutin
* %%
@@ -275,8 +275,15 @@
}
+ public void showExportMap() {
+
+ Campaign campaign = getModel().getCampaign();
+ String campaignId = campaign==null?null:campaign.getTopiaId();
+ context.setExportMapScreen(campaignId);
+ }
+
public void showExport() {
-
+
}
public void showOnBoard() {
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUI.css
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUI.css (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUI.css 2012-08-01 16:35:52 UTC (rev 343)
@@ -0,0 +1,89 @@
+BeanListHeader {
+ i18nPrefix: "sammoa.common.";
+}
+
+#campaignLabel {
+ text: "sammoa.label.campaign";
+}
+
+#campaignCombobox {
+ renderer: {new DecoratorProviderListCellRenderer(getHandler().getDecoratorProvider())};
+}
+
+#campainPeriodFilter {
+ border:{new TitledBorder(_("sammoa.label.campaign.period.filter"))};
+}
+
+#campaignBeginDateLabel {
+ text:"sammoa.label.campaign.beginDate";
+}
+
+#beginDatePicker {
+ patternLayout:{_("sammoa.datePattern")};
+ date:{getModel().getBeginDate()};
+}
+
+#campaignEndDateLabel {
+ text:"sammoa.label.campaign.endDate";
+}
+
+#endDatePicker {
+ patternLayout:{_("sammoa.datePattern")};
+ date:{getModel().getEndDate()};
+}
+
+#strateFilterListHeader {
+ beanType:{Strate.class};
+ showReset:true;
+ list:{strateFilter};
+ labelText:{_("sammoa.label.strateFilter")};
+}
+
+#routeTypeFilterListHeader {
+ beanType:{RouteType.class};
+ showReset:true;
+ list:{routeTypeFilter};
+ labelText:{_("sammoa.label.routeTypeFilter")};
+}
+
+#speciesTypeFilterListHeader {
+ beanType:{StringRef.class};
+ showReset:true;
+ list:{speciesTypeFilter};
+ labelText:{_("sammoa.label.speciesTypeFilter")};
+}
+
+#speciesFilterListHeader {
+ beanType:{Species.class};
+ showReset:true;
+ list:{speciesFilter};
+ labelText:{_("sammoa.label.speciesFilter")};
+}
+
+#quitButton {
+ text:"sammoa.action.quitExportMaps";
+}
+
+#exportEfforts {
+ text:"sammoa.action.exportEffortsMap";
+}
+
+#exportObservations {
+ text:"sammoa.action.exportObservationsMap";
+}
+
+#exportDirectoryFileChooseAction {
+ actionIcon:"fileChooser";
+}
+
+#exportEffortsFilenameLbl {
+ text:"sammoa.label.exportEffortsFilename";
+}
+
+#exportDirectoryLbl {
+ text:"sammoa.label.exportDirectory";
+}
+
+#exportObservationsFilenameLbl {
+ text:"sammoa.label.exportObservationsFilename";
+}
\ No newline at end of file
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUI.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUI.jaxx (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUI.jaxx 2012-08-01 16:35:52 UTC (rev 343)
@@ -0,0 +1,163 @@
+<JPanel id='campaignUI' layout='{new BorderLayout()}'
+ implements='fr.ulr.sammoa.ui.swing.SammoaUI<ExportMapUIHandler>'>
+
+ <import>
+ fr.ulr.sammoa.application.FlightState
+ fr.ulr.sammoa.persistence.Campaign
+ fr.ulr.sammoa.persistence.RouteType
+ fr.ulr.sammoa.persistence.Strate
+ fr.ulr.sammoa.persistence.Species
+ fr.ulr.sammoa.persistence.StringRef
+ fr.ulr.sammoa.ui.swing.SammoaUIContext
+
+ jaxx.runtime.swing.editor.bean.BeanListHeader
+ jaxx.runtime.swing.JAXXDatePicker
+ jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer
+
+ java.awt.BorderLayout
+ java.awt.event.ItemEvent
+ java.io.File
+
+ static org.nuiton.i18n.I18n._
+ </import>
+
+ <script><![CDATA[
+
+ public ExportMapUI(SammoaUIContext context) {
+ ExportMapUIHandler handler = new ExportMapUIHandler(context, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+ }
+
+ protected void $afterCompleteSetup() {
+ getHandler().afterInitUI();
+ }
+ ]]></script>
+
+ <ExportMapUIModel id='model'
+ initializer='getContextValue(ExportMapUIModel.class)'/>
+
+ <ExportMapUIHandler id='handler'
+ initializer='getContextValue(ExportMapUIHandler.class)'/>
+
+ <Table fill='both' constraints='BorderLayout.CENTER'>
+ <!-- export directory-->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='exportDirectoryLbl'/>
+ </cell>
+ <cell weightx='1' fill="horizontal">
+ <JTextField id='exportDirectory' text='{model.getExportDirectory().getAbsolutePath()}'
+ onKeyReleased='getModel().setExportDirectory(new File(((JTextField)event.getSource()).getText()))'/>
+ </cell>
+ <cell anchor="east">
+ <JButton id="exportDirectoryFileChooseAction"
+ onActionPerformed="getHandler().chooseEffortDirectory()"/>
+ </cell>
+
+ </row>
+ <!-- Campaign filter -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='campaignLabel'/>
+ </cell>
+ <cell fill='horizontal' weightx='1.0'>
+ <JComboBox id='campaignCombobox'
+ onItemStateChanged='if (ItemEvent.SELECTED == event.getStateChange()) { getModel().setSelectedCampaign((Campaign)event.getItem()); } else { getModel().setSelectedCampaign(null); }'/>
+ </cell>
+ </row>
+ <!-- Campaign Period filter -->
+ <row>
+ <cell weightx='1.0' columns='5'>
+ <JPanel id='campainPeriodFilter' layout='{new GridLayout(1,0)}'>
+ <JAXXDatePicker id='beginDatePicker'
+ onActionPerformed='getModel().setBeginDate(beginDatePicker.getDate())'/>
+ <JAXXDatePicker id='endDatePicker'
+ onActionPerformed='getModel().setEndDate(endDatePicker.getDate())'/>
+ </JPanel>
+ </cell>
+ </row>
+ <!-- Strate filter (Multi-selection)-->
+ <row>
+ <cell fill='both' weightx='1.0' weighty='1.0' columns='5'>
+ <JScrollPane id='strateFilterScrollPane'
+ columnHeaderView='{strateFilterListHeader}'>
+ <JList id='strateFilter' />
+ <BeanListHeader id='strateFilterListHeader' genericType='Strate'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <!-- Status filter (Multi-selection)-->
+ <row>
+ <cell fill='both' weightx='1.0' weighty='1.0' columns='5'>
+ <JScrollPane id='routeTypeFilterScrollPane'
+ columnHeaderView='{routeTypeFilterListHeader}'>
+ <JList id='routeTypeFilter' />
+ <BeanListHeader id='routeTypeFilterListHeader' genericType='RouteType'/>
+ </JScrollPane>
+ </cell>
+ </row>
+
+ <!-- export efforts filename-->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='exportEffortsFilenameLbl'/>
+ </cell>
+ <cell fill='horizontal' weightx='1.0'>
+ <JTextField id='exportEffortsFilename' text='{model.getExportEffortsFilename()}'
+ onKeyReleased='model.setExportEffortsFilename(((JTextField)event.getSource()).getText())'/>
+ </cell>
+ </row>
+
+ <!-- export efforts -->
+ <row>
+ <cell columns='5' fill="both">
+ <JPanel layout='{new BorderLayout()}'>
+ <JButton id='exportEfforts' constraints='BorderLayout.CENTER'
+ onActionPerformed='getHandler().exportEfforts()'/>
+ </JPanel>
+ </cell>
+ </row>
+
+ <!-- Species type filter (Multi-selection)-->
+ <row>
+ <cell fill='both' weightx='1.0' weighty='1.0' columns='5'>
+ <JScrollPane id='speciesTypeFilterScrollPane'
+ columnHeaderView='{speciesTypeFilterListHeader}'>
+ <JList id='speciesTypeFilter'/>
+ <BeanListHeader id='speciesTypeFilterListHeader' genericType='StringRef'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <!-- Species filter (Multi-selection)-->
+ <row>
+ <cell fill='both' weightx='1.0' weighty='1.0' columns='5'>
+ <JScrollPane id='speciesFilterScrollPane'
+ columnHeaderView='{speciesFilterListHeader}'>
+ <JList id='speciesFilter'/>
+ <BeanListHeader id='speciesFilterListHeader' genericType='Species'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <!-- export observations filename-->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='exportObservationsFilenameLbl'/>
+ </cell>
+ <cell fill='horizontal' weightx='1.0'>
+ <JTextField id='exportObservationsFilename' text='{model.getExportObservationsFilename()}'
+ onKeyReleased='model.setExportObservationsFilename(((JTextField)event.getSource()).getText())'/>
+ </cell>
+ </row>
+ <!--export observations -->
+ <row>
+ <cell columns='5' fill="both">
+ <JPanel layout='{new GridLayout(1,2,0,0)}'>
+ <JButton id='quitButton' onActionPerformed='getHandler().close()'/>
+ <JButton id='exportObservations'
+ onActionPerformed='getHandler().exportObservations()'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+</JPanel>
\ No newline at end of file
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIHandler.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIHandler.java 2012-08-01 16:35:52 UTC (rev 343)
@@ -0,0 +1,251 @@
+package fr.ulr.sammoa.ui.swing.io.exportMap;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ulr.sammoa.application.ReferentialService;
+import fr.ulr.sammoa.application.map.ExportMapModel;
+import fr.ulr.sammoa.application.map.ExportMapService;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.RouteType;
+import fr.ulr.sammoa.persistence.Species;
+import fr.ulr.sammoa.persistence.Strate;
+import fr.ulr.sammoa.persistence.StringRefs;
+import fr.ulr.sammoa.ui.swing.SammoaDecoratorProvider;
+import fr.ulr.sammoa.ui.swing.SammoaUIContext;
+import fr.ulr.sammoa.ui.swing.SammoaUIHandler;
+import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.OneClicListSelectionModel;
+import jaxx.runtime.swing.editor.bean.BeanListHeader;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.decorator.Decorator;
+import org.nuiton.util.decorator.DecoratorUtil;
+import org.nuiton.util.decorator.JXPathDecorator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.JList;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Handler of {@link ExportMapUI}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.5
+ */
+public class ExportMapUIHandler implements SammoaUIHandler {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(ExportMapUIHandler.class);
+
+ private final ExportMapUI ui;
+
+ protected SammoaUIContext context;
+
+ public ExportMapUIHandler(SammoaUIContext context,
+ ExportMapUI ui) {
+ this.context = context;
+ this.ui = ui;
+ }
+
+ protected ReferentialService getReferentialService() {
+ return context.getAppContext().getReferentialService();
+ }
+
+ protected ExportMapService getExportMapService() {
+ return context.getAppContext().getExportMapService();
+ }
+
+ public SammoaDecoratorProvider getDecoratorProvider() {
+ return context.getDecoratorProvider();
+ }
+
+ @Override
+ public void beforeInitUI() {
+
+ //-- create model --//
+
+ ExportMapUIModel model = new ExportMapUIModel();
+
+ List<Campaign> campaigns = getReferentialService().getCampaigns();
+ campaigns.add(0, null);
+ model.setCampaigns(campaigns);
+
+ List<String> speciesTypes = getReferentialService().getAllSpeciesTypes();
+ model.setSpeciesTypes(StringRefs.toRefs(speciesTypes));
+
+ List<Species> species = getReferentialService().getAllSpecies();
+ model.setSpecies(species);
+
+ model.setRouteTypes(Lists.newArrayList(RouteType.values()));
+
+ String campaignId = context.getCampaignId();
+
+ if (campaignId != null) {
+
+ Campaign campaign = getReferentialService().getCampaign(campaignId);
+
+ // selected cam
+ model.setSelectedCampaign(campaign);
+ }
+
+ //-- share model and handler in jaxx context --//
+ ui.setContextValue(this);
+ ui.setContextValue(model);
+
+ model.addPropertyChangeListener(new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ if (ExportMapUIModel.PROPERTY_SELECTED_CAMPAIGN.equals(evt.getPropertyName())) {
+ Campaign newValue = (Campaign) evt.getNewValue();
+ onSelectedCampaignChanged(newValue);
+ } else if (ExportMapUIModel.PROPERTY_STRATES.equals(evt.getPropertyName())) {
+
+ List<Strate> newValue = (List<Strate>) evt.getNewValue();
+ onStratesChanged(newValue);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void afterInitUI() {
+ ExportMapUIModel model = ui.getModel();
+
+ model.setExportEffortsFilename("Efforts");
+ model.setExportObservationsFilename("Observations");
+ model.setExportDirectory(FileUtil.getCurrentDirectory().getAbsoluteFile());
+
+ SwingUtil.fillComboBox(ui.getCampaignCombobox(),
+ model.getCampaigns(),
+ model.getSelectedCampaign());
+
+ prepareList(ui.getStrateFilterListHeader(), model.getStrates());
+ prepareList(ui.getRouteTypeFilterListHeader(), model.getRouteTypes());
+ prepareList(ui.getSpeciesTypeFilterListHeader(), model.getSpeciesTypes());
+ prepareList(ui.getSpeciesFilterListHeader(), model.getSpecies());
+
+ onSelectedCampaignChanged(model.getSelectedCampaign());
+ }
+
+ protected void onStratesChanged(List<Strate> newValue) {
+ if (logger.isInfoEnabled()) {
+ logger.info("New strates to use: {}", newValue.size());
+ }
+ ui.getStrateFilterListHeader().setData(newValue);
+ }
+
+ protected void onSelectedCampaignChanged(Campaign newCampaign) {
+
+ // reset strates,...
+ if (logger.isInfoEnabled()) {
+ Decorator<Campaign> decorator = getDecoratorProvider().getDecoratorByType(Campaign.class);
+ logger.info("New selected campain: {}", decorator.toString(newCampaign));
+ }
+
+ ExportMapUIModel model = ui.getModel();
+
+ model.setSelectedStrates(Collections.<Strate>emptyList());
+
+ List<Strate> strates;
+ if (newCampaign == null) {
+ strates = Collections.emptyList();
+ } else {
+ strates = getReferentialService().getAllStrates(newCampaign);
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("New strates: {}", strates.size());
+ }
+ model.setStrates(strates);
+ }
+
+ public void close() {
+ context.setHomeScreen();
+ }
+
+ @Override
+ public void onCloseUI() {
+ }
+
+ public void chooseEffortDirectory() {
+ File f = SammoaUtil.chooseDirectory(
+ ui,
+ _("sammoa.title.choose.export.directory"),
+ _("sammoa.action.choose.export.directory"),
+ ui.getModel().getExportDirectory()
+ );
+ ui.getModel().setExportDirectory(f);
+ }
+
+ public void exportEfforts() {
+
+ ExportMapUIModel model = ui.getModel();
+
+ ExportMapModel dataModel =
+ model.toModel(model.getExportEffortsFilename());
+
+ getExportMapService().exportEffortsMap(dataModel);
+ }
+
+ public void exportObservations() {
+
+ ExportMapUIModel model = ui.getModel();
+
+ ExportMapModel dataModel =
+ model.toModel(model.getExportObservationsFilename());
+
+ getExportMapService().exportObservationsMap(dataModel);
+ }
+
+
+ /**
+ * Remplit le modèle d'une liste graphique avec la liste des entités d'un
+ * type donné sur un service de persistance donné.
+ *
+ * @param list le component graphique à initialiser
+ * @param incomingData les données à mettre dans la liste
+ * @since 0.5
+ */
+ public <E> void prepareList(BeanListHeader<E> list, List<E> incomingData) {
+
+ Class<E> beanType = list.getBeanType();
+
+ JList jList = list.getList();
+
+ //FIXME-tchemit 2012-08-01 Fix selection model which bugs when deselect
+ OneClicListSelectionModel.installModel(jList);
+
+ // init list
+ Decorator<E> decorator = getDecoratorProvider().getDecoratorByType(beanType);
+ Preconditions.checkNotNull(decorator, "No decorator found for type " + beanType);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Will use decorator " + decorator);
+ }
+
+ list.putClientProperty("decorator", decorator);
+ List<E> data = Lists.newArrayList(incomingData);
+
+ // sort data from first decorator context
+ DecoratorUtil.sort((JXPathDecorator<E>) decorator, data, 0);
+
+ // set datas to list and init renderer
+ list.init((JXPathDecorator<E>) decorator, data);
+
+// // get the renderer initialized
+// ListCellRenderer renderer = list.getList().getCellRenderer();
+//
+// // add the specific renderer
+// list.getList().setCellRenderer(new ReferentielListCellRenderer(renderer));
+
+ list.putClientProperty("data", data);
+ }
+
+
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIModel.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIModel.java 2012-08-01 16:35:52 UTC (rev 343)
@@ -0,0 +1,277 @@
+package fr.ulr.sammoa.ui.swing.io.exportMap;
+
+import com.google.common.collect.Lists;
+import fr.ulr.sammoa.application.map.ExportMapModel;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.RouteType;
+import fr.ulr.sammoa.persistence.Species;
+import fr.ulr.sammoa.persistence.Strate;
+import fr.ulr.sammoa.persistence.StringRef;
+import org.jdesktop.beans.AbstractSerializableBean;
+
+import java.io.File;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Model of export map UI.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.5
+ */
+public class ExportMapUIModel extends AbstractSerializableBean {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_CAMPAIGNS = "campaigns";
+
+ public static final String PROPERTY_SELECTED_CAMPAIGN = "selectedCampaign";
+
+ public static final String PROPERTY_BEGIN_DATE = "beginDate";
+
+ public static final String PROPERTY_END_DATE = "endDate";
+
+ public static final String PROPERTY_STRATES = "strates";
+
+ public static final String PROPERTY_SELECTED_STRATES = "selectedStrates";
+
+ public static final String PROPERTY_ROUTE_TYPES = "routeTypes";
+
+ public static final String PROPERTY_SELECTED_ROUTE_TYPES = "selectedRouteTypes";
+
+ public static final String PROPERTY_SPECIES = "species";
+
+ public static final String PROPERTY_SELECTED_SPECIES = "selectedSpecies";
+
+ public static final String PROPERTY_SPECIES_TYPES = "speciesTypes";
+
+ public static final String PROPERTY_SELECTED_SPECIES_TYPES = "selectedSpeciesTypes";
+
+ public static final String PROPERTY_EXPORT_DIRECTORY = "exportDirectory";
+
+ public static final String PROPERTY_EXPORT_EFFORTS_FILENAME = "exportEffortsFilename";
+
+ public static final String PROPERTY_EXPORT_OBSERVATIONS_FILENAME = "exportObservationsFilename";
+
+ protected List<Campaign> campaigns;
+
+ protected Campaign selectedCampaign;
+
+ protected Date beginDate;
+
+ protected Date endDate;
+
+ protected List<Strate> strates;
+
+ protected List<Strate> selectedStrates;
+
+ protected List<RouteType> routeTypes;
+
+ protected List<RouteType> selectedRouteTypes;
+
+ protected List<Species> species;
+
+ protected List<Species> selectedSpecies;
+
+ protected List<StringRef> selectedSpeciesTypes;
+
+ protected List<StringRef> speciesTypes;
+
+ protected File exportDirectory;
+
+ protected String exportEffortsFilename;
+
+ protected String exportObservationsFilename;
+
+ public File getExportDirectory() {
+ return exportDirectory;
+ }
+
+ public void setExportDirectory(File exportDirectory) {
+ File oldValue = this.exportDirectory;
+ this.exportDirectory = exportDirectory;
+ firePropertyChange(PROPERTY_EXPORT_DIRECTORY, oldValue, exportDirectory);
+ }
+
+ public String getExportEffortsFilename() {
+ return exportEffortsFilename;
+ }
+
+ public void setExportEffortsFilename(String exportEffortsFilename) {
+ String oldValue = this.exportEffortsFilename;
+ this.exportEffortsFilename = exportEffortsFilename;
+ firePropertyChange(PROPERTY_EXPORT_EFFORTS_FILENAME, oldValue, exportEffortsFilename);
+ }
+
+ public String getExportObservationsFilename() {
+ return exportObservationsFilename;
+ }
+
+ public void setExportObservationsFilename(String exportObservationsFilename) {
+ String oldValue = this.exportObservationsFilename;
+ this.exportObservationsFilename = exportObservationsFilename;
+ firePropertyChange(PROPERTY_EXPORT_OBSERVATIONS_FILENAME, oldValue, exportObservationsFilename);
+ }
+
+ public List<Campaign> getCampaigns() {
+ if (campaigns == null) {
+ campaigns = Lists.newArrayList();
+ }
+ return campaigns;
+ }
+
+ public void setCampaigns(List<Campaign> campaigns) {
+ List<Campaign> oldValue = this.campaigns;
+ this.campaigns = campaigns;
+ firePropertyChange(PROPERTY_CAMPAIGNS, oldValue, campaigns);
+ }
+
+ public Campaign getSelectedCampaign() {
+ return selectedCampaign;
+ }
+
+ public void setSelectedCampaign(Campaign selectedCampaign) {
+ Campaign oldValue = this.selectedCampaign;
+ this.selectedCampaign = selectedCampaign;
+ firePropertyChange(PROPERTY_SELECTED_CAMPAIGN, oldValue, selectedCampaign);
+ }
+
+ public Date getBeginDate() {
+ return beginDate;
+ }
+
+ public void setBeginDate(Date beginDate) {
+ Date oldValue = this.beginDate;
+ this.beginDate = beginDate;
+ firePropertyChange(PROPERTY_BEGIN_DATE, oldValue, beginDate);
+ }
+
+ public Date getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(Date endDate) {
+ Date oldValue = this.endDate;
+ this.endDate = endDate;
+ firePropertyChange(PROPERTY_END_DATE, oldValue, endDate);
+ }
+
+ public List<Strate> getStrates() {
+ if (strates == null) {
+ strates = Lists.newArrayList();
+ }
+ return strates;
+ }
+
+ public void setStrates(List<Strate> strates) {
+ List<Strate> oldValue = this.strates;
+ this.strates = strates;
+ firePropertyChange(PROPERTY_STRATES, oldValue, strates);
+ }
+
+ public List<Strate> getSelectedStrates() {
+ if (selectedStrates == null) {
+ selectedStrates = Lists.newArrayList();
+ }
+ return selectedStrates;
+ }
+
+ public void setSelectedStrates(List<Strate> selectedStrates) {
+ List<Strate> oldValue = this.selectedStrates;
+ this.selectedStrates = selectedStrates;
+ firePropertyChange(PROPERTY_SELECTED_STRATES, oldValue, selectedStrates);
+ }
+
+ public List<RouteType> getRouteTypes() {
+ if (routeTypes == null) {
+ routeTypes = Lists.newArrayList();
+ }
+ return routeTypes;
+ }
+
+ public void setRouteTypes(List<RouteType> routeTypes) {
+ List<RouteType> oldValue = this.routeTypes;
+ this.routeTypes = routeTypes;
+ firePropertyChange(PROPERTY_ROUTE_TYPES, oldValue, routeTypes);
+ }
+
+ public List<RouteType> getSelectedRouteTypes() {
+ if (selectedRouteTypes == null) {
+ selectedRouteTypes = Lists.newArrayList();
+ }
+ return selectedRouteTypes;
+ }
+
+ public void setSelectedRouteTypes(List<RouteType> selectedRouteTypes) {
+ List<RouteType> oldValue = this.selectedRouteTypes;
+ this.selectedRouteTypes = selectedRouteTypes;
+ firePropertyChange(PROPERTY_SELECTED_ROUTE_TYPES, oldValue, selectedRouteTypes);
+ }
+
+ public List<Species> getSpecies() {
+ if (species == null) {
+ species = Lists.newArrayList();
+ }
+ return species;
+ }
+
+ public void setSpecies(List<Species> species) {
+ List<Species> oldValue = this.species;
+ this.species = species;
+ firePropertyChange(PROPERTY_SPECIES, oldValue, species);
+ }
+
+ public List<Species> getSelectedSpecies() {
+ if (selectedSpecies == null) {
+ selectedSpecies = Lists.newArrayList();
+ }
+ return selectedSpecies;
+ }
+
+ public void setSelectedSpecies(List<Species> selectedSpecies) {
+ List<Species> oldValue = this.selectedSpecies;
+ this.selectedSpecies = selectedSpecies;
+ firePropertyChange(PROPERTY_SELECTED_SPECIES, oldValue, selectedSpecies);
+ }
+
+ public List<StringRef> getSpeciesTypes() {
+ if (speciesTypes == null) {
+ speciesTypes = Lists.newArrayList();
+ }
+ return speciesTypes;
+ }
+
+ public void setSpeciesTypes(List<StringRef> speciesTypes) {
+ List<StringRef> oldValue = this.speciesTypes;
+ this.speciesTypes = speciesTypes;
+ firePropertyChange(PROPERTY_SPECIES_TYPES, oldValue, speciesTypes);
+ }
+
+ public List<StringRef> getSelectedSpeciesTypes() {
+ if (selectedSpeciesTypes == null) {
+ selectedSpeciesTypes = Lists.newArrayList();
+ }
+ return selectedSpeciesTypes;
+ }
+
+ public void setSelectedSpeciesTypes(List<StringRef> selectedSpeciesTypes) {
+ List<StringRef> oldValue = this.selectedSpeciesTypes;
+ this.selectedSpeciesTypes = selectedSpeciesTypes;
+ firePropertyChange(PROPERTY_SELECTED_SPECIES_TYPES, oldValue, selectedSpeciesTypes);
+ }
+
+ public ExportMapModel toModel(String filename) {
+ ExportMapModel result = ExportMapModel.newModel(
+ getExportDirectory(),
+ filename,
+ getSelectedCampaign(),
+ getBeginDate(),
+ getEndDate(),
+ getSelectedStrates(),
+ getSelectedRouteTypes(),
+ getSelectedSpecies(),
+ getSelectedSpeciesTypes()
+ );
+ return result;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/exportMap/ExportMapUIModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/SammoaUtil.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/SammoaUtil.java 2012-08-01 16:34:48 UTC (rev 342)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/SammoaUtil.java 2012-08-01 16:35:52 UTC (rev 343)
@@ -32,6 +32,7 @@
import org.apache.commons.beanutils.PropertyUtils;
import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.decorator.Highlighter;
+import org.nuiton.util.FileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,6 +40,7 @@
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
+import java.io.File;
import java.lang.reflect.InvocationTargetException;
/**
@@ -115,4 +117,76 @@
result.setVisible(true);
return result;
}
+
+ /**
+ * Choisir un fichier via un sélecteur graphique de fichiers.
+ *
+ * @param parent le component swing appelant le controle
+ * @param title le titre du dialogue de sélection
+ * @param buttonLabel le label du boutton d'acceptation
+ * @param incoming le fichier de base à utilier
+ * @param filters les filtres + descriptions sur le sélecteur de
+ * fichiers
+ * @return le fichier choisi ou le fichier incoming si l'opération a été
+ * annulée
+ */
+ public static File chooseFile(Component parent,
+ String title,
+ String buttonLabel,
+ File incoming,
+ String... filters) {
+ File oldBasedir = FileUtil.getCurrentDirectory();
+ if (incoming != null) {
+ File basedir;
+ if (incoming.isFile()) {
+ basedir = incoming.getParentFile();
+ } else {
+ basedir = incoming;
+ }
+ if (basedir.exists()) {
+ FileUtil.setCurrentDirectory(basedir);
+ }
+ }
+ File file = FileUtil.getFile(title, buttonLabel, parent, filters);
+ if (logger.isDebugEnabled()) {
+ logger.debug(title + " : " + file);
+ }
+ FileUtil.setCurrentDirectory(oldBasedir);
+ File result = file == null ? incoming : file;
+ return result;
+ }
+
+ /**
+ * Choisir un répertoire via un sélecteur graphique de fichiers.
+ *
+ * @param parent le component swing appelant le controle
+ * @param title le titre de la boite de dialogue de sléection
+ * @param buttonLabel le label de l'action d'acceptation
+ * @param incoming le fichier de base à utiliser
+ * @return le répertoire choisi ou le répertoire incoming si l'opération a
+ * été annulée
+ */
+ public static File chooseDirectory(Component parent,
+ String title,
+ String buttonLabel,
+ File incoming) {
+ File oldBasedir = FileUtil.getCurrentDirectory();
+ if (incoming != null) {
+ File basedir;
+ if (incoming.isFile()) {
+ basedir = incoming.getParentFile();
+ } else {
+ basedir = incoming;
+ }
+ if (basedir.exists()) {
+ FileUtil.setCurrentDirectory(basedir);
+ }
+ }
+ String file = FileUtil.getDirectory(parent, title, buttonLabel);
+ if (logger.isDebugEnabled()) {
+ logger.debug(title + " : " + file);
+ }
+ FileUtil.setCurrentDirectory(oldBasedir);
+ return file == null ? incoming : new File(file);
+ }
}
Modified: trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties
===================================================================
--- trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties 2012-08-01 16:34:48 UTC (rev 342)
+++ trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties 2012-08-01 16:35:52 UTC (rev 343)
@@ -5,6 +5,7 @@
sammoa.action.about.tip=About
sammoa.action.break.tip=Break
sammoa.action.cancel=Cancel
+sammoa.action.choose.export.directory=
sammoa.action.circleback.tip=Circle Back
sammoa.action.close=Close
sammoa.action.configuration=Configuration
@@ -12,6 +13,9 @@
sammoa.action.create=Create
sammoa.action.edit=Edit
sammoa.action.export=Export
+sammoa.action.exportEffortsMap=Export Efforts
+sammoa.action.exportMap=Export Maps
+sammoa.action.exportObservationsMap=Export Observations
sammoa.action.home=Home
sammoa.action.home.tip=Home
sammoa.action.import=Import
@@ -23,6 +27,7 @@
sammoa.action.next.tip=Next
sammoa.action.onBoard=On Board
sammoa.action.play.tip=Play
+sammoa.action.quitExportMaps=Quit
sammoa.action.reload.actions=Reload actions
sammoa.action.reload.ui=Reload sammoa ui
sammoa.action.save=Save
@@ -74,9 +79,13 @@
sammoa.label.campaign.name=Name\:
sammoa.label.campaign.observer=Observers\:
sammoa.label.campaign.period=Period\:
+sammoa.label.campaign.period.filter=Period filter
sammoa.label.campaign.region=Region\:
sammoa.label.campaign.strate=Strates\:
sammoa.label.campaign.transect=Transects\:
+sammoa.label.exportDirectory=Export directory
+sammoa.label.exportEffortsFilename=Export filename (Efforts)
+sammoa.label.exportObservationsFilename=Export filename (Observations)
sammoa.label.flight=Flight\:
sammoa.label.flight.beginDate=Start
sammoa.label.flight.comment=Comment\:
@@ -88,6 +97,10 @@
sammoa.label.region.code=Code\:
sammoa.label.region.name=Name\:
sammoa.label.region.species=Species\:
+sammoa.label.routeTypeFilter=Route type filter
+sammoa.label.speciesFilter=Species filter
+sammoa.label.speciesTypeFilter=Species type filter
+sammoa.label.strateFilter=Strate filter
sammoa.label.systemId=System Id\:
sammoa.label.transect.name=Name\:
sammoa.label.transect.strate=Strate\:
@@ -186,6 +199,8 @@
sammoa.timePattern=HH\:mm\:ss
sammoa.title.about=About Sammoa
sammoa.title.campaign=Campaign
+sammoa.title.choose.export.directory=
+sammoa.title.exportshape=
sammoa.title.flight=System %1$s - Campaign %2$s - Region %3$s - Flight n°%4$d
sammoa.title.home=Home
sammoa.title.validation=
Modified: trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_fr_FR.properties
===================================================================
--- trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_fr_FR.properties 2012-08-01 16:34:48 UTC (rev 342)
+++ trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_fr_FR.properties 2012-08-01 16:35:52 UTC (rev 343)
@@ -5,6 +5,7 @@
sammoa.action.about.tip=About
sammoa.action.break.tip=Break
sammoa.action.cancel=Cancel
+sammoa.action.choose.export.directory=
sammoa.action.circleback.tip=Circle Back
sammoa.action.close=Close
sammoa.action.configuration=Configuration
@@ -12,6 +13,9 @@
sammoa.action.create=Create
sammoa.action.edit=Edit
sammoa.action.export=Export
+sammoa.action.exportEffortsMap=Export des efforts
+sammoa.action.exportMap=Export Cartes
+sammoa.action.exportObservationsMap=Export des Observations
sammoa.action.home=Home
sammoa.action.home.tip=Home
sammoa.action.import=Import
@@ -23,6 +27,7 @@
sammoa.action.next.tip=Next
sammoa.action.onBoard=On Board
sammoa.action.play.tip=Play
+sammoa.action.quitExportMaps=Quitter
sammoa.action.reload.actions=Reload actions
sammoa.action.reload.ui=Reload sammoa ui
sammoa.action.save=Save
@@ -74,9 +79,13 @@
sammoa.label.campaign.name=Name\:
sammoa.label.campaign.observer=Observers\:
sammoa.label.campaign.period=Period\:
+sammoa.label.campaign.period.filter=Period filter
sammoa.label.campaign.region=Region\:
sammoa.label.campaign.strate=Strates\:
sammoa.label.campaign.transect=Transects\:
+sammoa.label.exportDirectory=Répertoire d'export
+sammoa.label.exportEffortsFilename=Nom du fichier (Effort)
+sammoa.label.exportObservationsFilename=Nom du fichier (Observations)
sammoa.label.flight=Flight\:
sammoa.label.flight.beginDate=Start
sammoa.label.flight.comment=Comment\:
@@ -88,6 +97,10 @@
sammoa.label.region.code=Code\:
sammoa.label.region.name=Name\:
sammoa.label.region.species=Species\:
+sammoa.label.routeTypeFilter=Route type filter
+sammoa.label.speciesFilter=Species filter
+sammoa.label.speciesTypeFilter=Species type filter
+sammoa.label.strateFilter=Strate filter
sammoa.label.systemId=System Id\:
sammoa.label.transect.name=Name\:
sammoa.label.transect.strate=Strate\:
@@ -186,6 +199,8 @@
sammoa.timePattern=HH\:mm\:ss
sammoa.title.about=About Sammoa
sammoa.title.campaign=Campaign
+sammoa.title.choose.export.directory=
+sammoa.title.exportshape=
sammoa.title.flight=System %1$s - Campaign %2$s - Region %3$s - Flight n°%4$d
sammoa.title.home=Home
sammoa.title.validation=
Added: trunk/sammoa-ui-swing/src/main/resources/icons/action-fileChooser.png
===================================================================
(Binary files differ)
Property changes on: trunk/sammoa-ui-swing/src/main/resources/icons/action-fileChooser.png
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ image/png
Added: trunk/sammoa-ui-swing/src/test/resources/logback-test.xml
===================================================================
--- trunk/sammoa-ui-swing/src/test/resources/logback-test.xml (rev 0)
+++ trunk/sammoa-ui-swing/src/test/resources/logback-test.xml 2012-08-01 16:35:52 UTC (rev 343)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ SAMMOA :: Application
+
+ $Id$
+ $HeadURL: http://svn.forge.codelutin.com/svn/sammoa/trunk/sammoa-ui-swing/src/main/re… $
+ %%
+ Copyright (C) 2012 UMS 3462, Code Lutin
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+
+<configuration>
+
+ <contextName>SAMMOA</contextName>
+
+ <property name="sammoa.log.pattern" value="%date %level [%thread] %logger [:%line] : %msg%n"/>
+
+ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>${sammoa.log.pattern}</pattern>
+ </encoder>
+ </appender>
+
+ <!--<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
+ <!--<file>${sammoa.log.file}</file>-->
+ <!--<encoder>-->
+ <!--<pattern>${sammoa.log.pattern}</pattern>-->
+ <!--</encoder>-->
+ <!--<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
+ <!--<fileNamePattern>${sammoa.log.file}-%d{yyyy-MM-dd}.log</fileNamePattern>-->
+ <!--<maxHistory>10</maxHistory>-->
+ <!--</rollingPolicy>-->
+ <!--</appender>-->
+
+ <logger name="fr.ulr.sammoa" level="INFO"/>
+
+ <root level="ERROR">
+ <!--<appender-ref ref="FILE"/>-->
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</configuration>
Property changes on: trunk/sammoa-ui-swing/src/test/resources/logback-test.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
1
0
r342 - in trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application: . map
by tchemit@users.forge.codelutin.com 01 Aug '12
by tchemit@users.forge.codelutin.com 01 Aug '12
01 Aug '12
Author: tchemit
Date: 2012-08-01 18:34:48 +0200 (Wed, 01 Aug 2012)
New Revision: 342
Url: http://forge.codelutin.com/repositories/revision/sammoa/342
Log:
refs #1203: Export SHP (add service part layout), with no implementation for the moment
Added:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapService.java
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaContext.java
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaContext.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaContext.java 2012-08-01 16:33:52 UTC (rev 341)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaContext.java 2012-08-01 16:34:48 UTC (rev 342)
@@ -29,6 +29,7 @@
import fr.ulr.sammoa.application.audio.AudioRecorderDefault;
import fr.ulr.sammoa.application.gps.GpsConfig;
import fr.ulr.sammoa.application.gps.GpsHandler;
+import fr.ulr.sammoa.application.map.ExportMapService;
import fr.ulr.sammoa.persistence.SammoaPersistence;
import java.lang.reflect.Constructor;
@@ -42,7 +43,7 @@
public class SammoaContext {
protected static SammoaContext instance;
-
+
protected SammoaConfig config;
protected SammoaPersistence persistence;
@@ -51,6 +52,8 @@
protected ReferentialService referentialService;
+ protected ExportMapService exportMapService;
+
protected AudioRecorder audioRecorder;
protected GpsHandler gpsHandler;
@@ -90,7 +93,7 @@
Class<? extends GpsHandler> gpsHandlerClass = gpsConfig.getGpsHandlerClass();
try {
- Constructor<? extends GpsHandler> constructor =
+ Constructor<? extends GpsHandler> constructor =
gpsHandlerClass.getConstructor(GpsConfig.class);
gpsHandler = constructor.newInstance(gpsConfig);
@@ -107,7 +110,7 @@
}
return gpsHandler;
}
-
+
public FlightService getFlightService() {
if (flightService == null) {
flightService = new FlightService(this);
@@ -122,6 +125,13 @@
return referentialService;
}
+ public ExportMapService getExportMapService() {
+ if (exportMapService == null) {
+ exportMapService = new ExportMapService(this);
+ }
+ return exportMapService;
+ }
+
public void open() {
persistence.open(
config.getApplicationConfig().getFlatOptions(),
Added: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java 2012-08-01 16:34:48 UTC (rev 342)
@@ -0,0 +1,113 @@
+package fr.ulr.sammoa.application.map;
+
+import com.google.common.collect.Lists;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.RouteType;
+import fr.ulr.sammoa.persistence.Species;
+import fr.ulr.sammoa.persistence.Strate;
+import fr.ulr.sammoa.persistence.StringRef;
+
+import java.io.File;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Model of export map UI.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.5
+ */
+public class ExportMapModel implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public static ExportMapModel newModel(File exportDirectory,
+ String exportFilename,
+ Campaign campaign,
+ Date beginDate,
+ Date endDate,
+ List<Strate> strates,
+ List<RouteType> routeTypes,
+ List<Species> species,
+ List<StringRef> speciesTypes) {
+ ExportMapModel result = new ExportMapModel();
+ result.exportDirectory=exportDirectory;
+ result.exportFilename=exportFilename;
+ result.campaign = campaign;
+ result.beginDate = beginDate;
+ result.endDate = endDate;
+ result.strates = strates;
+ result.routeTypes = routeTypes;
+ result.species = species;
+ result.speciesTypes = speciesTypes;
+
+ return result;
+ }
+
+ protected Campaign campaign;
+
+ protected Date beginDate;
+
+ protected Date endDate;
+
+ protected List<Strate> strates;
+
+ protected List<RouteType> routeTypes;
+
+ protected List<Species> species;
+
+ protected List<StringRef> speciesTypes;
+
+ protected File exportDirectory;
+ protected String exportFilename;
+
+ public File getExportDirectory() {
+ return exportDirectory;
+ }
+
+ public String getExportFilename() {
+ return exportFilename;
+ }
+
+ public Campaign getCampaign() {
+ return campaign;
+ }
+
+ public Date getBeginDate() {
+ return beginDate;
+ }
+
+ public Date getEndDate() {
+ return endDate;
+ }
+
+ public List<Strate> getStrates() {
+ if (strates == null) {
+ strates = Lists.newArrayList();
+ }
+ return strates;
+ }
+
+ public List<RouteType> getRouteTypes() {
+ if (routeTypes == null) {
+ routeTypes = Lists.newArrayList();
+ }
+ return routeTypes;
+ }
+
+ public List<Species> getSpecies() {
+ if (species == null) {
+ species = Lists.newArrayList();
+ }
+ return species;
+ }
+
+ public List<StringRef> getSpeciesTypes() {
+ if (speciesTypes == null) {
+ speciesTypes = Lists.newArrayList();
+ }
+ return speciesTypes;
+ }
+
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapService.java (rev 0)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapService.java 2012-08-01 16:34:48 UTC (rev 342)
@@ -0,0 +1,41 @@
+package fr.ulr.sammoa.application.map;
+
+import fr.ulr.sammoa.application.SammoaConfig;
+import fr.ulr.sammoa.application.SammoaContext;
+import fr.ulr.sammoa.persistence.SammoaPersistence;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+
+/**
+ * Export map service
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.5
+ */
+public class ExportMapService {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(ExportMapService.class);
+
+ protected SammoaContext context;
+
+ protected SammoaConfig config;
+
+ protected SammoaPersistence persistence;
+
+ public ExportMapService(SammoaContext context) {
+ this.context = context;
+ this.persistence = context.getPersistence();
+ this.config = context.getConfig();
+ }
+
+ public void exportEffortsMap(ExportMapModel dataModel) {
+
+ }
+
+ public void exportObservationsMap(ExportMapModel dataModel) {
+
+ }
+}
Property changes on: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/map/ExportMapService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
1
0
r341 - trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing
by tchemit@users.forge.codelutin.com 01 Aug '12
by tchemit@users.forge.codelutin.com 01 Aug '12
01 Aug '12
Author: tchemit
Date: 2012-08-01 18:33:52 +0200 (Wed, 01 Aug 2012)
New Revision: 341
Url: http://forge.codelutin.com/repositories/revision/sammoa/341
Log:
remove obsolete package
Removed:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/referential/
1
0
r340 - in trunk: sammoa-application/src/main/java/fr/ulr/sammoa/application sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence
by tchemit@users.forge.codelutin.com 01 Aug '12
by tchemit@users.forge.codelutin.com 01 Aug '12
01 Aug '12
Author: tchemit
Date: 2012-08-01 18:33:03 +0200 (Wed, 01 Aug 2012)
New Revision: 340
Url: http://forge.codelutin.com/repositories/revision/sammoa/340
Log:
add some methods in Referential servcie
Added:
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/SpeciesDAOImpl.java
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ReferentialService.java
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ReferentialService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ReferentialService.java 2012-08-01 16:32:14 UTC (rev 339)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ReferentialService.java 2012-08-01 16:33:03 UTC (rev 340)
@@ -28,7 +28,26 @@
import com.google.common.collect.Maps;
import fr.ulr.sammoa.application.csv.ObserverImportModel;
import fr.ulr.sammoa.application.csv.SpeciesImportModel;
-import fr.ulr.sammoa.persistence.*;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.CampaignDAO;
+import fr.ulr.sammoa.persistence.Observer;
+import fr.ulr.sammoa.persistence.ObserverDAO;
+import fr.ulr.sammoa.persistence.Observers;
+import fr.ulr.sammoa.persistence.Region;
+import fr.ulr.sammoa.persistence.RegionDAO;
+import fr.ulr.sammoa.persistence.SammoaDAOHelper;
+import fr.ulr.sammoa.persistence.SammoaPersistence;
+import fr.ulr.sammoa.persistence.Sector;
+import fr.ulr.sammoa.persistence.SectorDAO;
+import fr.ulr.sammoa.persistence.Sectors;
+import fr.ulr.sammoa.persistence.Species;
+import fr.ulr.sammoa.persistence.SpeciesDAO;
+import fr.ulr.sammoa.persistence.Strate;
+import fr.ulr.sammoa.persistence.StrateDAO;
+import fr.ulr.sammoa.persistence.StrateType;
+import fr.ulr.sammoa.persistence.Strates;
+import fr.ulr.sammoa.persistence.Transect;
+import fr.ulr.sammoa.persistence.TransectDAO;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaRuntimeException;
@@ -210,7 +229,7 @@
}
return result;
}
-
+
public String saveCampaign(Campaign campaign) {
Preconditions.checkArgument(campaign != null);
@@ -221,7 +240,7 @@
Preconditions.checkArgument(campaign.getRegion() != null);
String result;
-
+
TopiaContext transaction = persistence.beginTransaction();
try {
@@ -250,9 +269,9 @@
existCampaign.setEndDate(campaign.getEndDate());
dao.update(existCampaign);
}
-
- transaction.commitTransaction();
+ transaction.commitTransaction();
+
} catch (TopiaException e) {
throw new TopiaRuntimeException(e);
@@ -271,7 +290,7 @@
CampaignDAO dao = SammoaDAOHelper.getCampaignDAO(transaction);
result = dao.findByTopiaId(topiaId);
-
+
} catch (TopiaException e) {
throw new TopiaRuntimeException(e);
@@ -283,23 +302,58 @@
public List<Transect> getAllTransects(Campaign campaign) {
- List<Transect> result;
TopiaContext transaction = persistence.beginTransaction();
try {
TransectDAO dao = SammoaDAOHelper.getTransectDAO(transaction);
- result = dao.findAllByCampaignOrderedByName(campaign);
+ List<Transect> result =
+ dao.findAllByCampaignOrderedByName(campaign);
+ return result;
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+ } finally {
+ persistence.endTransaction(transaction);
+ }
+ }
+
+ public List<Strate> getAllStrates(Campaign campaign) {
+ TopiaContext transaction = persistence.beginTransaction();
+ try {
+
+ StrateDAO dao = SammoaDAOHelper.getStrateDAO(transaction);
+
+ List<Strate> result =
+ dao.findAllByCampaignOrderedByCode(campaign);
+ return result;
+
} catch (TopiaException e) {
throw new TopiaRuntimeException(e);
} finally {
persistence.endTransaction(transaction);
}
- return result;
}
+ public List<Species> getAllSpecies(Campaign campaign) {
+ TopiaContext transaction = persistence.beginTransaction();
+ try {
+
+ SpeciesDAO dao = SammoaDAOHelper.getSpeciesDAO(transaction);
+
+ List<Species> result =
+ dao.findAllByRegion(campaign.getRegion());
+ return result;
+
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+
+ } finally {
+ persistence.endTransaction(transaction);
+ }
+ }
+
public int importTransects(String campaignId, Iterable<Transect> transects) {
int result = 0;
@@ -362,7 +416,7 @@
result++;
if (logger.isDebugEnabled()) {
- logger.debug(String.format("Create new transect %1$s"+
+ logger.debug(String.format("Create new transect %1$s" +
"(graphicIndex = %2$d)",
newTransect.getName(),
graphicIndex)
@@ -553,7 +607,42 @@
return result;
}
-
+
+ public List<String> getAllSpeciesTypes() {
+ TopiaContext tx = persistence.beginTransaction();
+ try {
+
+ List<String> result =
+ SammoaDAOHelper.getSpeciesDAO(tx).findAllSpeciesTypes();
+
+ Collections.sort(result);
+
+ return result;
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+
+ } finally {
+ persistence.endTransaction(tx);
+ }
+
+ }
+
+ public List<Species> getAllSpecies() {
+ TopiaContext tx = persistence.beginTransaction();
+ try {
+
+ List<Species> result = SammoaDAOHelper.getSpeciesDAO(tx).findAll();
+ return result;
+
+ } catch (TopiaException e) {
+ throw new TopiaRuntimeException(e);
+
+ } finally {
+ persistence.endTransaction(tx);
+ }
+
+ }
+
public int importObservers(String campaignId, Reader reader) {
TopiaContext transaction = persistence.beginTransaction();
@@ -565,14 +654,14 @@
ObserverDAO observerDAO =
SammoaDAOHelper.getObserverDAO(transaction);
-
+
ObserverImportModel model = new ObserverImportModel(campaign);
Import<Observer> importCsv = Import.newImport(model, reader);
Iterator<Observer> it = importCsv.iterator();
while (it.hasNext()) {
-
+
Observer observer;
observer = it.next();
@@ -602,9 +691,9 @@
}
}
}
-
+
transaction.commitTransaction();
-
+
} catch (TopiaException e) {
throw new TopiaRuntimeException(e);
Added: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/SpeciesDAOImpl.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/SpeciesDAOImpl.java (rev 0)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/SpeciesDAOImpl.java 2012-08-01 16:33:03 UTC (rev 340)
@@ -0,0 +1,21 @@
+package fr.ulr.sammoa.persistence;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import org.nuiton.topia.TopiaException;
+
+import java.util.List;
+import java.util.Set;
+
+public class SpeciesDAOImpl<E extends Species> extends SpeciesDAOAbstract<E> {
+
+ public List<String> findAllSpeciesTypes() throws TopiaException {
+ Set<String> result = Sets.newHashSet();
+ List<E> all = findAll();
+ for (E e : all) {
+ result.add(e.getType());
+ }
+ return Lists.newArrayList(result);
+ }
+
+} //SpeciesDAOImpl<E extends Species>
Property changes on: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/SpeciesDAOImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
1
0
r339 - in trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations: . action
by tchemit@users.forge.codelutin.com 01 Aug '12
by tchemit@users.forge.codelutin.com 01 Aug '12
01 Aug '12
Author: tchemit
Date: 2012-08-01 18:32:14 +0200 (Wed, 01 Aug 2012)
New Revision: 339
Url: http://forge.codelutin.com/repositories/revision/sammoa/339
Log:
refacotr and clean observatiosn package
Added:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ForceSelectionSelectionModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationTableModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteTableModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToNextEditableCellAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToNextRowEditableAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToPreviousEditableCellAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToPreviousRowEditableAction.java
Removed:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ForceSelectionSelectionModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationForSelectedRouteHighlightPredicate.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationRouteTable.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationTableListSelectionListener.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationTableModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteNoModificationHighlightPredicate.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteTableListSelectionListener.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteTableModel.java
Modified:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/EffortPanel.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/EffortPanelHandler.java
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/EffortPanel.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/EffortPanel.jaxx 2012-08-01 15:26:31 UTC (rev 338)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/EffortPanel.jaxx 2012-08-01 16:32:14 UTC (rev 339)
@@ -36,6 +36,7 @@
fr.ulr.sammoa.ui.swing.flight.FlightUIModel
org.nuiton.validator.bean.list.BeanListValidator
+ org.jdesktop.swingx.JXTable
jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer
jaxx.runtime.swing.model.GenericListModel
@@ -63,14 +64,14 @@
<RouteTableModel id='routeTableModel'
initializer='new RouteTableModel(flightUIModel)'/>
- <RouteTableListSelectionListener id='routeSelectionModel'
- constructorParams='flightUIModel'/>
+ <!--RouteTableListSelectionListener id='routeSelectionModel'
+ constructorParams='flightUIModel'/-->
<ObservationTableModel id='observationTableModel'
constructorParams='flightUIModel'/>
- <ObservationTableListSelectionListener id='observationSelectionModel'
- constructorParams='flightUIModel'/>
+ <!--ObservationTableListSelectionListener id='observationSelectionModel'
+ constructorParams='flightUIModel'/-->
<!-- validator -->
<BeanListValidator id='routeValidator' genericType='Route'
@@ -131,8 +132,7 @@
<row>
<cell fill='both' weightx='1.0' weighty='1.0' columns='10'>
<JScrollPane id='routeTableScroll'>
- <ObservationRouteTable id='routeTable'
- constructorParams='_("sammoa.timePattern"), routeSelectionModel'/>
+ <JXTable id='routeTable'/>
</JScrollPane>
</cell>
</row>
@@ -161,8 +161,7 @@
<row>
<cell fill='both' weightx='1.0' weighty='1.0' columns='4'>
<JScrollPane id='observationTableScroll'>
- <ObservationRouteTable id='observationTable'
- constructorParams='_("sammoa.timePattern"), observationSelectionModel'/>
+ <JXTable id='observationTable' />
</JScrollPane>
</cell>
</row>
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/EffortPanelHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/EffortPanelHandler.java 2012-08-01 15:26:31 UTC (rev 338)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/EffortPanelHandler.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -31,19 +31,29 @@
import fr.ulr.sammoa.persistence.GeoPoint;
import fr.ulr.sammoa.persistence.Observation;
import fr.ulr.sammoa.persistence.ObservationStatus;
+import fr.ulr.sammoa.persistence.Observations;
import fr.ulr.sammoa.persistence.Observer;
import fr.ulr.sammoa.persistence.ObserverPosition;
import fr.ulr.sammoa.persistence.Position;
import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.Routes;
import fr.ulr.sammoa.ui.swing.SammoaColors;
import fr.ulr.sammoa.ui.swing.SammoaDecoratorProvider;
import fr.ulr.sammoa.ui.swing.SammoaUIContext;
import fr.ulr.sammoa.ui.swing.action.CircleBackAction;
+import fr.ulr.sammoa.ui.swing.observations.action.MoveToNextEditableCellAction;
+import fr.ulr.sammoa.ui.swing.observations.action.MoveToNextRowEditableAction;
+import fr.ulr.sammoa.ui.swing.observations.action.MoveToPreviousEditableCellAction;
+import fr.ulr.sammoa.ui.swing.observations.action.MoveToPreviousRowEditableAction;
import fr.ulr.sammoa.ui.swing.flight.FlightUIHandler;
import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import fr.ulr.sammoa.ui.swing.util.AbstractRowHighlightPredicate;
import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
import fr.ulr.sammoa.ui.swing.util.TableDataChangeListener;
+import fr.ulr.sammoa.ui.swing.util.TextCellEditor;
import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.JAXXWidgetUtil;
+import jaxx.runtime.swing.editor.cell.NumberCellEditor;
import jaxx.runtime.validator.swing.SwingListValidatorDataLocator;
import jaxx.runtime.validator.swing.SwingListValidatorHighlightPredicate;
import jaxx.runtime.validator.swing.SwingListValidatorMessageTableModel;
@@ -64,16 +74,29 @@
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.ListSelectionModel;
+import javax.swing.border.LineBorder;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import java.awt.Color;
import java.awt.Component;
+import java.awt.Rectangle;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.Date;
import java.util.List;
+import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
/**
@@ -136,6 +159,53 @@
JXTable dataTable = ui.getRouteTable();
+ init(dataTable, new ListSelectionListener() {
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+
+ if (!e.getValueIsAdjusting()) {
+
+ ListSelectionModel listSelectionModel =
+ (ListSelectionModel) e.getSource();
+ int firstIndex = e.getFirstIndex();
+ int lastIndex = e.getLastIndex();
+ Integer newSelectedRow = null;
+
+ if (listSelectionModel.isSelectionEmpty()) {
+
+ // no selection
+ } else if (listSelectionModel.isSelectedIndex(firstIndex)) {
+
+ // use first index
+ newSelectedRow = firstIndex;
+ } else if (listSelectionModel.isSelectedIndex(lastIndex)) {
+
+ // use last index
+ newSelectedRow = lastIndex;
+ }
+ FlightUIModel flightUIModel = ui.getFlightUIModel();
+ List<Route> routes = flightUIModel.getRoutes();
+ Route route = null;
+
+ if (newSelectedRow != null &&
+ newSelectedRow < routes.size()) {
+ route = routes.get(newSelectedRow);
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Select route from index {}", newSelectedRow);
+ }
+ } else {
+ if (logger.isInfoEnabled()) {
+ logger.info("No route selected");
+ }
+ }
+
+ // set new route in model to validate
+ flightUIModel.setRouteEditBean(route);
+ }
+ }
+ });
+
SwingUtil.setI18nTableHeaderRenderer(
dataTable,
n_("sammoa.observations.routeTable.column.effortNumber"),
@@ -307,6 +377,55 @@
n_("sammoa.observations.observationTable.column.circleback.tip")
);
+// init(dataTable, new ObservationTableListSelectionListener(ui.getFlightUIModel()));
+ init(dataTable, new ListSelectionListener() {
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+
+ FlightUIModel flightUIModel = ui.getFlightUIModel();
+
+ if (!e.getValueIsAdjusting()) {
+
+ ListSelectionModel listSelectionModel =
+ (ListSelectionModel) e.getSource();
+ int firstIndex = e.getFirstIndex();
+ int lastIndex = e.getLastIndex();
+ Integer newSelectedRow = null;
+
+ if (listSelectionModel.isSelectionEmpty()) {
+
+ // no selection
+ } else if (listSelectionModel.isSelectedIndex(firstIndex)) {
+
+ // use first index
+ newSelectedRow = firstIndex;
+ } else if (listSelectionModel.isSelectedIndex(lastIndex)) {
+
+ // use last index
+ newSelectedRow = lastIndex;
+ }
+ List<Observation> observations = flightUIModel.getObservations();
+ Observation observation = null;
+
+ if (newSelectedRow != null &&
+ newSelectedRow < observations.size()) {
+ observation = observations.get(newSelectedRow);
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Select observation from index {}", newSelectedRow);
+ }
+ } else {
+ if (logger.isInfoEnabled()) {
+ logger.info("No observation selected");
+ }
+ }
+
+ // set new observation in model to validate
+ flightUIModel.setObservationEditBean(observation);
+ }
+ }
+ });
+
// set renderer and editor as button for circle back action
int circleBack = ObservationTableModel.ObservationColumn.CIRCLE_BACK.ordinal();
CircleBackEditorRenderer editorRenderer = new CircleBackEditorRenderer(getFlightUIModel());
@@ -451,6 +570,112 @@
return SammoaUIContext.getUIContext().getDecoratorProvider();
}
+
+ public static void init(final JXTable table,
+ ListSelectionListener selectionListener) {
+
+ // make tab key to focus only next editable cell
+ table.setSelectionModel(new ForceSelectionSelectionModel());
+
+ table.setSortable(false);
+
+ table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
+
+ final Action moveToNextEditableCell = new MoveToNextEditableCellAction(table);
+ final Action moveToPreviousEditableCell = new MoveToPreviousEditableCellAction(table);
+ final Action moveToPreviousRowEditableCell = new MoveToPreviousRowEditableAction(table);
+ final Action moveToNextRowEditableCell = new MoveToNextRowEditableAction(table);
+
+ // redéfini les comportements par defaut de la table par les notres
+ table.getActionMap().put("selectNextRowCell", moveToNextEditableCell);
+ table.getActionMap().put("selectNextColumnCell", moveToNextEditableCell);
+ table.getActionMap().put("selectNextColumn", moveToNextEditableCell);
+ table.getActionMap().put("selectPreviousColumn", moveToPreviousEditableCell);
+
+ // Key adapter à ajouter sur les éditeurs où l'on souhaite gérer les
+ // touches "entrer", "gauche", "doite" de facon personnalisée.
+ KeyListener goNextCellAdapter = new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER ||
+ e.getKeyCode() == KeyEvent.VK_RIGHT) {
+ e.consume();
+ moveToNextEditableCell.actionPerformed(null);
+ } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
+ e.consume();
+ moveToPreviousEditableCell.actionPerformed(null);
+ } else if (e.getKeyCode() == KeyEvent.VK_UP) {
+ e.consume();
+ moveToPreviousRowEditableCell.actionPerformed(null);
+ } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
+ e.consume();
+ moveToNextRowEditableCell.actionPerformed(null);
+ }
+ }
+ };
+
+ // TextCellEditor
+ {
+ TextCellEditor editor = new TextCellEditor();
+ JTextField textField = editor.getComponent();
+ textField.addKeyListener(goNextCellAdapter);
+ textField.setBorder(new LineBorder(Color.GRAY, 2));
+// textField.setBorder(BasicBorders.getTextFieldBorder());
+ table.setDefaultEditor(String.class, editor);
+ }
+ // NumberCellEditor
+ {
+ NumberCellEditor<Integer> editor = JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, false);
+ editor.getNumberEditor().setSelectAllTextOnError(true);
+ JTextField textField = editor.getNumberEditor().getTextField();
+ textField.addKeyListener(goNextCellAdapter);
+ textField.setBorder(new LineBorder(Color.GRAY, 2));
+// textField.setBorder(BasicBorders.getTextFieldBorder());
+ table.setDefaultEditor(int.class, editor);
+ table.setDefaultEditor(Integer.class, editor);
+ }
+
+ // Boolean editor
+ {
+ TableCellEditor editor = table.getDefaultEditor(Boolean.class);
+ table.setDefaultEditor(boolean.class, editor);
+ TableCellRenderer renderer = table.getDefaultRenderer(Boolean.class);
+ table.setDefaultRenderer(boolean.class, renderer);
+ }
+
+ // Renderers
+ TableCellRenderer defaultDateCellRenderer = table.getDefaultRenderer(Date.class);
+ table.setDefaultRenderer(Date.class, JAXXWidgetUtil.newDateTableCellRenderer(defaultDateCellRenderer, _("sammoa.timePattern")));
+
+ table.getSelectionModel().addListSelectionListener(selectionListener);
+
+ SwingUtil.scrollToTableSelection(table);
+
+ table.getModel().addTableModelListener(new TableModelListener() {
+ @Override
+ public void tableChanged(TableModelEvent e) {
+ switch (e.getType()) {
+ case TableModelEvent.INSERT:
+
+ // auto select new added line
+ table.getSelectionModel().setSelectionInterval(e.getFirstRow(), e.getFirstRow());
+ Rectangle rect = table.getCellRect(e.getFirstRow(), 0, true);
+ table.scrollRectToVisible(rect);
+ break;
+
+ case TableModelEvent.DELETE:
+ case TableModelEvent.UPDATE:
+
+ // auto select first line ?
+ if (table.getSelectedRow() < 0 && table.getRowCount() > 0) {
+ table.getSelectionModel().setSelectionInterval(0, 0);
+ }
+ break;
+ }
+ }
+ });
+ }
+
private static class RouteValidatorDataLocator implements SwingListValidatorDataLocator<Route> {
@Override
@@ -558,4 +783,74 @@
}
}
+ public static class ObservationForSelectedRouteHighlightPredicate extends AbstractRowHighlightPredicate {
+
+ protected FlightUIModel UIModel;
+
+ public ObservationForSelectedRouteHighlightPredicate(FlightUIModel UIModel) {
+ this.UIModel = UIModel;
+ }
+
+ @Override
+ protected boolean isHighlighted(int rowIndex) {
+
+ Route selectedRoute = UIModel.getRouteEditBean();
+
+ boolean result;
+ if (selectedRoute != null) {
+
+ Route nextRoute = UIModel.getNextRoute(selectedRoute);
+
+ Observation observation = getValueAt(rowIndex);
+
+ result = Observations.inRoute(observation, selectedRoute, nextRoute);
+
+ } else {
+ result = false;
+ }
+ return result;
+ }
+
+ @Override
+ protected Observation getValueAt(int rowIndex) {
+ return UIModel.getObservations().get(rowIndex);
+ }
+ }
+
+ public class RouteNoModificationHighlightPredicate extends AbstractRowHighlightPredicate {
+
+ protected RouteTableModel model;
+
+ public RouteNoModificationHighlightPredicate(RouteTableModel model) {
+ this.model = model;
+ }
+
+ @Override
+ protected boolean isHighlighted(int rowIndex) {
+
+ Route route = getValueAt(rowIndex);
+
+ boolean result = false;
+
+ if (route.isDeleted()) {
+ // do nothing
+
+ } else {
+
+ int previousRouteIndex = rowIndex - 1;
+ if (previousRouteIndex >= 0) {
+
+ Route previousRoute = getValueAt(previousRouteIndex);
+
+ result = Routes.equal(route, previousRoute);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ protected Route getValueAt(int rowIndex) {
+ return model.getRow(rowIndex);
+ }
+ }
}
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ForceSelectionSelectionModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ForceSelectionSelectionModel.java 2012-08-01 15:26:31 UTC (rev 338)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ForceSelectionSelectionModel.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -1,59 +0,0 @@
-/*
- * #%L
- * SAMMOA :: UI Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ulr.sammoa.ui.swing.observations;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.swing.DefaultListSelectionModel;
-
-/**
- * Surcharge de modele de selection par default pour empecher la deselection
- * de la dernière ligne et pour qu'il y est toujours une ligne selectionnée.
- *
- * @author echatellier
- */
-public class ForceSelectionSelectionModel extends DefaultListSelectionModel {
-
- private static final Logger logger =
- LoggerFactory.getLogger(ForceSelectionSelectionModel.class);
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public int getSelectionMode() {
- return SINGLE_SELECTION;
- }
-
- @Override
- public void removeSelectionInterval(int index0, int index1) {
- // don't do anything
- if (logger.isDebugEnabled()) {
- logger.debug("don't remove selection interval ({}, {})",
- index0, index1);
- }
- }
-}
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ForceSelectionSelectionModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ForceSelectionSelectionModel.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ForceSelectionSelectionModel.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -0,0 +1,59 @@
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ *
+ * $Id$
+ * $HeadURL: http://svn.forge.codelutin.com/svn/sammoa/trunk/sammoa-ui-swing/src/main/ja… $
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ulr.sammoa.ui.swing.observations;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.DefaultListSelectionModel;
+
+/**
+ * Surcharge de modele de selection par default pour empecher la deselection
+ * de la dernière ligne et pour qu'il y est toujours une ligne selectionnée.
+ *
+ * @author echatellier
+ */
+public class ForceSelectionSelectionModel extends DefaultListSelectionModel {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(ForceSelectionSelectionModel.class);
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public int getSelectionMode() {
+ return SINGLE_SELECTION;
+ }
+
+ @Override
+ public void removeSelectionInterval(int index0, int index1) {
+ // don't do anything
+ if (logger.isDebugEnabled()) {
+ logger.debug("don't remove selection interval ({}, {})",
+ index0, index1);
+ }
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ForceSelectionSelectionModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationForSelectedRouteHighlightPredicate.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationForSelectedRouteHighlightPredicate.java 2012-08-01 15:26:31 UTC (rev 338)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationForSelectedRouteHighlightPredicate.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -1,69 +0,0 @@
-package fr.ulr.sammoa.ui.swing.observations;
-/*
- * #%L
- * SAMMOA :: UI Swing
- * $Id:$
- * $HeadURL:$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy 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.ulr.sammoa.persistence.Observation;
-import fr.ulr.sammoa.persistence.Observations;
-import fr.ulr.sammoa.persistence.Route;
-import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
-import fr.ulr.sammoa.ui.swing.util.AbstractRowHighlightPredicate;
-
-/**
- * Created: 16/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public class ObservationForSelectedRouteHighlightPredicate extends AbstractRowHighlightPredicate {
-
- protected FlightUIModel UIModel;
-
- public ObservationForSelectedRouteHighlightPredicate(FlightUIModel UIModel) {
- this.UIModel = UIModel;
- }
-
- @Override
- protected boolean isHighlighted(int rowIndex) {
-
- Route selectedRoute = UIModel.getRouteEditBean();
-
- boolean result;
- if (selectedRoute != null) {
-
- Route nextRoute = UIModel.getNextRoute(selectedRoute);
-
- Observation observation = getValueAt(rowIndex);
-
- result = Observations.inRoute(observation, selectedRoute, nextRoute);
-
- } else {
- result = false;
- }
- return result;
- }
-
- @Override
- protected Observation getValueAt(int rowIndex) {
- return UIModel.getObservations().get(rowIndex);
- }
-}
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationRouteTable.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationRouteTable.java 2012-08-01 15:26:31 UTC (rev 338)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationRouteTable.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -1,321 +0,0 @@
-/*
- * #%L
- * SAMMOA :: UI Swing
- * *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ulr.sammoa.ui.swing.observations;
-
-import fr.ulr.sammoa.ui.swing.util.TextCellEditor;
-import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.JAXXWidgetUtil;
-import jaxx.runtime.swing.editor.cell.NumberCellEditor;
-import org.jdesktop.swingx.JXTable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.swing.AbstractAction;
-import javax.swing.JTextField;
-import javax.swing.border.LineBorder;
-import javax.swing.event.ListSelectionListener;
-import javax.swing.event.TableModelEvent;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-import java.awt.Color;
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.util.Date;
-
-/**
- * Redefinition d'une table pour initialiser la selection par defaut
- * et forcer toujours une selection.
- * <p/>
- * http://www.jroller.com/santhosh/entry/tweaking_jtable_editing
- *
- * @author echatellier
- */
-public class ObservationRouteTable extends JXTable {
-
- private static final Logger logger = LoggerFactory.getLogger(ObservationRouteTable.class);
-
- private static final long serialVersionUID = 1L;
-
- /** Action qui se déplace à la prochaine cellule editable. */
- protected AbstractAction moveToNextEditableCell = new AbstractAction() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void actionPerformed(ActionEvent evt) {
-
- int currentRow = getSelectedRow();
- int currentColumn = getSelectedColumn();
-
- logger.debug("Move to next editable cell, {}, {}", currentRow, currentColumn);
-
- while (currentRow <= getRowCount() || currentColumn <= getColumnCount()) {
-
- // go to next cell
- currentColumn++;
-
- // select next cell
- if (currentColumn >= getColumnCount()) {
- currentColumn = 0;
- currentRow++;
- }
-
- if (isCellEditable(currentRow, currentColumn)) {
- doSelectCell(currentRow, currentColumn);
-// // select cell
-// setColumnSelectionInterval(currentColumn, currentColumn);
-// setRowSelectionInterval(currentRow, currentRow);
-// editCellAt(currentRow, currentColumn);
-// logger.debug("While select cell at {}, {}", currentRow, currentColumn);
- break;
- } else {
- logger.debug("Cell at {}, {} not editable", currentRow, currentColumn);
- }
- }
- }
- };
-
- /** Action qui se déplace à la cellule editable précédente. */
- protected AbstractAction moveToPreviousEditableCell = new AbstractAction() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void actionPerformed(ActionEvent evt) {
-
- int currentRow = getSelectedRow();
- int currentColumn = getSelectedColumn();
-
- logger.debug("Move to previous editable cell, {}, {}", currentRow, currentColumn);
-
-
- while (currentRow > 0 || currentColumn > 0) {
-
- // go to next cell
- currentColumn--;
-
- // select next cell
- if (currentColumn < 0) {
- currentColumn = getColumnCount() - 1;
- currentRow--;
- }
-
- if (isCellEditable(currentRow, currentColumn)) {
- doSelectCell(currentRow, currentColumn);
-// // select cell
-// setColumnSelectionInterval(currentColumn, currentColumn);
-// setRowSelectionInterval(currentRow, currentRow);
-// logger.debug("While select cell at {}, {}", currentRow, currentColumn);
-// editCellAt(currentRow, currentColumn);
- break;
- } else {
- logger.debug("Cell at {}, {} not editable", currentRow, currentColumn);
- }
- }
- }
- };
-
- /** Action qui se déplace à la cellule editable de la ligne du dessus (il faut que la cellule courant soit aussi éditable). */
- protected AbstractAction moveToPreviousRowEditableCell = new AbstractAction() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void actionPerformed(ActionEvent evt) {
-
- int currentRow = getSelectedRow();
- int currentColumn = getSelectedColumn();
-
- if (isCellEditable(currentRow, currentColumn)) {
- logger.debug("Move to previous row editable cell, {}, {}", currentRow, currentColumn);
- currentRow--;
-
- if (currentRow < 0) {
- logger.debug("No previous row");
- } else {
- doSelectCell(currentRow, currentColumn);
- }
- } else {
- logger.debug("Cell at {}, {} not editable", currentRow, currentColumn);
- }
- }
- };
-
- /** Action qui se déplace à la cellule editable de la ligne du dessus (il faut que la cellule courant soit aussi éditable). */
- protected AbstractAction moveToNextRowEditableCell = new AbstractAction() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void actionPerformed(ActionEvent evt) {
-
- int currentRow = getSelectedRow();
- int currentColumn = getSelectedColumn();
-
- if (isCellEditable(currentRow, currentColumn)) {
- logger.debug("Move to next row editable cell, {}, {}", currentRow, currentColumn);
- currentRow++;
-
- if (currentRow >= getRowCount()) {
- logger.debug("No next row");
- } else {
- doSelectCell(currentRow, currentColumn);
- }
- } else {
- logger.debug("Cell at {}, {} not editable", currentRow, currentColumn);
- }
- }
- };
-
- protected void doSelectCell(int currentRow, int currentColumn) {
- setColumnSelectionInterval(currentColumn, currentColumn);
- setRowSelectionInterval(currentRow, currentRow);
- logger.debug("While select cell at {}, {}", currentRow, currentColumn);
- editCellAt(currentRow, currentColumn);
- }
-
- /**
- * Key adapter à ajouter sur les éditeurs où l'on souhaite gérer les
- * touches "entrer", "gauche", "doite" de facon personnalisée.
- */
-// protected KeyListener goNextCellAdapter = new KeyAdapter() {
-// @Override
-// public void keyPressed(KeyEvent e) {
-// if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_RIGHT) {
-// e.consume();
-// moveToNextEditableCell.actionPerformed(null);
-// } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
-// e.consume();
-// moveToPreviousEditableCell.actionPerformed(null);
-// }
-// }
-// };
- public ObservationRouteTable(String datePattern,
- ListSelectionListener selectionListener) {
-
- // make tab key to focus only next editable cell
- setSelectionModel(new ForceSelectionSelectionModel());
-
- setSortable(false);
-
- putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
-
- // redéfini les comportements par defaut de la table par les notres
- getActionMap().put("selectNextRowCell", moveToNextEditableCell);
- getActionMap().put("selectNextColumnCell", moveToNextEditableCell);
- getActionMap().put("selectNextColumn", moveToNextEditableCell);
- getActionMap().put("selectPreviousColumn", moveToPreviousEditableCell);
-
- // Key adapter à ajouter sur les éditeurs où l'on souhaite gérer les
- // touches "entrer", "gauche", "doite" de facon personnalisée.
- KeyListener goNextCellAdapter = new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_ENTER ||
- e.getKeyCode() == KeyEvent.VK_RIGHT) {
- e.consume();
- moveToNextEditableCell.actionPerformed(null);
- } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
- e.consume();
- moveToPreviousEditableCell.actionPerformed(null);
- } else if (e.getKeyCode() == KeyEvent.VK_UP) {
- e.consume();
- moveToPreviousRowEditableCell.actionPerformed(null);
- } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
- e.consume();
- moveToNextRowEditableCell.actionPerformed(null);
- }
- }
- };
-
- // TextCellEditor
- {
- TextCellEditor editor = new TextCellEditor();
- JTextField textField = editor.getComponent();
- textField.addKeyListener(goNextCellAdapter);
- textField.setBorder(new LineBorder(Color.GRAY, 2));
-// textField.setBorder(BasicBorders.getTextFieldBorder());
- setDefaultEditor(String.class, editor);
- }
- // NumberCellEditor
- {
- NumberCellEditor<Integer> editor = JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, false);
- editor.getNumberEditor().setSelectAllTextOnError(true);
- JTextField textField = editor.getNumberEditor().getTextField();
- textField.addKeyListener(goNextCellAdapter);
- textField.setBorder(new LineBorder(Color.GRAY, 2));
-// textField.setBorder(BasicBorders.getTextFieldBorder());
- setDefaultEditor(int.class, editor);
- setDefaultEditor(Integer.class, editor);
- }
-
- // Boolean editor
- {
- TableCellEditor editor = getDefaultEditor(Boolean.class);
- setDefaultEditor(boolean.class, editor);
- TableCellRenderer renderer = getDefaultRenderer(Boolean.class);
- setDefaultRenderer(boolean.class, renderer);
- }
-
- // Renderers
- TableCellRenderer defaultDateCellRenderer = getDefaultRenderer(Date.class);
- setDefaultRenderer(Date.class, JAXXWidgetUtil.newDateTableCellRenderer(defaultDateCellRenderer, datePattern));
-
- if (selectionListener != null) {
- getSelectionModel().addListSelectionListener(selectionListener);
- }
-
- SwingUtil.scrollToTableSelection(this);
- }
-
- /** Appellé lorsque les données changent. */
- @Override
- public void tableChanged(TableModelEvent e) {
- super.tableChanged(e);
-
- switch (e.getType()) {
- case TableModelEvent.INSERT:
-
- // auto select new added line
- getSelectionModel().setSelectionInterval(e.getFirstRow(), e.getFirstRow());
- Rectangle rect = getCellRect(e.getFirstRow(), 0, true);
- scrollRectToVisible(rect);
- break;
-
- case TableModelEvent.DELETE:
- case TableModelEvent.UPDATE:
-
- // auto select first line ?
- if (getSelectedRow() < 0 && getRowCount() > 0) {
- getSelectionModel().setSelectionInterval(0, 0);
- }
- break;
- }
- }
-}
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationTableListSelectionListener.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationTableListSelectionListener.java 2012-08-01 15:26:31 UTC (rev 338)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationTableListSelectionListener.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -1,99 +0,0 @@
-/*
- * #%L
- * SAMMOA :: UI Swing
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-package fr.ulr.sammoa.ui.swing.observations;
-
-import com.google.common.base.Preconditions;
-import fr.ulr.sammoa.persistence.Observation;
-import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.swing.ListSelectionModel;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import java.util.List;
-
-/**
- * Listen the observation table selection model to set the
- * {@link FlightUIModel#observationEditBean} which isten the validator.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class ObservationTableListSelectionListener implements ListSelectionListener {
-
- private static final Logger logger =
- LoggerFactory.getLogger(ObservationTableListSelectionListener.class);
-
- protected final FlightUIModel flightUIModel;
-
- public ObservationTableListSelectionListener(FlightUIModel flightUIModel) {
- Preconditions.checkNotNull(flightUIModel);
- this.flightUIModel = flightUIModel;
- }
-
- @Override
- public void valueChanged(ListSelectionEvent e) {
-
- if (!e.getValueIsAdjusting()) {
-
- ListSelectionModel listSelectionModel =
- (ListSelectionModel) e.getSource();
- int firstIndex = e.getFirstIndex();
- int lastIndex = e.getLastIndex();
- Integer newSelectedRow = null;
-
- if (listSelectionModel.isSelectionEmpty()) {
-
- // no selection
- } else if (listSelectionModel.isSelectedIndex(firstIndex)) {
-
- // use first index
- newSelectedRow = firstIndex;
- } else if (listSelectionModel.isSelectedIndex(lastIndex)) {
-
- // use last index
- newSelectedRow = lastIndex;
- }
- List<Observation> observations = flightUIModel.getObservations();
- Observation observation = null;
-
- if (newSelectedRow != null &&
- newSelectedRow < observations.size()) {
- observation = observations.get(newSelectedRow);
-
- if (logger.isInfoEnabled()) {
- logger.info("Select observation from index {}", newSelectedRow);
- }
- } else {
- if (logger.isInfoEnabled()) {
- logger.info("No observation selected");
- }
- }
-
- // set new observation in model to validate
- flightUIModel.setObservationEditBean(observation);
- }
- }
-}
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationTableModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationTableModel.java 2012-08-01 15:26:31 UTC (rev 338)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationTableModel.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -1,265 +0,0 @@
-/*
- * #%L
- * SAMMOA :: UI Swing
- * *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-package fr.ulr.sammoa.ui.swing.observations;
-
-import com.google.common.base.Strings;
-import fr.ulr.sammoa.persistence.Campaign;
-import fr.ulr.sammoa.persistence.Flight;
-import fr.ulr.sammoa.persistence.Observation;
-import fr.ulr.sammoa.persistence.ObservationStatus;
-import fr.ulr.sammoa.persistence.Observer;
-import fr.ulr.sammoa.persistence.ObserverPosition;
-import fr.ulr.sammoa.persistence.Region;
-import fr.ulr.sammoa.persistence.Species;
-import fr.ulr.sammoa.persistence.SpeciesImpl;
-import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
-import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.lang3.tuple.Pair;
-
-import javax.swing.table.AbstractTableModel;
-import java.util.Date;
-import java.util.List;
-
-/** @author sletellier <letellier(a)codelutin.com> */
-public class ObservationTableModel extends AbstractTableModel {
-
- private static final long serialVersionUID = 1L;
-
- protected FlightUIModel flightUIModel;
-
- public ObservationTableModel(FlightUIModel flightUIModel) {
- this.flightUIModel = flightUIModel;
- }
-
- @Override
- public int getRowCount() {
- return getBean().size();
- }
-
- @Override
- public int getColumnCount() {
- return ObservationColumn.values().length;
- }
-
- @Override
- public String getColumnName(int column) {
- ObservationColumn observationColumn = ObservationColumn.valueOf(column);
- return observationColumn.getColumnName();
- }
-
- @Override
- public Class<?> getColumnClass(int column) {
- ObservationColumn observationColumn = ObservationColumn.valueOf(column);
- return observationColumn.getType();
- }
-
- @Override
- public boolean isCellEditable(int row, int column) {
- ObservationColumn observationColumn = ObservationColumn.valueOf(column);
- boolean result = observationColumn.isEditable();
- return result;
- }
-
- @Override
- public Object getValueAt(int row, int column) {
- Observation observation = getBean(row);
- ObservationColumn observationColumn = ObservationColumn.valueOf(column);
- Object result = observationColumn.getValue(observation);
- return result;
- }
-
- @Override
- public void setValueAt(Object aValue, int row, int column) {
- Observation observation = getBean(row);
- ObservationColumn observationColumn = ObservationColumn.valueOf(column);
- Flight flight = observation.getFlight();
- Campaign campaign = flight.getCampaign();
- Region region = campaign.getRegion();
- observationColumn.setValue(observation, aValue, region);
- fireTableRowsUpdated(row, row);
- }
-
- public int getBeanIndex(Observation bean) {
- int row = getBean().indexOf(bean);
- return row;
- }
-
- public List<Observation> getBean() {
- return flightUIModel.getObservations();
- }
-
- public Observation getBean(int row) {
- SwingUtil.ensureRowIndex(this, row);
- Observation bean = getBean().get(row);
- return bean;
- }
-
- public Pair<Integer, Integer> getCell(Observation bean, String fieldName) {
-
- int row = getBeanIndex(bean);
- int col = ObservationColumn.getValueFromFieldName(fieldName).ordinal();
-
- Pair<Integer, Integer> cell = Pair.of(row, col);
- return cell;
- }
-
- protected enum ObservationColumn {
-
- OBSERVATION_NUMBER(false, Observation.PROPERTY_OBSERVATION_NUMBER),
- OBSERVATION_TIME(false, Date.class, Observation.PROPERTY_OBSERVATION_TIME),
- OBSERVER(false,
- Observation.PROPERTY_OBSERVER_POSITION,
- ObserverPosition.PROPERTY_OBSERVER,
- Observer.PROPERTY_INITIALS
- ),
- POD_SIZE(true, int.class, Observation.PROPERTY_POD_SIZE),
- SPECIES(true, Observation.PROPERTY_SPECIES, Species.PROPERTY_CODE) {
- @Override
- public void setValue(Observation bean, Object value, Region region) {
- String newValue = (String) value;
-
- if (!Strings.isNullOrEmpty(newValue)) {
-
- String oldValue = bean.getSpecies() == null
- ? null : bean.getSpecies().getCode();
-
- if (!newValue.equals(oldValue)) {
-
- // Always use a new instance for different value to
- // fire change on Observation and not on Species
- Species species = new SpeciesImpl((String) value, region);
- bean.setSpecies(species);
- }
-
- } else {
- bean.setSpecies(null);
- }
- }
- },
- AGE(true, Observation.PROPERTY_AGE),
- DEC_ANGLE(true, int.class, Observation.PROPERTY_DEC_ANGLE),
- CUE(true, Observation.PROPERTY_CUE),
- BEHAVIOUR(true, Observation.PROPERTY_BEHAVIOUR) {
- @Override
- public void setValue(Observation bean, Object value, Region region) {
- String newValue = (String) value;
- if (Strings.isNullOrEmpty(newValue)) {
- newValue = null;
- }
- bean.setBehaviour(newValue);
- }
- },
- SWIM_DIR(true, int.class, Observation.PROPERTY_SWIM_DIR),
- CALVES(true, Observation.PROPERTY_CALVES),
- PHOTO(true, boolean.class, Observation.PROPERTY_PHOTO),
- COMMENT(true, Observation.PROPERTY_COMMENT),
- OBSERVATION_STATUS(true, ObservationStatus.class, Observation.PROPERTY_OBSERVATION_STATUS),
- DELETED(true, boolean.class, Observation.PROPERTY_DELETED),
- CIRCLE_BACK(true, Observation.class, "circleBack") {
- @Override
- public Object getValue(Observation bean) {
- return bean;
- }
-
- @Override
- public void setValue(Observation bean, Object value, Region region) {
- }
- };
-
- private boolean editable;
-
- private String[] beanProperties;
-
- private Class<?> type;
-
- private final String columnName;
-
- private ObservationColumn(boolean editable,
- String... beanProperties) {
- this(editable, String.class, beanProperties);
- }
-
- private ObservationColumn(boolean editable,
- Class<?> type,
- String... beanProperties) {
- this.editable = editable;
- this.type = type;
- this.beanProperties = beanProperties;
- this.columnName = beanProperties[0];
- }
-
- public Class<?> getType() {
- return type;
- }
-
- public String getColumnName() {
- return columnName;
- }
-
- public int getColumnIndex() {
- return ordinal();
- }
-
- public Object getValue(Observation bean) {
- Object result = SammoaUtil.getPropertyValue(bean, beanProperties);
- return result;
- }
-
- public void setValue(Observation bean, Object value, Region region) {
- if (type.isPrimitive() && value == null) {
- // can not set a null value to a primitive field
- } else {
- SammoaUtil.setPropertyValue(bean, value, beanProperties);
- }
- }
-
- public boolean isEditable() {
- boolean result = editable;
- return result;
- }
-
- public static ObservationColumn valueOf(int ordinal) {
- for (ObservationColumn value : values()) {
- if (ordinal == value.ordinal()) {
- return value;
- }
- }
- throw new EnumConstantNotPresentException(ObservationColumn.class,
- "ordinal=" + ordinal);
- }
-
- public static ObservationColumn getValueFromFieldName(String fieldName) {
- ObservationColumn result = null;
- for (ObservationColumn value : values()) {
- if (fieldName.equals(value.columnName)) {
- result = value;
- break;
- }
- }
- return result;
- }
- }
-}
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationTableModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationTableModel.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationTableModel.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -0,0 +1,265 @@
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * *
+ * $Id$
+ * $HeadURL: http://svn.forge.codelutin.com/svn/sammoa/trunk/sammoa-ui-swing/src/main/ja… $
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+package fr.ulr.sammoa.ui.swing.observations;
+
+import com.google.common.base.Strings;
+import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.Flight;
+import fr.ulr.sammoa.persistence.Observation;
+import fr.ulr.sammoa.persistence.ObservationStatus;
+import fr.ulr.sammoa.persistence.Observer;
+import fr.ulr.sammoa.persistence.ObserverPosition;
+import fr.ulr.sammoa.persistence.Region;
+import fr.ulr.sammoa.persistence.Species;
+import fr.ulr.sammoa.persistence.SpeciesImpl;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.lang3.tuple.Pair;
+
+import javax.swing.table.AbstractTableModel;
+import java.util.Date;
+import java.util.List;
+
+/** @author sletellier <letellier(a)codelutin.com> */
+public class ObservationTableModel extends AbstractTableModel {
+
+ private static final long serialVersionUID = 1L;
+
+ protected FlightUIModel flightUIModel;
+
+ public ObservationTableModel(FlightUIModel flightUIModel) {
+ this.flightUIModel = flightUIModel;
+ }
+
+ @Override
+ public int getRowCount() {
+ return getBean().size();
+ }
+
+ @Override
+ public int getColumnCount() {
+ return ObservationColumn.values().length;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ ObservationColumn observationColumn = ObservationColumn.valueOf(column);
+ return observationColumn.getColumnName();
+ }
+
+ @Override
+ public Class<?> getColumnClass(int column) {
+ ObservationColumn observationColumn = ObservationColumn.valueOf(column);
+ return observationColumn.getType();
+ }
+
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ ObservationColumn observationColumn = ObservationColumn.valueOf(column);
+ boolean result = observationColumn.isEditable();
+ return result;
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+ Observation observation = getBean(row);
+ ObservationColumn observationColumn = ObservationColumn.valueOf(column);
+ Object result = observationColumn.getValue(observation);
+ return result;
+ }
+
+ @Override
+ public void setValueAt(Object aValue, int row, int column) {
+ Observation observation = getBean(row);
+ ObservationColumn observationColumn = ObservationColumn.valueOf(column);
+ Flight flight = observation.getFlight();
+ Campaign campaign = flight.getCampaign();
+ Region region = campaign.getRegion();
+ observationColumn.setValue(observation, aValue, region);
+ fireTableRowsUpdated(row, row);
+ }
+
+ public int getBeanIndex(Observation bean) {
+ int row = getBean().indexOf(bean);
+ return row;
+ }
+
+ public List<Observation> getBean() {
+ return flightUIModel.getObservations();
+ }
+
+ public Observation getBean(int row) {
+ SwingUtil.ensureRowIndex(this, row);
+ Observation bean = getBean().get(row);
+ return bean;
+ }
+
+ public Pair<Integer, Integer> getCell(Observation bean, String fieldName) {
+
+ int row = getBeanIndex(bean);
+ int col = ObservationColumn.getValueFromFieldName(fieldName).ordinal();
+
+ Pair<Integer, Integer> cell = Pair.of(row, col);
+ return cell;
+ }
+
+ public enum ObservationColumn {
+
+ OBSERVATION_NUMBER(false, Observation.PROPERTY_OBSERVATION_NUMBER),
+ OBSERVATION_TIME(false, Date.class, Observation.PROPERTY_OBSERVATION_TIME),
+ OBSERVER(false,
+ Observation.PROPERTY_OBSERVER_POSITION,
+ ObserverPosition.PROPERTY_OBSERVER,
+ Observer.PROPERTY_INITIALS
+ ),
+ POD_SIZE(true, int.class, Observation.PROPERTY_POD_SIZE),
+ SPECIES(true, Observation.PROPERTY_SPECIES, Species.PROPERTY_CODE) {
+ @Override
+ public void setValue(Observation bean, Object value, Region region) {
+ String newValue = (String) value;
+
+ if (!Strings.isNullOrEmpty(newValue)) {
+
+ String oldValue = bean.getSpecies() == null
+ ? null : bean.getSpecies().getCode();
+
+ if (!newValue.equals(oldValue)) {
+
+ // Always use a new instance for different value to
+ // fire change on Observation and not on Species
+ Species species = new SpeciesImpl((String) value, region);
+ bean.setSpecies(species);
+ }
+
+ } else {
+ bean.setSpecies(null);
+ }
+ }
+ },
+ AGE(true, Observation.PROPERTY_AGE),
+ DEC_ANGLE(true, int.class, Observation.PROPERTY_DEC_ANGLE),
+ CUE(true, Observation.PROPERTY_CUE),
+ BEHAVIOUR(true, Observation.PROPERTY_BEHAVIOUR) {
+ @Override
+ public void setValue(Observation bean, Object value, Region region) {
+ String newValue = (String) value;
+ if (Strings.isNullOrEmpty(newValue)) {
+ newValue = null;
+ }
+ bean.setBehaviour(newValue);
+ }
+ },
+ SWIM_DIR(true, int.class, Observation.PROPERTY_SWIM_DIR),
+ CALVES(true, Observation.PROPERTY_CALVES),
+ PHOTO(true, boolean.class, Observation.PROPERTY_PHOTO),
+ COMMENT(true, Observation.PROPERTY_COMMENT),
+ OBSERVATION_STATUS(true, ObservationStatus.class, Observation.PROPERTY_OBSERVATION_STATUS),
+ DELETED(true, boolean.class, Observation.PROPERTY_DELETED),
+ CIRCLE_BACK(true, Observation.class, "circleBack") {
+ @Override
+ public Object getValue(Observation bean) {
+ return bean;
+ }
+
+ @Override
+ public void setValue(Observation bean, Object value, Region region) {
+ }
+ };
+
+ private boolean editable;
+
+ private String[] beanProperties;
+
+ private Class<?> type;
+
+ private final String columnName;
+
+ private ObservationColumn(boolean editable,
+ String... beanProperties) {
+ this(editable, String.class, beanProperties);
+ }
+
+ private ObservationColumn(boolean editable,
+ Class<?> type,
+ String... beanProperties) {
+ this.editable = editable;
+ this.type = type;
+ this.beanProperties = beanProperties;
+ this.columnName = beanProperties[0];
+ }
+
+ public Class<?> getType() {
+ return type;
+ }
+
+ public String getColumnName() {
+ return columnName;
+ }
+
+ public int getColumnIndex() {
+ return ordinal();
+ }
+
+ public Object getValue(Observation bean) {
+ Object result = SammoaUtil.getPropertyValue(bean, beanProperties);
+ return result;
+ }
+
+ public void setValue(Observation bean, Object value, Region region) {
+ if (type.isPrimitive() && value == null) {
+ // can not set a null value to a primitive field
+ } else {
+ SammoaUtil.setPropertyValue(bean, value, beanProperties);
+ }
+ }
+
+ public boolean isEditable() {
+ boolean result = editable;
+ return result;
+ }
+
+ public static ObservationColumn valueOf(int ordinal) {
+ for (ObservationColumn value : values()) {
+ if (ordinal == value.ordinal()) {
+ return value;
+ }
+ }
+ throw new EnumConstantNotPresentException(ObservationColumn.class,
+ "ordinal=" + ordinal);
+ }
+
+ public static ObservationColumn getValueFromFieldName(String fieldName) {
+ ObservationColumn result = null;
+ for (ObservationColumn value : values()) {
+ if (fieldName.equals(value.columnName)) {
+ result = value;
+ break;
+ }
+ }
+ return result;
+ }
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/ObservationTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteNoModificationHighlightPredicate.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteNoModificationHighlightPredicate.java 2012-08-01 15:26:31 UTC (rev 338)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteNoModificationHighlightPredicate.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -1,65 +0,0 @@
-/*
- * #%L
- * SAMMOA :: UI Swing
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-package fr.ulr.sammoa.ui.swing.observations;
-
-import fr.ulr.sammoa.persistence.Route;
-import fr.ulr.sammoa.persistence.Routes;
-import fr.ulr.sammoa.ui.swing.util.AbstractRowHighlightPredicate;
-
-public class RouteNoModificationHighlightPredicate extends AbstractRowHighlightPredicate {
-
- protected RouteTableModel model;
-
- public RouteNoModificationHighlightPredicate(RouteTableModel model) {
- this.model = model;
- }
-
- @Override
- protected boolean isHighlighted(int rowIndex) {
-
- Route route = getValueAt(rowIndex);
-
- boolean result = false;
-
- if (route.isDeleted()) {
- // do nothing
-
- } else {
-
- int previousRouteIndex = rowIndex - 1;
- if (previousRouteIndex >= 0) {
-
- Route previousRoute = getValueAt(previousRouteIndex);
-
- result = Routes.equal(route, previousRoute);
- }
- }
- return result;
- }
-
- @Override
- protected Route getValueAt(int rowIndex) {
- return model.getRow(rowIndex);
- }
-}
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteTableListSelectionListener.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteTableListSelectionListener.java 2012-08-01 15:26:31 UTC (rev 338)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteTableListSelectionListener.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -1,99 +0,0 @@
-/*
- * #%L
- * SAMMOA :: UI Swing
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-package fr.ulr.sammoa.ui.swing.observations;
-
-import com.google.common.base.Preconditions;
-import fr.ulr.sammoa.persistence.Route;
-import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.swing.ListSelectionModel;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import java.util.List;
-
-/**
- * Listen the route table selection model to set the
- * {@link FlightUIModel#routeEditBean} which isten the validator.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class RouteTableListSelectionListener implements ListSelectionListener {
-
- private static final Logger logger =
- LoggerFactory.getLogger(RouteTableListSelectionListener.class);
-
- protected final FlightUIModel flightUIModel;
-
- public RouteTableListSelectionListener(FlightUIModel flightUIModel) {
- Preconditions.checkNotNull(flightUIModel);
- this.flightUIModel = flightUIModel;
- }
-
- @Override
- public void valueChanged(ListSelectionEvent e) {
-
- if (!e.getValueIsAdjusting()) {
-
- ListSelectionModel listSelectionModel =
- (ListSelectionModel) e.getSource();
- int firstIndex = e.getFirstIndex();
- int lastIndex = e.getLastIndex();
- Integer newSelectedRow = null;
-
- if (listSelectionModel.isSelectionEmpty()) {
-
- // no selection
- } else if (listSelectionModel.isSelectedIndex(firstIndex)) {
-
- // use first index
- newSelectedRow = firstIndex;
- } else if (listSelectionModel.isSelectedIndex(lastIndex)) {
-
- // use last index
- newSelectedRow = lastIndex;
- }
- List<Route> routes = flightUIModel.getRoutes();
- Route route = null;
-
- if (newSelectedRow != null &&
- newSelectedRow < routes.size()) {
- route = routes.get(newSelectedRow);
-
- if (logger.isInfoEnabled()) {
- logger.info("Select route from index {}", newSelectedRow);
- }
- } else {
- if (logger.isInfoEnabled()) {
- logger.info("No route selected");
- }
- }
-
- // set new route in model to validate
- flightUIModel.setRouteEditBean(route);
- }
- }
-}
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteTableModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteTableModel.java 2012-08-01 15:26:31 UTC (rev 338)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteTableModel.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -1,242 +0,0 @@
-/*
- * #%L
- * SAMMOA :: UI Swing
- * *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-package fr.ulr.sammoa.ui.swing.observations;
-
-import fr.ulr.sammoa.persistence.Flight;
-import fr.ulr.sammoa.persistence.Route;
-import fr.ulr.sammoa.persistence.Transect;
-import fr.ulr.sammoa.persistence.TransectFlight;
-import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
-import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.lang3.tuple.Pair;
-
-import javax.swing.table.AbstractTableModel;
-import java.util.Date;
-import java.util.List;
-
-/** @author sletellier <letellier(a)codelutin.com> */
-public class RouteTableModel extends AbstractTableModel {
-
- private static final long serialVersionUID = 1L;
-
- protected FlightUIModel flightUIModel;
-
- public RouteTableModel(FlightUIModel flightUIModel) {
- this.flightUIModel = flightUIModel;
- }
-
- @Override
- public Class<?> getColumnClass(int column) {
- RouteColumn routeColumn = RouteColumn.valueOf(column);
- return routeColumn.getType();
- }
-
- @Override
- public int getRowCount() {
- return getBean().size();
- }
-
- public Route getRow(int index) {
- return getBean().get(index);
- }
-
- public List<Route> getBean() {
- return flightUIModel.getRoutes();
- }
-
- @Override
- public int getColumnCount() {
- return RouteColumn.values().length;
- }
-
- @Override
- public String getColumnName(int column) {
- return RouteColumn.valueOf(column).getColumnName();
- }
-
- @Override
- public boolean isCellEditable(int row, int column) {
- Route route = getRow(row);
- RouteColumn routeColumn = RouteColumn.valueOf(column);
- boolean result = routeColumn.isEditable(route);
- return result;
- }
-
- @Override
- public Object getValueAt(int row, int column) {
- Route route = getRow(row);
- RouteColumn routeColumn = RouteColumn.valueOf(column);
- Object result = routeColumn.getValue(route, this);
- return result;
- }
-
- @Override
- public void setValueAt(Object aValue, int row, int column) {
- Route route = getRow(row);
- RouteColumn routeColumn = RouteColumn.valueOf(column);
- routeColumn.setValue(route, aValue);
- fireTableRowsUpdated(row, row);
- }
-
- public int getBeanIndex(Route bean) {
- int row = getBean().indexOf(bean);
- return row;
- }
-
- public Route getBean(int row) {
- SwingUtil.ensureRowIndex(this, row);
- Route bean = getBean().get(row);
- return bean;
- }
-
- public Pair<Integer, Integer> getCell(Route bean, String fieldName) {
-
- int row = getBeanIndex(bean);
- int col = RouteColumn.getValueFromFieldName(fieldName).ordinal();
-
- Pair<Integer, Integer> cell = Pair.of(row, col);
- return cell;
- }
-
- protected Flight getFlight() {
- return flightUIModel.getFlight();
- }
-
- protected enum RouteColumn {
-
- EFFORT_NUMBER(false, Route.PROPERTY_EFFORT_NUMBER),
- BEGIN_TIME(false, Date.class, Route.PROPERTY_BEGIN_TIME),
- ROUTE_TYPE(false, Route.PROPERTY_ROUTE_TYPE),
- TRANSECT(false,
- Route.PROPERTY_TRANSECT_FLIGHT,
- TransectFlight.PROPERTY_TRANSECT,
- Transect.PROPERTY_NAME
- ) {
- @Override
- public Object getValue(Route bean, RouteTableModel model) {
- Object result;
- TransectFlight transectFlight = bean.getTransectFlight();
- if (transectFlight != null) {
-
- Transect transect = transectFlight.getTransect();
-
- // retrieve the index of the transectFlight in the flight
- int index = model.getFlight().getTransectFlightIndex(transectFlight);
-
- result = transect.getName() + " (" + index + ")";
-
- } else {
- result = null;
- }
- return result;
- }
- },
- SEA_STATE(true, int.class, Route.PROPERTY_SEA_STATE),
- SWELL(true, int.class, Route.PROPERTY_SWELL),
- TURBIDITY(true, int.class, Route.PROPERTY_TURBIDITY),
- SKY_GLINT(true, int.class, Route.PROPERTY_SKY_GLINT),
- GLARE_FROM(true, Integer.class, Route.PROPERTY_GLARE_FROM),
- GLARE_TO(true, Integer.class, Route.PROPERTY_GLARE_TO),
- GLARE_SEVERITY(true, int.class, Route.PROPERTY_GLARE_SEVERITY),
- GLARE_UNDER(true, boolean.class, Route.PROPERTY_GLARE_UNDER),
- CLOUD_COVER(true, int.class, Route.PROPERTY_CLOUD_COVER),
- SUBJECTIVE_CONDITIONS(true, Route.PROPERTY_SUBJECTIVE_CONDITIONS),
- UNEXPECTED_LEFT(true, Route.PROPERTY_UNEXPECTED_LEFT),
- UNEXEPECTED_RIGHT(true, Route.PROPERTY_UNEXPECTED_RIGHT),
- COMMENT(true, Route.PROPERTY_COMMENT),
- DELETED(true, boolean.class, Route.PROPERTY_DELETED);
-
- private final boolean editable;
-
- private final String[] beanProperties;
-
- private final Class<?> type;
-
- private final String columnName;
-
-
- private RouteColumn(boolean editable,
- String... beanProperties) {
- this(editable, null, beanProperties);
- }
-
- private RouteColumn(boolean editable,
- Class<?> type,
- String... beanProperties) {
- this.editable = editable;
- this.type = type;
- this.beanProperties = beanProperties;
- this.columnName = beanProperties[0];
- }
-
- public Class<?> getType() {
- return type;
- }
-
- public String getColumnName() {
- return columnName;
- }
-
- public Object getValue(Route bean, RouteTableModel model) {
- Object result = SammoaUtil.getPropertyValue(bean, beanProperties);
- return result;
- }
-
- public void setValue(Route bean, Object value) {
- if (type.isPrimitive() && value==null) {
- // can not set a null value to a primitive field
- } else {
- SammoaUtil.setPropertyValue(bean, value, beanProperties);
- }
- }
-
- public boolean isEditable(Route bean) {
- boolean result = editable;
- return result;
- }
-
- public static RouteColumn valueOf(int ordinal) {
- for (RouteColumn value : values()) {
- if (ordinal == value.ordinal()) {
- return value;
- }
- }
- throw new EnumConstantNotPresentException(RouteColumn.class,
- "ordinal=" + ordinal);
- }
-
- public static RouteColumn getValueFromFieldName(String fieldName) {
- RouteColumn result = null;
- for (RouteColumn value : values()) {
- if (fieldName.equals(value.columnName)) {
- result = value;
- break;
- }
- }
- return result;
- }
- }
-}
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteTableModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteTableModel.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteTableModel.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -0,0 +1,242 @@
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * *
+ * $Id$
+ * $HeadURL: http://svn.forge.codelutin.com/svn/sammoa/trunk/sammoa-ui-swing/src/main/ja… $
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+package fr.ulr.sammoa.ui.swing.observations;
+
+import fr.ulr.sammoa.persistence.Flight;
+import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.Transect;
+import fr.ulr.sammoa.persistence.TransectFlight;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.lang3.tuple.Pair;
+
+import javax.swing.table.AbstractTableModel;
+import java.util.Date;
+import java.util.List;
+
+/** @author sletellier <letellier(a)codelutin.com> */
+public class RouteTableModel extends AbstractTableModel {
+
+ private static final long serialVersionUID = 1L;
+
+ protected FlightUIModel flightUIModel;
+
+ public RouteTableModel(FlightUIModel flightUIModel) {
+ this.flightUIModel = flightUIModel;
+ }
+
+ @Override
+ public Class<?> getColumnClass(int column) {
+ RouteColumn routeColumn = RouteColumn.valueOf(column);
+ return routeColumn.getType();
+ }
+
+ @Override
+ public int getRowCount() {
+ return getBean().size();
+ }
+
+ public Route getRow(int index) {
+ return getBean().get(index);
+ }
+
+ public List<Route> getBean() {
+ return flightUIModel.getRoutes();
+ }
+
+ @Override
+ public int getColumnCount() {
+ return RouteColumn.values().length;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ return RouteColumn.valueOf(column).getColumnName();
+ }
+
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ Route route = getRow(row);
+ RouteColumn routeColumn = RouteColumn.valueOf(column);
+ boolean result = routeColumn.isEditable(route);
+ return result;
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+ Route route = getRow(row);
+ RouteColumn routeColumn = RouteColumn.valueOf(column);
+ Object result = routeColumn.getValue(route, this);
+ return result;
+ }
+
+ @Override
+ public void setValueAt(Object aValue, int row, int column) {
+ Route route = getRow(row);
+ RouteColumn routeColumn = RouteColumn.valueOf(column);
+ routeColumn.setValue(route, aValue);
+ fireTableRowsUpdated(row, row);
+ }
+
+ public int getBeanIndex(Route bean) {
+ int row = getBean().indexOf(bean);
+ return row;
+ }
+
+ public Route getBean(int row) {
+ SwingUtil.ensureRowIndex(this, row);
+ Route bean = getBean().get(row);
+ return bean;
+ }
+
+ public Pair<Integer, Integer> getCell(Route bean, String fieldName) {
+
+ int row = getBeanIndex(bean);
+ int col = RouteColumn.getValueFromFieldName(fieldName).ordinal();
+
+ Pair<Integer, Integer> cell = Pair.of(row, col);
+ return cell;
+ }
+
+ protected Flight getFlight() {
+ return flightUIModel.getFlight();
+ }
+
+ protected enum RouteColumn {
+
+ EFFORT_NUMBER(false, Route.PROPERTY_EFFORT_NUMBER),
+ BEGIN_TIME(false, Date.class, Route.PROPERTY_BEGIN_TIME),
+ ROUTE_TYPE(false, Route.PROPERTY_ROUTE_TYPE),
+ TRANSECT(false,
+ Route.PROPERTY_TRANSECT_FLIGHT,
+ TransectFlight.PROPERTY_TRANSECT,
+ Transect.PROPERTY_NAME
+ ) {
+ @Override
+ public Object getValue(Route bean, RouteTableModel model) {
+ Object result;
+ TransectFlight transectFlight = bean.getTransectFlight();
+ if (transectFlight != null) {
+
+ Transect transect = transectFlight.getTransect();
+
+ // retrieve the index of the transectFlight in the flight
+ int index = model.getFlight().getTransectFlightIndex(transectFlight);
+
+ result = transect.getName() + " (" + index + ")";
+
+ } else {
+ result = null;
+ }
+ return result;
+ }
+ },
+ SEA_STATE(true, int.class, Route.PROPERTY_SEA_STATE),
+ SWELL(true, int.class, Route.PROPERTY_SWELL),
+ TURBIDITY(true, int.class, Route.PROPERTY_TURBIDITY),
+ SKY_GLINT(true, int.class, Route.PROPERTY_SKY_GLINT),
+ GLARE_FROM(true, Integer.class, Route.PROPERTY_GLARE_FROM),
+ GLARE_TO(true, Integer.class, Route.PROPERTY_GLARE_TO),
+ GLARE_SEVERITY(true, int.class, Route.PROPERTY_GLARE_SEVERITY),
+ GLARE_UNDER(true, boolean.class, Route.PROPERTY_GLARE_UNDER),
+ CLOUD_COVER(true, int.class, Route.PROPERTY_CLOUD_COVER),
+ SUBJECTIVE_CONDITIONS(true, Route.PROPERTY_SUBJECTIVE_CONDITIONS),
+ UNEXPECTED_LEFT(true, Route.PROPERTY_UNEXPECTED_LEFT),
+ UNEXEPECTED_RIGHT(true, Route.PROPERTY_UNEXPECTED_RIGHT),
+ COMMENT(true, Route.PROPERTY_COMMENT),
+ DELETED(true, boolean.class, Route.PROPERTY_DELETED);
+
+ private final boolean editable;
+
+ private final String[] beanProperties;
+
+ private final Class<?> type;
+
+ private final String columnName;
+
+
+ private RouteColumn(boolean editable,
+ String... beanProperties) {
+ this(editable, null, beanProperties);
+ }
+
+ private RouteColumn(boolean editable,
+ Class<?> type,
+ String... beanProperties) {
+ this.editable = editable;
+ this.type = type;
+ this.beanProperties = beanProperties;
+ this.columnName = beanProperties[0];
+ }
+
+ public Class<?> getType() {
+ return type;
+ }
+
+ public String getColumnName() {
+ return columnName;
+ }
+
+ public Object getValue(Route bean, RouteTableModel model) {
+ Object result = SammoaUtil.getPropertyValue(bean, beanProperties);
+ return result;
+ }
+
+ public void setValue(Route bean, Object value) {
+ if (type.isPrimitive() && value==null) {
+ // can not set a null value to a primitive field
+ } else {
+ SammoaUtil.setPropertyValue(bean, value, beanProperties);
+ }
+ }
+
+ public boolean isEditable(Route bean) {
+ boolean result = editable;
+ return result;
+ }
+
+ public static RouteColumn valueOf(int ordinal) {
+ for (RouteColumn value : values()) {
+ if (ordinal == value.ordinal()) {
+ return value;
+ }
+ }
+ throw new EnumConstantNotPresentException(RouteColumn.class,
+ "ordinal=" + ordinal);
+ }
+
+ public static RouteColumn getValueFromFieldName(String fieldName) {
+ RouteColumn result = null;
+ for (RouteColumn value : values()) {
+ if (fieldName.equals(value.columnName)) {
+ result = value;
+ break;
+ }
+ }
+ return result;
+ }
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/RouteTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToNextEditableCellAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToNextEditableCellAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToNextEditableCellAction.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -0,0 +1,67 @@
+package fr.ulr.sammoa.ui.swing.observations.action;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.AbstractAction;
+import javax.swing.JTable;
+import java.awt.event.ActionEvent;
+
+/**
+* Action to edit next editable cell from selected cell.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.5
+*/
+public class MoveToNextEditableCellAction extends AbstractAction {
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(MoveToNextEditableCellAction.class);
+
+ protected final JTable table;
+
+ public MoveToNextEditableCellAction(JTable table) {
+ this.table = table;
+ }
+
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ int currentRow = table.getSelectedRow();
+ int currentColumn = table.getSelectedColumn();
+
+ logger.debug("Move to next editable cell, {}, {}", currentRow, currentColumn);
+
+ while (currentRow <= table.getRowCount() || currentColumn <= table.getColumnCount()) {
+
+ // go to next cell
+ currentColumn++;
+
+ // select next cell
+ if (currentColumn >= table.getColumnCount()) {
+ currentColumn = 0;
+ currentRow++;
+ }
+
+ if (table.isCellEditable(currentRow, currentColumn)) {
+ doSelectCell(currentRow, currentColumn);
+// // select cell
+// setColumnSelectionInterval(currentColumn, currentColumn);
+// setRowSelectionInterval(currentRow, currentRow);
+// editCellAt(currentRow, currentColumn);
+// logger.debug("While select cell at {}, {}", currentRow, currentColumn);
+ break;
+ } else {
+ logger.debug("Cell at {}, {} not editable", currentRow, currentColumn);
+ }
+ }
+ }
+
+ protected void doSelectCell(int currentRow, int currentColumn) {
+ table.setColumnSelectionInterval(currentColumn, currentColumn);
+ table.setRowSelectionInterval(currentRow, currentRow);
+ logger.debug("While select cell at {}, {}", currentRow, currentColumn);
+ table.editCellAt(currentRow, currentColumn);
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToNextEditableCellAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToNextRowEditableAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToNextRowEditableAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToNextRowEditableAction.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -0,0 +1,53 @@
+package fr.ulr.sammoa.ui.swing.observations.action;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.AbstractAction;
+import javax.swing.JTable;
+import java.awt.event.ActionEvent;
+
+/**
+* Action to edit next row only if selected cell is editable.
+*
+* @author tchemit <chemit(a)codelutin.com>
+* @since 0.5
+*/
+public class MoveToNextRowEditableAction extends AbstractAction {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger logger = LoggerFactory.getLogger(MoveToNextRowEditableAction.class);
+
+ protected final JTable table;
+
+ public MoveToNextRowEditableAction(JTable table) {
+ this.table = table;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ int currentRow = table.getSelectedRow();
+ int currentColumn = table.getSelectedColumn();
+
+ if (table.isCellEditable(currentRow, currentColumn)) {
+ logger.debug("Move to next row editable cell, {}, {}", currentRow, currentColumn);
+ currentRow++;
+
+ if (currentRow >= table.getRowCount()) {
+ logger.debug("No next row");
+ } else {
+ doSelectCell(currentRow, currentColumn);
+ }
+ } else {
+ logger.debug("Cell at {}, {} not editable", currentRow, currentColumn);
+ }
+ }
+
+ protected void doSelectCell(int currentRow, int currentColumn) {
+ table.setColumnSelectionInterval(currentColumn, currentColumn);
+ table.setRowSelectionInterval(currentRow, currentRow);
+ logger.debug("While select cell at {}, {}", currentRow, currentColumn);
+ table.editCellAt(currentRow, currentColumn);
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToNextRowEditableAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToPreviousEditableCellAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToPreviousEditableCellAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToPreviousEditableCellAction.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -0,0 +1,66 @@
+package fr.ulr.sammoa.ui.swing.observations.action;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.AbstractAction;
+import javax.swing.JTable;
+import java.awt.event.ActionEvent;
+
+/**
+ * Action to edit previous editable cell from selected cell.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.5
+ */
+public class MoveToPreviousEditableCellAction extends AbstractAction {
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(MoveToPreviousEditableCellAction.class);
+
+ protected final JTable table;
+
+ public MoveToPreviousEditableCellAction(JTable table) {
+ this.table = table;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ int currentRow = table.getSelectedRow();
+ int currentColumn = table.getSelectedColumn();
+
+ logger.debug("Move to previous editable cell, {}, {}", currentRow, currentColumn);
+
+ while (currentRow > 0 || currentColumn > 0) {
+
+ // go to next cell
+ currentColumn--;
+
+ // select next cell
+ if (currentColumn < 0) {
+ currentColumn = table.getColumnCount() - 1;
+ currentRow--;
+ }
+
+ if (table.isCellEditable(currentRow, currentColumn)) {
+ doSelectCell(currentRow, currentColumn);
+// // select cell
+// setColumnSelectionInterval(currentColumn, currentColumn);
+// setRowSelectionInterval(currentRow, currentRow);
+// logger.debug("While select cell at {}, {}", currentRow, currentColumn);
+// editCellAt(currentRow, currentColumn);
+ break;
+ } else {
+ logger.debug("Cell at {}, {} not editable", currentRow, currentColumn);
+ }
+ }
+ }
+
+ protected void doSelectCell(int currentRow, int currentColumn) {
+ table.setColumnSelectionInterval(currentColumn, currentColumn);
+ table.setRowSelectionInterval(currentRow, currentRow);
+ logger.debug("While select cell at {}, {}", currentRow, currentColumn);
+ table.editCellAt(currentRow, currentColumn);
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToPreviousEditableCellAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToPreviousRowEditableAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToPreviousRowEditableAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToPreviousRowEditableAction.java 2012-08-01 16:32:14 UTC (rev 339)
@@ -0,0 +1,53 @@
+package fr.ulr.sammoa.ui.swing.observations.action;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.AbstractAction;
+import javax.swing.JTable;
+import java.awt.event.ActionEvent;
+
+/**
+* Action to edit previous row only if selected cell is editable.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.5
+*/
+public class MoveToPreviousRowEditableAction extends AbstractAction {
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger logger = LoggerFactory.getLogger(MoveToPreviousRowEditableAction.class);
+
+ protected final JTable table;
+
+ public MoveToPreviousRowEditableAction(JTable table) {
+ this.table = table;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ int currentRow = table.getSelectedRow();
+ int currentColumn = table.getSelectedColumn();
+
+ if (table.isCellEditable(currentRow, currentColumn)) {
+ logger.debug("Move to previous row editable cell, {}, {}", currentRow, currentColumn);
+ currentRow--;
+
+ if (currentRow < 0) {
+ logger.debug("No previous row");
+ } else {
+ doSelectCell(currentRow, currentColumn);
+ }
+ } else {
+ logger.debug("Cell at {}, {} not editable", currentRow, currentColumn);
+ }
+ }
+
+ protected void doSelectCell(int currentRow, int currentColumn) {
+ table.setColumnSelectionInterval(currentColumn, currentColumn);
+ table.setRowSelectionInterval(currentRow, currentRow);
+ logger.debug("While select cell at {}, {}", currentRow, currentColumn);
+ table.editCellAt(currentRow, currentColumn);
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/action/MoveToPreviousRowEditableAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
1
0
r338 - tags/sammoa-0.4.1/sammoa-application/src/main/java/fr/ulr/sammoa/application
by fdesbois@users.forge.codelutin.com 01 Aug '12
by fdesbois@users.forge.codelutin.com 01 Aug '12
01 Aug '12
Author: fdesbois
Date: 2012-08-01 17:26:31 +0200 (Wed, 01 Aug 2012)
New Revision: 338
Url: http://forge.codelutin.com/repositories/revision/sammoa/338
Log:
refs #1378 : issue with GpsConfig default values
Modified:
tags/sammoa-0.4.1/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java
Modified: tags/sammoa-0.4.1/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java
===================================================================
--- tags/sammoa-0.4.1/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java 2012-08-01 13:38:03 UTC (rev 337)
+++ tags/sammoa-0.4.1/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java 2012-08-01 15:26:31 UTC (rev 338)
@@ -26,6 +26,7 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
+import fr.ulr.sammoa.application.gps.GpsConfig;
import fr.ulr.sammoa.persistence.AutoSaveListener;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.nuiton.util.ApplicationConfig;
@@ -91,6 +92,7 @@
try {
applicationConfig.loadDefaultOptions(SammoaConfigOption.class.getEnumConstants());
+ applicationConfig.loadDefaultOptions(GpsConfig.GpsConfigOption.class.getEnumConstants());
applicationConfig.parse(args);
} catch (ArgumentsParserException e) {
1
0
r337 - trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight
by fdesbois@users.forge.codelutin.com 01 Aug '12
by fdesbois@users.forge.codelutin.com 01 Aug '12
01 Aug '12
Author: fdesbois
Date: 2012-08-01 15:38:03 +0200 (Wed, 01 Aug 2012)
New Revision: 337
Url: http://forge.codelutin.com/repositories/revision/sammoa/337
Log:
fixes #1381 : remove column nbTimes from transect table
Added:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectCrossingNumberCellRenderer.java
Removed:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectNbTimesCellRenderer.java
Modified:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectFlightModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTable.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTableModel.java
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectCrossingNumberCellRenderer.java (from rev 336, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectNbTimesCellRenderer.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectCrossingNumberCellRenderer.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectCrossingNumberCellRenderer.java 2012-08-01 13:38:03 UTC (rev 337)
@@ -0,0 +1,60 @@
+package fr.ulr.sammoa.ui.swing.flight;
+/*
+ * #%L
+ * SAMMOA :: UI Swing
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2012 UMS 3462, Code Lutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import javax.swing.*;
+import javax.swing.table.TableCellRenderer;
+import java.awt.*;
+
+/**
+ * Created: 18/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class TransectCrossingNumberCellRenderer implements TableCellRenderer {
+
+ protected TableCellRenderer delegate;
+
+ protected TransectTableModel model;
+
+ public TransectCrossingNumberCellRenderer(TableCellRenderer delegate,
+ TransectTableModel model) {
+ this.delegate = delegate;
+ this.model = model;
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+
+ TransectFlightModel transectFlight = model.getRow(row);
+ TransectModel transect = transectFlight.getTransect();
+
+ int crossingNumber = transectFlight.getCrossingNumber();
+ int realNbTimes = transect.getRealNbTimes();
+
+ String newValue = crossingNumber + " (" + realNbTimes +")";
+
+ return delegate.getTableCellRendererComponent(table, newValue, isSelected, hasFocus, row, column);
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectCrossingNumberCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectFlightModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectFlightModel.java 2012-08-01 13:17:43 UTC (rev 336)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectFlightModel.java 2012-08-01 13:38:03 UTC (rev 337)
@@ -23,23 +23,16 @@
* #L%
*/
-import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import fr.ulr.sammoa.persistence.Flight;
import fr.ulr.sammoa.persistence.Observer;
import fr.ulr.sammoa.persistence.ObserverPosition;
-import fr.ulr.sammoa.persistence.ObserverPositions;
import fr.ulr.sammoa.persistence.Position;
-import fr.ulr.sammoa.persistence.Transect;
import fr.ulr.sammoa.persistence.TransectFlight;
import fr.ulr.sammoa.ui.swing.BaseModel;
-import javax.annotation.Nullable;
-import java.beans.PropertyChangeListener;
-import java.util.Map;
-
/**
* Created: 27/07/12
*
@@ -56,6 +49,8 @@
public static final String PROPERTY_DELETED = "deleted";
public static final String PROPERTY_INDEX = "index";
+
+ public static final String PROPERTY_CROSSING_NUMBER = "crossingNumber";
protected FlightUIModel flightModel;
@@ -131,6 +126,24 @@
firePropertyChange(PROPERTY_INDEX, oldValue, index);
}
+ public int getCrossingNumber() {
+ return getSource().getCrossingNumber();
+ }
+
+ public void setCrossingNumber(int crossingNumber) {
+ int oldValue = getCrossingNumber();
+ getSource().setCrossingNumber(crossingNumber);
+
+ // We need to update the manual nbTimes from transect to ensure next crossingNumber value
+ // only if the nbTimes is inferior to the new value manually set
+ int nbTimes = getTransect().getSource().getNbTimes();
+ if (crossingNumber > nbTimes) {
+ getTransect().getSource().setNbTimes(crossingNumber);
+ }
+
+ firePropertyChange(PROPERTY_CROSSING_NUMBER, oldValue, crossingNumber);
+ }
+
public ObserverPosition getObserverPositionByPosition(Position position) {
return getSource().getObserverPositionByPosition(position);
}
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectNbTimesCellRenderer.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectNbTimesCellRenderer.java 2012-08-01 13:17:43 UTC (rev 336)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectNbTimesCellRenderer.java 2012-08-01 13:38:03 UTC (rev 337)
@@ -1,63 +0,0 @@
-package fr.ulr.sammoa.ui.swing.flight;
-/*
- * #%L
- * SAMMOA :: UI Swing
- * $Id:$
- * $HeadURL:$
- * %%
- * Copyright (C) 2012 UMS 3462, Code Lutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy 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.ulr.sammoa.persistence.Transect;
-import fr.ulr.sammoa.persistence.TransectFlight;
-
-import javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-import java.awt.Component;
-
-/**
- * Created: 18/07/12
- *
- * @author fdesbois <desbois(a)codelutin.com>
- */
-public class TransectNbTimesCellRenderer implements TableCellRenderer {
-
- protected TableCellRenderer delegate;
-
- protected TransectTableModel model;
-
- public TransectNbTimesCellRenderer(TableCellRenderer delegate,
- TransectTableModel model) {
- this.delegate = delegate;
- this.model = model;
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
-
- TransectFlightModel transectFlight = model.getRow(row);
- TransectModel transect = transectFlight.getTransect();
-
- int nbTimes = transect.getSource().getNbTimes();
- int realNbTimes = transect.getRealNbTimes();
-
- String newValue = nbTimes + " (" + realNbTimes +")";
-
- return delegate.getTableCellRendererComponent(table, newValue, isSelected, hasFocus, row, column);
- }
-}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTable.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTable.java 2012-08-01 13:17:43 UTC (rev 336)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTable.java 2012-08-01 13:38:03 UTC (rev 337)
@@ -31,6 +31,7 @@
import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
import jaxx.runtime.swing.JAXXWidgetUtil;
import jaxx.runtime.swing.editor.BooleanCellEditor;
+import jaxx.runtime.swing.editor.cell.NumberCellEditor;
import jaxx.runtime.swing.renderer.DecoratorProviderTableCellRenderer;
import org.jdesktop.swingx.JXTable;
import org.nuiton.util.decorator.DecoratorProvider;
@@ -95,12 +96,15 @@
// Set specific renderer for NbTimes column
TableCellRenderer defaultRenderer = getDefaultRenderer(String.class);
- TransectNbTimesCellRenderer cellRenderer = new TransectNbTimesCellRenderer(defaultRenderer, getModel());
- getColumnModel().getColumn(TransectTableModel.TransectColumn.NB_TIMES.ordinal()).setCellRenderer(cellRenderer);
+ TransectCrossingNumberCellRenderer cellRenderer = new TransectCrossingNumberCellRenderer(defaultRenderer, getModel());
+ getColumnModel().getColumn(TransectTableModel.TransectColumn.CROSSING_NUMBER.ordinal()).setCellRenderer(cellRenderer);
setDefaultEditor(Boolean.class, booleanTableCell);
- setDefaultEditor(Integer.class, JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, false));
+ NumberCellEditor<Integer> numberCellEditor = JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, false);
+ setDefaultEditor(Integer.class, numberCellEditor);
+ setDefaultEditor(int.class, numberCellEditor);
+
initPositionColumnHeaderColors();
for (int i = 0; i < getModel().getRowCount(); i++) {
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTableModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTableModel.java 2012-08-01 13:17:43 UTC (rev 336)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTableModel.java 2012-08-01 13:38:03 UTC (rev 337)
@@ -25,7 +25,6 @@
package fr.ulr.sammoa.ui.swing.flight;
import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import fr.ulr.sammoa.persistence.Flight;
@@ -37,8 +36,7 @@
import fr.ulr.sammoa.persistence.TransectFlight;
import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
-import javax.annotation.Nullable;
-import javax.swing.SwingUtilities;
+import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import java.util.List;
@@ -264,18 +262,17 @@
CROSSING_NUMBER(
_("sammoa.flightPanel.table.column.crossingNumber"),
true,
- Integer.class,
- TransectFlightModel.PROPERTY_SOURCE,
- TransectFlight.PROPERTY_CROSSING_NUMBER
+ int.class,
+ TransectFlightModel.PROPERTY_CROSSING_NUMBER
),
- NB_TIMES(
- _("sammoa.flightPanel.table.column.nbTimes"),
- true,
- Integer.class,
- TransectFlightModel.PROPERTY_TRANSECT,
- TransectModel.PROPERTY_SOURCE,
- Transect.PROPERTY_NB_TIMES
- ),
+// NB_TIMES(
+// _("sammoa.flightPanel.table.column.nbTimes"),
+// true,
+// Integer.class,
+// TransectFlightModel.PROPERTY_TRANSECT,
+// TransectModel.PROPERTY_SOURCE,
+// Transect.PROPERTY_NB_TIMES
+// ),
DELETED(
_("sammoa.flightPanel.table.column.deleted"),
true,
1
0
r336 - trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/gps
by fdesbois@users.forge.codelutin.com 01 Aug '12
by fdesbois@users.forge.codelutin.com 01 Aug '12
01 Aug '12
Author: fdesbois
Date: 2012-08-01 15:17:43 +0200 (Wed, 01 Aug 2012)
New Revision: 336
Url: http://forge.codelutin.com/repositories/revision/sammoa/336
Log:
refs #1378 : issue with GpsConfig default values problem with 0.4.1
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/gps/GpsConfig.java
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/gps/GpsConfig.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/gps/GpsConfig.java 2012-08-01 12:37:54 UTC (rev 335)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/gps/GpsConfig.java 2012-08-01 13:17:43 UTC (rev 336)
@@ -40,6 +40,7 @@
public GpsConfig(ApplicationConfig applicationConfig) {
this.applicationConfig = applicationConfig;
+ this.applicationConfig.loadDefaultOptions(GpsConfigOption.values());
}
/**
1
0