Tutti-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- 4130 discussions
28 Dec '12
Author: kmorin
Date: 2012-12-28 17:35:52 +0100 (Fri, 28 Dec 2012)
New Revision: 121
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/121
Log:
refs ##1810: [PROTOCOLE] Ecran de saisie
ajout d'une entree dans l'enum des colonnes des especes
Modified:
trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
===================================================================
(Binary files differ)
1
0
r120 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: content/operation/fishing/environment content/operation/fishing/gearshooting content/operation/fishing/hydrology content/protocol util util/editor
by kmorin@users.forge.codelutin.com 28 Dec '12
by kmorin@users.forge.codelutin.com 28 Dec '12
28 Dec '12
Author: kmorin
Date: 2012-12-28 16:10:31 +0100 (Fri, 28 Dec 2012)
New Revision: 120
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/120
Log:
refs #1812: [Ecran Trait] Tableaux de pmfm
editeurs en fonction du type de valeur des caract?\195?\169ristiques
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java
Modified:
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/gearshooting/GearShootingTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java
Modified: 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/EnvironmentTabUIHandler.java 2012-12-28 11:52:41 UTC (rev 119)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2012-12-28 15:10:31 UTC (rev 120)
@@ -27,8 +27,11 @@
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor;
+import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
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.CaracteristicRow;
@@ -75,17 +78,22 @@
@Override
protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
- DefaultTableColumnModelExt columnModel =
- new DefaultTableColumnModelExt();
-
+ DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
+
{
- addColumnToModel(columnModel, null, newTableCellRender(Caracteristic.class), EnvironmentTableModel.KEY);
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(Caracteristic.class),
+ EnvironmentTableModel.KEY);
}
{
- addColumnToModel(columnModel, EnvironmentTableModel.VALUE);
+ addColumnToModel(columnModel,
+ new CaracteristicValueEditor(context),
+ new CaracteristicValueRenderer(context),
+ EnvironmentTableModel.VALUE);
}
@@ -221,6 +229,7 @@
keyComboModel.addElement(row);
}
}
+ keyCombo.setEnabled(keyCombo.getItemCount() > 0);
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2012-12-28 11:52:41 UTC (rev 119)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2012-12-28 15:10:31 UTC (rev 120)
@@ -29,6 +29,8 @@
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor;
+import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
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.CaracteristicRow;
@@ -80,12 +82,18 @@
{
- addColumnToModel(columnModel, null, newTableCellRender(Caracteristic.class), GearShootingTableModel.KEY);
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(Caracteristic.class),
+ GearShootingTableModel.KEY);
}
{
- addColumnToModel(columnModel, GearShootingTableModel.VALUE);
+ addColumnToModel(columnModel,
+ new CaracteristicValueEditor(context),
+ new CaracteristicValueRenderer(context),
+ GearShootingTableModel.VALUE);
}
@@ -221,6 +229,7 @@
keyComboModel.addElement(row);
}
}
+ keyCombo.setEnabled(keyCombo.getItemCount() > 0);
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java 2012-12-28 11:52:41 UTC (rev 119)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java 2012-12-28 15:10:31 UTC (rev 120)
@@ -37,7 +37,7 @@
* @author kmorin
* @since 0.3
*/
-public class HydrologyRowModel extends AbstractTuttiBeanUIModel<CaracteristicRow, HydrologyRowModel> {
+public class HydrologyRowModel extends AbstractTuttiBeanUIModel<Caracteristic, HydrologyRowModel> {
private static final Log log = LogFactory.getLog(HydrologyRowModel.class);
@@ -46,15 +46,15 @@
public static final String PROPERTY_GEAR_SHOOTING_END_VALUE = "gearShootingEndValue";
public static final String PROPERTY_AVERAGE_VALUE = "averageValue";
- protected static final Binder<CaracteristicRow, HydrologyRowModel> fromBeanBinder =
- BinderFactory.newBinder(CaracteristicRow.class,
+ protected static final Binder<Caracteristic, HydrologyRowModel> fromBeanBinder =
+ BinderFactory.newBinder(Caracteristic.class,
HydrologyRowModel.class);
- protected static final Binder<HydrologyRowModel, CaracteristicRow> toBeanBinder =
+ protected static final Binder<HydrologyRowModel, Caracteristic> toBeanBinder =
BinderFactory.newBinder(HydrologyRowModel.class,
- CaracteristicRow.class);
+ Caracteristic.class);
- protected String key;
+ protected Caracteristic key;
protected Object gearShootingStartValue;
@@ -63,14 +63,14 @@
protected Object averageValue;
public HydrologyRowModel() {
- super(CaracteristicRow.class, fromBeanBinder, toBeanBinder);
+ super(Caracteristic.class, fromBeanBinder, toBeanBinder);
}
- public HydrologyRowModel(String key) {
+ public HydrologyRowModel(Caracteristic key) {
this(key, null, null, null);
}
- public HydrologyRowModel(String key, Object gearShootingStartValue,
+ public HydrologyRowModel(Caracteristic key, Object gearShootingStartValue,
Object gearShootingEndValue, Object averageValue) {
this();
this.key = key;
@@ -79,11 +79,11 @@
this.averageValue = averageValue;
}
- public String getKey() {
+ public Caracteristic getKey() {
return key;
}
- public void setKey(String key) {
+ public void setKey(Caracteristic key) {
Object oldValue = getKey();
this.key = key;
firePropertyChange(PROPERTY_KEY, oldValue, key);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2012-12-28 11:52:41 UTC (rev 119)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2012-12-28 15:10:31 UTC (rev 120)
@@ -32,6 +32,8 @@
import fr.ifremer.tutti.ui.swing.util.HydrologicCaracteristicUtil;
import fr.ifremer.tutti.ui.swing.util.HydrologicCaracteristicUtil.Type;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueEditor;
+import fr.ifremer.tutti.ui.swing.util.editor.CaracteristicValueRenderer;
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.CaracteristicRow;
@@ -65,7 +67,7 @@
protected HydrologyTabUI ui;
- protected Map<String, Map<Type, Caracteristic>> availableCaracteristics;
+ protected Map<Caracteristic, Map<Type, Caracteristic>> availableCaracteristics;
public HydrologyTabUIHandler(EditFishingOperationUI parentUi, HydrologyTabUI ui) {
super(parentUi.getHandler().getContext(),
@@ -93,22 +95,34 @@
{
- addColumnToModel(columnModel, HydrologyTableModel.KEY);
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(Caracteristic.class),
+ HydrologyTableModel.KEY);
}
{
- addColumnToModel(columnModel, HydrologyTableModel.GEAR_SHOOTING_START_VALUE);
+ addColumnToModel(columnModel,
+ new CaracteristicValueEditor(context),
+ new CaracteristicValueRenderer(context),
+ HydrologyTableModel.GEAR_SHOOTING_START_VALUE);
}
{
- addColumnToModel(columnModel, HydrologyTableModel.GEAR_SHOOTING_END_VALUE);
+ addColumnToModel(columnModel,
+ new CaracteristicValueEditor(context),
+ new CaracteristicValueRenderer(context),
+ HydrologyTableModel.GEAR_SHOOTING_END_VALUE);
}
{
- addColumnToModel(columnModel, HydrologyTableModel.AVERAGE_VALUE);
+ addColumnToModel(columnModel,
+ new CaracteristicValueEditor(context),
+ new CaracteristicValueRenderer(context),
+ HydrologyTableModel.AVERAGE_VALUE);
}
@@ -140,10 +154,11 @@
if (hydrologyPmfm != null) {
for (Caracteristic caracteristic : hydrologyPmfm) {
String name = HydrologicCaracteristicUtil.getGlobalName(caracteristic.getName());
- Map<Type, Caracteristic> values = availableCaracteristics.get(name);
+ Caracteristic globalCaracteristic = HydrologicCaracteristicUtil.createGlobalCaracteristic(name, caracteristic);
+ Map<Type, Caracteristic> values = availableCaracteristics.get(globalCaracteristic);
if (values == null) {
values = Maps.newHashMap();
- availableCaracteristics.put(name, values);
+ availableCaracteristics.put(globalCaracteristic, values);
}
Type type = HydrologicCaracteristicUtil.getTypeOfCaracteristic(caracteristic);
values.put(type, caracteristic);
@@ -171,7 +186,7 @@
final JComboBox keyCombo = ui.getNewRowKey();
keyCombo.setModel(new DefaultComboBoxModel());
-
+ keyCombo.setRenderer(newListCellRender(Caracteristic.class));
keyCombo.getModel().addListDataListener(new ListDataListener() {
public void intervalAdded(ListDataEvent e) {
@@ -241,11 +256,11 @@
*/
public void addRow() {
JComboBox keyCombo = ui.getNewRowKey();
- CaracteristicRow key = (CaracteristicRow) keyCombo.getSelectedItem();
- HydrologyRowModel row = new HydrologyRowModel(key.getName());
+ Caracteristic key = (Caracteristic) keyCombo.getSelectedItem();
+ HydrologyRowModel row = new HydrologyRowModel(key);
getTableModel().addNewRow(getTable().getRowCount(), row);
- Map<Type, Caracteristic> caracteristics = availableCaracteristics.get(key.getName());
+ Map<Type, Caracteristic> caracteristics = availableCaracteristics.get(key);
CaracteristicMap map = new CaracteristicMap();
for (Caracteristic caracteristic : caracteristics.values()) {
map.put(caracteristic, null);
@@ -266,33 +281,36 @@
List<HydrologyRowModel> rows = Lists.newArrayList();
Collection<Caracteristic> selectedCaracteristics = hydrologyCaracteristics.keySet();
- Set<String> availableCaracteristicIds = availableCaracteristics.keySet();
+ Set<Caracteristic> globalCaracteristics = availableCaracteristics.keySet();
- for (String caracteristicId : availableCaracteristicIds) {
- Map<Type, Caracteristic> caracteristics = availableCaracteristics.get(caracteristicId);
+ for (Caracteristic availableCaracteristic : globalCaracteristics) {
+ Map<Type, Caracteristic> caracteristics = availableCaracteristics.get(availableCaracteristic);
//should add the global caracteristic to the combo or to the table?
boolean selectedCaracteristic = false;
+ Caracteristic sample = null;
for (Caracteristic caracteristic : caracteristics.values()) {
selectedCaracteristic = selectedCaracteristic || selectedCaracteristics.contains(caracteristic);
+ sample = caracteristic;
}
if (selectedCaracteristic) {
- HydrologyRowModel row = new HydrologyRowModel(caracteristicId,
+ HydrologyRowModel row = new HydrologyRowModel(availableCaracteristic,
hydrologyCaracteristics.get(caracteristics.get(Type.START)),
hydrologyCaracteristics.get(caracteristics.get(Type.END)),
hydrologyCaracteristics.get(caracteristics.get(Type.AVERAGE)));
rows.add(row);
} else {
- Caracteristic caracteristic = HydrologicCaracteristicUtil.createGlobalCaracteristic(caracteristicId);
- CaracteristicRow row = new CaracteristicRow(caracteristic.getName(), caracteristic);
- keyComboModel.addElement(row);
+ keyComboModel.addElement(availableCaracteristic);
}
}
+ keyCombo.setEnabled(keyCombo.getItemCount() > 0);
+
AbstractTuttiTableModel<HydrologyRowModel> tableModel = getTableModel();
tableModel.setRows(rows, false);
+
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-28 11:52:41 UTC (rev 119)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-28 15:10:31 UTC (rev 120)
@@ -321,7 +321,7 @@
Collection<String> availableCaracteristicNames = hydroCaracteristics.keySet();
List<Caracteristic> availableCaracteristics = Lists.newArrayList();
for (String name : availableCaracteristicNames) {
- Caracteristic caracteristic = HydrologicCaracteristicUtil.createGlobalCaracteristic(name);
+ Caracteristic caracteristic = HydrologicCaracteristicUtil.createGlobalCaracteristic(name, null);
availableCaracteristics.add(caracteristic);
}
List<String> hydrologyPmfm = model.getHydrologyPmfmId();
@@ -330,7 +330,7 @@
Collection<String> ids = hydroCaracteristics.get(caracteristicName);
for (String caracteristicId : hydrologyPmfm) {
if (ids.contains(caracteristicId)) {
- Caracteristic caracteristic = HydrologicCaracteristicUtil.createGlobalCaracteristic(caracteristicName);
+ Caracteristic caracteristic = HydrologicCaracteristicUtil.createGlobalCaracteristic(caracteristicName, null);
selection.add(caracteristic);
break;
}
@@ -345,6 +345,8 @@
// if new protocol can already cancel his creation
model.setModify(model.isCreate());
+
+ table.getTableHeader().setReorderingAllowed(true);
}
protected void initDoubleList(BeanDoubleList<Caracteristic> widget,
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java 2012-12-28 11:52:41 UTC (rev 119)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java 2012-12-28 15:10:31 UTC (rev 120)
@@ -46,10 +46,19 @@
return name;
}
- public static Caracteristic createGlobalCaracteristic(String name) {
+ public static Caracteristic createGlobalCaracteristic(String name, Caracteristic toClone) {
Caracteristic caracteristic = new Caracteristic();
caracteristic.setName(name);
caracteristic.setId(name);
+ if (toClone != null) {
+ caracteristic.setCategory(toClone.getCategory());
+ caracteristic.setBooleanType(toClone.isBooleanType());
+ caracteristic.setNumberType(toClone.isNumberType());
+ caracteristic.setQualitativeType(toClone.isQualitativeType());
+ caracteristic.setQualitativeValue(toClone.getQualitativeValue());
+ caracteristic.setTextType(toClone.isTextType());
+ caracteristic.setUnit(toClone.getUnit());
+ }
return caracteristic;
}
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueEditor.java 2012-12-28 15:10:31 UTC (rev 120)
@@ -0,0 +1,94 @@
+
+package fr.ifremer.tutti.ui.swing.util.editor;
+
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import java.awt.Color;
+import java.awt.Component;
+import java.util.List;
+import javax.swing.AbstractCellEditor;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.border.LineBorder;
+import javax.swing.table.TableCellEditor;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.JAXXWidgetUtil;
+import jaxx.runtime.swing.editor.bean.BeanUIUtil;
+import jaxx.runtime.swing.editor.cell.NumberCellEditor;
+import jaxx.runtime.swing.renderer.DecoratorListCellRenderer;
+import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;
+import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
+import org.nuiton.util.decorator.Decorator;
+
+/**
+ * Editor for the values of the caracteristics of the fishing operations.
+ * The editor depends on the caracteristic value type.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.3
+ */
+public class CaracteristicValueEditor extends AbstractCellEditor implements TableCellEditor {
+
+ protected int caracteristicColumn;
+
+ protected TableCellEditor editor;
+
+ protected Decorator<CaracteristicQualitativeValue> decorator;
+
+ public CaracteristicValueEditor(TuttiUIContext context) {
+ this(0, context);
+ }
+
+ public CaracteristicValueEditor(int caracteristicColumn, TuttiUIContext context) {
+ super();
+ this.caracteristicColumn = caracteristicColumn;
+ DecoratorService decoratorService = context.getService(DecoratorService.class);
+ decorator = decoratorService.getDecoratorByType(CaracteristicQualitativeValue.class);
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return editor.getCellEditorValue();
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ editor = table.getDefaultEditor(Object.class);
+
+ Caracteristic caracteristic = (Caracteristic) table.getModel().getValueAt(row, caracteristicColumn);
+ if (caracteristic != null) {
+ if (caracteristic.isBooleanType()) {
+ editor = table.getDefaultEditor(Boolean.class);
+
+ } else if (caracteristic.isNumberType()) {
+ NumberCellEditor<Float> editor =
+ JAXXWidgetUtil.newNumberTableCellEditor(Float.class, false);
+ editor.getNumberEditor().setSelectAllTextOnError(true);
+ editor.getNumberEditor().getTextField().setBorder(new LineBorder(Color.GRAY, 2));
+ this.editor = editor;
+
+ } else if (caracteristic.isQualitativeType()) {
+ JComboBox comboBox = new JComboBox();
+ comboBox.setRenderer(new DecoratorListCellRenderer(decorator));
+
+ List<CaracteristicQualitativeValue> data = caracteristic.getQualitativeValue();
+ // add a null value at first position
+ if (!data.isEmpty() && data.get(0) != null) {
+ data.add(0, null);
+ }
+ SwingUtil.fillComboBox(comboBox, data, null);
+
+
+ ObjectToStringConverter converter = BeanUIUtil.newDecoratedObjectToStringConverter(decorator);
+ BeanUIUtil.decorate(comboBox, converter);
+ editor = new ComboBoxCellEditor(comboBox);
+ }
+ }
+
+ Component result = editor.getTableCellEditorComponent(table, value, isSelected, row, column);
+ return result;
+ }
+
+}
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/CaracteristicValueRenderer.java 2012-12-28 15:10:31 UTC (rev 120)
@@ -0,0 +1,58 @@
+
+package fr.ifremer.tutti.ui.swing.util.editor;
+
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import java.awt.Component;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.editor.bean.BeanUIUtil;
+import jaxx.runtime.swing.renderer.DecoratorTableCellRenderer;
+import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor;
+import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
+import org.nuiton.util.decorator.Decorator;
+
+/**
+ * Renderer for the values of the caracteristics of the fishing operations.
+ * The renderer depends on the caracteristic value type.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 0.3
+ */
+public class CaracteristicValueRenderer implements TableCellRenderer {
+
+ protected int caracteristicColumn;
+
+ protected Decorator<CaracteristicQualitativeValue> decorator;
+
+ public CaracteristicValueRenderer(TuttiUIContext context) {
+ this(0, context);
+ }
+
+ public CaracteristicValueRenderer(int caracteristicColumn, TuttiUIContext context) {
+ super();
+ this.caracteristicColumn = caracteristicColumn;
+ DecoratorService decoratorService = context.getService(DecoratorService.class);
+ decorator = decoratorService.getDecoratorByType(CaracteristicQualitativeValue.class);
+ }
+
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ TableCellRenderer renderer = table.getDefaultRenderer(Object.class);
+ Caracteristic caracteristic = (Caracteristic) table.getModel().getValueAt(row, caracteristicColumn);
+ if (caracteristic != null) {
+ if (caracteristic.isBooleanType()) {
+ renderer = table.getDefaultRenderer(Boolean.class);
+
+ } else if (caracteristic.isQualitativeType()) {
+ renderer = new DecoratorTableCellRenderer(decorator);
+ }
+ }
+ Component result = renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ return result;
+ }
+
+}
1
0
r119 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: content/operation content/operation/fishing/hydrology util
by kmorin@users.forge.codelutin.com 28 Dec '12
by kmorin@users.forge.codelutin.com 28 Dec '12
28 Dec '12
Author: kmorin
Date: 2012-12-28 12:52:41 +0100 (Fri, 28 Dec 2012)
New Revision: 119
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/119
Log:
group the caracteritics by type
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/fishing/hydrology/HydrologyRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java
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-28 09:17:49 UTC (rev 118)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2012-12-28 11:52:41 UTC (rev 119)
@@ -270,20 +270,18 @@
environmentModel.setEnvironmentCaracteristics(environmentCaracteristics);
//init hydrology
- HydrologyTabUIModel hydrologyModel =
- ui.getHydrologyTabContent().getModel();
+ HydrologyTabUIModel hydrologyModel = ui.getHydrologyTabContent().getModel();
hydrologyModel.setAvailableCaracteristics(persistenceService.getAllFishingOperationHydrologicCaracteristic());
hydrologyModel.addPropertyChangeListener(
EditFishingOperationUIModel.PROPERTY_HYDROLOGY_CARACTERISTICS,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
- model.setModify(true);
+ model.setHydrologyCaracteristics((CaracteristicMap) evt.getNewValue());
}
}
);
CaracteristicMap hydrologyCaracteristics = model.getHydrologyCaracteristics();
- ui.getModel().setHydrologyCaracteristics(hydrologyCaracteristics);
hydrologyModel.setHydrologyCaracteristics(hydrologyCaracteristics);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java 2012-12-28 09:17:49 UTC (rev 118)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyRowModel.java 2012-12-28 11:52:41 UTC (rev 119)
@@ -54,7 +54,7 @@
BinderFactory.newBinder(HydrologyRowModel.class,
CaracteristicRow.class);
- protected Caracteristic key;
+ protected String key;
protected Object gearShootingStartValue;
@@ -66,11 +66,11 @@
super(CaracteristicRow.class, fromBeanBinder, toBeanBinder);
}
- public HydrologyRowModel(Caracteristic key) {
+ public HydrologyRowModel(String key) {
this(key, null, null, null);
}
- public HydrologyRowModel(Caracteristic key, Object gearShootingStartValue,
+ public HydrologyRowModel(String key, Object gearShootingStartValue,
Object gearShootingEndValue, Object averageValue) {
this();
this.key = key;
@@ -79,11 +79,11 @@
this.averageValue = averageValue;
}
- public Caracteristic getKey() {
+ public String getKey() {
return key;
}
- public void setKey(Caracteristic key) {
+ public void setKey(String key) {
Object oldValue = getKey();
this.key = key;
firePropertyChange(PROPERTY_KEY, oldValue, key);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2012-12-28 09:17:49 UTC (rev 118)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2012-12-28 11:52:41 UTC (rev 119)
@@ -25,16 +25,23 @@
*/
import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI;
+import fr.ifremer.tutti.ui.swing.util.HydrologicCaracteristicUtil;
+import fr.ifremer.tutti.ui.swing.util.HydrologicCaracteristicUtil.Type;
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.CaracteristicRow;
import fr.ifremer.tutti.ui.swing.util.table.TableRowModificationListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.event.ListDataEvent;
@@ -58,6 +65,8 @@
protected HydrologyTabUI ui;
+ protected Map<String, Map<Type, Caracteristic>> availableCaracteristics;
+
public HydrologyTabUIHandler(EditFishingOperationUI parentUi, HydrologyTabUI ui) {
super(parentUi.getHandler().getContext(),
HydrologyRowModel.PROPERTY_GEAR_SHOOTING_START_VALUE,
@@ -84,7 +93,7 @@
{
- addColumnToModel(columnModel, null, newTableCellRender(Caracteristic.class), HydrologyTableModel.KEY);
+ addColumnToModel(columnModel, HydrologyTableModel.KEY);
}
{
@@ -122,6 +131,26 @@
public void beforeInitUI() {
HydrologyTabUIModel model = new HydrologyTabUIModel();
ui.setContextValue(model);
+
+ model.addPropertyChangeListener(HydrologyTabUIModel.PROPERTY_AVAILABLE_CARACTERISTICS, new PropertyChangeListener() {
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ List<Caracteristic> hydrologyPmfm = (List<Caracteristic>) evt.getNewValue();
+ availableCaracteristics = Maps.newHashMap();
+ if (hydrologyPmfm != null) {
+ for (Caracteristic caracteristic : hydrologyPmfm) {
+ String name = HydrologicCaracteristicUtil.getGlobalName(caracteristic.getName());
+ Map<Type, Caracteristic> values = availableCaracteristics.get(name);
+ if (values == null) {
+ values = Maps.newHashMap();
+ availableCaracteristics.put(name, values);
+ }
+ Type type = HydrologicCaracteristicUtil.getTypeOfCaracteristic(caracteristic);
+ values.put(type, caracteristic);
+ }
+ }
+ }
+ });
}
@Override
@@ -172,11 +201,23 @@
TuttiBeanMonitor<HydrologyRowModel> monitor = getRowMonitor();
HydrologyRowModel row = monitor.getBean();
if (row != null) {
- ui.getModel().setCaracteristic(row.getKey(),
- row.getGearShootingStartValue(),
- row.getGearShootingEndValue(),
- row.getAverageValue()
- );
+ Map<Type, Caracteristic> caracteristics = availableCaracteristics.get(row.getKey());
+ CaracteristicMap map = new CaracteristicMap();
+ for (Type type : caracteristics.keySet()) {
+ Object value = null;
+ switch (type) {
+ case START:
+ value = row.getGearShootingStartValue();
+ break;
+ case END:
+ value = row.getGearShootingEndValue();
+ break;
+ case AVERAGE:
+ value = row.getAverageValue();
+ }
+ map.put(caracteristics.get(type), value);
+ }
+ ui.getModel().addCaracteristics(map);
}
}
};
@@ -199,13 +240,19 @@
* Adds a row with the parameter selected in the combo box
*/
public void addRow() {
-// JComboBox keyCombo = ui.getNewRowKey();
-// CaracteristicRow key = (CaracteristicRow) keyCombo.getSelectedItem();
-// HydrologyRowModel row = new HydrologyRowModel(key);
-// getTableModel().addNewRow(getTable().getRowCount(), row);
-// ui.getModel().setCaracteristic(row.getKey(), null, null, null);
-//
-// keyCombo.removeItem(key);
+ JComboBox keyCombo = ui.getNewRowKey();
+ CaracteristicRow key = (CaracteristicRow) keyCombo.getSelectedItem();
+ HydrologyRowModel row = new HydrologyRowModel(key.getName());
+ getTableModel().addNewRow(getTable().getRowCount(), row);
+
+ Map<Type, Caracteristic> caracteristics = availableCaracteristics.get(key.getName());
+ CaracteristicMap map = new CaracteristicMap();
+ for (Caracteristic caracteristic : caracteristics.values()) {
+ map.put(caracteristic, null);
+ }
+ ui.getModel().addCaracteristics(map);
+
+ keyCombo.removeItem(key);
}
/**
@@ -213,28 +260,39 @@
*/
public void reset() {
CaracteristicMap hydrologyCaracteristics = ui.getModel().getHydrologyCaracteristics();
-
- List<HydrologyRowModel> rows = Lists.newArrayList();
- Collection<Caracteristic> caracteristics = hydrologyCaracteristics.keySet();
- for (Caracteristic key : hydrologyCaracteristics.keySet()) {
- rows.add(new HydrologyRowModel(key));
- }
-
- AbstractTuttiTableModel<HydrologyRowModel> tableModel = getTableModel();
- tableModel.setRows(rows, false);
-
JComboBox keyCombo = ui.getNewRowKey();
DefaultComboBoxModel keyComboModel = (DefaultComboBoxModel) keyCombo.getModel();
keyComboModel.removeAllElements();
- List<Caracteristic> availableCaracteristics = ui.getModel().getAvailableCaracteristics();
- log.info(availableCaracteristics);
- for (Caracteristic caracteristic : availableCaracteristics) {
- if (!caracteristics.contains(caracteristic)) {
+ List<HydrologyRowModel> rows = Lists.newArrayList();
+ Collection<Caracteristic> selectedCaracteristics = hydrologyCaracteristics.keySet();
+ Set<String> availableCaracteristicIds = availableCaracteristics.keySet();
+
+ for (String caracteristicId : availableCaracteristicIds) {
+ Map<Type, Caracteristic> caracteristics = availableCaracteristics.get(caracteristicId);
+
+ //should add the global caracteristic to the combo or to the table?
+ boolean selectedCaracteristic = false;
+ for (Caracteristic caracteristic : caracteristics.values()) {
+ selectedCaracteristic = selectedCaracteristic || selectedCaracteristics.contains(caracteristic);
+ }
+
+ if (selectedCaracteristic) {
+ HydrologyRowModel row = new HydrologyRowModel(caracteristicId,
+ hydrologyCaracteristics.get(caracteristics.get(Type.START)),
+ hydrologyCaracteristics.get(caracteristics.get(Type.END)),
+ hydrologyCaracteristics.get(caracteristics.get(Type.AVERAGE)));
+ rows.add(row);
+
+ } else {
+ Caracteristic caracteristic = HydrologicCaracteristicUtil.createGlobalCaracteristic(caracteristicId);
CaracteristicRow row = new CaracteristicRow(caracteristic.getName(), caracteristic);
keyComboModel.addElement(row);
}
}
+
+ AbstractTuttiTableModel<HydrologyRowModel> tableModel = getTableModel();
+ tableModel.setRows(rows, false);
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java 2012-12-28 09:17:49 UTC (rev 118)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIModel.java 2012-12-28 11:52:41 UTC (rev 119)
@@ -42,6 +42,8 @@
*/
public class HydrologyTabUIModel extends AbstractTuttiTableUIModel<FishingOperation, HydrologyRowModel, HydrologyTabUIModel> {
+ public static final String PROPERTY_AVAILABLE_CARACTERISTICS = "availableCaracteristics";
+
protected CaracteristicMap hydrologyCaracteristics = new CaracteristicMap();
protected List<Caracteristic> availableCaracteristics;
@@ -67,13 +69,9 @@
this.hydrologyCaracteristics = hydrologyCaracteristics;
}
- public void setCaracteristic(Caracteristic param, Object gearShootingStartValue,
- Object gearShootingEndValue, Object averageValue) {
-
+ public void addCaracteristics(CaracteristicMap caracteristics) {
Object oldValue = Maps.newLinkedHashMap(hydrologyCaracteristics);
-// hydrologyCaracteristics.put(param + "." + GEAR_SHOOTING_START, gearShootingStartValue);
-// hydrologyCaracteristics.put(param + "." + GEAR_SHOOTING_END, gearShootingEndValue);
-// hydrologyCaracteristics.put(param + "." + AVERAGE, averageValue);
+ hydrologyCaracteristics.putAll(caracteristics);
firePropertyChange(EditFishingOperationUIModel.PROPERTY_HYDROLOGY_CARACTERISTICS, oldValue, hydrologyCaracteristics);
}
@@ -82,7 +80,9 @@
}
public void setAvailableCaracteristics(List<Caracteristic> availableCaracteristics) {
+ Object oldValue = getAvailableCaracteristics();
this.availableCaracteristics = availableCaracteristics;
+ firePropertyChange(PROPERTY_AVAILABLE_CARACTERISTICS, oldValue, availableCaracteristics);
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java 2012-12-28 09:17:49 UTC (rev 118)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java 2012-12-28 11:52:41 UTC (rev 119)
@@ -33,6 +33,12 @@
*/
public class HydrologicCaracteristicUtil {
+ public enum Type {
+ START,
+ END,
+ AVERAGE
+ }
+
public static String getGlobalName(String name) {
if (name.charAt(name.length() - 2) == '_') {
name = name.substring(0, name.length() - 2);
@@ -46,4 +52,23 @@
caracteristic.setId(name);
return caracteristic;
}
+
+ public static Type getTypeOfCaracteristic(Caracteristic caracteristic) {
+ String name = caracteristic.getName();
+ Type result = null;
+ if (name.charAt(name.length() - 2) == '_') {
+ char lastChar = name.charAt(name.length() - 1);
+ switch (lastChar) {
+ case 'S':
+ result = Type.START;
+ break;
+ case 'E':
+ result = Type.END;
+ break;
+ case 'A':
+ result = Type.AVERAGE;
+ }
+ }
+ return result;
+ }
}
1
0
28 Dec '12
Author: tchemit
Date: 2012-12-28 10:17:49 +0100 (Fri, 28 Dec 2012)
New Revision: 118
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/118
Log:
refs #1810: [PROTOCOLE] Ecran de saisie (add sampleCategoryOrder)
refs #1805: [Onglet Poisson] Assistance ?\195?\160 la saisie des lots de poissons (add isRowValid)
fix other batch table NPE
Modified:
trunk/tutti-persistence/src/main/xmi/tutti-persistence.properties
trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.properties
===================================================================
--- trunk/tutti-persistence/src/main/xmi/tutti-persistence.properties 2012-12-28 08:53:06 UTC (rev 117)
+++ trunk/tutti-persistence/src/main/xmi/tutti-persistence.properties 2012-12-28 09:17:49 UTC (rev 118)
@@ -40,5 +40,6 @@
fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol.attribute.environmentPmfmId.stereotype=ordered
fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol.attribute.hydrologyPmfmId.stereotype=ordered
fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol.attribute.species.stereotype=ordered
+fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol.attribute.sampleCategoryOrder.stereotype=ordered
fr.ifremer.tutti.persistence.entities.referential.Caracteristic.attribute.qualitativeValue.stereotype=ordered
Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
===================================================================
(Binary files differ)
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2012-12-28 08:53:06 UTC (rev 117)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2012-12-28 09:17:49 UTC (rev 118)
@@ -84,6 +84,7 @@
public BenthosBatchTableModel(TableColumnModel columnModel) {
super(columnModel);
+ setNoneEditableCols();
}
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java 2012-12-28 08:53:06 UTC (rev 117)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java 2012-12-28 09:17:49 UTC (rev 118)
@@ -76,6 +76,7 @@
public PlanktonBatchTableModel(TableColumnModel columnModel) {
super(columnModel);
+ setNoneEditableCols();
}
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java 2012-12-28 08:53:06 UTC (rev 117)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java 2012-12-28 09:17:49 UTC (rev 118)
@@ -65,4 +65,8 @@
public void setCategoryWeight(Float categoryWeight) {
this.categoryWeight = categoryWeight;
}
+
+ public boolean isValid() {
+ return categoryValue != null && categoryWeight != null;
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2012-12-28 08:53:06 UTC (rev 117)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2012-12-28 09:17:49 UTC (rev 118)
@@ -456,7 +456,21 @@
return ageSampleCategory;
}
- // public int getRowCount() {
-// return frequency == null ? 0 : frequency.size();
-// }
+ public boolean isRowValid() {
+ boolean result = species != null;
+ if (result) {
+ result = weight != null;
+
+ if (!result) {
+
+ // No weight filled, so at least one sample category must be valid
+ result = sortedUnsortedSampleCategory.isValid() ||
+ sizeSampleCategory.isValid() ||
+ sexSampleCategory.isValid() ||
+ maturitySampleCategory.isValid() ||
+ ageSampleCategory.isValid();
+ }
+ }
+ return result;
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2012-12-28 08:53:06 UTC (rev 117)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2012-12-28 09:17:49 UTC (rev 118)
@@ -45,6 +45,7 @@
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent;
import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
+import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
@@ -53,6 +54,7 @@
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
+import java.io.Serializable;
import java.util.List;
import java.util.Set;
@@ -138,8 +140,9 @@
protected void onModelRowsChanged(List<SpeciesBatchRowModel> rows) {
super.onModelRowsChanged(rows);
+ // compute row valid
for (SpeciesBatchRowModel row : rows) {
- boolean rowValid = row.getSpecies() != null;
+ boolean rowValid = row.isRowValid();
row.setValid(rowValid);
}
// build the new sampling tree from the new rows to edit
@@ -186,86 +189,42 @@
{ // SortedUnsortedCategory column
- addColumnToModel(columnModel,
- SampleCategoryComponent.newEditor(caracteristicDecorator),
- SampleCategoryComponent.newRender(defaultRenderer, caracteristicDecorator),
- SpeciesBatchTableModel.SORTED_UNSORTED_CATEGORY);
-
-// Caracteristic data =
-// persistenceService.getSortedUnsortedCaracteristic();
-//
-// addComboDataColumnToModel(columnModel,
-// SpeciesBatchTableModel.SORTED_UNSORTED_CATEGORY,
-// caracteristicDecorator,
-// data.getQualitativeValue());
+ addSampleCategoryColumnToModel(columnModel,
+ SpeciesBatchTableModel.SORTED_UNSORTED_CATEGORY,
+ caracteristicDecorator,
+ defaultRenderer);
}
{ // SizeCategory column
- addColumnToModel(columnModel,
- SampleCategoryComponent.newEditor(caracteristicDecorator),
- SampleCategoryComponent.newRender(defaultRenderer, caracteristicDecorator),
- SpeciesBatchTableModel.SIZE_CATEGORY);
-
-// Caracteristic data =
-// persistenceService.getSizeCategoryCaracteristic();
-//
-// addComboDataColumnToModel(columnModel,
-// SpeciesBatchTableModel.SIZE_CATEGORY,
-// caracteristicDecorator,
-// data.getQualitativeValue());
+ addSampleCategoryColumnToModel(columnModel,
+ SpeciesBatchTableModel.SIZE_CATEGORY,
+ caracteristicDecorator,
+ defaultRenderer);
}
{ // SexCategory column
- addColumnToModel(columnModel,
- SampleCategoryComponent.newEditor(caracteristicDecorator),
- SampleCategoryComponent.newRender(defaultRenderer, caracteristicDecorator),
- SpeciesBatchTableModel.SEX_CATEGORY);
-
-// Caracteristic data = persistenceService.getSexCaracteristic();
-//
-// addComboDataColumnToModel(columnModel,
-// SpeciesBatchTableModel.SEX_CATEGORY,
-// caracteristicDecorator,
-// data.getQualitativeValue());
+ addSampleCategoryColumnToModel(columnModel,
+ SpeciesBatchTableModel.SEX_CATEGORY,
+ caracteristicDecorator,
+ defaultRenderer);
}
{ // MaturityCategory column
- addColumnToModel(columnModel,
- SampleCategoryComponent.newEditor(caracteristicDecorator),
- SampleCategoryComponent.newRender(defaultRenderer, caracteristicDecorator),
- SpeciesBatchTableModel.MATURITY_CATEGORY);
-
-// Caracteristic data =
-// persistenceService.getMaturityCaracteristic();
-//
-//
-// addComboDataColumnToModel(columnModel,
-// SpeciesBatchTableModel.MATURITY_CATEGORY,
-// caracteristicDecorator,
-// data.getQualitativeValue());
+ addSampleCategoryColumnToModel(columnModel,
+ SpeciesBatchTableModel.MATURITY_CATEGORY,
+ caracteristicDecorator,
+ defaultRenderer);
}
{ // AgeCategory column
- Decorator<Float> floatDecorator = new Decorator<Float>(Float.class) {
- private static final long serialVersionUID = 1L;
-
- @Override
- public String toString(Object bean) {
- return String.valueOf(bean);
- }
- };
- addColumnToModel(columnModel,
- SampleCategoryComponent.newEditor(floatDecorator),
- SampleCategoryComponent.newRender(defaultRenderer, floatDecorator),
- SpeciesBatchTableModel.AGE_CATEGORY);
-
-// addFloatColumnToModel(columnModel,
-// SpeciesBatchTableModel.AGE_CATEGORY,
-// TuttiUI.DECIMAL3_PATTERN);
+ addSampleCategoryColumnToModel(columnModel,
+ SpeciesBatchTableModel.AGE_CATEGORY,
+ getDecorator(Float.class, null),
+ defaultRenderer);
}
{ // Weight column
@@ -333,13 +292,20 @@
recomputeTotalHorsVrac();
}
- if (SpeciesBatchRowModel.PROPERTY_SPECIES.equals(propertyName)) {
+ if (SAMPLING_PROPERTIES.contains(propertyName)) {
// species has changed, recompute valid property
- boolean rowValid = newValue != null;
+ boolean rowValid = row.isRowValid();
row.setValid(rowValid);
}
+ if (SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
+
+ // weight has changed, recompute valid property
+ boolean rowValid = row.isRowValid();
+ row.setValid(rowValid);
+ }
+
// SpeciesBatchUIModel model = getModel();
//
// SpeciesBatchTreeModel samplingTreeModel = model.getSamplingTreeModel();
@@ -715,4 +681,14 @@
//TODO Should we also set the total vrac weight ?
// getModel().setTotalVracWeight(totalVrac);
}
+
+ protected <C extends Serializable> void addSampleCategoryColumnToModel(TableColumnModel columnModel,
+ ColumnIdentifier<SpeciesBatchRowModel> columnIdentifier,
+ Decorator<C> decorator,
+ TableCellRenderer defaultRenderer) {
+ addColumnToModel(columnModel,
+ SampleCategoryComponent.newEditor(decorator),
+ SampleCategoryComponent.newRender(defaultRenderer, decorator),
+ columnIdentifier);
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesRowModel.java 2012-12-28 08:53:06 UTC (rev 117)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesRowModel.java 2012-12-28 09:17:49 UTC (rev 118)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.ui.swing.content.protocol;
+/*
+ * #%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.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2012-12-28 08:53:06 UTC (rev 117)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2012-12-28 09:17:49 UTC (rev 118)
@@ -1,6 +1,29 @@
package fr.ifremer.tutti.ui.swing.content.protocol;
-import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
+/*
+ * #%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;
@@ -43,7 +66,9 @@
EditProtocolSpeciesRowModel.PROPERTY_SIZE_FRENQUENCY_PMFM,
n_("tutti.table.protocol.species.header.sizeFrequency"),
n_("tutti.table.protocol.species.header.sizeFrequency"));
-
+
+ private static final long serialVersionUID = 1L;
+
public EditProtocolSpeciesTableModel(TableColumnModel columnModel) {
super(columnModel);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-28 08:53:06 UTC (rev 117)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-28 09:17:49 UTC (rev 118)
@@ -275,7 +275,8 @@
});
JXTable table = ui.getSpeciesTable();
- TableColumnModel columnModel = createTableColumnModel(null);
+ TableColumnModel columnModel = createTableColumnModel(
+ table.getDefaultRenderer(Object.class));
EditProtocolSpeciesTableModel tableModel =
new EditProtocolSpeciesTableModel(columnModel);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java 2012-12-28 08:53:06 UTC (rev 117)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java 2012-12-28 09:17:49 UTC (rev 118)
@@ -1,6 +1,30 @@
package fr.ifremer.tutti.ui.swing.util;
+/*
+ * #%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.referential.Caracteristic;
/**
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
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-28 08:53:06 UTC (rev 117)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-28 09:17:49 UTC (rev 118)
@@ -180,7 +180,6 @@
tutti.table.plankton.batch.header.speciesByGenusCode=Espèce
tutti.table.plankton.batch.header.toConfirm=A Confirmer
tutti.table.plankton.batch.header.weight=Poids
-tutti.table.species.batch.header.ageCategory=Age
tutti.table.protocol.species.header.maturity=Maturité
tutti.table.protocol.species.header.sex=Sexe
tutti.table.protocol.species.header.sizeCategory=Catégorie Taille
@@ -188,6 +187,7 @@
tutti.table.protocol.species.header.sortedUnsorted=Vrac / Hors Vrac
tutti.table.protocol.species.header.speciesId=Espèce
tutti.table.species.batch.header.age=Age
+tutti.table.species.batch.header.ageCategory=Age
tutti.table.species.batch.header.comment=Commentaire
tutti.table.species.batch.header.computedNumber=Nombre calculé
tutti.table.species.batch.header.computedWeight=Poids calculé
1
0
r117 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol
by kmorin@users.forge.codelutin.com 28 Dec '12
by kmorin@users.forge.codelutin.com 28 Dec '12
28 Dec '12
Author: kmorin
Date: 2012-12-28 09:53:06 +0100 (Fri, 28 Dec 2012)
New Revision: 117
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/117
Log:
debug
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-28 08:38:23 UTC (rev 116)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-28 08:53:06 UTC (rev 117)
@@ -50,6 +50,7 @@
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionListener;
+import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import jaxx.runtime.swing.editor.bean.BeanDoubleList;
import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
@@ -131,7 +132,7 @@
}
@Override
- protected TableColumnModel createTableColumnModel() {
+ protected TableColumnModel createTableColumnModel(TableCellRenderer renderer) {
JXTable table = ui.getSpeciesTable();
DecoratorService decoratorService = context.getService(DecoratorService.class);
JXPathDecorator<Caracteristic> decorator =
@@ -274,7 +275,7 @@
});
JXTable table = ui.getSpeciesTable();
- TableColumnModel columnModel = createTableColumnModel();
+ TableColumnModel columnModel = createTableColumnModel(null);
EditProtocolSpeciesTableModel tableModel =
new EditProtocolSpeciesTableModel(columnModel);
1
0
r116 - trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content
by tchemit@users.forge.codelutin.com 28 Dec '12
by tchemit@users.forge.codelutin.com 28 Dec '12
28 Dec '12
Author: tchemit
Date: 2012-12-28 09:38:23 +0100 (Fri, 28 Dec 2012)
New Revision: 116
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/116
Log:
remove obsolete package
Removed:
trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/catches/
1
0
r115 - in trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content: catches operation operation/catches operation/catches/species operation/catches/species/frequency
by tchemit@users.forge.codelutin.com 28 Dec '12
by tchemit@users.forge.codelutin.com 28 Dec '12
28 Dec '12
Author: tchemit
Date: 2012-12-28 09:35:21 +0100 (Fri, 28 Dec 2012)
New Revision: 115
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/115
Log:
move test
Added:
trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/catches/
trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/
trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/
trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModelTest.java
Removed:
trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/catches/species/
trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/species/
Copied: trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModelTest.java (from rev 114, trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyRowModelTest.java)
===================================================================
--- trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModelTest.java (rev 0)
+++ trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModelTest.java 2012-12-28 08:35:21 UTC (rev 115)
@@ -0,0 +1,66 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency;
+
+/*
+ * #%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 org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class SpeciesFrequencyRowModelTest {
+
+ @Test
+ public void compareTo() throws Exception {
+
+ SpeciesFrequencyRowModel s0 = new SpeciesFrequencyRowModel();
+ SpeciesFrequencyRowModel s1 = new SpeciesFrequencyRowModel();
+
+ // s0=null, s1=null
+ Assert.assertTrue(s0.compareTo(s1) == 0);
+
+ // s0=1, s1=null
+ s0.setLengthStep(1f);
+ Assert.assertTrue(s0.compareTo(s1) > 0);
+
+ // s0=null, s1=1
+ s0.setLengthStep(null);
+ s1.setLengthStep(1f);
+ Assert.assertTrue(s0.compareTo(s1) < 0);
+
+ // s0=2, s1=1
+ s0.setLengthStep(2f);
+ Assert.assertTrue(s0.compareTo(s1) > 0);
+
+ // s0=2, s1=2
+ s1.setLengthStep(2f);
+ Assert.assertTrue(s0.compareTo(s1) == 0);
+
+ // s0=2, s1=3
+ s1.setLengthStep(3f);
+ Assert.assertTrue(s0.compareTo(s1) < 0);
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModelTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
28 Dec '12
Author: tchemit
Date: 2012-12-28 09:34:01 +0100 (Fri, 28 Dec 2012)
New Revision: 114
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/114
Log:
refs #1805: [Onglet Poisson] Assistance ?\195?\160 la saisie des lots de poissons
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryEditor.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryRenderer.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/TableViewMode.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java
Removed:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/FrequencyCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIModel.java
Modified:
trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTreeModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
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/gearshooting/GearShootingTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyRowModelTest.java
Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
===================================================================
(Binary files differ)
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -104,6 +104,14 @@
registerMultiJXPathDecorator(Species.class, SPECIES_BY_GENUS, "${genusSpecies}$s", SEPARATOR, " - ");
registerMultiJXPathDecorator(SpeciesProtocol.class, "${speciesId}", SEPARATOR, " - ");
registerMultiJXPathDecorator(Attachment.class, "${name}$s", SEPARATOR, " - ");
+ registerDecorator(new Decorator<Float>(Float.class) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String toString(Object bean) {
+ return bean == null ? "" : String.valueOf(bean);
+ }
+ });
}
};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -43,6 +43,7 @@
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
+import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import java.util.List;
@@ -99,7 +100,7 @@
}
@Override
- protected TableColumnModel createTableColumnModel() {
+ protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
DefaultTableColumnModelExt columnModel =
new DefaultTableColumnModelExt();
@@ -327,7 +328,7 @@
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel();
+ TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
// create table model
AccidentalBatchTableModel tableModel =
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -49,10 +49,10 @@
public static final String PROPERTY_WEIGHT = "weight";
+ public static final String PROPERTY_NUMBER = "number";
+
public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight";
- public static final String PROPERTY_SAMPLING_RATIO = "samplingRatio";
-
public static final String PROPERTY_COMMENT = "comment";
public static final String PROPERTY_ATTACHMENTS = "attachments";
@@ -79,19 +79,20 @@
protected Float weight;
/**
- * Sample weight.
+ * Observed number.
*
- * @since 0.2
+ * @since 0.3
*/
- protected Float sampleWeight;
+ protected Integer number;
/**
- * Sampling ratio.
+ * Sample weight.
*
* @since 0.2
*/
- protected Float samplingRatio;
+ protected Float sampleWeight;
+
/**
* Comment on this catches.
*
@@ -163,14 +164,14 @@
firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight);
}
- public Float getSamplingRatio() {
- return samplingRatio;
+ public Integer getNumber() {
+ return number;
}
- public void setSamplingRatio(Float samplingRatio) {
- Object oldValue = getSamplingRatio();
- this.samplingRatio = samplingRatio;
- firePropertyChange(PROPERTY_SAMPLING_RATIO, oldValue, samplingRatio);
+ public void setNumber(Integer number) {
+ Object oldValue = getNumber();
+ this.number = number;
+ firePropertyChange(PROPERTY_NUMBER, oldValue, number);
}
public String getComment() {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -56,16 +56,17 @@
n_("tutti.table.benthos.batch.header.weight"),
n_("tutti.table.benthos.batch.header.weight"));
+ public static final ColumnIdentifier<BenthosBatchRowModel> NUMBER = ColumnIdentifier.newId(
+ BenthosBatchRowModel.PROPERTY_NUMBER,
+ n_("tutti.table.benthos.batch.header.number"),
+ n_("tutti.table.benthos.batch.header.number"));
+
+
public static final ColumnIdentifier<BenthosBatchRowModel> SAMPLE_WEIGHT = ColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
n_("tutti.table.benthos.batch.header.sampleWeight"),
n_("tutti.table.benthos.batch.header.sampleWeight"));
- public static final ColumnIdentifier<BenthosBatchRowModel> SAMPLING_RATIO = ColumnIdentifier.newId(
- BenthosBatchRowModel.PROPERTY_SAMPLING_RATIO,
- n_("tutti.table.benthos.batch.header.samplingRatio"),
- n_("tutti.table.benthos.batch.header.samplingRatio"));
-
public static final ColumnIdentifier<BenthosBatchRowModel> COMMENT = ColumnIdentifier.newId(
BenthosBatchRowModel.PROPERTY_COMMENT,
n_("tutti.table.benthos.batch.header.comment"),
@@ -83,8 +84,6 @@
public BenthosBatchTableModel(TableColumnModel columnModel) {
super(columnModel);
-
- setNoneEditableCols(SAMPLE_WEIGHT, SAMPLING_RATIO);
}
@Override
@@ -107,37 +106,12 @@
if (propertyName == SPECIES_BY_CODE) {
// update also other columns
- fireTableCellUpdated(rowIndex,
- SPECIES_BY_GENUS_CODE);
+ fireTableCellUpdated(rowIndex, SPECIES_BY_GENUS_CODE);
} else if (propertyName == SPECIES_BY_GENUS_CODE) {
// update also other columns
- fireTableCellUpdated(rowIndex,
- SPECIES_BY_CODE);
+ fireTableCellUpdated(rowIndex, SPECIES_BY_CODE);
}
}
-
- public void updateSamplingRatio(Set<BenthosBatchRowModel> rows) {
- for (BenthosBatchRowModel row : rows) {
- int rowIndex = getRows().indexOf(row);
- fireTableCellUpdated(rowIndex,
- SAMPLE_WEIGHT,
- SAMPLING_RATIO);
- }
-
-
- }
-
- @Override
- protected boolean isCellEditable(int rowIndex,
- int columnIndex,
- ColumnIdentifier<BenthosBatchRowModel> propertyName) {
-
- boolean result = super.isCellEditable(rowIndex,
- columnIndex,
- propertyName);
-
- return result;
- }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2012-12-28 08:34:01 UTC (rev 114)
@@ -120,7 +120,7 @@
<JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
<JXTable id='table'
- onFocusLost='handler.saveSelectedRowIfRequired(event);'/>
+ onFocusLost='handler.saveSelectedRowIfRequired(event)'/>
</JScrollPane>
</JPanel>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -43,6 +43,7 @@
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
+import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import java.util.List;
@@ -71,6 +72,8 @@
BenthosBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM,
BenthosBatchRowModel.PROPERTY_SPECIES,
BenthosBatchRowModel.PROPERTY_WEIGHT,
+ BenthosBatchRowModel.PROPERTY_NUMBER,
+ BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
BenthosBatchRowModel.PROPERTY_COMMENT);
this.ui = ui;
@@ -100,16 +103,16 @@
return getModel().getFishingOperation();
}
- @Override
- protected String[] getRowPropertiesToIgnore() {
- return new String[]{
- BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
- BenthosBatchRowModel.PROPERTY_SAMPLING_RATIO
- };
- }
+// @Override
+// protected String[] getRowPropertiesToIgnore() {
+// return new String[]{
+// BenthosBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
+// BenthosBatchRowModel.PROPERTY_SAMPLING_RATIO
+// };
+// }
@Override
- protected TableColumnModel createTableColumnModel() {
+ protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
DefaultTableColumnModelExt columnModel =
new DefaultTableColumnModelExt();
@@ -146,16 +149,18 @@
TuttiUI.DECIMAL3_PATTERN);
}
- { // Sample weight column
+ { // Number column
- addColumnToModel(columnModel,
- BenthosBatchTableModel.SAMPLE_WEIGHT);
+ addIntegerColumnToModel(columnModel,
+ BenthosBatchTableModel.NUMBER,
+ TuttiUI.INT_3_DIGITS_PATTERN);
}
- { // SamplingRatio column
+ { // Sample weight column
- addColumnToModel(columnModel,
- BenthosBatchTableModel.SAMPLING_RATIO);
+ addFloatColumnToModel(columnModel,
+ BenthosBatchTableModel.SAMPLE_WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
}
{ // Comment column
@@ -359,7 +364,7 @@
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel();
+ TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
// create table model
BenthosBatchTableModel tableModel =
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -42,6 +42,7 @@
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
+import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import java.util.List;
@@ -99,7 +100,7 @@
}
@Override
- protected TableColumnModel createTableColumnModel() {
+ protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
DefaultTableColumnModelExt columnModel =
new DefaultTableColumnModelExt();
@@ -333,7 +334,7 @@
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel();
+ TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
// create table model
MacroWasteBatchTableModel tableModel =
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -51,8 +51,6 @@
public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight";
- public static final String PROPERTY_SAMPLING_RATIO = "samplingRatio";
-
public static final String PROPERTY_COMMENT = "comment";
public static final String PROPERTY_ATTACHMENTS = "attachments";
@@ -86,13 +84,6 @@
protected Float sampleWeight;
/**
- * Sampling ratio.
- *
- * @since 0.2
- */
- protected Float samplingRatio;
-
- /**
* Comment on this catches.
*
* @since 0.2
@@ -163,16 +154,6 @@
firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight);
}
- public Float getSamplingRatio() {
- return samplingRatio;
- }
-
- public void setSamplingRatio(Float samplingRatio) {
- Object oldValue = getSamplingRatio();
- this.samplingRatio = samplingRatio;
- firePropertyChange(PROPERTY_SAMPLING_RATIO, oldValue, samplingRatio);
- }
-
public String getComment() {
return comment;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -64,11 +64,6 @@
n_("tutti.table.plankton.batch.header.sampleWeight"),
n_("tutti.table.plankton.batch.header.sampleWeight"));
- public static final ColumnIdentifier<PlanktonBatchRowModel> SAMPLING_RATIO = ColumnIdentifier.newId(
- PlanktonBatchRowModel.PROPERTY_SAMPLING_RATIO,
- n_("tutti.table.plankton.batch.header.elevationRate"),
- n_("tutti.table.plankton.batch.header.elevationRate"));
-
public static final ColumnIdentifier<PlanktonBatchRowModel> COMMENT = ColumnIdentifier.newId(
PlanktonBatchRowModel.PROPERTY_COMMENT,
n_("tutti.table.plankton.batch.header.comment"),
@@ -81,8 +76,6 @@
public PlanktonBatchTableModel(TableColumnModel columnModel) {
super(columnModel);
-
- setNoneEditableCols(SAMPLE_WEIGHT, SAMPLING_RATIO);
}
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -43,6 +43,7 @@
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
+import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import java.util.List;
@@ -98,24 +99,23 @@
return getModel().getFishingOperation();
}
- @Override
- protected String[] getRowPropertiesToIgnore() {
- return new String[]{
- PlanktonBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
- PlanktonBatchRowModel.PROPERTY_SAMPLING_RATIO
- };
- }
+// @Override
+// protected String[] getRowPropertiesToIgnore() {
+// return new String[]{
+// PlanktonBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
+// PlanktonBatchRowModel.PROPERTY_SAMPLING_RATIO
+// };
+// }
@Override
- protected TableColumnModel createTableColumnModel() {
+ protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
DefaultTableColumnModelExt columnModel =
new DefaultTableColumnModelExt();
List<Species> allSpecies = persistenceService.getAllSpecies();
- {
- // Species (by code) column
+ { // Species (by code) column
Decorator<Species> decorator = getDecorator(
Species.class, DecoratorService.SPECIES_BY_CODE);
@@ -125,8 +125,7 @@
decorator, allSpecies);
}
- {
- // Species (by genusCode) column
+ { // Species (by genusCode) column
Decorator<Species> decorator = getDecorator(
Species.class, DecoratorService.SPECIES_BY_GENUS);
@@ -150,12 +149,6 @@
PlanktonBatchTableModel.SAMPLE_WEIGHT);
}
- { // SamplingRatio column
-
- addColumnToModel(columnModel,
- PlanktonBatchTableModel.SAMPLING_RATIO);
- }
-
{ // Comment column
addColumnToModel(columnModel,
@@ -174,8 +167,7 @@
PlanktonBatchTableModel.ATTACHMENTS);
}
- {
- // Species to confirm column
+ { // Species to confirm column
addBooleanColumnToModel(columnModel,
PlanktonBatchTableModel.SPECIES_TO_CONFIRM,
@@ -356,7 +348,7 @@
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel();
+ TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
// create table model
PlanktonBatchTableModel tableModel =
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/FrequencyCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/FrequencyCellComponent.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/FrequencyCellComponent.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -1,257 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
-
-/*
- * #%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.base.Preconditions;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
-import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.AbstractCellEditor;
-import javax.swing.JButton;
-import javax.swing.JTable;
-import javax.swing.border.LineBorder;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Frame;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Component to render and edit frequency stuff from batch table.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class FrequencyCellComponent extends JButton {
-
- private static final long serialVersionUID = 1L;
-
- public static final String ROW_INDEX = "rowIndex";
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(FrequencyCellComponent.class);
-
- public FrequencyCellComponent() {
- setContentAreaFilled(false);
- setOpaque(false);
- setIcon(SwingUtil.createActionIcon("show-frequency"));
- }
-
- public static TableCellRenderer newRender() {
- return new FrequencyCellRenderer();
- }
-
- public static TableCellEditor newEditor(SpeciesFrequencyUI ui) {
- return new FrequencyCellEditor(ui);
- }
-
- public static class FrequencyCellEditor extends AbstractCellEditor implements TableCellEditor {
-
- private static final long serialVersionUID = 1L;
-
- protected final FrequencyCellComponent component;
-
- protected final SpeciesFrequencyUI ui;
-
- protected Frame frame;
-
- protected JTable table;
-
- protected SpeciesBatchTableModel tableModel;
-
- protected ColumnIdentifier<SpeciesBatchRowModel> columnIdentifier;
-
- protected SpeciesBatchRowModel editRow;
-
- protected Integer rowIndex;
-
- protected Integer columnIndex;
-
- public FrequencyCellEditor(SpeciesFrequencyUI ui) {
- this.ui = ui;
- component = new FrequencyCellComponent();
- component.setBorder(new LineBorder(Color.BLACK));
- component.addKeyListener(new KeyAdapter() {
- @Override
- public void keyReleased(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_ENTER ||
- e.getKeyCode() == KeyEvent.VK_SPACE) {
- e.consume();
- startEdit();
- }
- }
- });
-
- component.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
- e.consume();
- startEdit();
- }
- });
- }
-
- protected void startEdit() {
-
- Preconditions.checkNotNull(tableModel, "No table model assigned.");
-
- // open frequency dialog
-
- Preconditions.checkNotNull(editRow, "No editRow found.");
-
- if (log.isInfoEnabled()) {
- log.info("Will edit frequencies for row: " + rowIndex);
- }
-
- if (frame == null) {
- frame = SwingUtil.getParentContainer(ui, Frame.class);
- }
-
- ui.editBatch(editRow);
-
- // open frequency dialog
- TuttiUIUtil.openInDialog(
- ui, frame, _("tutti.title.frequency"), true, null);
-
- // at close, synch back frequencies
-
- editRow.updateTotalFromFrequencies();
-
- int r = rowIndex;
- int c = columnIndex;
-
- // stop edition
- stopCellEditing();
-
- // reselect this cell
- AbstractSelectTableAction.doSelectCell(table, r, c);
- table.requestFocus();
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table,
- Object value,
- boolean isSelected,
- int row,
- int column) {
- if (tableModel == null) {
- tableModel = (SpeciesBatchTableModel) table.getModel();
- this.table = table;
- columnIdentifier = tableModel.getPropertyName(column);
- }
- String text;
- if (value == null) {
- text = " - ";
- } else {
- text = String.valueOf(value);
- }
- component.setText(text);
-
- rowIndex = row;
- columnIndex = column;
-
- editRow = tableModel.getEntry(row);
-
- return component;
- }
-
- @Override
- public Object getCellEditorValue() {
-
- Preconditions.checkNotNull(editRow, "No editRow found in editor.");
-
- Object result;
- if (columnIdentifier == SpeciesBatchTableModel.COMPUTED_NUMBER) {
- result = editRow.getComputedNumber();
- } else {
- result = editRow.getComputedWeight();
- }
- if (log.isInfoEnabled()) {
- log.info("editor value (" + columnIdentifier + "): " + result);
- }
-
- return result;
- }
-
- @Override
- public boolean stopCellEditing() {
- boolean b = super.stopCellEditing();
- if (b) {
- rowIndex = null;
- editRow = null;
- columnIndex = null;
- }
- return b;
- }
-
- @Override
- public void cancelCellEditing() {
- super.cancelCellEditing();
- rowIndex = null;
- columnIndex = null;
- editRow = null;
- }
- }
-
- public static class FrequencyCellRenderer implements TableCellRenderer {
-
- protected final FrequencyCellComponent component;
-
- public FrequencyCellRenderer() {
- component = new FrequencyCellComponent();
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table,
- Object value,
- boolean isSelected,
- boolean hasFocus,
- int row,
- int column) {
-
- String text;
- if (value == null) {
- text = " - ";
- } else {
- text = String.valueOf(value);
- }
- boolean editable = table.isCellEditable(row, column);
- component.setEnabled(editable);
- component.setText(text);
- return component;
- }
- }
-}
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -0,0 +1,68 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
+
+/*
+ * #%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.io.Serializable;
+
+/**
+ * Represents a sample category value in the species batch table.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class SampleCategory<C extends Serializable> implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Sample category value.
+ *
+ * @since 0.3
+ */
+ protected C categoryValue;
+
+ /**
+ * Sample category weight.
+ *
+ * @since 0.3
+ */
+ protected Float categoryWeight;
+
+ public C getCategoryValue() {
+ return categoryValue;
+ }
+
+ public void setCategoryValue(C categoryValue) {
+ this.categoryValue = categoryValue;
+ }
+
+ public Float getCategoryWeight() {
+ return categoryWeight;
+ }
+
+ public void setCategoryWeight(Float categoryWeight) {
+ this.categoryWeight = categoryWeight;
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategory.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/operation/catches/species/SampleCategoryComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -0,0 +1,48 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
+
+/*
+ * #%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 org.nuiton.util.decorator.Decorator;
+
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import java.io.Serializable;
+
+/**
+ * To render and edit a {@link SampleCategory}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class SampleCategoryComponent {
+
+ public static <C extends Serializable> TableCellRenderer newRender(TableCellRenderer renderer, Decorator<C> decorator) {
+ return new SampleCategoryRenderer<C>(renderer, decorator);
+ }
+
+ public static <C extends Serializable> TableCellEditor newEditor(Decorator<C> decorator) {
+ return new SampleCategoryEditor<C>(decorator);
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryComponent.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/operation/catches/species/SampleCategoryEditor.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryEditor.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryEditor.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -0,0 +1,167 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
+
+/*
+ * #%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 jaxx.runtime.swing.editor.NumberEditor;
+import org.nuiton.util.decorator.Decorator;
+
+import javax.swing.AbstractCellEditor;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTable;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.event.AncestorEvent;
+import javax.swing.event.AncestorListener;
+import javax.swing.table.TableCellEditor;
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.io.Serializable;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since TODO
+ */
+public class SampleCategoryEditor<C extends Serializable> extends AbstractCellEditor
+ implements TableCellEditor, FocusListener, AncestorListener {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final NumberEditor numberEditor;
+
+ protected final JPanel editor;
+
+ protected final JLabel editorLabel;
+
+ protected final Decorator<C> categoryDecorator;
+
+ public SampleCategoryEditor(Decorator<C> categoryDecorator) {
+ this.categoryDecorator = categoryDecorator;
+ numberEditor = new NumberEditor();
+ numberEditor.getTextField().setHorizontalAlignment(SwingConstants.RIGHT);
+ numberEditor.getTextField().setBorder(null);
+ numberEditor.getTextField().addFocusListener(this);
+ numberEditor.getTextField().addAncestorListener(this);
+ numberEditor.setModelType(Float.class);
+ numberEditor.setUseSign(false);
+ numberEditor.init();
+
+ editor = new JPanel(new BorderLayout());
+ editor.add(BorderLayout.WEST, editorLabel = new JLabel());
+ editor.add(BorderLayout.CENTER, numberEditor);
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ int row,
+ int column) {
+
+ SampleCategory<C> sampleCategory = (SampleCategory<C>) value;
+
+ C categoryValue = sampleCategory == null ? null : sampleCategory.getCategoryValue();
+ Float number = sampleCategory == null ? null : sampleCategory.getCategoryWeight();
+
+ numberEditor.setModel(number);
+
+ // Check nullity and set the text that will be selected with the current value
+ if (number == null) {
+ numberEditor.setModelText("");
+ } else {
+ numberEditor.setModelText(String.valueOf(number));
+ }
+
+ String label = sampleCategory == null ? "-" :
+ categoryDecorator.toString(categoryValue);
+
+ editorLabel.setText(label);
+ return editor;
+ }
+
+ @Override
+ public Float getCellEditorValue() {
+ return (Float) numberEditor.getModel();
+ }
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ numberEditor.getTextField().requestFocus();
+ numberEditor.getTextField().selectAll();
+ }
+ });
+ }
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ }
+
+ @Override
+ public void ancestorAdded(AncestorEvent event) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ numberEditor.getTextField().requestFocus();
+ numberEditor.getTextField().selectAll();
+ }
+ });
+ }
+
+ @Override
+ public void ancestorRemoved(AncestorEvent event) {
+ }
+
+ @Override
+ public void ancestorMoved(AncestorEvent event) {
+ }
+
+ @Override
+ public boolean stopCellEditing() {
+ boolean result = super.stopCellEditing();
+ // Reset previous data to avoid keeping it on other cell edition
+ if (result) {
+ resetEditor();
+ }
+ return result;
+ }
+
+ @Override
+ public void cancelCellEditing() {
+ resetEditor();
+ super.cancelCellEditing();
+ }
+
+ protected void resetEditor() {
+ numberEditor.setModel(null);
+ // Use empty string, otherwise there is a NPE in NumberEditorHandler
+ numberEditor.setModelText("");
+ editorLabel.setText("-");
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryEditor.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/operation/catches/species/SampleCategoryRenderer.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryRenderer.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryRenderer.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -0,0 +1,82 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
+
+/*
+ * #%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 org.nuiton.util.decorator.Decorator;
+
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Component;
+import java.io.Serializable;
+
+/**
+ * To render a {@link SampleCategory} in a table cell.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class SampleCategoryRenderer<C extends Serializable> implements TableCellRenderer {
+
+ protected final TableCellRenderer delegate;
+
+ protected final Decorator<C> categoryDecorator;
+
+ public SampleCategoryRenderer(TableCellRenderer delegate,
+ Decorator<C> categoryDecorator) {
+ this.delegate = delegate;
+ this.categoryDecorator = categoryDecorator;
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column) {
+ SampleCategory<C> sampleCategory = (SampleCategory<C>) value;
+
+ String text = null;
+ if (sampleCategory != null) {
+ C categoryValue = sampleCategory.getCategoryValue();
+ Float number = sampleCategory.getCategoryWeight();
+
+ text = categoryDecorator.toString(categoryValue) + " / ";
+
+ if (number == null) {
+ text = "-";
+ } else {
+ text += number;
+ }
+ }
+
+ return delegate.getTableCellRendererComponent(table,
+ text,
+ isSelected,
+ hasFocus,
+ row,
+ column);
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryRenderer.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/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -31,6 +31,7 @@
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
import org.apache.commons.collections.CollectionUtils;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -52,22 +53,40 @@
public static final String PROPERTY_SPECIES_TO_CONFIRM = "speciesToConfirm";
+ public static final String PROPERTY_SORTED_UNSORTED_SAMPLE_CATEGORY = "sortedUnsortedSampleCategory";
+
public static final String PROPERTY_SORTED_UNSORTED_CATEGORY = "sortedUnsortedCategory";
+ public static final String PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT = "sortedUnsortedCategoryWeight";
+
+ public static final String PROPERTY_SIZE_SAMPLE_CATEGORY = "sizeSampleCategory";
+
public static final String PROPERTY_SIZE_CATEGORY = "sizeCategory";
+ public static final String PROPERTY_SIZE_CATEGORY_WEIGHT = "sizeCategoryWeight";
+
+ public static final String PROPERTY_SEX_SAMPLE_CATEGORY = "sexSampleCategory";
+
public static final String PROPERTY_SEX_CATEGORY = "sexCategory";
+ public static final String PROPERTY_SEX_CATEGORY_WEIGHT = "sexCategoryWeight";
+
+ public static final String PROPERTY_MATURITY_SAMPLE_CATEGORY = "maturitySampleCategory";
+
public static final String PROPERTY_MATURITY_CATEGORY = "maturityCategory";
- public static final String PROPERTY_AGE = "age";
+ public static final String PROPERTY_MATURITY_CATEGORY_WEIGHT = "maturityCategoryWeight";
+ public static final String PROPERTY_AGE_SAMPLE_CATEGORY = "ageSampleCategory";
+
+ public static final String PROPERTY_AGE_CATEGORY = "ageCategory";
+
+ public static final String PROPERTY_AGE_CATEGORY_WEIGHT = "ageCategoryWeight";
+
public static final String PROPERTY_WEIGHT = "weight";
- public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight";
+ public static final String PROPERTY_NUMBER = "number";
- public static final String PROPERTY_SAMPLING_RATIO = "samplingRatio";
-
public static final String PROPERTY_COMMENT = "comment";
public static final String PROPERTY_FREQUENCY = "frequency";
@@ -97,35 +116,35 @@
*
* @since 0.2
*/
- protected CaracteristicQualitativeValue sortedUnsortedCategory;
+ protected final SampleCategory<CaracteristicQualitativeValue> sortedUnsortedSampleCategory = new SampleCategory<CaracteristicQualitativeValue>();
/**
* Weight category (can be null).
*
* @since 0.2
*/
- protected CaracteristicQualitativeValue sizeCategory;
+ protected final SampleCategory<CaracteristicQualitativeValue> sizeSampleCategory = new SampleCategory<CaracteristicQualitativeValue>();
/**
* Sex (can be null).
*
* @since 0.2
*/
- protected CaracteristicQualitativeValue sexCategory;
+ protected final SampleCategory<CaracteristicQualitativeValue> sexSampleCategory = new SampleCategory<CaracteristicQualitativeValue>();
/**
* Maturity (can be null).
*
* @since 0.2
*/
- protected CaracteristicQualitativeValue maturityCategory;
+ protected final SampleCategory<CaracteristicQualitativeValue> maturitySampleCategory = new SampleCategory<CaracteristicQualitativeValue>();
/**
* Age (can be null).
*
* @since 0.2
*/
- protected Float age;
+ protected final SampleCategory<Float> ageSampleCategory = new SampleCategory<Float>();
/**
* Observed weight.
@@ -135,6 +154,13 @@
protected Float weight;
/**
+ * Observed number.
+ *
+ * @since 0.3
+ */
+ protected Integer number;
+
+ /**
* Total computed weight (from frequencies).
*
* @since 0.2
@@ -149,20 +175,6 @@
protected Float computedNumber;
/**
- * Sample weight.
- *
- * @since 0.2
- */
- protected Float sampleWeight;
-
- /**
- * Sampling ratio.
- *
- * @since 0.2
- */
- protected Float samplingRatio;
-
- /**
* Comment on this catches.
*
* @since 0.2
@@ -253,55 +265,105 @@
}
public CaracteristicQualitativeValue getSortedUnsortedCategory() {
- return sortedUnsortedCategory;
+ return sortedUnsortedSampleCategory.getCategoryValue();
}
public void setSortedUnsortedCategory(CaracteristicQualitativeValue sortedUnsortedCategory) {
Object oldValue = getSortedUnsortedCategory();
- this.sortedUnsortedCategory = sortedUnsortedCategory;
+ sortedUnsortedSampleCategory.setCategoryValue(sortedUnsortedCategory);
firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY, oldValue, sortedUnsortedCategory);
}
+ public Float getSortedUnsortedCategoryWeight() {
+ return sortedUnsortedSampleCategory.getCategoryWeight();
+ }
+
+ public void setSortedUnsortedCategoryWeight(Float sortedUnsortedCategoryWeight) {
+ Object oldValue = getSortedUnsortedCategoryWeight();
+ sortedUnsortedSampleCategory.setCategoryWeight(sortedUnsortedCategoryWeight);
+ firePropertyChange(PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT, oldValue, sortedUnsortedCategoryWeight);
+ }
+
public CaracteristicQualitativeValue getSizeCategory() {
- return sizeCategory;
+ return sizeSampleCategory.getCategoryValue();
}
public void setSizeCategory(CaracteristicQualitativeValue sizeCategory) {
Object oldValue = getSizeCategory();
- this.sizeCategory = sizeCategory;
+ this.sizeSampleCategory.setCategoryValue(sizeCategory);
firePropertyChange(PROPERTY_SIZE_CATEGORY, oldValue, sizeCategory);
}
+ public Float getSizeCategoryWeight() {
+ return sizeSampleCategory.getCategoryWeight();
+ }
+
+ public void setSizeCategoryWeight(Float sizeCategoryWeight) {
+ Object oldValue = getSizeCategoryWeight();
+ this.sizeSampleCategory.setCategoryWeight(sizeCategoryWeight);
+ firePropertyChange(PROPERTY_SIZE_CATEGORY_WEIGHT, oldValue, sizeCategoryWeight);
+ }
+
public CaracteristicQualitativeValue getSexCategory() {
- return sexCategory;
+ return sexSampleCategory.getCategoryValue();
}
public void setSexCategory(CaracteristicQualitativeValue sexCategory) {
Object oldValue = getSexCategory();
- this.sexCategory = sexCategory;
+ this.sexSampleCategory.setCategoryValue(sexCategory);
firePropertyChange(PROPERTY_SEX_CATEGORY, oldValue, sexCategory);
}
+ public Float getSexCategoryWeight() {
+ return sexSampleCategory.getCategoryWeight();
+ }
+
+ public void setSexCategoryWeight(Float sexCategoryWeight) {
+ Object oldValue = getSexCategoryWeight();
+ this.sexSampleCategory.setCategoryWeight(sexCategoryWeight);
+ firePropertyChange(PROPERTY_SEX_CATEGORY_WEIGHT, oldValue, sexCategoryWeight);
+ }
+
public CaracteristicQualitativeValue getMaturityCategory() {
- return maturityCategory;
+ return maturitySampleCategory.getCategoryValue();
}
public void setMaturityCategory(CaracteristicQualitativeValue maturityCategory) {
Object oldValue = getMaturityCategory();
- this.maturityCategory = maturityCategory;
+ this.maturitySampleCategory.setCategoryValue(maturityCategory);
firePropertyChange(PROPERTY_MATURITY_CATEGORY, oldValue, maturityCategory);
}
- public Float getAge() {
- return age;
+ public Float getMaturityCategoryWeight() {
+ return maturitySampleCategory.getCategoryWeight();
}
- public void setAge(Float age) {
- Object oldValue = getAge();
- this.age = age;
- firePropertyChange(PROPERTY_AGE, oldValue, age);
+ public void setMaturityCategoryWeight(Float maturityCategoryWeight) {
+ Object oldValue = getMaturityCategoryWeight();
+ this.maturitySampleCategory.setCategoryWeight(maturityCategoryWeight);
+ firePropertyChange(PROPERTY_MATURITY_CATEGORY_WEIGHT, oldValue, maturityCategoryWeight);
}
+ public Float getAgeCategory() {
+ return ageSampleCategory.getCategoryValue();
+ }
+
+ public void setAgeCategory(Float ageCategory) {
+ Object oldValue = getAgeCategory();
+ ageSampleCategory.setCategoryValue(ageCategory);
+ firePropertyChange(PROPERTY_AGE_CATEGORY, oldValue, ageCategory);
+ }
+
+ public Float getAgeCategoryWeight() {
+ return ageSampleCategory.getCategoryWeight();
+ }
+
+ public void setAgeCategoryWeight(Float ageCategoryWeight) {
+ Object oldValue = getAgeCategoryWeight();
+ ageSampleCategory.setCategoryWeight(ageCategoryWeight);
+ firePropertyChange(PROPERTY_AGE_CATEGORY_WEIGHT, oldValue, ageCategoryWeight);
+ }
+
public Float getWeight() {
return weight;
}
@@ -312,26 +374,16 @@
firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
}
- public Float getSampleWeight() {
- return sampleWeight;
+ public Integer getNumber() {
+ return number;
}
- public void setSampleWeight(Float sampleWeight) {
- Object oldValue = getSampleWeight();
- this.sampleWeight = sampleWeight;
- firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight);
+ public void setNumber(Integer number) {
+ Object oldValue = getNumber();
+ this.number = number;
+ firePropertyChange(PROPERTY_NUMBER, oldValue, number);
}
- public Float getSamplingRatio() {
- return samplingRatio;
- }
-
- public void setSamplingRatio(Float samplingRatio) {
- Object oldValue = getSamplingRatio();
- this.samplingRatio = samplingRatio;
- firePropertyChange(PROPERTY_SAMPLING_RATIO, oldValue, samplingRatio);
- }
-
public String getComment() {
return comment;
}
@@ -384,7 +436,27 @@
computedNumber);
}
- public int getRowCount() {
- return frequency == null ? 0 : frequency.size();
+ public SampleCategory<CaracteristicQualitativeValue> getSortedUnsortedSampleCategory() {
+ return sortedUnsortedSampleCategory;
}
+
+ public SampleCategory<CaracteristicQualitativeValue> getSizeSampleCategory() {
+ return sizeSampleCategory;
+ }
+
+ public SampleCategory<CaracteristicQualitativeValue> getSexSampleCategory() {
+ return sexSampleCategory;
+ }
+
+ public SampleCategory<CaracteristicQualitativeValue> getMaturitySampleCategory() {
+ return maturitySampleCategory;
+ }
+
+ public SampleCategory<Float> getAgeSampleCategory() {
+ return ageSampleCategory;
+ }
+
+ // public int getRowCount() {
+// return frequency == null ? 0 : frequency.size();
+// }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -52,29 +52,29 @@
n_("tutti.table.species.batch.header.speciesByGenusCode"));
public static final ColumnIdentifier<SpeciesBatchRowModel> SORTED_UNSORTED_CATEGORY = ColumnIdentifier.newId(
- SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_SAMPLE_CATEGORY,
n_("tutti.table.species.batch.header.sortedUnsortedCategory"),
n_("tutti.table.species.batch.header.sortedUnsortedCategory"));
public static final ColumnIdentifier<SpeciesBatchRowModel> SIZE_CATEGORY = ColumnIdentifier.newId(
- SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SIZE_SAMPLE_CATEGORY,
n_("tutti.table.species.batch.header.sizeCategory"),
n_("tutti.table.species.batch.header.sizeCategory"));
public static final ColumnIdentifier<SpeciesBatchRowModel> SEX_CATEGORY = ColumnIdentifier.newId(
- SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SEX_SAMPLE_CATEGORY,
n_("tutti.table.species.batch.header.sexCategory"),
n_("tutti.table.species.batch.header.sexCategory"));
public static final ColumnIdentifier<SpeciesBatchRowModel> MATURITY_CATEGORY = ColumnIdentifier.newId(
- SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_MATURITY_SAMPLE_CATEGORY,
n_("tutti.table.species.batch.header.maturityCategory"),
n_("tutti.table.species.batch.header.maturityCategory"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> AGE = ColumnIdentifier.newId(
- SpeciesBatchRowModel.PROPERTY_AGE,
- n_("tutti.table.species.batch.header.age"),
- n_("tutti.table.species.batch.header.age"));
+ public static final ColumnIdentifier<SpeciesBatchRowModel> AGE_CATEGORY = ColumnIdentifier.newId(
+ SpeciesBatchRowModel.PROPERTY_AGE_SAMPLE_CATEGORY,
+ n_("tutti.table.species.batch.header.ageCategory"),
+ n_("tutti.table.species.batch.header.ageCategory"));
public static final ColumnIdentifier<SpeciesBatchRowModel> WEIGHT = ColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_WEIGHT,
@@ -91,16 +91,11 @@
n_("tutti.table.species.batch.header.computedNumber"),
n_("tutti.table.species.batch.header.computedNumber"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> SAMPLE_WEIGHT = ColumnIdentifier.newId(
- SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
- n_("tutti.table.species.batch.header.sampleWeight"),
- n_("tutti.table.species.batch.header.sampleWeight"));
+ public static final ColumnIdentifier<SpeciesBatchRowModel> NUMBER = ColumnIdentifier.newId(
+ SpeciesBatchRowModel.PROPERTY_NUMBER,
+ n_("tutti.table.species.batch.header.number"),
+ n_("tutti.table.species.batch.header.number"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> SAMPLING_RATIO = ColumnIdentifier.newId(
- SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO,
- n_("tutti.table.species.batch.header.elevationRate"),
- n_("tutti.table.species.batch.header.elevationRate"));
-
public static final ColumnIdentifier<SpeciesBatchRowModel> COMMENT = ColumnIdentifier.newId(
SpeciesBatchRowModel.PROPERTY_COMMENT,
n_("tutti.table.species.batch.header.comment"),
@@ -118,13 +113,23 @@
protected final Set<ColumnIdentifier<SpeciesBatchRowModel>> noneEditableColIfNoSpecies;
+ protected final Set<ColumnIdentifier<SpeciesBatchRowModel>> sampleCols;
+
public SpeciesBatchTableModel(TableColumnModel columnModel) {
super(columnModel);
- setNoneEditableCols(SAMPLE_WEIGHT, SAMPLING_RATIO);
+ setNoneEditableCols();
+// setNoneEditableCols(SAMPLE_WEIGHT, SAMPLING_RATIO);
noneEditableColIfNoSpecies = Sets.newHashSet();
noneEditableColIfNoSpecies.add(COMPUTED_NUMBER);
noneEditableColIfNoSpecies.add(COMPUTED_WEIGHT);
+
+ sampleCols = Sets.newHashSet();
+ sampleCols.add(SORTED_UNSORTED_CATEGORY);
+ sampleCols.add(SIZE_CATEGORY);
+ sampleCols.add(SEX_CATEGORY);
+ sampleCols.add(MATURITY_CATEGORY);
+ sampleCols.add(AGE_CATEGORY);
}
@Override
@@ -172,12 +177,10 @@
}
public void updateSamplingRatio(Set<SpeciesBatchRowModel> rows) {
- for (SpeciesBatchRowModel row : rows) {
- int rowIndex = getRows().indexOf(row);
- fireTableCellUpdated(rowIndex, SAMPLE_WEIGHT, SAMPLING_RATIO);
- }
-
-
+// for (SpeciesBatchRowModel row : rows) {
+// int rowIndex = getRows().indexOf(row);
+// fireTableCellUpdated(rowIndex, SAMPLE_WEIGHT, SAMPLING_RATIO);
+// }
}
@Override
@@ -195,6 +198,12 @@
// must have filled a species to edit this column
SpeciesBatchRowModel entry = getEntry(rowIndex);
result = entry.getSpecies() != null;
+ } else if (sampleCols.contains(propertyName)) {
+
+ // can only edit if a category value is setted
+ SpeciesBatchRowModel entry = getEntry(rowIndex);
+ SampleCategory<?> value = (SampleCategory<?>) propertyName.getValue(entry);
+ result = value.getCategoryValue() != null;
}
}
return result;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTreeModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTreeModel.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTreeModel.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -27,16 +27,12 @@
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
-import com.google.common.collect.Sets;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import org.apache.commons.collections.CollectionUtils;
import java.io.Serializable;
import java.util.Collection;
-import java.util.List;
import java.util.Map;
-import java.util.Set;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -81,22 +77,22 @@
nodeToRow = HashMultimap.create();
}
- public void populate(List<SpeciesBatchRowModel> rows) {
+// public void populate(List<SpeciesBatchRowModel> rows) {
+//
+// clear();
+//
+// for (SpeciesBatchRowModel row : rows) {
+//
+// SpeciesBatchTreeNode node = getSamplingNode(row);
+//
+// // check if row is valid
+// boolean rowIsValid = isValid(row, node);
+//
+// // set it in row
+// row.setValid(rowIsValid);
+// }
+// }
- clear();
-
- for (SpeciesBatchRowModel row : rows) {
-
- SpeciesBatchTreeNode node = getSamplingNode(row);
-
- // check if row is valid
- boolean rowIsValid = isValid(row, node);
-
- // set it in row
- row.setValid(rowIsValid);
- }
- }
-
public String[] getSamplingOrder() {
return samplingOrder;
}
@@ -185,42 +181,42 @@
return result;
}
- public SamplingContext createSamplingContext(SpeciesBatchTreeNode rootNode) {
+// public SamplingContext createSamplingContext(SpeciesBatchTreeNode rootNode) {
+//
+// Set<SpeciesBatchRowModel> childRows = Sets.newHashSet();
+//
+// SpeciesBatchRowModel superSamplingRow = getNodeToRow(rootNode);
+//
+// float totalWeight = 0f;
+// for (int i = 0, nbChildren = rootNode.getChildCount(); i < nbChildren; i++) {
+// SpeciesBatchTreeNode node = rootNode.getChildAt(i);
+//
+// SpeciesBatchRowModel row = getNodeToRow(node);
+// if (row != null) {
+// CaracteristicQualitativeValue sortedUnsortedCategory =
+// row.getSortedUnsortedCategory();
+// if (sortedUnsortedCategory != null &&
+// "unsorted".equals(sortedUnsortedCategory.getName())) {
+//
+// // never take account of a such child
+//
+// } else {
+//
+// childRows.add(row);
+// Float weight = row.getWeight();
+// if (weight != null) {
+// totalWeight += weight;
+// }
+// }
+// }
+// }
+// SamplingContext result = new SamplingContext(rootNode,
+// superSamplingRow,
+// childRows,
+// totalWeight);
+// return result;
+// }
- Set<SpeciesBatchRowModel> childRows = Sets.newHashSet();
-
- SpeciesBatchRowModel superSamplingRow = getNodeToRow(rootNode);
-
- float totalWeight = 0f;
- for (int i = 0, nbChildren = rootNode.getChildCount(); i < nbChildren; i++) {
- SpeciesBatchTreeNode node = rootNode.getChildAt(i);
-
- SpeciesBatchRowModel row = getNodeToRow(node);
- if (row != null) {
- CaracteristicQualitativeValue sortedUnsortedCategory =
- row.getSortedUnsortedCategory();
- if (sortedUnsortedCategory != null &&
- "unsorted".equals(sortedUnsortedCategory.getName())) {
-
- // never take account of a such child
-
- } else {
-
- childRows.add(row);
- Float weight = row.getWeight();
- if (weight != null) {
- totalWeight += weight;
- }
- }
- }
- }
- SamplingContext result = new SamplingContext(rootNode,
- superSamplingRow,
- childRows,
- totalWeight);
- return result;
- }
-
public SpeciesBatchRowModel getNodeToRow(SpeciesBatchTreeNode node) {
Collection<SpeciesBatchRowModel> rows = nodeToRow.get(node);
@@ -249,49 +245,49 @@
return result;
}
- public static class SamplingContext {
-
- private final SpeciesBatchTreeNode rootNode;
-
- private final SpeciesBatchRowModel superSamplingRow;
-
- private final Set<SpeciesBatchRowModel> samplingRows;
-
- private final float totalWeight;
-
- public SamplingContext(SpeciesBatchTreeNode rootNode,
- SpeciesBatchRowModel superSamplingRow,
- Set<SpeciesBatchRowModel> samplingRows,
- float totalWeight) {
- this.rootNode = rootNode;
- this.superSamplingRow = superSamplingRow;
- this.samplingRows = samplingRows;
- this.totalWeight = totalWeight;
- }
-
- public SpeciesBatchTreeNode getRootNode() {
- return rootNode;
- }
-
- public SpeciesBatchRowModel getSuperSamplingRow() {
- return superSamplingRow;
- }
-
- public Set<SpeciesBatchRowModel> getSamplingRows() {
- return samplingRows;
- }
-
- public float getTotalWeight() {
- return totalWeight;
- }
-
- public void applyNewSampleValues(float samplingWeight,
- Float samplingRatio) {
-
- for (SpeciesBatchRowModel row : samplingRows) {
- row.setSampleWeight(samplingWeight);
- row.setSamplingRatio(samplingRatio);
- }
- }
- }
+// public static class SamplingContext {
+//
+// private final SpeciesBatchTreeNode rootNode;
+//
+// private final SpeciesBatchRowModel superSamplingRow;
+//
+// private final Set<SpeciesBatchRowModel> samplingRows;
+//
+// private final float totalWeight;
+//
+// public SamplingContext(SpeciesBatchTreeNode rootNode,
+// SpeciesBatchRowModel superSamplingRow,
+// Set<SpeciesBatchRowModel> samplingRows,
+// float totalWeight) {
+// this.rootNode = rootNode;
+// this.superSamplingRow = superSamplingRow;
+// this.samplingRows = samplingRows;
+// this.totalWeight = totalWeight;
+// }
+//
+// public SpeciesBatchTreeNode getRootNode() {
+// return rootNode;
+// }
+//
+// public SpeciesBatchRowModel getSuperSamplingRow() {
+// return superSamplingRow;
+// }
+//
+// public Set<SpeciesBatchRowModel> getSamplingRows() {
+// return samplingRows;
+// }
+//
+// public float getTotalWeight() {
+// return totalWeight;
+// }
+//
+// public void applyNewSampleValues(float samplingWeight,
+// Float samplingRatio) {
+//
+// for (SpeciesBatchRowModel row : samplingRows) {
+// row.setSampleWeight(samplingWeight);
+// row.setSamplingRatio(samplingRatio);
+// }
+// }
+// }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2012-12-28 08:34:01 UTC (rev 114)
@@ -28,6 +28,7 @@
fr.ifremer.tutti.ui.swing.TuttiUI
fr.ifremer.tutti.ui.swing.TuttiUIContext
+ fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyUI
fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
fr.ifremer.tutti.ui.swing.util.editor.AttachmentEditorUI
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -40,6 +40,8 @@
import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.FrequencyCellComponent;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent;
import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
@@ -49,6 +51,7 @@
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
import org.nuiton.util.decorator.Decorator;
+import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import java.util.List;
import java.util.Set;
@@ -75,7 +78,7 @@
SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY,
SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY,
SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_AGE);
+ SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY);
/**
* UI.
@@ -90,11 +93,17 @@
SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM,
SpeciesBatchRowModel.PROPERTY_SPECIES,
SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY_WEIGHT,
SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY_WEIGHT,
SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY_WEIGHT,
SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_AGE,
+ SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY_WEIGHT,
+ SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY,
+ SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY_WEIGHT,
SpeciesBatchRowModel.PROPERTY_WEIGHT,
+ SpeciesBatchRowModel.PROPERTY_NUMBER,
SpeciesBatchRowModel.PROPERTY_COMMENT,
SpeciesBatchRowModel.PROPERTY_ATTACHMENTS,
SpeciesBatchRowModel.PROPERTY_FREQUENCY);
@@ -129,19 +138,23 @@
protected void onModelRowsChanged(List<SpeciesBatchRowModel> rows) {
super.onModelRowsChanged(rows);
+ for (SpeciesBatchRowModel row : rows) {
+ boolean rowValid = row.getSpecies() != null;
+ row.setValid(rowValid);
+ }
// build the new sampling tree from the new rows to edit
- getModel().getSamplingTreeModel().populate(rows);
+// getModel().getSamplingTreeModel().populate(rows);
}
- @Override
- protected String[] getRowPropertiesToIgnore() {
- return new String[]{
- SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
- SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO};
- }
+// @Override
+// protected String[] getRowPropertiesToIgnore() {
+// return new String[]{
+// SpeciesBatchRowModel.PROPERTY_SAMPLE_WEIGHT,
+// SpeciesBatchRowModel.PROPERTY_SAMPLING_RATIO};
+// }
@Override
- protected TableColumnModel createTableColumnModel() {
+ protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
DefaultTableColumnModelExt columnModel =
new DefaultTableColumnModelExt();
@@ -151,8 +164,7 @@
List<Species> allSpecies = persistenceService.getAllSpecies();
- {
- // Species (by code) column
+ { // Species (by code) column
Decorator<Species> decorator = getDecorator(
Species.class, DecoratorService.SPECIES_BY_CODE);
@@ -162,8 +174,7 @@
decorator, allSpecies);
}
- {
- // Species (by genusCode) column
+ { // Species (by genusCode) column
Decorator<Species> decorator = getDecorator(
Species.class, DecoratorService.SPECIES_BY_GENUS);
@@ -173,59 +184,88 @@
decorator, allSpecies);
}
- {
+ { // SortedUnsortedCategory column
- // SortedUnsortedCategory column
+ addColumnToModel(columnModel,
+ SampleCategoryComponent.newEditor(caracteristicDecorator),
+ SampleCategoryComponent.newRender(defaultRenderer, caracteristicDecorator),
+ SpeciesBatchTableModel.SORTED_UNSORTED_CATEGORY);
- Caracteristic data =
- persistenceService.getSortedUnsortedCaracteristic();
-
- addComboDataColumnToModel(columnModel,
- SpeciesBatchTableModel.SORTED_UNSORTED_CATEGORY,
- caracteristicDecorator,
- data.getQualitativeValue());
+// Caracteristic data =
+// persistenceService.getSortedUnsortedCaracteristic();
+//
+// addComboDataColumnToModel(columnModel,
+// SpeciesBatchTableModel.SORTED_UNSORTED_CATEGORY,
+// caracteristicDecorator,
+// data.getQualitativeValue());
}
{ // SizeCategory column
- Caracteristic data =
- persistenceService.getSizeCategoryCaracteristic();
+ addColumnToModel(columnModel,
+ SampleCategoryComponent.newEditor(caracteristicDecorator),
+ SampleCategoryComponent.newRender(defaultRenderer, caracteristicDecorator),
+ SpeciesBatchTableModel.SIZE_CATEGORY);
- addComboDataColumnToModel(columnModel,
- SpeciesBatchTableModel.SIZE_CATEGORY,
- caracteristicDecorator,
- data.getQualitativeValue());
+// Caracteristic data =
+// persistenceService.getSizeCategoryCaracteristic();
+//
+// addComboDataColumnToModel(columnModel,
+// SpeciesBatchTableModel.SIZE_CATEGORY,
+// caracteristicDecorator,
+// data.getQualitativeValue());
}
{ // SexCategory column
- Caracteristic data = persistenceService.getSexCaracteristic();
+ addColumnToModel(columnModel,
+ SampleCategoryComponent.newEditor(caracteristicDecorator),
+ SampleCategoryComponent.newRender(defaultRenderer, caracteristicDecorator),
+ SpeciesBatchTableModel.SEX_CATEGORY);
- addComboDataColumnToModel(columnModel,
- SpeciesBatchTableModel.SEX_CATEGORY,
- caracteristicDecorator,
- data.getQualitativeValue());
+// Caracteristic data = persistenceService.getSexCaracteristic();
+//
+// addComboDataColumnToModel(columnModel,
+// SpeciesBatchTableModel.SEX_CATEGORY,
+// caracteristicDecorator,
+// data.getQualitativeValue());
}
{ // MaturityCategory column
- Caracteristic data =
- persistenceService.getMaturityCaracteristic();
+ addColumnToModel(columnModel,
+ SampleCategoryComponent.newEditor(caracteristicDecorator),
+ SampleCategoryComponent.newRender(defaultRenderer, caracteristicDecorator),
+ SpeciesBatchTableModel.MATURITY_CATEGORY);
-
- addComboDataColumnToModel(columnModel,
- SpeciesBatchTableModel.MATURITY_CATEGORY,
- caracteristicDecorator,
- data.getQualitativeValue());
+// Caracteristic data =
+// persistenceService.getMaturityCaracteristic();
+//
+//
+// addComboDataColumnToModel(columnModel,
+// SpeciesBatchTableModel.MATURITY_CATEGORY,
+// caracteristicDecorator,
+// data.getQualitativeValue());
}
- {
+ { // AgeCategory column
- // Age column
+ Decorator<Float> floatDecorator = new Decorator<Float>(Float.class) {
+ private static final long serialVersionUID = 1L;
- addFloatColumnToModel(columnModel,
- SpeciesBatchTableModel.AGE,
- TuttiUI.DECIMAL3_PATTERN);
+ @Override
+ public String toString(Object bean) {
+ return String.valueOf(bean);
+ }
+ };
+ addColumnToModel(columnModel,
+ SampleCategoryComponent.newEditor(floatDecorator),
+ SampleCategoryComponent.newRender(defaultRenderer, floatDecorator),
+ SpeciesBatchTableModel.AGE_CATEGORY);
+
+// addFloatColumnToModel(columnModel,
+// SpeciesBatchTableModel.AGE_CATEGORY,
+// TuttiUI.DECIMAL3_PATTERN);
}
{ // Weight column
@@ -251,18 +291,6 @@
SpeciesBatchTableModel.COMPUTED_NUMBER);
}
- { // Sample weight column
-
- addColumnToModel(columnModel,
- SpeciesBatchTableModel.SAMPLE_WEIGHT);
- }
-
- { // SamplingRatio column
-
- addColumnToModel(columnModel,
- SpeciesBatchTableModel.SAMPLING_RATIO);
- }
-
{ // Comment column
addColumnToModel(columnModel,
@@ -305,80 +333,87 @@
recomputeTotalHorsVrac();
}
- SpeciesBatchUIModel model = getModel();
+ if (SpeciesBatchRowModel.PROPERTY_SPECIES.equals(propertyName)) {
- SpeciesBatchTreeModel samplingTreeModel = model.getSamplingTreeModel();
-
- if (SAMPLING_PROPERTIES.contains(propertyName)) {
-
- // Need to rebuilt this row sampling tree path (and then recompute
- // old super - samplingRatio and new super - samplingRatio)
-
- // old node of the previous sampling def for this row
- // and remove it from any cache
- SpeciesBatchTreeNode oldNode = samplingTreeModel.removeNodeFromCache(row);
-
- boolean rowWasValid = row.isValid();
- if (oldNode != null && rowWasValid) {
-
- // remove this row from his super sampling
- recomputeSuperSamplingRatio(samplingTreeModel, oldNode);
- }
-
- // get new sampling node
- SpeciesBatchTreeNode newNode = samplingTreeModel.getSamplingNode(row);
-
- // check this row is valid
- boolean rowValid = samplingTreeModel.isValid(row, newNode);
-
- // push this state back to the row
+ // species has changed, recompute valid property
+ boolean rowValid = newValue != null;
row.setValid(rowValid);
-
- if (rowValid) {
-
- // can add it to his super-sampling
- recomputeSuperSamplingRatio(samplingTreeModel, newNode);
- } else {
-
- if (rowWasValid) {
-
- row.setSampleWeight(null);
- row.setSamplingRatio(null);
-
- getTableModel().updateSamplingRatio(Sets.newHashSet(row));
- }
- }
}
- if (SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
-
- // Need to recompute the super - samplingRatio
-
- SpeciesBatchTreeNode node = samplingTreeModel.getSamplingNode(row);
-
- boolean rowWasValid = row.isValid();
-
- // check this row is valid
- boolean rowValid = samplingTreeModel.isValid(row, node);
-
- // push this state back to the row
- row.setValid(rowValid);
-
- if (rowValid) {
- recomputeSuperSamplingRatio(samplingTreeModel, node);
- } else {
- if (rowWasValid) {
-
- // must remove this row from his super-sampling
- recomputeSuperSamplingRatio(samplingTreeModel, node);
-
- row.setSampleWeight(null);
- row.setSamplingRatio(null);
-
- getTableModel().updateSamplingRatio(Sets.newHashSet(row));
- }
- }
- }
+// SpeciesBatchUIModel model = getModel();
+//
+// SpeciesBatchTreeModel samplingTreeModel = model.getSamplingTreeModel();
+//
+// if (SAMPLING_PROPERTIES.contains(propertyName)) {
+//
+// // Need to rebuilt this row sampling tree path (and then recompute
+// // old super - samplingRatio and new super - samplingRatio)
+//
+// // old node of the previous sampling def for this row
+// // and remove it from any cache
+// SpeciesBatchTreeNode oldNode = samplingTreeModel.removeNodeFromCache(row);
+//
+// boolean rowWasValid = row.isValid();
+// if (oldNode != null && rowWasValid) {
+//
+// // remove this row from his super sampling
+// recomputeSuperSamplingRatio(samplingTreeModel, oldNode);
+// }
+//
+// // get new sampling node
+// SpeciesBatchTreeNode newNode = samplingTreeModel.getSamplingNode(row);
+//
+// // check this row is valid
+// boolean rowValid = samplingTreeModel.isValid(row, newNode);
+//
+// // push this state back to the row
+// row.setValid(rowValid);
+//
+// if (rowValid) {
+//
+// // can add it to his super-sampling
+// recomputeSuperSamplingRatio(samplingTreeModel, newNode);
+// } else {
+//
+// if (rowWasValid) {
+//
+//// row.setSampleWeight(null);
+//// row.setSamplingRatio(null);
+//
+// getTableModel().updateSamplingRatio(Sets.newHashSet(row));
+// }
+// }
+// }
+//
+// if (SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
+//
+// // Need to recompute the super - samplingRatio
+//
+// SpeciesBatchTreeNode node = samplingTreeModel.getSamplingNode(row);
+//
+// boolean rowWasValid = row.isValid();
+//
+// // check this row is valid
+// boolean rowValid = samplingTreeModel.isValid(row, node);
+//
+// // push this state back to the row
+// row.setValid(rowValid);
+//
+// if (rowValid) {
+// recomputeSuperSamplingRatio(samplingTreeModel, node);
+// } else {
+// if (rowWasValid) {
+//
+// // must remove this row from his super-sampling
+// recomputeSuperSamplingRatio(samplingTreeModel, node);
+//
+//// row.setSampleWeight(null);
+//// row.setSamplingRatio(null);
+//
+// getTableModel().updateSamplingRatio(Sets.newHashSet(row));
+// }
+// }
+// }
}
@Override
@@ -449,7 +484,7 @@
SpeciesBatchTreeModel samplingTreeModel = model.getSamplingTreeModel();
SpeciesBatchTreeNode node = samplingTreeModel.getSamplingNode(row);
boolean rowValid = samplingTreeModel.isValid(row, node);
- return rowValid;
+ return row.isValid();
}
@Override
@@ -492,17 +527,6 @@
@Override
public void selectFishingOperation(FishingOperation bean) {
-// JXTable table = ui.getTable();
-//
-// if (table.isEditing()) {
-//
-// // make sure to stop editor
-// table.editingCanceled(null);
-// }
-//
-// // make sure selection is empty (will remove bean from monitor)
-// table.clearSelection();
-
boolean empty = bean == null;
SpeciesBatchUIModel model = getModel();
@@ -576,7 +600,7 @@
SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY,
SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY,
SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_AGE
+ SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY
);
getModel().setSamplingOrder(samplingOrder);
@@ -584,7 +608,7 @@
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel();
+ TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
// create table model
SpeciesBatchTableModel tableModel =
@@ -611,50 +635,50 @@
//-- Internal methods --//
//------------------------------------------------------------------------//
- protected void recomputeSuperSamplingRatio(SpeciesBatchTreeModel samplingTreeModel,
- SpeciesBatchTreeNode node) {
+// protected void recomputeSuperSamplingRatio(SpeciesBatchTreeModel samplingTreeModel,
+// SpeciesBatchTreeNode node) {
+//
+// SpeciesBatchTreeNode superSamplingNode = node.getParent();
+//
+// Preconditions.checkNotNull(superSamplingNode,
+// "Super sampling node can't be null");
+//
+// SpeciesBatchTreeModel.SamplingContext samplingContext =
+// samplingTreeModel.createSamplingContext(superSamplingNode);
+//
+// float samplingTotalWeight = samplingContext.getTotalWeight();
+// Float superSamplingTotalWeight;
+// SpeciesBatchRowModel superSamplingRow =
+// samplingContext.getSuperSamplingRow();
+// if (superSamplingRow == null) {
+//
+// // Use directly the batch total weight (means no super-sampling)
+//
+// superSamplingTotalWeight = getModel().getSpeciesTotalWeight();
+// } else {
+// superSamplingTotalWeight = superSamplingRow.getWeight();
+// }
+//
+// if (log.isInfoEnabled()) {
+// log.info("Super sampling total weight: " +
+// superSamplingTotalWeight);
+// }
+//
+// Float samplingRatio = null;
+// if (superSamplingTotalWeight != null) {
+// samplingRatio = samplingTotalWeight / superSamplingTotalWeight;
+// }
+//
+// if (log.isInfoEnabled()) {
+// log.info("Sampling ratio: " + samplingRatio);
+// }
+//
+// samplingContext.applyNewSampleValues(samplingTotalWeight,
+// samplingRatio);
+//
+// getTableModel().updateSamplingRatio(samplingContext.getSamplingRows());
+// }
- SpeciesBatchTreeNode superSamplingNode = node.getParent();
-
- Preconditions.checkNotNull(superSamplingNode,
- "Super sampling node can't be null");
-
- SpeciesBatchTreeModel.SamplingContext samplingContext =
- samplingTreeModel.createSamplingContext(superSamplingNode);
-
- float samplingTotalWeight = samplingContext.getTotalWeight();
- Float superSamplingTotalWeight;
- SpeciesBatchRowModel superSamplingRow =
- samplingContext.getSuperSamplingRow();
- if (superSamplingRow == null) {
-
- // Use directly the batch total weight (means no super-sampling)
-
- superSamplingTotalWeight = getModel().getSpeciesTotalWeight();
- } else {
- superSamplingTotalWeight = superSamplingRow.getWeight();
- }
-
- if (log.isInfoEnabled()) {
- log.info("Super sampling total weight: " +
- superSamplingTotalWeight);
- }
-
- Float samplingRatio = null;
- if (superSamplingTotalWeight != null) {
- samplingRatio = samplingTotalWeight / superSamplingTotalWeight;
- }
-
- if (log.isInfoEnabled()) {
- log.info("Sampling ratio: " + samplingRatio);
- }
-
- samplingContext.applyNewSampleValues(samplingTotalWeight,
- samplingRatio);
-
- getTableModel().updateSamplingRatio(samplingContext.getSamplingRows());
- }
-
protected void recomputeTotalHorsVrac() {
// recompute total hors vrac
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -37,6 +37,10 @@
private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_TABLE_VIEW_MODE = "tableViewMode";
+
+
/**
* Sampling order (sets by protocol).
*
@@ -45,6 +49,13 @@
protected List<String> samplingOrder;
/**
+ * What to show in the table.
+ *
+ * @since 0.3
+ */
+ protected TableViewMode tableViewMode;
+
+ /**
* Tree of sampling for batch rows.
*
* @since 0.2
@@ -105,4 +116,13 @@
samplingTreeModel.setSamplingOrder(samplingOrder.toArray(new String[samplingOrder.size()]));
}
+ public TableViewMode getTableViewMode() {
+ return tableViewMode;
+ }
+
+ public void setTableViewMode(TableViewMode tableViewMode) {
+ Object oldValue = getTableViewMode();
+ this.tableViewMode = tableViewMode;
+ firePropertyChange(PROPERTY_TABLE_VIEW_MODE, oldValue, tableViewMode);
+ }
}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyRowModel.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyRowModel.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -1,191 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
-
-/*
- * #%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 com.google.common.collect.Ordering;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
-import org.nuiton.util.beans.Binder;
-import org.nuiton.util.beans.BinderFactory;
-
-import java.util.List;
-
-/**
- * Represents a batch frequency row.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBatchFrequency, SpeciesFrequencyRowModel> implements Comparable<SpeciesFrequencyRowModel> {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_LENGTH_STEP = "lengthStep";
-
- public static final String PROPERTY_NUMBER = "number";
-
- public static final String PROPERTY_WEIGHT = "weight";
-
- public static final String PROPERTY_COMPUTED_WEIGHT = "computedWeight";
-
-
- public static final String PROPERTY_LENGHT_STEP_CARACTERISTIC = "lengthStepCaracteristic";
-
-
- /**
- * Length step.
- *
- * @since 0.2
- */
- protected Float lengthStep;
-
- /**
- * Count of fishes for this lengthStep.
- *
- * @since 0.2
- */
- protected Integer number;
-
- /**
- * Weight of fishes observed.
- *
- * @since 0.2
- */
- protected Float weight;
-
- /**
- * Computed weight from number + relation taille-poids.
- *
- * @since 0.2
- */
- protected Float computedWeight;
-
- /**
- * Length step caracteristic.
- *
- * @since 0.3
- */
- protected Caracteristic lengthStepCaracteristic;
-
- protected static final Binder<SpeciesBatchFrequency, SpeciesFrequencyRowModel> fromBeanBinder =
- BinderFactory.newBinder(SpeciesBatchFrequency.class,
- SpeciesFrequencyRowModel.class);
-
- protected static final Binder<SpeciesFrequencyRowModel, SpeciesBatchFrequency> toBeanBinder =
- BinderFactory.newBinder(SpeciesFrequencyRowModel.class,
- SpeciesBatchFrequency.class);
-
- private static final Ordering<Float> ordering = Ordering.natural().nullsFirst();
-
- public static List<SpeciesFrequencyRowModel> fromBeans(List<SpeciesBatchFrequency> frequency) {
- List<SpeciesFrequencyRowModel> result = Lists.newArrayList();
- for (SpeciesBatchFrequency b : frequency) {
- SpeciesFrequencyRowModel model = new SpeciesFrequencyRowModel();
- fromBeanBinder.copy(b, model);
- result.add(model);
- }
- return result;
- }
-
- public static List<SpeciesBatchFrequency> toBeans(List<SpeciesFrequencyRowModel> frequency, SpeciesBatch batch) {
- List<SpeciesBatchFrequency> result = Lists.newArrayList();
- for (SpeciesFrequencyRowModel b : frequency) {
- SpeciesBatchFrequency model = new SpeciesBatchFrequency();
- toBeanBinder.copy(b, model);
- model.setBatch(batch);
- result.add(model);
- }
- return result;
- }
-
- public SpeciesFrequencyRowModel() {
- super(SpeciesBatchFrequency.class, fromBeanBinder, toBeanBinder);
- }
-
- public Float getLengthStep() {
- return lengthStep;
- }
-
- public void setLengthStep(Float lengthStep) {
- Object oldValue = getLengthStep();
- this.lengthStep = lengthStep;
- firePropertyChange(PROPERTY_LENGTH_STEP, oldValue, lengthStep);
- }
-
- public Integer getNumber() {
- return number;
- }
-
- public void setNumber(Integer number) {
- Object oldValue = getNumber();
- this.number = number;
- firePropertyChange(PROPERTY_NUMBER, oldValue, number);
- }
-
- public Float getWeight() {
- return weight;
- }
-
- public void setWeight(Float weight) {
- Object oldValue = getWeight();
- this.weight = weight;
- firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
- }
-
- public Float getComputedWeight() {
- return computedWeight;
- }
-
- public void setComputedWeight(Float computedWeight) {
- Object oldValue = getComputedWeight();
- this.computedWeight = computedWeight;
- firePropertyChange(PROPERTY_COMPUTED_WEIGHT, oldValue, computedWeight);
- }
-
- public Caracteristic getLengthStepCaracteristic() {
- return lengthStepCaracteristic;
- }
-
- public void setLengthStepCaracteristic(Caracteristic lengthStepCaracteristic) {
- Object oldValue = getLengthStepCaracteristic();
- this.lengthStepCaracteristic = lengthStepCaracteristic;
- firePropertyChange(PROPERTY_LENGHT_STEP_CARACTERISTIC, oldValue, lengthStepCaracteristic);
- }
-
- //TODO Use validator
- @Override
- public boolean isValid() {
- return lengthStep != null && number != null && lengthStepCaracteristic != null;
- }
-
- @Override
- public int compareTo(SpeciesFrequencyRowModel o) {
- int result = ordering.compare(lengthStep, o.lengthStep);
- return result;
- }
-}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyTableModel.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyTableModel.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -1,148 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
-
-/*
- * #%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.base.Preconditions;
-import com.google.common.collect.Maps;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
-import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
-
-import javax.swing.table.TableColumnModel;
-import java.util.List;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n.n_;
-
-/**
- * Model of the species frequency table.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class SpeciesFrequencyTableModel extends AbstractTuttiTableModel<SpeciesFrequencyRowModel> {
-
- private static final long serialVersionUID = 1L;
-
- public static final ColumnIdentifier<SpeciesFrequencyRowModel> LENGTH_STEP = ColumnIdentifier.newId(
- SpeciesFrequencyRowModel.PROPERTY_LENGTH_STEP,
- n_("tutti.table.species.frequency.header.lengthStep"),
- n_("tutti.table.species.frequency.header.lengthStep"));
-
- public static final ColumnIdentifier<SpeciesFrequencyRowModel> NUMBER = ColumnIdentifier.newId(
- SpeciesFrequencyRowModel.PROPERTY_NUMBER,
- n_("tutti.table.species.frequency.header.number"),
- n_("tutti.table.species.frequency.header.number"));
-
- public static final ColumnIdentifier<SpeciesFrequencyRowModel> WEIGHT = ColumnIdentifier.newId(
- SpeciesFrequencyRowModel.PROPERTY_WEIGHT,
- n_("tutti.table.species.frequency.header.weight"),
- n_("tutti.table.species.frequency.header.weight"));
-
- public static final ColumnIdentifier<SpeciesFrequencyRowModel> COMPUTED_WEIGHT = ColumnIdentifier.newId(
- SpeciesFrequencyRowModel.PROPERTY_COMPUTED_WEIGHT,
- n_("tutti.table.species.frequency.header.computedWeight"),
- n_("tutti.table.species.frequency.header.computedWeight"));
-
- private final SpeciesFrequencyUIModel uiModel;
-
- private final Map<Float, SpeciesFrequencyRowModel> rowCache;
-
- public SpeciesFrequencyTableModel(TableColumnModel columnModel,
- SpeciesFrequencyUIModel uiModel) {
- super(columnModel);
- this.uiModel = uiModel;
- this.rowCache = Maps.newTreeMap();
- setNoneEditableCols(COMPUTED_WEIGHT);
- }
-
- @Override
- protected SpeciesFrequencyRowModel createNewRow() {
- Float defaultStep = null;
-
- int rowCount = getRowCount();
- if (rowCount > 0) {
-
- SpeciesFrequencyRowModel rowModel = getEntry(rowCount - 1);
- Float lengthStep = rowModel.getLengthStep();
- if (lengthStep != null) {
- defaultStep = uiModel.getLengthStep(
- lengthStep + uiModel.getStep());
- }
- }
- SpeciesFrequencyRowModel result = new SpeciesFrequencyRowModel();
- result.setLengthStep(defaultStep);
- result.setValid(false);
- return result;
- }
-
- @Override
- public void setValueAt(Object aValue,
- int rowIndex,
- int columnIndex,
- ColumnIdentifier<SpeciesFrequencyRowModel> propertyName,
- SpeciesFrequencyRowModel entry) {
- super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
- // TODO Rebuild the computedWeight if possible...
- }
-
- public Map<Float, SpeciesFrequencyRowModel> getRowCache() {
- return rowCache;
- }
-
- @Override
- protected void onRowsChanged(List<SpeciesFrequencyRowModel> data) {
-
- // rebuild row cache
- rowCache.clear();
-
- for (SpeciesFrequencyRowModel row : data) {
- Float lengthStep = row.getLengthStep();
- if (lengthStep != null) {
- rowCache.put(lengthStep, row);
- }
- }
- }
-
- @Override
- protected void onRowAdded(int rowIndex, SpeciesFrequencyRowModel newValue) {
-
- Preconditions.checkNotNull(newValue, "can't add a null row");
-
- newValue.setLengthStepCaracteristic(uiModel.getLengthStepCaracteristic());
-
- // add new row to cache
- Float lengthStep = newValue.getLengthStep();
-
- Preconditions.checkNotNull(lengthStep,
- "can't add a null lengthStep row");
-
- float roundLenghtValue = uiModel.getLengthStep(lengthStep);
-
- if (!rowCache.containsKey(roundLenghtValue)) {
-
- rowCache.put(roundLenghtValue, newValue);
- }
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.css 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.css 2012-12-28 08:34:01 UTC (rev 114)
@@ -1,160 +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%
- */
-
-BeanComboBox {
- showReset: true;
- i18nPrefix: "tutti.property.";
- bean: {model};
-}
-
-NumberEditor {
- autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
- showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
-}
-
-#stepLabel {
- text: "tutti.label.frequencyConfiguration.step";
- labelFor: {stepField};
-}
-
-#stepField {
- property: "step";
- model: {model.getStep()};
- useFloat: true;
- numberPattern: {DECIMAL1_PATTERN};
- bean: {model};
-}
-
-#lenghtStepCaracteristicLabel {
- text: "tutti.label.frequencyConfiguration.lengthStepCaracteristic";
- labelFor: {lenghtStepCaracteristicComboBox};
-}
-
-#lenghtStepCaracteristicComboBox {
- property: "lengthStepCaracteristic";
- selectedItem: {model.getLengthStepCaracteristic()};
-}
-
-#minStepLabel {
- text: "tutti.label.frequencyConfiguration.minStep";
- labelFor: {minStepField};
-}
-
-#minStepField {
- property: "minStep";
- model: {model.getMinStep()};
- useFloat: true;
- showReset: true;
- numberPattern: {DECIMAL1_PATTERN};
- bean: {model};
-}
-
-#maxStepLabel {
- text: "tutti.label.frequencyConfiguration.maxStep";
- labelFor: {maxStepField};
-}
-
-#maxStepField {
- property: "maxStep";
- model: {model.getMaxStep()};
- useFloat: true;
- showReset: true;
- numberPattern: {DECIMAL1_PATTERN};
- bean: {model};
-}
-
-#rafaleStepLabel {
- text: "tutti.label.frequencyConfiguration.rafaleStep";
- labelFor: {rafaleStepField};
-}
-
-#rafaleStepField {
- modelType: {Float.class};
- useFloat: true;
- showReset: true;
- numberPattern: {DECIMAL1_PATTERN};
-}
-
-#generateButton {
- actionIcon: "generate";
- text: "tutti.action.generate";
- enabled: {model.isCanGenerate()};
-}
-
-#configurationPanel {
- border: {new TitledBorder(null, _("tutti.legend.frequencyConfiguration"))};
-}
-
-#modeConfigurationLayout {
- selected: {String.valueOf(mode.getSelectedValue())};
-}
-
-#modeConfigurationPanel {
- layout: {modeConfigurationLayout};
-}
-
-#simpleModeButton {
- text: "tutti.label.frequencyConfiguration.mode.simple";
- toolTipText: "tutti.label.frequencyConfiguration.mode.simple.tip";
- value: "simpleMode";
- selected: {model.isSimpleMode()};
- buttonGroup: "mode";
-}
-
-#simpleModeLabel {
- text: "tutti.label.frequencyConfiguration.no.configuration";
- horizontalAlignment: {JLabel.CENTER};
- enabled: false;
-}
-
-#autoGenModeButton {
- text: "tutti.label.frequencyConfiguration.mode.autoGen";
- toolTipText: "tutti.label.frequencyConfiguration.mode.autoGen.tip";
- value: "autoGenMode";
- selected: {model.isAutoGenMode()};
- buttonGroup: "mode";
-}
-
-#rafaleModeButton {
- text: "tutti.label.frequencyConfiguration.mode.rafale";
- toolTipText: "tutti.label.frequencyConfiguration.mode.rafale.tip";
- value: "rafaleMode";
- selected: {model.isRafaleMode()};
- buttonGroup: "mode";
-}
-
-#closeButton {
- actionIcon: "close";
- text: "tutti.action.close";
- mnemonic: F;
- enabled: {model.getRows().size() == 0 || model.getLengthStepCaracteristic() != null};
-}
-
-#table {
- selectionMode: {ListSelectionModel.SINGLE_SELECTION};
- selectionBackground: {null};
- selectionForeground: {Color.BLACK};
- sortable: false;
- enabled: {model.getLengthStepCaracteristic() != null}
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.jaxx 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.jaxx 2012-12-28 08:34:01 UTC (rev 114)
@@ -1,182 +0,0 @@
-<!--
- #%L
- Tutti :: UI
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2012 Ifremer
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/gpl-3.0.html>.
- #L%
- -->
-<JPanel id='homePanel' layout='{new BorderLayout()}'
- implements='fr.ifremer.tutti.ui.swing.TuttiUI<SpeciesFrequencyUIModel, SpeciesFrequencyUIHandler>'>
-
- <import>
- fr.ifremer.tutti.persistence.entities.referential.Caracteristic
-
- fr.ifremer.tutti.ui.swing.TuttiUIContext
- fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel
-
- jaxx.runtime.swing.CardLayout2Ext
- jaxx.runtime.swing.editor.bean.BeanComboBox
- jaxx.runtime.swing.editor.NumberEditor
-
- org.jdesktop.swingx.JXTable
-
- javax.swing.ListSelectionModel
- javax.swing.SwingConstants
-
- java.awt.Color
- java.awt.Dimension
-
- static org.nuiton.i18n.I18n._
- static jaxx.runtime.SwingUtil.getStringValue
- </import>
-
- <script><![CDATA[
-
- public SpeciesFrequencyUI(SpeciesBatchUI parentUI) {
- JAXXUtil.initContext(this, parentUI);
- SpeciesFrequencyUIHandler handler = new SpeciesFrequencyUIHandler(parentUI.getHandler().getContext(), this);
- setContextValue(handler);
- handler.beforeInitUI();
- }
-
- public void editBatch(SpeciesBatchRowModel row) {
- handler.editBatch(row);
- }
-
- protected void $afterCompleteSetup() {
- handler.afterInitUI();
- }
- ]]></script>
-
- <SpeciesFrequencyUIHandler id='handler'
- initializer='getContextValue(SpeciesFrequencyUIHandler.class)'/>
-
- <SpeciesFrequencyUIModel id='model'
- initializer='getContextValue(SpeciesFrequencyUIModel.class)'/>
-
- <CardLayout2Ext id='modeConfigurationLayout'
- constructorParams='this, "modeConfigurationPanel"'/>
-
- <JPanel id='configurationPanel' layout='{new BorderLayout()}'
- constraints='BorderLayout.NORTH'>
-
- <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.CENTER'>
- <VBox id='modePanel' constraints='BorderLayout.WEST'
- verticalAlignment='{SwingConstants.CENTER}'>
- <JRadioButton id='simpleModeButton'
- onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE)'/>
- <JRadioButton id='autoGenModeButton'
- onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.AUTO_GEN)'/>
- <JRadioButton id='rafaleModeButton'
- onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.RAFALE)'/>
- </VBox>
-
- <JPanel id='modeConfigurationPanel' constraints='BorderLayout.CENTER'>
- <JPanel id='simpleModePanel' constraints='"simpleMode"'
- layout='{new BorderLayout()}'>
- <JLabel id='simpleModeLabel' constraints='BorderLayout.CENTER'/>
- </JPanel>
- <JPanel id='autoGenModePanel' constraints='"autoGenMode"'>
- <Table fill='both' constraints='BorderLayout.SOUTH'>
- <!-- Min step-->
- <row>
- <cell anchor='west'>
- <JLabel id='minStepLabel'/>
- </cell>
- <cell weightx='1.0'>
- <NumberEditor id='minStepField' constructorParams='this'/>
- </cell>
- </row>
- <!-- Max step-->
- <row>
- <cell anchor='west'>
- <JLabel id='maxStepLabel'/>
- </cell>
- <cell weightx='1.0'>
- <NumberEditor id='maxStepField' constructorParams='this'/>
- </cell>
- </row>
- <!-- Actions -->
- <row>
- <cell columns='2'>
- <JPanel layout='{new GridLayout(1, 0)}'>
- <JButton id='generateButton'
- onActionPerformed='handler.generateLengthSteps()'/>
- </JPanel>
- </cell>
- </row>
- </Table>
- </JPanel>
- <JPanel id='rafaleModePanel' constraints='"rafaleMode"'>
- <Table fill='both' constraints='BorderLayout.SOUTH'>
- <!-- Rafale step-->
- <row>
- <cell weightx='1.0'>
- <JLabel id='rafaleStepLabel'/>
- </cell>
- </row>
- <row>
- <cell weightx='1.0'>
- <NumberEditor id='rafaleStepField' constructorParams='this'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </JPanel>
- </JPanel>
- <Table fill='both' constraints='BorderLayout.SOUTH'>
- <row>
- <cell columns='2'>
- <JSeparator/>
- </cell>
- </row>
- <!-- length step caracteristic -->
- <row>
- <cell anchor='west'>
- <JLabel id='lenghtStepCaracteristicLabel'/>
- </cell>
- <cell weightx='1.0'>
- <BeanComboBox id='lenghtStepCaracteristicComboBox'
- constructorParams='this'
- genericType='Caracteristic'/>
- </cell>
- </row>
- <!-- Step -->
- <row>
- <cell anchor='west'>
- <JLabel id='stepLabel'/>
- </cell>
- <cell weightx='1.0'>
- <NumberEditor id='stepField' constructorParams='this'/>
- </cell>
- </row>
- </Table>
- </JPanel>
-
- <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
- <JXTable id='table'/>
- </JScrollPane>
-
- <!-- actions -->
- <JPanel id='actionPanel' layout='{new GridLayout(1, 0)}'
- constraints='BorderLayout.SOUTH'>
- <JButton id='closeButton' onActionPerformed='handler.close()'/>
- </JPanel>
-
-</JPanel>
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIHandler.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIHandler.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -1,414 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
-
-/*
- * #%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.ezware.oxbow.swingbits.util.Preconditions;
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.ui.swing.TuttiUI;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.HighlightPredicate;
-import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-
-import javax.swing.JDialog;
-import javax.swing.table.TableColumnModel;
-import java.awt.Color;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<SpeciesFrequencyRowModel, SpeciesFrequencyUIModel> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(SpeciesFrequencyUIHandler.class);
-
- private final SpeciesFrequencyUI ui;
-
- public SpeciesFrequencyUIHandler(TuttiUIContext context,
- SpeciesFrequencyUI ui) {
- super(context,
- SpeciesFrequencyRowModel.PROPERTY_LENGTH_STEP,
- SpeciesFrequencyRowModel.PROPERTY_NUMBER,
- SpeciesFrequencyRowModel.PROPERTY_WEIGHT,
- SpeciesFrequencyRowModel.PROPERTY_COMPUTED_WEIGHT);
- this.ui = ui;
- }
-
- //------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
- //------------------------------------------------------------------------//
-
- @Override
- protected SpeciesFrequencyUIModel getModel() {
- return ui.getModel();
- }
-
- @Override
- protected SpeciesFrequencyTableModel getTableModel() {
- return (SpeciesFrequencyTableModel) getTable().getModel();
- }
-
- @Override
- protected JXTable getTable() {
- return ui.getTable();
- }
-
- @Override
- protected TableColumnModel createTableColumnModel() {
-
- DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
-
- { // LengthStep
-
- addFloatColumnToModel(columnModel,
- SpeciesFrequencyTableModel.LENGTH_STEP,
- TuttiUI.DECIMAL1_PATTERN);
- }
-
- { // Number
-
- addIntegerColumnToModel(columnModel,
- SpeciesFrequencyTableModel.NUMBER,
- TuttiUI.INT_6_DIGITS_PATTERN);
- }
-
- { // Weight
-
- addFloatColumnToModel(columnModel,
- SpeciesFrequencyTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN);
- }
-
- { // ComputedWeight
-
- addFloatColumnToModel(columnModel,
- SpeciesFrequencyTableModel.COMPUTED_WEIGHT,
- TuttiUI.DECIMAL3_PATTERN);
- }
- return columnModel;
- }
-
- @Override
- protected void onRowModified(SpeciesFrequencyRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
- if (SpeciesFrequencyRowModel.PROPERTY_NUMBER.equals(propertyName)) {
-
- // Need to recompute the computedWeight
- computeComputedWeight(row);
- }
- }
-
- @Override
- protected void onRowValidStateChanged(SpeciesFrequencyRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- }
-
- @Override
- protected void onRowModifyStateChanged(SpeciesFrequencyRowModel row,
- Boolean oldValue,
- Boolean newValue) {
- }
-
- //------------------------------------------------------------------------//
- //-- AbstractTuttiUIHandler methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public void beforeInitUI() {
-
- SpeciesFrequencyUIModel model = new SpeciesFrequencyUIModel();
-
- ui.setContextValue(model);
- }
-
- @Override
- public void afterInitUI() {
-
- initUI(ui);
-
- List<Caracteristic> lengthStepCaracterics =
- ui.getContextValue(
- List.class,
- SpeciesBatchUIHandler.SPECIES_FREQUENCY_LENGHTS);
- Preconditions.checkNotNull(lengthStepCaracterics);
-
- SpeciesFrequencyUIModel model = getModel();
-
- //TODO Use protocol to have lengthStepCaracteristic to use (if any protocol)
- initBeanComboBox(ui.getLenghtStepCaracteristicComboBox(),
- lengthStepCaracterics,
- model.getLengthStepCaracteristic());
-
- JXTable table = getTable();
-
- // create table column model
- TableColumnModel columnModel = createTableColumnModel();
-
- // create table model
- SpeciesFrequencyTableModel tableModel =
- new SpeciesFrequencyTableModel(columnModel, model);
-
- table.setModel(tableModel);
- table.setColumnModel(columnModel);
-
- installTableKeyListener(columnModel, table);
-
- table.getTableHeader().setReorderingAllowed(false);
-
- table.addHighlighter(TuttiUIUtil.newBackgroundColorHighlighter(
- HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY));
-
- // when model datas change let's propagate it table model
- listenRowsFromModel();
-
- //TODO Should it come from PROTOCOL or config ?
- model.setStep(.5f);
-
- model.setMinStep(10f);
- model.setMaxStep(20f);
-
- //TODO Configure this ?
- model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE);
-
- // always scroll to selected row
- SwingUtil.scrollToTableSelection(getTable());
-
- ui.getRafaleStepField().getTextField().addKeyListener(new KeyAdapter() {
-
- @Override
- public void keyReleased(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_ENTER) {
- e.consume();
- Float step = (Float) ui.getRafaleStepField().getModel();
-
- applyRafaleStep(step);
- }
- }
- });
-
- // when lengthStepCaracteristic changed, let's updates all row with the new value
- model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_LENGHT_STEP_CARACTERISTIC, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- Caracteristic newValue = (Caracteristic) evt.getNewValue();
- for (SpeciesFrequencyRowModel rowModel : getModel().getRows()) {
- rowModel.setLengthStepCaracteristic(newValue);
- }
- }
- });
- }
-
- @Override
- public void onCloseUI() {
- }
-
- //------------------------------------------------------------------------//
- //-- Public methods --//
- //------------------------------------------------------------------------//
-
- public void generateLengthSteps() {
-
- SpeciesFrequencyUIModel model = getModel();
-
- Map<Float, SpeciesFrequencyRowModel> rowsByStep =
- getTableModel().getRowCache();
-
- Float minStep = model.getLengthStep(model.getMinStep());
- Float maxStep = model.getLengthStep(model.getMaxStep());
-
- for (float i = minStep, step = model.getStep(); i <= maxStep; i += step) {
- if (!rowsByStep.containsKey(i)) {
-
- // add it
- SpeciesFrequencyRowModel newRow = new SpeciesFrequencyRowModel();
- newRow.setLengthStep(i);
- rowsByStep.put(i, newRow);
- }
- }
-
- List<SpeciesFrequencyRowModel> rows =
- Lists.newArrayList(rowsByStep.values());
-
- model.setRows(rows);
- }
-
- public void applyRafaleStep(Float step) {
-
- if (log.isInfoEnabled()) {
- log.info("Will apply rafale step: " + step);
- }
- SpeciesFrequencyUIModel model = getModel();
- SpeciesFrequencyTableModel tableModel = getTableModel();
-
- Map<Float, SpeciesFrequencyRowModel> rowsByStep = tableModel.getRowCache();
-
- float aroundLengthStep = model.getLengthStep(step);
-
- SpeciesFrequencyRowModel row = rowsByStep.get(aroundLengthStep);
-
- int rowIndex;
-
- if (row != null) {
-
- // increments current row
- Integer number = row.getNumber();
- row.setNumber((number == null ? 0 : number) + 1);
- rowIndex = tableModel.updateRow(row);
-
- } else {
-
- // create a new row
- row = new SpeciesFrequencyRowModel();
- row.setLengthStep(aroundLengthStep);
- row.setNumber(1);
-
- // get new index
- List<Float> steps = Lists.newArrayList(rowsByStep.keySet());
- steps.add(aroundLengthStep);
-
- Collections.sort(steps);
-
- rowIndex = steps.indexOf(aroundLengthStep);
-
- tableModel.addNewRow(rowIndex, row);
- }
-
- getTable().scrollRowToVisible(rowIndex);
- }
-
- public void editBatch(SpeciesBatchRowModel row) {
-
- List<SpeciesFrequencyRowModel> frequency = null;
-
- Caracteristic lengthStepCaracteristic = null;
- if (row != null) {
- frequency = row.getFrequency();
- }
-
-
- List<SpeciesFrequencyRowModel> editFrequency;
- if (CollectionUtils.isEmpty(frequency)) {
-
- // new list
- editFrequency = Lists.newArrayList();
- } else {
-
- editFrequency = Lists.newArrayList(frequency);
- lengthStepCaracteristic = frequency.get(0).getLengthStepCaracteristic();
- }
-
- if (log.isInfoEnabled()) {
- log.info("Will edit batch row: " + row + " with " +
- editFrequency.size() + " frequency");
- }
-
- SpeciesFrequencyUIModel model = getModel();
-
- model.setRows(editFrequency);
-
- if (lengthStepCaracteristic == null) {
-
- // no lengthStep caracteristic to apply make sure it is not setted.
- if (log.isInfoEnabled()) {
- log.info("No lengthStepCaracteristic to set.");
- }
- model.setLengthStepCaracteristic(null);
- } else {
-
- // apply existing lengthStepCaracteristic
-
- if (log.isInfoEnabled()) {
- log.info("Use lengthStepCaracteristic: " +
- lengthStepCaracteristic.getName());
- }
- model.setLengthStepCaracteristic(lengthStepCaracteristic);
- }
-
- // keep batch (will be used to push back editing entry)
- model.setBatch(row);
- }
-
- public void close() {
-
- if (log.isInfoEnabled()) {
- log.info("Will close UI " + ui);
- }
-
- SpeciesFrequencyUIModel model = getModel();
-
- // transfer rows to editor
- List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList();
- for (SpeciesFrequencyRowModel row : model.getRows()) {
- if (row.isValid()) {
-
- // can keep this row
- frequency.add(row);
- }
- }
-
- if (log.isInfoEnabled()) {
- log.info("Push back " + frequency.size() +
- " frequency to batch " + model.getBatch());
- }
-
- // push back to batch
- model.getBatch().setFrequency(frequency);
-
- ui.editBatch(null);
-
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
- }
-
- //------------------------------------------------------------------------//
- //-- Internal methods --//
- //------------------------------------------------------------------------//
-
- protected void computeComputedWeight(SpeciesFrequencyRowModel row) {
-
- if (log.isInfoEnabled()) {
- log.info("Will recompute computed weight for frequency: " + row);
- }
- }
-
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIModel.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIModel.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -1,194 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
-
-/*
- * #%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.referential.Caracteristic;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBatchRowModel, SpeciesFrequencyRowModel, SpeciesFrequencyUIModel> {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_CONFIGURATION_MODE = "configurationMode";
-
- public static final String PROPERTY_STEP = "step";
-
- private static final String PROPERTY_MIN_STEP = "minStep";
-
- private static final String PROPERTY_MAX_STEP = "maxStep";
-
- public static final String PROPERTY_CAN_GENERATE = "canGenerate";
-
- public static final String PROPERTY_SIMPLE_MODE = "simpleMode";
-
- public static final String PROPERTY_AUTO_GEN_MODE = "autoGenMode";
-
- public static final String PROPERTY_RAFALE_MODE = "rafaleMode";
-
- public static final String PROPERTY_LENGHT_STEP_CARACTERISTIC = "lengthStepCaracteristic";
-
- public static enum ConfigurationMode {
- SIMPLE,
- AUTO_GEN,
- RAFALE
- }
-
- /**
- * Fill mode.
- *
- * @since 0.2
- */
- protected ConfigurationMode configurationMode;
-
- /**
- * Batch that contains frequencies.
- *
- * @since 0.2
- */
- protected SpeciesBatchRowModel batch;
-
- /**
- * Default step to increment length step.
- *
- * @since 0.2
- */
- protected float step;
-
- /**
- * Min step to auto generate length steps.
- *
- * @since 0.2
- */
- protected Float minStep;
-
- /**
- * Max step to auto generate length steps.
- *
- * @since 0.2
- */
- protected Float maxStep;
-
- /**
- * Length step caracteristic.
- *
- * @since 0.3
- */
- protected Caracteristic lengthStepCaracteristic;
-
- public SpeciesFrequencyUIModel() {
- super(SpeciesBatchRowModel.class, null, null);
- }
-
- public ConfigurationMode getConfigurationMode() {
- return configurationMode;
- }
-
- public void setConfigurationMode(ConfigurationMode configurationMode) {
- Object oldValue = getConfigurationMode();
- this.configurationMode = configurationMode;
- firePropertyChange(PROPERTY_CONFIGURATION_MODE, oldValue, configurationMode);
- firePropertyChange(PROPERTY_SIMPLE_MODE, null, isSimpleMode());
- firePropertyChange(PROPERTY_AUTO_GEN_MODE, null, isAutoGenMode());
- firePropertyChange(PROPERTY_RAFALE_MODE, null, isRafaleMode());
- }
-
- public float getStep() {
- return step;
- }
-
- public void setStep(float step) {
- Object oldValue = getStep();
- this.step = step;
- firePropertyChange(PROPERTY_STEP, oldValue, step);
- }
-
- public Caracteristic getLengthStepCaracteristic() {
- return lengthStepCaracteristic;
- }
-
- public void setLengthStepCaracteristic(Caracteristic lengthStepCaracteristic) {
- Object oldValue = getLengthStepCaracteristic();
- this.lengthStepCaracteristic = lengthStepCaracteristic;
- firePropertyChange(PROPERTY_LENGHT_STEP_CARACTERISTIC, oldValue, lengthStepCaracteristic);
- }
-
- public Float getMinStep() {
- return minStep;
- }
-
- public void setMinStep(Float minStep) {
- Object oldValue = getMinStep();
- this.minStep = minStep;
- firePropertyChange(PROPERTY_MIN_STEP, oldValue, minStep);
- firePropertyChange(PROPERTY_CAN_GENERATE, null, isCanGenerate());
- }
-
- public Float getMaxStep() {
- return maxStep;
- }
-
- public void setMaxStep(Float maxStep) {
- Object oldValue = getMaxStep();
- this.maxStep = maxStep;
- firePropertyChange(PROPERTY_MAX_STEP, oldValue, maxStep);
- firePropertyChange(PROPERTY_CAN_GENERATE, null, isCanGenerate());
- }
-
- public boolean isSimpleMode() {
- return ConfigurationMode.SIMPLE == configurationMode;
- }
-
- public boolean isAutoGenMode() {
- return ConfigurationMode.AUTO_GEN == configurationMode;
- }
-
- public boolean isRafaleMode() {
- return ConfigurationMode.RAFALE == configurationMode;
- }
-
- public boolean isCanGenerate() {
- return minStep != null && maxStep != null && maxStep > minStep;
- }
-
- public SpeciesBatchRowModel getBatch() {
- return batch;
- }
-
- public void setBatch(SpeciesBatchRowModel batch) {
- this.batch = batch;
- }
-
- public float getLengthStep(float lengthStep) {
- int intValue = (int) (lengthStep * 10);
- int intStep = (int) (step * 10);
- int correctIntStep = intValue - (intValue % intStep);
- float result = correctIntStep / 10f;
- return result;
- }
-}
\ No newline at end of file
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/TableViewMode.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/TableViewMode.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/TableViewMode.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -0,0 +1,52 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species;
+
+/*
+ * #%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%
+ */
+
+/**
+ * What to show in the species table?
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public enum TableViewMode {
+ /**
+ * Show all nodes of sampling.
+ *
+ * @since 0.3
+ */
+ ALL,
+ /**
+ * Show only leaves of sampling.
+ *
+ * @since 0.3
+ */
+ LEAF,
+ /**
+ * Show onlyroot nodes of sampling.
+ *
+ * @since 0.3
+ */
+ ROOT
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/TableViewMode.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/catches/species/frequency/FrequencyCellComponent.java (from rev 108, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/FrequencyCellComponent.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -0,0 +1,259 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency;
+
+/*
+ * #%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.base.Preconditions;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchTableModel;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
+import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.AbstractCellEditor;
+import javax.swing.JButton;
+import javax.swing.JTable;
+import javax.swing.border.LineBorder;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Frame;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Component to render and edit frequency stuff from batch table.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class FrequencyCellComponent extends JButton {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String ROW_INDEX = "rowIndex";
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(FrequencyCellComponent.class);
+
+ public FrequencyCellComponent() {
+ setContentAreaFilled(false);
+ setOpaque(false);
+ setIcon(SwingUtil.createActionIcon("show-frequency"));
+ }
+
+ public static TableCellRenderer newRender() {
+ return new FrequencyCellRenderer();
+ }
+
+ public static TableCellEditor newEditor(SpeciesFrequencyUI ui) {
+ return new FrequencyCellEditor(ui);
+ }
+
+ public static class FrequencyCellEditor extends AbstractCellEditor implements TableCellEditor {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final FrequencyCellComponent component;
+
+ protected final SpeciesFrequencyUI ui;
+
+ protected Frame frame;
+
+ protected JTable table;
+
+ protected SpeciesBatchTableModel tableModel;
+
+ protected ColumnIdentifier<SpeciesBatchRowModel> columnIdentifier;
+
+ protected SpeciesBatchRowModel editRow;
+
+ protected Integer rowIndex;
+
+ protected Integer columnIndex;
+
+ public FrequencyCellEditor(SpeciesFrequencyUI ui) {
+ this.ui = ui;
+ component = new FrequencyCellComponent();
+ component.setBorder(new LineBorder(Color.BLACK));
+ component.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyReleased(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER ||
+ e.getKeyCode() == KeyEvent.VK_SPACE) {
+ e.consume();
+ startEdit();
+ }
+ }
+ });
+
+ component.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ e.consume();
+ startEdit();
+ }
+ });
+ }
+
+ protected void startEdit() {
+
+ Preconditions.checkNotNull(tableModel, "No table model assigned.");
+
+ // open frequency dialog
+
+ Preconditions.checkNotNull(editRow, "No editRow found.");
+
+ if (log.isInfoEnabled()) {
+ log.info("Will edit frequencies for row: " + rowIndex);
+ }
+
+ if (frame == null) {
+ frame = SwingUtil.getParentContainer(ui, Frame.class);
+ }
+
+ ui.editBatch(editRow);
+
+ // open frequency dialog
+ TuttiUIUtil.openInDialog(
+ ui, frame, _("tutti.title.frequency"), true, null);
+
+ // at close, synch back frequencies
+
+ editRow.updateTotalFromFrequencies();
+
+ int r = rowIndex;
+ int c = columnIndex;
+
+ // stop edition
+ stopCellEditing();
+
+ // reselect this cell
+ AbstractSelectTableAction.doSelectCell(table, r, c);
+ table.requestFocus();
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ int row,
+ int column) {
+ if (tableModel == null) {
+ tableModel = (SpeciesBatchTableModel) table.getModel();
+ this.table = table;
+ columnIdentifier = tableModel.getPropertyName(column);
+ }
+ String text;
+ if (value == null) {
+ text = " - ";
+ } else {
+ text = String.valueOf(value);
+ }
+ component.setText(text);
+
+ rowIndex = row;
+ columnIndex = column;
+
+ editRow = tableModel.getEntry(row);
+
+ return component;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+
+ Preconditions.checkNotNull(editRow, "No editRow found in editor.");
+
+ Object result;
+ if (columnIdentifier == SpeciesBatchTableModel.COMPUTED_NUMBER) {
+ result = editRow.getComputedNumber();
+ } else {
+ result = editRow.getComputedWeight();
+ }
+ if (log.isInfoEnabled()) {
+ log.info("editor value (" + columnIdentifier + "): " + result);
+ }
+
+ return result;
+ }
+
+ @Override
+ public boolean stopCellEditing() {
+ boolean b = super.stopCellEditing();
+ if (b) {
+ rowIndex = null;
+ editRow = null;
+ columnIndex = null;
+ }
+ return b;
+ }
+
+ @Override
+ public void cancelCellEditing() {
+ super.cancelCellEditing();
+ rowIndex = null;
+ columnIndex = null;
+ editRow = null;
+ }
+ }
+
+ public static class FrequencyCellRenderer implements TableCellRenderer {
+
+ protected final FrequencyCellComponent component;
+
+ public FrequencyCellRenderer() {
+ component = new FrequencyCellComponent();
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column) {
+
+ String text;
+ if (value == null) {
+ text = " - ";
+ } else {
+ text = String.valueOf(value);
+ }
+ boolean editable = table.isCellEditable(row, column);
+ component.setEnabled(editable);
+ component.setText(text);
+ return component;
+ }
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.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/catches/species/frequency/SpeciesFrequencyRowModel.java (from rev 109, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyRowModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -0,0 +1,191 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency;
+
+/*
+ * #%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 com.google.common.collect.Ordering;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
+
+import java.util.List;
+
+/**
+ * Represents a batch frequency row.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class SpeciesFrequencyRowModel extends AbstractTuttiBeanUIModel<SpeciesBatchFrequency, SpeciesFrequencyRowModel> implements Comparable<SpeciesFrequencyRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_LENGTH_STEP = "lengthStep";
+
+ public static final String PROPERTY_NUMBER = "number";
+
+ public static final String PROPERTY_WEIGHT = "weight";
+
+ public static final String PROPERTY_COMPUTED_WEIGHT = "computedWeight";
+
+
+ public static final String PROPERTY_LENGHT_STEP_CARACTERISTIC = "lengthStepCaracteristic";
+
+
+ /**
+ * Length step.
+ *
+ * @since 0.2
+ */
+ protected Float lengthStep;
+
+ /**
+ * Count of fishes for this lengthStep.
+ *
+ * @since 0.2
+ */
+ protected Integer number;
+
+ /**
+ * Weight of fishes observed.
+ *
+ * @since 0.2
+ */
+ protected Float weight;
+
+ /**
+ * Computed weight from number + relation taille-poids.
+ *
+ * @since 0.2
+ */
+ protected Float computedWeight;
+
+ /**
+ * Length step caracteristic.
+ *
+ * @since 0.3
+ */
+ protected Caracteristic lengthStepCaracteristic;
+
+ protected static final Binder<SpeciesBatchFrequency, SpeciesFrequencyRowModel> fromBeanBinder =
+ BinderFactory.newBinder(SpeciesBatchFrequency.class,
+ SpeciesFrequencyRowModel.class);
+
+ protected static final Binder<SpeciesFrequencyRowModel, SpeciesBatchFrequency> toBeanBinder =
+ BinderFactory.newBinder(SpeciesFrequencyRowModel.class,
+ SpeciesBatchFrequency.class);
+
+ private static final Ordering<Float> ordering = Ordering.natural().nullsFirst();
+
+ public static List<SpeciesFrequencyRowModel> fromBeans(List<SpeciesBatchFrequency> frequency) {
+ List<SpeciesFrequencyRowModel> result = Lists.newArrayList();
+ for (SpeciesBatchFrequency b : frequency) {
+ SpeciesFrequencyRowModel model = new SpeciesFrequencyRowModel();
+ fromBeanBinder.copy(b, model);
+ result.add(model);
+ }
+ return result;
+ }
+
+ public static List<SpeciesBatchFrequency> toBeans(List<SpeciesFrequencyRowModel> frequency, SpeciesBatch batch) {
+ List<SpeciesBatchFrequency> result = Lists.newArrayList();
+ for (SpeciesFrequencyRowModel b : frequency) {
+ SpeciesBatchFrequency model = new SpeciesBatchFrequency();
+ toBeanBinder.copy(b, model);
+ model.setBatch(batch);
+ result.add(model);
+ }
+ return result;
+ }
+
+ public SpeciesFrequencyRowModel() {
+ super(SpeciesBatchFrequency.class, fromBeanBinder, toBeanBinder);
+ }
+
+ public Float getLengthStep() {
+ return lengthStep;
+ }
+
+ public void setLengthStep(Float lengthStep) {
+ Object oldValue = getLengthStep();
+ this.lengthStep = lengthStep;
+ firePropertyChange(PROPERTY_LENGTH_STEP, oldValue, lengthStep);
+ }
+
+ public Integer getNumber() {
+ return number;
+ }
+
+ public void setNumber(Integer number) {
+ Object oldValue = getNumber();
+ this.number = number;
+ firePropertyChange(PROPERTY_NUMBER, oldValue, number);
+ }
+
+ public Float getWeight() {
+ return weight;
+ }
+
+ public void setWeight(Float weight) {
+ Object oldValue = getWeight();
+ this.weight = weight;
+ firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
+ }
+
+ public Float getComputedWeight() {
+ return computedWeight;
+ }
+
+ public void setComputedWeight(Float computedWeight) {
+ Object oldValue = getComputedWeight();
+ this.computedWeight = computedWeight;
+ firePropertyChange(PROPERTY_COMPUTED_WEIGHT, oldValue, computedWeight);
+ }
+
+ public Caracteristic getLengthStepCaracteristic() {
+ return lengthStepCaracteristic;
+ }
+
+ public void setLengthStepCaracteristic(Caracteristic lengthStepCaracteristic) {
+ Object oldValue = getLengthStepCaracteristic();
+ this.lengthStepCaracteristic = lengthStepCaracteristic;
+ firePropertyChange(PROPERTY_LENGHT_STEP_CARACTERISTIC, oldValue, lengthStepCaracteristic);
+ }
+
+ //TODO Use validator
+ @Override
+ public boolean isValid() {
+ return lengthStep != null && number != null && lengthStepCaracteristic != null;
+ }
+
+ @Override
+ public int compareTo(SpeciesFrequencyRowModel o) {
+ int result = ordering.compare(lengthStep, o.lengthStep);
+ return result;
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.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/catches/species/frequency/SpeciesFrequencyTableModel.java (from rev 109, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyTableModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -0,0 +1,148 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency;
+
+/*
+ * #%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.base.Preconditions;
+import com.google.common.collect.Maps;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
+import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+
+import javax.swing.table.TableColumnModel;
+import java.util.List;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * Model of the species frequency table.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class SpeciesFrequencyTableModel extends AbstractTuttiTableModel<SpeciesFrequencyRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final ColumnIdentifier<SpeciesFrequencyRowModel> LENGTH_STEP = ColumnIdentifier.newId(
+ SpeciesFrequencyRowModel.PROPERTY_LENGTH_STEP,
+ n_("tutti.table.species.frequency.header.lengthStep"),
+ n_("tutti.table.species.frequency.header.lengthStep"));
+
+ public static final ColumnIdentifier<SpeciesFrequencyRowModel> NUMBER = ColumnIdentifier.newId(
+ SpeciesFrequencyRowModel.PROPERTY_NUMBER,
+ n_("tutti.table.species.frequency.header.number"),
+ n_("tutti.table.species.frequency.header.number"));
+
+ public static final ColumnIdentifier<SpeciesFrequencyRowModel> WEIGHT = ColumnIdentifier.newId(
+ SpeciesFrequencyRowModel.PROPERTY_WEIGHT,
+ n_("tutti.table.species.frequency.header.weight"),
+ n_("tutti.table.species.frequency.header.weight"));
+
+ public static final ColumnIdentifier<SpeciesFrequencyRowModel> COMPUTED_WEIGHT = ColumnIdentifier.newId(
+ SpeciesFrequencyRowModel.PROPERTY_COMPUTED_WEIGHT,
+ n_("tutti.table.species.frequency.header.computedWeight"),
+ n_("tutti.table.species.frequency.header.computedWeight"));
+
+ private final SpeciesFrequencyUIModel uiModel;
+
+ private final Map<Float, SpeciesFrequencyRowModel> rowCache;
+
+ public SpeciesFrequencyTableModel(TableColumnModel columnModel,
+ SpeciesFrequencyUIModel uiModel) {
+ super(columnModel);
+ this.uiModel = uiModel;
+ this.rowCache = Maps.newTreeMap();
+ setNoneEditableCols(COMPUTED_WEIGHT);
+ }
+
+ @Override
+ protected SpeciesFrequencyRowModel createNewRow() {
+ Float defaultStep = null;
+
+ int rowCount = getRowCount();
+ if (rowCount > 0) {
+
+ SpeciesFrequencyRowModel rowModel = getEntry(rowCount - 1);
+ Float lengthStep = rowModel.getLengthStep();
+ if (lengthStep != null) {
+ defaultStep = uiModel.getLengthStep(
+ lengthStep + uiModel.getStep());
+ }
+ }
+ SpeciesFrequencyRowModel result = new SpeciesFrequencyRowModel();
+ result.setLengthStep(defaultStep);
+ result.setValid(false);
+ return result;
+ }
+
+ @Override
+ public void setValueAt(Object aValue,
+ int rowIndex,
+ int columnIndex,
+ ColumnIdentifier<SpeciesFrequencyRowModel> propertyName,
+ SpeciesFrequencyRowModel entry) {
+ super.setValueAt(aValue, rowIndex, columnIndex, propertyName, entry);
+ // TODO Rebuild the computedWeight if possible...
+ }
+
+ public Map<Float, SpeciesFrequencyRowModel> getRowCache() {
+ return rowCache;
+ }
+
+ @Override
+ protected void onRowsChanged(List<SpeciesFrequencyRowModel> data) {
+
+ // rebuild row cache
+ rowCache.clear();
+
+ for (SpeciesFrequencyRowModel row : data) {
+ Float lengthStep = row.getLengthStep();
+ if (lengthStep != null) {
+ rowCache.put(lengthStep, row);
+ }
+ }
+ }
+
+ @Override
+ protected void onRowAdded(int rowIndex, SpeciesFrequencyRowModel newValue) {
+
+ Preconditions.checkNotNull(newValue, "can't add a null row");
+
+ newValue.setLengthStepCaracteristic(uiModel.getLengthStepCaracteristic());
+
+ // add new row to cache
+ Float lengthStep = newValue.getLengthStep();
+
+ Preconditions.checkNotNull(lengthStep,
+ "can't add a null lengthStep row");
+
+ float roundLenghtValue = uiModel.getLengthStep(lengthStep);
+
+ if (!rowCache.containsKey(roundLenghtValue)) {
+
+ rowCache.put(roundLenghtValue, newValue);
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.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/catches/species/frequency/SpeciesFrequencyUI.css (from rev 109, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.css)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2012-12-28 08:34:01 UTC (rev 114)
@@ -0,0 +1,160 @@
+/*
+ * #%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%
+ */
+
+BeanComboBox {
+ showReset: true;
+ i18nPrefix: "tutti.property.";
+ bean: {model};
+}
+
+NumberEditor {
+ autoPopup: {handler.getConfig().isAutoPopupNumberEditor()};
+ showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
+}
+
+#stepLabel {
+ text: "tutti.label.frequencyConfiguration.step";
+ labelFor: {stepField};
+}
+
+#stepField {
+ property: "step";
+ model: {model.getStep()};
+ useFloat: true;
+ numberPattern: {DECIMAL1_PATTERN};
+ bean: {model};
+}
+
+#lenghtStepCaracteristicLabel {
+ text: "tutti.label.frequencyConfiguration.lengthStepCaracteristic";
+ labelFor: {lenghtStepCaracteristicComboBox};
+}
+
+#lenghtStepCaracteristicComboBox {
+ property: "lengthStepCaracteristic";
+ selectedItem: {model.getLengthStepCaracteristic()};
+}
+
+#minStepLabel {
+ text: "tutti.label.frequencyConfiguration.minStep";
+ labelFor: {minStepField};
+}
+
+#minStepField {
+ property: "minStep";
+ model: {model.getMinStep()};
+ useFloat: true;
+ showReset: true;
+ numberPattern: {DECIMAL1_PATTERN};
+ bean: {model};
+}
+
+#maxStepLabel {
+ text: "tutti.label.frequencyConfiguration.maxStep";
+ labelFor: {maxStepField};
+}
+
+#maxStepField {
+ property: "maxStep";
+ model: {model.getMaxStep()};
+ useFloat: true;
+ showReset: true;
+ numberPattern: {DECIMAL1_PATTERN};
+ bean: {model};
+}
+
+#rafaleStepLabel {
+ text: "tutti.label.frequencyConfiguration.rafaleStep";
+ labelFor: {rafaleStepField};
+}
+
+#rafaleStepField {
+ modelType: {Float.class};
+ useFloat: true;
+ showReset: true;
+ numberPattern: {DECIMAL1_PATTERN};
+}
+
+#generateButton {
+ actionIcon: "generate";
+ text: "tutti.action.generate";
+ enabled: {model.isCanGenerate()};
+}
+
+#configurationPanel {
+ border: {new TitledBorder(null, _("tutti.legend.frequencyConfiguration"))};
+}
+
+#modeConfigurationLayout {
+ selected: {String.valueOf(mode.getSelectedValue())};
+}
+
+#modeConfigurationPanel {
+ layout: {modeConfigurationLayout};
+}
+
+#simpleModeButton {
+ text: "tutti.label.frequencyConfiguration.mode.simple";
+ toolTipText: "tutti.label.frequencyConfiguration.mode.simple.tip";
+ value: "simpleMode";
+ selected: {model.isSimpleMode()};
+ buttonGroup: "mode";
+}
+
+#simpleModeLabel {
+ text: "tutti.label.frequencyConfiguration.no.configuration";
+ horizontalAlignment: {JLabel.CENTER};
+ enabled: false;
+}
+
+#autoGenModeButton {
+ text: "tutti.label.frequencyConfiguration.mode.autoGen";
+ toolTipText: "tutti.label.frequencyConfiguration.mode.autoGen.tip";
+ value: "autoGenMode";
+ selected: {model.isAutoGenMode()};
+ buttonGroup: "mode";
+}
+
+#rafaleModeButton {
+ text: "tutti.label.frequencyConfiguration.mode.rafale";
+ toolTipText: "tutti.label.frequencyConfiguration.mode.rafale.tip";
+ value: "rafaleMode";
+ selected: {model.isRafaleMode()};
+ buttonGroup: "mode";
+}
+
+#closeButton {
+ actionIcon: "close";
+ text: "tutti.action.close";
+ mnemonic: F;
+ enabled: {model.getRows().size() == 0 || model.getLengthStepCaracteristic() != null};
+}
+
+#table {
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+ enabled: {model.getLengthStepCaracteristic() != null}
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.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/catches/species/frequency/SpeciesFrequencyUI.jaxx (from rev 108, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUI.jaxx)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx 2012-12-28 08:34:01 UTC (rev 114)
@@ -0,0 +1,183 @@
+<!--
+ #%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<SpeciesFrequencyUIModel, SpeciesFrequencyUIHandler>'>
+
+ <import>
+ fr.ifremer.tutti.persistence.entities.referential.Caracteristic
+
+ fr.ifremer.tutti.ui.swing.TuttiUIContext
+ fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel
+ fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI
+
+ jaxx.runtime.swing.CardLayout2Ext
+ jaxx.runtime.swing.editor.bean.BeanComboBox
+ jaxx.runtime.swing.editor.NumberEditor
+
+ org.jdesktop.swingx.JXTable
+
+ javax.swing.ListSelectionModel
+ javax.swing.SwingConstants
+
+ java.awt.Color
+ java.awt.Dimension
+
+ static org.nuiton.i18n.I18n._
+ static jaxx.runtime.SwingUtil.getStringValue
+ </import>
+
+ <script><![CDATA[
+
+ public SpeciesFrequencyUI(SpeciesBatchUI parentUI) {
+ JAXXUtil.initContext(this, parentUI);
+ SpeciesFrequencyUIHandler handler = new SpeciesFrequencyUIHandler(parentUI.getHandler().getContext(), this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+ }
+
+ public void editBatch(SpeciesBatchRowModel row) {
+ handler.editBatch(row);
+ }
+
+ protected void $afterCompleteSetup() {
+ handler.afterInitUI();
+ }
+ ]]></script>
+
+ <SpeciesFrequencyUIHandler id='handler'
+ initializer='getContextValue(SpeciesFrequencyUIHandler.class)'/>
+
+ <SpeciesFrequencyUIModel id='model'
+ initializer='getContextValue(SpeciesFrequencyUIModel.class)'/>
+
+ <CardLayout2Ext id='modeConfigurationLayout'
+ constructorParams='this, "modeConfigurationPanel"'/>
+
+ <JPanel id='configurationPanel' layout='{new BorderLayout()}'
+ constraints='BorderLayout.NORTH'>
+
+ <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.CENTER'>
+ <VBox id='modePanel' constraints='BorderLayout.WEST'
+ verticalAlignment='{SwingConstants.CENTER}'>
+ <JRadioButton id='simpleModeButton'
+ onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE)'/>
+ <JRadioButton id='autoGenModeButton'
+ onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.AUTO_GEN)'/>
+ <JRadioButton id='rafaleModeButton'
+ onActionPerformed='model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.RAFALE)'/>
+ </VBox>
+
+ <JPanel id='modeConfigurationPanel' constraints='BorderLayout.CENTER'>
+ <JPanel id='simpleModePanel' constraints='"simpleMode"'
+ layout='{new BorderLayout()}'>
+ <JLabel id='simpleModeLabel' constraints='BorderLayout.CENTER'/>
+ </JPanel>
+ <JPanel id='autoGenModePanel' constraints='"autoGenMode"'>
+ <Table fill='both' constraints='BorderLayout.SOUTH'>
+ <!-- Min step-->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='minStepLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <NumberEditor id='minStepField' constructorParams='this'/>
+ </cell>
+ </row>
+ <!-- Max step-->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='maxStepLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <NumberEditor id='maxStepField' constructorParams='this'/>
+ </cell>
+ </row>
+ <!-- Actions -->
+ <row>
+ <cell columns='2'>
+ <JPanel layout='{new GridLayout(1, 0)}'>
+ <JButton id='generateButton'
+ onActionPerformed='handler.generateLengthSteps()'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ <JPanel id='rafaleModePanel' constraints='"rafaleMode"'>
+ <Table fill='both' constraints='BorderLayout.SOUTH'>
+ <!-- Rafale step-->
+ <row>
+ <cell weightx='1.0'>
+ <JLabel id='rafaleStepLabel'/>
+ </cell>
+ </row>
+ <row>
+ <cell weightx='1.0'>
+ <NumberEditor id='rafaleStepField' constructorParams='this'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </JPanel>
+ </JPanel>
+ <Table fill='both' constraints='BorderLayout.SOUTH'>
+ <row>
+ <cell columns='2'>
+ <JSeparator/>
+ </cell>
+ </row>
+ <!-- length step caracteristic -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='lenghtStepCaracteristicLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <BeanComboBox id='lenghtStepCaracteristicComboBox'
+ constructorParams='this'
+ genericType='Caracteristic'/>
+ </cell>
+ </row>
+ <!-- Step -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='stepLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <NumberEditor id='stepField' constructorParams='this'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+
+ <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
+ <JXTable id='table'/>
+ </JScrollPane>
+
+ <!-- actions -->
+ <JPanel id='actionPanel' layout='{new GridLayout(1, 0)}'
+ constraints='BorderLayout.SOUTH'>
+ <JButton id='closeButton' onActionPerformed='handler.close()'/>
+ </JPanel>
+
+</JPanel>
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.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/catches/species/frequency/SpeciesFrequencyUIHandler.java (from rev 109, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIHandler.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -0,0 +1,417 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency;
+
+/*
+ * #%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.ezware.oxbow.swingbits.util.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.ui.swing.TuttiUI;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
+
+import javax.swing.JDialog;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumnModel;
+import java.awt.Color;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<SpeciesFrequencyRowModel, SpeciesFrequencyUIModel> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(SpeciesFrequencyUIHandler.class);
+
+ private final SpeciesFrequencyUI ui;
+
+ public SpeciesFrequencyUIHandler(TuttiUIContext context,
+ SpeciesFrequencyUI ui) {
+ super(context,
+ SpeciesFrequencyRowModel.PROPERTY_LENGTH_STEP,
+ SpeciesFrequencyRowModel.PROPERTY_NUMBER,
+ SpeciesFrequencyRowModel.PROPERTY_WEIGHT,
+ SpeciesFrequencyRowModel.PROPERTY_COMPUTED_WEIGHT);
+ this.ui = ui;
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ protected SpeciesFrequencyUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
+ protected SpeciesFrequencyTableModel getTableModel() {
+ return (SpeciesFrequencyTableModel) getTable().getModel();
+ }
+
+ @Override
+ protected JXTable getTable() {
+ return ui.getTable();
+ }
+
+ @Override
+ protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
+
+ DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
+
+ { // LengthStep
+
+ addFloatColumnToModel(columnModel,
+ SpeciesFrequencyTableModel.LENGTH_STEP,
+ TuttiUI.DECIMAL1_PATTERN);
+ }
+
+ { // Number
+
+ addIntegerColumnToModel(columnModel,
+ SpeciesFrequencyTableModel.NUMBER,
+ TuttiUI.INT_6_DIGITS_PATTERN);
+ }
+
+ { // Weight
+
+ addFloatColumnToModel(columnModel,
+ SpeciesFrequencyTableModel.WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+
+ { // ComputedWeight
+
+ addFloatColumnToModel(columnModel,
+ SpeciesFrequencyTableModel.COMPUTED_WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+ return columnModel;
+ }
+
+ @Override
+ protected void onRowModified(SpeciesFrequencyRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ if (SpeciesFrequencyRowModel.PROPERTY_NUMBER.equals(propertyName)) {
+
+ // Need to recompute the computedWeight
+ computeComputedWeight(row);
+ }
+ }
+
+ @Override
+ protected void onRowValidStateChanged(SpeciesFrequencyRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ }
+
+ @Override
+ protected void onRowModifyStateChanged(SpeciesFrequencyRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void beforeInitUI() {
+
+ SpeciesFrequencyUIModel model = new SpeciesFrequencyUIModel();
+
+ ui.setContextValue(model);
+ }
+
+ @Override
+ public void afterInitUI() {
+
+ initUI(ui);
+
+ List<Caracteristic> lengthStepCaracterics =
+ ui.getContextValue(
+ List.class,
+ SpeciesBatchUIHandler.SPECIES_FREQUENCY_LENGHTS);
+ Preconditions.checkNotNull(lengthStepCaracterics);
+
+ SpeciesFrequencyUIModel model = getModel();
+
+ //TODO Use protocol to have lengthStepCaracteristic to use (if any protocol)
+ initBeanComboBox(ui.getLenghtStepCaracteristicComboBox(),
+ lengthStepCaracterics,
+ model.getLengthStepCaracteristic());
+
+ JXTable table = getTable();
+
+ // create table column model
+ TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
+
+ // create table model
+ SpeciesFrequencyTableModel tableModel =
+ new SpeciesFrequencyTableModel(columnModel, model);
+
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
+
+ installTableKeyListener(columnModel, table);
+
+ table.getTableHeader().setReorderingAllowed(false);
+
+ table.addHighlighter(TuttiUIUtil.newBackgroundColorHighlighter(
+ HighlightPredicate.READ_ONLY, Color.LIGHT_GRAY));
+
+ // when model datas change let's propagate it table model
+ listenRowsFromModel();
+
+ //TODO Should it come from PROTOCOL or config ?
+ model.setStep(.5f);
+
+ model.setMinStep(10f);
+ model.setMaxStep(20f);
+
+ //TODO Configure this ?
+ model.setConfigurationMode(SpeciesFrequencyUIModel.ConfigurationMode.SIMPLE);
+
+ // always scroll to selected row
+ SwingUtil.scrollToTableSelection(getTable());
+
+ ui.getRafaleStepField().getTextField().addKeyListener(new KeyAdapter() {
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_ENTER) {
+ e.consume();
+ Float step = (Float) ui.getRafaleStepField().getModel();
+
+ applyRafaleStep(step);
+ }
+ }
+ });
+
+ // when lengthStepCaracteristic changed, let's updates all row with the new value
+ model.addPropertyChangeListener(SpeciesFrequencyUIModel.PROPERTY_LENGHT_STEP_CARACTERISTIC, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ Caracteristic newValue = (Caracteristic) evt.getNewValue();
+ for (SpeciesFrequencyRowModel rowModel : getModel().getRows()) {
+ rowModel.setLengthStepCaracteristic(newValue);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void onCloseUI() {
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
+ public void generateLengthSteps() {
+
+ SpeciesFrequencyUIModel model = getModel();
+
+ Map<Float, SpeciesFrequencyRowModel> rowsByStep =
+ getTableModel().getRowCache();
+
+ Float minStep = model.getLengthStep(model.getMinStep());
+ Float maxStep = model.getLengthStep(model.getMaxStep());
+
+ for (float i = minStep, step = model.getStep(); i <= maxStep; i += step) {
+ if (!rowsByStep.containsKey(i)) {
+
+ // add it
+ SpeciesFrequencyRowModel newRow = new SpeciesFrequencyRowModel();
+ newRow.setLengthStep(i);
+ rowsByStep.put(i, newRow);
+ }
+ }
+
+ List<SpeciesFrequencyRowModel> rows =
+ Lists.newArrayList(rowsByStep.values());
+
+ model.setRows(rows);
+ }
+
+ public void applyRafaleStep(Float step) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Will apply rafale step: " + step);
+ }
+ SpeciesFrequencyUIModel model = getModel();
+ SpeciesFrequencyTableModel tableModel = getTableModel();
+
+ Map<Float, SpeciesFrequencyRowModel> rowsByStep = tableModel.getRowCache();
+
+ float aroundLengthStep = model.getLengthStep(step);
+
+ SpeciesFrequencyRowModel row = rowsByStep.get(aroundLengthStep);
+
+ int rowIndex;
+
+ if (row != null) {
+
+ // increments current row
+ Integer number = row.getNumber();
+ row.setNumber((number == null ? 0 : number) + 1);
+ rowIndex = tableModel.updateRow(row);
+
+ } else {
+
+ // create a new row
+ row = new SpeciesFrequencyRowModel();
+ row.setLengthStep(aroundLengthStep);
+ row.setNumber(1);
+
+ // get new index
+ List<Float> steps = Lists.newArrayList(rowsByStep.keySet());
+ steps.add(aroundLengthStep);
+
+ Collections.sort(steps);
+
+ rowIndex = steps.indexOf(aroundLengthStep);
+
+ tableModel.addNewRow(rowIndex, row);
+ }
+
+ getTable().scrollRowToVisible(rowIndex);
+ }
+
+ public void editBatch(SpeciesBatchRowModel row) {
+
+ List<SpeciesFrequencyRowModel> frequency = null;
+
+ Caracteristic lengthStepCaracteristic = null;
+ if (row != null) {
+ frequency = row.getFrequency();
+ }
+
+
+ List<SpeciesFrequencyRowModel> editFrequency;
+ if (CollectionUtils.isEmpty(frequency)) {
+
+ // new list
+ editFrequency = Lists.newArrayList();
+ } else {
+
+ editFrequency = Lists.newArrayList(frequency);
+ lengthStepCaracteristic = frequency.get(0).getLengthStepCaracteristic();
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Will edit batch row: " + row + " with " +
+ editFrequency.size() + " frequency");
+ }
+
+ SpeciesFrequencyUIModel model = getModel();
+
+ model.setRows(editFrequency);
+
+ if (lengthStepCaracteristic == null) {
+
+ // no lengthStep caracteristic to apply make sure it is not setted.
+ if (log.isInfoEnabled()) {
+ log.info("No lengthStepCaracteristic to set.");
+ }
+ model.setLengthStepCaracteristic(null);
+ } else {
+
+ // apply existing lengthStepCaracteristic
+
+ if (log.isInfoEnabled()) {
+ log.info("Use lengthStepCaracteristic: " +
+ lengthStepCaracteristic.getName());
+ }
+ model.setLengthStepCaracteristic(lengthStepCaracteristic);
+ }
+
+ // keep batch (will be used to push back editing entry)
+ model.setBatch(row);
+ }
+
+ public void close() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Will close UI " + ui);
+ }
+
+ SpeciesFrequencyUIModel model = getModel();
+
+ // transfer rows to editor
+ List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList();
+ for (SpeciesFrequencyRowModel row : model.getRows()) {
+ if (row.isValid()) {
+
+ // can keep this row
+ frequency.add(row);
+ }
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Push back " + frequency.size() +
+ " frequency to batch " + model.getBatch());
+ }
+
+ // push back to batch
+ model.getBatch().setFrequency(frequency);
+
+ ui.editBatch(null);
+
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected void computeComputedWeight(SpeciesFrequencyRowModel row) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Will recompute computed weight for frequency: " + row);
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.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/catches/species/frequency/SpeciesFrequencyUIModel.java (from rev 109, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesFrequencyUIModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -0,0 +1,195 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency;
+
+/*
+ * #%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.referential.Caracteristic;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class SpeciesFrequencyUIModel extends AbstractTuttiTableUIModel<SpeciesBatchRowModel, SpeciesFrequencyRowModel, SpeciesFrequencyUIModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_CONFIGURATION_MODE = "configurationMode";
+
+ public static final String PROPERTY_STEP = "step";
+
+ private static final String PROPERTY_MIN_STEP = "minStep";
+
+ private static final String PROPERTY_MAX_STEP = "maxStep";
+
+ public static final String PROPERTY_CAN_GENERATE = "canGenerate";
+
+ public static final String PROPERTY_SIMPLE_MODE = "simpleMode";
+
+ public static final String PROPERTY_AUTO_GEN_MODE = "autoGenMode";
+
+ public static final String PROPERTY_RAFALE_MODE = "rafaleMode";
+
+ public static final String PROPERTY_LENGHT_STEP_CARACTERISTIC = "lengthStepCaracteristic";
+
+ public static enum ConfigurationMode {
+ SIMPLE,
+ AUTO_GEN,
+ RAFALE
+ }
+
+ /**
+ * Fill mode.
+ *
+ * @since 0.2
+ */
+ protected ConfigurationMode configurationMode;
+
+ /**
+ * Batch that contains frequencies.
+ *
+ * @since 0.2
+ */
+ protected SpeciesBatchRowModel batch;
+
+ /**
+ * Default step to increment length step.
+ *
+ * @since 0.2
+ */
+ protected float step;
+
+ /**
+ * Min step to auto generate length steps.
+ *
+ * @since 0.2
+ */
+ protected Float minStep;
+
+ /**
+ * Max step to auto generate length steps.
+ *
+ * @since 0.2
+ */
+ protected Float maxStep;
+
+ /**
+ * Length step caracteristic.
+ *
+ * @since 0.3
+ */
+ protected Caracteristic lengthStepCaracteristic;
+
+ public SpeciesFrequencyUIModel() {
+ super(SpeciesBatchRowModel.class, null, null);
+ }
+
+ public ConfigurationMode getConfigurationMode() {
+ return configurationMode;
+ }
+
+ public void setConfigurationMode(ConfigurationMode configurationMode) {
+ Object oldValue = getConfigurationMode();
+ this.configurationMode = configurationMode;
+ firePropertyChange(PROPERTY_CONFIGURATION_MODE, oldValue, configurationMode);
+ firePropertyChange(PROPERTY_SIMPLE_MODE, null, isSimpleMode());
+ firePropertyChange(PROPERTY_AUTO_GEN_MODE, null, isAutoGenMode());
+ firePropertyChange(PROPERTY_RAFALE_MODE, null, isRafaleMode());
+ }
+
+ public float getStep() {
+ return step;
+ }
+
+ public void setStep(float step) {
+ Object oldValue = getStep();
+ this.step = step;
+ firePropertyChange(PROPERTY_STEP, oldValue, step);
+ }
+
+ public Caracteristic getLengthStepCaracteristic() {
+ return lengthStepCaracteristic;
+ }
+
+ public void setLengthStepCaracteristic(Caracteristic lengthStepCaracteristic) {
+ Object oldValue = getLengthStepCaracteristic();
+ this.lengthStepCaracteristic = lengthStepCaracteristic;
+ firePropertyChange(PROPERTY_LENGHT_STEP_CARACTERISTIC, oldValue, lengthStepCaracteristic);
+ }
+
+ public Float getMinStep() {
+ return minStep;
+ }
+
+ public void setMinStep(Float minStep) {
+ Object oldValue = getMinStep();
+ this.minStep = minStep;
+ firePropertyChange(PROPERTY_MIN_STEP, oldValue, minStep);
+ firePropertyChange(PROPERTY_CAN_GENERATE, null, isCanGenerate());
+ }
+
+ public Float getMaxStep() {
+ return maxStep;
+ }
+
+ public void setMaxStep(Float maxStep) {
+ Object oldValue = getMaxStep();
+ this.maxStep = maxStep;
+ firePropertyChange(PROPERTY_MAX_STEP, oldValue, maxStep);
+ firePropertyChange(PROPERTY_CAN_GENERATE, null, isCanGenerate());
+ }
+
+ public boolean isSimpleMode() {
+ return ConfigurationMode.SIMPLE == configurationMode;
+ }
+
+ public boolean isAutoGenMode() {
+ return ConfigurationMode.AUTO_GEN == configurationMode;
+ }
+
+ public boolean isRafaleMode() {
+ return ConfigurationMode.RAFALE == configurationMode;
+ }
+
+ public boolean isCanGenerate() {
+ return minStep != null && maxStep != null && maxStep > minStep;
+ }
+
+ public SpeciesBatchRowModel getBatch() {
+ return batch;
+ }
+
+ public void setBatch(SpeciesBatchRowModel batch) {
+ this.batch = batch;
+ }
+
+ public float getLengthStep(float lengthStep) {
+ int intValue = (int) (lengthStep * 10);
+ int intStep = (int) (step * 10);
+ int correctIntStep = intValue - (intValue % intStep);
+ float result = correctIntStep / 10f;
+ 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/catches/species/frequency/SpeciesFrequencyUIModel.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/fishing/environment/EnvironmentTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -40,6 +40,7 @@
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionListener;
+import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -73,7 +74,7 @@
}
@Override
- protected TableColumnModel createTableColumnModel() {
+ protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
DefaultTableColumnModelExt columnModel =
new DefaultTableColumnModelExt();
@@ -116,7 +117,7 @@
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel();
+ TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
// create table model
EnvironmentTableModel tableModel =
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -40,6 +40,7 @@
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionListener;
+import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -73,7 +74,7 @@
}
@Override
- protected TableColumnModel createTableColumnModel() {
+ protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
DefaultTableColumnModelExt columnModel =
new DefaultTableColumnModelExt();
@@ -116,7 +117,7 @@
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel();
+ TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
// create table model
GearShootingTableModel tableModel =
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -40,6 +40,7 @@
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionListener;
+import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -77,7 +78,7 @@
}
@Override
- protected TableColumnModel createTableColumnModel() {
+ protected TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer) {
DefaultTableColumnModelExt columnModel =
new DefaultTableColumnModelExt();
@@ -130,7 +131,7 @@
JXTable table = getTable();
// create table column model
- TableColumnModel columnModel = createTableColumnModel();
+ TableColumnModel columnModel = createTableColumnModel(table.getDefaultRenderer(Object.class));
// create table model
HydrologyTableModel tableModel =
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -86,7 +86,7 @@
protected abstract AbstractTuttiTableModel<R> getTableModel();
- protected abstract TableColumnModel createTableColumnModel();
+ protected abstract TableColumnModel createTableColumnModel(TableCellRenderer defaultRenderer);
protected abstract void onRowModified(R row,
String propertyName,
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-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-28 08:34:01 UTC (rev 114)
@@ -45,7 +45,6 @@
tutti.label.attachmentEditor.file=Fichier
tutti.label.attachmentEditor.fileComment=Commentaire
tutti.label.attachmentEditor.fileName=Nom
-tutti.label.catches.accidentalObserved=Captures accidentelles observées ?
tutti.label.catches.benthosTotalSampleSortedWeight=Poids total vrac échantillonné
tutti.label.catches.benthosTotalSortedWeight=Poids total vrac
tutti.label.catches.benthosTotalUnsortedWeight=Poids total hors vrac
@@ -56,7 +55,6 @@
tutti.label.catches.catchTotalUnsortedWeight=Poids total hors vrac
tutti.label.catches.catchTotalWeight=Poids total
tutti.label.catches.macroWasteTotalWeight=Poids total
-tutti.label.catches.planktonObserved=Plancton observé ?
tutti.label.catches.planktonTotalSampleWeight=Poids total échantillonné
tutti.label.catches.planktonTotalWeight=Poids total
tutti.label.catches.speciesTotalSampleSortedWeight=Poids total vrac échantillonné
@@ -73,9 +71,6 @@
tutti.label.cruise.program=Série
tutti.label.cruise.surveyPart=Série partielle
tutti.label.cruise.year=Année
-tutti.label.fishingOperation.averageBottomSalinity=Salinité de fond moyenne
-tutti.label.fishingOperation.averageBottomTemperature=Température de fond moyenne
-tutti.label.fishingOperation.beaufortScale=Force du vent
tutti.label.fishingOperation.date=Date
tutti.label.fishingOperation.distanceChalutee=Distance chalutée
tutti.label.fishingOperation.duree=Durée
@@ -87,30 +82,12 @@
tutti.label.fishingOperation.gearLatitude=Latitude
tutti.label.fishingOperation.gearLongitude=Longitude
tutti.label.fishingOperation.gearShootingEnd=Fin de traine
-tutti.label.fishingOperation.gearShootingEndBottomSalinity=Salinité de fond fin de traine
-tutti.label.fishingOperation.gearShootingEndBottomTemperature=Température de fond fin de traine
-tutti.label.fishingOperation.gearShootingEndDepth=Profondeur fin de traine
-tutti.label.fishingOperation.gearShootingEndSurfaceSalinity=Salinité de surface fin de traine
-tutti.label.fishingOperation.gearShootingEndSurfaceTemperature=Temperature de surface fin de traine
tutti.label.fishingOperation.gearShootingStart=Début de traine
-tutti.label.fishingOperation.gearShootingStartBottomSalinity=Salinité de fond début de traine
-tutti.label.fishingOperation.gearShootingStartBottomTemperature=Température de fond début de traine
-tutti.label.fishingOperation.gearShootingStartDepth=Profondeur début de traine
-tutti.label.fishingOperation.gearShootingStartSurfaceSalinity=Salinité de surface début de traine
-tutti.label.fishingOperation.gearShootingStartSurfaceTemperature=Temperature de surface début de traine
tutti.label.fishingOperation.gearTime=Heure
-tutti.label.fishingOperation.geometrieMesuree=Géométrie mesurée
tutti.label.fishingOperation.location=Localité
-tutti.label.fishingOperation.longueurBras=Longueur des funes
-tutti.label.fishingOperation.longueurFunes=Longueur des bras
-tutti.label.fishingOperation.ouvertureHorizontale=Ouverture horizontale
-tutti.label.fishingOperation.ouvertureVerticale=Ouverture verticale
-tutti.label.fishingOperation.seaState=Etat de la mer
tutti.label.fishingOperation.stationNumber=Code Station
tutti.label.fishingOperation.strata=Strate
tutti.label.fishingOperation.subStrata=Sous strate
-tutti.label.fishingOperation.systemeFermetureCul=Système de fermeture de cul
-tutti.label.fishingOperation.windDirection=Direction du vent
tutti.label.frequencyConfiguration.lengthStepCaracteristic=Type de mesure
tutti.label.frequencyConfiguration.maxStep=Classe max
tutti.label.frequencyConfiguration.minStep=Classe min
@@ -133,7 +110,6 @@
tutti.label.program.name=Nom
tutti.label.program.zone=Zone
tutti.label.protocol=Protocol de saisie
-tutti.label.species.speciesTotalUnsortedWeight=
tutti.label.tab.accidentel=Captures accidentelles
tutti.label.tab.benthos=Benthos
tutti.label.tab.catches=Captures
@@ -153,11 +129,9 @@
tutti.label.traitReminder=Trait \: %s
tutti.legend.catch.benthos=Benthos
tutti.legend.catch.macroWaste=Macro déchets
-tutti.legend.catch.other=Autres
tutti.legend.catch.species=Espèces
tutti.legend.catch.total=Capture
tutti.legend.frequencyConfiguration=Configuration
-tutti.legend.macroWasteCatches=Macro déchets
tutti.menu.actions=Actions
tutti.menu.actions.tip=Actions
tutti.menu.file=Fichier
@@ -179,44 +153,20 @@
tutti.table.accidental.batch.header.weight=Poids observé
tutti.table.benthos.batch.header.comment=Commentaire
tutti.table.benthos.batch.header.file=Pièces jointes
+tutti.table.benthos.batch.header.number=Nombre
tutti.table.benthos.batch.header.sampleWeight=Poids échantillonné
-tutti.table.benthos.batch.header.samplingRatio=Fraction d'élévation
tutti.table.benthos.batch.header.speciesByCode=Espèce
tutti.table.benthos.batch.header.speciesByGenusCode=Espèce
tutti.table.benthos.batch.header.toConfirm=A Confirmer
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.beaufortScale=Force du vent
-tutti.table.fishing.environment.keys.key3=Clé 3
-tutti.table.fishing.environment.keys.key4=Clé 4
-tutti.table.fishing.environment.keys.key5=Clé 5
-tutti.table.fishing.environment.keys.seaState=État de la mer
-tutti.table.fishing.environment.keys.windDirection=Direction du vent
tutti.table.fishing.gearShooting.header.key=Clé
tutti.table.fishing.gearShooting.header.value=Valeur
-tutti.table.fishing.gearShooting.keys.armLength=Longueur des bras
-tutti.table.fishing.gearShooting.keys.endDepth=Profondeur fin de traine
-tutti.table.fishing.gearShooting.keys.horizontalAperture=Ouverture horizontale
-tutti.table.fishing.gearShooting.keys.key3=Clé 3
-tutti.table.fishing.gearShooting.keys.key4=Clé 4
-tutti.table.fishing.gearShooting.keys.key5=Clé 5
-tutti.table.fishing.gearShooting.keys.measuredGeometry=Géométrie mesurée
-tutti.table.fishing.gearShooting.keys.startDepth=Profondeur début de traine
-tutti.table.fishing.gearShooting.keys.systemeFermetureCul=Système de fermeture du cul
-tutti.table.fishing.gearShooting.keys.verticalAperture=Ouverture verticale
-tutti.table.fishing.gearShooting.keys.warpLength=Longueur des funes
tutti.table.fishing.hydrology.header.averageValue=Moyenne
tutti.table.fishing.hydrology.header.gearShootingEndValue=Fin de traîne
tutti.table.fishing.hydrology.header.gearShootingStartValue=Début de traîne
tutti.table.fishing.hydrology.header.key=Clé
-tutti.table.fishing.hydrology.keys.key3=Clé 3
-tutti.table.fishing.hydrology.keys.key4=Clé 4
-tutti.table.fishing.hydrology.keys.key5=Clé 5
-tutti.table.fishing.hydrology.keys.salinity.bottom=Salinité au fond
-tutti.table.fishing.hydrology.keys.salinity.surface=Salinité à la surface
-tutti.table.fishing.hydrology.keys.temperature.bottom=Température au fond
-tutti.table.fishing.hydrology.keys.temperature.surface=Température à la surface
tutti.table.macrowaste.batch.header.comment=Commentaire
tutti.table.macrowaste.batch.header.file=Pièces jointes
tutti.table.macrowaste.batch.header.macroWasteCategory=Catégorie
@@ -224,13 +174,13 @@
tutti.table.macrowaste.batch.header.number=Nombre
tutti.table.macrowaste.batch.header.weight=Poids
tutti.table.plankton.batch.header.comment=Commentaire
-tutti.table.plankton.batch.header.elevationRate=Fraction d'élévation
tutti.table.plankton.batch.header.file=Pièces jointes
tutti.table.plankton.batch.header.sampleWeight=Poids échantillonné
tutti.table.plankton.batch.header.speciesByCode=Espèce
tutti.table.plankton.batch.header.speciesByGenusCode=Espèce
tutti.table.plankton.batch.header.toConfirm=A Confirmer
tutti.table.plankton.batch.header.weight=Poids
+tutti.table.species.batch.header.ageCategory=Age
tutti.table.protocol.species.header.maturity=Maturité
tutti.table.protocol.species.header.sex=Sexe
tutti.table.protocol.species.header.sizeCategory=Catégorie Taille
@@ -241,10 +191,9 @@
tutti.table.species.batch.header.comment=Commentaire
tutti.table.species.batch.header.computedNumber=Nombre calculé
tutti.table.species.batch.header.computedWeight=Poids calculé
-tutti.table.species.batch.header.elevationRate=Fraction d'élévation
tutti.table.species.batch.header.file=Pièces jointes
tutti.table.species.batch.header.maturityCategory=Maturité
-tutti.table.species.batch.header.sampleWeight=Poids échantillonné
+tutti.table.species.batch.header.number=Nombre
tutti.table.species.batch.header.sexCategory=Sexe
tutti.table.species.batch.header.sizeCategory=Catégorie Taille
tutti.table.species.batch.header.sortedUnsortedCategory=Vrac / Hors Vrac
Modified: trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyRowModelTest.java
===================================================================
--- trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyRowModelTest.java 2012-12-27 17:52:49 UTC (rev 113)
+++ trunk/tutti-ui-swing/src/test/java/fr/ifremer/tutti/ui/swing/content/operation/species/SpeciesFrequencyRowModelTest.java 2012-12-28 08:34:01 UTC (rev 114)
@@ -24,7 +24,7 @@
* #L%
*/
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesFrequencyRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
import org.junit.Assert;
import org.junit.Test;
1
0
r113 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing/content/operation java/fr/ifremer/tutti/ui/swing/content/protocol java/fr/ifremer/tutti/ui/swing/util resources/i18n
by kmorin@users.forge.codelutin.com 27 Dec '12
by kmorin@users.forge.codelutin.com 27 Dec '12
27 Dec '12
Author: kmorin
Date: 2012-12-27 18:52:49 +0100 (Thu, 27 Dec 2012)
New Revision: 113
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/113
Log:
refs #1810
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.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/FishingOperationsUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2012-12-27 17:49:54 UTC (rev 112)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2012-12-27 17:52:49 UTC (rev 113)
@@ -31,17 +31,15 @@
import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.decorator.Decorator;
-
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Date;
import java.util.List;
-
+import org.apache.commons.lang3.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import static org.nuiton.i18n.I18n._;
+import org.nuiton.util.decorator.Decorator;
/**
* Handler of UI {@link FishingOperationsUI}.
@@ -200,7 +198,7 @@
}
public void saveFishingOperation(FishingOperation toSave) {
-
+
// persist the fishingOperation
boolean create = toSave.getId() == null;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java 2012-12-27 17:49:54 UTC (rev 112)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java 2012-12-27 17:52:49 UTC (rev 113)
@@ -26,10 +26,11 @@
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jdesktop.beans.AbstractSerializableBean;
-import java.util.List;
-
/**
* Model fo UI {@link FishingOperationsUI}.
*
@@ -38,6 +39,8 @@
*/
public class FishingOperationsUIModel extends AbstractSerializableBean {
+ private static final Log log = LogFactory.getLog(FishingOperationsUIModel.class);
+
private static final long serialVersionUID = 1L;
public static final String PROPERTY_FISHING_OPERATION = "fishingOperation";
@@ -57,8 +60,9 @@
}
public void setFishingOperation(List<FishingOperation> fishingOperation) {
+ Object oldValue = getFishingOperation();
this.fishingOperation = fishingOperation;
- firePropertyChange(PROPERTY_FISHING_OPERATION, null, fishingOperation);
+ firePropertyChange(PROPERTY_FISHING_OPERATION, oldValue, fishingOperation);
}
public FishingOperation getSelectedFishingOperation() {
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesRowModel.java (from rev 107, 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/protocol/EditProtocolSpeciesRowModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesRowModel.java 2012-12-27 17:52:49 UTC (rev 113)
@@ -0,0 +1,128 @@
+package fr.ifremer.tutti.ui.swing.content.protocol;
+
+import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import java.util.List;
+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 EditProtocolSpeciesRowModel extends AbstractTuttiBeanUIModel<SpeciesProtocol, EditProtocolSpeciesRowModel> {
+
+ private static final Log log = LogFactory.getLog(EditProtocolSpeciesRowModel.class);
+
+ public static final String PROPERTY_SPECIES = "species";
+
+ public static final String PROPERTY_SORTED_UNSORTED_ENABLED = "sortedUnsortedEnabled";
+
+ public static final String PROPERTY_SIZE_CATEGORY_ENABLED = "sizeCategoryEnabled";
+
+ public static final String PROPERTY_SEX_ENABLED = "sexEnabled";
+
+ public static final String PROPERTY_MATURITY_ENABLED = "maturityEnabled";
+
+ public static final String PROPERTY_SIZE_FRENQUENCY_PMFM = "sizeFrenquencyPmfm";
+
+ protected Species species;
+
+ protected boolean sortedUnsortedEnabled;
+
+ protected boolean sizeCategoryEnabled;
+
+ protected boolean sexEnabled;
+
+ protected boolean maturityEnabled;
+
+ protected Caracteristic sizeFrenquencyPmfm;
+
+ protected static final Binder<SpeciesProtocol, EditProtocolSpeciesRowModel> fromBeanBinder =
+ BinderFactory.newBinder(SpeciesProtocol.class,
+ EditProtocolSpeciesRowModel.class);
+
+ protected static final Binder<EditProtocolSpeciesRowModel, SpeciesProtocol> toBeanBinder =
+ BinderFactory.newBinder(EditProtocolSpeciesRowModel.class,
+ SpeciesProtocol.class);
+
+ public EditProtocolSpeciesRowModel(Species species, Caracteristic sizeFrenquencyPmfm) {
+ super(SpeciesProtocol.class, fromBeanBinder, toBeanBinder);
+ this.species = species;
+ this.sizeFrenquencyPmfm = sizeFrenquencyPmfm;
+ }
+
+ public String getSpeciesId() {
+ return species.getId();
+ }
+
+ public Species getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(Species species) {
+ Object oldValue = getSpecies();
+ this.species = species;
+ firePropertyChange(PROPERTY_SPECIES, oldValue, species);
+ }
+
+ public boolean isSortedUnsortedEnabled() {
+ return sortedUnsortedEnabled;
+ }
+
+ public void setSortedUnsortedEnabled(boolean sortedUnsortedEnabled) {
+ Object oldValue = isSortedUnsortedEnabled();
+ this.sortedUnsortedEnabled = sortedUnsortedEnabled;
+ firePropertyChange(PROPERTY_SORTED_UNSORTED_ENABLED, oldValue, sortedUnsortedEnabled);
+ }
+
+ public boolean isSizeCategoryEnabled() {
+ return sizeCategoryEnabled;
+ }
+
+ public void setSizeCategoryEnabled(boolean sizeCategoryEnabled) {
+ Object oldValue = isSizeCategoryEnabled();
+ this.sizeCategoryEnabled = sizeCategoryEnabled;
+ firePropertyChange(PROPERTY_SIZE_CATEGORY_ENABLED, oldValue, sizeCategoryEnabled);
+ }
+
+ public boolean isSexEnabled() {
+ return sexEnabled;
+ }
+
+ public void setSexEnabled(boolean sexEnabled) {
+ Object oldValue = isSexEnabled();
+ this.sexEnabled = sexEnabled;
+ firePropertyChange(PROPERTY_SEX_ENABLED, oldValue, sexEnabled);
+ }
+
+ public boolean isMaturityEnabled() {
+ return maturityEnabled;
+ }
+
+ public void setMaturityEnabled(boolean maturityEnabled) {
+ Object oldValue = isMaturityEnabled();
+ this.maturityEnabled = maturityEnabled;
+ firePropertyChange(PROPERTY_MATURITY_ENABLED, oldValue, maturityEnabled);
+ }
+
+ public String getSizeFrenquencyPmfmId() {
+ return sizeFrenquencyPmfm != null ? sizeFrenquencyPmfm.getId() : null;
+ }
+
+ public Caracteristic getSizeFrenquencyPmfm() {
+ return sizeFrenquencyPmfm;
+ }
+
+ public void setSizeFrenquencyPmfm(Caracteristic sizeFrenquencyPmfm) {
+ Object oldValue = getSizeFrenquencyPmfm();
+ this.sizeFrenquencyPmfm = sizeFrenquencyPmfm;
+ firePropertyChange(PROPERTY_SIZE_FRENQUENCY_PMFM, oldValue, sizeFrenquencyPmfm);
+ }
+
+}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java (from rev 107, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2012-12-27 17:52:49 UTC (rev 113)
@@ -0,0 +1,59 @@
+package fr.ifremer.tutti.ui.swing.content.protocol;
+
+import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
+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 EditProtocolSpeciesTableModel extends AbstractTuttiTableModel<EditProtocolSpeciesRowModel> {
+
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SPECIES_ID = ColumnIdentifier.newId(
+ EditProtocolSpeciesRowModel.PROPERTY_SPECIES,
+ n_("tutti.table.protocol.species.header.speciesId"),
+ n_("tutti.table.protocol.species.header.speciesId"));
+
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SORTED_UNSORTED_ENABLED = ColumnIdentifier.newId(
+ EditProtocolSpeciesRowModel.PROPERTY_SORTED_UNSORTED_ENABLED,
+ n_("tutti.table.protocol.species.header.sortedUnsorted"),
+ n_("tutti.table.protocol.species.header.sortedUnsorted"));
+
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SIZE_CATEGORY_ENABLED = ColumnIdentifier.newId(
+ EditProtocolSpeciesRowModel.PROPERTY_SIZE_CATEGORY_ENABLED,
+ n_("tutti.table.protocol.species.header.sizeCategory"),
+ n_("tutti.table.protocol.species.header.sizeCategory"));
+
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SEX_ENABLED = ColumnIdentifier.newId(
+ EditProtocolSpeciesRowModel.PROPERTY_SEX_ENABLED,
+ n_("tutti.table.protocol.species.header.sex"),
+ n_("tutti.table.protocol.species.header.sex"));
+
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> MATURITY_ENABLED = ColumnIdentifier.newId(
+ EditProtocolSpeciesRowModel.PROPERTY_MATURITY_ENABLED,
+ n_("tutti.table.protocol.species.header.maturity"),
+ n_("tutti.table.protocol.species.header.maturity"));
+
+ public static final ColumnIdentifier<EditProtocolSpeciesRowModel> SIZE_FRENQUENCY_PMFM_ID = ColumnIdentifier.newId(
+ EditProtocolSpeciesRowModel.PROPERTY_SIZE_FRENQUENCY_PMFM,
+ n_("tutti.table.protocol.species.header.sizeFrequency"),
+ n_("tutti.table.protocol.species.header.sizeFrequency"));
+
+ public EditProtocolSpeciesTableModel(TableColumnModel columnModel) {
+ super(columnModel);
+
+ setNoneEditableCols(SPECIES_ID);
+ }
+
+ @Override
+ protected EditProtocolSpeciesRowModel createNewRow() {
+ EditProtocolSpeciesRowModel result = new EditProtocolSpeciesRowModel(null, null);
+ return result;
+ }
+
+}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2012-12-27 17:49:54 UTC (rev 112)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2012-12-27 17:52:49 UTC (rev 113)
@@ -81,3 +81,28 @@
selectionMode: 0;
model: {errorTableModel};
}
+
+#speciesTable {
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+}
+
+#gearList {
+ bean: {model};
+ property: gearPmfm;
+ border: {BorderFactory.createTitledBorder(_("tutti.label.tab.fishingOperation.gearShooting"))};
+}
+
+#environmentList {
+ bean: {model};
+ property: environmentPmfm;
+ border: {BorderFactory.createTitledBorder(_("tutti.label.tab.fishingOperation.environment"))};
+}
+
+#hydrologyList {
+ bean: {model};
+ property: hydrologyPmfm;
+ border: {BorderFactory.createTitledBorder(_("tutti.label.tab.fishingOperation.hydrology"))};
+}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2012-12-27 17:49:54 UTC (rev 112)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.jaxx 2012-12-27 17:52:49 UTC (rev 113)
@@ -25,15 +25,22 @@
implements='fr.ifremer.tutti.ui.swing.TuttiUI<EditProtocolUIModel, EditProtocolUIHandler>'>
<import>
+ fr.ifremer.tutti.persistence.entities.referential.Caracteristic
fr.ifremer.tutti.persistence.entities.referential.Zone
fr.ifremer.tutti.ui.swing.TuttiUIContext
jaxx.runtime.swing.editor.bean.BeanComboBox
+ jaxx.runtime.swing.editor.bean.BeanDoubleList
jaxx.runtime.validator.swing.SwingValidatorUtil
jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
java.awt.Dimension
-
+ java.awt.Color
+
+ javax.swing.ListSelectionModel
+
+ org.jdesktop.swingx.JXTable
+
static org.nuiton.i18n.I18n._
static jaxx.runtime.SwingUtil.getStringValue
@@ -68,42 +75,83 @@
<JSplitPane id='splitPane' constraints='BorderLayout.CENTER'>
- <Table id='form' fill='both'>
+ <JPanel layout='{new BorderLayout()}'>
+ <JTabbedPane constraints='BorderLayout.CENTER'>
+ <tab title='tutti.label.tab.protocol.info'>
+ <Table id='protocolInfoForm' fill='both'>
- <!-- protocol name -->
- <row>
- <cell anchor='west'>
- <JLabel id='nameLabel'/>
- </cell>
- <cell weightx='1.0'>
- <JTextField id='nameField'
- onKeyReleased='handler.setText(event, "name")'/>
- </cell>
- </row>
+ <!-- protocol name -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='nameLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <JTextField id='nameField'
+ onKeyReleased='handler.setText(event, "name")'/>
+ </cell>
+ </row>
- <!-- program comment -->
- <row weighty='0.8'>
- <cell columns='2'>
- <JScrollPane id='commentPane'
- onFocusGained='commentField.requestFocus()'>
- <JTextArea id='commentField'
- onKeyReleased='handler.setText(event, "comment")'/>
- </JScrollPane>
- </cell>
- </row>
+ <!-- program comment -->
+ <row weighty='0.8'>
+ <cell columns='2'>
+ <JScrollPane id='commentPane'
+ onFocusGained='commentField.requestFocus()'>
+ <JTextArea id='commentField'
+ onKeyReleased='handler.setText(event, "comment")'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ </Table>
+ </tab>
+
+ <tab title='tutti.label.tab.protocol.species'>
+ <Table fill='both'>
+ <row fill='both'>
+ <cell fill='both' weightx='1'>
+ <JComboBox id='newSpeciesRowCombo'/>
+ </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='speciesTable'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ </Table>
+ </tab>
+
+ <tab title='tutti.label.tab.protocol.pmfm'>
+ <Table fill='both' weightx='1'>
+ <row fill='both' weighty='1'>
+ <cell fill='both'>
+ <BeanDoubleList id='gearList' genericType='Caracteristic'/>
+ </cell>
+ </row>
+ <row fill='both' weighty='1'>
+ <cell fill='both'>
+ <BeanDoubleList id='environmentList' genericType='Caracteristic'/>
+ </cell>
+ </row>
+ <row fill='both' weighty='1'>
+ <cell fill='both'>
+ <BeanDoubleList id='hydrologyList' genericType='Caracteristic'/>
+ </cell>
+ </row>
+ </Table>
+ </tab>
+ </JTabbedPane>
- <!-- actions -->
- <row anchor='south'>
- <cell columns='2'>
- <JPanel layout='{new GridLayout(1, 0)}'>
- <JButton id='cancelButton' onActionPerformed='handler.cancel()'/>
- <JButton id='saveButton' onActionPerformed='handler.save()'/>
- </JPanel>
- </cell>
- </row>
- </Table>
-
- <!-- validation messages -->
+ <JPanel layout='{new GridLayout(1, 0)}' constraints='BorderLayout.SOUTH'>
+ <JButton id='cancelButton' onActionPerformed='handler.cancel()'/>
+ <JButton id='saveButton' onActionPerformed='handler.save()'/>
+ </JPanel>
+
+ </JPanel>
<JPanel id='messagePanel' layout='{new GridLayout()}'>
<JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
<JTable id='errorTable' />
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-27 17:49:54 UTC (rev 112)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2012-12-27 17:52:49 UTC (rev 113)
@@ -24,24 +24,50 @@
* #L%
*/
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Multimap;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.util.HydrologicCaracteristicUtil;
+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.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 jaxx.runtime.swing.editor.bean.BeanDoubleList;
import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
+import org.nuiton.util.decorator.JXPathDecorator;
+
/**
* TODO
*
* @author tchemit <chemit(a)codelutin.com>
* @since 0.3
*/
-public class EditProtocolUIHandler extends AbstractTuttiUIHandler<EditProtocolUIModel> {
+public class EditProtocolUIHandler extends AbstractTuttiTableUIHandler<EditProtocolSpeciesRowModel, EditProtocolUIModel> {
/** Logger. */
private static final Log log =
@@ -60,6 +86,12 @@
* @since 0.3
*/
private final PersistenceService persistenceService;
+
+ protected Map<String, Species> allSpecies;
+
+ protected Map<String, Caracteristic> allLengthStepPmfm;
+
+ protected Multimap<String, String> hydroCaracteristics;
public EditProtocolUIHandler(TuttiUIContext context, EditProtocolUI ui) {
super(context);
@@ -68,6 +100,93 @@
}
@Override
+ protected EditProtocolUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
+ protected JXTable getTable() {
+ return ui.getSpeciesTable();
+ }
+
+ @Override
+ protected AbstractTuttiTableModel<EditProtocolSpeciesRowModel> getTableModel() {
+ return (AbstractTuttiTableModel) getTable().getModel();
+ }
+
+ @Override
+ protected void onRowModified(EditProtocolSpeciesRowModel row, String propertyName, Object oldValue, Object newValue) {
+ log.info("onRowModified");
+ ui.getModel().setModify(true);
+ }
+
+ @Override
+ protected void onRowValidStateChanged(EditProtocolSpeciesRowModel row, Boolean oldValue, Boolean newValue) {
+ log.info("onRowValidStateChanged");
+ }
+
+ @Override
+ protected void onRowModifyStateChanged(EditProtocolSpeciesRowModel row, Boolean oldValue, Boolean newValue) {
+ log.info("onRowModifyStateChanged");
+ }
+
+ @Override
+ protected TableColumnModel createTableColumnModel() {
+ JXTable table = ui.getSpeciesTable();
+ DecoratorService decoratorService = context.getService(DecoratorService.class);
+ JXPathDecorator<Caracteristic> decorator =
+ (JXPathDecorator<Caracteristic>) decoratorService.getDecoratorByType(Caracteristic.class);
+ DefaultTableColumnModelExt columnModel = new DefaultTableColumnModelExt();
+
+ {
+
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(Species.class),
+ EditProtocolSpeciesTableModel.SPECIES_ID);
+ }
+
+ {
+
+ addBooleanColumnToModel(columnModel,
+ EditProtocolSpeciesTableModel.SORTED_UNSORTED_ENABLED,
+ table);
+ }
+
+ {
+
+ addBooleanColumnToModel(columnModel,
+ EditProtocolSpeciesTableModel.SIZE_CATEGORY_ENABLED,
+ table);
+ }
+
+ {
+
+ addBooleanColumnToModel(columnModel,
+ EditProtocolSpeciesTableModel.SEX_ENABLED,
+ table);
+ }
+
+ {
+
+ addBooleanColumnToModel(columnModel,
+ EditProtocolSpeciesTableModel.MATURITY_ENABLED,
+ table);
+ }
+
+ {
+
+ addComboDataColumnToModel(columnModel,
+ EditProtocolSpeciesTableModel.SIZE_FRENQUENCY_PMFM_ID,
+ decorator,
+ Lists.newArrayList(allLengthStepPmfm.values()));
+ }
+
+
+ return columnModel;
+ }
+
+ @Override
public void beforeInitUI() {
EditProtocolUIModel model = new EditProtocolUIModel();
@@ -93,6 +212,26 @@
}
listModelIsModify(model);
ui.setContextValue(model);
+
+ List<Species> species = persistenceService.getAllSpecies();
+ allSpecies = Maps.newHashMap();
+ for (Species s : species) {
+ allSpecies.put(s.getId(), s);
+ }
+
+ List<Caracteristic> lengthStepCaracteristics =
+ persistenceService.getAllSpeciesLengthStepCaracteristic();
+ allLengthStepPmfm = Maps.newHashMap();
+ for (Caracteristic c : lengthStepCaracteristics) {
+ allLengthStepPmfm.put(c.getId(), c);
+ }
+
+ List<Caracteristic> hydrologyPmfm = persistenceService.getAllFishingOperationHydrologicCaracteristic();
+ hydroCaracteristics = HashMultimap.create();
+ for (Caracteristic caracteristic : hydrologyPmfm) {
+ String name = HydrologicCaracteristicUtil.getGlobalName(caracteristic.getName());
+ hydroCaracteristics.put(name, caracteristic.getId());
+ }
}
@Override
@@ -106,20 +245,128 @@
new SwingValidatorMessageTableRenderer());
listenValidatorValid(ui.getValidator(), model);
+
+ // Species
+ final JComboBox speciesCombo = ui.getNewSpeciesRowCombo();
+ speciesCombo.setRenderer(newListCellRender(Species.class));
+ speciesCombo.setModel(new DefaultComboBoxModel());
+ for (Species species : allSpecies.values()) {
+ speciesCombo.addItem(species);
+ }
+ speciesCombo.getModel().addListDataListener(new ListDataListener() {
+ public void intervalAdded(ListDataEvent e) {
+ speciesCombo.setEnabled(true);
+ ui.getAddRow().setEnabled(true);
+ }
+
+ public void intervalRemoved(ListDataEvent e) {
+ if (speciesCombo.getItemCount() == 0) {
+ speciesCombo.setEnabled(false);
+ ui.getAddRow().setEnabled(false);
+ }
+ }
+
+ public void contentsChanged(ListDataEvent e) {
+ speciesCombo.setEnabled(true);
+ ui.getAddRow().setEnabled(true);
+ }
+ });
+
+ JXTable table = ui.getSpeciesTable();
+ TableColumnModel columnModel = createTableColumnModel();
+ EditProtocolSpeciesTableModel tableModel =
+ new EditProtocolSpeciesTableModel(columnModel);
+
+ List<SpeciesProtocol> speciesProtocol = model.getSpecies();
+ if (speciesProtocol == null) {
+ speciesProtocol = Lists.newArrayList();
+ }
+ List<EditProtocolSpeciesRowModel> rows = Lists.newArrayList();
+ for (SpeciesProtocol protocol : speciesProtocol) {
+ Species species = allSpecies.get(protocol.getSpeciesId());
+ speciesCombo.removeItem(species);
+ EditProtocolSpeciesRowModel row = new EditProtocolSpeciesRowModel(
+ species,
+ allLengthStepPmfm.get(protocol.getSizeFrenquencyPmfmId()));
+ row.fromBean(protocol);
+ rows.add(row);
+ }
+ tableModel.setRows(rows, false);
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
+ ListSelectionListener listener = new TableRowModificationListener<EditProtocolSpeciesRowModel>(
+ tableModel, getRowMonitor()) {
+
+ @Override
+ protected void saveSelectedRow() {
+ TuttiBeanMonitor<EditProtocolSpeciesRowModel> monitor = getRowMonitor();
+ EditProtocolSpeciesRowModel row = monitor.getBean();
+ if (row != null && monitor.wasModified()) {
+ ui.getModel().setModify(true);
+ }
+ }
+ };
+ table.getSelectionModel().addListSelectionListener(listener);
+
+ // PMFM
+ List<Caracteristic> gearPmfm = persistenceService.getAllFishingOperationGearCaracteristic();
+ initDoubleList(ui.getGearList(), gearPmfm, model.getGearPmfmId());
+ List<Caracteristic> environmentPmfm = persistenceService.getAllFishingOperationEnvironmentCaracteristic();
+ initDoubleList(ui.getEnvironmentList(), environmentPmfm, model.getEnvironmentPmfmId());
+ //hydro
+ List<Caracteristic> selection = Lists.newArrayList();
+ Collection<String> availableCaracteristicNames = hydroCaracteristics.keySet();
+ List<Caracteristic> availableCaracteristics = Lists.newArrayList();
+ for (String name : availableCaracteristicNames) {
+ Caracteristic caracteristic = HydrologicCaracteristicUtil.createGlobalCaracteristic(name);
+ availableCaracteristics.add(caracteristic);
+ }
+ List<String> hydrologyPmfm = model.getHydrologyPmfmId();
+ if (hydrologyPmfm != null) {
+ for (String caracteristicName : availableCaracteristicNames) {
+ Collection<String> ids = hydroCaracteristics.get(caracteristicName);
+ for (String caracteristicId : hydrologyPmfm) {
+ if (ids.contains(caracteristicId)) {
+ Caracteristic caracteristic = HydrologicCaracteristicUtil.createGlobalCaracteristic(caracteristicName);
+ selection.add(caracteristic);
+ break;
+ }
+ }
+ }
+ }
+ DecoratorService decoratorService =
+ context.getService(DecoratorService.class);
+ JXPathDecorator<Caracteristic> decorator =
+ (JXPathDecorator<Caracteristic>) decoratorService.getDecoratorByType(Caracteristic.class);
+ ui.getHydrologyList().init(decorator, availableCaracteristics, selection);
+
// if new protocol can already cancel his creation
model.setModify(model.isCreate());
}
+
+ protected void initDoubleList(BeanDoubleList<Caracteristic> widget,
+ List<Caracteristic> availableCaracteristics,
+ List<String> selectedCaracteristics) {
+ List<Caracteristic> selection = Lists.newArrayList();
+ if (selectedCaracteristics != null) {
+ for (Caracteristic caracteristic : availableCaracteristics) {
+ if (selectedCaracteristics.contains(caracteristic.getId())) {
+ selection.add(caracteristic);
+ }
+ }
+ }
+ DecoratorService decoratorService =
+ context.getService(DecoratorService.class);
+ JXPathDecorator<Caracteristic> decorator =
+ (JXPathDecorator<Caracteristic>) decoratorService.getDecoratorByType(Caracteristic.class);
+ widget.init(decorator, availableCaracteristics, selection);
+ }
@Override
public void onCloseUI() {
}
- @Override
- protected EditProtocolUIModel getModel() {
- return ui.getModel();
- }
-
public void cancel() {
context.setScreen(TuttiScreen.SELECT_CRUISE);
@@ -130,7 +377,25 @@
EditProtocolUIModel model = ui.getModel();
TuttiProtocol bean = model.toBean();
-
+
+ // get the species protocols from the table
+ List<SpeciesProtocol> protocols = Lists.newArrayList();
+ List<EditProtocolSpeciesRowModel> rows =
+ ((AbstractTuttiTableModel<EditProtocolSpeciesRowModel>)ui.getSpeciesTable().getModel()).getRows();
+ for (EditProtocolSpeciesRowModel row : rows) {
+ SpeciesProtocol protocol = row.toBean();
+ protocols.add(protocol);
+ }
+ bean.setSpecies(protocols);
+
+ // split the hydro grouped pmfm
+ List<String> hydroPmfm = bean.getHydrologyPmfmId();
+ List<String> allIds = Lists.newArrayList();
+ for (String id : hydroPmfm) {
+ allIds.addAll(hydroCaracteristics.get(id));
+ }
+ bean.setHydrologyPmfmId(allIds);
+
TuttiProtocol saved;
if (TuttiEntities.isNew(bean)) {
@@ -143,4 +408,18 @@
context.setScreen(TuttiScreen.SELECT_CRUISE);
}
+
+ public void addRow() {
+ JComboBox<Species> speciesCombo = ui.getNewSpeciesRowCombo();
+ Species species = (Species) speciesCombo.getSelectedItem();
+ EditProtocolSpeciesRowModel protocol = new EditProtocolSpeciesRowModel(species, null);
+ protocol.setMaturityEnabled(true);
+ protocol.setSizeCategoryEnabled(true);
+ protocol.setSexEnabled(true);
+ protocol.setSortedUnsortedEnabled(true);
+
+ getTableModel().addNewRow(getTable().getRowCount(), protocol);
+ speciesCombo.removeItem(species);
+ ui.getModel().setModify(true);
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2012-12-27 17:49:54 UTC (rev 112)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2012-12-27 17:52:49 UTC (rev 113)
@@ -24,8 +24,12 @@
* #L%
*/
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
-import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
+import java.util.List;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -33,18 +37,34 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.3
*/
-public class EditProtocolUIModel extends AbstractTuttiBeanUIModel<TuttiProtocol, EditProtocolUIModel> {
+public class EditProtocolUIModel extends AbstractTuttiTableUIModel<TuttiProtocol, EditProtocolSpeciesRowModel, EditProtocolUIModel> {
private static final long serialVersionUID = 1L;
public static final String PROPERTY_COMMENT = "comment";
public static final String PROPERTY_NAME = "name";
+
+ public static final String PROPERTY_GEAR_PMFM_ID = "gearPmfmId";
+ public static final String PROPERTY_ENVIRONMENT_PMFM_ID = "environmentPmfmId";
+
+ public static final String PROPERTY_HYDROLOGY_PMFM_ID = "hydrologyPmfmId";
+
+ public static final String PROPERTY_SPECIES = "species";
+
protected String name;
protected String comment;
+
+ protected List<String> gearPmfmId;
+ protected List<String> environmentPmfmId;
+
+ protected List<String> hydrologyPmfmId;
+
+ protected List<SpeciesProtocol> species;
+
protected static Binder<EditProtocolUIModel, TuttiProtocol> toBeanBinder =
BinderFactory.newBinder(EditProtocolUIModel.class,
TuttiProtocol.class);
@@ -77,4 +97,67 @@
firePropertyChange(PROPERTY_COMMENT, oldValue, comment);
}
+ public List<String> getGearPmfmId() {
+ return gearPmfmId;
+ }
+
+ public void setGearPmfmId(List<String> gearPmfmId) {
+ Object oldValue = getGearPmfmId();
+ this.gearPmfmId = gearPmfmId;
+ firePropertyChange(PROPERTY_GEAR_PMFM_ID, oldValue, gearPmfmId);
+ }
+
+ public void setGearPmfm(List<Caracteristic> gearPmfm) {
+ List<String> gearPmfmId = Lists.newArrayList();
+ for (Caracteristic caracteristic : gearPmfm) {
+ gearPmfmId.add(caracteristic.getId());
+ }
+ setGearPmfmId(gearPmfmId);
+ }
+
+ public List<String> getEnvironmentPmfmId() {
+ return environmentPmfmId;
+ }
+
+ public void setEnvironmentPmfmId(List<String> environmentPmfmId) {
+ Object oldValue = getEnvironmentPmfmId();
+ this.environmentPmfmId = environmentPmfmId;
+ firePropertyChange(PROPERTY_ENVIRONMENT_PMFM_ID, oldValue, environmentPmfmId);
+ }
+
+ public void setEnvironmentPmfm(List<Caracteristic> environmentPmfm) {
+ List<String> environmentPmfmId = Lists.newArrayList();
+ for (Caracteristic caracteristic : environmentPmfm) {
+ environmentPmfmId.add(caracteristic.getId());
+ }
+ setEnvironmentPmfmId(environmentPmfmId);
+ }
+
+ public List<String> getHydrologyPmfmId() {
+ return hydrologyPmfmId;
+ }
+
+ public void setHydrologyPmfmId(List<String> hydrologyPmfmId) {
+ Object oldValue = getHydrologyPmfmId();
+ this.hydrologyPmfmId = hydrologyPmfmId;
+ firePropertyChange(PROPERTY_HYDROLOGY_PMFM_ID, oldValue, hydrologyPmfmId);
+ }
+
+ public void setHydrologyPmfm(List<Caracteristic> hydrologyPmfm) {
+ List<String> hydrologyPmfmId = Lists.newArrayList();
+ for (Caracteristic caracteristic : hydrologyPmfm) {
+ hydrologyPmfmId.add(caracteristic.getId());
+ }
+ setHydrologyPmfmId(hydrologyPmfmId);
+ }
+
+ public List<SpeciesProtocol> getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(List<SpeciesProtocol> species) {
+ Object oldValue = getSpecies();
+ this.species = species;
+ firePropertyChange(PROPERTY_SPECIES, oldValue, species);
+ }
}
\ No newline at end of file
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/HydrologicCaracteristicUtil.java 2012-12-27 17:52:49 UTC (rev 113)
@@ -0,0 +1,25 @@
+
+package fr.ifremer.tutti.ui.swing.util;
+
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+
+/**
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ */
+public class HydrologicCaracteristicUtil {
+
+ public static String getGlobalName(String name) {
+ if (name.charAt(name.length() - 2) == '_') {
+ name = name.substring(0, name.length() - 2);
+ }
+ return name;
+ }
+
+ public static Caracteristic createGlobalCaracteristic(String name) {
+ Caracteristic caracteristic = new Caracteristic();
+ caracteristic.setName(name);
+ caracteristic.setId(name);
+ return caracteristic;
+ }
+}
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-27 17:49:54 UTC (rev 112)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2012-12-27 17:52:49 UTC (rev 113)
@@ -146,6 +146,9 @@
tutti.label.tab.macroDechet=Macro déchets
tutti.label.tab.observationIndividuel=Observations individuelles
tutti.label.tab.plancton=Plancton
+tutti.label.tab.protocol.info=Informations générales
+tutti.label.tab.protocol.pmfm=PMFM
+tutti.label.tab.protocol.species=Espèces
tutti.label.tab.species=Espèces
tutti.label.traitReminder=Trait \: %s
tutti.legend.catch.benthos=Benthos
@@ -228,6 +231,12 @@
tutti.table.plankton.batch.header.speciesByGenusCode=Espèce
tutti.table.plankton.batch.header.toConfirm=A Confirmer
tutti.table.plankton.batch.header.weight=Poids
+tutti.table.protocol.species.header.maturity=Maturité
+tutti.table.protocol.species.header.sex=Sexe
+tutti.table.protocol.species.header.sizeCategory=Catégorie Taille
+tutti.table.protocol.species.header.sizeFrequency=Fréquence Taile
+tutti.table.protocol.species.header.sortedUnsorted=Vrac / Hors Vrac
+tutti.table.protocol.species.header.speciesId=Espèce
tutti.table.species.batch.header.age=Age
tutti.table.species.batch.header.comment=Commentaire
tutti.table.species.batch.header.computedNumber=Nombre calculé
1
0
r112 - trunk/tutti-service/src/main/java/fr/ifremer/tutti/service
by kmorin@users.forge.codelutin.com 27 Dec '12
by kmorin@users.forge.codelutin.com 27 Dec '12
27 Dec '12
Author: kmorin
Date: 2012-12-27 18:49:54 +0100 (Thu, 27 Dec 2012)
New Revision: 112
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/112
Log:
add species protocol to decoratorservice
Modified:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2012-12-27 14:49:03 UTC (rev 111)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2012-12-27 17:49:54 UTC (rev 112)
@@ -28,6 +28,7 @@
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
@@ -101,6 +102,7 @@
registerMultiJXPathDecorator(Species.class, "${codeMemo}$s#${genusSpecies}$s", SEPARATOR, " - ");
registerMultiJXPathDecorator(Species.class, SPECIES_BY_CODE, "${codeMemo}$s", SEPARATOR, " - ");
registerMultiJXPathDecorator(Species.class, SPECIES_BY_GENUS, "${genusSpecies}$s", SEPARATOR, " - ");
+ registerMultiJXPathDecorator(SpeciesProtocol.class, "${speciesId}", SEPARATOR, " - ");
registerMultiJXPathDecorator(Attachment.class, "${name}$s", SEPARATOR, " - ");
}
};
1
0