Author: chatellier Date: 2009-06-04 16:29:09 +0000 (Thu, 04 Jun 2009) New Revision: 2323 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearTabUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityEditorUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx Log: Fix gear refresh UI Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearTabUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearTabUI.jaxx 2009-06-04 15:28:45 UTC (rev 2322) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearTabUI.jaxx 2009-06-04 16:29:09 UTC (rev 2323) @@ -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,64 +16,50 @@ * 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.GearImpl id='bean' javaBean='null'/> - - <script><![CDATA[ -import fr.ifremer.isisfish.types.RangeOfValues; + <script><![CDATA[ import fr.ifremer.isisfish.entities.Gear; import fr.ifremer.isisfish.entities.GearImpl; -import fr.ifremer.isisfish.ui.WelcomePanelUI; -import org.codelutin.topia.persistence.TopiaEntity; -import org.codelutin.topia.TopiaException; import jaxx.runtime.swing.editor.NumberEditor; -import jaxx.runtime.swing.navigation.NavigationTreeModel; -import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode; 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(""); fieldGearName.setText(""); fieldGearEffortUnit.setText(""); - fieldGearStandardisationFactor.setModelText(""); + fieldGearStandardisationFactor.setText(""); fieldGearParamName.setText(""); fieldGearComment.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"); + } } }); + public void refresh() { getVerifier().setSaveButton(save); getVerifier().setCancelButton(cancel); getVerifier().setNewButton(create, "Gear"); getVerifier().setDeleteButton(remove); 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); + getVerifier().addCurrentPanel(rangeOfValues); - if (getBean() != null){ + + /* chatellier commented since number editor is not working + if (getBean() != null) { fieldGearStandardisationFactor.init(); - } + }*/ } ]]> </script> @@ -104,13 +89,13 @@ <JLabel text="isisfish.gear.standardisationFactor" enabled='{isActif()}'/> </cell> <cell columns="2" fill='horizontal' weightx='1.0'> - <NumberEditor id='fieldGearStandardisationFactor' constructorParams='this' + <!--NumberEditor id='fieldGearStandardisationFactor' constructorParams='this' bean='{getBean()}' property='standardisationFactor' enabled='{isActif()}' decorator='boxed' _bean='{GearImpl.class}' - _method='"StandardisationFactor"' useSign='true'/> - <!--JTextField id="fieldGearStandardisationFactor" text='{getBean().getStandardisationFactor()}' + _method='"StandardisationFactor"' useSign='true'/--> + <JTextField id="fieldGearStandardisationFactor" text='{getBean().getStandardisationFactor()}' onKeyReleased='getBean().setStandardisationFactor(Double.parseDouble(fieldGearStandardisationFactor.getText()))' - enabled='{isActif()}' decorator='boxed' _bean='{GearImpl.class}' _method='"StandardisationFactor"'/--> + enabled='{isActif()}' decorator='boxed' _bean='{GearImpl.class}' _method='"StandardisationFactor"'/> </cell> </row> <row> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearUI.jaxx 2009-06-04 15:28:45 UTC (rev 2322) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/GearUI.jaxx 2009-06-04 16:29:09 UTC (rev 2323) @@ -23,7 +23,6 @@ import fr.ifremer.isisfish.ui.sensitivity.SensitivityTabbedPaneListener; // constructor code -getVerifier().addCurrentPanel(this); setButtonTitle(_("isisfish.input.continueMetiers")); setNextPath("$root/$metiers"); @@ -39,8 +38,12 @@ ]]></script> <JPanel id='body' layout='{new BorderLayout()}'> <JTabbedPane constraints='BorderLayout.CENTER' id="gearTab" name="Gear"> - <tab title='{_("isisfish.gear.title")}'><GearTabUI id="gearTabUI" constructorParams='this'/></tab> - <tab title='{_("isisfish.selectivity.title")}'><SelectivityUI id="selectivityUI" constructorParams='this'/></tab> + <tab title='{_("isisfish.gear.title")}'> + <GearTabUI id="gearTabUI" constructorParams='this'/> + </tab> + <tab title='{_("isisfish.selectivity.title")}'> + <SelectivityUI id="selectivityUI" constructorParams='this'/> + </tab> </JTabbedPane> </JPanel> </fr.ifremer.isisfish.ui.input.InputContentUI> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityEditorUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityEditorUI.jaxx 2009-06-04 15:28:45 UTC (rev 2322) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityEditorUI.jaxx 2009-06-04 16:29:09 UTC (rev 2323) @@ -15,7 +15,8 @@ * 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 --> @@ -26,13 +27,15 @@ <Boolean id='selectivityPopulationSelected' javaBean='false'/> <script><![CDATA[ +import javax.swing.table.DefaultTableModel; +import fr.ifremer.isisfish.entities.Equation; +import fr.ifremer.isisfish.entities.Gear; +import fr.ifremer.isisfish.entities.GearImpl; import fr.ifremer.isisfish.entities.Population; import fr.ifremer.isisfish.entities.PopulationImpl; +import fr.ifremer.isisfish.entities.Selectivity; import fr.ifremer.isisfish.entities.Species; import fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor; -import javax.swing.table.DefaultTableModel; -import fr.ifremer.isisfish.entities.Selectivity; -import fr.ifremer.isisfish.entities.Equation; import fr.ifremer.isisfish.ui.widget.editor.GenericCell; // TODO why it's commented ? to remove ? @@ -49,38 +52,29 @@ } }); -selectivityTable.addMouseListener(new MouseListener() { - +selectivityTable.addMouseListener(new MouseAdapter() { @Override - public void mouseClicked(MouseEvent e) { - } - - @Override - public void mousePressed(MouseEvent e) { - } - - @Override public void mouseReleased(MouseEvent e) { - remove.setEnabled(selectivityTable.getSelectedRow() != -1); + removeSelectivityButton.setEnabled(selectivityTable.getSelectedRow() != -1); } - - @Override - public void mouseEntered(MouseEvent e) { - } - - @Override - public void mouseExited(MouseEvent e) { - } }); public void refresh() { + + Gear 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); + if (getBean() != null) { setSelectivityTableModel(); fieldSelectivityPopulation.setModel(getSelectivityPopulationModel()); } getVerifier().addCurrentPanel(selectivityEquation); - remove.setEnabled(false); + removeSelectivityButton.setEnabled(false); } protected void setSelectivityTableModel() { @@ -89,7 +83,7 @@ public boolean isCellEditable(int row, int column) { boolean result = false; if (column > 0) { - result =true; + result = true; } return result; } @@ -106,22 +100,25 @@ equations.add(equation); } } - model.addColumn("Population", populations.toArray()); - model.addColumn("Equation", equations.toArray()); + model.addColumn(_("isisfish.common.population"), populations.toArray()); + model.addColumn(_("isisfish.common.equation"), equations.toArray()); selectivityTable.setModel(model); EquationTableEditor cellEditor = new EquationTableEditor(); selectivityTable.getColumnModel().getColumn(1).setCellEditor(cellEditor); } -protected void add() { +protected void addSelectivity() { getAction().addSelectivity((Population)getPopulation(), selectivityEquation.getEditor().getText(), getBean()); setSelectivityTableModel(); } -protected void remove() { - getAction().removeSelectivity(getBean(), (Selectivity) getBean().getPopulationSelectivity((Population) selectivityTable.getValueAt(selectivityTable.getSelectedRow(), 0))); +protected void removeSelectivity() { + Population selectedPopulation = (Population)selectivityTable.getValueAt(selectivityTable.getSelectedRow(), 0); + Selectivity selectedSelectivity = (Selectivity)getBean().getPopulationSelectivity(selectedPopulation); + getAction().removeSelectivity(getBean(), selectedSelectivity); setSelectivityTableModel(); + removeSelectivityButton.setEnabled(false); } protected DefaultComboBoxModel getSelectivityPopulationModel() { @@ -130,8 +127,8 @@ if (species != null) { selectivityPopulationModel.addElement(new GenericCell(" ", null, null)); for (Species s : species) { - if (s.getPopulation() != null){ - for (Population p : s.getPopulation()){ + if (s.getPopulation() != null) { + for (Population p : s.getPopulation()) { selectivityPopulationModel.addElement(new GenericCell(p.getName(), p, Population.class)); } } @@ -143,7 +140,7 @@ protected void selectivityChanged() { setSelectivityPopulationSelected(fieldSelectivityPopulation.getSelectedItem() != null); setPopulation((PopulationImpl) ((GenericCell) fieldSelectivityPopulation.getSelectedItem()).getValue()); - add.setEnabled(isSelectivityPopulationSelected()); + addSelectivityButton.setEnabled(isSelectivityPopulationSelected()); } ]]></script> <Table id='body'> @@ -162,7 +159,7 @@ <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> <InputOneEquationUI id='selectivityEquation' constructorParams='this' lblText='{_("isisfish.selectivity.equation")}' - bean='{getBean()}' nameEquation='Selectivity' actif='{isActif()}' + bean='{getBean()}' nameEquation='Selectivity' actif='{isActif()}' clazz='{fr.ifremer.isisfish.equation.SelectivityEquation.class}'/> </cell> </row> @@ -174,7 +171,7 @@ <Table> <row> <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id="add" text="isisfish.common.add" onActionPerformed='add()' enabled='{isActif()}'/> + <JButton id="addSelectivityButton" text="isisfish.common.add" onActionPerformed='addSelectivity()' enabled='{isActif()}'/> </cell> </row> <row> @@ -186,7 +183,7 @@ </row> <row> <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id="remove" text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActif()}'/> + <JButton id="removeSelectivityButton" text="isisfish.common.remove" onActionPerformed='removeSelectivity()' enabled='{isActif()}'/> </cell> </row> </Table> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx 2009-06-04 15:28:45 UTC (rev 2322) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx 2009-06-04 16:29:09 UTC (rev 2323) @@ -25,27 +25,18 @@ import fr.ifremer.isisfish.entities.Gear; import fr.ifremer.isisfish.entities.GearImpl; -// TODO why it's commented ? to remove ? -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"); - } - if (evt.getNewValue() != null) { - // add binding on getBean() - //jaxx.runtime.SwingUtil.applyDataBinding(get$Table0(), "fieldCellName.text", "fieldCellLongitude.text", "fieldCellLatitude.text", "fieldCellLand.selected", "fieldCellComment.text"); - } - } -}); - // refresh -public void refresh(){ +public void refresh() { getVerifier().setSaveButton(save); getVerifier().setCancelButton(cancel); - setBean(null); + Gear 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); + getVerifier().addCurrentPanel(editor); } ]]></script>