r91 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/content/operation java/fr/ifremer/tutti/ui/swing/content/operation/fishing java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment resources/i18n
Author: kmorin Date: 2012-12-19 16:39:51 +0100 (Wed, 19 Dec 2012) New Revision: 91 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/91 Log: use a table instead of a form in the environment tab Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java Removed: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTableModel.java Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.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/operation/EditFishingOperationUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx 2012-12-19 10:49:03 UTC (rev 90) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx 2012-12-19 15:39:51 UTC (rev 91) @@ -32,7 +32,7 @@ fr.ifremer.tutti.persistence.entities.referential.Person fr.ifremer.tutti.ui.swing.util.editor.SimpleTimeEditor - fr.ifremer.tutti.ui.swing.content.operation.fishing.EnvironmentTabUI + fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUI jaxx.runtime.swing.editor.bean.BeanComboBox jaxx.runtime.swing.editor.bean.BeanListHeader Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2012-12-19 10:49:03 UTC (rev 90) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2012-12-19 15:39:51 UTC (rev 91) @@ -24,10 +24,12 @@ * #L% */ +import com.google.common.collect.Maps; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.referential.Person; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler; +import fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUIModel; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -38,7 +40,10 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.List; +import java.util.Map; +import static org.nuiton.i18n.I18n._; + /** * Handler for UI {@link EditFishingOperationUI}. * @@ -97,7 +102,7 @@ ui.getFishingOperationValidPanel().remove( ui.getFishingOperationResetRadio()); - EditFishingOperationUIModel model = ui.getModel(); + final EditFishingOperationUIModel model = ui.getModel(); initUI(ui); @@ -120,7 +125,37 @@ model.setEmpty(true); listenValidatorValid(ui.getValidator(), getModel()); + + EnvironmentTabUIModel environmentModel = + ui.getEnvironmentTabContent().getModel(); + environmentModel.addPropertyChangeListener( + EditFishingOperationUIModel.PROPERTY_ENVIRONMENT_PARAMETERS, + new PropertyChangeListener() { + + public void propertyChange(PropertyChangeEvent evt) { + model.setModify(true); + } + } + ); + environmentModel.setEnvironmentParameters(getDefaultEnvironmentParams()); } + + protected Map<Object, Object> getDefaultEnvironmentParams() { + Map<Object, Object> environmentParams = Maps.newHashMap(); + environmentParams.put( + _(new String("tutti.table.fishing.environment.keys." + EnvironmentTabUIModel.KEY_BEAUFORT_SCALE)), + null + ); + environmentParams.put( + _(new String("tutti.table.fishing.environment.keys." + EnvironmentTabUIModel.KEY_WIND_DIRECTION)), + null + ); + environmentParams.put( + _(new String("tutti.table.fishing.environment.keys." + EnvironmentTabUIModel.KEY_SEA_STATE)), + null + ); + return environmentParams; + } @Override public void onCloseUI() { @@ -155,7 +190,8 @@ // if new fishingOperation can already cancel his creation model.setModify(!empty && model.isCreate()); - ui.getEnvironmentTabContent().getHandler().afterInitUI(); + ui.getEnvironmentTabContent().getModel().setEnvironmentParameters(getDefaultEnvironmentParams()); + ui.getEnvironmentTabContent().getHandler().reset(); } public void cancel() { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2012-12-19 10:49:03 UTC (rev 90) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2012-12-19 15:39:51 UTC (rev 91) @@ -26,9 +26,7 @@ import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.Cruise; -import fr.ifremer.tutti.persistence.entities.referential.BeaufortScale; import fr.ifremer.tutti.persistence.entities.referential.Person; -import fr.ifremer.tutti.persistence.entities.referential.SeaState; import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation; import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel; import fr.ird.type.SexagecimalPosition; @@ -37,6 +35,7 @@ import java.util.Date; import java.util.List; +import java.util.Map; /** * Model for UI {@link EditFishingOperationUI}. @@ -76,12 +75,14 @@ public static final String PROPERTY_GEAR_SHOOTING_END_DEPTH = "gearShootingEndDepth"; - public static final String PROPERTY_BEAUFORT_SCALE = "beaufortScale"; +// public static final String PROPERTY_BEAUFORT_SCALE = "beaufortScale"; +// +// public static final String PROPERTY_WIND_DIRECTION = "windDirection"; +// +// public static final String PROPERTY_SEA_STATE = "seaState"; + + public static final String PROPERTY_ENVIRONMENT_PARAMETERS = "environmentParameters"; - public static final String PROPERTY_WIND_DIRECTION = "windDirection"; - - public static final String PROPERTY_SEA_STATE = "seaState"; - public static final String PROPERTY_OUVERTURE_HORIZONTALE = "ouvertureHorizontale"; public static final String PROPERTY_OUVERTURE_VERTICALE = "ouvertureVerticale"; @@ -172,12 +173,14 @@ protected Float gearShootingEndDepth; - protected BeaufortScale beaufortScale; +// protected BeaufortScale beaufortScale; +// +// protected Integer windDirection; +// +// protected SeaState seaState; + + protected Map<Object, Object> environmentParameters; - protected Integer windDirection; - - protected SeaState seaState; - protected Float ouvertureHorizontale; protected Float ouvertureVerticale; @@ -383,36 +386,46 @@ firePropertyChange(PROPERTY_GEAR_SHOOTING_END_DEPTH, oldValue, gearShootingEndDepth); } - public BeaufortScale getBeaufortScale() { - return beaufortScale; +// public BeaufortScale getBeaufortScale() { +// return beaufortScale; +// } +// +// public void setBeaufortScale(BeaufortScale beaufortScale) { +// Object oldValue = getBeaufortScale(); +// this.beaufortScale = beaufortScale; +// firePropertyChange(PROPERTY_BEAUFORT_SCALE, oldValue, beaufortScale); +// } +// +// public Integer getWindDirection() { +// return windDirection; +// } +// +// public void setWindDirection(Integer windDirection) { +// Object oldValue = getWindDirection(); +// this.windDirection = windDirection; +// firePropertyChange(PROPERTY_WIND_DIRECTION, oldValue, windDirection); +// } +// +// public SeaState getSeaState() { +// return seaState; +// } +// +// public void setSeaState(SeaState seaState) { +// Object oldValue = getSeaState(); +// this.seaState = seaState; +// firePropertyChange(PROPERTY_SEA_STATE, oldValue, seaState); +// } + + public Map<Object, Object> getEnvironmentParameters() { + return environmentParameters; } - - public void setBeaufortScale(BeaufortScale beaufortScale) { - Object oldValue = getBeaufortScale(); - this.beaufortScale = beaufortScale; - firePropertyChange(PROPERTY_BEAUFORT_SCALE, oldValue, beaufortScale); + + public void setEnvironmentParameters(Map<Object, Object> environmentParameters) { + Object oldValue = getEnvironmentParameters(); + this.environmentParameters = environmentParameters; + firePropertyChange(PROPERTY_ENVIRONMENT_PARAMETERS, oldValue, environmentParameters); } - public Integer getWindDirection() { - return windDirection; - } - - public void setWindDirection(Integer windDirection) { - Object oldValue = getWindDirection(); - this.windDirection = windDirection; - firePropertyChange(PROPERTY_WIND_DIRECTION, oldValue, windDirection); - } - - public SeaState getSeaState() { - return seaState; - } - - public void setSeaState(SeaState seaState) { - Object oldValue = getSeaState(); - this.seaState = seaState; - firePropertyChange(PROPERTY_SEA_STATE, oldValue, seaState); - } - public Float getOuvertureHorizontale() { return ouvertureHorizontale; } Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentRowModel.java 2012-12-19 10:49:03 UTC (rev 90) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentRowModel.java 2012-12-19 15:39:51 UTC (rev 91) @@ -1,94 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.fishing; - -/* - * #%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.ui.swing.AbstractTuttiBeanUIModel; -import java.io.Serializable; -import org.nuiton.util.beans.Binder; -import org.nuiton.util.beans.BinderFactory; - -/** - * - * @author kmorin - * @since 0.3 - */ -public class EnvironmentRowModel extends AbstractTuttiBeanUIModel<Object, EnvironmentRowModel> { - - public static final String PROPERTY_KEY = "key"; - public static final String PROPERTY_VALUE = "value"; - - protected static final Binder<Object, EnvironmentRowModel> fromBeanBinder = - BinderFactory.newBinder(Object.class, - EnvironmentRowModel.class); - - protected static final Binder<EnvironmentRowModel, Object> toBeanBinder = - BinderFactory.newBinder(EnvironmentRowModel.class, - Object.class); - - protected String key; - - protected String value; - - public EnvironmentRowModel() { - super(Object.class, fromBeanBinder, toBeanBinder); - } - - public EnvironmentRowModel(String key) { - this(); - this.key = key; - } -// -// public FishingOperationEnvironmentRowModel(Object o, -// List<SpeciesBatchFrequency> frequencies) { -// this(); -// fromBean(aBatch); -// List<SpeciesFrequencyRowModel> frequencyRows = -// SpeciesFrequencyRowModel.fromBeans(frequencies); -// frequency.addAll(frequencyRows); -// Collections.sort(frequency); -// updateTotalFromFrequencies(); -// } - - public String getKey() { - return key; - } - - public void setKey(String key) { - Object oldValue = getKey(); - this.key = key; - firePropertyChange(PROPERTY_KEY, oldValue, key); - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - Object oldValue = getValue(); - this.value = value; - firePropertyChange(PROPERTY_VALUE, oldValue, value); - } - -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUI.css 2012-12-19 10:49:03 UTC (rev 90) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUI.css 2012-12-19 15:39:51 UTC (rev 91) @@ -1,29 +0,0 @@ -/* - * #%L - * Tutti :: UI - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -#environmentTable { - selectionMode: {ListSelectionModel.SINGLE_SELECTION}; - selectionBackground: {null}; - selectionForeground: {Color.BLACK}; - sortable: false; -} \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUI.jaxx 2012-12-19 10:49:03 UTC (rev 90) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUI.jaxx 2012-12-19 15:39:51 UTC (rev 91) @@ -1,69 +0,0 @@ -<!-- - #%L - Tutti :: UI - $Id$ - $HeadURL$ - %% - Copyright (C) 2012 Ifremer - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> -<Table implements='fr.ifremer.tutti.ui.swing.TuttiUI<EnvironmentTabUIModel, EnvironmentTabUIHandler>'> - - <import> - org.jdesktop.swingx.JXTable - fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI - javax.swing.ListSelectionModel - java.awt.Color - </import> - - <EnvironmentTabUIHandler id='handler' - initializer='getContextValue(EnvironmentTabUIHandler.class)'/> - - <EnvironmentTabUIModel id='model' - initializer='getContextValue(EnvironmentTabUIModel.class)'/> - - <row fill='both'> - <cell fill='both' weightx='1'> - <JComboBox id='newRowKey'/> - </cell> - <cell fill='both'> - <JButton id='addRow' actionIcon='add' - onActionPerformed='handler.addRow()'/> - </cell> - </row> - <row fill='both' weighty='1'> - <cell fill='both' columns='2'> - <JScrollPane> - <JXTable id='environmentTable'/> - </JScrollPane> - </cell> - </row> - <script><![CDATA[ - -public EnvironmentTabUI(EditFishingOperationUI parentUI) { - EnvironmentTabUIHandler handler = new EnvironmentTabUIHandler(parentUI, this); - setContextValue(handler); - handler.beforeInitUI(); -} - -protected void $afterCompleteSetup() { - handler.afterInitUI(); -} - - ]]></script> - -</Table> \ No newline at end of file Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUIHandler.java 2012-12-19 10:49:03 UTC (rev 90) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUIHandler.java 2012-12-19 15:39:51 UTC (rev 91) @@ -1,192 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.fishing; - -/* - * #%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.ui.swing.content.operation.EditFishingOperationUI; -import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; -import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.List; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JComboBox; -import javax.swing.event.ListDataEvent; -import javax.swing.event.ListDataListener; -import javax.swing.table.TableColumnModel; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.JXTable; -import org.jdesktop.swingx.table.DefaultTableColumnModelExt; - -/** - * - * @author kmorin - * @since 0.3 - */ -public class EnvironmentTabUIHandler extends AbstractTuttiTableUIHandler<EnvironmentRowModel, EnvironmentTabUIModel> { - - private final static Log log = LogFactory.getLog(EnvironmentTabUIHandler.class); - - protected EnvironmentTabUI ui; - - public EnvironmentTabUIHandler(EditFishingOperationUI parentUi, EnvironmentTabUI ui) { - super(parentUi.getHandler().getContext()); - this.ui = ui; - } - - @Override - protected JXTable getTable() { - return ui.getEnvironmentTable(); - } - - @Override - protected AbstractTuttiTableModel<EnvironmentRowModel> getTableModel() { - return (EnvironmentTableModel) getTable().getModel(); - } - - @Override - protected TableColumnModel createTableColumnModel() { - DefaultTableColumnModelExt columnModel = - new DefaultTableColumnModelExt(); - - { - - addColumnToModel(columnModel, EnvironmentTableModel.KEY); - } - - { - - addColumnToModel(columnModel, EnvironmentTableModel.VALUE); - } - - - return columnModel; - } - - @Override - protected void onRowModified(EnvironmentRowModel row, String propertyName, Object oldValue, Object newValue) { - } - - @Override - protected void onRowValidStateChanged(EnvironmentRowModel row, Boolean oldValue, Boolean newValue) { - } - - @Override - protected void onRowModifyStateChanged(EnvironmentRowModel row, Boolean oldValue, Boolean newValue) { - } - - @Override - public void beforeInitUI() { - EnvironmentTabUIModel model = new EnvironmentTabUIModel(); - ui.setContextValue(model); - } - - @Override - public void afterInitUI() { - initUI(ui); - - JXTable table = getTable(); - - // create table column model - TableColumnModel columnModel = createTableColumnModel(); - - // create table model - EnvironmentTableModel tableModel = - new EnvironmentTableModel(columnModel); - - table.setModel(tableModel); - table.setColumnModel(columnModel); - - final JComboBox keyCombo = ui.getNewRowKey(); - keyCombo.setModel(new DefaultComboBoxModel()); - - keyCombo.addItemListener(new ItemListener() { - - public void itemStateChanged(ItemEvent e) { - log.debug("item state changed " + e.paramString()); - } - }); - keyCombo.getModel().addListDataListener(new ListDataListener() { - - public void intervalAdded(ListDataEvent e) { - keyCombo.setEnabled(true); - ui.getAddRow().setEnabled(true); - } - - public void intervalRemoved(ListDataEvent e) { - if (keyCombo.getItemCount() == 0) { - keyCombo.setEnabled(false); - ui.getAddRow().setEnabled(false); - } - } - - public void contentsChanged(ListDataEvent e) { - keyCombo.setEnabled(true); - ui.getAddRow().setEnabled(true); - } - }); - - reset(); - } - - @Override - public void onCloseUI() { - } - - @Override - protected EnvironmentTabUIModel getModel() { - return ui.getModel(); - } - - public void addRow() { - JComboBox keyCombo = ui.getNewRowKey(); - String key = (String) keyCombo.getSelectedItem(); - EnvironmentRowModel row = new EnvironmentRowModel(key); - getTableModel().addNewRow(getTable().getRowCount(), row); - - keyCombo.removeItem(key); - } - - public void reset() { - List<EnvironmentRowModel> rows = Lists.newArrayList(); - List<String> defaultKeys = Lists.newArrayList(ui.getModel().getDefaultKeys()); - for (String key : defaultKeys) { - rows.add(new EnvironmentRowModel(key)); - } - - AbstractTuttiTableModel<EnvironmentRowModel> tableModel = getTableModel(); - tableModel.setRows(rows); - - JComboBox keyCombo = ui.getNewRowKey(); - DefaultComboBoxModel keyComboModel = (DefaultComboBoxModel)keyCombo.getModel(); - for (String key : ui.getModel().getKeys()) { - if (!defaultKeys.contains(key)) { - keyComboModel.addElement(key); - } - } - } - -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUIModel.java 2012-12-19 10:49:03 UTC (rev 90) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUIModel.java 2012-12-19 15:39:51 UTC (rev 91) @@ -1,83 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.fishing; - -/* - * #%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.ui.swing.util.table.AbstractTuttiTableUIModel; -import org.nuiton.util.beans.Binder; -import org.nuiton.util.beans.BinderModelBuilder; - -import static org.nuiton.i18n.I18n._; - -/** - * - * @author kmorin - */ -public class EnvironmentTabUIModel extends AbstractTuttiTableUIModel<FishingOperation, EnvironmentRowModel, EnvironmentTabUIModel> { - - protected FishingOperation fishingOperation; - - public static final String KEY_BEAUFORT_SCALE = "beaufortScale"; - public static final String KEY_WIND_DIRECTION = "windDirection"; - public static final String KEY_SEA_STATE = "seaState"; - - protected static final Binder<FishingOperation, EnvironmentTabUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, EnvironmentTabUIModel.class) - .toBinder(); - - protected static final Binder<EnvironmentTabUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(EnvironmentTabUIModel.class, FishingOperation.class) - .toBinder(); - - public EnvironmentTabUIModel() { - super(FishingOperation.class, fromBeanBinder, toBeanBinder); - } - - public FishingOperation getFishingOperation() { - return fishingOperation; - } - - public void setFishingOperation(FishingOperation fishingOperation) { - this.fishingOperation = fishingOperation; - } - - public String[] getKeys() { - return new String[] { - _("tutti.table.fishing.environment.keys." + KEY_BEAUFORT_SCALE), - _("tutti.table.fishing.environment.keys." + KEY_WIND_DIRECTION), - _("tutti.table.fishing.environment.keys." + KEY_SEA_STATE), - _("tutti.table.fishing.environment.keys." + "key3"), - _("tutti.table.fishing.environment.keys." + "key4"), - _("tutti.table.fishing.environment.keys." + "key5") - }; - } - - public String[] getDefaultKeys() { - return new String[] { - _("tutti.table.fishing.environment.keys." + KEY_BEAUFORT_SCALE), - _("tutti.table.fishing.environment.keys." + KEY_WIND_DIRECTION), - _("tutti.table.fishing.environment.keys." + KEY_SEA_STATE) - }; - } - -} Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTableModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTableModel.java 2012-12-19 10:49:03 UTC (rev 90) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTableModel.java 2012-12-19 15:39:51 UTC (rev 91) @@ -1,62 +0,0 @@ -package fr.ifremer.tutti.ui.swing.content.operation.fishing; - -/* - * #%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.ui.swing.util.table.AbstractTuttiTableModel; -import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; -import javax.swing.table.TableColumnModel; - -import static org.nuiton.i18n.I18n.n_; - -/** - * - * @author kmorin - * since 0.3 - */ -public class EnvironmentTableModel extends AbstractTuttiTableModel<EnvironmentRowModel> { - - public static final ColumnIdentifier<EnvironmentRowModel> KEY = ColumnIdentifier.newId( - EnvironmentRowModel.PROPERTY_KEY, - n_("tutti.table.fishing.environment.header.key"), - n_("tutti.table.fishing.environment.header.key")); - - public static final ColumnIdentifier<EnvironmentRowModel> VALUE = ColumnIdentifier.newId( - EnvironmentRowModel.PROPERTY_VALUE, - n_("tutti.table.fishing.environment.header.value"), - n_("tutti.table.fishing.environment.header.value")); - - public EnvironmentTableModel(TableColumnModel columnModel) { - super(columnModel); - - setNoneEditableCols(KEY); - } - - @Override - protected EnvironmentRowModel createNewRow() { - EnvironmentRowModel result = new EnvironmentRowModel(); - return result; - } - -} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java (from rev 90, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentRowModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentRowModel.java 2012-12-19 15:39:51 UTC (rev 91) @@ -0,0 +1,87 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing.environment; + +/* + * #%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.ui.swing.AbstractTuttiBeanUIModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +/** + * + * @author kmorin + * @since 0.3 + */ +public class EnvironmentRowModel extends AbstractTuttiBeanUIModel<Object, EnvironmentRowModel> { + + private static final Log log = LogFactory.getLog(EnvironmentRowModel.class); + + public static final String PROPERTY_KEY = "key"; + public static final String PROPERTY_VALUE = "value"; + + protected static final Binder<Object, EnvironmentRowModel> fromBeanBinder = + BinderFactory.newBinder(Object.class, + EnvironmentRowModel.class); + + protected static final Binder<EnvironmentRowModel, Object> toBeanBinder = + BinderFactory.newBinder(EnvironmentRowModel.class, + Object.class); + + protected String key; + + protected String value; + + public EnvironmentRowModel() { + super(Object.class, fromBeanBinder, toBeanBinder); + } + + public EnvironmentRowModel(String key) { + this(); + this.key = key; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + Object oldValue = getKey(); + this.key = key; + firePropertyChange(PROPERTY_KEY, oldValue, key); + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + log.info(">>>>>>>>>>>>>>< setValue " + value); + Object oldValue = getValue(); + this.value = value; + firePropertyChange(PROPERTY_VALUE, oldValue, value); + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css (from rev 90, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUI.css) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.css 2012-12-19 15:39:51 UTC (rev 91) @@ -0,0 +1,29 @@ +/* + * #%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% + */ +#environmentTable { + selectionMode: {ListSelectionModel.SINGLE_SELECTION}; + selectionBackground: {null}; + selectionForeground: {Color.BLACK}; + sortable: false; +} \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.jaxx (from rev 90, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUI.jaxx) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.jaxx (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUI.jaxx 2012-12-19 15:39:51 UTC (rev 91) @@ -0,0 +1,69 @@ +<!-- + #%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% + --> +<Table implements='fr.ifremer.tutti.ui.swing.TuttiUI<EnvironmentTabUIModel, EnvironmentTabUIHandler>'> + + <import> + org.jdesktop.swingx.JXTable + fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI + javax.swing.ListSelectionModel + java.awt.Color + </import> + + <EnvironmentTabUIHandler id='handler' + initializer='getContextValue(EnvironmentTabUIHandler.class)'/> + + <EnvironmentTabUIModel id='model' + initializer='getContextValue(EnvironmentTabUIModel.class)'/> + + <row fill='both'> + <cell fill='both' weightx='1'> + <JComboBox id='newRowKey'/> + </cell> + <cell fill='both'> + <JButton id='addRow' actionIcon='add' + onActionPerformed='handler.addRow()'/> + </cell> + </row> + <row fill='both' weighty='1'> + <cell fill='both' columns='2'> + <JScrollPane> + <JXTable id='environmentTable'/> + </JScrollPane> + </cell> + </row> + <script><![CDATA[ + +public EnvironmentTabUI(EditFishingOperationUI parentUI) { + EnvironmentTabUIHandler handler = new EnvironmentTabUIHandler(parentUI, this); + setContextValue(handler); + handler.beforeInitUI(); +} + +protected void $afterCompleteSetup() { + handler.afterInitUI(); +} + + ]]></script> + +</Table> \ No newline at end of file Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java (from rev 90, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUIHandler.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2012-12-19 15:39:51 UTC (rev 91) @@ -0,0 +1,221 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing.environment; + +/* + * #%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.ui.swing.content.operation.EditFishingOperationUI; +import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler; +import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.event.ListDataEvent; +import javax.swing.event.ListDataListener; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableColumnModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.table.DefaultTableColumnModelExt; + +/** + * + * @author kmorin + * @since 0.3 + */ +public class EnvironmentTabUIHandler extends AbstractTuttiTableUIHandler<EnvironmentRowModel, EnvironmentTabUIModel> { + + private final static Log log = LogFactory.getLog(EnvironmentTabUIHandler.class); + + protected EnvironmentTabUI ui; + + public EnvironmentTabUIHandler(EditFishingOperationUI parentUi, EnvironmentTabUI ui) { + super(parentUi.getHandler().getContext(), EnvironmentRowModel.PROPERTY_VALUE); + this.ui = ui; + } + + @Override + protected JXTable getTable() { + return ui.getEnvironmentTable(); + } + + @Override + protected AbstractTuttiTableModel<EnvironmentRowModel> getTableModel() { + return (EnvironmentTableModel) getTable().getModel(); + } + + @Override + protected TableColumnModel createTableColumnModel() { + DefaultTableColumnModelExt columnModel = + new DefaultTableColumnModelExt(); + + { + + addColumnToModel(columnModel, EnvironmentTableModel.KEY); + } + + { + + addColumnToModel(columnModel, EnvironmentTableModel.VALUE); + } + + + return columnModel; + } + + @Override + protected void onRowModified(EnvironmentRowModel row, String propertyName, Object oldValue, Object newValue) { + } + + @Override + protected void onRowValidStateChanged(EnvironmentRowModel row, Boolean oldValue, Boolean newValue) { + } + + @Override + protected void onRowModifyStateChanged(EnvironmentRowModel row, Boolean oldValue, Boolean newValue) { + } + + @Override + public void beforeInitUI() { + EnvironmentTabUIModel model = new EnvironmentTabUIModel(); + ui.setContextValue(model); + } + + @Override + public void afterInitUI() { + initUI(ui); + + JXTable table = getTable(); + + // create table column model + TableColumnModel columnModel = createTableColumnModel(); + + // create table model + EnvironmentTableModel tableModel = + new EnvironmentTableModel(columnModel); + + table.setModel(tableModel); + table.setColumnModel(columnModel); + + final JComboBox keyCombo = ui.getNewRowKey(); + keyCombo.setModel(new DefaultComboBoxModel()); + + keyCombo.addItemListener(new ItemListener() { + + public void itemStateChanged(ItemEvent e) { + log.debug("item state changed " + e.paramString()); + } + }); + keyCombo.getModel().addListDataListener(new ListDataListener() { + + public void intervalAdded(ListDataEvent e) { + keyCombo.setEnabled(true); + ui.getAddRow().setEnabled(true); + } + + public void intervalRemoved(ListDataEvent e) { + if (keyCombo.getItemCount() == 0) { + keyCombo.setEnabled(false); + ui.getAddRow().setEnabled(false); + } + } + + public void contentsChanged(ListDataEvent e) { + keyCombo.setEnabled(true); + ui.getAddRow().setEnabled(true); + } + }); + + // modify the model when the user enters a value + ListSelectionListener listener = new TableRowModificationListener<EnvironmentRowModel>( + tableModel, getRowMonitor()) { + + @Override + protected void saveSelectedRow() { + TuttiBeanMonitor<EnvironmentRowModel> monitor = getRowMonitor(); + EnvironmentRowModel row = monitor.getBean(); + if (row != null) { + ui.getModel().setParameter(row.getKey(), row.getValue()); + } + } + }; + table.getSelectionModel().addListSelectionListener(listener); + + } + + @Override + public void onCloseUI() { + } + + @Override + protected EnvironmentTabUIModel getModel() { + return ui.getModel(); + } + + /** + * Adds a row with the parameter selected in the combo box + */ + public void addRow() { + JComboBox keyCombo = ui.getNewRowKey(); + String key = (String) keyCombo.getSelectedItem(); + EnvironmentRowModel row = new EnvironmentRowModel(key); + getTableModel().addNewRow(getTable().getRowCount(), row); + ui.getModel().setParameter(key, null); + + keyCombo.removeItem(key); + } + + /** + * Resets the table with the data from the database + */ + public void reset() { + Map<Object, Object> environmentParameters = ui.getModel().getEnvironmentParameters(); + + List<EnvironmentRowModel> rows = Lists.newArrayList(); + Collection<Object> params = environmentParameters.keySet(); + for (Object key : environmentParameters.keySet()) { + rows.add(new EnvironmentRowModel(key.toString())); + } + + AbstractTuttiTableModel<EnvironmentRowModel> tableModel = getTableModel(); + tableModel.setRows(rows); + + JComboBox keyCombo = ui.getNewRowKey(); + DefaultComboBoxModel keyComboModel = (DefaultComboBoxModel) keyCombo.getModel(); + keyComboModel.removeAllElements(); + for (String param : ui.getModel().getKeys()) { + if (!params.contains(param)) { + keyComboModel.addElement(param); + } + } + } + +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java (from rev 90, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTabUIModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIModel.java 2012-12-19 15:39:51 UTC (rev 91) @@ -0,0 +1,83 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing.environment; + +/* + * #%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 java.util.Map; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel; +import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel; +import java.util.HashMap; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderModelBuilder; + +import static org.nuiton.i18n.I18n._; + +/** + * + * @author kmorin + */ +public class EnvironmentTabUIModel extends AbstractTuttiTableUIModel<FishingOperation, EnvironmentRowModel, EnvironmentTabUIModel> { + + protected Map<Object, Object> environmentParameters; + + public static final String KEY_BEAUFORT_SCALE = "beaufortScale"; + public static final String KEY_WIND_DIRECTION = "windDirection"; + public static final String KEY_SEA_STATE = "seaState"; + + protected static final Binder<FishingOperation, EnvironmentTabUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(FishingOperation.class, EnvironmentTabUIModel.class) + .toBinder(); + + protected static final Binder<EnvironmentTabUIModel, FishingOperation> toBeanBinder = BinderModelBuilder.newEmptyBuilder(EnvironmentTabUIModel.class, FishingOperation.class) + .toBinder(); + + public EnvironmentTabUIModel() { + super(FishingOperation.class, fromBeanBinder, toBeanBinder); + } + + public Map<Object, Object> getEnvironmentParameters() { + return environmentParameters; + } + + public void setEnvironmentParameters(Map<Object, Object> environmentParameters) { + this.environmentParameters = environmentParameters; + } + + public void setParameter(Object param, Object value) { + Object oldValue = new HashMap<Object, Object>(environmentParameters); + environmentParameters.put(param, value); + firePropertyChange(EditFishingOperationUIModel.PROPERTY_ENVIRONMENT_PARAMETERS, oldValue, environmentParameters); + } + + public String[] getKeys() { + return new String[] { + _(new String("tutti.table.fishing.environment.keys." + KEY_BEAUFORT_SCALE)), + _(new String("tutti.table.fishing.environment.keys." + KEY_WIND_DIRECTION)), + _(new String("tutti.table.fishing.environment.keys." + KEY_SEA_STATE)), + _(new String("tutti.table.fishing.environment.keys." + "key3")), + _(new String("tutti.table.fishing.environment.keys." + "key4")), + _(new String("tutti.table.fishing.environment.keys." + "key5")) + }; + } +} Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java (from rev 90, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/EnvironmentTableModel.java) =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java 2012-12-19 15:39:51 UTC (rev 91) @@ -0,0 +1,62 @@ +package fr.ifremer.tutti.ui.swing.content.operation.fishing.environment; + +/* + * #%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.ui.swing.util.table.AbstractTuttiTableModel; +import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; +import javax.swing.table.TableColumnModel; + +import static org.nuiton.i18n.I18n.n_; + +/** + * + * @author kmorin + * since 0.3 + */ +public class EnvironmentTableModel extends AbstractTuttiTableModel<EnvironmentRowModel> { + + public static final ColumnIdentifier<EnvironmentRowModel> KEY = ColumnIdentifier.newId( + EnvironmentRowModel.PROPERTY_KEY, + n_("tutti.table.fishing.environment.header.key"), + n_("tutti.table.fishing.environment.header.key")); + + public static final ColumnIdentifier<EnvironmentRowModel> VALUE = ColumnIdentifier.newId( + EnvironmentRowModel.PROPERTY_VALUE, + n_("tutti.table.fishing.environment.header.value"), + n_("tutti.table.fishing.environment.header.value")); + + public EnvironmentTableModel(TableColumnModel columnModel) { + super(columnModel); + + setNoneEditableCols(KEY); + } + + @Override + protected EnvironmentRowModel createNewRow() { + EnvironmentRowModel result = new EnvironmentRowModel(); + return result; + } + +} Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties =================================================================== --- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-19 10:49:03 UTC (rev 90) +++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-19 15:39:51 UTC (rev 91) @@ -165,7 +165,6 @@ tutti.table.benthos.batch.header.weight=Poids tutti.table.fishing.environment.header.key=Clé tutti.table.fishing.environment.header.value=Valeur -tutti.table.fishing.environment.keys.= tutti.table.fishing.environment.keys.beaufortScale=Force du vent tutti.table.fishing.environment.keys.key3=Clé 3 tutti.table.fishing.environment.keys.key4=Clé 4
participants (1)
-
kmorin@users.forge.codelutin.com