Author: chatellier Date: 2009-05-26 15:52:43 +0000 (Tue, 26 May 2009) New Revision: 2283 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx Log: Display correct distributionReproduction matrix (cut&paste ?). Refactor all UI (beautiful variables names, etc...) Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx 2009-05-26 13:58:39 UTC (rev 2282) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx 2009-05-26 15:52:43 UTC (rev 2283) @@ -28,16 +28,19 @@ <Boolean id='popSeasonInfoNotNull' javaBean='false'/> <script><![CDATA[ +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; import fr.ifremer.isisfish.entities.PopulationSeasonInfoImpl; import fr.ifremer.isisfish.types.Month; import fr.ifremer.isisfish.entities.Population; import fr.ifremer.isisfish.entities.PopulationImpl; +import fr.ifremer.isisfish.ui.widget.Interval; +import fr.ifremer.isisfish.ui.widget.IntervalPanel; +import org.codelutin.math.matrix.MatrixND; import org.codelutin.math.matrix.gui.MatrixPanelEvent; import org.codelutin.math.matrix.gui.MatrixPanelListener; -import fr.ifremer.isisfish.ui.widget.Interval; -protected MatrixPanelListener listener = null; -protected Interval interval = null; +protected MatrixPanelListener matrixPanelListener = null; +protected Interval seasonInterval = null; protected boolean init = false; /* @@ -45,19 +48,19 @@ * When first is set, last value from getPopulationSeasonInfo() * is erased by interval.getLast() default value. */ -ip.addPropertyChangeListener("first", new PropertyChangeListener() { +seasonIntervalPanel.addPropertyChangeListener("first", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (getPopulationSeasonInfo() != null) { - getPopulationSeasonInfo().setFirstMonth(new Month(interval.getFirst())); + getPopulationSeasonInfo().setFirstMonth(new Month(seasonInterval.getFirst())); } } }); -ip.addPropertyChangeListener("last", new PropertyChangeListener() { +seasonIntervalPanel.addPropertyChangeListener("last", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (getPopulationSeasonInfo() != null) { - getPopulationSeasonInfo().setLastMonth(new Month(interval.getLast())); + getPopulationSeasonInfo().setLastMonth(new Month(seasonInterval.getLast())); } } }); @@ -65,56 +68,54 @@ addPropertyChangeListener("bean", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getOldValue() != null || evt.getNewValue() == null) { - // remove previous binding on getBean() - //jaxx.runtime.SwingUtil.removeDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); fieldPopulationSeasonComment.setText(""); fieldPopulationSeasonReproductionDistribution.setMatrix(null); } if (evt.getNewValue() != null) { - // add binding on getBean() - //jaxx.runtime.SwingUtil.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); + } } }); create.addActionListener(new ActionListener() { - @Override public void actionPerformed(ActionEvent e) { getContextValue(InputAction.class).createPopulationSeasonInfo(getBean()); - setCombo(); + setPopulationSeasonInfoCombo(); } }); remove.addActionListener(new ActionListener() { - @Override public void actionPerformed(ActionEvent e) { getContextValue(InputAction.class).removePopulationSeasonInfo(getBean(), getPopulationSeasonInfo()); - setCombo(); + setPopulationSeasonInfoCombo(); } }); save.addActionListener(new ActionListener() { - @Override public void actionPerformed(ActionEvent e) { getVerifier().topiaSave(); - setCombo(); + setPopulationSeasonInfoCombo(); } }); -listener = new MatrixPanelListener() { - +matrixPanelListener = new MatrixPanelListener() { @Override - public void matrixChanged(MatrixPanelEvent arg0) { - if (getPopulationSeasonInfo() != null && fieldPopulationSeasonReproductionDistribution.getMatrix() != null){ - getPopulationSeasonInfo().setLengthChangeMatrix(fieldPopulationSeasonReproductionDistribution.getMatrix().copy()); + public void matrixChanged(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); } } }; -public void refresh(){ - if (!isActif()){ + +public void refresh() { + if (!isActif()) { setPopSeasonInfoNotNull(false); } getVerifier().setSaveButton(save, false); @@ -125,28 +126,30 @@ setBean((PopulationImpl) population); // Model instanciation - interval = new Interval(); - interval.setMin(0); - interval.setMax(11); - interval.setFirst(0); - interval.setLast(2); + seasonInterval = new Interval(); + seasonInterval.setMin(0); + seasonInterval.setMax(11); + seasonInterval.setFirst(0); + seasonInterval.setLast(2); - setCombo(); - setInterval(); + setPopulationSeasonInfoCombo(); + setSeasonInterval(); - ip.setLabelRenderer(Month.MONTH); - ip.setModel(interval); + seasonIntervalPanel.setLabelRenderer(Month.MONTH); + seasonIntervalPanel.setModel(seasonInterval); + fieldPopulationSeasonReproductionDistribution.addMatrixListener(matrixPanelListener); + if(getPopulationSeasonInfo() != null) { PopulationSeasonInfoImpl popInfo = getPopulationSeasonInfo(); setPopulationSeasonInfo(null); setPopulationSeasonInfo(popInfo); getVerifier().addCurrentEntity(getPopulationSeasonInfo()); } - fieldPopulationSeasonReproductionDistribution.addMatrixListener(listener); getVerifier().addCurrentPanel(populationSeasonSpecializedUI); } -protected void setInterval() { + +protected void setSeasonInterval() { if(getPopulationSeasonInfo() != null) { try { if (log.isDebugEnabled()) { @@ -155,23 +158,23 @@ Month firstMonth = getPopulationSeasonInfo().getFirstMonth(); if (firstMonth != null) { - interval.setFirst(firstMonth.getMonthNumber()); + seasonInterval.setFirst(firstMonth.getMonthNumber()); if (log.isDebugEnabled()) { - log.debug(" first : " + interval.getFirst()); + log.debug(" first : " + seasonInterval.getFirst()); } } else { - interval.setFirst(0); + seasonInterval.setFirst(0); } Month lastMonth = getPopulationSeasonInfo().getLastMonth(); if (lastMonth != null) { - interval.setLast(lastMonth.getMonthNumber()); + seasonInterval.setLast(lastMonth.getMonthNumber()); if (log.isDebugEnabled()) { - log.debug(" last : " + interval.getLast()); + log.debug(" last : " + seasonInterval.getLast()); } } else { - interval.setLast(3); + seasonInterval.setLast(3); } } catch (Exception e) { if (log.isErrorEnabled()) { @@ -180,29 +183,42 @@ } } } -protected void setCombo(){ - if (getBean() != null){ - jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationSeasonInfoChooser,getBean().getPopulationSeasonInfo(), getPopulationSeasonInfo(), true); + +protected void setPopulationSeasonInfoCombo() { + if (getBean() != null) { + jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationSeasonInfoChooser, + getBean().getPopulationSeasonInfo(), getPopulationSeasonInfo(), true); } } -protected void seasonGroupChanged(){ - if (getPopulationSeasonInfo() != null){ + +protected void seasonGroupChanged() { + if (getPopulationSeasonInfo() != null) { getPopulationSeasonInfo().setGroupChange(fieldPopulationSeasonGroupChange.isSelected()); } } + protected void seasonChanged(ActionEvent event) { init = true; - setPopulationSeasonInfo((PopulationSeasonInfoImpl)fieldPopulationSeasonInfoChooser.getSelectedItem()); - getVerifier().addCurrentEntity(getPopulationSeasonInfo()); + PopulationSeasonInfo seasonInfoSelected = (PopulationSeasonInfo)fieldPopulationSeasonInfoChooser.getSelectedItem(); + if (log.isDebugEnabled()) { + log.debug("Season changed : " + seasonInfoSelected); + } + setPopulationSeasonInfo((PopulationSeasonInfoImpl)seasonInfoSelected); setPopSeasonInfoNotNull(getPopulationSeasonInfo() != null); - setInterval(); - setMatrix(); + setSeasonInterval(); + setReproductionDistributionMatrix(); + //getVerifier().addCurrentEntity(getPopulationSeasonInfo()); init = false; } -protected void setMatrix(){ - fieldPopulationSeasonReproductionDistribution.setMatrix(getPopulationSeasonInfo().getLengthChangeMatrix()); + +protected void setReproductionDistributionMatrix() { + MatrixND reproductionDistribution = getPopulationSeasonInfo().getReproductionDistribution(); + fieldPopulationSeasonReproductionDistribution.setMatrix(reproductionDistribution); } -protected boolean isAgeGroupType(boolean result){ + +// TODO une methode isXXX ne prend pas de parametre +// et ne fait rien +protected boolean isAgeGroupType(boolean result) { populationSeasonSpecializedUI.setVisible(result); return result; } @@ -227,7 +243,7 @@ <JLabel text="isisfish.common.season" enabled='{isPopSeasonInfoNotNull()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <IntervalPanel id='ip' enabled='{isPopSeasonInfoNotNull()}' decorator='boxed'/> + <IntervalPanel id='seasonIntervalPanel' enabled='{isPopSeasonInfoNotNull()}' decorator='boxed'/> </cell> </row> <row> @@ -259,13 +275,15 @@ </row> <row> <cell anchor='east'> - <JLabel text="isisfish.populationSeasons.distributionSpawning" enabled='{isPopSeasonInfoNotNull()}' visible='{getPopulationSeasonInfo().getReproduction()}'/> + <JLabel text="isisfish.populationSeasons.distributionSpawning" enabled='{isPopSeasonInfoNotNull()}' + visible='{getPopulationSeasonInfo().getReproduction()}'/> </cell> <cell fill='both' weightx='1.0' weighty='0.2'> <org.codelutin.math.matrix.gui.JAXXMatrixEditor id ='fieldPopulationSeasonReproductionDistribution' - matrix='{getPopulationSeasonInfo() == null ? null : getPopulationSeasonInfo().getLengthChangeMatrix()}' enabled='{isPopSeasonInfoNotNull()}' + matrix='{getPopulationSeasonInfo() == null ? null : getPopulationSeasonInfo().getReproductionDistribution()}' + enabled='{isPopSeasonInfoNotNull()}' visible='{getPopulationSeasonInfo().getReproduction()}' - decorator='boxed' _bean='{PopulationSeasonInfoImpl.class}' _method='"LengthChangeMatrix"'/> + decorator='boxed' _bean='{PopulationSeasonInfoImpl.class}' _method='"ReproductionDistribution"'/> </cell> </row> <row>