r4227 - in trunk/src/main: java/fr/ifremer/isisfish/ui java/fr/ifremer/isisfish/ui/input java/fr/ifremer/isisfish/ui/input/cell java/fr/ifremer/isisfish/ui/input/check java/fr/ifremer/isisfish/ui/input/gear java/fr/ifremer/isisfish/ui/input/metier java/fr/ifremer/isisfish/ui/input/observation java/fr/ifremer/isisfish/ui/input/population java/fr/ifremer/isisfish/ui/input/port java/fr/ifremer/isisfish/ui/input/setofvessels java/fr/ifremer/isisfish/ui/input/species java/fr/ifremer/isisfish/
Author: echatellier Date: 2015-05-20 12:09:09 +0000 (Wed, 20 May 2015) New Revision: 4227 Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4227 Log: Move script code to dedicated handler Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoComboRenderer.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonInfoComboRenderer.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionListRenderer.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/MetierListRenderer.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeListRenderer.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/models/common/EnumComboModel.java Removed: trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/ Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/SaveVerifier.java trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeSaveVerifier.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckResult.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/FisheryTreeSelectionModel.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneUI.jaxx trunk/src/main/resources/i18n/isis-fish_en_GB.properties Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/SaveVerifier.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/SaveVerifier.java 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/SaveVerifier.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric + * Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -25,6 +25,8 @@ package fr.ifremer.isisfish.ui; +import javax.swing.JOptionPane; + /** * Isis interface modification verifier. * @@ -38,16 +40,18 @@ * by : $Author$ */ public interface SaveVerifier { - + + public static final int YES_OPTION = JOptionPane.YES_OPTION; + public static final int NO_OPTION = JOptionPane.NO_OPTION; + public static final int CANCEL_OPTION = JOptionPane.CANCEL_OPTION; + /** * Tell verifier to check for unsaved modification. * - * Then return user choice ({@link javax.swing.JOptionPane} type). - * - * @return user JOptionPane response - * @see javax.swing.JOptionPane#YES_OPTION - * @see javax.swing.JOptionPane#NO_OPTION - * @see javax.swing.JOptionPane#CANCEL_OPTION + * @return user int response + * @see #YES_OPTION + * @see #NO_OPTION + * @see #CANCEL_OPTION */ public int checkEdit(); } Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeSaveVerifier.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeSaveVerifier.java 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeSaveVerifier.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2009 - 2010 Ifremer, Code Lutin + * Copyright (C) 2009 - 2015 Ifremer, 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 @@ -28,8 +28,6 @@ import java.util.ArrayList; import java.util.List; -import javax.swing.JOptionPane; - /** * WelcomeSaveVerifier. * @@ -66,7 +64,7 @@ // return false, if at least one verifier // return cancel option - if (reponse == JOptionPane.CANCEL_OPTION) { + if (reponse == SaveVerifier.CANCEL_OPTION) { canExit = false; } } Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/FormuleComboRenderer.java) =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/FormuleComboRenderer.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,69 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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.ifremer.isisfish.ui.input; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import fr.ifremer.isisfish.entities.Formule; + +/** + * Renderer pour la combo des {@link Formule}. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class FormuleComboRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = -8277883340386163087L; + + /* + * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) + */ + @Override + public Component getListCellRendererComponent(JList<?> list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + // this must be used to have alterned highlight rows and default + // selection color + JLabel c = (JLabel) super.getListCellRendererComponent(list, value, + index, isSelected, cellHasFocus); + + // there is no default selection + if (value != null) { + Formule formule = (Formule) value; + c.setText(formule.getName()); + } + return c; + } +} Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputContentHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -48,7 +48,7 @@ protected void init(final T inputContentUI) { this.inputContentUI = inputContentUI; } - + /** * Action appelée lors du clic sur un layer (sensitivity). * Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputOneEquationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -242,41 +242,30 @@ ]]> </script> <JPanel id="body"> - <Table> + <Table insets="0"> <row> <cell fill='horizontal' anchor='east'> <JLabel text='{getText()}' enabled='{isActive()}'/> </cell> - <cell fill='horizontal' weightx='1.0'> + <cell fill='horizontal'> <JComboBox id="formuleComboBox" onActionPerformed='formuleChanged()' enabled='{isActive()}' genericType="fr.ifremer.isisfish.entities.Formule" - renderer="{new fr.ifremer.isisfish.ui.input.renderer.FormuleComboRenderer()}" /> + renderer="{new FormuleComboRenderer()}" /> </cell> </row> <row> - <cell fill='both' weighty='1.0'> - <Table> - <row> - <cell fill='horizontal'> - <JButton text="isisfish.common.saveModel" onActionPerformed='saveModel()' enabled='{isActive() && formuleCategory != null}'/> - </cell> - </row> - <row> - <cell fill='horizontal'> - <JButton text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActive() && clazz != null && formuleCategory != null}'/> - </cell> - </row> - <row> - <cell fill='horizontal' weighty='1.0'> - <JPanel/> - </cell> - </row> - </Table> + <cell fill='horizontal' anchor='north'> + <JButton text="isisfish.common.saveModel" onActionPerformed='saveModel()' enabled='{isActive() && formuleCategory != null}'/> </cell> - <cell fill='both' weightx='1.0' weighty='1.0'> + <cell fill='both' weightx='1.0' weighty='1.0' rows="2"> <org.nuiton.widget.editor.Editor id='editor' askIfNotSaved="false" enabled='{isActive()}'/> </cell> </row> + <row> + <cell fill='horizontal' anchor='north' weighty='1.0'> + <JButton text="isisfish.common.openEditor" onActionPerformed='openEditor()' enabled='{isActive() && clazz != null && formuleCategory != null}'/> + </cell> + </row> </Table> </JPanel> </fr.ifremer.isisfish.ui.input.InputContentUI> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputTabbedPaneListener.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -25,7 +25,6 @@ package fr.ifremer.isisfish.ui.input; -import javax.swing.JOptionPane; import javax.swing.JTabbedPane; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -114,7 +113,7 @@ int response = saveVerifier.checkEdit(); - if (response == JOptionPane.CANCEL_OPTION) { + if (response == SaveVerifier.CANCEL_OPTION) { exit = false; } return exit; Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/cell/CellHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -31,9 +31,6 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import com.bbn.openmap.event.SelectMouseMode; import fr.ifremer.isisfish.entities.Cell; @@ -49,9 +46,6 @@ */ public class CellHandler extends InputContentHandler<CellUI> { - /** Class logger. */ - private static final Log log = LogFactory.getLog(CellHandler.class); - protected boolean init; protected void init(final CellUI cellUI) { Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckResult.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckResult.java 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckResult.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2002 - 2011 Ifremer, CodeLutin, Chatellier Eric + * Copyright (C) 2002 - 2015 Ifremer, CodeLutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -48,9 +48,9 @@ protected Set<Object> order = new LinkedHashSet<Object>(); - protected Map<Object, List<String>> info = new HashMap<Object, List<String>>(); - protected Map<Object, List<String>> warning = new HashMap<Object, List<String>>(); - protected Map<Object, List<String>> error = new HashMap<Object, List<String>>(); + protected Map<Object, List<String>> info = new HashMap<>(); + protected Map<Object, List<String>> warning = new HashMap<>(); + protected Map<Object, List<String>> error = new HashMap<>(); public StringBuffer getInfo() { StringBuffer result = new StringBuffer(); @@ -187,7 +187,7 @@ order.add(o); List<String> list = info.get(o); if (list == null) { - info.put(o, list = new LinkedList<String>()); + info.put(o, list = new LinkedList<>()); } list.add(message); } @@ -202,7 +202,7 @@ order.add(o); List<String> list = warning.get(o); if (list == null) { - warning.put(o, list = new LinkedList<String>()); + warning.put(o, list = new LinkedList<>()); } list.add(message); } @@ -217,7 +217,7 @@ order.add(o); List<String> list = error.get(o); if (list == null) { - error.put(o, list = new LinkedList<String>()); + error.put(o, list = new LinkedList<>()); } list.add(message); } Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,60 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.gear; + +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * Gear handler. + */ +public class GearHandler extends InputContentHandler<GearUI> { + + protected void init(final GearUI gearUI) { + super.init(gearUI); + + gearUI.setButtonTitle(t("isisfish.input.continueMetiers")); + gearUI.setNextPath(n("isisfish.input.tree.metiers")); + + gearUI.addPropertyChangeListener(GearUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + + } + if (evt.getNewValue() != null) { + //getVerifier().addCurrentPanel(gearTabUI, selectivityUI); + } + } + }); + + // install change listener + // (depends on sensitivity can't be done on constructor) + gearUI.installChangeListener(gearUI.gearTab); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearHandler.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,54 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.gear; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * Gear tab handler. + */ +public class GearTabHandler extends InputContentHandler<GearTabUI> { + + protected void init(final GearTabUI gearTabUI) { + super.init(gearTabUI); + + gearTabUI.addPropertyChangeListener(GearTabUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + gearTabUI.fieldGearName.setText(""); + gearTabUI.fieldGearEffortUnit.setText(""); + gearTabUI.fieldGearStandardisationFactor.setText(""); + gearTabUI.fieldGearParamName.setText(""); + gearTabUI.fieldGearComment.setText(""); + } + if (evt.getNewValue() != null) { + + } + } + }); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearTabUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric + Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -27,11 +27,7 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Gear id='bean' javaBean='null'/> - <import> - fr.ifremer.isisfish.entities.Gear; - java.beans.PropertyChangeEvent; - java.beans.PropertyChangeListener; - </import> + <GearTabHandler id="handler" /> <BeanValidator id='validator' context="gear" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Gear' @@ -41,40 +37,11 @@ </BeanValidator> <script><![CDATA[ - -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldGearName.setText(""); - fieldGearEffortUnit.setText(""); - fieldGearStandardisationFactor.setText(""); - fieldGearParamName.setText(""); - fieldGearComment.setText(""); - } - if (evt.getNewValue() != null) { - - } - } - }); -} - -/*public void refresh() { - Gear gear = getSaveVerifier().getEntity(Gear.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - setBean(null); - setBean(gear); - - getVerifier().addCurrentPanel(rangeOfValues); - - // chatellier commented since number editor is not working - //if (getBean() != null) { - // fieldGearStandardisationFactor.init(); - //} -}*/ + protected void $afterCompleteSetup() { + handler.init(this); + } ]]></script> + <JPanel id="body"> <Table> <row> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -26,50 +26,25 @@ <fr.ifremer.isisfish.entities.Gear id='bean' javaBean='null'/> - <import> - static org.nuiton.i18n.I18n.t - static org.nuiton.i18n.I18n.n - java.beans.PropertyChangeEvent; - java.beans.PropertyChangeListener; - </import> + <GearHandler id="handler" /> + <script><![CDATA[ + protected void $afterCompleteSetup() { + handler.init(this); + } -protected void $afterCompleteSetup() { - setButtonTitle(t("isisfish.input.continueMetiers")); - setNextPath(n("isisfish.input.tree.metiers")); + @Override + public void setLayer(boolean active) { + super.setLayer(active); + gearTabUI.setLayer(active); + selectivityUI.setLayer(active); + } - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - - } - if (evt.getNewValue() != null) { - //getVerifier().addCurrentPanel(gearTabUI, selectivityUI); - } - } - }); - - // install change listener - // (depends on sensitivity can't be done on constructor) - installChangeListener(gearTab); -} - -/*public void refresh() { - //getVerifier().addCurrentPanel(gearTabUI, selectivityUI); -}*/ - -@Override -public void setLayer(boolean active) { - super.setLayer(active); - gearTabUI.setLayer(active); - selectivityUI.setLayer(active); -} - -@Override -public void resetChangeModel() { - gearTabUI.resetChangeModel(); - selectivityUI.resetChangeModel(); -} + @Override + public void resetChangeModel() { + gearTabUI.resetChangeModel(); + selectivityUI.resetChangeModel(); + } ]]></script> <JPanel id="body"> <JTabbedPane constraints='BorderLayout.CENTER' id="gearTab"> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,86 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.gear; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import fr.ifremer.isisfish.types.RangeOfValues; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericComboModel; + +/** + * RangeOfValues handler. + */ +public class RangeOfValuesHandler extends InputContentHandler<RangeOfValuesUI> { + + /** Class logger. */ + private static final Log log = LogFactory.getLog(RangeOfValuesHandler.class); + + protected boolean init; + + protected void init(final RangeOfValuesUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(RangeOfValuesUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + + GenericComboModel<String> gearParamTypeModel = new GenericComboModel<>(); + if (evt.getNewValue() == null) { + inputContentUI.fieldGearParamPossibleValue.setText(""); + inputContentUI.fieldGearParamType.setSelectedItem(null); + inputContentUI.fieldGearParamType.setModel(gearParamTypeModel); + } + if (evt.getNewValue() != null) { + init = true; + + List<String> values = new ArrayList<String>(); + for (String value : RangeOfValues.getPossibleTypes()) { + values.add(value); + } + gearParamTypeModel.setElementList(values); + + inputContentUI.fieldGearParamType.setModel(gearParamTypeModel); + if (inputContentUI.getBean().getPossibleValue() != null) { + inputContentUI.fieldGearParamType.setSelectedItem(inputContentUI.getBean().getPossibleValue().getType()); + } + + init = false; + } + } + }); + } + + protected void gearParamChanged() { + if (inputContentUI.fieldGearParamType.getSelectedItem() != null && !init) { + inputContentUI.getBean().setPossibleValue(new RangeOfValues(inputContentUI.fieldGearParamType.getSelectedItem().toString() + .concat("[" + inputContentUI.fieldGearParamPossibleValue.getText() + "]"))); + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/RangeOfValuesUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -27,55 +27,12 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Gear id='bean' javaBean='null'/> - <import> - fr.ifremer.isisfish.types.RangeOfValues - fr.ifremer.isisfish.entities.Gear - java.beans.PropertyChangeEvent; - java.beans.PropertyChangeListener - java.util.List - java.util.ArrayList - fr.ifremer.isisfish.ui.models.common.GenericComboModel - </import> + <RangeOfValuesHandler id="handler" /> <script><![CDATA[ - -boolean init = false; - -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - - GenericComboModel<String> gearParamTypeModel = new GenericComboModel<>(); - if (evt.getNewValue() == null) { - fieldGearParamPossibleValue.setText(""); - fieldGearParamType.setSelectedItem(null); - fieldGearParamType.setModel(gearParamTypeModel); - } - if (evt.getNewValue() != null) { - init = true; - - List<String> values = new ArrayList<String>(); - for (String value : RangeOfValues.getPossibleTypes()) { - values.add(value); - } - gearParamTypeModel.setElementList(values); - - fieldGearParamType.setModel(gearParamTypeModel); - if (getBean().getPossibleValue() != null) { - fieldGearParamType.setSelectedItem(getBean().getPossibleValue().getType()); - } - - init = false; - } - } - }); -} - -protected void gearParamChanged() { - if (fieldGearParamType.getSelectedItem() != null && !init) { - getBean().setPossibleValue(new RangeOfValues(fieldGearParamType.getSelectedItem().toString().concat("[" + fieldGearParamPossibleValue.getText() + "]"))); + protected void $afterCompleteSetup() { + handler.init(this); } -} ]]></script> <JPanel id='body'> <Table> @@ -83,11 +40,11 @@ <cell fill='horizontal' weightx='0.5'> <JComboBox id="fieldGearParamType" genericType="String" - onItemStateChanged='gearParamChanged()' enabled='{isActive()}'/> + onItemStateChanged='handler.gearParamChanged()' enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='0.5'> <JTextField id="fieldGearParamPossibleValue" text='{getBean().getPossibleValue() == null ? "" : getBean().getPossibleValue().getValues()}' - onKeyReleased='gearParamChanged()' enabled='{isActive()}'/> + onKeyReleased='handler.gearParamChanged()' enabled='{isActive()}'/> </cell> </row> </Table> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,142 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.gear; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import fr.ifremer.isisfish.entities.Equation; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.Selectivity; +import fr.ifremer.isisfish.entities.Species; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericComboModel; +import fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor; + +/** + * Selectivity handler. + */ +public class SelectivityHandler extends InputContentHandler<SelectivityUI> { + + /** Class logger. */ + private static final Log log = LogFactory.getLog(SelectivityHandler.class); + + protected void init(final SelectivityUI selectivityUI) { + super.init(selectivityUI); + + selectivityUI.addPropertyChangeListener(SelectivityUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + selectivityUI.setPopulation(null); + selectivityUI.selectivityTable.setModel(new GearPopulationSelectivityModel()); + } + if (evt.getNewValue() != null) { + refresh(); + } + } + }); + } + + public void refresh() { + + //Gear gear = (Gear)inputContentUI.getSaveVerifier().getEntity(Gear.class); + + // add null before, for second to be considered as a changed event + // otherwize, setBean has no effect + //setBean(null); + //setBean(gear); + + if (inputContentUI.getBean() != null) { + setSelectivityTableModel(); + inputContentUI.fieldSelectivityPopulation.setModel(getSelectivityPopulationModel()); + } + } + + protected void setSelectivityTableModel() { + + List<Selectivity> selectivitiesList = new ArrayList<Selectivity>(); + + // set model even if no selectivity + // to clear data + if (inputContentUI.getBean().getPopulationSelectivity() != null) { + // move collection to list + // and add all entity to verifier + for (Selectivity oneSelectivity : inputContentUI.getBean().getPopulationSelectivity()) { + inputContentUI.getSaveVerifier().addCurrentEntity(oneSelectivity); + selectivitiesList.add(oneSelectivity); + + // hack to enable save button :( + oneSelectivity.addPropertyChangeListener(new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + inputContentUI.changeModel.setStayChanged(true); + } + }); + } + } + + // set table model + GearPopulationSelectivityModel model = new GearPopulationSelectivityModel(selectivitiesList); + inputContentUI.selectivityTable.setModel(model); + inputContentUI.selectivityTable.setDefaultRenderer(Equation.class, model); + inputContentUI.selectivityTable.setDefaultEditor(Equation.class, new EquationTableEditor()); + } + + protected void addSelectivity() { + inputContentUI.getAction().addSelectivity(inputContentUI.getPopulation(), + inputContentUI.selectivityEquation.getEditor().getText(), inputContentUI.getBean()); + setSelectivityTableModel(); + } + + protected void removeSelectivity() { + GearPopulationSelectivityModel model = (GearPopulationSelectivityModel)inputContentUI.selectivityTable.getModel(); + Selectivity selectedSelectivity = model.getSelectivities().get(inputContentUI.selectivityTable.getSelectedRow()); + inputContentUI.getAction().removeSelectivity(inputContentUI.getBean(), selectedSelectivity); + inputContentUI.getSaveVerifier().removeCurrentEntity(selectedSelectivity.getTopiaId()); + setSelectivityTableModel(); + inputContentUI.removeSelectivityButton.setEnabled(false); + } + + protected GenericComboModel<Population> getSelectivityPopulationModel() { + List<Species> species = inputContentUI.getFisheryRegion().getSpecies(); + List<Population> populations = new ArrayList<>(); + if (species != null) { + for (Species s : species) { + if (s.getPopulation() != null) { + populations.addAll(s.getPopulation()); + } + } + } + GenericComboModel<Population> selectivityPopulationModel = new GenericComboModel<>(populations); + return selectivityPopulationModel; + } + + protected void selectivityChanged() { + inputContentUI.setPopulation((Population)inputContentUI.fieldSelectivityPopulation.getSelectedItem()); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityHandler.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/gear/SelectivityUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -29,6 +29,8 @@ <fr.ifremer.isisfish.entities.Population id='population' javaBean='null'/> + <SelectivityHandler id="handler" /> + <BeanValidator id='validator' context="selectivity" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Gear' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> @@ -37,116 +39,17 @@ <fr.ifremer.isisfish.ui.input.ChangeModel id="changeModel" changed="{validator.isChanged()}" valid="{validator.isValid()}" /> - <import> - fr.ifremer.isisfish.entities.Equation - fr.ifremer.isisfish.entities.Gear - fr.ifremer.isisfish.entities.Population - fr.ifremer.isisfish.entities.Selectivity - fr.ifremer.isisfish.entities.Species - fr.ifremer.isisfish.ui.models.common.GenericComboModel - fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - java.util.ArrayList - javax.swing.DefaultComboBoxModel - </import> - <script><![CDATA[ -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - setPopulation(null); - selectivityTable.setModel(new GearPopulationSelectivityModel()); - } - if (evt.getNewValue() != null) { - refresh(); - } - } - }); -} - -@Override -public void resetChangeModel() { - changeModel.setStayChanged(false); -} - -public void refresh() { - - Gear gear = (Gear)getSaveVerifier().getEntity(Gear.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - //setBean(null); - //setBean(gear); - - if (getBean() != null) { - setSelectivityTableModel(); - fieldSelectivityPopulation.setModel(getSelectivityPopulationModel()); + protected void $afterCompleteSetup() { + handler.init(this); } -} -protected void setSelectivityTableModel() { - - List<Selectivity> selectivitiesList = new ArrayList<Selectivity>(); - - // set model even if no selectivity - // to clear data - if (getBean().getPopulationSelectivity() != null) { - // move collection to list - // and add all entity to verifier - for (Selectivity oneSelectivity : getBean().getPopulationSelectivity()) { - getSaveVerifier().addCurrentEntity(oneSelectivity); - selectivitiesList.add(oneSelectivity); - - // hack to enable save button :( - oneSelectivity.addPropertyChangeListener(new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - changeModel.setStayChanged(true); - } - }); - } + @Override + public void resetChangeModel() { + changeModel.setStayChanged(false); } - - // set table model - GearPopulationSelectivityModel model = new GearPopulationSelectivityModel(selectivitiesList); - selectivityTable.setModel(model); - selectivityTable.setDefaultRenderer(Equation.class, model); - selectivityTable.setDefaultEditor(Equation.class, new EquationTableEditor()); -} - -protected void addSelectivity() { - getAction().addSelectivity(getPopulation(), selectivityEquation.getEditor().getText(), getBean()); - setSelectivityTableModel(); -} - -protected void removeSelectivity() { - GearPopulationSelectivityModel model = (GearPopulationSelectivityModel)selectivityTable.getModel(); - Selectivity selectedSelectivity = model.getSelectivities().get(selectivityTable.getSelectedRow()); - getAction().removeSelectivity(getBean(), selectedSelectivity); - getSaveVerifier().removeCurrentEntity(selectedSelectivity.getTopiaId()); - setSelectivityTableModel(); - removeSelectivityButton.setEnabled(false); -} - -protected DefaultComboBoxModel getSelectivityPopulationModel() { - List<Species> species = getFisheryRegion().getSpecies(); - List<Population> populations = new ArrayList<Population>(); - if (species != null) { - for (Species s : species) { - if (s.getPopulation() != null) { - populations.addAll(s.getPopulation()); - } - } - } - GenericComboModel<Population> selectivityPopulationModel = new GenericComboModel<>(populations); - return selectivityPopulationModel; -} - -protected void selectivityChanged() { - setPopulation((Population)fieldSelectivityPopulation.getSelectedItem()); -} ]]></script> + <JPanel id='body'> <Table> <row> @@ -157,7 +60,7 @@ <JLabel text="isisfish.selectivity.selectPopulation" enabled='{isActive()}' decorator='boxed' /> </cell> <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldSelectivityPopulation" onItemStateChanged='selectivityChanged()' + <JComboBox id="fieldSelectivityPopulation" onItemStateChanged='handler.selectivityChanged()' genericType="fr.ifremer.isisfish.entities.Population" enabled='{isActive()}' decorator='boxed' /> </cell> @@ -173,7 +76,7 @@ </row> <row> <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id="addSelectivityButton" text="isisfish.common.add" onActionPerformed='addSelectivity()' + <JButton id="addSelectivityButton" text="isisfish.common.add" onActionPerformed='handler.addSelectivity()' enabled='{getPopulation() != null}' decorator='boxed' /> </cell> </row> @@ -189,7 +92,7 @@ </row> <row> <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id="removeSelectivityButton" text="isisfish.common.remove" onActionPerformed='removeSelectivity()' + <JButton id="removeSelectivityButton" text="isisfish.common.remove" onActionPerformed='handler.removeSelectivity()' enabled='false' decorator='boxed' /> </cell> </row> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,46 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.metier; + +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * Metier handler. + */ +public class MetierHandler extends InputContentHandler<MetierUI> { + + protected void init(final MetierUI metierUI) { + super.init(metierUI); + + metierUI.setButtonTitle(t("isisfish.input.continueTripTypes")); + metierUI.setNextPath(n("isisfish.input.tree.triptypes")); + + // install change listener + // (depends on sensitivity can't be done on constructor) + metierUI.installChangeListener(metierUI.metierTab); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoComboRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/MetierSeasonInfoComboRenderer.java) =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoComboRenderer.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoComboRenderer.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,70 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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.ifremer.isisfish.ui.input.metier; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import fr.ifremer.isisfish.entities.MetierSeasonInfo; + +/** + * Renderer pour la combo des {@link MetierSeasonInfo}. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class MetierSeasonInfoComboRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = -8277883340386163087L; + + /* + * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) + */ + @Override + public Component getListCellRendererComponent(JList<?> list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + // this must be used to have alterned highlight rows and default + // selection color + JLabel c = (JLabel) super.getListCellRendererComponent(list, value, + index, isSelected, cellHasFocus); + + MetierSeasonInfo metierSeasonInfo = (MetierSeasonInfo) value; + + // there is no default selection + if (value != null) { + c.setText(metierSeasonInfo.getFirstMonth() + "-" + metierSeasonInfo.getLastMonth()); + } + return c; + } +} Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,143 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.metier; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; + +import fr.ifremer.isisfish.entities.Equation; +import fr.ifremer.isisfish.entities.MetierSeasonInfo; +import fr.ifremer.isisfish.entities.Species; +import fr.ifremer.isisfish.entities.TargetSpecies; +import fr.ifremer.isisfish.ui.input.InputAction; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericComboModel; +import fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor; + +/** + * Metier tab handler. + */ +public class MetierSeasonInfoSpeciesHandler extends InputContentHandler<MetierSeasonInfoSpeciesUI> { + + protected void init(final MetierSeasonInfoSpeciesUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(MetierSeasonInfoSpeciesUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + setSeasonModel(); + inputContentUI.setSpecies(null); + inputContentUI.setMetierSeasonInfo(null); + setTargetSpeciesModel(); + setTableTargetSpeciesModel(); + } + }); + } + + protected void setSeasonModel() { + List<MetierSeasonInfo> metierSeasonInfo = null; + + if (inputContentUI.getBean() != null) { + metierSeasonInfo = inputContentUI.getBean().getMetierSeasonInfo(); + } + GenericComboModel<MetierSeasonInfo> seasonModel = new GenericComboModel<>(metierSeasonInfo); + inputContentUI.fieldMetierSeasonInfo.setModel(seasonModel); + } + + protected void metierSeasonInfoChanged() { + MetierSeasonInfo selectedMSI = (MetierSeasonInfo)inputContentUI.fieldMetierSeasonInfo.getSelectedItem(); + inputContentUI.setMetierSeasonInfo(selectedMSI); + if (selectedMSI != null) { + inputContentUI.getSaveVerifier().addCurrentEntity(inputContentUI.getMetierSeasonInfo()); + setTableTargetSpeciesModel(); + } + } + + protected void setTargetSpeciesModel() { + List<Species> species = inputContentUI.getFisheryRegion().getSpecies(); + GenericComboModel<Species> fieldTargetSpeciesModel = new GenericComboModel<>(species); + inputContentUI.fieldTargetSpecies.setModel(fieldTargetSpeciesModel); + } + + protected void speciesChanged() { + Species species = (Species)inputContentUI.fieldTargetSpecies.getSelectedItem(); + inputContentUI.setSpecies(species); + } + + protected void setTableTargetSpeciesModel() { + List<TargetSpecies> targetSpecies = new ArrayList<>(); + + if (inputContentUI.getBean() != null && inputContentUI.getMetierSeasonInfo() != null) { + // SpeciesTargetSpecies can be null durring region creation + if (inputContentUI.getMetierSeasonInfo().getSpeciesTargetSpecies() != null) { + // move collection to list + // and add all entity to verifier + for (TargetSpecies oneTargetSpecies : inputContentUI.getMetierSeasonInfo().getSpeciesTargetSpecies()) { + targetSpecies.add(oneTargetSpecies); + inputContentUI.getSaveVerifier().addCurrentEntity(oneTargetSpecies); + oneTargetSpecies.addPropertyChangeListener(new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + inputContentUI.changeModel.setStayChanged(true); + } + }); + } + } + } + + // set table model + MetierSeasonInfoTargetSpeciesTableModel model = new MetierSeasonInfoTargetSpeciesTableModel(targetSpecies); + inputContentUI.tableTargetSpecies.setModel(model); + inputContentUI.tableTargetSpecies.setDefaultRenderer(Equation.class, model); + inputContentUI.tableTargetSpecies.setDefaultEditor(Equation.class, new EquationTableEditor()); + } + + protected void add() { + Species selectedSpecies = (Species)inputContentUI.fieldTargetSpecies.getSelectedItem(); + if (selectedSpecies != null) { + // il n'y en a pas a la creation de la base + //Formule selectedFormule = (Formule)targetFactor.getFormuleComboBox().getSelectedItem(); + inputContentUI.getContextValue(InputAction.class).addTargetSpecies( + inputContentUI.getBean(), + inputContentUI.getMetierSeasonInfo(), + selectedSpecies, + inputContentUI.targetFactor.getEditor().getText(), + inputContentUI.fieldPrimaryCatch.isSelected()); + setTableTargetSpeciesModel(); + } + } + + protected void remove() { + // TODO change delete selected truc from model + Object[] targetSpecies = inputContentUI.getMetierSeasonInfo().getSpeciesTargetSpecies().toArray(); + + Object o = targetSpecies[inputContentUI.tableTargetSpecies.getSelectedRow()]; + if (o != null) { + TargetSpecies ts = (TargetSpecies)o; + inputContentUI.getAction().removeTargetSpecies(inputContentUI.getMetierSeasonInfo(), ts); + inputContentUI.getSaveVerifier().removeCurrentEntity(ts.getTopiaId()); + setTableTargetSpeciesModel(); + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoSpeciesUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -31,22 +31,7 @@ <fr.ifremer.isisfish.entities.Species id='species' javaBean='null'/> - <import> - fr.ifremer.isisfish.entities.MetierSeasonInfo - fr.ifremer.isisfish.ui.models.common.GenericListModel - fr.ifremer.isisfish.ui.models.common.GenericComboModel - fr.ifremer.isisfish.entities.Equation - fr.ifremer.isisfish.entities.Metier - fr.ifremer.isisfish.entities.Species - fr.ifremer.isisfish.entities.TargetSpecies - fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - java.util.ArrayList - java.util.List - java.awt.Dimension - fr.ifremer.isisfish.ui.input.InputAction - </import> + <MetierSeasonInfoSpeciesHandler id="handler" /> <BeanValidator id='validator' context="metier" bean='{getMetierSeasonInfo()}' beanClass='fr.ifremer.isisfish.entities.MetierSeasonInfo' @@ -56,110 +41,21 @@ <fr.ifremer.isisfish.ui.input.ChangeModel id="changeModel" changed="{validator.isChanged()}" valid="{validator.isValid()}" /> - <script><![CDATA[ + <import> + java.awt.Dimension + </import> -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - setSeasonModel(); - setSpecies(null); - setMetierSeasonInfo(null); - setTargetSpeciesModel(); - setTableTargetSpeciesModel(); - } - }); -} - -@Override -public void resetChangeModel() { - changeModel.setStayChanged(false); -} - -protected void setSeasonModel() { - List<MetierSeasonInfo> metierSeasonInfo = null; - - if (getBean() != null) { - metierSeasonInfo = getBean().getMetierSeasonInfo(); + <script><![CDATA[ + protected void $afterCompleteSetup() { + handler.init(this); } - GenericComboModel<MetierSeasonInfo> seasonModel = new GenericComboModel<>(metierSeasonInfo); - fieldMetierSeasonInfo.setModel(seasonModel); -} -protected void metierSeasonInfoChanged() { - MetierSeasonInfo selectedMSI = (MetierSeasonInfo)fieldMetierSeasonInfo.getSelectedItem(); - setMetierSeasonInfo(selectedMSI); - if (selectedMSI != null) { - getSaveVerifier().addCurrentEntity(getMetierSeasonInfo()); - setTableTargetSpeciesModel(); + @Override + public void resetChangeModel() { + changeModel.setStayChanged(false); } -} - -protected void setTargetSpeciesModel() { - List<Species> species = getFisheryRegion().getSpecies(); - GenericComboModel<Species> fieldTargetSpeciesModel = new GenericComboModel<>(species); - fieldTargetSpecies.setModel(fieldTargetSpeciesModel); -} - -protected void speciesChanged() { - Species species = (Species)fieldTargetSpecies.getSelectedItem(); - setSpecies(species); -} - -protected void setTableTargetSpeciesModel() { - List<TargetSpecies> targetSpecies = new ArrayList<TargetSpecies>(); - - if (getBean() != null && getMetierSeasonInfo() != null) { - // SpeciesTargetSpecies can be null durring region creation - if (getMetierSeasonInfo().getSpeciesTargetSpecies() != null) { - // move collection to list - // and add all entity to verifier - for (TargetSpecies oneTargetSpecies : getMetierSeasonInfo().getSpeciesTargetSpecies()) { - targetSpecies.add(oneTargetSpecies); - getSaveVerifier().addCurrentEntity(oneTargetSpecies); - oneTargetSpecies.addPropertyChangeListener(new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - changeModel.setStayChanged(true); - } - }); - } - } - } - - // set table model - MetierSeasonInfoTargetSpeciesTableModel model = new MetierSeasonInfoTargetSpeciesTableModel(targetSpecies); - tableTargetSpecies.setModel(model); - tableTargetSpecies.setDefaultRenderer(Equation.class, model); - tableTargetSpecies.setDefaultEditor(Equation.class, new EquationTableEditor()); -} - -protected void add() { - Species selectedSpecies = (Species)fieldTargetSpecies.getSelectedItem(); - if (selectedSpecies != null) { - // il n'y en a pas a la creation de la base - //Formule selectedFormule = (Formule)targetFactor.getFormuleComboBox().getSelectedItem(); - getContextValue(InputAction.class).addTargetSpecies( - getBean(), - getMetierSeasonInfo(), - selectedSpecies, - targetFactor.getEditor().getText(), - fieldPrimaryCatch.isSelected()); - setTableTargetSpeciesModel(); - } -} - -protected void remove() { - // TODO change delete selected truc from model - Object[] targetSpecies = getMetierSeasonInfo().getSpeciesTargetSpecies().toArray(); - - Object o = targetSpecies[tableTargetSpecies.getSelectedRow()]; - if (o != null) { - TargetSpecies ts = (TargetSpecies)o; - getAction().removeTargetSpecies(getMetierSeasonInfo(), ts); - getSaveVerifier().removeCurrentEntity(ts.getTopiaId()); - setTableTargetSpeciesModel(); - } -} ]]></script> + <JPanel id="body"> <Table> <row> @@ -170,9 +66,9 @@ <JLabel text="isisfish.metierSeasonInfoSpecies.selectSeason" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldMetierSeasonInfo" onItemStateChanged='metierSeasonInfoChanged()' + <JComboBox id="fieldMetierSeasonInfo" onItemStateChanged='handler.metierSeasonInfoChanged()' genericType="fr.ifremer.isisfish.entities.MetierSeasonInfo" - renderer="{new fr.ifremer.isisfish.ui.input.renderer.MetierSeasonInfoComboRenderer()}" + renderer="{new MetierSeasonInfoComboRenderer()}" enabled='{isActive() && (isSensitivity() || !changeModel.isChanged() ) }'/> </cell> </row> @@ -182,7 +78,7 @@ enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldTargetSpecies" onItemStateChanged='speciesChanged()' + <JComboBox id="fieldTargetSpecies" onItemStateChanged='handler.speciesChanged()' genericType="fr.ifremer.isisfish.entities.Species" enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/> </cell> @@ -208,7 +104,7 @@ </row> <row> <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id="add" text="isisfish.common.add" onActionPerformed='add()' + <JButton id="add" text="isisfish.common.add" onActionPerformed='handler.add()' enabled='{getMetierSeasonInfo() != null && getSpecies() != null}' decorator='boxed'/> </cell> </row> @@ -225,7 +121,7 @@ <row> <cell columns='2' fill='horizontal' weightx='1.0'> <JButton id="remove" text="isisfish.common.remove" - onActionPerformed='remove()' enabled='false' decorator='boxed'/> + onActionPerformed='handler.remove()' enabled='false' decorator='boxed'/> </cell> </row> </Table> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,211 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.metier; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.event.ListSelectionListener; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import fr.ifremer.isisfish.entities.MetierSeasonInfo; +import fr.ifremer.isisfish.entities.Zone; +import fr.ifremer.isisfish.types.Month; +import fr.ifremer.isisfish.ui.input.InputAction; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericComboModel; +import fr.ifremer.isisfish.ui.models.common.GenericListModel; +import fr.ifremer.isisfish.ui.widget.Interval; + +/** + * Metier tab handler. + */ +public class MetierSeasonInfoZoneHandler extends InputContentHandler<MetierSeasonInfoZoneUI> { + + /** Class logger. */ + private static final Log log = LogFactory.getLog(MetierSeasonInfoZoneHandler.class); + + protected Interval interval = null; + protected boolean init = false; + + protected void init(final MetierSeasonInfoZoneUI inputContentUI) { + super.init(inputContentUI); + + /* + * Don't add both in same listener. + * When first is set, last value from getPopulationSeasonInfo() + * is erased by interval.getLast() default value. + */ + inputContentUI.ip.addPropertyChangeListener("first", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (inputContentUI.getMetierSeasonInfo() != null) { + inputContentUI.getMetierSeasonInfo().setFirstMonth(new Month(interval.getFirst())); + } + } + }); + inputContentUI.ip.addPropertyChangeListener("last", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (inputContentUI.getMetierSeasonInfo() != null) { + inputContentUI.getMetierSeasonInfo().setLastMonth(new Month(interval.getLast())); + } + } + }); + + inputContentUI.addPropertyChangeListener(MetierSeasonInfoZoneUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + + } + if (evt.getNewValue() != null) { + refresh(); + } + } + }); + } + + protected void save() { + inputContentUI.getSaveVerifier().save(); + setMetierSeasonInfoCombo(); + } + + protected void create() { + MetierSeasonInfo newMSI = inputContentUI.getContextValue(InputAction.class).createMetierSeasonInfo(inputContentUI.getBean()); + inputContentUI.setMetierSeasonInfo(newMSI); + setMetierSeasonInfoCombo(); + } + + protected void delete() { + inputContentUI.getContextValue(InputAction.class).removeMetierSeasonInfo(inputContentUI.getBean(), inputContentUI.getMetierSeasonInfo()); + inputContentUI.setMetierSeasonInfo(null); + setMetierSeasonInfoCombo(); + } + + public void refresh() { + + inputContentUI.setMetierSeasonInfo(null); + + if (inputContentUI.getBean() != null) { + // Model instanciation + interval = new Interval(); + interval.setMin(0); + interval.setMax(11); + interval.setFirst(0); + interval.setLast(2); + + setMetierSeasonInfoCombo(); + setSeason(); + setMetierZone(); + + inputContentUI.ip.setLabelRenderer(Month.MONTH); + inputContentUI.ip.setModel(interval); + } + } + + protected void setSeason() { + if (inputContentUI.getMetierSeasonInfo() != null) { + + // register selected item in save verifier + inputContentUI.getSaveVerifier().addCurrentEntity(inputContentUI.getMetierSeasonInfo()); + + try { + if (log.isDebugEnabled()) { + log.debug("Refresh interval : "); + } + Month firstMonth = inputContentUI.getMetierSeasonInfo().getFirstMonth(); + if (firstMonth != null) { + interval.setFirst(firstMonth.getMonthNumber()); + if (log.isDebugEnabled()) { + log.debug(" first : " + interval.getFirst()); + } + } else { + interval.setFirst(0); + } + + Month lastMonth = inputContentUI.getMetierSeasonInfo().getLastMonth(); + if (lastMonth != null) { + interval.setLast(lastMonth.getMonthNumber()); + if (log.isDebugEnabled()) { + log.debug(" last : " + interval.getLast()); + } + } else { + interval.setLast(3); + } + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Can't display season", e); + } + } + } + } + protected void setMetierZone() { + if (inputContentUI.getMetierSeasonInfo() != null) { + ListSelectionListener[] listeners = inputContentUI.metierZones.getListSelectionListeners(); + for (ListSelectionListener listener : listeners) { + inputContentUI.metierZones.removeListSelectionListener(listener); + } + + List<Zone> allZones = inputContentUI.getFisheryRegion().getZone(); + GenericListModel<Zone> model = new GenericListModel<>(allZones); + inputContentUI.metierZones.setModel(model); + // restore selection + if (inputContentUI.metierSeasonInfo.getZone() != null) { + for (Zone zone : inputContentUI.metierSeasonInfo.getZone()) { + int index = allZones.indexOf(zone); + inputContentUI.metierZones.getSelectionModel().addSelectionInterval(index, index); + } + } + + for (ListSelectionListener listener : listeners) { + inputContentUI.metierZones.addListSelectionListener(listener); + } + } + } + + protected void setMetierSeasonInfoCombo() { + List<MetierSeasonInfo> metierSeasonInfoList = inputContentUI.getBean().getMetierSeasonInfo(); + GenericComboModel<MetierSeasonInfo> metierSeasonInfoModel = new GenericComboModel<>(metierSeasonInfoList); + inputContentUI.metierSeasonInfoCombo.setModel(metierSeasonInfoModel); + metierSeasonInfoModel.setSelectedItem(inputContentUI.getMetierSeasonInfo()); + } + + protected void metierZonesChanged() { + List<Zone> selected = inputContentUI.metierZones.getSelectedValuesList(); + List<Zone> zones = new ArrayList<>(selected); + inputContentUI.getMetierSeasonInfo().setZone(zones); + } + + protected void seasonChanged() { + init = true; + inputContentUI.setMetierSeasonInfo((MetierSeasonInfo)inputContentUI.metierSeasonInfoCombo.getSelectedItem()); + setSeason(); + setMetierZone(); + init = false; + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoZoneUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -29,21 +29,7 @@ <fr.ifremer.isisfish.entities.MetierSeasonInfo id='metierSeasonInfo' javaBean='null'/> - <import> - fr.ifremer.isisfish.entities.Metier - fr.ifremer.isisfish.entities.MetierSeasonInfo - fr.ifremer.isisfish.entities.Zone - fr.ifremer.isisfish.types.Month - fr.ifremer.isisfish.ui.models.common.GenericComboModel - fr.ifremer.isisfish.ui.models.common.GenericListModel - fr.ifremer.isisfish.ui.widget.Interval - fr.ifremer.isisfish.ui.widget.IntervalPanel - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - java.util.ArrayList - java.awt.Dimension - fr.ifremer.isisfish.ui.input.InputAction - </import> + <MetierSeasonInfoZoneHandler id="handler" /> <BeanValidator id='validator' context="metier" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Metier' @@ -58,177 +44,21 @@ <fr.ifremer.isisfish.ui.input.ChangeModel id="changeModel" changed="{validator.isChanged() || validatorSeason.isChanged()}" valid="{validator.isValid() && validatorSeason.isValid()}" /> - <script><![CDATA[ - - protected Interval interval = null; - protected boolean init = false; + <import> + java.awt.Dimension + </import> + <script><![CDATA[ protected void $afterCompleteSetup() { - /* - * Don't add both in same listener. - * When first is set, last value from getPopulationSeasonInfo() - * is erased by interval.getLast() default value. - */ - ip.addPropertyChangeListener("first", new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (getMetierSeasonInfo() != null) { - getMetierSeasonInfo().setFirstMonth(new Month(interval.getFirst())); - } - } - }); - ip.addPropertyChangeListener("last", new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (getMetierSeasonInfo() != null) { - getMetierSeasonInfo().setLastMonth(new Month(interval.getLast())); - } - } - }); - - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - - } - if (evt.getNewValue() != null) { - refresh(); - } - } - }); + handler.init(this); } @Override public void resetChangeModel() { changeModel.setStayChanged(false); } - - protected void save() { - getSaveVerifier().save(); - setMetierSeasonInfoCombo(); - } - - protected void create() { - MetierSeasonInfo newMSI = getContextValue(InputAction.class).createMetierSeasonInfo(getBean()); - setMetierSeasonInfo(newMSI); - setMetierSeasonInfoCombo(); - } - - protected void delete() { - getContextValue(InputAction.class).removeMetierSeasonInfo(getBean(), getMetierSeasonInfo()); - setMetierSeasonInfo(null); - setMetierSeasonInfoCombo(); - } - - public void refresh() { - - if (log.isDebugEnabled()) { - log.debug("Refresh called in ui : " + this); - } - - setMetierSeasonInfo(null); - - if (getBean() != null) { - // Model instanciation - interval = new Interval(); - interval.setMin(0); - interval.setMax(11); - interval.setFirst(0); - interval.setLast(2); - - setMetierSeasonInfoCombo(); - setSeason(); - setMetierZone(); - - ip.setLabelRenderer(Month.MONTH); - ip.setModel(interval); - } - } - - protected void setSeason() { - if (getMetierSeasonInfo() != null) { - - // register selected item in save verifier - getSaveVerifier().addCurrentEntity(getMetierSeasonInfo()); - - try { - if (log.isDebugEnabled()) { - log.debug("Refresh interval : "); - } - Month firstMonth = getMetierSeasonInfo().getFirstMonth(); - if (firstMonth != null) { - interval.setFirst(firstMonth.getMonthNumber()); - if (log.isDebugEnabled()) { - log.debug(" first : " + interval.getFirst()); - } - } else { - interval.setFirst(0); - } - - Month lastMonth = getMetierSeasonInfo().getLastMonth(); - if (lastMonth != null) { - interval.setLast(lastMonth.getMonthNumber()); - if (log.isDebugEnabled()) { - log.debug(" last : " + interval.getLast()); - } - } else { - interval.setLast(3); - } - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Can't display season", e); - } - } - } - } - protected void setMetierZone() { - if (getMetierSeasonInfo() != null) { - ListSelectionListener[] listeners = metierZones.getListSelectionListeners(); - for (ListSelectionListener listener : listeners) { - metierZones.removeListSelectionListener(listener); - } - - List<Zone> allZones = getFisheryRegion().getZone(); - GenericListModel<Zone> model = new GenericListModel<>(allZones); - metierZones.setModel(model); - // restore selection - if (metierSeasonInfo.getZone() != null) { - for (Zone zone : metierSeasonInfo.getZone()) { - int index = allZones.indexOf(zone); - metierZones.getSelectionModel().addSelectionInterval(index, index); - } - } - - for (ListSelectionListener listener : listeners) { - metierZones.addListSelectionListener(listener); - } - } - } - - protected void setMetierSeasonInfoCombo() { - List<MetierSeasonInfo> metierSeasonInfoList = getBean().getMetierSeasonInfo(); - GenericComboModel<MetierSeasonInfo> metierSeasonInfoModel = new GenericComboModel<>(metierSeasonInfoList); - metierSeasonInfoCombo.setModel(metierSeasonInfoModel); - metierSeasonInfoModel.setSelectedItem(getMetierSeasonInfo()); - } - - protected void metierZonesChanged() { - List<Zone> selected = metierZones.getSelectedValuesList(); - List<Zone> zones = new ArrayList<Zone>(); - for (Zone o : selected) { - zones.add(o); - } - getMetierSeasonInfo().setZone(zones); - } - - protected void seasonChanged() { - init = true; - setMetierSeasonInfo((MetierSeasonInfo)metierSeasonInfoCombo.getSelectedItem()); - setSeason(); - setMetierZone(); - init = false; - } ]]></script> + <JPanel id="body"> <Table> <row> @@ -239,10 +69,10 @@ <JLabel text="isisfish.metierSeasonInfoZone.selectSeason" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JComboBox id="metierSeasonInfoCombo" onItemStateChanged='seasonChanged()' + <JComboBox id="metierSeasonInfoCombo" onItemStateChanged='handler.seasonChanged()' genericType="fr.ifremer.isisfish.entities.MetierSeasonInfo" enabled='{isActive() && (isSensitivity() || !changeModel.isChanged() ) }' - renderer="{new fr.ifremer.isisfish.ui.input.renderer.MetierSeasonInfoComboRenderer()}" /> + renderer="{new MetierSeasonInfoComboRenderer()}" /> </cell> </row> <row> @@ -250,7 +80,7 @@ <JLabel text="isisfish.metierSeasonInfoZone.season" enabled='{getMetierSeasonInfo() != null}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <IntervalPanel id='ip' enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/> + <fr.ifremer.isisfish.ui.widget.IntervalPanel id='ip' enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/> </cell> </row> <row> @@ -259,7 +89,7 @@ </cell> <cell fill='both' weightx='1.0' weighty='0.7'> <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <JList id="metierZones" onValueChanged='metierZonesChanged()' + <JList id="metierZones" onValueChanged='handler.metierZonesChanged()' genericType="fr.ifremer.isisfish.entities.Zone" enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/> </JScrollPane> @@ -289,7 +119,7 @@ <JButton id='save' decorator='boxed' text="isisfish.common.save" enabled="{changeModel.isValid() && changeModel.isChanged()}" - onActionPerformed="save();validator.setChanged(false);validatorSeason.setChanged(false);"/> + onActionPerformed="handler.save();validator.setChanged(false);validatorSeason.setChanged(false);"/> </cell> <cell fill='horizontal' weightx='0.5'> <JButton id='cancel' decorator='boxed' @@ -303,13 +133,13 @@ <JButton id='create' decorator='boxed' text="isisfish.common.new" enabled="{!changeModel.isChanged()}" - onActionPerformed="create()"/> + onActionPerformed="handler.create()"/> </cell> <cell fill='horizontal' weightx='0.5'> <JButton id='delete' decorator='boxed' text="isisfish.common.remove" enabled="{getMetierSeasonInfo() != null}" - onActionPerformed="delete()"/> + onActionPerformed="handler.delete()"/> </cell> </row> </Table> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,64 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.metier; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import fr.ifremer.isisfish.entities.Gear; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericComboModel; + +/** + * Metier tab handler. + */ +public class MetierTabHandler extends InputContentHandler<MetierTabUI> { + + protected boolean init; + + protected void init(final MetierTabUI metierTabUI) { + super.init(metierTabUI); + + metierTabUI.addPropertyChangeListener(MetierTabUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + GenericComboModel<Gear> model = new GenericComboModel<>(metierTabUI.getFisheryRegion().getGear()); + if (evt.getNewValue() == null) { + + } + if (evt.getNewValue() != null) { + init = true; + model.setSelectedItem(metierTabUI.bean.getGear()); + init = false; + } + metierTabUI.fieldMetierGear.setModel(model); + } + }); + } + + protected void gearChanged() { + if (!init) { + inputContentUI.getBean().setGear((Gear)inputContentUI.fieldMetierGear.getSelectedItem()); + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabHandler.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierTabUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric + Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -27,61 +27,24 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Metier id='bean' javaBean='null'/> - <import> - fr.ifremer.isisfish.entities.Gear - fr.ifremer.isisfish.entities.Metier - fr.ifremer.isisfish.ui.models.common.GenericComboModel - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - java.awt.Dimension - </import> - + <MetierTabHandler id="handler" /> + <BeanValidator id='validator' context="metier" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Metier' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> <field name="name" component="fieldMetierName" /> </BeanValidator> - <script><![CDATA[ -protected boolean init = false; + <import> + java.awt.Dimension + </import> -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - GenericComboModel<Gear> model = new GenericComboModel<>(getFisheryRegion().getGear()); - if (evt.getNewValue() == null) { - - } - if (evt.getNewValue() != null) { - init = true; - model.setSelectedItem(bean.getGear()); - init = false; - } - fieldMetierGear.setModel(model); - } - }); -} - -/*public void refresh() { - - if (log.isDebugEnabled()) { - log.debug("Refresh called in ui : " + this); + <script><![CDATA[ + protected void $afterCompleteSetup() { + handler.init(this); } - - Metier metier = getSaveVerifier().getEntity(Metier.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - setBean(null); - setBean(metier); -}*/ - -protected void gearChanged() { - if (!init) { - getBean().setGear((Gear)fieldMetierGear.getSelectedItem()); - } -} ]]></script> + <JPanel id="body"> <Table> <row> @@ -102,7 +65,7 @@ <JLabel text="isisfish.common.gear" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldMetierGear" onItemStateChanged='gearChanged()' + <JComboBox id="fieldMetierGear" onItemStateChanged='handler.gearChanged()' genericType="fr.ifremer.isisfish.entities.Gear" enabled='{isActive()}' decorator='boxed'/> </cell> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric + Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -26,36 +26,29 @@ <fr.ifremer.isisfish.entities.Metier id='bean' javaBean='null'/> - <import> - static org.nuiton.i18n.I18n.t - static org.nuiton.i18n.I18n.n - </import> + <MetierHandler id="handler" /> -<script><![CDATA[ -protected void $afterCompleteSetup() { - setButtonTitle(t("isisfish.input.continueTripTypes")); - setNextPath(n("isisfish.input.tree.triptypes")); - - // install change listener - // (depends on sensitivity can't be done on constructor) - installChangeListener(metierTab); -} + <script><![CDATA[ + protected void $afterCompleteSetup() { + handler.init(this); + } -@Override -public void setLayer(boolean active) { - super.setLayer(active); - metierTabUI.setLayer(active); - metierSeasonInfoUI.setLayer(active); - metierSeasonSpeciesUI.setLayer(active); -} - -@Override -public void resetChangeModel() { - metierTabUI.resetChangeModel(); - metierSeasonInfoUI.resetChangeModel(); - metierSeasonSpeciesUI.resetChangeModel(); -} + @Override + public void setLayer(boolean active) { + super.setLayer(active); + metierTabUI.setLayer(active); + metierSeasonInfoUI.setLayer(active); + metierSeasonSpeciesUI.setLayer(active); + } + + @Override + public void resetChangeModel() { + metierTabUI.resetChangeModel(); + metierSeasonInfoUI.resetChangeModel(); + metierSeasonSpeciesUI.resetChangeModel(); + } ]]></script> + <JPanel id="body"> <JTabbedPane id="metierTab" constraints='BorderLayout.CENTER'> <tab title='isisfish.metier.title'> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,74 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.observation; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import org.nuiton.math.matrix.MatrixND; +import org.nuiton.math.matrix.gui.MatrixPanelEvent; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * Observation handler. + */ +public class ObservationHandler extends InputContentHandler<ObservationUI> { + + protected void init(final ObservationUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(ObservationUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldObservationValue.setMatrix(null); + } + if (evt.getNewValue() != null) { + setObservationValueMatrix(); + } + } + }); + } + + protected void setObservationValueMatrix() { + MatrixND prop = inputContentUI.getBean().getValue(); + if (prop != null) { + inputContentUI.fieldObservationValue.setMatrix(prop.copy()); + } else { + inputContentUI.fieldObservationValue.setMatrix(null); + } + } + + protected void createObservationValueMatrix() { + inputContentUI.getAction().createObservationValueMatrix(inputContentUI.getBean()); + setObservationValueMatrix(); + } + + protected void observationValueMatrixChanged(MatrixPanelEvent event) { + MatrixND mat = inputContentUI.fieldObservationValue.getMatrix(); + if (inputContentUI.getBean() != null && mat != null) { + inputContentUI.getBean().setValue(mat.copy()); + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/observation/ObservationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2014 Ifremer, Code Lutin, Chatellier Eric + Copyright (C) 2014 - 2015 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -23,64 +23,25 @@ #L% --> <fr.ifremer.isisfish.ui.input.InputContentUI - superGenericType='fr.ifremer.isisfish.entities.Observation'> + superGenericType='fr.ifremer.isisfish.entities.Observation'> - <!-- bean property --> - <fr.ifremer.isisfish.entities.Observation - id='bean' javaBean='null' /> + <!-- bean property --> + <fr.ifremer.isisfish.entities.Observation id='bean' javaBean='null' /> - <import> - static org.nuiton.i18n.I18n.t - static org.nuiton.i18n.I18n.n - org.nuiton.math.matrix.gui.MatrixPanelEvent - org.nuiton.math.matrix.MatrixND - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - </import> + <ObservationHandler id="handler" /> - <BeanValidator id='validator' - bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Observation' - uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> - <field name="name" component="fieldObservationName" /> - </BeanValidator> + <BeanValidator id='validator' + bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Observation' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> + <field name="name" component="fieldObservationName" /> + </BeanValidator> - <script><![CDATA[ - -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldObservationValue.setMatrix(null); - } - if (evt.getNewValue() != null) { - setObservationValueMatrix(); - } - } - }); -} - -protected void setObservationValueMatrix() { - MatrixND prop = getBean().getValue(); - if (prop != null) { - fieldObservationValue.setMatrix(prop.copy()); - } else { - fieldObservationValue.setMatrix(null); + <script><![CDATA[ + protected void $afterCompleteSetup() { + handler.init(this); } -} - -protected void createObservationValueMatrix() { - getAction().createObservationValueMatrix(getBean()); - setObservationValueMatrix(); -} - -protected void observationValueMatrixChanged(MatrixPanelEvent event) { - MatrixND mat = fieldObservationValue.getMatrix(); - if (getBean() != null && mat != null) { - getBean().setValue(mat.copy()); - } -} - ]]></script> + <JPanel id="body"> <Table> <row> @@ -124,7 +85,7 @@ <row> <cell columns='2' fill='both' weighty='1' weightx='1.0'> <org.nuiton.math.matrix.gui.MatrixPanelEditor - id="fieldObservationValue" onMatrixChanged="observationValueMatrixChanged(event)" + id="fieldObservationValue" onMatrixChanged="handler.observationValueMatrixChanged(event)" enabled='{isActive()}' decorator='boxed' _sensitivityBean='{fr.ifremer.isisfish.entities.Observation.class}' _sensitivityMethod='"Value"' /> @@ -135,7 +96,7 @@ <JPanel/> </cell> <cell fill='horizontal' weightx='1.0'> - <JButton text="isisfish.common.newMatrix" onActionPerformed='createObservationValueMatrix()' enabled='{isActive()}' decorator='boxed'/> + <JButton text="isisfish.common.newMatrix" onActionPerformed='handler.createObservationValueMatrix()' enabled='{isActive()}' decorator='boxed'/> </cell> </row> </Table> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,137 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import static org.nuiton.i18n.I18n.t; + +import java.awt.BorderLayout; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.List; + +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.table.DefaultTableModel; + +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.Species; +import fr.ifremer.isisfish.ui.input.InputAction; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.input.InputUI; +import jaxx.runtime.JAXXUtil; + +/** + * Population handler. + */ +public class PopulationBasicsHandler extends InputContentHandler<PopulationBasicsUI> { + + protected void init(final PopulationBasicsUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(PopulationBasicsUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldPopulationBasicsName.setText(""); + inputContentUI.fieldPopulationBasicsGeographicID.setText(""); + inputContentUI.fieldPopulationBasicsNbClasses.setText(""); + inputContentUI.fieldPopulationBasicsComment.setText(""); + inputContentUI.tableAgeLength.setModel(new DefaultTableModel()); + } + if (evt.getNewValue() != null) { + setTableAgeLengthModel(); + } + } + }); + } + + public void refresh() { + Population population = inputContentUI.getSaveVerifier().getEntity(Population.class); + + // add null before, for second to be considered as a changed event + // otherwize, setBean has no effect + inputContentUI.setBean(null); + inputContentUI.setBean(population); + + if (inputContentUI.getBean() != null) { + setTableAgeLengthModel(); + } + //getSaveVerifier().addCurrentPanel(growthEquation, growthReverseEquation); + } + + /** + * Open creation classe wizard after confirmation. + */ + protected void createGroups() { + + int response = JOptionPane.showConfirmDialog(inputContentUI, t("isisfish.populationBasics.confirmCreateGroups"), + t("isisfish.common.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); + + if (response == JOptionPane.YES_OPTION) { + JFrame wizardFrame = new JFrame(); + wizardFrame.setLayout(new BorderLayout()); + WizardGroupCreationUI wizard = new WizardGroupCreationUI(inputContentUI); + wizard.getHandler().initParent(inputContentUI); + wizardFrame.add(wizard, BorderLayout.CENTER); + wizardFrame.setTitle(t("isisfish.wizardGroupCreation.title")); + Species species = inputContentUI.getBean().getSpecies(); + wizard.getHandler().setAgeType(species.isAgeGroupType()); + if (wizard.getHandler().isAgeType()) { + wizard.getHandler().setCard("singleGroupAge"); + } else { + wizard.getHandler().setCard("beginGroupLength"); + } + wizardFrame.pack(); + wizardFrame.setLocationRelativeTo(inputContentUI); + wizardFrame.setVisible(true); + } + + } + + protected void setTableAgeLengthModel() { + List<PopulationGroup> popGroup = inputContentUI.getBean().getPopulationGroup(); + if (popGroup != null){ + DefaultTableModel model = new DefaultTableModel(2, popGroup.size() + 1); + model.setValueAt("Age", 0, 0); + model.setValueAt("Lengths", 1, 0); + int cnt = 1; + for (PopulationGroup pg : popGroup){ + model.setValueAt(pg.getAge(), 0, cnt); + model.setValueAt(pg.getLength(), 1, cnt); + cnt++; + } + inputContentUI.tableAgeLength.setModel(model); + } + } + + protected void create() { + // find species node + InputUI inputUI = inputContentUI.getContextValue(InputUI.class, JAXXUtil.PARENT); + Species species = inputUI.getHandler().findSpecies(inputUI); + // create node and select it + Population population = inputContentUI.getContextValue(InputAction.class).createPopulation(inputContentUI.getTopiaContext(), species); + inputUI.getHandler().insertTreeNode(inputUI, Population.class, population); + inputContentUI.setInfoText(t("isisfish.message.creation.finished")); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationBasicsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2012 Ifremer, Code Lutin, Chatellier Eric + Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -27,20 +27,7 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/> - <import> - static org.nuiton.i18n.I18n.t - fr.ifremer.isisfish.entities.Species; - fr.ifremer.isisfish.entities.PopulationGroup; - fr.ifremer.isisfish.entities.Population; - javax.swing.table.DefaultTableModel; - java.beans.PropertyChangeEvent; - java.beans.PropertyChangeListener; - javax.swing.JOptionPane - javax.swing.JFrame - java.awt.BorderLayout - fr.ifremer.isisfish.ui.input.InputUI - fr.ifremer.isisfish.ui.input.InputAction - </import> + <PopulationBasicsHandler id="handler" /> <BeanValidator id='validator' context="basics" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population' @@ -49,93 +36,11 @@ </BeanValidator> <script><![CDATA[ -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldPopulationBasicsName.setText(""); - fieldPopulationBasicsGeographicID.setText(""); - fieldPopulationBasicsNbClasses.setText(""); - fieldPopulationBasicsComment.setText(""); - tableAgeLength.setModel(new DefaultTableModel()); - } - if (evt.getNewValue() != null) { - setTableAgeLengthModel(); - } - } - }); -} - -public void refresh() { - Population population = getSaveVerifier().getEntity(Population.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - setBean(null); - setBean(population); - - if (getBean() != null) { - setTableAgeLengthModel(); + protected void $afterCompleteSetup() { + handler.init(this); } - //getSaveVerifier().addCurrentPanel(growthEquation, growthReverseEquation); -} + ]]></script> -/** - * Open creation classe wizard after confirmation. - */ -protected void createGroups() { - - int response = JOptionPane.showConfirmDialog(this, t("isisfish.populationBasics.confirmCreateGroups"), - t("isisfish.common.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); - - if (response == JOptionPane.YES_OPTION) { - JFrame wizardFrame = new JFrame(); - wizardFrame.setLayout(new BorderLayout()); - WizardGroupCreationUI wizard = new WizardGroupCreationUI(this); - wizard.init(this); - wizardFrame.add(wizard, BorderLayout.CENTER); - wizardFrame.setTitle(t("isisfish.wizardGroupCreation.title")); - Species species = getBean().getSpecies(); - wizard.setAgeType(species.isAgeGroupType()); - if (wizard.isAgeType()) { - wizard.setCard("singleGroupAge"); - } else { - wizard.setCard("beginGroupLength"); - } - wizardFrame.pack(); - wizardFrame.setLocationRelativeTo(this); - wizardFrame.setVisible(true); - } - -} - -protected void setTableAgeLengthModel() { - java.util.List<PopulationGroup> popGroup = getBean().getPopulationGroup(); - if (popGroup != null){ - DefaultTableModel model = new DefaultTableModel(2, popGroup.size() + 1); - model.setValueAt("Age", 0, 0); - model.setValueAt("Lengths", 1, 0); - int cnt = 1; - for (PopulationGroup pg : popGroup){ - model.setValueAt(pg.getAge(), 0, cnt); - model.setValueAt(pg.getLength(), 1, cnt); - cnt++; - } - tableAgeLength.setModel(model); - } -} - -protected void create() { - // find species node - InputUI inputUI = getContextValue(InputUI.class, JAXXUtil.PARENT); - Species species = inputUI.getHandler().findSpecies(inputUI); - // create node and select it - Population population = getContextValue(InputAction.class).createPopulation(getTopiaContext(), species); - inputUI.getHandler().insertTreeNode(inputUI, Population.class, population); - setInfoText(t("isisfish.message.creation.finished")); -} - ]]> - </script> <JPanel id="body"> <Table> <row> @@ -176,7 +81,7 @@ </cell> <cell fill='horizontal'> <JButton id="buttonPopulationBasicsCreateClasses" text="isisfish.populationBasics.recreateClasses" - onActionPerformed='createGroups()' enabled='{isActive()}' decorator='boxed'/> + onActionPerformed='handler.createGroups()' enabled='{isActive()}' decorator='boxed'/> </cell> <cell fill='horizontal'> <JCheckBox id="fieldPopulationBasicsPlusGroup" text="isisfish.populationBasics.plusGroup" @@ -277,7 +182,7 @@ <JButton id='create' decorator='boxed' text="isisfish.common.new" enabled="{!validator.isChanged()}" - onActionPerformed="create()"/> + onActionPerformed="handler.create()"/> </cell> <cell fill='horizontal' weightx='0.5'> <JButton id='delete' decorator='boxed' Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,87 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import java.awt.CardLayout; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import org.nuiton.math.matrix.gui.MatrixPanelEvent; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * Population handler. + */ +public class PopulationCapturabilityHandler extends InputContentHandler<PopulationCapturabilityUI> { + + protected void init(final PopulationCapturabilityUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(PopulationCapturabilityUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldPopulationCapturabilityComment.setText(""); + inputContentUI.fieldPopulationCapturability.setMatrix(null); + } + if (evt.getNewValue() != null) { + if (inputContentUI.getBean().getCapturability() != null) { + inputContentUI.fieldPopulationCapturability.setMatrix(inputContentUI.getBean().getCapturability().copy()); + } + refreshHidablePanel(); + } + } + }); + } + + protected void populationCapturabilityMatrixChanged(MatrixPanelEvent event) { + if (inputContentUI.getBean() != null && inputContentUI.fieldPopulationCapturability.getMatrix() != null) { + inputContentUI.getBean().setCapturability(inputContentUI.fieldPopulationCapturability.getMatrix().copy()); + } + } + + protected void useEquationChanged() { + inputContentUI.getBean().setCapturabilityEquationUsed(inputContentUI.fieldUseCapturabilityEquation.isSelected()); + + // compute matrix again to not diplay values computed by equation + if (!inputContentUI.fieldUseCapturabilityEquation.isSelected()) { + if (inputContentUI.getBean().getCapturability() != null) { + inputContentUI.fieldPopulationCapturability.setMatrix(inputContentUI.getBean().getCapturability().copy()); + } + } + refreshHidablePanel(); + } + + protected void refreshHidablePanel() { + if (inputContentUI.getBean() != null) { + if (inputContentUI.getBean().isCapturabilityEquationUsed()) { + inputContentUI.fieldUseCapturabilityEquation.setSelected(true); + ((CardLayout)inputContentUI.hidablePanel.getLayout()).show(inputContentUI.hidablePanel, "fieldUseEquation"); + } else { + inputContentUI.fieldUseCapturabilityEquation.setSelected(false); + ((CardLayout)inputContentUI.hidablePanel.getLayout()).show(inputContentUI.hidablePanel, "fieldUseMatrix"); + } + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationCapturabilityUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric + Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -27,14 +27,7 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/> - <import> - fr.ifremer.isisfish.entities.Population - org.nuiton.math.matrix.gui.MatrixPanelEvent - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - org.nuiton.math.matrix.gui.MatrixPanelListener - java.awt.CardLayout - </import> + <PopulationCapturabilityHandler id="handler" /> <BeanValidator id='validator' context="capturability" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population' @@ -42,68 +35,11 @@ </BeanValidator> <script><![CDATA[ -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldPopulationCapturabilityComment.setText(""); - fieldPopulationCapturability.setMatrix(null); - } - if (evt.getNewValue() != null) { - if (getBean().getCapturability() != null) { - fieldPopulationCapturability.setMatrix(getBean().getCapturability().copy()); - } - refreshHidablePanel(); - } - } - }); -} - -protected void populationCapturabilityMatrixChanged(MatrixPanelEvent event) { - if (getBean() != null && fieldPopulationCapturability.getMatrix() != null) { - getBean().setCapturability(fieldPopulationCapturability.getMatrix().copy()); + protected void $afterCompleteSetup() { + handler.init(this); } -} + ]]></script> -/*public void refresh() { - Population population = getSaveVerifier().getEntity(Population.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - setBean(null); - setBean(population); - - if (getBean() != null){ - if (getBean().getCapturability() != null) { - fieldPopulationCapturability.setMatrix(getBean().getCapturability().copy()); - } - } -}*/ -protected void useEquationChanged() { - getBean().setCapturabilityEquationUsed(fieldUseCapturabilityEquation.isSelected()); - - // compute matrix again to not diplay values computed by equation - if (!fieldUseCapturabilityEquation.isSelected()) { - if (getBean().getCapturability() != null) { - fieldPopulationCapturability.setMatrix(getBean().getCapturability().copy()); - } - } - refreshHidablePanel(); -} -protected void refreshHidablePanel() { - if (getBean() != null) { - if (getBean().isCapturabilityEquationUsed()) { - fieldUseCapturabilityEquation.setSelected(true); - ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseEquation"); - } - else { - fieldUseCapturabilityEquation.setSelected(false); - ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseMatrix"); - } - } -} - ]]> - </script> <JPanel id="body"> <Table> <row> @@ -114,18 +50,18 @@ <row> <cell columns='2' fill='horizontal' weightx='1.0' anchor='east'> <JCheckBox id="fieldUseCapturabilityEquation" selected='{getBean().isCapturabilityEquationUsed()}' - text="isisfish.populationCapturability.useCapturabilityEquation" onActionPerformed='useEquationChanged()' + text="isisfish.populationCapturability.useCapturabilityEquation" onActionPerformed='handler.useEquationChanged()' enabled='{isActive()}' decorator='boxed'/> </cell> </row> <row> <cell columns='2' fill='both' weightx='1.0' weighty='0.5'> - <JPanel id="hidablePanel" layout='{new CardLayout()}'> + <JPanel id="hidablePanel" layout='{new java.awt.CardLayout()}'> <org.nuiton.math.matrix.gui.MatrixPanelEditor id ='fieldPopulationCapturability' matrix='{getBean().getCapturability() == null ? null : getBean().getCapturability().copy()}' enabled='{isActive()}' decorator='boxed' _sensitivityBean='{Population.class}' _sensitivityMethod='"Capturability"' - onMatrixChanged="populationCapturabilityMatrixChanged(event)" + onMatrixChanged="handler.populationCapturabilityMatrixChanged(event)" constraints='"fieldUseMatrix"' /> <fr.ifremer.isisfish.ui.input.InputOneEquationUI id='capturabilityEquation' constructorParams='this' text='isisfish.common.capturability' active='{isActive()}' Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,36 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * Population handler. + */ +public class PopulationEquationHandler extends InputContentHandler<PopulationEquationUI> { + + protected void init(final PopulationEquationUI inputContentUI) { + super.init(inputContentUI); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationEquationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric + Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -27,9 +27,7 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/> - <import> - fr.ifremer.isisfish.entities.Population; - </import> + <PopulationEquationHandler id="handler" /> <BeanValidator id='validator' context="equation" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population' @@ -37,18 +35,11 @@ </BeanValidator> <script><![CDATA[ -/*public void refresh() { - Population population = getSaveVerifier().getEntity(Population.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - setBean(null); - setBean(population); + protected void $afterCompleteSetup() { + handler.init(this); + } + ]]></script> - getSaveVerifier().addCurrentPanel(naturalDeathRate, meanWeight, price); -}*/ - ]]> - </script> <JPanel id="body"> <Table> <row> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,113 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.math.matrix.MatrixND; + +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericComboModel; + +/** + * Population handler. + */ +public class PopulationGroupHandler extends InputContentHandler<PopulationGroupUI> { + + /** Class logger. */ + private static final Log log = LogFactory.getLog(PopulationGroupHandler.class); + + protected void init(final PopulationGroupUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(PopulationGroupUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + + GenericComboModel<PopulationGroup> groupModel = new GenericComboModel<>(); + + if (evt.getNewValue() == null) { + inputContentUI.setPopulationGroup(null); + } + if (evt.getNewValue() != null) { + groupModel.setElementList(inputContentUI.getBean().getPopulationGroup()); + } + + inputContentUI.populationGroupPopulationGroupComboBox.setModel(groupModel); + } + }); + + inputContentUI.addPropertyChangeListener(PopulationGroupUI.PROPERTY_POPULATION_GROUP, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldPopulationGroupMeanWeight.setText(""); + inputContentUI.fieldPopulationGroupPrice.setText(""); + inputContentUI.fieldPopulationGroupReproductionRate.setText(""); + inputContentUI.fieldPopulationGroupMaturityOgive.setText(""); + inputContentUI.fieldPopulationGroupAge.setText(""); + inputContentUI.fieldPopulationGroupMinLength.setText(""); + inputContentUI.fieldPopulationGroupMaxLength.setText(""); + inputContentUI.fieldPopulationGroupComment.setText(""); + inputContentUI.fieldPopulationGroupNaturalDeathRate.setMatrix(null); + } + if (evt.getNewValue() != null) { + + } + } + }); + } + + protected void setNaturalDeathRateMatrix() { + try { + Population population = inputContentUI.getBean(); + MatrixND naturalDeathRateMatrix = population.getNaturalDeathRateMatrix(); + + // extract only line for this population group + MatrixND naturalDeathRateMatrix2 = naturalDeathRateMatrix.getSubMatrix(0, inputContentUI.getPopulationGroup()); + inputContentUI.fieldPopulationGroupNaturalDeathRate.setMatrix(naturalDeathRateMatrix2.copy()); + } catch (Exception e) { + // can happen if population has no zone yet + // TODO maybe display a message + if (log.isWarnEnabled()) { + log.warn("No zone defined for this population group", e); + } + } + } + + /** + * Called on PopulationGroup combo box selection. + */ + protected void populationGroupChanged() { + PopulationGroup selectedPopulationGroup = (PopulationGroup)inputContentUI.populationGroupPopulationGroupComboBox.getSelectedItem(); + inputContentUI.setPopulationGroup(selectedPopulationGroup); + if (selectedPopulationGroup != null) { + inputContentUI.getSaveVerifier().addCurrentEntity(selectedPopulationGroup); + setNaturalDeathRateMatrix(); + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupHandler.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationGroupUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -39,14 +39,7 @@ <fr.ifremer.isisfish.entities.PopulationGroup id='populationGroup' javaBean='null'/> - <import> - fr.ifremer.isisfish.entities.PopulationGroup - fr.ifremer.isisfish.entities.Population - org.nuiton.math.matrix.MatrixND - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - fr.ifremer.isisfish.ui.models.common.GenericComboModel - </import> + <PopulationGroupHandler id="handler" /> <BeanValidator id='validator' context="group" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population' @@ -63,78 +56,16 @@ valid="{validator.isValid() && validatorGroup.isValid()}" /> <script><![CDATA[ -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - - GenericComboModel<PopulationGroup> groupModel = new GenericComboModel<>(); - - if (evt.getNewValue() == null) { - setPopulationGroup(null); - } - if (evt.getNewValue() != null) { - groupModel.setElementList(getBean().getPopulationGroup()); - } - - populationGroupPopulationGroupComboBox.setModel(groupModel); - } - }); - - addPropertyChangeListener(PROPERTY_POPULATION_GROUP, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldPopulationGroupMeanWeight.setText(""); - fieldPopulationGroupPrice.setText(""); - fieldPopulationGroupReproductionRate.setText(""); - fieldPopulationGroupMaturityOgive.setText(""); - fieldPopulationGroupAge.setText(""); - fieldPopulationGroupMinLength.setText(""); - fieldPopulationGroupMaxLength.setText(""); - fieldPopulationGroupComment.setText(""); - fieldPopulationGroupNaturalDeathRate.setMatrix(null); - } - if (evt.getNewValue() != null) { - - } - } - }); -} - -@Override -public void resetChangeModel() { - changeModel.setStayChanged(false); -} - -protected void setNaturalDeathRateMatrix() { - try { - Population population = getBean(); - MatrixND naturalDeathRateMatrix = population.getNaturalDeathRateMatrix(); - - // extract only line for this population group - MatrixND naturalDeathRateMatrix2 = naturalDeathRateMatrix.getSubMatrix(0, getPopulationGroup()); - fieldPopulationGroupNaturalDeathRate.setMatrix(naturalDeathRateMatrix2.copy()); - } catch (Exception e) { - // can happen if population has no zone yet - // TODO maybe display a message - if (log.isWarnEnabled()) { - log.warn("No zone defined for this population group", e); - } + protected void $afterCompleteSetup() { + handler.init(this); } -} -/** - * Called on PopulationGroup combo box selection. - */ -protected void populationGroupChanged() { - PopulationGroup selectedPopulationGroup = (PopulationGroup)populationGroupPopulationGroupComboBox.getSelectedItem(); - setPopulationGroup(selectedPopulationGroup); - if (selectedPopulationGroup != null) { - getSaveVerifier().addCurrentEntity(selectedPopulationGroup); - setNaturalDeathRateMatrix(); + @Override + public void resetChangeModel() { + changeModel.setStayChanged(false); } -} - ]]> - </script> + ]]></script> + <JPanel id="body"> <Table> <row> @@ -144,7 +75,7 @@ <cell columns='2' fill='horizontal' weightx='1.0'> <JComboBox id='populationGroupPopulationGroupComboBox' genericType="fr.ifremer.isisfish.entities.PopulationGroup" - onActionPerformed='populationGroupChanged()' enabled='{isActive()}'/> + onActionPerformed='handler.populationGroupChanged()' enabled='{isActive()}'/> </cell> </row> <row> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,46 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * Population handler. + */ +public class PopulationHandler extends InputContentHandler<PopulationUI> { + + protected void init(final PopulationUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.setButtonTitle(t("isisfish.input.continueGears")); + inputContentUI.setNextPath(n("isisfish.input.tree.gears")); + + // install change listener + // (depends on sensitivity can't be done on constructor) + inputContentUI.installChangeListener(inputContentUI.populationTab); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,122 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import org.nuiton.math.matrix.MatrixND; +import org.nuiton.math.matrix.gui.MatrixPanelEvent; + +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; +import fr.ifremer.isisfish.entities.Zone; +import fr.ifremer.isisfish.ui.input.InputAction; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericComboModel; + +/** + * Population handler. + */ +public class PopulationMigrationEmigrationHandler extends InputContentHandler<PopulationMigrationEmigrationUI> { + + protected void init(final PopulationMigrationEmigrationUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(PopulationMigrationEmigrationUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldPopulationMigrationEmigrationCoefficient.setText(""); + inputContentUI.populationMigrationEmigrationTable.setMatrix(null); + } + if (evt.getNewValue() != null) { + + } + setFieldPopulationMigrationMigrationGroupChooserModel(); + setFieldPopulationMigrationMigrationDepartureZoneChooserModel(); + setAddButton(); + } + }); + } + + public void init(PopulationSeasonInfo pi) { + // add null before, for second to be considered as a changed event + // otherwize, setBean has no effect + //setPopInfo(null); + //setPopInfo(pi); + inputContentUI.populationMigrationEmigrationTable.setMatrix(inputContentUI.getPopInfo().getEmigrationMatrix().copy()); + } + + protected void populationMigrationEmigrationMatrixChanged(MatrixPanelEvent event) { + inputContentUI.remove.setEnabled(inputContentUI.populationMigrationEmigrationTable.getTable().getSelectedRow() != -1); + if (inputContentUI.popInfo != null) { + inputContentUI.popInfo.setMigrationMatrix(inputContentUI.populationMigrationEmigrationTable.getMatrix().clone()); + } + } + + protected void setFieldPopulationMigrationMigrationGroupChooserModel() { + GenericComboModel<PopulationGroup> groups = new GenericComboModel<>(); + if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationGroup() != null) { + //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationGroupChooser,getBean().getPopulationGroup(), null, true); + groups.setElementList(inputContentUI.getBean().getPopulationGroup()); + } + inputContentUI.fieldPopulationMigrationEmigrationGroupChooser.setModel(groups); + } + + protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel() { + GenericComboModel<Zone> zones = new GenericComboModel<>(); + if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationZone() != null) { + //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true); + zones.setElementList(inputContentUI.getBean().getPopulationZone()); + } + inputContentUI.fieldPopulationMigrationEmigrationDepartureZoneChooser.setModel(zones); + } + + protected void add() { + inputContentUI.getContextValue(InputAction.class).addEmigration(inputContentUI.getPopInfo(), + (PopulationGroup)inputContentUI.fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem(), + (Zone)inputContentUI.fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem(), + Double.parseDouble(inputContentUI.fieldPopulationMigrationEmigrationCoefficient.getText())); + inputContentUI.populationMigrationEmigrationTable.setMatrix(inputContentUI.getPopInfo().getEmigrationMatrix().clone()); + } + + protected void remove() { + int row = inputContentUI.populationMigrationEmigrationTable.getTable().getSelectedRow(); + if (row != -1) { + Object group = inputContentUI.populationMigrationEmigrationTable.getTable().getValueAt(row, 0); + Object arrival = inputContentUI.populationMigrationEmigrationTable.getTable().getValueAt(row, 1); + + MatrixND mat = inputContentUI.popInfo.getEmigrationMatrix().clone(); + mat.setValue(group, arrival, 0); + inputContentUI.popInfo.setEmigrationMatrix(mat); + inputContentUI.populationMigrationEmigrationTable.setMatrix(inputContentUI.getPopInfo().getEmigrationMatrix().copy()); + } + } + + protected void setAddButton() { + inputContentUI.add.setEnabled(inputContentUI.isActive() && inputContentUI.fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem() != null + && inputContentUI.fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem() != null + && !inputContentUI.fieldPopulationMigrationEmigrationCoefficient.getText().equals("")); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEmigrationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -28,97 +28,14 @@ <fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/> <fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/> - <import> - fr.ifremer.isisfish.entities.Population - fr.ifremer.isisfish.entities.PopulationGroup - fr.ifremer.isisfish.entities.PopulationSeasonInfo - fr.ifremer.isisfish.entities.Zone - org.nuiton.math.matrix.MatrixND - org.nuiton.math.matrix.gui.MatrixPanelEvent - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - org.nuiton.math.matrix.gui.MatrixPanelListener - fr.ifremer.isisfish.ui.input.InputAction - fr.ifremer.isisfish.ui.models.common.GenericComboModel - </import> + <PopulationMigrationEmigrationHandler id="handler" /> <script><![CDATA[ -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldPopulationMigrationEmigrationCoefficient.setText(""); - populationMigrationEmigrationTable.setMatrix(null); - } - if (evt.getNewValue() != null) { - - } - setFieldPopulationMigrationMigrationGroupChooserModel(); - setFieldPopulationMigrationMigrationDepartureZoneChooserModel(); - setAddButton(); - } - }); -} - -public void init(PopulationSeasonInfo pi){ - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - //setPopInfo(null); - //setPopInfo(pi); - populationMigrationEmigrationTable.setMatrix(getPopInfo().getEmigrationMatrix().copy()); -} - -protected void populationMigrationEmigrationMatrixChanged(MatrixPanelEvent event) { - remove.setEnabled(populationMigrationEmigrationTable.getTable().getSelectedRow() != -1); - if (popInfo != null) { - popInfo.setMigrationMatrix(populationMigrationEmigrationTable.getMatrix().clone()); + protected void $afterCompleteSetup() { + handler.init(this); } -} + ]]></script> -protected void setFieldPopulationMigrationMigrationGroupChooserModel() { - GenericComboModel<PopulationGroup> groups = new GenericComboModel<>(); - if (getBean() != null && getBean().getPopulationGroup() != null) { - //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationGroupChooser,getBean().getPopulationGroup(), null, true); - groups.setElementList(getBean().getPopulationGroup()); - } - fieldPopulationMigrationEmigrationGroupChooser.setModel(groups); -} -protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel() { - GenericComboModel<Zone> zones = new GenericComboModel<>(); - if (getBean() != null && getBean().getPopulationZone() != null){ - //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationEmigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true); - zones.setElementList(getBean().getPopulationZone()); - } - fieldPopulationMigrationEmigrationDepartureZoneChooser.setModel(zones); -} -protected void add() { - getContextValue(InputAction.class).addEmigration( - getPopInfo(), - (PopulationGroup) fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem(), - (Zone) fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem(), - Double.parseDouble(fieldPopulationMigrationEmigrationCoefficient.getText())); - populationMigrationEmigrationTable.setMatrix(getPopInfo().getEmigrationMatrix().clone()); -} - -protected void remove() { - int row = populationMigrationEmigrationTable.getTable().getSelectedRow(); - if (row != -1) { - Object group = populationMigrationEmigrationTable.getTable().getValueAt(row, 0); - Object arrival = populationMigrationEmigrationTable.getTable().getValueAt(row, 1); - - MatrixND mat = popInfo.getEmigrationMatrix().clone(); - mat.setValue(group, arrival, 0); - popInfo.setEmigrationMatrix(mat); - populationMigrationEmigrationTable.setMatrix(getPopInfo().getEmigrationMatrix().copy()); - } -} -protected void setAddButton() { - add.setEnabled(isActive() - && fieldPopulationMigrationEmigrationGroupChooser.getSelectedItem() != null - && fieldPopulationMigrationEmigrationDepartureZoneChooser.getSelectedItem() != null - && !fieldPopulationMigrationEmigrationCoefficient.getText().equals("")); -} -]]></script> <JPanel id="body"> <Table> <row> @@ -128,13 +45,13 @@ <cell fill='horizontal' weightx='0.5'> <JComboBox id="fieldPopulationMigrationEmigrationGroupChooser" genericType="fr.ifremer.isisfish.entities.PopulationGroup" - enabled='{isActive()}' onItemStateChanged='setAddButton()'/> + enabled='{isActive()}' onItemStateChanged='handler.setAddButton()'/> </cell> <cell> <JLabel text="isisfish.populationMigrationEmigration.coefficient" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JTextField id="fieldPopulationMigrationEmigrationCoefficient" enabled='{isActive()}' onKeyReleased='setAddButton()'/> + <JTextField id="fieldPopulationMigrationEmigrationCoefficient" enabled='{isActive()}' onKeyReleased='handler.setAddButton()'/> </cell> </row> <row> @@ -144,7 +61,7 @@ <cell fill='horizontal' weightx='0.5'> <JComboBox id="fieldPopulationMigrationEmigrationDepartureZoneChooser" genericType="fr.ifremer.isisfish.entities.Zone" - enabled='{isActive()}' onItemStateChanged='setAddButton()'/> + enabled='{isActive()}' onItemStateChanged='handler.setAddButton()'/> </cell> <cell columns='2' fill='horizontal' weightx='0.5'> <JPanel/> @@ -152,7 +69,7 @@ </row> <row columns='4'> <cell fill='horizontal' weightx='1.0'> - <JButton id="add" text="isisfish.common.add" onActionPerformed='add()' + <JButton id="add" text="isisfish.common.add" onActionPerformed='handler.add()' enabled='false'/> </cell> </row> @@ -160,13 +77,13 @@ <cell fill='both' weightx='1.0' weighty='1.0'> <org.nuiton.math.matrix.gui.MatrixPanelEditor id='populationMigrationEmigrationTable' linearModel="true" enabled='{isActive()}' - onMatrixChanged="populationMigrationEmigrationMatrixChanged(event)"/> + onMatrixChanged="handler.populationMigrationEmigrationMatrixChanged(event)"/> </cell> </row> <row> <cell columns='4' fill='horizontal' weightx='1.0'> <JButton id="remove" text="isisfish.common.remove" - onActionPerformed='remove()' enabled='{isActive()}'/> + onActionPerformed='handler.remove()' enabled='{isActive()}'/> </cell> </row> </Table> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,41 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * Population handler. + */ +public class PopulationMigrationEquationHandler extends InputContentHandler<PopulationMigrationEquationUI> { + + protected void init(final PopulationMigrationEquationUI inputContentUI) { + super.init(inputContentUI); + } + + public void init(PopulationSeasonInfo pi) { + + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationEquationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -29,24 +29,20 @@ <fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/> - <import> - fr.ifremer.isisfish.entities.PopulationSeasonInfo; - fr.ifremer.isisfish.entities.Population; - </import> + <PopulationMigrationEquationHandler id="handler" /> <script><![CDATA[ -public void init(PopulationSeasonInfo populationSeasonInfo) { - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - //setPopInfo(null); - //setPopInfo(populationSeasonInfo); -} + protected void $afterCompleteSetup() { + handler.init(this); + } + /*public void init(PopulationSeasonInfo populationSeasonInfo) { + // add null before, for second to be considered as a changed event + // otherwize, setBean has no effect + //setPopInfo(null); + //setPopInfo(populationSeasonInfo); + }*/ + ]]></script> -/*public void refresh() { - getSaveVerifier().addCurrentPanel(immigrationEquation, emigrationEquation, migrationEquation); -}*/ - ]]> - </script> <JPanel id="body"> <Table> <row> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,115 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import java.awt.CardLayout; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericComboModel; + +/** + * Population handler. + */ +public class PopulationMigrationHandler extends InputContentHandler<PopulationMigrationUI> { + + protected void init(final PopulationMigrationUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(PopulationMigrationUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldPopulationMigrationComment.setText(""); + inputContentUI.fieldUseEquationMigration.setSelected(false); + } + if (evt.getNewValue() != null) { + + } + refresh(); + } + }); + } + + public void refresh() { + //Population population = inputContentUI.getSaveVerifier().getEntity(Population.class); + + // add null before, for second to be considered as a changed event + // otherwize, setBean has no effect + //setBean(null); + //setBean(population); + + // refresh psi list in combo box + GenericComboModel<PopulationSeasonInfo> model = (GenericComboModel<PopulationSeasonInfo>)inputContentUI.fieldPopulationMigrationSeasonChooser.getModel(); + if (inputContentUI.getBean() != null) { + PopulationSeasonInfo previousSelected = (PopulationSeasonInfo)model.getSelectedItem(); + model.setElementList(inputContentUI.getBean().getPopulationSeasonInfo()); + + // do this to keep selected after cancel/refresh + if (previousSelected != null) { + for (PopulationSeasonInfo psi : inputContentUI.getBean().getPopulationSeasonInfo()) { + if (psi.getTopiaId().equals(previousSelected.getTopiaId())) { + model.setSelectedItem(psi); + } + } + } + + seasonChanged(); + } else { + model.setElementList(null); + } + } + + protected void seasonChanged() { + GenericComboModel<PopulationSeasonInfo> model = (GenericComboModel<PopulationSeasonInfo>)inputContentUI.fieldPopulationMigrationSeasonChooser.getModel(); + PopulationSeasonInfo selectedPSI = (PopulationSeasonInfo)model.getSelectedItem(); + inputContentUI.setPopInfo(selectedPSI); + if (inputContentUI.getPopInfo() != null) { + inputContentUI.getSaveVerifier().addCurrentEntity(inputContentUI.getPopInfo()); + inputContentUI.populationMigrationEquationUI.getHandler().init(inputContentUI.getPopInfo()); + inputContentUI.populationMigrationMigrationUI.getHandler().init(inputContentUI.getPopInfo()); + inputContentUI.populationMigrationImmigrationUI.getHandler().init(inputContentUI.getPopInfo()); + inputContentUI.populationMigrationEmigrationUI.getHandler().init(inputContentUI.getPopInfo()); + } + refreshHidablePanel(); + } + + protected void useEquationChanged() { + inputContentUI.getPopInfo().setUseEquationMigration(inputContentUI.fieldUseEquationMigration.isSelected()); + refreshHidablePanel(); + } + + protected void refreshHidablePanel() { + if (inputContentUI.getPopInfo() != null) { + if (inputContentUI.getPopInfo().isUseEquationMigration()) { + inputContentUI.fieldUseEquationMigration.setSelected(true); + ((CardLayout)inputContentUI.hidablePanel.getLayout()).show(inputContentUI.hidablePanel, "fieldUseEquation"); + } else { + inputContentUI.fieldUseEquationMigration.setSelected(false); + ((CardLayout)inputContentUI.hidablePanel.getLayout()).show(inputContentUI.hidablePanel, "fieldUseMatrix"); + } + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,121 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import org.nuiton.math.matrix.MatrixND; +import org.nuiton.math.matrix.gui.MatrixPanelEvent; + +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; +import fr.ifremer.isisfish.entities.Zone; +import fr.ifremer.isisfish.ui.input.InputAction; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericComboModel; + +/** + * Population handler. + */ +public class PopulationMigrationImmigrationHandler extends InputContentHandler<PopulationMigrationImmigrationUI> { + + protected void init(final PopulationMigrationImmigrationUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(PopulationMigrationImmigrationUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldPopulationMigrationImmigrationCoefficient.setText(""); + inputContentUI.populationMigrationImmigrationTable.setMatrix(null); + } + if (evt.getNewValue() != null) { + + } + setFieldPopulationMigrationMigrationGroupChooserModel(); + setFieldPopulationMigrationMigrationArrivalZoneChooserModel(); + setAddButton(); + } + }); + } + + protected void populationMigrationImmigrationMatrixChanged(MatrixPanelEvent event) { + if (inputContentUI.getPopInfo() != null) { + inputContentUI.getPopInfo().setImmigrationMatrix(inputContentUI.populationMigrationImmigrationTable.getMatrix().clone()); + } + } + + public void init(PopulationSeasonInfo populationSeasonInfo) { + // add null before, for second to be considered as a changed event + // otherwize, setBean has no effect + //setPopInfo(null); + //setPopInfo(populationSeasonInfo); + + inputContentUI.populationMigrationImmigrationTable.setMatrix(inputContentUI.getPopInfo().getImmigrationMatrix().copy()); + } + + protected void setFieldPopulationMigrationMigrationGroupChooserModel() { + GenericComboModel<PopulationGroup> groups = new GenericComboModel<>(); + if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationGroup() != null) { + groups.setElementList(inputContentUI.getBean().getPopulationGroup()); + } + inputContentUI.fieldPopulationMigrationImmigrationGroupChooser.setModel(groups); + } + + protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel() { + GenericComboModel<Zone> zones = new GenericComboModel<>(); + if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationZone() != null) { + //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationArrivalZoneChooser,getBean().getPopulationZone(), null, true); + zones.setElementList(inputContentUI.getBean().getPopulationZone()); + } + inputContentUI.fieldPopulationMigrationImmigrationArrivalZoneChooser.setModel(zones); + } + + protected void add() { + inputContentUI.getContextValue(InputAction.class).addImmigration(inputContentUI.getPopInfo(), + (PopulationGroup)inputContentUI.fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem(), + (Zone)inputContentUI.fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem(), + Double.parseDouble(inputContentUI.fieldPopulationMigrationImmigrationCoefficient.getText())); + inputContentUI.populationMigrationImmigrationTable.setMatrix(inputContentUI.getPopInfo().getImmigrationMatrix().clone()); + } + + protected void remove() { + int row = inputContentUI.populationMigrationImmigrationTable.getTable().getSelectedRow(); + if (row != -1) { + Object group = inputContentUI.populationMigrationImmigrationTable.getTable().getValueAt(row, 0); + Object departure = inputContentUI.populationMigrationImmigrationTable.getTable().getValueAt(row, 1); + + MatrixND mat = inputContentUI.getPopInfo().getImmigrationMatrix().clone(); + mat.setValue(group, departure, 0); + inputContentUI.getPopInfo().setImmigrationMatrix(mat); + inputContentUI.populationMigrationImmigrationTable.setMatrix(inputContentUI.getPopInfo().getImmigrationMatrix().copy()); + } + } + + protected void setAddButton() { + inputContentUI.add.setEnabled(inputContentUI.isActive() && inputContentUI.fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem() != null + && !inputContentUI.fieldPopulationMigrationImmigrationCoefficient.getText().equals("") + && inputContentUI.fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem() != null); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationImmigrationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -28,97 +28,14 @@ <fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/> <fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/> - <import> - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - fr.ifremer.isisfish.entities.Population - fr.ifremer.isisfish.entities.PopulationGroup - fr.ifremer.isisfish.entities.PopulationSeasonInfo - fr.ifremer.isisfish.entities.Zone - org.nuiton.math.matrix.MatrixND - org.nuiton.math.matrix.gui.MatrixPanelEvent - org.nuiton.math.matrix.gui.MatrixPanelListener - fr.ifremer.isisfish.ui.input.InputAction - fr.ifremer.isisfish.ui.models.common.GenericComboModel - </import> + <PopulationMigrationImmigrationHandler id="handler" /> <script><![CDATA[ -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldPopulationMigrationImmigrationCoefficient.setText(""); - populationMigrationImmigrationTable.setMatrix(null); - } - if (evt.getNewValue() != null) { - - } - setFieldPopulationMigrationMigrationGroupChooserModel(); - setFieldPopulationMigrationMigrationArrivalZoneChooserModel(); - setAddButton(); - } - }); -} - -protected void populationMigrationImmigrationMatrixChanged(MatrixPanelEvent event) { - if (getPopInfo() != null){ - getPopInfo().setImmigrationMatrix(populationMigrationImmigrationTable.getMatrix().clone()); + protected void $afterCompleteSetup() { + handler.init(this); } -} + ]]></script> -public void init(PopulationSeasonInfo populationSeasonInfo) { - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - //setPopInfo(null); - //setPopInfo(populationSeasonInfo); - - populationMigrationImmigrationTable.setMatrix(getPopInfo().getImmigrationMatrix().copy()); -} - -protected void setFieldPopulationMigrationMigrationGroupChooserModel(){ - GenericComboModel<PopulationGroup> groups = new GenericComboModel<>(); - if (getBean() != null && getBean().getPopulationGroup() != null){ - groups.setElementList(getBean().getPopulationGroup()); - } - fieldPopulationMigrationImmigrationGroupChooser.setModel(groups); -} -protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel(){ - GenericComboModel<Zone> zones = new GenericComboModel<>(); - if (getBean() != null && getBean().getPopulationZone() != null){ - //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationArrivalZoneChooser,getBean().getPopulationZone(), null, true); - zones.setElementList(getBean().getPopulationZone()); - } - fieldPopulationMigrationImmigrationArrivalZoneChooser.setModel(zones); -} -protected void add() { - getContextValue(InputAction.class).addImmigration(getPopInfo(), - (PopulationGroup) fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem(), - (Zone) fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem(), - Double.parseDouble(fieldPopulationMigrationImmigrationCoefficient.getText())); - populationMigrationImmigrationTable.setMatrix(getPopInfo().getImmigrationMatrix().clone()); -} -protected void remove() { - int row = populationMigrationImmigrationTable.getTable().getSelectedRow(); - if (row != -1) { - Object group = populationMigrationImmigrationTable.getTable().getValueAt(row, 0); - Object departure = populationMigrationImmigrationTable.getTable().getValueAt(row, 1); - - MatrixND mat = getPopInfo().getImmigrationMatrix().clone(); - mat.setValue(group, departure, 0); - getPopInfo().setImmigrationMatrix(mat); - populationMigrationImmigrationTable.setMatrix(getPopInfo().getImmigrationMatrix().copy()); - } -} - -protected void setAddButton() { - add.setEnabled(isActive() && - fieldPopulationMigrationImmigrationGroupChooser.getSelectedItem() != null && - !fieldPopulationMigrationImmigrationCoefficient.getText().equals("") && - fieldPopulationMigrationImmigrationArrivalZoneChooser.getSelectedItem() != null - ); -} - ]]> - </script> <JPanel id="body"> <Table> <row> @@ -128,13 +45,13 @@ <cell fill='horizontal' weightx='0.5'> <JComboBox id="fieldPopulationMigrationImmigrationGroupChooser" genericType="fr.ifremer.isisfish.entities.PopulationGroup" - enabled='{isActive()}' onActionPerformed='setAddButton()'/> + enabled='{isActive()}' onActionPerformed='handler.setAddButton()'/> </cell> <cell> <JLabel text="isisfish.populationMigrationImmigration.coefficient" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JTextField id="fieldPopulationMigrationImmigrationCoefficient" enabled='{isActive()}' onKeyReleased='setAddButton()'/> + <JTextField id="fieldPopulationMigrationImmigrationCoefficient" enabled='{isActive()}' onKeyReleased='handler.setAddButton()'/> </cell> </row> <row> @@ -144,7 +61,7 @@ <cell fill='horizontal' weightx='0.5'> <JComboBox id="fieldPopulationMigrationImmigrationArrivalZoneChooser" genericType="fr.ifremer.isisfish.entities.Zone" - enabled='{isActive()}' onActionPerformed='setAddButton()'/> + enabled='{isActive()}' onActionPerformed='handler.setAddButton()'/> </cell> <cell columns='2' fill='horizontal' weightx='0.5'> <JPanel/> @@ -152,7 +69,7 @@ </row> <row columns='4'> <cell fill='horizontal' weightx='1.0'> - <JButton id="add" text="isisfish.common.add" onActionPerformed='add()' + <JButton id="add" text="isisfish.common.add" onActionPerformed='handler.add()' enabled='false'/> </cell> </row> @@ -160,13 +77,13 @@ <cell fill='both' weightx='1.0' weighty='1.0'> <org.nuiton.math.matrix.gui.MatrixPanelEditor id='populationMigrationImmigrationTable' linearModel="true" enabled='{isActive()}' - onMatrixChanged="populationMigrationImmigrationMatrixChanged(event)"/> + onMatrixChanged="handler.populationMigrationImmigrationMatrixChanged(event)"/> </cell> </row> <row> <cell columns='4' fill='horizontal' weightx='1.0'> <JButton id="remove" text="isisfish.common.remove" - onActionPerformed='remove()' enabled='{isActive()}'/> + onActionPerformed='handler.remove()' enabled='{isActive()}'/> </cell> </row> </Table> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,132 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import org.nuiton.math.matrix.MatrixND; +import org.nuiton.math.matrix.gui.MatrixPanelEvent; + +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; +import fr.ifremer.isisfish.entities.Zone; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericComboModel; + +/** + * Population handler. + */ +public class PopulationMigrationMigrationHandler extends InputContentHandler<PopulationMigrationMigrationUI> { + + protected void init(final PopulationMigrationMigrationUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(PopulationMigrationMigrationUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldPopulationMigrationMigrationCoefficient.setText(""); + inputContentUI.populationMigrationMigrationTable.setMatrix(null); + } + if (evt.getNewValue() != null) { + + } + setFieldPopulationMigrationMigrationGroupChooserModel(); + setFieldPopulationMigrationMigrationDepartureZoneChooserModel(); + setFieldPopulationMigrationMigrationArrivalZoneChooserModel(); + setAddButton(); + } + }); + } + + protected void populationMigrationMigrationMatrixChanged(MatrixPanelEvent event) { + if (inputContentUI.getPopInfo() != null) { + inputContentUI.getPopInfo().setMigrationMatrix(inputContentUI.populationMigrationMigrationTable.getMatrix().clone()); + } + } + + public void init(PopulationSeasonInfo pi) { + // add null before, for second to be considered as a changed event + // otherwize, setBean has no effect + //setPopInfo(null); + //setPopInfo(pi); + + inputContentUI.populationMigrationMigrationTable.setMatrix(inputContentUI.getPopInfo().getMigrationMatrix().copy()); + } + + protected void setFieldPopulationMigrationMigrationGroupChooserModel() { + GenericComboModel<PopulationGroup> groups = new GenericComboModel<>(); + if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationGroup() != null) { + groups.setElementList(inputContentUI.getBean().getPopulationGroup()); + } + inputContentUI.fieldPopulationMigrationMigrationGroupChooser.setModel(groups); + } + + protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel() { + GenericComboModel<Zone> zones = new GenericComboModel<>(); + if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationZone() != null) { + //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true); + zones.setElementList(inputContentUI.getBean().getPopulationZone()); + } + inputContentUI.fieldPopulationMigrationMigrationDepartureZoneChooser.setModel(zones); + } + + protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel() { + GenericComboModel<Zone> zones = new GenericComboModel<>(); + if (inputContentUI.getBean() != null && inputContentUI.getBean().getPopulationZone() != null) { + //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationArrivalZoneChooser,getBean().getPopulationZone(), null, true); + zones.setElementList(inputContentUI.getBean().getPopulationZone()); + } + inputContentUI.fieldPopulationMigrationMigrationArrivalZoneChooser.setModel(zones); + } + + protected void add() { + inputContentUI.getAction().addMigration(inputContentUI.getPopInfo(), (PopulationGroup)inputContentUI.fieldPopulationMigrationMigrationGroupChooser.getSelectedItem(), + (Zone)inputContentUI.fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem(), + (Zone)inputContentUI.fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem(), + Double.parseDouble(inputContentUI.fieldPopulationMigrationMigrationCoefficient.getText())); + inputContentUI.populationMigrationMigrationTable.setMatrix(inputContentUI.getPopInfo().getMigrationMatrix().clone()); + } + + protected void remove() { + int row = inputContentUI.populationMigrationMigrationTable.getTable().getSelectedRow(); + if (row != -1) { + Object group = inputContentUI.populationMigrationMigrationTable.getTable().getValueAt(row, 0); + Object departure = inputContentUI.populationMigrationMigrationTable.getTable().getValueAt(row, 1); + Object arrival = inputContentUI.populationMigrationMigrationTable.getTable().getValueAt(row, 2); + + MatrixND mat = inputContentUI.getPopInfo().getMigrationMatrix().clone(); + mat.setValue(group, departure, arrival, 0); + inputContentUI.getPopInfo().setMigrationMatrix(mat); + inputContentUI.populationMigrationMigrationTable.setMatrix(inputContentUI.getPopInfo().getMigrationMatrix().copy()); + } + } + + protected void setAddButton() { + inputContentUI.add.setEnabled(inputContentUI.isActive() && inputContentUI.fieldPopulationMigrationMigrationGroupChooser.getSelectedItem() != null + && !inputContentUI.fieldPopulationMigrationMigrationCoefficient.getText().equals("") + && inputContentUI.fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem() != null + && inputContentUI.fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem() != null); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationHandler.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationMigrationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -33,107 +33,14 @@ <Boolean id='zoneArrivalSelected' javaBean='false'/> <Boolean id='coefNonVide' javaBean='false'/> - <import> - fr.ifremer.isisfish.entities.PopulationSeasonInfo - fr.ifremer.isisfish.entities.Population - fr.ifremer.isisfish.entities.PopulationGroup - fr.ifremer.isisfish.entities.PopulationSeasonInfo - fr.ifremer.isisfish.entities.Zone - org.nuiton.math.matrix.MatrixND - org.nuiton.math.matrix.gui.MatrixPanelEvent - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - org.nuiton.math.matrix.gui.MatrixPanelListener - javax.swing.text.Document - fr.ifremer.isisfish.ui.models.common.GenericComboModel - </import> + <PopulationMigrationMigrationHandler id="handler" /> <script><![CDATA[ -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldPopulationMigrationMigrationCoefficient.setText(""); - populationMigrationMigrationTable.setMatrix(null); - } - if (evt.getNewValue() != null) { - - } - setFieldPopulationMigrationMigrationGroupChooserModel(); - setFieldPopulationMigrationMigrationDepartureZoneChooserModel(); - setFieldPopulationMigrationMigrationArrivalZoneChooserModel(); - setAddButton(); - } - }); -} - -protected void populationMigrationMigrationMatrixChanged(MatrixPanelEvent event) { - if (getPopInfo() != null) { - getPopInfo().setMigrationMatrix(populationMigrationMigrationTable.getMatrix().clone()); + protected void $afterCompleteSetup() { + handler.init(this); } -} -public void init(PopulationSeasonInfo pi) { - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - //setPopInfo(null); - //setPopInfo(pi); + ]]></script> - populationMigrationMigrationTable.setMatrix(getPopInfo().getMigrationMatrix().copy()); -} - -protected void setFieldPopulationMigrationMigrationGroupChooserModel() { - GenericComboModel<PopulationGroup> groups = new GenericComboModel<>(); - if (getBean() != null && getBean().getPopulationGroup() != null){ - groups.setElementList(getBean().getPopulationGroup()); - } - fieldPopulationMigrationMigrationGroupChooser.setModel(groups); -} -protected void setFieldPopulationMigrationMigrationDepartureZoneChooserModel(){ - GenericComboModel<Zone> zones = new GenericComboModel<>(); - if (getBean() != null && getBean().getPopulationZone() != null){ - //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationDepartureZoneChooser,getBean().getPopulationZone(), null, true); - zones.setElementList(getBean().getPopulationZone()); - } - fieldPopulationMigrationMigrationDepartureZoneChooser.setModel(zones); -} -protected void setFieldPopulationMigrationMigrationArrivalZoneChooserModel(){ - GenericComboModel<Zone> zones = new GenericComboModel<>(); - if (getBean() != null && getBean().getPopulationZone() != null){ - //jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationMigrationMigrationArrivalZoneChooser,getBean().getPopulationZone(), null, true); - zones.setElementList(getBean().getPopulationZone()); - } - fieldPopulationMigrationMigrationArrivalZoneChooser.setModel(zones); -} -protected void add() { - getAction().addMigration(getPopInfo(), - (PopulationGroup) fieldPopulationMigrationMigrationGroupChooser.getSelectedItem(), - (Zone) fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem(), - (Zone) fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem(), - Double.parseDouble(fieldPopulationMigrationMigrationCoefficient.getText())); - populationMigrationMigrationTable.setMatrix(getPopInfo().getMigrationMatrix().clone()); -} -protected void remove() { - int row = populationMigrationMigrationTable.getTable().getSelectedRow(); - if (row != -1) { - Object group = populationMigrationMigrationTable.getTable().getValueAt(row, 0); - Object departure = populationMigrationMigrationTable.getTable().getValueAt(row, 1); - Object arrival = populationMigrationMigrationTable.getTable().getValueAt(row, 2); - - MatrixND mat = getPopInfo().getMigrationMatrix().clone(); - mat.setValue(group, departure, arrival, 0); - getPopInfo().setMigrationMatrix(mat); - populationMigrationMigrationTable.setMatrix(getPopInfo().getMigrationMatrix().copy()); - } -} -protected void setAddButton() { - add.setEnabled(isActive() && - fieldPopulationMigrationMigrationGroupChooser.getSelectedItem() != null && - !fieldPopulationMigrationMigrationCoefficient.getText().equals("") && - fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem() != null && - fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem() != null); -} - ]]> - </script> <JPanel id="body"> <Table> <row> @@ -142,16 +49,17 @@ </cell> <cell fill='horizontal' weightx='0.5'> <JComboBox id="fieldPopulationMigrationMigrationGroupChooser" enabled='{isActive()}' - onItemStateChanged="setAddButton()"/> + genericType="fr.ifremer.isisfish.entities.PopulationGroup" + onItemStateChanged="handler.setAddButton()"/> </cell> <cell> <JLabel text="isisfish.populationMigrationMigration.coefficient" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='0.5'> <JTextField id="fieldPopulationMigrationMigrationCoefficient" enabled='{isActive()}'/> - <Document initializer="fieldPopulationMigrationMigrationCoefficient.getDocument()" - onInsertUpdate='setAddButton()' - onRemoveUpdate='setAddButton()' /> + <javax.swing.text.Document initializer="fieldPopulationMigrationMigrationCoefficient.getDocument()" + onInsertUpdate='handler.setAddButton()' + onRemoveUpdate='handler.setAddButton()' /> </cell> </row> <row> @@ -161,7 +69,7 @@ <cell fill='horizontal' weightx='0.5'> <JComboBox id="fieldPopulationMigrationMigrationDepartureZoneChooser" enabled='{isActive()}' genericType="fr.ifremer.isisfish.entities.Zone" - onItemStateChanged="setAddButton()"/> + onItemStateChanged="handler.setAddButton()"/> </cell> <cell> <JLabel text="isisfish.populationMigrationMigration.arrivalZone" enabled='{isActive()}'/> @@ -169,25 +77,25 @@ <cell fill='horizontal' weightx='0.5'> <JComboBox id="fieldPopulationMigrationMigrationArrivalZoneChooser" enabled='{isActive()}' genericType="fr.ifremer.isisfish.entities.Zone" - onItemStateChanged="setAddButton()"/> + onItemStateChanged="handler.setAddButton()"/> </cell> </row> <row columns='4'> <cell fill='horizontal' weightx='1.0'> - <JButton id="add" text="isisfish.common.add" onActionPerformed='add()' enabled='false'/> + <JButton id="add" text="isisfish.common.add" onActionPerformed='handler.add()' enabled='false'/> </cell> </row> <row columns='4'> <cell fill='both' weightx='1.0' weighty='1.0'> <org.nuiton.math.matrix.gui.MatrixPanelEditor id='populationMigrationMigrationTable' linearModel='{true}' enabled='{isActive()}' - onMatrixChanged="populationMigrationMigrationMatrixChanged(event)" /> + onMatrixChanged="handler.populationMigrationMigrationMatrixChanged(event)" /> </cell> </row> <row> <cell columns='4' fill='horizontal' weightx='1.0'> <JButton id="remove" text="isisfish.common.remove" - onActionPerformed='remove()' enabled='{isActive()}' /> + onActionPerformed='handler.remove()' enabled='{isActive()}' /> </cell> </row> </Table> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationMigrationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric + Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -29,16 +29,7 @@ <fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/> - <import> - static org.nuiton.i18n.I18n.t - fr.ifremer.isisfish.entities.PopulationSeasonInfo; - fr.ifremer.isisfish.entities.Population; - fr.ifremer.isisfish.ui.models.common.GenericComboModel; - fr.ifremer.isisfish.ui.input.renderer.PopulationSeasonInfoComboRenderer; - java.beans.PropertyChangeEvent; - java.beans.PropertyChangeListener; - java.awt.CardLayout - </import> + <PopulationMigrationHandler id="handler" /> <BeanValidator id='validator' context="migration" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population' @@ -54,92 +45,22 @@ valid="{validator.isValid() && validatorSeason.isValid()}" /> <script><![CDATA[ -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldPopulationMigrationComment.setText(""); - fieldUseEquationMigration.setSelected(false); - } - if (evt.getNewValue() != null) { + protected void $afterCompleteSetup() { + handler.init(this); + } - } - refresh(); - } - }); -} - -@Override -public void resetChangeModel() { - changeModel.setStayChanged(false); -} - -public void refresh() { - Population population = getSaveVerifier().getEntity(Population.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - //setBean(null); - //setBean(population); - - // refresh psi list in combo box - GenericComboModel<PopulationSeasonInfo> model = (GenericComboModel<PopulationSeasonInfo>)fieldPopulationMigrationSeasonChooser.getModel(); - if (getBean() != null) { - PopulationSeasonInfo previousSelected = (PopulationSeasonInfo)model.getSelectedItem(); - model.setElementList(getBean().getPopulationSeasonInfo()); - - // do this to keep selected after cancel/refresh - if (previousSelected != null) { - for (PopulationSeasonInfo psi : getBean().getPopulationSeasonInfo()) { - if (psi.getTopiaId().equals(previousSelected.getTopiaId())) { - model.setSelectedItem(psi); - } - } - } - - seasonChanged(); + @Override + public void resetChangeModel() { + changeModel.setStayChanged(false); } - else { - model.setElementList(null); - } -} -protected void seasonChanged() { - GenericComboModel<PopulationSeasonInfo> model = (GenericComboModel<PopulationSeasonInfo>)fieldPopulationMigrationSeasonChooser.getModel(); - PopulationSeasonInfo selectedPSI = (PopulationSeasonInfo)model.getSelectedItem(); - setPopInfo(selectedPSI); - if (getPopInfo() != null) { - getSaveVerifier().addCurrentEntity(getPopInfo()); - populationMigrationEquationUI.init(getPopInfo()); - populationMigrationMigrationUI.init(getPopInfo()); - populationMigrationImmigrationUI.init(getPopInfo()); - populationMigrationEmigrationUI.init(getPopInfo()); + @Override + public void setLayer(boolean active) { + super.setLayer(active); + populationMigrationEquationUI.setLayer(active); } - refreshHidablePanel(); -} -protected void useEquationChanged() { - getPopInfo().setUseEquationMigration(fieldUseEquationMigration.isSelected()); - refreshHidablePanel(); -} -protected void refreshHidablePanel() { - if (getPopInfo() != null) { - if (getPopInfo().isUseEquationMigration()) { - fieldUseEquationMigration.setSelected(true); - ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseEquation"); - } - else { - fieldUseEquationMigration.setSelected(false); - ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseMatrix"); - } - } -} -@Override -public void setLayer(boolean active) { - super.setLayer(active); - populationMigrationEquationUI.setLayer(active); -} - ]]> - </script> + ]]></script> + <JPanel id='body'> <Table> <row> @@ -149,22 +70,22 @@ <cell fill='horizontal' weightx='1.0'> <JComboBox id="fieldPopulationMigrationSeasonChooser" genericType="PopulationSeasonInfo" - model='{new GenericComboModel<PopulationSeasonInfo>()}' + model='{new fr.ifremer.isisfish.ui.models.common.GenericComboModel<PopulationSeasonInfo>()}' renderer="{new PopulationSeasonInfoComboRenderer()}" - onActionPerformed='seasonChanged()' + onActionPerformed='handler.seasonChanged()' enabled='{isActive()}'/> </cell> </row> <row> <cell columns='2' anchor='west'> <JCheckBox id="fieldUseEquationMigration" selected='{getPopInfo().isUseEquationMigration()}' - text="isisfish.populationMigration.useEquation" onActionPerformed='useEquationChanged()' + text="isisfish.populationMigration.useEquation" onActionPerformed='handler.useEquationChanged()' enabled='{getPopInfo() != null}' decorator='boxed'/> </cell> </row> <row> <cell columns='2' fill='both' weightx='1.0' weighty='0.7'> - <JPanel id="hidablePanel" layout='{new CardLayout()}'> + <JPanel id="hidablePanel" layout='{new java.awt.CardLayout()}'> <JTabbedPane id="fieldUseMatrix" constraints='"fieldUseMatrix"' enabled='{getPopInfo() != null}'> <tab title='{t("isisfish.populationMigrationMigration.title")}'> <PopulationMigrationMigrationUI id="populationMigrationMigrationUI" constructorParams='this' decorator='boxed' Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,36 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * Population handler. + */ +public class PopulationPriceHandler extends InputContentHandler<PopulationPriceUI> { + + protected void init(final PopulationPriceUI inputContentUI) { + super.init(inputContentUI); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceHandler.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationPriceUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric + Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -27,9 +27,7 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/> - <import> - fr.ifremer.isisfish.entities.Population; - </import> + <PopulationPriceHandler id="handler" /> <BeanValidator id='validator' context="equation" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population' @@ -37,18 +35,11 @@ </BeanValidator> <script><![CDATA[ -/*public void refresh() { - Population population = getSaveVerifier().getEntity(Population.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - setBean(null); - setBean(population); + protected void $afterCompleteSetup() { + handler.init(this); + } + ]]></script> - getSaveVerifier().addCurrentPanel(naturalDeathRate, meanWeight, price); -}*/ - ]]> - </script> <JPanel id="body"> <Table> <row> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,61 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import org.nuiton.math.matrix.gui.MatrixPanelEvent; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * Population handler. + */ +public class PopulationRecruitmentHandler extends InputContentHandler<PopulationRecruitmentUI> { + + protected void init(final PopulationRecruitmentUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(PopulationRecruitmentUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldPopulationMonthGapBetweenReproRecrutement.setText(""); + inputContentUI.fieldPopulationRecruitmentComment.setText(""); + } + if (evt.getNewValue() != null) { + + } + } + }); + } + + protected void populationRecruitmentDistributionMatrixChanged(MatrixPanelEvent event) { + if (inputContentUI.getBean() != null){ + if (inputContentUI.fieldPopulationRecruitmentDistribution.getMatrix() != null){ + inputContentUI.getBean().setRecruitmentDistribution(inputContentUI.fieldPopulationRecruitmentDistribution.getMatrix().copy()); + } + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationRecruitmentUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -27,13 +27,7 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/> - <import> - fr.ifremer.isisfish.entities.Population; - org.nuiton.math.matrix.gui.MatrixPanelEvent; - java.beans.PropertyChangeEvent; - java.beans.PropertyChangeListener; - org.nuiton.math.matrix.gui.MatrixPanelListener; - </import> + <PopulationRecruitmentHandler id="handler" /> <BeanValidator id='validator' context="recruitement" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population' @@ -41,48 +35,11 @@ </BeanValidator> <script><![CDATA[ -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldPopulationMonthGapBetweenReproRecrutement.setText(""); - fieldPopulationRecruitmentComment.setText(""); - } - if (evt.getNewValue() != null) { - - } - } - }); -} - -protected void populationRecruitmentDistributionMatrixChanged(MatrixPanelEvent event) { - if (getBean() != null){ - if (fieldPopulationRecruitmentDistribution.getMatrix() != null){ - getBean().setRecruitmentDistribution(fieldPopulationRecruitmentDistribution.getMatrix().copy()); - } + protected void $afterCompleteSetup() { + handler.init(this); } -} + ]]></script> -/*public void refresh() { - Population population = getSaveVerifier().getEntity(Population.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - setBean(null); - setBean(population); - - if (getBean() != null && getBean().getRecruitmentDistribution() != null) { - fieldPopulationRecruitmentDistribution.setMatrix(getBean().getRecruitmentDistribution().copy()); - - // chatellier : number editor is not working - //fieldPopulationMonthGapBetweenReproRecrutement.init(); - } - - // TODO add only once - //fieldPopulationRecruitmentDistribution.addMatrixListener(listener); -}*/ - ]]> - </script> <JPanel id='body'> <Table> <row> @@ -119,7 +76,7 @@ <org.nuiton.math.matrix.gui.MatrixPanelEditor id ='fieldPopulationRecruitmentDistribution' matrix='{getBean() == null ? null : bean.getRecruitmentDistribution().copy()}' enabled='{isActive()}' decorator='boxed' _sensitivityBean='{Population.class}' _sensitivityMethod='"RecruitmentDistribution"' - onMatrixChanged="populationRecruitmentDistributionMatrixChanged(event)" /> + onMatrixChanged="handler.populationRecruitmentDistributionMatrixChanged(event)" /> </cell> <cell> <JButton icon="table.png" toolTipText="isisfish.common.newMatrix" Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonInfoComboRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/PopulationSeasonInfoComboRenderer.java) =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonInfoComboRenderer.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonInfoComboRenderer.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,70 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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.ifremer.isisfish.ui.input.population; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; + +/** + * Renderer pour la combo des {@link PopulationSeasonInfo}. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class PopulationSeasonInfoComboRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = -8277883340386163087L; + + /* + * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) + */ + @Override + public Component getListCellRendererComponent(JList<?> list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + // this must be used to have alterned highlight rows and default + // selection color + JLabel c = (JLabel) super.getListCellRendererComponent(list, value, + index, isSelected, cellHasFocus); + + PopulationSeasonInfo populationSeasonInfo = (PopulationSeasonInfo) value; + + // there is no default selection + if (value != null) { + c.setText(populationSeasonInfo.getFirstMonth() + " - " + populationSeasonInfo.getLastMonth()); + } + return c; + } +} Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,105 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import static org.nuiton.i18n.I18n.t; + +import javax.swing.JOptionPane; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.math.matrix.MatrixND; +import org.nuiton.math.matrix.gui.MatrixPanelEditor; +import org.nuiton.math.matrix.gui.MatrixPanelEvent; + +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.util.ErrorHelper; + +/** + * Population handler. + */ +public class PopulationSeasonSpacializedHandler extends InputContentHandler<PopulationSeasonSpacializedUI> { + + /** Class logger. */ + private static final Log log = LogFactory.getLog(PopulationSeasonsHandler.class); + + protected void init(final PopulationSeasonSpacializedUI inputContentUI) { + super.init(inputContentUI); + } + + protected void populationSeasonLengthMatrixChanged(MatrixPanelEvent event) { + if (inputContentUI.getPopulationSeasonInfo() != null && inputContentUI.matrixPanelPopulationSeasonLengthChange.getMatrix() != null) { + // must be a copy for fire event + MatrixND lengthChangeMatrix = inputContentUI.matrixPanelPopulationSeasonLengthChange.getMatrix().copy(); + inputContentUI.getPopulationSeasonInfo().setLengthChangeMatrix(lengthChangeMatrix); + } + } + + /** + * Called on spacialized radio button change. + */ + protected void spacializedActionPerformed() { + PopulationSeasonInfo popInfo = inputContentUI.getPopulationSeasonInfo(); + boolean spacializedSelection = inputContentUI.radioPopulationSeasonGroupChangeLengthNoSpacialized.isSelected(); + popInfo.setSimpleLengthChangeMatrix(spacializedSelection); + try { + MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix(); + if (lengthChangeMatrix != null) { + if (popInfo.isSimpleLengthChangeMatrix()) { + lengthChangeMatrix = popInfo.unspacializeLengthChangeMatrix(lengthChangeMatrix); + } else { + lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix); + } + popInfo.setLengthChangeMatrix(lengthChangeMatrix); + inputContentUI.matrixPanelPopulationSeasonLengthChange.setMatrix(lengthChangeMatrix); + } + } catch(Exception eee) { + if (log.isErrorEnabled()) { + log.error("Can't (un)spacialize Matrix Change Of Group", eee); + } + ErrorHelper.showErrorDialog(t("isisfish.error.input.spacializematrix"), eee); + } + } + + protected void computeMatrixChangeOfGroup() { + PopulationSeasonInfo popInfo = inputContentUI.getPopulationSeasonInfo(); + MatrixND lengthChangeMatrix = popInfo.computeLengthChangeMatrix(); + if (!popInfo.isSimpleLengthChangeMatrix()){ + lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix); + } + popInfo.setLengthChangeMatrix(lengthChangeMatrix); + } + + protected void showSpacializedMatrixChangeOfGroup() { + PopulationSeasonInfo popInfo = inputContentUI.getPopulationSeasonInfo(); + MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix(); + if (popInfo.isSimpleLengthChangeMatrix()) { + lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix); + } + MatrixPanelEditor panel = new MatrixPanelEditor(false, 800, 300); + panel.setMatrix(lengthChangeMatrix); + JOptionPane.showMessageDialog(inputContentUI, panel, t("isisfish.populationSeasons.spacialized.visualisation"), JOptionPane.INFORMATION_MESSAGE); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedHandler.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonSpacializedUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -31,76 +31,12 @@ <Boolean id='ageGroupType' javaBean='false'/> - <import> - static org.nuiton.i18n.I18n.t - fr.ifremer.isisfish.entities.PopulationSeasonInfo; - fr.ifremer.isisfish.ui.util.ErrorHelper; - org.nuiton.math.matrix.MatrixND; - org.nuiton.math.matrix.gui.MatrixPanelEditor; - org.nuiton.math.matrix.gui.MatrixPanelEvent; - org.nuiton.math.matrix.gui.MatrixPanelListener; - javax.swing.JOptionPane - </import> + <PopulationSeasonSpacializedHandler id="handler" /> <script><![CDATA[ -protected void populationSeasonLengthMatrixChanged(MatrixPanelEvent event) { - if (getPopulationSeasonInfo() != null && matrixPanelPopulationSeasonLengthChange.getMatrix() != null) { - // must be a copy for fire event - MatrixND lengthChangeMatrix = matrixPanelPopulationSeasonLengthChange.getMatrix().copy(); - getPopulationSeasonInfo().setLengthChangeMatrix(lengthChangeMatrix); + protected void $afterCompleteSetup() { + handler.init(this); } -} - -/*public void refresh() { - // TODO add only once - //matrixPanelPopulationSeasonLengthChange.addMatrixListener(matrixPanelListener); -}*/ - -/** - * Called on spacialized radio button change. - */ -protected void spacializedActionPerformed() { - PopulationSeasonInfo popInfo = getPopulationSeasonInfo(); - boolean spacializedSelection = radioPopulationSeasonGroupChangeLengthNoSpacialized.isSelected(); - popInfo.setSimpleLengthChangeMatrix(spacializedSelection); - try { - MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix(); - if (lengthChangeMatrix != null) { - if (popInfo.isSimpleLengthChangeMatrix()) { - lengthChangeMatrix = popInfo.unspacializeLengthChangeMatrix(lengthChangeMatrix); - } else { - lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix); - } - popInfo.setLengthChangeMatrix(lengthChangeMatrix); - matrixPanelPopulationSeasonLengthChange.setMatrix(lengthChangeMatrix); - } - } catch(Exception eee) { - if (log.isErrorEnabled()) { - log.error("Can't (un)spacialize Matrix Change Of Group", eee); - } - ErrorHelper.showErrorDialog(t("isisfish.error.input.spacializematrix"), eee); - } -} - -protected void computeMatrixChangeOfGroup() { - PopulationSeasonInfo popInfo = getPopulationSeasonInfo(); - MatrixND lengthChangeMatrix = popInfo.computeLengthChangeMatrix(); - if (!popInfo.isSimpleLengthChangeMatrix()){ - lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix); - } - popInfo.setLengthChangeMatrix(lengthChangeMatrix); -} - -protected void showSpacializedMatrixChangeOfGroup() { - PopulationSeasonInfo popInfo = getPopulationSeasonInfo(); - MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix(); - if (popInfo.isSimpleLengthChangeMatrix()) { - lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix); - } - MatrixPanelEditor panel = new MatrixPanelEditor(false, 800, 300); - panel.setMatrix(lengthChangeMatrix); - JOptionPane.showMessageDialog(this, panel, t("isisfish.populationSeasons.spacialized.visualisation"), JOptionPane.INFORMATION_MESSAGE); -} ]]></script> <JPanel id='body'> @@ -114,7 +50,7 @@ buttonGroup="radioPopulationSeasonGroupChangeLengthSpacializedGroup" selected='{getPopulationSeasonInfo().isSimpleLengthChangeMatrix()}' enabled='{getPopulationSeasonInfo() != null}' - text="isisfish.populationSeasons.noSpacialized" onActionPerformed='spacializedActionPerformed()' + text="isisfish.populationSeasons.noSpacialized" onActionPerformed='handler.spacializedActionPerformed()' visible='{isAgeGroupType()}' decorator='boxed' /> </cell> <cell fill='horizontal' weightx='0.5'> @@ -122,7 +58,7 @@ buttonGroup="radioPopulationSeasonGroupChangeLengthSpacializedGroup" selected='{!getPopulationSeasonInfo().isSimpleLengthChangeMatrix()}' enabled='{getPopulationSeasonInfo() != null}' - text="isisfish.populationSeasons.spacialized" onActionPerformed='spacializedActionPerformed()' + text="isisfish.populationSeasons.spacialized" onActionPerformed='handler.spacializedActionPerformed()' visible='{isAgeGroupType()}' decorator='boxed' /> </cell> </row> @@ -133,12 +69,12 @@ </cell> <cell fill='horizontal' weightx='0.5'> <JButton text="isisfish.populationSeasons.computeCoefficient" decorator='boxed' visible='{isAgeGroupType()}' - enabled='{getPopulationSeasonInfo() != null}' onActionPerformed='computeMatrixChangeOfGroup()'/> + enabled='{getPopulationSeasonInfo() != null}' onActionPerformed='handler.computeMatrixChangeOfGroup()'/> </cell> <cell fill='horizontal' weightx='0.5'> <JButton id="buttonPopulationSeasonGroupChangeLengthButtonShow" text="isisfish.populationSeasons.showSpacialized" enabled='{radioPopulationSeasonGroupChangeLengthNoSpacialized.isSelected() && getPopulationSeasonInfo() != null}' - onActionPerformed='showSpacializedMatrixChangeOfGroup()' + onActionPerformed='handler.showSpacializedMatrixChangeOfGroup()' visible='{isAgeGroupType()}' decorator='boxed'/> </cell> </row> @@ -152,7 +88,7 @@ _sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"LengthChangeMatrix"' visible='{isAgeGroupType()}' decorator='boxed' matrix='{getPopulationSeasonInfo() == null ? null : getPopulationSeasonInfo().getLengthChangeMatrix().copy()}' - onMatrixChanged="populationSeasonLengthMatrixChanged(event)" /> + onMatrixChanged="handler.populationSeasonLengthMatrixChanged(event)" /> </cell> </row> </Table> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,234 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.math.matrix.MatrixND; +import org.nuiton.math.matrix.gui.MatrixPanelEvent; + +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; +import fr.ifremer.isisfish.types.Month; +import fr.ifremer.isisfish.ui.input.InputAction; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericComboModel; +import fr.ifremer.isisfish.ui.widget.Interval; + +/** + * Population handler. + */ +public class PopulationSeasonsHandler extends InputContentHandler<PopulationSeasonsUI> { + + /** Class logger. */ + private static final Log log = LogFactory.getLog(PopulationSeasonsHandler.class); + + protected Interval seasonInterval; + + protected boolean init = false; + + protected void init(final PopulationSeasonsUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(PopulationSeasonsUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldPopulationSeasonComment.setText(""); + inputContentUI.fieldPopulationSeasonReproductionDistribution.setMatrix(null); + } + if (evt.getNewValue() != null) { + refresh(); + } + } + }); + + /* + * Don't add both in same listener. + * When first is set, last value from getPopulationSeasonInfo() + * is erased by interval.getLast() default value. + */ + inputContentUI.seasonIntervalPanel.addPropertyChangeListener("first", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (inputContentUI.getPopulationSeasonInfo() != null) { + inputContentUI.getPopulationSeasonInfo().setFirstMonth(new Month(seasonInterval.getFirst())); + setReproductionDistributionMatrix(); + } + } + }); + inputContentUI.seasonIntervalPanel.addPropertyChangeListener("last", new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (inputContentUI.getPopulationSeasonInfo() != null) { + inputContentUI.getPopulationSeasonInfo().setLastMonth(new Month(seasonInterval.getLast())); + setReproductionDistributionMatrix(); + } + } + }); + } + + protected void create() { + PopulationSeasonInfo seasonNew = inputContentUI.getContextValue(InputAction.class).createPopulationSeasonInfo(inputContentUI.getBean()); + inputContentUI.setPopulationSeasonInfo(seasonNew); + setPopulationSeasonInfoCombo(); + } + + protected void delete() { + inputContentUI.getContextValue(InputAction.class).removePopulationSeasonInfo(inputContentUI.getBean(), inputContentUI.getPopulationSeasonInfo()); + inputContentUI.setPopulationSeasonInfo(null); + setPopulationSeasonInfoCombo(); + } + + protected void save() { + inputContentUI.getSaveVerifier().save(); + setPopulationSeasonInfoCombo(); + } + + protected void populationSeasonReproductionDistributionMatrixChanged(MatrixPanelEvent event) { + if (inputContentUI.getPopulationSeasonInfo() != null && inputContentUI.fieldPopulationSeasonReproductionDistribution.getMatrix() != null) { + MatrixND reproductionDistribution = inputContentUI.fieldPopulationSeasonReproductionDistribution.getMatrix().copy(); + if (log.isDebugEnabled()) { + log.debug("Matrix ReproductionDistribution modified : " + reproductionDistribution); + } + inputContentUI.getPopulationSeasonInfo().setReproductionDistribution(reproductionDistribution); + } + } + + public void refresh() { + //Population population = inputContentUI.getSaveVerifier().getEntity(Population.class); + + // add null before, for second to be considered as a changed event + // otherwize, setBean has no effect + //setBean(null); + //setBean(population); + + inputContentUI.setPopulationSeasonInfo(null); + + // Model instanciation + seasonInterval = new Interval(); + seasonInterval.setMin(0); + seasonInterval.setMax(11); + seasonInterval.setFirst(0); + seasonInterval.setLast(2); + + setPopulationSeasonInfoCombo(); + setSeasonInterval(); + + inputContentUI.seasonIntervalPanel.setLabelRenderer(Month.MONTH); + inputContentUI.seasonIntervalPanel.setModel(seasonInterval); + + //fieldPopulationSeasonReproductionDistribution.addMatrixListener(matrixPanelListener); + + /*if(getPopulationSeasonInfo() != null) { + PopulationSeasonInfo popInfo = getPopulationSeasonInfo(); + setPopulationSeasonInfo(null); + setPopulationSeasonInfo(popInfo); + getSaveVerifier().addCurrentEntity(getPopulationSeasonInfo()); + }*/ + //getSaveVerifier().addCurrentPanel(populationSeasonSpecializedUI); + } + + protected void setSeasonInterval() { + if (inputContentUI.getPopulationSeasonInfo() != null) { + try { + if (log.isDebugEnabled()) { + log.debug("Updating interval : "); + } + Month firstMonth = inputContentUI.getPopulationSeasonInfo().getFirstMonth(); + + if (firstMonth != null) { + seasonInterval.setFirst(firstMonth.getMonthNumber()); + + if (log.isDebugEnabled()) { + log.debug(" first : " + seasonInterval.getFirst()); + } + } else { + seasonInterval.setFirst(0); + } + + Month lastMonth = inputContentUI.getPopulationSeasonInfo().getLastMonth(); + if (lastMonth != null) { + seasonInterval.setLast(lastMonth.getMonthNumber()); + if (log.isDebugEnabled()) { + log.debug(" last : " + seasonInterval.getLast()); + } + } else { + seasonInterval.setLast(3); + } + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Can't display interval", e); + } + } + } + } + + protected void setPopulationSeasonInfoCombo() { + if (inputContentUI.getBean() != null) { + GenericComboModel<PopulationSeasonInfo> populationSeasonInfoModel = new GenericComboModel<>(inputContentUI.getBean().getPopulationSeasonInfo()); + inputContentUI.fieldPopulationSeasonInfoChooser.setModel(populationSeasonInfoModel); + populationSeasonInfoModel.setSelectedItem(inputContentUI.getPopulationSeasonInfo()); + } + } + + protected void seasonGroupChanged() { + if (inputContentUI.getPopulationSeasonInfo() != null) { + inputContentUI.getPopulationSeasonInfo().setGroupChange(inputContentUI.fieldPopulationSeasonGroupChange.isSelected()); + } + } + + protected void seasonChanged() { + init = true; + PopulationSeasonInfo seasonInfoSelected = (PopulationSeasonInfo)inputContentUI.fieldPopulationSeasonInfoChooser.getSelectedItem(); + if (log.isDebugEnabled()) { + log.debug("Season changed : " + seasonInfoSelected); + } + inputContentUI.setPopulationSeasonInfo(seasonInfoSelected); + if (seasonInfoSelected != null) { + inputContentUI.getSaveVerifier().addCurrentEntity(seasonInfoSelected); + } + setSeasonInterval(); + setReproductionDistributionMatrix(); + init = false; + } + + protected void setReproductionDistributionMatrix() { + if (inputContentUI.getPopulationSeasonInfo() != null){ + MatrixND reproductionDistribution = inputContentUI.getPopulationSeasonInfo().getReproductionDistribution(); + // must be a copy (otherwise, modify current entity matrix) + if (reproductionDistribution != null){ + inputContentUI.fieldPopulationSeasonReproductionDistribution.setMatrix(reproductionDistribution.copy()); + } + } + } + + // TODO une methode isXXX ne prend pas de parametre + // et ne fait rien + protected boolean isAgeGroupType(boolean result) { + inputContentUI.populationSeasonSpecializedUI.setVisible(result); + return result; + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsHandler.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -29,19 +29,7 @@ <fr.ifremer.isisfish.entities.PopulationSeasonInfo id='populationSeasonInfo' javaBean='null'/> - <import> - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - fr.ifremer.isisfish.ui.models.common.GenericComboModel - fr.ifremer.isisfish.entities.PopulationSeasonInfo - fr.ifremer.isisfish.types.Month - fr.ifremer.isisfish.entities.Population - fr.ifremer.isisfish.ui.widget.Interval - org.nuiton.math.matrix.MatrixND - org.nuiton.math.matrix.gui.MatrixPanelEvent - org.nuiton.math.matrix.gui.MatrixPanelListener - fr.ifremer.isisfish.ui.input.InputAction - </import> + <PopulationSeasonsHandler id="handler" /> <BeanValidator id='validator' context="seasons" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population' @@ -58,202 +46,22 @@ valid="{validator.isValid() && validatorSeason.isValid()}" /> <script><![CDATA[ -protected Interval seasonInterval; - -protected boolean init = false; - -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldPopulationSeasonComment.setText(""); - fieldPopulationSeasonReproductionDistribution.setMatrix(null); - } - if (evt.getNewValue() != null) { - refresh(); - } - } - }); - - /* - * Don't add both in same listener. - * When first is set, last value from getPopulationSeasonInfo() - * is erased by interval.getLast() default value. - */ - seasonIntervalPanel.addPropertyChangeListener("first", new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (getPopulationSeasonInfo() != null) { - getPopulationSeasonInfo().setFirstMonth(new Month(seasonInterval.getFirst())); - setReproductionDistributionMatrix(); - } - } - }); - seasonIntervalPanel.addPropertyChangeListener("last", new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (getPopulationSeasonInfo() != null) { - getPopulationSeasonInfo().setLastMonth(new Month(seasonInterval.getLast())); - setReproductionDistributionMatrix(); - } - } - }); -} - -@Override -public void resetChangeModel() { - changeModel.setStayChanged(false); -} - -protected void create() { - PopulationSeasonInfo seasonNew = getContextValue(InputAction.class).createPopulationSeasonInfo(getBean()); - setPopulationSeasonInfo(seasonNew); - setPopulationSeasonInfoCombo(); -} - -protected void delete() { - getContextValue(InputAction.class).removePopulationSeasonInfo(getBean(), getPopulationSeasonInfo()); - setPopulationSeasonInfo(null); - setPopulationSeasonInfoCombo(); -} - -protected void save() { - getSaveVerifier().save(); - setPopulationSeasonInfoCombo(); -} - -protected void populationSeasonReproductionDistributionMatrixChanged(MatrixPanelEvent event) { - if (getPopulationSeasonInfo() != null && fieldPopulationSeasonReproductionDistribution.getMatrix() != null) { - MatrixND reproductionDistribution = fieldPopulationSeasonReproductionDistribution.getMatrix().copy(); - if (log.isDebugEnabled()) { - log.debug("Matrix ReproductionDistribution modified : " + reproductionDistribution); - } - getPopulationSeasonInfo().setReproductionDistribution(reproductionDistribution); + protected void $afterCompleteSetup() { + handler.init(this); } -} -public void refresh() { - Population population = getSaveVerifier().getEntity(Population.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - //setBean(null); - //setBean(population); - - setPopulationSeasonInfo(null); - - // Model instanciation - seasonInterval = new Interval(); - seasonInterval.setMin(0); - seasonInterval.setMax(11); - seasonInterval.setFirst(0); - seasonInterval.setLast(2); - - setPopulationSeasonInfoCombo(); - setSeasonInterval(); - - seasonIntervalPanel.setLabelRenderer(Month.MONTH); - seasonIntervalPanel.setModel(seasonInterval); - - //fieldPopulationSeasonReproductionDistribution.addMatrixListener(matrixPanelListener); - - /*if(getPopulationSeasonInfo() != null) { - PopulationSeasonInfo popInfo = getPopulationSeasonInfo(); - setPopulationSeasonInfo(null); - setPopulationSeasonInfo(popInfo); - getSaveVerifier().addCurrentEntity(getPopulationSeasonInfo()); - }*/ - //getSaveVerifier().addCurrentPanel(populationSeasonSpecializedUI); -} - -protected void setSeasonInterval() { - if(getPopulationSeasonInfo() != null) { - try { - if (log.isDebugEnabled()) { - log.debug("Updating interval : "); - } - Month firstMonth = getPopulationSeasonInfo().getFirstMonth(); - - if (firstMonth != null) { - seasonInterval.setFirst(firstMonth.getMonthNumber()); - - if (log.isDebugEnabled()) { - log.debug(" first : " + seasonInterval.getFirst()); - } - } else { - seasonInterval.setFirst(0); - } - - Month lastMonth = getPopulationSeasonInfo().getLastMonth(); - if (lastMonth != null) { - seasonInterval.setLast(lastMonth.getMonthNumber()); - if (log.isDebugEnabled()) { - log.debug(" last : " + seasonInterval.getLast()); - } - } else { - seasonInterval.setLast(3); - } - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Can't display interval", e); - } - } + @Override + public void resetChangeModel() { + changeModel.setStayChanged(false); } -} -protected void setPopulationSeasonInfoCombo() { - if (getBean() != null) { - GenericComboModel<PopulationSeasonInfo> populationSeasonInfoModel = new GenericComboModel<>(getBean().getPopulationSeasonInfo()); - fieldPopulationSeasonInfoChooser.setModel(populationSeasonInfoModel); - populationSeasonInfoModel.setSelectedItem(getPopulationSeasonInfo()); + @Override + public void setLayer(boolean active) { + super.setLayer(active); + populationSeasonSpecializedUI.setLayer(active); } -} + ]]></script> -protected void seasonGroupChanged() { - if (getPopulationSeasonInfo() != null) { - getPopulationSeasonInfo().setGroupChange(fieldPopulationSeasonGroupChange.isSelected()); - } -} - -protected void seasonChanged() { - init = true; - PopulationSeasonInfo seasonInfoSelected = (PopulationSeasonInfo)fieldPopulationSeasonInfoChooser.getSelectedItem(); - if (log.isDebugEnabled()) { - log.debug("Season changed : " + seasonInfoSelected); - } - setPopulationSeasonInfo(seasonInfoSelected); - if (seasonInfoSelected != null) { - getSaveVerifier().addCurrentEntity(seasonInfoSelected); - } - setSeasonInterval(); - setReproductionDistributionMatrix(); - init = false; -} - -protected void setReproductionDistributionMatrix() { - if (getPopulationSeasonInfo() != null){ - MatrixND reproductionDistribution = getPopulationSeasonInfo().getReproductionDistribution(); - // must be a copy (otherwise, modify current entity matrix) - if (reproductionDistribution != null){ - fieldPopulationSeasonReproductionDistribution.setMatrix(reproductionDistribution.copy()); - } - } -} - -// TODO une methode isXXX ne prend pas de parametre -// et ne fait rien -protected boolean isAgeGroupType(boolean result) { - populationSeasonSpecializedUI.setVisible(result); - return result; -} - -@Override -public void setLayer(boolean active) { - super.setLayer(active); - populationSeasonSpecializedUI.setLayer(active); -} - ]]> - </script> <JPanel id='body'> <Table> <row> @@ -266,8 +74,8 @@ <cell fill='horizontal' weightx='1.0'> <JComboBox id="fieldPopulationSeasonInfoChooser" genericType="PopulationSeasonInfo" - onItemStateChanged='seasonChanged()' enabled='{isActive() && (isSensitivity() || !changeModel.isChanged() ) }' - renderer="{new fr.ifremer.isisfish.ui.input.renderer.PopulationSeasonInfoComboRenderer()}"/> + onItemStateChanged='handler.seasonChanged()' enabled='{isActive() && (isSensitivity() || !changeModel.isChanged() ) }' + renderer="{new PopulationSeasonInfoComboRenderer()}"/> </cell> </row> <row> @@ -284,16 +92,18 @@ <JPanel/> </cell> <cell fill='both' weightx='1.0'> - <JCheckBox id="fieldPopulationSeasonGroupChange" text="isisfish.populationSeasons.changeGroup" selected='{getPopulationSeasonInfo().isGroupChange()}' + <JCheckBox id="fieldPopulationSeasonGroupChange" text="isisfish.populationSeasons.changeGroup" + selected='{getPopulationSeasonInfo().isGroupChange()}' decorator='boxed' _sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"GroupChange"' - onActionPerformed='seasonGroupChanged()' enabled='{getPopulationSeasonInfo() != null}' visible='{isAgeGroupType(getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/> + onActionPerformed='handler.seasonGroupChanged()' enabled='{getPopulationSeasonInfo() != null}' + visible='{handler.isAgeGroupType(getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/> </cell> </row> <row> <cell columns='2' fill='both' weightx='1.0' weighty='0.6'> <PopulationSeasonSpacializedUI id='populationSeasonSpecializedUI' constructorParams='this' bean='{getBean()}' populationSeasonInfo='{getPopulationSeasonInfo()}' - ageGroupType='{isAgeGroupType(!getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/> + ageGroupType='{handler.isAgeGroupType(!getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/> </cell> </row> <row> @@ -317,7 +127,7 @@ enabled='{getPopulationSeasonInfo() != null}' visible='{getPopulationSeasonInfo().isReproduction()}' decorator='boxed' _sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"ReproductionDistribution"' - onMatrixChanged="populationSeasonReproductionDistributionMatrixChanged(event)" /> + onMatrixChanged="handler.populationSeasonReproductionDistributionMatrixChanged(event)" /> </cell> </row> <row> @@ -344,7 +154,7 @@ <JButton id='save' decorator='boxed' text="isisfish.common.save" enabled="{changeModel.isValid() && changeModel.isChanged()}" - onActionPerformed="save();validator.setChanged(false);validatorSeason.setChanged(false);"/> + onActionPerformed="handler.save();validator.setChanged(false);validatorSeason.setChanged(false);"/> </cell> <cell fill='horizontal' weightx='0.5'> <JButton id='cancel' decorator='boxed' @@ -358,13 +168,13 @@ <JButton id='create' decorator='boxed' text="isisfish.common.new" enabled="{!changeModel.isChanged()}" - onActionPerformed="create()"/> + onActionPerformed="handler.create()"/> </cell> <cell fill='horizontal' weightx='0.5'> <JButton id='delete' decorator='boxed' text="isisfish.common.remove" enabled="{getPopulationSeasonInfo() != null}" - onActionPerformed="delete()"/> + onActionPerformed="handler.delete()"/> </cell> </row> </Table> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2012 Ifremer, Code Lutin, Chatellier Eric + Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -27,51 +27,43 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/> - <import> - static org.nuiton.i18n.I18n.t - static org.nuiton.i18n.I18n.n - </import> + <PopulationHandler id="handler" /> <script><![CDATA[ -protected void $afterCompleteSetup() { - setButtonTitle(t("isisfish.input.continueGears")); - setNextPath(n("isisfish.input.tree.gears")); - - // install change listener - // (depends on sensitivity can't be done on constructor) - installChangeListener(populationTab); -} + protected void $afterCompleteSetup() { + handler.init(this); + } -@Override -public void setLayer(boolean active) { - super.setLayer(active); - populationBasicsUI.setLayer(active); - populationZoneUI.setLayer(active); - populationSeasonsUI.setLayer(active); - populationEquationUI.setLayer(active); - populationRecruitementUI.setLayer(active); - populationGroupUI.setLayer(active); - populationCapturabilityUI.setLayer(active); - populationMigrationUI.setLayer(active); - populationPriceUI.setLayer(active); - variablesUI.setLayer(active); -} + @Override + public void setLayer(boolean active) { + super.setLayer(active); + populationBasicsUI.setLayer(active); + populationZoneUI.setLayer(active); + populationSeasonsUI.setLayer(active); + populationEquationUI.setLayer(active); + populationRecruitementUI.setLayer(active); + populationGroupUI.setLayer(active); + populationCapturabilityUI.setLayer(active); + populationMigrationUI.setLayer(active); + populationPriceUI.setLayer(active); + variablesUI.setLayer(active); + } -@Override -public void resetChangeModel() { - populationBasicsUI.resetChangeModel(); - populationZoneUI.resetChangeModel(); - populationSeasonsUI.resetChangeModel(); - populationEquationUI.resetChangeModel(); - populationRecruitementUI.resetChangeModel(); - populationGroupUI.resetChangeModel(); - populationCapturabilityUI.resetChangeModel(); - populationMigrationUI.resetChangeModel(); - populationPriceUI.resetChangeModel(); - variablesUI.resetChangeModel(); -} - ]]> - </script> + @Override + public void resetChangeModel() { + populationBasicsUI.resetChangeModel(); + populationZoneUI.resetChangeModel(); + populationSeasonsUI.resetChangeModel(); + populationEquationUI.resetChangeModel(); + populationRecruitementUI.resetChangeModel(); + populationGroupUI.resetChangeModel(); + populationCapturabilityUI.resetChangeModel(); + populationMigrationUI.resetChangeModel(); + populationPriceUI.resetChangeModel(); + variablesUI.resetChangeModel(); + } + ]]></script> + <JPanel id='body'> <JTabbedPane id="populationTab"> <!-- Saisie des populations --> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,145 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JList; + +import org.nuiton.math.matrix.gui.MatrixPanelEvent; + +import fr.ifremer.isisfish.entities.Zone; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericListModel; + +/** + * Population handler. + */ +public class PopulationZonesEditorHandler extends InputContentHandler<PopulationZonesEditorUI> { + + protected boolean init = false; + + protected void init(final PopulationZonesEditorUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(PopulationZonesEditorUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + setPopulationZonesPresenceModel(); + setFieldPopulationZonesReproductionModel(getSelectedValues(inputContentUI.populationZonesPresence)); + setFieldPopulationZonesRecruitmentModel(getSelectedValues(inputContentUI.populationZonesPresence)); + setFieldPopulationMappingZoneReproZoneRecru(); + } + if (evt.getNewValue() != null) { + init = true; + setPopulationZonesPresenceModel(); + setFieldPopulationZonesReproductionModel(getSelectedValues(inputContentUI.populationZonesPresence)); + setFieldPopulationZonesRecruitmentModel(getSelectedValues(inputContentUI.populationZonesPresence)); + setFieldPopulationMappingZoneReproZoneRecru(); + init = false; + } + } + }); + } + + protected void populationMappingZoneReproZoneRecruMatrixChanged(MatrixPanelEvent event) { + inputContentUI.getBean().setMappingZoneReproZoneRecru(inputContentUI.fieldPopulationMappingZoneReproZoneRecru.getMatrix().clone()); + } + + protected void setFieldPopulationMappingZoneReproZoneRecru() { + if (inputContentUI.getBean() != null) { + if (inputContentUI.getBean().getMappingZoneReproZoneRecru() != null) { + inputContentUI.fieldPopulationMappingZoneReproZoneRecru.setMatrix(inputContentUI.getBean().getMappingZoneReproZoneRecru().copy()); + } + } + } + protected void setPopulationZonesPresenceModel() { + if (inputContentUI.getBean() != null) { + List<Zone> zones = inputContentUI.getFisheryRegion().getZone(); + setModel(zones, inputContentUI.getBean().getPopulationZone(), inputContentUI.populationZonesPresence); + } + } + protected void setFieldPopulationZonesReproductionModel(List<Zone> zones) { + if (inputContentUI.getBean() != null) { + setModel(zones, inputContentUI.getBean().getReproductionZone(), inputContentUI.fieldPopulationZonesReproduction); + } + } + protected void setFieldPopulationZonesRecruitmentModel(List<Zone> zones) { + if (inputContentUI.getBean() != null) { + setModel(zones, inputContentUI.getBean().getRecruitmentZone(), inputContentUI.fieldPopulationZonesRecruitment); + } + } + + /** + * Change model of {@code associatedList} with all available zones, but keep + * selection with {@code selectedZones}. + */ + protected void setModel(List<Zone> availableZones, List<Zone> selectedZones, JList<Zone> associatedList) { + GenericListModel<Zone> zoneModel = new GenericListModel<>(availableZones); + associatedList.setModel(zoneModel); + + // can be null at population init + if (selectedZones != null) { + for (Zone selectedZone : selectedZones) { + int index = availableZones.indexOf(selectedZone); + associatedList.addSelectionInterval(index, index); + } + } + } + + protected void presenceChanged() { + if (!init) { + inputContentUI.getBean().setPopulationZone(getSelectedValues(inputContentUI.populationZonesPresence)); + setFieldPopulationZonesReproductionModel(getSelectedValues(inputContentUI.populationZonesPresence)); + setFieldPopulationZonesRecruitmentModel(getSelectedValues(inputContentUI.populationZonesPresence)); + setFieldPopulationMappingZoneReproZoneRecru(); + } + } + + protected void reproductionChanged() { + if (!init) { + inputContentUI.getBean().setReproductionZone(getSelectedValues(inputContentUI.fieldPopulationZonesReproduction)); + setFieldPopulationMappingZoneReproZoneRecru(); + } + } + + protected void recruitementChanged() { + if (!init) { + inputContentUI.getBean().setRecruitmentZone(getSelectedValues(inputContentUI.fieldPopulationZonesRecruitment)); + setFieldPopulationMappingZoneReproZoneRecru(); + } + } + + /** + * Get selected values for components as list. + */ + protected List<Zone> getSelectedValues(JList<Zone> component) { + List<Zone> selectedValues = component.getSelectedValuesList(); + List<Zone> selectedZone = new ArrayList<>(selectedValues); + return selectedZone; + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorHandler.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesEditorUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -27,129 +27,18 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/> + <PopulationZonesEditorHandler id="handler" /> + <import> - fr.ifremer.isisfish.entities.Zone - fr.ifremer.isisfish.ui.models.common.GenericListModel - org.nuiton.math.matrix.gui.MatrixPanelEvent - org.nuiton.math.matrix.gui.MatrixPanelListener - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - java.util.List - java.util.ArrayList java.awt.Dimension </import> <script><![CDATA[ -protected boolean init = false; - -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - setPopulationZonesPresenceModel(); - setFieldPopulationZonesReproductionModel(getSelectedValues(populationZonesPresence)); - setFieldPopulationZonesRecruitmentModel(getSelectedValues(populationZonesPresence)); - setFieldPopulationMappingZoneReproZoneRecru(); - } - if (evt.getNewValue() != null) { - init = true; - setPopulationZonesPresenceModel(); - setFieldPopulationZonesReproductionModel(getSelectedValues(populationZonesPresence)); - setFieldPopulationZonesRecruitmentModel(getSelectedValues(populationZonesPresence)); - setFieldPopulationMappingZoneReproZoneRecru(); - init = false; - } - } - }); -} - -protected void populationMappingZoneReproZoneRecruMatrixChanged(MatrixPanelEvent event) { - getBean().setMappingZoneReproZoneRecru(fieldPopulationMappingZoneReproZoneRecru.getMatrix().clone()); -} - -/*public void refresh() { - setPopulationZonesPresenceModel(); - setFieldPopulationZonesReproductionModel(getSelectedValues(populationZonesPresence)); - setFieldPopulationZonesRecruitmentModel(getSelectedValues(populationZonesPresence)); - //fieldPopulationMappingZoneReproZoneRecru.removeMatrixPanelListener(listener); - setFieldPopulationMappingZoneReproZoneRecru(); - //fieldPopulationMappingZoneReproZoneRecru.addMatrixListener(listener); -}*/ - -protected void setFieldPopulationMappingZoneReproZoneRecru() { - if (getBean() != null) { - if (getBean().getMappingZoneReproZoneRecru() != null) { - fieldPopulationMappingZoneReproZoneRecru.setMatrix(getBean().getMappingZoneReproZoneRecru().copy()); - } + protected void $afterCompleteSetup() { + handler.init(this); } -} -protected void setPopulationZonesPresenceModel() { - if (getBean() != null) { - java.util.List<Zone> zones = getFisheryRegion().getZone(); - setModel(zones, getBean().getPopulationZone(), populationZonesPresence); - } -} -protected void setFieldPopulationZonesReproductionModel(List<Zone> zones) { - if (getBean() != null) { - setModel(zones, getBean().getReproductionZone(), fieldPopulationZonesReproduction); - } -} -protected void setFieldPopulationZonesRecruitmentModel(List<Zone> zones) { - if (getBean() != null) { - setModel(zones, getBean().getRecruitmentZone(), fieldPopulationZonesRecruitment); - } -} + ]]></script> -/** - * Change model of {@code associatedList} with all available zones, but keep - * selection with {@code selectedZones}. - */ -protected void setModel(List<Zone> availableZones, List<Zone> selectedZones, JList<Zone> associatedList) { - GenericListModel<Zone> zoneModel = new GenericListModel<>(availableZones); - associatedList.setModel(zoneModel); - - // can be null at population init - if (selectedZones != null) { - for (Zone selectedZone : selectedZones) { - int index = availableZones.indexOf(selectedZone); - associatedList.addSelectionInterval(index, index); - } - } -} - -protected void presenceChanged() { - if (!init) { - getBean().setPopulationZone(getSelectedValues(populationZonesPresence)); - setFieldPopulationZonesReproductionModel(getSelectedValues(populationZonesPresence)); - setFieldPopulationZonesRecruitmentModel(getSelectedValues(populationZonesPresence)); - setFieldPopulationMappingZoneReproZoneRecru(); - } -} - -protected void reproductionChanged() { - if (!init) { - getBean().setReproductionZone(getSelectedValues(fieldPopulationZonesReproduction)); - setFieldPopulationMappingZoneReproZoneRecru(); - } -} - -protected void recruitementChanged() { - if (!init) { - getBean().setRecruitmentZone(getSelectedValues(fieldPopulationZonesRecruitment)); - setFieldPopulationMappingZoneReproZoneRecru(); - } -} - -/** - * Get selected values for components as list. - */ -protected List<Zone> getSelectedValues(JList<Zone> component) { - List<Zone> selectedValues = component.getSelectedValuesList(); - List<Zone> selectedZone = new ArrayList<Zone>(selectedValues); - return selectedZone; -} - ]]> - </script> <JPanel id='body'> <Table> <row> @@ -167,19 +56,19 @@ <cell fill='both' weightx='0.3' weighty='0.5'> <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> <JList id="populationZonesPresence" genericType="fr.ifremer.isisfish.entities.Zone" - onValueChanged='presenceChanged()' enabled='{isActive()}'/> + onValueChanged='handler.presenceChanged()' enabled='{isActive()}'/> </JScrollPane> </cell> <cell fill='both' weightx='0.3' weighty='0.5'> <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> <JList id="fieldPopulationZonesReproduction" genericType="fr.ifremer.isisfish.entities.Zone" - onValueChanged='reproductionChanged()' enabled='{isActive()}'/> + onValueChanged='handler.reproductionChanged()' enabled='{isActive()}'/> </JScrollPane> </cell> <cell fill='both' weightx='0.3' weighty='0.5'> <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> <JList id="fieldPopulationZonesRecruitment" genericType="fr.ifremer.isisfish.entities.Zone" - onValueChanged='recruitementChanged()' enabled='{isActive()}'/> + onValueChanged='handler.recruitementChanged()' enabled='{isActive()}'/> </JScrollPane> </cell> </row> @@ -192,7 +81,7 @@ <cell columns='3' fill='both' weightx='1.0' weighty='0.5'> <org.nuiton.math.matrix.gui.MatrixPanelEditor id='fieldPopulationMappingZoneReproZoneRecru' constructorParams='false' enabled='{isActive()}' - onMatrixChanged="populationMappingZoneReproZoneRecruMatrixChanged(event)" + onMatrixChanged="handler.populationMappingZoneReproZoneRecruMatrixChanged(event)" decorator='boxed' _sensitivityBean='{fr.ifremer.isisfish.entities.Population.class}' _sensitivityMethod='"MappingZoneReproZoneRecru"' /> </cell> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,37 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * Population handler. + */ +public class PopulationZonesHandler extends InputContentHandler<PopulationZonesUI> { + + protected void init(final PopulationZonesUI inputContentUI) { + super.init(inputContentUI); + + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationZonesUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -27,30 +27,25 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/> + <PopulationZonesHandler id="handler" /> + <BeanValidator id='validator' context="zones" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Population' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> </BeanValidator> <script><![CDATA[ -/*public void refresh() { - Population population = getSaveVerifier().getEntity(Population.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - setBean(null); - setBean(population); + protected void $afterCompleteSetup() { + handler.init(this); + } - getSaveVerifier().addCurrentPanel(popZones); -}*/ + @Override + public void setLayer(boolean active) { + super.setLayer(active); + popZones.setLayer(active); + } + ]]></script> -@Override -public void setLayer(boolean active) { - super.setLayer(active); - popZones.setLayer(active); -} - ]]> - </script> <JPanel id='body'> <Table> <row> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,421 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.population; + +import java.awt.CardLayout; + +import javax.swing.JFrame; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.topia.TopiaContext; + +import fr.ifremer.isisfish.IsisFishDAOHelper; +import fr.ifremer.isisfish.entities.Equation; +import fr.ifremer.isisfish.entities.Population; +import fr.ifremer.isisfish.entities.PopulationGroup; +import fr.ifremer.isisfish.entities.PopulationGroupDAO; + +/** + * wizard group creation handler. + */ +public class WizardGroupCreationHandler { + + /** Class logger. */ + private static final Log log = LogFactory.getLog(WizardGroupCreationHandler.class); + + protected WizardGroupCreationUI wizardUI; + + protected String current = null; + protected boolean ageType = false; + protected boolean inputType = false; + protected boolean sameSizeType = false; + protected boolean growthCurveType = false; + + protected double first = 0; + protected double last = 0; + + protected String maxLength = ""; + protected int numberOfGroup = 0; + protected double groupSize = 0; + + protected double step = 1; + protected PopulationBasicsUI popBasic; + + protected void init(final WizardGroupCreationUI wizardUI) { + this.wizardUI = wizardUI; + } + + public void initParent(PopulationBasicsUI popBasic) { + this.popBasic = popBasic; + } + + /** + * @return Returns the ageType. + */ + public boolean isAgeType() { + return this.ageType; + } + + /** + * @param ageType The ageType to set. + */ + public void setAgeType(boolean ageType) { + this.ageType = ageType; + } + + /** + * @return Returns the inputType. + */ + public boolean isInputType() { + return this.inputType; + } + + /** + * @param inputType The inputType to set. + */ + public void setInputType(boolean inputType) { + this.inputType = inputType; + } + + /** + * @return Returns the sameSizeType. + */ + public boolean isSameSizeType() { + return this.sameSizeType; + } + + /** + * @param sameSizeType The sameSizeType to set. + */ + public void setSameSizeType(boolean sameSizeType) { + this.sameSizeType = sameSizeType; + } + + /** + * @return Returns the growthCurveType. + */ + public boolean isGrowthCurveType() { + return this.growthCurveType; + } + + /** + * @param growthCurveType The growthCurveType to set. + */ + public void setGrowthCurveType(boolean growthCurveType) { + this.growthCurveType = growthCurveType; + } + + /** + * @return Returns the first. + */ + public double getFirst() { + return this.first; + } + + /** + * @param first The first to set. + */ + public void setFirst(double first) { + this.first = first; + } + + /** + * @return Returns the last. + */ + public double getLast() { + return this.last; + } + + /** + * @param last The last to set. + */ + public void setLast(double last) { + this.last = last; + } + + /** + * @return Returns the maxLength. + */ + public String getMaxLength() { + return this.maxLength; + } + + /** + * @param maxLength The maxLength to set. + */ + public void setMaxLength(String maxLength) { + this.maxLength = maxLength; + } + + /** + * @return Returns the numberOfGroup. + */ + public int getNumberOfGroup() { + return this.numberOfGroup; + } + + /** + * @param numberOfGroup The numberOfGroup to set. + */ + public void setNumberOfGroup(int numberOfGroup) { + this.numberOfGroup = numberOfGroup; + } + + /** + * @return Returns the groupSize. + */ + public double getGroupSize() { + return this.groupSize; + } + + /** + * @param groupSize The groupSize to set. + */ + public void setGroupSize(double groupSize) { + this.groupSize = groupSize; + } + + /** + * @return Returns the step. + */ + public double getStep() { + return this.step; + } + + /** + * @param step The step to set. + */ + public void setStep(double step) { + this.step = step; + } + + public void setCard(String name) { + current = name; + ((CardLayout) wizardUI.wizardPanels.getLayout()).show(wizardUI.wizardPanels, name); + } + + protected void prev() { + if (isAgeType()) { + // do nothing only one panel + } else { + setCard("beginGroupLength"); + } + wizardUI.prev.setEnabled(false); + wizardUI.next.setEnabled(true); + wizardUI.finish.setEnabled(false); + } + + protected void next() { + if (isAgeType()) { + // do nothing only one panel + } else if (isInputType()) { + setCard("endInputGroupLength"); + } else if (isSameSizeType()) { + setCard("endSameSizeGroupLength"); + } else if (isGrowthCurveType()) { + setCard("endGrowthCurveGroupLength"); + } + wizardUI.prev.setEnabled(true); + wizardUI.next.setEnabled(false); + wizardUI.finish.setEnabled(true); + } + + protected void finish() { + if (log.isDebugEnabled()) { + log.debug("wizardGroupFinish called"); + } + + try { + Population pop = popBasic.getBean(); + // remove all old group + pop.clearPopulationGroup(); + + TopiaContext isisContext = pop.getTopiaContext(); + PopulationGroupDAO populationGroupDAO = IsisFishDAOHelper.getPopulationGroupDAO(isisContext); + + if (isAgeType()) { + double ageFirst = getFirst(); + double ageLast = getLast(); + for (int id = 0; id + ageFirst <= ageLast; id++) { + PopulationGroup group = populationGroupDAO.create(); + group.setId(id); + group.setPopulation(pop); + group.setAge(ageFirst + id); + pop.addPopulationGroup(group); + populationGroupDAO.update(group); + } + } else if (isInputType()) { + double minLength = getFirst(); + String[] values = getMaxLength().split(";"); + for (int i = 0; i < values.length; i++) { + if (!"".equals(values[i])) { + double length = Double.parseDouble(values[i]); + PopulationGroup group = populationGroupDAO.create(); + group.setId(i); + group.setPopulation(pop); + group.setMinLength(minLength); + group.setMaxLength(length); + pop.addPopulationGroup(group); + populationGroupDAO.update(group); + minLength = length; + } + } + + } else if (isSameSizeType()) { + double minLength = getFirst(); + int numberOfGroup = getNumberOfGroup(); + double step = getGroupSize(); + if (numberOfGroup < 0) { + // return new OutputView("Error.xml", "error", t("isisfish.error.number.classes.upper.zero")); + } + if (step == 0) { + // return new OutputView("Error.xml", "error", t"isisfish.error.no.null.time.step")); + } + + double maxLength = minLength; + for (int i = 0; i < numberOfGroup; i++) { + maxLength = minLength + step; + PopulationGroup group = populationGroupDAO.create(); + group.setId(i); + group.setPopulation(pop); + group.setMinLength(minLength); + group.setMaxLength(maxLength); + pop.addPopulationGroup(group); + populationGroupDAO.update(group); + minLength = maxLength; + } + } else if (isGrowthCurveType()) { + double minLength = getFirst(); + int numberOfGroup = getNumberOfGroup(); + int step = (int) getStep(); + + Equation equation = pop.getGrowth(); + if (equation == null) { + // return new OutputView("Error.xml", "error", t("isisfish.error.growth.equation.before.create.group.population")); + } + double deltat = -1; + double Lmin = minLength; + for (int i = 0; i < numberOfGroup; i++) { + // on creer la classe avec une valeur Lmax fausses ... + PopulationGroup group = populationGroupDAO.create(); + group.setId(i); + group.setPopulation(pop); + group.setMinLength(Lmin); + group.setMaxLength(Lmin); + pop.addPopulationGroup(group); + + if (deltat < 0) { + // premier passage, recuperation de l'age minimum + deltat = pop.getAge(minLength, group); + } + // incrementation pour calculer la longueur max de la classe + deltat += step; + + // ... pour pouvoir avoir la classe pour l'equation + double Lmax = pop.getLength(deltat, group); + group.setMaxLength(Lmax); + Lmin = Lmax; + } + } + popBasic.getHandler().refresh(); + cancel(); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Can't create PopulationGroup", e); + } + } + + } + + protected void cancel() { + wizardUI.getParentContainer(JFrame.class).dispose(); + } + + protected void refreshChoice() { + setInputType(wizardUI.beginGroupLengthTypeInput.isSelected()); + setSameSizeType(wizardUI.beginGroupLengthTypeSameSize.isSelected()); + setGrowthCurveType(wizardUI.beginGroupLengthTypeGrowthCurve.isSelected()); + } + + protected void stepChanged() { + if (!wizardUI.fieldStep.getText().equals("")) { + setStep(Double.parseDouble(wizardUI.fieldStep.getText())); + } + } + + protected void firstAgeChanged() { + if (!wizardUI.firstAge.getText().equals("")) { + setFirst(Double.parseDouble(wizardUI.firstAge.getText())); + } + } + + protected void lastAgeChanged() { + if (!wizardUI.lastAge.getText().equals("")) { + setLast(Double.parseDouble(wizardUI.lastAge.getText())); + } + } + + protected void firstInputLengthChanged() { + if (!wizardUI.firstInputLength.getText().equals("")) { + setFirst(Double.parseDouble(wizardUI.firstInputLength.getText())); + } + } + + protected void maximalGroupsLengthChanged() { + if (!wizardUI.maximalGroupsLength.getText().equals("")) { + setMaxLength(wizardUI.maximalGroupsLength.getText()); + } + } + + protected void firstSizeLengthChanged() { + if (!wizardUI.firstSizeLength.getText().equals("")) { + setFirst(Double.parseDouble(wizardUI.firstSizeLength.getText())); + } + } + + protected void sameSizeNumberOfGroupChanged() { + if (!wizardUI.sameSizeNumberOfGroup.getText().equals("")) { + setNumberOfGroup(Integer.parseInt(wizardUI.sameSizeNumberOfGroup.getText())); + } + } + + protected void groupWidthChanged() { + if (!wizardUI.groupWidth.getText().equals("")) { + setGroupSize(Double.parseDouble(wizardUI.groupWidth.getText())); + } + } + + protected void growthCurveFirstGroupChanged() { + if (!wizardUI.growthCurveFirstGroup.getText().equals("")) { + setFirst(Double.parseDouble(wizardUI.growthCurveFirstGroup.getText())); + } + } + + protected void fieldNumberOfGroupChanged() { + if (!wizardUI.fieldNumberOfGroup.getText().equals("")) { + setNumberOfGroup(Integer.parseInt(wizardUI.fieldNumberOfGroup.getText())); + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/population/WizardGroupCreationUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric + Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -23,375 +23,16 @@ #L% --> <JPanel id="wizardGroup" layout='{new BorderLayout()}'> - <import> - org.nuiton.topia.TopiaContext - fr.ifremer.isisfish.IsisFishDAOHelper - fr.ifremer.isisfish.entities.Equation - fr.ifremer.isisfish.entities.Population - fr.ifremer.isisfish.entities.PopulationGroup - fr.ifremer.isisfish.entities.PopulationGroupDAO - java.awt.CardLayout - javax.swing.JFrame - </import> + <WizardGroupCreationHandler id="handler" /> + <script><![CDATA[ + protected void $afterCompleteSetup() { + handler.init(this); + } + ]]></script> - protected String current = null; - protected boolean ageType = false; - protected boolean inputType = false; - protected boolean sameSizeType = false; - protected boolean growthCurveType = false; - - protected double first = 0; - protected double last = 0; - - protected String maxLength = ""; - protected int numberOfGroup = 0; - protected double groupSize = 0; - - protected double step = 1; - protected PopulationBasicsUI popBasic; - - public void init(PopulationBasicsUI popBasic) { - this.popBasic = popBasic; - } - - /** - * @return Returns the ageType. - */ - public boolean isAgeType() { - return this.ageType; - } - - /** - * @param ageType The ageType to set. - */ - public void setAgeType(boolean ageType) { - this.ageType = ageType; - } - - /** - * @return Returns the inputType. - */ - public boolean isInputType() { - return this.inputType; - } - - /** - * @param inputType The inputType to set. - */ - public void setInputType(boolean inputType) { - this.inputType = inputType; - } - - /** - * @return Returns the sameSizeType. - */ - public boolean isSameSizeType() { - return this.sameSizeType; - } - - /** - * @param sameSizeType The sameSizeType to set. - */ - public void setSameSizeType(boolean sameSizeType) { - this.sameSizeType = sameSizeType; - } - - /** - * @return Returns the growthCurveType. - */ - public boolean isGrowthCurveType() { - return this.growthCurveType; - } - - /** - * @param growthCurveType The growthCurveType to set. - */ - public void setGrowthCurveType(boolean growthCurveType) { - this.growthCurveType = growthCurveType; - } - - /** - * @return Returns the first. - */ - public double getFirst() { - return this.first; - } - - /** - * @param first The first to set. - */ - public void setFirst(double first) { - this.first = first; - } - - /** - * @return Returns the last. - */ - public double getLast() { - return this.last; - } - - /** - * @param last The last to set. - */ - public void setLast(double last) { - this.last = last; - } - - /** - * @return Returns the maxLength. - */ - public String getMaxLength() { - return this.maxLength; - } - - /** - * @param maxLength The maxLength to set. - */ - public void setMaxLength(String maxLength) { - this.maxLength = maxLength; - } - - /** - * @return Returns the numberOfGroup. - */ - public int getNumberOfGroup() { - return this.numberOfGroup; - } - - /** - * @param numberOfGroup The numberOfGroup to set. - */ - public void setNumberOfGroup(int numberOfGroup) { - this.numberOfGroup = numberOfGroup; - } - - /** - * @return Returns the groupSize. - */ - public double getGroupSize() { - return this.groupSize; - } - - /** - * @param groupSize The groupSize to set. - */ - public void setGroupSize(double groupSize) { - this.groupSize = groupSize; - } - - /** - * @return Returns the step. - */ - public double getStep() { - return this.step; - } - - /** - * @param step The step to set. - */ - public void setStep(double step) { - this.step = step; - } - - public void setCard(String name){ - current = name; - ((CardLayout) wizardPanels.getLayout()).show(wizardPanels, name); - } - protected void prev(){ - if (isAgeType()) { - // do nothing only one panel - } else { - setCard("beginGroupLength"); - } - prev.setEnabled(false); - next.setEnabled(true); - finish.setEnabled(false); - } - protected void next(){ - if (isAgeType()) { - // do nothing only one panel - } else if (isInputType()) { - setCard("endInputGroupLength"); - } else if (isSameSizeType()) { - setCard("endSameSizeGroupLength"); - } else if (isGrowthCurveType()) { - setCard("endGrowthCurveGroupLength"); - } - prev.setEnabled(true); - next.setEnabled(false); - finish.setEnabled(true); - } - protected void finish() { - if (log.isDebugEnabled()) { - log.debug("wizardGroupFinish called"); - } - - try { - Population pop = popBasic.getBean(); - // remove all old group - pop.clearPopulationGroup(); - - TopiaContext isisContext = pop.getTopiaContext(); - PopulationGroupDAO populationGroupDAO = IsisFishDAOHelper.getPopulationGroupDAO(isisContext); - - if (isAgeType()) { - double ageFirst = getFirst(); - double ageLast = getLast(); - for (int id=0; id + ageFirst <= ageLast; id++) { - PopulationGroup group = populationGroupDAO.create(); - group.setId(id); - group.setPopulation(pop); - group.setAge(ageFirst + id); - pop.addPopulationGroup(group); - populationGroupDAO.update(group); - } - } else if (isInputType()) { - double minLength = getFirst(); - String [] values = getMaxLength().split(";"); - for(int i=0; i<values.length; i++){ - if (!"".equals(values[i])) { - double length = Double.parseDouble(values[i]); - PopulationGroup group = populationGroupDAO.create(); - group.setId(i); - group.setPopulation(pop); - group.setMinLength(minLength); - group.setMaxLength(length); - pop.addPopulationGroup(group); - populationGroupDAO.update(group); - minLength = length; - } - } - - } else if (isSameSizeType()) { - double minLength = getFirst(); - int numberOfGroup = getNumberOfGroup(); - double step = getGroupSize(); - if (numberOfGroup < 0){ -// return new OutputView("Error.xml", "error", t("isisfish.error.number.classes.upper.zero")); - } - if (step == 0){ -// return new OutputView("Error.xml", "error", t"isisfish.error.no.null.time.step")); - } - - double maxLength = minLength; - for(int i=0; i<numberOfGroup; i++){ - maxLength = minLength + step; - PopulationGroup group = populationGroupDAO.create(); - group.setId(i); - group.setPopulation(pop); - group.setMinLength(minLength); - group.setMaxLength(maxLength); - pop.addPopulationGroup(group); - populationGroupDAO.update(group); - minLength = maxLength; - } - } else if (isGrowthCurveType()) { - double minLength = getFirst(); - int numberOfGroup = getNumberOfGroup(); - int step = (int)getStep(); - - Equation equation = pop.getGrowth(); - if(equation == null){ -// return new OutputView("Error.xml", "error", t("isisfish.error.growth.equation.before.create.group.population")); - } - double deltat = -1; - double Lmin = minLength; - for(int i=0; i<numberOfGroup; i++){ - // on creer la classe avec une valeur Lmax fausses ... - PopulationGroup group = populationGroupDAO.create(); - group.setId(i); - group.setPopulation(pop); - group.setMinLength(Lmin); - group.setMaxLength(Lmin); - pop.addPopulationGroup(group); - - if(deltat < 0) { - // premier passage, recuperation de l'age minimum - deltat = pop.getAge(minLength, group); - } - // incrementation pour calculer la longueur max de la classe - deltat += step; - - // ... pour pouvoir avoir la classe pour l'equation - double Lmax = pop.getLength(deltat, group); - group.setMaxLength(Lmax); - Lmin = Lmax; - } - } - popBasic.refresh(); - cancel(); - } - catch(Exception e) { - if (log.isErrorEnabled()) { - log.error("Can't create PopulationGroup", e); - } - } - - } - protected void cancel(){ - getParentContainer(JFrame.class).dispose(); - } - protected void refreshChoice(){ - setInputType(beginGroupLengthTypeInput.isSelected()); - setSameSizeType(beginGroupLengthTypeSameSize.isSelected()); - setGrowthCurveType(beginGroupLengthTypeGrowthCurve.isSelected()); - } - protected void stepChanged(){ - if (!fieldStep.getText().equals("")){ - setStep(Double.parseDouble(fieldStep.getText())); - } - } - protected void firstAgeChanged(){ - if (!firstAge.getText().equals("")){ - setFirst(Double.parseDouble(firstAge.getText())); - } - } - protected void lastAgeChanged(){ - if(!lastAge.getText().equals("")){ - setLast(Double.parseDouble(lastAge.getText())); - } - } - protected void firstInputLengthChanged(){ - if(!firstInputLength.getText().equals("")){ - setFirst(Double.parseDouble(firstInputLength.getText())); - } - } - protected void maximalGroupsLengthChanged(){ - if(!maximalGroupsLength.getText().equals("")){ - setMaxLength(maximalGroupsLength.getText()); - } - } - protected void firstSizeLengthChanged(){ - if(!firstSizeLength.getText().equals("")){ - setFirst(Double.parseDouble(firstSizeLength.getText())); - } - } - protected void sameSizeNumberOfGroupChanged(){ - if(!sameSizeNumberOfGroup.getText().equals("")){ - setNumberOfGroup(Integer.parseInt(sameSizeNumberOfGroup.getText())); - } - } - protected void groupWidthChanged(){ - if(!groupWidth.getText().equals("")){ - setGroupSize(Double.parseDouble(groupWidth.getText())); - } - } - protected void growthCurveFirstGroupChanged(){ - if(!growthCurveFirstGroup.getText().equals("")){ - setFirst(Double.parseDouble(growthCurveFirstGroup.getText())); - } - } - protected void fieldNumberOfGroupChanged(){ - if(!fieldNumberOfGroup.getText().equals("")){ - setNumberOfGroup(Integer.parseInt(fieldNumberOfGroup.getText())); - } - } - ]]> - </script> - <JPanel id="wizardPanels" layout='{new CardLayout()}' constraints='BorderLayout.CENTER'> + <JPanel id="wizardPanels" layout='{new java.awt.CardLayout()}' constraints='BorderLayout.CENTER'> <Table constraints='"beginGroupLength"'> <row> <cell fill='horizontal' weightx='1.0'> @@ -400,17 +41,20 @@ </row> <row> <cell fill='horizontal' weightx='1.0'> - <JRadioButton id="beginGroupLengthTypeInput" buttonGroup="groupLengthType" text="isisfish.wizardGroupCreation.allValues" onActionPerformed='refreshChoice()'/> + <JRadioButton id="beginGroupLengthTypeInput" buttonGroup="groupLengthType" + text="isisfish.wizardGroupCreation.allValues" onActionPerformed='handler.refreshChoice()'/> </cell> </row> <row> <cell fill='horizontal' weightx='1.0'> - <JRadioButton id="beginGroupLengthTypeSameSize" buttonGroup="groupLengthType" text="isisfish.wizardGroupCreation.allGroupsSameSize" onActionPerformed='refreshChoice()'/> + <JRadioButton id="beginGroupLengthTypeSameSize" buttonGroup="groupLengthType" + text="isisfish.wizardGroupCreation.allGroupsSameSize" onActionPerformed='handler.refreshChoice()'/> </cell> </row> <row> <cell fill='horizontal' weightx='1.0'> - <JRadioButton id="beginGroupLengthTypeGrowthCurve" buttonGroup="groupLengthType" text="isisfish.wizardGroupCreation.computedGrowthCurve" onActionPerformed='refreshChoice()'/> + <JRadioButton id="beginGroupLengthTypeGrowthCurve" buttonGroup="groupLengthType" + text="isisfish.wizardGroupCreation.computedGrowthCurve" onActionPerformed='handler.refreshChoice()'/> </cell> </row> </Table> @@ -425,7 +69,7 @@ <JLabel text="isisfish.wizardGroupCreation.firstAge"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="firstAge" onFocusLost='firstAgeChanged()'/> + <JTextField id="firstAge" onFocusLost='handler.firstAgeChanged()'/> </cell> </row> <row> @@ -433,7 +77,7 @@ <JLabel text="isisfish.wizardGroupCreation.lastAge"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="lastAge" onFocusLost='lastAgeChanged()'/> + <JTextField id="lastAge" onFocusLost='handler.lastAgeChanged()'/> </cell> </row> <row> @@ -463,7 +107,7 @@ <JLabel text="isisfish.wizardGroupCreation.firstLength"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="firstInputLength" onFocusLost='firstInputLengthChanged()'/> + <JTextField id="firstInputLength" onFocusLost='handler.firstInputLengthChanged()'/> </cell> </row> <row> @@ -471,7 +115,7 @@ <JLabel text="isisfish.wizardGroupCreation.maxGroupsLength"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="maximalGroupsLength" onFocusLost='maximalGroupsLengthChanged()'/> + <JTextField id="maximalGroupsLength" onFocusLost='handler.maximalGroupsLengthChanged()'/> </cell> </row> <row> @@ -491,7 +135,7 @@ <JLabel text="isisfish.wizardGroupCreation.firstLength"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="firstSizeLength" onFocusLost='firstSizeLengthChanged()'/> + <JTextField id="firstSizeLength" onFocusLost='handler.firstSizeLengthChanged()'/> </cell> </row> <row> @@ -499,7 +143,7 @@ <JLabel text="isisfish.wizardGroupCreation.numberGroup"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="sameSizeNumberOfGroup" onFocusLost='sameSizeNumberOfGroupChanged()'/> + <JTextField id="sameSizeNumberOfGroup" onFocusLost='handler.sameSizeNumberOfGroupChanged()'/> </cell> </row> <row> @@ -507,7 +151,7 @@ <JLabel text="isisfish.wizardGroupCreation.groupWidth"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="groupWidth" onFocusLost='groupWidthChanged()'/> + <JTextField id="groupWidth" onFocusLost='handler.groupWidthChanged()'/> </cell> </row> <row> @@ -537,7 +181,7 @@ <JLabel text="isisfish.wizardGroupCreation.firstGroup"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="growthCurveFirstGroup" onFocusLost='growthCurveFirstGroupChanged()'/> + <JTextField id="growthCurveFirstGroup" onFocusLost='handler.growthCurveFirstGroupChanged()'/> </cell> </row> <row> @@ -545,7 +189,7 @@ <JLabel text="isisfish.wizardGroupCreation.numberGroups"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldNumberOfGroup" onFocusLost='fieldNumberOfGroupChanged()'/> + <JTextField id="fieldNumberOfGroup" onFocusLost='handler.fieldNumberOfGroupChanged()'/> </cell> </row> <row> @@ -553,7 +197,7 @@ <JLabel text="isisfish.wizardGroupCreation.timeStep"/> </cell> <cell fill='horizontal' weightx='1.0'> - <JTextField id="fieldStep" onFocusLost='stepChanged()'/> + <JTextField id="fieldStep" onFocusLost='handler.stepChanged()'/> </cell> </row> <row> @@ -566,16 +210,16 @@ <Table id="navButton" constraints='BorderLayout.SOUTH'> <row> <cell fill='horizontal' weightx='0.2'> - <JButton id='prev' enabled='false' text="isisfish.common.prev" onActionPerformed='prev()'/> + <JButton id='prev' enabled='false' text="isisfish.common.prev" onActionPerformed='handler.prev()'/> </cell> <cell fill='horizontal' weightx='0.2'> - <JButton id='next' text="isisfish.common.next" onActionPerformed='next()'/> + <JButton id='next' text="isisfish.common.next" onActionPerformed='handler.next()'/> </cell> <cell fill='horizontal' weightx='0.2'> - <JButton id='finish' enabled='false' text="isisfish.common.finish" onActionPerformed='finish()'/> + <JButton id='finish' enabled='false' text="isisfish.common.finish" onActionPerformed='handler.finish()'/> </cell> <cell fill='horizontal' weightx='0.2'> - <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='cancel()'/> + <JButton id='cancel' text="isisfish.common.cancel" onActionPerformed='handler.cancel()'/> </cell> </row> </Table> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,106 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.port; + +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + +import java.awt.event.MouseEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import com.bbn.openmap.event.SelectMouseMode; + +import fr.ifremer.isisfish.entities.Cell; +import fr.ifremer.isisfish.map.CellSelectionLayer; +import fr.ifremer.isisfish.map.OpenMapEvents; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericListModel; + +/** + * Port handler. + */ +public class PortHandler extends InputContentHandler<PortUI> { + + protected boolean init = false; + + protected void init(final PortUI inputContentUI) { + super.init(inputContentUI); + + new OpenMapEvents(inputContentUI.portMap, new SelectMouseMode(false), CellSelectionLayer.SINGLE_SELECTION) { + @Override + public boolean mouseClicked(MouseEvent e) { + if (inputContentUI.getBean() != null) { // impossible de desactiver la carte :( + for (Cell c : inputContentUI.portMap.getSelectedCells()) { + if (inputContentUI.getBean().getCell() != null) { + if (!inputContentUI.getBean().getCell().getTopiaId().equals(c.getTopiaId())){ + inputContentUI.portCell.setSelectedValue(c, true); + return true; + } + } else { + inputContentUI.portCell.setSelectedValue(c, true); + return true; + } + } + } + return true; + } + }; + + inputContentUI.setButtonTitle(t("isisfish.input.continueSpecies")); + inputContentUI.setNextPath(n("isisfish.input.tree.species")); + + inputContentUI.addPropertyChangeListener(PortUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldPortName.setText(""); + inputContentUI.fieldPortComment.setText(""); + } + if (evt.getNewValue() != null) { + + } + fillCellList(); + } + }); + } + + protected void fillCellList() { + GenericListModel<Cell> cellModel = new GenericListModel<>(); + if (inputContentUI.getBean() != null) { + init = true; + cellModel.setElementList(inputContentUI.getFisheryRegion().getCell()); + inputContentUI.portCell.setModel(cellModel); + inputContentUI.portCell.setSelectedValue(inputContentUI.getBean().getCell(), true); + init = false; + } else { + inputContentUI.portCell.setModel(cellModel); + } + } + + protected void portChanged() { + if (inputContentUI.getBean() != null && !init) { + inputContentUI.getBean().setCell(inputContentUI.portCell.getSelectedValue()); + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortHandler.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/port/PortUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -27,20 +27,7 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Port id='bean' javaBean='null'/> - <import> - static org.nuiton.i18n.I18n.t - static org.nuiton.i18n.I18n.n - fr.ifremer.isisfish.entities.Port - fr.ifremer.isisfish.entities.Cell - fr.ifremer.isisfish.map.CellSelectionLayer - fr.ifremer.isisfish.map.CopyMapToClipboardListener - fr.ifremer.isisfish.map.OpenMapEvents - com.bbn.openmap.event.SelectMouseMode - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - java.awt.event.MouseEvent - fr.ifremer.isisfish.ui.models.common.GenericListModel - </import> + <PortHandler id="handler" /> <BeanValidator id='validator' bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Port' @@ -50,79 +37,11 @@ </BeanValidator> <script><![CDATA[ -boolean init = false; - -protected void $afterCompleteSetup() { - - //portMap.init(portMapInfo); - new OpenMapEvents(portMap, new SelectMouseMode(false), CellSelectionLayer.SINGLE_SELECTION) { - @Override - public boolean mouseClicked(MouseEvent e) { - if (getBean() != null) { // impossible de desactiver la carte :( - for (Cell c : portMap.getSelectedCells()) { - if (getBean().getCell() != null) { - if (!getBean().getCell().getTopiaId().equals(c.getTopiaId())){ - portCell.setSelectedValue(c, true); - return true; - } - } - else { - portCell.setSelectedValue(c, true); - return true; - } - } - } - return true; - } - }; - - setButtonTitle(t("isisfish.input.continueSpecies")); - setNextPath(n("isisfish.input.tree.species")); - - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldPortName.setText(""); - fieldPortComment.setText(""); - } - if (evt.getNewValue() != null) { - - } - fillCellList(); - } - }); -} - -/*public void refresh() { - Port port = getSaveVerifier().getEntity(Port.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - setBean(null); - setBean(port); - // reload region in map - refreshRegionInMap(portMap); -}*/ - -protected void fillCellList() { - GenericListModel<Cell> cellModel = new GenericListModel<>(); - if (getBean() != null) { - init = true; - cellModel.setElementList(getFisheryRegion().getCell()); - portCell.setModel(cellModel); - portCell.setSelectedValue(getBean().getCell(), true); - init = false; - } else { - portCell.setModel(cellModel); + protected void $afterCompleteSetup() { + handler.init(this); } -} - -protected void portChanged() { - if (getBean() != null && !init) { - getBean().setCell(portCell.getSelectedValue()); - } -} ]]></script> + <JPanel id="body"> <JSplitPane oneTouchExpandable="true" dividerLocation="270" orientation="horizontal"> <Table> @@ -147,7 +66,7 @@ <JScrollPane id="spPortCell"> <JList id="portCell" genericType="fr.ifremer.isisfish.entities.Cell" selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}" - onValueChanged='portChanged()' enabled='{isActive()}' decorator='boxed' /> + onValueChanged='handler.portChanged()' enabled='{isActive()}' decorator='boxed' /> </JScrollPane> </cell> </row> @@ -159,7 +78,8 @@ <row> <cell columns='2' fill='both' weighty='0.3' weightx='1.0' > <JScrollPane> - <JTextArea id="fieldPortComment" text='{SwingUtil.getStringValue(getBean().getComment())}' onKeyReleased='getBean().setComment(fieldPortComment.getText())' enabled='{isActive()}' decorator='boxed'/> + <JTextArea id="fieldPortComment" text='{SwingUtil.getStringValue(getBean().getComment())}' + onKeyReleased='getBean().setComment(fieldPortComment.getText())' enabled='{isActive()}' decorator='boxed'/> </JScrollPane> </cell> </row> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,106 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.setofvessels; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; + +import fr.ifremer.isisfish.entities.EffortDescription; +import fr.ifremer.isisfish.entities.Metier; +import fr.ifremer.isisfish.ui.input.InputAction; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericListModel; + +/** + * set of vessels handler. + */ +public class EffortDescriptionHandler extends InputContentHandler<EffortDescriptionUI> { + + protected void init(final EffortDescriptionUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(EffortDescriptionUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + GenericListModel<Metier> metierModel = (GenericListModel<Metier>)inputContentUI.fieldEffortDescriptionMetierList.getModel(); + if (evt.getNewValue() == null) { + metierModel.setElementList(null); + } + if (evt.getNewValue() != null) { + metierModel.setElementList(inputContentUI.getFisheryRegion().getMetier()); + setEffortDescriptionEffortDescriptionList(); + } + } + }); + } + + /** + * Get input action from context. + */ + @Deprecated + protected InputAction getInputAction() { + return inputContentUI.getContextValue(InputAction.class); + } + + protected void onFieldEffortDescriptionMetierListValueChanged() { + // active le bouton seulement si l'interface est active + // dans le cas de sensitivity par exemple + if (inputContentUI.isActive()) { + inputContentUI.buttonEffortDescriptionAdd.setEnabled(inputContentUI.fieldEffortDescriptionMetierList.getSelectedIndex() != -1); + } + } + + protected void onFieldEffortDescriptionEffortDescriptionListValueChanged() { + // active le bouton seulement si l'interface est active + // dans le cas de sensitivity par exemple + if (inputContentUI.isActive()) { + inputContentUI.removeEffortDescriptionButton.setEnabled(inputContentUI.fieldEffortDescriptionEffortDescriptionList.getSelectedIndex() != -1); + } + } + + protected void setEffortDescriptionEffortDescriptionList() { + GenericListModel<EffortDescription> model = new GenericListModel<>(); + if (inputContentUI.getBean() != null && inputContentUI.getBean().getPossibleMetiers() != null) { + List<EffortDescription> effortDescriptions = new ArrayList<>(inputContentUI.getBean().getPossibleMetiers()); + model.setElementList(effortDescriptions); + } + inputContentUI.fieldEffortDescriptionEffortDescriptionList.setModel(model); + } + + protected void addEffortDescriptions() { + List<Metier> selectedValues = inputContentUI.fieldEffortDescriptionMetierList.getSelectedValuesList(); + for (Metier selectedMetier : selectedValues) { + getInputAction().addEffortDescription(inputContentUI.getBean(), selectedMetier); + } + setEffortDescriptionEffortDescriptionList(); + } + protected void removeEffortDescriptions() { + List<EffortDescription> selectedValues = inputContentUI.fieldEffortDescriptionEffortDescriptionList.getSelectedValuesList(); + for (EffortDescription selectedEffortDescription : selectedValues) { + getInputAction().removeEffortDescription(inputContentUI.getBean(), selectedEffortDescription); + } + setEffortDescriptionEffortDescriptionList(); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionListRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/EffortDescriptionListRenderer.java) =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionListRenderer.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionListRenderer.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,67 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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.ifremer.isisfish.ui.input.setofvessels; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import fr.ifremer.isisfish.entities.EffortDescription; + +/** + * Renderer pour liste des {@link EffortDescription}. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class EffortDescriptionListRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1113492654780402245L; + + /* + * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) + */ + @Override + public Component getListCellRendererComponent(JList<?> list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + // this must be used to have alterned highlight rows and default + // selection color + JLabel c = (JLabel) super.getListCellRendererComponent(list, value, + index, isSelected, cellHasFocus); + + EffortDescription effort = (EffortDescription) value; + c.setText(effort.getPossibleMetiers().getName()); + + return c; + } +} Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,109 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.setofvessels; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; + +import fr.ifremer.isisfish.entities.EffortDescription; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericListModel; + +/** + * set of vessels handler. + */ +public class EffortDescriptionParametersHandler extends InputContentHandler<EffortDescriptionParametersUI> { + + protected void init(final EffortDescriptionParametersUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(EffortDescriptionParametersUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.setEffortDescription(null); + } + if (evt.getNewValue() != null) { + GenericListModel<EffortDescription> model = new GenericListModel<>(); + // getBean().getPossibleMetiers() can be null at region creation + if (inputContentUI.getBean() != null && inputContentUI.getBean().getPossibleMetiers() != null) { + List<EffortDescription> effortDescriptions = new ArrayList<>(inputContentUI.getBean().getPossibleMetiers()); + model.setElementList(effortDescriptions); + } + inputContentUI.fieldEffortDescriptionEffortDescriptionList.setModel(model); + } + } + }); + inputContentUI.addPropertyChangeListener(EffortDescriptionParametersUI.PROPERTY_EFFORT_DESCRIPTION, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldEffortDescriptionFishingOperation.setText(""); + inputContentUI.fieldEffortDescriptionFishingOperationDuration.setText(""); + inputContentUI.fieldEffortDescriptionGearsNumberPerOperation.setText(""); + inputContentUI.fieldEffortDescriptionCrewSize.setText(""); + inputContentUI.fieldEffortDescriptionUnitCostOfFishing.setText(""); + inputContentUI.fieldEffortDescriptionFixedCrewSalary.setText(""); + inputContentUI.fieldEffortDescriptionCrewFoodCost.setText(""); + inputContentUI.fieldEffortDescriptionCrewShareRate.setText(""); + inputContentUI.fieldEffortDescriptionRepairAndMaintenanceGearCost.setText(""); + inputContentUI.fieldEffortDescriptionLandingCosts.setText(""); + inputContentUI.fieldEffortDescriptionOtherRunningCost.setText(""); + } + if (evt.getNewValue() != null) { + // FIX non working binding in jaxx 2.4.1 + if (inputContentUI.getEffortDescription().getFishingOperationDuration() == null) { + inputContentUI.fieldEffortDescriptionFishingOperationDuration.setText(""); + } + } + } + }); + } + + protected void effortDescriptionSelectionChanged() { + EffortDescription selectedEffort = (EffortDescription)inputContentUI.fieldEffortDescriptionEffortDescriptionList.getSelectedValue(); + inputContentUI.setEffortDescription(selectedEffort); + + if (inputContentUI.getEffortDescription() != null) { + inputContentUI.getSaveVerifier().addCurrentEntity(inputContentUI.getEffortDescription()); + selectedEffort.addPropertyChangeListener(new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + inputContentUI.changeModel.setStayChanged(true); + } + }); + + /* NumberEditor is not working + fieldEffortDescriptionFishingOperation.init(); + fieldEffortDescriptionGearsNumberPerOperation.init(); + fieldEffortDescriptionCrewSize.init(); + fieldEffortDescriptionUnitCostOfFishing.init(); + fieldEffortDescriptionFixedCrewSalary.init(); + fieldEffortDescriptionCrewFoodCost.init(); + fieldEffortDescriptionCrewShareRate.init(); + fieldEffortDescriptionRepairAndMaintenanceGearCost.init(); + fieldEffortDescriptionLandingCosts.init(); + fieldEffortDescriptionOtherRunningCost.init();*/ + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionParametersUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -29,18 +29,8 @@ <fr.ifremer.isisfish.entities.EffortDescription id='effortDescription' javaBean='null'/> - <import> - static org.nuiton.i18n.I18n.t - java.util.ArrayList; - fr.ifremer.isisfish.entities.EffortDescription; - fr.ifremer.isisfish.entities.SetOfVessels; - fr.ifremer.isisfish.types.TimeUnit; - fr.ifremer.isisfish.ui.models.common.GenericListModel; - fr.ifremer.isisfish.ui.input.renderer.EffortDescriptionListRenderer; - java.beans.PropertyChangeEvent; - java.beans.PropertyChangeListener; - </import> - + <EffortDescriptionParametersHandler id="handler" /> + <BeanValidator id='validator' context="effortdescriptionparameters" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.SetOfVessels' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> @@ -54,89 +44,21 @@ <fr.ifremer.isisfish.ui.input.ChangeModel id="changeModel" changed="{validator.isChanged() || validatorEffort.isChanged()}" valid="{validator.isValid() && validatorEffort.isValid()}"/> - <script><![CDATA[ -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - setEffortDescription(null); - } - if (evt.getNewValue() != null) { - GenericListModel<EffortDescription> model = new GenericListModel<>(); - // getBean().getPossibleMetiers() can be null at region creation - if (getBean() != null && getBean().getPossibleMetiers() != null) { - List<EffortDescription> effortDescriptions = new ArrayList<EffortDescription>(getBean().getPossibleMetiers()); - model.setElementList(effortDescriptions); - } - fieldEffortDescriptionEffortDescriptionList.setModel(model); - } - } - }); - addPropertyChangeListener(PROPERTY_EFFORT_DESCRIPTION, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldEffortDescriptionFishingOperation.setText(""); - fieldEffortDescriptionFishingOperationDuration.setText(""); - fieldEffortDescriptionGearsNumberPerOperation.setText(""); - fieldEffortDescriptionCrewSize.setText(""); - fieldEffortDescriptionUnitCostOfFishing.setText(""); - fieldEffortDescriptionFixedCrewSalary.setText(""); - fieldEffortDescriptionCrewFoodCost.setText(""); - fieldEffortDescriptionCrewShareRate.setText(""); - fieldEffortDescriptionRepairAndMaintenanceGearCost.setText(""); - fieldEffortDescriptionLandingCosts.setText(""); - fieldEffortDescriptionOtherRunningCost.setText(""); - } - if (evt.getNewValue() != null) { - // FIX non working binding in jaxx 2.4.1 - if (getEffortDescription().getFishingOperationDuration() == null) { - fieldEffortDescriptionFishingOperationDuration.setText(""); - } - } - } - }); -} + <import> + fr.ifremer.isisfish.types.TimeUnit + </import> -@Override -public void resetChangeModel() { - changeModel.setStayChanged(false); -} - -/*public void refresh() { - SetOfVessels setOfVessels = getSaveVerifier().getEntity(SetOfVessels.class); - - // twice event for jaxx bindings detection - setBean(null); - setBean(setOfVessels); -}*/ - -protected void effortDescriptionSelectionChanged() { - EffortDescription selectedEffort = (EffortDescription)fieldEffortDescriptionEffortDescriptionList.getSelectedValue(); - setEffortDescription(selectedEffort); - - if (getEffortDescription() != null) { - getSaveVerifier().addCurrentEntity(getEffortDescription()); - selectedEffort.addPropertyChangeListener(new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - changeModel.setStayChanged(true); - } - }); - - /* NumberEditor is not working - fieldEffortDescriptionFishingOperation.init(); - fieldEffortDescriptionGearsNumberPerOperation.init(); - fieldEffortDescriptionCrewSize.init(); - fieldEffortDescriptionUnitCostOfFishing.init(); - fieldEffortDescriptionFixedCrewSalary.init(); - fieldEffortDescriptionCrewFoodCost.init(); - fieldEffortDescriptionCrewShareRate.init(); - fieldEffortDescriptionRepairAndMaintenanceGearCost.init(); - fieldEffortDescriptionLandingCosts.init(); - fieldEffortDescriptionOtherRunningCost.init();*/ + <script><![CDATA[ + protected void $afterCompleteSetup() { + handler.init(this); } -} - ]]> - </script> + + @Override + public void resetChangeModel() { + changeModel.setStayChanged(false); + } + ]]></script> + <JPanel id="body"> <Table> <row> @@ -144,7 +66,7 @@ <JScrollPane> <JList id="fieldEffortDescriptionEffortDescriptionList" selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}" genericType="EffortDescription" - onValueChanged='effortDescriptionSelectionChanged()' + onValueChanged='handler.effortDescriptionSelectionChanged()' cellRenderer='{new EffortDescriptionListRenderer()}' enabled='{isActive()}' /> </JScrollPane> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -27,18 +27,7 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.SetOfVessels id='bean' javaBean='null'/> - <import> - java.util.ArrayList - fr.ifremer.isisfish.entities.EffortDescription - fr.ifremer.isisfish.entities.SetOfVessels - fr.ifremer.isisfish.entities.Metier - fr.ifremer.isisfish.ui.models.common.GenericListModel - fr.ifremer.isisfish.ui.input.renderer.MetierListRenderer - fr.ifremer.isisfish.ui.input.renderer.EffortDescriptionListRenderer - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - fr.ifremer.isisfish.ui.input.InputAction - </import> + <EffortDescriptionHandler id="handler" /> <BeanValidator id='validator' context="effortdescription" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.SetOfVessels' @@ -46,96 +35,30 @@ </BeanValidator> <script><![CDATA[ -/** - * Get input action from context. - */ -protected InputAction getInputAction() { - return getContextValue(InputAction.class); -} - -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - GenericListModel<Metier> metierModel = (GenericListModel<Metier>)fieldEffortDescriptionMetierList.getModel(); - if (evt.getNewValue() == null) { - metierModel.setElementList(null); - } - if (evt.getNewValue() != null) { - metierModel.setElementList(getFisheryRegion().getMetier()); - setEffortDescriptionEffortDescriptionList(); - } - } - }); -} - -/*public void refresh() { - SetOfVessels setOfVessels = getSaveVerifier().getEntity(SetOfVessels.class); - - // twice event for jaxx bindings detection - setBean(null); - setBean(setOfVessels); -}*/ - -protected void onFieldEffortDescriptionMetierListValueChanged() { - // active le bouton seulement si l'interface est active - // dans le cas de sensitivity par exemple - if (isActive()) { - buttonEffortDescriptionAdd.setEnabled(fieldEffortDescriptionMetierList.getSelectedIndex() != -1); + protected void $afterCompleteSetup() { + handler.init(this); } -} + ]]></script> -protected void onFieldEffortDescriptionEffortDescriptionListValueChanged() { - // active le bouton seulement si l'interface est active - // dans le cas de sensitivity par exemple - if (isActive()) { - removeEffortDescriptionButton.setEnabled(fieldEffortDescriptionEffortDescriptionList.getSelectedIndex() != -1); - } -} - -protected void setEffortDescriptionEffortDescriptionList() { - GenericListModel<EffortDescription> model = new GenericListModel<>(); - if (getBean() != null && getBean().getPossibleMetiers() != null) { - List<EffortDescription> effortDescriptions = new ArrayList<>(getBean().getPossibleMetiers()); - model.setElementList(effortDescriptions); - } - fieldEffortDescriptionEffortDescriptionList.setModel(model); -} - -protected void addEffortDescriptions() { - List<Metier> selectedValues = fieldEffortDescriptionMetierList.getSelectedValuesList(); - for (Metier selectedMetier : selectedValues) { - getInputAction().addEffortDescription(getBean(), selectedMetier); - } - setEffortDescriptionEffortDescriptionList(); -} -protected void removeEffortDescriptions() { - List<EffortDescription> selectedValues = fieldEffortDescriptionEffortDescriptionList.getSelectedValuesList(); - for (EffortDescription selectedEffortDescription : selectedValues) { - getInputAction().removeEffortDescription(getBean(), selectedEffortDescription); - } - setEffortDescriptionEffortDescriptionList(); -} - ]]> - </script> <JPanel id="body"> <Table> <row> <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> <JScrollPane> <JList id="fieldEffortDescriptionMetierList" selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}" - genericType="Metier" - model='{new GenericListModel<Metier>()}' cellRenderer='{new MetierListRenderer()}' - onValueChanged='onFieldEffortDescriptionMetierListValueChanged()' enabled='{isActive()}' decorator='boxed' /> + genericType="fr.ifremer.isisfish.entities.Metier" + model='{new fr.ifremer.isisfish.ui.models.common.GenericListModel<fr.ifremer.isisfish.entities.Metier>()}' cellRenderer='{new MetierListRenderer()}' + onValueChanged='handler.onFieldEffortDescriptionMetierListValueChanged()' enabled='{isActive()}' decorator='boxed' /> </JScrollPane> </cell> </row> <row> <cell fill='horizontal' weightx='0.5'> - <JButton id="buttonEffortDescriptionAdd" text="isisfish.common.add" onActionPerformed='addEffortDescriptions()' enabled='false' + <JButton id="buttonEffortDescriptionAdd" text="isisfish.common.add" onActionPerformed='handler.addEffortDescriptions()' enabled='false' decorator='boxed' /> </cell> <cell fill='horizontal' weightx='0.5'> - <JButton id='removeEffortDescriptionButton' text="isisfish.common.remove" onActionPerformed='removeEffortDescriptions()' + <JButton id='removeEffortDescriptionButton' text="isisfish.common.remove" onActionPerformed='handler.removeEffortDescriptions()' enabled='false' decorator='boxed' /> </cell> </row> @@ -143,9 +66,9 @@ <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> <JScrollPane> <JList id="fieldEffortDescriptionEffortDescriptionList" selectionMode="{javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}" - genericType="EffortDescription" + genericType="fr.ifremer.isisfish.entities.EffortDescription" cellRenderer='{new EffortDescriptionListRenderer()}' - onValueChanged='onFieldEffortDescriptionEffortDescriptionListValueChanged()' enabled='{isActive()}' decorator='boxed' /> + onValueChanged='handler.onFieldEffortDescriptionEffortDescriptionListValueChanged()' enabled='{isActive()}' decorator='boxed' /> </JScrollPane> </cell> </row> Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/MetierListRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/MetierListRenderer.java) =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/MetierListRenderer.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/MetierListRenderer.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,67 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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.ifremer.isisfish.ui.input.setofvessels; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import fr.ifremer.isisfish.entities.Metier; + +/** + * Renderer pour liste des metiers. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class MetierListRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1113492654780402245L; + + /* + * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) + */ + @Override + public Component getListCellRendererComponent(JList<?> list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + // this must be used to have alterned highlight rows and default + // selection color + JLabel c = (JLabel) super.getListCellRendererComponent(list, value, + index, isSelected, cellHasFocus); + + Metier metier = (Metier) value; + c.setText(metier.getName()); + + return c; + } +} Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,76 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.setofvessels; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import fr.ifremer.isisfish.entities.Port; +import fr.ifremer.isisfish.entities.VesselType; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericComboModel; + +/** + * set of vessels handler. + */ +public class SetOfVesselsBasicsHandler extends InputContentHandler<SetOfVesselsBasicsUI> { + + protected boolean init; + + protected void init(final SetOfVesselsBasicsUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(SetOfVesselsBasicsUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + + } + if (evt.getNewValue() != null) { + init = true; + + GenericComboModel<Port> modelPort = new GenericComboModel<>(inputContentUI.getFisheryRegion().getPort()); + inputContentUI.fieldSetOfVesselsPort.setModel(modelPort); + inputContentUI.fieldSetOfVesselsPort.setSelectedItem(inputContentUI.getBean().getPort()); + + GenericComboModel<VesselType> modelVessel = new GenericComboModel<>(inputContentUI.getFisheryRegion().getVesselType()); + inputContentUI.fieldSetOfVesselsVesselType.setModel(modelVessel); + inputContentUI.fieldSetOfVesselsVesselType.setSelectedItem(inputContentUI.getBean().getVesselType()); + + init=false; + } + } + }); + } + + protected void portChanged() { + if (!init) { + inputContentUI.getBean().setPort((Port)inputContentUI.fieldSetOfVesselsPort.getSelectedItem()); + } + } + protected void vesselTypeChanged() { + if (!init) { + inputContentUI.getBean().setVesselType((VesselType)inputContentUI.fieldSetOfVesselsVesselType.getSelectedItem()); + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsBasicsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -27,14 +27,7 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.SetOfVessels id='bean' javaBean='null'/> - <import> - fr.ifremer.isisfish.entities.Port - fr.ifremer.isisfish.entities.VesselType - fr.ifremer.isisfish.entities.SetOfVessels - fr.ifremer.isisfish.ui.models.common.GenericComboModel - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - </import> + <SetOfVesselsBasicsHandler id="handler" /> <BeanValidator id='validator' context="basics" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.SetOfVessels' @@ -43,64 +36,11 @@ </BeanValidator> <script><![CDATA[ -boolean init = false; - -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - - } - if (evt.getNewValue() != null) { - init = true; - - GenericComboModel<Port> modelPort = new GenericComboModel<>(getFisheryRegion().getPort()); - fieldSetOfVesselsPort.setModel(modelPort); - fieldSetOfVesselsPort.setSelectedItem(getBean().getPort()); - - GenericComboModel<VesselType> modelVessel = new GenericComboModel<>(getFisheryRegion().getVesselType()); - fieldSetOfVesselsVesselType.setModel(modelVessel); - fieldSetOfVesselsVesselType.setSelectedItem(getBean().getVesselType()); - - init=false; - } - } - }); -} - -/*public void refresh() { - SetOfVessels setOfVessels = (SetOfVessels)getSaveVerifier().getEntity(SetOfVessels.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - setBean(null); - setBean(setOfVessels); - - if (getBean() != null) { - init = true; - jaxx.runtime.SwingUtil.fillComboBox(fieldSetOfVesselsPort,getFisheryRegion().getPort(), getBean().getPort(), true); - jaxx.runtime.SwingUtil.fillComboBox(fieldSetOfVesselsVesselType,getFisheryRegion().getVesselType(), getBean().getVesselType(), true); - init=false; - getSaveVerifier().addCurrentPanel(technicalEfficiency); - - // NumberEditor is not working - //fieldSetOfVesselsNumberOfVessels.init(); - //fieldSetOfVesselsFixedCosts.init(); + protected void $afterCompleteSetup() { + handler.init(this); } -}*/ + ]]></script> -protected void portChanged() { - if (!init) { - getBean().setPort((Port)fieldSetOfVesselsPort.getSelectedItem()); - } -} -protected void vesselTypeChanged() { - if (!init) { - getBean().setVesselType((VesselType)fieldSetOfVesselsVesselType.getSelectedItem()); - } -} - ]]> - </script> <JPanel id='body'> <Table> <row> @@ -119,8 +59,8 @@ <JLabel text="isisfish.common.port" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldSetOfVesselsPort" onItemStateChanged='portChanged()' - genericType="Port" + <JComboBox id="fieldSetOfVesselsPort" onItemStateChanged='handler.portChanged()' + genericType="fr.ifremer.isisfish.entities.Port" enabled='{isActive()}' decorator='boxed'/> </cell> </row> @@ -129,8 +69,8 @@ <JLabel text="isisfish.setOfVessels.vesselType" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldSetOfVesselsVesselType" onItemStateChanged='vesselTypeChanged()' - genericType="VesselType" + <JComboBox id="fieldSetOfVesselsVesselType" onItemStateChanged='handler.vesselTypeChanged()' + genericType="fr.ifremer.isisfish.entities.VesselType" enabled='{isActive()}' decorator='boxed'/> </cell> </row> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,46 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.setofvessels; + +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * set of vessels handler. + */ +public class SetOfVesselsHandler extends InputContentHandler<SetOfVesselsUI> { + + protected void init(final SetOfVesselsUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.setButtonTitle(t("isisfish.input.continueStrategies")); + inputContentUI.setNextPath(n("isisfish.input.tree.strategies")); + + // install change listener + // (depends on sensitivity can't be done on constructor) + inputContentUI.installChangeListener(inputContentUI.setOfVesselsTab); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsHandler.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/SetOfVesselsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -26,40 +26,29 @@ <fr.ifremer.isisfish.entities.SetOfVessels id='bean' javaBean='null'/> - <import> - static org.nuiton.i18n.I18n.t - static org.nuiton.i18n.I18n.n - </import> + <SetOfVesselsHandler id="handler" /> <script><![CDATA[ -protected void $afterCompleteSetup() { - setButtonTitle(t("isisfish.input.continueStrategies")); - setNextPath(n("isisfish.input.tree.strategies")); + protected void $afterCompleteSetup() { + handler.init(this); + } - // install change listener - // (depends on sensitivity can't be done on constructor) - installChangeListener(setOfVesselsTab); -} - -/*public void refresh() { - getSaveVerifier().addCurrentPanel(setOfVesselsBasicsUI, effortDescriptionUI, effortParametersUI); -}*/ - -@Override -public void setLayer(boolean active) { - super.setLayer(active); - setOfVesselsBasicsUI.setLayer(active); - effortDescriptionUI.setLayer(active); - effortParametersUI.setLayer(active); -} - -@Override -public void resetChangeModel() { - setOfVesselsBasicsUI.resetChangeModel(); - effortDescriptionUI.resetChangeModel(); - effortParametersUI.resetChangeModel(); -} + @Override + public void setLayer(boolean active) { + super.setLayer(active); + setOfVesselsBasicsUI.setLayer(active); + effortDescriptionUI.setLayer(active); + effortParametersUI.setLayer(active); + } + + @Override + public void resetChangeModel() { + setOfVesselsBasicsUI.resetChangeModel(); + effortDescriptionUI.resetChangeModel(); + effortParametersUI.resetChangeModel(); + } ]]></script> + <JPanel id="body"> <JTabbedPane id="setOfVesselsTab"> <tab title='isisfish.setOfVessels.title'> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,74 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.species; + +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.input.InputUI; + +/** + * Species handler. + */ +public class SpeciesHandler extends InputContentHandler<SpeciesUI> { + + protected void init(final SpeciesUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.setButtonTitle(t("isisfish.input.continuePopulations")); + + inputContentUI.addPropertyChangeListener(SpeciesUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldSpeciesName.setText(""); + inputContentUI.fieldSpeciesScientificName.setText(""); + inputContentUI.fieldSpeciesCodeRubbin.setText(""); + inputContentUI.fieldSpeciesCEE.setText(""); + inputContentUI.fieldSpeciesComment.setText(""); + } + if (evt.getNewValue() != null) { + + } + } + }); + } + + protected void goTo() { + // FIXME il ne faut pas appeler le parent + // on ne sais jamais de quel type est le parent + InputUI inputUI = inputContentUI.getParentContainer(InputUI.class); + if (inputUI != null) { + if (inputContentUI.getBean() == null) { + inputUI.getHandler().setTreeSelection(inputContentUI, n("isisfish.input.tree.species"), n("isisfish.input.tree.populations")); + } + else { + inputUI.getHandler().setTreeSelection(inputContentUI, inputContentUI.getBean().getTopiaId(), n("isisfish.input.tree.populations")); + } + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesHandler.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,42 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.species; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * Species structured handler. + */ +public class SpeciesStructuredHandler extends InputContentHandler<SpeciesStructuredUI> { + + protected void init(final SpeciesStructuredUI inputContentUI) { + super.init(inputContentUI); + } + + protected void dynamicChanged() { + if (inputContentUI.getBean() != null) { + inputContentUI.getBean().setAgeGroupType(inputContentUI.fieldSpeciesDynamicAge.isSelected()); + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredHandler.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesStructuredUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric + Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -26,20 +26,20 @@ <fr.ifremer.isisfish.entities.Species id='bean' javaBean='null'/> + <SpeciesStructuredHandler id="handler" /> + <script><![CDATA[ - protected void dynamicChanged() { - if (getBean() != null) { - getBean().setAgeGroupType(fieldSpeciesDynamicAge.isSelected()); - } + protected void $afterCompleteSetup() { + handler.init(this); } - ]]> - </script> + ]]></script> + <JPanel id='body'> <Table> <row> <cell fill='horizontal' weightx='0.5'> <JRadioButton id="fieldSpeciesDynamicAge" text="isisfish.species.age" selected='{getBean().isAgeGroupType()}' - buttonGroup="structuredGroup" onItemStateChanged='dynamicChanged()' enabled='{isActive()}'/> + buttonGroup="structuredGroup" onItemStateChanged='handler.dynamicChanged()' enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='0.5'> <JRadioButton id="fieldSpeciesDynamicLength" text="isisfish.species.length" selected='{!getBean().isAgeGroupType()}' Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/species/SpeciesUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric + Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -27,15 +27,7 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Species id='bean' javaBean='null'/> - <import> - static org.nuiton.i18n.I18n.t - static org.nuiton.i18n.I18n.n - fr.ifremer.isisfish.entities.Species - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - fr.ifremer.isisfish.ui.input.InputAction - fr.ifremer.isisfish.ui.input.InputUI - </import> + <SpeciesHandler id="handler" /> <BeanValidator id='validator' bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Species' @@ -44,56 +36,16 @@ </BeanValidator> <script><![CDATA[ -protected void $afterCompleteSetup() { - setButtonTitle(t("isisfish.input.continuePopulations")); - - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldSpeciesName.setText(""); - fieldSpeciesScientificName.setText(""); - fieldSpeciesCodeRubbin.setText(""); - fieldSpeciesCEE.setText(""); - fieldSpeciesComment.setText(""); - } - if (evt.getNewValue() != null) { - - } - } - }); -} - -@Override -protected void goTo() { - // FIXME il ne faut pas appeler le parent - // on ne sais jamais de quel type est le parent - InputUI inputUI = getParentContainer(InputUI.class); - if (inputUI != null) { - if (getBean() == null) { - inputUI.getHandler().setTreeSelection(this, n("isisfish.input.tree.species"), n("isisfish.input.tree.populations")); - } - else { - inputUI.getHandler().setTreeSelection(this, getBean().getTopiaId(), n("isisfish.input.tree.populations")); - } + protected void $afterCompleteSetup() { + handler.init(this); } -} - -/*public void refresh() { - Species species = (Species)getSaveVerifier().getEntity(Species.class); - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - setBean(null); - setBean(species); - - if (getBean() != null) { - setNextPath("$root/$species/" + getBean().getTopiaId() + "/$populations"); - // Number Editor is not working - //fieldSpeciesCEE.init(); + @Override + protected void goTo() { + handler.goTo(); } -}*/ - ]]> - </script> + ]]></script> + <JPanel id='body'> <Table> <row> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,45 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.strategy; + +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * Strategy handler. + */ +public class StrategyHandler extends InputContentHandler<StrategyUI> { + + protected void init(final StrategyUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.setButtonTitle(t("isisfish.input.continueObservations")); + inputContentUI.setNextPath(n("isisfish.input.tree.observations")); + // install change listener + // (depends on sensitivity can't be done on constructor) + inputContentUI.installChangeListener(inputContentUI.strategyTab); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,93 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.strategy; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import org.nuiton.math.matrix.MatrixND; +import org.nuiton.math.matrix.gui.MatrixPanelEvent; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * Strategy handler. + */ +public class StrategyMonthInfoHandler extends InputContentHandler<StrategyMonthInfoUI> { + + protected void init(final StrategyMonthInfoUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(StrategyMonthInfoUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.setStrategyMonthInfo0(null); + inputContentUI.setStrategyMonthInfo1(null); + inputContentUI.setStrategyMonthInfo2(null); + inputContentUI.setStrategyMonthInfo3(null); + inputContentUI.setStrategyMonthInfo4(null); + inputContentUI.setStrategyMonthInfo5(null); + inputContentUI.setStrategyMonthInfo6(null); + inputContentUI.setStrategyMonthInfo7(null); + inputContentUI.setStrategyMonthInfo8(null); + inputContentUI.setStrategyMonthInfo9(null); + inputContentUI.setStrategyMonthInfo10(null); + inputContentUI.setStrategyMonthInfo11(null); + inputContentUI.fieldStrategyProportion.setMatrix(null); + } + if (evt.getNewValue() != null) { + inputContentUI.setStrategyMonthInfo0(inputContentUI.getBean().getStrategyMonthInfo().get(0)); + inputContentUI.setStrategyMonthInfo1(inputContentUI.getBean().getStrategyMonthInfo().get(1)); + inputContentUI.setStrategyMonthInfo2(inputContentUI.getBean().getStrategyMonthInfo().get(2)); + inputContentUI.setStrategyMonthInfo3(inputContentUI.getBean().getStrategyMonthInfo().get(3)); + inputContentUI.setStrategyMonthInfo4(inputContentUI.getBean().getStrategyMonthInfo().get(4)); + inputContentUI.setStrategyMonthInfo5(inputContentUI.getBean().getStrategyMonthInfo().get(5)); + inputContentUI.setStrategyMonthInfo6(inputContentUI.getBean().getStrategyMonthInfo().get(6)); + inputContentUI.setStrategyMonthInfo7(inputContentUI.getBean().getStrategyMonthInfo().get(7)); + inputContentUI.setStrategyMonthInfo8(inputContentUI.getBean().getStrategyMonthInfo().get(8)); + inputContentUI.setStrategyMonthInfo9(inputContentUI.getBean().getStrategyMonthInfo().get(9)); + inputContentUI.setStrategyMonthInfo10(inputContentUI.getBean().getStrategyMonthInfo().get(10)); + inputContentUI.setStrategyMonthInfo11(inputContentUI.getBean().getStrategyMonthInfo().get(11)); + setProportionMetierMatrix(); + } + } + }); + } + + protected void setProportionMetierMatrix() { + MatrixND prop = inputContentUI.getBean().getProportionMetier(); + if (prop != null) { + inputContentUI.fieldStrategyProportion.setMatrix(prop.copy()); + } else { + inputContentUI.fieldStrategyProportion.setMatrix(null); + } + } + + protected void strategyProportionMatrixChanged(MatrixPanelEvent event) { + MatrixND mat = inputContentUI.fieldStrategyProportion.getMatrix(); + if (inputContentUI.getBean() != null && mat != null) { + inputContentUI.getBean().setProportionMetier(mat.copy()); + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyMonthInfoUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric + Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -39,15 +39,7 @@ <fr.ifremer.isisfish.entities.StrategyMonthInfo id='strategyMonthInfo10' javaBean='null'/> <fr.ifremer.isisfish.entities.StrategyMonthInfo id='strategyMonthInfo11' javaBean='null'/> - <import> - static org.nuiton.i18n.I18n.t - org.apache.commons.lang3.StringUtils - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - static org.nuiton.i18n.I18n.t - org.nuiton.math.matrix.gui.MatrixPanelEvent - org.nuiton.math.matrix.MatrixND - </import> + <StrategyMonthInfoHandler id="handler" /> <BeanValidator id='validator' context="month" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Strategy' @@ -105,90 +97,39 @@ <fr.ifremer.isisfish.ui.input.ChangeModel id="changeModel" changed="{validator0.isChanged() || validator1.isChanged() || validator2.isChanged() || validator3.isChanged() || validator4.isChanged() || validator5.isChanged() || validator6.isChanged() || validator7.isChanged() || validator8.isChanged() || validator9.isChanged() || validator10.isChanged() || validator11.isChanged()}" valid="{validator0.isValid() && validator1.isValid() && validator2.isValid() && validator3.isValid() && validator4.isValid() && validator5.isValid() && validator6.isValid() && validator7.isValid() && validator8.isValid() && validator9.isValid() && validator10.isValid() && validator11.isValid()}" /> - - <script><![CDATA[ -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - setStrategyMonthInfo0(null); - setStrategyMonthInfo1(null); - setStrategyMonthInfo2(null); - setStrategyMonthInfo3(null); - setStrategyMonthInfo4(null); - setStrategyMonthInfo5(null); - setStrategyMonthInfo6(null); - setStrategyMonthInfo7(null); - setStrategyMonthInfo8(null); - setStrategyMonthInfo9(null); - setStrategyMonthInfo10(null); - setStrategyMonthInfo11(null); - fieldStrategyProportion.setMatrix(null); - } - if (evt.getNewValue() != null) { - setStrategyMonthInfo0(getBean().getStrategyMonthInfo().get(0)); - setStrategyMonthInfo1(getBean().getStrategyMonthInfo().get(1)); - setStrategyMonthInfo2(getBean().getStrategyMonthInfo().get(2)); - setStrategyMonthInfo3(getBean().getStrategyMonthInfo().get(3)); - setStrategyMonthInfo4(getBean().getStrategyMonthInfo().get(4)); - setStrategyMonthInfo5(getBean().getStrategyMonthInfo().get(5)); - setStrategyMonthInfo6(getBean().getStrategyMonthInfo().get(6)); - setStrategyMonthInfo7(getBean().getStrategyMonthInfo().get(7)); - setStrategyMonthInfo8(getBean().getStrategyMonthInfo().get(8)); - setStrategyMonthInfo9(getBean().getStrategyMonthInfo().get(9)); - setStrategyMonthInfo10(getBean().getStrategyMonthInfo().get(10)); - setStrategyMonthInfo11(getBean().getStrategyMonthInfo().get(11)); - setProportionMetierMatrix(); - } - } - }); -} -@Override -public void resetChangeModel() { - changeModel.setStayChanged(false); -} + <import> + org.apache.commons.lang3.StringUtils + </import> -/*@Override -public void refresh() { - //getSaveVerifier().addCurrentPanel(strategyJanuary, strategyFebuary, strategyMarch, - // strategyApril, strategyMay, strategyJune, - // strategyJuly, strategyAugust, strategySeptember, - // strategyOctober, strategyNovember, strategyDecember); -}*/ + <script><![CDATA[ + protected void $afterCompleteSetup() { + handler.init(this); + } -@Override -public void setLayer(boolean active) { - super.setLayer(active); - strategyJanuary.setLayer(active); - strategyFebuary.setLayer(active); - strategyMarch.setLayer(active); - strategyApril.setLayer(active); - strategyMay.setLayer(active); - strategyJune.setLayer(active); - strategyJuly.setLayer(active); - strategyAugust.setLayer(active); - strategySeptember.setLayer(active); - strategyOctober.setLayer(active); - strategyNovember.setLayer(active); - strategyDecember.setLayer(active); -} -protected void setProportionMetierMatrix() { - MatrixND prop = getBean().getProportionMetier(); - if (prop != null) { - fieldStrategyProportion.setMatrix(prop.copy()); + @Override + public void resetChangeModel() { + changeModel.setStayChanged(false); } - else { - fieldStrategyProportion.setMatrix(null); + + @Override + public void setLayer(boolean active) { + super.setLayer(active); + strategyJanuary.setLayer(active); + strategyFebuary.setLayer(active); + strategyMarch.setLayer(active); + strategyApril.setLayer(active); + strategyMay.setLayer(active); + strategyJune.setLayer(active); + strategyJuly.setLayer(active); + strategyAugust.setLayer(active); + strategySeptember.setLayer(active); + strategyOctober.setLayer(active); + strategyNovember.setLayer(active); + strategyDecember.setLayer(active); } -} -protected void strategyProportionMatrixChanged(MatrixPanelEvent event) { - MatrixND mat = fieldStrategyProportion.getMatrix(); - if (getBean() != null && mat != null) { - getBean().setProportionMetier(mat.copy()); - } -} ]]></script> + <JPanel id='body'> <Table constraints='BorderLayout.CENTER'> <row> @@ -253,7 +194,7 @@ <row> <cell fill='both' weightx='1' weighty='1' columns="4"> <org.nuiton.math.matrix.gui.MatrixPanelEditor id="fieldStrategyProportion" - onMatrixChanged="strategyProportionMatrixChanged(event)" + onMatrixChanged="handler.strategyProportionMatrixChanged(event)" enabled='{isActive()}' decorator='boxed' _sensitivityBean='{fr.ifremer.isisfish.entities.Strategy.class}' _sensitivityMethod='"ProportionMetier"'/> </cell> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,73 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.strategy; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import fr.ifremer.isisfish.entities.TripType; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericComboModel; + +/** + * Strategy one month info handler. + */ +public class StrategyOneMonthInfoHandler extends InputContentHandler<StrategyOneMonthInfoUI> { + + protected boolean init; + + protected void init(final StrategyOneMonthInfoUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(StrategyOneMonthInfoUI.PROPERTY_STRATEGY_MONTH_INFO, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + + } + if (evt.getNewValue() != null) { + init = true; + refresh(); + init = false; + } + } + }); + } + + protected void refresh() { + if (inputContentUI.getStrategyMonthInfo() != null) { + inputContentUI.numberOfTrips.putClientProperty("sensitivityBeanID", inputContentUI.getStrategyMonthInfo().getTopiaId()); + inputContentUI.fieldStrategyMonthInfoMinInactivityDays.putClientProperty("sensitivityBeanID", inputContentUI.getStrategyMonthInfo().getTopiaId()); + + GenericComboModel<TripType> model = new GenericComboModel<>(inputContentUI.getFisheryRegion().getTripType()); + inputContentUI.fieldStrategyMonthInfoTripType.setModel(model); + inputContentUI.fieldStrategyMonthInfoTripType.setSelectedItem(inputContentUI.getStrategyMonthInfo().getTripType()); + } + else { + // don't put in addPropertyChangeListener + // if called after, remove content :( + inputContentUI.numberOfTrips.setText(""); + inputContentUI.fieldStrategyMonthInfoMinInactivityDays.setText(""); + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyOneMonthInfoUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -31,51 +31,14 @@ <fr.ifremer.isisfish.entities.StrategyMonthInfo id='strategyMonthInfo' javaBean='null'/> - <import> - fr.ifremer.isisfish.entities.Strategy - fr.ifremer.isisfish.entities.StrategyMonthInfo - fr.ifremer.isisfish.entities.TripType - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - fr.ifremer.isisfish.ui.models.common.GenericComboModel - </import> + <StrategyOneMonthInfoHandler id="handler" /> <script><![CDATA[ -protected boolean init; - -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_STRATEGY_MONTH_INFO, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - - } - if (evt.getNewValue() != null) { - init = true; - refresh(); - init = false; - } - } - }); -} - -public void refresh() { - if (getStrategyMonthInfo() != null) { - numberOfTrips.putClientProperty("sensitivityBeanID", getStrategyMonthInfo().getTopiaId()); - fieldStrategyMonthInfoMinInactivityDays.putClientProperty("sensitivityBeanID", getStrategyMonthInfo().getTopiaId()); - - GenericComboModel<TripType> model = new GenericComboModel<>(getFisheryRegion().getTripType()); - fieldStrategyMonthInfoTripType.setModel(model); - fieldStrategyMonthInfoTripType.setSelectedItem(getStrategyMonthInfo().getTripType()); + protected void $afterCompleteSetup() { + handler.init(this); } - else { - // don't put in addPropertyChangeListener - // if called after, remove content :( - numberOfTrips.setText(""); - fieldStrategyMonthInfoMinInactivityDays.setText(""); - } -} - ]]></script> + <JPanel id="body"> <Table> <row> @@ -88,7 +51,7 @@ <JComboBox id="fieldStrategyMonthInfoTripType" genericType="fr.ifremer.isisfish.entities.TripType" onActionPerformed='getStrategyMonthInfo().setTripType((TripType)fieldStrategyMonthInfoTripType.getSelectedItem())' - renderer='{new fr.ifremer.isisfish.ui.input.renderer.TripTypeListRenderer(true)}' + renderer='{new fr.ifremer.isisfish.ui.input.triptype.TripTypeListRenderer(true)}' enabled='{isActive()}' decorator='boxed'/> </cell> </row> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,70 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.strategy; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import fr.ifremer.isisfish.entities.SetOfVessels; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericComboModel; + +/** + * Strategy tab handler. + */ +public class StrategyTabHandler extends InputContentHandler<StrategyTabUI> { + + protected boolean init; + + protected void init(final StrategyTabUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(StrategyTabUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldStrategyName.setText(""); + inputContentUI.fieldStrategyProportionSetOfVessels.setText(""); + inputContentUI.fieldStrategyComment.setText(""); + } + if (evt.getNewValue() != null) { + init = true; + setSetOfVesselsModel(); + init = false; + } + } + }); + } + + protected void setSetOfVesselsModel() { + GenericComboModel<SetOfVessels> modelVessel = new GenericComboModel<>(inputContentUI.getFisheryRegion().getSetOfVessels()); + inputContentUI.fieldStrategySetOfVessels.setModel(modelVessel); + inputContentUI.fieldStrategySetOfVessels.setSelectedItem(inputContentUI.getBean().getSetOfVessels()); + } + + protected void setOfVesselsChanged() { + if (!init) { + inputContentUI.getBean().setSetOfVessels((SetOfVessels)inputContentUI.fieldStrategySetOfVessels.getSelectedItem()); + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyTabUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -27,13 +27,7 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Strategy id='bean' javaBean='null'/> - <import> - fr.ifremer.isisfish.entities.Strategy - fr.ifremer.isisfish.entities.SetOfVessels - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - fr.ifremer.isisfish.ui.models.common.GenericComboModel - </import> + <StrategyTabHandler id="handler" /> <BeanValidator id='validator' context="basics" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Strategy' @@ -42,66 +36,11 @@ </BeanValidator> <script><![CDATA[ -protected boolean init; - -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldStrategyName.setText(""); - fieldStrategyProportionSetOfVessels.setText(""); - fieldStrategyComment.setText(""); - } - if (evt.getNewValue() != null) { - init = true; - setSetOfVesselsModel(); - init = false; - } - } - }); -} - -/*public void refresh() { - //Strategy strategy = (Strategy)getSaveVerifier().getEntity(Strategy.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - //setBean(null); - //setBean(strategy); - - if (getBean() != null) { - setSetOfVesselsModel(); - //fieldStrategyProportionSetOfVessels.init(); - - // code to replace bindings : - strategyInactivity.setActive(isActive() && getBean().isInactivityEquationUsed()); - - //getSaveVerifier().addCurrentPanel(strategyInactivity); + protected void $afterCompleteSetup() { + handler.init(this); } - else { - // listener seam to be called after refresh and remove content :( - fieldStrategyName.setText(""); - //fieldStrategyProportionSetOfVessels.setModelText("0.0"); - fieldStrategyProportionSetOfVessels.setText("0.0"); - fieldStrategyComment.setText(""); - - // code to replace bindings : - strategyInactivity.setActive(isActive()); - } -}*/ - -protected void setSetOfVesselsModel() { - GenericComboModel<SetOfVessels> modelVessel = new GenericComboModel<>(getFisheryRegion().getSetOfVessels()); - fieldStrategySetOfVessels.setModel(modelVessel); - fieldStrategySetOfVessels.setSelectedItem(getBean().getSetOfVessels()); -} - -protected void setOfVesselsChanged() { - if (!init) { - getBean().setSetOfVessels((SetOfVessels)fieldStrategySetOfVessels.getSelectedItem()); - } -} ]]></script> + <JPanel id="body"> <Table> <row> @@ -122,7 +61,7 @@ <cell fill='horizontal' weightx='1.0'> <JComboBox id="fieldStrategySetOfVessels" genericType="fr.ifremer.isisfish.entities.SetOfVessels" - onItemStateChanged='setOfVesselsChanged()' + onItemStateChanged='handler.setOfVesselsChanged()' enabled='{isActive()}' decorator='boxed'/> </cell> </row> @@ -147,7 +86,8 @@ <cell fill='horizontal' weightx='1.0'> <JCheckBox id="fieldUseEquationInactivity" selected='{getBean().isInactivityEquationUsed()}' text="isisfish.strategy.inactivityEquationUsed" - onActionPerformed='getBean().setInactivityEquationUsed(fieldUseEquationInactivity.isSelected())' enabled='{isActive()}' decorator='boxed'/> + onActionPerformed='getBean().setInactivityEquationUsed(fieldUseEquationInactivity.isSelected())' + enabled='{isActive()}' decorator='boxed'/> </cell> </row> <row> @@ -166,7 +106,8 @@ </cell> <cell fill='both' weightx='1.0' weighty='0.5'> <JScrollPane> - <JTextArea id="fieldStrategyComment" text='{jaxx.runtime.SwingUtil.getStringValue(getBean().getComment())}' onKeyReleased='getBean().setComment(fieldStrategyComment.getText())' enabled='{isActive()}' decorator='boxed'/> + <JTextArea id="fieldStrategyComment" text='{jaxx.runtime.SwingUtil.getStringValue(getBean().getComment())}' + onKeyReleased='getBean().setComment(fieldStrategyComment.getText())' enabled='{isActive()}' decorator='boxed'/> </JScrollPane> </cell> </row> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/strategy/StrategyUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric + Copyright (C) 2009 - 2015 Ifremer, Code Lutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -26,37 +26,27 @@ <fr.ifremer.isisfish.entities.Strategy id='bean' javaBean='null'/> - <import> - static org.nuiton.i18n.I18n.t - static org.nuiton.i18n.I18n.n - </import> + <StrategyHandler id="handler" /> <script><![CDATA[ -protected void $afterCompleteSetup() { - setButtonTitle(t("isisfish.input.continueObservations")); - setNextPath(n("isisfish.input.tree.observations")); - // install change listener - // (depends on sensitivity can't be done on constructor) - installChangeListener(strategyTab); -} + protected void $afterCompleteSetup() { + handler.init(this); + } -/*public void refresh() { - getSaveVerifier().addCurrentPanel(strategyMonthInfoUI, strategyTabUI); -}*/ - -@Override -public void setLayer(boolean active) { - super.setLayer(active); - strategyTabUI.setLayer(active); - strategyMonthInfoUI.setLayer(active); -} - -@Override -public void resetChangeModel() { - strategyTabUI.resetChangeModel(); - strategyMonthInfoUI.resetChangeModel(); -} + @Override + public void setLayer(boolean active) { + super.setLayer(active); + strategyTabUI.setLayer(active); + strategyMonthInfoUI.setLayer(active); + } + + @Override + public void resetChangeModel() { + strategyTabUI.resetChangeModel(); + strategyMonthInfoUI.resetChangeModel(); + } ]]></script> + <JPanel id="body"> <JTabbedPane id="strategyTab"> <tab title='isisfish.strategy.title'> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/FisheryTreeSelectionModel.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/FisheryTreeSelectionModel.java 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/FisheryTreeSelectionModel.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -23,7 +23,6 @@ package fr.ifremer.isisfish.ui.input.tree; -import javax.swing.JOptionPane; import javax.swing.tree.DefaultTreeSelectionModel; import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; @@ -104,7 +103,7 @@ // check for non validated modification InputSaveVerifier inputSaveVerifier = ui.getContextValue(InputSaveVerifier.class); - if (inputSaveVerifier.checkEdit() == JOptionPane.CANCEL_OPTION) { + if (inputSaveVerifier.checkEdit() == InputSaveVerifier.CANCEL_OPTION) { result = false; } Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,59 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.triptype; + +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +import fr.ifremer.isisfish.ui.input.InputContentHandler; + +/** + * Trip type handler. + */ +public class TripTypeHandler extends InputContentHandler<TripTypeUI> { + + protected void init(final TripTypeUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.setButtonTitle(t("isisfish.input.continueVesselTypes")); + inputContentUI.setNextPath(n("isisfish.input.tree.vesseltypes")); + + inputContentUI.addPropertyChangeListener(TripTypeUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldTripTypeName.setText(""); + inputContentUI.fieldTripTypeDuration.setText(""); + inputContentUI.fieldTripTypeMinTimeBetweenTrip.setText(""); + inputContentUI.fieldTripTypeComment.setText(""); + } + if (evt.getNewValue() != null) { + + } + } + }); + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeListRenderer.java (from rev 4226, trunk/src/main/java/fr/ifremer/isisfish/ui/input/renderer/TripTypeListRenderer.java) =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeListRenderer.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeListRenderer.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,85 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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.ifremer.isisfish.ui.input.triptype; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import fr.ifremer.isisfish.entities.TripType; + +/** + * Renderer pour liste des trip types. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class TripTypeListRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1113492654780402245L; + + /** Append trip type details. */ + protected boolean appendDetails; + + public TripTypeListRenderer() { + this(false); + } + + public TripTypeListRenderer(boolean appendDetails) { + this.appendDetails = appendDetails; + } + + /* + * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) + */ + @Override + public Component getListCellRendererComponent(JList<?> list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + // this must be used to have alternated highlight rows and default + // selection color + JLabel c = (JLabel) super.getListCellRendererComponent(list, value, + index, isSelected, cellHasFocus); + + TripType tripType = (TripType) value; + if (tripType != null) { + if (appendDetails) { + c.setText(tripType.getName() + "(" + tripType.getTripDuration() + ":" + + tripType.getMinTimeBetweenTrip() + ")"); + } else { + c.setText(tripType.getName()); + } + } + + return c; + } +} Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -27,14 +27,7 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.TripType id='bean' javaBean='null'/> - <import> - static org.nuiton.i18n.I18n.t - static org.nuiton.i18n.I18n.n - fr.ifremer.isisfish.entities.TripType - fr.ifremer.isisfish.types.TimeUnit - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - </import> + <TripTypeHandler id="handler" /> <BeanValidator id='validator' bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.TripType' @@ -42,36 +35,16 @@ <field name="name" component="fieldTripTypeName" /> </BeanValidator> + <import> + fr.ifremer.isisfish.types.TimeUnit + </import> + <script><![CDATA[ -protected void $afterCompleteSetup() { - setButtonTitle(t("isisfish.input.continueVesselTypes")); - setNextPath(n("isisfish.input.tree.vesseltypes")); + protected void $afterCompleteSetup() { + handler.init(this); + } + ]]></script> - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldTripTypeName.setText(""); - fieldTripTypeDuration.setText(""); - fieldTripTypeMinTimeBetweenTrip.setText(""); - fieldTripTypeComment.setText(""); - } - if (evt.getNewValue() != null) { - - } - } - }); -} - -/*public void refresh() { - TripType tripType = (TripType)getSaveVerifier().getEntity(TripType.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - setBean(null); - setBean(tripType); -}*/ - ]]> - </script> <JPanel id="body"> <Table> <row> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -42,6 +42,8 @@ import fr.ifremer.isisfish.entities.Variable; import fr.ifremer.isisfish.entities.VariableDAO; import fr.ifremer.isisfish.entities.VariableType; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.input.vesseltype.VesselTypeUI; import fr.ifremer.isisfish.ui.models.common.GenericListModel; /** @@ -53,28 +55,44 @@ * Last update : $Date$ * By : $Author$ */ -public class EntityVariableHandler { +public class EntityVariableHandler extends InputContentHandler<EntityVariableUI> { /** Class logger. */ private static final Log log = LogFactory.getLog(EntityVariableHandler.class); + protected void init(final EntityVariableUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.addPropertyChangeListener(EntityVariableUI.PROPERTY_BEAN, new java.beans.PropertyChangeListener() { + public void propertyChange(java.beans.PropertyChangeEvent evt) { + reloadVariables(); + } + }); + + inputContentUI.addPropertyChangeListener(EntityVariableUI.PROPERTY_VARIABLE, new java.beans.PropertyChangeListener() { + public void propertyChange(java.beans.PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.matrixPanel.setMatrix(null); + } + } + }); + } + /** * Init view with currently entity variables. - * - * @param view view */ - public void initView(EntityVariableUI view) { + protected void reloadVariables() { // clear previous - view.getVariablesList().clearSelection(); + inputContentUI.getVariablesList().clearSelection(); // fill current list List<Variable> variables = null; - GenericListModel<Variable> model = (GenericListModel<Variable>)view.getVariablesList().getModel(); - TopiaEntity bean = view.getBean(); + GenericListModel<Variable> model = (GenericListModel<Variable>)inputContentUI.getVariablesList().getModel(); + TopiaEntity bean = inputContentUI.getBean(); if (bean != null) { try { - TopiaContext context = view.getTopiaContext(); + TopiaContext context = inputContentUI.getTopiaContext(); VariableDAO dao = IsisFishDAOHelper.getVariableDAO(context); variables = dao.findAllByEntityId(bean.getTopiaId()); } catch (TopiaException ex) { @@ -83,15 +101,15 @@ // try to set entity name in label try { - String name = BeanUtils.getProperty(view.getBean(), "name"); - view.getVariableEntityName().setText(name); + String name = BeanUtils.getProperty(inputContentUI.getBean(), "name"); + inputContentUI.getVariableEntityName().setText(name); } catch (Exception ex) { if (log.isWarnEnabled()) { log.warn("Can't get entity name", ex); } } } else { - view.getVariableEntityName().setText(""); + inputContentUI.getVariableEntityName().setText(""); } model.setElementList(variables); @@ -162,20 +180,6 @@ view.setVariable(variable); view.getSaveVerifier().addCurrentEntity(variable); - /*if (variable != null) { - view.getVariableNameField().setText(variable.getName()); - - String type = variable.getType(); - view.getVariableTypeCombo().setSelectedItem(type); // fire showSelectedType - - if ("double".equals(type)) { - view.getVariableDoubleValue().setText(String.valueOf(variable.getDoubleValue())); - } else if ("matrix".equals(type)) { - //view.get - } else if ("equation".equals(type)) { - //cardLayout.show(view.getVariableTypePanel(), "equationtype"); - } - }*/ } /** @@ -228,20 +232,11 @@ break; } // equation already set by ui component - //try { - // save in db - //TopiaContext context = view.getTopiaContext(); - //VariableDAO dao = IsisFishDAOHelper.getVariableDAO(context); - //dao.update(variable); - //context.commitTransaction(); - view.getSaveVerifier().save(); + view.getSaveVerifier().save(); - // refresh ui (name change) - GenericListModel<Variable> model = (GenericListModel<Variable>)view.getVariablesList().getModel(); - List<Variable> variables = model.getElementList(); - model.setElementList(variables); - /*} catch (TopiaException ex) { - throw new IsisFishRuntimeException("Can't save variable", ex); - }*/ + // refresh ui (name change) + GenericListModel<Variable> model = (GenericListModel<Variable>)view.getVariablesList().getModel(); + List<Variable> variables = model.getElementList(); + model.setElementList(variables); } } Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -23,46 +23,31 @@ #L% --> <fr.ifremer.isisfish.ui.input.InputContentUI superGenericType='org.nuiton.topia.persistence.TopiaEntityContextable'> - <import> - static org.nuiton.i18n.I18n.t - fr.ifremer.isisfish.ui.models.common.GenericComboModel - </import> - <EntityVariableHandler id="varHandler" /> <!-- bean property --> <org.nuiton.topia.persistence.TopiaEntityContextable id='bean' javaBean='null'/> <fr.ifremer.isisfish.entities.Variable id="variable" javaBean='null' /> + + <EntityVariableHandler id="handler" /> <script><![CDATA[ protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new java.beans.PropertyChangeListener() { - public void propertyChange(java.beans.PropertyChangeEvent evt) { - varHandler.initView(EntityVariableUI.this); - } - }); - - addPropertyChangeListener(PROPERTY_VARIABLE, new java.beans.PropertyChangeListener() { - public void propertyChange(java.beans.PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - matrixPanel.setMatrix(null); - } - } - }); + handler.init(this); } ]]></script> <Table> <row> <cell fill="both" weightx='1.0' weighty='1.0'> - <Table border='{BorderFactory.createTitledBorder(t("isisfish.variables.variableslist"))}'> + <Table border='{BorderFactory.createTitledBorder(org.nuiton.i18n.I18n.t("isisfish.variables.variableslist"))}'> <row> <cell fill="both" weightx='1.0' weighty='1.0'> <JScrollPane> <JList id="variablesList" cellRenderer="{new VariableListRenderer()}" genericType='fr.ifremer.isisfish.entities.Variable' model="{new fr.ifremer.isisfish.ui.models.common.GenericListModel<Variable>()}" - onValueChanged="getVarHandler().showSelectedVariable(this)" + onValueChanged="handler.showSelectedVariable(this)" selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}" enabled='{isActive()}'/> </JScrollPane> @@ -70,14 +55,14 @@ </row> <row> <cell fill="horizontal"> - <JButton text="isisfish.variables.addvariable" onActionPerformed="getVarHandler().addNewVariable(this)" + <JButton text="isisfish.variables.addvariable" onActionPerformed="handler.addNewVariable(this)" enabled='{isActive()}' decorator='boxed' /> </cell> </row> </Table> </cell> <cell fill="both" weightx='3.0' weighty='1.0' rows="2"> - <Table border='{BorderFactory.createTitledBorder(t("isisfish.variables.variabledetail"))}'> + <Table border='{BorderFactory.createTitledBorder(org.nuiton.i18n.I18n.t("isisfish.variables.variabledetail"))}'> <row> <cell fill="horizontal"> <JLabel text="isisfish.variables.entityname" @@ -95,11 +80,8 @@ </cell> <cell fill="horizontal" weightx='1.0'> <JTextField id="variableNameField" text="{getVariable().getName()}" - enabled='{isActive() && getVariable() != null}' decorator='boxed' /> - <javax.swing.text.Document - initializer="variableNameField.getDocument()" - onInsertUpdate='getVariable().setName(variableNameField.getText())' - onRemoveUpdate='getVariable().setName(variableNameField.getText())' /> + enabled='{isActive() && getVariable() != null}' decorator='boxed' + onKeyReleased="getVariable().setName(variableNameField.getText())" /> </cell> </row> <row> @@ -108,10 +90,11 @@ enabled='{isActive() && getVariable() != null}'/> </cell> <cell fill="horizontal" weightx='1.0'> - <JComboBox id="variableTypeCombo" model="{new GenericComboModel<fr.ifremer.isisfish.entities.Variable>()}" - genericType="fr.ifremer.isisfish.entities.Variable" + <JComboBox id="variableTypeCombo" + model="{new fr.ifremer.isisfish.ui.models.common.EnumComboModel<fr.ifremer.isisfish.entities.VariableType>(fr.ifremer.isisfish.entities.VariableType.class)}" + genericType="fr.ifremer.isisfish.entities.VariableType" selectedItem="{getVariable().getType()}" - onActionPerformed="getVarHandler().showSelectedType(this)" + onActionPerformed="handler.showSelectedType(this)" enabled='{isActive() && getVariable() != null}' decorator='boxed' /> </cell> </row> @@ -121,9 +104,9 @@ <JPanel id="variableTypePanel" layout="{variableTypeLayout}"> <!-- double --> - <Table constraints='"doubletype"'> + <Table constraints='"doubletype"' insets="0"> <row> - <cell fill="horizontal" anchor="northeast" weighty='1.0'> + <cell fill="horizontal" anchor="east" weighty='1.0'> <JLabel text="isisfish.variables.double.value" enabled='{isActive() && getVariable() != null}' /> </cell> <cell fill="horizontal" weightx='1.0' anchor="northeast" weighty='1.0'> @@ -136,7 +119,7 @@ </Table> <!-- matrix --> - <Table constraints='"matrixtype"'> + <Table constraints='"matrixtype"' insets="0"> <row> <cell fill="horizontal"> <JLabel text="isisfish.variables.matrix.value" @@ -155,7 +138,7 @@ </Table> <!-- equation --> - <Table constraints='"equationtype"'> + <Table constraints='"equationtype"' insets="0"> <row> <cell fill="both" weightx='1.0' weighty='1.0'> <fr.ifremer.isisfish.ui.input.InputOneEquationUI id="variableEquationValue" @@ -181,24 +164,21 @@ <JScrollPane> <JTextArea id="variableComment" rows="3" text="{jaxx.runtime.SwingUtil.getStringValue(getVariable().getComment())}" - enabled='{isActive() && getVariable() != null}' decorator='boxed' /> - <javax.swing.text.Document - initializer="variableComment.getDocument()" - onInsertUpdate='getVariable().setComment(variableComment.getText())' - onRemoveUpdate='getVariable().setComment(variableComment.getText())' /> + enabled='{isActive() && getVariable() != null}' decorator='boxed' + onKeyReleased="getVariable().setComment(variableComment.getText())" /> </JScrollPane> </cell> </row> <row> <cell anchor="west"> <JButton text="isisfish.variables.deletevariable" - onActionPerformed="getVarHandler().deleteVariable(this)" + onActionPerformed="handler.deleteVariable(this)" enabled='{isActive() && getVariable() != null}' decorator='boxed' /> </cell> <cell anchor="east" weightx='1.0'> <JButton text="isisfish.variables.savevariable" - onActionPerformed="getVarHandler().saveVariable(this)" + onActionPerformed="handler.saveVariable(this)" enabled='{isActive() && getVariable() != null}' decorator='boxed' /> </cell> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,91 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.vesseltype; + +import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; + +import fr.ifremer.isisfish.entities.TripType; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericListModel; + +/** + * Trip type handler. + */ +public class VesselTypeHandler extends InputContentHandler<VesselTypeUI> { + + protected boolean init; + + protected void init(final VesselTypeUI inputContentUI) { + super.init(inputContentUI); + + inputContentUI.setButtonTitle(t("isisfish.input.continueSetOfVessels")); + inputContentUI.setNextPath(n("isisfish.input.tree.setofvessels")); + + inputContentUI.addPropertyChangeListener(VesselTypeUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + inputContentUI.fieldVesselTypeName.setText(""); + inputContentUI.fieldVesselTypeLength.setText(""); + inputContentUI.fieldVesselTypeSpeed.setText(""); + inputContentUI.fieldVesselTypeMaxTripDuration.setText(""); + inputContentUI.fieldVesselTypeActivityRange.setText(""); + inputContentUI.fieldVesselTypeMinCrewSize.setText(""); + inputContentUI.fieldVesselTypeSpeed.setText(""); + inputContentUI.fieldVesselTypeUnitFuelCostOfTravel.setText(""); + inputContentUI.fieldVesselTypeComment.setText(""); + } + if (evt.getNewValue() != null) { + setTripTypeListModel(); + } + } + }); + } + + protected void setTripTypeListModel() { + init = true; + List<TripType> tripTypes = inputContentUI.getFisheryRegion().getTripType(); + GenericListModel<TripType> tripTypeModel = new GenericListModel<>(tripTypes); + inputContentUI.vesselTypeTripType.setModel(tripTypeModel); + + if (inputContentUI.getBean() != null && inputContentUI.getBean().getTripType() != null) { + for (TripType tripType : inputContentUI.getBean().getTripType()) { + int index = tripTypes.indexOf(tripType); + inputContentUI.vesselTypeTripType.addSelectionInterval(index, index); + } + } + init = false; + } + protected void tripTypeChanged() { + if (!init) { + List<TripType> tripTypes = new ArrayList<>(inputContentUI.vesselTypeTripType.getSelectedValuesList()); + inputContentUI.getBean().setTripType(tripTypes); + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeHandler.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/vesseltype/VesselTypeUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -27,16 +27,7 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.VesselType id='bean' javaBean='null'/> - <import> - static org.nuiton.i18n.I18n.t - static org.nuiton.i18n.I18n.n - fr.ifremer.isisfish.entities.VesselType - fr.ifremer.isisfish.entities.TripType - fr.ifremer.isisfish.types.TimeUnit - fr.ifremer.isisfish.ui.models.common.GenericListModel - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - </import> + <VesselTypeHandler id="handler" /> <BeanValidator id='validator' bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.VesselType' @@ -44,76 +35,16 @@ <field name="name" component="fieldVesselTypeName" /> </BeanValidator> - <script><![CDATA[ -protected boolean init; + <import> + fr.ifremer.isisfish.types.TimeUnit + </import> -protected void $afterCompleteSetup() { - setButtonTitle(t("isisfish.input.continueSetOfVessels")); - setNextPath(n("isisfish.input.tree.setofvessels")); - - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldVesselTypeName.setText(""); - fieldVesselTypeLength.setText(""); - fieldVesselTypeSpeed.setText(""); - fieldVesselTypeMaxTripDuration.setText(""); - fieldVesselTypeActivityRange.setText(""); - fieldVesselTypeMinCrewSize.setText(""); - fieldVesselTypeSpeed.setText(""); - fieldVesselTypeUnitFuelCostOfTravel.setText(""); - fieldVesselTypeComment.setText(""); - } - if (evt.getNewValue() != null) { - setTripTypeListModel(); - } - } - }); -} - -/*public void refresh() { - VesselType vesselType = getSaveVerifier().getEntity(VesselType.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - setBean(null); - setBean(vesselType); - - if (getBean() != null) { - setListModel(); - - // NumberEditor is not working - //fieldVesselTypeLength.init(); - //fieldVesselTypeLength.init(); - //fieldVesselTypeSpeed.init(); - //fieldVesselTypeActivityRange.init(); - //fieldVesselTypeMinCrewSize.init(); - //fieldVesselTypeSpeed.init(); - //fieldVesselTypeUnitFuelCostOfTravel.init(); + <script><![CDATA[ + protected void $afterCompleteSetup() { + handler.init(this); } -}*/ - -protected void setTripTypeListModel() { - init = true; - List<TripType> tripTypes = getFisheryRegion().getTripType(); - GenericListModel<TripType> tripTypeModel = new GenericListModel<>(tripTypes); - vesselTypeTripType.setModel(tripTypeModel); - - if (getBean() != null && getBean().getTripType() != null) { - for (TripType tripType : getBean().getTripType()) { - int index = tripTypes.indexOf(tripType); - vesselTypeTripType.addSelectionInterval(index, index); - } - } - init = false; -} -protected void tripTypeChanged() { - if (!init) { - List<TripType> tripTypes = new ArrayList<TripType>(vesselTypeTripType.getSelectedValuesList()); - getBean().setTripType(tripTypes); - } -} ]]></script> + <JPanel id="body"> <Table> <row> @@ -214,9 +145,9 @@ </cell> <cell fill='both' weightx='1.0' weighty='0.7'> <JScrollPane> - <JList id="vesselTypeTripType" onValueChanged='tripTypeChanged()' + <JList id="vesselTypeTripType" onValueChanged='handler.tripTypeChanged()' genericType="fr.ifremer.isisfish.entities.TripType" - cellRenderer="{new fr.ifremer.isisfish.ui.input.renderer.TripTypeListRenderer()}" + cellRenderer="{new fr.ifremer.isisfish.ui.input.triptype.TripTypeListRenderer()}" enabled='{isActive()}' decorator='boxed' _sensitivityBean='{VesselType.class}' _sensitivityMethod='"TripType"'/> </JScrollPane> </cell> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsHandler.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,124 @@ +/* + * #%L + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, Codelutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.input.zone; + +import java.awt.event.MouseEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.event.ListSelectionEvent; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.bbn.openmap.event.SelectMouseMode; + +import fr.ifremer.isisfish.entities.Cell; +import fr.ifremer.isisfish.map.CellSelectionLayer; +import fr.ifremer.isisfish.map.OpenMapEvents; +import fr.ifremer.isisfish.ui.input.InputContentHandler; +import fr.ifremer.isisfish.ui.models.common.GenericListModel; + +/** + * Zone handler. + */ +public class ZoneBasicsHandler extends InputContentHandler<ZoneBasicsUI> { + + /** Class logger. */ + private static final Log log = LogFactory.getLog(ZoneBasicsHandler.class); + + protected void init(final ZoneBasicsUI zoneBasicsUI) { + super.init(zoneBasicsUI); + + new OpenMapEvents(zoneBasicsUI.zoneMap, new SelectMouseMode(false), CellSelectionLayer.MULT_SELECTION) { + @Override + public boolean mouseClicked(MouseEvent e) { + boolean result = false; + if (zoneBasicsUI.getBean() != null) { // impossible de desactiver la carte :( + zoneBasicsUI.getBean().setCell(zoneBasicsUI.zoneMap.getSelectedCells()); + setZoneCells(); + } + return result; + } + }; + + zoneBasicsUI.addPropertyChangeListener(ZoneBasicsUI.PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + zoneBasicsUI.fieldZoneName.setText(""); + zoneBasicsUI.fieldZoneComment.setText(""); + zoneBasicsUI.zoneMap.setSelectedCells(); + } + if (evt.getNewValue() != null) { + + } + setZoneCells(); + } + }); + } + + protected void setZoneCells() { + GenericListModel<Cell> zoneModel = new GenericListModel<>(); + if (inputContentUI.getBean() != null) { + + // build model + List<Cell> cells = inputContentUI.getFisheryRegion().getCell(); + zoneModel.setElementList(cells); + inputContentUI.zoneCells.setModel(zoneModel); + + // restore selection + int firstIndex = -1; + if (inputContentUI.getBean().getCell() != null) { + for (Cell selectedCell : inputContentUI.getBean().getCell()) { + int index = cells.indexOf(selectedCell); + inputContentUI.zoneCells.addSelectionInterval(index, index); + + if (firstIndex == -1) { + firstIndex = index; + } + } + } + + // sroll to visible + if (firstIndex != -1) { + inputContentUI.zoneCells.ensureIndexIsVisible(firstIndex); + } + } else { + inputContentUI.zoneCells.setModel(zoneModel); + } + } + + public void zoneCellsChange(ListSelectionEvent event) { + // sans ca, ca boucle (modification depuis la carte) + if (event.getValueIsAdjusting()) { + // pas a faie dans le cas d'une AS + if (inputContentUI.isActive()) { + List<Cell> cells = new ArrayList<>(inputContentUI.zoneCells.getSelectedValuesList()); + inputContentUI.getBean().setCell(cells); + } + } + } +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneBasicsUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -27,20 +27,7 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Zone id='bean' javaBean='null'/> - <import> - javax.swing.event.ListSelectionEvent - fr.ifremer.isisfish.entities.Cell - fr.ifremer.isisfish.entities.Zone - fr.ifremer.isisfish.map.CellSelectionLayer - fr.ifremer.isisfish.map.CopyMapToClipboardListener - fr.ifremer.isisfish.map.OpenMapEvents - fr.ifremer.isisfish.ui.models.common.GenericListModel - com.bbn.openmap.event.SelectMouseMode - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - java.awt.event.MouseEvent - java.util.ArrayList - </import> + <ZoneBasicsHandler id="handler" /> <BeanValidator id='validator' bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Zone' @@ -50,68 +37,11 @@ </BeanValidator> <script><![CDATA[ -protected void $afterCompleteSetup() { - - //zoneMap.init(zoneMapInfo); - new OpenMapEvents(zoneMap, new SelectMouseMode(false), CellSelectionLayer.MULT_SELECTION) { - @Override - public boolean mouseClicked(MouseEvent e) { - boolean result = false; - if (getBean() != null) { // impossible de desactiver la carte :( - getBean().setCell(zoneMap.getSelectedCells()); - setZoneCells(); - } - return result; - } - }; - - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - fieldZoneName.setText(""); - fieldZoneComment.setText(""); - zoneMap.setSelectedCells(); - } - if (evt.getNewValue() != null) { - - } - setZoneCells(); - } - }); -} - -protected void setZoneCells() { - GenericListModel<Cell> zoneModel = new GenericListModel<Cell>(); - if (getBean() != null) { - List<Cell> cells = getFisheryRegion().getCell(); - zoneModel.setElementList(cells); - zoneCells.setModel(zoneModel); - if (getBean().getCell() != null) { - for (Cell selectedCell : getBean().getCell()) { - int index = cells.indexOf(selectedCell); - zoneCells.addSelectionInterval(index, index); - } - } - } else { - zoneCells.setModel(zoneModel); + protected void $afterCompleteSetup() { + handler.init(this); } -} + ]]></script> -protected void zoneCellsChange(ListSelectionEvent event) { - // sans ca, ca boucle (modification depuis la carte) - if (event.getValueIsAdjusting()) { - // pas a faie dans le cas d'une AS - if (isActive()) { - List<Cell> cells = new ArrayList<Cell>(); - for (Cell o : zoneCells.getSelectedValuesList()) { - cells.add(o); - } - getBean().setCell(cells); - } - } -} -]]> - </script> <JPanel id='body'> <JSplitPane oneTouchExpandable="true" dividerLocation="200" orientation="horizontal"> <Table> @@ -138,7 +68,7 @@ <JScrollPane id="spZoneCells"> <JList id="zoneCells" enabled='{isActive()}' genericType="fr.ifremer.isisfish.entities.Cell" - onValueChanged='zoneCellsChange(event)' decorator='boxed'/> + onValueChanged='handler.zoneCellsChange(event)' decorator='boxed'/> </JScrollPane> </cell> </row> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneHandler.java 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneHandler.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -26,9 +26,6 @@ import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import fr.ifremer.isisfish.ui.input.InputContentHandler; /** @@ -36,17 +33,14 @@ */ public class ZoneHandler extends InputContentHandler<ZoneUI> { - /** Class logger. */ - private static final Log log = LogFactory.getLog(ZoneHandler.class); + protected void init(final ZoneUI inputContentUI) { + super.init(inputContentUI); - protected void init(final ZoneUI zoneUI) { - super.init(zoneUI); + inputContentUI.setButtonTitle(t("isisfish.input.continuePorts")); + inputContentUI.setNextPath(n("isisfish.input.tree.ports")); - zoneUI.setButtonTitle(t("isisfish.input.continuePorts")); - zoneUI.setNextPath(n("isisfish.input.tree.ports")); - // install change listener // (depends on sensitivity can't be done on constructor) - zoneUI.installChangeListener(zoneUI.zoneTab); + inputContentUI.installChangeListener(inputContentUI.zoneTab); } } Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneUI.jaxx 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/zone/ZoneUI.jaxx 2015-05-20 12:09:09 UTC (rev 4227) @@ -29,22 +29,22 @@ <ZoneHandler id="handler" /> <script><![CDATA[ - protected void $afterCompleteSetup() { - handler.init(this); - } + protected void $afterCompleteSetup() { + handler.init(this); + } - @Override - public void setLayer(boolean active) { - super.setLayer(active); - zoneBasicsUI.setLayer(active); - variablesUI.setLayer(active); - } - - @Override - public void resetChangeModel() { - zoneBasicsUI.resetChangeModel(); - variablesUI.resetChangeModel(); - } + @Override + public void setLayer(boolean active) { + super.setLayer(active); + zoneBasicsUI.setLayer(active); + variablesUI.setLayer(active); + } + + @Override + public void resetChangeModel() { + zoneBasicsUI.resetChangeModel(); + variablesUI.resetChangeModel(); + } ]]></script> <JPanel id="body"> Added: trunk/src/main/java/fr/ifremer/isisfish/ui/models/common/EnumComboModel.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/models/common/EnumComboModel.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/models/common/EnumComboModel.java 2015-05-20 12:09:09 UTC (rev 4227) @@ -0,0 +1,45 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, CodeLutin, Chatellier Eric + * %% + * 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.ifremer.isisfish.ui.models.common; + +import org.jdesktop.swingx.combobox.EnumComboBoxModel; + +/** + * Just a delegator class to not use external API in Isis. + * + * @author Eric Chatellier + * + * @param <E> enum type + */ +public class EnumComboModel<E extends Enum<E>> extends EnumComboBoxModel<E>{ + + /** serialVersionUID. */ + private static final long serialVersionUID = -912859822412819321L; + + public EnumComboModel(Class<E> en) { + super(en); + } + +} Property changes on: trunk/src/main/java/fr/ifremer/isisfish/ui/models/common/EnumComboModel.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/src/main/resources/i18n/isis-fish_en_GB.properties =================================================================== --- trunk/src/main/resources/i18n/isis-fish_en_GB.properties 2015-05-18 09:52:01 UTC (rev 4226) +++ trunk/src/main/resources/i18n/isis-fish_en_GB.properties 2015-05-20 12:09:09 UTC (rev 4227) @@ -990,7 +990,7 @@ isisfish.variables.variabledetail=Variable details isisfish.variables.variablename=Variable name \: isisfish.variables.variableslist=Variables -isisfish.variables.variabletype=Variable type +isisfish.variables.variabletype=Variable type \: isisfish.vcs.ask.passphrase=Enter your pass phrase (if your private key have one). isisfish.vcs.ask.passphrase.title=Ask your pass phrase isisfish.vcs.commit=vcs.commit
participants (1)
-
echatellier@users.forge.codelutin.com