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
r515 - in trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application: flightController io
by fdesbois@users.forge.codelutin.com 04 Sep '12
by fdesbois@users.forge.codelutin.com 04 Sep '12
04 Sep '12
Author: fdesbois
Date: 2012-09-04 18:04:41 +0200 (Tue, 04 Sep 2012)
New Revision: 515
Url: http://forge.codelutin.com/repositories/revision/sammoa/515
Log:
refs #1197 : use lastTransect reference to save audio
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/BaseFlightController.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerOnBoard.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerValidation.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorage.java
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/BaseFlightController.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/BaseFlightController.java 2012-09-04 12:48:41 UTC (rev 514)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/BaseFlightController.java 2012-09-04 16:04:41 UTC (rev 515)
@@ -237,9 +237,9 @@
startTime = timeLog.log(startTime, "start()", "Commited");
// Fire events after commit
- fireRouteAdded(previousRoute, currentRoute);
- fireNextTransectChanged(nextTransect);
- fireStateChanged(state);
+ onRouteAdded(previousRoute, currentRoute);
+ onNextTransectChanged(nextTransect);
+ onStateChanged(state);
timeLog.log(startTime, "start()", "Fired");
@@ -265,7 +265,7 @@
this.nextTransect = nextTransect;
// Fire transect changed
- fireNextTransectChanged(nextTransect);
+ onNextTransectChanged(nextTransect);
timeLog.log(startTime, "setNextTransect()", "Fired");
}
@@ -279,7 +279,7 @@
setCurrentRoute(currentRoute, false);
}
- private void setCurrentRoute(Route currentRoute, boolean fireChanges) {
+ private void setCurrentRoute(Route newCurrentRoute, boolean fireChanges) {
long startTime = TimeLog.getTime();
@@ -287,9 +287,11 @@
"The controller must be initialized before calling any action");
if (logger.isInfoEnabled()) {
- logger.info("Set currentRoute : {}", Routes.toString(currentRoute));
+ logger.info("Set currentRoute : {}", Routes.toString(newCurrentRoute));
}
+ currentRoute = newCurrentRoute;
+
if (currentRoute == null) {
if (flight.getEndDate() == null) {
@@ -298,39 +300,46 @@
} else {
state = FlightState.ENDED;
}
- this.currentRoute = null;
} else {
+ // Use previous not deleted route
if (currentRoute.isDeleted()) {
- this.currentRoute = service.getPreviousRoute(currentRoute);
- } else {
- this.currentRoute = currentRoute;
+ currentRoute = service.getPreviousRoute(newCurrentRoute);
}
- if (this.currentRoute.getRouteType() == RouteType.LEG) {
- state = FlightState.ON_EFFORT;
+ // Update state, lastTransect and nextTransect depends on routeType
+ switch (currentRoute.getRouteType()) {
- } else {
- state = FlightState.OFF_EFFORT;
- }
+ case LEG:
+ state = FlightState.ON_EFFORT;
+ lastTransect = service.getPreviousTransect(currentRoute);
+ nextTransect = flight.getNextTransectFlightFrom(lastTransect);
+ break;
- lastTransect = service.getPreviousTransect(this.currentRoute);
+ case CIRCLE_BACK:
+ state = FlightState.OFF_EFFORT;
+ lastTransect = service.getPreviousTransect(currentRoute);
+ nextTransect = lastTransect;
+ break;
- // Selection of the nextTransect, keep the last one for circleBack
- if (this.currentRoute.getRouteType() == RouteType.CIRCLE_BACK) {
- nextTransect = lastTransect;
+ case TRANSIT:
+ state = FlightState.OFF_EFFORT;
+ lastTransect = null;
+ nextTransect = flight.getNextTransectFlightFrom(
+ service.getPreviousTransect(currentRoute));
+ break;
- } else {
- nextTransect = flight.getNextTransectFlightFrom(lastTransect);
+ default:
}
}
if (fireChanges) {
- fireStateChanged(state);
- fireNextTransectChanged(nextTransect);
- fireCurrentRouteChanged(this.currentRoute);
+ onStateChanged(state);
+ onLastTransectChanged(lastTransect);
+ onNextTransectChanged(nextTransect);
+ onCurrentRouteChanged(currentRoute);
}
timeLog.log(startTime, "setCurrentRoute()");
@@ -378,9 +387,10 @@
startTime = timeLog.log(startTime, "begin()", "Commited");
// Fire events after commit
- fireRouteAdded(previousRoute, currentRoute);
- fireNextTransectChanged(nextTransect);
- fireStateChanged(state);
+ onRouteAdded(previousRoute, currentRoute);
+ onLastTransectChanged(lastTransect);
+ onNextTransectChanged(nextTransect);
+ onStateChanged(state);
timeLog.log(startTime, "begin()", "Fired");
@@ -431,9 +441,9 @@
startTime = timeLog.log(startTime, "circleBack()", "Commited");
// Fire events after commit
- fireRouteAdded(previousRoute, currentRoute);
- fireNextTransectChanged(nextTransect);
- fireStateChanged(state);
+ onRouteAdded(previousRoute, currentRoute);
+ onNextTransectChanged(nextTransect);
+ onStateChanged(state);
timeLog.log(startTime, "circleBack()", "Fired");
@@ -475,7 +485,7 @@
startTime = timeLog.log(startTime, "add()", "Commited");
// Fire events after commit
- fireRouteAdded(previousRoute, currentRoute);
+ onRouteAdded(previousRoute, currentRoute);
timeLog.log(startTime, "add()", "Fired");
@@ -541,7 +551,7 @@
startTime = timeLog.log(startTime, "observation()", "Commited");
- fireObservationAdded(observation, geoPoint);
+ onObservationAdded(observation, geoPoint);
timeLog.log(startTime, "observation()", "Fired");
@@ -571,6 +581,8 @@
Date currentDate = geoPoint.getRecordTime();
+ lastTransect = null;
+
// Create new TRANSIT route
if (logger.isInfoEnabled()) {
logger.info(String.format("Create TRANSIT [END] at %1$tH:%1$tM:%1$tS.%1$tL", currentDate));
@@ -583,9 +595,10 @@
transaction.commitTransaction();
// Fire events after commit
- fireRouteAdded(previousRoute, currentRoute);
- fireNextTransectChanged(nextTransect);
- fireStateChanged(state);
+ onRouteAdded(previousRoute, currentRoute);
+ onLastTransectChanged(lastTransect);
+ onNextTransectChanged(nextTransect);
+ onStateChanged(state);
} catch (TopiaException e) {
throw new TopiaRuntimeException(e);
@@ -634,9 +647,9 @@
startTime = timeLog.log(startTime, "stop()", "Commited");
// Fire events after commit
- fireCurrentRouteChanged(currentRoute);
- fireNextTransectChanged(nextTransect);
- fireStateChanged(state);
+ onCurrentRouteChanged(currentRoute);
+ onNextTransectChanged(nextTransect);
+ onStateChanged(state);
timeLog.log(startTime, "stop()", "Fired");
@@ -724,20 +737,20 @@
return deviceManagerProvider;
}
- protected void fireObservationAdded(Observation observation, GeoPoint location) {
+ protected void onObservationAdded(Observation observation, GeoPoint location) {
ObservationEvent event = new ObservationEvent(this, observation, location);
for (FlightControllerListener listener : listeners) {
listener.onObservationAdded(event);
}
}
- protected void fireStateChanged(FlightState state) {
+ protected void onStateChanged(FlightState state) {
for (FlightControllerListener listener : listeners) {
listener.onStateChanged(state);
}
}
- protected void fireRouteAdded(Route previousRoute, Route newRoute) {
+ protected void onRouteAdded(Route previousRoute, Route newRoute) {
Preconditions.checkNotNull(newRoute);
RouteEvent event = new RouteEvent(this, newRoute, true, previousRoute);
for (FlightControllerListener listener : listeners) {
@@ -745,17 +758,21 @@
}
}
- protected void fireCurrentRouteChanged(Route route) {
+ protected void onCurrentRouteChanged(Route route) {
RouteEvent event = new RouteEvent(this, route, false, null);
for (FlightControllerListener listener : listeners) {
listener.onCurrentRouteChanged(event);
}
}
- protected void fireNextTransectChanged(TransectFlight nextTransect) {
+ protected void onNextTransectChanged(TransectFlight nextTransect) {
for (FlightControllerListener listener : listeners) {
listener.onNextTransectChanged(nextTransect);
}
}
+ protected void onLastTransectChanged(TransectFlight lastTransect) {
+ // no fire by default
+ }
+
}
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerOnBoard.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerOnBoard.java 2012-09-04 12:48:41 UTC (rev 514)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerOnBoard.java 2012-09-04 16:04:41 UTC (rev 515)
@@ -32,7 +32,6 @@
import fr.ulr.sammoa.persistence.Flight;
import fr.ulr.sammoa.persistence.GeoPoint;
import fr.ulr.sammoa.persistence.GeoPoints;
-import fr.ulr.sammoa.persistence.Route;
import fr.ulr.sammoa.persistence.RouteType;
import fr.ulr.sammoa.persistence.SammoaDAOHelper;
import fr.ulr.sammoa.persistence.TransectFlight;
@@ -46,7 +45,7 @@
*
* @author fdesbois <florian.desbois(a)codelutin.com>
*/
-public class FlightControllerOnBoard extends BaseFlightController implements GpsLocationListener, FlightControllerListener {
+public class FlightControllerOnBoard extends BaseFlightController implements GpsLocationListener {
protected GpsHandler gpsHandler;
@@ -74,8 +73,6 @@
super.init(flight);
- addFlightControllerListener(this);
-
initCurrentRoute(service.getLastUnfinishedRoute(flight));
if (isRunning()) {
@@ -84,11 +81,13 @@
audioRecorder.start();
- // Restart recording audio if onEffort or circleBack
+ // Restart recording audio if onEffort or circleBack (recovery mode)
if (state == FlightState.ON_EFFORT
- || currentRoute.getRouteType() == RouteType.CIRCLE_BACK) {
+ || currentRoute.getRouteType() == RouteType.CIRCLE_BACK) {
- saveAudio(3);
+ File audioFile = flightStorage.getAudioFile(
+ lastTransect, audioRecorder.getOutputType().getExtension());
+ audioRecorder.record(audioFile, 3);
}
}
}
@@ -133,45 +132,17 @@
}
@Override
- public void onCurrentRouteChanged(RouteEvent event) {
- if (event.isNew()) {
+ protected void onLastTransectChanged(TransectFlight lastTransect) {
- Route newRoute = event.getRoute();
+ if (lastTransect == null) {
+ audioRecorder.stopRecord(3);
- if (RouteType.LEG == newRoute.getRouteType()
- || RouteType.CIRCLE_BACK == newRoute.getRouteType()) {
-
- saveAudio(3);
-
- } else {
-
- // Stop recording after 2 minutes (120 seconds)
- audioRecorder.stopRecord(120);
- }
+ } else {
+ File audioFile = flightStorage.getAudioFile(
+ lastTransect, audioRecorder.getOutputType().getExtension());
+ audioRecorder.record(audioFile, 3);
}
- }
- @Override
- public void onNextTransectChanged(TransectFlight nextTransect) {
- // nothing to do
+ super.onLastTransectChanged(lastTransect);
}
-
- @Override
- public void onStateChanged(FlightState state) {
- // nothing to do
- }
-
- @Override
- public void onObservationAdded(ObservationEvent event) {
- // nothing to do
- }
-
- protected void saveAudio(long delaySeconds) {
-
- String extension = audioRecorder.getOutputType().getExtension();
-
- File audioFile = flightStorage.getAudioFile(currentRoute, extension);
-
- audioRecorder.record(audioFile, delaySeconds);
- }
}
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerValidation.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerValidation.java 2012-09-04 12:48:41 UTC (rev 514)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerValidation.java 2012-09-04 16:04:41 UTC (rev 515)
@@ -23,6 +23,7 @@
* #L%
*/
+import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import fr.ulr.sammoa.application.device.DeviceManager;
import fr.ulr.sammoa.application.device.audio.AudioReader;
@@ -49,8 +50,7 @@
*
* @author fdesbois <florian.desbois(a)codelutin.com>
*/
-public class FlightControllerValidation extends BaseFlightController
-implements FlightControllerListener {
+public class FlightControllerValidation extends BaseFlightController {
private static final Logger logger = LoggerFactory.getLogger(FlightControllerValidation.class);
@@ -73,8 +73,6 @@
super.init(flight);
- addFlightControllerListener(this);
-
initCurrentRoute(null);
geoPoints = service.getFlightGeoPoints(flight);
@@ -101,33 +99,10 @@
DateTime newTime;
if (position > 0) {
-
newTime = previousTime.plus(position);
} else {
-
newTime = new DateTime(previousTime);
-
-// // Arbitrary add 1 second for the newTime
-// newTime = DateUtils.addMilliseconds(previousTime, 1000);
-//
-// // Ensure that newTime is before nextRoute time
-// Route nextRoute = Routes.findNext(routes, currentRoute);
-// if (nextRoute != null) {
-//
-// logger.debug(String.format("Next route %1$s at %2$tH:%2$tM:%2$tS.%2$tL",
-// nextRoute.getRouteType(),
-// nextRoute.getBeginTime())
-// );
-//
-// // If greater or equals than the nextRoute, we use the middle
-// // time between previous and next route
-// if (newTime.after(nextRoute.getBeginTime())
-// || newTime.equals(nextRoute.getBeginTime())) {
-//
-// newTime = Routes.getMiddleTime(currentRoute, nextRoute);
-// }
-// }
}
if (logger.isDebugEnabled()) {
@@ -147,12 +122,6 @@
result.setSpeed(location.getSpeed());
result.setAltitude(location.getAltitude());
-// // Ensure captureDelay of the new recording time
-// long locationSeconds = DateUtils.getFragmentInSeconds(location.getRecordTime(), Calendar.MINUTE);
-// long newSeconds = DateUtils.getFragmentInSeconds(newTime, Calendar.MINUTE);
-// int captureDelay = (int) newSeconds - (int) locationSeconds;
-// result.setCaptureDelay(captureDelay);
-
int captureDelay = Dates
.toInterval(locationTime, newTime)
.toDuration()
@@ -176,49 +145,40 @@
return result;
}
+
@Override
- public void onCurrentRouteChanged(RouteEvent event) {
- if (event.isNew()) {
- if (logger.isDebugEnabled()) {
- logger.debug("Add route {} to cache", Routes.toString(event.getRoute()));
- }
- routes.add(event.getRoute());
+ protected void onRouteAdded(Route previousRoute, Route newRoute) {
- } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Add route {} to cache", Routes.toString(newRoute));
+ }
+ routes.add(newRoute);
+ // Ensure previous, it could be different from argument because
+ // the audio time could overflow on more than one route
+ previousRoute = Routes.findPrevious(routes, newRoute);
+
+ super.onRouteAdded(previousRoute, newRoute);
+ }
+
+ @Override
+ protected void onLastTransectChanged(TransectFlight transectFlight) {
+
+ // Only change audio if lastTransect isn't the same
+ if (!Objects.equal(lastTransect, transectFlight)) {
+
audioReader.unload();
- if (currentRoute != null) {
+ if (transectFlight != null) {
File file = flightStorage.getAudioFile(
- currentRoute, audioReader.getOutputType().getExtension());
+ transectFlight, audioReader.getOutputType().getExtension());
if (file.exists()) {
audioReader.load(file);
}
}
}
- }
- @Override
- public void onNextTransectChanged(TransectFlight nextTransect) {
- // nothing to do
+ super.onLastTransectChanged(transectFlight);
}
-
- @Override
- public void onStateChanged(FlightState state) {
- // nothing to do
- }
-
- @Override
- public void onObservationAdded(ObservationEvent event) {
- // nothing to do
- }
-
- @Override
- protected void fireRouteAdded(Route previousRoute, Route newRoute) {
-
- // Ensure previous, it could be different from argument because
- // the audio time could overflow on more than one route
- super.fireRouteAdded(Routes.findPrevious(routes, newRoute), newRoute);
- }
}
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorage.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorage.java 2012-09-04 12:48:41 UTC (rev 514)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/FlightStorage.java 2012-09-04 16:04:41 UTC (rev 515)
@@ -29,7 +29,7 @@
import fr.ulr.sammoa.persistence.Campaign;
import fr.ulr.sammoa.persistence.Flight;
import fr.ulr.sammoa.persistence.Region;
-import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.TransectFlight;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.nuiton.util.decorator.Decorator;
@@ -54,9 +54,9 @@
return SammoaDirectories.getAudioDirectory(getDirectory());
}
- public File getAudioFile(Route route, String ext) {
+ public File getAudioFile(TransectFlight transectFlight, String ext) {
- String fileName = route.getTopiaId() + "." + ext;
+ String fileName = transectFlight.getTopiaId() + "." + ext;
return new File(getAudioDirectory(), fileName);
}
1
0
r514 - in trunk: . sammoa-ui-swing sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util
by fdesbois@users.forge.codelutin.com 04 Sep '12
by fdesbois@users.forge.codelutin.com 04 Sep '12
04 Sep '12
Author: fdesbois
Date: 2012-09-04 14:48:41 +0200 (Tue, 04 Sep 2012)
New Revision: 514
Url: http://forge.codelutin.com/repositories/revision/sammoa/514
Log:
fixes #1416 : use swing-bits for sorting and filtering. Be careful of conversion between model and view indexes in tables.
Removed:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectCrossingNumberCellRenderer.java
Modified:
trunk/pom.xml
trunk/sammoa-ui-swing/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/flight/FlightUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanelHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/AbstractRowHighlightPredicate.java
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/TableSelectionListener.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-09-04 12:47:21 UTC (rev 513)
+++ trunk/pom.xml 2012-09-04 12:48:41 UTC (rev 514)
@@ -305,6 +305,12 @@
<version>${swingXVersion}</version>
</dependency>
+ <dependency>
+ <groupId>com.ezware.oxbow</groupId>
+ <artifactId>swing-bits</artifactId>
+ <version>0.5.0</version>
+ </dependency>
+
<!-- librairie topia -->
<dependency>
<groupId>org.nuiton.topia</groupId>
Modified: trunk/sammoa-ui-swing/pom.xml
===================================================================
--- trunk/sammoa-ui-swing/pom.xml 2012-09-04 12:47:21 UTC (rev 513)
+++ trunk/sammoa-ui-swing/pom.xml 2012-09-04 12:48:41 UTC (rev 514)
@@ -137,6 +137,11 @@
<artifactId>swingx-common</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.ezware.oxbow</groupId>
+ <artifactId>swing-bits</artifactId>
+ </dependency>
+
<!-- Validation -->
<dependency>
<groupId>org.nuiton.jaxx</groupId>
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-09-04 12:47:21 UTC (rev 513)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/MainUIHandler.java 2012-09-04 12:48:41 UTC (rev 514)
@@ -341,6 +341,8 @@
helper.setOptionCallBack("actions");
helper.addOption(SammoaConfig.SammoaConfigOption.KEY_CIRCLE_BACK);
helper.setOptionCallBack("actions");
+ helper.addOption(SammoaConfig.SammoaConfigOption.KEY_VALID_TRANSECT);
+ helper.setOptionCallBack("actions");
helper.addOption(SammoaConfig.SammoaConfigOption.KEY_VALID_OBSERVATION);
helper.setOptionCallBack("actions");
helper.addOption(SammoaConfig.SammoaConfigOption.KEY_VALID_ROUTE);
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java 2012-09-04 12:47:21 UTC (rev 513)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java 2012-09-04 12:48:41 UTC (rev 514)
@@ -143,6 +143,7 @@
import javax.swing.event.ListSelectionEvent;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
+import java.awt.Component;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.ItemEvent;
@@ -486,7 +487,7 @@
int index = TransectFlightModel.indexOfTransectFlight(
getModel().getTransectFlights(), route.getTransectFlight());
- ui.getTransectFlightSelectionModel().setSelectionInterval(index, index);
+ SammoaUtil.selectTableRow(ui.getTransectTable(), index);
}
transectFlightSelectionIsAdjusting = false;
@@ -776,7 +777,7 @@
// Retrieve the last selected row from the table
JTable table = ui.getTransectTable();
- int fromIndex = SammoaUtil.getLastSelectedRow(table);
+ int fromIndex = SammoaUtil.getLastSelectedTableRow(table);
if (fromIndex == -1) {
// Add after the last row
fromIndex = table.getRowCount();
@@ -1226,7 +1227,8 @@
Transect transectBean = referentialService.getTransect(transectId);
- StrateModel strate = Iterables.find(getModel().getStrates(), StrateModel.withStrate(transectBean.getStrate()));
+ StrateModel strate = Iterables.find(
+ getModel().getStrates(), StrateModel.withStrate(transectBean.getStrate()));
TransectModel transect = new TransectModel(transectBean);
@@ -1235,8 +1237,35 @@
ui.getStrateCombobox().setSelectedItem(strate);
- // Maybe auto-scroll ? auto-selection ?
+ ui.getTransectList().ensureIndexIsVisible(strate.getTransects().size() - 1);
}
}
};
+
+ private static 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(table.convertRowIndexToModel(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);
+ }
+ }
}
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectCrossingNumberCellRenderer.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectCrossingNumberCellRenderer.java 2012-09-04 12:47:21 UTC (rev 513)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectCrossingNumberCellRenderer.java 2012-09-04 12:48:41 UTC (rev 514)
@@ -1,60 +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 javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-import java.awt.Component;
-
-/**
- * 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);
- }
-}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanelHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanelHandler.java 2012-09-04 12:47:21 UTC (rev 513)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanelHandler.java 2012-09-04 12:48:41 UTC (rev 514)
@@ -23,6 +23,7 @@
* #L%
*/
+import com.ezware.oxbow.swingbits.table.filter.TableRowFilterSupport;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@@ -264,8 +265,6 @@
}
// Fire on TableModel to update the row (highlighting)
- // ensureRowIndex in case of new route, otherwise the size is
- // not updated yet in tableModel and an IndexOutOfBounds appears
int index = getModel().indexOfRoutes(route);
SwingUtil.ensureRowIndex(ui.getRouteTableModel(), index);
ui.getRouteTableModel().fireTableRowsUpdated(index, index);
@@ -572,9 +571,6 @@
selectRouteByObservation(newValue);
}
-// else {
-// SammoaUtil.unselectAll(ui.getObservationTable());
-// }
}
});
@@ -778,6 +774,10 @@
table.setDefaultEditor(Date.class, new TimeCellEditor(datePicker));
}
+ if (getModel().isValidationMode()) {
+ TableRowFilterSupport.forTable(table).searchable(true).apply();
+ }
+
SammoaUtil.addTableSelectionListener(table, selectionModelAdapter);
SwingUtil.scrollToTableSelection(table);
@@ -789,13 +789,11 @@
protected void fireObservationsUpdated(Route route, boolean scrollToFirst) {
- FlightUIModel model = getModel();
-
Iterable<Observation> observations = Observations.filterInRoute(
- model.getObservations(), route, model.getRoutes(), true);
+ getModel().getObservations(), route, getModel().getRoutes(), true);
SammoaUtil.fireTableRowsUpdated(ui.getObservationTable(),
- model.getObservations(),
+ getModel().getObservations(),
observations,
scrollToFirst);
}
@@ -817,7 +815,7 @@
getModel().getRoutes(), observation, true);
int routeIndex = getModel().indexOfRoutes(route);
- ui.getRouteTable().getSelectionModel().setSelectionInterval(routeIndex, routeIndex);
+ SammoaUtil.selectTableRow(ui.getRouteTable(), routeIndex);
}
private PropertyChangeListener observationTimeChangeListener = new PropertyChangeListener() {
@@ -847,7 +845,7 @@
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- Observation observation = model.getBean(row);
+ Observation observation = model.getBean(table.convertRowIndexToModel(row));
Route route = Routes.findWithObservation(model.getFlightUIModel().getRoutes(), observation, true);
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/AbstractRowHighlightPredicate.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/AbstractRowHighlightPredicate.java 2012-09-04 12:47:21 UTC (rev 513)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/AbstractRowHighlightPredicate.java 2012-09-04 12:48:41 UTC (rev 514)
@@ -49,8 +49,8 @@
@Override
public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
- int columnIndex = adapter.column;
- int rowIndex = adapter.row;
+ int columnIndex = adapter.convertColumnIndexToModel(adapter.column);
+ int rowIndex = adapter.convertRowIndexToModel(adapter.row);
Object object = getValueAt(rowIndex);
boolean result;
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-09-04 12:47:21 UTC (rev 513)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/SammoaUtil.java 2012-09-04 12:48:41 UTC (rev 514)
@@ -94,14 +94,40 @@
}
((AbstractTableModel) table.getModel()).fireTableRowsUpdated(firstIndex, lastIndex);
if (scrollToFirst) {
- table.scrollRowToVisible(firstIndex);
+ table.scrollRowToVisible(table.convertRowIndexToView(firstIndex));
}
}
}
+ /**
+ * Select the row with the model {@code index} in given {@code table}.
+ *
+ * @param table Jtable to select the row
+ * @param index Model index to select
+ */
+ public static void selectTableRow(JTable table, int index) {
+ int viewIndex = table.convertRowIndexToView(index);
+ table.setRowSelectionInterval(viewIndex, viewIndex);
+ }
+
+ public static int getLastSelectedTableRow(JTable table) {
+ int result;
+ int nbRows = table.getSelectedRows().length;
+ if (nbRows > 0) {
+ int lastRow = table.getSelectedRows()[nbRows - 1];
+ result = table.convertRowIndexToModel(lastRow);
+
+ } else {
+ // No line selected
+ result = -1;
+ }
+ return result;
+ }
+
public static <T> TableSelectionListener<T> addTableSelectionListener(JTable table,
SelectionModelAdapter<T> selectionModelAdapter) {
- TableSelectionListener<T> result = new TableSelectionListener<T>(selectionModelAdapter);
+ TableSelectionListener<T> result =
+ new TableSelectionListener<T>(table, selectionModelAdapter);
table.getSelectionModel().addListSelectionListener(result);
return result;
}
@@ -305,17 +331,4 @@
JOptionPane.YES_NO_OPTION);
return i == JOptionPane.YES_OPTION;
}
-
- public static int getLastSelectedRow(JTable table) {
- int result;
- int nbRows = table.getSelectedRows().length;
- if (nbRows > 0) {
- result = table.getSelectedRows()[nbRows - 1];
-
- } else {
- // No line selected
- result = -1;
- }
- return result;
- }
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/TableSelectionListener.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/TableSelectionListener.java 2012-09-04 12:47:21 UTC (rev 513)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/TableSelectionListener.java 2012-09-04 12:48:41 UTC (rev 514)
@@ -27,6 +27,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
@@ -41,9 +42,13 @@
private static final Logger logger = LoggerFactory.getLogger(TableSelectionListener.class);
+ protected JTable table;
+
protected SelectionModelAdapter<T> selectionModelAdapter;
- public TableSelectionListener(SelectionModelAdapter<T> selectionModelAdapter) {
+ public TableSelectionListener(JTable table,
+ SelectionModelAdapter<T> selectionModelAdapter) {
+ this.table = table;
this.selectionModelAdapter = selectionModelAdapter;
}
@@ -64,11 +69,11 @@
} else if (listSelectionModel.isSelectedIndex(firstIndex)) {
// use first index
- newSelectedRow = firstIndex;
+ newSelectedRow = table.convertRowIndexToModel(firstIndex);
} else if (listSelectionModel.isSelectedIndex(lastIndex)) {
// use last index
- newSelectedRow = lastIndex;
+ newSelectedRow = table.convertRowIndexToModel(lastIndex);
}
List<T> elements = selectionModelAdapter.getElements();
T element = null;
@@ -78,7 +83,7 @@
element = elements.get(newSelectedRow);
if (logger.isInfoEnabled()) {
- logger.info("Select {} from index {}",
+ logger.info("Select {} at model index {}",
element.getClass().getSimpleName(), newSelectedRow);
}
1
0
r513 - in trunk: sammoa-application/src/main/java/fr/ulr/sammoa/application sammoa-application/src/main/resources/i18n sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action
by fdesbois@users.forge.codelutin.com 04 Sep '12
by fdesbois@users.forge.codelutin.com 04 Sep '12
04 Sep '12
Author: fdesbois
Date: 2012-09-04 14:47:21 +0200 (Tue, 04 Sep 2012)
New Revision: 513
Url: http://forge.codelutin.com/repositories/revision/sammoa/513
Log:
refs #1372 : issue on delete transect + add shortcut config
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java
trunk/sammoa-application/src/main/resources/i18n/sammoa-application_en_GB.properties
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidTransectAction.java
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java 2012-09-03 17:31:14 UTC (rev 512)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/SammoaConfig.java 2012-09-04 12:47:21 UTC (rev 513)
@@ -76,6 +76,8 @@
public static final String PROPERTY_CIRCLE_BACK = "circleBack";
+ public static final String PROPERTY_VALID_TRANSECT = "validTransect";
+
public static final String PROPERTY_VALID_ROUTE = "validRoute";
public static final String PROPERTY_VALID_OBSERVATION = "validObservation";
@@ -464,6 +466,13 @@
false,
false),
+ KEY_VALID_TRANSECT("ui." + PROPERTY_VALID_TRANSECT,
+ n_("sammoa.config.ui.validTransect"),
+ "alt pressed T",
+ KeyStroke.class,
+ false,
+ false),
+
KEY_VALID_ROUTE("ui." + PROPERTY_VALID_ROUTE,
n_("sammoa.config.ui.validRoute"),
"alt pressed R",
Modified: trunk/sammoa-application/src/main/resources/i18n/sammoa-application_en_GB.properties
===================================================================
--- trunk/sammoa-application/src/main/resources/i18n/sammoa-application_en_GB.properties 2012-09-03 17:31:14 UTC (rev 512)
+++ trunk/sammoa-application/src/main/resources/i18n/sammoa-application_en_GB.properties 2012-09-04 12:47:21 UTC (rev 513)
@@ -33,6 +33,7 @@
sammoa.config.ui.stop=Stop
sammoa.config.ui.validObservation=Validate the selected observation
sammoa.config.ui.validRoute=Validate the selected route
+sammoa.config.ui.validTransect=Validate the selected transect
sammoa.dateTimePattern=dd/MM/yyyy HH\:mm\:ss
sammoa.dbf.import.error.unableToReadField=impossible to read value for column %s at line %s
sammoa.flight.decorator.flight=Flight %1$d
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidTransectAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidTransectAction.java 2012-09-03 17:31:14 UTC (rev 512)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidTransectAction.java 2012-09-04 12:47:21 UTC (rev 513)
@@ -82,7 +82,7 @@
TransectFlight transectFlightChanged =
getValidationService().validateTransectFlight(getModel().getFlight(), transectFlight);
- if (transectFlightChanged.isDeleted()) {
+ if (transectFlightChanged == null) {
getModel().removeTransectFlight(index);
} else {
1
0
r512 - in trunk/sammoa-ui-swing/src/main: java/fr/ulr/sammoa/ui/swing/io/input/application resources/i18n
by fdesbois@users.forge.codelutin.com 03 Sep '12
by fdesbois@users.forge.codelutin.com 03 Sep '12
03 Sep '12
Author: fdesbois
Date: 2012-09-03 19:31:14 +0200 (Mon, 03 Sep 2012)
New Revision: 512
Url: http://forge.codelutin.com/repositories/revision/sammoa/512
Log:
fixes #1448 : add column to indicate flight exist
Modified:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/application/FlightTableModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/application/ImportApplicationUIHandler.java
trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/application/FlightTableModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/application/FlightTableModel.java 2012-09-03 15:47:49 UTC (rev 511)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/application/FlightTableModel.java 2012-09-03 17:31:14 UTC (rev 512)
@@ -41,19 +41,19 @@
protected final List<FlightImportEntry> data;
- protected final boolean canSelect;
+ protected final boolean campaignExist;
- protected Class<?>[] COLUMN_TYPES = {String.class, Boolean.class};
+ protected Class<?>[] COLUMN_TYPES = {String.class, Boolean.class, Boolean.class};
- public FlightTableModel(List<FlightImportEntry> data, boolean canSelect) {
+ public FlightTableModel(List<FlightImportEntry> data, boolean campaignExist) {
Preconditions.checkNotNull(data);
this.data = data;
- this.canSelect = canSelect;
+ this.campaignExist = campaignExist;
}
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
- return canSelect && columnIndex == 1;
+ return campaignExist && columnIndex == 2;
}
@Override
@@ -68,7 +68,7 @@
@Override
public int getColumnCount() {
- return canSelect ? 2 : 1;
+ return campaignExist ? 3 : 1;
}
@Override
@@ -83,6 +83,9 @@
result = flightImportEntry.getFlightStorage().getName();
break;
case 1:
+ result = flightImportEntry.getExistingFlight() != null;
+ break;
+ case 2:
result = flightImportEntry.isTreat();
break;
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/application/ImportApplicationUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/application/ImportApplicationUIHandler.java 2012-09-03 15:47:49 UTC (rev 511)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/application/ImportApplicationUIHandler.java 2012-09-03 17:31:14 UTC (rev 512)
@@ -342,6 +342,8 @@
table,
n_("sammoa.importApplication.flightTable.column.flightName"),
n_("sammoa.importApplication.flightTable.column.flightName.tip"),
+ n_("sammoa.importApplication.flightTable.column.flightExist"),
+ n_("sammoa.importApplication.flightTable.column.flightExist.tip"),
n_("sammoa.importApplication.flightTable.column.toTreat"),
n_("sammoa.importApplication.flightTable.column.toTreat.tip"));
} else {
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-09-03 15:47:49 UTC (rev 511)
+++ trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties 2012-09-03 17:31:14 UTC (rev 512)
@@ -92,6 +92,8 @@
sammoa.flightPanel.table.column.position.left=Left
sammoa.flightPanel.table.column.position.navigator=Nav
sammoa.flightPanel.table.column.position.right=Right
+sammoa.importApplication.flightTable.column.flightExist=Flight exist
+sammoa.importApplication.flightTable.column.flightExist.tip=Flight exist
sammoa.importApplication.flightTable.column.flightName=Flight name
sammoa.importApplication.flightTable.column.flightName.tip=Flight name
sammoa.importApplication.flightTable.column.toTreat=Select
1
0
r511 - in trunk/sammoa-ui-swing/src/main: java/fr/ulr/sammoa/ui/swing java/fr/ulr/sammoa/ui/swing/flight java/fr/ulr/sammoa/ui/swing/flight/action java/fr/ulr/sammoa/ui/swing/flight/bar java/fr/ulr/sammoa/ui/swing/flight/effort java/fr/ulr/sammoa/ui/swing/flight/effort/action java/fr/ulr/sammoa/ui/swing/region java/fr/ulr/sammoa/ui/swing/transect resources
by fdesbois@users.forge.codelutin.com 03 Sep '12
by fdesbois@users.forge.codelutin.com 03 Sep '12
03 Sep '12
Author: fdesbois
Date: 2012-09-03 17:47:49 +0200 (Mon, 03 Sep 2012)
New Revision: 511
Url: http://forge.codelutin.com/repositories/revision/sammoa/511
Log:
Clean packages :
- rename and move observations to flight.effort
- move action to flight.action
- rename SammoaAction to BaseFlightAction, old FlightAction is useless
- rename flightUIModel in EffortPanel to model
Added:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/CloseAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/AddAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/BaseFlightAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/BeginAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/CenterObservationAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/CircleBackAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/DeleteTransectAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/DeviceAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/EndAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/LeftObservationAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/NextAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/NextTransectAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ObservationAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/RightObservationAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StartAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StartAudioAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StopAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StopAudioAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidObservationAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidRouteAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidTransectAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/DeviceStateLED.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBar.css
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBar.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBarHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBarModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanel.css
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanel.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanelHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/ObservationTableModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/RouteTableModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/SpeciesCodeValidator.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/action/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/action/MoveToNextEditableCellAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/action/MoveToNextRowEditableAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/action/MoveToPreviousEditableCellAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/action/MoveToPreviousRowEditableAction.java
Removed:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/DeviceStateLED.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.css
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarModel.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/
Modified:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/region/RegionUI.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/transect/TransectUI.jaxx
trunk/sammoa-ui-swing/src/main/resources/validators.xml
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/CloseAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/CloseAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/CloseAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/CloseAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,63 @@
+package fr.ulr.sammoa.ui.swing;
+/*
+ * #%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 com.google.common.base.Preconditions;
+import jaxx.runtime.JAXXObject;
+
+import javax.swing.AbstractAction;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 24/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class CloseAction extends AbstractAction {
+
+ private static final long serialVersionUID = 1L;
+
+ protected JComponent ui;
+
+ public CloseAction(JComponent ui) {
+ super(_("sammoa.action.close"));
+ Preconditions.checkArgument(ui instanceof SammoaUI);
+ this.ui = ui;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ JDialog container = ((JAXXObject) ui).getParentContainer(JDialog.class);
+ if (container != null) {
+ container.dispose();
+ } else {
+ ui.setVisible(false);
+ }
+ ((SammoaUI<?>) ui).getHandler().onCloseUI();
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/CloseAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/DeviceStateLED.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/DeviceStateLED.java 2012-09-03 14:57:07 UTC (rev 510)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/DeviceStateLED.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -1,102 +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.flight;
-
-import fr.ulr.sammoa.application.device.DeviceState;
-import fr.ulr.sammoa.application.device.DeviceStateEvent;
-import fr.ulr.sammoa.application.device.DeviceStateListener;
-import org.nuiton.util.Resource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.swing.ImageIcon;
-import javax.swing.JLabel;
-
-/**
- * Panel qui écoute l'état du peripherique pour afficher à l'utilsateur un voyant
- * lunineux dépendant de l'état du peripherique.
- * <p/>
- * Indicateurs pour l'état du peripherique
- * <ul>
- * <li>voyant gris : pas de peripherique
- * <li>voyant bleu : peripherique prêt
- * <li>voyant vert : enregistrement en cours
- * <li>voyant rouge clignotant : enregistrement mais pas de données
- * </ul>
- *
- * @author chatellier
- */
-public class DeviceStateLED extends JLabel implements DeviceStateListener {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 1L;
-
- private static final Logger logger = LoggerFactory.getLogger(DeviceStateLED.class);
-
- protected DeviceState state;
-
- protected static final ImageIcon NO_DEVICE_ICON = Resource.getIcon("/icons/device/nodevice.png");
-
- protected static final ImageIcon READY_ICON = Resource.getIcon("/icons/device/ready.png");
-
- protected static final ImageIcon RECORDING_ICON = Resource.getIcon("/icons/device/recording.png");
-
- protected static final ImageIcon NO_DATA_ICON = Resource.getIcon("/icons/device/nodata.gif");
-
- @Override
- public void stateChanged(DeviceStateEvent event) {
- setState(event.getNewValue());
- }
-
- public void setState(DeviceState state) {
- DeviceState oldValue = getState();
- this.state = state;
-
- if (oldValue != state) {
-
- logger.debug("[{}] Update LED status: {}",
- getClass().getSimpleName(), state);
-
- switch (state) {
- case UNAVAILABLE:
- setIcon(NO_DEVICE_ICON);
- break;
- case READY:
- setIcon(READY_ICON);
- break;
- case RUNNING:
- setIcon(RECORDING_ICON);
- break;
- case ERROR:
- setIcon(NO_DATA_ICON);
- break;
- }
- }
- }
-
- public DeviceState getState() {
- return state;
- }
-}
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.css
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.css 2012-09-03 14:57:07 UTC (rev 510)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.css 2012-09-03 15:47:49 UTC (rev 511)
@@ -1,101 +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%
- */
-
-#stateBar {
- background: {model.getEffortPanelColor()};
-}
-
-#clockTime {
- delay: 1000;
- pattern: "dd/MM/yyyy HH:mm:ss";
- visible: {!flightUIModel.isValidationMode()};
-}
-#audioTime {
- visible: {flightUIModel.isValidationMode()};
- text: {dateFormat.format(flightUIModel.getCurrentRoute().getBeginTime())};
-}
-
-#beginButton {
- _actionName: {"begin"};
-}
-
-#endButton {
- _actionName: {"end"};
-}
-
-#nextButton {
- _actionName: {"next"};
-}
-
-#effortButtonPanel {
- background: {model.getEffortPanelColor()};
-}
-
-#statusPanel {
- background: {model.getEffortPanelColor()};
-}
-
-#lblEffort {
- text: {flightUIModel.getFlightState().name()};
-}
-
-#lblTransect {
- text: {flightUIModel.getCurrentRoute().getTransectFlight().getTransect().getName()};
-}
-
-#lblStatus {
- text: {flightUIModel.getCurrentRoute().getRouteType().name()
- + (flightUIModel.getCurrentRoute().getEffortNumber() != null
- ? " " + flightUIModel.getCurrentRoute().getEffortNumber()
- : "")};
-}
-
-#lblObservation {
- text: {flightUIModel.getCurrentRoute().getTransectFlight().getTransect().getName()};
-}
-
-#cbPanel {
- background: {model.getEffortPanelColor()};
-}
-
-#gpsLED {
- text: "sammoa.statusBar.gps";
-}
-
-#audioLED {
- text: "sammoa.statusBar.audio";
-}
-
-#indicatorPanel {
- background: {model.getEffortPanelColor()};
-}
-
-#lblAlt {
- text: {model.getAlt()};
-}
-
-#lblSpeed {
- text: {model.getSpeed()};
-}
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.jaxx 2012-09-03 14:57:07 UTC (rev 510)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.jaxx 2012-09-03 15:47:49 UTC (rev 511)
@@ -1,130 +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%
- -->
-<JPanel id='statusBar' layout='{new GridLayout(0,1,0,0)}'>
-
- <import>
- java.text.SimpleDateFormat
- javax.swing.BoxLayout
- javax.swing.SwingConstants
- jaxx.runtime.swing.ClockWidget
- </import>
-
- <script><![CDATA[
-
- protected void $afterCompleteSetup() {
- getHandler().init();
- }
-
- ]]></script>
-
- <FlightBarHandler id='handler' constructorParams='this'/>
-
- <FlightUIModel id='flightUIModel' initializer='getHandler().getParentUI().getModel()'/>
-
- <FlightBarModel id='model'/>
-
- <SimpleDateFormat id='dateFormat' constructorParams='"dd/MM/yyyy HH:mm:ss"'/>
-
- <Table id='validationBar'>
- <row>
- <cell fill='horizontal' weightx='0.2'>
- <JPanel id='audioButtonPanel'
- layout='{new BoxLayout(audioButtonPanel, BoxLayout.X_AXIS)}'>
- <JButton id='startAudioButton'/>
- <JButton id='stopAudioButton'/>
- </JPanel>
- </cell>
- <cell fill='horizontal'>
- <JSlider id='audioSlider' enabled='false'/>
- </cell>
- <cell fill='horizontal' weightx='0.2'>
- <JPanel id='validButtonPanel'
- layout='{new BoxLayout(validButtonPanel, BoxLayout.X_AXIS)}'>
- <JButton id='validRouteButton'/>
- <JButton id='validObservationButton'/>
- <JButton id='validTransectButton'/>
- </JPanel>
- </cell>
- </row>
- </Table>
- <Table id='stateBar'>
- <row>
- <cell fill='horizontal' weightx='0.2'>
- <ClockWidget id='clockTime'/>
- </cell>
- <cell fill='horizontal' weightx='0.2'>
- <JLabel id='audioTime'/>
- </cell>
- <cell fill='vertical'>
- <JSeparator constructorParams='SwingConstants.VERTICAL'/>
- </cell>
- <cell fill='horizontal'>
- <JPanel id='effortButtonPanel'
- layout='{new BoxLayout(effortButtonPanel, BoxLayout.X_AXIS)}'>
- <JButton id='beginButton'/>
- <JButton id='endButton'/>
- <JButton id='nextButton'/>
- </JPanel>
- </cell>
- <cell fill='vertical'>
- <JSeparator constructorParams='SwingConstants.VERTICAL'/>
- </cell>
- <cell fill='horizontal' weightx='0.2' anchor='center'>
- <JLabel id='lblEffort'/>
- </cell>
- <cell fill='vertical'>
- <JSeparator constructorParams='SwingConstants.VERTICAL'/>
- </cell>
- <cell fill='horizontal' weightx='0.2' anchor='center'>
- <JLabel id='lblTransect'/>
- </cell>
- <cell fill='vertical'>
- <JSeparator constructorParams='SwingConstants.VERTICAL'/>
- </cell>
- <cell fill='horizontal' weightx='0.2' anchor='center'>
- <JLabel id='lblStatus'/>
- </cell>
- <cell fill='vertical'>
- <JSeparator constructorParams='SwingConstants.VERTICAL'/>
- </cell>
- <cell fill='horizontal' weightx='0.2' anchor='center'>
- <JPanel id='cbPanel' layout='{new BoxLayout(cbPanel, BoxLayout.Y_AXIS)}'>
- <DeviceStateLED id='gpsLED' />
- <DeviceStateLED id='audioLED' />
- </JPanel>
- </cell>
- <cell fill='vertical'>
- <JSeparator constructorParams='SwingConstants.VERTICAL'/>
- </cell>
- <cell fill='horizontal' weightx='0.2' anchor='center'>
- <JPanel id='indicatorPanel'
- layout='{new BoxLayout(indicatorPanel, BoxLayout.Y_AXIS)}'>
- <JLabel id='lblAlt'/>
- <JLabel id='lblSpeed'/>
- </JPanel>
- </cell>
- </row>
- </Table>
-</JPanel>
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarHandler.java 2012-09-03 14:57:07 UTC (rev 510)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarHandler.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -1,129 +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.flight;
-
-import fr.ulr.sammoa.application.device.audio.AudioRecorder;
-import fr.ulr.sammoa.application.device.gps.GpsHandler;
-import fr.ulr.sammoa.application.flightController.FlightController;
-import fr.ulr.sammoa.application.flightController.FlightState;
-import fr.ulr.sammoa.persistence.Route;
-import fr.ulr.sammoa.ui.swing.SammoaColors;
-import jaxx.runtime.JAXXUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-/** @author sletellier <letellier(a)codelutin.com> */
-public class FlightBarHandler implements PropertyChangeListener {
-
- private static final Logger logger =
- LoggerFactory.getLogger(FlightBarHandler.class);
-
- protected final FlightBar ui;
-
- public FlightBarHandler(FlightBar ui) {
- this.ui = ui;
- }
-
- public FlightUI getParentUI() {
- return ui.getContextValue(FlightUI.class, JAXXUtil.PARENT);
- }
-
- protected FlightBarModel getModel() {
- return ui.getModel();
- }
-
- public void init() {
-
- FlightUIModel flightUIModel = ui.getFlightUIModel();
- flightUIModel.addPropertyChangeListener(this);
-
-
- FlightController flightController =
- ui.getContextValue(FlightUIHandler.class).getFlightController();
-
- if (flightUIModel.isValidationMode()) {
-
- // Put actionName for validation buttons
- ui.getStartAudioButton().putClientProperty("actionName", "startAudio");
- ui.getStopAudioButton().putClientProperty("actionName", "stopAudio");
- ui.getValidObservationButton().putClientProperty("actionName", "validObservation");
- ui.getValidRouteButton().putClientProperty("actionName", "validRoute");
- ui.getValidTransectButton().putClientProperty("actionName", "validTransect");
-
- } else {
-
- // Remove the bar used only for validation
- ui.remove(ui.getValidationBar());
-
- AudioRecorder audioRecorder = flightController.getDeviceManager(AudioRecorder.class);
- ui.getAudioLED().setState(audioRecorder.getState());
- audioRecorder.addDeviceStateListener(ui.getAudioLED());
-
- GpsHandler gpsHandler = flightController.getDeviceManager(GpsHandler.class);
- ui.getGpsLED().setState(gpsHandler.getState());
- gpsHandler.addDeviceStateListener(ui.getGpsLED());
- gpsHandler.addGpsLocationListener(getModel());
- }
-
- if (FlightState.OFF_EFFORT.equals(ui.getFlightUIModel().getFlightState())) {
- getModel().setEffortPanelColor(SammoaColors.ON_EFFORT_BACKGROUND_COLOR);
- }
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- String propertyName = evt.getPropertyName();
-
- if (FlightUIModel.PROPERTY_FLIGHT_STATE.equals(propertyName)) {
-
- logger.debug("Modify flight bar background color");
-
- // si l'etat du vol passe en off effort
- // affiche à l'utilisateur
- FlightState newState = (FlightState) evt.getNewValue();
- if (FlightState.OFF_EFFORT.equals(newState)) {
- getModel().setEffortPanelColor(SammoaColors.ON_EFFORT_BACKGROUND_COLOR);
-
- } else {
- getModel().setEffortPanelColor(null);
- }
-
- } else if (FlightUIModel.PROPERTY_CURRENT_ROUTE.equals(propertyName)) {
-
- Route route = (Route) evt.getNewValue();
-
- logger.debug("New value received for current route {}", route);
-
- if (route == null || route.getTransectFlight() == null) {
- // set null will hide label
- ui.getLblTransect().setText(null);
- }
-
- }
- }
-}
Deleted: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarModel.java 2012-09-03 14:57:07 UTC (rev 510)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarModel.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -1,91 +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.flight;
-
-import fr.ulr.sammoa.application.device.gps.GpsLocationEvent;
-import fr.ulr.sammoa.application.device.gps.GpsLocationListener;
-import fr.ulr.sammoa.persistence.GeoPoint;
-import org.jdesktop.beans.AbstractSerializableBean;
-
-import java.awt.Color;
-
-import static org.nuiton.i18n.I18n._;
-
-/** @author sletellier <letellier(a)codelutin.com> */
-public class FlightBarModel extends AbstractSerializableBean implements GpsLocationListener {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_ALT = "alt";
-
- public static final String PROPERTY_SPEED = "speed";
-
- public static final String PROPERTY_EFFORT_PANEL_COLOR = "effortPanelColor";
-
- protected float alt;
-
- protected float speed;
-
- protected Color effortPanelColor;
-
- public String getAlt() {
- return _("sammoa.statusbar.alt", alt);
- }
-
- public void setAlt(float alt) {
- float oldValue = this.alt;
- this.alt = alt;
- firePropertyChange(PROPERTY_ALT, oldValue, alt);
- }
-
- public String getSpeed() {
- return _("sammoa.statusbar.speed", speed);
- }
-
- public void setSpeed(float speed) {
- float oldValue = this.speed;
- this.speed = speed;
- firePropertyChange(PROPERTY_SPEED, oldValue, speed);
- }
-
- public Color getEffortPanelColor() {
- return effortPanelColor;
- }
-
- public void setEffortPanelColor(Color effortPanelColor) {
- Color oldColor = this.effortPanelColor;
- this.effortPanelColor = effortPanelColor;
- firePropertyChange(PROPERTY_EFFORT_PANEL_COLOR, oldColor, this.effortPanelColor);
- }
-
- @Override
- public void locationChanged(GpsLocationEvent event) {
- GeoPoint newLocation = event.getNewValue();
- if (newLocation != null) {
- setSpeed((float) newLocation.getSpeed());
- setAlt((float) newLocation.getAltitude());
- }
- }
-}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.jaxx 2012-09-03 14:57:07 UTC (rev 510)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.jaxx 2012-09-03 15:47:49 UTC (rev 511)
@@ -40,7 +40,8 @@
fr.ulr.sammoa.persistence.Observer
fr.ulr.sammoa.application.flightController.FlightState
fr.ulr.sammoa.ui.swing.SammoaUIContext
- fr.ulr.sammoa.ui.swing.observations.EffortPanel
+ fr.ulr.sammoa.ui.swing.flight.bar.FlightBar
+ fr.ulr.sammoa.ui.swing.flight.effort.EffortPanel
</import>
<FlightUIHandler id='handler'
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java 2012-09-03 14:57:07 UTC (rev 510)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -88,23 +88,23 @@
import fr.ulr.sammoa.ui.swing.SammoaUIContext;
import fr.ulr.sammoa.ui.swing.SammoaUIHandler;
import fr.ulr.sammoa.ui.swing.UIDecoratorService;
-import fr.ulr.sammoa.ui.swing.action.AddAction;
-import fr.ulr.sammoa.ui.swing.action.BeginAction;
-import fr.ulr.sammoa.ui.swing.action.CenterObservationAction;
-import fr.ulr.sammoa.ui.swing.action.CircleBackAction;
-import fr.ulr.sammoa.ui.swing.action.DeleteTransectAction;
-import fr.ulr.sammoa.ui.swing.action.EndAction;
-import fr.ulr.sammoa.ui.swing.action.LeftObservationAction;
-import fr.ulr.sammoa.ui.swing.action.NextAction;
-import fr.ulr.sammoa.ui.swing.action.NextTransectAction;
-import fr.ulr.sammoa.ui.swing.action.RightObservationAction;
-import fr.ulr.sammoa.ui.swing.action.StartAction;
-import fr.ulr.sammoa.ui.swing.action.StartAudioAction;
-import fr.ulr.sammoa.ui.swing.action.StopAction;
-import fr.ulr.sammoa.ui.swing.action.StopAudioAction;
-import fr.ulr.sammoa.ui.swing.action.ValidObservationAction;
-import fr.ulr.sammoa.ui.swing.action.ValidRouteAction;
-import fr.ulr.sammoa.ui.swing.action.ValidTransectAction;
+import fr.ulr.sammoa.ui.swing.flight.action.AddAction;
+import fr.ulr.sammoa.ui.swing.flight.action.BeginAction;
+import fr.ulr.sammoa.ui.swing.flight.action.CenterObservationAction;
+import fr.ulr.sammoa.ui.swing.flight.action.CircleBackAction;
+import fr.ulr.sammoa.ui.swing.flight.action.DeleteTransectAction;
+import fr.ulr.sammoa.ui.swing.flight.action.EndAction;
+import fr.ulr.sammoa.ui.swing.flight.action.LeftObservationAction;
+import fr.ulr.sammoa.ui.swing.flight.action.NextAction;
+import fr.ulr.sammoa.ui.swing.flight.action.NextTransectAction;
+import fr.ulr.sammoa.ui.swing.flight.action.RightObservationAction;
+import fr.ulr.sammoa.ui.swing.flight.action.StartAction;
+import fr.ulr.sammoa.ui.swing.flight.action.StartAudioAction;
+import fr.ulr.sammoa.ui.swing.flight.action.StopAction;
+import fr.ulr.sammoa.ui.swing.flight.action.StopAudioAction;
+import fr.ulr.sammoa.ui.swing.flight.action.ValidObservationAction;
+import fr.ulr.sammoa.ui.swing.flight.action.ValidRouteAction;
+import fr.ulr.sammoa.ui.swing.flight.action.ValidTransectAction;
import fr.ulr.sammoa.ui.swing.flight.layer.BaseGeoPointLayer;
import fr.ulr.sammoa.ui.swing.flight.layer.LineGeoPointLayer;
import fr.ulr.sammoa.ui.swing.flight.layer.SimpleGeoPointLayer;
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/AddAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/AddAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/AddAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/AddAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,60 @@
+/*
+ * #%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.flight.action;
+
+import fr.ulr.sammoa.application.flightController.FlightState;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import jaxx.runtime.JAXXContext;
+import org.nuiton.util.Resource;
+
+import javax.swing.Action;
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 03/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class AddAction extends BaseFlightAction {
+
+ private static final long serialVersionUID = 1L;
+
+ public AddAction(JAXXContext context) {
+ super(Resource.getIcon("/icons/action-add.png"), context);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.add.tip"));
+ bindModelProperties(FlightUIModel.PROPERTY_FLIGHT_STATE);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ getFlightController().add();
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ return getModel().getFlightState() == FlightState.ON_EFFORT;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/AddAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/BaseFlightAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/SammoaAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/BaseFlightAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/BaseFlightAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,92 @@
+/*
+ * #%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.flight.action;
+
+import fr.ulr.sammoa.application.flightController.FlightController;
+import fr.ulr.sammoa.ui.swing.SammoaUIContext;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIHandler;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import jaxx.runtime.JAXXContext;
+
+import javax.swing.AbstractAction;
+import javax.swing.Icon;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+/**
+ * Created: 03/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public abstract class BaseFlightAction extends AbstractAction {
+
+ protected JAXXContext context;
+
+ public BaseFlightAction(String name, Icon icon, JAXXContext context) {
+ super(name, icon);
+ init(context);
+ }
+
+ public BaseFlightAction(String name, JAXXContext context) {
+ super(name);
+ init(context);
+ }
+
+ public BaseFlightAction(Icon icon, JAXXContext context) {
+ this("", icon, context);
+ }
+
+ protected void init(JAXXContext context) {
+ this.context = context;
+ setEnabled(checkEnabled());
+ }
+
+ protected FlightController getFlightController() {
+ return context.getContextValue(FlightUIHandler.class).getFlightController();
+ }
+
+ protected FlightUIModel getModel() {
+ return context.getContextValue(FlightUIHandler.class).getModel();
+ }
+
+ protected SammoaUIContext getSammoaUIContext() {
+ return context.getContextValue(SammoaUIContext.class);
+ }
+
+ protected void bindModelProperties(String... properties) {
+ for (String property : properties) {
+ getModel().addPropertyChangeListener(property, enabledListener);
+ }
+ }
+
+ protected PropertyChangeListener enabledListener = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ setEnabled(checkEnabled());
+ }
+ };
+
+ protected abstract boolean checkEnabled();
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/BaseFlightAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/BeginAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/BeginAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/BeginAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/BeginAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,74 @@
+/*
+ * #%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.flight.action;
+
+import fr.ulr.sammoa.application.flightController.FlightState;
+import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.RouteType;
+import fr.ulr.sammoa.persistence.TransectFlight;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import jaxx.runtime.JAXXContext;
+
+import javax.swing.Action;
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 03/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class BeginAction extends BaseFlightAction {
+
+ private static final long serialVersionUID = 1L;
+
+ public BeginAction(JAXXContext context) {
+ super(_("sammoa.action.begin"), context);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.begin.tip"));
+ bindModelProperties(
+ FlightUIModel.PROPERTY_FLIGHT_STATE,
+ FlightUIModel.PROPERTY_CURRENT_ROUTE,
+ FlightUIModel.PROPERTY_NEXT_TRANSECT
+ );
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ getFlightController().begin();
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ Route currentRoute = getModel().getCurrentRoute();
+ boolean isCircleBack = currentRoute != null
+ && RouteType.CIRCLE_BACK == currentRoute.getRouteType();
+
+ TransectFlight nextTransect = getModel().getNextTransect();
+ boolean isReadyForLeg = nextTransect != null
+ && getModel().getFlightState() == FlightState.OFF_EFFORT;
+
+ return isCircleBack || isReadyForLeg;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/BeginAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/CenterObservationAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/CenterObservationAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/CenterObservationAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/CenterObservationAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,46 @@
+/*
+ * #%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.flight.action;
+
+import fr.ulr.sammoa.persistence.Position;
+import jaxx.runtime.JAXXContext;
+
+import javax.swing.Action;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 03/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class CenterObservationAction extends ObservationAction {
+
+ private static final long serialVersionUID = 1L;
+
+ public CenterObservationAction(JAXXContext context) {
+ super(_("sammoa.observation.observations.center"), context, Position.NAVIGATOR);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.center.tip"));
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/CenterObservationAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/CircleBackAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/CircleBackAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/CircleBackAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/CircleBackAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,88 @@
+/*
+ * #%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.flight.action;
+
+import com.google.common.collect.Iterables;
+import fr.ulr.sammoa.persistence.Observation;
+import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.RouteType;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import jaxx.runtime.JAXXContext;
+import org.nuiton.util.Resource;
+
+import javax.swing.Action;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import java.awt.event.ActionEvent;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 03/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class CircleBackAction extends BaseFlightAction {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String CLIENT_PROPERTY_OBSERVATION = "observation";
+
+ protected static final ImageIcon CIRCLE_BACK_ICON = Resource.getIcon("/icons/undo.png");
+
+ public CircleBackAction(JAXXContext context) {
+ super(CIRCLE_BACK_ICON, context);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.circleBack.tip"));
+ bindModelProperties(FlightUIModel.PROPERTY_CURRENT_ROUTE);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ Observation observation = null;
+ Object source = e.getSource();
+ if (source instanceof JComponent) {
+ JComponent comp = (JComponent) source;
+ observation = (Observation) comp.getClientProperty(CLIENT_PROPERTY_OBSERVATION);
+ }
+
+ if (observation == null) {
+ List<Observation> obsList = getModel().getObservations();
+ observation = Iterables.getLast(obsList);
+ }
+
+ getFlightController().circleBack(observation);
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ boolean result = false;
+ Route route = getModel().getCurrentRoute();
+ if (route != null) {
+ result = route.getRouteType() != RouteType.TRANSIT;
+ }
+ return result;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/CircleBackAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/DeleteTransectAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/DeleteTransectAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/DeleteTransectAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/DeleteTransectAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,78 @@
+package fr.ulr.sammoa.ui.swing.flight.action;
+
+import fr.ulr.sammoa.application.FlightService;
+import fr.ulr.sammoa.application.flightController.FlightState;
+import fr.ulr.sammoa.ui.swing.flight.FlightUI;
+import fr.ulr.sammoa.ui.swing.flight.TransectFlightModel;
+import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
+import jaxx.runtime.JAXXContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.Action;
+import javax.swing.JComponent;
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 03/09/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public class DeleteTransectAction extends BaseFlightAction {
+
+ /** Logger. */
+ private static final Logger logger = LoggerFactory.getLogger(DeleteTransectAction.class);
+
+ public static final String CLIENT_PROPERTY_TRANSECT_FLIGHT = "transectFlight";
+
+ public DeleteTransectAction(JAXXContext context) {
+ super((String) null, context);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.deleteTransect.tip"));
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Object source = e.getSource();
+ if (source instanceof JComponent) {
+ JComponent comp = (JComponent) source;
+
+ final TransectFlightModel transectFlight =
+ (TransectFlightModel) comp.getClientProperty(CLIENT_PROPERTY_TRANSECT_FLIGHT);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Change transect {} deleted flag to {}",
+ transectFlight.getSource().getTransect().getName(),
+ !transectFlight.isDeleted());
+ }
+
+ transectFlight.setDeleted(!transectFlight.isDeleted());
+
+ // #1372: If flight isn't started, we propose to delete definitely the transect
+ if (FlightState.WAITING == getModel().getFlightState() && transectFlight.isDeleted()) {
+
+ if (SammoaUtil.askQuestion((FlightUI) context, _("sammoa.confirmDialog.deleteTransect.message"))) {
+
+ FlightService service =
+ getSammoaUIContext().getService(FlightService.class);
+ service.deleteTansectFlight(getModel().getFlight(), transectFlight.getSource());
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Delete transect {} ",
+ transectFlight.getSource().getTransect().getName());
+ }
+
+ // Update model
+ int index = getModel().indexOfTransectFlights(transectFlight);
+ getModel().removeTransectFlight(index);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ return true;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/DeleteTransectAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/DeviceAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/DeviceAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/DeviceAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/DeviceAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,71 @@
+/*
+ * #%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.flight.action;
+
+import fr.ulr.sammoa.application.device.DeviceManager;
+import fr.ulr.sammoa.application.device.DeviceStateEvent;
+import fr.ulr.sammoa.application.device.DeviceStateListener;
+import jaxx.runtime.JAXXContext;
+
+import javax.swing.Icon;
+
+/**
+ * Created: 03/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public abstract class DeviceAction<T extends DeviceManager> extends BaseFlightAction {
+
+ private static final long serialVersionUID = 1L;
+
+ protected T device;
+
+ protected DeviceAction(Icon icon, JAXXContext context) {
+ super(icon, context);
+ }
+
+ protected DeviceAction(String name, JAXXContext context) {
+ super(name, context);
+ }
+
+ protected T getDevice() {
+ if (device == null) {
+ device = getFlightController().getDeviceManager(getDeviceClass());
+ device.addDeviceStateListener(new DeviceStateListener() {
+
+ @Override
+ public void stateChanged(DeviceStateEvent event) {
+ setEnabled(checkEnabled());
+ }
+ });
+ }
+ return device;
+ }
+
+ protected boolean hasDevice() {
+ return device != null || getFlightController().getDeviceManager(getDeviceClass()) != null;
+ }
+
+ protected abstract Class<T> getDeviceClass();
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/DeviceAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/EndAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/EndAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/EndAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/EndAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,59 @@
+/*
+ * #%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.flight.action;
+
+import fr.ulr.sammoa.application.flightController.FlightState;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import jaxx.runtime.JAXXContext;
+
+import javax.swing.Action;
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 03/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class EndAction extends BaseFlightAction {
+
+ private static final long serialVersionUID = 1L;
+
+ public EndAction(JAXXContext context) {
+ super(_("sammoa.action.end"), context);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.end.tip"));
+ bindModelProperties(FlightUIModel.PROPERTY_FLIGHT_STATE);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ getFlightController().end();
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ return getModel().getFlightState() == FlightState.ON_EFFORT;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/EndAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/LeftObservationAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/LeftObservationAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/LeftObservationAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/LeftObservationAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,46 @@
+/*
+ * #%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.flight.action;
+
+import fr.ulr.sammoa.persistence.Position;
+import jaxx.runtime.JAXXContext;
+
+import javax.swing.Action;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 03/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class LeftObservationAction extends ObservationAction {
+
+ private static final long serialVersionUID = 1L;
+
+ public LeftObservationAction(JAXXContext context) {
+ super(_("sammoa.observation.observations.left"), context, Position.FRONT_LEFT);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.left.tip"));
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/LeftObservationAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/NextAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/NextAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/NextAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/NextAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,60 @@
+/*
+ * #%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.flight.action;
+
+import fr.ulr.sammoa.application.flightController.FlightState;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import jaxx.runtime.JAXXContext;
+
+import javax.swing.Action;
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 03/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class NextAction extends BaseFlightAction {
+
+ private static final long serialVersionUID = 1L;
+
+ public NextAction(JAXXContext context) {
+ super(_("sammoa.action.next"), context);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.next.tip"));
+ bindModelProperties(FlightUIModel.PROPERTY_FLIGHT_STATE);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ getFlightController().next();
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ return getModel().getFlightState() == FlightState.ON_EFFORT
+ && getModel().getNextTransect() != null;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/NextAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/NextTransectAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/NextTransectAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/NextTransectAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/NextTransectAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,68 @@
+/*
+ * #%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.flight.action;
+
+import fr.ulr.sammoa.ui.swing.flight.TransectFlightModel;
+import jaxx.runtime.JAXXContext;
+import org.nuiton.util.Resource;
+
+import javax.swing.Action;
+import javax.swing.JComponent;
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 03/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class NextTransectAction extends BaseFlightAction {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String CLIENT_PROPERTY_TRANSECT_FLIGHT = "transectFlight";
+
+ public NextTransectAction(JAXXContext context) {
+ super(Resource.getIcon("/icons/action-next-transect.png"), context);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.nextTransect.tip"));
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Object source = e.getSource();
+ if (source instanceof JComponent) {
+ JComponent component = (JComponent) e.getSource();
+ TransectFlightModel transectFlight =
+ (TransectFlightModel) component.getClientProperty(CLIENT_PROPERTY_TRANSECT_FLIGHT);
+
+ getFlightController().setNextTransect(transectFlight.getSource());
+ }
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ return true;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/NextTransectAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ObservationAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ObservationAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ObservationAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ObservationAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,61 @@
+/*
+ * #%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.flight.action;
+
+import fr.ulr.sammoa.application.flightController.FlightState;
+import fr.ulr.sammoa.persistence.Position;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import jaxx.runtime.JAXXContext;
+
+import java.awt.event.ActionEvent;
+
+/**
+ * Created: 03/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public abstract class ObservationAction extends BaseFlightAction {
+
+ private static final long serialVersionUID = 1L;
+
+ protected Position position;
+
+ public ObservationAction(String name, JAXXContext context, Position position) {
+ super(name, context);
+ this.position = position;
+ bindModelProperties(FlightUIModel.PROPERTY_FLIGHT_STATE);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ getFlightController().observation(position);
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ FlightState state = getModel().getFlightState();
+ return state == FlightState.ON_EFFORT
+ || state == FlightState.OFF_EFFORT;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ObservationAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/RightObservationAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/RightObservationAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/RightObservationAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/RightObservationAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,46 @@
+/*
+ * #%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.flight.action;
+
+import fr.ulr.sammoa.persistence.Position;
+import jaxx.runtime.JAXXContext;
+
+import javax.swing.Action;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 03/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class RightObservationAction extends ObservationAction {
+
+ private static final long serialVersionUID = 1L;
+
+ public RightObservationAction(JAXXContext context) {
+ super(_("sammoa.observation.observations.right"), context, Position.FRONT_RIGHT);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.right.tip"));
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/RightObservationAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StartAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/StartAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StartAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StartAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,60 @@
+/*
+ * #%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.flight.action;
+
+import fr.ulr.sammoa.application.flightController.FlightState;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import jaxx.runtime.JAXXContext;
+import org.nuiton.util.Resource;
+
+import javax.swing.Action;
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 05/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class StartAction extends BaseFlightAction {
+
+ private static final long serialVersionUID = 1L;
+
+ public StartAction(JAXXContext context) {
+ super(Resource.getIcon("/icons/playback_play.png"), context);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.start.tip"));
+ bindModelProperties(FlightUIModel.PROPERTY_FLIGHT_STATE);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ getFlightController().start();
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ return getModel().getFlightState() == FlightState.WAITING;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StartAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StartAudioAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/StartAudioAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StartAudioAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StartAudioAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,64 @@
+/*
+ * #%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.flight.action;
+
+import fr.ulr.sammoa.application.device.DeviceState;
+import fr.ulr.sammoa.application.device.audio.AudioReader;
+import jaxx.runtime.JAXXContext;
+import org.nuiton.util.Resource;
+
+import javax.swing.Action;
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 05/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class StartAudioAction extends DeviceAction<AudioReader> {
+
+ private static final long serialVersionUID = 1L;
+
+ public StartAudioAction(JAXXContext context) {
+ super(Resource.getIcon("/icons/playback_play.png"), context);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.startAudio.tip"));
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ getDevice().start();
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ return hasDevice() && getDevice().getState() == DeviceState.READY;
+ }
+
+ @Override
+ protected Class<AudioReader> getDeviceClass() {
+ return AudioReader.class;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StartAudioAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StopAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/StopAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StopAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StopAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,61 @@
+/*
+ * #%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.flight.action;
+
+import fr.ulr.sammoa.application.flightController.FlightState;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import jaxx.runtime.JAXXContext;
+import org.nuiton.util.Resource;
+
+import javax.swing.Action;
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 05/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class StopAction extends BaseFlightAction {
+
+ private static final long serialVersionUID = 1L;
+
+ public StopAction(JAXXContext context) {
+ super(Resource.getIcon("/icons/playback_stop.png"), context);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.stop.tip"));
+ bindModelProperties(FlightUIModel.PROPERTY_FLIGHT_STATE);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ getFlightController().stop();
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ return getModel().getFlight().getEndDate() == null
+ && getModel().getFlightState() == FlightState.OFF_EFFORT;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StopAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StopAudioAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/StopAudioAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StopAudioAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StopAudioAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,64 @@
+/*
+ * #%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.flight.action;
+
+import fr.ulr.sammoa.application.device.DeviceState;
+import fr.ulr.sammoa.application.device.audio.AudioReader;
+import jaxx.runtime.JAXXContext;
+import org.nuiton.util.Resource;
+
+import javax.swing.Action;
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 05/07/12
+ *
+ * @author fdesbois <desbois(a)codelutin.com>
+ */
+public class StopAudioAction extends DeviceAction<AudioReader> {
+
+ private static final long serialVersionUID = 1L;
+
+ public StopAudioAction(JAXXContext context) {
+ super(Resource.getIcon("/icons/playback_stop.png"), context);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.stopAudio.tip"));
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ getDevice().stop();
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ return hasDevice() && getDevice().getState() == DeviceState.RUNNING;
+ }
+
+ @Override
+ protected Class<AudioReader> getDeviceClass() {
+ return AudioReader.class;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/StopAudioAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,155 @@
+package fr.ulr.sammoa.ui.swing.flight.action;
+/*
+ * #%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 com.google.common.base.Preconditions;
+import com.google.common.collect.Maps;
+import fr.ulr.sammoa.application.ValidationService;
+import fr.ulr.sammoa.persistence.Observation;
+import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.Validable;
+import fr.ulr.sammoa.ui.swing.SammoaUIContext;
+import jaxx.runtime.JAXXContext;
+import org.jdesktop.beans.AbstractBean;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.Resource;
+import org.nuiton.validator.bean.list.BeanListValidator;
+import org.nuiton.validator.bean.list.BeanListValidatorEvent;
+import org.nuiton.validator.bean.list.BeanListValidatorListener;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Map;
+
+/**
+ * Created: 23/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public abstract class ValidAction extends BaseFlightAction {
+
+ protected ValidationService validationService;
+
+ protected Map<Class<?>, BeanListValidator<?>> validators = Maps.newHashMap();
+
+ public ValidAction(String name, JAXXContext context) {
+ super(name, Resource.getIcon("/icons/action-tick.png"), context);
+ }
+
+ protected ValidationService getValidationService() {
+ if (validationService == null) {
+ validationService =
+ SammoaUIContext.getUIContext().getService(ValidationService.class);
+ }
+ return validationService;
+ }
+
+ /**
+ * Retrieve a validator for the {@code beanClass}. A cache
+ * is used to keep the validator for this property. A listener is also
+ * used to call checkEnabled() on each validation change.
+ *
+ * @param beanClass Class of the bean
+ * @param <E> generic type of the bean
+ * @return the {@link BeanListValidator} found
+ * @throws NullPointerException if no validator exists in context for the
+ * given {@code modelPropertyName}
+ */
+ private <E extends Validable> BeanListValidator<E> getValidator(Class<E> beanClass) {
+ BeanListValidator<E> validator = (BeanListValidator<E>) validators.get(beanClass);
+ if (validator == null) {
+ String prefix = beanClass.getSimpleName().toLowerCase();
+ String contextValueName = prefix + "Validator";
+ validator = context.getContextValue(BeanListValidator.class,
+ contextValueName);
+ Preconditions.checkNotNull(validator,
+ "No validator exists for bean type : "
+ + beanClass.getName()
+ + " (property from context = "
+ + contextValueName + ")"
+ );
+ validator.addBeanListValidatorListener(new BeanListValidatorListener() {
+
+ @Override
+ public void onFieldChanged(BeanListValidatorEvent event) {
+ setEnabled(checkEnabled());
+ }
+ });
+ validators.put(beanClass, validator);
+ }
+ return validator;
+ }
+
+ protected BeanListValidator<Route> getRouteValidator() {
+ return getValidator(Route.class);
+ }
+
+ protected BeanListValidator<Observation> getObservationValidator() {
+ return getValidator(Observation.class);
+ }
+
+ protected <E extends TopiaEntity & Validable> void bindValidableEntity(String propertyName,
+ Class<E> propertyClass) {
+
+ getModel().addPropertyChangeListener(propertyName, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ TopiaEntity oldValue = (TopiaEntity) evt.getOldValue();
+ if (oldValue != null) {
+ oldValue.removePropertyChangeListener(
+ "deleted", enabledListener);
+ }
+ TopiaEntity newValue = (TopiaEntity) evt.getNewValue();
+ if (newValue != null) {
+ newValue.addPropertyChangeListener(
+ "deleted", enabledListener);
+ }
+ enabledListener.propertyChange(evt);
+ }
+ });
+ }
+
+ protected <E extends AbstractBean & Validable> void bindValidableModel(String propertyName,
+ Class<E> propertyClass) {
+
+ getModel().addPropertyChangeListener(propertyName, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ AbstractBean oldValue = (AbstractBean) evt.getOldValue();
+ if (oldValue != null) {
+ oldValue.removePropertyChangeListener(
+ "deleted", enabledListener);
+ }
+ AbstractBean newValue = (AbstractBean) evt.getNewValue();
+ if (newValue != null) {
+ newValue.addPropertyChangeListener(
+ "deleted", enabledListener);
+ }
+ enabledListener.propertyChange(evt);
+ }
+ });
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidObservationAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidObservationAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidObservationAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidObservationAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,84 @@
+package fr.ulr.sammoa.ui.swing.flight.action;
+/*
+ * #%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.ui.swing.flight.FlightUIModel;
+import jaxx.runtime.JAXXContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.Action;
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 23/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public class ValidObservationAction extends ValidAction {
+
+ /** Logger. */
+ private static final Logger logger = LoggerFactory.getLogger(ValidObservationAction.class);
+
+ private static final long serialVersionUID = 1L;
+
+ public ValidObservationAction(JAXXContext context) {
+ super(_("sammoa.action.validObservation"), context);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.validObservation.tip"));
+ bindValidableEntity(FlightUIModel.PROPERTY_OBSERVATION_EDIT_BEAN, Observation.class);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ Observation observation = getModel().getObservationEditBean();
+
+ if (observation != null) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Validation for observation {}", observation.getObservationNumber());
+ }
+
+ Observation observationChanged = getValidationService().validateObservation(observation);
+
+ if (observationChanged.isDeleted()) {
+ getModel().removeObservation(observationChanged);
+ } else {
+ getModel().updateObservation(observationChanged);
+ getModel().setObservationEditBean(observationChanged);
+ }
+ }
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ Observation observation = getModel().getObservationEditBean();
+ return observation != null
+ && Observations.isValid(observation, getObservationValidator());
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidObservationAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidRouteAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidRouteAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidRouteAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidRouteAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,110 @@
+package fr.ulr.sammoa.ui.swing.flight.action;
+/*
+ * #%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.application.FlightService;
+import fr.ulr.sammoa.persistence.Observation;
+import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.Routes;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import jaxx.runtime.JAXXContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.Action;
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 23/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public class ValidRouteAction extends ValidAction {
+
+ /** Logger. */
+ private static final Logger logger = LoggerFactory.getLogger(ValidRouteAction.class);
+
+ private static final long serialVersionUID = 1L;
+
+ protected boolean validatorIsAdjusting;
+
+ public ValidRouteAction(JAXXContext context) {
+ super(_("sammoa.action.validRoute"), context);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.validRoute.tip"));
+ bindValidableEntity(FlightUIModel.PROPERTY_OBSERVATION_EDIT_BEAN, Observation.class);
+ bindValidableEntity(FlightUIModel.PROPERTY_ROUTE_EDIT_BEAN, Route.class);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ Route route = getModel().getRouteEditBean();
+
+ if (route != null) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Validation for route {} : {}",
+ route.getRouteType(),
+ route.getEffortNumber()
+ );
+ }
+
+ Route routeChanged = getValidationService().validateRoute(route);
+
+ if (routeChanged.isDeleted()) {
+ getModel().removeRoute(routeChanged);
+ } else {
+ getModel().updateRoute(routeChanged);
+
+ validatorIsAdjusting = true;
+
+ getModel().setCurrentRoute(routeChanged);
+ getModel().setRouteEditBean(routeChanged);
+
+ getModel().setObservationEditBean(null);
+
+ // Reload all observations
+ FlightService service =
+ getSammoaUIContext().getService(FlightService.class);
+ getModel().clearObservation();
+ getModel().addAllObservation(service.getObservations(getModel().getFlight()));
+
+ validatorIsAdjusting = false;
+ }
+ }
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ boolean result = isEnabled();
+ if (!validatorIsAdjusting) {
+ Route bean = getModel().getRouteEditBean();
+ result = bean != null
+ && Routes.isValid(bean, getRouteValidator(), getObservationValidator());
+ }
+ return result;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidRouteAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidTransectAction.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidTransectAction.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidTransectAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidTransectAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,135 @@
+package fr.ulr.sammoa.ui.swing.flight.action;
+/*
+ * #%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.application.FlightService;
+import fr.ulr.sammoa.persistence.Observation;
+import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.TransectFlight;
+import fr.ulr.sammoa.persistence.TransectFlights;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import fr.ulr.sammoa.ui.swing.flight.TransectFlightModel;
+import jaxx.runtime.JAXXContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.Action;
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 23/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public class ValidTransectAction extends ValidAction {
+
+ /** Logger. */
+ private static final Logger logger = LoggerFactory.getLogger(ValidTransectAction.class);
+
+ private static final long serialVersionUID = 1L;
+
+ protected boolean validatorIsAdjusting;
+
+ public ValidTransectAction(JAXXContext context) {
+ super(_("sammoa.action.validTransect"), context);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.validTransect.tip"));
+ bindValidableEntity(FlightUIModel.PROPERTY_OBSERVATION_EDIT_BEAN, Observation.class);
+ bindValidableEntity(FlightUIModel.PROPERTY_ROUTE_EDIT_BEAN, Route.class);
+ bindValidableModel(FlightUIModel.PROPERTY_TRANSECT_FLIGHT_EDIT_BEAN, TransectFlightModel.class);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ TransectFlightModel bean = getModel().getTransectFlightEditBean();
+
+ if (bean != null) {
+
+ TransectFlight transectFlight = bean.getSource();
+
+ int index = getModel().indexOfTransectFlights(bean);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Validation for transectFlight {} : {}",
+ index,
+ transectFlight.getTransect().getName()
+ );
+ }
+
+ TransectFlight transectFlightChanged =
+ getValidationService().validateTransectFlight(getModel().getFlight(), transectFlight);
+
+ if (transectFlightChanged.isDeleted()) {
+ getModel().removeTransectFlight(index);
+
+ } else {
+ getModel().updateTransectFlight(transectFlightChanged);
+
+ validatorIsAdjusting = true;
+
+ Route routeEditBean = getModel().getRouteEditBean();
+
+ getModel().setRouteEditBean(null);
+
+ // Reload all routes
+ FlightService service =
+ getSammoaUIContext().getService(FlightService.class);
+ getModel().clearRoute();
+ getModel().addAllRoute(service.getRoutes(getModel().getFlight()));
+
+ // Keep the route selected
+ if (routeEditBean != null && !routeEditBean.isDeleted()) {
+ getModel().setCurrentRoute(routeEditBean);
+ getModel().setRouteEditBean(routeEditBean);
+ }
+
+ getModel().setObservationEditBean(null);
+
+ // Reload all observations
+ getModel().clearObservation();
+ getModel().addAllObservation(service.getObservations(getModel().getFlight()));
+
+ validatorIsAdjusting = false;
+ }
+ }
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ boolean result = isEnabled();
+ if (!validatorIsAdjusting) {
+ TransectFlightModel bean = getModel().getTransectFlightEditBean();
+ if (bean != null) {
+ TransectFlight transectflight = bean.getSource();
+ result = transectflight != null
+ && TransectFlights.isValid(transectflight,
+ getRouteValidator(),
+ getObservationValidator());
+ }
+ }
+ return result;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/action/ValidTransectAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/DeviceStateLED.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/DeviceStateLED.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/DeviceStateLED.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/DeviceStateLED.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,102 @@
+/*
+ * #%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.flight.bar;
+
+import fr.ulr.sammoa.application.device.DeviceState;
+import fr.ulr.sammoa.application.device.DeviceStateEvent;
+import fr.ulr.sammoa.application.device.DeviceStateListener;
+import org.nuiton.util.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+
+/**
+ * Panel qui écoute l'état du peripherique pour afficher à l'utilsateur un voyant
+ * lunineux dépendant de l'état du peripherique.
+ * <p/>
+ * Indicateurs pour l'état du peripherique
+ * <ul>
+ * <li>voyant gris : pas de peripherique
+ * <li>voyant bleu : peripherique prêt
+ * <li>voyant vert : enregistrement en cours
+ * <li>voyant rouge clignotant : enregistrement mais pas de données
+ * </ul>
+ *
+ * @author chatellier
+ */
+public class DeviceStateLED extends JLabel implements DeviceStateListener {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger logger = LoggerFactory.getLogger(DeviceStateLED.class);
+
+ protected DeviceState state;
+
+ protected static final ImageIcon NO_DEVICE_ICON = Resource.getIcon("/icons/device/nodevice.png");
+
+ protected static final ImageIcon READY_ICON = Resource.getIcon("/icons/device/ready.png");
+
+ protected static final ImageIcon RECORDING_ICON = Resource.getIcon("/icons/device/recording.png");
+
+ protected static final ImageIcon NO_DATA_ICON = Resource.getIcon("/icons/device/nodata.gif");
+
+ @Override
+ public void stateChanged(DeviceStateEvent event) {
+ setState(event.getNewValue());
+ }
+
+ public void setState(DeviceState state) {
+ DeviceState oldValue = getState();
+ this.state = state;
+
+ if (oldValue != state) {
+
+ logger.debug("[{}] Update LED status: {}",
+ getClass().getSimpleName(), state);
+
+ switch (state) {
+ case UNAVAILABLE:
+ setIcon(NO_DEVICE_ICON);
+ break;
+ case READY:
+ setIcon(READY_ICON);
+ break;
+ case RUNNING:
+ setIcon(RECORDING_ICON);
+ break;
+ case ERROR:
+ setIcon(NO_DATA_ICON);
+ break;
+ }
+ }
+ }
+
+ public DeviceState getState() {
+ return state;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/DeviceStateLED.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBar.css (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.css)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBar.css (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBar.css 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,101 @@
+/*
+ * #%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%
+ */
+
+#stateBar {
+ background: {model.getEffortPanelColor()};
+}
+
+#clockTime {
+ delay: 1000;
+ pattern: "dd/MM/yyyy HH:mm:ss";
+ visible: {!flightUIModel.isValidationMode()};
+}
+#audioTime {
+ visible: {flightUIModel.isValidationMode()};
+ text: {dateFormat.format(flightUIModel.getCurrentRoute().getBeginTime())};
+}
+
+#beginButton {
+ _actionName: {"begin"};
+}
+
+#endButton {
+ _actionName: {"end"};
+}
+
+#nextButton {
+ _actionName: {"next"};
+}
+
+#effortButtonPanel {
+ background: {model.getEffortPanelColor()};
+}
+
+#statusPanel {
+ background: {model.getEffortPanelColor()};
+}
+
+#lblEffort {
+ text: {flightUIModel.getFlightState().name()};
+}
+
+#lblTransect {
+ text: {flightUIModel.getCurrentRoute().getTransectFlight().getTransect().getName()};
+}
+
+#lblStatus {
+ text: {flightUIModel.getCurrentRoute().getRouteType().name()
+ + (flightUIModel.getCurrentRoute().getEffortNumber() != null
+ ? " " + flightUIModel.getCurrentRoute().getEffortNumber()
+ : "")};
+}
+
+#lblObservation {
+ text: {flightUIModel.getCurrentRoute().getTransectFlight().getTransect().getName()};
+}
+
+#cbPanel {
+ background: {model.getEffortPanelColor()};
+}
+
+#gpsLED {
+ text: "sammoa.statusBar.gps";
+}
+
+#audioLED {
+ text: "sammoa.statusBar.audio";
+}
+
+#indicatorPanel {
+ background: {model.getEffortPanelColor()};
+}
+
+#lblAlt {
+ text: {model.getAlt()};
+}
+
+#lblSpeed {
+ text: {model.getSpeed()};
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBar.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBar.jaxx (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.jaxx)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBar.jaxx (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBar.jaxx 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,132 @@
+<!--
+ #%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%
+ -->
+<JPanel id='statusBar' layout='{new GridLayout(0,1,0,0)}'>
+
+ <import>
+ java.text.SimpleDateFormat
+ javax.swing.BoxLayout
+ javax.swing.SwingConstants
+ jaxx.runtime.swing.ClockWidget
+
+ fr.ulr.sammoa.ui.swing.flight.FlightUIModel
+ </import>
+
+ <script><![CDATA[
+
+ protected void $afterCompleteSetup() {
+ getHandler().init();
+ }
+
+ ]]></script>
+
+ <FlightBarHandler id='handler' constructorParams='this'/>
+
+ <FlightUIModel id='flightUIModel' initializer='getHandler().getParentUI().getModel()'/>
+
+ <FlightBarModel id='model'/>
+
+ <SimpleDateFormat id='dateFormat' constructorParams='"dd/MM/yyyy HH:mm:ss"'/>
+
+ <Table id='validationBar'>
+ <row>
+ <cell fill='horizontal' weightx='0.2'>
+ <JPanel id='audioButtonPanel'
+ layout='{new BoxLayout(audioButtonPanel, BoxLayout.X_AXIS)}'>
+ <JButton id='startAudioButton'/>
+ <JButton id='stopAudioButton'/>
+ </JPanel>
+ </cell>
+ <cell fill='horizontal'>
+ <JSlider id='audioSlider' enabled='false'/>
+ </cell>
+ <cell fill='horizontal' weightx='0.2'>
+ <JPanel id='validButtonPanel'
+ layout='{new BoxLayout(validButtonPanel, BoxLayout.X_AXIS)}'>
+ <JButton id='validRouteButton'/>
+ <JButton id='validObservationButton'/>
+ <JButton id='validTransectButton'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+ <Table id='stateBar'>
+ <row>
+ <cell fill='horizontal' weightx='0.2'>
+ <ClockWidget id='clockTime'/>
+ </cell>
+ <cell fill='horizontal' weightx='0.2'>
+ <JLabel id='audioTime'/>
+ </cell>
+ <cell fill='vertical'>
+ <JSeparator constructorParams='SwingConstants.VERTICAL'/>
+ </cell>
+ <cell fill='horizontal'>
+ <JPanel id='effortButtonPanel'
+ layout='{new BoxLayout(effortButtonPanel, BoxLayout.X_AXIS)}'>
+ <JButton id='beginButton'/>
+ <JButton id='endButton'/>
+ <JButton id='nextButton'/>
+ </JPanel>
+ </cell>
+ <cell fill='vertical'>
+ <JSeparator constructorParams='SwingConstants.VERTICAL'/>
+ </cell>
+ <cell fill='horizontal' weightx='0.2' anchor='center'>
+ <JLabel id='lblEffort'/>
+ </cell>
+ <cell fill='vertical'>
+ <JSeparator constructorParams='SwingConstants.VERTICAL'/>
+ </cell>
+ <cell fill='horizontal' weightx='0.2' anchor='center'>
+ <JLabel id='lblTransect'/>
+ </cell>
+ <cell fill='vertical'>
+ <JSeparator constructorParams='SwingConstants.VERTICAL'/>
+ </cell>
+ <cell fill='horizontal' weightx='0.2' anchor='center'>
+ <JLabel id='lblStatus'/>
+ </cell>
+ <cell fill='vertical'>
+ <JSeparator constructorParams='SwingConstants.VERTICAL'/>
+ </cell>
+ <cell fill='horizontal' weightx='0.2' anchor='center'>
+ <JPanel id='cbPanel' layout='{new BoxLayout(cbPanel, BoxLayout.Y_AXIS)}'>
+ <DeviceStateLED id='gpsLED' />
+ <DeviceStateLED id='audioLED' />
+ </JPanel>
+ </cell>
+ <cell fill='vertical'>
+ <JSeparator constructorParams='SwingConstants.VERTICAL'/>
+ </cell>
+ <cell fill='horizontal' weightx='0.2' anchor='center'>
+ <JPanel id='indicatorPanel'
+ layout='{new BoxLayout(indicatorPanel, BoxLayout.Y_AXIS)}'>
+ <JLabel id='lblAlt'/>
+ <JLabel id='lblSpeed'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+</JPanel>
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBar.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBarHandler.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarHandler.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBarHandler.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBarHandler.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,132 @@
+/*
+ * #%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.flight.bar;
+
+import fr.ulr.sammoa.application.device.audio.AudioRecorder;
+import fr.ulr.sammoa.application.device.gps.GpsHandler;
+import fr.ulr.sammoa.application.flightController.FlightController;
+import fr.ulr.sammoa.application.flightController.FlightState;
+import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.ui.swing.SammoaColors;
+import fr.ulr.sammoa.ui.swing.flight.FlightUI;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIHandler;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import jaxx.runtime.JAXXUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+/** @author sletellier <letellier(a)codelutin.com> */
+public class FlightBarHandler implements PropertyChangeListener {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(FlightBarHandler.class);
+
+ protected final FlightBar ui;
+
+ public FlightBarHandler(FlightBar ui) {
+ this.ui = ui;
+ }
+
+ public FlightUI getParentUI() {
+ return ui.getContextValue(FlightUI.class, JAXXUtil.PARENT);
+ }
+
+ protected FlightBarModel getModel() {
+ return ui.getModel();
+ }
+
+ public void init() {
+
+ FlightUIModel flightUIModel = ui.getFlightUIModel();
+ flightUIModel.addPropertyChangeListener(this);
+
+
+ FlightController flightController =
+ ui.getContextValue(FlightUIHandler.class).getFlightController();
+
+ if (flightUIModel.isValidationMode()) {
+
+ // Put actionName for validation buttons
+ ui.getStartAudioButton().putClientProperty("actionName", "startAudio");
+ ui.getStopAudioButton().putClientProperty("actionName", "stopAudio");
+ ui.getValidObservationButton().putClientProperty("actionName", "validObservation");
+ ui.getValidRouteButton().putClientProperty("actionName", "validRoute");
+ ui.getValidTransectButton().putClientProperty("actionName", "validTransect");
+
+ } else {
+
+ // Remove the bar used only for validation
+ ui.remove(ui.getValidationBar());
+
+ AudioRecorder audioRecorder = flightController.getDeviceManager(AudioRecorder.class);
+ ui.getAudioLED().setState(audioRecorder.getState());
+ audioRecorder.addDeviceStateListener(ui.getAudioLED());
+
+ GpsHandler gpsHandler = flightController.getDeviceManager(GpsHandler.class);
+ ui.getGpsLED().setState(gpsHandler.getState());
+ gpsHandler.addDeviceStateListener(ui.getGpsLED());
+ gpsHandler.addGpsLocationListener(getModel());
+ }
+
+ if (FlightState.OFF_EFFORT.equals(ui.getFlightUIModel().getFlightState())) {
+ getModel().setEffortPanelColor(SammoaColors.ON_EFFORT_BACKGROUND_COLOR);
+ }
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ String propertyName = evt.getPropertyName();
+
+ if (FlightUIModel.PROPERTY_FLIGHT_STATE.equals(propertyName)) {
+
+ logger.debug("Modify flight bar background color");
+
+ // si l'etat du vol passe en off effort
+ // affiche à l'utilisateur
+ FlightState newState = (FlightState) evt.getNewValue();
+ if (FlightState.OFF_EFFORT.equals(newState)) {
+ getModel().setEffortPanelColor(SammoaColors.ON_EFFORT_BACKGROUND_COLOR);
+
+ } else {
+ getModel().setEffortPanelColor(null);
+ }
+
+ } else if (FlightUIModel.PROPERTY_CURRENT_ROUTE.equals(propertyName)) {
+
+ Route route = (Route) evt.getNewValue();
+
+ logger.debug("New value received for current route {}", route);
+
+ if (route == null || route.getTransectFlight() == null) {
+ // set null will hide label
+ ui.getLblTransect().setText(null);
+ }
+
+ }
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBarHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBarModel.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarModel.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBarModel.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBarModel.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,91 @@
+/*
+ * #%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.flight.bar;
+
+import fr.ulr.sammoa.application.device.gps.GpsLocationEvent;
+import fr.ulr.sammoa.application.device.gps.GpsLocationListener;
+import fr.ulr.sammoa.persistence.GeoPoint;
+import org.jdesktop.beans.AbstractSerializableBean;
+
+import java.awt.Color;
+
+import static org.nuiton.i18n.I18n._;
+
+/** @author sletellier <letellier(a)codelutin.com> */
+public class FlightBarModel extends AbstractSerializableBean implements GpsLocationListener {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_ALT = "alt";
+
+ public static final String PROPERTY_SPEED = "speed";
+
+ public static final String PROPERTY_EFFORT_PANEL_COLOR = "effortPanelColor";
+
+ protected float alt;
+
+ protected float speed;
+
+ protected Color effortPanelColor;
+
+ public String getAlt() {
+ return _("sammoa.statusbar.alt", alt);
+ }
+
+ public void setAlt(float alt) {
+ float oldValue = this.alt;
+ this.alt = alt;
+ firePropertyChange(PROPERTY_ALT, oldValue, alt);
+ }
+
+ public String getSpeed() {
+ return _("sammoa.statusbar.speed", speed);
+ }
+
+ public void setSpeed(float speed) {
+ float oldValue = this.speed;
+ this.speed = speed;
+ firePropertyChange(PROPERTY_SPEED, oldValue, speed);
+ }
+
+ public Color getEffortPanelColor() {
+ return effortPanelColor;
+ }
+
+ public void setEffortPanelColor(Color effortPanelColor) {
+ Color oldColor = this.effortPanelColor;
+ this.effortPanelColor = effortPanelColor;
+ firePropertyChange(PROPERTY_EFFORT_PANEL_COLOR, oldColor, this.effortPanelColor);
+ }
+
+ @Override
+ public void locationChanged(GpsLocationEvent event) {
+ GeoPoint newLocation = event.getNewValue();
+ if (newLocation != null) {
+ setSpeed((float) newLocation.getSpeed());
+ setAlt((float) newLocation.getAltitude());
+ }
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/bar/FlightBarModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanel.css (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/EffortPanel.css)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanel.css (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanel.css 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,164 @@
+/*
+ * #%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%
+ */
+
+#effortPanel {
+ minimumSize:{new Dimension(0,0)};
+ preferredSize:{new Dimension(0,0)};
+}
+
+#scrollPanel {
+ columnHeaderView:{errorTable.getTableHeader()};
+}
+
+#errorTable {
+ rowSelectionAllowed:true;
+ autoCreateRowSorter:true;
+ autoResizeMode:2;
+ cellSelectionEnabled:false;
+ selectionMode:0;
+ model:{errorTableModel};
+ sortable:false;
+}
+
+#transecLbl {
+ text: "sammoa.observation.observationCondition.transec";
+}
+
+#observersLbl {
+ text: "sammoa.observation.observationCondition.observers";
+}
+
+#lblObservation {
+ text: "sammoa.observationCondition.title";
+ horizontalTextPosition: {JLabel.CENTER};
+ horizontalAlignment: {JLabel.CENTER};
+}
+
+#navLabel {
+ text: "sammoa.flightPanel.table.column.position.navigator";
+ enabled: {model.getRouteEditBean() != null};
+}
+
+#navObserversModel {
+ elements:{model.getFlightObserverForPositions()};
+}
+
+#navComboBox {
+ enabled: {model.getRouteEditBean() != null};
+ model: {navObserversModel};
+ /*renderer: {new DecoratorProviderListCellRenderer(handler.getDecoratorProvider())};*/
+ selectedItem: {getHandler().getObserverByPosition(model.getRouteEditBean(), Position.NAVIGATOR)};
+}
+
+#leftLabel {
+ text: "sammoa.flightPanel.table.column.position.left";
+ enabled: {model.getRouteEditBean() != null};
+}
+
+#leftObserversModel {
+ elements:{model.getFlightObserverForPositions()};
+}
+
+#leftComboBox {
+ enabled: {model.getRouteEditBean() != null};
+ model: {leftObserversModel};
+ /*renderer: {new DecoratorProviderListCellRenderer(handler.getDecoratorProvider())};*/
+ selectedItem: {getHandler().getObserverByPosition(model.getRouteEditBean(), Position.FRONT_LEFT)};
+ background: {SammoaColors.POSITION_LEFT_COLOR};
+}
+
+#rightLabel {
+ text: "sammoa.flightPanel.table.column.position.right";
+ enabled: {model.getRouteEditBean() != null};
+}
+
+#rightObserversModel {
+ elements:{model.getFlightObserverForPositions()};
+}
+
+#rightComboBox {
+ enabled: {model.getRouteEditBean() != null};
+ model: {rightObserversModel};
+ /*renderer: {new DecoratorProviderListCellRenderer(handler.getDecoratorProvider())};*/
+ selectedItem: {getHandler().getObserverByPosition(model.getRouteEditBean(), Position.FRONT_RIGHT)};
+ background: {SammoaColors.POSITION_RIGHT_COLOR};
+}
+
+#conavLabel {
+ text: "sammoa.flightPanel.table.column.position.co-navigator";
+ enabled: {model.getRouteEditBean() != null};
+}
+
+#coNavObserversModel {
+ elements:{model.getFlightObserverForPositions()};
+}
+
+#conavComboBox {
+ enabled: {model.getRouteEditBean() != null};
+ model: {coNavObserversModel};
+ /*renderer: {new DecoratorProviderListCellRenderer(handler.getDecoratorProvider())};*/
+ selectedItem: {getHandler().getObserverByPosition(model.getRouteEditBean(), Position.CO_NAVIGATOR)};
+}
+
+#routeTable {
+ model: {routeTableModel};
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+ _terminateEditOnFocusLost: {true};
+}
+
+#addButton {
+ _actionName: {"add"};
+}
+
+#lblObservation2 {
+ text: "sammoa.observation.title";
+ horizontalTextPosition: {JLabel.CENTER};
+ horizontalAlignment: {JLabel.CENTER};
+}
+
+#observationTable {
+ model:{observationTableModel};
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+ _terminateEditOnFocusLost: {true};
+}
+
+#leftButton {
+ _actionName: {"leftObservation"};
+ background: {SammoaColors.POSITION_LEFT_COLOR};
+}
+
+#centerButton {
+ _actionName: {"centerObservation"};
+}
+
+#rightButton {
+ _actionName: {"rightObservation"};
+ background: {SammoaColors.POSITION_RIGHT_COLOR};
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanel.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanel.jaxx (from rev 510, 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/flight/effort/EffortPanel.jaxx (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanel.jaxx 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,184 @@
+<!--
+ #%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%
+ -->
+<JSplitPane id='effortSplitPane' resizeWeight='0.9'>
+
+ <import>
+ java.awt.Dimension
+ java.awt.Color
+ javax.swing.ListSelectionModel
+
+ fr.ulr.sammoa.persistence.Position
+ fr.ulr.sammoa.persistence.Route
+ fr.ulr.sammoa.persistence.Observer
+ fr.ulr.sammoa.persistence.Observation
+
+ fr.ulr.sammoa.ui.swing.SammoaColors
+ fr.ulr.sammoa.ui.swing.flight.FlightUIModel
+
+ org.nuiton.validator.bean.list.BeanListValidator
+ org.jdesktop.swingx.JXTable
+
+ jaxx.runtime.swing.model.GenericListModel
+ jaxx.runtime.validator.swing.SwingListValidatorMessageTableModel
+
+ static org.nuiton.i18n.I18n._
+
+ </import>
+
+ <EffortPanelHandler id='handler' constructorParams='this'/>
+
+ <SwingListValidatorMessageTableModel id='errorTableModel'/>
+
+ <FlightUIModel id='model'
+ initializer='handler.getParentUI().getModel()'/>
+
+ <GenericListModel id='navObserversModel' genericType='Observer'/>
+
+ <GenericListModel id='leftObserversModel' genericType='Observer'/>
+
+ <GenericListModel id='rightObserversModel' genericType='Observer'/>
+
+ <GenericListModel id='coNavObserversModel' genericType='Observer'/>
+
+ <RouteTableModel id='routeTableModel'
+ initializer='new RouteTableModel(model)'/>
+
+ <!--RouteTableListSelectionListener id='routeSelectionModel'
+ constructorParams='flightUIModel'/-->
+
+ <ObservationTableModel id='observationTableModel'
+ constructorParams='model'/>
+
+ <!--ObservationTableListSelectionListener id='observationSelectionModel'
+ constructorParams='flightUIModel'/-->
+
+ <!-- validator -->
+ <BeanListValidator id='routeValidator' genericType='Route'
+ initializer='BeanListValidator.newValidator(Route.class, null)'/>
+
+ <BeanListValidator id='observationValidator' genericType='Observation'
+ initializer='BeanListValidator.newValidator(Observation.class, null)'/>
+
+ <script><![CDATA[
+
+ protected void $afterCompleteSetup() {
+ getHandler().init();
+ }
+
+ ]]></script>
+
+ <Table id='effortPanel'>
+
+ <row>
+ <cell fill='both' weightx='1.0' weighty='1'>
+ <Table id='routePanel'>
+ <row>
+ <cell>
+ <JButton id='addButton'/>
+ </cell>
+ <cell>
+ <JLabel id='navLabel'/>
+ </cell>
+ <cell>
+ <JComboBox id='navComboBox'
+ onActionPerformed='handler.setObserverByPosition(navObserversModel.getSelectedItem(), Position.NAVIGATOR)'/>
+ </cell>
+ <cell>
+ <JLabel id='leftLabel'/>
+ </cell>
+ <cell>
+ <JComboBox id='leftComboBox'
+ onActionPerformed='handler.setObserverByPosition(leftObserversModel.getSelectedItem(), Position.FRONT_LEFT)'/>
+ </cell>
+ <cell>
+ <JLabel id='rightLabel'/>
+ </cell>
+ <cell>
+ <JComboBox id='rightComboBox'
+ onActionPerformed='handler.setObserverByPosition(rightObserversModel.getSelectedItem(), Position.FRONT_RIGHT)'/>
+ </cell>
+ <cell>
+ <JLabel id='conavLabel'/>
+ </cell>
+ <cell>
+ <JComboBox id='conavComboBox'
+ onActionPerformed='handler.setObserverByPosition(coNavObserversModel.getSelectedItem(), Position.CO_NAVIGATOR)'/>
+ </cell>
+ <cell weightx='1' anchor='east'>
+ <JLabel id='lblObservation'/>
+ </cell>
+ </row>
+ <row>
+ <cell fill='both' weightx='1.0' weighty='1.0' columns='10'>
+ <JScrollPane id='routeTableScroll'>
+ <JXTable id='routeTable'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ </Table>
+
+ </cell>
+ </row>
+ <row>
+ <cell fill='both' weightx='1.0' weighty='1.6'>
+ <Table id='observations'>
+
+ <row>
+ <cell>
+ <JButton id='leftButton'/>
+ </cell>
+ <cell>
+ <JButton id='centerButton'/>
+ </cell>
+ <cell>
+ <JButton id='rightButton'/>
+ </cell>
+ <cell weightx='1' anchor='east'>
+ <JLabel id='lblObservation2'/>
+ </cell>
+ </row>
+ <row>
+ <cell fill='both' weightx='1.0' weighty='1.0' columns='4'>
+ <JScrollPane id='observationTableScroll'>
+ <JXTable id='observationTable' />
+ </JScrollPane>
+ </cell>
+ </row>
+
+ </Table>
+ </cell>
+ </row>
+ </Table>
+
+ <JPanel id='validationTable' layout='{new BorderLayout()}'>
+
+ <JScrollPane id='scrollPanel' constraints='BorderLayout.CENTER'>
+
+ <JXTable id='errorTable'/>
+ </JScrollPane>
+
+ </JPanel>
+
+</JSplitPane>
\ No newline at end of file
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanel.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanelHandler.java (from rev 510, 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/flight/effort/EffortPanelHandler.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanelHandler.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,1063 @@
+package fr.ulr.sammoa.ui.swing.flight.effort;
+/*
+ * #%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 com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import fr.ulr.sammoa.application.FlightService;
+import fr.ulr.sammoa.application.device.DeviceState;
+import fr.ulr.sammoa.application.device.DeviceStateEvent;
+import fr.ulr.sammoa.application.device.DeviceStateListener;
+import fr.ulr.sammoa.application.device.audio.AudioRecorder;
+import fr.ulr.sammoa.application.device.gps.GpsHandler;
+import fr.ulr.sammoa.application.flightController.FlightController;
+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.SammoaUIContext;
+import fr.ulr.sammoa.ui.swing.UIDecoratorService;
+import fr.ulr.sammoa.ui.swing.flight.FlightUI;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIHandler;
+import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import fr.ulr.sammoa.ui.swing.flight.TransectFlightModel;
+import fr.ulr.sammoa.ui.swing.flight.action.CircleBackAction;
+import fr.ulr.sammoa.ui.swing.flight.effort.action.MoveToNextEditableCellAction;
+import fr.ulr.sammoa.ui.swing.flight.effort.action.MoveToNextRowEditableAction;
+import fr.ulr.sammoa.ui.swing.flight.effort.action.MoveToPreviousEditableCellAction;
+import fr.ulr.sammoa.ui.swing.flight.effort.action.MoveToPreviousRowEditableAction;
+import fr.ulr.sammoa.ui.swing.util.AbstractRowHighlightPredicate;
+import fr.ulr.sammoa.ui.swing.util.ButtonActionTableCellEditorRenderer;
+import fr.ulr.sammoa.ui.swing.util.DeletedRowHighlightPredicate;
+import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
+import fr.ulr.sammoa.ui.swing.util.SelectionModelAdapter;
+import fr.ulr.sammoa.ui.swing.util.TableDataChangeListener;
+import fr.ulr.sammoa.ui.swing.util.TextCellEditor;
+import fr.ulr.sammoa.ui.swing.util.TimeCellEditor;
+import fr.ulr.sammoa.ui.swing.util.ValidRowHighlightPredicate;
+import jaxx.runtime.JAXXUtil;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.JAXXDatePicker;
+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;
+import jaxx.runtime.validator.swing.SwingListValidatorMessageTableRenderer;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import org.apache.commons.lang3.tuple.Pair;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.Highlighter;
+import org.jdesktop.swingx.table.TableColumnExt;
+import org.nuiton.util.decorator.Decorator;
+import org.nuiton.validator.NuitonValidatorScope;
+import org.nuiton.validator.bean.list.BeanListValidator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.Action;
+import javax.swing.DefaultCellEditor;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.ListCellRenderer;
+import javax.swing.border.LineBorder;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableModel;
+import java.awt.Color;
+import java.awt.Component;
+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_;
+
+/**
+ * Handler of {@link EffortPanel} ui.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.4
+ */
+public class EffortPanelHandler implements DeviceStateListener {
+
+ private static final Logger logger =
+ LoggerFactory.getLogger(EffortPanelHandler.class);
+
+ protected static final Color DEVICE_ERROR_BACKGROUND_COLOR = Color.RED;
+
+ public static final String ROUTE_VALIDATOR_CONTEXT_VALUE =
+ "routeValidator";
+
+ public static final String OBSERVATION_VALIDATOR_CONTEXT_VALUE =
+ "observationValidator";
+
+ protected boolean comboIsAdjusting;
+
+ private final SammoaUIContext context;
+
+ private final EffortPanel ui;
+
+ public EffortPanelHandler(EffortPanel ui) {
+ this.ui = ui;
+ context = ui.getContextValue(SammoaUIContext.class);
+ }
+
+ public FlightUI getParentUI() {
+ return ui.getContextValue(FlightUI.class, JAXXUtil.PARENT);
+ }
+
+ public FlightUIModel getModel() {
+ return ui.getModel();
+ }
+
+ public void init() {
+
+ final UIDecoratorService decoratorService =
+ context.getService(UIDecoratorService.class);
+
+ ListCellRenderer observeCellRenderer =
+ decoratorService.newListCellRender(Observer.class);
+
+ ui.getNavComboBox().setRenderer(observeCellRenderer);
+ ui.getLeftComboBox().setRenderer(observeCellRenderer);
+ ui.getRightComboBox().setRenderer(observeCellRenderer);
+ ui.getConavComboBox().setRenderer(observeCellRenderer);
+
+ JTable errorTable = ui.getErrorTable();
+
+ // prepare error table ui
+ SwingValidatorUtil.installUI(
+ errorTable,
+ new SwingListValidatorMessageTableRenderer() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected String decorateBean(Object bean) {
+ return decoratorService.getDecorator(bean).toString(bean);
+ }
+
+ }
+ );
+
+ initRouteTable();
+
+ initObservationTable();
+ }
+
+
+ /**
+ * Add hightlighters on the editor of beans.
+ *
+ * @param validator the validator where to find bean states
+ * @param editor the editor of beans
+ * @param dataLocator the data locator
+ * @param scopes scopes to hightlight
+ * @param <O> type of bean to validate
+ * @since 2.5.3
+ */
+ public static <O> void addHightLighterOnEditor(BeanListValidator<O> validator,
+ JXTable editor,
+ SwingListValidatorDataLocator<O> dataLocator,
+ NuitonValidatorScope... scopes) {
+
+ for (NuitonValidatorScope scope : scopes) {
+
+ SwingListValidatorHighlightPredicate<O> predicate = SwingListValidatorHighlightPredicate.newPredicate(
+ scope,
+ validator, dataLocator
+ );
+
+ Highlighter highlighter = SammoaUtil.newBackgroundColorHighlighter(
+ predicate, SwingValidatorUtil.getColor(scope));
+ editor.addHighlighter(highlighter);
+ }
+ }
+
+ public Observer getObserverByPosition(Route route, Position position) {
+ Observer result;
+ if (route != null) {
+ ObserverPosition observerPosition =
+ route.getObserverPositionByPosition(position);
+ result = observerPosition.getObserver();
+
+ } else {
+ result = null;
+ }
+ return result;
+ }
+
+ public void setObserverByPosition(Observer newValue, Position position) {
+ if (!comboIsAdjusting) {
+
+ Route route = getModel().getRouteEditBean();
+ if (route != null) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Set observer %s for position %s", newValue, position));
+ }
+
+ FlightService flightService = context.getService(FlightService.class);
+ flightService.setRouteObserverByPosition(route, newValue, position);
+
+ // the method setObserverByPosition could update other positions
+ // so we need to refresh all comboboxes
+ comboIsAdjusting = true;
+
+ try {
+ if (Position.NAVIGATOR != position) {
+ ObserverPosition navPosition = route.getObserverPositionByPosition(Position.NAVIGATOR);
+ ui.getNavComboBox().setSelectedItem(navPosition.getObserver());
+ }
+
+ if (Position.FRONT_LEFT != position) {
+ ObserverPosition leftPosition = route.getObserverPositionByPosition(Position.FRONT_LEFT);
+ ui.getLeftComboBox().setSelectedItem(leftPosition.getObserver());
+ }
+
+ if (Position.FRONT_RIGHT != position) {
+ ObserverPosition rightPosition = route.getObserverPositionByPosition(Position.FRONT_RIGHT);
+ ui.getRightComboBox().setSelectedItem(rightPosition.getObserver());
+ }
+
+ if (Position.CO_NAVIGATOR != position) {
+ ObserverPosition conavPosition = route.getObserverPositionByPosition(Position.CO_NAVIGATOR);
+ ui.getConavComboBox().setSelectedItem(conavPosition.getObserver());
+ }
+ } finally {
+
+ comboIsAdjusting = false;
+ }
+
+ // Fire on TableModel to update the row (highlighting)
+ // ensureRowIndex in case of new route, otherwise the size is
+ // not updated yet in tableModel and an IndexOutOfBounds appears
+ int index = getModel().indexOfRoutes(route);
+ SwingUtil.ensureRowIndex(ui.getRouteTableModel(), index);
+ ui.getRouteTableModel().fireTableRowsUpdated(index, index);
+
+ // Update observation table to ensure observer's name during validation
+ if (getModel().isValidationMode()) {
+ fireObservationsUpdated(route, false);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void stateChanged(DeviceStateEvent event) {
+ DeviceState state = event.getNewValue();
+ if (DeviceState.ERROR == state) {
+ ui.getObservationTable().setBackground(DEVICE_ERROR_BACKGROUND_COLOR);
+
+ } else {
+ ui.getObservationTable().setBackground(Color.WHITE);
+ }
+ }
+
+ public void initRouteTable() {
+
+ JXTable table = ui.getRouteTable();
+ RouteTableModel tableModel = ui.getRouteTableModel();
+
+ SwingUtil.setI18nTableHeaderRenderer(
+ table,
+ n_("sammoa.observations.routeTable.column.effortNumber"),
+ n_("sammoa.observations.routeTable.column.effortNumber.tip"),
+ n_("sammoa.observations.routeTable.column.beginTime"),
+ n_("sammoa.observations.routeTable.column.beginTime.tip"),
+ n_("sammoa.observations.routeTable.column.routeType"),
+ n_("sammoa.observations.routeTable.column.routeType.tip"),
+ n_("sammoa.observations.routeTable.column.transect"),
+ n_("sammoa.observations.routeTable.column.transect.tip"),
+ n_("sammoa.observations.routeTable.column.seaState"),
+ n_("sammoa.observations.routeTable.column.seaState.tip"),
+ n_("sammoa.observations.routeTable.column.swell"),
+ n_("sammoa.observations.routeTable.column.swell.tip"),
+ n_("sammoa.observations.routeTable.column.turbidity"),
+ n_("sammoa.observations.routeTable.column.turbidity.tip"),
+ n_("sammoa.observations.routeTable.column.skyGlint"),
+ n_("sammoa.observations.routeTable.column.skyGlint.tip"),
+ n_("sammoa.observations.routeTable.column.glareFrom"),
+ n_("sammoa.observations.routeTable.column.glareFrom.tip"),
+ n_("sammoa.observations.routeTable.column.glareTo"),
+ n_("sammoa.observations.routeTable.column.glareTo.tip"),
+ n_("sammoa.observations.routeTable.column.glareSeverity"),
+ n_("sammoa.observations.routeTable.column.glareSeverity.tip"),
+ n_("sammoa.observations.routeTable.column.glareUnder"),
+ n_("sammoa.observations.routeTable.column.glareUnder.tip"),
+ n_("sammoa.observations.routeTable.column.cloudCover"),
+ n_("sammoa.observations.routeTable.column.cloudCover.tip"),
+ n_("sammoa.observations.routeTable.column.subjectiveConditions"),
+ n_("sammoa.observations.routeTable.column.subjectiveConditions.tip"),
+ n_("sammoa.observations.routeTable.column.unexpectedLeft"),
+ n_("sammoa.observations.routeTable.column.unexpectedLeft.tip"),
+ n_("sammoa.observations.routeTable.column.unexpectedRight"),
+ n_("sammoa.observations.routeTable.column.unexpectedRight.tip"),
+ n_("sammoa.observations.routeTable.column.comment"),
+ n_("sammoa.observations.routeTable.column.comment.tip"),
+ n_("sammoa.observations.routeTable.column.deleted"),
+ n_("sammoa.observations.routeTable.column.deleted.tip")
+ );
+
+ init(table, new SelectionModelAdapter<Route>() {
+
+ @Override
+ public List<Route> getElements() {
+ return getModel().getRoutes();
+ }
+
+ @Override
+ public void setSelectedElement(Route element) {
+ getModel().setRouteEditBean(element);
+ }
+ });
+
+ // Listeners
+ {
+ int columnToEditOnInsert = RouteTableModel.RouteColumn.SEA_STATE.ordinal();
+ getModel().addPropertyChangeListener(
+ FlightUIModel.PROPERTY_ROUTES,
+ new TableDataChangeListener(table, columnToEditOnInsert)
+ );
+
+ if (getModel().isValidationMode()) {
+
+ // FlightController # change current route
+ getModel().addPropertyChangeListener(
+ FlightUIModel.PROPERTY_ROUTE_EDIT_BEAN,
+ new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ Route route = (Route) evt.getNewValue();
+ getParentUI().getHandler().getFlightController().setCurrentRoute(route);
+
+ // no unselect but ensure valid button (a select will cause a loop)
+ getModel().setObservationEditBean(null);
+ }
+ }
+ );
+
+ // Refresh matching routes from selected transectFlight
+ getModel().addPropertyChangeListener(
+ FlightUIModel.PROPERTY_TRANSECT_FLIGHT_EDIT_BEAN, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ TransectFlightModel oldValue = (TransectFlightModel) evt.getOldValue();
+ if (oldValue != null) {
+ fireRoutesUpdated(oldValue, false);
+ }
+ TransectFlightModel newValue = (TransectFlightModel) evt.getNewValue();
+ if (newValue != null) {
+ fireRoutesUpdated(newValue, true);
+ }
+ }
+ });
+ }
+ }
+
+ // Validation
+ {
+ JTable errorTable = ui.getErrorTable();
+ SwingListValidatorMessageTableModel errorTableModel = ui.getErrorTableModel();
+
+ BeanListValidator<Route> validator = ui.getRouteValidator();
+ validator.setContext(getValidatorContext());
+ getParentUI().setContextValue(validator, ROUTE_VALIDATOR_CONTEXT_VALUE);
+
+ RouteValidatorDataLocator dataLocator = new RouteValidatorDataLocator();
+
+ SwingValidatorUtil.registerListValidator(
+ validator,
+ errorTableModel,
+ table,
+ errorTable,
+ dataLocator
+ );
+
+ addHightLighterOnEditor(
+ validator,
+ table,
+ dataLocator,
+ NuitonValidatorScope.ERROR,
+ NuitonValidatorScope.WARNING
+ );
+
+ for (Route route : tableModel.getBean()) {
+ validator.addBean(route);
+ }
+ }
+
+ // Highlighters
+ {
+ table.addHighlighter(SammoaUtil.newBackgroundColorHighlighter(
+ new RouteForSelectedTransectFlightHighlightPredicate(getModel()),
+ SammoaColors.OBSERVATION_FOR_ROUTE_ROW_COLOR)
+ );
+ table.addHighlighter(SammoaUtil.newForegroundColorHighlighter(
+ new RouteNoModificationHighlightPredicate(tableModel),
+ SammoaColors.ROUTE_NO_MODIFICATION_ROW_COLOR)
+ );
+ table.addHighlighter(SammoaUtil.newForegroundColorHighlighter(
+ new DeletedRowHighlightPredicate(getModel().getRoutes()),
+ SammoaColors.DELETED_ROW_COLOR)
+ );
+ table.addHighlighter(SammoaUtil.newForegroundColorHighlighter(
+ new ValidRowHighlightPredicate(getModel().getRoutes()),
+ SammoaColors.VALID_ROW_COLOR)
+ );
+ }
+ }
+
+ public void initObservationTable() {
+
+ JXTable table = ui.getObservationTable();
+ ObservationTableModel tableModel = ui.getObservationTableModel();
+
+ SwingUtil.setI18nTableHeaderRenderer(
+ table,
+ n_("sammoa.observations.observationTable.column.observationNumber"),
+ n_("sammoa.observations.observationTable.column.observationNumber.tip"),
+ n_("sammoa.observations.observationTable.column.observationTime"),
+ n_("sammoa.observations.observationTable.column.observationTime.tip"),
+ n_("sammoa.observations.observationTable.column.position"),
+ n_("sammoa.observations.observationTable.column.position.tip"),
+ n_("sammoa.observations.observationTable.column.podSize"),
+ n_("sammoa.observations.observationTable.column.podSize.tip"),
+ n_("sammoa.observations.observationTable.column.species"),
+ n_("sammoa.observations.observationTable.column.species.tip"),
+ n_("sammoa.observations.observationTable.column.age"),
+ n_("sammoa.observations.observationTable.column.age.tip"),
+ n_("sammoa.observations.observationTable.column.decAngle"),
+ n_("sammoa.observations.observationTable.column.decAngle.tip"),
+ n_("sammoa.observations.observationTable.column.cue"),
+ n_("sammoa.observations.observationTable.column.cue.tip"),
+ n_("sammoa.observations.observationTable.column.behaviour"),
+ n_("sammoa.observations.observationTable.column.behaviour.tip"),
+ n_("sammoa.observations.observationTable.column.swimDir"),
+ n_("sammoa.observations.observationTable.column.swimDir.tip"),
+ n_("sammoa.observations.observationTable.column.calves"),
+ n_("sammoa.observations.observationTable.column.calves.tip"),
+ n_("sammoa.observations.observationTable.column.photo"),
+ n_("sammoa.observations.observationTable.column.photo.tip"),
+ n_("sammoa.observations.observationTable.column.comment"),
+ n_("sammoa.observations.observationTable.column.comment.tip"),
+ n_("sammoa.observations.observationTable.column.observationStatus"),
+ n_("sammoa.observations.observationTable.column.observationStatus.tip"),
+ n_("sammoa.observations.observationTable.column.deleted"),
+ n_("sammoa.observations.observationTable.column.deleted.tip"),
+ n_("sammoa.observations.observationTable.column.circleback"),
+ n_("sammoa.observations.observationTable.column.circleback.tip")
+ );
+
+ init(table, new SelectionModelAdapter<Observation>() {
+
+ @Override
+ public List<Observation> getElements() {
+ return getModel().getObservations();
+ }
+
+ @Override
+ public void setSelectedElement(Observation element) {
+ getModel().setObservationEditBean(element);
+ }
+ });
+
+ // Listeners
+ {
+ FlightController flightController =
+ getParentUI().getHandler().getFlightController();
+
+ int columnToEditOnInsert = ObservationTableModel.ObservationColumn.POD_SIZE.ordinal();
+ getModel().addPropertyChangeListener(
+ FlightUIModel.PROPERTY_OBSERVATIONS,
+ new TableDataChangeListener(table, columnToEditOnInsert)
+ );
+
+ // For CircleBack buttons
+ getModel().addPropertyChangeListener(
+ FlightUIModel.PROPERTY_FLIGHT_STATE,
+ new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ FlightUIModel model = (FlightUIModel) evt.getSource();
+
+ if (model.sizeObservations() > 0) {
+
+ ui.getObservationTableModel().fireTableRowsUpdated(
+ 0, model.sizeObservations() - 1);
+ }
+ }
+ });
+
+ // Refresh matching observations from selected route
+ getModel().addPropertyChangeListener(
+ FlightUIModel.PROPERTY_ROUTE_EDIT_BEAN,
+ new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ Route oldValue = (Route) evt.getOldValue();
+ if (oldValue != null) {
+ fireObservationsUpdated(oldValue, false);
+ }
+ Route newValue = (Route) evt.getNewValue();
+ if (newValue != null) {
+ fireObservationsUpdated(newValue, true);
+ }
+ }
+ });
+
+ if (getModel().isValidationMode()) {
+
+ // For validation, time change is listening to properly select the route
+ getModel().addPropertyChangeListener(
+ FlightUIModel.PROPERTY_OBSERVATION_EDIT_BEAN,
+ new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ Observation oldValue = (Observation) evt.getNewValue();
+ if (oldValue != null) {
+ oldValue.removePropertyChangeListener(
+ Observation.PROPERTY_OBSERVATION_TIME,
+ observationTimeChangeListener);
+ }
+ Observation newValue = (Observation) evt.getNewValue();
+ if (newValue != null) {
+ newValue.addPropertyChangeListener(
+ Observation.PROPERTY_OBSERVATION_TIME,
+ observationTimeChangeListener);
+
+ selectRouteByObservation(newValue);
+ }
+// else {
+// SammoaUtil.unselectAll(ui.getObservationTable());
+// }
+ }
+ });
+
+ } else {
+ flightController.getDeviceManager(GpsHandler.class).addDeviceStateListener(this);
+ flightController.getDeviceManager(AudioRecorder.class).addDeviceStateListener(this);
+ }
+ }
+
+ table.addHighlighter(
+ SammoaUtil.newBackgroundColorHighlighter(
+ new ObservationForSelectedRouteHighlightPredicate(getModel()),
+ SammoaColors.OBSERVATION_FOR_ROUTE_ROW_COLOR)
+ );
+
+ // Validation
+ {
+ JTable errorTable = ui.getErrorTable();
+ SwingListValidatorMessageTableModel errorTableModel = ui.getErrorTableModel();
+
+ BeanListValidator<Observation> validator = ui.getObservationValidator();
+ validator.setContext(getValidatorContext());
+ getParentUI().setContextValue(validator, OBSERVATION_VALIDATOR_CONTEXT_VALUE);
+
+ ObservationValidatorDataLocator dataLocator =
+ new ObservationValidatorDataLocator();
+
+ SwingValidatorUtil.registerListValidator(
+ validator,
+ errorTableModel,
+ table,
+ errorTable,
+ dataLocator
+ );
+
+ addHightLighterOnEditor(
+ validator,
+ table,
+ dataLocator,
+ NuitonValidatorScope.ERROR,
+ NuitonValidatorScope.WARNING
+ );
+
+ for (Observation observation : tableModel.getBean()) {
+ validator.addBean(observation);
+ }
+ }
+
+ // Renderers/Editors/Highlighters
+ {
+ UIDecoratorService decoratorService =
+ context.getService(UIDecoratorService.class);
+
+ TableCellRenderer stringRenderer = table.getDefaultRenderer(String.class);
+
+ // ObservationStatus
+ {
+ JComboBox comboBox = new JComboBox(ObservationStatus.values());
+ table.setDefaultEditor(
+ ObservationStatus.class, new DefaultCellEditor(comboBox));
+ }
+
+ // Position
+ {
+ TableCellRenderer renderer;
+ if (getModel().isValidationMode()) {
+ renderer = new ObservationPositionCellRenderer(
+ stringRenderer, decoratorService, ui.getObservationTableModel());
+
+ } else {
+ renderer = decoratorService.newTableCellRender(Position.class);
+ }
+
+ JComboBox comboBox = new JComboBox();
+ comboBox.setRenderer(decoratorService.newListCellRender(Position.class));
+ SwingUtil.fillComboBox(comboBox, ImmutableList.of(
+ Position.FRONT_LEFT, Position.NAVIGATOR, Position.FRONT_RIGHT
+ ), null);
+
+ table.setDefaultRenderer(Position.class, renderer);
+ table.setDefaultEditor(
+ Position.class, new DefaultCellEditor(comboBox));
+ }
+
+ // CircleBack action
+ {
+ int circleBack = ObservationTableModel.ObservationColumn.CIRCLE_BACK.ordinal();
+ ButtonActionTableCellEditorRenderer editorRenderer = new ButtonActionTableCellEditorRenderer(
+ CircleBackAction.CLIENT_PROPERTY_OBSERVATION,
+ JButton.class,
+ new Supplier<Action>() {
+
+ @Override
+ public Action get() {
+ FlightUIHandler flightUIHandler = getParentUI().getHandler();
+ return flightUIHandler.getActionMap().get("circleBack");
+ }
+ },
+ null
+ );
+ TableColumnExt column = table.getColumnExt(circleBack);
+
+ column.setSortable(false);
+ column.setCellEditor(editorRenderer);
+ column.setCellRenderer(editorRenderer);
+ }
+
+ table.addHighlighter(SammoaUtil.newForegroundColorHighlighter(
+ new DeletedRowHighlightPredicate(getModel().getObservations()),
+ SammoaColors.DELETED_ROW_COLOR)
+ );
+ table.addHighlighter(SammoaUtil.newForegroundColorHighlighter(
+ new ValidRowHighlightPredicate(getModel().getObservations()),
+ SammoaColors.VALID_ROW_COLOR)
+ );
+ }
+ }
+
+ public <T> void init(final JXTable table,
+ SelectionModelAdapter<T> selectionModelAdapter) {
+
+ 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);
+ }
+ }
+ };
+
+ // Text
+ {
+ 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);
+ }
+
+ // Number
+ {
+ 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
+ {
+ TableCellRenderer renderer = table.getDefaultRenderer(Boolean.class);
+ table.setDefaultRenderer(boolean.class, renderer);
+
+ TableCellEditor editor = table.getDefaultEditor(Boolean.class);
+ table.setDefaultEditor(boolean.class, editor);
+ }
+
+ // Date
+ {
+ TableCellRenderer defaultDateCellRenderer = table.getDefaultRenderer(Date.class);
+ TableCellRenderer renderer = JAXXWidgetUtil.newDateTableCellRenderer(
+ defaultDateCellRenderer, _("sammoa.timePattern"));
+ table.setDefaultRenderer(Date.class, renderer);
+
+ JAXXDatePicker datePicker = new JAXXDatePicker();
+ datePicker.setShowPopupButton(false);
+ datePicker.setPatternLayout(_("sammoa.timePattern"));
+ JTextField textField = datePicker.getEditor();
+// textField.addKeyListener(goNextCellAdapter);
+ textField.setBorder(new LineBorder(Color.GRAY, 2));
+ table.setDefaultEditor(Date.class, new TimeCellEditor(datePicker));
+ }
+
+ SammoaUtil.addTableSelectionListener(table, selectionModelAdapter);
+
+ SwingUtil.scrollToTableSelection(table);
+ }
+
+ protected String getValidatorContext() {
+ return getModel().isValidationMode() ? "validation" : "onBoard";
+ }
+
+ protected void fireObservationsUpdated(Route route, boolean scrollToFirst) {
+
+ FlightUIModel model = getModel();
+
+ Iterable<Observation> observations = Observations.filterInRoute(
+ model.getObservations(), route, model.getRoutes(), true);
+
+ SammoaUtil.fireTableRowsUpdated(ui.getObservationTable(),
+ model.getObservations(),
+ observations,
+ scrollToFirst);
+ }
+
+ protected void fireRoutesUpdated(TransectFlightModel transectFlight, boolean scrollToFirst) {
+
+ Iterable<Route> routes = Iterables.filter(
+ getModel().getRoutes(), Routes.withTransectFlight(transectFlight.getSource()));
+
+ SammoaUtil.fireTableRowsUpdated(ui.getRouteTable(),
+ getModel().getRoutes(),
+ routes,
+ scrollToFirst);
+ }
+
+ protected void selectRouteByObservation(Observation observation) {
+
+ Route route = Routes.findWithObservation(
+ getModel().getRoutes(), observation, true);
+
+ int routeIndex = getModel().indexOfRoutes(route);
+ ui.getRouteTable().getSelectionModel().setSelectionInterval(routeIndex, routeIndex);
+ }
+
+ private PropertyChangeListener observationTimeChangeListener = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ selectRouteByObservation((Observation) evt.getSource());
+ }
+ };
+
+ private static class ObservationPositionCellRenderer implements TableCellRenderer {
+
+ protected TableCellRenderer delegate;
+
+ protected Decorator<Position> decorator;
+
+ protected ObservationTableModel model;
+
+ public ObservationPositionCellRenderer(TableCellRenderer delegate,
+ UIDecoratorService decoratorService,
+ ObservationTableModel model) {
+ this.delegate = delegate;
+ this.decorator = decoratorService.getDecoratorByType(Position.class);
+ this.model = model;
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+
+ Observation observation = model.getBean(row);
+
+ Route route = Routes.findWithObservation(model.getFlightUIModel().getRoutes(), observation, true);
+
+ ObserverPosition observerPosition = route.getObserverPositionByPosition(observation.getPosition());
+
+ String newValue = decorator.toString(observation.getPosition());
+ if (observerPosition != null && observerPosition.getObserver() != null) {
+ newValue += " (" + observerPosition.getObserver().getInitials() + ")";
+ }
+
+ return delegate.getTableCellRendererComponent(table, newValue, isSelected, hasFocus, row, column);
+ }
+ }
+
+ private static class RouteValidatorDataLocator implements SwingListValidatorDataLocator<Route> {
+
+ @Override
+ public boolean acceptType(Class<?> beanType) {
+ return Route.class.isAssignableFrom(beanType);
+ }
+
+ @Override
+ public Pair<Integer, Integer> locateDataCell(TableModel tableModel,
+ Route bean,
+ String fieldName) {
+ RouteTableModel model = (RouteTableModel) tableModel;
+
+ Pair<Integer, Integer> cell =
+ model.getCell(bean, fieldName);
+ return cell;
+ }
+
+ @Override
+ public int locateBeanRowIndex(TableModel tableModel, Route bean) {
+ RouteTableModel model = (RouteTableModel) tableModel;
+ return model.getBeanIndex(bean);
+ }
+
+ @Override
+ public Route locateBean(TableModel tableModel, int rowIndex) {
+ RouteTableModel model =
+ (RouteTableModel) tableModel;
+ return model.getBean(rowIndex);
+ }
+ }
+
+ private static class ObservationValidatorDataLocator implements SwingListValidatorDataLocator<Observation> {
+
+ @Override
+ public boolean acceptType(Class<?> beanType) {
+ return Observation.class.isAssignableFrom(beanType);
+ }
+
+ @Override
+ public Pair<Integer, Integer> locateDataCell(TableModel tableModel,
+ Observation bean,
+ String fieldName) {
+ ObservationTableModel model = (ObservationTableModel) tableModel;
+
+ Pair<Integer, Integer> cell =
+ model.getCell(bean, fieldName);
+ return cell;
+ }
+
+ @Override
+ public int locateBeanRowIndex(TableModel tableModel, Observation bean) {
+ ObservationTableModel model = (ObservationTableModel) tableModel;
+ return model.getBeanIndex(bean);
+ }
+
+ @Override
+ public Observation locateBean(TableModel tableModel, int rowIndex) {
+ ObservationTableModel model =
+ (ObservationTableModel) tableModel;
+ return model.getBean(rowIndex);
+ }
+ }
+
+// public static class DeletedRowHighlightPredicate<T extends Deletable> extends AbstractRowHighlightPredicate {
+//
+// protected FlightUIModel UIModel;
+//
+// protected Class<T> referenceClass;
+//
+// public DeletedRowHighlightPredicate(FlightUIModel UIModel,
+// Class<T> referenceClass) {
+// this.UIModel = UIModel;
+// this.referenceClass = referenceClass;
+// }
+//
+// @Override
+// protected boolean isHighlighted(int rowIndex) {
+// boolean result = getValueAt(rowIndex).isDeleted();
+// return result;
+// }
+//
+// @Override
+// protected T getValueAt(int rowIndex) {
+// List<T> list;
+// if (Route.class.isAssignableFrom(referenceClass)) {
+// list = (List<T>) UIModel.getRoutes();
+//
+// } else if (Observation.class.isAssignableFrom(referenceClass)) {
+// list = (List<T>) UIModel.getObservations();
+//
+// } else {
+// throw new IllegalStateException("Not supported type " + referenceClass.getName());
+// }
+// return list.get(rowIndex);
+// }
+// }
+
+ public static class RouteForSelectedTransectFlightHighlightPredicate extends AbstractRowHighlightPredicate {
+
+ protected FlightUIModel UIModel;
+
+ public RouteForSelectedTransectFlightHighlightPredicate(FlightUIModel UIModel) {
+ this.UIModel = UIModel;
+ }
+
+ @Override
+ protected boolean isHighlighted(int rowIndex) {
+
+ TransectFlightModel selectedTransectFlight = UIModel.getTransectFlightEditBean();
+
+ boolean result;
+ if (selectedTransectFlight != null) {
+
+ Route route = getValueAt(rowIndex);
+
+ result = selectedTransectFlight.getSource().equals(route.getTransectFlight());
+
+ } else {
+ result = false;
+ }
+ return result;
+ }
+
+ @Override
+ protected Route getValueAt(int rowIndex) {
+ return UIModel.getRoutes().get(rowIndex);
+ }
+ }
+
+ 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) {
+
+ Observation observation = getValueAt(rowIndex);
+
+ result = Observations.inRoute(observation, selectedRoute, UIModel.getRoutes(), true);
+
+ } 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);
+ }
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/EffortPanelHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/ObservationTableModel.java (from rev 510, 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/flight/effort/ObservationTableModel.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/ObservationTableModel.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,266 @@
+/*
+ * #%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.flight.effort;
+
+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.Position;
+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) {
+ Observation observation = getBean(row);
+ ObservationColumn observationColumn = ObservationColumn.valueOf(column);
+ boolean result = observationColumn.isEditable(observation, flightUIModel.isValidationMode());
+ 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 FlightUIModel getFlightUIModel() {
+ return flightUIModel;
+ }
+
+ public enum ObservationColumn {
+
+ OBSERVATION_NUMBER(false, int.class, Observation.PROPERTY_OBSERVATION_NUMBER),
+ OBSERVATION_TIME(true, Date.class, Observation.PROPERTY_OBSERVATION_TIME) {
+
+ @Override
+ public boolean isEditable(Observation bean, boolean validationMode) {
+ return super.isEditable(bean, validationMode) && validationMode;
+ }
+ },
+ POSITION(true, Position.class, Observation.PROPERTY_POSITION),
+ POD_SIZE(true, int.class, Observation.PROPERTY_POD_SIZE),
+ SPECIES(true, String.class, 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, String.class, Observation.PROPERTY_AGE),
+ DEC_ANGLE(true, int.class, Observation.PROPERTY_DEC_ANGLE),
+ CUE(true, String.class, Observation.PROPERTY_CUE),
+ BEHAVIOUR(true, String.class, 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, String.class, Observation.PROPERTY_CALVES),
+ PHOTO(true, boolean.class, Observation.PROPERTY_PHOTO),
+ COMMENT(true, String.class, 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,
+ 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(Observation bean, boolean validationMode) {
+ boolean result = !bean.isValid() && 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/flight/effort/ObservationTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/RouteTableModel.java (from rev 510, 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/flight/effort/RouteTableModel.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/RouteTableModel.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,244 @@
+/*
+ * #%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.flight.effort;
+
+import fr.ulr.sammoa.persistence.Flight;
+import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.RouteType;
+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, flightUIModel.isValidationMode());
+ 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, Integer.class, Route.PROPERTY_EFFORT_NUMBER),
+ BEGIN_TIME(true, Date.class, Route.PROPERTY_BEGIN_TIME) {
+
+ @Override
+ public boolean isEditable(Route bean, boolean validationMode) {
+ return super.isEditable(bean, validationMode) && validationMode;
+ }
+ },
+ ROUTE_TYPE(false, RouteType.class, Route.PROPERTY_ROUTE_TYPE),
+ TRANSECT(false, String.class,
+ 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();
+
+// int index = model.getFlight().getTransectFlightIndex(transectFlight);
+// result = transect.getName() + " (" + index + ")";
+
+ int crossingNumber = transectFlight.getCrossingNumber();
+ result = transect.getName() + " (" + crossingNumber + ")";
+
+ } 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, String.class, Route.PROPERTY_SUBJECTIVE_CONDITIONS),
+ UNEXPECTED_LEFT(true, String.class, Route.PROPERTY_UNEXPECTED_LEFT),
+ UNEXEPECTED_RIGHT(true, String.class, Route.PROPERTY_UNEXPECTED_RIGHT),
+ COMMENT(true, String.class, 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,
+ 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 validationMode) {
+ boolean result = !bean.isValid() && 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/flight/effort/RouteTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/SpeciesCodeValidator.java (from rev 510, trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/SpeciesCodeValidator.java)
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/SpeciesCodeValidator.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/SpeciesCodeValidator.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,59 @@
+package fr.ulr.sammoa.ui.swing.flight.effort;
+/*
+ * #%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 com.opensymphony.xwork2.validator.ValidationException;
+import fr.ulr.sammoa.application.ReferentialService;
+import fr.ulr.sammoa.application.SammoaContext;
+import fr.ulr.sammoa.persistence.Species;
+import fr.ulr.sammoa.ui.swing.SammoaUIContext;
+import org.nuiton.validator.xwork2.field.CollectionFieldExpressionValidator;
+
+import java.util.Collection;
+
+/**
+ * To validate that a given species use a known {@link Species#getCode()}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.5
+ */
+public class SpeciesCodeValidator extends CollectionFieldExpressionValidator {
+
+ protected Collection<Species> species;
+
+ @Override
+ protected Collection<?> getCollection(Object object) throws ValidationException {
+ if (species == null) {
+ SammoaContext appContext = SammoaUIContext.getUIContext().getAppContext();
+ species = appContext.getService(ReferentialService.class).getAllValidSpecies();
+ }
+ return species;
+ }
+
+ @Override
+ public String getValidatorType() {
+ return "speciesCode";
+ }
+
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/SpeciesCodeValidator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/action/MoveToNextEditableCellAction.java (from rev 510, 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/flight/effort/action/MoveToNextEditableCellAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/action/MoveToNextEditableCellAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,90 @@
+package fr.ulr.sammoa.ui.swing.flight.effort.action;
+/*
+ * #%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 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/flight/effort/action/MoveToNextEditableCellAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/action/MoveToNextRowEditableAction.java (from rev 510, 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/flight/effort/action/MoveToNextRowEditableAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/action/MoveToNextRowEditableAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,76 @@
+package fr.ulr.sammoa.ui.swing.flight.effort.action;
+/*
+ * #%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 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/flight/effort/action/MoveToNextRowEditableAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/action/MoveToPreviousEditableCellAction.java (from rev 510, 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/flight/effort/action/MoveToPreviousEditableCellAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/action/MoveToPreviousEditableCellAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,89 @@
+package fr.ulr.sammoa.ui.swing.flight.effort.action;
+/*
+ * #%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 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/flight/effort/action/MoveToPreviousEditableCellAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/action/MoveToPreviousRowEditableAction.java (from rev 510, 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/flight/effort/action/MoveToPreviousRowEditableAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/effort/action/MoveToPreviousRowEditableAction.java 2012-09-03 15:47:49 UTC (rev 511)
@@ -0,0 +1,76 @@
+package fr.ulr.sammoa.ui.swing.flight.effort.action;
+/*
+ * #%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 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/flight/effort/action/MoveToPreviousRowEditableAction.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/region/RegionUI.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/region/RegionUI.jaxx 2012-09-03 14:57:07 UTC (rev 510)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/region/RegionUI.jaxx 2012-09-03 15:47:49 UTC (rev 511)
@@ -27,7 +27,7 @@
implements='fr.ulr.sammoa.ui.swing.SammoaUI<RegionUIHandler>'>
<import>
- fr.ulr.sammoa.ui.swing.action.CloseAction
+ fr.ulr.sammoa.ui.swing.CloseAction
fr.ulr.sammoa.ui.swing.SammoaUIContext
jaxx.runtime.swing.editor.FileEditor
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/transect/TransectUI.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/transect/TransectUI.jaxx 2012-09-03 14:57:07 UTC (rev 510)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/transect/TransectUI.jaxx 2012-09-03 15:47:49 UTC (rev 511)
@@ -28,7 +28,7 @@
<import>
fr.ulr.sammoa.ui.swing.flight.StrateModel
- fr.ulr.sammoa.ui.swing.action.CloseAction
+ fr.ulr.sammoa.ui.swing.CloseAction
fr.ulr.sammoa.ui.swing.SammoaUIContext
jaxx.runtime.validator.swing.SwingValidatorUtil
Modified: trunk/sammoa-ui-swing/src/main/resources/validators.xml
===================================================================
--- trunk/sammoa-ui-swing/src/main/resources/validators.xml 2012-09-03 14:57:07 UTC (rev 510)
+++ trunk/sammoa-ui-swing/src/main/resources/validators.xml 2012-09-03 15:47:49 UTC (rev 511)
@@ -41,7 +41,7 @@
<validator name="fieldexpression" class="com.opensymphony.xwork2.validator.validators.FieldExpressionValidator"/>
<validator name="email" class="com.opensymphony.xwork2.validator.validators.EmailValidator"/>
- <validator name="speciesCode" class="fr.ulr.sammoa.ui.swing.observations.SpeciesCodeValidator"/>
+ <validator name="speciesCode" class="fr.ulr.sammoa.ui.swing.flight.effort.SpeciesCodeValidator"/>
<validator name="collectionUniqueKey" class="org.nuiton.validator.xwork2.field.CollectionUniqueKeyValidator"/>
<!--<validator name="url" class="com.opensymphony.xwork2.validator.validators.URLValidator"/>
1
0
r510 - in trunk: sammoa-application/src/main/java/fr/ulr/sammoa/application sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util sammoa-ui-swing/src/main/resources/i18n
by fdesbois@users.forge.codelutin.com 03 Sep '12
by fdesbois@users.forge.codelutin.com 03 Sep '12
03 Sep '12
Author: fdesbois
Date: 2012-09-03 16:57:07 +0200 (Mon, 03 Sep 2012)
New Revision: 510
Url: http://forge.codelutin.com/repositories/revision/sammoa/510
Log:
fixes #1372 :
- add new DeleteTransectAction
- support addAll in TableDataChangeListener
- support checkbox in ButtonActionTableCellEditorRenderer
- add transectFlightEditBean matching selection in FlightUIModel
Added:
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/DeleteTransectAction.java
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ValidationService.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/NextTransectAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/SammoaAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidObservationAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidRouteAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidTransectAction.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.css
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.jaxx
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIModel.java
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/observations/EffortPanelHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/ButtonActionTableCellEditorRenderer.java
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/TableDataChangeListener.java
trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java 2012-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -305,6 +305,38 @@
}
}
+ public void deleteTansectFlight(Flight flight,
+ TransectFlight transectFlight) {
+
+ TopiaContext tx = beginTransaction();
+ try {
+
+ deleteTansectFlight(tx, flight, transectFlight);
+
+ tx.commitTransaction();
+
+ } catch (TopiaException ex) {
+ throw new TopiaRuntimeException(ex);
+ } finally {
+ endTransaction(tx);
+ }
+ }
+
+ protected void deleteTansectFlight(TopiaContext tx,
+ Flight flight,
+ TransectFlight transectFlight)
+ throws TopiaException {
+
+ SammoaDAOHelper.getObserverPositionDAO(tx).deleteAll(
+ transectFlight.getObserverPosition());
+
+ flight.removeTransectFlight(transectFlight);
+
+ SammoaDAOHelper.getTransectFlightDAO(tx).delete(transectFlight);
+
+ SammoaDAOHelper.getFlightDAO(tx).update(flight);
+ }
+
/**
* Remove the given flight from db and storage.
*
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ValidationService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ValidationService.java 2012-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ValidationService.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -51,27 +51,22 @@
TopiaContext tx = beginTransaction();
try {
+ TransectFlight result;
- TransectFlightDAO transectFlightDAO = SammoaDAOHelper.getTransectFlightDAO(tx);
- TransectFlight result = transectFlightDAO.findByTopiaId(transectFlight.getTopiaId());
-
boolean valid = !transectFlight.isValid();
if (transectFlight.isDeleted()) {
-// ObserverPositionDAO observerPositionDAO = SammoaDAOHelper.getObserverPositionDAO(tx);
-// observerPositionDAO.deleteAll(transectFlightExists.getObserverPosition());
-//
-// FlightDAO flightDAO = SammoaDAOHelper.getFlightDAO(tx);
-// Flight flightExists = flightDAO.findByTopiaId(flight.getTopiaId());
-//
-// flightExists.removeTransectFlight(transectFlightExists);
-//
-// // XXX-fdesbois-2012-08-23 : maybe useless with cascade on delete ?
-// transectFlightDAO.delete(transectFlightExists);
+ // Use FlightService for delete
+ context.getService(FlightService.class).deleteTansectFlight(tx, flight, transectFlight);
+ result = null;
+
} else {
+ TransectFlightDAO transectFlightDAO = SammoaDAOHelper.getTransectFlightDAO(tx);
+ result = transectFlightDAO.findByTopiaId(transectFlight.getTopiaId());
+
RouteDAO routeDAO = SammoaDAOHelper.getRouteDAO(tx);
List<Route> routes = routeDAO.findAllByTransectFlight(result);
@@ -153,7 +148,6 @@
if (route.isDeleted()) {
- // TODO-fdesbois-2012-08-23 : manage observerPosition attached to observations
ObserverPositionDAO observerPositionDAO = SammoaDAOHelper.getObserverPositionDAO(tx);
observerPositionDAO.deleteAll(route.getObserverPosition());
Added: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/DeleteTransectAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/DeleteTransectAction.java (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/DeleteTransectAction.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -0,0 +1,78 @@
+package fr.ulr.sammoa.ui.swing.action;
+
+import fr.ulr.sammoa.application.FlightService;
+import fr.ulr.sammoa.application.flightController.FlightState;
+import fr.ulr.sammoa.ui.swing.flight.FlightUI;
+import fr.ulr.sammoa.ui.swing.flight.TransectFlightModel;
+import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
+import jaxx.runtime.JAXXContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.Action;
+import javax.swing.JComponent;
+import java.awt.event.ActionEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Created: 03/09/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public class DeleteTransectAction extends SammoaAction {
+
+ /** Logger. */
+ private static final Logger logger = LoggerFactory.getLogger(DeleteTransectAction.class);
+
+ public static final String CLIENT_PROPERTY_TRANSECT_FLIGHT = "transectFlight";
+
+ public DeleteTransectAction(JAXXContext context) {
+ super((String) null, context);
+ putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.deleteTransect.tip"));
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Object source = e.getSource();
+ if (source instanceof JComponent) {
+ JComponent comp = (JComponent) source;
+
+ final TransectFlightModel transectFlight =
+ (TransectFlightModel) comp.getClientProperty(CLIENT_PROPERTY_TRANSECT_FLIGHT);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Change transect {} deleted flag to {}",
+ transectFlight.getSource().getTransect().getName(),
+ !transectFlight.isDeleted());
+ }
+
+ transectFlight.setDeleted(!transectFlight.isDeleted());
+
+ // #1372: If flight isn't started, we propose to delete definitely the transect
+ if (FlightState.WAITING == getModel().getFlightState() && transectFlight.isDeleted()) {
+
+ if (SammoaUtil.askQuestion((FlightUI) context, _("sammoa.confirmDialog.deleteTransect.message"))) {
+
+ FlightService service =
+ getSammoaUIContext().getService(FlightService.class);
+ service.deleteTansectFlight(getModel().getFlight(), transectFlight.getSource());
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Delete transect {} ",
+ transectFlight.getSource().getTransect().getName());
+ }
+
+ // Update model
+ int index = getModel().indexOfTransectFlights(transectFlight);
+ getModel().removeTransectFlight(index);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected boolean checkEnabled() {
+ return true;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/DeleteTransectAction.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/action/NextTransectAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/NextTransectAction.java 2012-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/NextTransectAction.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -52,11 +52,10 @@
@Override
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
- TransectFlightModel transectFlight = null;
-
if (source instanceof JComponent) {
JComponent component = (JComponent) e.getSource();
- transectFlight = (TransectFlightModel) component.getClientProperty(CLIENT_PROPERTY_TRANSECT_FLIGHT);
+ TransectFlightModel transectFlight =
+ (TransectFlightModel) component.getClientProperty(CLIENT_PROPERTY_TRANSECT_FLIGHT);
getFlightController().setNextTransect(transectFlight.getSource());
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/SammoaAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/SammoaAction.java 2012-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/SammoaAction.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -24,6 +24,7 @@
package fr.ulr.sammoa.ui.swing.action;
import fr.ulr.sammoa.application.flightController.FlightController;
+import fr.ulr.sammoa.ui.swing.SammoaUIContext;
import fr.ulr.sammoa.ui.swing.flight.FlightUIHandler;
import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
import jaxx.runtime.JAXXContext;
@@ -69,6 +70,10 @@
return context.getContextValue(FlightUIHandler.class).getModel();
}
+ protected SammoaUIContext getSammoaUIContext() {
+ return context.getContextValue(SammoaUIContext.class);
+ }
+
protected void bindModelProperties(String... properties) {
for (String property : properties) {
getModel().addPropertyChangeListener(property, enabledListener);
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidAction.java 2012-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidAction.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -31,6 +31,7 @@
import fr.ulr.sammoa.persistence.Validable;
import fr.ulr.sammoa.ui.swing.SammoaUIContext;
import jaxx.runtime.JAXXContext;
+import org.jdesktop.beans.AbstractBean;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.util.Resource;
import org.nuiton.validator.bean.list.BeanListValidator;
@@ -108,8 +109,8 @@
return getValidator(Observation.class);
}
- protected <E extends TopiaEntity & Validable> void bindValidableModel(String propertyName,
- Class<E> propertyClass) {
+ protected <E extends TopiaEntity & Validable> void bindValidableEntity(String propertyName,
+ Class<E> propertyClass) {
getModel().addPropertyChangeListener(propertyName, new PropertyChangeListener() {
@@ -129,4 +130,26 @@
}
});
}
+
+ protected <E extends AbstractBean & Validable> void bindValidableModel(String propertyName,
+ Class<E> propertyClass) {
+
+ getModel().addPropertyChangeListener(propertyName, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ AbstractBean oldValue = (AbstractBean) evt.getOldValue();
+ if (oldValue != null) {
+ oldValue.removePropertyChangeListener(
+ "deleted", enabledListener);
+ }
+ AbstractBean newValue = (AbstractBean) evt.getNewValue();
+ if (newValue != null) {
+ newValue.addPropertyChangeListener(
+ "deleted", enabledListener);
+ }
+ enabledListener.propertyChange(evt);
+ }
+ });
+ }
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidObservationAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidObservationAction.java 2012-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidObservationAction.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -50,7 +50,7 @@
public ValidObservationAction(JAXXContext context) {
super(_("sammoa.action.validObservation"), context);
putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.validObservation.tip"));
- bindValidableModel(FlightUIModel.PROPERTY_OBSERVATION_EDIT_BEAN, Observation.class);
+ bindValidableEntity(FlightUIModel.PROPERTY_OBSERVATION_EDIT_BEAN, Observation.class);
}
@Override
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidRouteAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidRouteAction.java 2012-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidRouteAction.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -27,7 +27,6 @@
import fr.ulr.sammoa.persistence.Observation;
import fr.ulr.sammoa.persistence.Route;
import fr.ulr.sammoa.persistence.Routes;
-import fr.ulr.sammoa.ui.swing.SammoaUIContext;
import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
import jaxx.runtime.JAXXContext;
import org.slf4j.Logger;
@@ -55,8 +54,8 @@
public ValidRouteAction(JAXXContext context) {
super(_("sammoa.action.validRoute"), context);
putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.validRoute.tip"));
- bindValidableModel(FlightUIModel.PROPERTY_OBSERVATION_EDIT_BEAN, Observation.class);
- bindValidableModel(FlightUIModel.PROPERTY_ROUTE_EDIT_BEAN, Route.class);
+ bindValidableEntity(FlightUIModel.PROPERTY_OBSERVATION_EDIT_BEAN, Observation.class);
+ bindValidableEntity(FlightUIModel.PROPERTY_ROUTE_EDIT_BEAN, Route.class);
}
@Override
@@ -89,7 +88,7 @@
// Reload all observations
FlightService service =
- context.getContextValue(SammoaUIContext.class).getService(FlightService.class);
+ getSammoaUIContext().getService(FlightService.class);
getModel().clearObservation();
getModel().addAllObservation(service.getObservations(getModel().getFlight()));
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidTransectAction.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidTransectAction.java 2012-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidTransectAction.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -28,7 +28,6 @@
import fr.ulr.sammoa.persistence.Route;
import fr.ulr.sammoa.persistence.TransectFlight;
import fr.ulr.sammoa.persistence.TransectFlights;
-import fr.ulr.sammoa.ui.swing.SammoaUIContext;
import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
import fr.ulr.sammoa.ui.swing.flight.TransectFlightModel;
import jaxx.runtime.JAXXContext;
@@ -57,21 +56,21 @@
public ValidTransectAction(JAXXContext context) {
super(_("sammoa.action.validTransect"), context);
putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.validTransect.tip"));
- bindValidableModel(FlightUIModel.PROPERTY_OBSERVATION_EDIT_BEAN, Observation.class);
- bindValidableModel(FlightUIModel.PROPERTY_ROUTE_EDIT_BEAN, Route.class);
+ bindValidableEntity(FlightUIModel.PROPERTY_OBSERVATION_EDIT_BEAN, Observation.class);
+ bindValidableEntity(FlightUIModel.PROPERTY_ROUTE_EDIT_BEAN, Route.class);
+ bindValidableModel(FlightUIModel.PROPERTY_TRANSECT_FLIGHT_EDIT_BEAN, TransectFlightModel.class);
}
@Override
public void actionPerformed(ActionEvent e) {
- Route route = getModel().getRouteEditBean();
+ TransectFlightModel bean = getModel().getTransectFlightEditBean();
- if (route != null && route.getTransectFlight() != null) {
+ if (bean != null) {
- TransectFlight transectFlight = route.getTransectFlight();
+ TransectFlight transectFlight = bean.getSource();
- int index = TransectFlightModel.indexOfTransectFlight(
- getModel().getTransectFlights(), transectFlight);
+ int index = getModel().indexOfTransectFlights(bean);
if (logger.isDebugEnabled()) {
logger.debug("Validation for transectFlight {} : {}",
@@ -91,18 +90,20 @@
validatorIsAdjusting = true;
+ Route routeEditBean = getModel().getRouteEditBean();
+
getModel().setRouteEditBean(null);
// Reload all routes
FlightService service =
- context.getContextValue(SammoaUIContext.class).getService(FlightService.class);
+ getSammoaUIContext().getService(FlightService.class);
getModel().clearRoute();
getModel().addAllRoute(service.getRoutes(getModel().getFlight()));
// Keep the route selected
- if (!route.isDeleted()) {
- getModel().setCurrentRoute(route);
- getModel().setRouteEditBean(route);
+ if (routeEditBean != null && !routeEditBean.isDeleted()) {
+ getModel().setCurrentRoute(routeEditBean);
+ getModel().setRouteEditBean(routeEditBean);
}
getModel().setObservationEditBean(null);
@@ -120,11 +121,11 @@
protected boolean checkEnabled() {
boolean result = isEnabled();
if (!validatorIsAdjusting) {
- Route route = getModel().getRouteEditBean();
- if (route != null) {
- TransectFlight bean = route.getTransectFlight();
- result = bean != null
- && TransectFlights.isValid(bean,
+ TransectFlightModel bean = getModel().getTransectFlightEditBean();
+ if (bean != null) {
+ TransectFlight transectflight = bean.getSource();
+ result = transectflight != null
+ && TransectFlights.isValid(transectflight,
getRouteValidator(),
getObservationValidator());
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.css
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.css 2012-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.css 2012-09-03 14:57:07 UTC (rev 510)
@@ -144,6 +144,9 @@
#transectTable {
model:{transectTableModel};
selectionModel:{transectFlightSelectionModel};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
}
#startButton {
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.jaxx
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.jaxx 2012-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUI.jaxx 2012-09-03 14:57:07 UTC (rev 510)
@@ -28,6 +28,7 @@
<import>
java.awt.BorderLayout
java.awt.Dimension
+ java.awt.Color
javax.swing.ListSelectionModel
javax.swing.DefaultListSelectionModel
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java 2012-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -79,6 +79,7 @@
import fr.ulr.sammoa.persistence.Observations;
import fr.ulr.sammoa.persistence.Observer;
import fr.ulr.sammoa.persistence.Route;
+import fr.ulr.sammoa.persistence.Routes;
import fr.ulr.sammoa.persistence.Strate;
import fr.ulr.sammoa.persistence.Transect;
import fr.ulr.sammoa.persistence.TransectFlight;
@@ -91,6 +92,7 @@
import fr.ulr.sammoa.ui.swing.action.BeginAction;
import fr.ulr.sammoa.ui.swing.action.CenterObservationAction;
import fr.ulr.sammoa.ui.swing.action.CircleBackAction;
+import fr.ulr.sammoa.ui.swing.action.DeleteTransectAction;
import fr.ulr.sammoa.ui.swing.action.EndAction;
import fr.ulr.sammoa.ui.swing.action.LeftObservationAction;
import fr.ulr.sammoa.ui.swing.action.NextAction;
@@ -112,6 +114,8 @@
import fr.ulr.sammoa.ui.swing.util.ColorTableCellRenderer;
import fr.ulr.sammoa.ui.swing.util.DeletedRowHighlightPredicate;
import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
+import fr.ulr.sammoa.ui.swing.util.SelectionModelAdapter;
+import fr.ulr.sammoa.ui.swing.util.TableDataChangeListener;
import fr.ulr.sammoa.ui.swing.util.ValidRowHighlightPredicate;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.SwingUtil;
@@ -128,6 +132,7 @@
import javax.swing.ActionMap;
import javax.swing.DefaultCellEditor;
import javax.swing.InputMap;
+import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
@@ -138,7 +143,6 @@
import javax.swing.event.ListSelectionEvent;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
-import java.awt.Color;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.ItemEvent;
@@ -186,6 +190,8 @@
protected FlightController flightController;
+ protected boolean transectFlightSelectionIsAdjusting;
+
public FlightUIHandler(SammoaUIContext context, FlightUI ui) {
this.context = context;
this.ui = ui;
@@ -416,53 +422,79 @@
TransectTableModel tableModel = ui.getTransectTableModel();
-// if (getModel().isValidationMode()) {
-//
-// table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-//
-// SammoaUtil.addTableSelectionListener(
-// table, new SelectionModelAdapter<TransectFlightModel>() {
-//
-// @Override
-// public List<TransectFlightModel> getElements() {
-// return getModel().getTransectFlights();
-// }
-//
-// @Override
-// public void setSelectedElement(TransectFlightModel element) {
-// getModel().setTransectFlightEditBean(element);
-// }
-// });
-//
-// getModel().addPropertyChangeListener(
-// FlightUIModel.PROPERTY_ROUTE_EDIT_BEAN, new PropertyChangeListener() {
-//
-// @Override
-// public void propertyChange(PropertyChangeEvent evt) {
-//
-// int index = -1;
-//
-// if (evt.getNewValue() != null) {
-//
-// Route route = (Route) evt.getNewValue();
-//
-// index = TransectFlightModel.indexOfTransectFlight(
-// getModel().getTransectFlights(), route.getTransectFlight());
-// }
-//
-// // Unselect all
-// if (index == -1) {
-//
-//// SammoaUtil.unselectAll(ui.getTransectTable());
-//
-// // Select the corresponding transectFlight
-// } else {
-// ui.getTransectFlightSelectionModel().setSelectionInterval(index, index);
-// }
-// }
-// });
-// }
+ getModel().addPropertyChangeListener(
+ FlightUIModel.PROPERTY_TRANSECT_FLIGHTS,
+ new TableDataChangeListener(table, TableDataChangeListener.NO_COLUMN_INDEX_TO_EDIT_ON_INSERT));
+ if (getModel().isValidationMode()) {
+
+ table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+
+ SammoaUtil.addTableSelectionListener(
+ table, new SelectionModelAdapter<TransectFlightModel>() {
+
+ @Override
+ public List<TransectFlightModel> getElements() {
+ return getModel().getTransectFlights();
+ }
+
+ @Override
+ public void setSelectedElement(TransectFlightModel element) {
+ getModel().setTransectFlightEditBean(element);
+ }
+ });
+
+ // Select the first route matching the transectFlight
+ getModel().addPropertyChangeListener(
+ FlightUIModel.PROPERTY_TRANSECT_FLIGHT_EDIT_BEAN, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ TransectFlightModel transectFlight = (TransectFlightModel) evt.getNewValue();
+ if (!transectFlightSelectionIsAdjusting && transectFlight != null) {
+
+ transectFlightSelectionIsAdjusting = true;
+
+ Route route = FluentIterable
+ .from(getModel().getRoutes())
+ .filter(Routes.withTransectFlight(transectFlight.getSource()))
+ .first()
+ .orNull();
+
+ getModel().setRouteEditBean(route);
+
+ transectFlightSelectionIsAdjusting = false;
+ }
+ }
+ });
+
+ // Select the transectFlight matching the route
+ getModel().addPropertyChangeListener(
+ FlightUIModel.PROPERTY_ROUTE_EDIT_BEAN, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ if (!transectFlightSelectionIsAdjusting && evt.getNewValue() != null) {
+
+ transectFlightSelectionIsAdjusting = true;
+
+ Route route = (Route) evt.getNewValue();
+
+ if (route.getTransectFlight() != null) {
+
+ int index = TransectFlightModel.indexOfTransectFlight(
+ getModel().getTransectFlights(), route.getTransectFlight());
+ ui.getTransectFlightSelectionModel().setSelectionInterval(index, index);
+ }
+
+ transectFlightSelectionIsAdjusting = false;
+ }
+ }
+ });
+ }
+
NumberCellEditor<Integer> numberCellEditor = JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, false);
table.setDefaultEditor(Integer.class, numberCellEditor);
table.setDefaultEditor(int.class, numberCellEditor);
@@ -513,12 +545,48 @@
column.setHeaderRenderer(new ColorTableCellRenderer(stringRenderer, SammoaColors.POSITION_RIGHT_COLOR));
}
- // ACTION column (Next Transect)
+ // ACTION deleted column
{
+ int columnIndex = TransectTableModel.TransectColumn.DELETED.ordinal();
+ TableColumn column = table.getColumnModel().getColumn(columnIndex);
+ ButtonActionTableCellEditorRenderer editorRenderer = new ButtonActionTableCellEditorRenderer(
+ NextTransectAction.CLIENT_PROPERTY_TRANSECT_FLIGHT,
+ JCheckBox.class,
+ new Supplier<Action>() {
+
+ @Override
+ public Action get() {
+ Action result = getActionMap().get("deleteTransect");
+ return result;
+ }
+ },
+ new Predicate<Object>() {
+
+ @Override
+ public boolean apply(Object input) {
+ TransectFlight transectFlight =
+ ((TransectFlightModel) input).getSource();
+
+ // Enabled only if no route match the transectFlight
+ // Note : the deleted route case is too complex, the user must delete routes before transect
+ boolean result = FluentIterable
+ .from(getModel().getRoutes())
+ .anyMatch(Routes.withTransectFlight(transectFlight));
+ return !result;
+ }
+ });
+
+ column.setCellEditor(editorRenderer);
+ column.setCellRenderer(editorRenderer);
+ }
+
+ // ACTION nextTransect column
+ {
int columnIndex = TransectTableModel.TransectColumn.ACTION.ordinal();
TableColumn column = table.getColumnModel().getColumn(columnIndex);
ButtonActionTableCellEditorRenderer editorRenderer = new ButtonActionTableCellEditorRenderer(
NextTransectAction.CLIENT_PROPERTY_TRANSECT_FLIGHT,
+ JButton.class,
new Supplier<Action>() {
@Override
@@ -539,10 +607,6 @@
column.setCellRenderer(editorRenderer);
}
- table.setSortable(false);
- table.setSelectionBackground(null);
- table.setSelectionForeground(Color.BLACK);
-
table.addHighlighter(SammoaUtil.newBackgroundColorHighlighter(
new CurrentTransectHighlightPredicate(tableModel),
SammoaColors.CURRENT_TRANSECT_ROW_COLOR)
@@ -733,10 +797,7 @@
List<TransectFlightModel> newTransectFlights =
prepareTransectFlights(getModel(), transectFlights);
- getModel().getTransectFlights().addAll(fromIndex, newTransectFlights);
-
- int toIndex = fromIndex + newTransectFlights.size() - 1;
- ui.getTransectTableModel().fireTableRowsInserted(fromIndex, toIndex);
+ getModel().addAllTransectFlights(fromIndex, newTransectFlights);
}
}
@@ -766,15 +827,17 @@
if (logger.isDebugEnabled()) {
logger.debug("Select transectFlights {}", event.getFirstIndex());
}
+ if (event.getFirstIndex() != -1) {
- for (int i = event.getFirstIndex(),
- transectFlightsize = getModel().getTransectFlights().size();
- i <= event.getLastIndex() && i < transectFlightsize; i++) {
+ for (int i = event.getFirstIndex(),
+ transectFlightsize = getModel().getTransectFlights().size();
+ i <= event.getLastIndex() && i < transectFlightsize; i++) {
- TransectFlightModel model = getModel().getTransectFlights().get(i);
+ TransectFlightModel model = getModel().getTransectFlights().get(i);
- boolean selected = selectionModel.isSelectedIndex(i);
- model.getTransect().setSelectedInFlight(selected);
+ boolean selected = selectionModel.isSelectedIndex(i);
+ model.getTransect().setSelectedInFlight(selected);
+ }
}
}
@@ -791,6 +854,7 @@
putAction("centerObservation", new CenterObservationAction(ui));
putAction("rightObservation", new RightObservationAction(ui));
putAction("circleBack", new CircleBackAction(ui));
+ putAction("deleteTransect", new DeleteTransectAction(ui));
if (getModel().isValidationMode()) {
putAction("validObservation", new ValidObservationAction(ui));
putAction("validRoute", new ValidRouteAction(ui));
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIModel.java 2012-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIModel.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -70,7 +70,7 @@
public static final String PROPERTY_ROUTE_EDIT_BEAN = "routeEditBean";
-// public static final String PROPERTY_TRANSECT_FLIGHT_EDIT_BEAN = "transectFlightEditBean";
+ public static final String PROPERTY_TRANSECT_FLIGHT_EDIT_BEAN = "transectFlightEditBean";
public static final String PROPERTY_FLIGHT_OBSERVER_FOR_POSITIONS = "flightObserverForPositions";
@@ -123,7 +123,7 @@
*/
protected Route routeEditBean;
-// protected TransectFlightModel transectFlightEditBean;
+ protected TransectFlightModel transectFlightEditBean;
/**
* La liste des observateurs du vol, sans les pilotes avec l'observateur null
@@ -351,17 +351,17 @@
this.routeEditBean = routeEditBean;
firePropertyChange(PROPERTY_ROUTE_EDIT_BEAN, oldRouteEditBean, routeEditBean);
}
-//
-// public TransectFlightModel getTransectFlightEditBean() {
-// return transectFlightEditBean;
-// }
-//
-// public void setTransectFlightEditBean(TransectFlightModel transectFlightEditBean) {
-// TransectFlightModel oldValue = this.transectFlightEditBean;
-// this.transectFlightEditBean = transectFlightEditBean;
-// firePropertyChange(PROPERTY_TRANSECT_FLIGHT_EDIT_BEAN, oldValue, transectFlightEditBean);
-// }
+ public TransectFlightModel getTransectFlightEditBean() {
+ return transectFlightEditBean;
+ }
+
+ public void setTransectFlightEditBean(TransectFlightModel transectFlightEditBean) {
+ TransectFlightModel oldValue = this.transectFlightEditBean;
+ this.transectFlightEditBean = transectFlightEditBean;
+ firePropertyChange(PROPERTY_TRANSECT_FLIGHT_EDIT_BEAN, oldValue, transectFlightEditBean);
+ }
+
public List<Observer> getFlightObserverForPositions() {
if (flightObserverForPositions == null) {
flightObserverForPositions = Lists.newArrayList();
@@ -370,7 +370,8 @@
}
public void setFlightObserverForPositions(List<Observer> flightObserverForPositions) {
- List<Observer> oldValue = ImmutableList.copyOf(getFlightObserverForPositions());
+ // Note: Can't use ImmutableList for copy, the list contains the null observer
+ List<Observer> oldValue = Lists.newArrayList(getFlightObserverForPositions());
this.flightObserverForPositions = flightObserverForPositions;
firePropertyChange(PROPERTY_FLIGHT_OBSERVER_FOR_POSITIONS, oldValue, flightObserverForPositions);
}
@@ -398,19 +399,6 @@
public StrateModel getStrateAll() {
return !getStrates().isEmpty() ? getStrates().get(0) : null;
}
-//
-// public List<Transect> getTransects() {
-// if (transects == null) {
-// transects = Lists.newArrayList();
-// }
-// return transects;
-// }
-//
-// public void setTransects(List<Transect> transects) {
-// List<Transect> oldValue = Lists.newArrayList(getTransects());
-// this.transects = transects;
-// firePropertyChange(PROPERTY_TRANSECTS, oldValue, transects);
-// }
public List<StrateModel> getStrates() {
if (strates == null) {
@@ -448,12 +436,22 @@
return transectFlights;
}
+ public int indexOfTransectFlights(TransectFlightModel transectFlight) {
+ return getTransectFlights().indexOf(transectFlight);
+ }
+
public void setTransectFlights(List<TransectFlightModel> transectFlights) {
List<TransectFlightModel> oldValue = ImmutableList.copyOf(getTransectFlights());
this.transectFlights = transectFlights;
firePropertyChange(PROPERTY_TRANSECT_FLIGHTS, oldValue, transectFlights);
}
+ public void addAllTransectFlights(int index, Collection<TransectFlightModel> transectFlights) {
+ List<TransectFlightModel> oldValue = ImmutableList.copyOf(getTransectFlights());
+ getTransectFlights().addAll(index, transectFlights);
+ fireIndexedPropertyChange(PROPERTY_TRANSECT_FLIGHTS, index, oldValue, getTransectFlights());
+ }
+
public void removeTransectFlight(int index) {
List<TransectFlightModel> oldValue = ImmutableList.copyOf(getTransectFlights());
getTransectFlights().remove(index);
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-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTableModel.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -51,10 +51,6 @@
this.reference = reference;
}
- public FlightUIModel getReference() {
- return reference;
- }
-
public Flight getFlight() {
return reference.getFlight();
}
@@ -270,9 +266,17 @@
DELETED(
_("sammoa.flightPanel.table.column.deleted"),
true,
- Boolean.class,
- TransectFlightModel.PROPERTY_DELETED
- ),
+ TransectFlightModel.class
+ ) {
+ @Override
+ public Object getValue(int index, TransectFlightModel bean) {
+ return bean;
+ }
+
+ @Override
+ public void setValue(TransectFlightModel bean, Object value, TransectTableModel model) {
+ }
+ },
ACTION(
_("sammoa.flightPanel.table.column.action"),
true,
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-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/EffortPanelHandler.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -48,6 +48,7 @@
import fr.ulr.sammoa.ui.swing.flight.FlightUI;
import fr.ulr.sammoa.ui.swing.flight.FlightUIHandler;
import fr.ulr.sammoa.ui.swing.flight.FlightUIModel;
+import fr.ulr.sammoa.ui.swing.flight.TransectFlightModel;
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;
@@ -83,6 +84,7 @@
import javax.swing.Action;
import javax.swing.DefaultCellEditor;
+import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.JTextField;
@@ -115,8 +117,6 @@
private static final Logger logger =
LoggerFactory.getLogger(EffortPanelHandler.class);
- public static final String ERROR_TABLE = "errorTable";
-
protected static final Color DEVICE_ERROR_BACKGROUND_COLOR = Color.RED;
public static final String ROUTE_VALIDATOR_CONTEXT_VALUE =
@@ -356,6 +356,8 @@
);
if (flightUIModel.isValidationMode()) {
+
+ // FlightController # change current route
flightUIModel.addPropertyChangeListener(
FlightUIModel.PROPERTY_ROUTE_EDIT_BEAN,
new PropertyChangeListener() {
@@ -370,6 +372,24 @@
}
}
);
+
+ // Refresh matching routes from selected transectFlight
+ flightUIModel.addPropertyChangeListener(
+ FlightUIModel.PROPERTY_TRANSECT_FLIGHT_EDIT_BEAN, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ TransectFlightModel oldValue = (TransectFlightModel) evt.getOldValue();
+ if (oldValue != null) {
+ fireRoutesUpdated(oldValue, false);
+ }
+ TransectFlightModel newValue = (TransectFlightModel) evt.getNewValue();
+ if (newValue != null) {
+ fireRoutesUpdated(newValue, true);
+ }
+ }
+ });
}
}
@@ -407,6 +427,10 @@
// Highlighters
{
+ table.addHighlighter(SammoaUtil.newBackgroundColorHighlighter(
+ new RouteForSelectedTransectFlightHighlightPredicate(flightUIModel),
+ SammoaColors.OBSERVATION_FOR_ROUTE_ROW_COLOR)
+ );
table.addHighlighter(SammoaUtil.newForegroundColorHighlighter(
new RouteNoModificationHighlightPredicate(tableModel),
SammoaColors.ROUTE_NO_MODIFICATION_ROW_COLOR)
@@ -507,7 +531,7 @@
}
});
- // For highlighting depends on selected route
+ // Refresh matching observations from selected route
flightUIModel.addPropertyChangeListener(
FlightUIModel.PROPERTY_ROUTE_EDIT_BEAN,
new PropertyChangeListener() {
@@ -642,6 +666,7 @@
int circleBack = ObservationTableModel.ObservationColumn.CIRCLE_BACK.ordinal();
ButtonActionTableCellEditorRenderer editorRenderer = new ButtonActionTableCellEditorRenderer(
CircleBackAction.CLIENT_PROPERTY_OBSERVATION,
+ JButton.class,
new Supplier<Action>() {
@Override
@@ -768,30 +793,26 @@
FlightUIModel model = ui.getFlightUIModel();
- Iterable<Observation> observations =
- Observations.filterInRoute(model.getObservations(), route, model.getRoutes(), true);
+ Iterable<Observation> observations = Observations.filterInRoute(
+ model.getObservations(), route, model.getRoutes(), true);
- if (Iterables.isEmpty(observations)) {
- // nothing to do
+ SammoaUtil.fireTableRowsUpdated(ui.getObservationTable(),
+ model.getObservations(),
+ observations,
+ scrollToFirst);
+ }
- } else {
+ protected void fireRoutesUpdated(TransectFlightModel transectFlight, boolean scrollToFirst) {
- int firstIndex = -1;
- int lastIndex = -1;
- for (Observation observation : observations) {
- int index = model.indexOfObservations(observation);
- if (firstIndex == -1 || firstIndex > index) {
- firstIndex = index;
- }
- if (lastIndex == -1 || lastIndex < index) {
- lastIndex = index;
- }
- }
- ui.getObservationTableModel().fireTableRowsUpdated(firstIndex, lastIndex);
- if (scrollToFirst) {
- ui.getObservationTable().scrollRowToVisible(firstIndex);
- }
- }
+ FlightUIModel model = ui.getFlightUIModel();
+
+ Iterable<Route> routes = Iterables.filter(
+ model.getRoutes(), Routes.withTransectFlight(transectFlight.getSource()));
+
+ SammoaUtil.fireTableRowsUpdated(ui.getRouteTable(),
+ model.getRoutes(),
+ routes,
+ scrollToFirst);
}
protected void selectRouteByObservation(Observation observation) {
@@ -945,6 +966,38 @@
// }
// }
+ public static class RouteForSelectedTransectFlightHighlightPredicate extends AbstractRowHighlightPredicate {
+
+ protected FlightUIModel UIModel;
+
+ public RouteForSelectedTransectFlightHighlightPredicate(FlightUIModel UIModel) {
+ this.UIModel = UIModel;
+ }
+
+ @Override
+ protected boolean isHighlighted(int rowIndex) {
+
+ TransectFlightModel selectedTransectFlight = UIModel.getTransectFlightEditBean();
+
+ boolean result;
+ if (selectedTransectFlight != null) {
+
+ Route route = getValueAt(rowIndex);
+
+ result = selectedTransectFlight.getSource().equals(route.getTransectFlight());
+
+ } else {
+ result = false;
+ }
+ return result;
+ }
+
+ @Override
+ protected Route getValueAt(int rowIndex) {
+ return UIModel.getRoutes().get(rowIndex);
+ }
+ }
+
public static class ObservationForSelectedRouteHighlightPredicate extends AbstractRowHighlightPredicate {
protected FlightUIModel UIModel;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/ButtonActionTableCellEditorRenderer.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/ButtonActionTableCellEditorRenderer.java 2012-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/ButtonActionTableCellEditorRenderer.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -25,12 +25,16 @@
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
+import com.google.common.base.Throwables;
import com.google.common.collect.Maps;
-import javax.swing.*;
+import javax.swing.AbstractButton;
+import javax.swing.AbstractCellEditor;
+import javax.swing.Action;
+import javax.swing.JTable;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
-import java.awt.*;
+import java.awt.Component;
import java.util.Map;
/**
@@ -47,13 +51,17 @@
protected Predicate<Object> enabledPredicate;
- protected Map<Object, JButton> cache;
+ protected Map<Object, AbstractButton> cache;
+ protected Class<? extends AbstractButton> buttonClass;
+
public ButtonActionTableCellEditorRenderer(String actionPropertyName,
+ Class<? extends AbstractButton> buttonClass,
Supplier<Action> actionSupplier,
Predicate<Object> enabledPredicate) {
this.actionPropertyName = actionPropertyName;
+ this.buttonClass = buttonClass;
this.actionSupplier = actionSupplier;
this.enabledPredicate = enabledPredicate;
this.cache = Maps.newHashMap();
@@ -82,11 +90,17 @@
return result;
}
- protected JButton getButton(Object bean) {
- JButton result = cache.get(bean);
+ protected AbstractButton getButton(Object bean) {
+ AbstractButton result = cache.get(bean);
if (result == null) {
- result = new JButton();
+ try {
+ result = buttonClass.newInstance();
+ } catch (InstantiationException ex) {
+ throw Throwables.propagate(ex);
+ } catch (IllegalAccessException ex) {
+ throw Throwables.propagate(ex);
+ }
result.putClientProperty(actionPropertyName, bean);
result.setAction(actionSupplier.get());
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-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/SammoaUtil.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -25,11 +25,14 @@
package fr.ulr.sammoa.ui.swing.util;
import com.google.common.base.Joiner;
+import com.google.common.base.Predicates;
import com.google.common.base.Throwables;
+import com.google.common.collect.Iterables;
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.SwingUtil;
import org.apache.commons.beanutils.NestedNullException;
import org.apache.commons.beanutils.PropertyUtils;
+import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.decorator.Highlighter;
import org.nuiton.util.FileUtil;
@@ -45,6 +48,7 @@
import javax.swing.JTable;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
+import javax.swing.table.AbstractTableModel;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
@@ -67,10 +71,31 @@
// never instanciate util class
}
- public static void unselectAll(JTable table) {
- int size = table.getRowCount();
- if (size > 0) {
- table.removeRowSelectionInterval(0, size - 1);
+ public static <T> void fireTableRowsUpdated(JXTable table,
+ Iterable<T> references,
+ Iterable<T> updated,
+ boolean scrollToFirst) {
+
+ if (Iterables.isEmpty(updated)) {
+ // nothing to do
+
+ } else {
+
+ int firstIndex = -1;
+ int lastIndex = -1;
+ for (T element : updated) {
+ int index = Iterables.indexOf(references, Predicates.equalTo(element));
+ if (firstIndex == -1 || firstIndex > index) {
+ firstIndex = index;
+ }
+ if (lastIndex == -1 || lastIndex < index) {
+ lastIndex = index;
+ }
+ }
+ ((AbstractTableModel) table.getModel()).fireTableRowsUpdated(firstIndex, lastIndex);
+ if (scrollToFirst) {
+ table.scrollRowToVisible(firstIndex);
+ }
}
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/TableDataChangeListener.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/TableDataChangeListener.java 2012-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/TableDataChangeListener.java 2012-09-03 14:57:07 UTC (rev 510)
@@ -65,7 +65,8 @@
if (evt.getOldValue() == null) {
tableModel.fireTableDataChanged();
- // UPDATE : we use null newValue to fire update
+ // UPDATE : we use null newValue to fire update because no
+ // event is fired if the size is the same and all elements equals
} else if (evt.getNewValue() == null) {
int oldSize = ((Collection) evt.getOldValue()).size();
@@ -111,9 +112,10 @@
}
} else {
- tableModel.fireTableRowsInserted(rowIndex, rowIndex);
+ // use diff between size for multiple insert (addAll)
+ int diff = newSize - oldSize;
+ tableModel.fireTableRowsInserted(rowIndex, rowIndex + diff - 1);
-// int columnIndex = getFirstEditableColumn(rowIndex);
if (firstEditableColumn != NO_COLUMN_INDEX_TO_EDIT_ON_INSERT) {
table.changeSelection(rowIndex, firstEditableColumn, false, false);
table.editCellAt(rowIndex, firstEditableColumn);
@@ -130,7 +132,9 @@
}
} else {
- tableModel.fireTableRowsDeleted(rowIndex, rowIndex);
+ // use diff between size for multiple delete (removeAll)
+ int diff = oldSize - newSize;
+ tableModel.fireTableRowsDeleted(rowIndex, rowIndex + diff - 1);
}
// UPDATE
@@ -145,16 +149,4 @@
}
}
}
-//
-// protected int getFirstEditableColumn(int rowIndex) {
-// for (int columnIndex = 0; columnIndex < tableModel.getColumnCount(); columnIndex++) {
-//
-// boolean editable = tableModel.isCellEditable(rowIndex, columnIndex);
-//
-// if (editable) {
-// return columnIndex;
-// }
-// }
-// return NO_COLUMN_INDEX_TO_EDIT_ON_INSERT;
-// }
}
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-09-01 10:23:12 UTC (rev 509)
+++ trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties 2012-09-03 14:57:07 UTC (rev 510)
@@ -15,6 +15,7 @@
sammoa.action.configuration=Configuration
sammoa.action.configuration.tip=Configuration
sammoa.action.create=Create
+sammoa.action.deleteTransect.tip=Mark transect as deleted
sammoa.action.edit=Edit
sammoa.action.end=End
sammoa.action.end.tip=END \: end effort and create a new TRANSIT route
@@ -55,6 +56,7 @@
sammoa.action.validTransect=Transect
sammoa.action.validTransect.tip=Validate the selected transect and all its routes and observations
sammoa.action.validation=Validation
+sammoa.askQuestion.deleteTransect.message=
sammoa.config.category.applications=Application
sammoa.config.category.applications.description=Application
sammoa.config.category.gps=GPS
@@ -63,6 +65,7 @@
sammoa.config.category.other.description=Other
sammoa.config.category.shortcuts=Shortcuts
sammoa.config.category.shortcuts.description=List of all the shortcuts
+sammoa.confirmDialog.deleteTransect.message=The flight is not started, do you want to definetely delete this flight's transect ?
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
1
0
r509 - in trunk: . sammoa-application sammoa-persistence sammoa-ui-swing
by maven-release@users.forge.codelutin.com 01 Sep '12
by maven-release@users.forge.codelutin.com 01 Sep '12
01 Sep '12
Author: maven-release
Date: 2012-09-01 12:23:12 +0200 (Sat, 01 Sep 2012)
New Revision: 509
Url: http://forge.codelutin.com/repositories/revision/sammoa/509
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
trunk/pom.xml
trunk/sammoa-application/pom.xml
trunk/sammoa-persistence/pom.xml
trunk/sammoa-ui-swing/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-09-01 10:23:05 UTC (rev 508)
+++ trunk/pom.xml 2012-09-01 10:23:12 UTC (rev 509)
@@ -15,7 +15,7 @@
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.7</version>
+ <version>0.8-SNAPSHOT</version>
<modules>
<module>sammoa-persistence</module>
@@ -81,12 +81,12 @@
<!-- ************************************************************* -->
<scm>
- <url>http://svn.forge.codelutin.com/svn/sammoa/tags/sammoa-0.7</url>
+ <url>http://svn.forge.codelutin.com/svn/sammoa/trunk</url>
<connection>
- scm:svn:http://svn.forge.codelutin.com/svn/sammoa/tags/sammoa-0.7
+ scm:svn:http://svn.forge.codelutin.com/svn/sammoa/trunk
</connection>
<developerConnection>
- scm:svn:http://svn.forge.codelutin.com/svn/sammoa/tags/sammoa-0.7
+ scm:svn:http://svn.forge.codelutin.com/svn/sammoa/trunk
</developerConnection>
</scm>
Modified: trunk/sammoa-application/pom.xml
===================================================================
--- trunk/sammoa-application/pom.xml 2012-09-01 10:23:05 UTC (rev 508)
+++ trunk/sammoa-application/pom.xml 2012-09-01 10:23:12 UTC (rev 509)
@@ -9,7 +9,7 @@
<parent>
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.7</version>
+ <version>0.8-SNAPSHOT</version>
</parent>
<artifactId>sammoa-application</artifactId>
Modified: trunk/sammoa-persistence/pom.xml
===================================================================
--- trunk/sammoa-persistence/pom.xml 2012-09-01 10:23:05 UTC (rev 508)
+++ trunk/sammoa-persistence/pom.xml 2012-09-01 10:23:12 UTC (rev 509)
@@ -9,7 +9,7 @@
<parent>
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.7</version>
+ <version>0.8-SNAPSHOT</version>
</parent>
<artifactId>sammoa-persistence</artifactId>
Modified: trunk/sammoa-ui-swing/pom.xml
===================================================================
--- trunk/sammoa-ui-swing/pom.xml 2012-09-01 10:23:05 UTC (rev 508)
+++ trunk/sammoa-ui-swing/pom.xml 2012-09-01 10:23:12 UTC (rev 509)
@@ -9,7 +9,7 @@
<parent>
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.7</version>
+ <version>0.8-SNAPSHOT</version>
</parent>
<artifactId>sammoa-ui-swing</artifactId>
1
0
Author: maven-release
Date: 2012-09-01 12:23:05 +0200 (Sat, 01 Sep 2012)
New Revision: 508
Url: http://forge.codelutin.com/repositories/revision/sammoa/508
Log:
[maven-release-plugin] copy for tag sammoa-0.7
Added:
tags/sammoa-0.7/
1
0
r507 - in trunk: . sammoa-application sammoa-persistence sammoa-ui-swing
by maven-release@users.forge.codelutin.com 01 Sep '12
by maven-release@users.forge.codelutin.com 01 Sep '12
01 Sep '12
Author: maven-release
Date: 2012-09-01 12:22:57 +0200 (Sat, 01 Sep 2012)
New Revision: 507
Url: http://forge.codelutin.com/repositories/revision/sammoa/507
Log:
[maven-release-plugin] prepare release sammoa-0.7
Modified:
trunk/pom.xml
trunk/sammoa-application/pom.xml
trunk/sammoa-persistence/pom.xml
trunk/sammoa-ui-swing/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-09-01 10:13:55 UTC (rev 506)
+++ trunk/pom.xml 2012-09-01 10:22:57 UTC (rev 507)
@@ -15,7 +15,7 @@
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.7-SNAPSHOT</version>
+ <version>0.7</version>
<modules>
<module>sammoa-persistence</module>
@@ -81,12 +81,12 @@
<!-- ************************************************************* -->
<scm>
- <url>http://svn.forge.codelutin.com/svn/sammoa/trunk</url>
+ <url>http://svn.forge.codelutin.com/svn/sammoa/tags/sammoa-0.7</url>
<connection>
- scm:svn:http://svn.forge.codelutin.com/svn/sammoa/trunk
+ scm:svn:http://svn.forge.codelutin.com/svn/sammoa/tags/sammoa-0.7
</connection>
<developerConnection>
- scm:svn:http://svn.forge.codelutin.com/svn/sammoa/trunk
+ scm:svn:http://svn.forge.codelutin.com/svn/sammoa/tags/sammoa-0.7
</developerConnection>
</scm>
Modified: trunk/sammoa-application/pom.xml
===================================================================
--- trunk/sammoa-application/pom.xml 2012-09-01 10:13:55 UTC (rev 506)
+++ trunk/sammoa-application/pom.xml 2012-09-01 10:22:57 UTC (rev 507)
@@ -9,7 +9,7 @@
<parent>
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.7-SNAPSHOT</version>
+ <version>0.7</version>
</parent>
<artifactId>sammoa-application</artifactId>
Modified: trunk/sammoa-persistence/pom.xml
===================================================================
--- trunk/sammoa-persistence/pom.xml 2012-09-01 10:13:55 UTC (rev 506)
+++ trunk/sammoa-persistence/pom.xml 2012-09-01 10:22:57 UTC (rev 507)
@@ -9,7 +9,7 @@
<parent>
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.7-SNAPSHOT</version>
+ <version>0.7</version>
</parent>
<artifactId>sammoa-persistence</artifactId>
Modified: trunk/sammoa-ui-swing/pom.xml
===================================================================
--- trunk/sammoa-ui-swing/pom.xml 2012-09-01 10:13:55 UTC (rev 506)
+++ trunk/sammoa-ui-swing/pom.xml 2012-09-01 10:22:57 UTC (rev 507)
@@ -9,7 +9,7 @@
<parent>
<groupId>fr.ulr</groupId>
<artifactId>sammoa</artifactId>
- <version>0.7-SNAPSHOT</version>
+ <version>0.7</version>
</parent>
<artifactId>sammoa-ui-swing</artifactId>
1
0
r506 - in trunk: sammoa-application/src/test/java/fr/ulr/sammoa/application sammoa-persistence sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/application sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/application sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util
by fdesbois@users.forge.codelutin.com 01 Sep '12
by fdesbois@users.forge.codelutin.com 01 Sep '12
01 Sep '12
Author: fdesbois
Date: 2012-09-01 12:13:55 +0200 (Sat, 01 Sep 2012)
New Revision: 506
Url: http://forge.codelutin.com/repositories/revision/sammoa/506
Log:
improve dependencies and add missing license headers
Modified:
trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/SammoaConfigMock.java
trunk/sammoa-persistence/pom.xml
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Dates.java
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Position.java
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Validables.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/application/ImportApplicationUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/application/ExportApplicationUIHandler.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/SelectionModelAdapter.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/TableSelectionListener.java
Modified: trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/SammoaConfigMock.java
===================================================================
--- trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/SammoaConfigMock.java 2012-09-01 09:51:38 UTC (rev 505)
+++ trunk/sammoa-application/src/test/java/fr/ulr/sammoa/application/SammoaConfigMock.java 2012-09-01 10:13:55 UTC (rev 506)
@@ -1,5 +1,29 @@
package fr.ulr.sammoa.application;
+/*
+ * #%L
+ * SAMMOA :: Application
+ * $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%
+ */
+
/**
* Created: 30/08/12
*
Modified: trunk/sammoa-persistence/pom.xml
===================================================================
--- trunk/sammoa-persistence/pom.xml 2012-09-01 09:51:38 UTC (rev 505)
+++ trunk/sammoa-persistence/pom.xml 2012-09-01 10:13:55 UTC (rev 506)
@@ -52,6 +52,11 @@
</dependency>
<dependency>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>nuiton-i18n</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
Modified: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Dates.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Dates.java 2012-09-01 09:51:38 UTC (rev 505)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Dates.java 2012-09-01 10:13:55 UTC (rev 506)
@@ -1,5 +1,29 @@
package fr.ulr.sammoa.persistence;
+/*
+ * #%L
+ * SAMMOA :: Persistence
+ * $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 org.joda.time.DateTime;
import org.joda.time.Interval;
Modified: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Position.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Position.java 2012-09-01 09:51:38 UTC (rev 505)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Position.java 2012-09-01 10:13:55 UTC (rev 506)
@@ -1,5 +1,29 @@
package fr.ulr.sammoa.persistence;
+/*
+ * #%L
+ * SAMMOA :: Persistence
+ * $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 static org.nuiton.i18n.I18n.n_;
/**
Modified: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Validables.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Validables.java 2012-09-01 09:51:38 UTC (rev 505)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Validables.java 2012-09-01 10:13:55 UTC (rev 506)
@@ -1,5 +1,29 @@
package fr.ulr.sammoa.persistence;
+/*
+ * #%L
+ * SAMMOA :: Persistence
+ * $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 com.google.common.base.Predicate;
import org.nuiton.validator.bean.list.BeanListValidator;
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/application/ImportApplicationUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/application/ImportApplicationUIHandler.java 2012-09-01 09:51:38 UTC (rev 505)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/input/application/ImportApplicationUIHandler.java 2012-09-01 10:13:55 UTC (rev 506)
@@ -23,6 +23,7 @@
* #L%
*/
+import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import fr.ulr.sammoa.application.FlightService;
import fr.ulr.sammoa.application.ReferentialService;
@@ -42,7 +43,6 @@
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.ErrorDialogUI;
import jaxx.runtime.swing.editor.FileEditor;
-import org.apache.commons.lang.StringUtils;
import org.nuiton.util.FileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -390,7 +390,7 @@
// validate that backup filename not empty and does not exist
// in backup directory
String backupFilename = model.getBackupFilename();
- if (StringUtils.isBlank(backupFilename)) {
+ if (Strings.isNullOrEmpty(backupFilename)) {
valid = false;
} else {
File backupFile = getBackupFile(backupFilename);
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/application/ExportApplicationUIHandler.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/application/ExportApplicationUIHandler.java 2012-09-01 09:51:38 UTC (rev 505)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/io/output/application/ExportApplicationUIHandler.java 2012-09-01 10:13:55 UTC (rev 506)
@@ -23,6 +23,7 @@
* #L%
*/
+import com.google.common.base.Strings;
import fr.ulr.sammoa.application.FlightService;
import fr.ulr.sammoa.application.ReferentialService;
import fr.ulr.sammoa.application.SammoaConfig;
@@ -40,7 +41,6 @@
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.ErrorDialogUI;
import jaxx.runtime.swing.renderer.DecoratorListCellRenderer;
-import org.apache.commons.lang.StringUtils;
import org.nuiton.util.FileUtil;
import org.nuiton.util.decorator.Decorator;
import org.slf4j.Logger;
@@ -342,7 +342,7 @@
// validate that backup filename not empty and does not exist
// in backup directory
String backupFilename = model.getBackupFilename();
- if (StringUtils.isBlank(backupFilename)) {
+ if (Strings.isNullOrEmpty(backupFilename)) {
valid = false;
} else {
File backupFile = getBackupFile(backupFilename);
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/SelectionModelAdapter.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/SelectionModelAdapter.java 2012-09-01 09:51:38 UTC (rev 505)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/SelectionModelAdapter.java 2012-09-01 10:13:55 UTC (rev 506)
@@ -1,5 +1,29 @@
package fr.ulr.sammoa.ui.swing.util;
+/*
+ * #%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 java.util.List;
/**
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/TableSelectionListener.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/TableSelectionListener.java 2012-09-01 09:51:38 UTC (rev 505)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/TableSelectionListener.java 2012-09-01 10:13:55 UTC (rev 506)
@@ -1,5 +1,29 @@
package fr.ulr.sammoa.ui.swing.util;
+/*
+ * #%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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
1
0