Author: chatellier Date: 2009-06-08 15:37:31 +0000 (Mon, 08 Jun 2009) New Revision: 2341 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyOneMonthInfoUI.jaxx Log: Add only one matrix listener on UI (it's enough) Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyOneMonthInfoUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyOneMonthInfoUI.jaxx 2009-06-08 15:36:09 UTC (rev 2340) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyOneMonthInfoUI.jaxx 2009-06-08 15:37:31 UTC (rev 2341) @@ -34,69 +34,60 @@ import jaxx.runtime.swing.editor.NumberEditor; import fr.ifremer.isisfish.entities.TripType; -protected MatrixPanelListener matrixListener; - protected int month = 0; -protected PropertyChangeListener listener; -fieldStrategyMonthInfoProportion.addPropertyChangeListener(new PropertyChangeListener() { +matrixListener = new MatrixPanelListener() { @Override - public void propertyChange(PropertyChangeEvent evt) { - if (fieldStrategyMonthInfoProportion.getMatrix() != null) { - if (fieldStrategyMonthInfoProportion.getMatrix() != null) { - getStrategyMonthInfo().setProportionMetier(fieldStrategyMonthInfoProportion.getMatrix()); - } + public void matrixChanged(MatrixPanelEvent event) { + if (getStrategyMonthInfo() != null && fieldStrategyMonthInfoProportion.getMatrix() != null) { + log.debug("Matrix modified : " + fieldStrategyMonthInfoProportion.getMatrix()); + getStrategyMonthInfo().setProportionMetier(fieldStrategyMonthInfoProportion.getMatrix().copy()); } } -}); +}; +fieldStrategyMonthInfoProportion.addMatrixListener(matrixListener); @Override public void refresh() { Strategy strategy = (Strategy)getVerifier().getEntity(Strategy.class); - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - setBean(null); + // don't use setBean(null) here setBean((StrategyImpl)strategy); if (getBean() != null) { Object[] monthInfos = getBean().getStrategyMonthInfo().toArray(); if (monthInfos.length != 0) { + + // add null before, for second to be considered as a changed event + // otherwize, setBean has no effect + setStrategyMonthInfo(null); setStrategyMonthInfo((StrategyMonthInfoImpl) monthInfos[month]); getVerifier().addCurrentEntity(getStrategyMonthInfo()); - } - } - if (getStrategyMonthInfo() != null) { - numberOfTrips.putClientProperty("beanID", getStrategyMonthInfo().getTopiaId()); - fieldStrategyMonthInfoProportion.putClientProperty("beanID", getStrategyMonthInfo().getTopiaId()); - fieldStrategyMonthInfoMinInactivityDays.putClientProperty("beanID", getStrategyMonthInfo().getTopiaId()); - ActionListener[] listeners = fieldStrategyMonthInfoTripType.getActionListeners(); - for (ActionListener listener : listeners) { - fieldStrategyMonthInfoTripType.removeActionListener(listener); - } - jaxx.runtime.SwingUtil.fillComboBox(fieldStrategyMonthInfoTripType,getRegion().getTripType(), getStrategyMonthInfo().getTripType(), true); - for (ActionListener listener : listeners) { - fieldStrategyMonthInfoTripType.addActionListener(listener); - } - setProportionMetierMatrix(); - //fieldStrategyMonthInfoMinInactivityDays.setText( - } - else { - // don't put in addPropertyChangeListener - // if called after, remove content :( - numberOfTrips.setText(""); - fieldStrategyMonthInfoMinInactivityDays.setText(""); - fieldStrategyMonthInfoProportion.setMatrix(null); - } - matrixListener = new MatrixPanelListener() { - @Override - public void matrixChanged(MatrixPanelEvent event) { - if (getStrategyMonthInfo() != null && fieldStrategyMonthInfoProportion.getMatrix() != null) { - getStrategyMonthInfo().setProportionMetier(fieldStrategyMonthInfoProportion.getMatrix().copy()); + + if (getStrategyMonthInfo() != null) { + numberOfTrips.putClientProperty("beanID", getStrategyMonthInfo().getTopiaId()); + fieldStrategyMonthInfoProportion.putClientProperty("beanID", getStrategyMonthInfo().getTopiaId()); + fieldStrategyMonthInfoMinInactivityDays.putClientProperty("beanID", getStrategyMonthInfo().getTopiaId()); + ActionListener[] listeners = fieldStrategyMonthInfoTripType.getActionListeners(); + for (ActionListener listener : listeners) { + fieldStrategyMonthInfoTripType.removeActionListener(listener); + } + jaxx.runtime.SwingUtil.fillComboBox(fieldStrategyMonthInfoTripType,getRegion().getTripType(), getStrategyMonthInfo().getTripType(), true); + for (ActionListener listener : listeners) { + fieldStrategyMonthInfoTripType.addActionListener(listener); + } + setProportionMetierMatrix(); } + else { + // don't put in addPropertyChangeListener + // if called after, remove content :( + numberOfTrips.setText(""); + fieldStrategyMonthInfoMinInactivityDays.setText(""); + fieldStrategyMonthInfoProportion.setMatrix(null); + } } - }; - fieldStrategyMonthInfoProportion.addMatrixListener(matrixListener); + } + //fieldStrategyMonthInfoProportion.addMatrixListener(matrixListener); } @Override