Author: chatellier Date: 2009-05-28 17:24:56 +0000 (Thu, 28 May 2009) New Revision: 2291 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationGroupUI.jaxx Log: Remove NumberEditor (bindings are not working) Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationGroupUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationGroupUI.jaxx 2009-05-28 15:06:54 UTC (rev 2290) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationGroupUI.jaxx 2009-05-28 17:24:56 UTC (rev 2291) @@ -1,7 +1,6 @@ <!-- /* *##% - * Copyright (C) 2005 - * Ifremer, Code Lutin, Cedric Pineau, Benjamin Poussin + * 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 @@ -17,25 +16,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *##%*/ - -/* * - * IsisFish.java - * - * Created: 1 aout 2005 18:37:25 CEST - * - * @author Benjamin POUSSIN <poussin at codelutin.com> - * @version $Revision: 1312 $ - * - * Last update: $Date: 2008-08-28 10:21:07 +0200 (jeu, 28 aoû 2008) $ - * by : $Author: sletellier $ - */ --> <fr.ifremer.isisfish.ui.input.InputContentUI> <!-- bean property --> <fr.ifremer.isisfish.entities.PopulationImpl id='bean' javaBean='null'/> - <fr.ifremer.isisfish.entities.PopulationGroupImpl id='populationGroup' javaBean='null'/> <Boolean id='popGroupNotNull' javaBean='false'/> @@ -47,67 +33,73 @@ import fr.ifremer.isisfish.entities.PopulationImpl; import org.codelutin.math.matrix.AbstractMatrixND; import org.codelutin.math.matrix.MatrixND; -import jaxx.runtime.swing.editor.NumberEditor; addPropertyChangeListener("populationGroup", 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(""); fieldPopulationGroupMeanWeight.setText(""); fieldPopulationGroupPrice.setText(""); - fieldPopulationGroupReproductionRate.setModelText(""); - fieldPopulationGroupAge.setModelText(""); - fieldPopulationGroupMinLength.setModelText(""); - fieldPopulationGroupMaxLength.setModelText(""); + fieldPopulationGroupReproductionRate.setText(""); + fieldPopulationGroupAge.setText(""); + fieldPopulationGroupMinLength.setText(""); + fieldPopulationGroupMaxLength.setText(""); fieldPopulationGroupComment.setText(""); fieldPopulationGroupNaturalDeathRate.setMatrix(null); setPopGroupNotNull(false); } if (evt.getNewValue() != null) { // add binding on getBean() - //jaxx.runtime.SwingUtil.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); } } }); -public void refresh(){ - if (!isActif()){ +public void refresh() { + if (!isActif()) { setPopGroupNotNull(false); } getVerifier().setSaveButton(save); getVerifier().setCancelButton(cancel); Population population = getVerifier().getEntity(Population.class); setBean((PopulationImpl) population); - if (getBean() != null){ - if (getBean().getPopulationGroup() != null){ - jaxx.runtime.SwingUtil.fillComboBox(fieldPopulationGroupPopulationGroup,getBean().getPopulationGroup(), getPopulationGroup(), true); + if (getBean() != null) { + if (getBean().getPopulationGroup() != null) { + jaxx.runtime.SwingUtil.fillComboBox(populationGroupPopulationGroupComboBox, getBean().getPopulationGroup(), getPopulationGroup(), true); } } } -protected void setMatrix(){ - fieldPopulationGroupNaturalDeathRate.setMatrix(((AbstractMatrixND)getBean().getNaturalDeathRateMatrix()).getSubMatrixOnSemantic(0, getPopulationGroup())); + +protected void setNaturalDeathRateMatrix() { + Population population = getBean(); + AbstractMatrixND naturalDeathRateMatrix = (AbstractMatrixND)population.getNaturalDeathRateMatrix(); + + // TODO what is this code for ??? + MatrixND naturalDeathRateMatrix2 = naturalDeathRateMatrix.getSubMatrixOnSemantic(0, getPopulationGroup()); + fieldPopulationGroupNaturalDeathRate.setMatrix(naturalDeathRateMatrix2); } -protected void groupChanged(){ - if (fieldPopulationGroupPopulationGroup.getSelectedItem() != null){ - setPopulationGroup((PopulationGroupImpl)fieldPopulationGroupPopulationGroup.getSelectedItem()); - getVerifier().addCurrentEntity(getPopulationGroup()); - setMatrix(); + +/** + * Called on PopulationGroup combo box selection. + */ +protected void populationGroupChanged() { + PopulationGroup selectedPopulationGroup = (PopulationGroup)populationGroupPopulationGroupComboBox.getSelectedItem(); + if (selectedPopulationGroup != null) { + setPopulationGroup((PopulationGroupImpl)selectedPopulationGroup); + getVerifier().addCurrentEntity(selectedPopulationGroup); + setNaturalDeathRateMatrix(); + + // init number editor (not working on bindings) + /*fieldPopulationGroupReproductionRate.init(); + fieldPopulationGroupAge.init(); + fieldPopulationGroupMinLength.init(); + fieldPopulationGroupMaxLength.init();*/ + setPopGroupNotNull(true); - if (getPopulationGroup() != null){ - fieldPopulationGroupReproductionRate.init(); - fieldPopulationGroupAge.init(); - fieldPopulationGroupMinLength.init(); - fieldPopulationGroupMaxLength.init(); - } } - else{ + else { setPopGroupNotNull(false); } - - } - ]]> </script> <Table id='body'> @@ -116,7 +108,7 @@ <JLabel text="isisfish.common.populationGroup" enabled='{isActif()}'/> </cell> <cell columns='2' fill='horizontal' weightx='1.0'> - <JComboBox id='fieldPopulationGroupPopulationGroup' onActionPerformed='groupChanged()' enabled='{isActif()}'/> + <JComboBox id='populationGroupPopulationGroupComboBox' onActionPerformed='populationGroupChanged()' enabled='{isActif()}'/> </cell> </row> <row> @@ -124,7 +116,8 @@ <JLabel text="isisfish.populationGroup.meanWeigth" enabled='{isPopGroupNotNull()}'/> </cell> <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldPopulationGroupMeanWeight" text='{getPopulationGroup().getMeanWeight()}' editable='{false}' enabled='{isPopGroupNotNull()}' decorator='boxed'/> + <JTextField id="fieldPopulationGroupMeanWeight" text='{getPopulationGroup().getMeanWeight()}' + editable='{false}' enabled='{isPopGroupNotNull()}' decorator='boxed'/> </cell> </row> <row> @@ -132,7 +125,8 @@ <JLabel text="isisfish.populationGroup.price" enabled='{isPopGroupNotNull()}'/> </cell> <cell columns='2' fill='horizontal' weightx='1.0'> - <JTextField id="fieldPopulationGroupPrice" text='{getPopulationGroup().getPrice()}' editable='{false}' enabled='{isPopGroupNotNull()}' decorator='boxed'/> + <JTextField id="fieldPopulationGroupPrice" text='{getPopulationGroup().getPrice()}' + editable='{false}' enabled='{isPopGroupNotNull()}' decorator='boxed'/> </cell> </row> <row> @@ -150,13 +144,13 @@ <JLabel text="isisfish.populationGroup.reproductionRate" enabled='{isPopGroupNotNull()}'/> </cell> <cell columns='2' fill='horizontal' weightx='1.0'> - <NumberEditor id='fieldPopulationGroupReproductionRate' constructorParams='this' + <!--NumberEditor id='fieldPopulationGroupReproductionRate' constructorParams='this' bean='{getPopulationGroup()}' property='reproductionRate' useSign='true' enabled='{isPopGroupNotNull()}' decorator='boxed' - _bean='{PopulationGroupImpl.class}' _method='"ReproductionRate"'/> - <!--JTextField id="fieldPopulationGroupReproductionRate" text='{getPopulationGroup().getReproductionRate()}' + _bean='{PopulationGroupImpl.class}' _method='"ReproductionRate"'/--> + <JTextField id="fieldPopulationGroupReproductionRate" text='{getPopulationGroup().getReproductionRate()}' onKeyReleased='getPopulationGroup().setReproductionRate(Double.parseDouble(fieldPopulationGroupReproductionRate.getText()))' - enabled='{isPopGroupNotNull()}' decorator='boxed' _bean='{PopulationGroupImpl.class}' _method='"ReproductionRate"'/--> + enabled='{isPopGroupNotNull()}' decorator='boxed' _bean='{PopulationGroupImpl.class}' _method='"ReproductionRate"'/> </cell> </row> <row> @@ -164,13 +158,13 @@ <JLabel text="isisfish.populationGroup.age" enabled='{isPopGroupNotNull()}'/> </cell> <cell columns='2' fill='horizontal' weightx='1.0'> - <NumberEditor id='fieldPopulationGroupAge' constructorParams='this' + <!--NumberEditor id='fieldPopulationGroupAge' constructorParams='this' bean='{getPopulationGroup()}' property='age' useSign='true' enabled='{isPopGroupNotNull()}' decorator='boxed' - _bean='{PopulationGroupImpl.class}' _method='"Age"'/> - <!--JTextField id="fieldPopulationGroupAge" text='{getPopulationGroup().getAge()}' + _bean='{PopulationGroupImpl.class}' _method='"Age"'/--> + <JTextField id="fieldPopulationGroupAge" text='{getPopulationGroup().getAge()}' onKeyReleased='getPopulationGroup().setAge(Double.parseDouble(fieldPopulationGroupAge.getText()))' - enabled='{isPopGroupNotNull()}' decorator='boxed' _bean='{PopulationGroupImpl.class}' _method='"Age"'/--> + enabled='{isPopGroupNotNull()}' decorator='boxed' _bean='{PopulationGroupImpl.class}' _method='"Age"'/> </cell> </row> <row> @@ -178,24 +172,24 @@ <JLabel text="isisfish.populationGroup.length" enabled='{isPopGroupNotNull()}'/> </cell> <cell fill='both' weightx='0.5'> - <NumberEditor id='fieldPopulationGroupMinLength' constructorParams='this' + <!--NumberEditor id='fieldPopulationGroupMinLength' constructorParams='this' bean='{getPopulationGroup()}' property='minLength' toolTipText="minimum length" useSign='true' enabled='{isPopGroupNotNull()}' decorator='boxed' - _bean='{PopulationGroupImpl.class}' _method='"MinLength"'/> - <!--JTextField id="fieldPopulationGroupMinLength" text='{getPopulationGroup().getMinLength()}' + _bean='{PopulationGroupImpl.class}' _method='"MinLength"'/--> + <JTextField id="fieldPopulationGroupMinLength" text='{getPopulationGroup().getMinLength()}' toolTipText="minimum length" onKeyReleased='getPopulationGroup().setMinLength(Double.parseDouble(fieldPopulationGroupMinLength.getText()))' - enabled='{isPopGroupNotNull()}' decorator='boxed' _bean='{PopulationGroupImpl.class}' _method='"MinLength"'/--> + enabled='{isPopGroupNotNull()}' decorator='boxed' _bean='{PopulationGroupImpl.class}' _method='"MinLength"'/> </cell> <cell fill='both' weightx='0.5'> - <NumberEditor id='fieldPopulationGroupMaxLength' constructorParams='this' + <!--NumberEditor id='fieldPopulationGroupMaxLength' constructorParams='this' bean='{getPopulationGroup()}' property='maxLength' toolTipText="maximum length" useSign='true' enabled='{isPopGroupNotNull()}' decorator='boxed' - _bean='{PopulationGroupImpl.class}' _method='"MaxLength"'/> - <!--JTextField id="fieldPopulationGroupMaxLength" text='{getPopulationGroup().getMaxLength()}' + _bean='{PopulationGroupImpl.class}' _method='"MaxLength"'/--> + <JTextField id="fieldPopulationGroupMaxLength" text='{getPopulationGroup().getMaxLength()}' toolTipText="maximum length" onKeyReleased='getPopulationGroup().setMaxLength(Double.parseDouble(fieldPopulationGroupMaxLength.getText()))' - enabled='{isPopGroupNotNull()}' decorator='boxed' _bean='{PopulationGroupImpl.class}' _method='"MaxLength"'/--> + enabled='{isPopGroupNotNull()}' decorator='boxed' _bean='{PopulationGroupImpl.class}' _method='"MaxLength"'/> </cell> </row> <row>