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
September 2012
- 4 participants
- 111 discussions
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
r505 - in trunk: sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map src/site/rst
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 11:51:38 +0200 (Sat, 01 Sep 2012)
New Revision: 505
Url: http://forge.codelutin.com/repositories/revision/sammoa/505
Log:
fixes #1451 : update import doc
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/StrateImportModel.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/TransectImportModel.java
trunk/src/site/rst/import-export.rst
trunk/src/site/rst/index.rst
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/StrateImportModel.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/StrateImportModel.java 2012-09-01 09:51:22 UTC (rev 504)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/StrateImportModel.java 2012-09-01 09:51:38 UTC (rev 505)
@@ -30,39 +30,49 @@
import org.nuiton.util.csv.ext.AbstractImportModel;
/**
+ * <pre>
+ * - colonne 0 : "Nom" : Nom de la strate (strate.name) C,50
+ * - colonne 1 : "type_strat" : Type de la strate (strate.strateType) N,4,0
+ *
+ * * C : COAST (Côte)
+ * * N : NERITIC (Néritique)
+ * * P : SLOPE (Pente)
+ * * O : OCEANIC (Océanique)
+ *
+ * - colonne 2 : "Secteur" : Nom du secteur (strate.sector.name) C,12
+ * - colonne 3 : "ID_Secteur" : Numéro du secteur (strate.sector.sectorNumber) N,4,0
+ * - colonne 4 : "Area" : Surface de la strate (non utilisé pour le moment) N,19,11
+ * - colonne 5 : "Shape_Leng" : Longueur sur le fichier shape (non utilisé pour le moment) N,19,11
+ * - colonne 6 : "Shape_Area" : Surface sur le fichier shape (non utilisé pour le moment) N,19,11
+ * </pre>
+ *
* Created: 25/07/12
*
* @author fdesbois <desbois(a)codelutin.com>
*/
public class StrateImportModel extends AbstractImportModel<Strate> {
- // 0 : Nom
- // 1 : Area (not used)
- // 2 : Shape_Leng (not used)
- // 3 : Shape_Area (not used)
- // 4 : Secteur (name)
- // 5 : type_strat (string) for StrateType (code match)
- // 6 : ID_Secteur (double)
+
public StrateImportModel() {
super(';');
newMandatoryColumn("Nom", Strate.PROPERTY_NAME);
+ newMandatoryColumn("type_strat",
+ Strate.PROPERTY_STRATE_TYPE,
+ new StrateTypeValueParser()
+ );
newMandatoryColumn("Secteur",
Strate.PROPERTY_SECTOR
+ "." + Sector.PROPERTY_NAME
);
- newMandatoryColumn("type_strat",
- Strate.PROPERTY_STRATE_TYPE,
- new StrateTypeValueParser()
- );
newMandatoryColumn("ID_Secteur",
Strate.PROPERTY_SECTOR
+ "." + Sector.PROPERTY_SECTOR_NUMBER,
new DoubleToIntegerValueParser()
);
newIgnoredColumn("Area");
+ newIgnoredColumn("Shape_Leng");
newIgnoredColumn("Shape_Area");
- newIgnoredColumn("Shape_Leng");
}
@Override
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/TransectImportModel.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/TransectImportModel.java 2012-09-01 09:51:22 UTC (rev 504)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/input/map/TransectImportModel.java 2012-09-01 09:51:38 UTC (rev 505)
@@ -33,24 +33,30 @@
import org.nuiton.util.csv.ext.AbstractImportModel;
/**
+ * <pre>
+ * - colonne 0 : "TR_ID" : Identifiant et nom du transect (transect.name)
+ * - colonne 1 : "Xstart" : Coordonnée X de début du transect (transect.startX)
+ * - colonne 2 : "Ystart" : Coordonnée Y de début du transect (transect.startY)
+ * - colonne 3 : "Xend" : Coordonnée X de fin du transect (transect.endX)
+ * - colonne 4 : "Yend" : Coordonnée Y de fin du transect (transect.endY)
+ * - colonne 5 : "Length" : longueur du transect (transect.length)
+ * - colonne 6 : "Passage" : Numéro de passage (transect.nbTimes)
+ * - colonne 7 : "SECTEUR" : Numéro du secteur (transect.strate.sector.sectorNumber)
+ * - colonne 8 : "STRATE" : Type de strate (transect.strate.strateType)
+ *
+ * * C : COAST (Côte)
+ * * N : NERITIC (Néritique)
+ * * P : SLOPE (Pente)
+ * * O : OCEANIC (Océanique)
+ *
+ * </pre>
+ *
* Created: 25/07/12
*
* @author fdesbois <desbois(a)codelutin.com>
*/
public class TransectImportModel extends AbstractImportModel<Transect> {
- // 0 : Length
- // 1 : TR_ID used as name
- // 2 : Xstart
- // 3 : Ystart
- // 4 : Xend
- // 5 : Yend
- // 6 : Passage (double) used for nbTimes
- // 7 : SECTEUR (double) use as sectorNumber
- // 8 : STRATE (string) for StrateType (code match)
- // 9 : Shape_Leng (not used)
-
-
public TransectImportModel() {
super(';');
newMandatoryColumn("Length",
@@ -89,7 +95,6 @@
Transect.PROPERTY_NB_TIMES,
new DoubleToIntegerValueParser()
);
- newIgnoredColumn("Shape_Leng");
}
@Override
Modified: trunk/src/site/rst/import-export.rst
===================================================================
--- trunk/src/site/rst/import-export.rst 2012-09-01 09:51:22 UTC (rev 504)
+++ trunk/src/site/rst/import-export.rst 2012-09-01 09:51:38 UTC (rev 505)
@@ -43,6 +43,7 @@
A noter que ce sont des rôles de station de travail, une seule même machine physique peut avoir tous ces différents rôles.
.. image:: ulr-sammoa-echange-data.svg
+ :scale: 20%
TODO explications supplémentaires sur les étapes
@@ -73,28 +74,28 @@
+++++++++++++++++++++++
- colonne 0 : "Nom" : Nom de la strate (strate.name) C,50
-- colonne 1 : "Area" : Surface de la strate (non utilisé pour le moment) N,19,11
-- colonne 2 : "Shape_Leng" : Longueur sur le fichier shape (non utilisé pour le moment) N,19,11
-- colonne 3 : "Shape_Area" : Surface sur le fichier shape (non utilisé pour le moment) N,19,11
-- colonne 4 : "Secteur" : Nom du secteur (strate.sector.name) C,12
-- colonne 5 : "type_strat" : Type de la strate (strate.strateType) N,4,0
+- colonne 1 : "type_strat" : Type de la strate (strate.strateType) N,4,0
* C : COAST (Côte)
* N : NERITIC (Néritique)
* P : SLOPE (Pente)
* O : OCEANIC (Océanique)
-- colonne 6 : "ID_Secteur" : Numéro du secteur (strate.sector.sectorNumber) N,4,0
+- colonne 2 : "Secteur" : Nom du secteur (strate.sector.name) C,12
+- colonne 3 : "ID_Secteur" : Numéro du secteur (strate.sector.sectorNumber) N,4,0
+- colonne 4 : "Area" : Surface de la strate (non utilisé pour le moment) N,19,11
+- colonne 5 : "Shape_Leng" : Longueur sur le fichier shape (non utilisé pour le moment) N,19,11
+- colonne 6 : "Shape_Area" : Surface sur le fichier shape (non utilisé pour le moment) N,19,11
Fichier de transect (dbf)
+++++++++++++++++++++++++
-- colonne 0 : "Length" : longueur du transect (transect.length)
-- colonne 1 : "TR_ID" : Identifiant et nom du transect (transect.name)
-- colonne 2 : "Xstart" : Coordonnée X de début du transect (transect.startX)
-- colonne 3 : "Ystart" : Coordonnée Y de début du transect (transect.startY)
-- colonne 4 : "Xend" : Coordonnée X de fin du transect (transect.endX)
-- colonne 5 : "Yend" : Coordonnée Y de fin du transect (transect.endY)
+- colonne 0 : "TR_ID" : Identifiant et nom du transect (transect.name)
+- colonne 1 : "Xstart" : Coordonnée X de début du transect (transect.startX)
+- colonne 2 : "Ystart" : Coordonnée Y de début du transect (transect.startY)
+- colonne 3 : "Xend" : Coordonnée X de fin du transect (transect.endX)
+- colonne 4 : "Yend" : Coordonnée Y de fin du transect (transect.endY)
+- colonne 5 : "Length" : longueur du transect (transect.length)
- colonne 6 : "Passage" : Numéro de passage (transect.nbTimes)
- colonne 7 : "SECTEUR" : Numéro du secteur (transect.strate.sector.sectorNumber)
- colonne 8 : "STRATE" : Type de strate (transect.strate.strateType)
@@ -104,8 +105,6 @@
* P : SLOPE (Pente)
* O : OCEANIC (Océanique)
-- colonne 9 : "Shape_Leng" : longueur sur le fichier shape (non utilisé pour le moment)
-
Sauvegarde des fichiers
+++++++++++++++++++++++
Modified: trunk/src/site/rst/index.rst
===================================================================
--- trunk/src/site/rst/index.rst 2012-09-01 09:51:22 UTC (rev 504)
+++ trunk/src/site/rst/index.rst 2012-09-01 09:51:38 UTC (rev 505)
@@ -67,7 +67,7 @@
Premiers pas
------------
-Version 0.5
+Version 0.7
~~~~~~~~~~~
1. Une fois l'application démarré, il faut créer une nouvelle campagne via le bouton "New" à côté de la
@@ -91,6 +91,7 @@
<import-export.html#observateurs-csv>`_
5. Une fois la campagne prête, vous pouvez créer un nouveau vol depuis la page d'accueil avec le bouton "On Board".
+ L'application propose un numéro de vol, mais vous pouvez le modifier si vous le souhaitez.
L'écran principal s'affiche, vous pouvez désormais préparer le plan de vol avec les transects et les observateurs.
6. Une fois le plan de vol préparé, vous pouvez lancer le vol via le bouton START
1
0
01 Sep '12
Author: fdesbois
Date: 2012-09-01 11:51:22 +0200 (Sat, 01 Sep 2012)
New Revision: 504
Url: http://forge.codelutin.com/repositories/revision/sammoa/504
Log:
fixes #1417 :
- improve validations
- add validation for transect
- disable delete for the moment
Added:
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Validables.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/util/SelectionModelAdapter.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/TableSelectionListener.java
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ValidationService.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapService.java
trunk/sammoa-persistence/pom.xml
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/AutoSaveListener.java
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Observations.java
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Routes.java
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/TransectFlights.java
trunk/sammoa-persistence/src/main/xmi/sammoa.zargo
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/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/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/TransectFlightModel.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/DeletedRowHighlightPredicate.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/java/fr/ulr/sammoa/ui/swing/util/ValidRowHighlightPredicate.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/ValidationService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ValidationService.java 2012-09-01 09:51:00 UTC (rev 503)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/ValidationService.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -24,7 +24,6 @@
*/
import fr.ulr.sammoa.persistence.Flight;
-import fr.ulr.sammoa.persistence.FlightDAO;
import fr.ulr.sammoa.persistence.Observation;
import fr.ulr.sammoa.persistence.ObservationDAO;
import fr.ulr.sammoa.persistence.Observations;
@@ -47,46 +46,47 @@
*/
public class ValidationService extends SammoaServiceSupport {
- public void validateTransect(Flight flight,
- TransectFlight transectFlight) {
+ public TransectFlight validateTransectFlight(Flight flight,
+ TransectFlight transectFlight) {
TopiaContext tx = beginTransaction();
try {
TransectFlightDAO transectFlightDAO = SammoaDAOHelper.getTransectFlightDAO(tx);
- TransectFlight transectFlightExists = transectFlightDAO.findByTopiaId(transectFlight.getTopiaId());
+ TransectFlight result = transectFlightDAO.findByTopiaId(transectFlight.getTopiaId());
boolean valid = !transectFlight.isValid();
- if (transectFlightExists.isDeleted()) {
+ if (transectFlight.isDeleted()) {
- ObserverPositionDAO observerPositionDAO = SammoaDAOHelper.getObserverPositionDAO(tx);
- observerPositionDAO.deleteAll(transectFlightExists.getObserverPosition());
+// 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);
- 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);
-
} else {
RouteDAO routeDAO = SammoaDAOHelper.getRouteDAO(tx);
- List<Route> routes = routeDAO.findAllByTransectFlight(transectFlightExists);
+ List<Route> routes = routeDAO.findAllByTransectFlight(result);
for (Route route : routes) {
validateRoute(tx, route, valid);
}
- transectFlightExists.setValid(valid);
- transectFlightDAO.update(transectFlightExists);
+ result.setValid(valid);
+ transectFlightDAO.update(result);
}
tx.commitTransaction();
transectFlight.setValid(valid);
+ return result;
} catch (TopiaException ex) {
throw new TopiaRuntimeException(ex);
@@ -95,21 +95,22 @@
}
}
- public void validateRoute(Route route) {
+ public Route validateRoute(Route route) {
TopiaContext tx = beginTransaction();
try {
RouteDAO routeDAO = SammoaDAOHelper.getRouteDAO(tx);
- Route routeExists = routeDAO.findByTopiaId(route.getTopiaId());
+ Route result = routeDAO.findByTopiaId(route.getTopiaId());
boolean valid = !route.isValid();
- validateRoute(tx, routeExists, valid);
+ validateRoute(tx, result, valid);
tx.commitTransaction();
route.setValid(valid);
+ return result;
} catch (TopiaException ex) {
throw new TopiaRuntimeException(ex);
@@ -118,22 +119,23 @@
}
}
- public void validateObservation(Observation observation) {
+ public Observation validateObservation(Observation observation) {
TopiaContext tx = beginTransaction();
try {
ObservationDAO dao = SammoaDAOHelper.getObservationDAO(tx);
- Observation observationExists =
+ Observation result =
dao.findByTopiaId(observation.getTopiaId());
boolean valid = !observation.isValid();
- validateObservation(tx, observationExists, valid);
+ validateObservation(tx, result, valid);
tx.commitTransaction();
observation.setValid(valid);
+ return result;
} catch (TopiaException ex) {
throw new TopiaRuntimeException(ex);
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapService.java 2012-09-01 09:51:00 UTC (rev 503)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapService.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -238,9 +238,9 @@
effortGroup = null;
}
- boolean routeIsValid = Routes.isRouteAccepted(route,
- routeTypes,
- strates);
+ boolean routeIsValid = Routes.isAccepted(route,
+ routeTypes,
+ strates);
if (routeIsValid) {
@@ -475,7 +475,7 @@
routeObservations.size()}
);
}
- if (!Routes.isRouteAccepted(route, routeTypes, strates)) {
+ if (!Routes.isAccepted(route, routeTypes, strates)) {
// not selected route
continue;
Modified: trunk/sammoa-persistence/pom.xml
===================================================================
--- trunk/sammoa-persistence/pom.xml 2012-09-01 09:51:00 UTC (rev 503)
+++ trunk/sammoa-persistence/pom.xml 2012-09-01 09:51:22 UTC (rev 504)
@@ -47,6 +47,11 @@
</dependency>
<dependency>
+ <groupId>org.nuiton</groupId>
+ <artifactId>nuiton-validator</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
Modified: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/AutoSaveListener.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/AutoSaveListener.java 2012-09-01 09:51:00 UTC (rev 503)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/AutoSaveListener.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -133,6 +133,11 @@
public synchronized void stop() {
stop = true;
commit();
+ if (logger.isWarnEnabled() && !changedEntities.isEmpty() || !createdEntities.isEmpty()) {
+ logger.warn("Some entities are removed from autoSave but unsaved, check log for errors");
+ }
+ changedEntities.clear();
+ createdEntities.clear();
}
protected class AutoCommit extends TimerTask {
Modified: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Observations.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Observations.java 2012-09-01 09:51:00 UTC (rev 503)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Observations.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -30,6 +30,7 @@
import com.google.common.collect.Iterables;
import org.apache.commons.collections.CollectionUtils;
import org.joda.time.Interval;
+import org.nuiton.validator.bean.list.BeanListValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,6 +63,11 @@
return Iterables.filter(observations, inRoute(route, routes, ignoreDeleted));
}
+ public static boolean isValid(Observation observation,
+ BeanListValidator<Observation> validator) {
+ return Validables.isValid(observation, validator);
+ }
+
public static boolean inRoute(Observation observation,
Route route,
Iterable<Route> routes,
@@ -104,26 +110,6 @@
return new InRoutePredicate(route, routes, ignoreDeleted);
}
-// public static boolean inDateInterval(Observation observation, Interval interval) {
-//
-// boolean result = Dates.inInterval(observation.getObservationTime(), interval);
-//
-//// Date thruDate = periodDate.getThruDate();
-////
-//// boolean result;
-//// if (thruDate == null) {
-//// result = periodDate.afterBegin(observation.getObservationTime());
-//// } else {
-//// result = periodDate.between(observation.getObservationTime())
-//// && !thruDate.equals(observation.getObservationTime());
-//// }
-// return result;
-// }
-
- public static Predicate<Observation> inDateInterval(Interval interval) {
- return new InDateIntervalPredicate(interval);
- }
-
public static void removeOtherSpecies(List<Observation> observations,
List<Species> species) {
if (CollectionUtils.isNotEmpty(species)) {
@@ -176,6 +162,14 @@
return result;
}
+ public static Predicate<Observation> inDateInterval(Interval interval) {
+ return new InDateIntervalPredicate(interval);
+ }
+
+ public static Predicate<Observation> isValid(BeanListValidator<Observation> validator) {
+ return new IsValidPredicate(validator);
+ }
+
private static Function<Observation, Date> TO_DATE_FUNCTION = new Function<Observation, Date>() {
@Override
@@ -223,4 +217,19 @@
}
}
+ private static class IsValidPredicate implements Predicate<Observation> {
+
+ protected BeanListValidator<Observation> validator;
+
+ public IsValidPredicate(BeanListValidator<Observation> validator) {
+ Preconditions.checkNotNull(validator);
+ this.validator = validator;
+ }
+
+ @Override
+ public boolean apply(Observation input) {
+ return isValid(input, validator);
+ }
+ }
+
}
Modified: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Routes.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Routes.java 2012-09-01 09:51:00 UTC (rev 503)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Routes.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -29,11 +29,13 @@
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.ComparisonChain;
+import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables;
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.nuiton.validator.bean.list.BeanListValidator;
import java.util.Comparator;
import java.util.Date;
@@ -71,9 +73,9 @@
return result;
}
- public static boolean isRouteAccepted(Route route,
- List<RouteType> routeTypes,
- List<Strate> strates) {
+ public static boolean isAccepted(Route route,
+ List<RouteType> routeTypes,
+ List<Strate> strates) {
boolean result = false;
if (CollectionUtils.isEmpty(routeTypes) ||
@@ -91,8 +93,45 @@
return result;
}
+ public static boolean isValid(Route route,
+ BeanListValidator<Route> routeValidator,
+ BeanListValidator<Observation> observationValidator) {
+
+ boolean result;
+ if (route.isDeleted()) {
+ result = true;
+
+ } else {
+
+ Set<Route> routes = routeValidator.getBeans();
+
+ result = Validables.isValid(route, routeValidator)
+ && !Routes.equal(route, Routes.findPrevious(routes, route));
+
+ if (result) {
+
+ // Check validity of observations
+ result = FluentIterable
+ .from(observationValidator.getBeans())
+ .filter(Observations.inRoute(route, routes, true))
+ .allMatch(Observations.isValid(observationValidator));
+ }
+ }
+ return result;
+ }
+
public static boolean equal(Route o1, Route o2) {
+ if (o1 == null && o2 != null) {
+ return false;
+ }
+ if (o2 == null && o1 != null) {
+ return false;
+ }
+ if (o1 == null) {
+ return true;
+ }
+
boolean result = Objects.equal(o1.getRouteType(), o2.getRouteType());
// We assume that time equality for a same routeType is an equivalence
@@ -165,18 +204,22 @@
Observation observation,
boolean ignoreDeleted) {
- return Iterables.find(routes, new WithObservationPredicate(observation, routes, ignoreDeleted), null);
+ return Iterables.find(routes, withObservation(routes, observation, ignoreDeleted));
}
-// public static Date getMiddleTime(Route previousRoute, Route nextRoute) {
-// Date previousTime = previousRoute.getBeginTime();
-// Date nextTime = nextRoute.getBeginTime();
-//
-// long diff = nextTime.getTime() - previousTime.getTime();
-// Date result = new Date(nextTime.getTime() - diff / 2);
-// return result;
-// }
+ public static boolean withTransectFlight(Route route, TransectFlight transectFlight) {
+ return transectFlight.equals(route.getTransectFlight());
+ }
+ public static Predicate<Route> withTransectFlight(TransectFlight transectFlight) {
+ return new WithTransectFlightPredicate(transectFlight);
+ }
+
+ public static Predicate<Route> isValid(BeanListValidator<Route> validator,
+ BeanListValidator<Observation> obsValidator) {
+ return new IsValidPredicate(validator, obsValidator);
+ }
+
public static Predicate<Route> isDeleted() {
return IS_DELETED_PREDICATE;
}
@@ -185,6 +228,12 @@
return BY_DATE_COMPARATOR;
}
+ public static Predicate<Route> withObservation(Iterable<Route> routes,
+ Observation observation,
+ boolean ignoreDeleted) {
+ return new WithObservationPredicate(observation, routes, ignoreDeleted);
+ }
+
private static Comparator<Route> BY_DATE_COMPARATOR = new Comparator<Route>() {
@Override
@@ -238,6 +287,41 @@
}
}
+ private static class WithTransectFlightPredicate implements Predicate<Route> {
+
+ protected TransectFlight transectFlight;
+
+ public WithTransectFlightPredicate(TransectFlight transectFlight) {
+ Preconditions.checkNotNull(transectFlight);
+ this.transectFlight = transectFlight;
+ }
+
+ @Override
+ public boolean apply(Route input) {
+ return withTransectFlight(input, transectFlight);
+ }
+ }
+
+ private static class IsValidPredicate implements Predicate<Route> {
+
+ protected BeanListValidator<Route> validator;
+
+ protected BeanListValidator<Observation> obsValidator;
+
+ private IsValidPredicate(BeanListValidator<Route> validator,
+ BeanListValidator<Observation> obsValidator) {
+ Preconditions.checkNotNull(validator);
+ Preconditions.checkNotNull(obsValidator);
+ this.validator = validator;
+ this.obsValidator = obsValidator;
+ }
+
+ @Override
+ public boolean apply(Route input) {
+ return isValid(input, validator, obsValidator);
+ }
+ }
+
private static <T> T getNext(Iterable<T> elements,
final T element,
final Comparator<T> comparator) {
Modified: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/TransectFlights.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/TransectFlights.java 2012-09-01 09:51:00 UTC (rev 503)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/TransectFlights.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -26,7 +26,9 @@
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
+import com.google.common.collect.FluentIterable;
import com.google.common.collect.Sets;
+import org.nuiton.validator.bean.list.BeanListValidator;
import java.util.Set;
@@ -51,6 +53,22 @@
return result;
}
+ public static boolean isValid(TransectFlight transectFlight,
+ BeanListValidator<Route> routeValidator,
+ BeanListValidator<Observation> observationValidator) {
+
+ boolean result = transectFlight.isValid() || transectFlight.isDeleted();
+
+ if (!result) {
+
+ // Check validity of routes
+ result = FluentIterable.from(routeValidator.getBeans())
+ .filter(Routes.withTransectFlight(transectFlight))
+ .allMatch(Routes.isValid(routeValidator, observationValidator));
+ }
+ return result;
+ }
+
public static Predicate<TransectFlight> isNotDeleted() {
return Predicates.not(isDeleted());
}
Added: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Validables.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Validables.java (rev 0)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Validables.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -0,0 +1,41 @@
+package fr.ulr.sammoa.persistence;
+
+import com.google.common.base.Predicate;
+import org.nuiton.validator.bean.list.BeanListValidator;
+
+/**
+ * Created: 31/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public final class Validables {
+
+ private Validables() {
+ // static class do not have instanciation
+ }
+
+ public static <E extends Validable> boolean isValid(E bean, BeanListValidator<E> validator) {
+ return bean.isValid()
+ || bean.isDeleted()
+ || validator.getContext(bean).isValid();
+ }
+
+ public static <E extends Validable> Predicate<E> isValid(BeanListValidator<E> validator) {
+ return new IsValidPredicate<E>(validator);
+ }
+
+ private static class IsValidPredicate<E extends Validable> implements Predicate<E> {
+
+ protected BeanListValidator<E> validator;
+
+ private IsValidPredicate(BeanListValidator<E> validator) {
+ this.validator = validator;
+ }
+
+ @Override
+ public boolean apply(E input) {
+ return isValid(input, validator);
+ }
+ }
+
+}
Property changes on: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Validables.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/sammoa-persistence/src/main/xmi/sammoa.zargo
===================================================================
--- trunk/sammoa-persistence/src/main/xmi/sammoa.zargo 2012-09-01 09:51:00 UTC (rev 503)
+++ trunk/sammoa-persistence/src/main/xmi/sammoa.zargo 2012-09-01 09:51:22 UTC (rev 504)
@@ -1,9 +1,7 @@
-PKhiAsammoa.argo�TK��0�ﯰr��l�B��.�bϕO���8��zƱ�8}����JQ5��y�̔\7��@T�*{�Uw��Bծ��rK�G�ζJ����,#e��(Ot�#T���weq�'���)c�(��+
+PK(�Asammoa.argo�TK��0�ﯰr��l�B��.�bϕO���8��zƱ�8}����JQ5��y�̔\7��@T�*{�Uw��Bծ��rK�G�ζJ����,#e��(Ot�#T���weq�'���)c�(��+
X�}c��^N�q�������)��V�7J
_���\(�9��@�PJ�= ����j�V�����N���%�C�H�N��I����L<�'9�h���R���Vh��I�Ijì�`O���A4��^�I��*p�����G[N�i�P�=
-�V�Ch��(`�5��18��!F��NݹU�'��nP5eq&��/�����<��-�����휈3F��@ o4�|T���jIm�&o�g&���v�e���*�����LJ��OO+FM݆4F
-�2j�-J�☆��y��E�uT�Ge�y��g��}䞽~nh:�B�ӝ�7�_���3
-V��M�w��d����o�zm�j�4�s�%�Ts�m�����}I�gi�q{�qi�����Xҳ��^[7L��2���ճ-��wc�UY%�]<�q��d�h�����G<1�hx����7PK��DH�PKhiAsammoa_Diagrammedeclasses.pgml�]m��6���_�*{B� &����s�c����m��R�k�����[���w�;��H��lR�D��nR�D���F���t����q6�.��h���p�
+�V�Ch��(`�5��18��!F��NݹU�'��nP5eq&��/�����<��-�����휈3F��@ o4�|T���jIm�Q��j��tFh`��ہۖ�����ӷ�~�?=e�5t�7X�g�ʨ �(!��~��Uf(��Q���繟����{�������O�" �I~y"^�(XeJ7�߂����"��/굡~��Ӑ;�i�<�S1�U�!�k���%q#��]`���ǥ��Z��cI��zmQ�0��|Hr�W϶��ލ-oTe�P/t�HǑ*����c��?��(��z���PK/UgH�PK(�Asammoa_Diagrammedeclasses.pgml�]m��6���_�*{B� &����s�c����m��R�k�����[���w�;��H��lR�D��nR�D���F���t����q6�.��h���p�
��(O����rw��=����^�������}�<=�>�����σg�.ƫ�3~E��8\�ӧU�h�p1\<Dk~Q��x:|X/���j:�m�Z�G��"�XO/~����l�\^o���������sB�y��\/&s���q���<��A��W϶�z��������w��5/��i{������X�)�~�=��9��S��#��O��N���Y�j2�-���pF�oO�_������p1�����B�����j��ޯW��u:�/�p��[���!��l�"�y͢ūg�q�����g>���P�a������p�{�����O����*���{鏛��h5�?�B�\����W�8��?}�/w��?����uw�| �_V|�(��2���i�3On0�~;�U��J8���Sm�H8A�j�v��=�#6}?��d�̢��w��p6�z������h6V������3���z��N���f9]�s.��_�-��%�/����B�.ˋ�Q��ܬ����Z�?�/J�,J/��?��O�����U��L/�ཽ�^"/(mImU���%K�&�&)���w���fn�x��~�NU]k�ٚ����?�
�Y��Uh^��+��_f�����շ�<�?����}�4_��T�u�L�����L�Z���֔��\.�-�*z|.V�����������*����.J�a��/�UXs=�kR�]��`�h�vyNV�n���0�����AT)F�q ����.�{�V_8��њJwK��b��ip��o8�q��Kg��
x��]��
@@ -93,85 +91,83 @@
K�n�Z�߶K�nĚ���䘘F�}��ie������ #�O�c�G�!2
�3H�σ��� ͵G�Y皣�b֤�
TjH��9�9��*5�c����4P���us��
-Tj�y��7G;�@�"���Ѣ�)�j_�����}�cd�N��#���8{���PK+����*֡PKhiA&sammoa_Diagrammedecasdutilisation.pgmlMN=o�0��+�7�ٵAuM 0�1Q�d`���aY"qd'U~|������ݻw��Os'���m�q ���P�G��l7��eޕ���l:�\/��D`$���c�:����|�L�d�8m�n�����Xu��"����1���4TrR*�����M��9U�����o�� �n��gV��I�������л��z�Y��:��d�PKǒV9�PKhiAsammoa_Diagrammedeclasses2.pgml��o�8��_���t'�)�1/]өחӤ�VݺI�4�(qRn$D@��t����@Jwi�N�8���<��1��1��;F^0髠��
-����������KUޜ��r�����Յ2�/|����⽢��� ��Frc@"7��q�Z�zN8
-f��x�(tƽ(vb��;�Ù�Bқy�O�ߝ�N�����y�����0d{hX�G��iG����)�g�I_M��-�e��H��� �u<
-��4�x鍴��M��$&|EP�W2�����oS'���EލO�CǏ��(&! �)�����:���a�4*Vt�8�nf1)����
-ɐ����uzj�=ߧ����¾z��$�A-���$�|�;�wv�$�}<
-�;'&��a�r^7v&#�ps��g�G_���]=�+ddW�� ���t���[�n㾪���dW�Y�U�F)�ajIL~�|�A�à�a��a�:��V����ʺZU>&q��2/v|�����e�7�?(�6#�_6b0+�g���s�99gdB]|~�䯀:��!�Z:�e�zy;ʊΉ��s������I���}�߸�;aE���y�����:I���I٩����UtȲKV9��-W&�\or����y��Xf
-�@Gf��7���j�jX�����F�+����쇖z�ë��?
-OqH�@l�D�c�<4�#�<�j�8�(wl5�|jZ>C�u�Eo[N��,O�0ӱ�J����s�,uc�M�їE��2wnZ2���QDs3�V��}�S�k�0L�D��e��hGŇ|��BE3�*T踂
-]�
-��%�Z�ׅ��4�nK���K95(i�f ����%(J(T诠�tS��O��>�D$�K�4�(Н�B�����d���2
-�2
--.��Εɠ�����Z�"�ډ(PQ�
-�X��"�[C=MX��n��J�VI(\*�K(P�P�.+(���^&:UPl��6�.f��2�an&����a\E�D`4Ȩ���x�M#�Q����]������֪����Et�JG������,����E���¦Y谠����Ϯ��Cgщ����Mb
-v&��4dj
-/?�j��j
-
-j���z!�%;����joƋ�j��`AO�"�(�P^"��nEPIY�Ƭ��ST�U�
-q{��a���
-U
-=�3)��3�������P�h�3)˒�1�Њ�So�*6t\�H7p�N�r��t����퓚�z5�N��0O�u�j�DN��^�s9�*�J>�CǴ,N��{��)T<���a,t�;����s�ء��$�Pw�R1�X���˖�6�H.��x,��0�-�S!��s��f촐��Bų�b<����7�m��!����&瞄�L� ��p";�9�*U���}Y8Y�7o����y0�d'�_S�h��O�IM i�j/�\'�qC��qY�.6���gi�`��*c���UԼ���mk�ߣe��Cq�[�������9bJ�z��h1��g�?�[M�
-�|E�}K۽�6����y�6iϮ�$۲��� ;�N�D2ʫ��L��p�5V���]بsN\��j/�!5�wJ/�7����&�2�ǻqpG�E6h �gQ\x��IZ�A �����%l���mhc[kɶ�H���m4P�!���l�
-�Z����Ͷ!�pclÖl�G�m�2ۂ_.>bې�m�P&�4�����k�m�����7���6X�͐5�mH�0�Yz)#?Ba/v9�l����f��v�����D`��殤�?�f��������m(;y%C�.n<�'�̊�۹���5�H�����5�%�:n�^��#2F��DbD~���q����4�t�N�D|w��!F� Uq���)&�ۚ�� �d!\�{�@��d���dtC��l�"�W�fm���>�o:�Ѻ�����e�%���I���:)2&�֒Ѷl�m�톣�F�k��Vd��e�ϖ�
-��Rdta_�m[v�k������\����po�ܺ!��wm�{E����t/?�\�nkE��&;�5�:�1D��M�Fc�d�PKe����VPKhiAsammoa.todoeO�j�0<�_��.YnkW6�M��{��Xk#P�ERL?�5%Ѕeg��aV�/�,`�ƙ�H�3��Tz���ٝ�HɾI����Н?�ģBҞ���J�H��*%a%�u�|��
+Tj�y��7G;�@�"����ƷL�T��>ɱ/]��r�}ɿzx�����PK:�&s�*ѡPK)�A&sammoa_Diagrammedecasdutilisation.pgmlMN=o�0��+�7�ٵAuM 0�1Q�d`���aY"qd'U~|������ݻw��Os'���m�q ���P�G��l7��eޕ���l:�\/��D`$���c�:����|�L�d�8m�n�����Xu��"����1���4TrR*�����M��9U�����o�� �n��gV��I�������л��z�Y��:��d�PKǒV9�PK)�Asammoa_Diagrammedeclasses2.pgml��o�8��_���t'�)6�������i�v�nݤi�N�ʍ�����$�@RJ[��6U1�����>�'&�on��tE��gC
+Y�3'��3o(�8�3e��h���_�O��7|������$���Md��\��؉�9KZ#o`G^��J�5�m/������w��Y�p�"���?����q`��ɲ�{���=]�H�Mt�T�Z�n�6:�3E9P�yGJ��=�Cy�֔B�$��Nc �;#�u�E�b��x�{Jzk{��Ą�*Vv%U�w%�Ю����6�����8�C�b�:f4�!����>�*��9�l��q���X���ʳ�^Fԅ������̬�h�p�A
+��K���X~���˒U�q`;���Qr�p�W6������,��g^@sc1�F�f(�7ӳ[8S���ڟ�ˡ>NK.��]����iIɮ:��������%�ް|�Q�è�a��a�:��V�����ÒĻZU�3�h$���gv�;C9 ��p�Ro3����i�?������K��������p�߶r`Y~��iK .�1�Q�oć���b�J���k����0NUC�0Z�U��n嬴S�<ȽW1 �!Y��D�2��z�+,����Ʋ��ud���f��Zi5Z�T[����*`��J}v�ʃ3xD���pԐ��D*&b#S�����Rs���y�૭�$]�����l���r��.�eS�q8����/��ܾ���2K�Ϻ�8ڦ�c�d��KnXҀ��^���h����٬
+R�
+��J��H_U��SŇl����fU�T�DP�F*T�)=E��RL����R�Ҭ3�u�O�B%�jF(M$�GF(TD(��_��4C��ONP�1���+M���(5�(���rr�9F!���i~h��>P)��/��P ������E�o�z��R�nҍ�P%�V!�*F�G(TB��&�U&(L�پ'�蔠��K,.�Ћ2277+�&Na�T)�G�h����t�"��r��{Qd�h�`�Ԙ�.v'�R�'���[�8
+8
+��R���E�H�(tX )q���Ed�b賀��S�3��aHi�lޔj#���h*�� Bz�)��jo�O��)\�RF�J�Jz�x�OT=�,u>�&㔁J�jQ��5}0��@�@U���({R�I����(�,U��n�'e�=EL�Y�>0���b��Я*6�,��������}ZS\OS�h�ŔG��QGA�jWE��S�RK�RY�ȳ�4�,!M��LSj��>���2M��gWυ�>C�B� ������V�#�m�6z�9H�O��:_˪��H�O��5�Y���NL�XJ-�M��1Q���-kV�j[l��̝��Z�t�5/�t">�W�!xg;>�CJ��DېN�6�qvϞ<���.˒�'����I�dP��I��q��������9�����Z�oG6ko���1��vx�.8�|���"r�y1�c�K@`�_�Q��>(�3�������_�f�Õw8�ATM!μ�W�|$_"[Vmp�9���=�)�g��wޮM���G�
+�o.��Ѩ���d���&��S>h�Ӌ�Ƚ���0WG�G]0}p�p�yܶd����,�M�+�B��4��]}М���X��m���
+�&=���i��6����s���Fm#M�F۰��Nۤ��Ʀ`n��s|��~gm�=���i��6���������V�V�6�Զ�wm���ңI��w�6y�`��?PKɟ���FAPK)�Asammoa.todoeO�j�0<�_��.YnkW6�M��{��Xk#P�ERL?�5%Ѕeg��aV�/�,`�ƙ�H�3��Tz���ٝ�HɾI����Н?�ģBҞ���J�H��*%a%�u�|��
���,���\�l�v�
-l�:�L�A;��Nx�{�i7�����D�7��=�l5�^8�0�@h�@���h^PZ���ˢ����CYV�j*8�5���ӓ��LB�l�)�?�~�$?PKP����KPKhiAsammoa_profile.profile�����Q(K-*���S�UP2�3PRH�K�O��K ����Z()��qq��e��qqr�䔦g恘���>
+l�:�L�A;��Nx�{�i7�����D�7��=�l5�^8�0�@h�@���h^PZ���ˢ����CYV�j*8�5���ӓ��LB�l�)�?�~�$?PKP����KPK)�Asammoa_profile.profile�����Q(K-*���S�UP2�3PRH�K�O��K ����Z()��qq��e��qqr�䔦g恘���>
�z& Q}�0�
-�����������b<��SR�S�R�K�����+�,EȂ9PK8��7y�PKhiA
-sammoa.xmi�]ݖ�8r�ߧ���cϜl�%��${�s��N'�w���jD�j�)RCR=�^�5r��L����IP�Z�@�(�G��%d�P��P(T}��癫<� t|O����h>W�g���M�?��\u�+?����{{�|�9�Ts�9����?�}C��ißM���f8�#7ȏϕ�!#4��vŖ�_L����/Z���2��+j��>�E��k<`d�����>[���a/B���Z��?�� "m��ԧ�|��;���#/T(�
-�d���m���:՛u˟��_5m�[�;%��NH�'w��E�%�y�l]�Z���P�/Z��O仦��[���B����;S������>~��'�k��0�oaWI���oȻ~�9.���о�~��ӊ� ?Mߋ�}W�$]_�]�α�!U;W�+�*WWF��KƦm��mtۨ���l6_47���?_�D�r�f3=W��n�M�v��U�O6rCL���Q�7�O_����I��h�%���R���ak����
-���~{�{�����*�w�����rۡ�uq���C������? q�w����|�����7�n ��40^響��p���}�~��u��k1:R�N���ܷ|���;����;-��Sda���2C怜�0�
-���]8s4Ŋ,GA��@ М���
-���(�`�e����� ;�/)_��%������_G��s{d�<�A��0e�߿���S����7��Ϧ�K���Wl�dH�SLҀ�����ye9�^�)��ȭW��?������=�E��p@�hď���t�d) C���C�AL�?��l�K�lK�L4ߣ3%R�]��r��H�_��N��p+�����b��b�,9��G�U,j����r�%�ܯ��H��tx �� �����0���.қ̯�^s��b> �l���ED��K���������b:�_������6�� �/e�w1]b>�?����l|�8��-�!> o�POe��p���I��F2��?,�.���^�<Q�z��^~$,��?�NĂ�~2s�T��(��S��R�"@Dd��wȟ.1�1 j�E8l(���[�V���̍f�i�Y�T�c���'w��O��vH�B�>�t N��Z(���F �L�8���m�F�C�4-U렞�"l4�ʍj?e^!Ť�d9� �7�П�cD~'���ꢼ���!w����C�Zs�-5����x`�X�C��$�d~���^�=��&��۳Z�n�֙���u��7h��:�1�K�0�SLfM����ꎻ�[�߾�ݺ��#��`Iϑz'��,y�$awd�a��'����zӆK���n���ͲᱬlS�ɞ��a���O��\���!��w㿖���������m���=Ӧ0���Y6&F���~��2��U��%���f�D�~���V�`!?VC�8hؘ�O�3F�E�C�}�Z�R���z=��8��N�����F�ÿ�=W�Й8d�b�?_L\��1�"ypg���6d
-!�V�2c�=�<��%��P0���}v��b�],L�6��,�ט-�șr��Y��F�cY:`��|T#�/�՜��#m,�L�L.����T魟+��<��A+�e^j�5s,����̳ȡF(B������h��������
-?�^����%�5���][�F�����GD�A��ض�l�e���e��\g#�~�8�M!.p|����u������~��#����w����ܗ�Vu?�o_�s9�m�6Ey���%��l6�\����UJ��&�b��t�/l�ֿ�
-��_�u����$���u)�4.e���dM���{�s���#i��3�7��<>���KA(way����2����.����q��?s���0�M'� ���I��i.>�7^��'y��}gV�g����?� ��[�oz9�����qh:
-�t}S��8�
-�K$s՛fZc���,��hۓ��t�M��3�e)c�8��0W�GJ Y�[Hr�����Xߘ�H�V�1ۣ�s�N�Lճ���x��l�m<d.Ahc}��Z�jR���lն2���^յ�m��6�:����S�k��������8�8�w{�R�n���(b�p����gqne�V\% N �[�\��9ѡ�۔�c�݃-��-vSv[���\`�Ud�VV[l|�N��e:EΏ��n�1v��1�y��CeT�_�O��ۘeU�7��A�W�7�`��+ⳮ��S���Q$�aF��[|�<&\�q�]3�#�����l�|ats�t'Pljh�b'�����Γ�q�1��S�\L��d�������\�6h2���7�Ϊ����Q=<h��yr9z��N�M��q˰q���u����aq�����X�<�"4uhざy���Xcf���6>�SD�ʽ�h̔�N��l�$�yA�n��SH��Z��U��Yc;u����WH
-'�-&r^�<��yP��>�t
-|�ȸ���5���nfB���.7k�|�Z�Ff<�= /A#��C�<���/N#wO��U�̕qk��G��뮊ٹ�`I,����\̚X�>Xou�y���d@���e�ʪ�w
/E�ֵ�W�u0����p�\�N`�x��OC���.)=�[K ���0�UI���.�I�.5�\[}(��7���Z��I�R��9d�8^��3+N�X�,��ˍ��@H�q���s���M�0�о7�3}��BͬM/!=M�$Ly�{T�[���d4a�l�t��Reҏq���ʾ�P�Kv���gT�����
-���e�T`��Mѓ�_�V�ml��6���D�^��e�>n�E��/��٭UjeXZL�IQ��M�+��s��\5j�H�c�Z�{�7��B0 rͭ�f����b6�P�Z��)'��&�.
-*[�:_@��!= 8�"�1n<��pdg�D�0�?,{��aE���pF�ŭ4?�S�#�)��u��A��-��`CZN(P�+�
-�gH��Ur PŶ�����j�jW7P��������e#f���,�'�b3Z��_�ϧ\08�|����E`ό�
-��Er�:��u�������c��( �p���I�chg�{�L��x���\�Z�͙>��'N�?�Z�����f����D�ٲt���ѥ!r�e�����S%�(%��4P<�i
-f�)<��9�(V2�?m���@yNoq��(�k����+�V+��Q�VkuԮ�A�N��[�P�yu����Z����qRxx2�J�@�Um2�=6�~Ւ�����$�]jX��2(#����M����6��_����T���B����eZ��_i��O�ƒntt�X&�N��b� �c�g��*�].g�P:\�Mf^��I�_a��SfX`4<�[N˟��o���a��[�"|�vg�H�k��C�^\���f�������ޙAD�S��-���h!��ƮT<BN@0`ƨ$@���ԉ��OK�>c7���uy8p��B��\��2� dYj� 27��HP/$_N��93ױ7.@�<-&O��b��.
-�!�cHv �ЂN0�'�R�w:�5{M{�[����KйF����v�� �c�FA�Ces�v�I*^�>��I���Ò#���u�#<ǞE�� x�4^�1Uװ�ƻ�=
-��V������,���9,�d����Γm���Ӟg�{Pٷ!�S2�F�x�D�j�S/1n^�4+�-fa"N�KR*k��q�q�6 ᠈��0g��G4�ѐ�
-͑���N�`�[w�?`�B��z�Q�`�I��C�z���"{?+�}o�H���j���eߤ ��"7S3�Hq���k���9ա�G �ZpS3�@)n��Y�>HƜ�@d��0Y�[@�)�������5�q됻Y���F��Ԯ\1����&A�C���ʁH`"���2-&z@�>�Hu��5 ,nY�����2�,�&�8}P�!���@�[¸�0�wB�Ay���E�a�C���so������#r8�(�P��'��E�uy0Po{��h醪��81�DŸm1����� B�8�Sϒ,-&�P�@#Lu�,�$�fwC�'�5˚Q��L`�Tjǡi���,��^�א]fHAr]�¨�R�zݎfKEf����e�fc���;yu�x����1��8p�8�]@H���ch����1�`�9r�N ������7ÂO����T�"�x3<C� �ς�̈́�p�T�c�D�*naK�7�;0�-����P�2ա��KB��B��ƚ�=��Z��mn���q}�;��g1qg��A�Y�Cea�,�t;K��]�~�dP�l.���a��,��1�����PA��
-���9�TÕJ��XLAc��� 1��xOB��sX��ZL-�Ȓ8��Nu�q�Rq����XN�_�@����HQ#��.�$,�&3�%�E<��7�ƂA�y=�.�W$~�o��XZ�Q L ��u��O mx���J�U���Zv��EW�tP�R-v�/n�22����/y�}�U�� \������g.�����!�uA��{����=fJ�`��qc��( ,�p��I�#������0������Y-�X���3�֍7��x 3�|�Ϲ�j��9�&3�S]�d��'ϑ{�Y#��>��}��Y6��p�.k@<5`r��L�<�T&�aC������c��N�U���̀����G��B�)� �<C�Ɂ'A $�Ku��"3�
-=��y���d�G���L��FRU A������O.��9ա��gq�eZ�h��R��z�sj�`P'0���-�G��8a:�dxZL=q���^���X��c�v��?�9�(N�[Lu��B�:����8>2�=+�_�O}X�E�0{����A�,��2��kH����@�K�����.�.�8Xڌ�:!Fw:���#�VL%
-q���F�C���=A����q���=�{m�\�unt��E�ɳI�_?0��jA!�B�A�C�C��En��
-��GK^#���\��;
-��7� F�;���Q��kA���AdA�C���b�\:���&�g2<5J̴��uyPPg�@8a67*�m?��-fpȱ��J���AF�T�:C��7�y�l�����?��f
-�@���r�3�$�.*�<(Ij�A{'iF� w،|(�[�t����:��Pm�kv�mE����x��(��bj��5�R*�3Ķ���������7e�Y�?I�@p(�:�8 U<��#T�::�Ű������Lu�l��iגm���=Ӧ���Y6;e�ND�z)I�˟n���ג��݈0 �-d�Y��8}���Pc�Q\&��#i~�{�HI�S�G�>�͓�Pc ޝp�9�dvH���Іp�9�p����4�s�Y�S�C�>(Ƒ�Pc�H��=�>��[� g �s�Ce}�B�`��I�@]zԵ�Y=M��b��҄�f�ǘ�Z��@�>p�:��,� �Ѷu�TB @�;�%�f9����$N�k�dEXo.G�A��
-�[^�'����ף�*
-�c�}�j`K\��U�k�B@�4?�1r%+7ա�*.�Jnp~��b�H�R���?���eg10 N�@�C5��Ҭ{w�%�qO䀞ټ��o�Fkj�W�k�j!��I��7���pR�7�=�{e�Y��=Hh��PM'��Z��j[T(ڦ�k�I�)#�y{��P@��� � ΄�:��
-�w��̻ ���G��� 6zS��[�{��?�f!N T�Hu�B�/rE����hQ��Bx��@f
-�
-kP@���Ė *b�:���#�(�1�3�(8&� աޑ1�;��Mor���V?(�h1�����A�C�s�4l ԋ�
-��nG�̬Bcv����h������?Ȱ� 4�� ա�emN*'�{`G��C�n\g� 0�u���S̹�o��`�g2Dm�«�Q�����mS6�4l6[�6[E*KfN���i{XpI�z� �
-�o����ףVX�z��3fʈ��������8���}��K�ױ��^�����l����E�q�7��O�{�X�%4/3�{�У�o���Ed,9�!is�en�'�`B�dz|>9��ђk
-����u�M�>��j�a��Ϲ�j��Ɔ���96��l�?:N�#3��4F1>}��d|�M�&ܲ�O�h�3�>�ooz`�$ ���E��Ŝ����:��]!*�W���u,�S��sXnИA��0p��:7�-Y���@���d���ݦ:T�8T:m�jMp,Z�0
-S��
-��P �*�H�ɑ">4ev��Ğf^?��^����R��aZ;���@�����G
-�k�jUww��t�~�����Z;�l̴DK���? >6� )��(�lkmMU-ʉ��n�&Scobs�;����n�|"�u��(>*���K������� �\�m��aB0!;{�vu���Z����E���?g�_<?z�C�t8�+���[��L6�Àn�Ul=l�bC������L;P>1�;"S���X8p�)�j�ş��z�N<]���=�6w�(S���V�Q�bv�$�DPz����[DW��I%k� pE���rz�;�2�ݜ}!�X=��eɑ ���)�,9F*�1�$!�,����&���iy�f ݞh:���m��v[E,��2v<����ߜ�w#L`;�a�����<�M�.��K1 ���LvCf�
-�)�Gfr*����bJt��'v�"�}�:�_�nc��c�B�^��e3�f'�A��/�7gf��K^��<*�@�0}b��^e���M9�/q�`*�_5��ϫ���d�M=4�cO�^�)h�掇��JX��[̽v�¢nfaFke]'��o3�@^Z��zX$��������
-b�7:���U�2�r�_3���"�_ߔ]g�#��ƶ�.��L��Uc�w5��?r4(�~�F03���Q���/N�.6S��!6�Lz�Wv=,V��p���N��yD]]�{ݘ͝�f�=��8i�z1U���<�D/̼D_'5��
-�a}}�S�rG{�.%y}�k�)s%nep�^��t� '�ςJ^�%/S�/c�=�s�bw��=�N���ZСq��
-\
-��LZ.��:P�R�����@f�'z]�$e7��P��7�Au;9�e�fY��(�X(`�C<���`Ȳ��{O*3(�.��db,�@��Ŕ�� �ɤ:T�ȿ���Rsg�:�!�͑3��Z�01��a��`~� A Ӎ�\��0��L�SrJ��$�ϲ����NJu�[�x���G�k�9�S�X�@(L��?TЕ��#��@ ��bRJX�T�G���T�X&t��4
-������f�D�0��44��k1q�`}��P��ħu+W�V3�(M\R��5���fӶ&V�e�1,�n"�k��k���
-�9���fE�ĉ�Y/&�Y\*ba��L�x�n9͊�E�:;>hz��A,���U��
-�fs�����-��L[R�d�����[!&#co1Kޑq>���\�X�ˇÙ���\�~0�ޖ�py�% ���� �E�t3f�F�7ˆG2���zw��Û1�%�:
-��0����rd.o/�w�`+H���[�3�W��gg�,����P}c�S%��$.��de�<�]��V\��93P�p�&%w�������d0�Á���v�ߝN�7AF�atu�ƭ�Ff�Ɋ*a�W?��-,�肎̈(����d��~Y���q
-��E���j9�ᕎ��ê�a[����i�l�:mv���E�)NL5���x �����Gx�={旆�:�9�9
-�F�轄l��@�z��md����lrV��$�'fc'(��E� cA�s�3�r�0듦��UJt�B�j[�&�Z#��҅y��#��X쏰��噫"�k0G2��9�3�i�Se����,�K���K(V���sU>
-gpC��=�~�b���)��0L�^?!8�|��K���"�6�߆��Q�r�c�؏�k��zt��a"kq��_>$m��̚|ɐ���8��\\Z�͙/���<A?�Z�ĭ�ٓPjt�]�3�m���K][6�5�w�/��gQ~��QCd�Q���N�3��K�VG���
-Εb�9/犑y��g�:��{%�%U���� c6���<�Nf:XP�vA������F��^Gm���6�Ɲ�E���:D��:gtQ��� ����N'\re��Y�P ���e
-���{ W�4��D%������DS7�k��O�S���6A���M�O���YO)�#"y�ߧҷާ1A!^f+��d���J�Vq���o��fk��t�m�sr8֮�Y�9�jrFs�SDq�E�g�ۻ)��I�H�f��S�gW�C<_�/F�-Y�3
-0G&���vBL|+�"���$����9�Ȕ-����]b?��/������%�<��H!�C�)D���5��=e�.Bz3GV���&�s|с܋�ED�ӟ�G��_J��'"���!@��i�r���oEy�������bpu
-#-���^:R��T�����kF�������6���(��6��sy��j�O��3rG�_{�����'7�w3��5R�X��=�����~��a�]
-�����i������6p���րۙ����ooo�1��=����PKH.�?�"��PKhiA��DH�sammoa.argoPKhiA+����*֡�sammoa_Diagrammedeclasses.pgmlPKhiAǒV9�&�-sammoa_Diagrammedecasdutilisation.pgmlPKhiAe����V�.sammoa_Diagrammedeclasses2.pgmlPKhiAP����K27sammoa.todoPKhiA8��7y�O8sammoa_profile.profilePKhiAH.�?�"��
-9sammoa.xmiPK�\
\ No newline at end of file
+�����������b<��SR�S�R�K�����+�,EȂ9PK8��7y�PK)�A
+sammoa.xmi�]ݖ�8r�ߧ���cϜl�E��({�s$�������{f7Ws TsM����*���\fr�g��$O�բB�����ݒ�X(|U(������S�p����Ey�6�/�[���c��O��K�7��o�o����i��$�y~�����7A8n�q�6��GSd�����c�&S��:t��l��TE5_5�WjW���j/��AQ����8|�(��v`�&؏QL(������� �I�^8(1��"��8a�G
+%���K�,_���w�_fz�n����f����N �a[!w����+Jt�^���i���+UW��|�T�}�V�������wʟ��3��'����ẍ́� &�l�))��
+y�oV��/ߨ
+���7�;-���
+���wqK������\;R�sѼ �rq�nb��6�شڸ��R_]��f�Us�2����(I�.�h2 �Kō��r�J^��� /����Ag�x������n�Eq�����Q�/p����7�CO�o�l4&�����\�V��(��Џ��.}��#�|�]�0R�hD��Q�ç�s��j���7+�_���|? ��x���������{����btd����=�o���w����
+�)� ��Ɗ�1e��uY�ap%7_�u�N�+A8e�B%DS
+d,>+���3��1h�u0�$������L�쉒���1���|��8�J��w�Q2g�O&�cFJS�����|��~7|�b�V�M~ŎC��;�"
+�������K�E��ۈ�z���c����!���o}�E#yD��У37"ӘHI����]�
+�~��eu\�֡$п�D�=�c"�P��%y++�E�t�u�)脘�b��+6Z��%6ɜ�Xy
+<Ŧ���I/Oq=����_O�H�G�L�@o����P#�я0я�,$���J�5
+)�#�϶��>�Ŵ��ұTȸ)�� O��q0�,���������sAHn�-C�Rvr�#��c������w��A���
+���c��z�(+��Cd$,%ڐA�\�a.t�����V��_gA��#a����p$����Ǣx(G�O�B%��""�O�K����Q�/�QC��/d�B��'�o�4,��
+ߢz+����
+-�C�2��S"��L!�7J�e���-/�i�BBX�ikzu�,®��ܨ�2�R,�K�1�pxU�y>F�w�>��.�[|\r�om<��!�5��\c����M!!���A?�ax�b�}@�'�h��uZ��a!:�][m�]�`�nVץ8'l̼�%�Ɣ.-��N1�5]Fj��;�n�~��vˆC����9={�讲��Y���P͢C,o���g�M�f o��f�w�����N�*{>�?}r�ry2R<Ro�-�W\"�~9K[��ͮ�P���#��m� W���|����
+�U��9�m�f�D�^����`!?QC�8l8��O�sF�ǡK�}�Z��L���]��86�Nw����F�ǿ��T����d��?��<��1�"yxo��6d
+#�V���=�<��#��Q8���}6��`�}�,�6�]��ט̼؝r��Y�R�J�}Y�g��|T#�/�ל��#m�/�L�L//���T�_*��4��A/e^j�5s,/w���L�ȡ�P�H�qa�=�����%�`6�A8�$k �%K�K�_��A�����'D�A��X��l����y��\g#�v�8�M!.p|����m���c �u���H��xw��˻��C)hն�����?����XjS����VR��Va������/;M�RZl[⦣~fk��5WP�2̨���*��oKAd�\?�N�T�O|��8��]>���K1��C������͠�r����>�����<2��ޭ?8�{QX�A&��_'}ý����^y��ck�Y�����3���7�M�~G^�r�61t3?��m���x���~�s�\�H�7˴��1Y&OѺ'=��H�Z�g\�R��q)a�P����/���7&�w|U�oL�����$Grw�ش:���(6�䪞��G�ƃ�e��h�s!�X@����E}B6r4�����U���J��q�Snmܻb
+Bz-�qsE_�[(N��ݞ:E��p6���\�"��I�[�W�����֥�.{�t���6����{�`���.�-��yH/��*�^+�-6<_���<�"��ءYr�nl̯^����P��n�
+��'V�m̲*�����+�kf0H��IW��G�Ϩ_3#���[|�<&\�p͝3�#��O��l�|at}
+�l'Pǩhc'�����Γ�a�1��S�^L�8g�������o2���7�N���-�Q=�o�yr>z����C�±�v���ى�z�b��8�L�Hz�a,�!�"4uh㾞{���Xgf���6>�SD�˽���̔�N��l$�yA�n��RH���Z�U��Yc;u����WH
+'�-&r^�<��yP��>�t|8˸��z5��637�u������%�����O`O�s��Ť�&O,�h����1��j���2"�aT�U~rź�bv.=X*`q>�&��k�j�'.:l9mƁ����p�s���um�U{0,%$�"�Z�#����KJ���-'<�gUҤ��mұK���V�
+%�
+�<��/bR���o�?��W���̊�'2+�r��1�~�&#����y�{8r����]�Ps+D�KHO�/ S����>���(MX9�,�̬L��}\,Wye_D��$;���r*@����yċR*0Hϧ�Y���Rkn[���l"��1M���[�(�Bȝ��P�V��Ť��o�d��ҫ<��NU�v��,PkpO��@�H�\sk�9����MF*V��#��2�����Ae+VzfHO
+�d��s���L�C8�sP�~���=W�"nj�B8���r+͏��� v��i��y��<�O_�P�3pݨ����L��6�4KՒ�&�M
+@P ��r��k��F�n��F��s�]1�$�@@f��[������~>���~����
+�X�o���V�m��a?v��աN��6�����G��+7E!aP�C�t}H��;@���bB�σ�O�o����Ԓn��Y6>r��9��T��<��0#V�&^Ζ���nd�.
+q�7��j�.K <6Pr�R"��%�㉦`nQ���Q<���b%����@�Q��O����~�r����,�Ri����i5���v%;�:Vul����|��^[\����~Rxxr�J�@�Um2zlr��%7��72G�I���m��ڦ�05[w��h1�mt���eo�G;�8K��˵V���J��%��1���;]��:��:3�&�Uz3_���2�ܼF%������*4���ixo9��ľ�j�u.�I��ڍ�O*!oq�!pw��
+;zq�g�G���z�n+�w 2L�S�P�>f����R��>3F%/��n<��xZ���V��Á��*���%� H ��vɑ w3�^��B��t��3s{����b�J(��������M1�dr-��8�p�)ӡ�H�p��U���m:#�V[:s/���R:����Hp��@�<0
+2*����LR9�r���F�vK�P`�/�%�]�)�m�����i��-�����j��{W�%0��_[Hc��iR��{,�y��g����1%�k�'.��繽cJ$�ͫ��D���,���B�Ce���n(�� �H�)Ҡ�� �Y��Dd:@�A���uN�`���?`KA��F�Q��<ő^��6��E�>S
+6�z��$�bi1U����=VI/@�sEne4��f���� mr�C���jQ�M�l���YL�dq� Ir� � nT�h~�n%�xZ��m*�t�1�[��͂�7wr�
+H���I Nld:��) ����p8 ��b����L�[�2��K�>q ��bj%���2�at���� |� ���h�]�pf:��?��Y�^)<!υ�r�K~q�[�^���.ڪ��4��$�i�l�q��!7�����4�$K��"� �3*�%�tin`H��.��!�eY3]�����%p\���R,�{
+i2C
+���F�אFW�;1",UCV����e�fc
+�F�-�|�r<Պ�a��n��8K�. ��YZ�14a�`���0мp�N ���c�T4g��O����L�"�x3<A� �ς�̈́�p�L�c�D�(n�I/��71�-���Px2ӡ��KB��"��º��#5�6�Uv��7�l�zĝI3q� �,ӡ�0P�<������.� rw2(66��{ϰ�|��m��\V(���ƌ��Ja�X�@~a��l ���pK����[�ZeL-�(�8���t�q&Qq���s�n���@���sH���.J$,�&3�$�܇���Ƃ��<�^�u��?'·
+�l�,-�(&��L�ʺm�ߑAB+�g���q�j�L��P�0�Q��f���q�������9�;�^y�H���������,�o�~�_g�\q���H/!�`�t���W�n�B¢�����s�ڹ:<��|6r}{�%��ts�в�x/aN���9��T��<���f{�בΖ���rd��l�ň=Ƨ�p�e|�M�&ܼ��
+�\�*0w>- �����O��<��亩����l91`rGF��tő�`����t��F���䦓 ��e:T}�y��]��y���d�������FRU A������O��9ӡ��gq�eZ�h�;R�����c�`P'0�|�-lG��6a:�dxZLy;q���]������da���x�?�9P(N�'�tH���:����89�1|;�_�OIX�E�0{��A�,��2��KH����B�K[���}.���8�ی��F�1��D�#�^L�q���E�C���5B��4ZI��32�-�\
+nt��C!�ɷwIQ_?0��jA!�B�A�C�C��En�
+��GK^����^��w�CnhA��� ���(�ׂ"��ȂL�z��ł�t���uL
+dx�.90�Q���AA���D����q�0��MF�,�ckA���L��u�ao2���2���A�Sa��0S��m�̐��:? ���$)�����)��c+�,n�ө�a�RB�� �;-��/�%�
+ƣ<[���'N���t����v�~v8B
+>�Ĕ�g1�$ ����P�T�D��Pk��b���Z2ӡ��'�]K��]ˡ�G���;e�FD�r)I�˟n���ג��݈��-d�Y��8}���Pc�Q\&��#i����U�$S�)�#N���t�1�N���=2��yZ�th8ܜ�8@d�[�c�)��,O���!N��t�1H$��m���-愳�p�9ӡ�>e!Dh��Q��LzԵ��]]s�b��҄�&�ǘ�Z��@�>pd:��,� �Ѷe�TB @�;�%�f9����$N�lodEXn.��N��
+�[^�'�����*�[C�}�j`K\���ɵr!�R��������PMw�Jnp~���b�H�2���?���eg10 N�@�C5��Ҭ{7���@䀞�<�����v�Z�WӴ��V���a�{���pR�.7�=�{e�Y��]Hh��PM'��U���l*-�0tu�a
+��<���q�( ��b��HgB2�fq���K�]�
+p@�����J����i�}P@��U�'�Yd:
+P�������Hq��pa!<�p 7݊5( ��b
+bK�3j���\�Ș�[p��P���Z?zp'�d
+��s��Mq�`� ӡ�U��&g������63�А]��9s�>�֍o�π2l-
+��4�t�fY�#�ʉ�ؐ��P�k�?�̭�u=|�s�K���SL�Ϸ�6G���(�y��4Cǎ�)�:��j��V�m�sc[H;�8�;Nh���7�6�v�u������ ��&R#��n�� ��ȥ��I��W�镣)�=~���ˊ,[�o��{��ǿ�?]�m
+.���|�E�>~DOn��ZS���@뇴;C��ٝS� Q>�"����JK��^����ƫ(����^?ǀL�s)J�Z��
+{�yul��ٲ}t�C��ПM������v��7��p�.K@<�����@���%�$�2a�s�V�>8x��Ps7��X�̣W)<!ϵ� ��A�a@g�����n+�<�d�GL)���V�>�B��Pu ��P�t[�D.t�m�-�f+�C%zv��#�@��)�#�(�4�X�����^�r���Y�`r'�?R����W��u(ufp�3��cj�$�1�-�Z�������&.��������tM�)'�F���F�����C&H������������V.8�҇�<��&$s���� Y���l]��mB�k.>P[ynv���~�d��_Hd/���`�x`��ny*42Yw��Wi���ŋ
+yn<$���3�@����D4�t�fu?(�q��c���O>a��84�x�����m ��Q��2��#h��I����Zn5W��.
+�#�J����I�)b��\v�{d®9�B2��z�$�˒=A"g�kS�Yr��W$�UI B&�� !b�M�ͱ�r3��g��R���:���X&���7<����ߜ�w#L`;z۲M[�y�9&��K1����LvCf�
+�)�Gf�(��
+Ŕ��O�<0ā��`���V��R��d3�z#�@��/�7gf��K^��|UL�a��NM���_��r�_��T�u��jl��V_�FȲ�F"hZ��SІ�
+[ŕ����̽v�¢nfaF�eC'��3�@�^�zX$��������
+b�7:���U��ɲꯈ�YC@^_�]��#��ƶ�]ˡ�F�=2L�f�u��t?B#��D@P��a
��f��:�f�Hwˮ����.���Q0B3����i�N�L��i��5X�U3��.(N_�9%zA`�9�B8)�el���#���!�r`�x���]{K�)q+�[��"�CN8)~T�R�@(E��p��ܣ?'-B'�܃��@~j�'P����9���ͤ���5(�8�*;�f�����QR6p0J
+L+q
+T���h��P�,7�^g�}�����Y��}�IcF�`��b��L�`H���r2B=�L��b�!�b���}��M���S�v���ô3?� K� ��FL��S�[��)�%�a��g��I-p'e:
+l�M<�c�'�5@�S��K,A &�t8<T��#��
+@ ��bRJX�T�{���ԜD&�մ�ӫ14�;́��A��ih ��b���� ӡ�Չ��V�v��&Qy��4�K��oͦm��ڶغ�DD���~s���͊���QL`��T��,ə8�:�f9͊�Y�:9>�F��A,����q����떷D���3mI���CH�2o�����$[TxCR��|��s���M>�΄,��� � ����.A�^y�,�3�VZ��7ܓ)�������
+9,aH�q��_��ԗ#s.x[پ�l[A��u�J�I�:�>;Q�`1�7$��k�*���( q��� �(��1�Ɔg��zX�͙�ڠ��iRr��NѵN�YH3;���j'�����j'�m�p�v�\h�本��x�c̱����.�Ȍ8�b�AKf��u-,.�p���.��v`=��q�zX3t�h�|][M��bGQ�76rʼn�F}6^�rV����+<ž�}�K��\��#�U͉�J�:�� �a�C��O^�A�8�fl/n�&g!���z\a�p.�0�(?b�g� �F�3�r�0���%�c#Gs�n�]�MD.�L��)̜݃����s����"�k0GR8a�ݔ�"Ξ7a�%L:�Y87�q��/+}�qj���6¿Έ�ȓ���?`;�l��G�j V�)�0#fͨe�i�}#7Qz: !&D�<�r}{�%� ���s^l���gƒ�^����2a%5��.�y����P��Uˢ��n�nw[���b���ǿ���T)��]�@ȇ��p�d�ܣ�=��E'�����]a�@h�����p�A+??��ZY�|�r���fc�Z�����h�f9lGC�W}�Q��a�q/KG��E��&6�:�
+��6'��
+�m��sZ�?������9��%3�Mݠ��p�>�KM
+�Z�s9�?�|�+d=g����\�6���>���<�͊��F+�[%��{�����z��q|@�+츾{��Pڐ5����!g47^>CG[��Mk33���?�њ̈́H�b*����[������"�h�&k�`Bf�Q����C�Q`'Z�6��B��X��yA�L�тX� ��9����|�S�hD���i�
+���H!��B�5��+SoћY8���<<W9��˽(���=���q�L�Y�Dq`}"��\��;�ǯ��9��7��1����A.��Ί�b����L;9%�����#����NﮥV6��Q�m��
+���?���ț�Zt�O�UU�?�a�%��F�����AP9�&���0nR����ߎ�m
+�}Bn���'�������{Cq����7�PKa;�v�"��PK(�A/UgH�sammoa.argoPK(�A:�&s�*ѡ�sammoa_Diagrammedeclasses.pgmlPK)�AǒV9�&�-sammoa_Diagrammedecasdutilisation.pgmlPK)�Aɟ���FA�.sammoa_Diagrammedeclasses2.pgmlPK)�AP����K�5sammoa.todoPK)�A8��7y�7sammoa_profile.profilePK)�Aa;�v�"��
+�7sammoa.xmiPK��Z
\ No newline at end of file
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 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidAction.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -26,13 +26,19 @@
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.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;
/**
@@ -69,7 +75,7 @@
* @throws NullPointerException if no validator exists in context for the
* given {@code modelPropertyName}
*/
- private <E> BeanListValidator<E> getValidator(Class<E> beanClass) {
+ 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();
@@ -94,7 +100,33 @@
return validator;
}
- protected <E> boolean isValid(E bean) {
- return getValidator((Class<E>) bean.getClass()).getContext(bean).isValid();
+ protected BeanListValidator<Route> getRouteValidator() {
+ return getValidator(Route.class);
}
+
+ protected BeanListValidator<Observation> getObservationValidator() {
+ return getValidator(Observation.class);
+ }
+
+ protected <E extends TopiaEntity & Validable> void bindValidableModel(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);
+ }
+ });
+ }
}
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 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidObservationAction.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -24,6 +24,7 @@
*/
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;
@@ -49,7 +50,7 @@
public ValidObservationAction(JAXXContext context) {
super(_("sammoa.action.validObservation"), context);
putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.validObservation.tip"));
- bindModelProperties(FlightUIModel.PROPERTY_OBSERVATION_EDIT_BEAN);
+ bindValidableModel(FlightUIModel.PROPERTY_OBSERVATION_EDIT_BEAN, Observation.class);
}
@Override
@@ -63,10 +64,13 @@
logger.debug("Validation for observation {}", observation.getObservationNumber());
}
- getValidationService().validateObservation(observation);
+ Observation observationChanged = getValidationService().validateObservation(observation);
- if (observation.isDeleted()) {
- getModel().removeObservation(observation);
+ if (observationChanged.isDeleted()) {
+ getModel().removeObservation(observationChanged);
+ } else {
+ getModel().updateObservation(observationChanged);
+ getModel().setObservationEditBean(observationChanged);
}
}
}
@@ -74,6 +78,7 @@
@Override
protected boolean checkEnabled() {
Observation observation = getModel().getObservationEditBean();
- return observation != null && (observation.isDeleted() || isValid(observation));
+ return observation != null
+ && Observations.isValid(observation, getObservationValidator());
}
}
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 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidRouteAction.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -23,11 +23,8 @@
* #L%
*/
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
import fr.ulr.sammoa.application.FlightService;
import fr.ulr.sammoa.persistence.Observation;
-import fr.ulr.sammoa.persistence.Observations;
import fr.ulr.sammoa.persistence.Route;
import fr.ulr.sammoa.persistence.Routes;
import fr.ulr.sammoa.ui.swing.SammoaUIContext;
@@ -38,8 +35,6 @@
import javax.swing.Action;
import java.awt.event.ActionEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import static org.nuiton.i18n.I18n._;
@@ -60,24 +55,8 @@
public ValidRouteAction(JAXXContext context) {
super(_("sammoa.action.validRoute"), context);
putValue(Action.SHORT_DESCRIPTION, _("sammoa.action.validRoute.tip"));
- getModel().addPropertyChangeListener(
- FlightUIModel.PROPERTY_ROUTE_EDIT_BEAN, new PropertyChangeListener() {
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- Route oldValue = (Route) evt.getOldValue();
- if (oldValue != null) {
- oldValue.removePropertyChangeListener(
- Route.PROPERTY_DELETED, enabledListener);
- }
- Route newValue = (Route) evt.getNewValue();
- if (newValue != null) {
- newValue.addPropertyChangeListener(
- Route.PROPERTY_DELETED, enabledListener);
- }
- enabledListener.propertyChange(evt);
- }
- });
+ bindValidableModel(FlightUIModel.PROPERTY_OBSERVATION_EDIT_BEAN, Observation.class);
+ bindValidableModel(FlightUIModel.PROPERTY_ROUTE_EDIT_BEAN, Route.class);
}
@Override
@@ -94,14 +73,18 @@
);
}
- getValidationService().validateRoute(route);
+ Route routeChanged = getValidationService().validateRoute(route);
- if (route.isDeleted()) {
- getModel().removeRoute(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
@@ -120,43 +103,9 @@
boolean result = isEnabled();
if (!validatorIsAdjusting) {
Route bean = getModel().getRouteEditBean();
- result = bean != null && (bean.isDeleted() || isRouteValid(bean));
+ result = bean != null
+ && Routes.isValid(bean, getRouteValidator(), getObservationValidator());
}
return result;
}
-
- protected boolean isRouteValid(Route bean) {
- boolean result = isValid(bean)
- && isDifferentFromPreviousRoute(bean)
- && isObservationsValid(bean);
- return result;
- }
-
- protected boolean isDifferentFromPreviousRoute(Route bean) {
- boolean result;
- Route previousRoute = Routes.findPrevious(getModel().getRoutes(), bean);
- result = previousRoute == null || !Routes.equal(bean, previousRoute);
- return result;
- }
-
- protected boolean isObservationsValid(Route bean) {
-
- Iterable<Observation> observations =
- Observations.filterInRoute(
- getModel().getObservations(),
- bean,
- getModel().getRoutes(),
- true
- );
-
- // All observations must be deleted or valid
- boolean result = Iterables.all(observations, new Predicate<Observation>() {
-
- @Override
- public boolean apply(Observation input) {
- return input.isDeleted() || isValid(input);
- }
- });
- return result;
- }
}
Added: 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 (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidTransectAction.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -0,0 +1,134 @@
+package fr.ulr.sammoa.ui.swing.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.SammoaUIContext;
+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"));
+ bindValidableModel(FlightUIModel.PROPERTY_OBSERVATION_EDIT_BEAN, Observation.class);
+ bindValidableModel(FlightUIModel.PROPERTY_ROUTE_EDIT_BEAN, Route.class);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ Route route = getModel().getRouteEditBean();
+
+ if (route != null && route.getTransectFlight() != null) {
+
+ TransectFlight transectFlight = route.getTransectFlight();
+
+ int index = TransectFlightModel.indexOfTransectFlight(
+ getModel().getTransectFlights(), transectFlight);
+
+ 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;
+
+ getModel().setRouteEditBean(null);
+
+ // Reload all routes
+ FlightService service =
+ context.getContextValue(SammoaUIContext.class).getService(FlightService.class);
+ getModel().clearRoute();
+ getModel().addAllRoute(service.getRoutes(getModel().getFlight()));
+
+ // Keep the route selected
+ if (!route.isDeleted()) {
+ getModel().setCurrentRoute(route);
+ getModel().setRouteEditBean(route);
+ }
+
+ 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) {
+ Route route = getModel().getRouteEditBean();
+ if (route != null) {
+ TransectFlight bean = route.getTransectFlight();
+ result = bean != null
+ && TransectFlights.isValid(bean,
+ getRouteValidator(),
+ getObservationValidator());
+ }
+ }
+ return result;
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/action/ValidTransectAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.css
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.css 2012-09-01 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.css 2012-09-01 09:51:22 UTC (rev 504)
@@ -72,6 +72,10 @@
: "")};
}
+#lblObservation {
+ text: {flightUIModel.getCurrentRoute().getTransectFlight().getTransect().getName()};
+}
+
#cbPanel {
background: {model.getEffortPanelColor()};
}
Modified: 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-01 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBar.jaxx 2012-09-01 09:51:22 UTC (rev 504)
@@ -64,6 +64,7 @@
layout='{new BoxLayout(validButtonPanel, BoxLayout.X_AXIS)}'>
<JButton id='validRouteButton'/>
<JButton id='validObservationButton'/>
+ <JButton id='validTransectButton'/>
</JPanel>
</cell>
</row>
Modified: 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-01 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightBarHandler.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -73,6 +73,7 @@
ui.getStopAudioButton().putClientProperty("actionName", "stopAudio");
ui.getValidObservationButton().putClientProperty("actionName", "validObservation");
ui.getValidRouteButton().putClientProperty("actionName", "validRoute");
+ ui.getValidTransectButton().putClientProperty("actionName", "validTransect");
} else {
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 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -102,6 +102,7 @@
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.layer.BaseGeoPointLayer;
import fr.ulr.sammoa.ui.swing.flight.layer.LineGeoPointLayer;
import fr.ulr.sammoa.ui.swing.flight.layer.SimpleGeoPointLayer;
@@ -415,6 +416,53 @@
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);
+// }
+// }
+// });
+// }
+
NumberCellEditor<Integer> numberCellEditor = JAXXWidgetUtil.newNumberTableCellEditor(Integer.class, false);
table.setDefaultEditor(Integer.class, numberCellEditor);
table.setDefaultEditor(int.class, numberCellEditor);
@@ -491,6 +539,10 @@
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)
@@ -507,10 +559,6 @@
new ValidRowHighlightPredicate(getModel().getTransectFlights()),
SammoaColors.VALID_ROW_COLOR)
);
-
- table.setSortable(false);
- table.setSelectionBackground(null);
- table.setSelectionForeground(Color.BLACK);
}
startTime = timeLog.log(startTime, "afterInitUI", "decoration done (editor/renderer)");
@@ -746,6 +794,7 @@
if (getModel().isValidationMode()) {
putAction("validObservation", new ValidObservationAction(ui));
putAction("validRoute", new ValidRouteAction(ui));
+ putAction("validTransect", new ValidTransectAction(ui));
putAction("startAudio", new StartAudioAction(ui));
putAction("stopAudio", new StopAudioAction(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 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIModel.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -24,6 +24,7 @@
*/
package fr.ulr.sammoa.ui.swing.flight;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import fr.ulr.sammoa.application.flightController.FlightState;
import fr.ulr.sammoa.persistence.Flight;
@@ -69,6 +70,8 @@
public static final String PROPERTY_ROUTE_EDIT_BEAN = "routeEditBean";
+// public static final String PROPERTY_TRANSECT_FLIGHT_EDIT_BEAN = "transectFlightEditBean";
+
public static final String PROPERTY_FLIGHT_OBSERVER_FOR_POSITIONS = "flightObserverForPositions";
public static final String PROPERTY_MAP_FOLLOW = "mapFollow";
@@ -120,6 +123,8 @@
*/
protected Route routeEditBean;
+// protected TransectFlightModel transectFlightEditBean;
+
/**
* La liste des observateurs du vol, sans les pilotes avec l'observateur null
*
@@ -164,7 +169,7 @@
}
public void setObservers(List<Observer> observers) {
- List<Observer> oldValue = Lists.newArrayList(getObservers());
+ List<Observer> oldValue = ImmutableList.copyOf(getObservers());
this.observers = observers;
firePropertyChange(PROPERTY_OBSERVERS, oldValue, observers);
}
@@ -230,27 +235,33 @@
}
public void addObservation(Observation observation) {
- List<Observation> oldValue = Lists.newArrayList(getObservations());
+ List<Observation> oldValue = ImmutableList.copyOf(getObservations());
int index = sizeObservations();
getObservations().add(observation);
fireIndexedPropertyChange(PROPERTY_OBSERVATIONS, index, oldValue, getObservations());
}
public void removeObservation(Observation observation) {
- List<Observation> oldValue = Lists.newArrayList(getObservations());
+ List<Observation> oldValue = ImmutableList.copyOf(getObservations());
int index = indexOfObservations(observation);
getObservations().remove(index);
fireIndexedPropertyChange(PROPERTY_OBSERVATIONS, index, oldValue, getObservations());
}
+ public void updateObservation(Observation observation) {
+ int index = indexOfObservations(observation);
+ getObservations().set(index, observation);
+ fireIndexedPropertyChange(PROPERTY_OBSERVATIONS, index, getObservations(), null);
+ }
+
public void clearObservation() {
- List<Observation> oldValue = Lists.newArrayList(getObservations());
+ List<Observation> oldValue = ImmutableList.copyOf(getObservations());
getObservations().clear();
firePropertyChange(PROPERTY_OBSERVATIONS, oldValue, getObservations());
}
public void addAllObservation(Collection<Observation> observations) {
- List<Observation> oldValue = Lists.newArrayList(getObservations());
+ List<Observation> oldValue = ImmutableList.copyOf(getObservations());
getObservations().addAll(observations);
firePropertyChange(PROPERTY_OBSERVATIONS, oldValue, getObservations());
}
@@ -281,17 +292,35 @@
}
public void addRoute(int index, Route route) {
- List<Route> oldValue = Lists.newArrayList(getRoutes());
+ List<Route> oldValue = ImmutableList.copyOf(getRoutes());
getRoutes().add(index, route);
fireIndexedPropertyChange(PROPERTY_ROUTES, index, oldValue, getRoutes());
}
public void removeRoute(Route route) {
- List<Route> oldValue = Lists.newArrayList(getRoutes());
+ List<Route> oldValue = ImmutableList.copyOf(getRoutes());
int index = getRoutes().indexOf(route);
getRoutes().remove(index);
fireIndexedPropertyChange(PROPERTY_ROUTES, index, oldValue, getRoutes());
}
+
+ public void updateRoute(Route route) {
+ int index = getRoutes().indexOf(route);
+ getRoutes().set(index, route);
+ fireIndexedPropertyChange(PROPERTY_ROUTES, index, getRoutes(), null);
+ }
+
+ public void clearRoute() {
+ List<Route> oldValue = ImmutableList.copyOf(getRoutes());
+ getRoutes().clear();
+ firePropertyChange(PROPERTY_ROUTES, oldValue, getRoutes());
+ }
+
+ public void addAllRoute(Collection<Route> routes) {
+ List<Route> oldValue = ImmutableList.copyOf(getRoutes());
+ getRoutes().addAll(routes);
+ firePropertyChange(PROPERTY_ROUTES, oldValue, getRoutes());
+ }
//
// public SwingValidatorMessageTableModel getValidatorTableModel() {
// return validatorTableModel;
@@ -322,6 +351,16 @@
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 List<Observer> getFlightObserverForPositions() {
if (flightObserverForPositions == null) {
@@ -331,7 +370,7 @@
}
public void setFlightObserverForPositions(List<Observer> flightObserverForPositions) {
- List<Observer> oldValue = Lists.newArrayList(getFlightObserverForPositions());
+ List<Observer> oldValue = ImmutableList.copyOf(getFlightObserverForPositions());
this.flightObserverForPositions = flightObserverForPositions;
firePropertyChange(PROPERTY_FLIGHT_OBSERVER_FOR_POSITIONS, oldValue, flightObserverForPositions);
}
@@ -381,7 +420,7 @@
}
public void setStrates(List<StrateModel> strates) {
- List<StrateModel> oldValue = Lists.newArrayList(getStrates());
+ List<StrateModel> oldValue = ImmutableList.copyOf(getStrates());
this.strates = strates;
firePropertyChange(PROPERTY_STRATES, oldValue, strates);
}
@@ -410,11 +449,28 @@
}
public void setTransectFlights(List<TransectFlightModel> transectFlights) {
- List<TransectFlightModel> oldValue = Lists.newArrayList(getTransectFlights());
+ List<TransectFlightModel> oldValue = ImmutableList.copyOf(getTransectFlights());
this.transectFlights = transectFlights;
firePropertyChange(PROPERTY_TRANSECT_FLIGHTS, oldValue, transectFlights);
}
+ public void removeTransectFlight(int index) {
+ List<TransectFlightModel> oldValue = ImmutableList.copyOf(getTransectFlights());
+ getTransectFlights().remove(index);
+ fireIndexedPropertyChange(PROPERTY_TRANSECT_FLIGHTS, index, oldValue, getTransectFlights());
+ }
+
+ public void updateTransectFlight(TransectFlight transectFlight) {
+ int index = TransectFlightModel.indexOfTransectFlight(
+ getTransectFlights(), transectFlight);
+ getTransectFlights().get(index).setSource(transectFlight);
+ fireIndexedPropertyChange(PROPERTY_TRANSECT_FLIGHTS, index, getTransectFlights(), null);
+
+ // Update instance in flight list
+ int flightIndex = getFlight().getTransectFlight().indexOf(transectFlight);
+ flight.getTransectFlight().set(flightIndex, transectFlight);
+ }
+
public List<GeoPoint> getGeoPoints() {
if (geoPoints == null) {
geoPoints = Lists.newArrayList();
@@ -423,7 +479,7 @@
}
public void setGeoPoints(List<GeoPoint> geoPoints) {
- List<GeoPoint> oldValue = Lists.newArrayList(getGeoPoints());
+ List<GeoPoint> oldValue = ImmutableList.copyOf(getGeoPoints());
this.geoPoints = geoPoints;
firePropertyChange(PROPERTY_GEO_POINTS, oldValue, geoPoints);
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectFlightModel.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectFlightModel.java 2012-09-01 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectFlightModel.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -27,13 +27,12 @@
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
-import fr.ulr.sammoa.persistence.Deletable;
import fr.ulr.sammoa.persistence.Flight;
import fr.ulr.sammoa.persistence.Observer;
import fr.ulr.sammoa.persistence.ObserverPosition;
import fr.ulr.sammoa.persistence.Position;
import fr.ulr.sammoa.persistence.TransectFlight;
-import fr.ulr.sammoa.persistence.Validatable;
+import fr.ulr.sammoa.persistence.Validable;
import org.jdesktop.beans.AbstractSerializableBean;
/**
@@ -41,7 +40,7 @@
*
* @author fdesbois <desbois(a)codelutin.com>
*/
-public class TransectFlightModel extends AbstractSerializableBean implements Deletable, Validatable {
+public class TransectFlightModel extends AbstractSerializableBean implements Validable {
private static final long serialVersionUID = 1L;
@@ -122,7 +121,6 @@
index = getFlight().getTransectFlight().size() - 1;
}
-
getFlight().getTransectFlight().remove(getSource());
// Use add on Flight to fire change
@@ -169,11 +167,13 @@
return flightModel.getFlight();
}
- public static Predicate<TransectFlightModel> withTransectFlight(TransectFlight transectFlight) {
- return new WithTransectFlightPredicate(transectFlight);
+ public static int indexOfTransectFlight(Iterable<TransectFlightModel> transectFlightModels,
+ TransectFlight transectFlight) {
+ return Iterables.indexOf(
+ transectFlightModels, new WithTransectFlightPredicate(transectFlight));
}
- protected static class WithTransectFlightPredicate implements Predicate<TransectFlightModel> {
+ private static class WithTransectFlightPredicate implements Predicate<TransectFlightModel> {
protected TransectFlight transectFlight;
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 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/TransectTableModel.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -24,7 +24,6 @@
*/
package fr.ulr.sammoa.ui.swing.flight;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import fr.ulr.sammoa.persistence.Flight;
import fr.ulr.sammoa.persistence.Observer;
@@ -35,7 +34,7 @@
import fr.ulr.sammoa.persistence.TransectFlight;
import fr.ulr.sammoa.ui.swing.util.SammoaUtil;
-import javax.swing.*;
+import javax.swing.SwingUtilities;
import javax.swing.table.AbstractTableModel;
import java.util.List;
@@ -78,10 +77,8 @@
}
public int getRowIndex(final TransectFlight transectFlight) {
- int result = Iterables.indexOf(
- getTransectFlights(),
- TransectFlightModel.withTransectFlight(transectFlight)
- );
+ int result = TransectFlightModel.indexOfTransectFlight(
+ getTransectFlights(), transectFlight);
return result;
}
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 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/observations/EffortPanelHandler.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -56,6 +56,7 @@
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;
@@ -86,10 +87,7 @@
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListCellRenderer;
-import javax.swing.ListSelectionModel;
import javax.swing.border.LineBorder;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel;
@@ -122,10 +120,10 @@
protected static final Color DEVICE_ERROR_BACKGROUND_COLOR = Color.RED;
public static final String ROUTE_VALIDATOR_CONTEXT_VALUE =
- "routeimplValidator";
+ "routeValidator";
public static final String OBSERVATION_VALIDATOR_CONTEXT_VALUE =
- "observationimplValidator";
+ "observationValidator";
protected boolean comboIsAdjusting;
@@ -291,7 +289,7 @@
public void initRouteTable() {
- FlightUIModel flightUIModel = ui.getFlightUIModel();
+ final FlightUIModel flightUIModel = ui.getFlightUIModel();
JXTable table = ui.getRouteTable();
RouteTableModel tableModel = ui.getRouteTableModel();
@@ -336,52 +334,16 @@
n_("sammoa.observations.routeTable.column.deleted.tip")
);
- init(table, new ListSelectionListener() {
+ init(table, new SelectionModelAdapter<Route>() {
@Override
- public void valueChanged(ListSelectionEvent e) {
+ public List<Route> getElements() {
+ return ui.getFlightUIModel().getRoutes();
+ }
- if (!e.getValueIsAdjusting()) {
-
- ListSelectionModel listSelectionModel =
- (ListSelectionModel) e.getSource();
- int firstIndex = e.getFirstIndex();
- int lastIndex = e.getLastIndex();
- Integer newSelectedRow = null;
-
- if (listSelectionModel.isSelectionEmpty()) {
-
- // no selection
- } else if (listSelectionModel.isSelectedIndex(firstIndex)) {
-
- // use first index
- newSelectedRow = firstIndex;
- } else if (listSelectionModel.isSelectedIndex(lastIndex)) {
-
- // use last index
- newSelectedRow = lastIndex;
- }
- FlightUIModel flightUIModel = ui.getFlightUIModel();
- List<Route> routes = flightUIModel.getRoutes();
- Route route = null;
-
- if (newSelectedRow != null &&
- newSelectedRow < routes.size()) {
- route = routes.get(newSelectedRow);
-
- if (logger.isInfoEnabled()) {
- logger.info("Select route from index {}", newSelectedRow);
- }
-
- } else {
- if (logger.isInfoEnabled()) {
- logger.info("No route selected");
- }
- }
-
- // set new route in model to validate
- flightUIModel.setRouteEditBean(route);
- }
+ @Override
+ public void setSelectedElement(Route element) {
+ ui.getFlightUIModel().setRouteEditBean(element);
}
});
@@ -402,6 +364,9 @@
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)
+ flightUIModel.setObservationEditBean(null);
}
}
);
@@ -500,53 +465,16 @@
n_("sammoa.observations.observationTable.column.circleback.tip")
);
- init(table, new ListSelectionListener() {
+ init(table, new SelectionModelAdapter<Observation>() {
@Override
- public void valueChanged(ListSelectionEvent e) {
+ public List<Observation> getElements() {
+ return ui.getFlightUIModel().getObservations();
+ }
- FlightUIModel flightUIModel = ui.getFlightUIModel();
-
- if (!e.getValueIsAdjusting()) {
-
- ListSelectionModel listSelectionModel =
- (ListSelectionModel) e.getSource();
- int firstIndex = e.getFirstIndex();
- int lastIndex = e.getLastIndex();
- Integer newSelectedRow = null;
-
- if (listSelectionModel.isSelectionEmpty()) {
-
- // no selection
- } else if (listSelectionModel.isSelectedIndex(firstIndex)) {
-
- // use first index
- newSelectedRow = firstIndex;
- } else if (listSelectionModel.isSelectedIndex(lastIndex)) {
-
- // use last index
- newSelectedRow = lastIndex;
- }
- List<Observation> observations = flightUIModel.getObservations();
- Observation observation = null;
-
- if (newSelectedRow != null &&
- newSelectedRow < observations.size()) {
- observation = observations.get(newSelectedRow);
-
- if (logger.isInfoEnabled()) {
- logger.info("Select observation from index {}", newSelectedRow);
- }
-
- } else {
- if (logger.isInfoEnabled()) {
- logger.info("No observation selected");
- }
- }
-
- // set new observation in model to validate
- flightUIModel.setObservationEditBean(observation);
- }
+ @Override
+ public void setSelectedElement(Observation element) {
+ ui.getFlightUIModel().setObservationEditBean(element);
}
});
@@ -622,6 +550,9 @@
selectRouteByObservation(newValue);
}
+// else {
+// SammoaUtil.unselectAll(ui.getObservationTable());
+// }
}
});
@@ -739,8 +670,8 @@
}
}
- public void init(final JXTable table,
- ListSelectionListener selectionListener) {
+ public <T> void init(final JXTable table,
+ SelectionModelAdapter<T> selectionModelAdapter) {
final Action moveToNextEditableCell = new MoveToNextEditableCellAction(table);
final Action moveToPreviousEditableCell = new MoveToPreviousEditableCellAction(table);
@@ -824,7 +755,7 @@
table.setDefaultEditor(Date.class, new TimeCellEditor(datePicker));
}
- table.getSelectionModel().addListSelectionListener(selectionListener);
+ SammoaUtil.addTableSelectionListener(table, selectionModelAdapter);
SwingUtil.scrollToTableSelection(table);
}
Modified: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/DeletedRowHighlightPredicate.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/DeletedRowHighlightPredicate.java 2012-09-01 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/DeletedRowHighlightPredicate.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -23,7 +23,7 @@
* #L%
*/
-import fr.ulr.sammoa.persistence.Deletable;
+import fr.ulr.sammoa.persistence.Validable;
import java.util.List;
@@ -34,9 +34,9 @@
*/
public class DeletedRowHighlightPredicate extends AbstractRowHighlightPredicate {
- protected List<? extends Deletable> model;
+ protected List<? extends Validable> model;
- public DeletedRowHighlightPredicate(List<? extends Deletable> model) {
+ public DeletedRowHighlightPredicate(List<? extends Validable> model) {
this.model = model;
}
@@ -47,7 +47,7 @@
}
@Override
- protected Deletable getValueAt(int rowIndex) {
+ protected Validable getValueAt(int rowIndex) {
return model.get(rowIndex);
}
}
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 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/SammoaUtil.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -67,6 +67,20 @@
// 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> TableSelectionListener<T> addTableSelectionListener(JTable table,
+ SelectionModelAdapter<T> selectionModelAdapter) {
+ TableSelectionListener<T> result = new TableSelectionListener<T>(selectionModelAdapter);
+ table.getSelectionModel().addListSelectionListener(result);
+ return result;
+ }
+
public static Highlighter newBackgroundColorHighlighter(HighlightPredicate predicate, Color color) {
return new SammoaColorHighlighter(predicate, color, false);
}
Added: 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 (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/SelectionModelAdapter.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -0,0 +1,17 @@
+package fr.ulr.sammoa.ui.swing.util;
+
+import java.util.List;
+
+/**
+ * Created: 31/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ * @see TableSelectionListener
+ */
+public interface SelectionModelAdapter<T> {
+
+ List<T> getElements();
+
+ void setSelectedElement(T element);
+
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/SelectionModelAdapter.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/util/TableDataChangeListener.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/TableDataChangeListener.java 2012-09-01 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/TableDataChangeListener.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -65,6 +65,25 @@
if (evt.getOldValue() == null) {
tableModel.fireTableDataChanged();
+ // UPDATE : we use null newValue to fire update
+ } else if (evt.getNewValue() == null) {
+
+ int oldSize = ((Collection) evt.getOldValue()).size();
+
+ int rowIndex;
+ if (evt instanceof IndexedPropertyChangeEvent) {
+ rowIndex = ((IndexedPropertyChangeEvent) evt).getIndex();
+ } else {
+ rowIndex = -1;
+ }
+
+ if (rowIndex == -1) {
+ tableModel.fireTableRowsUpdated(0, oldSize - 1);
+
+ } else {
+ tableModel.fireTableRowsUpdated(rowIndex, rowIndex);
+ }
+
} else {
int oldSize = ((Collection) evt.getOldValue()).size();
Added: 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 (rev 0)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/TableSelectionListener.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -0,0 +1,71 @@
+package fr.ulr.sammoa.ui.swing.util;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import java.util.List;
+
+/**
+ * Created: 31/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public class TableSelectionListener<T> implements ListSelectionListener {
+
+ private static final Logger logger = LoggerFactory.getLogger(TableSelectionListener.class);
+
+ protected SelectionModelAdapter<T> selectionModelAdapter;
+
+ public TableSelectionListener(SelectionModelAdapter<T> selectionModelAdapter) {
+ this.selectionModelAdapter = selectionModelAdapter;
+ }
+
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+
+ if (!e.getValueIsAdjusting()) {
+
+ ListSelectionModel listSelectionModel =
+ (ListSelectionModel) e.getSource();
+ int firstIndex = e.getFirstIndex();
+ int lastIndex = e.getLastIndex();
+ Integer newSelectedRow = null;
+
+ if (listSelectionModel.isSelectionEmpty()) {
+
+ // no selection
+ } else if (listSelectionModel.isSelectedIndex(firstIndex)) {
+
+ // use first index
+ newSelectedRow = firstIndex;
+ } else if (listSelectionModel.isSelectedIndex(lastIndex)) {
+
+ // use last index
+ newSelectedRow = lastIndex;
+ }
+ List<T> elements = selectionModelAdapter.getElements();
+ T element = null;
+
+ if (newSelectedRow != null &&
+ newSelectedRow < elements.size()) {
+ element = elements.get(newSelectedRow);
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Select {} from index {}",
+ element.getClass().getSimpleName(), newSelectedRow);
+ }
+
+ } else {
+ if (logger.isInfoEnabled()) {
+ logger.info("No element selected");
+ }
+ }
+
+ // set new element in adapter
+ selectionModelAdapter.setSelectedElement(element);
+ }
+ }
+}
Property changes on: trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/TableSelectionListener.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/util/ValidRowHighlightPredicate.java
===================================================================
--- trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/ValidRowHighlightPredicate.java 2012-09-01 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/util/ValidRowHighlightPredicate.java 2012-09-01 09:51:22 UTC (rev 504)
@@ -23,7 +23,7 @@
* #L%
*/
-import fr.ulr.sammoa.persistence.Validatable;
+import fr.ulr.sammoa.persistence.Validable;
import java.util.List;
@@ -34,9 +34,9 @@
*/
public class ValidRowHighlightPredicate extends AbstractRowHighlightPredicate {
- protected List<? extends Validatable> model;
+ protected List<? extends Validable> model;
- public ValidRowHighlightPredicate(List<? extends Validatable> model) {
+ public ValidRowHighlightPredicate(List<? extends Validable> model) {
this.model = model;
}
@@ -47,7 +47,7 @@
}
@Override
- protected Validatable getValueAt(int rowIndex) {
+ protected Validable getValueAt(int rowIndex) {
return model.get(rowIndex);
}
}
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 09:51:00 UTC (rev 503)
+++ trunk/sammoa-ui-swing/src/main/resources/i18n/sammoa-ui-swing_en_GB.properties 2012-09-01 09:51:22 UTC (rev 504)
@@ -52,6 +52,8 @@
sammoa.action.validObservation.tip=Validate the selected observation
sammoa.action.validRoute=Route
sammoa.action.validRoute.tip=Validate the selected route and all its observations
+sammoa.action.validTransect=Transect
+sammoa.action.validTransect.tip=Validate the selected transect and all its routes and observations
sammoa.action.validation=Validation
sammoa.config.category.applications=Application
sammoa.config.category.applications.description=Application
1
0
r503 - in trunk: sammoa-application/src/main/java/fr/ulr/sammoa/application sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence
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 11:51:00 +0200 (Sat, 01 Sep 2012)
New Revision: 503
Url: http://forge.codelutin.com/repositories/revision/sammoa/503
Log:
fixes #1429 : resolve issue on delete flight + improve AutoSave when creation error
Modified:
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/AutoSaveListener.java
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 09:50:23 UTC (rev 502)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java 2012-09-01 09:51:00 UTC (rev 503)
@@ -362,9 +362,6 @@
Set<ObserverPosition> positions = Sets.newHashSet();
- // keep observerPositions to delete from transectFlights
- positions.addAll(TransectFlights.toObserverPositions(flight.getTransectFlight()));
-
// delete routes
List<Route> routes = getRoutes(tx, flight);
// keep observerPositions to delete from routes
@@ -374,18 +371,19 @@
// delete observations
List<Observation> observations = getObservations(tx, flight);
- // keep observerPositions to delete
-// positions.addAll(Observations.toObserverPositions(observations));
ObservationDAO observationDAO = SammoaDAOHelper.getObservationDAO(tx);
observationDAO.deleteAll(observations);
- // delete observationPositions
- ObserverPositionDAO observerPositionDAO = SammoaDAOHelper.getObserverPositionDAO(tx);
- observerPositionDAO.deleteAll(positions);
+ // keep observerPositions to delete from transectFlights
+ positions.addAll(TransectFlights.toObserverPositions(flight.getTransectFlight()));
- // delete flight
+ // delete flight (cascade delete on transectFlights)
dao.delete(flight);
+ // delete observerPositions
+ ObserverPositionDAO observerPositionDAO = SammoaDAOHelper.getObserverPositionDAO(tx);
+ observerPositionDAO.deleteAll(positions);
+
} catch (TopiaException e) {
throw new SammoaTechnicalException(e);
}
Modified: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/AutoSaveListener.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/AutoSaveListener.java 2012-09-01 09:50:23 UTC (rev 502)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/AutoSaveListener.java 2012-09-01 09:51:00 UTC (rev 503)
@@ -145,10 +145,14 @@
TopiaContext transaction = persistence.openContext();
try {
- saveEntities(transaction, createdEntities, CREATE_ACTION);
+ Set<TopiaEntity> errorSavedEntities =
+ saveEntities(transaction, createdEntities, CREATE_ACTION);
- saveEntities(transaction, changedEntities, UPDATE_ACTION);
+ changedEntities.addAll(
+ saveEntities(transaction, changedEntities, UPDATE_ACTION));
+ changedEntities.addAll(errorSavedEntities);
+
} finally {
persistence.closeContext(transaction);
}
@@ -174,13 +178,15 @@
* @param transaction TopiaContex used to commit
* @param entities synchronized Set of entities to save
* @param action SaveAction to use
+ * @return a Set of entities in error during save
*/
- protected void saveEntities(TopiaContext transaction,
- Set<TopiaEntity> entities,
- SaveAction action) {
+ protected Set<TopiaEntity> saveEntities(TopiaContext transaction,
+ Set<TopiaEntity> entities,
+ SaveAction action) {
+ Set<TopiaEntity> result;
if (entities.isEmpty()) {
- // do nothing
+ result = Collections.emptySet();
} else {
@@ -199,18 +205,21 @@
transaction.commitTransaction();
+ result = Collections.emptySet();
+
} catch (TopiaException e) {
if (logger.isErrorEnabled()) {
logger.error(String.format("Error during %s", action), e);
}
- entities.addAll(entitiesCopy);
+ result = entitiesCopy;
}
if (logger.isDebugEnabled() && !entitiesCopy.isEmpty()) {
logger.debug(String.format("%s %d entities", action, entitiesCopy.size()));
}
}
+ return result;
}
protected interface SaveAction {
1
0
01 Sep '12
Author: fdesbois
Date: 2012-09-01 11:50:23 +0200 (Sat, 01 Sep 2012)
New Revision: 502
Url: http://forge.codelutin.com/repositories/revision/sammoa/502
Log:
refs #1419 : improve time using Joda-Time. PeriodDates is replaced by Joda-Time Interval class.
Added:
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Dates.java
Modified:
trunk/pom.xml
trunk/sammoa-application/pom.xml
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/FakeGpsHandler.java
trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsHandlerGpsylon.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/output/map/ExportMapService.java
trunk/sammoa-persistence/pom.xml
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Flights.java
trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Observations.java
trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-09-01 09:50:03 UTC (rev 501)
+++ trunk/pom.xml 2012-09-01 09:50:23 UTC (rev 502)
@@ -122,6 +122,8 @@
<swingXVersion>1.6.4</swingXVersion>
<xworkVersion>2.3.4</xworkVersion>
+ <jodaTimeVersion>2.1</jodaTimeVersion>
+
<slf4jVersion>1.6.6</slf4jVersion>
<logbackVersion>1.0.6</logbackVersion>
@@ -166,6 +168,12 @@
</dependency>
<dependency>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ <version>${jodaTimeVersion}</version>
+ </dependency>
+
+ <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guavaVersion}</version>
Modified: trunk/sammoa-application/pom.xml
===================================================================
--- trunk/sammoa-application/pom.xml 2012-09-01 09:50:03 UTC (rev 501)
+++ trunk/sammoa-application/pom.xml 2012-09-01 09:50:23 UTC (rev 502)
@@ -50,6 +50,11 @@
</dependency>
<dependency>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
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 09:50:03 UTC (rev 501)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/FlightService.java 2012-09-01 09:50:23 UTC (rev 502)
@@ -34,6 +34,7 @@
import fr.ulr.sammoa.application.io.SammoaStorages;
import fr.ulr.sammoa.persistence.AutoSaveListener;
import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.Dates;
import fr.ulr.sammoa.persistence.Flight;
import fr.ulr.sammoa.persistence.FlightDAO;
import fr.ulr.sammoa.persistence.Flights;
@@ -61,10 +62,10 @@
import fr.ulr.sammoa.persistence.TransectFlights;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
+import org.joda.time.Interval;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaRuntimeException;
-import org.nuiton.util.PeriodDates;
import org.nuiton.util.TimeLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -120,7 +121,7 @@
List<Flight> result = dao.findAllByCampaign(campaign);
- Collections.sort(result, Flights.onDate());
+ Collections.sort(result, Flights.orderByDate());
timeLog.log(start, "getFlights(" + campaign.getCode() + ")");
return result;
@@ -165,7 +166,7 @@
FlightDAO dao = SammoaDAOHelper.getFlightDAO(transaction);
campaignFlights = dao.findAllByCampaign(campaign);
- Collections.sort(campaignFlights, Flights.onDate());
+ Collections.sort(campaignFlights, Flights.orderByDate());
} catch (TopiaException e) {
throw new TopiaRuntimeException(e);
@@ -173,13 +174,12 @@
}
// Filter on period
- final PeriodDates period = new PeriodDates(beginDate, endDate);
+ final Interval interval = Dates.toInterval(beginDate, endDate);
Iterable<Flight> result = Iterables.filter(campaignFlights, new Predicate<Flight>() {
@Override
public boolean apply(Flight input) {
- return input.getBeginDate() != null &&
- period.between(input.getBeginDate());
+ return Dates.inInterval(input.getBeginDate(), interval);
}
});
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/FakeGpsHandler.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/FakeGpsHandler.java 2012-09-01 09:50:03 UTC (rev 501)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/FakeGpsHandler.java 2012-09-01 09:50:23 UTC (rev 502)
@@ -26,10 +26,10 @@
import fr.ulr.sammoa.application.device.DeviceState;
import fr.ulr.sammoa.application.device.DeviceTechnicalException;
+import fr.ulr.sammoa.persistence.Dates;
import fr.ulr.sammoa.persistence.GeoPoint;
import fr.ulr.sammoa.persistence.GeoPointImpl;
import fr.ulr.sammoa.persistence.GeoPoints;
-import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -180,8 +180,7 @@
}
protected Date getDate() {
- Date result = new Date();
- result = DateUtils.setMilliseconds(result, 0);
+ Date result = Dates.newDateWithoutMillis();
return result;
}
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsHandlerGpsylon.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsHandlerGpsylon.java 2012-09-01 09:50:03 UTC (rev 501)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/device/gps/GpsHandlerGpsylon.java 2012-09-01 09:50:23 UTC (rev 502)
@@ -27,11 +27,11 @@
import fr.ulr.sammoa.application.device.DeviceState;
import fr.ulr.sammoa.application.device.DeviceTechnicalException;
+import fr.ulr.sammoa.persistence.Dates;
import fr.ulr.sammoa.persistence.GeoPoint;
import fr.ulr.sammoa.persistence.GeoPointImpl;
import fr.ulr.sammoa.persistence.GeoPoints;
import gnu.io.CommPortIdentifier;
-import org.apache.commons.lang3.time.DateUtils;
import org.dinopolis.gpstool.gpsinput.GPSDataProcessor;
import org.dinopolis.gpstool.gpsinput.GPSDevice;
import org.dinopolis.gpstool.gpsinput.GPSException;
@@ -260,8 +260,7 @@
protected Date getDate() {
// FIXME-fdesbois-2012-07-02 : ensure time with GPS value and not system timestamp
- Date result = new Date();
- result = DateUtils.setMilliseconds(result, 0);
+ Date result = Dates.newDateWithoutMillis();
return result;
}
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-01 09:50:03 UTC (rev 501)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/flightController/FlightControllerValidation.java 2012-09-01 09:50:23 UTC (rev 502)
@@ -26,6 +26,7 @@
import com.google.common.base.Preconditions;
import fr.ulr.sammoa.application.device.DeviceManager;
import fr.ulr.sammoa.application.device.audio.AudioReader;
+import fr.ulr.sammoa.persistence.Dates;
import fr.ulr.sammoa.persistence.Flight;
import fr.ulr.sammoa.persistence.GeoPoint;
import fr.ulr.sammoa.persistence.GeoPointImpl;
@@ -34,15 +35,13 @@
import fr.ulr.sammoa.persistence.Routes;
import fr.ulr.sammoa.persistence.SammoaDAOHelper;
import fr.ulr.sammoa.persistence.TransectFlight;
-import org.apache.commons.lang3.time.DateUtils;
+import org.joda.time.DateTime;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
-import java.util.Calendar;
-import java.util.Date;
import java.util.List;
/**
@@ -90,25 +89,24 @@
GeoPoint result;
- Date previousTime = currentRoute.getBeginTime();
+ DateTime previousTime = Dates.toDateTime(currentRoute.getBeginTime());
if (logger.isDebugEnabled()) {
logger.debug(String.format("Get location after previousTime %1$tH:%1$tM:%1$tS.%1$tL",
- previousTime)
+ previousTime.toDate())
);
}
long position = audioReader.getPosition();
- Date newTime;
+ DateTime newTime;
if (position > 0) {
- newTime = DateUtils.addSeconds(previousTime, (int) position);
+ newTime = previousTime.plus(position);
} else {
- newTime = new Date();
- newTime.setTime(previousTime.getTime());
+ newTime = new DateTime(previousTime);
// // Arbitrary add 1 second for the newTime
// newTime = DateUtils.addMilliseconds(previousTime, 1000);
@@ -134,28 +132,37 @@
if (logger.isDebugEnabled()) {
logger.debug(String.format("Get location at newTime %1$tH:%1$tM:%1$tS.%1$tL",
- newTime)
+ newTime.toDate())
);
}
// Retrieve the appropriate location
- GeoPoint location = GeoPoints.getClosestPoint(geoPoints, newTime);
+ GeoPoint location = GeoPoints.getClosestPoint(geoPoints, newTime.toDate());
+ DateTime locationTime = Dates.toDateTime(location.getRecordTime());
// Create a new location if no one is available for the newTime
- if (!location.getRecordTime().equals(newTime)) {
+ if (!locationTime.equals(newTime)) {
result = new GeoPointImpl(location.getLatitude(), location.getLongitude());
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;
+// // 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()
+ .toStandardSeconds()
+ .getSeconds();
+
result.setCaptureDelay(captureDelay);
result.setFlight(flight);
- result.setRecordTime(newTime);
+ result.setRecordTime(newTime.toDate());
SammoaDAOHelper.getGeoPointDAO(tx).create(result);
geoPoints.add(result);
Modified: trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapService.java
===================================================================
--- trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapService.java 2012-09-01 09:50:03 UTC (rev 501)
+++ trunk/sammoa-application/src/main/java/fr/ulr/sammoa/application/io/output/map/ExportMapService.java 2012-09-01 09:50:23 UTC (rev 502)
@@ -34,6 +34,7 @@
import fr.ulr.sammoa.application.FlightService;
import fr.ulr.sammoa.application.SammoaServiceSupport;
import fr.ulr.sammoa.persistence.Campaign;
+import fr.ulr.sammoa.persistence.Dates;
import fr.ulr.sammoa.persistence.Flight;
import fr.ulr.sammoa.persistence.GeoPoint;
import fr.ulr.sammoa.persistence.GeoPoints;
@@ -50,14 +51,13 @@
import fr.ulr.sammoa.persistence.Strate;
import fr.ulr.sammoa.persistence.Transect;
import fr.ulr.sammoa.persistence.TransectFlight;
+import org.joda.time.DateTime;
+import org.joda.time.Interval;
import org.nuiton.topia.TopiaContext;
-import org.nuiton.util.PeriodDates;
import org.nuiton.util.TimeLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -76,7 +76,7 @@
private static final TimeLog timeLog = new TimeLog(ExportMapService.class);
- protected final DateFormat timeFormat = new SimpleDateFormat("HHmmss");
+// protected final DateFormat timeFormat = new SimpleDateFormat("HHmmss");
public int exportEffortsMap(ExportMapModel dataModel) {
Preconditions.checkNotNull(dataModel);
@@ -435,39 +435,43 @@
effortGroup = null;
}
- // compute route period
- Date beginTime = new Date(route.getBeginTime().getTime());
+ // compute route time interval
+ DateTime beginTime = Dates.toDateTime(route.getBeginTime());
- Date routeEndTime;
+ DateTime endTime;
if (nextRouteIndex < nbRoutes) {
// use next route begin time
Route nextRoute = routes.get(nextRouteIndex);
- routeEndTime = nextRoute.getBeginTime();
+ endTime = Dates.toDateTime(nextRoute.getBeginTime());
} else {
// use flight end date
- routeEndTime = flight.getEndDate();
+ endTime = Dates.toDateTime(flight.getEndDate());
}
- if (routeEndTime != null) {
- routeEndTime = new Date(routeEndTime.getTime());
- Preconditions.checkState(routeEndTime.after(beginTime),
- String.format("Route debut de route %s - fin de route %s", beginTime, routeEndTime));
+
+ if (endTime.equals(beginTime)) {
+
+ // ignore this route, we will use the next one
+ continue;
}
- PeriodDates routePeriod =
- new PeriodDates(beginTime, routeEndTime);
+ Preconditions.checkState(endTime.isAfter(beginTime),
+ String.format("Route debut de route %s - fin de route %s", beginTime, endTime));
+ Interval routeInterval =
+ Dates.toInterval(beginTime, endTime);
+
// Get observations for this route
List<Observation> routeObservations =
Observations.retainsObservations(observations,
- routePeriod);
+ routeInterval);
if (logger.isDebugEnabled()) {
logger.debug("Export Observations from route {} [{}-{}] nb observations {}",
new Object[]{beginTime,
- routeEndTime,
+ endTime,
routeObservations.size()}
);
}
@@ -662,7 +666,7 @@
protected void fillDateRecord(Date date, Map<String, Object> record) {
record.put("DATE", date);
- record.put("HHMMSS", timeFormat.format(date));
+ record.put("HHMMSS", Dates.toDateTime(date).toString("HHmmss"));
}
protected void fillGeoPointRecordAndFlush(GeoPoint geoPoint,
Modified: trunk/sammoa-persistence/pom.xml
===================================================================
--- trunk/sammoa-persistence/pom.xml 2012-09-01 09:50:03 UTC (rev 501)
+++ trunk/sammoa-persistence/pom.xml 2012-09-01 09:50:23 UTC (rev 502)
@@ -27,6 +27,11 @@
</dependency>
<dependency>
+ <groupId>joda-time</groupId>
+ <artifactId>joda-time</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
Added: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Dates.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Dates.java (rev 0)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Dates.java 2012-09-01 09:50:23 UTC (rev 502)
@@ -0,0 +1,62 @@
+package fr.ulr.sammoa.persistence;
+
+import org.joda.time.DateTime;
+import org.joda.time.Interval;
+
+import java.util.Date;
+
+/**
+ * Created: 31/08/12
+ *
+ * @author fdesbois <florian.desbois(a)codelutin.com>
+ */
+public final class Dates {
+
+ private Dates() {
+ // static class do not have instanciation
+ }
+
+ public static Interval toInterval(DateTime begin, DateTime end) {
+ return new Interval(begin, end);
+ }
+
+ public static Interval toInterval(Date begin, Date end) {
+ return toInterval(toDateTime(begin), toDateTime(end));
+ }
+
+ public static DateTime toDateTime(Date date) {
+ return new DateTime(date);
+ }
+
+ public static Date newDateWithoutMillis() {
+ return DateTime.now().withMillisOfSecond(0).toDate();
+ }
+
+ public static boolean inInterval(Date date, Date begin, Date end) {
+ return inInterval(date, toInterval(begin, end));
+ }
+
+ public static boolean inInterval(Date date, Interval interval) {
+ return interval.contains(toDateTime(date));
+ }
+
+// public static Predicate<Date> inInterval(Interval interval) {
+// return new InIntervalPredicate(interval);
+// }
+//
+// private static class InIntervalPredicate implements Predicate<Date> {
+//
+// protected Interval interval;
+//
+// public InIntervalPredicate(Interval interval) {
+// Preconditions.checkNotNull(interval);
+// this.interval = interval;
+// }
+//
+// @Override
+// public boolean apply(Date input) {
+// return inInterval(input, interval);
+// }
+// }
+
+}
Property changes on: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Dates.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Flights.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Flights.java 2012-09-01 09:50:03 UTC (rev 501)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Flights.java 2012-09-01 09:50:23 UTC (rev 502)
@@ -41,8 +41,8 @@
// static class do not have instanciation
}
- public static Comparator<Flight> onDate() {
- return ON_DATE_COMPARATOR;
+ public static Comparator<Flight> orderByDate() {
+ return ORDER_BY_DATE_COMPARATOR;
}
public static Function<Flight, String> toSystemId() {
@@ -89,7 +89,7 @@
}
}
- protected static Comparator<Flight> ON_DATE_COMPARATOR =
+ protected static Comparator<Flight> ORDER_BY_DATE_COMPARATOR =
new Comparator<Flight>() {
@Override
Modified: trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Observations.java
===================================================================
--- trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Observations.java 2012-09-01 09:50:03 UTC (rev 501)
+++ trunk/sammoa-persistence/src/main/java/fr/ulr/sammoa/persistence/Observations.java 2012-09-01 09:50:23 UTC (rev 502)
@@ -29,7 +29,7 @@
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables;
import org.apache.commons.collections.CollectionUtils;
-import org.nuiton.util.PeriodDates;
+import org.joda.time.Interval;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -95,9 +95,7 @@
Date begin = previousRoute.getBeginTime();
Date end = nextRoute != null ? nextRoute.getBeginTime() : null;
- PeriodDates period = new PeriodDates(begin, end);
-
- return inPeriod(observation, period);
+ return Dates.inInterval(observation.getObservationTime(), begin, end);
}
public static Predicate<Observation> inRoute(Route route,
@@ -106,24 +104,26 @@
return new InRoutePredicate(route, routes, ignoreDeleted);
}
- public static boolean inPeriod(Observation observation, PeriodDates periodDate) {
+// public static boolean inDateInterval(Observation observation, Interval interval) {
+//
+// boolean result = Dates.inInterval(observation.getObservationTime(), interval);
+//
+//// Date thruDate = periodDate.getThruDate();
+////
+//// boolean result;
+//// if (thruDate == null) {
+//// result = periodDate.afterBegin(observation.getObservationTime());
+//// } else {
+//// result = periodDate.between(observation.getObservationTime())
+//// && !thruDate.equals(observation.getObservationTime());
+//// }
+// return result;
+// }
- Date thruDate = periodDate.getThruDate();
-
- boolean result;
- if (thruDate == null) {
- result = periodDate.afterBegin(observation.getObservationTime());
- } else {
- result = periodDate.between(observation.getObservationTime())
- && !thruDate.equals(observation.getObservationTime());
- }
- return result;
+ public static Predicate<Observation> inDateInterval(Interval interval) {
+ return new InDateIntervalPredicate(interval);
}
- public static Predicate<Observation> inPeriod(PeriodDates periodDate) {
- return new InPeriodPredicate(periodDate);
- }
-
public static void removeOtherSpecies(List<Observation> observations,
List<Species> species) {
if (CollectionUtils.isNotEmpty(species)) {
@@ -140,7 +140,7 @@
}
public static List<Observation> retainsObservations(List<Observation> observations,
- PeriodDates periodDate) {
+ Interval interval) {
// List<Observation> result = Lists.newArrayList();
// Iterator<Observation> itr = observations.iterator();
@@ -168,7 +168,7 @@
List<Observation> result = FluentIterable
.from(observations)
- .filter(inPeriod(periodDate))
+ .filter(inDateInterval(interval))
.toImmutableList();
Iterables.removeAll(observations, result);
@@ -208,18 +208,18 @@
}
}
- private static class InPeriodPredicate implements Predicate<Observation> {
+ private static class InDateIntervalPredicate implements Predicate<Observation> {
- protected PeriodDates periodDate;
+ protected Interval interval;
- public InPeriodPredicate(PeriodDates periodDate) {
- Preconditions.checkNotNull(periodDate);
- this.periodDate = periodDate;
+ public InDateIntervalPredicate(Interval interval) {
+ Preconditions.checkNotNull(interval);
+ this.interval = interval;
}
@Override
public boolean apply(Observation input) {
- return Observations.inPeriod(input, periodDate);
+ return Dates.inInterval(input.getObservationTime(), interval);
}
}
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 09:50:03 UTC (rev 501)
+++ trunk/sammoa-ui-swing/src/main/java/fr/ulr/sammoa/ui/swing/flight/FlightUIHandler.java 2012-09-01 09:50:23 UTC (rev 502)
@@ -542,6 +542,7 @@
@Override
public void onCloseUI() {
transectUi.removeComponentListener(transectUIListener);
+ flightController.close();
try {
context.closeService(flightController);
1
0