Author: tchemit Date: 2012-12-05 00:32:56 +0100 (Wed, 05 Dec 2012) New Revision: 29 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/29 Log: introduce a package for each trait catches save trait species specific fields Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTableModel.java Removed: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTableModel.java Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TraitBean.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/campaign/EditCampaignUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/campaign/EditSurveyUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CatchesUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CatchesUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CatchesUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesCatchEntryModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesTabUIModel.java trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TraitBean.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TraitBean.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TraitBean.java 2012-12-04 23:32:56 UTC (rev 29) @@ -119,7 +119,14 @@ protected Float averageBottomSalinity; + protected Float speciesTotalWeight; + protected Float speciesTotalVracWeight; + + protected Float speciesSampleVracWeight; + + protected Float speciesTotalHorsVracWeight; + public CampaignBean getCampaign() { return campaign; } @@ -431,4 +438,36 @@ public void setAverageBottomSalinity(Float averageBottomSalinity) { this.averageBottomSalinity = averageBottomSalinity; } + + public Float getSpeciesTotalWeight() { + return speciesTotalWeight; + } + + public void setSpeciesTotalWeight(Float speciesTotalWeight) { + this.speciesTotalWeight = speciesTotalWeight; + } + + public Float getSpeciesTotalVracWeight() { + return speciesTotalVracWeight; + } + + public void setSpeciesTotalVracWeight(Float speciesTotalVracWeight) { + this.speciesTotalVracWeight = speciesTotalVracWeight; + } + + public Float getSpeciesSampleVracWeight() { + return speciesSampleVracWeight; + } + + public void setSpeciesSampleVracWeight(Float speciesSampleVracWeight) { + this.speciesSampleVracWeight = speciesSampleVracWeight; + } + + public Float getSpeciesTotalHorsVracWeight() { + return speciesTotalHorsVracWeight; + } + + public void setSpeciesTotalHorsVracWeight(Float speciesTotalHorsVracWeight) { + this.speciesTotalHorsVracWeight = speciesTotalHorsVracWeight; + } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/campaign/EditCampaignUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/campaign/EditCampaignUIHandler.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/campaign/EditCampaignUIHandler.java 2012-12-04 23:32:56 UTC (rev 29) @@ -26,6 +26,7 @@ import fr.ifremer.tutti.persistence.entities.CampaignBean; import fr.ifremer.tutti.persistence.entities.SurveyBean; +import fr.ifremer.tutti.persistence.entities.TuttiBeans; import fr.ifremer.tutti.persistence.entities.referential.UserBean; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; @@ -137,7 +138,7 @@ CampaignBean bean = model.toBean(); CampaignBean saved; - if (model.isCreate()) { + if (TuttiBeans.isNew(bean)) { saved = persistenceService.createCampaign(bean); } else { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/campaign/EditSurveyUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/campaign/EditSurveyUIHandler.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/campaign/EditSurveyUIHandler.java 2012-12-04 23:32:56 UTC (rev 29) @@ -25,6 +25,7 @@ */ import fr.ifremer.tutti.persistence.entities.SurveyBean; +import fr.ifremer.tutti.persistence.entities.TuttiBeans; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; import fr.ifremer.tutti.ui.swing.TuttiScreen; @@ -120,7 +121,7 @@ SurveyBean bean = model.toBean(); SurveyBean saved; - if (model.isCreate()) { + if (TuttiBeans.isNew(bean)) { saved = persistenceService.createSurvey(bean); } else { Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUI.css 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUI.css 2012-12-04 23:32:56 UTC (rev 29) @@ -1,59 +0,0 @@ -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -NumberEditor { - autoPopup:{handler.getConfig().isAutoPopupNumberEditor()}; - showPopupButton:{handler.getConfig().isShowNumberEditorButton()}; - bean:{model}; - showReset:true; -} - -#totalWeightLabel { - text:"tutti.label.benthos.totalWeight"; - labelFor:{totalWeightField}; -} - -#totalWeightField { - property:"totalWeight"; - model:{model.getTotalWeight()}; - useFloat:false; - numberPattern:{INT_6_DIGITS_PATTERN}; -} - -#sampleTotalWeightLabel { - text:"tutti.label.benthos.sampleTotalWeight"; - labelFor:{totalWeightField}; -} - -#sampleTotalWeightField { - property:"sampleTotalWeight"; - model:{model.getSampleTotalWeight()}; - useFloat:false; - numberPattern:{INT_6_DIGITS_PATTERN}; -} - -#table { - model:{getContextValue(TableModel.class)}; - columnModel:{getContextValue(TableColumnModel.class)}; -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUI.jaxx 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUI.jaxx 2012-12-04 23:32:56 UTC (rev 29) @@ -1,100 +0,0 @@ -<!-- - #%L - Tutti :: UI - $Id$ - $HeadURL$ - %% - Copyright (C) 2012 Ifremer - %% - 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 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 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-3.0.html>. - #L% - --> -<JPanel id='homePanel' layout='{new BorderLayout()}' - implements='fr.ifremer.tutti.ui.swing.TuttiUI<BenthosTabUIModel, BenthosTabUIHandler>'> - - <import> - fr.ifremer.tutti.persistence.entities.referential.BeaufortScaleBean - fr.ifremer.tutti.persistence.entities.referential.SeaStateBean - fr.ifremer.tutti.persistence.entities.StrataBean - fr.ifremer.tutti.persistence.entities.TraitBean - fr.ifremer.tutti.persistence.entities.referential.UserBean - fr.ifremer.tutti.ui.swing.TuttiUIContext - - jaxx.runtime.swing.editor.NumberEditor - - jaxx.runtime.validator.swing.SwingValidatorUtil - jaxx.runtime.validator.swing.SwingValidatorMessageTableModel - - javax.swing.table.TableModel - javax.swing.table.TableColumnModel - - static org.nuiton.i18n.I18n._ - </import> - - <script><![CDATA[ - -public BenthosTabUI(CatchesUI parentUI) { - BenthosTabUIHandler handler = new BenthosTabUIHandler(parentUI, this); - setContextValue(handler); - handler.beforeInitUI(); -} - -public void selectTrait(TraitBean trait) { handler.selectTrait(trait); } - -protected void $afterCompleteSetup() { handler.afterInitUI(); } - ]]></script> - - <BenthosTabUIHandler id='handler' - initializer='getContextValue(BenthosTabUIHandler.class)'/> - - <BenthosTabUIModel id='model' - initializer='getContextValue(BenthosTabUIModel.class)'/> - - <SwingValidatorMessageTableModel id='errorTableModel'/> - - <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' - uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> - <field name='totalWeight' component='totalWeightField'/> - <field name='sampleTotalWeight' component='sampleTotalWeightField'/> - </BeanValidator> - - <Table id='form' fill='both' constraints='BorderLayout.NORTH'> - - <!-- Poids total --> - <row> - <cell anchor='west'> - <JLabel id='totalWeightLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='totalWeightField' constructorParams='this'/> - </cell> - </row> - - <!-- Poids total échantillonné --> - <row> - <cell> - <JLabel id='sampleTotalWeightLabel'/> - </cell> - <cell> - <NumberEditor id='sampleTotalWeightField' constructorParams='this'/> - </cell> - </row> - </Table> - - <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> - <JTable id='table'/> - </JScrollPane> - -</JPanel> Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUIHandler.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUIHandler.java 2012-12-04 23:32:56 UTC (rev 29) @@ -1,181 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.catches; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.TraitBean; -import fr.ifremer.tutti.persistence.entities.TraitBenthosCatchBean; -import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; -import fr.ifremer.tutti.persistence.entities.referential.SpeciesBean; -import fr.ifremer.tutti.service.PersistenceService; -import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; -import jaxx.runtime.SwingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.JComboBox; -import javax.swing.JTable; -import javax.swing.table.DefaultTableColumnModel; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.List; - -import static org.nuiton.i18n.I18n._; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.1 - */ -public class BenthosTabUIHandler extends AbstractTuttiUIHandler<BenthosTabUIModel> { - - /** Logger. */ - private static final Log log = LogFactory.getLog(BenthosTabUIHandler.class); - - private final BenthosTabUI ui; - - private final CatchesUI parentUi; - - private final PersistenceService persistenceService; - - public BenthosTabUIHandler(CatchesUI parentUi, BenthosTabUI ui) { - super(parentUi.getHandler().getContext()); - this.ui = ui; - this.parentUi = parentUi; - this.persistenceService = context.getService(PersistenceService.class); - } - - @Override - public void beforeInitUI() { - - BenthosTabUIModel model = new BenthosTabUIModel(); - ui.setContextValue(model); - - JTable tb = new JTable(); - - TableCellEditor defaultEditor = tb.getDefaultEditor(String.class); - TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class); - - // prepare the table column model - TableColumnModel columnModel = new DefaultTableColumnModel(); - - TableColumn col; - - // species (by code) column - - col = new TableColumn(0); - - JComboBox speciesEditor = new JComboBox(); - List<SpeciesBean> allSpecies = persistenceService.getAllSpecies(); - SwingUtil.fillComboBox(speciesEditor, allSpecies, null); -// col.setCellEditor(); - col.setCellRenderer(newTableCellRender(SpeciesBean.class)); - col.setHeaderValue(_("tutti.table.benthos.header.speciesByCode")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("speciesByCode"); - columnModel.addColumn(col); - - // Poids observé - col = new TableColumn(1); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.benthos.header.weight")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("weight"); - columnModel.addColumn(col); - - // Nombre observé - col = new TableColumn(2); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.benthos.header.number")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("computedNumber"); - columnModel.addColumn(col); - - ui.setContextValue(columnModel); - - final BenthosTableModel tableModel = new BenthosTableModel(columnModel); - ui.setContextValue(tableModel); - - model.addPropertyChangeListener(BenthosTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - tableModel.setData((List<TraitSpeciesCatchBean>) evt.getNewValue()); - } - }); - - } - - @Override - public void afterInitUI() { - BenthosTabUIModel model = ui.getModel(); - - initUI(ui); - } - - @Override - public void onCloseUI() { - } - - @Override - protected BenthosTabUIModel getModel() { - return ui.getModel(); - } - - public void selectTrait(TraitBean bean) { - - boolean empty = bean == null; - - BenthosTabUIModel model = ui.getModel(); - - List<TraitBenthosCatchBean> catches; - - if (empty) { - catches = null; - bean = new TraitBean(); - } else { - catches = persistenceService.getAllTraitBenthosCatch(bean.getId()); - } - - model.fromBean(bean); - model.setCatches(catches); - } - - public void cancel() { - - if (log.isInfoEnabled()) { - log.info("Cancel edition"); - } - } - - public void save() { - if (log.isInfoEnabled()) { - log.info("Will save"); - } - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUIModel.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUIModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -1,95 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.catches; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.TraitBean; -import fr.ifremer.tutti.persistence.entities.TraitBenthosCatchBean; -import org.jdesktop.beans.AbstractSerializableBean; -import org.nuiton.util.beans.BinderFactory; - -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.1 - */ -public class BenthosTabUIModel extends AbstractSerializableBean { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; - - public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight"; - - public static final String PROPERTY_CATCHES = "catches"; - - protected Float totalWeight; - - protected Float sampleTotalWeight; - - protected List<TraitBenthosCatchBean> catches; - - public Float getTotalWeight() { - return totalWeight; - } - - public void setTotalWeight(Float totalWeight) { - Object oldValue = getTotalWeight(); - this.totalWeight = totalWeight; - firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); - } - - public Float getSampleTotalWeight() { - return sampleTotalWeight; - } - - public void setSampleTotalWeight(Float sampleTotalWeight) { - Object oldValue = getSampleTotalWeight(); - this.sampleTotalWeight = sampleTotalWeight; - firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight); - } - - public List<TraitBenthosCatchBean> getCatches() { - return catches; - } - - public void setCatches(List<TraitBenthosCatchBean> catches) { - Object oldValue = getCatches(); - this.catches = catches; - firePropertyChange(PROPERTY_CATCHES, oldValue, catches); - } - - public void fromBean(TraitBean bean) { - BinderFactory.newBinder(TraitBean.class, - BenthosTabUIModel.class).copy(bean, this); - } - - public TraitBean toBean() { - TraitBean result = new TraitBean(); - BinderFactory.newBinder(BenthosTabUIModel.class, - TraitBean.class).copy(this, result); - return result; - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTableModel.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTableModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -1,78 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.catches; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -import com.google.common.collect.Lists; -import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; - -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableColumnModel; -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.1 - */ -public class BenthosTableModel extends AbstractTableModel { - - private static final long serialVersionUID = 1L; - - protected List<TraitSpeciesCatchBean> data; - - protected final TableColumnModel columnModel; - - public BenthosTableModel(TableColumnModel columnModel) { - this.columnModel = columnModel; - } - - public void setData(List<TraitSpeciesCatchBean> data) { - if (data == null) { - data = Lists.newArrayList(); - data.add(new TraitSpeciesCatchBean()); - } - this.data = data; - fireTableDataChanged(); - } - - @Override - public int getRowCount() { - return data == null ? 0 : data.size(); - } - - @Override - public int getColumnCount() { - return columnModel.getColumnCount(); - } - - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - return null; - } - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return true; - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUI.css 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUI.css 2012-12-04 23:32:56 UTC (rev 29) @@ -1,59 +0,0 @@ -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -NumberEditor { - autoPopup:{handler.getConfig().isAutoPopupNumberEditor()}; - showPopupButton:{handler.getConfig().isShowNumberEditorButton()}; - bean:{model}; - showReset:true; -} - -#totalWeightLabel { - text:"tutti.label.captureAccidentel.totalWeight"; - labelFor:{totalWeightField}; -} - -#totalWeightField { - property:"totalWeight"; - model:{model.getTotalWeight()}; - useFloat:false; - numberPattern:{INT_6_DIGITS_PATTERN}; -} - -#sampleTotalWeightLabel { - text:"tutti.label.captureAccidentel.sampleTotalWeight"; - labelFor:{totalWeightField}; -} - -#sampleTotalWeightField { - property:"sampleTotalWeight"; - model:{model.getSampleTotalWeight()}; - useFloat:false; - numberPattern:{INT_6_DIGITS_PATTERN}; -} - -#table { - model:{getContextValue(TableModel.class)}; - columnModel:{getContextValue(TableColumnModel.class)}; -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUI.jaxx 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUI.jaxx 2012-12-04 23:32:56 UTC (rev 29) @@ -1,100 +0,0 @@ -<!-- - #%L - Tutti :: UI - $Id$ - $HeadURL$ - %% - Copyright (C) 2012 Ifremer - %% - 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 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 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-3.0.html>. - #L% - --> -<JPanel id='homePanel' layout='{new BorderLayout()}' - implements='fr.ifremer.tutti.ui.swing.TuttiUI<CaptureAccidentelTabUIModel, CaptureAccidentelTabUIHandler>'> - - <import> - fr.ifremer.tutti.persistence.entities.referential.BeaufortScaleBean - fr.ifremer.tutti.persistence.entities.referential.SeaStateBean - fr.ifremer.tutti.persistence.entities.StrataBean - fr.ifremer.tutti.persistence.entities.TraitBean - fr.ifremer.tutti.persistence.entities.referential.UserBean - fr.ifremer.tutti.ui.swing.TuttiUIContext - - jaxx.runtime.swing.editor.NumberEditor - - jaxx.runtime.validator.swing.SwingValidatorUtil - jaxx.runtime.validator.swing.SwingValidatorMessageTableModel - - javax.swing.table.TableModel - javax.swing.table.TableColumnModel - - static org.nuiton.i18n.I18n._ - </import> - - <script><![CDATA[ - -public CaptureAccidentelTabUI(CatchesUI parentUI) { - CaptureAccidentelTabUIHandler handler = new CaptureAccidentelTabUIHandler(parentUI, this); - setContextValue(handler); - handler.beforeInitUI(); -} - -public void selectTrait(TraitBean trait) { handler.selectTrait(trait); } - -protected void $afterCompleteSetup() { handler.afterInitUI(); } - ]]></script> - - <CaptureAccidentelTabUIHandler id='handler' - initializer='getContextValue(CaptureAccidentelTabUIHandler.class)'/> - - <CaptureAccidentelTabUIModel id='model' - initializer='getContextValue(CaptureAccidentelTabUIModel.class)'/> - - <SwingValidatorMessageTableModel id='errorTableModel'/> - - <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' - uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> - <field name='totalWeight' component='totalWeightField'/> - <field name='sampleTotalWeight' component='sampleTotalWeightField'/> - </BeanValidator> - - <Table id='form' fill='both' constraints='BorderLayout.NORTH'> - - <!-- Poids total --> - <row> - <cell anchor='west'> - <JLabel id='totalWeightLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='totalWeightField' constructorParams='this'/> - </cell> - </row> - - <!-- Poids total échantillonné --> - <row> - <cell> - <JLabel id='sampleTotalWeightLabel'/> - </cell> - <cell> - <NumberEditor id='sampleTotalWeightField' constructorParams='this'/> - </cell> - </row> - </Table> - - <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> - <JTable id='table'/> - </JScrollPane> - -</JPanel> \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUIHandler.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUIHandler.java 2012-12-04 23:32:56 UTC (rev 29) @@ -1,181 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.catches; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.TraitBean; -import fr.ifremer.tutti.persistence.entities.TraitCaptureAccidentelCatchBean; -import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; -import fr.ifremer.tutti.persistence.entities.referential.SpeciesBean; -import fr.ifremer.tutti.service.PersistenceService; -import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; -import jaxx.runtime.SwingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.JComboBox; -import javax.swing.JTable; -import javax.swing.table.DefaultTableColumnModel; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.List; - -import static org.nuiton.i18n.I18n._; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class CaptureAccidentelTabUIHandler extends AbstractTuttiUIHandler<CaptureAccidentelTabUIModel> { - - /** Logger. */ - private static final Log log = LogFactory.getLog(CaptureAccidentelTabUIHandler.class); - - private final CaptureAccidentelTabUI ui; - - private final CatchesUI parentUi; - - private final PersistenceService persistenceService; - - public CaptureAccidentelTabUIHandler(CatchesUI parentUi, CaptureAccidentelTabUI ui) { - super(parentUi.getHandler().getContext()); - this.ui = ui; - this.parentUi = parentUi; - this.persistenceService = context.getService(PersistenceService.class); - } - - @Override - public void beforeInitUI() { - - CaptureAccidentelTabUIModel model = new CaptureAccidentelTabUIModel(); - ui.setContextValue(model); - - JTable tb = new JTable(); - - TableCellEditor defaultEditor = tb.getDefaultEditor(String.class); - TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class); - - // prepare the table column model - TableColumnModel columnModel = new DefaultTableColumnModel(); - - TableColumn col; - - // species (by code) column - - col = new TableColumn(0); - - JComboBox speciesEditor = new JComboBox(); - List<SpeciesBean> allSpecies = persistenceService.getAllSpecies(); - SwingUtil.fillComboBox(speciesEditor, allSpecies, null); -// col.setCellEditor(); - col.setCellRenderer(newTableCellRender(SpeciesBean.class)); - col.setHeaderValue(_("tutti.table.captureAccidentel.header.speciesByCode")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("speciesByCode"); - columnModel.addColumn(col); - - // Poids observé - col = new TableColumn(1); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.captureAccidentel.header.weight")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("weight"); - columnModel.addColumn(col); - - // Nombre observé - col = new TableColumn(2); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.captureAccidentel.header.number")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("computedNumber"); - columnModel.addColumn(col); - - ui.setContextValue(columnModel); - - final CaptureAccidentelTableModel tableModel = new CaptureAccidentelTableModel(columnModel); - ui.setContextValue(tableModel); - - model.addPropertyChangeListener(CaptureAccidentelTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - tableModel.setData((List<TraitSpeciesCatchBean>) evt.getNewValue()); - } - }); - - } - - @Override - public void afterInitUI() { - CaptureAccidentelTabUIModel model = ui.getModel(); - - initUI(ui); - } - - @Override - public void onCloseUI() { - } - - @Override - protected CaptureAccidentelTabUIModel getModel() { - return ui.getModel(); - } - - public void selectTrait(TraitBean bean) { - - boolean empty = bean == null; - - CaptureAccidentelTabUIModel model = ui.getModel(); - - List<TraitCaptureAccidentelCatchBean> catches; - - if (empty) { - catches = null; - bean = new TraitBean(); - } else { - catches = persistenceService.getAllTraitCaptureAccidentelCatch(bean.getId()); - } - - model.fromBean(bean); - model.setCatches(catches); - } - - public void cancel() { - - if (log.isInfoEnabled()) { - log.info("Cancel edition"); - } - } - - public void save() { - if (log.isInfoEnabled()) { - log.info("Will save"); - } - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUIModel.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUIModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -1,95 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.catches; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.TraitBean; -import fr.ifremer.tutti.persistence.entities.TraitCaptureAccidentelCatchBean; -import org.jdesktop.beans.AbstractSerializableBean; -import org.nuiton.util.beans.BinderFactory; - -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class CaptureAccidentelTabUIModel extends AbstractSerializableBean { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; - - public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight"; - - public static final String PROPERTY_CATCHES = "catches"; - - protected Float totalWeight; - - protected Float sampleTotalWeight; - - protected List<TraitCaptureAccidentelCatchBean> catches; - - public Float getTotalWeight() { - return totalWeight; - } - - public void setTotalWeight(Float totalWeight) { - Object oldValue = getTotalWeight(); - this.totalWeight = totalWeight; - firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); - } - - public Float getSampleTotalWeight() { - return sampleTotalWeight; - } - - public void setSampleTotalWeight(Float sampleTotalWeight) { - Object oldValue = getSampleTotalWeight(); - this.sampleTotalWeight = sampleTotalWeight; - firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight); - } - - public List<TraitCaptureAccidentelCatchBean> getCatches() { - return catches; - } - - public void setCatches(List<TraitCaptureAccidentelCatchBean> catches) { - Object oldValue = getCatches(); - this.catches = catches; - firePropertyChange(PROPERTY_CATCHES, oldValue, catches); - } - - public void fromBean(TraitBean bean) { - BinderFactory.newBinder(TraitBean.class, - CaptureAccidentelTabUIModel.class).copy(bean, this); - } - - public TraitBean toBean() { - TraitBean result = new TraitBean(); - BinderFactory.newBinder(CaptureAccidentelTabUIModel.class, - TraitBean.class).copy(this, result); - return result; - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTableModel.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTableModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -1,78 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.catches; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -import com.google.common.collect.Lists; -import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; - -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableColumnModel; -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class CaptureAccidentelTableModel extends AbstractTableModel { - - private static final long serialVersionUID = 1L; - - protected List<TraitSpeciesCatchBean> data; - - protected final TableColumnModel columnModel; - - public CaptureAccidentelTableModel(TableColumnModel columnModel) { - this.columnModel = columnModel; - } - - public void setData(List<TraitSpeciesCatchBean> data) { - if (data == null) { - data = Lists.newArrayList(); - data.add(new TraitSpeciesCatchBean()); - } - this.data = data; - fireTableDataChanged(); - } - - @Override - public int getRowCount() { - return data == null ? 0 : data.size(); - } - - @Override - public int getColumnCount() { - return columnModel.getColumnCount(); - } - - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - return null; - } - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return true; - } -} \ No newline at end of file Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CatchesUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CatchesUI.css 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CatchesUI.css 2012-12-04 23:32:56 UTC (rev 29) @@ -54,7 +54,7 @@ enabled:{model.getSelectedTrait() != null}; } -#captureAccidentelTab { +#accidentelTab { enabled:{model.getSelectedTrait() != null}; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CatchesUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CatchesUI.jaxx 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CatchesUI.jaxx 2012-12-04 23:32:56 UTC (rev 29) @@ -28,6 +28,10 @@ fr.ifremer.tutti.persistence.entities.TraitBean fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.catches.accidentel.AccidentelTabUI + fr.ifremer.tutti.ui.swing.content.catches.benthos.BenthosTabUI + fr.ifremer.tutti.ui.swing.content.catches.macrodechet.MacroDechetTabUI + fr.ifremer.tutti.ui.swing.content.catches.plancton.PlanctonTabUI fr.ifremer.tutti.ui.swing.content.catches.species.SpeciesTabUI jaxx.runtime.swing.editor.bean.BeanComboBox @@ -84,8 +88,8 @@ <tab id='macroDechetTab' title='tutti.label.tab.macroDechet'> <MacroDechetTabUI id='macroDechetTabContent' constructorParams='this'/> </tab> - <tab id='captureAccidentelTab' title='tutti.label.tab.captureAccidentel'> - <CaptureAccidentelTabUI id='captureAccidentelTabContent' constructorParams='this'/> + <tab id='accidentelTab' title='tutti.label.tab.accidentel'> + <AccidentelTabUI id='accidentelTabContent' constructorParams='this'/> </tab> <tab id='observationIndividuelTab' title='tutti.label.tab.observationIndividuel'> <JLabel text='tutti.to.be.done' horizontalAlignment='{JLabel.CENTER}'/> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CatchesUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CatchesUIHandler.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CatchesUIHandler.java 2012-12-04 23:32:56 UTC (rev 29) @@ -120,6 +120,9 @@ // ui will be saved so we do not want to keep selected tab indexes ui.getTabPane().setSelectedIndex(0); ui.getTraitTabContent().getTraitTabPane().setSelectedIndex(0); + + // when quitting ui, let's de-select trait (will save any changes) + selectTrait(null); } @Override @@ -156,7 +159,7 @@ ui.getBenthosTabContent().selectTrait(selectedTrait); ui.getPlanctonTabContent().selectTrait(selectedTrait); ui.getMacroDechetTabContent().selectTrait(selectedTrait); - ui.getCaptureAccidentelTabContent().selectTrait(selectedTrait); + ui.getAccidentelTabContent().selectTrait(selectedTrait); // repaint tabs ui.getTabPane().repaint(); Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUI.css 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUI.css 2012-12-04 23:32:56 UTC (rev 29) @@ -1,59 +0,0 @@ -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -NumberEditor { - autoPopup:{handler.getConfig().isAutoPopupNumberEditor()}; - showPopupButton:{handler.getConfig().isShowNumberEditorButton()}; - bean:{model}; - showReset:true; -} - -#totalWeightLabel { - text:"tutti.label.macroDechet.totalWeight"; - labelFor:{totalWeightField}; -} - -#totalWeightField { - property:"totalWeight"; - model:{model.getTotalWeight()}; - useFloat:false; - numberPattern:{INT_6_DIGITS_PATTERN}; -} - -#sampleTotalWeightLabel { - text:"tutti.label.macroDechet.sampleTotalWeight"; - labelFor:{totalWeightField}; -} - -#sampleTotalWeightField { - property:"sampleTotalWeight"; - model:{model.getSampleTotalWeight()}; - useFloat:false; - numberPattern:{INT_6_DIGITS_PATTERN}; -} - -#table { - model:{getContextValue(TableModel.class)}; - columnModel:{getContextValue(TableColumnModel.class)}; -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUI.jaxx 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUI.jaxx 2012-12-04 23:32:56 UTC (rev 29) @@ -1,100 +0,0 @@ -<!-- - #%L - Tutti :: UI - $Id$ - $HeadURL$ - %% - Copyright (C) 2012 Ifremer - %% - 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 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 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-3.0.html>. - #L% - --> -<JPanel id='homePanel' layout='{new BorderLayout()}' - implements='fr.ifremer.tutti.ui.swing.TuttiUI<MacroDechetTabUIModel, MacroDechetTabUIHandler>'> - - <import> - fr.ifremer.tutti.persistence.entities.referential.BeaufortScaleBean - fr.ifremer.tutti.persistence.entities.referential.SeaStateBean - fr.ifremer.tutti.persistence.entities.StrataBean - fr.ifremer.tutti.persistence.entities.TraitBean - fr.ifremer.tutti.persistence.entities.referential.UserBean - fr.ifremer.tutti.ui.swing.TuttiUIContext - - jaxx.runtime.swing.editor.NumberEditor - - jaxx.runtime.validator.swing.SwingValidatorUtil - jaxx.runtime.validator.swing.SwingValidatorMessageTableModel - - javax.swing.table.TableModel - javax.swing.table.TableColumnModel - - static org.nuiton.i18n.I18n._ - </import> - - <script><![CDATA[ - -public MacroDechetTabUI(CatchesUI parentUI) { - MacroDechetTabUIHandler handler = new MacroDechetTabUIHandler(parentUI, this); - setContextValue(handler); - handler.beforeInitUI(); -} - -public void selectTrait(TraitBean trait) { handler.selectTrait(trait); } - -protected void $afterCompleteSetup() { handler.afterInitUI(); } - ]]></script> - - <MacroDechetTabUIHandler id='handler' - initializer='getContextValue(MacroDechetTabUIHandler.class)'/> - - <MacroDechetTabUIModel id='model' - initializer='getContextValue(MacroDechetTabUIModel.class)'/> - - <SwingValidatorMessageTableModel id='errorTableModel'/> - - <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' - uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> - <field name='totalWeight' component='totalWeightField'/> - <field name='sampleTotalWeight' component='sampleTotalWeightField'/> - </BeanValidator> - - <Table id='form' fill='both' constraints='BorderLayout.NORTH'> - - <!-- Poids total --> - <row> - <cell anchor='west'> - <JLabel id='totalWeightLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='totalWeightField' constructorParams='this'/> - </cell> - </row> - - <!-- Poids total échantillonné --> - <row> - <cell> - <JLabel id='sampleTotalWeightLabel'/> - </cell> - <cell> - <NumberEditor id='sampleTotalWeightField' constructorParams='this'/> - </cell> - </row> - </Table> - - <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> - <JTable id='table'/> - </JScrollPane> - -</JPanel> \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUIHandler.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUIHandler.java 2012-12-04 23:32:56 UTC (rev 29) @@ -1,181 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.catches; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.TraitBean; -import fr.ifremer.tutti.persistence.entities.TraitMacroDechetCatchBean; -import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; -import fr.ifremer.tutti.persistence.entities.referential.SpeciesBean; -import fr.ifremer.tutti.service.PersistenceService; -import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; -import jaxx.runtime.SwingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.JComboBox; -import javax.swing.JTable; -import javax.swing.table.DefaultTableColumnModel; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.List; - -import static org.nuiton.i18n.I18n._; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class MacroDechetTabUIHandler extends AbstractTuttiUIHandler<MacroDechetTabUIModel> { - - /** Logger. */ - private static final Log log = LogFactory.getLog(MacroDechetTabUIHandler.class); - - private final MacroDechetTabUI ui; - - private final CatchesUI parentUi; - - private final PersistenceService persistenceService; - - public MacroDechetTabUIHandler(CatchesUI parentUi, MacroDechetTabUI ui) { - super(parentUi.getHandler().getContext()); - this.ui = ui; - this.parentUi = parentUi; - this.persistenceService = context.getService(PersistenceService.class); - } - - @Override - public void beforeInitUI() { - - MacroDechetTabUIModel model = new MacroDechetTabUIModel(); - ui.setContextValue(model); - - JTable tb = new JTable(); - - TableCellEditor defaultEditor = tb.getDefaultEditor(String.class); - TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class); - - // prepare the table column model - TableColumnModel columnModel = new DefaultTableColumnModel(); - - TableColumn col; - - // species (by code) column - - col = new TableColumn(0); - - JComboBox speciesEditor = new JComboBox(); - List<SpeciesBean> allSpecies = persistenceService.getAllSpecies(); - SwingUtil.fillComboBox(speciesEditor, allSpecies, null); -// col.setCellEditor(); - col.setCellRenderer(newTableCellRender(SpeciesBean.class)); - col.setHeaderValue(_("tutti.table.macroDechet.header.speciesByCode")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("speciesByCode"); - columnModel.addColumn(col); - - // Poids observé - col = new TableColumn(1); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.macroDechet.header.weight")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("weight"); - columnModel.addColumn(col); - - // Nombre observé - col = new TableColumn(2); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.macroDechet.header.number")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("computedNumber"); - columnModel.addColumn(col); - - ui.setContextValue(columnModel); - - final MacroDechetTableModel tableModel = new MacroDechetTableModel(columnModel); - ui.setContextValue(tableModel); - - model.addPropertyChangeListener(MacroDechetTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - tableModel.setData((List<TraitSpeciesCatchBean>) evt.getNewValue()); - } - }); - - } - - @Override - public void afterInitUI() { - MacroDechetTabUIModel model = ui.getModel(); - - initUI(ui); - } - - @Override - public void onCloseUI() { - } - - @Override - protected MacroDechetTabUIModel getModel() { - return ui.getModel(); - } - - public void selectTrait(TraitBean bean) { - - boolean empty = bean == null; - - MacroDechetTabUIModel model = ui.getModel(); - - List<TraitMacroDechetCatchBean> catches; - - if (empty) { - catches = null; - bean = new TraitBean(); - } else { - catches = persistenceService.getAllTraitMacroDechetCatch(bean.getId()); - } - - model.fromBean(bean); - model.setCatches(catches); - } - - public void cancel() { - - if (log.isInfoEnabled()) { - log.info("Cancel edition"); - } - } - - public void save() { - if (log.isInfoEnabled()) { - log.info("Will save"); - } - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUIModel.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUIModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -1,95 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.catches; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.TraitBean; -import fr.ifremer.tutti.persistence.entities.TraitMacroDechetCatchBean; -import org.jdesktop.beans.AbstractSerializableBean; -import org.nuiton.util.beans.BinderFactory; - -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class MacroDechetTabUIModel extends AbstractSerializableBean { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; - - public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight"; - - public static final String PROPERTY_CATCHES = "catches"; - - protected Float totalWeight; - - protected Float sampleTotalWeight; - - protected List<TraitMacroDechetCatchBean> catches; - - public Float getTotalWeight() { - return totalWeight; - } - - public void setTotalWeight(Float totalWeight) { - Object oldValue = getTotalWeight(); - this.totalWeight = totalWeight; - firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); - } - - public Float getSampleTotalWeight() { - return sampleTotalWeight; - } - - public void setSampleTotalWeight(Float sampleTotalWeight) { - Object oldValue = getSampleTotalWeight(); - this.sampleTotalWeight = sampleTotalWeight; - firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight); - } - - public List<TraitMacroDechetCatchBean> getCatches() { - return catches; - } - - public void setCatches(List<TraitMacroDechetCatchBean> catches) { - Object oldValue = getCatches(); - this.catches = catches; - firePropertyChange(PROPERTY_CATCHES, oldValue, catches); - } - - public void fromBean(TraitBean bean) { - BinderFactory.newBinder(TraitBean.class, - MacroDechetTabUIModel.class).copy(bean, this); - } - - public TraitBean toBean() { - TraitBean result = new TraitBean(); - BinderFactory.newBinder(MacroDechetTabUIModel.class, - TraitBean.class).copy(this, result); - return result; - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTableModel.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTableModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -1,78 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.catches; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -import com.google.common.collect.Lists; -import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; - -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableColumnModel; -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class MacroDechetTableModel extends AbstractTableModel { - - private static final long serialVersionUID = 1L; - - protected List<TraitSpeciesCatchBean> data; - - protected final TableColumnModel columnModel; - - public MacroDechetTableModel(TableColumnModel columnModel) { - this.columnModel = columnModel; - } - - public void setData(List<TraitSpeciesCatchBean> data) { - if (data == null) { - data = Lists.newArrayList(); - data.add(new TraitSpeciesCatchBean()); - } - this.data = data; - fireTableDataChanged(); - } - - @Override - public int getRowCount() { - return data == null ? 0 : data.size(); - } - - @Override - public int getColumnCount() { - return columnModel.getColumnCount(); - } - - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - return null; - } - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return true; - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUI.css 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUI.css 2012-12-04 23:32:56 UTC (rev 29) @@ -1,59 +0,0 @@ -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -NumberEditor { - autoPopup:{handler.getConfig().isAutoPopupNumberEditor()}; - showPopupButton:{handler.getConfig().isShowNumberEditorButton()}; - bean:{model}; - showReset:true; -} - -#totalWeightLabel { - text:"tutti.label.plancton.totalWeight"; - labelFor:{totalWeightField}; -} - -#totalWeightField { - property:"totalWeight"; - model:{model.getTotalWeight()}; - useFloat:false; - numberPattern:{INT_6_DIGITS_PATTERN}; -} - -#sampleTotalWeightLabel { - text:"tutti.label.plancton.sampleTotalWeight"; - labelFor:{totalWeightField}; -} - -#sampleTotalWeightField { - property:"sampleTotalWeight"; - model:{model.getSampleTotalWeight()}; - useFloat:false; - numberPattern:{INT_6_DIGITS_PATTERN}; -} - -#table { - model:{getContextValue(TableModel.class)}; - columnModel:{getContextValue(TableColumnModel.class)}; -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUI.jaxx 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUI.jaxx 2012-12-04 23:32:56 UTC (rev 29) @@ -1,100 +0,0 @@ -<!-- - #%L - Tutti :: UI - $Id$ - $HeadURL$ - %% - Copyright (C) 2012 Ifremer - %% - 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 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 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-3.0.html>. - #L% - --> -<JPanel id='homePanel' layout='{new BorderLayout()}' - implements='fr.ifremer.tutti.ui.swing.TuttiUI<PlanctonTabUIModel, PlanctonTabUIHandler>'> - - <import> - fr.ifremer.tutti.persistence.entities.referential.BeaufortScaleBean - fr.ifremer.tutti.persistence.entities.referential.SeaStateBean - fr.ifremer.tutti.persistence.entities.StrataBean - fr.ifremer.tutti.persistence.entities.TraitBean - fr.ifremer.tutti.persistence.entities.referential.UserBean - fr.ifremer.tutti.ui.swing.TuttiUIContext - - jaxx.runtime.swing.editor.NumberEditor - - jaxx.runtime.validator.swing.SwingValidatorUtil - jaxx.runtime.validator.swing.SwingValidatorMessageTableModel - - javax.swing.table.TableModel - javax.swing.table.TableColumnModel - - static org.nuiton.i18n.I18n._ - </import> - - <script><![CDATA[ - -public PlanctonTabUI(CatchesUI parentUI) { - PlanctonTabUIHandler handler = new PlanctonTabUIHandler(parentUI, this); - setContextValue(handler); - handler.beforeInitUI(); -} - -public void selectTrait(TraitBean trait) { handler.selectTrait(trait); } - -protected void $afterCompleteSetup() { handler.afterInitUI(); } - ]]></script> - - <PlanctonTabUIHandler id='handler' - initializer='getContextValue(PlanctonTabUIHandler.class)'/> - - <PlanctonTabUIModel id='model' - initializer='getContextValue(PlanctonTabUIModel.class)'/> - - <SwingValidatorMessageTableModel id='errorTableModel'/> - - <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' - uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> - <field name='totalWeight' component='totalWeightField'/> - <field name='sampleTotalWeight' component='sampleTotalWeightField'/> - </BeanValidator> - - <Table id='form' fill='both' constraints='BorderLayout.NORTH'> - - <!-- Poids total --> - <row> - <cell anchor='west'> - <JLabel id='totalWeightLabel'/> - </cell> - <cell weightx='1.0'> - <NumberEditor id='totalWeightField' constructorParams='this'/> - </cell> - </row> - - <!-- Poids total échantillonné --> - <row> - <cell> - <JLabel id='sampleTotalWeightLabel'/> - </cell> - <cell> - <NumberEditor id='sampleTotalWeightField' constructorParams='this'/> - </cell> - </row> - </Table> - - <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> - <JTable id='table'/> - </JScrollPane> - -</JPanel> \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUIHandler.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUIHandler.java 2012-12-04 23:32:56 UTC (rev 29) @@ -1,181 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.catches; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.TraitBean; -import fr.ifremer.tutti.persistence.entities.TraitPlanctonCatchBean; -import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; -import fr.ifremer.tutti.persistence.entities.referential.SpeciesBean; -import fr.ifremer.tutti.service.PersistenceService; -import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; -import jaxx.runtime.SwingUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.JComboBox; -import javax.swing.JTable; -import javax.swing.table.DefaultTableColumnModel; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.List; - -import static org.nuiton.i18n.I18n._; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class PlanctonTabUIHandler extends AbstractTuttiUIHandler<PlanctonTabUIModel> { - - /** Logger. */ - private static final Log log = LogFactory.getLog(PlanctonTabUIHandler.class); - - private final PlanctonTabUI ui; - - private final CatchesUI parentUi; - - private final PersistenceService persistenceService; - - public PlanctonTabUIHandler(CatchesUI parentUi, PlanctonTabUI ui) { - super(parentUi.getHandler().getContext()); - this.ui = ui; - this.parentUi = parentUi; - this.persistenceService = context.getService(PersistenceService.class); - } - - @Override - public void beforeInitUI() { - - PlanctonTabUIModel model = new PlanctonTabUIModel(); - ui.setContextValue(model); - - JTable tb = new JTable(); - - TableCellEditor defaultEditor = tb.getDefaultEditor(String.class); - TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class); - - // prepare the table column model - TableColumnModel columnModel = new DefaultTableColumnModel(); - - TableColumn col; - - // species (by code) column - - col = new TableColumn(0); - - JComboBox speciesEditor = new JComboBox(); - List<SpeciesBean> allSpecies = persistenceService.getAllSpecies(); - SwingUtil.fillComboBox(speciesEditor, allSpecies, null); -// col.setCellEditor(); - col.setCellRenderer(newTableCellRender(SpeciesBean.class)); - col.setHeaderValue(_("tutti.table.plancton.header.speciesByCode")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("speciesByCode"); - columnModel.addColumn(col); - - // Poids observé - col = new TableColumn(1); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.plancton.header.weight")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("weight"); - columnModel.addColumn(col); - - // Nombre observé - col = new TableColumn(2); - col.setCellEditor(defaultEditor); - col.setCellRenderer(defaultRenderer); - col.setHeaderValue(_("tutti.table.plancton.header.number")); -// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); - col.setIdentifier("computedNumber"); - columnModel.addColumn(col); - - ui.setContextValue(columnModel); - - final PlanctonTableModel tableModel = new PlanctonTableModel(columnModel); - ui.setContextValue(tableModel); - - model.addPropertyChangeListener(PlanctonTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - tableModel.setData((List<TraitSpeciesCatchBean>) evt.getNewValue()); - } - }); - - } - - @Override - public void afterInitUI() { - PlanctonTabUIModel model = ui.getModel(); - - initUI(ui); - } - - @Override - public void onCloseUI() { - } - - @Override - protected PlanctonTabUIModel getModel() { - return ui.getModel(); - } - - public void selectTrait(TraitBean bean) { - - boolean empty = bean == null; - - PlanctonTabUIModel model = ui.getModel(); - - List<TraitPlanctonCatchBean> catches; - - if (empty) { - catches = null; - bean = new TraitBean(); - } else { - catches = persistenceService.getAllTraitPlanctonCatch(bean.getId()); - } - - model.fromBean(bean); - model.setCatches(catches); - } - - public void cancel() { - - if (log.isInfoEnabled()) { - log.info("Cancel edition"); - } - } - - public void save() { - if (log.isInfoEnabled()) { - log.info("Will save"); - } - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUIModel.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUIModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -1,95 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.catches; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.entities.TraitBean; -import fr.ifremer.tutti.persistence.entities.TraitPlanctonCatchBean; -import org.jdesktop.beans.AbstractSerializableBean; -import org.nuiton.util.beans.BinderFactory; - -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class PlanctonTabUIModel extends AbstractSerializableBean { - - private static final long serialVersionUID = 1L; - - public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; - - public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight"; - - public static final String PROPERTY_CATCHES = "catches"; - - protected Float totalWeight; - - protected Float sampleTotalWeight; - - protected List<TraitPlanctonCatchBean> catches; - - public Float getTotalWeight() { - return totalWeight; - } - - public void setTotalWeight(Float totalWeight) { - Object oldValue = getTotalWeight(); - this.totalWeight = totalWeight; - firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); - } - - public Float getSampleTotalWeight() { - return sampleTotalWeight; - } - - public void setSampleTotalWeight(Float sampleTotalWeight) { - Object oldValue = getSampleTotalWeight(); - this.sampleTotalWeight = sampleTotalWeight; - firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight); - } - - public List<TraitPlanctonCatchBean> getCatches() { - return catches; - } - - public void setCatches(List<TraitPlanctonCatchBean> catches) { - Object oldValue = getCatches(); - this.catches = catches; - firePropertyChange(PROPERTY_CATCHES, oldValue, catches); - } - - public void fromBean(TraitBean bean) { - BinderFactory.newBinder(TraitBean.class, - PlanctonTabUIModel.class).copy(bean, this); - } - - public TraitBean toBean() { - TraitBean result = new TraitBean(); - BinderFactory.newBinder(PlanctonTabUIModel.class, - TraitBean.class).copy(this, result); - return result; - } -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTableModel.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTableModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -1,78 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.catches; - -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * 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 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 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-3.0.html>. - * #L% - */ - -import com.google.common.collect.Lists; -import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; - -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableColumnModel; -import java.util.List; - -/** - * @author tchemit <chemit@codelutin.com> - * @since 0.2 - */ -public class PlanctonTableModel extends AbstractTableModel { - - private static final long serialVersionUID = 1L; - - protected List<TraitSpeciesCatchBean> data; - - protected final TableColumnModel columnModel; - - public PlanctonTableModel(TableColumnModel columnModel) { - this.columnModel = columnModel; - } - - public void setData(List<TraitSpeciesCatchBean> data) { - if (data == null) { - data = Lists.newArrayList(); - data.add(new TraitSpeciesCatchBean()); - } - this.data = data; - fireTableDataChanged(); - } - - @Override - public int getRowCount() { - return data == null ? 0 : data.size(); - } - - @Override - public int getColumnCount() { - return columnModel.getColumnCount(); - } - - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - return null; - } - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return true; - } -} \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUI.css (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUI.css 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,59 @@ +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +NumberEditor { + autoPopup:{handler.getConfig().isAutoPopupNumberEditor()}; + showPopupButton:{handler.getConfig().isShowNumberEditorButton()}; + bean:{model}; + showReset:true; +} + +#totalWeightLabel { + text:"tutti.label.captureAccidentel.totalWeight"; + labelFor:{totalWeightField}; +} + +#totalWeightField { + property:"totalWeight"; + model:{model.getTotalWeight()}; + useFloat:false; + numberPattern:{INT_6_DIGITS_PATTERN}; +} + +#sampleTotalWeightLabel { + text:"tutti.label.captureAccidentel.sampleTotalWeight"; + labelFor:{totalWeightField}; +} + +#sampleTotalWeightField { + property:"sampleTotalWeight"; + model:{model.getSampleTotalWeight()}; + useFloat:false; + numberPattern:{INT_6_DIGITS_PATTERN}; +} + +#table { + model:{getContextValue(TableModel.class)}; + columnModel:{getContextValue(TableColumnModel.class)}; +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUI.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUI.jaxx (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUI.jaxx 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,98 @@ +<!-- + #%L + Tutti :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 Ifremer + %% + 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 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 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-3.0.html>. + #L% + --> +<JPanel id='homePanel' layout='{new BorderLayout()}' + implements='fr.ifremer.tutti.ui.swing.TuttiUI<AccidentelTabUIModel, AccidentelTabUIHandler>'> + + <import> + fr.ifremer.tutti.persistence.entities.TraitBean + + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.catches.CatchesUI + + jaxx.runtime.swing.editor.NumberEditor + + jaxx.runtime.validator.swing.SwingValidatorUtil + jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + + javax.swing.table.TableModel + javax.swing.table.TableColumnModel + + static org.nuiton.i18n.I18n._ + </import> + + <script><![CDATA[ + +public AccidentelTabUI(CatchesUI parentUI) { + AccidentelTabUIHandler handler = new AccidentelTabUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +public void selectTrait(TraitBean trait) { handler.selectTrait(trait); } + +protected void $afterCompleteSetup() { handler.afterInitUI(); } + ]]></script> + + <AccidentelTabUIHandler id='handler' + initializer='getContextValue(AccidentelTabUIHandler.class)'/> + + <AccidentelTabUIModel id='model' + initializer='getContextValue(AccidentelTabUIModel.class)'/> + + <SwingValidatorMessageTableModel id='errorTableModel'/> + + <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' + uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> + <field name='totalWeight' component='totalWeightField'/> + <field name='sampleTotalWeight' component='sampleTotalWeightField'/> + </BeanValidator> + + <Table id='form' fill='both' constraints='BorderLayout.NORTH'> + + <!-- Poids total --> + <row> + <cell anchor='west'> + <JLabel id='totalWeightLabel'/> + </cell> + <cell weightx='1.0'> + <NumberEditor id='totalWeightField' constructorParams='this'/> + </cell> + </row> + + <!-- Poids total échantillonné --> + <row> + <cell> + <JLabel id='sampleTotalWeightLabel'/> + </cell> + <cell> + <NumberEditor id='sampleTotalWeightField' constructorParams='this'/> + </cell> + </row> + </Table> + + <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> + <JTable id='table'/> + </JScrollPane> + +</JPanel> \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUIHandler.java (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUIHandler.java 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,182 @@ +package fr.ifremer.tutti.ui.swing.content.catches.accidentel; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.TraitBean; +import fr.ifremer.tutti.persistence.entities.TraitCaptureAccidentelCatchBean; +import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; +import fr.ifremer.tutti.persistence.entities.referential.SpeciesBean; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; +import fr.ifremer.tutti.ui.swing.content.catches.CatchesUI; +import jaxx.runtime.SwingUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.table.DefaultTableColumnModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class AccidentelTabUIHandler extends AbstractTuttiUIHandler<AccidentelTabUIModel> { + + /** Logger. */ + private static final Log log = LogFactory.getLog(AccidentelTabUIHandler.class); + + private final AccidentelTabUI ui; + + private final CatchesUI parentUi; + + private final PersistenceService persistenceService; + + public AccidentelTabUIHandler(CatchesUI parentUi, AccidentelTabUI ui) { + super(parentUi.getHandler().getContext()); + this.ui = ui; + this.parentUi = parentUi; + this.persistenceService = context.getService(PersistenceService.class); + } + + @Override + public void beforeInitUI() { + + AccidentelTabUIModel model = new AccidentelTabUIModel(); + ui.setContextValue(model); + + JTable tb = new JTable(); + + TableCellEditor defaultEditor = tb.getDefaultEditor(String.class); + TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class); + + // prepare the table column model + TableColumnModel columnModel = new DefaultTableColumnModel(); + + TableColumn col; + + // species (by code) column + + col = new TableColumn(0); + + JComboBox speciesEditor = new JComboBox(); + List<SpeciesBean> allSpecies = persistenceService.getAllSpecies(); + SwingUtil.fillComboBox(speciesEditor, allSpecies, null); +// col.setCellEditor(); + col.setCellRenderer(newTableCellRender(SpeciesBean.class)); + col.setHeaderValue(_("tutti.table.captureAccidentel.header.speciesByCode")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("speciesByCode"); + columnModel.addColumn(col); + + // Poids observé + col = new TableColumn(1); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.captureAccidentel.header.weight")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("weight"); + columnModel.addColumn(col); + + // Nombre observé + col = new TableColumn(2); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.captureAccidentel.header.number")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("computedNumber"); + columnModel.addColumn(col); + + ui.setContextValue(columnModel); + + final AccidentelTableModel tableModel = new AccidentelTableModel(columnModel); + ui.setContextValue(tableModel); + + model.addPropertyChangeListener(AccidentelTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + tableModel.setData((List<TraitSpeciesCatchBean>) evt.getNewValue()); + } + }); + + } + + @Override + public void afterInitUI() { + AccidentelTabUIModel model = ui.getModel(); + + initUI(ui); + } + + @Override + public void onCloseUI() { + } + + @Override + protected AccidentelTabUIModel getModel() { + return ui.getModel(); + } + + public void selectTrait(TraitBean bean) { + + boolean empty = bean == null; + + AccidentelTabUIModel model = ui.getModel(); + + List<TraitCaptureAccidentelCatchBean> catches; + + if (empty) { + catches = null; + bean = new TraitBean(); + } else { + catches = persistenceService.getAllTraitCaptureAccidentelCatch(bean.getId()); + } + + model.fromBean(bean); + model.setCatches(catches); + } + + public void cancel() { + + if (log.isInfoEnabled()) { + log.info("Cancel edition"); + } + } + + public void save() { + if (log.isInfoEnabled()) { + log.info("Will save"); + } + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUIHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUIModel.java (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTabUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUIModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,95 @@ +package fr.ifremer.tutti.ui.swing.content.catches.accidentel; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.TraitBean; +import fr.ifremer.tutti.persistence.entities.TraitCaptureAccidentelCatchBean; +import org.jdesktop.beans.AbstractSerializableBean; +import org.nuiton.util.beans.BinderFactory; + +import java.util.List; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class AccidentelTabUIModel extends AbstractSerializableBean { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; + + public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight"; + + public static final String PROPERTY_CATCHES = "catches"; + + protected Float totalWeight; + + protected Float sampleTotalWeight; + + protected List<TraitCaptureAccidentelCatchBean> catches; + + public Float getTotalWeight() { + return totalWeight; + } + + public void setTotalWeight(Float totalWeight) { + Object oldValue = getTotalWeight(); + this.totalWeight = totalWeight; + firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); + } + + public Float getSampleTotalWeight() { + return sampleTotalWeight; + } + + public void setSampleTotalWeight(Float sampleTotalWeight) { + Object oldValue = getSampleTotalWeight(); + this.sampleTotalWeight = sampleTotalWeight; + firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight); + } + + public List<TraitCaptureAccidentelCatchBean> getCatches() { + return catches; + } + + public void setCatches(List<TraitCaptureAccidentelCatchBean> catches) { + Object oldValue = getCatches(); + this.catches = catches; + firePropertyChange(PROPERTY_CATCHES, oldValue, catches); + } + + public void fromBean(TraitBean bean) { + BinderFactory.newBinder(TraitBean.class, + AccidentelTabUIModel.class).copy(bean, this); + } + + public TraitBean toBean() { + TraitBean result = new TraitBean(); + BinderFactory.newBinder(AccidentelTabUIModel.class, + TraitBean.class).copy(this, result); + return result; + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTabUIModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTableModel.java (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CaptureAccidentelTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTableModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,78 @@ +package fr.ifremer.tutti.ui.swing.content.catches.accidentel; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; + +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableColumnModel; +import java.util.List; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class AccidentelTableModel extends AbstractTableModel { + + private static final long serialVersionUID = 1L; + + protected List<TraitSpeciesCatchBean> data; + + protected final TableColumnModel columnModel; + + public AccidentelTableModel(TableColumnModel columnModel) { + this.columnModel = columnModel; + } + + public void setData(List<TraitSpeciesCatchBean> data) { + if (data == null) { + data = Lists.newArrayList(); + data.add(new TraitSpeciesCatchBean()); + } + this.data = data; + fireTableDataChanged(); + } + + @Override + public int getRowCount() { + return data == null ? 0 : data.size(); + } + + @Override + public int getColumnCount() { + return columnModel.getColumnCount(); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + return null; + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return true; + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/accidentel/AccidentelTableModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUI.css (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUI.css 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,59 @@ +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +NumberEditor { + autoPopup:{handler.getConfig().isAutoPopupNumberEditor()}; + showPopupButton:{handler.getConfig().isShowNumberEditorButton()}; + bean:{model}; + showReset:true; +} + +#totalWeightLabel { + text:"tutti.label.benthos.totalWeight"; + labelFor:{totalWeightField}; +} + +#totalWeightField { + property:"totalWeight"; + model:{model.getTotalWeight()}; + useFloat:false; + numberPattern:{INT_6_DIGITS_PATTERN}; +} + +#sampleTotalWeightLabel { + text:"tutti.label.benthos.sampleTotalWeight"; + labelFor:{totalWeightField}; +} + +#sampleTotalWeightField { + property:"sampleTotalWeight"; + model:{model.getSampleTotalWeight()}; + useFloat:false; + numberPattern:{INT_6_DIGITS_PATTERN}; +} + +#table { + model:{getContextValue(TableModel.class)}; + columnModel:{getContextValue(TableColumnModel.class)}; +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUI.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUI.jaxx (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUI.jaxx 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,98 @@ +<!-- + #%L + Tutti :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 Ifremer + %% + 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 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 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-3.0.html>. + #L% + --> +<JPanel id='homePanel' layout='{new BorderLayout()}' + implements='fr.ifremer.tutti.ui.swing.TuttiUI<BenthosTabUIModel, BenthosTabUIHandler>'> + + <import> + fr.ifremer.tutti.persistence.entities.TraitBean + + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.catches.CatchesUI + + jaxx.runtime.swing.editor.NumberEditor + + jaxx.runtime.validator.swing.SwingValidatorUtil + jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + + javax.swing.table.TableModel + javax.swing.table.TableColumnModel + + static org.nuiton.i18n.I18n._ + </import> + + <script><![CDATA[ + +public BenthosTabUI(CatchesUI parentUI) { + BenthosTabUIHandler handler = new BenthosTabUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +public void selectTrait(TraitBean trait) { handler.selectTrait(trait); } + +protected void $afterCompleteSetup() { handler.afterInitUI(); } + ]]></script> + + <BenthosTabUIHandler id='handler' + initializer='getContextValue(BenthosTabUIHandler.class)'/> + + <BenthosTabUIModel id='model' + initializer='getContextValue(BenthosTabUIModel.class)'/> + + <SwingValidatorMessageTableModel id='errorTableModel'/> + + <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' + uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> + <field name='totalWeight' component='totalWeightField'/> + <field name='sampleTotalWeight' component='sampleTotalWeightField'/> + </BeanValidator> + + <Table id='form' fill='both' constraints='BorderLayout.NORTH'> + + <!-- Poids total --> + <row> + <cell anchor='west'> + <JLabel id='totalWeightLabel'/> + </cell> + <cell weightx='1.0'> + <NumberEditor id='totalWeightField' constructorParams='this'/> + </cell> + </row> + + <!-- Poids total échantillonné --> + <row> + <cell> + <JLabel id='sampleTotalWeightLabel'/> + </cell> + <cell> + <NumberEditor id='sampleTotalWeightField' constructorParams='this'/> + </cell> + </row> + </Table> + + <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> + <JTable id='table'/> + </JScrollPane> + +</JPanel> Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUIHandler.java (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUIHandler.java 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,182 @@ +package fr.ifremer.tutti.ui.swing.content.catches.benthos; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.TraitBean; +import fr.ifremer.tutti.persistence.entities.TraitBenthosCatchBean; +import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; +import fr.ifremer.tutti.persistence.entities.referential.SpeciesBean; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; +import fr.ifremer.tutti.ui.swing.content.catches.CatchesUI; +import jaxx.runtime.SwingUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.table.DefaultTableColumnModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class BenthosTabUIHandler extends AbstractTuttiUIHandler<BenthosTabUIModel> { + + /** Logger. */ + private static final Log log = LogFactory.getLog(BenthosTabUIHandler.class); + + private final BenthosTabUI ui; + + private final CatchesUI parentUi; + + private final PersistenceService persistenceService; + + public BenthosTabUIHandler(CatchesUI parentUi, BenthosTabUI ui) { + super(parentUi.getHandler().getContext()); + this.ui = ui; + this.parentUi = parentUi; + this.persistenceService = context.getService(PersistenceService.class); + } + + @Override + public void beforeInitUI() { + + BenthosTabUIModel model = new BenthosTabUIModel(); + ui.setContextValue(model); + + JTable tb = new JTable(); + + TableCellEditor defaultEditor = tb.getDefaultEditor(String.class); + TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class); + + // prepare the table column model + TableColumnModel columnModel = new DefaultTableColumnModel(); + + TableColumn col; + + // species (by code) column + + col = new TableColumn(0); + + JComboBox speciesEditor = new JComboBox(); + List<SpeciesBean> allSpecies = persistenceService.getAllSpecies(); + SwingUtil.fillComboBox(speciesEditor, allSpecies, null); +// col.setCellEditor(); + col.setCellRenderer(newTableCellRender(SpeciesBean.class)); + col.setHeaderValue(_("tutti.table.benthos.header.speciesByCode")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("speciesByCode"); + columnModel.addColumn(col); + + // Poids observé + col = new TableColumn(1); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.benthos.header.weight")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("weight"); + columnModel.addColumn(col); + + // Nombre observé + col = new TableColumn(2); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.benthos.header.number")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("computedNumber"); + columnModel.addColumn(col); + + ui.setContextValue(columnModel); + + final BenthosTableModel tableModel = new BenthosTableModel(columnModel); + ui.setContextValue(tableModel); + + model.addPropertyChangeListener(BenthosTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + tableModel.setData((List<TraitSpeciesCatchBean>) evt.getNewValue()); + } + }); + + } + + @Override + public void afterInitUI() { + BenthosTabUIModel model = ui.getModel(); + + initUI(ui); + } + + @Override + public void onCloseUI() { + } + + @Override + protected BenthosTabUIModel getModel() { + return ui.getModel(); + } + + public void selectTrait(TraitBean bean) { + + boolean empty = bean == null; + + BenthosTabUIModel model = ui.getModel(); + + List<TraitBenthosCatchBean> catches; + + if (empty) { + catches = null; + bean = new TraitBean(); + } else { + catches = persistenceService.getAllTraitBenthosCatch(bean.getId()); + } + + model.fromBean(bean); + model.setCatches(catches); + } + + public void cancel() { + + if (log.isInfoEnabled()) { + log.info("Cancel edition"); + } + } + + public void save() { + if (log.isInfoEnabled()) { + log.info("Will save"); + } + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUIHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUIModel.java (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUIModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,95 @@ +package fr.ifremer.tutti.ui.swing.content.catches.benthos; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.TraitBean; +import fr.ifremer.tutti.persistence.entities.TraitBenthosCatchBean; +import org.jdesktop.beans.AbstractSerializableBean; +import org.nuiton.util.beans.BinderFactory; + +import java.util.List; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class BenthosTabUIModel extends AbstractSerializableBean { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; + + public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight"; + + public static final String PROPERTY_CATCHES = "catches"; + + protected Float totalWeight; + + protected Float sampleTotalWeight; + + protected List<TraitBenthosCatchBean> catches; + + public Float getTotalWeight() { + return totalWeight; + } + + public void setTotalWeight(Float totalWeight) { + Object oldValue = getTotalWeight(); + this.totalWeight = totalWeight; + firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); + } + + public Float getSampleTotalWeight() { + return sampleTotalWeight; + } + + public void setSampleTotalWeight(Float sampleTotalWeight) { + Object oldValue = getSampleTotalWeight(); + this.sampleTotalWeight = sampleTotalWeight; + firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight); + } + + public List<TraitBenthosCatchBean> getCatches() { + return catches; + } + + public void setCatches(List<TraitBenthosCatchBean> catches) { + Object oldValue = getCatches(); + this.catches = catches; + firePropertyChange(PROPERTY_CATCHES, oldValue, catches); + } + + public void fromBean(TraitBean bean) { + BinderFactory.newBinder(TraitBean.class, + BenthosTabUIModel.class).copy(bean, this); + } + + public TraitBean toBean() { + TraitBean result = new TraitBean(); + BinderFactory.newBinder(BenthosTabUIModel.class, + TraitBean.class).copy(this, result); + return result; + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTabUIModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTableModel.java (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTableModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,78 @@ +package fr.ifremer.tutti.ui.swing.content.catches.benthos; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; + +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableColumnModel; +import java.util.List; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class BenthosTableModel extends AbstractTableModel { + + private static final long serialVersionUID = 1L; + + protected List<TraitSpeciesCatchBean> data; + + protected final TableColumnModel columnModel; + + public BenthosTableModel(TableColumnModel columnModel) { + this.columnModel = columnModel; + } + + public void setData(List<TraitSpeciesCatchBean> data) { + if (data == null) { + data = Lists.newArrayList(); + data.add(new TraitSpeciesCatchBean()); + } + this.data = data; + fireTableDataChanged(); + } + + @Override + public int getRowCount() { + return data == null ? 0 : data.size(); + } + + @Override + public int getColumnCount() { + return columnModel.getColumnCount(); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + return null; + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return true; + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/benthos/BenthosTableModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUI.css (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUI.css 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,59 @@ +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +NumberEditor { + autoPopup:{handler.getConfig().isAutoPopupNumberEditor()}; + showPopupButton:{handler.getConfig().isShowNumberEditorButton()}; + bean:{model}; + showReset:true; +} + +#totalWeightLabel { + text:"tutti.label.macroDechet.totalWeight"; + labelFor:{totalWeightField}; +} + +#totalWeightField { + property:"totalWeight"; + model:{model.getTotalWeight()}; + useFloat:false; + numberPattern:{INT_6_DIGITS_PATTERN}; +} + +#sampleTotalWeightLabel { + text:"tutti.label.macroDechet.sampleTotalWeight"; + labelFor:{totalWeightField}; +} + +#sampleTotalWeightField { + property:"sampleTotalWeight"; + model:{model.getSampleTotalWeight()}; + useFloat:false; + numberPattern:{INT_6_DIGITS_PATTERN}; +} + +#table { + model:{getContextValue(TableModel.class)}; + columnModel:{getContextValue(TableColumnModel.class)}; +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUI.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUI.jaxx (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUI.jaxx 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,98 @@ +<!-- + #%L + Tutti :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 Ifremer + %% + 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 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 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-3.0.html>. + #L% + --> +<JPanel id='homePanel' layout='{new BorderLayout()}' + implements='fr.ifremer.tutti.ui.swing.TuttiUI<MacroDechetTabUIModel, MacroDechetTabUIHandler>'> + + <import> + fr.ifremer.tutti.persistence.entities.TraitBean + + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.catches.CatchesUI + + jaxx.runtime.swing.editor.NumberEditor + + jaxx.runtime.validator.swing.SwingValidatorUtil + jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + + javax.swing.table.TableModel + javax.swing.table.TableColumnModel + + static org.nuiton.i18n.I18n._ + </import> + + <script><![CDATA[ + +public MacroDechetTabUI(CatchesUI parentUI) { + MacroDechetTabUIHandler handler = new MacroDechetTabUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +public void selectTrait(TraitBean trait) { handler.selectTrait(trait); } + +protected void $afterCompleteSetup() { handler.afterInitUI(); } + ]]></script> + + <MacroDechetTabUIHandler id='handler' + initializer='getContextValue(MacroDechetTabUIHandler.class)'/> + + <MacroDechetTabUIModel id='model' + initializer='getContextValue(MacroDechetTabUIModel.class)'/> + + <SwingValidatorMessageTableModel id='errorTableModel'/> + + <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' + uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> + <field name='totalWeight' component='totalWeightField'/> + <field name='sampleTotalWeight' component='sampleTotalWeightField'/> + </BeanValidator> + + <Table id='form' fill='both' constraints='BorderLayout.NORTH'> + + <!-- Poids total --> + <row> + <cell anchor='west'> + <JLabel id='totalWeightLabel'/> + </cell> + <cell weightx='1.0'> + <NumberEditor id='totalWeightField' constructorParams='this'/> + </cell> + </row> + + <!-- Poids total échantillonné --> + <row> + <cell> + <JLabel id='sampleTotalWeightLabel'/> + </cell> + <cell> + <NumberEditor id='sampleTotalWeightField' constructorParams='this'/> + </cell> + </row> + </Table> + + <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> + <JTable id='table'/> + </JScrollPane> + +</JPanel> \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUIHandler.java (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUIHandler.java 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,182 @@ +package fr.ifremer.tutti.ui.swing.content.catches.macrodechet; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.TraitBean; +import fr.ifremer.tutti.persistence.entities.TraitMacroDechetCatchBean; +import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; +import fr.ifremer.tutti.persistence.entities.referential.SpeciesBean; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; +import fr.ifremer.tutti.ui.swing.content.catches.CatchesUI; +import jaxx.runtime.SwingUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.table.DefaultTableColumnModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class MacroDechetTabUIHandler extends AbstractTuttiUIHandler<MacroDechetTabUIModel> { + + /** Logger. */ + private static final Log log = LogFactory.getLog(MacroDechetTabUIHandler.class); + + private final MacroDechetTabUI ui; + + private final CatchesUI parentUi; + + private final PersistenceService persistenceService; + + public MacroDechetTabUIHandler(CatchesUI parentUi, MacroDechetTabUI ui) { + super(parentUi.getHandler().getContext()); + this.ui = ui; + this.parentUi = parentUi; + this.persistenceService = context.getService(PersistenceService.class); + } + + @Override + public void beforeInitUI() { + + MacroDechetTabUIModel model = new MacroDechetTabUIModel(); + ui.setContextValue(model); + + JTable tb = new JTable(); + + TableCellEditor defaultEditor = tb.getDefaultEditor(String.class); + TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class); + + // prepare the table column model + TableColumnModel columnModel = new DefaultTableColumnModel(); + + TableColumn col; + + // species (by code) column + + col = new TableColumn(0); + + JComboBox speciesEditor = new JComboBox(); + List<SpeciesBean> allSpecies = persistenceService.getAllSpecies(); + SwingUtil.fillComboBox(speciesEditor, allSpecies, null); +// col.setCellEditor(); + col.setCellRenderer(newTableCellRender(SpeciesBean.class)); + col.setHeaderValue(_("tutti.table.macroDechet.header.speciesByCode")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("speciesByCode"); + columnModel.addColumn(col); + + // Poids observé + col = new TableColumn(1); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.macroDechet.header.weight")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("weight"); + columnModel.addColumn(col); + + // Nombre observé + col = new TableColumn(2); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.macroDechet.header.number")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("computedNumber"); + columnModel.addColumn(col); + + ui.setContextValue(columnModel); + + final MacroDechetTableModel tableModel = new MacroDechetTableModel(columnModel); + ui.setContextValue(tableModel); + + model.addPropertyChangeListener(MacroDechetTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + tableModel.setData((List<TraitSpeciesCatchBean>) evt.getNewValue()); + } + }); + + } + + @Override + public void afterInitUI() { + MacroDechetTabUIModel model = ui.getModel(); + + initUI(ui); + } + + @Override + public void onCloseUI() { + } + + @Override + protected MacroDechetTabUIModel getModel() { + return ui.getModel(); + } + + public void selectTrait(TraitBean bean) { + + boolean empty = bean == null; + + MacroDechetTabUIModel model = ui.getModel(); + + List<TraitMacroDechetCatchBean> catches; + + if (empty) { + catches = null; + bean = new TraitBean(); + } else { + catches = persistenceService.getAllTraitMacroDechetCatch(bean.getId()); + } + + model.fromBean(bean); + model.setCatches(catches); + } + + public void cancel() { + + if (log.isInfoEnabled()) { + log.info("Cancel edition"); + } + } + + public void save() { + if (log.isInfoEnabled()) { + log.info("Will save"); + } + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUIHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUIModel.java (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTabUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUIModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,95 @@ +package fr.ifremer.tutti.ui.swing.content.catches.macrodechet; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.TraitBean; +import fr.ifremer.tutti.persistence.entities.TraitMacroDechetCatchBean; +import org.jdesktop.beans.AbstractSerializableBean; +import org.nuiton.util.beans.BinderFactory; + +import java.util.List; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class MacroDechetTabUIModel extends AbstractSerializableBean { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; + + public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight"; + + public static final String PROPERTY_CATCHES = "catches"; + + protected Float totalWeight; + + protected Float sampleTotalWeight; + + protected List<TraitMacroDechetCatchBean> catches; + + public Float getTotalWeight() { + return totalWeight; + } + + public void setTotalWeight(Float totalWeight) { + Object oldValue = getTotalWeight(); + this.totalWeight = totalWeight; + firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); + } + + public Float getSampleTotalWeight() { + return sampleTotalWeight; + } + + public void setSampleTotalWeight(Float sampleTotalWeight) { + Object oldValue = getSampleTotalWeight(); + this.sampleTotalWeight = sampleTotalWeight; + firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight); + } + + public List<TraitMacroDechetCatchBean> getCatches() { + return catches; + } + + public void setCatches(List<TraitMacroDechetCatchBean> catches) { + Object oldValue = getCatches(); + this.catches = catches; + firePropertyChange(PROPERTY_CATCHES, oldValue, catches); + } + + public void fromBean(TraitBean bean) { + BinderFactory.newBinder(TraitBean.class, + MacroDechetTabUIModel.class).copy(bean, this); + } + + public TraitBean toBean() { + TraitBean result = new TraitBean(); + BinderFactory.newBinder(MacroDechetTabUIModel.class, + TraitBean.class).copy(this, result); + return result; + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTabUIModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTableModel.java (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/MacroDechetTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTableModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,78 @@ +package fr.ifremer.tutti.ui.swing.content.catches.macrodechet; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; + +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableColumnModel; +import java.util.List; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class MacroDechetTableModel extends AbstractTableModel { + + private static final long serialVersionUID = 1L; + + protected List<TraitSpeciesCatchBean> data; + + protected final TableColumnModel columnModel; + + public MacroDechetTableModel(TableColumnModel columnModel) { + this.columnModel = columnModel; + } + + public void setData(List<TraitSpeciesCatchBean> data) { + if (data == null) { + data = Lists.newArrayList(); + data.add(new TraitSpeciesCatchBean()); + } + this.data = data; + fireTableDataChanged(); + } + + @Override + public int getRowCount() { + return data == null ? 0 : data.size(); + } + + @Override + public int getColumnCount() { + return columnModel.getColumnCount(); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + return null; + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return true; + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/macrodechet/MacroDechetTableModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUI.css (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUI.css 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,59 @@ +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +NumberEditor { + autoPopup:{handler.getConfig().isAutoPopupNumberEditor()}; + showPopupButton:{handler.getConfig().isShowNumberEditorButton()}; + bean:{model}; + showReset:true; +} + +#totalWeightLabel { + text:"tutti.label.plancton.totalWeight"; + labelFor:{totalWeightField}; +} + +#totalWeightField { + property:"totalWeight"; + model:{model.getTotalWeight()}; + useFloat:false; + numberPattern:{INT_6_DIGITS_PATTERN}; +} + +#sampleTotalWeightLabel { + text:"tutti.label.plancton.sampleTotalWeight"; + labelFor:{totalWeightField}; +} + +#sampleTotalWeightField { + property:"sampleTotalWeight"; + model:{model.getSampleTotalWeight()}; + useFloat:false; + numberPattern:{INT_6_DIGITS_PATTERN}; +} + +#table { + model:{getContextValue(TableModel.class)}; + columnModel:{getContextValue(TableColumnModel.class)}; +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUI.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUI.jaxx (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUI.jaxx 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,98 @@ +<!-- + #%L + Tutti :: UI + $Id$ + $HeadURL$ + %% + Copyright (C) 2012 Ifremer + %% + 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 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 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-3.0.html>. + #L% + --> +<JPanel id='homePanel' layout='{new BorderLayout()}' + implements='fr.ifremer.tutti.ui.swing.TuttiUI<PlanctonTabUIModel, PlanctonTabUIHandler>'> + + <import> + fr.ifremer.tutti.persistence.entities.TraitBean + + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.catches.CatchesUI + + jaxx.runtime.swing.editor.NumberEditor + + jaxx.runtime.validator.swing.SwingValidatorUtil + jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + + javax.swing.table.TableModel + javax.swing.table.TableColumnModel + + static org.nuiton.i18n.I18n._ + </import> + + <script><![CDATA[ + +public PlanctonTabUI(CatchesUI parentUI) { + PlanctonTabUIHandler handler = new PlanctonTabUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +public void selectTrait(TraitBean trait) { handler.selectTrait(trait); } + +protected void $afterCompleteSetup() { handler.afterInitUI(); } + ]]></script> + + <PlanctonTabUIHandler id='handler' + initializer='getContextValue(PlanctonTabUIHandler.class)'/> + + <PlanctonTabUIModel id='model' + initializer='getContextValue(PlanctonTabUIModel.class)'/> + + <SwingValidatorMessageTableModel id='errorTableModel'/> + + <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel' + uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'> + <field name='totalWeight' component='totalWeightField'/> + <field name='sampleTotalWeight' component='sampleTotalWeightField'/> + </BeanValidator> + + <Table id='form' fill='both' constraints='BorderLayout.NORTH'> + + <!-- Poids total --> + <row> + <cell anchor='west'> + <JLabel id='totalWeightLabel'/> + </cell> + <cell weightx='1.0'> + <NumberEditor id='totalWeightField' constructorParams='this'/> + </cell> + </row> + + <!-- Poids total échantillonné --> + <row> + <cell> + <JLabel id='sampleTotalWeightLabel'/> + </cell> + <cell> + <NumberEditor id='sampleTotalWeightField' constructorParams='this'/> + </cell> + </row> + </Table> + + <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> + <JTable id='table'/> + </JScrollPane> + +</JPanel> \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUIHandler.java (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUIHandler.java 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,182 @@ +package fr.ifremer.tutti.ui.swing.content.catches.plancton; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.TraitBean; +import fr.ifremer.tutti.persistence.entities.TraitPlanctonCatchBean; +import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; +import fr.ifremer.tutti.persistence.entities.referential.SpeciesBean; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; +import fr.ifremer.tutti.ui.swing.content.catches.CatchesUI; +import jaxx.runtime.SwingUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.table.DefaultTableColumnModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class PlanctonTabUIHandler extends AbstractTuttiUIHandler<PlanctonTabUIModel> { + + /** Logger. */ + private static final Log log = LogFactory.getLog(PlanctonTabUIHandler.class); + + private final PlanctonTabUI ui; + + private final CatchesUI parentUi; + + private final PersistenceService persistenceService; + + public PlanctonTabUIHandler(CatchesUI parentUi, PlanctonTabUI ui) { + super(parentUi.getHandler().getContext()); + this.ui = ui; + this.parentUi = parentUi; + this.persistenceService = context.getService(PersistenceService.class); + } + + @Override + public void beforeInitUI() { + + PlanctonTabUIModel model = new PlanctonTabUIModel(); + ui.setContextValue(model); + + JTable tb = new JTable(); + + TableCellEditor defaultEditor = tb.getDefaultEditor(String.class); + TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class); + + // prepare the table column model + TableColumnModel columnModel = new DefaultTableColumnModel(); + + TableColumn col; + + // species (by code) column + + col = new TableColumn(0); + + JComboBox speciesEditor = new JComboBox(); + List<SpeciesBean> allSpecies = persistenceService.getAllSpecies(); + SwingUtil.fillComboBox(speciesEditor, allSpecies, null); +// col.setCellEditor(); + col.setCellRenderer(newTableCellRender(SpeciesBean.class)); + col.setHeaderValue(_("tutti.table.plancton.header.speciesByCode")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("speciesByCode"); + columnModel.addColumn(col); + + // Poids observé + col = new TableColumn(1); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.plancton.header.weight")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("weight"); + columnModel.addColumn(col); + + // Nombre observé + col = new TableColumn(2); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.plancton.header.number")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("computedNumber"); + columnModel.addColumn(col); + + ui.setContextValue(columnModel); + + final PlanctonTableModel tableModel = new PlanctonTableModel(columnModel); + ui.setContextValue(tableModel); + + model.addPropertyChangeListener(PlanctonTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + tableModel.setData((List<TraitSpeciesCatchBean>) evt.getNewValue()); + } + }); + + } + + @Override + public void afterInitUI() { + PlanctonTabUIModel model = ui.getModel(); + + initUI(ui); + } + + @Override + public void onCloseUI() { + } + + @Override + protected PlanctonTabUIModel getModel() { + return ui.getModel(); + } + + public void selectTrait(TraitBean bean) { + + boolean empty = bean == null; + + PlanctonTabUIModel model = ui.getModel(); + + List<TraitPlanctonCatchBean> catches; + + if (empty) { + catches = null; + bean = new TraitBean(); + } else { + catches = persistenceService.getAllTraitPlanctonCatch(bean.getId()); + } + + model.fromBean(bean); + model.setCatches(catches); + } + + public void cancel() { + + if (log.isInfoEnabled()) { + log.info("Cancel edition"); + } + } + + public void save() { + if (log.isInfoEnabled()) { + log.info("Will save"); + } + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUIHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUIModel.java (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTabUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUIModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,95 @@ +package fr.ifremer.tutti.ui.swing.content.catches.plancton; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.TraitBean; +import fr.ifremer.tutti.persistence.entities.TraitPlanctonCatchBean; +import org.jdesktop.beans.AbstractSerializableBean; +import org.nuiton.util.beans.BinderFactory; + +import java.util.List; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class PlanctonTabUIModel extends AbstractSerializableBean { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_TOTAL_WEIGHT = "totalWeight"; + + public static final String PROPERTY_SAMPLE_TOTAL_WEIGHT = "sampleTotalWeight"; + + public static final String PROPERTY_CATCHES = "catches"; + + protected Float totalWeight; + + protected Float sampleTotalWeight; + + protected List<TraitPlanctonCatchBean> catches; + + public Float getTotalWeight() { + return totalWeight; + } + + public void setTotalWeight(Float totalWeight) { + Object oldValue = getTotalWeight(); + this.totalWeight = totalWeight; + firePropertyChange(PROPERTY_TOTAL_WEIGHT, oldValue, totalWeight); + } + + public Float getSampleTotalWeight() { + return sampleTotalWeight; + } + + public void setSampleTotalWeight(Float sampleTotalWeight) { + Object oldValue = getSampleTotalWeight(); + this.sampleTotalWeight = sampleTotalWeight; + firePropertyChange(PROPERTY_SAMPLE_TOTAL_WEIGHT, oldValue, sampleTotalWeight); + } + + public List<TraitPlanctonCatchBean> getCatches() { + return catches; + } + + public void setCatches(List<TraitPlanctonCatchBean> catches) { + Object oldValue = getCatches(); + this.catches = catches; + firePropertyChange(PROPERTY_CATCHES, oldValue, catches); + } + + public void fromBean(TraitBean bean) { + BinderFactory.newBinder(TraitBean.class, + PlanctonTabUIModel.class).copy(bean, this); + } + + public TraitBean toBean() { + TraitBean result = new TraitBean(); + BinderFactory.newBinder(PlanctonTabUIModel.class, + TraitBean.class).copy(this, result); + return result; + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTabUIModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTableModel.java (from rev 25, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/PlanctonTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTableModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -0,0 +1,78 @@ +package fr.ifremer.tutti.ui.swing.content.catches.plancton; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Ifremer + * %% + * 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 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 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-3.0.html>. + * #L% + */ + +import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; + +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableColumnModel; +import java.util.List; + +/** + * @author tchemit <chemit@codelutin.com> + * @since 0.2 + */ +public class PlanctonTableModel extends AbstractTableModel { + + private static final long serialVersionUID = 1L; + + protected List<TraitSpeciesCatchBean> data; + + protected final TableColumnModel columnModel; + + public PlanctonTableModel(TableColumnModel columnModel) { + this.columnModel = columnModel; + } + + public void setData(List<TraitSpeciesCatchBean> data) { + if (data == null) { + data = Lists.newArrayList(); + data.add(new TraitSpeciesCatchBean()); + } + this.data = data; + fireTableDataChanged(); + } + + @Override + public int getRowCount() { + return data == null ? 0 : data.size(); + } + + @Override + public int getColumnCount() { + return columnModel.getColumnCount(); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + return null; + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return true; + } +} \ No newline at end of file Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTableModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesCatchEntryModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesCatchEntryModel.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesCatchEntryModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -24,7 +24,6 @@ * #L% */ -import fr.ifremer.tutti.persistence.entities.TraitBean; import fr.ifremer.tutti.persistence.entities.TraitSpeciesCatchBean; import fr.ifremer.tutti.persistence.entities.VracHorsVracEnum; import fr.ifremer.tutti.persistence.entities.referential.SexBean; @@ -66,13 +65,6 @@ public static final String PROPERTY_COMMENT = "comment"; /** - * When catch was observed. - * - * @since 0.2 - */ - protected TraitBean trait; - - /** * Species observed. * * @since 0.2 @@ -149,14 +141,6 @@ */ protected String comment; - public TraitBean getTrait() { - return trait; - } - - public void setTrait(TraitBean trait) { - this.trait = trait; - } - public SpeciesBean getSpecies() { return species; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesTabUI.jaxx 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesTabUI.jaxx 2012-12-04 23:32:56 UTC (rev 29) @@ -25,11 +25,8 @@ implements='fr.ifremer.tutti.ui.swing.TuttiUI<SpeciesTabUIModel, SpeciesTabUIHandler>'> <import> - fr.ifremer.tutti.persistence.entities.referential.BeaufortScaleBean - fr.ifremer.tutti.persistence.entities.referential.SeaStateBean - fr.ifremer.tutti.persistence.entities.StrataBean fr.ifremer.tutti.persistence.entities.TraitBean - fr.ifremer.tutti.persistence.entities.referential.UserBean + fr.ifremer.tutti.ui.swing.TuttiUIContext fr.ifremer.tutti.ui.swing.content.catches.CatchesUI @@ -41,8 +38,6 @@ jaxx.runtime.validator.swing.SwingValidatorMessageTableModel javax.swing.ListSelectionModel - javax.swing.table.TableModel - javax.swing.table.TableColumnModel java.awt.Color Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesTabUIHandler.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesTabUIHandler.java 2012-12-04 23:32:56 UTC (rev 29) @@ -90,14 +90,16 @@ private final PersistenceService persistenceService; - private final BeanMonitor monitor; + private final BeanMonitor rowMonitor; + private final BeanMonitor traitMonitor; + public SpeciesTabUIHandler(CatchesUI parentUi, SpeciesTabUI ui) { super(parentUi.getHandler().getContext()); this.ui = ui; this.parentUi = parentUi; this.persistenceService = context.getService(PersistenceService.class); - monitor = new BeanMonitor( + rowMonitor = new BeanMonitor( SpeciesCatchEntryModel.PROPERTY_SPECIES, SpeciesCatchEntryModel.PROPERTY_SPECIES_TO_CONFIRM, SpeciesCatchEntryModel.PROPERTY_VRAC_HORS_VRAC, @@ -109,6 +111,12 @@ SpeciesCatchEntryModel.PROPERTY_SAMPLE_WEIGHT, SpeciesCatchEntryModel.PROPERTY_ELEVATION_RATIO, SpeciesCatchEntryModel.PROPERTY_COMMENT); + traitMonitor = new BeanMonitor( + SpeciesTabUIModel.PROPERTY_SAMPLE_VRAC_WEIGHT, + SpeciesTabUIModel.PROPERTY_TOTAL_HORS_VRAC_WEIGHT, + SpeciesTabUIModel.PROPERTY_TOTAL_VRAC_WEIGHT, + SpeciesTabUIModel.PROPERTY_TOTAL_WEIGHT + ); } @Override @@ -116,6 +124,8 @@ SpeciesTabUIModel model = new SpeciesTabUIModel(); ui.setContextValue(model); + + traitMonitor.setBean(model); } @Override @@ -170,13 +180,19 @@ log.info("New selected row: " + selectedRow); } - SpeciesCatchEntryModel entry = - tableModel.getEntry(selectedRow); + SpeciesCatchEntryModel entry; + if (selectedRow == -1) { + // no selection + entry = null; + } else { + entry = tableModel.getEntry(selectedRow); + } + if (log.isInfoEnabled()) { log.info("Will monitor entry: " + entry); } - monitor.setBean(entry); + rowMonitor.setBean(entry); } } }); @@ -185,9 +201,15 @@ public void saveSelectedRowIfRequired(FocusEvent event) { Component oppositeComponent = event.getOppositeComponent(); - JXTable parentContainer = SwingUtil.getParentContainer( - oppositeComponent, JXTable.class); + JXTable parentContainer = null; + if (oppositeComponent != null) { + + // check out if still on table + parentContainer = SwingUtil.getParentContainer( + oppositeComponent, JXTable.class); + } + if (parentContainer == null) { // out of the table can save @@ -197,12 +219,12 @@ public void saveSelectedRowIfRequired() { - SpeciesCatchEntryModel bean = (SpeciesCatchEntryModel) monitor.getBean(); + SpeciesCatchEntryModel bean = (SpeciesCatchEntryModel) rowMonitor.getBean(); if (bean != null) { // there is a bean attached to the monitor - if (monitor.wasModified()) { + if (rowMonitor.wasModified()) { // monitored bean was modified, save it if (log.isInfoEnabled()) { @@ -211,8 +233,11 @@ TraitSpeciesCatchBean catchBean = bean.toBean(); - TraitBean trait = parentUi.getModel().getSelectedTrait(); + TraitBean trait = getModel().getTrait(); catchBean.setTrait(trait); + if (log.isInfoEnabled()) { + log.info("Selected trait: " + trait.getId()); + } if (TuttiBeans.isNew(catchBean)) { @@ -223,7 +248,7 @@ } // clear modified flag on the monitor - monitor.clearModified(); + rowMonitor.clearModified(); } } } @@ -234,58 +259,68 @@ public void selectTrait(TraitBean bean) { + if (traitMonitor.wasModified()) { + + // previous trait was modified, let's save it + SpeciesTabUIModel traitMonitorBean = + (SpeciesTabUIModel) traitMonitor.getBean(); + + TraitBean traitBean = traitMonitorBean.toBean(); + + if (log.isInfoEnabled()) { + log.info("Trait " + traitBean.getId() + + " was modified, will save it."); + } + + persistenceService.saveTrait(traitBean); + } + // make sure selection is empty (will remove bean from monitor) ui.getTable().clearSelection(); boolean empty = bean == null; - SpeciesTabUIModel model = ui.getModel(); + SpeciesTabUIModel model = getModel(); List<SpeciesCatchEntryModel> rows; if (empty) { rows = null; bean = new TraitBean(); + model.setTrait(null); } else { + + if (log.isInfoEnabled()) { + log.info("Get species catches for trait: " + bean.getId()); + } List<TraitSpeciesCatchBean> catches = persistenceService.getAllTraitSpeciesCatch(bean.getId()); rows = Lists.newArrayList(); for (TraitSpeciesCatchBean aCatch : catches) { SpeciesCatchEntryModel entry = new SpeciesCatchEntryModel(); - entry.setTrait(bean); entry.fromBean(aCatch); rows.add(entry); } + model.setTrait(bean); } model.fromBean(bean); - model.setCatches(rows); + model.setRows(rows); + //monitor.setBean(null); rows = model.getRows(); - monitor.setBean(rows.get(0)); + rowMonitor.setBean(rows.get(0)); + traitMonitor.clearModified(); } - public void cancel() { - - if (log.isInfoEnabled()) { - log.info("Cancel edition"); - } - } - @Override protected SpeciesTabUIModel getModel() { return ui.getModel(); } - public void save() { - if (log.isInfoEnabled()) { - log.info("Will save"); - } - } - protected TableColumnModel createTableColumnModel(JXTable table) { KeyListener keyAdapter = createTableKeyListener(getModel(), table); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesTabUIModel.java 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/species/SpeciesTabUIModel.java 2012-12-04 23:32:56 UTC (rev 29) @@ -30,7 +30,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jdesktop.beans.AbstractSerializableBean; -import org.nuiton.util.beans.BinderFactory; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderModelBuilder; import java.util.List; @@ -57,6 +58,8 @@ public static final String PROPERTY_NEW_ROW = "newRow"; + protected TraitBean trait; + protected Float totalWeight; protected Float totalVracWeight; @@ -72,6 +75,28 @@ */ protected List<SpeciesCatchEntryModel> rows; + protected final Binder<TraitBean, SpeciesTabUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(TraitBean.class, SpeciesTabUIModel.class) + .addProperty("speciesTotalWeight", PROPERTY_TOTAL_WEIGHT) + .addProperty("speciesTotalHorsVracWeight", PROPERTY_TOTAL_HORS_VRAC_WEIGHT) + .addProperty("speciesTotalVracWeight", PROPERTY_TOTAL_VRAC_WEIGHT) + .addProperty("speciesSampleVracWeight", PROPERTY_SAMPLE_VRAC_WEIGHT) + .toBinder(); + + protected final Binder<SpeciesTabUIModel, TraitBean> toBeanBinder = BinderModelBuilder.newEmptyBuilder(SpeciesTabUIModel.class, TraitBean.class) + .addProperty(PROPERTY_TOTAL_WEIGHT, "speciesTotalWeight") + .addProperty(PROPERTY_TOTAL_HORS_VRAC_WEIGHT, "speciesTotalHorsVracWeight") + .addProperty(PROPERTY_TOTAL_VRAC_WEIGHT, "speciesTotalVracWeight") + .addProperty(PROPERTY_SAMPLE_VRAC_WEIGHT, "speciesSampleVracWeight") + .toBinder(); + + public TraitBean getTrait() { + return trait; + } + + public void setTrait(TraitBean trait) { + this.trait = trait; + } + public Float getTotalWeight() { return totalWeight; } @@ -120,7 +145,7 @@ return rows; } - public void setCatches(List<SpeciesCatchEntryModel> rows) { + public void setRows(List<SpeciesCatchEntryModel> rows) { Object oldValue = getRowCount(); if (rows == null) { rows = Lists.newArrayList(); @@ -142,15 +167,17 @@ } public void fromBean(TraitBean bean) { - BinderFactory.newBinder(TraitBean.class, - SpeciesTabUIModel.class).copy(bean, this); + + fromBeanBinder.copy(bean, this); } public TraitBean toBean() { - TraitBean result = new TraitBean(); - BinderFactory.newBinder(SpeciesTabUIModel.class, - TraitBean.class).copy(this, result); + TraitBean result = trait; + toBeanBinder.copy(this, result); return result; } + public String getId() { + return trait == null ? null : trait.getId(); + } } Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-04 23:31:44 UTC (rev 28) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-04 23:32:56 UTC (rev 29) @@ -64,8 +64,8 @@ tutti.label.survey=Série de campagne tutti.label.survey.name=Nom tutti.label.survey.zone=Zone +tutti.label.tab.accidentel=Captures accidentelles tutti.label.tab.benthos=Benthos -tutti.label.tab.captureAccidentel=Captures accidentelles tutti.label.tab.macroDechet=Macro déchets tutti.label.tab.observationIndividuel=Observations individuelles tutti.label.tab.plancton=Plancton