Author: chatellier Date: 2009-06-08 08:23:01 +0000 (Mon, 08 Jun 2009) New Revision: 2333 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/RangeOfValuesUI.jaxx Log: Make rangeofvalues refresh working Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/RangeOfValuesUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/RangeOfValuesUI.jaxx 2009-06-05 16:29:51 UTC (rev 2332) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/RangeOfValuesUI.jaxx 2009-06-08 08:23:01 UTC (rev 2333) @@ -1,3 +1,22 @@ +<!-- +/* *##% + * Copyright (C) 2005 - 2009 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 published by the Free Software Foundation; either version 2 + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + --> <fr.ifremer.isisfish.ui.input.InputContentUI> <!-- bean property --> @@ -11,13 +30,10 @@ 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");fieldPopulationBasicsName.setText(""); fieldGearParamPossibleValue.setText(""); } if (evt.getNewValue() != null) { - // add binding on getBean() - //jaxx.runtime.SwingUtil.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); + } } }); @@ -27,17 +43,21 @@ @Override public void refresh() { Gear gear = getVerifier().getEntity(Gear.class); + + // add null before, for second to be considered as a changed event + // otherwize, setBean has no effect + setBean(null); setBean((GearImpl) gear); - java.util.List<Object> values = new ArrayList<Object>(); - for (String value : fr.ifremer.isisfish.types.RangeOfValues.getPossibleTypes()) { - values.add(value); - } + if (getBean() != null) { - if (values != null) { - init = true; - jaxx.runtime.SwingUtil.fillComboBox(fieldGearParamType, values, getBean().getPossibleValue() == null ? null : getBean().getPossibleValue().getType(), true); - init = false; + java.util.List<Object> values = new ArrayList<Object>(); + for (String value : RangeOfValues.getPossibleTypes()) { + values.add(value); } + + init = true; + jaxx.runtime.SwingUtil.fillComboBox(fieldGearParamType, values, getBean().getPossibleValue() == null ? null : getBean().getPossibleValue().getType(), true); + init = false; } } @@ -46,7 +66,7 @@ } -protected void paramChanged() { +protected void gearParamChanged() { if (fieldGearParamType.getSelectedItem() != null) { if (!init) { getBean().setPossibleValue(new RangeOfValues(fieldGearParamType.getSelectedItem().toString().concat("[" + fieldGearParamPossibleValue.getText() + "]"))); @@ -57,10 +77,10 @@ <Table id='body'> <row> <cell fill='horizontal' weightx='0.5'> - <JComboBox id="fieldGearParamType" onActionPerformed='paramChanged()' enabled='{isActif()}'/> + <JComboBox id="fieldGearParamType" onActionPerformed='gearParamChanged()' enabled='{isActif()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JTextField id="fieldGearParamPossibleValue" text='{getBean().getPossibleValue() == null ? "" : getBean().getPossibleValue().getValues()}' onKeyReleased='paramChanged()' enabled='{isActif()}'/> + <JTextField id="fieldGearParamPossibleValue" text='{getBean().getPossibleValue().getValues()}' onKeyReleased='gearParamChanged()' enabled='{isActif()}'/> </cell> </row> </Table>