Author: tchemit Date: 2012-12-12 18:22:58 +0100 (Wed, 12 Dec 2012) New Revision: 47 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/47 Log: move last ui from catches package to operation package Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTableModel.java Removed: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/ Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2012-12-12 17:06:45 UTC (rev 46) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.jaxx 2012-12-12 17:22:58 UTC (rev 47) @@ -28,10 +28,10 @@ fr.ifremer.tutti.persistence.entities.data.FishingOperation 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.operation.accidental.AccidentelTabUI + fr.ifremer.tutti.ui.swing.content.operation.benthos.BenthosTabUI + fr.ifremer.tutti.ui.swing.content.operation.macrowaste.MacroDechetTabUI + fr.ifremer.tutti.ui.swing.content.operation.plankton.PlanctonTabUI fr.ifremer.tutti.ui.swing.content.operation.species.SpeciesTabUI jaxx.runtime.swing.editor.bean.BeanComboBox Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.css (from rev 46, 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/operation/accidental/AccidentelTabUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.css 2012-12-12 17:22:58 UTC (rev 47) @@ -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/operation/accidental/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/operation/accidental/AccidentelTabUI.jaxx (from rev 46, 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/operation/accidental/AccidentelTabUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUI.jaxx 2012-12-12 17:22:58 UTC (rev 47) @@ -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.data.FishingOperation + + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI + + 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(FishingOperationsUI parentUI) { + AccidentelTabUIHandler handler = new AccidentelTabUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); } + +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/operation/accidental/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/operation/accidental/AccidentelTabUIHandler.java (from rev 46, 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/operation/accidental/AccidentelTabUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIHandler.java 2012-12-12 17:22:58 UTC (rev 47) @@ -0,0 +1,182 @@ +package fr.ifremer.tutti.ui.swing.content.operation.accidental; + +/* + * #%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.data.AccidentelBatch; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; +import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; +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 FishingOperationsUI parentUi; + + private final PersistenceService persistenceService; + + public AccidentelTabUIHandler(FishingOperationsUI 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<Species> allSpecies = persistenceService.getAllSpecies(); + SwingUtil.fillComboBox(speciesEditor, allSpecies, null); +// col.setCellEditor(); +// col.setCellRenderer(newTableCellRender(Species.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<SpeciesBatch>) 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 selectFishingOperation(FishingOperation bean) { + + boolean empty = bean == null; + + AccidentelTabUIModel model = ui.getModel(); + + List<AccidentelBatch> catches; + + if (empty) { + catches = null; + bean = new FishingOperation(); + } else { + catches = persistenceService.getAllAccidentelBatch(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/operation/accidental/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/operation/accidental/AccidentelTabUIModel.java (from rev 46, 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/operation/accidental/AccidentelTabUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTabUIModel.java 2012-12-12 17:22:58 UTC (rev 47) @@ -0,0 +1,95 @@ +package fr.ifremer.tutti.ui.swing.content.operation.accidental; + +/* + * #%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.data.AccidentelBatch; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +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<AccidentelBatch> 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<AccidentelBatch> getCatches() { + return catches; + } + + public void setCatches(List<AccidentelBatch> catches) { + Object oldValue = getCatches(); + this.catches = catches; + firePropertyChange(PROPERTY_CATCHES, oldValue, catches); + } + + public void fromBean(FishingOperation bean) { + BinderFactory.newBinder(FishingOperation.class, + AccidentelTabUIModel.class).copy(bean, this); + } + + public FishingOperation toBean() { + FishingOperation result = new FishingOperation(); + BinderFactory.newBinder(AccidentelTabUIModel.class, + FishingOperation.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/operation/accidental/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/operation/accidental/AccidentelTableModel.java (from rev 46, 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/operation/accidental/AccidentelTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/accidental/AccidentelTableModel.java 2012-12-12 17:22:58 UTC (rev 47) @@ -0,0 +1,78 @@ +package fr.ifremer.tutti.ui.swing.content.operation.accidental; + +/* + * #%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.data.SpeciesBatch; + +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<SpeciesBatch> data; + + protected final TableColumnModel columnModel; + + public AccidentelTableModel(TableColumnModel columnModel) { + this.columnModel = columnModel; + } + + public void setData(List<SpeciesBatch> data) { + if (data == null) { + data = Lists.newArrayList(); + data.add(new SpeciesBatch()); + } + 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/operation/accidental/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/operation/benthos/BenthosTabUI.css (from rev 46, 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/operation/benthos/BenthosTabUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.css 2012-12-12 17:22:58 UTC (rev 47) @@ -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/operation/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/operation/benthos/BenthosTabUI.jaxx (from rev 46, 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/operation/benthos/BenthosTabUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUI.jaxx 2012-12-12 17:22:58 UTC (rev 47) @@ -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.data.FishingOperation + + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI + + 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(FishingOperationsUI parentUI) { + BenthosTabUIHandler handler = new BenthosTabUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); } + +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/operation/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/operation/benthos/BenthosTabUIHandler.java (from rev 46, 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/operation/benthos/BenthosTabUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIHandler.java 2012-12-12 17:22:58 UTC (rev 47) @@ -0,0 +1,182 @@ +package fr.ifremer.tutti.ui.swing.content.operation.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.data.BenthosBatch; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; +import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; +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 FishingOperationsUI parentUi; + + private final PersistenceService persistenceService; + + public BenthosTabUIHandler(FishingOperationsUI 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<Species> allSpecies = persistenceService.getAllSpecies(); + SwingUtil.fillComboBox(speciesEditor, allSpecies, null); +// col.setCellEditor(); +// col.setCellRenderer(newTableCellRender(Species.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<SpeciesBatch>) 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 selectFishingOperation(FishingOperation bean) { + + boolean empty = bean == null; + + BenthosTabUIModel model = ui.getModel(); + + List<BenthosBatch> catches; + + if (empty) { + catches = null; + bean = new FishingOperation(); + } else { + catches = persistenceService.getAllBenthosBatch(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/operation/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/operation/benthos/BenthosTabUIModel.java (from rev 46, 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/operation/benthos/BenthosTabUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTabUIModel.java 2012-12-12 17:22:58 UTC (rev 47) @@ -0,0 +1,95 @@ +package fr.ifremer.tutti.ui.swing.content.operation.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.data.BenthosBatch; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +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<BenthosBatch> 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<BenthosBatch> getCatches() { + return catches; + } + + public void setCatches(List<BenthosBatch> catches) { + Object oldValue = getCatches(); + this.catches = catches; + firePropertyChange(PROPERTY_CATCHES, oldValue, catches); + } + + public void fromBean(FishingOperation bean) { + BinderFactory.newBinder(FishingOperation.class, + BenthosTabUIModel.class).copy(bean, this); + } + + public FishingOperation toBean() { + FishingOperation result = new FishingOperation(); + BinderFactory.newBinder(BenthosTabUIModel.class, + FishingOperation.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/operation/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/operation/benthos/BenthosTableModel.java (from rev 46, 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/operation/benthos/BenthosTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/benthos/BenthosTableModel.java 2012-12-12 17:22:58 UTC (rev 47) @@ -0,0 +1,78 @@ +package fr.ifremer.tutti.ui.swing.content.operation.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.data.SpeciesBatch; + +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<SpeciesBatch> data; + + protected final TableColumnModel columnModel; + + public BenthosTableModel(TableColumnModel columnModel) { + this.columnModel = columnModel; + } + + public void setData(List<SpeciesBatch> data) { + if (data == null) { + data = Lists.newArrayList(); + data.add(new SpeciesBatch()); + } + 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/operation/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/operation/macrowaste/MacroDechetTabUI.css (from rev 46, 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/operation/macrowaste/MacroDechetTabUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.css 2012-12-12 17:22:58 UTC (rev 47) @@ -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/operation/macrowaste/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/operation/macrowaste/MacroDechetTabUI.jaxx (from rev 46, 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/operation/macrowaste/MacroDechetTabUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUI.jaxx 2012-12-12 17:22:58 UTC (rev 47) @@ -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.data.FishingOperation + + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI + + 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(FishingOperationsUI parentUI) { + MacroDechetTabUIHandler handler = new MacroDechetTabUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); } + +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/operation/macrowaste/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/operation/macrowaste/MacroDechetTabUIHandler.java (from rev 46, 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/operation/macrowaste/MacroDechetTabUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIHandler.java 2012-12-12 17:22:58 UTC (rev 47) @@ -0,0 +1,182 @@ +package fr.ifremer.tutti.ui.swing.content.operation.macrowaste; + +/* + * #%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.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.MacroDechetBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; +import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; +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 FishingOperationsUI parentUi; + + private final PersistenceService persistenceService; + + public MacroDechetTabUIHandler(FishingOperationsUI 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<Species> allSpecies = persistenceService.getAllSpecies(); + SwingUtil.fillComboBox(speciesEditor, allSpecies, null); +// col.setCellEditor(); +// col.setCellRenderer(newTableCellRender(Species.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<SpeciesBatch>) 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 selectFishingOperation(FishingOperation bean) { + + boolean empty = bean == null; + + MacroDechetTabUIModel model = ui.getModel(); + + List<MacroDechetBatch> catches; + + if (empty) { + catches = null; + bean = new FishingOperation(); + } else { + catches = persistenceService.getAllMacroDechetBatch(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/operation/macrowaste/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/operation/macrowaste/MacroDechetTabUIModel.java (from rev 46, 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/operation/macrowaste/MacroDechetTabUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTabUIModel.java 2012-12-12 17:22:58 UTC (rev 47) @@ -0,0 +1,95 @@ +package fr.ifremer.tutti.ui.swing.content.operation.macrowaste; + +/* + * #%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.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.MacroDechetBatch; +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<MacroDechetBatch> 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<MacroDechetBatch> getCatches() { + return catches; + } + + public void setCatches(List<MacroDechetBatch> catches) { + Object oldValue = getCatches(); + this.catches = catches; + firePropertyChange(PROPERTY_CATCHES, oldValue, catches); + } + + public void fromBean(FishingOperation bean) { + BinderFactory.newBinder(FishingOperation.class, + MacroDechetTabUIModel.class).copy(bean, this); + } + + public FishingOperation toBean() { + FishingOperation result = new FishingOperation(); + BinderFactory.newBinder(MacroDechetTabUIModel.class, + FishingOperation.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/operation/macrowaste/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/operation/macrowaste/MacroDechetTableModel.java (from rev 46, 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/operation/macrowaste/MacroDechetTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/macrowaste/MacroDechetTableModel.java 2012-12-12 17:22:58 UTC (rev 47) @@ -0,0 +1,78 @@ +package fr.ifremer.tutti.ui.swing.content.operation.macrowaste; + +/* + * #%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.data.SpeciesBatch; + +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<SpeciesBatch> data; + + protected final TableColumnModel columnModel; + + public MacroDechetTableModel(TableColumnModel columnModel) { + this.columnModel = columnModel; + } + + public void setData(List<SpeciesBatch> data) { + if (data == null) { + data = Lists.newArrayList(); + data.add(new SpeciesBatch()); + } + 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/operation/macrowaste/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/operation/plankton/PlanctonTabUI.css (from rev 46, 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/operation/plankton/PlanctonTabUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.css 2012-12-12 17:22:58 UTC (rev 47) @@ -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/operation/plankton/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/operation/plankton/PlanctonTabUI.jaxx (from rev 46, 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/operation/plankton/PlanctonTabUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUI.jaxx 2012-12-12 17:22:58 UTC (rev 47) @@ -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.data.FishingOperation + + fr.ifremer.tutti.ui.swing.TuttiUIContext + fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI + + 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(FishingOperationsUI parentUI) { + PlanctonTabUIHandler handler = new PlanctonTabUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +public void selectFishingOperation(FishingOperation fishingOperation) { handler.selectFishingOperation(fishingOperation); } + +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/operation/plankton/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/operation/plankton/PlanctonTabUIHandler.java (from rev 46, 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/operation/plankton/PlanctonTabUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIHandler.java 2012-12-12 17:22:58 UTC (rev 47) @@ -0,0 +1,182 @@ +package fr.ifremer.tutti.ui.swing.content.operation.plankton; + +/* + * #%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.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.PlanctonBatch; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; +import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; +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 FishingOperationsUI parentUi; + + private final PersistenceService persistenceService; + + public PlanctonTabUIHandler(FishingOperationsUI 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<Species> allSpecies = persistenceService.getAllSpecies(); + SwingUtil.fillComboBox(speciesEditor, allSpecies, null); +// col.setCellEditor(); +// col.setCellRenderer(newTableCellRender(Species.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<SpeciesBatch>) 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 selectFishingOperation(FishingOperation bean) { + + boolean empty = bean == null; + + PlanctonTabUIModel model = ui.getModel(); + + List<PlanctonBatch> catches; + + if (empty) { + catches = null; + bean = new FishingOperation(); + } else { + catches = persistenceService.getAllPlanctonBatch(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/operation/plankton/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/operation/plankton/PlanctonTabUIModel.java (from rev 46, 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/operation/plankton/PlanctonTabUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTabUIModel.java 2012-12-12 17:22:58 UTC (rev 47) @@ -0,0 +1,95 @@ +package fr.ifremer.tutti.ui.swing.content.operation.plankton; + +/* + * #%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.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.PlanctonBatch; +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<PlanctonBatch> 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<PlanctonBatch> getCatches() { + return catches; + } + + public void setCatches(List<PlanctonBatch> catches) { + Object oldValue = getCatches(); + this.catches = catches; + firePropertyChange(PROPERTY_CATCHES, oldValue, catches); + } + + public void fromBean(FishingOperation bean) { + BinderFactory.newBinder(FishingOperation.class, + PlanctonTabUIModel.class).copy(bean, this); + } + + public FishingOperation toBean() { + FishingOperation result = new FishingOperation(); + BinderFactory.newBinder(PlanctonTabUIModel.class, + FishingOperation.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/operation/plankton/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/operation/plankton/PlanctonTableModel.java (from rev 46, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/plancton/PlanctonTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/plankton/PlanctonTableModel.java 2012-12-12 17:22:58 UTC (rev 47) @@ -0,0 +1,78 @@ +package fr.ifremer.tutti.ui.swing.content.operation.plankton; + +/* + * #%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.data.SpeciesBatch; + +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<SpeciesBatch> data; + + protected final TableColumnModel columnModel; + + public PlanctonTableModel(TableColumnModel columnModel) { + this.columnModel = columnModel; + } + + public void setData(List<SpeciesBatch> data) { + if (data == null) { + data = Lists.newArrayList(); + data.add(new SpeciesBatch()); + } + 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/operation/plankton/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/operation/species/SpeciesTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java 2012-12-12 17:06:45 UTC (rev 46) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesTabUIHandler.java 2012-12-12 17:22:58 UTC (rev 47) @@ -318,8 +318,9 @@ SpeciesBatchTreeModel samplingTreeModel = model.getSamplingTreeModel(); - if (SAMPLING_PROPERTIES.contains(propertyName)) { + if (SAMPLING_PROPERTIES.contains(propertyName) && row.isValid()) { + // Need to rebuilt this row sampling tree path (and then recompute // old super - samplingRatio and new super - samplingRatio) @@ -333,7 +334,8 @@ moveSamplingNode(samplingTreeModel, row, oldNode, newNode); } - if (SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) { + if (SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName) && + row.isValid()) { // Need to recompute the super - samplingRatio