r3276 - in isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input: . model renderer
Author: chatellier Date: 2011-04-20 15:36:48 +0000 (Wed, 20 Apr 2011) New Revision: 3276 Log: Refactoring model. Fix some ui (binding on validator...) Added: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/ChangeModel.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/EffortDescriptionListModel.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/GearComboModel.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/GearPopulationSelectivityModel.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierListModel.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoComboModel.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoTargetSpeciesTableModel.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/PopulationComboModel.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/PopulationSeasonInfoComboModel.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/SpeciesComboModel.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/TripTypeListModel.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/ZoneListModel.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/EffortDescriptionListRenderer.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/MetierListRenderer.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/MetierSeasonInfoComboRenderer.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/PopulationSeasonInfoComboRenderer.java isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/TripTypeListRenderer.java Removed: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesEditorUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityEditorUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/gear/ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/metier/ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/population/ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/triptype/ Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/EffortDescriptionParametersUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/EffortDescriptionUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoZoneUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierTabUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationGroupUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEmigrationUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEquationUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationImmigrationUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationMigrationUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationRecruitmentUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationZonesEditorUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/VesselTypeUI.jaxx Added: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/ChangeModel.java =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/ChangeModel.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/ChangeModel.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,110 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; + +/** + * Cette classe est utilisé pour conservé un etat de changement + * dans une UI, dans les cas ou les beans changent sur les validateurs et + * que l'etat change du validateur est reset. + * + * Elle permet aussi de se bind directement dessus (PCS); + * + * Cela permet en gros d'agregger plusieurs validateurs. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class ChangeModel { + + public static final String PROPERTY_CHANGED = "changed"; + + public static final String PROPERTY_VALID = "valid"; + + protected boolean changed; + + protected boolean valid = true; + + /** + * If {@code true} true, {@link #isChanged()} will always return true. + */ + protected boolean stayChanged = false; + + protected PropertyChangeSupport support; + + public ChangeModel() { + support = new PropertyChangeSupport(this); + } + + public boolean isChanged() { + return changed || stayChanged; + } + + public void setChanged(boolean changed) { + boolean oldValue = this.changed; + this.changed = changed; + support.firePropertyChange(PROPERTY_CHANGED, oldValue, this.changed); + } + + public boolean isValid() { + return valid; + } + + public void setValid(boolean valid) { + boolean oldValue = this.valid; + this.valid = valid; + support.firePropertyChange(PROPERTY_VALID, oldValue, this.valid); + } + + public void setStayChanged(boolean stayChanged) { + boolean oldValue = isChanged(); + this.stayChanged = stayChanged; + support.firePropertyChange(PROPERTY_CHANGED, oldValue, isChanged()); + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + support.addPropertyChangeListener(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + support.removePropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, + PropertyChangeListener listener) { + support.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(String propertyName, + PropertyChangeListener listener) { + support.removePropertyChangeListener(propertyName, listener); + } +} Property changes on: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/ChangeModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/EffortDescriptionParametersUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/EffortDescriptionParametersUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/EffortDescriptionParametersUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -33,8 +33,8 @@ fr.ifremer.isisfish.entities.EffortDescription; fr.ifremer.isisfish.entities.SetOfVessels; fr.ifremer.isisfish.types.TimeUnit; - fr.ifremer.isisfish.ui.input.setofvessels.EffortDescriptionListModel; - fr.ifremer.isisfish.ui.input.setofvessels.EffortDescriptionListRenderer; + fr.ifremer.isisfish.ui.input.model.EffortDescriptionListModel; + fr.ifremer.isisfish.ui.input.renderer.EffortDescriptionListRenderer; java.beans.PropertyChangeEvent; java.beans.PropertyChangeListener; </import> Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/EffortDescriptionUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/EffortDescriptionUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/EffortDescriptionUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -32,10 +32,10 @@ fr.ifremer.isisfish.entities.EffortDescription; fr.ifremer.isisfish.entities.SetOfVessels; fr.ifremer.isisfish.entities.Metier; - fr.ifremer.isisfish.ui.input.setofvessels.MetierListModel; - fr.ifremer.isisfish.ui.input.setofvessels.MetierListRenderer; - fr.ifremer.isisfish.ui.input.setofvessels.EffortDescriptionListModel; - fr.ifremer.isisfish.ui.input.setofvessels.EffortDescriptionListRenderer; + fr.ifremer.isisfish.ui.input.model.MetierListModel; + fr.ifremer.isisfish.ui.input.renderer.MetierListRenderer; + fr.ifremer.isisfish.ui.input.model.EffortDescriptionListModel; + fr.ifremer.isisfish.ui.input.renderer.EffortDescriptionListRenderer; java.beans.PropertyChangeEvent; java.beans.PropertyChangeListener; </import> Deleted: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesEditorUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesEditorUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesEditorUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -1,230 +0,0 @@ -<!-- - #%L - IsisFish - - $Id$ - $HeadURL$ - %% - Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric - %% - 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, see - <http://www.gnu.org/licenses/gpl-2.0.html>. - #L% - --> -<fr.ifremer.isisfish.ui.input.InputContentUI superGenericType='fr.ifremer.isisfish.entities.Metier'> - - <!-- bean property --> - <fr.ifremer.isisfish.entities.Metier id='bean' javaBean='null'/> - <fr.ifremer.isisfish.entities.MetierSeasonInfo id='metierSeasonInfo' javaBean='null'/> - - <Boolean id='metierSeasonSelected' javaBean='false'/> - <Boolean id='targetSpeciesSelected' javaBean='false'/> - - <import> - fr.ifremer.isisfish.entities.Equation; - fr.ifremer.isisfish.entities.Metier; - fr.ifremer.isisfish.entities.Species; - fr.ifremer.isisfish.entities.TargetSpecies; - fr.ifremer.isisfish.ui.input.metier.MetierSeasonInfoTargetSpeciesTableModel; - fr.ifremer.isisfish.ui.input.metier.SpeciesComboModel; - fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor; - java.beans.PropertyChangeEvent; - java.beans.PropertyChangeListener; - java.util.ArrayList - java.awt.Dimension - javax.swing.DefaultComboBoxModel - </import> - - <script><![CDATA[ - -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - setTargetSpeciesModel(); - } - if (evt.getNewValue() != null) { - setTableTargetSpeciesModel(); - } - } - }); - - addPropertyChangeListener(PROPERTY_METIER_SEASON_INFO, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getOldValue() != null || evt.getNewValue() == null) { - - } - if (evt.getNewValue() != null) { - setTargetSpeciesModel(); - remove.setEnabled(false); - setAddButton(); - - // is actif is not working for targetFactor - // maybe set to true by addCurrentPanel - targetFactor.setActive(targetSpeciesSelected); - } - } - }); -} - -public void refresh() { - //getSaveVerifier().addCurrentPanel(targetFactor); - if (getBean() != null) { - setTableTargetSpeciesModel(); - } - else { - setTargetSpeciesModel(); - } - setTargetSpeciesModel(); - remove.setEnabled(false); - setAddButton(); - - // is actif is not working for targetFactor - // maybe set to true by addCurrentPanel - targetFactor.setActive(targetSpeciesSelected); -} - -protected void setTargetSpeciesModel() { - java.util.List<Species> species = getFisheryRegion().getSpecies(); - SpeciesComboModel fieldTargetSpeciesModel = new SpeciesComboModel(species); - fieldTargetSpecies.setModel(fieldTargetSpeciesModel); -} - -protected void setTableTargetSpeciesModel() { - if (getMetierSeasonInfo() != null) { - java.util.List<TargetSpecies> targetSpecies = new ArrayList<TargetSpecies>(); - - // SpeciesTargetSpecies can be null durring region creation - if (getMetierSeasonInfo().getSpeciesTargetSpecies() != null) { - // move collection to list - // and add all entity to verifier - for (TargetSpecies oneTargetSpecies : getMetierSeasonInfo().getSpeciesTargetSpecies()) { - getSaveVerifier().addCurrentEntity(oneTargetSpecies); - targetSpecies.add(oneTargetSpecies); - } - } - - // set table model - MetierSeasonInfoTargetSpeciesTableModel model = new MetierSeasonInfoTargetSpeciesTableModel(targetSpecies); - tableTargetSpecies.setModel(model); - tableTargetSpecies.setDefaultRenderer(Equation.class, model); - tableTargetSpecies.setDefaultEditor(Equation.class, new EquationTableEditor()); - } -} - -protected void add() { - Species selectedSpecies = (Species)fieldTargetSpecies.getSelectedItem(); - if (getMetierSeasonInfo() != null && selectedSpecies != null) { - // il n'y en a pas a la creaion de la base - //Formule selectedFormule = (Formule)targetFactor.getFormuleComboBox().getSelectedItem(); - getContextValue(InputAction.class).addTargetSpecies( - getBean(), - getMetierSeasonInfo(), - selectedSpecies, - targetFactor.getEditor().getText(), - fieldPrimaryCatch.isSelected()); - setTableTargetSpeciesModel(); - } -} - -protected void remove() { - if (isMetierSeasonSelected()) { - // TODO change delete selected truc from model - Object[] targetSpecies = getMetierSeasonInfo().getSpeciesTargetSpecies().toArray(); - - Object o = targetSpecies[tableTargetSpecies.getSelectedRow()]; - if (o != null) { - TargetSpecies ts = (TargetSpecies)o; - getAction().removeTargetSpecies(getMetierSeasonInfo(), ts); - setTableTargetSpeciesModel(); - } - } -} - -protected void targetSpeciesChanged() { - setTargetSpeciesSelected(fieldTargetSpecies.getSelectedItem() != null); - setTableTargetSpeciesModel(); - setAddButton(); -} - -protected void setAddButton() { - add.setEnabled(isMetierSeasonSelected() && isTargetSpeciesSelected()); -} - ]]></script> - <JPanel id="body"> - <Table> - <row> - <cell fill='both' weightx='1.0' weighty='0.5'> - <Table> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.metierSeasonInfoSpecies.selectSpecies" - enabled='{isMetierSeasonSelected()}' decorator='boxed'/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldTargetSpecies" onActionPerformed='targetSpeciesChanged()' - enabled='{isMetierSeasonSelected()}' decorator='boxed'/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> - <InputOneEquationUI id='targetFactor' constructorParams='this' - active='{isTargetSpeciesSelected()}' - text='isisfish.metierSeasonInfoSpecies.targetFactor' - bean='{getMetierSeasonInfo()}' formuleCategory='TargetFactor' - clazz='{fr.ifremer.isisfish.equation.TargetSpeciesTargetFactorEquation.class}' - decorator='boxed' _sensitivityBean='{Metier.class}' _sensitivityMethod='""'/> - </cell> - </row> - <row> - <cell fill='horizontal'> - <JPanel/> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JCheckBox id="fieldPrimaryCatch" text="isisfish.metierSeasonInfoSpecies.mainSpecies" - enabled='{isTargetSpeciesSelected()}' decorator='boxed'/> - </cell> - </row> - </Table> - </cell> - </row> - <row> - <cell fill='both' weightx='1.0' weighty='0.5'> - <Table> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id="add" text="isisfish.common.add" onActionPerformed='add()' - enabled='{isMetierSeasonSelected()}' decorator='boxed'/> - </cell> - </row> - <row> - <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> - <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <JTable id="tableTargetSpecies" rowHeight='24' enabled='{isMetierSeasonSelected()}' decorator='boxed' - onMouseReleased="remove.setEnabled(tableTargetSpecies.getSelectedRow() != -1)"/> - </JScrollPane> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id="remove" text="isisfish.common.remove" - onActionPerformed='remove()' enabled='false' decorator='boxed'/> - </cell> - </row> - </Table> - </cell> - </row> - </Table> - </JPanel> -</fr.ifremer.isisfish.ui.input.InputContentUI> Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoSpeciesUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -29,22 +29,33 @@ <fr.ifremer.isisfish.entities.MetierSeasonInfo id='metierSeasonInfo' javaBean='null'/> - <Boolean id='metierSeasonInfoSelected' javaBean='false'/> + <fr.ifremer.isisfish.entities.Species id='species' javaBean='null'/> <import> - fr.ifremer.isisfish.entities.Metier; fr.ifremer.isisfish.entities.MetierSeasonInfo; - fr.ifremer.isisfish.ui.input.metier.MetierSeasonInfoComboModel; - java.beans.PropertyChangeEvent; - java.beans.PropertyChangeListener; + fr.ifremer.isisfish.ui.input.model.MetierSeasonInfoComboModel; + fr.ifremer.isisfish.entities.Equation; + fr.ifremer.isisfish.entities.Metier; + fr.ifremer.isisfish.entities.Species; + fr.ifremer.isisfish.entities.TargetSpecies; + fr.ifremer.isisfish.ui.input.model.MetierSeasonInfoTargetSpeciesTableModel; + fr.ifremer.isisfish.ui.input.model.SpeciesComboModel; + fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor; + java.beans.PropertyChangeEvent; + java.beans.PropertyChangeListener; + java.util.ArrayList + java.awt.Dimension javax.swing.DefaultComboBoxModel </import> - <BeanValidator id='validator' context="seasonspecies" - bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Metier' + <BeanValidator id='validator' context="metier" + bean='{getMetierSeasonInfo()}' beanClass='fr.ifremer.isisfish.entities.MetierSeasonInfo' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> </BeanValidator> + <ChangeModel id="changeModel" changed="{validator.isChanged()}" + valid="{validator.isValid()}" /> + <script><![CDATA[ protected void $afterCompleteSetup() { @@ -53,57 +64,94 @@ if (evt.getNewValue() == null) { DefaultComboBoxModel seasonModel = new DefaultComboBoxModel(); fieldMetierSeasonInfo.setModel(seasonModel); + setMetierSeasonInfo(null); + setSpecies(null); } if (evt.getNewValue() != null) { setSeasonModel(); + setTargetSpeciesModel(); } } }); } -/*public void refresh() { - //Metier metier = getSaveVerifier().getEntity(Metier.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - //setBean(null); - //setBean(metier); - - getVerifier().addCurrentPanel(metierSeasonInfoSpeciesEditor); - if (getBean() != null) { - setSeasonModel(); - } - else { - DefaultComboBoxModel seasonModel = new DefaultComboBoxModel(); - fieldMetierSeasonInfo.setModel(seasonModel); - } -}*/ - -protected void setSeasonModel(){ +protected void setSeasonModel() { java.util.List<MetierSeasonInfo> metierSeasonInfo = getBean().getMetierSeasonInfo(); MetierSeasonInfoComboModel seasonModel = new MetierSeasonInfoComboModel(metierSeasonInfo); fieldMetierSeasonInfo.setModel(seasonModel); - - // fix refresh() problem false, because first is null - setMetierSeasonInfoSelected(false); } + protected void metierSeasonInfoChanged() { MetierSeasonInfo selectedMSI = (MetierSeasonInfo)fieldMetierSeasonInfo.getSelectedItem(); - setMetierSeasonInfoSelected( selectedMSI != null); - if (isMetierSeasonInfoSelected()) { - if (log.isDebugEnabled()) { - log.debug("Metier season changed : " + selectedMSI); - } - setMetierSeasonInfo(selectedMSI); + setMetierSeasonInfo(selectedMSI); + if (selectedMSI != null) { getSaveVerifier().addCurrentEntity(getMetierSeasonInfo()); + setTableTargetSpeciesModel(); } - metierSeasonInfoSpeciesEditor.refresh(); } - at Override -public void setLayer(boolean active) { - super.setLayer(active); - metierSeasonInfoSpeciesEditor.setLayer(active); + +protected void setTargetSpeciesModel() { + java.util.List<Species> species = getFisheryRegion().getSpecies(); + SpeciesComboModel fieldTargetSpeciesModel = new SpeciesComboModel(species); + fieldTargetSpecies.setModel(fieldTargetSpeciesModel); } + +protected void speciesChanged() { + Species species = (Species)fieldTargetSpecies.getSelectedItem(); + setSpecies(species); +} + +protected void setTableTargetSpeciesModel() { + List<TargetSpecies> targetSpecies = new ArrayList<TargetSpecies>(); + + // SpeciesTargetSpecies can be null durring region creation + if (getMetierSeasonInfo().getSpeciesTargetSpecies() != null) { + // move collection to list + // and add all entity to verifier + for (TargetSpecies oneTargetSpecies : getMetierSeasonInfo().getSpeciesTargetSpecies()) { + targetSpecies.add(oneTargetSpecies); + getSaveVerifier().addCurrentEntity(oneTargetSpecies); + oneTargetSpecies.addPropertyChangeListener(new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + changeModel.setStayChanged(true); + } + }); + } + } + + // set table model + MetierSeasonInfoTargetSpeciesTableModel model = new MetierSeasonInfoTargetSpeciesTableModel(targetSpecies); + tableTargetSpecies.setModel(model); + tableTargetSpecies.setDefaultRenderer(Equation.class, model); + tableTargetSpecies.setDefaultEditor(Equation.class, new EquationTableEditor()); +} + +protected void add() { + Species selectedSpecies = (Species)fieldTargetSpecies.getSelectedItem(); + if (selectedSpecies != null) { + // il n'y en a pas a la creation de la base + //Formule selectedFormule = (Formule)targetFactor.getFormuleComboBox().getSelectedItem(); + getContextValue(InputAction.class).addTargetSpecies( + getBean(), + getMetierSeasonInfo(), + selectedSpecies, + targetFactor.getEditor().getText(), + fieldPrimaryCatch.isSelected()); + setTableTargetSpeciesModel(); + } +} + +protected void remove() { + // TODO change delete selected truc from model + Object[] targetSpecies = getMetierSeasonInfo().getSpeciesTargetSpecies().toArray(); + + Object o = targetSpecies[tableTargetSpecies.getSelectedRow()]; + if (o != null) { + TargetSpecies ts = (TargetSpecies)o; + getAction().removeTargetSpecies(getMetierSeasonInfo(), ts); + setTableTargetSpeciesModel(); + } +} ]]></script> <JPanel id="body"> <Table> @@ -111,22 +159,65 @@ <cell columns="2" fill='both' weightx='1.0' weighty='0.5'> <Table> <row> - <cell fill='horizontal' anchor='east'> + <cell fill='horizontal'> <JLabel text="isisfish.metierSeasonInfoSpecies.selectSeason" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldMetierSeasonInfo" onActionPerformed='metierSeasonInfoChanged()' - renderer="{new fr.ifremer.isisfish.ui.input.metier.MetierSeasonInfoComboRenderer()}" enabled='{isActive()}'/> + <JComboBox id="fieldMetierSeasonInfo" onItemStateChanged='metierSeasonInfoChanged()' + renderer="{new fr.ifremer.isisfish.ui.input.renderer.MetierSeasonInfoComboRenderer()}" enabled='{isActive()}'/> </cell> </row> <row> + <cell fill='horizontal'> + <JLabel text="isisfish.metierSeasonInfoSpecies.selectSpecies" + enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldTargetSpecies" onItemStateChanged='speciesChanged()' + enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/> + </cell> + </row> + <row> <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> - <MetierSeasonInfoSpeciesEditorUI id='metierSeasonInfoSpeciesEditor' constructorParams='this' - bean='{getBean()}' metierSeasonInfo='{getMetierSeasonInfo()}' metierSeasonSelected='{isMetierSeasonInfoSelected()}' - active='{isActive()}' - _sensitivityBean='{MetierSeasonInfo.class}' _sensitivityMethod='"SpeciesTargetSpecies"'/> + <InputOneEquationUI id='targetFactor' constructorParams='this' + active='{isActive() && getMetierSeasonInfo() != null}' + text='isisfish.metierSeasonInfoSpecies.targetFactor' + bean='{getMetierSeasonInfo()}' formuleCategory='TargetFactor' + clazz='{fr.ifremer.isisfish.equation.TargetSpeciesTargetFactorEquation.class}' + decorator='boxed'/> </cell> </row> + <row> + <cell fill='horizontal'> + <JPanel/> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JCheckBox id="fieldPrimaryCatch" text="isisfish.metierSeasonInfoSpecies.mainSpecies" + enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JButton id="add" text="isisfish.common.add" onActionPerformed='add()' + enabled='{getMetierSeasonInfo() != null && getSpecies() != null}' decorator='boxed'/> + </cell> + </row> + <row> + <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> + <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> + <JTable id="tableTargetSpecies" rowHeight='24' enabled='{getMetierSeasonInfo() != null}' + decorator='boxed'/> + <ListSelectionModel initializer="tableTargetSpecies.getSelectionModel()" + onValueChanged="remove.setEnabled(tableTargetSpecies.getSelectedRow() != -1)" /> + </JScrollPane> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JButton id="remove" text="isisfish.common.remove" + onActionPerformed='remove()' enabled='false' decorator='boxed'/> + </cell> + </row> </Table> </cell> </row> @@ -134,13 +225,13 @@ <cell fill='horizontal' weightx='0.5'> <JButton id='save' decorator='boxed' text="isisfish.common.save" - enabled="{validator.isValid() && validator.isChanged()}" - onActionPerformed="getSaveVerifier().save();validator.setChanged(false);"/> + enabled="{changeModel.isValid() && changeModel.isChanged()}" + onActionPerformed="getSaveVerifier().save();validator.setChanged(false);changeModel.setStayChanged(false);"/> </cell> <cell fill='horizontal' weightx='0.5'> <JButton id='cancel' decorator='boxed' text="isisfish.common.cancel" - enabled="{validator.isChanged()}" + enabled="{changeModel.isChanged()}" onActionPerformed="getSaveVerifier().cancel()"/> </cell> </row> Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoZoneUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoZoneUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierSeasonInfoZoneUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -35,7 +35,8 @@ fr.ifremer.isisfish.entities.Season; fr.ifremer.isisfish.entities.Zone; fr.ifremer.isisfish.types.Month; - fr.ifremer.isisfish.ui.input.metier.MetierSeasonInfoComboModel; + fr.ifremer.isisfish.ui.input.model.MetierSeasonInfoComboModel; + fr.ifremer.isisfish.ui.input.model.ZoneListModel; fr.ifremer.isisfish.ui.widget.Interval; fr.ifremer.isisfish.ui.widget.IntervalPanel; java.beans.PropertyChangeEvent; @@ -43,12 +44,20 @@ java.util.ArrayList java.awt.Dimension </import> - - <BeanValidator id='validator' context="seasonzones" + + <BeanValidator id='validator' context="metier" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Metier' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> </BeanValidator> + <BeanValidator id='validatorSeason' context="metier" + bean='{getMetierSeasonInfo()}' beanClass='fr.ifremer.isisfish.entities.MetierSeasonInfo' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> + </BeanValidator> + + <ChangeModel id="changeModel" changed="{validator.isChanged() || validatorSeason.isChanged()}" + valid="{validator.isValid() && validatorSeason.isValid()}" /> + <script><![CDATA[ protected Interval interval = null; @@ -173,7 +182,16 @@ for (ListSelectionListener listener : listeners) { metierZones.removeListSelectionListener(listener); } - metierZones.fillList(getFisheryRegion().getZone(), getMetierSeasonInfo().getZone()); + + List<Zone> allZones = getFisheryRegion().getZone(); + ZoneListModel model = new ZoneListModel(allZones); + metierZones.setModel(model); + // restore selection + for (Zone zone : metierSeasonInfo.getZone()) { + int index = allZones.indexOf(zone); + metierZones.getSelectionModel().addSelectionInterval(index, index); + } + for (ListSelectionListener listener : listeners) { metierZones.addListSelectionListener(listener); } @@ -214,8 +232,8 @@ <JLabel text="isisfish.metierSeasonInfoZone.selectSeason" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JComboBox id="metierSeasonInfoCombo" onItemStateChanged='seasonChanged()' enabled='{isActive()}' - renderer="{new fr.ifremer.isisfish.ui.input.metier.MetierSeasonInfoComboRenderer()}" /> + <JComboBox id="metierSeasonInfoCombo" onItemStateChanged='seasonChanged()' enabled='{isActive() && !changeModel.isChanged()}' + renderer="{new fr.ifremer.isisfish.ui.input.renderer.MetierSeasonInfoComboRenderer()}" /> </cell> </row> <row> @@ -232,7 +250,7 @@ </cell> <cell fill='both' weightx='1.0' weighty='0.7'> <JScrollPane minimumSize='{new Dimension(0,0)}' preferredSize='{new Dimension(0,0)}'> - <JAXXList id="metierZones" onValueChanged='metierZonesChanged()' + <JList id="metierZones" onValueChanged='metierZonesChanged()' enabled='{getMetierSeasonInfo() != null}' decorator='boxed'/> </JScrollPane> </cell> @@ -260,13 +278,13 @@ <cell fill='horizontal' weightx='0.5'> <JButton id='save' decorator='boxed' text="isisfish.common.save" - enabled="{validator.isValid() && validator.isChanged()}" - onActionPerformed="save();validator.setChanged(false);"/> + enabled="{changeModel.isValid() && changeModel.isChanged()}" + onActionPerformed="save();validator.setChanged(false);validatorSeason.setChanged(false);"/> </cell> <cell fill='horizontal' weightx='0.5'> <JButton id='cancel' decorator='boxed' text="isisfish.common.cancel" - enabled="{validator.isChanged()}" + enabled="{changeModel.isChanged()}" onActionPerformed="getSaveVerifier().cancel()"/> </cell> </row> @@ -274,7 +292,7 @@ <cell fill='horizontal' weightx='0.5'> <JButton id='create' decorator='boxed' text="isisfish.common.new" - enabled="{!validator.isChanged()}" + enabled="{!changeModel.isChanged()}" onActionPerformed="create()"/> </cell> <cell fill='horizontal' weightx='0.5'> Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierTabUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierTabUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/MetierTabUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -30,6 +30,7 @@ <import> fr.ifremer.isisfish.entities.Gear; fr.ifremer.isisfish.entities.Metier; + fr.ifremer.isisfish.ui.input.model.GearComboModel; java.beans.PropertyChangeEvent; java.beans.PropertyChangeListener; java.awt.Dimension @@ -42,8 +43,6 @@ </BeanValidator> <script><![CDATA[ - - protected boolean init = false; protected void $afterCompleteSetup() { @@ -54,7 +53,9 @@ } if (evt.getNewValue() != null) { init = true; - jaxx.runtime.SwingUtil.fillComboBox(fieldMetierGear, getFisheryRegion().getGear(), getBean().getGear(), true); + GearComboModel model = new GearComboModel(getFisheryRegion().getGear()); + fieldMetierGear.setModel(model); + model.setSelectedItem(bean.getGear()); init = false; } } @@ -101,7 +102,7 @@ <JLabel text="isisfish.common.gear" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JAXXComboBox id="fieldMetierGear" onActionPerformed='gearChanged()' + <JComboBox id="fieldMetierGear" onItemStateChanged='gearChanged()' enabled='{isActive()}' decorator='boxed'/> </cell> </row> Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationGroupUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationGroupUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationGroupUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -57,7 +57,7 @@ addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getNewValue() == null) { - + setPopulationGroup(null); } if (evt.getNewValue() != null) { if (getBean().getPopulationGroup() != null) { @@ -120,8 +120,8 @@ */ protected void populationGroupChanged() { PopulationGroup selectedPopulationGroup = (PopulationGroup)populationGroupPopulationGroupComboBox.getSelectedItem(); + setPopulationGroup(selectedPopulationGroup); if (selectedPopulationGroup != null) { - setPopulationGroup(selectedPopulationGroup); getSaveVerifier().addCurrentEntity(selectedPopulationGroup); setNaturalDeathRateMatrix(); Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEmigrationUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEmigrationUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEmigrationUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -61,8 +61,8 @@ public void init(PopulationSeasonInfo pi){ // add null before, for second to be considered as a changed event // otherwize, setBean has no effect - setPopInfo(null); - setPopInfo(pi); + //setPopInfo(null); + //setPopInfo(pi); populationMigrationEmigrationTable.setMatrix(getPopInfo().getEmigrationMatrix().copy()); } Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEquationUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEquationUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationEquationUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -26,6 +26,7 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/> + <fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/> <import> @@ -37,8 +38,8 @@ public void init(PopulationSeasonInfo populationSeasonInfo) { // add null before, for second to be considered as a changed event // otherwize, setBean has no effect - setPopInfo(null); - setPopInfo(populationSeasonInfo); + //setPopInfo(null); + //setPopInfo(populationSeasonInfo); } /*public void refresh() { Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationImmigrationUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationImmigrationUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationImmigrationUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -67,8 +67,8 @@ public void init(PopulationSeasonInfo populationSeasonInfo) { // add null before, for second to be considered as a changed event // otherwize, setBean has no effect - setPopInfo(null); - setPopInfo(populationSeasonInfo); + //setPopInfo(null); + //setPopInfo(populationSeasonInfo); populationMigrationImmigrationTable.setMatrix(getPopInfo().getImmigrationMatrix().copy()); } Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationMigrationUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationMigrationUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationMigrationUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -44,6 +44,7 @@ java.beans.PropertyChangeEvent; java.beans.PropertyChangeListener; org.nuiton.math.matrix.gui.MatrixPanelListener; + javax.swing.text.Document </import> <script><![CDATA[ @@ -54,7 +55,7 @@ populationMigrationMigrationTable.setMatrix(null); } if (evt.getNewValue() != null) { - + refreshPanel(); } } }); @@ -68,8 +69,8 @@ public void init(PopulationSeasonInfo pi) { // add null before, for second to be considered as a changed event // otherwize, setBean has no effect - setPopInfo(null); - setPopInfo(pi); + //setPopInfo(null); + //setPopInfo(pi); if (getPopInfo() != null && getPopInfo().getMigrationMatrix() != null){ populationMigrationMigrationTable.setMatrix(getPopInfo().getMigrationMatrix().copy()); @@ -91,8 +92,8 @@ //populationMigrationMigrationTable.addMatrixListener(listener); - remove.setEnabled(false); - setAddButton(); + //remove.setEnabled(false); + //setAddButton(); } protected void setFieldPopulationMigrationMigrationGroupChooserModel(){ if (getBean() != null && getBean().getPopulationGroup() != null){ @@ -128,7 +129,7 @@ getPopInfo().setMigrationMatrix(mat); remove.setEnabled(false); } -protected void groupChanged(){ +/*protected void groupChanged(){ setGPopSelected(fieldPopulationMigrationMigrationGroupChooser.getSelectedItem() != null); setAddButton(); } @@ -143,10 +144,14 @@ protected void zoneArrivalChanged(){ setZoneArrivalSelected(fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem() != null); setAddButton(); +}*/ +protected void setAddButton() { + add.setEnabled(isActive() && + fieldPopulationMigrationMigrationGroupChooser.getSelectedItem() != null && + !fieldPopulationMigrationMigrationCoefficient.getText().equals("") && + fieldPopulationMigrationMigrationDepartureZoneChooser.getSelectedItem() != null && + fieldPopulationMigrationMigrationArrivalZoneChooser.getSelectedItem() != null); } -protected void setAddButton(){ - add.setEnabled(getGPopSelected() && getZoneDepartSelected() && getZoneArrivalSelected() && getCoefNonVide()); -} ]]> </script> <JPanel id="body"> @@ -156,13 +161,17 @@ <JLabel text="isisfish.common.populationGroup" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JAXXComboBox id="fieldPopulationMigrationMigrationGroupChooser" enabled='{isActive()}' onActionPerformed='groupChanged()'/> + <JAXXComboBox id="fieldPopulationMigrationMigrationGroupChooser" enabled='{isActive()}' + onItemStateChanged="setAddButton()"/> </cell> <cell> <JLabel text="isisfish.populationMigrationMigration.coefficient" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JTextField id="fieldPopulationMigrationMigrationCoefficient" enabled='{isActive()}' onKeyReleased='coefChanged()'/> + <JTextField id="fieldPopulationMigrationMigrationCoefficient" enabled='{isActive()}'/> + <Document initializer="fieldPopulationMigrationMigrationCoefficient.getDocument()" + onInsertUpdate='setAddButton()' + onRemoveUpdate='setAddButton()' /> </cell> </row> <row> @@ -170,18 +179,20 @@ <JLabel text="isisfish.populationMigrationMigration.departureZone" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JAXXComboBox id="fieldPopulationMigrationMigrationDepartureZoneChooser" enabled='{isActive()}' onActionPerformed='zoneDepartueChanged()'/> + <JAXXComboBox id="fieldPopulationMigrationMigrationDepartureZoneChooser" enabled='{isActive()}' + onItemStateChanged="setAddButton()"/> </cell> <cell> <JLabel text="isisfish.populationMigrationMigration.arrivalZone" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JAXXComboBox id="fieldPopulationMigrationMigrationArrivalZoneChooser" enabled='{isActive()}' onActionPerformed='zoneArrivalChanged()'/> + <JAXXComboBox id="fieldPopulationMigrationMigrationArrivalZoneChooser" enabled='{isActive()}' + onItemStateChanged="setAddButton()"/> </cell> </row> <row columns='4'> <cell fill='horizontal' weightx='1.0'> - <JButton id="add" text="isisfish.common.add" onActionPerformed='add()' enabled='{isActive()}'/> + <JButton id="add" text="isisfish.common.add" onActionPerformed='add()' enabled='false'/> </cell> </row> <row columns='4'> @@ -189,12 +200,12 @@ <org.nuiton.math.matrix.gui.MatrixPanelEditor id ='populationMigrationMigrationTable' linearModel='{true}' enabled='{isActive()}' onMatrixChanged="populationMigrationMigrationMatrixChanged(event)" - onMouseReleased="remove.setEnabled(populationMigrationMigrationTable.getTable().getSelectedRow() != -1)"/> + onMouseReleased="remove.setEnabled(isActive() && populationMigrationMigrationTable.getTable().getSelectedRow() != -1)"/> </cell> </row> <row> <cell columns='4' fill='horizontal' weightx='1.0'> - <JButton id="remove" text="isisfish.common.remove" onActionPerformed='remove()' enabled='{isActive()}'/> + <JButton id="remove" text="isisfish.common.remove" onActionPerformed='remove()' /> </cell> </row> </Table> Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -26,15 +26,14 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Population id='bean' javaBean='null'/> - <fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/> - <Boolean id="selectedPopulationSeasonInfo" javaBean='false' /> + <fr.ifremer.isisfish.entities.PopulationSeasonInfo id='popInfo' javaBean='null'/> <import> fr.ifremer.isisfish.entities.PopulationSeasonInfo; fr.ifremer.isisfish.entities.Population; - fr.ifremer.isisfish.ui.input.population.PopulationSeasonInfoComboModel; - fr.ifremer.isisfish.ui.input.population.PopulationSeasonInfoComboRenderer; + fr.ifremer.isisfish.ui.input.model.PopulationSeasonInfoComboModel; + fr.ifremer.isisfish.ui.input.renderer.PopulationSeasonInfoComboRenderer; java.beans.PropertyChangeEvent; java.beans.PropertyChangeListener; java.awt.CardLayout @@ -88,13 +87,6 @@ else { model.setPopulationSeasonInfos(null); } - - //getSaveVerifier().addCurrentPanel(populationMigrationEquationUI, populationMigrationMigrationUI, populationMigrationImmigrationUI, populationMigrationEmigrationUI); - // addCurrentPanel set all to isActive() - // force it to isSelectedPopulationSeasonInfo() - // twice for real change event :( - setSelectedPopulationSeasonInfo(fieldPopulationMigrationSeasonChooser.getModel().getSelectedItem() == null); - setSelectedPopulationSeasonInfo(fieldPopulationMigrationSeasonChooser.getModel().getSelectedItem() != null); } protected void seasonChanged() { @@ -107,12 +99,7 @@ populationMigrationMigrationUI.init(getPopInfo()); populationMigrationImmigrationUI.init(getPopInfo()); populationMigrationEmigrationUI.init(getPopInfo()); - - setSelectedPopulationSeasonInfo(isActive()); } - else { - setSelectedPopulationSeasonInfo(false); - } refreshHidablePanel(); } protected void useEquationChanged() { @@ -155,28 +142,32 @@ <row> <cell columns='2' anchor='west'> <JCheckBox id="fieldUseEquationMigration" selected='{getPopInfo().getUseEquationMigration()}' - text="isisfish.populationMigration.useEquation" onActionPerformed='useEquationChanged()' enabled='{isSelectedPopulationSeasonInfo()}' decorator='boxed'/> + text="isisfish.populationMigration.useEquation" onActionPerformed='useEquationChanged()' + enabled='{getPopInfo() != null}' decorator='boxed'/> </cell> </row> <row> <cell columns='2' fill='both' weightx='1.0' weighty='0.7'> <JPanel id="hidablePanel" layout='{new CardLayout()}'> - <JTabbedPane id="fieldUseMatrix" constraints='"fieldUseMatrix"' enabled='{isSelectedPopulationSeasonInfo()}'> + <JTabbedPane id="fieldUseMatrix" constraints='"fieldUseMatrix"' enabled='{getPopInfo() != null}'> <tab title='{_("isisfish.populationMigrationMigration.title")}'> <PopulationMigrationMigrationUI id="populationMigrationMigrationUI" constructorParams='this' decorator='boxed' - _sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"MigrationMatrix"' active='{isSelectedPopulationSeasonInfo()}' /> + bean="{getBean()}" popInfo="{getPopInfo()}" active="{isActive() && getPopInfo() != null}" + _sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"MigrationMatrix"' /> </tab> <tab title='{_("isisfish.populationMigrationImmigration.title")}'> <PopulationMigrationImmigrationUI id="populationMigrationImmigrationUI" constructorParams='this' decorator='boxed' - _sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"ImmigrationMatrix"' active='{isSelectedPopulationSeasonInfo()}' /> + bean="{getBean()}" popInfo="{getPopInfo()}" active="{isActive() && getPopInfo() != null}" + _sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"ImmigrationMatrix"' /> </tab> <tab title='{_("isisfish.populationMigrationEmigration.title")}'> <PopulationMigrationEmigrationUI id="populationMigrationEmigrationUI" constructorParams='this' decorator='boxed' - _sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"EmigrationMatrix"' active='{isSelectedPopulationSeasonInfo()}' /> + bean="{getBean()}" popInfo="{getPopInfo()}" active="{isActive() && getPopInfo() != null}" + _sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"EmigrationMatrix"' /> </tab> </JTabbedPane> <PopulationMigrationEquationUI id='populationMigrationEquationUI' constraints='"fieldUseEquation"' constructorParams='this' - active='{isSelectedPopulationSeasonInfo()}' /> + bean="{getBean()}" popInfo="{getPopInfo()}" active="{isActive() && getPopInfo() != null}" /> </JPanel> </cell> </row> Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationRecruitmentUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationRecruitmentUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationRecruitmentUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -117,7 +117,7 @@ </cell> <cell fill='both' weightx='1.0' weighty='0.5'> <org.nuiton.math.matrix.gui.MatrixPanelEditor id ='fieldPopulationRecruitmentDistribution' - matrix='{getBean().getRecruitmentDistribution() == null ? null : getBean().getRecruitmentDistribution().copy()}' + matrix='{getBean() == null ? null : bean.getRecruitmentDistribution().copy()}' enabled='{isActive()}' decorator='boxed' _sensitivityBean='{Population.class}' _sensitivityMethod='"RecruitmentDistribution"' onMatrixChanged="populationRecruitmentDistributionMatrixChanged(event)" /> </cell> Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -32,7 +32,7 @@ <import> java.beans.PropertyChangeEvent java.beans.PropertyChangeListener - fr.ifremer.isisfish.ui.input.population.PopulationSeasonInfoComboModel + fr.ifremer.isisfish.ui.input.model.PopulationSeasonInfoComboModel fr.ifremer.isisfish.entities.PopulationSeasonInfo fr.ifremer.isisfish.types.Month fr.ifremer.isisfish.entities.Population @@ -257,7 +257,7 @@ <cell fill='horizontal' weightx='1.0'> <JComboBox id="fieldPopulationSeasonInfoChooser" onItemStateChanged='seasonChanged()' enabled='{isActive()}' - renderer="{new fr.ifremer.isisfish.ui.input.population.PopulationSeasonInfoComboRenderer()}"/> + renderer="{new fr.ifremer.isisfish.ui.input.renderer.PopulationSeasonInfoComboRenderer()}"/> </cell> </row> <row> Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationZonesEditorUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationZonesEditorUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/PopulationZonesEditorUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -29,7 +29,7 @@ <import> fr.ifremer.isisfish.entities.Zone; - fr.ifremer.isisfish.ui.input.population.ZoneListModel; + fr.ifremer.isisfish.ui.input.model.ZoneListModel; org.nuiton.math.matrix.gui.MatrixPanelEvent; org.nuiton.math.matrix.gui.MatrixPanelListener; java.beans.PropertyChangeEvent; Deleted: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityEditorUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityEditorUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityEditorUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -1,188 +0,0 @@ -<!-- - #%L - IsisFish - - $Id$ - $HeadURL$ - %% - Copyright (C) 2009 - 2011 Ifremer, Code Lutin, Chatellier Eric - %% - 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, see - <http://www.gnu.org/licenses/gpl-2.0.html>. - #L% - --> -<fr.ifremer.isisfish.ui.input.InputContentUI superGenericType='Gear'> - - <!-- bean property --> - <fr.ifremer.isisfish.entities.Gear id='bean' javaBean='null'/> - - <fr.ifremer.isisfish.entities.Population id='population' javaBean='null'/> - - <import> - fr.ifremer.isisfish.entities.Equation - fr.ifremer.isisfish.entities.Gear - fr.ifremer.isisfish.entities.Population - fr.ifremer.isisfish.entities.Selectivity - fr.ifremer.isisfish.entities.Species - fr.ifremer.isisfish.ui.input.gear.GearPopulationSelectivityModel - fr.ifremer.isisfish.ui.input.gear.PopulationComboModel - fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor - java.beans.PropertyChangeEvent - java.beans.PropertyChangeListener - java.util.ArrayList - javax.swing.DefaultComboBoxModel - </import> - - <script><![CDATA[ -protected void $afterCompleteSetup() { - addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getNewValue() == null) { - - } - if (evt.getNewValue() != null) { - refresh(); - } - } - }); -} - -/*selectivityTable.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - // le bouton ne doit pas s'activer dans l'analyse de sensibilite - if (isActive()) { - removeSelectivityButton.setEnabled(selectivityTable.getSelectedRow() != -1); - } - } -});*/ - -public void refresh() { - - Gear gear = (Gear)getSaveVerifier().getEntity(Gear.class); - - // add null before, for second to be considered as a changed event - // otherwize, setBean has no effect - //setBean(null); - //setBean(gear); - - if (getBean() != null) { - setSelectivityTableModel(); - fieldSelectivityPopulation.setModel(getSelectivityPopulationModel()); - } - //getSaveVerifier().addCurrentPanel(selectivityEquation); - - // reset to false after addCurrentPanel refresh - selectivityEquation.setActive(false); - - removeSelectivityButton.setEnabled(false); -} - -protected void setSelectivityTableModel() { - - java.util.List<Selectivity> selectivitiesList = new ArrayList<Selectivity>(); - - // set model even if no selectivity - // to clear data - if (getBean().getPopulationSelectivity() != null){ - // move collection to list - // and add all entity to verifier - for (Selectivity oneSelectivity : getBean().getPopulationSelectivity()) { - getSaveVerifier().addCurrentEntity(oneSelectivity); - selectivitiesList.add(oneSelectivity); - } - } - - // set table model - GearPopulationSelectivityModel model = new GearPopulationSelectivityModel(selectivitiesList); - selectivityTable.setModel(model); - selectivityTable.setDefaultRenderer(Equation.class, model); - selectivityTable.setDefaultEditor(Equation.class, new EquationTableEditor()); -} - -protected void addSelectivity() { - getAction().addSelectivity(getPopulation(), selectivityEquation.getEditor().getText(), getBean()); - setSelectivityTableModel(); -} - -protected void removeSelectivity() { - GearPopulationSelectivityModel model = (GearPopulationSelectivityModel)selectivityTable.getModel(); - Selectivity selectedSelectivity = model.getSelectivities().get(selectivityTable.getSelectedRow()); - getAction().removeSelectivity(getBean(), selectedSelectivity); - setSelectivityTableModel(); - removeSelectivityButton.setEnabled(false); -} - -protected DefaultComboBoxModel getSelectivityPopulationModel() { - java.util.List<Species> species = getFisheryRegion().getSpecies(); - java.util.List<Population> populations = new ArrayList<Population>(); - if (species != null) { - for (Species s : species) { - if (s.getPopulation() != null) { - populations.addAll(s.getPopulation()); - } - } - } - PopulationComboModel selectivityPopulationModel = new PopulationComboModel(populations); - return selectivityPopulationModel; -} - -protected void selectivityChanged() { - setPopulation((Population)fieldSelectivityPopulation.getSelectedItem()); - addSelectivityButton.setEnabled(getPopulation() != null); -} - ]]></script> - <JPanel id='body'> - <Table> - <row> - <cell fill='horizontal' anchor='east'> - <JLabel text="isisfish.selectivity.selectPopulation" enabled='{isActive()}' decorator='boxed' /> - </cell> - <cell fill='horizontal' weightx='1.0'> - <JComboBox id="fieldSelectivityPopulation" onActionPerformed='selectivityChanged()' enabled='{isActive()}' - decorator='boxed' /> - </cell> - </row> - <row> - <cell columns='2' fill='both' weightx='1.0' weighty='1.0' insets="0"> - <InputOneEquationUI id='selectivityEquation' constructorParams='this' - text='isisfish.selectivity.equation' - bean='{getBean()}' formuleCategory='Selectivity' active='{getPopulation() != null}' - clazz='{fr.ifremer.isisfish.equation.SelectivityEquation.class}' - decorator='boxed' /> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id="addSelectivityButton" text="isisfish.common.add" onActionPerformed='addSelectivity()' - enabled='{getPopulation() != null}' decorator='boxed' /> - </cell> - </row> - <row> - <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> - <JScrollPane> - <JTable id="selectivityTable" rowHeight='24' enabled='{isActive()}' - decorator='boxed' /> - </JScrollPane> - </cell> - </row> - <row> - <cell columns='2' fill='horizontal' weightx='1.0'> - <JButton id="removeSelectivityButton" text="isisfish.common.remove" onActionPerformed='removeSelectivity()' - enabled='{isActive() && selectivityTable.getSelectedRow() != -1}' decorator='boxed' /> - </cell> - </row> - </Table> - </JPanel> -</fr.ifremer.isisfish.ui.input.InputContentUI> Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/SelectivityUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -27,39 +27,164 @@ <!-- bean property --> <fr.ifremer.isisfish.entities.Gear id='bean' javaBean='null'/> + <fr.ifremer.isisfish.entities.Population id='population' javaBean='null'/> + <BeanValidator id='validator' context="selectivity" bean='{getBean()}' beanClass='fr.ifremer.isisfish.entities.Gear' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI"> </BeanValidator> <import> + fr.ifremer.isisfish.entities.Equation fr.ifremer.isisfish.entities.Gear + fr.ifremer.isisfish.entities.Population + fr.ifremer.isisfish.entities.Selectivity + fr.ifremer.isisfish.entities.Species + fr.ifremer.isisfish.ui.input.model.GearPopulationSelectivityModel + fr.ifremer.isisfish.ui.input.model.PopulationComboModel + fr.ifremer.isisfish.ui.widget.editor.EquationTableEditor + java.beans.PropertyChangeEvent + java.beans.PropertyChangeListener + java.util.ArrayList + javax.swing.DefaultComboBoxModel </import> <script><![CDATA[ -/*public void refresh() { +protected void $afterCompleteSetup() { + addPropertyChangeListener(PROPERTY_BEAN, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getNewValue() == null) { + setPopulation(null); + selectivityTable.setModel(new GearPopulationSelectivityModel()); + } + if (evt.getNewValue() != null) { + refresh(); + } + } + }); +} + +public void refresh() { + Gear gear = (Gear)getSaveVerifier().getEntity(Gear.class); - + // add null before, for second to be considered as a changed event // otherwize, setBean has no effect - setBean(null); - setBean(gear); + //setBean(null); + //setBean(gear); + + if (getBean() != null) { + setSelectivityTableModel(); + fieldSelectivityPopulation.setModel(getSelectivityPopulationModel()); + } +} + +protected void setSelectivityTableModel() { - getSaveVerifier().addCurrentPanel(editor); -}*/ + java.util.List<Selectivity> selectivitiesList = new ArrayList<Selectivity>(); + + // set model even if no selectivity + // to clear data + if (getBean().getPopulationSelectivity() != null) { + // move collection to list + // and add all entity to verifier + for (Selectivity oneSelectivity : getBean().getPopulationSelectivity()) { + getSaveVerifier().addCurrentEntity(oneSelectivity); + selectivitiesList.add(oneSelectivity); - at Override -public void setLayer(boolean active) { - super.setLayer(active); - editor.setLayer(active); + // hack to enable save button :( + oneSelectivity.addPropertyChangeListener(new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + validator.setChanged(true); + } + }); + } + } + + // set table model + GearPopulationSelectivityModel model = new GearPopulationSelectivityModel(selectivitiesList); + selectivityTable.setModel(model); + selectivityTable.setDefaultRenderer(Equation.class, model); + selectivityTable.setDefaultEditor(Equation.class, new EquationTableEditor()); } + +protected void addSelectivity() { + getAction().addSelectivity(getPopulation(), selectivityEquation.getEditor().getText(), getBean()); + setSelectivityTableModel(); +} + +protected void removeSelectivity() { + GearPopulationSelectivityModel model = (GearPopulationSelectivityModel)selectivityTable.getModel(); + Selectivity selectedSelectivity = model.getSelectivities().get(selectivityTable.getSelectedRow()); + getAction().removeSelectivity(getBean(), selectedSelectivity); + setSelectivityTableModel(); + removeSelectivityButton.setEnabled(false); +} + +protected DefaultComboBoxModel getSelectivityPopulationModel() { + java.util.List<Species> species = getFisheryRegion().getSpecies(); + java.util.List<Population> populations = new ArrayList<Population>(); + if (species != null) { + for (Species s : species) { + if (s.getPopulation() != null) { + populations.addAll(s.getPopulation()); + } + } + } + PopulationComboModel selectivityPopulationModel = new PopulationComboModel(populations); + return selectivityPopulationModel; +} + +protected void selectivityChanged() { + setPopulation((Population)fieldSelectivityPopulation.getSelectedItem()); +} ]]></script> <JPanel id='body'> <Table> <row> <cell columns="2" fill='both' weightx='1.0' weighty='1.0'> - <SelectivityEditorUI id='editor' constructorParams='this' bean='{getBean()}' active="{isActive()}" - _sensitivityBean='{Gear.class}' _sensitivityMethod='"PopulationSelectivity"'/> + <Table> + <row> + <cell fill='horizontal' anchor='east'> + <JLabel text="isisfish.selectivity.selectPopulation" enabled='{isActive()}' decorator='boxed' /> + </cell> + <cell fill='horizontal' weightx='1.0'> + <JComboBox id="fieldSelectivityPopulation" onItemStateChanged='selectivityChanged()' + enabled='{isActive()}' decorator='boxed' /> + </cell> + </row> + <row> + <cell columns='2' fill='both' weightx='1.0' weighty='1.0' insets="0"> + <InputOneEquationUI id='selectivityEquation' constructorParams='this' + text='isisfish.selectivity.equation' + bean='{getBean()}' formuleCategory='Selectivity' active='{getPopulation() != null}' + clazz='{fr.ifremer.isisfish.equation.SelectivityEquation.class}' + decorator='boxed' /> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JButton id="addSelectivityButton" text="isisfish.common.add" onActionPerformed='addSelectivity()' + enabled='{getPopulation() != null}' decorator='boxed' /> + </cell> + </row> + <row> + <cell columns='2' fill='both' weightx='1.0' weighty='1.0'> + <JScrollPane> + <JTable id="selectivityTable" rowHeight='24' enabled='{isActive()}' + decorator='boxed' /> + <ListSelectionModel initializer='selectivityTable.getSelectionModel()' + onValueChanged="removeSelectivityButton.setEnabled(isActive() && selectivityTable.getSelectedRow() != -1)" /> + </JScrollPane> + </cell> + </row> + <row> + <cell columns='2' fill='horizontal' weightx='1.0'> + <JButton id="removeSelectivityButton" text="isisfish.common.remove" onActionPerformed='removeSelectivity()' + enabled='false' decorator='boxed' /> + </cell> + </row> + </Table> </cell> </row> <row> Modified: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/VesselTypeUI.jaxx =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/VesselTypeUI.jaxx 2011-04-20 15:32:27 UTC (rev 3275) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/VesselTypeUI.jaxx 2011-04-20 15:36:48 UTC (rev 3276) @@ -32,7 +32,7 @@ fr.ifremer.isisfish.entities.VesselType fr.ifremer.isisfish.entities.TripType fr.ifremer.isisfish.types.TimeUnit - fr.ifremer.isisfish.ui.input.triptype.TripTypeListModel + fr.ifremer.isisfish.ui.input.model.TripTypeListModel jaxx.runtime.swing.editor.NumberEditor java.beans.PropertyChangeEvent java.beans.PropertyChangeListener @@ -210,7 +210,7 @@ <JScrollPane> <JAXXList id="vesselTypeTripType" selectedValues='{getBean().getTripType() == null ? null : getBean().getTripType().toArray()}' onMouseClicked='tripTypeChanged()' - cellRenderer="{new fr.ifremer.isisfish.ui.input.triptype.TripTypeListRenderer()}" + cellRenderer="{new fr.ifremer.isisfish.ui.input.renderer.TripTypeListRenderer()}" enabled='{isActive()}' decorator='boxed' _sensitivityBean='{VesselType.class}' _sensitivityMethod='"TripType"'/> </JScrollPane> </cell> Copied: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/EffortDescriptionListModel.java (from rev 3273, isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionListModel.java) =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/EffortDescriptionListModel.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/EffortDescriptionListModel.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,106 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.model; + +import java.util.List; + +import javax.swing.DefaultListModel; + +import fr.ifremer.isisfish.entities.EffortDescription; + +/** + * Model pour la liste des metiers de l'interface SetOfVessels. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class EffortDescriptionListModel extends DefaultListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = -2715181950778932871L; + + /** Listes des EffortDescription */ + protected List<EffortDescription> effortDescriptions; + + /** + * Empty constructor. + */ + public EffortDescriptionListModel() { + this(null); + } + + /** + * Constructor with effortDescriptions list. + * + * @param effortDescriptions liste des effortDescriptions + */ + public EffortDescriptionListModel(List<EffortDescription> effortDescriptions) { + setEffortDescriptions(effortDescriptions); + } + + /** + * Get effortDescriptions lists. + * + * @return the effortDescriptions + */ + public List<EffortDescription> getEffortDescriptions() { + return effortDescriptions; + } + + /** + * Set effortDescriptions list. + * + * @param effortDescriptions the effortDescriptions list to set + */ + public void setEffortDescriptions(List<EffortDescription> effortDescriptions) { + this.effortDescriptions = effortDescriptions; + fireContentsChanged(this, 0, getSize()); + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return effortDescriptions.get(index); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int size = 0; + + if (effortDescriptions != null) { + size = effortDescriptions.size(); + } + return size; + } +} Added: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/GearComboModel.java =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/GearComboModel.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/GearComboModel.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,82 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, CodeLutin, Chatellier Eric + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.model; + +import java.util.List; + +import javax.swing.DefaultComboBoxModel; + +import fr.ifremer.isisfish.entities.Gear; + +/** + * Model pour la liste des {@link Gear}. + * + * Pas de selection par defaut. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class GearComboModel extends DefaultComboBoxModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6171850179969290032L; + + /** Species list */ + protected List<Gear> gearList; + + /** + * Constructor with gears list. + * + * @param gearList gears list + */ + public GearComboModel(List<Gear> gearList) { + this.gearList = gearList; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return gearList.get(index); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int size = 0; + + if (gearList != null) { + size = gearList.size(); + } + return size; + } +} Property changes on: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/GearComboModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Copied: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/GearPopulationSelectivityModel.java (from rev 3273, isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/gear/GearPopulationSelectivityModel.java) =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/GearPopulationSelectivityModel.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/GearPopulationSelectivityModel.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,259 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.model; + +import static org.nuiton.i18n.I18n._; + +import java.awt.Component; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableCellRenderer; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import fr.ifremer.isisfish.entities.Equation; +import fr.ifremer.isisfish.entities.Gear; +import fr.ifremer.isisfish.entities.Selectivity; +import fr.ifremer.isisfish.ui.sensitivity.SensitivityTableModel; + +/** + * Table model for {@link Gear}#{@link Selectivity}. + * + * Columns : + * <li>selectivity population name</li> + * <li>selectivity equation</li> + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class GearPopulationSelectivityModel extends AbstractTableModel implements TableCellRenderer, SensitivityTableModel { + + /** Log. */ + private static Log log = LogFactory.getLog(GearPopulationSelectivityModel.class); + + /** serialVersionUID. */ + private static final long serialVersionUID = 3169786638868209920L; + + /** Columns names. */ + public final static String[] COLUMN_NAMES = { + _("isisfish.common.population"), + _("isisfish.common.equation") + }; + + protected List<Selectivity> selectivities; + + /** + * Empty constructor. + */ + public GearPopulationSelectivityModel() { + this(null); + } + + /** + * Constructor with data. + * + * @param selectivities initial selectivities + */ + public GearPopulationSelectivityModel( + List<Selectivity> selectivities) { + this.selectivities = selectivities; + } + + /** + * Set target species list. + * + * @param selectivities the selectivities to set + */ + public void setSelectivities(List<Selectivity> selectivities) { + this.selectivities = selectivities; + } + + /** + * Get selectivity list. + * + * @return selectivity list + */ + public List<Selectivity> getSelectivities() { + return this.selectivities; + } + + /* + * @see javax.swing.table.TableModel#getColumnCount() + */ + @Override + public int getColumnCount() { + return COLUMN_NAMES.length; + } + + /* + * @see javax.swing.table.TableModel#getRowCount() + */ + @Override + public int getRowCount() { + int rows = 0; + if (selectivities != null) { + rows = selectivities.size(); + } + return rows; + } + + /* + * @see javax.swing.table.TableModel#getValueAt(int, int) + */ + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + + Object result = null; + + Selectivity selectivity = selectivities.get(rowIndex); + switch (columnIndex) { + case 0: + result = selectivity.getPopulation().getName(); + break; + case 1: + result = selectivity.getEquation(); + break; + default: + throw new IndexOutOfBoundsException("No such column " + columnIndex); + } + + return result; + } + + /* + * @see javax.swing.table.TableModel#getColumnClass(int) + */ + @Override + public Class<?> getColumnClass(int columnIndex) { + + Class<?> result = null; + + switch (columnIndex) { + case 0: + result = String.class; + break; + case 1: + result = Equation.class; + break; + default: + throw new IndexOutOfBoundsException("No such column " + columnIndex); + } + + return result; + } + + /* + * @see javax.swing.table.TableModel#getColumnName(int) + */ + @Override + public String getColumnName(int columnIndex) { + return COLUMN_NAMES[columnIndex]; + } + + /* + * @see javax.swing.table.TableModel#isCellEditable(int, int) + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return columnIndex > 0; + } + + /* + * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int) + */ + @Override + public void setValueAt(Object value, int rowIndex, int columnIndex) { + + if (log.isDebugEnabled()) { + log.debug("Cell edition (column " + columnIndex + ") = " + value); + } + + Selectivity selectivity = selectivities.get(rowIndex); + switch (columnIndex) { + case 1: + Equation eq = (Equation)value; + // two events for event to be fired + selectivity.setEquation(null); + selectivity.setEquation(eq); + break; + default: + throw new IndexOutOfBoundsException("Can't edit column " + columnIndex); + } + + } + + /* + * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) + */ + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + + Component c = null; + switch (column) { + case 0: + c = new JLabel(value.toString()); + break; + case 1: + Equation equation = (Equation)value; + c = new JButton(equation.getName() + "(" + equation.getCategory() + ")"); + break; + default: + throw new IndexOutOfBoundsException("No such column " + column); + } + return c; + } + + /* + * @see fr.ifremer.isisfish.ui.sensitivity.SensitivityTableModel#getPropertyAtColumn(int) + */ + @Override + public String getPropertyAtColumn(int column) { + String result = null; + if (column == 1) { + result = "equation"; + } + return result; + } + + /* + * @see fr.ifremer.isisfish.ui.sensitivity.SensitivityTableModel#getBeanAtRow(int) + */ + @Override + public Object getBeanAtRow(int rowIndex) { + Object result = null; + result = selectivities.get(rowIndex); + return result; + } +} Copied: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierListModel.java (from rev 3273, isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/MetierListModel.java) =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierListModel.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierListModel.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,106 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.model; + +import java.util.List; + +import javax.swing.DefaultListModel; + +import fr.ifremer.isisfish.entities.Metier; + +/** + * Model pour la liste des metiers de l'interface SetOfVessels. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class MetierListModel extends DefaultListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = -2715181950778932871L; + + /** Listes des metiers */ + protected List<Metier> metiers; + + /** + * Empty constructor. + */ + public MetierListModel() { + this(null); + } + + /** + * Constructor with metiers list. + * + * @param metiers liste des metiers + */ + public MetierListModel(List<Metier> metiers) { + setMetiers(metiers); + } + + /** + * Get metiers list. + * + * @return the metiers list + */ + public List<Metier> getMetiers() { + return metiers; + } + + /** + * Set metiers list. + * + * @param metiers the metiers list to set + */ + public void setMetiers(List<Metier> metiers) { + this.metiers = metiers; + fireContentsChanged(this, 0, getSize()); + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return metiers.get(index); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int size = 0; + + if (metiers != null) { + size = metiers.size(); + } + return size; + } +} Copied: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoComboModel.java (from rev 3249, isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoComboModel.java) =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoComboModel.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoComboModel.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,82 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.model; + +import java.util.List; + +import javax.swing.DefaultComboBoxModel; + +import fr.ifremer.isisfish.entities.MetierSeasonInfo; + +/** + * Model pour la liste des {@link MetierSeasonInfo}. + * + * Pas de selection par defaut. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author: chatellier $ + */ +public class MetierSeasonInfoComboModel extends DefaultComboBoxModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6171850179969290032L; + + /** MetierSeasonInfo list */ + protected List<MetierSeasonInfo> metierSeasonInfo; + + /** + * Constructor with species list. + * + * @param metierSeasonInfo species list + */ + public MetierSeasonInfoComboModel(List<MetierSeasonInfo> metierSeasonInfo) { + this.metierSeasonInfo = metierSeasonInfo; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return metierSeasonInfo.get(index); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int size = 0; + + if (metierSeasonInfo != null) { + size = metierSeasonInfo.size(); + } + return size; + } +} Copied: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoTargetSpeciesTableModel.java (from rev 3273, isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoTargetSpeciesTableModel.java) =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoTargetSpeciesTableModel.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoTargetSpeciesTableModel.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,267 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.model; + +import static org.nuiton.i18n.I18n._; + +import java.awt.Component; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableCellRenderer; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import fr.ifremer.isisfish.entities.Equation; +import fr.ifremer.isisfish.entities.MetierSeasonInfo; +import fr.ifremer.isisfish.entities.TargetSpecies; +import fr.ifremer.isisfish.ui.sensitivity.SensitivityTableModel; + +/** + * Table model for {@link MetierSeasonInfo}#{@link TargetSpecies}. + * + * Columns : + * <li>target species name</li> + * <li>target species equation</li> + * <li>target species primaryCatch</li> + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class MetierSeasonInfoTargetSpeciesTableModel extends AbstractTableModel implements TableCellRenderer, SensitivityTableModel { + + /** Log. */ + private static Log log = LogFactory.getLog(MetierSeasonInfoTargetSpeciesTableModel.class); + + /** serialVersionUID. */ + private static final long serialVersionUID = 3169786638868209920L; + + /** Columns names. */ + public final static String[] COLUMN_NAMES = { + _("isisfish.metierSeasonInfoSpecies.species"), + _("isisfish.metierSeasonInfoSpecies.targetFactor"), + _("isisfish.metierSeasonInfoSpecies.mainSpecies") }; + + protected List<TargetSpecies> targetSpeciesList; + + /** + * Empty constructor. + */ + public MetierSeasonInfoTargetSpeciesTableModel() { + this(null); + } + + /** + * Constructor with data. + * + * @param targetSpeciesList initial target species + */ + public MetierSeasonInfoTargetSpeciesTableModel( + List<TargetSpecies> targetSpeciesList) { + this.targetSpeciesList = targetSpeciesList; + } + + /** + * Set target species list. + * + * @param targetSpeciesList the targetSpecies to set + */ + public void setTargetSpecies(List<TargetSpecies> targetSpeciesList) { + this.targetSpeciesList = targetSpeciesList; + } + + /* + * @see javax.swing.table.TableModel#getColumnCount() + */ + @Override + public int getColumnCount() { + return COLUMN_NAMES.length; + } + + /* + * @see javax.swing.table.TableModel#getRowCount() + */ + @Override + public int getRowCount() { + int rows = 0; + if (targetSpeciesList != null) { + rows = targetSpeciesList.size(); + } + return rows; + } + + /* + * @see javax.swing.table.TableModel#getValueAt(int, int) + */ + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + + Object result = null; + + TargetSpecies targetSpecies = targetSpeciesList.get(rowIndex); + switch (columnIndex) { + case 0: + result = targetSpecies.getSpecies().getName(); + break; + case 1: + result = targetSpecies.getTargetFactorEquation(); + break; + case 2: + result = targetSpecies.getPrimaryCatch(); + break; + default: + throw new IndexOutOfBoundsException("No such column " + columnIndex); + } + + return result; + } + + /* + * @see javax.swing.table.TableModel#getColumnClass(int) + */ + @Override + public Class<?> getColumnClass(int columnIndex) { + + Class<?> result = null; + + switch (columnIndex) { + case 0: + result = String.class; + break; + case 1: + result = Equation.class; + break; + case 2: + result = Boolean.class; + break; + default: + throw new IndexOutOfBoundsException("No such column " + columnIndex); + } + + return result; + } + + /* + * @see javax.swing.table.TableModel#getColumnName(int) + */ + @Override + public String getColumnName(int columnIndex) { + return COLUMN_NAMES[columnIndex]; + } + + /* + * @see javax.swing.table.TableModel#isCellEditable(int, int) + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return columnIndex > 0; + } + + /* + * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int) + */ + @Override + public void setValueAt(Object value, int rowIndex, int columnIndex) { + + if (log.isDebugEnabled()) { + log.debug("Cell edition (column " + columnIndex + ") = " + value); + } + + TargetSpecies targetSpecies = targetSpeciesList.get(rowIndex); + switch (columnIndex) { + case 1: + Equation eq = (Equation)value; + // two events for event to be fired + targetSpecies.setTargetFactorEquation(null); + targetSpecies.setTargetFactorEquation(eq); + break; + case 2: + Boolean bValue = (Boolean)value; + targetSpecies.setPrimaryCatch(bValue); + break; + default: + throw new IndexOutOfBoundsException("Can't edit column " + columnIndex); + } + + } + + /* + * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) + */ + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + + Component c = null; + switch (column) { + case 0: + c = new JLabel(value.toString()); + break; + case 1: + Equation equation = (Equation)value; + c = new JButton(equation.getName() + "(" + equation.getCategory() + ")"); + break; + case 2: + Boolean bValue = (Boolean)value; + c = new JCheckBox(); + ((JCheckBox)c).setSelected(bValue); + break; + default: + throw new IndexOutOfBoundsException("No such column " + column); + } + return c; + } + + /* + * @see fr.ifremer.isisfish.ui.sensitivity.SensitivityTableModel#getPropertyAtColumn(int) + */ + @Override + public String getPropertyAtColumn(int column) { + String property = null; + if (column == 1) { + property = "targetFactorEquation"; + } + return property; + } + + /* + * @see fr.ifremer.isisfish.ui.sensitivity.SensitivityTableModel#getBeanAtRow(int) + */ + @Override + public Object getBeanAtRow(int rowIndex) { + Object value = null; + value = targetSpeciesList.get(rowIndex); + return value; + } +} Copied: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/PopulationComboModel.java (from rev 3273, isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/gear/PopulationComboModel.java) =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/PopulationComboModel.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/PopulationComboModel.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,82 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.model; + +import java.util.List; + +import javax.swing.DefaultComboBoxModel; + +import fr.ifremer.isisfish.entities.Population; + +/** + * Model pour la liste des {@link Population}. + * + * Pas de selection par defaut. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author: chatellier $ + */ +public class PopulationComboModel extends DefaultComboBoxModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6171850179969290032L; + + /** Population list */ + protected List<Population> populations; + + /** + * Constructor with species list. + * + * @param populations populations list + */ + public PopulationComboModel(List<Population> populations) { + this.populations = populations; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return populations.get(index); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int size = 0; + + if (populations != null) { + size = populations.size(); + } + return size; + } +} Copied: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/PopulationSeasonInfoComboModel.java (from rev 3273, isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonInfoComboModel.java) =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/PopulationSeasonInfoComboModel.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/PopulationSeasonInfoComboModel.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,108 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.model; + +import java.util.List; + +import javax.swing.DefaultComboBoxModel; + +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; + +/** + * Model pour la liste des {@link PopulationSeasonInfo}. + * + * @author chatellier + * @version $Revision: 2350 $ + * + * Last update : $Date: 2009-06-09 13:52:58 +0200 (mar. 09 juin 2009) $ + * By : $Author: chatellier $ + */ +public class PopulationSeasonInfoComboModel extends DefaultComboBoxModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6171850179969290032L; + + /** PopulationSeasonInfo list */ + protected List<PopulationSeasonInfo> populationSeasonInfos; + + /** + * Empty constructor. + */ + public PopulationSeasonInfoComboModel() { + this(null); + } + + /** + * Constructor with population season info list. + * + * @param populationSeasonInfos population season info list + */ + public PopulationSeasonInfoComboModel(List<PopulationSeasonInfo> populationSeasonInfos) { + setPopulationSeasonInfos(populationSeasonInfos); + } + + /** + * Get population season info list. + * + * @return population season info list + */ + public List<PopulationSeasonInfo> getPopulationSeasonInfos() { + return populationSeasonInfos; + } + + /** + * Set population season info list. + * + * @param populationSeasonInfos the population season info list to set + */ + public void setPopulationSeasonInfos(List<PopulationSeasonInfo> populationSeasonInfos) { + this.populationSeasonInfos = populationSeasonInfos; + + // clear selection + setSelectedItem(null); + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return populationSeasonInfos.get(index); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int size = 0; + + if (populationSeasonInfos != null) { + size = populationSeasonInfos.size(); + } + return size; + } +} Copied: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/SpeciesComboModel.java (from rev 3273, isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/metier/SpeciesComboModel.java) =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/SpeciesComboModel.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/SpeciesComboModel.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,82 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.model; + +import java.util.List; + +import javax.swing.DefaultComboBoxModel; + +import fr.ifremer.isisfish.entities.Species; + +/** + * Model pour la liste des {@link Species}. + * + * Pas de selection par defaut. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author: chatellier $ + */ +public class SpeciesComboModel extends DefaultComboBoxModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6171850179969290032L; + + /** Species list */ + protected List<Species> speciesList; + + /** + * Constructor with species list. + * + * @param speciesList species list + */ + public SpeciesComboModel(List<Species> speciesList) { + this.speciesList = speciesList; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return speciesList.get(index); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int size = 0; + + if (speciesList != null) { + size = speciesList.size(); + } + return size; + } +} Copied: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/TripTypeListModel.java (from rev 3273, isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeListModel.java) =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/TripTypeListModel.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/TripTypeListModel.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,82 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.model; + +import java.util.List; + +import javax.swing.DefaultListModel; + +import fr.ifremer.isisfish.entities.TripType; + +/** + * Model pour la liste des {@link TripType}. + * + * Pas de selection par defaut. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author: chatellier $ + */ +public class TripTypeListModel extends DefaultListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6171850179969290032L; + + /** Trip types list */ + protected List<TripType> tripTypes; + + /** + * Constructor with trip types list. + * + * @param tripTypes Trip types list + */ + public TripTypeListModel(List<TripType> tripTypes) { + this.tripTypes = tripTypes; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return tripTypes.get(index); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int size = 0; + + if (tripTypes != null) { + size = tripTypes.size(); + } + return size; + } +} Copied: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/ZoneListModel.java (from rev 3273, isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/population/ZoneListModel.java) =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/ZoneListModel.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/model/ZoneListModel.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,82 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.model; + +import java.util.List; + +import javax.swing.DefaultListModel; + +import fr.ifremer.isisfish.entities.Zone; + +/** + * Model pour la liste des {@link Zone}. + * + * Pas de selection par defaut. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author: chatellier $ + */ +public class ZoneListModel extends DefaultListModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6171850179969290032L; + + /** Zones list */ + protected List<Zone> zones; + + /** + * Constructor with zone list. + * + * @param zones zones list + */ + public ZoneListModel(List<Zone> zones) { + this.zones = zones; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + return zones.get(index); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int size = 0; + + if (zones != null) { + size = zones.size(); + } + return size; + } +} Copied: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/EffortDescriptionListRenderer.java (from rev 3148, isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/EffortDescriptionListRenderer.java) =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/EffortDescriptionListRenderer.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/EffortDescriptionListRenderer.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,67 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.renderer; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import fr.ifremer.isisfish.entities.EffortDescription; + +/** + * Renderer pour liste des {@link EffortDescription}. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class EffortDescriptionListRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1113492654780402245L; + + /* + * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) + */ + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + // this must be used to have alterned highlight rows and default + // selection color + JLabel c = (JLabel) super.getListCellRendererComponent(list, value, + index, isSelected, cellHasFocus); + + EffortDescription effort = (EffortDescription) value; + c.setText(effort.getPossibleMetiers().getName()); + + return c; + } +} Copied: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/MetierListRenderer.java (from rev 3148, isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/setofvessels/MetierListRenderer.java) =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/MetierListRenderer.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/MetierListRenderer.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,67 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.renderer; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import fr.ifremer.isisfish.entities.Metier; + +/** + * Renderer pour liste des metiers. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class MetierListRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1113492654780402245L; + + /* + * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) + */ + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + // this must be used to have alterned highlight rows and default + // selection color + JLabel c = (JLabel) super.getListCellRendererComponent(list, value, + index, isSelected, cellHasFocus); + + Metier metier = (Metier) value; + c.setText(metier.getName()); + + return c; + } +} Copied: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/MetierSeasonInfoComboRenderer.java (from rev 3148, isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/metier/MetierSeasonInfoComboRenderer.java) =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/MetierSeasonInfoComboRenderer.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/MetierSeasonInfoComboRenderer.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,70 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.renderer; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import fr.ifremer.isisfish.entities.MetierSeasonInfo; + +/** + * Renderer pour la combo des {@link MetierSeasonInfo}. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author: chatellier $ + */ +public class MetierSeasonInfoComboRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = -8277883340386163087L; + + /* + * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) + */ + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + // this must be used to have alterned highlight rows and default + // selection color + JLabel c = (JLabel) super.getListCellRendererComponent(list, value, + index, isSelected, cellHasFocus); + + MetierSeasonInfo metierSeasonInfo = (MetierSeasonInfo) value; + + // there is no default selection + if (value != null) { + c.setText(metierSeasonInfo.getFirstMonth() + "-" + metierSeasonInfo.getLastMonth()); + } + return c; + } +} Copied: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/PopulationSeasonInfoComboRenderer.java (from rev 3148, isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/population/PopulationSeasonInfoComboRenderer.java) =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/PopulationSeasonInfoComboRenderer.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/PopulationSeasonInfoComboRenderer.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,70 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.renderer; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import fr.ifremer.isisfish.entities.PopulationSeasonInfo; + +/** + * Renderer pour la combo des {@link PopulationSeasonInfo}. + * + * @author chatellier + * @version $Revision: 2350 $ + * + * Last update : $Date: 2009-06-09 13:52:58 +0200 (mar. 09 juin 2009) $ + * By : $Author: chatellier $ + */ +public class PopulationSeasonInfoComboRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = -8277883340386163087L; + + /* + * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) + */ + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + // this must be used to have alterned highlight rows and default + // selection color + JLabel c = (JLabel) super.getListCellRendererComponent(list, value, + index, isSelected, cellHasFocus); + + PopulationSeasonInfo populationSeasonInfo = (PopulationSeasonInfo) value; + + // there is no default selection + if (value != null) { + c.setText(populationSeasonInfo.getFirstMonth() + " - " + populationSeasonInfo.getLastMonth()); + } + return c; + } +} Copied: isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/TripTypeListRenderer.java (from rev 3148, isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/triptype/TripTypeListRenderer.java) =================================================================== --- isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/TripTypeListRenderer.java (rev 0) +++ isis-fish/branches/3.3.1/src/main/java/fr/ifremer/isisfish/ui/input/renderer/TripTypeListRenderer.java 2011-04-20 15:36:48 UTC (rev 3276) @@ -0,0 +1,67 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2010 Ifremer, CodeLutin + * %% + * 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, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.ui.input.renderer; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import fr.ifremer.isisfish.entities.TripType; + +/** + * Renderer pour liste des trip types. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author: chatellier $ + */ +public class TripTypeListRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = 1113492654780402245L; + + /* + * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) + */ + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + // this must be used to have alternated highlight rows and default + // selection color + JLabel c = (JLabel) super.getListCellRendererComponent(list, value, + index, isSelected, cellHasFocus); + + TripType tripType = (TripType) value; + c.setText(tripType.getName()); + + return c; + } +}
participants (1)
-
chatellier@users.labs.libre-entreprise.org