Author: tchemit Date: 2012-11-26 11:27:11 +0100 (Mon, 26 Nov 2012) New Revision: 20 Url: http://forge.codelutin.com/repositories/revision/tutti/20 Log: add benthos tab continue catches tab fix casino import icon Added: 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/resources/icons/action-pupitri-import.png Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/campaign/EditCampaignUI.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/FishesTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/FishesTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/FishesTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/FishesTableModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/TraitTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/TraitTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/TraitTabUIHandler.java trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/campaign/EditCampaignUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/campaign/EditCampaignUI.css 2012-11-26 10:26:20 UTC (rev 19) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/campaign/EditCampaignUI.css 2012-11-26 10:27:11 UTC (rev 20) @@ -152,7 +152,7 @@ } #importCasinoButton { - actionIcon:"casion-import"; + actionIcon:"casino-import"; text:"tutti.action.casino-import"; } Added: 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 (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUI.css 2012-11-26 10:27:11 UTC (rev 20) @@ -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/BenthosTabUI.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: 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 (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUI.jaxx 2012-11-26 10:27:11 UTC (rev 20) @@ -0,0 +1,99 @@ +<!-- + #%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.BeaufortScaleBean + fr.ifremer.tutti.persistence.entities.SeaStateBean + fr.ifremer.tutti.persistence.entities.StrataBean + fr.ifremer.tutti.persistence.entities.TraitBean + fr.ifremer.tutti.persistence.entities.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='comment' component='commentField'/--> + </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/BenthosTabUI.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: 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 (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUIHandler.java 2012-11-26 10:27:11 UTC (rev 20) @@ -0,0 +1,180 @@ +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.CatchBean; +import fr.ifremer.tutti.persistence.entities.SpeciesBean; +import fr.ifremer.tutti.persistence.entities.TraitBean; +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<CatchBean>) 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<CatchBean> catches; + + if (empty) { + catches = null; + bean = new TraitBean(); + } else { + catches = persistenceService.getAllCatches(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/BenthosTabUIHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: 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 (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTabUIModel.java 2012-11-26 10:27:11 UTC (rev 20) @@ -0,0 +1,95 @@ +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.CatchBean; +import fr.ifremer.tutti.persistence.entities.TraitBean; +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<CatchBean> 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<CatchBean> getCatches() { + return catches; + } + + public void setCatches(List<CatchBean> 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/BenthosTabUIModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: 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 (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/BenthosTableModel.java 2012-11-26 10:27:11 UTC (rev 20) @@ -0,0 +1,78 @@ +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.CatchBean; + +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<CatchBean> data; + + protected final TableColumnModel columnModel; + + public BenthosTableModel(TableColumnModel columnModel) { + this.columnModel = columnModel; + } + + public void setData(List<CatchBean> data) { + if (data == null) { + data = Lists.newArrayList(); + data.add(new CatchBean()); + } + 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/BenthosTableModel.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/CatchesUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CatchesUI.jaxx 2012-11-26 10:26:20 UTC (rev 19) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CatchesUI.jaxx 2012-11-26 10:27:11 UTC (rev 20) @@ -74,7 +74,7 @@ <FishesTabUI id='fishesTabContent' constructorParams='this'/> </tab> <tab id='benthosTab' title='tutti.label.tab.benthos'> - <JLabel text='tutti.to.be.done' horizontalAlignment='{JLabel.CENTER}'/> + <BenthosTabUI id='benthosTabContent' constructorParams='this'/> </tab> <tab id='planctonTab' title='tutti.label.tab.plancton'> <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-11-26 10:26:20 UTC (rev 19) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/CatchesUIHandler.java 2012-11-26 10:27:11 UTC (rev 20) @@ -152,12 +152,12 @@ // propagate trait to his tabs ui.getTraitTabContent().selectTrait(selectedTrait); + ui.getFishesTabContent().selectTrait(selectedTrait); + ui.getBenthosTabContent().selectTrait(selectedTrait); // repaint tabs ui.getTabPane().repaint(); -// ui.getFishesTabContent().selectTrait(selectedTrait); -// ui.getBenthosTabContent().selectTrait(selectedTrait); // ui.getPlanctonTabContent().selectTrait(selectedTrait); // ui.getMacroDechetsTabContent().selectTrait(selectedTrait); // ui.getCaptureAccidentellesTabContent().selectTrait(selectedTrait); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/FishesTabUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/FishesTabUI.css 2012-11-26 10:26:20 UTC (rev 19) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/FishesTabUI.css 2012-11-26 10:27:11 UTC (rev 20) @@ -65,6 +65,7 @@ numberPattern:{INT_6_DIGITS_PATTERN}; } -#fishesTable { - model:{new FishesTableModel()}; +#table { + model:{getContextValue(TableModel.class)}; + columnModel:{getContextValue(TableColumnModel.class)}; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/FishesTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/FishesTabUI.jaxx 2012-11-26 10:26:20 UTC (rev 19) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/FishesTabUI.jaxx 2012-11-26 10:27:11 UTC (rev 20) @@ -37,6 +37,9 @@ jaxx.runtime.validator.swing.SwingValidatorUtil jaxx.runtime.validator.swing.SwingValidatorMessageTableModel + javax.swing.table.TableModel + javax.swing.table.TableColumnModel + static org.nuiton.i18n.I18n._ </import> @@ -96,7 +99,7 @@ </Table> <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'> - <JTable id='fishesTable'/> + <JTable id='table'/> </JScrollPane> </JPanel> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/FishesTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/FishesTabUIHandler.java 2012-11-26 10:26:20 UTC (rev 19) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/FishesTabUIHandler.java 2012-11-26 10:27:11 UTC (rev 20) @@ -25,14 +25,29 @@ */ import fr.ifremer.tutti.persistence.entities.CatchBean; +import fr.ifremer.tutti.persistence.entities.SpeciesBean; import fr.ifremer.tutti.persistence.entities.TraitBean; 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.DefaultTableCellRenderer; +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 javax.swing.table.TableModel; +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 @@ -57,9 +72,146 @@ @Override public void beforeInitUI() { + FishesTabUIModel model = new FishesTabUIModel(); + ui.setContextValue(model); - ui.setContextValue(model); + JTable tb = new JTable(); + + TableCellEditor defaultEditor = tb.getDefaultEditor(String.class); + TableCellRenderer defaultRenderer = tb.getDefaultRenderer(Object.class); + + DefaultTableCellRenderer dRender = new DefaultTableCellRenderer(); + // 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.fishes.header.speciesByCode")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("speciesByCode"); + columnModel.addColumn(col); + + // Vrac / Hors vrac + col = new TableColumn(1); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.fishes.header.vracHorsVrac")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("vracHorsVrac"); + columnModel.addColumn(col); + + // Catégorie de poids + col = new TableColumn(2); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.fishes.header.weightCategory")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("weightCategory"); + columnModel.addColumn(col); + + // Sex + col = new TableColumn(3); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.fishes.header.sex")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("sex"); + columnModel.addColumn(col); + + // Maturity + col = new TableColumn(4); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.fishes.header.maturity")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("maturity"); + columnModel.addColumn(col); + + // Age + col = new TableColumn(5); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.fishes.header.age")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("age"); + columnModel.addColumn(col); + + // Type de mensuration + col = new TableColumn(6); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.fishes.header.mensurationType")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("mensurationType"); + columnModel.addColumn(col); + + // Poids observé + col = new TableColumn(7); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.fishes.header.weight")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("weight"); + columnModel.addColumn(col); + + // Poids calculé + col = new TableColumn(8); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.fishes.header.computedWeight")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("computedWeight"); + columnModel.addColumn(col); + + // Nombre calculé + col = new TableColumn(9); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.fishes.header.computedNumber")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("computedNumber"); + columnModel.addColumn(col); + + // Poids d'échantillon + col = new TableColumn(10); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.fishes.header.sampleWeight")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("sampleWeight"); + columnModel.addColumn(col); + + // Fraction d'élévation + col = new TableColumn(11); + col.setCellEditor(defaultEditor); + col.setCellRenderer(defaultRenderer); + col.setHeaderValue(_("tutti.table.fishes.header.elevationRate")); +// col.setHeaderRenderer(SwingUtil.newStringTableCellRenderer(dRender,50, true)); + col.setIdentifier("elevationRate"); + columnModel.addColumn(col); + + ui.setContextValue(columnModel); + + final FishesTableModel tableModel = new FishesTableModel(columnModel); + ui.setContextValue(tableModel); + + model.addPropertyChangeListener(FishesTabUIModel.PROPERTY_CATCHES, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + tableModel.setData((List<CatchBean>) evt.getNewValue()); + } + }); + } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/FishesTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/FishesTableModel.java 2012-11-26 10:26:20 UTC (rev 19) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/FishesTableModel.java 2012-11-26 10:27:11 UTC (rev 20) @@ -24,11 +24,14 @@ * #L% */ +import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.CatchBean; + import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableColumnModel; +import java.util.List; /** - * TODO - * * @author tchemit <chemit@codelutin.com> * @since 0.1 */ @@ -36,18 +39,40 @@ private static final long serialVersionUID = 1L; + protected List<CatchBean> data; + + protected final TableColumnModel columnModel; + + public FishesTableModel(TableColumnModel columnModel) { + this.columnModel = columnModel; + } + + public void setData(List<CatchBean> data) { + if (data == null) { + data = Lists.newArrayList(); + data.add(new CatchBean()); + } + this.data = data; + fireTableDataChanged(); + } + @Override public int getRowCount() { - return 0; + return data == null ? 0 : data.size(); } @Override public int getColumnCount() { - return 0; + return columnModel.getColumnCount(); } @Override public Object getValueAt(int rowIndex, int columnIndex) { return null; } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return true; + } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/TraitTabUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/TraitTabUI.css 2012-11-26 10:26:20 UTC (rev 19) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/TraitTabUI.css 2012-11-26 10:27:11 UTC (rev 20) @@ -477,6 +477,11 @@ enabled:{model.isModify()}; } +#importPupitriButton { + actionIcon:"pupitri-import"; + text:"tutti.action.pupitri-import"; +} + #messagePanel { border:{BorderFactory.createTitledBorder("Messages")}; height:200; Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/TraitTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/TraitTabUI.jaxx 2012-11-26 10:26:20 UTC (rev 19) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/TraitTabUI.jaxx 2012-11-26 10:27:11 UTC (rev 20) @@ -527,10 +527,16 @@ </JTabbedPane> <!-- Actions --> - <JPanel layout='{new GridLayout(1,2,0,0)}' constraints='BorderLayout.SOUTH'> - <JButton id='cancelButton' onActionPerformed='handler.cancel()'/> - <JButton id='saveButton' onActionPerformed='handler.save()'/> + <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.SOUTH'> + <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.NORTH'> + <JButton id='importPupitriButton' onActionPerformed='handler.importPupitri()'/> + </JPanel> + <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.CENTER'> + <JButton id='cancelButton' onActionPerformed='handler.cancel()'/> + <JButton id='saveButton' onActionPerformed='handler.save()'/> + </JPanel> </JPanel> + </JPanel> <JLabel id='noTraitPane'/> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/TraitTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/TraitTabUIHandler.java 2012-11-26 10:26:20 UTC (rev 19) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/catches/TraitTabUIHandler.java 2012-11-26 10:27:11 UTC (rev 20) @@ -24,7 +24,6 @@ * #L% */ -import com.google.common.collect.Lists; import fr.ifremer.tutti.persistence.entities.TraitBean; import fr.ifremer.tutti.persistence.entities.UserBean; import fr.ifremer.tutti.service.PersistenceService; @@ -33,11 +32,9 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.validator.bean.simple.SimpleBeanValidator; import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.ListSelectionModel; import java.awt.BorderLayout; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -121,7 +118,7 @@ model.setEmpty(true); - listenValidatorValid(ui.getValidator(),getModel() ); + listenValidatorValid(ui.getValidator(), getModel()); } @Override @@ -207,6 +204,10 @@ ui.getTraitTabPane().setSelectedIndex(selectedIndex); } + public void importPupitri() { + //TODO + } + public void setGearShootingStartLatitude(String text) { ui.getModel().setGearShootingStartLatitude(Float.valueOf(text)); } 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-11-26 10:26:20 UTC (rev 19) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-11-26 10:27:11 UTC (rev 20) @@ -15,6 +15,7 @@ tutti.action.manageProtocol=Protocole tutti.action.manageProtocol.tip=Gérer les protocoles tutti.action.new=Nouveau +tutti.action.pupitri-import=Import PUPITRI tutti.action.reload.actions=Recharger les actions tutti.action.reload.home=Reload home screen tutti.action.reload.ui=Recharger l'interface graphique @@ -41,6 +42,8 @@ tutti.config.ui.autoPopupNumberEditor=Toujours afficher le pavé numérique lors de l'édition d'un nombre tutti.config.ui.config=Chemin du fichier de configuration des interfaces graphiques tutti.config.ui.showNumberEditorButton=Afficher le pavé numérique de saisie +tutti.label.benthos.sampleTotalWeight=Poids échantilloné observé +tutti.label.benthos.totalWeight=Poids total observé tutti.label.campaign=Campagne tutti.label.campaign.country=Pays tutti.label.campaign.name=Nom @@ -119,6 +122,32 @@ tutti.menu.synchronisations=Synchronisation tutti.menu.synchronisations.tip=Import/Export tutti.service.config=Configuration des services de Tutti +tutti.table.benthos.header.number=Nb ob. +tutti.table.benthos.header.speciesByCode=Espèce +tutti.table.benthos.header.weight=Poids ob. +tutti.table.fishes.header.age=Age +tutti.table.fishes.header.computedNumber=Nombre calculé +tutti.table.fishes.header.computedNumber.tip=Nombre calculé +tutti.table.fishes.header.computedWeight=Poids calculé +tutti.table.fishes.header.computedWeight.tip=Poids calculé +tutti.table.fishes.header.elevationRate=Fraction d'él +tutti.table.fishes.header.elevationRate.tip=Fraction d'él +tutti.table.fishes.header.maturity=Maturité +tutti.table.fishes.header.maturity.tip=Maturié +tutti.table.fishes.header.mensurationType=Type de mensuration +tutti.table.fishes.header.mensurationType.tip=Type de mensuration +tutti.table.fishes.header.sampleWeight=Poids échan +tutti.table.fishes.header.sampleWeight.tip=Poids échan +tutti.table.fishes.header.sex=Sexe +tutti.table.fishes.header.sex.tip=Sexe +tutti.table.fishes.header.speciesByCode=Espèce +tutti.table.fishes.header.speciesByCode.tip=Espèce +tutti.table.fishes.header.vracHorsVrac=Vrac / Hors Vrac +tutti.table.fishes.header.vracHorsVrac.tip=Vrac / Hors Vrac +tutti.table.fishes.header.weight=Poids +tutti.table.fishes.header.weight.tip=Poids +tutti.table.fishes.header.weightCategory=Catégorie Poids +tutti.table.fishes.header.weightCategory.tip=Catégorie Poids tutti.title.about=A propos de Tutti tutti.title.create.campaign=Créer une nouvelle campagne tutti.title.create.survey=Créer une nouvelle série de campagne Copied: trunk/tutti-ui-swing/src/main/resources/icons/action-pupitri-import.png (from rev 18, trunk/tutti-ui-swing/src/main/resources/icons/action-casino-import.png) =================================================================== (Binary files differ)