r93 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/content/operation java/fr/ifremer/tutti/ui/swing/content/operation/fishing java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology java/fr/ifremer/tutti/ui/swing/util/table resources/i18n
Author: kmorin Date: 2012-12-20 12:29:15 +0100 (Thu, 20 Dec 2012) New Revision: 93 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/93 Log: refs #1812 Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx 2012-12-19 23:24:11 UTC (rev 92) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx 2012-12-20 11:29:15 UTC (rev 93) @@ -31,6 +31,8 @@ fr.ifremer.tutti.ui.swing.util.editor.SimpleTimeEditor fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUI + fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUI + fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUI jaxx.runtime.swing.editor.bean.BeanComboBox jaxx.runtime.swing.editor.bean.BeanListHeader @@ -304,225 +306,22 @@ <tab id='traitGearShootingTab' title='tutti.label.tab.fishingOperation.gearShooting'> - <Table fill='both' id='gearShootingForm'> - - <!--row> - <cell> - <JLabel id='gearShootingStartDepthLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='gearShootingStartDepthField' - constructorParams='this'/> - </cell> - </row> - - <row> - <cell> - <JLabel id='gearShootingEndDepthLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='gearShootingEndDepthField' - constructorParams='this'/> - </cell> - </row> - - <row> - <cell anchor='west'> - <JLabel id='ouvertureHorizontaleLabel'/> - </cell> - <cell fill='horizontal'> - <NumberEditor id='ouvertureHorizontaleField' - constructorParams='this'/> - </cell> - </row> - - <row> - <cell anchor='west'> - <JLabel id='ouvertureVerticaleLabel'/> - </cell> - <cell fill='horizontal'> - <NumberEditor id='ouvertureVerticaleField' - constructorParams='this'/> - </cell> - </row> - - <row> - <cell anchor='west'> - <JLabel id='longueurFunesLabel'/> - </cell> - <cell fill='horizontal'> - <NumberEditor id='longueurFunesField' constructorParams='this'/> - </cell> - </row> - - <row> - <cell anchor='west'> - <JLabel id='longueurBrasLabel'/> - </cell> - <cell fill='horizontal'> - <NumberEditor id='longueurBrasField' constructorParams='this'/> - </cell> - </row> - - <row> - <cell columns='2'> - <JPanel layout='{new GridLayout(1,0)}'> - <JCheckBox id='systemeFermetureCulCheckBox' - onItemStateChanged='handler.setBoolean(event, "systemeFermetureCul")'/> - <JCheckBox id='geometrieMesureeCheckBox' - onItemStateChanged='handler.setBoolean(event, "geometrieMesuree")'/> - </JPanel> - </cell> - </row--> - </Table> + <GearShootingTabUI id='gearShootingTabContent' constructorParams='this'/> + </tab> <tab id='environmentTab' title='tutti.label.tab.fishingOperation.environment'> <EnvironmentTabUI id='environmentTabContent' constructorParams='this'/> - <!-- <Table fill='both' id='environmentForm'> - - Beaufort scale - <row> - <cell anchor='west'> - <JLabel id='beaufortScaleLabel'/> - </cell> - <cell weightx='1.0'> - <BeanComboBox id='beaufortScaleComboBox' constructorParams='this' - genericType='BeaufortScale'/> - </cell> - </row> - - Wind direction - <row> - <cell anchor='west'> - <JLabel id='windDirectionLabel'/> - </cell> - <cell fill='horizontal'> - <NumberEditor id='windDirectionField' constructorParams='this'/> - </cell> - </row> - - Sea state - <row> - <cell anchor='west'> - <JLabel id='seaStateLabel'/> - </cell> - <cell fill='horizontal'> - <BeanComboBox id='seaStateComboBox' constructorParams='this' - genericType='SeaState'/> - </cell> - </row> - </Table>--> + </tab> <tab id='traitHydrologyTabContent' title='tutti.label.tab.fishingOperation.hydrology'> - <Table fill='both' id='hydrologyForm'> + <HydrologyTabUI id='hydrologyTabContent' constructorParams='this'/> - <!--row> - <cell> - <JLabel id='gearShootingStartSurfaceTemperatureLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='gearShootingStartSurfaceTemperatureField' - constructorParams='this'/> - </cell> - </row> - - <row> - <cell> - <JLabel id='gearShootingEndSurfaceTemperatureLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='gearShootingEndSurfaceTemperatureField' - constructorParams='this'/> - </cell> - </row> - - <row> - <cell> - <JLabel id='gearShootingStartBottomTemperatureLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='gearShootingStartBottomTemperatureField' - constructorParams='this'/> - </cell> - </row> - - <row> - <cell> - <JLabel id='gearShootingEndBottomTemperatureLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='gearShootingEndBottomTemperatureField' - constructorParams='this'/> - </cell> - </row> - - <row> - <cell> - <JLabel id='averageBottomTemperatureLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='averageBottomTemperatureField' - constructorParams='this'/> - </cell> - </row> - - <row> - <cell> - <JLabel id='gearShootingStartSurfaceSalinityLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='gearShootingStartSurfaceSalinityField' - constructorParams='this'/> - </cell> - </row> - - <row> - <cell> - <JLabel id='gearShootingEndSurfaceSalinityLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='gearShootingEndSurfaceSalinityField' - constructorParams='this'/> - </cell> - </row> - - <row> - <cell> - <JLabel id='gearShootingStartBottomSalinityLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='gearShootingStartBottomSalinityField' - constructorParams='this'/> - </cell> - </row> - - <row> - <cell> - <JLabel id='gearShootingEndBottomSalinityLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='gearShootingEndBottomSalinityField' - constructorParams='this'/> - </cell> - </row> - - <row> - <cell> - <JLabel id='averageBottomSalinityLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='averageBottomSalinityField' - constructorParams='this'/> - </cell> - </row--> - - </Table> </tab> </JTabbedPane> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2012-12-19 23:24:11 UTC (rev 92) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2012-12-20 11:29:15 UTC (rev 93) @@ -24,6 +24,7 @@ * #L% */ +import fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUI; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; @@ -33,7 +34,11 @@ import fr.ifremer.tutti.persistence.entities.referential.Zone; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; +import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUI; import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUIModel; +import fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUI; +import fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUIModel; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; @@ -179,8 +184,26 @@ model.setEmpty(true); listenValidatorValid(ui.getValidator(), getModel()); + + //init gear shooting + GearShootingTabUIModel gearShootingModel = + ui.getGearShootingTabContent().getModel(); + gearShootingModel.addPropertyChangeListener( + EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_PARAMETERS, + new PropertyChangeListener() { - EnvironmentTabUIModel environmentModel = + public void propertyChange(PropertyChangeEvent evt) { + model.setModify(true); + model.setGearShootingParameters((Map<Object, Object>)evt.getNewValue()); + } + } + ); + Map<Object, Object> gearShootingParams = getDefaultGearShootingParams(); + ui.getModel().setGearShootingParameters(gearShootingParams); + gearShootingModel.setGearShootingParameters(gearShootingParams); + + //init environment + EnvironmentTabUIModel environmentModel = ui.getEnvironmentTabContent().getModel(); environmentModel.addPropertyChangeListener( EditFishingOperationUIModel.PROPERTY_ENVIRONMENT_PARAMETERS, @@ -188,14 +211,71 @@ public void propertyChange(PropertyChangeEvent evt) { model.setModify(true); + model.setEnvironmentParameters((Map<Object, Object>)evt.getNewValue()); } } + ); + Map<Object, Object> environmentParams = getDefaultEnvironmentParams(); + ui.getModel().setEnvironmentParameters(environmentParams); + environmentModel.setEnvironmentParameters(environmentParams); + + //init hydrology + HydrologyTabUIModel hydrologyModel = + ui.getHydrologyTabContent().getModel(); + hydrologyModel.addPropertyChangeListener( + EditFishingOperationUIModel.PROPERTY_HYDROLOGY_PARAMETERS, + new PropertyChangeListener() { + + public void propertyChange(PropertyChangeEvent evt) { + model.setModify(true); + } + } ); - environmentModel.setEnvironmentParameters(getDefaultEnvironmentParams()); + Map<Object, Object> hydrologyParams = getDefaultHydrologyParams(); + ui.getModel().setHydrologyParameters(hydrologyParams); + hydrologyModel.setHydrologyParameters(getDefaultHydrologyParams()); } + protected Map<Object, Object> getDefaultGearShootingParams() { + Map<Object, Object> gearShootingParams = Maps.newLinkedHashMap(); + gearShootingParams.put( + _(new String("tutti.table.fishing.gearShooting.keys." + GearShootingTabUIModel.KEY_START_DEPTH)), + null + ); + gearShootingParams.put( + _(new String("tutti.table.fishing.gearShooting.keys." + GearShootingTabUIModel.KEY_END_DEPTH)), + null + ); + gearShootingParams.put( + _(new String("tutti.table.fishing.gearShooting.keys." + GearShootingTabUIModel.KEY_HORIZONTAL_APERTURE)), + null + ); + gearShootingParams.put( + _(new String("tutti.table.fishing.gearShooting.keys." + GearShootingTabUIModel.KEY_VERTICAL_APERTURE)), + null + ); + gearShootingParams.put( + _(new String("tutti.table.fishing.gearShooting.keys." + GearShootingTabUIModel.KEY_WARP_LENGTH)), + null + ); + gearShootingParams.put( + _(new String("tutti.table.fishing.gearShooting.keys." + GearShootingTabUIModel.KEY_ARM_LENGTH)), + null + ); + gearShootingParams.put( + _(new String("tutti.table.fishing.gearShooting.keys." + GearShootingTabUIModel.KEY_SYSTEME_FERMETURE_CUL)), + null + ); + gearShootingParams.put( + _(new String("tutti.table.fishing.gearShooting.keys." + GearShootingTabUIModel.KEY_MEASURED_GEOMETRY)), + null + ); + + return gearShootingParams; + } + protected Map<Object, Object> getDefaultEnvironmentParams() { - Map<Object, Object> environmentParams = Maps.newHashMap(); + Map<Object, Object> environmentParams = Maps.newLinkedHashMap(); environmentParams.put( _(new String("tutti.table.fishing.environment.keys." + EnvironmentTabUIModel.KEY_BEAUFORT_SCALE)), null @@ -211,6 +291,27 @@ return environmentParams; } + protected Map<Object, Object> getDefaultHydrologyParams() { + Map<Object, Object> hydrologyParams = Maps.newLinkedHashMap(); + hydrologyParams.put( + _(new String("tutti.table.fishing.hydrology.keys." + HydrologyTabUIModel.TEMPERATURE + "." + HydrologyTabUIModel.SURFACE)), + null + ); + hydrologyParams.put( + _(new String("tutti.table.fishing.hydrology.keys." + HydrologyTabUIModel.TEMPERATURE + "." + HydrologyTabUIModel.BOTTOM)), + null + ); + hydrologyParams.put( + _(new String("tutti.table.fishing.hydrology.keys." + HydrologyTabUIModel.SALINITY + "." + HydrologyTabUIModel.SURFACE)), + null + ); + hydrologyParams.put( + _(new String("tutti.table.fishing.hydrology.keys." + HydrologyTabUIModel.SALINITY + "." + HydrologyTabUIModel.BOTTOM)), + null + ); + return hydrologyParams; + } + @Override public void onCloseUI() { } @@ -244,8 +345,20 @@ // if new fishingOperation can already cancel his creation model.setModify(!empty && model.isCreate()); - ui.getEnvironmentTabContent().getModel().setEnvironmentParameters(getDefaultEnvironmentParams()); - ui.getEnvironmentTabContent().getHandler().reset(); + //reset gear shooting + GearShootingTabUI gearShootingTab = ui.getGearShootingTabContent(); + gearShootingTab.getModel().setGearShootingParameters(getDefaultGearShootingParams()); + gearShootingTab.getHandler().reset(); + + //reset environment + EnvironmentTabUI environmentTab = ui.getEnvironmentTabContent(); + environmentTab.getModel().setEnvironmentParameters(getDefaultEnvironmentParams()); + environmentTab.getHandler().reset(); + + //reset hydrology + HydrologyTabUI hydrologyTab = ui.getHydrologyTabContent(); + hydrologyTab.getModel().setHydrologyParameters(getDefaultHydrologyParams()); + hydrologyTab.getHandler().reset(); } public void cancel() { @@ -289,6 +402,14 @@ ui.getFishingOperationTabPane().setSelectedIndex(selectedIndex); getModel().setModify(false); + + for (Object key : ui.getModel().getEnvironmentParameters().keySet()) { + log.info(key + " : " + ui.getModel().getEnvironmentParameters().get(key)); + } + + for (Object key : ui.getModel().getHydrologyParameters().keySet()) { + log.info(key + " : " + ui.getModel().getHydrologyParameters().get(key)); + } } public void importPupitri() { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2012-12-19 23:24:11 UTC (rev 92) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2012-12-20 11:29:15 UTC (rev 93) @@ -71,8 +71,6 @@ public static final String PROPERTY_GEAR_SHOOTING_END_DATE = "gearShootingEndDate"; - public static final String PROPERTY_ENVIRONMENT_PARAMETERS = "environmentParameters"; - public static final String PROPERTY_FISHING_OPERATION_RECTILIGNE = "fishingOperationRectiligne"; public static final String PROPERTY_DISTANCE_CHALUTEE = "distanceChalutee"; @@ -87,6 +85,12 @@ public static final String PROPERTY_SAISISSEUR = "saisisseur"; + public static final String PROPERTY_GEAR_SHOOTING_PARAMETERS = "gearShootingParameters"; + + public static final String PROPERTY_ENVIRONMENT_PARAMETERS = "environmentParameters"; + + public static final String PROPERTY_HYDROLOGY_PARAMETERS = "hydrologyParameters"; + protected boolean empty; protected Cruise cruise; @@ -127,8 +131,6 @@ protected Integer gearShootingEndTime; - protected Map<Object, Object> environmentParameters; - protected boolean fishingOperationRectiligne; protected Float distanceChalutee; @@ -142,7 +144,13 @@ protected String comment; protected List<Person> saisisseur; + + protected Map<Object, Object> gearShootingParameters; + + protected Map<Object, Object> environmentParameters; + protected Map<Object, Object> hydrologyParameters; + protected static Binder<EditFishingOperationUIModel, FishingOperation> toBeanBinder = BinderFactory.newBinder(EditFishingOperationUIModel.class, FishingOperation.class); @@ -282,16 +290,6 @@ firePropertyChange(PROPERTY_GEAR_SHOOTING_END_DATE, oldValue, gearShootingEndDate); } - public Map<Object, Object> getEnvironmentParameters() { - return environmentParameters; - } - - public void setEnvironmentParameters(Map<Object, Object> environmentParameters) { - Object oldValue = getEnvironmentParameters(); - this.environmentParameters = environmentParameters; - firePropertyChange(PROPERTY_ENVIRONMENT_PARAMETERS, oldValue, environmentParameters); - } - public boolean isFishingOperationRectiligne() { return fishingOperationRectiligne; } @@ -361,4 +359,33 @@ firePropertyChange(PROPERTY_SAISISSEUR, null, saisisseur); } + public Map<Object, Object> getGearShootingParameters() { + return gearShootingParameters; + } + + public void setGearShootingParameters(Map<Object, Object> gearShootingParameters) { + Object oldValue = getGearShootingParameters(); + this.gearShootingParameters = gearShootingParameters; + firePropertyChange(PROPERTY_GEAR_SHOOTING_PARAMETERS, oldValue, gearShootingParameters); + } + + public Map<Object, Object> getEnvironmentParameters() { + return environmentParameters; + } + + public void setEnvironmentParameters(Map<Object, Object> environmentParameters) { + Object oldValue = getEnvironmentParameters(); + this.environmentParameters = environmentParameters; + firePropertyChange(PROPERTY_ENVIRONMENT_PARAMETERS, oldValue, environmentParameters); + } + + public Map<Object, Object> getHydrologyParameters() { + return hydrologyParameters; + } + + public void setHydrologyParameters(Map<Object, Object> hydrologyParameters) { + Object oldValue = getHydrologyParameters(); + this.hydrologyParameters = hydrologyParameters; + firePropertyChange(PROPERTY_HYDROLOGY_PARAMETERS, oldValue, hydrologyParameters); + } } \ No newline at end of file Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java 2012-12-19 23:24:11 UTC (rev 92) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java 2012-12-20 11:29:15 UTC (rev 93) @@ -78,7 +78,6 @@ } public void setValue(String value) { - log.info(">>>>>>>>>>>>>>< setValue " + value); Object oldValue = getValue(); this.value = value; firePropertyChange(PROPERTY_VALUE, oldValue, value); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2012-12-19 23:24:11 UTC (rev 92) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2012-12-20 11:29:15 UTC (rev 93) @@ -30,8 +30,6 @@ import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; import java.util.Collection; import java.util.List; import java.util.Map; @@ -128,12 +126,6 @@ final JComboBox keyCombo = ui.getNewRowKey(); keyCombo.setModel(new DefaultComboBoxModel()); - keyCombo.addItemListener(new ItemListener() { - - public void itemStateChanged(ItemEvent e) { - log.debug("item state changed " + e.paramString()); - } - }); keyCombo.getModel().addListDataListener(new ListDataListener() { public void intervalAdded(ListDataEvent e) { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java 2012-12-19 23:24:11 UTC (rev 92) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java 2012-12-20 11:29:15 UTC (rev 93) @@ -24,11 +24,11 @@ * #L% */ +import com.google.common.collect.Maps; import java.util.Map; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel; import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; -import java.util.HashMap; import org.nuiton.util.beans.Binder; import org.nuiton.util.beans.BinderModelBuilder; @@ -37,6 +37,7 @@ /** * * @author kmorin + * @since 0.3 */ public class EnvironmentTabUIModel extends AbstractTuttiTableUIModel<FishingOperation, EnvironmentRowModel, EnvironmentTabUIModel> { @@ -65,7 +66,7 @@ } public void setParameter(Object param, Object value) { - Object oldValue = new HashMap<Object, Object>(environmentParameters); + Object oldValue = Maps.newLinkedHashMap(environmentParameters); environmentParameters.put(param, value); firePropertyChange(EditFishingOperationUIModel.PROPERTY_ENVIRONMENT_PARAMETERS, oldValue, environmentParameters); } Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingRowModel.java (from rev 92, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingRowModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingRowModel.java 2012-12-20 11:29:15 UTC (rev 93) @@ -0,0 +1,62 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting; + +import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +/** + * + * @author kmorin + * @since 0.3 + */ +public class GearShootingRowModel extends AbstractTuttiBeanUIModel<Object, GearShootingRowModel> { + + private static final Log log = LogFactory.getLog(GearShootingRowModel.class); + + public static final String PROPERTY_KEY = "key"; + public static final String PROPERTY_VALUE = "value"; + + protected static final Binder<Object, GearShootingRowModel> fromBeanBinder = + BinderFactory.newBinder(Object.class, + GearShootingRowModel.class); + + protected static final Binder<GearShootingRowModel, Object> toBeanBinder = + BinderFactory.newBinder(GearShootingRowModel.class, + Object.class); + + protected String key; + + protected String value; + + public GearShootingRowModel() { + super(Object.class, fromBeanBinder, toBeanBinder); + } + + public GearShootingRowModel(String key) { + this(); + this.key = key; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + Object oldValue = getKey(); + this.key = key; + firePropertyChange(PROPERTY_KEY, oldValue, key); + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + Object oldValue = getValue(); + this.value = value; + firePropertyChange(PROPERTY_VALUE, oldValue, value); + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css (from rev 92, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.css 2012-12-20 11:29:15 UTC (rev 93) @@ -0,0 +1,29 @@ +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +#gearShootingTable { + selectionMode: {ListSelectionModel.SINGLE_SELECTION}; + selectionBackground: {null}; + selectionForeground: {Color.BLACK}; + sortable: false; +} \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.jaxx (from rev 92, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUI.jaxx 2012-12-20 11:29:15 UTC (rev 93) @@ -0,0 +1,46 @@ +<Table implements='fr.ifremer.tutti.ui.swing.TuttiUI<GearShootingTabUIModel, GearShootingTabUIHandler>'> + + <import> + org.jdesktop.swingx.JXTable + fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI + javax.swing.ListSelectionModel + java.awt.Color + </import> + + <GearShootingTabUIHandler id='handler' + initializer='getContextValue(GearShootingTabUIHandler.class)'/> + + <GearShootingTabUIModel id='model' + initializer='getContextValue(GearShootingTabUIModel.class)'/> + + <row fill='both'> + <cell fill='both' weightx='1'> + <JComboBox id='newRowKey'/> + </cell> + <cell fill='both'> + <JButton id='addRow' actionIcon='add' + onActionPerformed='handler.addRow()'/> + </cell> + </row> + <row fill='both' weighty='1'> + <cell fill='both' columns='2'> + <JScrollPane> + <JXTable id='gearShootingTable'/> + </JScrollPane> + </cell> + </row> + <script><![CDATA[ + +public GearShootingTabUI(EditFishingOperationUI parentUI) { + GearShootingTabUIHandler handler = new GearShootingTabUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +protected void $afterCompleteSetup() { + handler.afterInitUI(); +} + + ]]></script> + +</Table> \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java (from rev 92, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2012-12-20 11:29:15 UTC (rev 93) @@ -0,0 +1,189 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting; + +import com.google.common.collect.Lists; +import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI; +import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; +import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.event.ListDataEvent; +import javax.swing.event.ListDataListener; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableColumnModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.table.DefaultTableColumnModelExt; + +/** + * + * @author kmorin + * @since 0.3 + */ +public class GearShootingTabUIHandler extends AbstractTuttiTableUIHandler<GearShootingRowModel, GearShootingTabUIModel> { + + private final static Log log = LogFactory.getLog(GearShootingTabUIHandler.class); + + protected GearShootingTabUI ui; + + public GearShootingTabUIHandler(EditFishingOperationUI parentUi, GearShootingTabUI ui) { + super(parentUi.getHandler().getContext(), GearShootingRowModel.PROPERTY_VALUE); + this.ui = ui; + } + + @Override + protected JXTable getTable() { + return ui.getGearShootingTable(); + } + + @Override + protected AbstractTuttiTableModel<GearShootingRowModel> getTableModel() { + return (GearShootingTableModel) getTable().getModel(); + } + + @Override + protected TableColumnModel createTableColumnModel() { + DefaultTableColumnModelExt columnModel = + new DefaultTableColumnModelExt(); + + { + + addColumnToModel(columnModel, GearShootingTableModel.KEY); + } + + { + + addColumnToModel(columnModel, GearShootingTableModel.VALUE); + } + + + return columnModel; + } + + @Override + protected void onRowModified(GearShootingRowModel row, String propertyName, Object oldValue, Object newValue) { + } + + @Override + protected void onRowValidStateChanged(GearShootingRowModel row, Boolean oldValue, Boolean newValue) { + } + + @Override + protected void onRowModifyStateChanged(GearShootingRowModel row, Boolean oldValue, Boolean newValue) { + } + + @Override + public void beforeInitUI() { + GearShootingTabUIModel model = new GearShootingTabUIModel(); + ui.setContextValue(model); + } + + @Override + public void afterInitUI() { + initUI(ui); + + JXTable table = getTable(); + + // create table column model + TableColumnModel columnModel = createTableColumnModel(); + + // create table model + GearShootingTableModel tableModel = + new GearShootingTableModel(columnModel); + + table.setModel(tableModel); + table.setColumnModel(columnModel); + + final JComboBox keyCombo = ui.getNewRowKey(); + keyCombo.setModel(new DefaultComboBoxModel()); + + keyCombo.getModel().addListDataListener(new ListDataListener() { + + public void intervalAdded(ListDataEvent e) { + keyCombo.setEnabled(true); + ui.getAddRow().setEnabled(true); + } + + public void intervalRemoved(ListDataEvent e) { + if (keyCombo.getItemCount() == 0) { + keyCombo.setEnabled(false); + ui.getAddRow().setEnabled(false); + } + } + + public void contentsChanged(ListDataEvent e) { + keyCombo.setEnabled(true); + ui.getAddRow().setEnabled(true); + } + }); + + // modify the model when the user enters a value + ListSelectionListener listener = new TableRowModificationListener<GearShootingRowModel>( + tableModel, getRowMonitor()) { + + @Override + protected void saveSelectedRow() { + TuttiBeanMonitor<GearShootingRowModel> monitor = getRowMonitor(); + GearShootingRowModel row = monitor.getBean(); + if (row != null) { + ui.getModel().setParameter(row.getKey(), row.getValue()); + } + } + }; + table.getSelectionModel().addListSelectionListener(listener); + + } + + @Override + public void onCloseUI() { + } + + @Override + protected GearShootingTabUIModel getModel() { + return ui.getModel(); + } + + /** + * Adds a row with the parameter selected in the combo box + */ + public void addRow() { + JComboBox keyCombo = ui.getNewRowKey(); + String key = (String) keyCombo.getSelectedItem(); + GearShootingRowModel row = new GearShootingRowModel(key); + getTableModel().addNewRow(getTable().getRowCount(), row); + ui.getModel().setParameter(key, null); + + keyCombo.removeItem(key); + } + + /** + * Resets the table with the data from the database + */ + public void reset() { + Map<Object, Object> gearShootingParameters = ui.getModel().getGearShootingParameters(); + + List<GearShootingRowModel> rows = Lists.newArrayList(); + Collection<Object> params = gearShootingParameters.keySet(); + for (Object key : gearShootingParameters.keySet()) { + rows.add(new GearShootingRowModel(key.toString())); + } + + AbstractTuttiTableModel<GearShootingRowModel> tableModel = getTableModel(); + tableModel.setRows(rows); + + JComboBox keyCombo = ui.getNewRowKey(); + DefaultComboBoxModel keyComboModel = (DefaultComboBoxModel) keyCombo.getModel(); + keyComboModel.removeAllElements(); + for (String param : ui.getModel().getKeys()) { + if (!params.contains(param)) { + keyComboModel.addElement(param); + } + } + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java (from rev 92, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIModel.java 2012-12-20 11:29:15 UTC (rev 93) @@ -0,0 +1,95 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.collect.Maps; +import java.util.Map; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; +import java.util.HashMap; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderModelBuilder; + +import static org.nuiton.i18n.I18n._; + +/** + * + * @author kmorin + * @since 0.3 + */ +public class GearShootingTabUIModel extends AbstractTuttiTableUIModel<FishingOperation, GearShootingRowModel, GearShootingTabUIModel> { + + protected Map<Object, Object> gearShootingParameters; + + public static final String KEY_START_DEPTH = "startDepth"; + public static final String KEY_END_DEPTH = "endDepth"; + public static final String KEY_VERTICAL_APERTURE = "verticalAperture"; + public static final String KEY_HORIZONTAL_APERTURE = "horizontalAperture"; + public static final String KEY_WARP_LENGTH = "warpLength"; + public static final String KEY_ARM_LENGTH = "armLength"; + public static final String KEY_SYSTEME_FERMETURE_CUL = "systemeFermetureCul"; + public static final String KEY_MEASURED_GEOMETRY = "measuredGeometry"; + + protected static final Binder<FishingOperation, GearShootingTabUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, GearShootingTabUIModel.class) + .toBinder(); + + protected static final Binder<GearShootingTabUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(GearShootingTabUIModel.class, FishingOperation.class) + .toBinder(); + + public GearShootingTabUIModel() { + super(FishingOperation.class, fromBeanBinder, toBeanBinder); + } + + public Map<Object, Object> getGearShootingParameters() { + return gearShootingParameters; + } + + public void setGearShootingParameters(Map<Object, Object> gearShooting) { + this.gearShootingParameters = gearShooting; + } + + public void setParameter(Object param, Object value) { + Object oldValue = Maps.newLinkedHashMap(gearShootingParameters); + gearShootingParameters.put(param, value); + firePropertyChange(EditFishingOperationUIModel.PROPERTY_GEAR_SHOOTING_PARAMETERS, oldValue, gearShootingParameters); + } + + public String[] getKeys() { + return new String[] { + _(new String("tutti.table.fishing.gearShooting.keys." + KEY_START_DEPTH)), + _(new String("tutti.table.fishing.gearShooting.keys." + KEY_END_DEPTH)), + _(new String("tutti.table.fishing.gearShooting.keys." + KEY_HORIZONTAL_APERTURE)), + _(new String("tutti.table.fishing.gearShooting.keys." + KEY_VERTICAL_APERTURE)), + _(new String("tutti.table.fishing.gearShooting.keys." + KEY_WARP_LENGTH)), + _(new String("tutti.table.fishing.gearShooting.keys." + KEY_ARM_LENGTH)), + _(new String("tutti.table.fishing.gearShooting.keys." + KEY_SYSTEME_FERMETURE_CUL)), + _(new String("tutti.table.fishing.gearShooting.keys." + KEY_MEASURED_GEOMETRY)), + _(new String("tutti.table.fishing.gearShooting.keys." + "key3")), + _(new String("tutti.table.fishing.gearShooting.keys." + "key4")), + _(new String("tutti.table.fishing.gearShooting.keys." + "key5")) + }; + } +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java (from rev 92, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java 2012-12-20 11:29:15 UTC (rev 93) @@ -0,0 +1,62 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; +import javax.swing.table.TableColumnModel; + +import static org.nuiton.i18n.I18n.n_; + +/** + * + * @author kmorin + * since 0.3 + */ +public class GearShootingTableModel extends AbstractTuttiTableModel<GearShootingRowModel> { + + public static final ColumnIdentifier<GearShootingRowModel> KEY = ColumnIdentifier.newId( + GearShootingRowModel.PROPERTY_KEY, + n_("tutti.table.fishing.gearShooting.header.key"), + n_("tutti.table.fishing.gearShooting.header.key")); + + public static final ColumnIdentifier<GearShootingRowModel> VALUE = ColumnIdentifier.newId( + GearShootingRowModel.PROPERTY_VALUE, + n_("tutti.table.fishing.gearShooting.header.value"), + n_("tutti.table.fishing.gearShooting.header.value")); + + public GearShootingTableModel(TableColumnModel columnModel) { + super(columnModel); + + setNoneEditableCols(KEY); + } + + @Override + protected GearShootingRowModel createNewRow() { + GearShootingRowModel result = new GearShootingRowModel(); + return result; + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java (from rev 91, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java 2012-12-20 11:29:15 UTC (rev 93) @@ -0,0 +1,88 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology; + +import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +/** + * + * @author kmorin + * @since 0.3 + */ +public class HydrologyRowModel extends AbstractTuttiBeanUIModel<Object, HydrologyRowModel> { + + private static final Log log = LogFactory.getLog(HydrologyRowModel.class); + + public static final String PROPERTY_KEY = "key"; + public static final String PROPERTY_GEAR_SHOOTING_START_VALUE = "gearShootingStartValue"; + public static final String PROPERTY_GEAR_SHOOTING_END_VALUE = "gearShootingEndValue"; + public static final String PROPERTY_AVERAGE_VALUE = "averageValue"; + + protected static final Binder<Object, HydrologyRowModel> fromBeanBinder = + BinderFactory.newBinder(Object.class, + HydrologyRowModel.class); + + protected static final Binder<HydrologyRowModel, Object> toBeanBinder = + BinderFactory.newBinder(HydrologyRowModel.class, + Object.class); + + protected String key; + + protected String gearShootingStartValue; + + protected String gearShootingEndValue; + + protected String averageValue; + + public HydrologyRowModel() { + super(Object.class, fromBeanBinder, toBeanBinder); + } + + public HydrologyRowModel(String key) { + this(); + this.key = key; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + Object oldValue = getKey(); + this.key = key; + firePropertyChange(PROPERTY_KEY, oldValue, key); + } + + public String getGearShootingStartValue() { + return gearShootingStartValue; + } + + public void setGearShootingStartValue(String gearShootingStartValue) { + Object oldValue = getGearShootingStartValue(); + this.gearShootingStartValue = gearShootingStartValue; + firePropertyChange(PROPERTY_GEAR_SHOOTING_START_VALUE, oldValue, gearShootingStartValue); + } + + public String getGearShootingEndValue() { + return gearShootingEndValue; + } + + public void setGearShootingEndValue(String gearShootingEndValue) { + Object oldValue = getGearShootingEndValue(); + this.gearShootingEndValue = gearShootingEndValue; + firePropertyChange(PROPERTY_GEAR_SHOOTING_END_VALUE, oldValue, gearShootingEndValue); + } + + public String getAverageValue() { + return averageValue; + } + + public void setAverageValue(String averageValue) { + Object oldValue = getAverageValue(); + this.averageValue = averageValue; + firePropertyChange(PROPERTY_AVERAGE_VALUE, oldValue, averageValue); + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css (from rev 91, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.css 2012-12-20 11:29:15 UTC (rev 93) @@ -0,0 +1,6 @@ +#hydrologyTable { + selectionMode: {ListSelectionModel.SINGLE_SELECTION}; + selectionBackground: {null}; + selectionForeground: {Color.BLACK}; + sortable: false; +} \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx (from rev 91, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUI.jaxx 2012-12-20 11:29:15 UTC (rev 93) @@ -0,0 +1,46 @@ +<Table implements='fr.ifremer.tutti.ui.swing.TuttiUI<HydrologyTabUIModel, HydrologyTabUIHandler>'> + + <import> + org.jdesktop.swingx.JXTable + fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI + javax.swing.ListSelectionModel + java.awt.Color + </import> + + <HydrologyTabUIHandler id='handler' + initializer='getContextValue(HydrologyTabUIHandler.class)'/> + + <HydrologyTabUIModel id='model' + initializer='getContextValue(HydrologyTabUIModel.class)'/> + + <row fill='both'> + <cell fill='both' weightx='1'> + <JComboBox id='newRowKey'/> + </cell> + <cell fill='both'> + <JButton id='addRow' actionIcon='add' + onActionPerformed='handler.addRow()'/> + </cell> + </row> + <row fill='both' weighty='1'> + <cell fill='both' columns='2'> + <JScrollPane> + <JXTable id='hydrologyTable'/> + </JScrollPane> + </cell> + </row> + <script><![CDATA[ + +public HydrologyTabUI(EditFishingOperationUI parentUI) { + HydrologyTabUIHandler handler = new HydrologyTabUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +protected void $afterCompleteSetup() { + handler.afterInitUI(); +} + + ]]></script> + +</Table> \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java (from rev 91, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2012-12-20 11:29:15 UTC (rev 93) @@ -0,0 +1,207 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology; + +import com.google.common.collect.Lists; +import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI; +import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; +import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.event.ListDataEvent; +import javax.swing.event.ListDataListener; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableColumnModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.table.DefaultTableColumnModelExt; + +/** + * + * @author kmorin + * @since 0.3 + */ +public class HydrologyTabUIHandler extends AbstractTuttiTableUIHandler<HydrologyRowModel, HydrologyTabUIModel> { + + private final static Log log = LogFactory.getLog(HydrologyTabUIHandler.class); + + protected HydrologyTabUI ui; + + public HydrologyTabUIHandler(EditFishingOperationUI parentUi, HydrologyTabUI ui) { + super(parentUi.getHandler().getContext(), + HydrologyRowModel.PROPERTY_GEAR_SHOOTING_START_VALUE, + HydrologyRowModel.PROPERTY_AVERAGE_VALUE, + HydrologyRowModel.PROPERTY_GEAR_SHOOTING_END_VALUE + ); + this.ui = ui; + } + + @Override + protected JXTable getTable() { + return ui.getHydrologyTable(); + } + + @Override + protected AbstractTuttiTableModel<HydrologyRowModel> getTableModel() { + return (HydrologyTableModel) getTable().getModel(); + } + + @Override + protected TableColumnModel createTableColumnModel() { + DefaultTableColumnModelExt columnModel = + new DefaultTableColumnModelExt(); + + { + + addColumnToModel(columnModel, HydrologyTableModel.KEY); + } + + { + + addColumnToModel(columnModel, HydrologyTableModel.GEAR_SHOOTING_START_VALUE); + } + + { + + addColumnToModel(columnModel, HydrologyTableModel.AVERAGE_VALUE); + } + + { + + addColumnToModel(columnModel, HydrologyTableModel.GEAR_SHOOTING_END_VALUE); + } + + + return columnModel; + } + + @Override + protected void onRowModified(HydrologyRowModel row, String propertyName, Object oldValue, Object newValue) { + } + + @Override + protected void onRowValidStateChanged(HydrologyRowModel row, Boolean oldValue, Boolean newValue) { + } + + @Override + protected void onRowModifyStateChanged(HydrologyRowModel row, Boolean oldValue, Boolean newValue) { + } + + @Override + public void beforeInitUI() { + HydrologyTabUIModel model = new HydrologyTabUIModel(); + ui.setContextValue(model); + } + + @Override + public void afterInitUI() { + initUI(ui); + + JXTable table = getTable(); + + // create table column model + TableColumnModel columnModel = createTableColumnModel(); + + // create table model + HydrologyTableModel tableModel = + new HydrologyTableModel(columnModel); + + table.setModel(tableModel); + table.setColumnModel(columnModel); + + final JComboBox keyCombo = ui.getNewRowKey(); + keyCombo.setModel(new DefaultComboBoxModel()); + + keyCombo.getModel().addListDataListener(new ListDataListener() { + + public void intervalAdded(ListDataEvent e) { + keyCombo.setEnabled(true); + ui.getAddRow().setEnabled(true); + } + + public void intervalRemoved(ListDataEvent e) { + if (keyCombo.getItemCount() == 0) { + keyCombo.setEnabled(false); + ui.getAddRow().setEnabled(false); + } + } + + public void contentsChanged(ListDataEvent e) { + keyCombo.setEnabled(true); + ui.getAddRow().setEnabled(true); + } + }); + + // modify the model when the user enters a value + ListSelectionListener listener = new TableRowModificationListener<HydrologyRowModel>( + tableModel, getRowMonitor()) { + + @Override + protected void saveSelectedRow() { + TuttiBeanMonitor<HydrologyRowModel> monitor = getRowMonitor(); + HydrologyRowModel row = monitor.getBean(); + if (row != null) { + ui.getModel().setParameter(row.getKey(), + row.getGearShootingStartValue(), + row.getGearShootingEndValue(), + row.getAverageValue() + ); + } + } + }; + table.getSelectionModel().addListSelectionListener(listener); + + } + + @Override + public void onCloseUI() { + } + + @Override + protected HydrologyTabUIModel getModel() { + return ui.getModel(); + } + + /** + * Adds a row with the parameter selected in the combo box + */ + public void addRow() { + JComboBox keyCombo = ui.getNewRowKey(); + String key = (String) keyCombo.getSelectedItem(); + HydrologyRowModel row = new HydrologyRowModel(key); + getTableModel().addNewRow(getTable().getRowCount(), row); + ui.getModel().setParameter(key, null, null, null); + + keyCombo.removeItem(key); + } + + /** + * Resets the table with the data from the database + */ + public void reset() { + Map<Object, Object> hydrologyParameters = ui.getModel().getHydrologyParameters(); + + List<HydrologyRowModel> rows = Lists.newArrayList(); + Collection<Object> params = hydrologyParameters.keySet(); + for (Object key : hydrologyParameters.keySet()) { + rows.add(new HydrologyRowModel(key.toString())); + } + + AbstractTuttiTableModel<HydrologyRowModel> tableModel = getTableModel(); + tableModel.setRows(rows); + + JComboBox keyCombo = ui.getNewRowKey(); + DefaultComboBoxModel keyComboModel = (DefaultComboBoxModel) keyCombo.getModel(); + keyComboModel.removeAllElements(); + for (String param : ui.getModel().getKeys()) { + if (!params.contains(param)) { + keyComboModel.addElement(param); + } + } + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java (from rev 91, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java 2012-12-20 11:29:15 UTC (rev 93) @@ -0,0 +1,69 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology; + +import com.google.common.collect.Maps; +import java.util.Map; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderModelBuilder; + +import static org.nuiton.i18n.I18n._; + +/** + * + * @author kmorin + * @since 0.3 + */ +public class HydrologyTabUIModel extends AbstractTuttiTableUIModel<FishingOperation, HydrologyRowModel, HydrologyTabUIModel> { + + protected Map<Object, Object> hydrologyParameters; + + public static final String GEAR_SHOOTING_START = "gearShootingStart"; + public static final String GEAR_SHOOTING_END = "gearShootingEnd"; + public static final String AVERAGE = "average"; + public static final String SURFACE = "surface"; + public static final String BOTTOM = "bottom"; + public static final String TEMPERATURE = "temperature"; + public static final String SALINITY = "salinity"; + + protected static final Binder<FishingOperation, HydrologyTabUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, HydrologyTabUIModel.class) + .toBinder(); + + protected static final Binder<HydrologyTabUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(HydrologyTabUIModel.class, FishingOperation.class) + .toBinder(); + + public HydrologyTabUIModel() { + super(FishingOperation.class, fromBeanBinder, toBeanBinder); + } + + public Map<Object, Object> getHydrologyParameters() { + return hydrologyParameters; + } + + public void setHydrologyParameters(Map<Object, Object> environmentParameters) { + this.hydrologyParameters = environmentParameters; + } + + public void setParameter(Object param, Object gearShootingStartValue, + Object gearShootingEndValue, Object averageValue) { + + Object oldValue = Maps.newLinkedHashMap(hydrologyParameters); + hydrologyParameters.put(param + "." + GEAR_SHOOTING_START, gearShootingStartValue); + hydrologyParameters.put(param + "." + GEAR_SHOOTING_END, gearShootingEndValue); + hydrologyParameters.put(param + "." + AVERAGE, averageValue); + firePropertyChange(EditFishingOperationUIModel.PROPERTY_HYDROLOGY_PARAMETERS, oldValue, hydrologyParameters); + } + + public String[] getKeys() { + return new String[] { + _(new String("tutti.table.fishing.hydrology.keys." + TEMPERATURE + "." + SURFACE)), + _(new String("tutti.table.fishing.hydrology.keys." + TEMPERATURE + "." + BOTTOM)), + _(new String("tutti.table.fishing.hydrology.keys." + SALINITY + "." + SURFACE)), + _(new String("tutti.table.fishing.hydrology.keys." + SALINITY + "." + BOTTOM)), + _(new String("tutti.table.fishing.hydrology.keys." + "key3")), + _(new String("tutti.table.fishing.hydrology.keys." + "key4")), + _(new String("tutti.table.fishing.hydrology.keys." + "key5")) + }; + } +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java (from rev 91, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java 2012-12-20 11:29:15 UTC (rev 93) @@ -0,0 +1,72 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; +import javax.swing.table.TableColumnModel; + +import static org.nuiton.i18n.I18n.n_; + +/** + * + * @author kmorin + * since 0.3 + */ +public class HydrologyTableModel extends AbstractTuttiTableModel<HydrologyRowModel> { + + public static final ColumnIdentifier<HydrologyRowModel> KEY = ColumnIdentifier.newId( + HydrologyRowModel.PROPERTY_KEY, + n_("tutti.table.fishing.hydrology.header.key"), + n_("tutti.table.fishing.hydrology.header.key")); + + public static final ColumnIdentifier<HydrologyRowModel> GEAR_SHOOTING_START_VALUE = ColumnIdentifier.newId( + HydrologyRowModel.PROPERTY_GEAR_SHOOTING_START_VALUE, + n_("tutti.table.fishing.hydrology.header.gearShootingStartValue"), + n_("tutti.table.fishing.hydrology.header.gearShootingStartValue")); + + public static final ColumnIdentifier<HydrologyRowModel> GEAR_SHOOTING_END_VALUE = ColumnIdentifier.newId( + HydrologyRowModel.PROPERTY_GEAR_SHOOTING_END_VALUE, + n_("tutti.table.fishing.hydrology.header.gearShootingEndValue"), + n_("tutti.table.fishing.hydrology.header.gearShootingEndValue")); + + public static final ColumnIdentifier<HydrologyRowModel> AVERAGE_VALUE = ColumnIdentifier.newId( + HydrologyRowModel.PROPERTY_AVERAGE_VALUE, + n_("tutti.table.fishing.hydrology.header.averageValue"), + n_("tutti.table.fishing.hydrology.header.averageValue")); + + public HydrologyTableModel(TableColumnModel columnModel) { + super(columnModel); + + setNoneEditableCols(KEY); + } + + @Override + protected HydrologyRowModel createNewRow() { + HydrologyRowModel result = new HydrologyRowModel(); + return result; + } + +} Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-19 23:24:11 UTC (rev 92) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-20 11:29:15 UTC (rev 93) @@ -114,7 +114,7 @@ // listen when bean is changed rowMonitor.addPropertyChangeListener(TuttiBeanMonitor.PROPERTY_BEAN, new PropertyChangeListener() { - + final Set<String> propertiesToSkip = Sets.newHashSet(getRowPropertiesToIgnore()); Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-19 23:24:11 UTC (rev 92) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-20 11:29:15 UTC (rev 93) @@ -176,6 +176,30 @@ tutti.table.fishing.environment.keys.key5=Clé 5 tutti.table.fishing.environment.keys.seaState=État de la mer tutti.table.fishing.environment.keys.windDirection=Direction du vent +tutti.table.fishing.gearShooting.header.key=Clé +tutti.table.fishing.gearShooting.header.value=Valeur +tutti.table.fishing.gearShooting.keys.armLength=Longueur des bras +tutti.table.fishing.gearShooting.keys.endDepth=Profondeur fin de traine +tutti.table.fishing.gearShooting.keys.horizontalAperture=Ouverture horizontale +tutti.table.fishing.gearShooting.keys.key3=Clé 3 +tutti.table.fishing.gearShooting.keys.key4=Clé 4 +tutti.table.fishing.gearShooting.keys.key5=Clé 5 +tutti.table.fishing.gearShooting.keys.measuredGeometry=Géométrie mesurée +tutti.table.fishing.gearShooting.keys.startDepth=Profondeur début de traine +tutti.table.fishing.gearShooting.keys.systemeFermetureCul=Système de fermeture du cul +tutti.table.fishing.gearShooting.keys.verticalAperture=Ouverture verticale +tutti.table.fishing.gearShooting.keys.warpLength=Longueur des funes +tutti.table.fishing.hydrology.header.averageValue=Moyenne +tutti.table.fishing.hydrology.header.gearShootingEndValue=Début de traîne +tutti.table.fishing.hydrology.header.gearShootingStartValue=Fin de traîne +tutti.table.fishing.hydrology.header.key=Clé +tutti.table.fishing.hydrology.keys.key3=Clé 3 +tutti.table.fishing.hydrology.keys.key4=Clé 4 +tutti.table.fishing.hydrology.keys.key5=Clé 5 +tutti.table.fishing.hydrology.keys.salinity.bottom=Salinité au fond +tutti.table.fishing.hydrology.keys.salinity.surface=Salinité à la surface +tutti.table.fishing.hydrology.keys.temperature.bottom=Température au fond +tutti.table.fishing.hydrology.keys.temperature.surface=Température à la surface tutti.table.macrowaste.batch.header.comment=Commentaire tutti.table.macrowaste.batch.header.file=Pièces jointes tutti.table.macrowaste.batch.header.macroWasteCategory=Catégorie
participants (1)
-
kmorin@users.forge.codelutin.com