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
January 2013
- 4 participants
- 143 discussions
r137 - in trunk/tutti-ui-swing/src/main: java/fr/ifremer/tutti/ui/swing java/fr/ifremer/tutti/ui/swing/content/operation/catches/species java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split java/fr/ifremer/tutti/ui/swing/util resources/i18n
by tchemit@users.forge.codelutin.com 01 Jan '13
by tchemit@users.forge.codelutin.com 01 Jan '13
01 Jan '13
Author: tchemit
Date: 2013-01-02 00:04:02 +0100 (Wed, 02 Jan 2013)
New Revision: 137
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/137
Log:
refs #1805: [Onglet Poisson] Assistance ?\195?\160 la saisie des lots de poissons (ajout creation lot esp?\195?\168ce) + am?\195?\169lioration des dialog
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.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/operation/catches/species/frequency/FrequencyCellComponent.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/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.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/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/AbstractTuttiUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -30,9 +30,12 @@
import fr.ifremer.tutti.persistence.entities.IdAware;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.ui.swing.config.TuttiConfig;
+import fr.ifremer.tutti.ui.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.UIMessageNotifier;
import fr.ifremer.tutti.ui.swing.util.editor.SimpleTimeEditor;
+import jaxx.runtime.JAXXUtil;
+import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.editor.NumberEditor;
import jaxx.runtime.swing.editor.bean.BeanComboBox;
import jaxx.runtime.swing.editor.bean.BeanDoubleList;
@@ -45,14 +48,24 @@
import org.nuiton.util.decorator.JXPathDecorator;
import org.nuiton.validator.bean.simple.SimpleBeanValidator;
+import javax.swing.AbstractAction;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
import javax.swing.JList;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.text.JTextComponent;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.KeyEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
@@ -87,6 +100,10 @@
this.context = context;
}
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
@Override
public void showInformationMessage(String message) {
context.showInformationMessage(message);
@@ -137,6 +154,62 @@
}
}
+ public void openDialog(TuttiUI ui,
+ TuttiUI dialogContent,
+ String title, Dimension dim) {
+ Frame frame = SwingUtil.getParentContainer(ui, Frame.class);
+
+ JDialog result = new JDialog(frame, true);
+ result.setTitle(title);
+ result.add((Component) dialogContent);
+ result.setResizable(true);
+
+ result.setSize(dim);
+
+ final AbstractTuttiUIHandler handler = dialogContent.getHandler();
+
+ if (handler instanceof Cancelable) {
+
+ // add a auto-close action
+ JRootPane rootPane = result.getRootPane();
+
+ KeyStroke shortcutClosePopup = getConfig().getShortcutClosePopup();
+
+ rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+ shortcutClosePopup, "close");
+ rootPane.getActionMap().put("close", new AbstractAction() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ ((Cancelable) handler).cancel();
+ }
+ });
+ }
+
+ result.addWindowListener(new WindowAdapter() {
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ Component ui = (Component) e.getSource();
+ if (log.isInfoEnabled()) {
+ log.info("Destroy ui " + ui);
+ }
+ JAXXUtil.destroy(ui);
+ }
+ });
+ SwingUtil.center(frame, result);
+ result.setVisible(true);
+ }
+
+ public void closeDialog(TuttiUI ui) {
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
protected void initUI(TuttiUI ui) {
for (Map.Entry<String, Object> entry : ui.get$objectMap().entrySet()) {
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 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -97,6 +97,14 @@
public static final String PROPERTY_ATTACHMENTS = "attachments";
+ public static final String PROPERTY_BATCH_PARENT = "batchParent";
+
+ public static final String PROPERTY_BATCH_CHILD = "batchChild";
+
+ public static final String PROPERTY_BATCH_LEAF = "batchLeaf";
+
+ public static final String PROPERTY_BATCH_ROOT = "batchRoot";
+
/**
* Is catch is vrac or horsVrac?.
*
@@ -195,6 +203,22 @@
*/
protected List<SpeciesFrequencyRowModel> frequency;
+ /**
+ * Parent of this batch (can be null if batch is root).
+ *
+ * @see #isBatchRoot()
+ * @since 0.3
+ */
+ protected SpeciesBatchRowModel batchParent;
+
+ /**
+ * List of child batches (can be null or empty if batch is a leaf).
+ *
+ * @see #isBatchLeaf()
+ * @since 0.3
+ */
+ protected List<SpeciesBatchRowModel> batchChild;
+
protected static final Binder<SpeciesBatch, SpeciesBatchRowModel> fromBeanBinder =
BinderFactory.newBinder(SpeciesBatch.class,
SpeciesBatchRowModel.class);
@@ -419,6 +443,36 @@
firePropertyChange(PROPERTY_FREQUENCY, null, frequency);
}
+ public SpeciesBatchRowModel getBatchParent() {
+ return batchParent;
+ }
+
+ public void setBatchParent(SpeciesBatchRowModel batchParent) {
+ Object oldValue = getBatchParent();
+ this.batchParent = batchParent;
+ firePropertyChange(PROPERTY_BATCH_PARENT, oldValue, batchParent);
+ firePropertyChange(PROPERTY_BATCH_ROOT, null, isBatchRoot());
+ }
+
+ public List<SpeciesBatchRowModel> getBatchChild() {
+ return batchChild;
+ }
+
+ public void setChilds(List<SpeciesBatchRowModel> batchChild) {
+ this.batchChild = batchChild;
+ // force to propagate child changes
+ firePropertyChange(PROPERTY_BATCH_CHILD, null, batchChild);
+ firePropertyChange(PROPERTY_BATCH_LEAF, null, isBatchLeaf());
+ }
+
+ public boolean isBatchLeaf() {
+ return CollectionUtils.isEmpty(batchChild);
+ }
+
+ public boolean isBatchRoot() {
+ return batchParent == null;
+ }
+
public Float getComputedWeight() {
return computedWeight;
}
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 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -45,16 +45,15 @@
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.content.operation.catches.species.split.CreateSpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.CreateSpeciesBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
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.AbstractSelectTableAction;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
-import jaxx.runtime.SwingUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -65,7 +64,6 @@
import javax.swing.SwingUtilities;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
-import java.awt.Frame;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.io.Serializable;
@@ -236,82 +234,6 @@
// when row valid state has changed, recompute action enabled states
recomputeBatchActionEnable();
-
-
-// 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
@@ -354,7 +276,6 @@
@Override
protected void onModelRowsChanged(List<SpeciesBatchRowModel> rows) {
super.onModelRowsChanged(rows);
-
// build the new sampling tree from the new rows to edit
// getModel().getSamplingTreeModel().populate(rows);
}
@@ -478,7 +399,8 @@
JXTable table = getTable();
// create table column model
- TableCellRenderer defaultRenderer = table.getDefaultRenderer(Object.class);
+ TableCellRenderer defaultRenderer =
+ table.getDefaultRenderer(Object.class);
DefaultTableColumnModelExt columnModel =
new DefaultTableColumnModelExt();
@@ -556,7 +478,7 @@
{ // Computed weight column (from frequencies)
addColumnToModel(columnModel,
- FrequencyCellComponent.newEditor(ui.getFrequencyEditor()),
+ FrequencyCellComponent.newEditor(ui),
FrequencyCellComponent.newRender(),
SpeciesBatchTableModel.COMPUTED_WEIGHT);
}
@@ -564,7 +486,7 @@
{ // Computed number column (from frequencies)
addColumnToModel(columnModel,
- FrequencyCellComponent.newEditor(ui.getFrequencyEditor()),
+ FrequencyCellComponent.newEditor(ui),
FrequencyCellComponent.newRender(),
SpeciesBatchTableModel.COMPUTED_NUMBER);
}
@@ -650,6 +572,41 @@
public void createSpeciesBatch() {
+ CreateSpeciesBatchUI createBatchEditor =
+ ui.getCreateSpeciesBatchUI();
+
+ createBatchEditor.getHandler().openUI(getModel());
+
+ openDialog(ui,
+ createBatchEditor,
+ _("tutti.title.createBatch"),
+ ui.getPreferredSize());
+
+ CreateSpeciesBatchUIModel createModel = createBatchEditor.getModel();
+
+ if (createModel.isValid()) {
+
+ SpeciesBatchTableModel tableModel = getTableModel();
+
+ SpeciesBatchRowModel newRow = tableModel.createNewRow();
+ newRow.setSpecies(createModel.getSpecies());
+ newRow.setWeight(createModel.getBatchWeight());
+
+ recomputeRowValidState(newRow);
+
+ tableModel.addNewRow(newRow);
+
+ saveRow(newRow);
+
+ // update available species list
+ getModel().getAvailableSpecies().remove(newRow.getSpecies());
+
+ }
+
+ // reset create ui
+ createBatchEditor.getHandler().openUI(null);
+
+ recomputeBatchActionEnable();
}
public void splitSpeciesBatch() {
@@ -658,104 +615,145 @@
// get selected row
int rowIndex = table.getSelectedRow();
- SpeciesBatchRowModel selectedRow = getTableModel().getEntry(rowIndex);
+ Preconditions.checkState(rowIndex != -1,
+ "Cant split batch if no batch selected");
+
+ SpeciesBatchTableModel tableModel = getTableModel();
+
+ SpeciesBatchRowModel parentBatch = tableModel.getEntry(rowIndex);
+
if (log.isInfoEnabled()) {
- log.info("Open split batch for row [" + rowIndex + "]");
+ log.info("Open split batch ui for row [" + rowIndex + "]");
}
- SplitSpeciesBatchUI sampleCategoryEditor = ui.getSplitSpeciesBatchUI();
- sampleCategoryEditor.getHandler().editBatch(selectedRow);
+ SplitSpeciesBatchUI splitBatchEditor = ui.getSplitSpeciesBatchUI();
+ splitBatchEditor.getHandler().editBatch(parentBatch);
- Frame frame = SwingUtil.getParentContainer(ui, Frame.class);
+ openDialog(ui,
+ splitBatchEditor,
+ _("tutti.title.splitBatch"),
+ ui.getPreferredSize());
- // open split batch dialog
- TuttiUIUtil.openInDialog(sampleCategoryEditor,
- frame,
- _("tutti.title.splitBatch"), true, null);
-
// at close, synch back batches ?
- SplitSpeciesBatchUIModel splitModel = sampleCategoryEditor.getModel();
+ SplitSpeciesBatchUIModel splitModel = splitBatchEditor.getModel();
if (splitModel.isValid()) {
// create batch rows
- SpeciesBatchTableModel batchTableModel = getTableModel();
-
int insertRow = rowIndex;
SampleCategoryType selectedCategory = splitModel.getSelectedCategory();
// Create rows in batch table model
- List<SpeciesBatchRowModel> newBatchRows = Lists.newArrayList();
+ List<SpeciesBatchRowModel> newBatches = Lists.newArrayList();
for (SplitSpeciesBatchRowModel row : splitModel.getRows()) {
if (row.isValid()) {
// can keep this row
- SpeciesBatchRowModel batchNewRow = batchTableModel.createNewRow();
- batchNewRow.setSpecies(selectedRow.getSpecies());
- batchNewRow.setSpeciesToConfirm(selectedRow.getSpeciesToConfirm());
+ SpeciesBatchRowModel newBatch = tableModel.createNewRow();
+ newBatch.setSpecies(parentBatch.getSpecies());
+ newBatch.setSpeciesToConfirm(parentBatch.getSpeciesToConfirm());
if (selectedCategory == SampleCategoryType.sortedUnsorted) {
- batchNewRow.setSortedUnsortedCategory((CaracteristicQualitativeValue) row.getCategoryValue());
- batchNewRow.setSortedUnsortedCategoryWeight(row.getWeight());
+ newBatch.setSortedUnsortedCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ newBatch.setSortedUnsortedCategoryWeight(row.getWeight());
} else {
- batchNewRow.setSortedUnsortedCategory(selectedRow.getSortedUnsortedCategory());
- batchNewRow.setSortedUnsortedCategoryWeight(selectedRow.getSortedUnsortedCategoryWeight());
+ newBatch.setSortedUnsortedCategory(parentBatch.getSortedUnsortedCategory());
+ newBatch.setSortedUnsortedCategoryWeight(parentBatch.getSortedUnsortedCategoryWeight());
}
if (selectedCategory == SampleCategoryType.size) {
- batchNewRow.setSizeCategory((CaracteristicQualitativeValue) row.getCategoryValue());
- batchNewRow.setSizeCategoryWeight(row.getWeight());
+ newBatch.setSizeCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ newBatch.setSizeCategoryWeight(row.getWeight());
} else {
- batchNewRow.setSizeCategory(selectedRow.getSizeCategory());
- batchNewRow.setSizeCategoryWeight(selectedRow.getSizeCategoryWeight());
+ newBatch.setSizeCategory(parentBatch.getSizeCategory());
+ newBatch.setSizeCategoryWeight(parentBatch.getSizeCategoryWeight());
}
if (selectedCategory == SampleCategoryType.sex) {
- batchNewRow.setSexCategory((CaracteristicQualitativeValue) row.getCategoryValue());
- batchNewRow.setSexCategoryWeight(row.getWeight());
+ newBatch.setSexCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ newBatch.setSexCategoryWeight(row.getWeight());
} else {
- batchNewRow.setSexCategory(selectedRow.getSexCategory());
- batchNewRow.setSexCategoryWeight(selectedRow.getSexCategoryWeight());
+ newBatch.setSexCategory(parentBatch.getSexCategory());
+ newBatch.setSexCategoryWeight(parentBatch.getSexCategoryWeight());
}
if (selectedCategory == SampleCategoryType.maturity) {
- batchNewRow.setMaturityCategory((CaracteristicQualitativeValue) row.getCategoryValue());
- batchNewRow.setMaturityCategoryWeight(row.getWeight());
+ newBatch.setMaturityCategory((CaracteristicQualitativeValue) row.getCategoryValue());
+ newBatch.setMaturityCategoryWeight(row.getWeight());
} else {
- batchNewRow.setMaturityCategory(selectedRow.getMaturityCategory());
- batchNewRow.setMaturityCategoryWeight(selectedRow.getMaturityCategoryWeight());
+ newBatch.setMaturityCategory(parentBatch.getMaturityCategory());
+ newBatch.setMaturityCategoryWeight(parentBatch.getMaturityCategoryWeight());
}
if (selectedCategory == SampleCategoryType.age) {
- batchNewRow.setAgeCategory((Float) row.getCategoryValue());
- batchNewRow.setAgeCategoryWeight(row.getWeight());
+ newBatch.setAgeCategory((Float) row.getCategoryValue());
+ newBatch.setAgeCategoryWeight(row.getWeight());
} else {
- batchNewRow.setAgeCategory(selectedRow.getAgeCategory());
- batchNewRow.setAgeCategoryWeight(selectedRow.getAgeCategoryWeight());
+ newBatch.setAgeCategory(parentBatch.getAgeCategory());
+ newBatch.setAgeCategoryWeight(parentBatch.getAgeCategoryWeight());
}
- batchTableModel.addNewRow(++insertRow, batchNewRow);
- boolean rowValid = isRowValid(batchNewRow);
- batchNewRow.setValid(rowValid);
- saveRow(batchNewRow);
+ tableModel.addNewRow(++insertRow, newBatch);
+ boolean rowValid = isRowValid(newBatch);
+ newBatch.setValid(rowValid);
+ newBatch.setBatchParent(parentBatch);
+ newBatches.add(newBatch);
}
}
+ // add new batches to his parent
+ parentBatch.setChilds(newBatches);
+
+ //TODO Should only save parentBatch (will persist all his childs)
+ //saveRow(parentBatch);
+
+ // save new batches
+ saveRows(newBatches);
}
// reset split ui
- sampleCategoryEditor.getHandler().editBatch(null);
+ splitBatchEditor.getHandler().editBatch(null);
+ recomputeBatchActionEnable();
- // reselect this cell
- AbstractSelectTableAction.doSelectCell(table, rowIndex, 0);
- table.requestFocus();
+// // reselect this cell
+// AbstractSelectTableAction.doSelectCell(table, rowIndex, 0);
+// table.requestFocus();
}
public void removeSpeciesSubBatch() {
//TODO
+ int rowIndex = getTable().getSelectedRow();
+
+ Preconditions.checkState(rowIndex != -1,
+ "Cant remove sub batch if no batch selected");
+
+ SpeciesBatchRowModel parentBatch = getTableModel().getEntry(rowIndex);
+
+ // collect of rows to remove from model
+ Set<SpeciesBatchRowModel> rowToRemove = Sets.newHashSet();
+ collectChilds(parentBatch, rowToRemove);
+
+ // remove all rows from the model
+ getModel().getRows().removeAll(rowToRemove);
+
+ // remove childs from parent batch
+ parentBatch.setChilds(null);
+
+ // save parent batch (will destroy all his childs from db)
+ saveRow(parentBatch);
+
+ // refresh table from parent batch row index to the end
+ getTableModel().fireTableRowsUpdated(rowIndex,
+ getTableModel().getRowCount() - 1);
}
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
+ protected void saveRows(Iterable<SpeciesBatchRowModel> rows) {
+ for (SpeciesBatchRowModel row : rows) {
+ saveRow(row);
+ }
+ }
+
protected void saveRow(SpeciesBatchRowModel row) {
SpeciesBatch catchBean = row.toBean();
@@ -792,50 +790,6 @@
row.setFrequency(frequencyRows);
}
-// 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());
-// }
-
protected void recomputeTotalHorsVrac() {
// recompute total hors vrac
@@ -873,6 +827,7 @@
// getModel().setTotalVracWeight(totalVrac);
}
+
protected void recomputeBatchActionEnable() {
int rowIndex = getTable().getSelectedRow();
@@ -903,13 +858,15 @@
if (enableSplit) {
- // the select batch can not have any batch child
+ // can split if selected batch is a leaf
+ enableSplit = row.isBatchLeaf();
}
if (enableRemove) {
- // the selected batch must have some batch child
+ // can remove sub batch if selected batch is not a leaf
+ enableRemove = !row.isBatchLeaf();
}
}
getModel().setCreateSpeciesBatchEnabled(enableAdd);
@@ -918,6 +875,18 @@
}
+ protected void collectChilds(SpeciesBatchRowModel row,
+ Set<SpeciesBatchRowModel> collectedRows) {
+
+ if (!row.isBatchLeaf()) {
+
+ for (SpeciesBatchRowModel batchChild : row.getBatchChild()) {
+ collectedRows.add(batchChild);
+ collectChilds(batchChild, collectedRows);
+ }
+ }
+ }
+
protected <C extends Serializable> void addSampleCategoryColumnToModel(TableColumnModel columnModel,
ColumnIdentifier<SpeciesBatchRowModel> columnIdentifier,
Decorator<C> decorator,
@@ -927,4 +896,49 @@
SampleCategoryComponent.newRender(defaultRenderer, decorator),
columnIdentifier);
}
+
+
+// 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());
+// }
}
Modified: 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/FrequencyCellComponent.java 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/FrequencyCellComponent.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -25,9 +25,10 @@
*/
import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
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.content.operation.catches.species.SpeciesBatchUI;
import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import jaxx.runtime.SwingUtil;
@@ -42,11 +43,11 @@
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 java.util.List;
import static org.nuiton.i18n.I18n._;
@@ -76,7 +77,7 @@
return new FrequencyCellRenderer();
}
- public static TableCellEditor newEditor(SpeciesFrequencyUI ui) {
+ public static TableCellEditor newEditor(SpeciesBatchUI ui) {
return new FrequencyCellEditor(ui);
}
@@ -86,10 +87,8 @@
protected final FrequencyCellComponent component;
- protected final SpeciesFrequencyUI ui;
+ protected final SpeciesBatchUI ui;
- protected Frame frame;
-
protected JTable table;
protected SpeciesBatchTableModel tableModel;
@@ -102,7 +101,7 @@
protected Integer columnIndex;
- public FrequencyCellEditor(SpeciesFrequencyUI ui) {
+ public FrequencyCellEditor(SpeciesBatchUI ui) {
this.ui = ui;
component = new FrequencyCellComponent();
component.setBorder(new LineBorder(Color.BLACK));
@@ -138,20 +137,44 @@
log.info("Will edit frequencies for row: " + rowIndex);
}
- if (frame == null) {
- frame = SwingUtil.getParentContainer(ui, Frame.class);
- }
+ SpeciesFrequencyUI frequencyEditor = ui.getFrequencyEditor();
+ frequencyEditor.editBatch(editRow);
- ui.editBatch(editRow);
-
// open frequency dialog
- TuttiUIUtil.openInDialog(
- ui, frame, _("tutti.title.frequency"), true, null);
+ ui.getHandler().openDialog(ui,
+ frequencyEditor,
+ _("tutti.title.frequency"),
+ ui.getPreferredSize());
- // at close, synch back frequencies
+ SpeciesFrequencyUIModel frequencyModel = frequencyEditor.getModel();
- editRow.updateTotalFromFrequencies();
+ if (frequencyModel.isValid()) {
+ // at close, synch back frequencies
+
+ // transfer rows to editor
+ List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList();
+ for (SpeciesFrequencyRowModel row : frequencyModel.getRows()) {
+ if (row.isValid()) {
+
+ // can keep this row
+ frequency.add(row);
+ }
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Push back " + frequency.size() +
+ " frequency to batch " + frequencyModel.getBatch());
+ }
+
+ // push back to batch
+ editRow.setFrequency(frequency);
+
+ editRow.updateTotalFromFrequencies();
+ }
+
+ frequencyEditor.editBatch(null);
+
int r = rowIndex;
int c = columnIndex;
Modified: 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.css 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2013-01-01 23:04:02 UTC (rev 137)
@@ -35,7 +35,7 @@
#splitPane {
orientation: {JSplitPane.VERTICAL_SPLIT};
- resizeWeight: 0.8;
+ resizeWeight: 0.2;
oneTouchExpandable: true;
continuousLayout: true;
}
Modified: 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/SpeciesFrequencyUIHandler.java 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -31,17 +31,17 @@
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.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
-import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
+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.table.DefaultTableColumnModelExt;
-import javax.swing.JDialog;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
@@ -54,7 +54,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.2
*/
-public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<SpeciesFrequencyRowModel, SpeciesFrequencyUIModel> {
+public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<SpeciesFrequencyRowModel, SpeciesFrequencyUIModel> implements Cancelable {
/** Logger. */
private static final Log log =
@@ -253,6 +253,27 @@
}
//------------------------------------------------------------------------//
+ //-- Cancelable methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void cancel() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Cancel UI " + ui);
+ }
+
+ // evict model from validator
+ ui.getValidator().setBean(null);
+
+ // when canceling always invalid model (in that way)
+ getModel().setValid(false);
+
+ // close dialog
+ closeDialog(ui);
+ }
+
+ //------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
@@ -352,8 +373,11 @@
newRow.setComputedWeight(rowModel.getComputedWeight());
editFrequency.add(newRow);
}
- lengthStepCaracteristic =
- frequency.get(0).getLengthStepCaracteristic();
+
+ if (CollectionUtils.isNotEmpty(frequency)) {
+ lengthStepCaracteristic =
+ frequency.get(0).getLengthStepCaracteristic();
+ }
}
if (log.isInfoEnabled()) {
@@ -363,6 +387,9 @@
SpeciesFrequencyUIModel model = getModel();
+ // connect model to validator
+ ui.getValidator().setBean(model);
+
model.setRows(editFrequency);
if (lengthStepCaracteristic == null) {
@@ -387,49 +414,13 @@
model.setBatch(speciesBatch);
}
- public void cancel() {
-
- if (log.isInfoEnabled()) {
- log.info("Cancel UI " + ui);
- }
-
- // when canceling always invalid model (in that way)
- getModel().setValid(false);
-
- ui.editBatch(null);
-
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
- }
-
public void save() {
if (log.isInfoEnabled()) {
- log.info("Will Save and close UI " + ui);
+ log.info("Save 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);
+ closeDialog(ui);
}
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css 2013-01-01 23:04:02 UTC (rev 137)
@@ -36,7 +36,7 @@
#splitPane {
orientation: {JSplitPane.VERTICAL_SPLIT};
- resizeWeight: 0.8;
+ resizeWeight: 0.2;
oneTouchExpandable: true;
continuousLayout: true;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx 2013-01-01 23:04:02 UTC (rev 137)
@@ -75,7 +75,7 @@
<field name='batchWeight' component='batchWeightField'/>
</BeanValidator>
- <JSplitPane id='splitPane' constraints='BorderLayout.CENTER'>
+ <JSplitPane id='splitPane' constraints='BorderLayout.NORTH'>
<Table id='configurationPanel' fill='both'>
@@ -113,7 +113,8 @@
<!-- Messages report -->
<JPanel id='messagePanel' layout='{new GridLayout()}'>
- <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
+ <JScrollPane id='errorTableScrollPane'
+ columnHeaderView='{errorTable.getTableHeader()}'>
<JTable id='errorTable'/>
</JScrollPane>
</JPanel>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -29,13 +29,12 @@
import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel;
-import jaxx.runtime.SwingUtil;
+import fr.ifremer.tutti.ui.swing.util.Cancelable;
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 javax.swing.JDialog;
import java.util.List;
/**
@@ -44,7 +43,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.3
*/
-public class CreateSpeciesBatchUIHandler extends AbstractTuttiUIHandler<CreateSpeciesBatchUIModel> {
+public class CreateSpeciesBatchUIHandler extends AbstractTuttiUIHandler<CreateSpeciesBatchUIModel> implements Cancelable {
/** Logger. */
private static final Log log =
@@ -104,15 +103,42 @@
}
//------------------------------------------------------------------------//
+ //-- Cancelable methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void cancel() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Cancel UI " + ui);
+ }
+
+ // evict model from validator
+ ui.getValidator().setBean(null);
+
+ // when canceling always invalid model
+ getModel().setValid(false);
+
+ // close dialog
+ closeDialog(ui);
+ }
+
+ //------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
- public void editBatch(SpeciesBatchUIModel batchModel) {
+ public void openUI(SpeciesBatchUIModel batchModel) {
- getModel().setSpecies(null);
- getModel().setBatchWeight(null);
+ CreateSpeciesBatchUIModel model = getModel();
+ // connect model to validator
+ ui.getValidator().setBean(model);
+
+ model.setSpecies(null);
+ model.setBatchWeight(null);
+
List<Species> speciesToUse = Lists.newArrayList();
+
if (batchModel != null) {
speciesToUse.addAll(batchModel.getAvailableSpecies());
@@ -121,26 +147,13 @@
ui.getSpeciesComboBox().setData(speciesToUse);
}
- public void cancel() {
-
-
- if (log.isInfoEnabled()) {
- log.info("Cancel UI " + ui);
- }
-
- // wehn canceling always invalid model
- getModel().setValid(false);
-
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
- }
-
public void save() {
-
if (log.isInfoEnabled()) {
log.info("Save UI " + ui);
}
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ // close dialog
+ closeDialog(ui);
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css 2013-01-01 23:04:02 UTC (rev 137)
@@ -30,7 +30,7 @@
#splitPane {
orientation: {JSplitPane.VERTICAL_SPLIT};
- resizeWeight: 0.8;
+ resizeWeight: 0.2;
oneTouchExpandable: true;
continuousLayout: true;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -33,18 +33,16 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.util.Cancelable;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
-import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
-import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-import javax.swing.JDialog;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;
@@ -56,7 +54,7 @@
* @since 0.3
*/
public class SplitSpeciesBatchUIHandler
- extends AbstractTuttiTableUIHandler<SplitSpeciesBatchRowModel, SplitSpeciesBatchUIModel> {
+ extends AbstractTuttiTableUIHandler<SplitSpeciesBatchRowModel, SplitSpeciesBatchUIModel> implements Cancelable {
/** Logger. */
private static final Log log =
@@ -198,15 +196,6 @@
}
});
- // when sample weight changed, revalidate model
- model.addPropertyChangeListener(SplitSpeciesBatchUIModel.PROPERTY_SAMPLE_WEIGHT, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
-
- validateModel();
- }
- });
-
generateTableModel(null);
initTable(getTable());
@@ -222,6 +211,27 @@
}
//------------------------------------------------------------------------//
+ //-- Cancelable methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void cancel() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Cancel UI " + ui);
+ }
+
+ // evict model from validator
+ ui.getValidator().setBean(null);
+
+ // when canceling always invalid model
+ getModel().setValid(false);
+
+ // close dialog
+ closeDialog(ui);
+ }
+
+ //------------------------------------------------------------------------//
//-- Public methods --//
//------------------------------------------------------------------------//
@@ -285,6 +295,9 @@
SplitSpeciesBatchUIModel model = getModel();
+ // connect model to validator
+ ui.getValidator().setBean(model);
+
model.setSampleWeight(null);
model.setCategory(categories);
model.setBatchWeight(batchWeight);
@@ -293,24 +306,13 @@
model.setBatch(batch);
}
- public void cancel() {
-
- if (log.isInfoEnabled()) {
- log.info("Cancel UI " + ui);
- }
-
- editBatch(null);
-
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
- }
-
public void save() {
if (log.isInfoEnabled()) {
log.info("Save UI " + ui);
}
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ closeDialog(ui);
}
//------------------------------------------------------------------------//
@@ -334,25 +336,6 @@
getModel().setSampleWeight(result);
}
- protected void validateModel() {
-
- SplitSpeciesBatchUIModel model = getModel();
-
- int rowCount = model.getRowCount();
-
- // at least one row
- boolean valid = rowCount > 0;
-
- if (valid && !model.isSample()) {
-
- // sample Weight = batch weight
- valid = ObjectUtils.equals(model.getBatchWeight(),
- model.getSampleWeight());
- }
-
- model.setValid(valid);
- }
-
protected void generateTableModel(SampleCategoryType category) {
// when generate a new table model, then reset previous rows from model
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -0,0 +1,36 @@
+package fr.ifremer.tutti.ui.swing.util;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 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%
+ */
+
+/**
+ * To cancel contract.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public interface Cancelable {
+
+ void cancel();
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/Cancelable.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/util/TuttiUIUtil.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-01-01 23:04:02 UTC (rev 137)
@@ -26,8 +26,6 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.service.TuttiServiceTechnicalException;
-import jaxx.runtime.JAXXUtil;
-import jaxx.runtime.SwingUtil;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -35,20 +33,11 @@
import org.jdesktop.swingx.decorator.Highlighter;
import org.nuiton.util.FileUtil;
-import javax.swing.Action;
-import javax.swing.JComponent;
-import javax.swing.JDialog;
import javax.swing.JOptionPane;
-import javax.swing.JRootPane;
-import javax.swing.KeyStroke;
import javax.swing.UIManager;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
import java.io.File;
/**
@@ -66,51 +55,51 @@
// never instanciate util class
}
- public static JDialog openInDialog(JComponent ui,
- Frame frame,
- String title,
- boolean modal,
- Action closeAction) {
- return openInDialog(ui, frame, title, modal, closeAction, null);
- }
+ // public static JDialog openInDialog(JComponent ui,
+// Frame frame,
+// String title,
+// boolean modal,
+// Action closeAction) {
+// return openInDialog(ui, frame, title, modal, closeAction, null);
+// }
+//
+// public static JDialog openInDialog(JComponent ui,
+// Frame frame,
+// String title,
+// boolean modal,
+// Action closeAction,
+// Dimension dim) {
+//
+// JDialog result = new JDialog(frame, modal);
+// result.setTitle(title);
+// result.add(ui);
+// result.setResizable(true);
+// if (dim == null) {
+// result.setSize(550, 450);
+// } else {
+// result.setSize(dim);
+// }
+// if (closeAction != null) {
+// JRootPane rootPane = result.getRootPane();
+// rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
+// rootPane.getActionMap().put("close", closeAction);
+// }
+// result.addWindowListener(new WindowAdapter() {
+//
+// @Override
+// public void windowClosed(WindowEvent e) {
+// Component ui = (Component) e.getSource();
+// if (log.isInfoEnabled()) {
+// log.info("Destroy ui " + ui);
+// }
+// JAXXUtil.destroy(ui);
+// }
+// });
+// SwingUtil.center(frame, result);
+// result.setVisible(true);
+// return result;
+// }
- public static JDialog openInDialog(JComponent ui,
- Frame frame,
- String title,
- boolean modal,
- Action closeAction,
- Dimension dim) {
-
- JDialog result = new JDialog(frame, modal);
- result.setTitle(title);
- result.add(ui);
- result.setResizable(true);
- if (dim == null) {
- result.setSize(550, 450);
- } else {
- result.setSize(dim);
- }
- if (closeAction != null) {
- JRootPane rootPane = result.getRootPane();
- rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
- rootPane.getActionMap().put("close", closeAction);
- }
- result.addWindowListener(new WindowAdapter() {
-
- @Override
- public void windowClosed(WindowEvent e) {
- Component ui = (Component) e.getSource();
- if (log.isInfoEnabled()) {
- log.info("Destroy ui " + ui);
- }
- JAXXUtil.destroy(ui);
- }
- });
- SwingUtil.center(frame, result);
- result.setVisible(true);
- return result;
- }
-
/**
* Choisir un fichier via un sélecteur graphique de fichiers.
*
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 2013-01-01 18:27:33 UTC (rev 136)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-01-01 23:04:02 UTC (rev 137)
@@ -240,6 +240,7 @@
tutti.title.create.cruise=Créer une nouvelle campagne
tutti.title.create.program=Créer une nouvelle série de campagne
tutti.title.create.protocol=Créer un nouveau protocol de saisie
+tutti.title.createBatch=Créer un lot pour une nouvelle espèce
tutti.title.edit.cruise=Éditer une campagne existante
tutti.title.edit.operations=Saisie des opérations de pêches (%s)
tutti.title.edit.program=Éditer une série de campagne existante
1
0
r136 - in trunk: tutti-persistence tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split
by tchemit@users.forge.codelutin.com 01 Jan '13
by tchemit@users.forge.codelutin.com 01 Jan '13
01 Jan '13
Author: tchemit
Date: 2013-01-01 19:27:33 +0100 (Tue, 01 Jan 2013)
New Revision: 136
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/136
Log:
optimize dependencies
Modified:
trunk/tutti-persistence/pom.xml
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
Modified: trunk/tutti-persistence/pom.xml
===================================================================
--- trunk/tutti-persistence/pom.xml 2013-01-01 16:10:44 UTC (rev 135)
+++ trunk/tutti-persistence/pom.xml 2013-01-01 18:27:33 UTC (rev 136)
@@ -26,6 +26,11 @@
<artifactId>guava</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+
</dependencies>
<build>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2013-01-01 16:10:44 UTC (rev 135)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2013-01-01 18:27:33 UTC (rev 136)
@@ -26,7 +26,7 @@
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.service.DecoratorService;
-import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang3.ObjectUtils;
import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-01-01 18:27:33 UTC (rev 136)
@@ -38,7 +38,7 @@
import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
import jaxx.runtime.validator.swing.SwingValidatorUtil;
-import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
1
0
01 Jan '13
Author: tchemit
Date: 2013-01-01 17:10:44 +0100 (Tue, 01 Jan 2013)
New Revision: 135
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/135
Log:
refs #1805: [Onglet Poisson] Assistance ?\195?\160 la saisie des lots de poissons
- am?\195?\169lioration de l'api table
- am?\195?\169lioration de la saisie des mensurations
- ajout de la validation ?\195?\160 diff?\195?\169rents endroits
- d?\195?\169but d'utilisation du protocole dans l'?\195?\169cran de saisie des lots de poisson (mais non test?\195?\169 et non fini)
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-error-validation.xml
trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-warning-validation.xml
trunk/tutti-ui-swing/src/main/resources/icons/action-batch-create.png
Removed:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/TableRowModificationListener.java
Modified:
trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.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/BenthosBatchTableModel.java
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/MacroWasteBatchTableModel.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/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/SampleCategoryType.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/SpeciesBatchUI.css
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/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
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/EnvironmentTableModel.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/gearshooting/GearShootingTableModel.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/HydrologyTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.jaxx
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/EditProtocolUI.css
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/table/AbstractSelectTableAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java
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/AbstractTuttiTableUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableCellAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
trunk/tutti-ui-swing/src/main/resources/icons/action-batch-delete.png
trunk/tutti-ui-swing/src/main/resources/icons/action-batch-split.png
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -72,6 +72,8 @@
List<Species> getAllSpecies();
+ Species getSpecies(String speciesId);
+
List<FishingOperationLocation> getAllFishingOperationStrata(String zoneId);
List<FishingOperationLocation> getAllFishingOperationSubStrata(String locationId);
Modified: trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java
===================================================================
--- trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-persistence-dev/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceDevImpl.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -191,6 +191,12 @@
}
@Override
+ public Species getSpecies(String id) {
+ Species result = getBean(Species.class, id);
+ return result;
+ }
+
+ @Override
public List<Zone> getAllZone() {
List<Zone> result = getDataInNewList(Zone.class);
return result;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -137,6 +137,12 @@
}
@Override
+ public Species getSpecies(String speciesId) {
+ checkDriverExists();
+ return driver.getSpecies(speciesId);
+ }
+
+ @Override
public List<Zone> getAllZone() {
checkDriverExists();
return driver.getAllZone();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/MainUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -57,7 +57,7 @@
text: "tutti.action.manageProtocol";
toolTipText: "tutti.action.manageProtocol.tip";
mnemonic: P;
- enabled: {model.getScreen() != TuttiScreen.EDIT_PROTOCOL && model.getProtocolId() != null};
+ enabled: {model.getScreen() != TuttiScreen.EDIT_PROTOCOL && model.isProtocolFilled()};
/*actionIcon: "protocol";*/
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -68,11 +68,12 @@
PROPERTY_CRUISE_ID,
PROPERTY_PROTOCOL_ID);
-
public static final String PROPERTY_SCREEN = "screen";
public static final String PROPERTY_CRUISE_CONTEXT_FILLED = "cruiseContextFilled";
+ public static final String PROPERTY_PROTOCOL_FILLED = "protocolFilled";
+
/**
* Application context (only one for all the application).
*
@@ -190,6 +191,10 @@
StringUtils.isNotBlank(cruiseId);
}
+ public boolean isProtocolFilled() {
+ return StringUtils.isNotBlank(protocolId);
+ }
+
public TuttiScreen getScreen() {
return screen;
}
@@ -217,11 +222,13 @@
}
public void setProtocolId(String protocolId) {
-
+ boolean oldValue = isProtocolFilled();
this.protocolId = protocolId;
// always propagate the change
firePropertyChange(PROPERTY_PROTOCOL_ID, null, protocolId);
+ firePropertyChange(PROPERTY_PROTOCOL_FILLED,
+ oldValue, isProtocolFilled());
}
public void setScreen(TuttiScreen screen) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -143,7 +143,7 @@
}
#headOfMissionList {
- property: "headOfMission";
+ property: headOfMission;
border: {BorderFactory.createTitledBorder(_("tutti.label.list.headOfMission"))};
}
@@ -177,17 +177,18 @@
text: "tutti.action.generateCampaignName";
enabled: {model.isCanGenerateName()};
}
+
#messagePanel {
border: {BorderFactory.createTitledBorder(_("tutti.title.messages"))};
- height: 200;
- width: 500;
+ /*height: 200;
+ width: 500;*/
}
#errorTable {
rowSelectionAllowed: true;
autoCreateRowSorter: true;
- autoResizeMode: 2;
+ autoResizeMode: {JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS};
cellSelectionEnabled: false;
- selectionMode: 0;
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
model: {errorTableModel};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -36,6 +36,7 @@
property: program;
beanType: {Program.class};
selectedItem: {model.getProgram()};
+ enabled: {!programCombobox.isEmpty()};
}
#editProgramButton {
@@ -56,8 +57,8 @@
#cruiseCombobox {
property: cruise;
- enabled: {model.isProgramFound()};
selectedItem: {model.getCruise()};
+ enabled: {!cruiseCombobox.isEmpty()};
}
#editCruiseButton {
@@ -80,6 +81,7 @@
#protocolCombobox {
property: protocol;
selectedItem: {model.getProtocol()};
+ enabled: {!protocolCombobox.isEmpty()};
}
#editProtocolButton {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchTableUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -30,7 +30,6 @@
import com.ezware.oxbow.swingbits.table.filter.JTableFilter;
import com.ezware.oxbow.swingbits.table.filter.TableRowFilterSupport;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
@@ -114,7 +113,7 @@
TableColumnModel columnModel,
AbstractTuttiTableModel<R> tableModel) {
- installTableKeyListener(columnModel, table, true);
+ installTableKeyListener(columnModel, table);
JTableFilter tableFilter = new JTableFilter(table);
TableRowFilterSupport.forFilter(tableFilter).searchable(true).useTableRenderers(true).actions(true).apply();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -276,8 +276,8 @@
#errorTable {
rowSelectionAllowed: true;
autoCreateRowSorter: true;
- autoResizeMode: 2;
+ autoResizeMode: {JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS};
cellSelectionEnabled: false;
- selectionMode: 0;
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
model: {errorTableModel};
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -67,7 +67,7 @@
public AccidentalBatchTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel,true, true);
setNoneEditableCols();
}
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -130,6 +130,15 @@
}
@Override
+ protected void onRowModified(int rowIndex,
+ AccidentalBatchRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<AccidentalBatchRowModel> rowMonitor,
AccidentalBatchRowModel row) {
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -82,7 +82,7 @@
n_("tutti.table.benthos.batch.header.toConfirm"));
public BenthosBatchTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, true, true);
setNoneEditableCols();
}
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -34,6 +34,7 @@
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.fishing.environment.EnvironmentRowModel;
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;
@@ -133,6 +134,15 @@
}
@Override
+ protected void onRowModified(int rowIndex,
+ BenthosBatchRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<BenthosBatchRowModel> rowMonitor,
BenthosBatchRowModel row) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -70,7 +70,7 @@
n_("tutti.table.macrowaste.batch.header.file"));
public MacroWasteBatchTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, true, true);
setNoneEditableCols();
}
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -132,6 +132,15 @@
}
@Override
+ protected void onRowModified(int rowIndex,
+ MacroWasteBatchRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<MacroWasteBatchRowModel> rowMonitor,
MacroWasteBatchRowModel row) {
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -75,7 +75,7 @@
n_("tutti.table.plankton.batch.header.file"));
public PlanktonBatchTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, true, true);
setNoneEditableCols();
}
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -131,6 +131,15 @@
}
@Override
+ protected void onRowModified(int rowIndex,
+ PlanktonBatchRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<PlanktonBatchRowModel> rowMonitor,
PlanktonBatchRowModel row) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SampleCategoryType.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -26,6 +26,7 @@
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.service.DecoratorService;
+import org.apache.commons.lang.ObjectUtils;
import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
@@ -70,4 +71,15 @@
public SampleCategoryEnum getType() {
return type;
}
+
+ public static SampleCategoryType valueOf(SampleCategoryEnum type) {
+ SampleCategoryType result = null;
+ for (SampleCategoryType sampleCategoryType : values()) {
+ if (ObjectUtils.equals(type, sampleCategoryType.type)) {
+ result = sampleCategoryType;
+ break;
+ }
+ }
+ return result;
+ }
}
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -152,7 +152,7 @@
protected final Set<ColumnIdentifier<SpeciesBatchRowModel>> sampleCols;
public SpeciesBatchTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, false, false);
setNoneEditableCols();
// setNoneEditableCols(SAMPLE_WEIGHT, SAMPLING_RATIO);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -79,14 +79,18 @@
label: "tutti.title.batchActions";
}
-#splitBatchMenu {
- text: "tutti.action.splitBatch";
+#splitSpeciesBatchMenu {
+ text: "tutti.action.splitSpeciesBatch";
+ mnemonic: S;
actionIcon: batch-split;
+ enabled: {model.isSplitSpeciesBatchEnabled()};
}
-#removeSubBatchMenu {
- text: "tutti.action.removeSubBatch";
+#removeSpeciesSubBatchMenu {
+ text: "tutti.action.removeSpeciesSubBatch";
+ mnemonic: R;
actionIcon: batch-delete;
+ enabled: {model.isRemoveSpeciesSubBatchEnabled()};
}
#table {
@@ -97,8 +101,10 @@
}
#createSpeciesBatchButton {
- actionIcon: batch-split;
+ actionIcon: batch-create;
+ mnemonic: C;
text: "tutti.action.createSpeciesBatch";
+ enabled: {model.isCreateSpeciesBatchEnabled()};
}
#filterTablePane {
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-01-01 16:10:44 UTC (rev 135)
@@ -26,10 +26,10 @@
<import>
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.content.operation.catches.species.split.SplitSampleCategoryUI
+ fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.CreateSpeciesBatchUI
+ fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI
fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
fr.ifremer.tutti.ui.swing.util.editor.AttachmentEditorUI
@@ -81,18 +81,19 @@
<SpeciesFrequencyUI id='frequencyEditor' constructorParams='this'/>
- <SplitSampleCategoryUI id='sampleCategoryEditor' constructorParams='this'/>
+ <CreateSpeciesBatchUI id='createSpeciesBatchUI' constructorParams='this'/>
+ <SplitSpeciesBatchUI id='splitSpeciesBatchUI' constructorParams='this'/>
<LongTextEditorUI id='longTextEditor'/>
<AttachmentEditorUI id='attachmentEditor'/>
- <JPopupMenu id='tablePopup'
- onPopupMenuWillBecomeVisible='handler.updateTablePopup()'>
- <JMenuItem id='splitBatchMenu'
- onActionPerformed='handler.splitBatch()'/>
- <JMenuItem id='removeSubBatchMenu'
- onActionPerformed='handler.removeBatch()'/>
+ <JPopupMenu id='tablePopup'>
+ <!--onPopupMenuWillBecomeVisible='handler.updateTablePopup()'>-->
+ <JMenuItem id='splitSpeciesBatchMenu'
+ onActionPerformed='handler.splitSpeciesBatch()'/>
+ <JMenuItem id='removeSpeciesSubBatchMenu'
+ onActionPerformed='handler.removeSpeciesSubBatch()'/>
</JPopupMenu>
<Table id='form' fill='both' constraints='BorderLayout.NORTH'>
@@ -144,7 +145,6 @@
<JRadioButton id='filterSpeciesBatchRootButton'
onActionPerformed='model.setTableViewMode(TableViewMode.ROOT)'/>
</JPanel>
-
</JPanel>
</cell>
</row>
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -30,8 +30,11 @@
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
+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;
import fr.ifremer.tutti.persistence.entities.referential.Species;
@@ -42,9 +45,9 @@
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.content.operation.catches.species.split.SplitSampleCategoryRowModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSampleCategoryUI;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSampleCategoryUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent;
@@ -52,6 +55,7 @@
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.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
@@ -134,6 +138,9 @@
SpeciesBatchUIModel model = getModel();
+ List<Species> availableSpecies =
+ Lists.newArrayList(model.getAllSpecies());
+
List<SpeciesBatchRowModel> rows;
if (empty) {
@@ -147,6 +154,9 @@
rows = Lists.newArrayList();
if (!TuttiEntities.isNew(bean)) {
+
+ Set<Species> speciesUsed = Sets.newHashSet();
+
List<SpeciesBatch> catches =
persistenceService.getAllSpeciesBatch(bean.getId());
for (SpeciesBatch aBatch : catches) {
@@ -155,10 +165,15 @@
SpeciesBatchRowModel entry =
new SpeciesBatchRowModel(aBatch, frequencies);
rows.add(entry);
+ speciesUsed.add(entry.getSpecies());
}
+ availableSpecies.removeAll(speciesUsed);
}
}
+
+ model.setAvailableSpecies(availableSpecies);
model.setRows(rows);
+ recomputeBatchActionEnable();
}
//------------------------------------------------------------------------//
@@ -195,59 +210,12 @@
}
@Override
- protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SpeciesBatchRowModel> rowMonitor,
- SpeciesBatchRowModel row) {
-
- if (row.isValid()) {
- // there is a valid bean attached to the monitor
-
- if (rowMonitor.wasModified()) {
-
- // monitored bean was modified, save it
- if (log.isInfoEnabled()) {
- log.info("Row " + row + " was modified, will save it");
- }
-
- showInformationMessage(
- "[ Captures - Espèces ] " +
- "Sauvegarde des modifications de " + row + ".");
-
- saveRow(row);
-
- // clear modified flag on the monitor
- rowMonitor.clearModified();
- }
- } else {
-
- // row is not valid can not save it
-
- SpeciesBatch catchBean = row.toBean();
-
- if (!TuttiEntities.isNew(catchBean)) {
-
- // remove this
- persistenceService.deleteSpeciesBatch(catchBean.getId());
- }
- }
- }
-
- @Override
- protected void onModelRowsChanged(List<SpeciesBatchRowModel> rows) {
- super.onModelRowsChanged(rows);
-
- // build the new sampling tree from the new rows to edit
-// getModel().getSamplingTreeModel().populate(rows);
- }
-
- @Override
protected void onRowModified(int rowIndex,
SpeciesBatchRowModel row,
String propertyName,
Object oldValue,
Object newValue) {
- super.onRowModified(rowIndex, row, propertyName, oldValue, newValue);
-
if (RECOMPUTE_TOTAL_WEIGHT.contains(propertyName)) {
// Need to recompute totalHorsVracWeight
@@ -257,17 +225,19 @@
if (SAMPLING_PROPERTIES.contains(propertyName)) {
// species has changed, recompute valid property
- boolean rowValid = isRowValid(row);
- row.setValid(rowValid);
+ recomputeRowValidState(row);
}
if (SpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
// weight has changed, recompute valid property
- boolean rowValid = isRowValid(row);
- row.setValid(rowValid);
+ recomputeRowValidState(row);
}
+ // when row valid state has changed, recompute action enabled states
+ recomputeBatchActionEnable();
+
+
// SpeciesBatchUIModel model = getModel();
//
// SpeciesBatchTreeModel samplingTreeModel = model.getSamplingTreeModel();
@@ -344,6 +314,70 @@
// }
}
+ @Override
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SpeciesBatchRowModel> rowMonitor,
+ SpeciesBatchRowModel row) {
+
+ if (row.isValid()) {
+ // there is a valid bean attached to the monitor
+
+ if (rowMonitor.wasModified()) {
+
+ // monitored bean was modified, save it
+ if (log.isInfoEnabled()) {
+ log.info("Row " + row + " was modified, will save it");
+ }
+
+ showInformationMessage(
+ "[ Captures - Espèces ] " +
+ "Sauvegarde des modifications de " + row + ".");
+
+ saveRow(row);
+
+ // clear modified flag on the monitor
+ rowMonitor.clearModified();
+ }
+ } else {
+
+ // row is not valid can not save it
+
+ SpeciesBatch catchBean = row.toBean();
+
+ if (!TuttiEntities.isNew(catchBean)) {
+
+ // remove this
+ persistenceService.deleteSpeciesBatch(catchBean.getId());
+ }
+ }
+ }
+
+ @Override
+ protected void onModelRowsChanged(List<SpeciesBatchRowModel> rows) {
+ super.onModelRowsChanged(rows);
+
+ // build the new sampling tree from the new rows to edit
+// getModel().getSamplingTreeModel().populate(rows);
+ }
+
+ @Override
+ protected void onRowValidStateChanged(int rowIndex, SpeciesBatchRowModel row, Boolean oldValue, Boolean newValue) {
+ super.onRowValidStateChanged(rowIndex, row, oldValue, newValue);
+
+ // when row valid state has changed, recompute action enabled states
+ recomputeBatchActionEnable();
+ }
+
+ @Override
+ protected void onAfterSelectedRowChanged(int oldRowIndex,
+ SpeciesBatchRowModel oldRow,
+ int newRowIndex,
+ SpeciesBatchRowModel newRow) {
+ super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow);
+
+ // when selected row has changed, recompute action enabled states
+ recomputeBatchActionEnable();
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -386,17 +420,60 @@
initUI(ui);
- //TODO Will come from protocol
- List<String> samplingOrder = Lists.newArrayList(
- SpeciesBatchRowModel.PROPERTY_SPECIES,
- SpeciesBatchRowModel.PROPERTY_SORTED_UNSORTED_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SIZE_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_SEX_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_MATURITY_CATEGORY,
- SpeciesBatchRowModel.PROPERTY_AGE_CATEGORY
- );
+ List<SampleCategoryType> samplingOrder;
+ List<Species> allSpecies;
+
+ if (getContext().isProtocolFilled()) {
+
+ // there is a protocol
+
+ TuttiProtocol protocol =
+ persistenceService.getProtocol(getContext().getProtocolId());
+
+ // fill sampling order from protocol
+
+ List<SampleCategoryEnum> sampleCategoryOrder =
+ protocol.getSampleCategoryOrder();
+ samplingOrder = Lists.newArrayList();
+ for (SampleCategoryEnum sampleCategoryEnum : sampleCategoryOrder) {
+
+ SampleCategoryType sampleCategoryType =
+ SampleCategoryType.valueOf(sampleCategoryEnum);
+ samplingOrder.add(sampleCategoryType);
+ }
+
+ // fill available species from protocol
+
+ allSpecies = Lists.newArrayList();
+ List<SpeciesProtocol> protocolSpecies = protocol.getSpecies();
+ for (SpeciesProtocol protocolSpecy : protocolSpecies) {
+ Species species = persistenceService.getSpecies(
+ protocolSpecy.getSpeciesId());
+ allSpecies.add(species);
+ }
+
+ } else {
+ // no protocol, use default values
+
+ samplingOrder = Lists.newArrayList(
+ SampleCategoryType.sortedUnsorted,
+ SampleCategoryType.size,
+ SampleCategoryType.sex,
+ SampleCategoryType.maturity,
+ SampleCategoryType.age);
+
+ allSpecies = Lists.newArrayList(
+ persistenceService.getAllSpecies());
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Will use sampling order: " + samplingOrder);
+ log.info("Will use " + allSpecies.size() + " species.");
+ }
+
getModel().setSamplingOrder(samplingOrder);
+ getModel().setAllSpecies(allSpecies);
JXTable table = getTable();
@@ -409,8 +486,6 @@
Decorator<CaracteristicQualitativeValue> caracteristicDecorator =
getDecorator(CaracteristicQualitativeValue.class, null);
- List<Species> allSpecies = persistenceService.getAllSpecies();
-
{ // Species (by code) column
Decorator<Species> decorator = getDecorator(
@@ -541,9 +616,11 @@
//------------------------------------------------------------------------//
public void autoSelectRowInTable(MouseEvent e) {
- if (SwingUtilities.isRightMouseButton(e) ||
- e.isPopupTrigger()) {
+ boolean rightClick = SwingUtilities.isRightMouseButton(e);
+
+ if (rightClick || SwingUtilities.isLeftMouseButton(e)) {
+
// get the coordinates of the mouse click
Point p = e.getPoint();
@@ -552,56 +629,31 @@
// get the row index at this point
int rowIndex = source.rowAtPoint(p);
- if (log.isInfoEnabled()) {
- log.info("At point [" + p + "] found Row " + rowIndex);
+ if (log.isDebugEnabled()) {
+ log.debug("At point [" + p + "] found Row " + rowIndex);
}
- if (rowIndex != -1) {
- // select new row
+ // select row (could empty selection)
+ if (rowIndex == -1) {
+ source.clearSelection();
+ } else {
source.setRowSelectionInterval(rowIndex, rowIndex);
}
- ui.getTablePopup().show(source, e.getX(), e.getY());
- }
- }
+ if (rightClick) {
- public void updateTablePopup() {
-
- int rowIndex = getTable().getSelectedRow();
- boolean enableSplit = false;
- boolean enableRemove = false;
-
- if (rowIndex != -1) {
-
- // there is a selected row
-
- //TODO If there is some sub-batch, can remove them
- //TODO If there is no sub-batch, can split current batch
-
- SpeciesBatchRowModel row = getTableModel().getEntry(rowIndex);
-
- if (row.isValid()) {
-
- // must have at least species filled in row
- // otherwise nothing can be done
-
- enableSplit = true;
+ // on right click show popup
+ ui.getTablePopup().show(source, e.getX(), e.getY());
}
}
-
- ui.getSplitBatchMenu().setEnabled(enableSplit);
- ui.getRemoveSubBatchMenu().setEnabled(enableRemove);
}
- public void removeBatch() {
- //TODO
- }
-
public void createSpeciesBatch() {
}
- public void splitBatch() {
+ public void splitSpeciesBatch() {
+
JXTable table = getTable();
// get selected row
@@ -611,7 +663,7 @@
if (log.isInfoEnabled()) {
log.info("Open split batch for row [" + rowIndex + "]");
}
- SplitSampleCategoryUI sampleCategoryEditor = ui.getSampleCategoryEditor();
+ SplitSpeciesBatchUI sampleCategoryEditor = ui.getSplitSpeciesBatchUI();
sampleCategoryEditor.getHandler().editBatch(selectedRow);
Frame frame = SwingUtil.getParentContainer(ui, Frame.class);
@@ -622,7 +674,7 @@
_("tutti.title.splitBatch"), true, null);
// at close, synch back batches ?
- SplitSampleCategoryUIModel splitModel = sampleCategoryEditor.getModel();
+ SplitSpeciesBatchUIModel splitModel = sampleCategoryEditor.getModel();
if (splitModel.isValid()) {
@@ -637,7 +689,7 @@
// Create rows in batch table model
List<SpeciesBatchRowModel> newBatchRows = Lists.newArrayList();
- for (SplitSampleCategoryRowModel row : splitModel.getRows()) {
+ for (SplitSpeciesBatchRowModel row : splitModel.getRows()) {
if (row.isValid()) {
// can keep this row
@@ -696,6 +748,10 @@
table.requestFocus();
}
+ public void removeSpeciesSubBatch() {
+ //TODO
+ }
+
//------------------------------------------------------------------------//
//-- Internal methods --//
//------------------------------------------------------------------------//
@@ -817,6 +873,51 @@
// getModel().setTotalVracWeight(totalVrac);
}
+ protected void recomputeBatchActionEnable() {
+
+ int rowIndex = getTable().getSelectedRow();
+
+ boolean enableAdd =
+ CollectionUtils.isNotEmpty(getModel().getAvailableSpecies());
+
+ boolean enableSplit = false;
+ boolean enableRemove = false;
+
+ if (rowIndex != -1) {
+
+ // there is a selected row
+
+ //TODO If there is some sub-batch, can remove them
+ //TODO If there is no sub-batch, can split current batch
+
+ SpeciesBatchRowModel row = getTableModel().getEntry(rowIndex);
+
+ if (row.isValid()) {
+
+ // must have at least species filled in row
+ // otherwise nothing can be done
+
+ enableSplit = true;
+ enableRemove = true;
+ }
+
+ if (enableSplit) {
+
+ // the select batch can not have any batch child
+
+ }
+
+ if (enableRemove) {
+
+ // the selected batch must have some batch child
+ }
+ }
+ getModel().setCreateSpeciesBatchEnabled(enableAdd);
+ getModel().setSplitSpeciesBatchEnabled(enableSplit);
+ getModel().setRemoveSpeciesSubBatchEnabled(enableRemove);
+
+ }
+
protected <C extends Serializable> void addSampleCategoryColumnToModel(TableColumnModel columnModel,
ColumnIdentifier<SpeciesBatchRowModel> columnIdentifier,
Decorator<C> decorator,
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -24,6 +24,7 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
@@ -40,15 +41,38 @@
public static final String PROPERTY_TABLE_VIEW_MODE = "tableViewMode";
+ public static final String PROPERTY_AVAILABLE_SPECIES = "availableSpecies";
+ public static final String PROPERTY_ALL_SPECIES = "allSpecies";
+
+ public static final String PROPERTY_CREATE_SPECIES_BATCH_ENABLED = "createSpeciesBatchEnabled";
+
+ public static final String PROPERTY_SPLIT_SPECIES_BATCH_ENABLED = "splitSpeciesBatchEnabled";
+
+ public static final String PROPERTY_REMOVE_SPECIES_SUB_BATCH_ENABLED = "removeSpeciesSubBatchEnabled";
+
/**
* Sampling order (sets by protocol).
*
* @since 0.2
*/
- protected List<String> samplingOrder;
+ protected List<SampleCategoryType> samplingOrder;
/**
+ * All usable species (sets by protocol).
+ *
+ * @since 0.3
+ */
+ protected List<Species> allSpecies;
+
+ /**
+ * All available species (says available species that are not used in any batch).
+ *
+ * @since 0.3
+ */
+ protected List<Species> availableSpecies;
+
+ /**
* What to show in the table.
*
* @since 0.3
@@ -56,6 +80,27 @@
protected TableViewMode tableViewMode;
/**
+ * Can user create a new species batch ?
+ *
+ * @since 0.3
+ */
+ protected boolean createSpeciesBatchEnabled;
+
+ /**
+ * Can user split a selected species batch ?
+ *
+ * @since 0.3
+ */
+ protected boolean splitSpeciesBatchEnabled;
+
+ /**
+ * Can user remove a selected species sub batches?
+ *
+ * @since 0.3
+ */
+ protected boolean removeSpeciesSubBatchEnabled;
+
+ /**
* Tree of sampling for batch rows.
*
* @since 0.2
@@ -107,13 +152,12 @@
return samplingTreeModel;
}
- public List<String> getSamplingOrder() {
+ public List<SampleCategoryType> getSamplingOrder() {
return samplingOrder;
}
- public void setSamplingOrder(List<String> samplingOrder) {
+ public void setSamplingOrder(List<SampleCategoryType> samplingOrder) {
this.samplingOrder = samplingOrder;
- samplingTreeModel.setSamplingOrder(samplingOrder.toArray(new String[samplingOrder.size()]));
}
public TableViewMode getTableViewMode() {
@@ -140,4 +184,54 @@
public boolean isTableViewModeRoot() {
return TableViewMode.ROOT.equals(tableViewMode);
}
+
+ public List<Species> getAllSpecies() {
+ return allSpecies;
+ }
+
+ public void setAllSpecies(List<Species> allSpecies) {
+ Object oldValue = getAllSpecies();
+ this.allSpecies = allSpecies;
+ firePropertyChange(PROPERTY_ALL_SPECIES, oldValue, allSpecies);
+ }
+
+ public List<Species> getAvailableSpecies() {
+ return availableSpecies;
+ }
+
+ public void setAvailableSpecies(List<Species> availableSpecies) {
+ Object oldValue = getAvailableSpecies();
+ this.availableSpecies = availableSpecies;
+ firePropertyChange(PROPERTY_AVAILABLE_SPECIES, oldValue, availableSpecies);
+ }
+
+ public boolean isCreateSpeciesBatchEnabled() {
+ return createSpeciesBatchEnabled;
+ }
+
+ public void setCreateSpeciesBatchEnabled(boolean createSpeciesBatchEnabled) {
+ Object oldValue = isCreateSpeciesBatchEnabled();
+ this.createSpeciesBatchEnabled = createSpeciesBatchEnabled;
+ firePropertyChange(PROPERTY_CREATE_SPECIES_BATCH_ENABLED, oldValue, createSpeciesBatchEnabled);
+ }
+
+ public boolean isSplitSpeciesBatchEnabled() {
+ return splitSpeciesBatchEnabled;
+ }
+
+ public void setSplitSpeciesBatchEnabled(boolean splitSpeciesBatchEnabled) {
+ Object oldValue = isSplitSpeciesBatchEnabled();
+ this.splitSpeciesBatchEnabled = splitSpeciesBatchEnabled;
+ firePropertyChange(PROPERTY_SPLIT_SPECIES_BATCH_ENABLED, oldValue, splitSpeciesBatchEnabled);
+ }
+
+ public boolean isRemoveSpeciesSubBatchEnabled() {
+ return removeSpeciesSubBatchEnabled;
+ }
+
+ public void setRemoveSpeciesSubBatchEnabled(boolean removeSpeciesSubBatchEnabled) {
+ Object oldValue = isRemoveSpeciesSubBatchEnabled();
+ this.removeSpeciesSubBatchEnabled = removeSpeciesSubBatchEnabled;
+ firePropertyChange(PROPERTY_REMOVE_SPECIES_SUB_BATCH_ENABLED, oldValue, removeSpeciesSubBatchEnabled);
+ }
}
Modified: 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/SpeciesFrequencyRowModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyRowModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -177,11 +177,11 @@
firePropertyChange(PROPERTY_LENGHT_STEP_CARACTERISTIC, oldValue, lengthStepCaracteristic);
}
- //TODO Use validator
- @Override
- public boolean isValid() {
- return lengthStep != null && number != null && lengthStepCaracteristic != null;
- }
+// //TODO Use validator
+// @Override
+// public boolean isValid() {
+// return lengthStep != null && number != null && lengthStepCaracteristic != null;
+// }
@Override
public int compareTo(SpeciesFrequencyRowModel o) {
Modified: 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/SpeciesFrequencyTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -71,7 +71,7 @@
public SpeciesFrequencyTableModel(TableColumnModel columnModel,
SpeciesFrequencyUIModel uiModel) {
- super(columnModel);
+ super(columnModel, true, true);
this.uiModel = uiModel;
this.rowCache = Maps.newTreeMap();
setNoneEditableCols(COMPUTED_WEIGHT);
Modified: 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.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -33,6 +33,13 @@
showPopupButton: {handler.getConfig().isShowNumberEditorButton()};
}
+#splitPane {
+ orientation: {JSplitPane.VERTICAL_SPLIT};
+ resizeWeight: 0.8;
+ oneTouchExpandable: true;
+ continuousLayout: true;
+}
+
#stepLabel {
text: "tutti.label.frequencyConfiguration.step";
labelFor: {stepField};
@@ -46,12 +53,12 @@
bean: {model};
}
-#lenghtStepCaracteristicLabel {
+#lengthStepCaracteristicLabel {
text: "tutti.label.frequencyConfiguration.lengthStepCaracteristic";
- labelFor: {lenghtStepCaracteristicComboBox};
+ labelFor: {lengthStepCaracteristicComboBox};
}
-#lenghtStepCaracteristicComboBox {
+#lengthStepCaracteristicComboBox {
property: lengthStepCaracteristic;
selectedItem: {model.getLengthStepCaracteristic()};
}
@@ -157,4 +164,32 @@
selectionForeground: {Color.BLACK};
sortable: false;
enabled: {model.getLengthStepCaracteristic() != null}
+}
+
+#cancelButton {
+ actionIcon: cancel;
+ mnemonic: C;
+ text: "tutti.action.cancel";
+}
+
+#saveButton {
+ actionIcon: save;
+ mnemonic: S;
+ text: "tutti.action.save";
+ enabled: {model.isValid()};
+}
+
+#messagePanel {
+ border: {BorderFactory.createTitledBorder(_("tutti.title.messages"))};
+ /*height: 200;
+ width: 500;*/
+}
+
+#errorTable {
+ rowSelectionAllowed: true;
+ autoCreateRowSorter: true;
+ autoResizeMode: {JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS};
+ cellSelectionEnabled: false;
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ model: {errorTableModel};
}
\ No newline at end of file
Modified: 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/SpeciesFrequencyUI.jaxx 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx 2013-01-01 16:10:44 UTC (rev 135)
@@ -35,6 +35,9 @@
jaxx.runtime.swing.editor.bean.BeanComboBox
jaxx.runtime.swing.editor.NumberEditor
+ jaxx.runtime.validator.swing.SwingValidatorUtil
+ jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
+
org.jdesktop.swingx.JXTable
javax.swing.ListSelectionModel
@@ -71,113 +74,135 @@
<SpeciesFrequencyUIModel id='model'
initializer='getContextValue(SpeciesFrequencyUIModel.class)'/>
+ <SwingValidatorMessageTableModel id='errorTableModel'/>
+
+ <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
+ uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
+ <field name='lengthStepCaracteristic' component='lengthStepCaracteristicComboBox'/>
+ <field name='rows' component='tableScrollPane'/>
+ </BeanValidator>
+
<CardLayout2Ext id='modeConfigurationLayout'
constructorParams='this, "modeConfigurationPanel"'/>
- <JPanel id='configurationPanel' layout='{new BorderLayout()}'
- constraints='BorderLayout.NORTH'>
+ <JSplitPane id='splitPane' constraints='BorderLayout.CENTER'>
- <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 layout='{new BorderLayout()}'>
- <JPanel id='modeConfigurationPanel' constraints='BorderLayout.CENTER'>
- <JPanel id='simpleModePanel' constraints='"simpleMode"'
- layout='{new BorderLayout()}'>
- <JLabel id='simpleModeLabel' constraints='BorderLayout.CENTER'/>
+ <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>
- <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>
+ <Table fill='both' constraints='BorderLayout.SOUTH'>
+ <row>
+ <cell columns='2'>
+ <JSeparator/>
+ </cell>
+ </row>
+ <!-- length step caracteristic -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='lengthStepCaracteristicLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <BeanComboBox id='lengthStepCaracteristicComboBox'
+ 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>
- </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>
+ <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>
+ <!-- actions -->
+ <JPanel id='actionPanel' layout='{new GridLayout(1, 0)}'
+ constraints='BorderLayout.SOUTH'>
+ <JButton id='cancelButton' onActionPerformed='handler.cancel()'/>
+ <JButton id='saveButton' onActionPerformed='handler.save()'/>
+ </JPanel>
+ </JPanel>
+ <!-- Messages report -->
+ <JPanel id='messagePanel' layout='{new GridLayout()}'>
+ <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
+ <JTable id='errorTable'/>
+ </JScrollPane>
+ </JPanel>
+ </JSplitPane>
</JPanel>
\ No newline at end of file
Modified: 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/SpeciesFrequencyUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -34,7 +34,8 @@
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
import jaxx.runtime.SwingUtil;
-import org.apache.commons.collections.CollectionUtils;
+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;
@@ -92,23 +93,20 @@
@Override
protected boolean isRowValid(SpeciesFrequencyRowModel row) {
- //TODO
- return row.getLengthStep() != null && row.getWeight() != null;
+ return row.getLengthStepCaracteristic() != null &&
+ row.getLengthStep() != null &&
+ row.getNumber() != null;
}
@Override
- protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SpeciesFrequencyRowModel> rowMonitor,
- SpeciesFrequencyRowModel row) {
- }
-
- @Override
protected void onRowModified(int rowIndex,
SpeciesFrequencyRowModel row,
String propertyName,
Object oldValue,
Object newValue) {
- super.onRowModified(rowIndex, row, propertyName, oldValue, newValue);
+ recomputeRowValidState(row);
+
if (SpeciesFrequencyRowModel.PROPERTY_NUMBER.equals(propertyName)) {
// Need to recompute the computedWeight
@@ -116,6 +114,20 @@
}
}
+ @Override
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SpeciesFrequencyRowModel> rowMonitor,
+ SpeciesFrequencyRowModel row) {
+ }
+
+ @Override
+ protected void onRowValidStateChanged(int rowIndex,
+ SpeciesFrequencyRowModel row,
+ Boolean oldValue,
+ Boolean newValue) {
+ super.onRowValidStateChanged(rowIndex, row, oldValue, newValue);
+ ui.getValidator().doValidate();
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -147,7 +159,7 @@
SpeciesFrequencyUIModel model = getModel();
//TODO Use protocol to have lengthStepCaracteristic to use (if any protocol)
- initBeanComboBox(ui.getLenghtStepCaracteristicComboBox(),
+ initBeanComboBox(ui.getLengthStepCaracteristicComboBox(),
lengthStepCaracterics,
model.getLengthStepCaracteristic());
@@ -180,7 +192,9 @@
Caracteristic newValue = (Caracteristic) evt.getNewValue();
for (SpeciesFrequencyRowModel rowModel : getModel().getRows()) {
rowModel.setLengthStepCaracteristic(newValue);
+ recomputeRowValidState(rowModel);
}
+ ui.getValidator().doValidate();
}
});
@@ -224,9 +238,14 @@
table.setModel(tableModel);
table.setColumnModel(columnModel);
- installTableKeyListener(columnModel, table, true);
+ installTableKeyListener(columnModel, table);
initTable(table);
+
+ SwingValidatorUtil.installUI(ui.getErrorTable(),
+ new SwingValidatorMessageTableRenderer());
+
+ listenValidatorValid(ui.getValidator(), model);
}
@Override
@@ -240,6 +259,7 @@
public void generateLengthSteps() {
SpeciesFrequencyUIModel model = getModel();
+ SpeciesFrequencyTableModel tableModel = getTableModel();
Map<Float, SpeciesFrequencyRowModel> rowsByStep =
getTableModel().getRowCache();
@@ -251,7 +271,7 @@
if (!rowsByStep.containsKey(i)) {
// add it
- SpeciesFrequencyRowModel newRow = new SpeciesFrequencyRowModel();
+ SpeciesFrequencyRowModel newRow = tableModel.createNewRow();
newRow.setLengthStep(i);
rowsByStep.put(i, newRow);
}
@@ -289,7 +309,8 @@
} else {
// create a new row
- row = new SpeciesFrequencyRowModel();
+
+ row = tableModel.createNewRow();
row.setLengthStep(aroundLengthStep);
row.setNumber(1);
@@ -307,28 +328,36 @@
getTable().scrollRowToVisible(rowIndex);
}
- public void editBatch(SpeciesBatchRowModel row) {
+ public void editBatch(SpeciesBatchRowModel speciesBatch) {
List<SpeciesFrequencyRowModel> frequency = null;
Caracteristic lengthStepCaracteristic = null;
- if (row != null) {
- frequency = row.getFrequency();
+ if (speciesBatch != null) {
+ frequency = speciesBatch.getFrequency();
}
- List<SpeciesFrequencyRowModel> editFrequency;
- if (CollectionUtils.isEmpty(frequency)) {
+ List<SpeciesFrequencyRowModel> editFrequency = Lists.newArrayList();
- // new list
- editFrequency = Lists.newArrayList();
- } else {
+ if (frequency != null) {
- editFrequency = Lists.newArrayList(frequency);
- lengthStepCaracteristic = frequency.get(0).getLengthStepCaracteristic();
+ SpeciesFrequencyTableModel tableModel = getTableModel();
+
+ for (SpeciesFrequencyRowModel rowModel : frequency) {
+
+ SpeciesFrequencyRowModel newRow = tableModel.createNewRow();
+ newRow.setLengthStepCaracteristic(rowModel.getLengthStepCaracteristic());
+ newRow.setLengthStep(rowModel.getLengthStep());
+ newRow.setNumber(rowModel.getNumber());
+ newRow.setComputedWeight(rowModel.getComputedWeight());
+ editFrequency.add(newRow);
+ }
+ lengthStepCaracteristic =
+ frequency.get(0).getLengthStepCaracteristic();
}
if (log.isInfoEnabled()) {
- log.info("Will edit batch row: " + row + " with " +
+ log.info("Will edit batch row: " + speciesBatch + " with " +
editFrequency.size() + " frequency");
}
@@ -355,15 +384,29 @@
}
// keep batch (will be used to push back editing entry)
- model.setBatch(row);
+ model.setBatch(speciesBatch);
}
- public void close() {
+ public void cancel() {
if (log.isInfoEnabled()) {
- log.info("Will close UI " + ui);
+ log.info("Cancel UI " + ui);
}
+ // when canceling always invalid model (in that way)
+ getModel().setValid(false);
+
+ ui.editBatch(null);
+
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
+
+ public void save() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Will Save and close UI " + ui);
+ }
+
SpeciesFrequencyUIModel model = getModel();
// transfer rows to editor
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -192,4 +192,18 @@
float result = correctIntStep / 10f;
return result;
}
+
+ public boolean isOneRowValid() {
+ boolean result = getRowCount() > 0;
+ if (result) {
+ result = false;
+ for (SpeciesFrequencyRowModel row : rows) {
+ if (row.isValid()) {
+ result = true;
+ break;
+ }
+ }
+ }
+ 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/split/CreateSpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,92 @@
+/*
+ * #%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()};
+ showReset: true;
+}
+
+#splitPane {
+ orientation: {JSplitPane.VERTICAL_SPLIT};
+ resizeWeight: 0.8;
+ oneTouchExpandable: true;
+ continuousLayout: true;
+}
+
+#speciesLabel {
+ text: "tutti.label.createSpeciesBatch.species";
+ labelFor: {speciesComboBox};
+}
+
+#speciesComboBox {
+ property: species;
+ selectedItem: {model.getSpecies()};
+ data: {model.getAvailableSpecies()};
+}
+
+#batchWeightLabel {
+ text: "tutti.label.createSpeciesBatch.batchWeight";
+ labelFor: {batchWeightField};
+}
+
+#batchWeightField {
+ property: batchWeight;
+ model: {model.getBatchWeight()};
+ useFloat: true;
+ numberPattern: {DECIMAL1_PATTERN};
+ bean: {model};
+}
+
+#saveButton {
+ actionIcon: save;
+ text: "tutti.action.save";
+ enabled: {model.isValid()};
+}
+
+#cancelButton {
+ actionIcon: cancel;
+ text: "tutti.action.cancel";
+}
+
+#messagePanel {
+ border: {BorderFactory.createTitledBorder(_("tutti.title.messages"))};
+ /*height: 200;
+ width: 500;*/
+}
+
+#errorTable {
+ rowSelectionAllowed: true;
+ autoCreateRowSorter: true;
+ autoResizeMode: {JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS};
+ cellSelectionEnabled: false;
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ model: {errorTableModel};
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,122 @@
+<!--
+ #%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<CreateSpeciesBatchUIModel, CreateSpeciesBatchUIHandler>'>
+
+ <import>
+ fr.ifremer.tutti.persistence.entities.referential.Species
+
+ fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType
+ fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI
+
+ fr.ifremer.tutti.ui.swing.TuttiUI
+ fr.ifremer.tutti.ui.swing.TuttiUIContext
+
+ org.jdesktop.swingx.JXTable
+
+ jaxx.runtime.swing.editor.bean.BeanComboBox
+ jaxx.runtime.swing.editor.NumberEditor
+
+ jaxx.runtime.validator.swing.SwingValidatorUtil
+ jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
+
+ javax.swing.ListSelectionModel
+
+ java.awt.Color
+
+ static org.nuiton.i18n.I18n._
+ static jaxx.runtime.SwingUtil.getStringValue
+ </import>
+
+ <script><![CDATA[
+
+public CreateSpeciesBatchUI(SpeciesBatchUI parentUI) {
+ JAXXUtil.initContext(this, parentUI);
+ CreateSpeciesBatchUIHandler handler = new CreateSpeciesBatchUIHandler(parentUI, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+}
+
+protected void $afterCompleteSetup() { handler.afterInitUI(); }
+ ]]></script>
+
+ <CreateSpeciesBatchUIHandler id='handler'
+ initializer='getContextValue(CreateSpeciesBatchUIHandler.class)'/>
+
+ <CreateSpeciesBatchUIModel id='model'
+ initializer='getContextValue(CreateSpeciesBatchUIModel.class)'/>
+
+ <SwingValidatorMessageTableModel id='errorTableModel'/>
+
+ <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
+ uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
+ <field name='species' component='speciesComboBox'/>
+ <field name='batchWeight' component='batchWeightField'/>
+ </BeanValidator>
+
+ <JSplitPane id='splitPane' constraints='BorderLayout.CENTER'>
+
+ <Table id='configurationPanel' fill='both'>
+
+ <!-- Species -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='speciesLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <BeanComboBox id='speciesComboBox' constructorParams='this'
+ genericType='Species'/>
+ </cell>
+ </row>
+
+ <!-- Species batch weight -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='batchWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <NumberEditor id='batchWeightField' constructorParams='this'/>
+ </cell>
+ </row>
+
+ <!-- Form Actions -->
+ <row>
+ <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>
+
+ <!-- Messages report -->
+ <JPanel id='messagePanel' layout='{new GridLayout()}'>
+ <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
+ <JTable id='errorTable'/>
+ </JScrollPane>
+ </JPanel>
+ </JSplitPane>
+
+</JPanel>
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,146 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiUIHandler;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel;
+import jaxx.runtime.SwingUtil;
+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 javax.swing.JDialog;
+import java.util.List;
+
+/**
+ * Handler of {@link CreateSpeciesBatchUI}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class CreateSpeciesBatchUIHandler extends AbstractTuttiUIHandler<CreateSpeciesBatchUIModel> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(CreateSpeciesBatchUIHandler.class);
+
+ /**
+ * UI.
+ *
+ * @since 0.3
+ */
+ private final CreateSpeciesBatchUI ui;
+
+ public CreateSpeciesBatchUIHandler(SpeciesBatchUI parentUi, CreateSpeciesBatchUI ui) {
+ super(parentUi.getHandler().getContext());
+ this.ui = ui;
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void beforeInitUI() {
+
+ CreateSpeciesBatchUIModel model = new CreateSpeciesBatchUIModel();
+ ui.setContextValue(model);
+ listModelIsModify(model);
+ }
+
+ @Override
+ public void afterInitUI() {
+
+ initUI(ui);
+
+ initBeanComboBox(ui.getSpeciesComboBox(),
+ Lists.<Species>newArrayList(),
+ null);
+
+ SwingValidatorUtil.installUI(ui.getErrorTable(),
+ new SwingValidatorMessageTableRenderer());
+
+ listenValidatorValid(ui.getValidator(), getModel());
+ }
+
+ @Override
+ public void onCloseUI() {
+
+ if (log.isInfoEnabled()) {
+ log.info("closing: " + ui);
+ }
+
+ }
+
+ @Override
+ protected CreateSpeciesBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
+ public void editBatch(SpeciesBatchUIModel batchModel) {
+
+ getModel().setSpecies(null);
+ getModel().setBatchWeight(null);
+
+ List<Species> speciesToUse = Lists.newArrayList();
+ if (batchModel != null) {
+
+ speciesToUse.addAll(batchModel.getAvailableSpecies());
+ }
+
+ ui.getSpeciesComboBox().setData(speciesToUse);
+ }
+
+ public void cancel() {
+
+
+ if (log.isInfoEnabled()) {
+ log.info("Cancel UI " + ui);
+ }
+
+ // wehn canceling always invalid model
+ getModel().setValid(false);
+
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
+
+ public void save() {
+
+
+ if (log.isInfoEnabled()) {
+ log.info("Save UI " + ui);
+ }
+
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIHandler.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/split/CreateSpeciesBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,103 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 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.Species;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+
+import java.util.List;
+
+/**
+ * Model of {@link CreateSpeciesBatchUI}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class CreateSpeciesBatchUIModel extends AbstractTuttiBeanUIModel<CreateSpeciesBatchUIModel, CreateSpeciesBatchUIModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_AVAILABLE_SPECIES = "availableSpecies";
+
+ public static final String PROPERTY_SPECIES = "species";
+
+ public static final String PROPERTY_BATCH_WEIGHT = "batchWeight";
+
+ /**
+ * All available species (sets by protocol).
+ *
+ * @since 0.3
+ */
+ protected List<Species> availableSpecies;
+
+ /**
+ * Species to select.
+ *
+ * @since 0.3
+ */
+ protected Species species;
+
+ /**
+ * Incoming batch weight to split.
+ *
+ * @since 0.3
+ */
+ protected Float batchWeight;
+
+ public CreateSpeciesBatchUIModel() {
+ super(CreateSpeciesBatchUIModel.class, null, null);
+ }
+
+ public List<Species> getAvailableSpecies() {
+ return availableSpecies;
+ }
+
+ public void setAvailableSpecies(List<Species> availableSpecies) {
+ Object oldValue = getAvailableSpecies();
+ this.availableSpecies = availableSpecies;
+ firePropertyChange(PROPERTY_AVAILABLE_SPECIES, oldValue, availableSpecies);
+ }
+
+ public Species getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(Species species) {
+ Object oldSpecies = getSpecies();
+ this.species = species;
+ firePropertyChange(PROPERTY_SPECIES, oldSpecies, getSpecies());
+ }
+
+ public Float getBatchWeight() {
+ return batchWeight;
+ }
+
+ public void setBatchWeight(Float batchWeight) {
+ Object oldValue = getBatchWeight();
+ this.batchWeight = batchWeight;
+ firePropertyChange(PROPERTY_BATCH_WEIGHT, oldValue, batchWeight);
+ }
+
+}
\ 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/split/CreateSpeciesBatchUIModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -1,115 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
-
-/*
- * #%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.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategory;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
-import org.nuiton.util.beans.Binder;
-import org.nuiton.util.beans.BinderFactory;
-
-import java.io.Serializable;
-
-/**
- * A row in the {@link SplitSampleCategoryUIModel}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-public class SplitSampleCategoryRowModel extends AbstractTuttiBeanUIModel<SplitSampleCategoryRowModel, SplitSampleCategoryRowModel> {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_CATEGORY_VALUE = "categoryValue";
-
- public static final String PROPERTY_WEIGHT = "weight";
-
- /**
- * Delegate sample category which contains category value + weight.
- *
- * @since 0.3
- */
- protected final SampleCategory<Serializable> category = SampleCategory.newSample(null);
-
- protected static final Binder<SplitSampleCategoryRowModel, SplitSampleCategoryRowModel> fromBeanBinder =
- BinderFactory.newBinder(SplitSampleCategoryRowModel.class,
- SplitSampleCategoryRowModel.class);
-
- protected static final Binder<SplitSampleCategoryRowModel, SplitSampleCategoryRowModel> toBeanBinder =
- BinderFactory.newBinder(SplitSampleCategoryRowModel.class,
- SplitSampleCategoryRowModel.class);
-
- public SplitSampleCategoryRowModel() {
- super(SplitSampleCategoryRowModel.class, fromBeanBinder, toBeanBinder);
- }
-
- public SampleCategoryType getCategoryType() {
- return category.getCategoryType();
- }
-
- public void setCategoryType(SampleCategoryType categoryType) {
- category.setCategoryType(categoryType);
- }
-
- public Serializable getCategoryValue() {
- return category.getCategoryValue();
- }
-
- public void setCategoryValue(Serializable categoryValue) {
- Object oldValue = getCategoryValue();
- category.setCategoryValue(categoryValue);
- firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
- }
-
- public void setCategoryValue(CaracteristicQualitativeValue categoryValue) {
- Object oldValue = getCategoryValue();
- category.setCategoryValue(categoryValue);
- firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
- }
-
- public void setCategoryValue(Float categoryValue) {
- Object oldValue = getCategoryValue();
- category.setCategoryValue(categoryValue);
- firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
- }
-
- public Float getWeight() {
- return category.getCategoryWeight();
- }
-
- public void setWeight(Float weight) {
- Object oldValue = getWeight();
- category.setCategoryWeight(weight);
- firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
- }
-
- //TODO Use validator
- @Override
- public boolean isValid() {
- return category.isValid();
- }
-
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -1,76 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
-import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
-
-import javax.swing.table.TableColumnModel;
-
-import static org.nuiton.i18n.I18n.n_;
-
-/**
- * Table model of sample categories values.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-public class SplitSampleCategoryTableModel extends AbstractTuttiTableModel<SplitSampleCategoryRowModel> {
-
- private static final long serialVersionUID = 1L;
-
- public static final ColumnIdentifier<SplitSampleCategoryRowModel> EDITABLE_CATEGORY_VALUE = ColumnIdentifier.newId(
- SplitSampleCategoryRowModel.PROPERTY_CATEGORY_VALUE,
- n_("tutti.table.species.sampleCategory.header.category"),
- n_("tutti.table.species.sampleCategory.header.category"));
-
- public static final ColumnIdentifier<SplitSampleCategoryRowModel> READ_ONLY_CATEGORY_VALUE = ColumnIdentifier.newId(
- SplitSampleCategoryRowModel.PROPERTY_CATEGORY_VALUE,
- n_("tutti.table.species.sampleCategory.header.category"),
- n_("tutti.table.species.sampleCategory.header.category"));
-
- public static final ColumnIdentifier<SplitSampleCategoryRowModel> WEIGHT = ColumnIdentifier.newId(
- SplitSampleCategoryRowModel.PROPERTY_WEIGHT,
- n_("tutti.table.species.sampleCategory.header.weight"),
- n_("tutti.table.species.sampleCategory.header.weight"));
-
- private final SplitSampleCategoryUIModel uiModel;
-
- public SplitSampleCategoryTableModel(TableColumnModel columnModel,
- SplitSampleCategoryUIModel uiModel) {
- super(columnModel);
- this.uiModel = uiModel;
- setNoneEditableCols(READ_ONLY_CATEGORY_VALUE);
- }
-
- @Override
- public SplitSampleCategoryRowModel createNewRow() {
- SplitSampleCategoryRowModel result = new SplitSampleCategoryRowModel();
- result.setCategoryType(uiModel.getSelectedCategory());
- result.setValid(false);
- return result;
- }
-
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -1,93 +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};
-}
-
-#configurationPanel {
- border: {new TitledBorder(null, _("tutti.legend.sampleCategoryConfiguration"))};
-}
-
-#categoryLabel {
- text: "tutti.label.sampleCategoryConfiguration.category";
- labelFor: {categoryComboBox};
-}
-
-#categoryComboBox {
- property: selectedCategory;
- selectedItem: {model.getSelectedCategory()};
-}
-
-#sampleCheckBox {
- text: "tutti.label.sampleCategoryConfiguration.sample";
- selected: {model.isSample()};
-}
-
-#speciesLabel {
- text: "tutti.label.sampleCategoryConfiguration.species";
- labelFor: {speciesField};
-}
-
-#speciesField {
- editable: false;
- text: {handler.decorateSpecies(model.getSpecies())};
-}
-
-#batchWeightLabel {
- text: "tutti.label.sampleCategoryConfiguration.batchWeight";
- labelFor: {batchWeightField};
-}
-
-#batchWeightField {
- editable: false;
- text: {getStringValue(model.getBatchWeight())};
-}
-
-#sampleWeightLabel {
- text: "tutti.label.sampleCategoryConfiguration.sampleWeight";
- labelFor: {sampleWeightField};
-}
-
-#sampleWeightField {
- editable: false;
- text: {getStringValue(model.getSampleWeight())};
-}
-
-#closeButton {
- actionIcon: close;
- text: "tutti.action.close";
- mnemonic: F;
- enabled: {model.isValid()};
-}
-
-#table {
- selectionMode: {ListSelectionModel.SINGLE_SELECTION};
- selectionBackground: {null};
- selectionForeground: {Color.BLACK};
- sortable: false;
- enabled: {model.getSelectedCategory() != null}
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx 2013-01-01 16:10:44 UTC (rev 135)
@@ -1,144 +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<SplitSampleCategoryUIModel, SplitSampleCategoryUIHandler>'>
-
- <import>
- fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType
- fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI
-
- fr.ifremer.tutti.ui.swing.TuttiUI
- fr.ifremer.tutti.ui.swing.TuttiUIContext
-
- org.jdesktop.swingx.JXTable
-
- jaxx.runtime.swing.editor.bean.BeanComboBox
- jaxx.runtime.validator.swing.SwingValidatorUtil
- jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
-
- javax.swing.ListSelectionModel
-
- java.awt.Color
-
- static org.nuiton.i18n.I18n._
- static jaxx.runtime.SwingUtil.getStringValue
- </import>
-
- <script><![CDATA[
-
-public SplitSampleCategoryUI(SpeciesBatchUI parentUI) {
- JAXXUtil.initContext(this, parentUI);
- SplitSampleCategoryUIHandler handler = new SplitSampleCategoryUIHandler(parentUI, this);
- setContextValue(handler);
- handler.beforeInitUI();
-}
-
-protected void $afterCompleteSetup() { handler.afterInitUI(); }
- ]]></script>
-
- <SplitSampleCategoryUIHandler id='handler'
- initializer='getContextValue(SplitSampleCategoryUIHandler.class)'/>
-
- <SplitSampleCategoryUIModel id='model'
- initializer='getContextValue(SplitSampleCategoryUIModel.class)'/>
-
- <SwingValidatorMessageTableModel id='errorTableModel'/>
-
- <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
- uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
- <field name='category' component='categoryComboBox'/>
- <field name='sample' component='sampleCheckBox'/>
- <field name='sampleWeight' component='sampleWeightField'/>
- </BeanValidator>
-
- <Table id='configurationPanel' fill='both' constraints='BorderLayout.NORTH'>
-
- <!-- SampleCategory choice -->
- <row>
- <cell anchor='west'>
- <JLabel id='categoryLabel'/>
- </cell>
- <cell weightx='1.0'>
- <BeanComboBox id='categoryComboBox' constructorParams='this'
- genericType='SampleCategoryType'/>
- </cell>
- </row>
-
- <!-- Split as a sample or not ? -->
- <row>
- <cell columns='2'>
- <JCheckBox id='sampleCheckBox'
- onItemStateChanged='handler.setBoolean(event, "sample")'/>
- </cell>
- </row>
-
- <row>
- <cell columns="2">
- <JSeparator/>
- </cell>
- </row>
-
- <!-- Incoming Batch Species -->
- <row>
- <cell anchor='west'>
- <JLabel id='speciesLabel'/>
- </cell>
- <cell weightx='1.0'>
- <JTextField id='speciesField'/>
- </cell>
- </row>
-
- <!-- Incoming Batch Total weight -->
- <row>
- <cell anchor='west'>
- <JLabel id='batchWeightLabel'/>
- </cell>
- <cell weightx='1.0'>
- <JTextField id='batchWeightField'/>
- </cell>
- </row>
-
- <!-- Sample Total weight -->
- <row>
- <cell anchor='west'>
- <JLabel id='sampleWeightLabel'/>
- </cell>
- <cell weightx='1.0'>
- <JTextField id='sampleWeightField'/>
- </cell>
- </row>
-
- </Table>
-
- <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>
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -1,428 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
-import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.ui.swing.TuttiUI;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategory;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
-import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.lang.ObjectUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-
-import javax.swing.JDialog;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.List;
-
-/**
- * Handler of {@link SplitSampleCategoryUI}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-public class SplitSampleCategoryUIHandler extends AbstractTuttiTableUIHandler<SplitSampleCategoryRowModel, SplitSampleCategoryUIModel> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(SplitSampleCategoryUIHandler.class);
-
- /**
- * Parent UI.
- *
- * @since 0.3
- */
- private final SpeciesBatchUI parentUi;
-
- /**
- * UI.
- *
- * @since 0.3
- */
- private final SplitSampleCategoryUI ui;
-
- public SplitSampleCategoryUIHandler(SpeciesBatchUI parentUi,
- SplitSampleCategoryUI ui) {
- super(parentUi.getHandler().getContext(),
- SplitSampleCategoryRowModel.PROPERTY_CATEGORY_VALUE,
- SplitSampleCategoryRowModel.PROPERTY_WEIGHT);
- this.parentUi = parentUi;
- this.ui = ui;
- }
-
- //------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
- //------------------------------------------------------------------------//
-
- @Override
- protected SplitSampleCategoryTableModel getTableModel() {
- return (SplitSampleCategoryTableModel) getTable().getModel();
- }
-
- @Override
- protected JXTable getTable() {
- return ui.getTable();
- }
-
- @Override
- protected boolean isRowValid(SplitSampleCategoryRowModel row) {
- //TODO
- return row.getCategoryValue() != null && row.getWeight() != null;
- }
-
- @Override
- protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SplitSampleCategoryRowModel> rowMonitor,
- SplitSampleCategoryRowModel row) {
- if (rowMonitor.wasModified()) {
-
- if (row.isValid()) {
- if (log.isInfoEnabled()) {
- log.info("Change row that was modified and valid");
- }
- }
-
- rowMonitor.clearModified();
- }
- }
-
- @Override
- protected void onRowModified(int rowIndex,
- SplitSampleCategoryRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
-
- super.onRowModified(rowIndex, row, propertyName, oldValue, newValue);
-
- if (SplitSampleCategoryRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
-
- // Need to recompute the sample weight
- computeSampleWeight(row);
- }
- }
-
- //------------------------------------------------------------------------//
- //-- AbstractTuttiUIHandler methods --//
- //------------------------------------------------------------------------//
-
- @Override
- protected SplitSampleCategoryUIModel getModel() {
- return ui.getModel();
- }
-
- @Override
- public void beforeInitUI() {
-
- SplitSampleCategoryUIModel model = new SplitSampleCategoryUIModel();
-
- ui.setContextValue(model);
- }
-
- @Override
- public void afterInitUI() {
-
- initUI(ui);
-
- SplitSampleCategoryUIModel model = getModel();
-
- //TODO Use protocol to have lengthStepCaracteristic to use (if any protocol)
- initBeanComboBox(ui.getCategoryComboBox(),
- Lists.<SampleCategoryType>newArrayList(),
- model.getSelectedCategory());
-
- // when category changed, remove selected category
- model.addPropertyChangeListener(SplitSampleCategoryUIModel.PROPERTY_CATEGORY, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
-
- SplitSampleCategoryUIModel source =
- (SplitSampleCategoryUIModel) evt.getSource();
-
- // unselect previous selected category
- source.setSelectedCategory(null);
-
- // fill comboBox with new list
- ui.getCategoryComboBox().setData((List<SampleCategoryType>) evt.getNewValue());
- }
- });
-
- // when selected category changed, regenerate the table model + add inside some default rows
- model.addPropertyChangeListener(SplitSampleCategoryUIModel.PROPERTY_SELECTED_CATEGORY, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
-
- SampleCategoryType newValue =
- (SampleCategoryType) evt.getNewValue();
- generateTableModel(newValue);
- }
- });
-
- // when sample weight changed, revalidate model
- model.addPropertyChangeListener(SplitSampleCategoryUIModel.PROPERTY_SAMPLE_WEIGHT, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
-
- validateModel();
- }
- });
-
- generateTableModel(null);
-
- initTable(getTable());
- }
-
- @Override
- public void onCloseUI() {
- }
-
- //------------------------------------------------------------------------//
- //-- Public methods --//
- //------------------------------------------------------------------------//
-
- public String decorateSpecies(Species object) {
- String result = object == null ? "" : super.decorate(object);
- return result;
- }
-
- public void editBatch(SpeciesBatchRowModel batch) {
-
- // get possible the last used
- List<SampleCategoryType> categories =
- Lists.newArrayList(SampleCategoryType.values());
-
- Float batchWeight = null;
-
- if (batch != null) {
- //TODO Use the samplingOrder
- List<String> samplingOrder =
- parentUi.getModel().getSamplingOrder();
-
- SampleCategory<?> lastCategory = null;
-
- if (batch.getSortedUnsortedSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.sortedUnsorted);
- lastCategory = batch.getSortedUnsortedSampleCategory();
- }
-
- if (batch.getSizeSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.size);
- lastCategory = batch.getSizeSampleCategory();
- }
-
- if (batch.getSexSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.sex);
- lastCategory = batch.getSexSampleCategory();
- }
-
- if (batch.getMaturitySampleCategory().isValid()) {
- categories.remove(SampleCategoryType.maturity);
- lastCategory = batch.getMaturitySampleCategory();
- }
-
- if (batch.getAgeSampleCategory().isValid()) {
- categories.remove(SampleCategoryType.age);
- lastCategory = batch.getAgeSampleCategory();
- }
-
-
- if (lastCategory == null) {
-
- // no category, then must only come from the weight
- batchWeight = batch.getWeight();
-
- } else {
-
- // use last category weight
- batchWeight = lastCategory.getCategoryWeight();
- }
- }
-
- SplitSampleCategoryUIModel model = getModel();
-
- model.setSampleWeight(null);
- model.setCategory(categories);
- model.setBatchWeight(batchWeight);
-
- // keep batch (will be used to push back editing entry)
- model.setBatch(batch);
- }
-
- public void close() {
-
- if (log.isInfoEnabled()) {
- log.info("Will close UI " + ui);
- }
-
- SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
- }
-
- //------------------------------------------------------------------------//
- //-- Internal methods --//
- //------------------------------------------------------------------------//
-
- protected void computeSampleWeight(SplitSampleCategoryRowModel row) {
-
- if (log.isInfoEnabled()) {
- log.info("Will recompute sample weight from row: " + row);
- }
-
- Float result = 0f;
- List<SplitSampleCategoryRowModel> rows = getTableModel().getRows();
- for (SplitSampleCategoryRowModel rowModel : rows) {
- Float weight = rowModel.getWeight();
- if (weight != null) {
- result += weight;
- }
- }
- getModel().setSampleWeight(result);
- }
-
- protected void validateModel() {
-
- SplitSampleCategoryUIModel model = getModel();
-
- int rowCount = model.getRowCount();
-
- // at least one row
- boolean valid = rowCount > 0;
-
- if (valid && !model.isSample()) {
-
- // sample Weight = batch weight
- valid = ObjectUtils.equals(model.getBatchWeight(),
- model.getSampleWeight());
- }
-
- model.setValid(valid);
- }
-
- protected void generateTableModel(SampleCategoryType category) {
-
- // when generate a new table model, then reset previous rows from model
- getModel().setRows(null);
-
- Caracteristic data = null;
-
- DefaultTableColumnModelExt columnModel =
- new DefaultTableColumnModelExt();
-
- boolean editableCategoryValue = false;
- if (category != null) {
-
- switch (category) {
-
- case sortedUnsorted:
- data = persistenceService.getSortedUnsortedCaracteristic();
- break;
- case size:
- data = persistenceService.getSizeCategoryCaracteristic();
- break;
- case sex:
- data = persistenceService.getSexCaracteristic();
- break;
- case maturity:
- data = persistenceService.getMaturityCaracteristic();
- break;
- case age:
- editableCategoryValue = true;
- addFloatColumnToModel(columnModel,
- SplitSampleCategoryTableModel.EDITABLE_CATEGORY_VALUE,
- TuttiUI.DECIMAL1_PATTERN);
- break;
- }
-
- if (data != null) {
-
- if (log.isInfoEnabled()) {
- log.info("Got " + data.sizeQualitativeValue() + " qualitative data to add");
- }
- addColumnToModel(columnModel,
- null,
- newTableCellRender(CaracteristicQualitativeValue.class),
- SplitSampleCategoryTableModel.READ_ONLY_CATEGORY_VALUE);
- }
- { // Weight
-
- addFloatColumnToModel(columnModel,
- SplitSampleCategoryTableModel.WEIGHT,
- TuttiUI.DECIMAL3_PATTERN);
- }
- }
-
- // create table model
- SplitSampleCategoryTableModel tableModel =
- new SplitSampleCategoryTableModel(columnModel, getModel());
-
- JXTable table = getTable();
-
- // remove all listener on tables we could add before
- uninstallTableSaveOnRowChangedSelectionListener();
-// uninstallTableKeyListener();
-
- if (log.isInfoEnabled()) {
- log.info("Install new table model " + tableModel);
- }
- table.setModel(tableModel);
- table.setColumnModel(columnModel);
-
- // install table listeners
- installTableSaveOnRowChangedSelectionListener();
-// installTableKeyListener(columnModel, table, editableCategoryValue);
-
- // fill datas
-
- List<SplitSampleCategoryRowModel> rows = Lists.newArrayList();
-
- if (data != null) {
-
- // add a row for each qualitive value
- for (CaracteristicQualitativeValue qualitativeValue : data.getQualitativeValue()) {
- if (log.isInfoEnabled()) {
- log.info("Add QV: " + qualitativeValue);
- }
- SplitSampleCategoryRowModel newRow = tableModel.createNewRow();
- newRow.setCategoryValue(qualitativeValue);
- rows.add(newRow);
- }
- }
-
- if (log.isInfoEnabled()) {
- log.info("Will add " + rows.size() + " rows in table model.");
- }
-
- getModel().setRows(rows);
- }
-
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -1,165 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
-
-/*
- * #%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.Species;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
-
-import java.util.List;
-
-/**
- * Model of {@link SplitSampleCategoryUI}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.3
- */
-public class SplitSampleCategoryUIModel extends AbstractTuttiTableUIModel<SpeciesBatchRowModel, SplitSampleCategoryRowModel, SplitSampleCategoryUIModel> {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_CATEGORY = "category";
-
- public static final String PROPERTY_SPECIES = "species";
-
- public static final String PROPERTY_SAMPLE = "sample";
-
- public static final String PROPERTY_SELECTED_CATEGORY = "selectedCategory";
-
- public static final String PROPERTY_BATCH_WEIGHT = "batchWeight";
-
- public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight";
-
- /**
- * Batch which fires the editor.
- *
- * @since 0.3
- */
- protected SpeciesBatchRowModel batch;
-
- /**
- * Sample categories.
- *
- * @since 0.3
- */
- protected List<SampleCategoryType> category;
-
- /**
- * Selected Sample category.
- *
- * @since 0.3
- */
- protected SampleCategoryType selectedCategory;
-
- /**
- * Flag when the batch to split is a sample.
- *
- * @since 0.3
- */
- protected boolean sample;
-
- /**
- * Incoming batch weight to split.
- *
- * @since 0.3
- */
- protected Float batchWeight;
-
- /**
- * Sample weight of split batches.
- *
- * @since 0.3
- */
- protected Float sampleWeight;
-
- public SplitSampleCategoryUIModel() {
- super(SpeciesBatchRowModel.class, null, null);
- }
-
- public SpeciesBatchRowModel getBatch() {
- return batch;
- }
-
- public void setBatch(SpeciesBatchRowModel batch) {
- Object oldSpecies = getSpecies();
- this.batch = batch;
- firePropertyChange(PROPERTY_SPECIES, oldSpecies, getSpecies());
- }
-
- public Species getSpecies() {
- return batch == null ? null : batch.getSpecies();
- }
-
- public List<SampleCategoryType> getCategory() {
- return category;
- }
-
- public void setCategory(List<SampleCategoryType> category) {
- Object oldValue = getCategory();
- this.category = category;
- firePropertyChange(PROPERTY_CATEGORY, oldValue, category);
- }
-
- public SampleCategoryType getSelectedCategory() {
- return selectedCategory;
- }
-
- public void setSelectedCategory(SampleCategoryType selectedCategory) {
- Object oldValue = getSelectedCategory();
- this.selectedCategory = selectedCategory;
- firePropertyChange(PROPERTY_SELECTED_CATEGORY, oldValue, selectedCategory);
- }
-
- public boolean isSample() {
- return sample;
- }
-
- public void setSample(boolean sample) {
- Object oldValue = isSample();
- this.sample = sample;
- firePropertyChange(PROPERTY_SAMPLE, oldValue, sample);
- }
-
- public Float getBatchWeight() {
- return batchWeight;
- }
-
- public void setBatchWeight(Float batchWeight) {
- Object oldValue = getBatchWeight();
- this.batchWeight = batchWeight;
- firePropertyChange(PROPERTY_BATCH_WEIGHT, oldValue, batchWeight);
- }
-
- public Float getSampleWeight() {
- return sampleWeight;
- }
-
- public void setSampleWeight(Float sampleWeight) {
- Object oldValue = getSampleWeight();
- this.sampleWeight = sampleWeight;
- firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight);
- }
-}
\ No newline at end of file
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java (from rev 134, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryRowModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchRowModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,116 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
+
+/*
+ * #%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.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.ui.swing.AbstractTuttiBeanUIModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategory;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
+
+import java.io.Serializable;
+
+/**
+ * A row in the {@link SplitSpeciesBatchUIModel}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class SplitSpeciesBatchRowModel
+ extends AbstractTuttiBeanUIModel<SplitSpeciesBatchRowModel, SplitSpeciesBatchRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_CATEGORY_VALUE = "categoryValue";
+
+ public static final String PROPERTY_WEIGHT = "weight";
+
+ /**
+ * Delegate sample category which contains category value + weight.
+ *
+ * @since 0.3
+ */
+ protected final SampleCategory<Serializable> category = SampleCategory.newSample(null);
+
+ protected static final Binder<SplitSpeciesBatchRowModel, SplitSpeciesBatchRowModel> fromBeanBinder =
+ BinderFactory.newBinder(SplitSpeciesBatchRowModel.class,
+ SplitSpeciesBatchRowModel.class);
+
+ protected static final Binder<SplitSpeciesBatchRowModel, SplitSpeciesBatchRowModel> toBeanBinder =
+ BinderFactory.newBinder(SplitSpeciesBatchRowModel.class,
+ SplitSpeciesBatchRowModel.class);
+
+ public SplitSpeciesBatchRowModel() {
+ super(SplitSpeciesBatchRowModel.class, fromBeanBinder, toBeanBinder);
+ }
+
+ public SampleCategoryType getCategoryType() {
+ return category.getCategoryType();
+ }
+
+ public void setCategoryType(SampleCategoryType categoryType) {
+ category.setCategoryType(categoryType);
+ }
+
+ public Serializable getCategoryValue() {
+ return category.getCategoryValue();
+ }
+
+ public void setCategoryValue(Serializable categoryValue) {
+ Object oldValue = getCategoryValue();
+ category.setCategoryValue(categoryValue);
+ firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
+ }
+
+ public void setCategoryValue(CaracteristicQualitativeValue categoryValue) {
+ Object oldValue = getCategoryValue();
+ category.setCategoryValue(categoryValue);
+ firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
+ }
+
+ public void setCategoryValue(Float categoryValue) {
+ Object oldValue = getCategoryValue();
+ category.setCategoryValue(categoryValue);
+ firePropertyChange(PROPERTY_CATEGORY_VALUE, oldValue, categoryValue);
+ }
+
+ public Float getWeight() {
+ return category.getCategoryWeight();
+ }
+
+ public void setWeight(Float weight) {
+ Object oldValue = getWeight();
+ category.setCategoryWeight(weight);
+ firePropertyChange(PROPERTY_WEIGHT, oldValue, weight);
+ }
+
+ //TODO Use validator
+ @Override
+ public boolean isValid() {
+ return category.isValid();
+ }
+
+}
\ No newline at end of file
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java (from rev 134, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryTableModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,78 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
+import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+
+import javax.swing.table.TableColumnModel;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * Table model of sample categories values.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class SplitSpeciesBatchTableModel
+ extends AbstractTuttiTableModel<SplitSpeciesBatchRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final ColumnIdentifier<SplitSpeciesBatchRowModel> EDITABLE_CATEGORY_VALUE = ColumnIdentifier.newId(
+ SplitSpeciesBatchRowModel.PROPERTY_CATEGORY_VALUE,
+ n_("tutti.table.species.sampleCategory.header.category"),
+ n_("tutti.table.species.sampleCategory.header.category"));
+
+ public static final ColumnIdentifier<SplitSpeciesBatchRowModel> READ_ONLY_CATEGORY_VALUE = ColumnIdentifier.newId(
+ SplitSpeciesBatchRowModel.PROPERTY_CATEGORY_VALUE,
+ n_("tutti.table.species.sampleCategory.header.category"),
+ n_("tutti.table.species.sampleCategory.header.category"));
+
+ public static final ColumnIdentifier<SplitSpeciesBatchRowModel> WEIGHT = ColumnIdentifier.newId(
+ SplitSpeciesBatchRowModel.PROPERTY_WEIGHT,
+ n_("tutti.table.species.sampleCategory.header.weight"),
+ n_("tutti.table.species.sampleCategory.header.weight"));
+
+ private final SplitSpeciesBatchUIModel uiModel;
+
+ public SplitSpeciesBatchTableModel(TableColumnModel columnModel,
+ SplitSpeciesBatchUIModel uiModel,
+ boolean createEmptyRowIsEmpty) {
+ super(columnModel, createEmptyRowIsEmpty, createEmptyRowIsEmpty);
+ this.uiModel = uiModel;
+ setNoneEditableCols(READ_ONLY_CATEGORY_VALUE);
+ }
+
+ @Override
+ public SplitSpeciesBatchRowModel createNewRow() {
+ SplitSpeciesBatchRowModel result = new SplitSpeciesBatchRowModel();
+ result.setCategoryType(uiModel.getSelectedCategory());
+ result.setValid(false);
+ return result;
+ }
+
+}
\ No newline at end of file
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css (from rev 134, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.css)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,121 @@
+/*
+ * #%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};
+}
+
+#splitPane {
+ orientation: {JSplitPane.VERTICAL_SPLIT};
+ resizeWeight: 0.8;
+ oneTouchExpandable: true;
+ continuousLayout: true;
+}
+
+#configurationPanel {
+ border: {new TitledBorder(null, _("tutti.legend.splitSpeciesBatchConfiguration"))};
+}
+
+#categoryLabel {
+ text: "tutti.label.sampleCategoryConfiguration.category";
+ labelFor: {categoryComboBox};
+}
+
+#categoryComboBox {
+ property: selectedCategory;
+ selectedItem: {model.getSelectedCategory()};
+}
+
+#sampleCheckBox {
+ text: "tutti.label.sampleCategoryConfiguration.sample";
+ selected: {model.isSample()};
+}
+
+#speciesLabel {
+ text: "tutti.label.sampleCategoryConfiguration.species";
+ labelFor: {speciesField};
+}
+
+#speciesField {
+ editable: false;
+ text: {handler.decorateSpecies(model.getSpecies())};
+}
+
+#batchWeightLabel {
+ text: "tutti.label.sampleCategoryConfiguration.batchWeight";
+ labelFor: {batchWeightField};
+}
+
+#batchWeightField {
+ editable: false;
+ text: {getStringValue(model.getBatchWeight())};
+}
+
+#sampleWeightLabel {
+ text: "tutti.label.sampleCategoryConfiguration.sampleWeight";
+ labelFor: {sampleWeightField};
+}
+
+#sampleWeightField {
+ editable: false;
+ text: {getStringValue(model.getSampleWeight())};
+}
+
+#table {
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+ enabled: {model.getSelectedCategory() != null}
+}
+
+#cancelButton {
+ actionIcon: cancel;
+ mnemonic: C;
+ text: "tutti.action.cancel";
+}
+
+#saveButton {
+ actionIcon: save;
+ mnemonic: S;
+ text: "tutti.action.save";
+ enabled: {model.isValid()};
+}
+
+#messagePanel {
+ border: {BorderFactory.createTitledBorder(_("tutti.title.messages"))};
+ /*height: 200;
+ width: 500;*/
+}
+
+#errorTable {
+ rowSelectionAllowed: true;
+ autoCreateRowSorter: true;
+ autoResizeMode: {JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS};
+ cellSelectionEnabled: false;
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ model: {errorTableModel};
+}
\ No newline at end of file
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx (from rev 134, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUI.jaxx)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUI.jaxx 2013-01-01 16:10:44 UTC (rev 135)
@@ -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%
+ -->
+<JPanel id='homePanel' layout='{new BorderLayout()}'
+ implements='fr.ifremer.tutti.ui.swing.TuttiUI<SplitSpeciesBatchUIModel, SplitSpeciesBatchUIHandler>'>
+
+ <import>
+ fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType
+ fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI
+
+ fr.ifremer.tutti.ui.swing.TuttiUI
+ fr.ifremer.tutti.ui.swing.TuttiUIContext
+
+ org.jdesktop.swingx.JXTable
+
+ jaxx.runtime.swing.editor.bean.BeanComboBox
+ jaxx.runtime.validator.swing.SwingValidatorUtil
+ jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
+
+ javax.swing.ListSelectionModel
+
+ java.awt.Color
+
+ static org.nuiton.i18n.I18n._
+ static jaxx.runtime.SwingUtil.getStringValue
+ </import>
+
+ <script><![CDATA[
+
+public SplitSpeciesBatchUI(SpeciesBatchUI parentUI) {
+ JAXXUtil.initContext(this, parentUI);
+ SplitSpeciesBatchUIHandler handler = new SplitSpeciesBatchUIHandler(parentUI, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+}
+
+protected void $afterCompleteSetup() { handler.afterInitUI(); }
+ ]]></script>
+
+ <SplitSpeciesBatchUIHandler id='handler'
+ initializer='getContextValue(SplitSpeciesBatchUIHandler.class)'/>
+
+ <SplitSpeciesBatchUIModel id='model'
+ initializer='getContextValue(SplitSpeciesBatchUIModel.class)'/>
+
+ <SwingValidatorMessageTableModel id='errorTableModel'/>
+
+ <BeanValidator id='validator' bean='model' errorTableModel='errorTableModel'
+ uiClass='jaxx.runtime.validator.swing.ui.ImageValidationUI'>
+ <field name='selectedCategory' component='categoryComboBox'/>
+ <field name='sample' component='sampleCheckBox'/>
+ <field name='sampleWeight' component='sampleWeightField'/>
+ </BeanValidator>
+
+ <JSplitPane id='splitPane' constraints='BorderLayout.CENTER'>
+
+ <JPanel layout='{new BorderLayout()}'>
+
+ <Table id='configurationPanel' fill='both'
+ constraints='BorderLayout.NORTH'>
+
+ <!-- SampleCategory choice -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='categoryLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <BeanComboBox id='categoryComboBox' constructorParams='this'
+ genericType='SampleCategoryType'/>
+ </cell>
+ </row>
+
+ <!-- Split as a sample or not ? -->
+ <row>
+ <cell columns='2'>
+ <JCheckBox id='sampleCheckBox'
+ onItemStateChanged='handler.setBoolean(event, "sample")'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns="2">
+ <JSeparator/>
+ </cell>
+ </row>
+
+ <!-- Incoming Batch Species -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='speciesLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <JTextField id='speciesField'/>
+ </cell>
+ </row>
+
+ <!-- Incoming Batch Total weight -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='batchWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <JTextField id='batchWeightField'/>
+ </cell>
+ </row>
+
+ <!-- Sample Total weight -->
+ <row>
+ <cell anchor='west'>
+ <JLabel id='sampleWeightLabel'/>
+ </cell>
+ <cell weightx='1.0'>
+ <JTextField id='sampleWeightField'/>
+ </cell>
+ </row>
+
+ </Table>
+
+ <JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
+ <JXTable id='table'/>
+ </JScrollPane>
+
+ <!-- actions -->
+ <JPanel id='actionPanel' layout='{new GridLayout(1, 0)}'
+ constraints='BorderLayout.SOUTH'>
+ <JButton id='cancelButton' onActionPerformed='handler.cancel()'/>
+ <JButton id='saveButton' onActionPerformed='handler.save()'/>
+ </JPanel>
+
+ </JPanel>
+ <!-- Messages report -->
+ <JPanel id='messagePanel' layout='{new GridLayout()}'>
+ <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
+ <JTable id='errorTable'/>
+ </JScrollPane>
+ </JPanel>
+ </JSplitPane>
+
+
+</JPanel>
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java (from rev 134, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIHandler.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,456 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.ui.swing.TuttiUI;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategory;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
+
+import javax.swing.JDialog;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+/**
+ * Handler of {@link SplitSpeciesBatchUI}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class SplitSpeciesBatchUIHandler
+ extends AbstractTuttiTableUIHandler<SplitSpeciesBatchRowModel, SplitSpeciesBatchUIModel> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(SplitSpeciesBatchUIHandler.class);
+
+ /**
+ * Parent UI.
+ *
+ * @since 0.3
+ */
+ private final SpeciesBatchUI parentUi;
+
+ /**
+ * UI.
+ *
+ * @since 0.3
+ */
+ private final SplitSpeciesBatchUI ui;
+
+ public SplitSpeciesBatchUIHandler(SpeciesBatchUI parentUi,
+ SplitSpeciesBatchUI ui) {
+ super(parentUi.getHandler().getContext(),
+ SplitSpeciesBatchRowModel.PROPERTY_CATEGORY_VALUE,
+ SplitSpeciesBatchRowModel.PROPERTY_WEIGHT);
+ this.parentUi = parentUi;
+ this.ui = ui;
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ protected SplitSpeciesBatchTableModel getTableModel() {
+ return (SplitSpeciesBatchTableModel) getTable().getModel();
+ }
+
+ @Override
+ protected JXTable getTable() {
+ return ui.getTable();
+ }
+
+ @Override
+ protected boolean isRowValid(SplitSpeciesBatchRowModel row) {
+ //TODO
+ return row.getCategoryValue() != null && row.getWeight() != null;
+ }
+
+ @Override
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<SplitSpeciesBatchRowModel> rowMonitor,
+ SplitSpeciesBatchRowModel row) {
+ if (rowMonitor.wasModified()) {
+
+ if (row.isValid()) {
+ if (log.isInfoEnabled()) {
+ log.info("Change row that was modified and valid");
+ }
+ }
+
+ rowMonitor.clearModified();
+ }
+ }
+
+ @Override
+ protected void onRowModified(int rowIndex,
+ SplitSpeciesBatchRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+
+ recomputeRowValidState(row);
+
+ if (SplitSpeciesBatchRowModel.PROPERTY_WEIGHT.equals(propertyName)) {
+
+ // Need to recompute the sample weight
+ computeSampleWeight(row);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ protected SplitSpeciesBatchUIModel getModel() {
+ return ui.getModel();
+ }
+
+ @Override
+ public void beforeInitUI() {
+
+ SplitSpeciesBatchUIModel model = new SplitSpeciesBatchUIModel();
+
+ ui.setContextValue(model);
+ }
+
+ @Override
+ public void afterInitUI() {
+
+ initUI(ui);
+
+ SplitSpeciesBatchUIModel model = getModel();
+
+ //TODO Use protocol to have lengthStepCaracteristic to use (if any protocol)
+ initBeanComboBox(ui.getCategoryComboBox(),
+ Lists.<SampleCategoryType>newArrayList(),
+ model.getSelectedCategory());
+
+ // when category changed, remove selected category
+ model.addPropertyChangeListener(SplitSpeciesBatchUIModel.PROPERTY_CATEGORY, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ SplitSpeciesBatchUIModel source =
+ (SplitSpeciesBatchUIModel) evt.getSource();
+
+ // unselect previous selected category
+ source.setSelectedCategory(null);
+
+ // fill comboBox with new list
+ ui.getCategoryComboBox().setData((List<SampleCategoryType>) evt.getNewValue());
+ }
+ });
+
+ // when selected category changed, regenerate the table model + add inside some default rows
+ model.addPropertyChangeListener(SplitSpeciesBatchUIModel.PROPERTY_SELECTED_CATEGORY, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ SplitSpeciesBatchUIModel source =
+ (SplitSpeciesBatchUIModel) evt.getSource();
+
+ // when selected category change, sample total weight is reset
+ source.setSampleWeight(null);
+
+ SampleCategoryType newValue =
+ (SampleCategoryType) evt.getNewValue();
+ generateTableModel(newValue);
+ }
+ });
+
+ // when sample weight changed, revalidate model
+ model.addPropertyChangeListener(SplitSpeciesBatchUIModel.PROPERTY_SAMPLE_WEIGHT, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ validateModel();
+ }
+ });
+
+ generateTableModel(null);
+
+ initTable(getTable());
+
+ SwingValidatorUtil.installUI(ui.getErrorTable(),
+ new SwingValidatorMessageTableRenderer());
+
+ listenValidatorValid(ui.getValidator(), model);
+ }
+
+ @Override
+ public void onCloseUI() {
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
+ public String decorateSpecies(Species object) {
+ String result = object == null ? "" : super.decorate(object);
+ return result;
+ }
+
+ public void editBatch(SpeciesBatchRowModel batch) {
+
+ // get possible the last used
+ List<SampleCategoryType> categories =
+ Lists.newArrayList(SampleCategoryType.values());
+
+ Float batchWeight = null;
+
+ if (batch != null) {
+ //TODO Use the samplingOrder
+ List<SampleCategoryType> samplingOrder =
+ parentUi.getModel().getSamplingOrder();
+
+ SampleCategory<?> lastCategory = null;
+
+ if (batch.getSortedUnsortedSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.sortedUnsorted);
+ lastCategory = batch.getSortedUnsortedSampleCategory();
+ }
+
+ if (batch.getSizeSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.size);
+ lastCategory = batch.getSizeSampleCategory();
+ }
+
+ if (batch.getSexSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.sex);
+ lastCategory = batch.getSexSampleCategory();
+ }
+
+ if (batch.getMaturitySampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.maturity);
+ lastCategory = batch.getMaturitySampleCategory();
+ }
+
+ if (batch.getAgeSampleCategory().isValid()) {
+ categories.remove(SampleCategoryType.age);
+ lastCategory = batch.getAgeSampleCategory();
+ }
+
+
+ if (lastCategory == null) {
+
+ // no category, then must only come from the weight
+ batchWeight = batch.getWeight();
+
+ } else {
+
+ // use last category weight
+ batchWeight = lastCategory.getCategoryWeight();
+ }
+ }
+
+ SplitSpeciesBatchUIModel model = getModel();
+
+ model.setSampleWeight(null);
+ model.setCategory(categories);
+ model.setBatchWeight(batchWeight);
+
+ // keep batch (will be used to push back editing entry)
+ model.setBatch(batch);
+ }
+
+ public void cancel() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Cancel UI " + ui);
+ }
+
+ editBatch(null);
+
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
+
+ public void save() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Save UI " + ui);
+ }
+
+ SwingUtil.getParentContainer(ui, JDialog.class).setVisible(false);
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected void computeSampleWeight(SplitSpeciesBatchRowModel row) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Will recompute sample weight from row: " + row);
+ }
+
+ Float result = 0f;
+ List<SplitSpeciesBatchRowModel> rows = getTableModel().getRows();
+ for (SplitSpeciesBatchRowModel rowModel : rows) {
+ Float weight = rowModel.getWeight();
+ if (weight != null) {
+ result += weight;
+ }
+ }
+ getModel().setSampleWeight(result);
+ }
+
+ protected void validateModel() {
+
+ SplitSpeciesBatchUIModel model = getModel();
+
+ int rowCount = model.getRowCount();
+
+ // at least one row
+ boolean valid = rowCount > 0;
+
+ if (valid && !model.isSample()) {
+
+ // sample Weight = batch weight
+ valid = ObjectUtils.equals(model.getBatchWeight(),
+ model.getSampleWeight());
+ }
+
+ model.setValid(valid);
+ }
+
+ protected void generateTableModel(SampleCategoryType category) {
+
+ // when generate a new table model, then reset previous rows from model
+ getModel().setRows(null);
+
+ Caracteristic data = null;
+
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+
+ boolean editableCategoryValue = false;
+ if (category != null) {
+
+ switch (category) {
+
+ case sortedUnsorted:
+ data = persistenceService.getSortedUnsortedCaracteristic();
+ break;
+ case size:
+ data = persistenceService.getSizeCategoryCaracteristic();
+ break;
+ case sex:
+ data = persistenceService.getSexCaracteristic();
+ break;
+ case maturity:
+ data = persistenceService.getMaturityCaracteristic();
+ break;
+ case age:
+ editableCategoryValue = true;
+ addFloatColumnToModel(columnModel,
+ SplitSpeciesBatchTableModel.EDITABLE_CATEGORY_VALUE,
+ TuttiUI.DECIMAL1_PATTERN);
+ break;
+ }
+
+ if (data != null) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Got " + data.sizeQualitativeValue() + " qualitative data to add");
+ }
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(CaracteristicQualitativeValue.class),
+ SplitSpeciesBatchTableModel.READ_ONLY_CATEGORY_VALUE);
+ }
+ { // Weight
+
+ addFloatColumnToModel(columnModel,
+ SplitSpeciesBatchTableModel.WEIGHT,
+ TuttiUI.DECIMAL3_PATTERN);
+ }
+ }
+
+ // create table model
+ SplitSpeciesBatchTableModel tableModel =
+ new SplitSpeciesBatchTableModel(columnModel,
+ getModel(),
+ editableCategoryValue);
+
+ JXTable table = getTable();
+
+ // remove all listener on tables we could add before
+ uninstallTableSaveOnRowChangedSelectionListener();
+ uninstallTableKeyListener();
+
+ if (log.isInfoEnabled()) {
+ log.info("Install new table model " + tableModel);
+ }
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
+
+ // install table listeners
+ installTableSaveOnRowChangedSelectionListener();
+ installTableKeyListener(columnModel, table);
+
+ // fill datas
+
+ List<SplitSpeciesBatchRowModel> rows = Lists.newArrayList();
+
+ if (data != null) {
+
+ // add a row for each qualitive value
+ for (CaracteristicQualitativeValue qualitativeValue : data.getQualitativeValue()) {
+ if (log.isInfoEnabled()) {
+ log.info("Add QV: " + qualitativeValue);
+ }
+ SplitSpeciesBatchRowModel newRow = tableModel.createNewRow();
+ newRow.setCategoryValue(qualitativeValue);
+ rows.add(newRow);
+ }
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Will add " + rows.size() + " rows in table model " +
+ "(can add a first empty row? " + editableCategoryValue + ").");
+ }
+
+ getModel().setRows(rows);
+ }
+
+}
\ No newline at end of file
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java (from rev 134, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSampleCategoryUIModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,166 @@
+package fr.ifremer.tutti.ui.swing.content.operation.catches.species.split;
+
+/*
+ * #%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.Species;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SampleCategoryType;
+import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
+
+import java.util.List;
+
+/**
+ * Model of {@link SplitSpeciesBatchUI}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.3
+ */
+public class SplitSpeciesBatchUIModel
+ extends AbstractTuttiTableUIModel<SpeciesBatchRowModel, SplitSpeciesBatchRowModel, SplitSpeciesBatchUIModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_CATEGORY = "category";
+
+ public static final String PROPERTY_SPECIES = "species";
+
+ public static final String PROPERTY_SAMPLE = "sample";
+
+ public static final String PROPERTY_SELECTED_CATEGORY = "selectedCategory";
+
+ public static final String PROPERTY_BATCH_WEIGHT = "batchWeight";
+
+ public static final String PROPERTY_SAMPLE_WEIGHT = "sampleWeight";
+
+ /**
+ * Batch which fires the editor.
+ *
+ * @since 0.3
+ */
+ protected SpeciesBatchRowModel batch;
+
+ /**
+ * Sample categories.
+ *
+ * @since 0.3
+ */
+ protected List<SampleCategoryType> category;
+
+ /**
+ * Selected Sample category.
+ *
+ * @since 0.3
+ */
+ protected SampleCategoryType selectedCategory;
+
+ /**
+ * Flag when the batch to split is a sample.
+ *
+ * @since 0.3
+ */
+ protected boolean sample;
+
+ /**
+ * Incoming batch weight to split.
+ *
+ * @since 0.3
+ */
+ protected Float batchWeight;
+
+ /**
+ * Sample weight of split batches.
+ *
+ * @since 0.3
+ */
+ protected Float sampleWeight;
+
+ public SplitSpeciesBatchUIModel() {
+ super(SpeciesBatchRowModel.class, null, null);
+ }
+
+ public SpeciesBatchRowModel getBatch() {
+ return batch;
+ }
+
+ public void setBatch(SpeciesBatchRowModel batch) {
+ Object oldSpecies = getSpecies();
+ this.batch = batch;
+ firePropertyChange(PROPERTY_SPECIES, oldSpecies, getSpecies());
+ }
+
+ public Species getSpecies() {
+ return batch == null ? null : batch.getSpecies();
+ }
+
+ public List<SampleCategoryType> getCategory() {
+ return category;
+ }
+
+ public void setCategory(List<SampleCategoryType> category) {
+ Object oldValue = getCategory();
+ this.category = category;
+ firePropertyChange(PROPERTY_CATEGORY, oldValue, category);
+ }
+
+ public SampleCategoryType getSelectedCategory() {
+ return selectedCategory;
+ }
+
+ public void setSelectedCategory(SampleCategoryType selectedCategory) {
+ Object oldValue = getSelectedCategory();
+ this.selectedCategory = selectedCategory;
+ firePropertyChange(PROPERTY_SELECTED_CATEGORY, oldValue, selectedCategory);
+ }
+
+ public boolean isSample() {
+ return sample;
+ }
+
+ public void setSample(boolean sample) {
+ Object oldValue = isSample();
+ this.sample = sample;
+ firePropertyChange(PROPERTY_SAMPLE, oldValue, sample);
+ }
+
+ public Float getBatchWeight() {
+ return batchWeight;
+ }
+
+ public void setBatchWeight(Float batchWeight) {
+ Object oldValue = getBatchWeight();
+ this.batchWeight = batchWeight;
+ firePropertyChange(PROPERTY_BATCH_WEIGHT, oldValue, batchWeight);
+ }
+
+ public Float getSampleWeight() {
+ return sampleWeight;
+ }
+
+ public void setSampleWeight(Float sampleWeight) {
+ Object oldValue = getSampleWeight();
+ this.sampleWeight = sampleWeight;
+ firePropertyChange(PROPERTY_SAMPLE_WEIGHT, oldValue, sampleWeight);
+ }
+}
\ No newline at end of file
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTabUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -86,6 +86,15 @@
}
@Override
+ protected void onRowModified(int rowIndex,
+ EnvironmentRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<EnvironmentRowModel> rowMonitor,
EnvironmentRowModel row) {
// getModel().setCaracteristic(row.getKey(), row.getValue());
Modified: 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/operation/fishing/environment/EnvironmentTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/environment/EnvironmentTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -50,7 +50,7 @@
n_("tutti.table.fishing.environment.header.value"));
public EnvironmentTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, false, false);
setNoneEditableCols(KEY);
}
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTabUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -86,6 +86,15 @@
}
@Override
+ protected void onRowModified(int rowIndex,
+ GearShootingRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<GearShootingRowModel> rowMonitor,
GearShootingRowModel row) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/gearshooting/GearShootingTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -50,7 +50,7 @@
n_("tutti.table.fishing.gearShooting.header.value"));
public GearShootingTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, false, false);
setNoneEditableCols(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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTabUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -29,6 +29,7 @@
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.content.operation.fishing.environment.EnvironmentRowModel;
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;
@@ -92,6 +93,24 @@
}
@Override
+ protected boolean isRowValid(HydrologyRowModel row) {
+ //TODO
+ return row.getGearShootingStartValue() != null ||
+ row.getGearShootingEndValue() != null ||
+ row.getAverageValue() != null;
+ }
+
+
+ @Override
+ protected void onRowModified(int rowIndex,
+ HydrologyRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
protected void saveSelectedRowIfRequired(TuttiBeanMonitor<HydrologyRowModel> rowMonitor,
HydrologyRowModel row) {
@@ -115,14 +134,6 @@
getModel().addCaracteristics(map);
}
- @Override
- protected boolean isRowValid(HydrologyRowModel row) {
- //TODO
- return row.getGearShootingStartValue() != null ||
- row.getGearShootingEndValue() != null ||
- row.getAverageValue() != null;
- }
-
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/hydrology/HydrologyTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -60,7 +60,7 @@
n_("tutti.table.fishing.hydrology.header.averageValue"));
public HydrologyTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, false, false);
setNoneEditableCols(KEY);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -87,8 +87,8 @@
#errorTable {
rowSelectionAllowed: true;
autoCreateRowSorter: true;
- autoResizeMode: 2;
+ autoResizeMode: {JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS};
cellSelectionEnabled: false;
- selectionMode: 0;
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
model: {errorTableModel};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.jaxx 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/program/EditProgramUI.jaxx 2013-01-01 16:10:44 UTC (rev 135)
@@ -33,6 +33,7 @@
jaxx.runtime.validator.swing.SwingValidatorMessageTableModel
java.awt.Dimension
+ javax.swing.ListSelectionModel
static org.nuiton.i18n.I18n._
static jaxx.runtime.SwingUtil.getStringValue
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolSpeciesTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -75,7 +75,7 @@
private static final long serialVersionUID = 1L;
public EditProtocolSpeciesTableModel(TableColumnModel columnModel) {
- super(columnModel);
+ super(columnModel, false, false);
setNoneEditableCols(SPECIES_ID);
}
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-01-01 16:10:44 UTC (rev 135)
@@ -72,16 +72,16 @@
#messagePanel {
border: {BorderFactory.createTitledBorder(_("tutti.title.messages"))};
- height: 200;
- width: 500;
+ /*height: 200;
+ width: 500;*/
}
#errorTable {
rowSelectionAllowed: true;
autoCreateRowSorter: true;
- autoResizeMode: 2;
+ autoResizeMode: {JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS};
cellSelectionEnabled: false;
- selectionMode: 0;
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
model: {errorTableModel};
}
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -24,6 +24,7 @@
* #L%
*/
+import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.Lists;
@@ -125,23 +126,21 @@
}
@Override
- protected void saveSelectedRowIfRequired(TuttiBeanMonitor<EditProtocolSpeciesRowModel> rowMonitor,
- EditProtocolSpeciesRowModel row) {
-
- // nothing to save when row changes, model is marked to be save
- // when a row has changed and is valid or other protocol properties are modified
- }
-
- @Override
protected void onRowModified(int rowIndex,
EditProtocolSpeciesRowModel row,
String propertyName,
Object oldValue,
Object newValue) {
- super.onRowModified(rowIndex, row, propertyName, oldValue, newValue);
- if (row.isValid()) {
+ recomputeRowValidState(row);
+ }
+
+ @Override
+ protected void onRowValidStateChanged(int rowIndex, EditProtocolSpeciesRowModel row, Boolean oldValue, Boolean newValue) {
+ super.onRowValidStateChanged(rowIndex, row, oldValue, newValue);
+
+ if (row != null && row.isModify() && newValue != null && newValue) {
// row was modified and is valid, we can save protocol
// even if after the row becomes again not valid, this is not a
// problem since we will only save valid data!
@@ -149,6 +148,14 @@
}
}
+ @Override
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<EditProtocolSpeciesRowModel> rowMonitor,
+ EditProtocolSpeciesRowModel row) {
+
+ // nothing to save when row changes, model is marked to be save
+ // when a row has changed and is valid or other protocol properties are modified
+ }
+
//------------------------------------------------------------------------//
//-- AbstractTuttiUIHandler methods --//
//------------------------------------------------------------------------//
@@ -163,7 +170,7 @@
EditProtocolUIModel model = new EditProtocolUIModel();
- // can't load directly model fro database here, since we want to
+ // can't load directly model from database here, since we want to
// fill only the model with rows (transformed from speciesProtocol)
// As we still don't have the table model at this point, wait the
// afterUI method to fill model
@@ -177,6 +184,7 @@
allLengthStepPmfm = TuttiEntities.splitById(
persistenceService.getAllSpeciesLengthStepCaracteristic());
+ hydroCaracteristics = ArrayListMultimap.create();
for (Caracteristic caracteristic :
persistenceService.getAllFishingOperationHydrologicCaracteristic()) {
String name = HydrologicCaracteristicUtil.getGlobalName(caracteristic.getName());
@@ -251,6 +259,8 @@
List<Species> speciesList = Lists.newArrayList(allSpecies.values());
+ List<EditProtocolSpeciesRowModel> rows = Lists.newArrayList();
+
// load protocol if existing
String protocolId = context.getProtocolId();
@@ -269,7 +279,6 @@
model.fromBean(protocol);
// build speciesProtocol rows
- List<EditProtocolSpeciesRowModel> rows = Lists.newArrayList();
List<SpeciesProtocol> speciesProtocols = protocol.getSpecies();
if (CollectionUtils.isNotEmpty(speciesProtocols)) {
@@ -287,11 +296,11 @@
log.debug("Will edit protocol: " + protocolId + " with " +
rows.size() + " species declared.");
}
-
- // set to model ( will propagate to tableModel)
- model.setRows(rows);
}
+ // set to model ( will propagate to tableModel)
+ model.setRows(rows);
+
// init species combo box
initBeanComboBox(ui.getSpeciesComboBox(), speciesList, null);
selectFirstInCombo(ui.getSpeciesComboBox());
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractSelectTableAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractSelectTableAction.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractSelectTableAction.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -44,22 +44,24 @@
private static final Log log =
LogFactory.getLog(AbstractSelectTableAction.class);
- private final JTable table;
+ public static void doSelectCell(JTable table,
+ int rowIndex,
+ int columnIndex) {
+ table.setColumnSelectionInterval(columnIndex, columnIndex);
+ table.setRowSelectionInterval(rowIndex, rowIndex);
+ table.editCellAt(rowIndex, columnIndex);
+ }
+
private final M model;
+ private final JTable table;
+
public AbstractSelectTableAction(M model, JTable table) {
this.model = model;
this.table = table;
}
- public static void doSelectCell(JTable table, int rowIndex, int columnIndex) {
-
- table.setColumnSelectionInterval(columnIndex, columnIndex);
- table.setRowSelectionInterval(rowIndex, rowIndex);
- table.editCellAt(rowIndex, columnIndex);
- }
-
protected void doSelectCell(int rowIndex, int columnIndex) {
if (log.isDebugEnabled()) {
@@ -69,7 +71,6 @@
doSelectCell(table, rowIndex, columnIndex);
}
-
protected int getSelectedRow() {
int result = table.getSelectedRow();
return result;
@@ -89,9 +90,17 @@
}
protected boolean isCellEditable(int rowIndex, int columnIndex) {
- return table.isCellEditable(rowIndex, columnIndex);
+ boolean result;
+ result = rowIndex > -1 && columnIndex > -1 &&
+// rowIndex < getRowCount() && columnIndex < getColumnCount() &&
+ table.isCellEditable(rowIndex, columnIndex);
+ return result;
}
+ protected boolean isCreateNewRow() {
+ return model.isCreateNewRow();
+ }
+
protected String getCellCoordinate(int rowIndex, int columnIndex) {
return " [" + rowIndex + ", " + columnIndex + "]";
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -79,9 +79,27 @@
*/
protected Set<ColumnIdentifier<?>> noneEditableCols;
+ /**
+ * Creates a new row when moving to next editable cell / row ?
+ *
+ * @since 0.3
+ */
+ protected final boolean createNewRow;
+
+ /**
+ * Creates a first empty row when setting a null or empty list of rows ?
+ *
+ * @since 0.3
+ */
+ protected final boolean createEmptyRowIsEmpty;
+
public abstract R createNewRow();
- protected AbstractTuttiTableModel(TableColumnModel columnModel) {
+ protected AbstractTuttiTableModel(TableColumnModel columnModel,
+ boolean createNewRow,
+ boolean createEmptyRowIsEmpty) {
+ this.createNewRow = createNewRow;
+ this.createEmptyRowIsEmpty = createEmptyRowIsEmpty;
int nbcols = columnModel.getColumnCount();
columns = new TableColumn[nbcols];
columnIdentifiers = Lists.newArrayList();
@@ -97,16 +115,15 @@
}
public final void setRows(List<R> data) {
- setRows(data, true);
- }
- public final void setRows(List<R> data, boolean checkEmpty) {
-
// can't accept a empty data list
Preconditions.checkNotNull(data, "Data list can not be null.");
- if (checkEmpty && data.isEmpty()) {
+ if (createEmptyRowIsEmpty && data.isEmpty()) {
+ if (log.isInfoEnabled()) {
+ log.info("Creates a first empty row on tableModel " + this);
+ }
// add a first edit line
data.add(createNewRow());
}
@@ -118,6 +135,14 @@
fireTableDataChanged();
}
+ public boolean isCreateNewRow() {
+ return createNewRow;
+ }
+
+ public boolean isCreateEmptyRowIsEmpty() {
+ return createEmptyRowIsEmpty;
+ }
+
public final void addNewRow() {
R newValue = createNewRow();
addNewRow(newValue);
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -53,7 +53,9 @@
import javax.swing.JComboBox;
import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
import javax.swing.border.LineBorder;
+import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
@@ -105,6 +107,23 @@
protected abstract boolean isRowValid(R row);
/**
+ * Invoke each time the {@link AbstractTuttiBeanUIModel#modify} state on
+ * the current selected row changed.
+ *
+ * @param rowIndex row index of the modified row
+ * @param row modified row
+ * @param propertyName name of the modified property of the row
+ * @param oldValue old value of the modified property
+ * @param newValue new value of the modified property
+ * @since 0.3
+ */
+ protected abstract void onRowModified(int rowIndex,
+ R row,
+ String propertyName,
+ Object oldValue,
+ Object newValue);
+
+ /**
* Given the row monitor and his monitored row, try to save it if required.
* <p/>
* Coming in this method, we are sure that row is not null.
@@ -165,6 +184,11 @@
(Boolean) newValue);
} else if (!propertiesToSkip.contains(propertyName)) {
+ if (log.isInfoEnabled()) {
+ log.info("row [" + rowIndex + "] property " +
+ propertyName + " changed from " + oldValue +
+ " to " + newValue);
+ }
onRowModified(rowIndex, row,
propertyName,
oldValue,
@@ -200,34 +224,20 @@
}
protected void onModelRowsChanged(List<R> rows) {
+ if (log.isInfoEnabled()) {
+ log.info("Will set " + (rows == null ? 0 : rows.size()) +
+ " rows on model.");
+ }
if (CollectionUtils.isNotEmpty(rows)) {
+
+ // compute valid state for each row
for (R row : rows) {
- boolean rowIsValid = isRowValid(row);
- row.setValid(rowIsValid);
+ recomputeRowValidState(row);
}
}
getTableModel().setRows(rows);
}
- protected void onRowModified(int rowIndex,
- R row,
- String propertyName,
- Object oldValue,
- Object newValue) {
-
- if (log.isInfoEnabled()) {
- log.info("row [" + rowIndex + "] property " +
- propertyName + " changed from " + oldValue +
- " to " + newValue);
- }
-
- // recompute row valid state
- boolean valid = isRowValid(row);
-
- // apply it to row
- row.setValid(valid);
- }
-
protected void onRowModifyStateChanged(int rowIndex,
R row,
Boolean oldValue,
@@ -253,6 +263,16 @@
}
}
+ protected void onAfterSelectedRowChanged(int oldRowIndex,
+ R oldRow,
+ int newRowIndex,
+ R newRow) {
+ if (log.isInfoEnabled()) {
+ log.info("Selected row changed from [" + oldRowIndex + "] to [" +
+ newRowIndex + "]");
+ }
+ }
+
//------------------------------------------------------------------------//
//-- Internal methods (init methods) --//
//------------------------------------------------------------------------//
@@ -424,12 +444,48 @@
// create new listener
// save when row chaged and was modified
- tableSelectionListener = new TableRowModificationListener<R>(
- getTableModel(), rowMonitor) {
+ tableSelectionListener = new ListSelectionListener() {
+ /**
+ * Current selected row index.
+ *
+ * @since 0.3
+ */
+ protected int selectedRowIndex;
+
@Override
- protected void saveSelectedRow() {
+ public void valueChanged(ListSelectionEvent e) {
- saveSelectedRowIfNeeded();
+ if (!e.getValueIsAdjusting()) {
+ ListSelectionModel source = (ListSelectionModel) e.getSource();
+
+ int oldRowIndex = selectedRowIndex;
+ R oldRow = rowMonitor.getBean();
+
+ int newRowIndex = source.getLeadSelectionIndex();
+ R newRow;
+
+ if (source.isSelectionEmpty()) {
+
+ newRow = null;
+ } else {
+ newRow = getTableModel().getEntry(newRowIndex);
+ }
+
+ // save selected entry if required
+ saveSelectedRowIfNeeded();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Will monitor entry: " + newRow);
+ }
+ rowMonitor.setBean(newRow);
+
+ selectedRowIndex = newRowIndex;
+
+ onAfterSelectedRowChanged(oldRowIndex,
+ oldRow,
+ selectedRowIndex,
+ rowMonitor.getBean());
+ }
}
};
@@ -455,7 +511,7 @@
}
protected void installTableKeyListener(TableColumnModel columnModel,
- JTable table, boolean canCreateRow) {
+ JTable table) {
Preconditions.checkState(
keyAdapter == null,
@@ -464,33 +520,34 @@
AbstractTuttiTableModel<R> model = getTableModel();
final MoveToNextEditableCellAction nextCellAction =
- MoveToNextEditableCellAction.newAction(model, table, canCreateRow);
+ MoveToNextEditableCellAction.newAction(model, table);
final MoveToPreviousEditableCellAction previousCellAction =
MoveToPreviousEditableCellAction.newAction(model, table);
final MoveToNextEditableRowAction nextRowAction =
- MoveToNextEditableRowAction.newAction(model, table, canCreateRow);
+ MoveToNextEditableRowAction.newAction(model, table);
final MoveToPreviousEditableRowAction previousRowAction =
MoveToPreviousEditableRowAction.newAction(model, table);
- // Key adapter à ajouter sur les éditeurs où l'on souhaite gérer les
- // touches "entrer", "gauche", "droite" de facon personnalisée.
keyAdapter = new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_ENTER ||
- e.getKeyCode() == KeyEvent.VK_RIGHT ||
- e.getKeyCode() == KeyEvent.VK_TAB) {
+
+ int keyCode = e.getKeyCode();
+ if (keyCode == KeyEvent.VK_LEFT ||
+ (keyCode == KeyEvent.VK_TAB && e.isShiftDown())) {
e.consume();
+ previousCellAction.actionPerformed(null);
+ } else if (//e.getKeyCode() == KeyEvent.VK_ENTER ||
+ keyCode == KeyEvent.VK_RIGHT ||
+ keyCode == KeyEvent.VK_TAB) {
+ e.consume();
nextCellAction.actionPerformed(null);
- } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
+ } else if (keyCode == KeyEvent.VK_UP) {
e.consume();
- previousCellAction.actionPerformed(null);
- } else if (e.getKeyCode() == KeyEvent.VK_UP) {
- e.consume();
previousRowAction.actionPerformed(null);
- } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
+ } else if (keyCode == KeyEvent.VK_DOWN) {
e.consume();
nextRowAction.actionPerformed(null);
}
@@ -549,4 +606,12 @@
}
}
+ protected final void recomputeRowValidState(R row) {
+
+ // recompute row valid state
+ boolean valid = isRowValid(row);
+
+ // apply it to row
+ row.setValid(valid);
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIModel.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIModel.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -56,12 +56,13 @@
}
public void setRows(List<R> rows) {
- Object oldValue = getRows();
if (rows == null) {
rows = Lists.newArrayList();
}
this.rows = rows;
- firePropertyChange(PROPERTY_ROWS, oldValue, rows);
+
+ // always propagates (since empty list will not fire and we want it)
+ firePropertyChange(PROPERTY_ROWS, null, rows);
}
public int getRowCount() {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableCellAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableCellAction.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableCellAction.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -44,20 +44,12 @@
private static final Log log =
LogFactory.getLog(MoveToNextEditableCellAction.class);
- public static <M extends AbstractTuttiTableModel> MoveToNextEditableCellAction<M> newAction(M model, JTable table, boolean canCreateRow) {
- return new MoveToNextEditableCellAction<M>(model, table, canCreateRow);
+ public static <M extends AbstractTuttiTableModel> MoveToNextEditableCellAction<M> newAction(M model, JTable table) {
+ return new MoveToNextEditableCellAction<M>(model, table);
}
- /**
- * Can create new row if reach the end of editable cells ?
- *
- * @since 0.3
- */
- private final boolean canCreateRow;
-
- protected MoveToNextEditableCellAction(M model, JTable table, boolean canCreateRow) {
+ protected MoveToNextEditableCellAction(M model, JTable table) {
super(model, table);
- this.canCreateRow = canCreateRow;
}
@Override
@@ -89,7 +81,8 @@
if (currentRow == rowCount) {
- if (canCreateRow) {
+ if (isCreateNewRow()) {
+
// create a new row in model
addNewRow();
} else {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -44,20 +44,12 @@
private static final Log log =
LogFactory.getLog(MoveToNextEditableRowAction.class);
- public static <M extends AbstractTuttiTableModel> MoveToNextEditableRowAction<M> newAction(M model, JTable table, boolean canCreateRow) {
- return new MoveToNextEditableRowAction<M>(model, table, canCreateRow);
+ public static <M extends AbstractTuttiTableModel> MoveToNextEditableRowAction<M> newAction(M model, JTable table) {
+ return new MoveToNextEditableRowAction<M>(model, table);
}
- /**
- * Can create new row if reach the end of editable cells ?
- *
- * @since 0.3
- */
- private final boolean canCreateRow;
-
- protected MoveToNextEditableRowAction(M model, JTable table, boolean canCreateRow) {
+ protected MoveToNextEditableRowAction(M model, JTable table) {
super(model, table);
- this.canCreateRow = canCreateRow;
}
@Override
@@ -77,7 +69,8 @@
if (log.isDebugEnabled()) {
log.debug("No next row");
}
- if (canCreateRow) {
+ if (isCreateNewRow()) {
+
// create a new row in model
addNewRow();
} else {
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/TableRowModificationListener.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/TableRowModificationListener.java 2012-12-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/TableRowModificationListener.java 2013-01-01 16:10:44 UTC (rev 135)
@@ -1,90 +0,0 @@
-package fr.ifremer.tutti.ui.swing.util.table;
-
-/*
- * #%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.TuttiBeanMonitor;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.ListSelectionModel;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import java.io.Serializable;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public abstract class TableRowModificationListener<R extends Serializable> implements ListSelectionListener {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(TableRowModificationListener.class);
-
- private final AbstractTuttiTableModel<R> tableModel;
-
- private final TuttiBeanMonitor<R> beanMonitor;
-
- protected abstract void saveSelectedRow();
-
- public TableRowModificationListener(AbstractTuttiTableModel<R> tableModel,
- TuttiBeanMonitor<R> beanMonitor) {
- this.tableModel = tableModel;
- this.beanMonitor = beanMonitor;
- }
-
- @Override
- public void valueChanged(ListSelectionEvent e) {
- if (!e.getValueIsAdjusting()) {
- ListSelectionModel source = (ListSelectionModel) e.getSource();
- int selectedRow = source.getLeadSelectionIndex();
-
- // save selected entry if required
- saveSelectedRow();
-
- R entry;
-
- if (source.isSelectionEmpty()) {
-
- // no selection
- entry = null;
- if (log.isInfoEnabled()) {
- log.info("Selection is now empty.");
- }
- } else {
- entry = tableModel.getEntry(selectedRow);
-
- if (log.isInfoEnabled()) {
- log.info("New selected row: " + selectedRow);
- }
- }
-
- if (log.isInfoEnabled()) {
- log.info("Will monitor entry: " + entry);
- }
- beanMonitor.setBean(entry);
- }
- }
-}
Added: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel-error-validation.xml (rev 0)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel-error-validation.xml 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,50 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 - 2013 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%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//Apache Struts//XWork Validator 1.0.3//EN"
+ "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
+<validators>
+
+ <field name="lengthStepCaracteristic">
+
+ <field-validator type="required" short-circuit="true">
+ <message>
+ tutti.validator.error.speciesFrequency.lengthStepCaracteristic.required
+ </message>
+ </field-validator>
+
+ </field>
+
+ <field name="rows">
+
+ <field-validator type="fieldexpression" short-circuit="true">
+ <param name="expression">
+ <![CDATA[ oneRowValid ]]></param>
+ <message>
+ tutti.validator.error.speciesFrequency.oneRowRequired
+ </message>
+ </field-validator>
+
+ </field>
+</validators>
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIModel-error-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel-error-validation.xml (rev 0)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel-error-validation.xml 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,51 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 - 2013 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%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//Apache Struts//XWork Validator 1.0.3//EN"
+ "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
+<validators>
+
+ <field name="species">
+ <field-validator type="required" short-circuit="true">
+ <message>tutti.validator.error.createSpeciesBatch.species.required
+ </message>
+ </field-validator>
+ </field>
+
+ <field name="batchWeight">
+
+ <field-validator type="required" short-circuit="true">
+ <message>tutti.validator.error.createSpeciesBatch.batchWeight.required
+ </message>
+ </field-validator>
+
+ <field-validator type="fieldexpression" short-circuit="true">
+ <param name="expression"><![CDATA[ batchWeight >0 ]]></param>
+ <message>
+ tutti.validator.error.createSpeciesBatch.batchWeight.invalidValue
+ </message>
+ </field-validator>
+
+ </field>
+</validators>
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/CreateSpeciesBatchUIModel-error-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-error-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-error-validation.xml (rev 0)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-error-validation.xml 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,68 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 - 2013 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%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//Apache Struts//XWork Validator 1.0.3//EN"
+ "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
+<validators>
+
+ <field name="selectedCategory">
+ <field-validator type="required" short-circuit="true">
+ <message>
+ tutti.validator.error.splitSpeciesBatch.selectedCategory.required
+ </message>
+ </field-validator>
+ </field>
+
+ <field name="sampleWeight">
+
+ <field-validator type="required" short-circuit="true">
+ <message>tutti.validator.error.splitSpeciesBatch.sampleWeight.required
+ </message>
+ </field-validator>
+
+ <field-validator type="fieldexpression" short-circuit="true">
+ <param name="expression"><![CDATA[ sampleWeight > 0 ]]></param>
+ <message>
+ tutti.validator.error.splitSpeciesBatch.sampleWeight.invalidValue
+ </message>
+ </field-validator>
+
+ <field-validator type="fieldexpression" short-circuit="true">
+ <param name="expression">
+ <![CDATA[ sampleWeight <= batchWeight]]></param>
+ <message>
+ tutti.validator.error.splitSpeciesBatch.sampleWeight.sampleBatchGreaterThanBatchWeight
+ </message>
+ </field-validator>
+
+ <field-validator type="fieldexpression" short-circuit="true">
+ <param name="expression">
+ <![CDATA[ ( sample || batchWeight == sampleWeight ) ]]></param>
+ <message>
+ tutti.validator.error.splitSpeciesBatch.sampleWeight.mismatchBatchWeight
+ </message>
+ </field-validator>
+
+ </field>
+</validators>
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-error-validation.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-warning-validation.xml
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-warning-validation.xml (rev 0)
+++ trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-warning-validation.xml 2013-01-01 16:10:44 UTC (rev 135)
@@ -0,0 +1,40 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 - 2013 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%
+ -->
+<!DOCTYPE validators PUBLIC
+ "-//Apache Struts//XWork Validator 1.0.3//EN"
+ "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
+<validators>
+
+ <field name="sample">
+
+ <field-validator type="fieldexpression" short-circuit="true">
+ <param name="expression">
+ <![CDATA[ !sample ]]></param>
+ <message>
+ tutti.validator.warning.splitSpeciesBatch.sampleBatch
+ </message>
+ </field-validator>
+
+ </field>
+</validators>
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/resources/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIModel-warning-validation.xml
___________________________________________________________________
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-31 18:59:33 UTC (rev 134)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-01-01 16:10:44 UTC (rev 135)
@@ -24,14 +24,14 @@
tutti.action.reload.application=Recharger l'application
tutti.action.reload.home=Reload home screen
tutti.action.reload.ui=Recharger l'interface graphique
-tutti.action.removeSubBatch=Supprimer les lots
+tutti.action.removeSpeciesSubBatch=Supprimer les lots
tutti.action.reset.fishingOperationValidState=Réinitialiser
tutti.action.save=Enregistrer
tutti.action.selectCampaign=Campagne
tutti.action.selectCampaign.tip=Sélectionner la campagne à utiliser
tutti.action.site=Site
tutti.action.site.tip=Accéder au site du projet Tutti
-tutti.action.splitBatch=Catégoriser un lot
+tutti.action.splitSpeciesBatch=Catégoriser un lot
tutti.application.config=Configuration de l'application Tutti
tutti.application.name=Tutti
tutti.config.category.applications=Application
@@ -71,6 +71,8 @@
tutti.label.catches.speciesTotalUnsortedWeight=Poids total hors vrac
tutti.label.catches.speciesTotalWeight=Poids total
tutti.label.comment=Commentaire
+tutti.label.createSpeciesBatch.batchWeight=Poids du lot
+tutti.label.createSpeciesBatch.species=Espèce du lot
tutti.label.cruise=Campagne
tutti.label.cruise.beginDate=Date de début
tutti.label.cruise.country=Pays
@@ -150,7 +152,7 @@
tutti.legend.catch.total=Capture
tutti.legend.filterSpeciesBatchMode=Filtrer les lots
tutti.legend.frequencyConfiguration=Configuration
-tutti.legend.sampleCategoryConfiguration=Configuration
+tutti.legend.splitSpeciesBatchConfiguration=Configuration
tutti.menu.actions=Actions
tutti.menu.actions.tip=Actions
tutti.menu.file=Fichier
@@ -255,6 +257,9 @@
tutti.to.be.done=< A FAIRE >
tutti.tooltip.attachment.none=Pas de pièce-jointes
tutti.tooltip.comment.none=Pas de commentaire
+tutti.validator.error.createSpeciesBatch.batchWeight.invalidValue=Le poids du lot doit être strictement positif
+tutti.validator.error.createSpeciesBatch.batchWeight.required=Le poids du lot est obligatoire
+tutti.validator.error.createSpeciesBatch.species.required=L'espèce est obligatoire
tutti.validator.error.cruise.beginDate.required=La date de début est obligatoire
tutti.validator.error.cruise.country.required=Le pays est obligatoire
tutti.validator.error.cruise.endDate.required=La date de fin est obligatoire
@@ -271,3 +276,11 @@
tutti.validator.error.program.name.required=Le nom de la série est obligatoire
tutti.validator.error.program.zone.required=La zone de la série est obligatoire
tutti.validator.error.protocol.name.required=Le nom du protocol est obligatoire
+tutti.validator.error.speciesFrequency.lengthStepCaracteristic.required=La classe de taille est obligatoire
+tutti.validator.error.speciesFrequency.oneRowRequired=Au moins une classe de taille doit être observée
+tutti.validator.error.splitSpeciesBatch.sampleWeight.invalidValue=La somme des poids ventilés doit être strictement positive
+tutti.validator.error.splitSpeciesBatch.sampleWeight.mismatchBatchWeight=La somme des poids ventilés doit être égale à celle du lot
+tutti.validator.error.splitSpeciesBatch.sampleWeight.required=Pas de poids ventilé
+tutti.validator.error.splitSpeciesBatch.sampleWeight.sampleBatchGreaterThanBatchWeight=La somme des poids ventilés doit être inférieur ou égale à celle du poids du lot
+tutti.validator.error.splitSpeciesBatch.selectedCategory.required=La catégorie est obligatoire
+tutti.validator.warning.splitSpeciesBatch.sampleBatch=Ce lot est-il vraiment un échantillon du lot parent ?
Copied: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-create.png (from rev 134, trunk/tutti-ui-swing/src/main/resources/icons/action-batch-split.png)
===================================================================
(Binary files differ)
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-create.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-delete.png
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-batch-split.png
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0